Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Greybus modules |
| 3 | * |
| 4 | * Copyright 2014 Google Inc. |
| 5 | * |
| 6 | * Released under the GPLv2 only. |
| 7 | */ |
| 8 | |
| 9 | #ifndef __MODULE_H |
| 10 | #define __MODULE_H |
| 11 | |
| 12 | /* Increase these values if needed */ |
| 13 | #define MAX_CPORTS_PER_MODULE 10 |
| 14 | #define MAX_STRINGS_PER_MODULE 10 |
| 15 | |
| 16 | struct gb_module { |
| 17 | struct device dev; |
| 18 | |
Alex Elder | 8c12cde | 2014-10-01 21:54:12 -0500 | [diff] [blame^] | 19 | struct list_head interfaces; |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 20 | struct list_head links; /* greybus_host_device->modules */ |
| 21 | u8 module_id; /* Physical location within the Endo */ |
| 22 | |
| 23 | struct greybus_descriptor_module module; |
| 24 | int num_cports; |
| 25 | int num_strings; |
| 26 | u16 cport_ids[MAX_CPORTS_PER_MODULE]; |
| 27 | struct gmod_string *string[MAX_STRINGS_PER_MODULE]; |
| 28 | |
| 29 | struct greybus_host_device *hd; |
| 30 | |
| 31 | struct gb_i2c_device *gb_i2c_dev; |
| 32 | struct gb_gpio_device *gb_gpio_dev; |
| 33 | struct gb_sdio_host *gb_sdio_host; |
| 34 | struct gb_tty *gb_tty; |
| 35 | struct gb_usb_device *gb_usb_dev; |
| 36 | struct gb_battery *gb_battery; |
| 37 | }; |
| 38 | #define to_gb_module(d) container_of(d, struct gb_module, dev) |
| 39 | |
| 40 | static inline void |
| 41 | gb_module_set_drvdata(struct gb_module *gmod, void *data) |
| 42 | { |
| 43 | dev_set_drvdata(&gmod->dev, data); |
| 44 | } |
| 45 | |
| 46 | static inline void *gb_module_get_drvdata(struct gb_module *gmod) |
| 47 | { |
| 48 | return dev_get_drvdata(&gmod->dev); |
| 49 | } |
| 50 | |
| 51 | const struct greybus_module_id *gb_module_match_id(struct gb_module *gmod, |
| 52 | const struct greybus_module_id *id); |
| 53 | |
| 54 | struct gb_module *gb_module_create(struct greybus_host_device *hd, |
| 55 | u8 module_id); |
| 56 | void gb_module_destroy(struct gb_module *module); |
| 57 | |
| 58 | #endif /* __MODULE_H */ |