-greybus-y := core.o gbuf.o
+greybus-y := core.o gbuf.o i2c-gb.o
obj-m += greybus.o
-obj-m += i2c-gb.o
obj-m += sdio-gb.o
obj-m += gpio-gb.o
obj-m += uart-gb.o
}
EXPORT_SYMBOL_GPL(greybus_deregister);
+
+static int new_device(struct greybus_device *gdev,
+ const struct greybus_device_id *id)
+{
+ int retval;
+
+ /* Allocate all of the different "sub device types" for this device */
+ retval = gb_i2c_probe(gdev, id);
+ return 0;
+}
+
+
+int __init gb_init(void)
+{
+ return 0;
+}
+
+void __exit gb_exit(void)
+{
+}
+
+module_init(gb_init);
+module_exit(gb_exit);
+
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org>");
#include <linux/gpio/driver.h>
#include "greybus.h"
-struct gb_gpio {
+struct gb_gpio_device {
struct gpio_chip chip;
struct greybus_device *gdev;
struct gpio_chip *gpio;
static int direction_input(struct gpio_chip *gpio, unsigned nr)
{
-// struct gb_gpio *gb_gpio = container_of(gpio, struct gb_gpio, chip);
+ //struct gb_gpio_device *gb_gpio_dev = container_of(gpio, struct gb_gpio_device, chip);
// FIXME - do something there
return 0;
static int gpio_gb_probe(struct greybus_device *gdev, const struct greybus_device_id *id)
{
- struct gb_gpio *gb_gpio;
+ struct gb_gpio_device *gb_gpio;
struct gpio_chip *gpio;
struct device *dev = &gdev->dev;
int retval;
static void gpio_gb_disconnect(struct greybus_device *gdev)
{
- struct gb_gpio *gb_gpio;
+ struct gb_gpio_device *gb_gpio_dev;
- gb_gpio = greybus_get_drvdata(gdev);
+ gb_gpio_dev = greybus_get_drvdata(gdev);
- gpiochip_remove(&gb_gpio->chip);
+ gpiochip_remove(&gb_gpio_dev->chip);
}
static struct greybus_driver gpio_gb_driver = {
*/
#define GBUF_FREE_BUFFER BIT(0) /* Free the transfer buffer with the gbuf */
+/* For SP1 hardware, we are going to "hardcode" each device to have all logical
+ * blocks in order to be able to address them as one unified "unit". Then
+ * higher up layers will then be able to talk to them as one logical block and
+ * properly know how they are hooked together (i.e. which i2c port is on the
+ * same module as the gpio pins, etc.)
+ *
+ * So, put the "private" data structures here in greybus.h and link to them off
+ * of the "main" greybus_device structure.
+ */
+
+struct gb_i2c_device;
+struct gb_gpio_device;
+struct gb_sdio_host;
+struct gb_tty;
+struct gb_usb_device;
struct greybus_device {
struct device dev;
struct greybus_descriptor descriptor;
int num_cport;
struct cport cport[0];
+
+ struct gb_i2c_device *gb_i2c_dev;
+ struct gb_gpio_device *gb_gpio_dev;
+ struct gb_sdio_host *gb_sdio_host;
+ struct gb_tty *gb_tty;
+ struct gb_usb_device *gb_usb_dev;
};
#define to_greybus_device(d) container_of(d, struct greybus_device, dev)
+/*
+ * Because we are allocating a data structure per "type" in the greybus device,
+ * we have static functions for this, not "dynamic" drivers like we really
+ * should in the end.
+ */
+int gb_i2c_probe(struct greybus_device *gdev, const struct greybus_device_id *id);
+void gb_i2c_disconnect(struct greybus_device *gdev);
+
struct gbuf *greybus_alloc_gbuf(struct greybus_device *gdev,
struct cport *cport,
#include <linux/i2c.h>
#include "greybus.h"
-struct i2c_gb_data {
+struct gb_i2c_device {
struct i2c_adapter *adapter;
struct greybus_device *gdev;
};
unsigned short flags, char read_write, u8 command,
int size, union i2c_smbus_data *data)
{
- struct i2c_gb_data *i2c_gb_data;
+ struct gb_i2c_device *i2c_gb_dev;
struct greybus_device *gdev;
- i2c_gb_data = i2c_get_adapdata(adap);
- gdev = i2c_gb_data->gdev;
+ i2c_gb_dev = i2c_get_adapdata(adap);
+ gdev = i2c_gb_dev->gdev;
// FIXME - do the actual work of sending a i2c message here...
switch (size) {
.functionality = i2c_gb_func,
};
-static int i2c_gb_probe(struct greybus_device *gdev, const struct greybus_device_id *id)
+int gb_i2c_probe(struct greybus_device *gdev,
+ const struct greybus_device_id *id)
{
- struct i2c_gb_data *i2c_gb_data;
+ struct gb_i2c_device *i2c_gb_dev;
struct i2c_adapter *adapter;
int retval;
- i2c_gb_data = kzalloc(sizeof(*i2c_gb_data), GFP_KERNEL);
- if (!i2c_gb_data)
+ i2c_gb_dev = kzalloc(sizeof(*i2c_gb_dev), GFP_KERNEL);
+ if (!i2c_gb_dev)
return -ENOMEM;
adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
if (!adapter) {
- kfree(i2c_gb_data);
+ kfree(i2c_gb_dev);
return -ENOMEM;
}
- i2c_set_adapdata(adapter, i2c_gb_data);
+ i2c_set_adapdata(adapter, i2c_gb_dev);
adapter->owner = THIS_MODULE;
adapter->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
adapter->algo = &smbus_algorithm;
goto error;
}
- i2c_gb_data->gdev = gdev;
- i2c_gb_data->adapter = adapter;
+ i2c_gb_dev->gdev = gdev;
+ i2c_gb_dev->adapter = adapter;
- greybus_set_drvdata(gdev, i2c_gb_data);
+ greybus_set_drvdata(gdev, i2c_gb_dev);
return 0;
error:
kfree(adapter);
- kfree(i2c_gb_data);
+ kfree(i2c_gb_dev);
return retval;
}
-static void i2c_gb_disconnect(struct greybus_device *gdev)
+void gb_i2c_disconnect(struct greybus_device *gdev)
{
- struct i2c_gb_data *i2c_gb_data;
+ struct gb_i2c_device *i2c_gb_dev;
- i2c_gb_data = greybus_get_drvdata(gdev);
- i2c_del_adapter(i2c_gb_data->adapter);
- kfree(i2c_gb_data->adapter);
- kfree(i2c_gb_data);
+ i2c_gb_dev = greybus_get_drvdata(gdev);
+ i2c_del_adapter(i2c_gb_dev->adapter);
+ kfree(i2c_gb_dev->adapter);
+ kfree(i2c_gb_dev);
}
+#if 0
static struct greybus_driver i2c_gb_driver = {
- .probe = i2c_gb_probe,
- .disconnect = i2c_gb_disconnect,
+ .probe = gb_i2c_probe,
+ .disconnect = gb_i2c_disconnect,
.id_table = id_table,
};
module_greybus_driver(i2c_gb_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org>");
+#endif
#include <linux/mmc/host.h>
#include "greybus.h"
-struct sd_gb_host {
+struct gb_sdio_host {
struct mmc_host *mmc;
struct mmc_request *mrq;
// FIXME - some lock?
static int sd_gb_probe(struct greybus_device *gdev, const struct greybus_device_id *id)
{
struct mmc_host *mmc;
- struct sd_gb_host *host;
+ struct gb_sdio_host *host;
- mmc = mmc_alloc_host(sizeof(struct sd_gb_host), &gdev->dev);
+ mmc = mmc_alloc_host(sizeof(struct gb_sdio_host), &gdev->dev);
if (!mmc)
return -ENOMEM;
static void sd_gb_disconnect(struct greybus_device *gdev)
{
struct mmc_host *mmc;
- struct sd_gb_host *host;
+ struct gb_sdio_host *host;
host = greybus_get_drvdata(gdev);
mmc = host->mmc;
unsigned long arg)
{
struct gb_tty *gb_tty = tty->driver_data;
- int retval = -ENOIOCTLCMD;
switch (cmd) {
case TIOCGSERIAL:
- retval = get_serial_info(gb_tty,
- (struct serial_struct __user *)arg);
- break;
+ return get_serial_info(gb_tty,
+ (struct serial_struct __user *)arg);
case TIOCSSERIAL:
- retval = set_serial_info(gb_tty,
- (struct serial_struct __user *)arg);
- break;
+ return set_serial_info(gb_tty,
+ (struct serial_struct __user *)arg);
case TIOCMIWAIT:
- retval = wait_serial_change(gb_tty, arg);
- break;
+ return wait_serial_change(gb_tty, arg);
case TIOCGICOUNT:
- retval = get_serial_usage(gb_tty,
- (struct serial_icounter_struct __user *)arg);
- break;
+ return get_serial_usage(gb_tty,
+ (struct serial_icounter_struct __user *)arg);
}
- return retval;
+ return -ENOIOCTLCMD;
}