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 | |
Alex Elder | b09c94a | 2014-10-01 21:54:16 -0500 | [diff] [blame] | 23 | /* Information taken from the manifest module descriptor */ |
| 24 | u16 vendor; |
| 25 | u16 product; |
| 26 | u16 version; |
Alex Elder | b09c94a | 2014-10-01 21:54:16 -0500 | [diff] [blame] | 27 | char *vendor_string; |
| 28 | char *product_string; |
Alex Elder | 63cc932 | 2014-10-02 12:30:02 -0500 | [diff] [blame] | 29 | u64 unique_id; |
Alex Elder | b09c94a | 2014-10-01 21:54:16 -0500 | [diff] [blame] | 30 | |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 31 | struct greybus_host_device *hd; |
| 32 | |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 33 | struct gb_tty *gb_tty; |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 34 | }; |
| 35 | #define to_gb_module(d) container_of(d, struct gb_module, dev) |
| 36 | |
| 37 | static inline void |
| 38 | gb_module_set_drvdata(struct gb_module *gmod, void *data) |
| 39 | { |
| 40 | dev_set_drvdata(&gmod->dev, data); |
| 41 | } |
| 42 | |
| 43 | static inline void *gb_module_get_drvdata(struct gb_module *gmod) |
| 44 | { |
| 45 | return dev_get_drvdata(&gmod->dev); |
| 46 | } |
| 47 | |
| 48 | const struct greybus_module_id *gb_module_match_id(struct gb_module *gmod, |
| 49 | const struct greybus_module_id *id); |
| 50 | |
| 51 | struct gb_module *gb_module_create(struct greybus_host_device *hd, |
| 52 | u8 module_id); |
| 53 | void gb_module_destroy(struct gb_module *module); |
| 54 | |
Matt Porter | 6271b5b | 2014-10-21 22:43:29 -0400 | [diff] [blame^] | 55 | struct gb_module *gb_module_find(struct greybus_host_device *hd, |
| 56 | u8 module_id); |
| 57 | |
Alex Elder | 574341c | 2014-10-16 06:35:35 -0500 | [diff] [blame] | 58 | void gb_module_interfaces_init(struct gb_module *gmod); |
| 59 | |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 60 | #endif /* __MODULE_H */ |