Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 1 | /* |
Greg Kroah-Hartman | 4ec7b07 | 2014-12-11 17:10:56 -0500 | [diff] [blame] | 2 | * Greybus Interface Block code |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 3 | * |
| 4 | * Copyright 2014 Google Inc. |
Alex Elder | a46e967 | 2014-12-12 12:08:42 -0600 | [diff] [blame] | 5 | * Copyright 2014 Linaro Ltd. |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 6 | * |
| 7 | * Released under the GPLv2 only. |
| 8 | */ |
| 9 | |
Greg Kroah-Hartman | a93938a | 2014-12-19 14:56:30 -0800 | [diff] [blame] | 10 | #ifndef __INTERFACE_H |
| 11 | #define __INTERFACE_H |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 12 | |
Greg Kroah-Hartman | 4ec7b07 | 2014-12-11 17:10:56 -0500 | [diff] [blame] | 13 | /* Greybus "public" definitions" */ |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 14 | struct gb_interface { |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 15 | struct device dev; |
Viresh Kumar | cdee4f7 | 2015-06-22 16:42:26 +0530 | [diff] [blame] | 16 | struct gb_control *control; |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 17 | |
Greg Kroah-Hartman | e232b79 | 2014-12-19 14:56:29 -0800 | [diff] [blame] | 18 | struct list_head bundles; |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 19 | struct list_head links; /* gb_host_device->interfaces */ |
Greg Kroah-Hartman | 86cad66 | 2014-12-23 15:16:50 -0800 | [diff] [blame] | 20 | struct list_head manifest_descs; |
Greg Kroah-Hartman | df67155 | 2014-12-21 14:10:26 -0800 | [diff] [blame] | 21 | u8 interface_id; /* Physical location within the Endo */ |
Viresh Kumar | c3add78 | 2015-07-01 12:13:58 +0530 | [diff] [blame] | 22 | u8 device_id; /* Device id allocated for the interface block by the SVC */ |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 23 | |
Viresh Kumar | a93db2d | 2015-04-01 20:32:02 +0530 | [diff] [blame] | 24 | /* Information taken from the manifest descriptor */ |
Alex Elder | b09c94a | 2014-10-01 21:54:16 -0500 | [diff] [blame] | 25 | char *vendor_string; |
| 26 | char *product_string; |
| 27 | |
Viresh Kumar | 3944a45 | 2015-08-12 09:19:31 +0530 | [diff] [blame] | 28 | /* Information taken from the hotplug event */ |
Viresh Kumar | b32a5c5 | 2015-12-22 22:04:33 +0530 | [diff] [blame] | 29 | u32 ddbl1_manufacturer_id; |
| 30 | u32 ddbl1_product_id; |
Johan Hovold | 9f59263 | 2015-11-25 15:58:56 +0100 | [diff] [blame] | 31 | u32 vendor_id; |
| 32 | u32 product_id; |
Viresh Kumar | 57c6bcc | 2015-12-28 11:59:00 +0530 | [diff] [blame] | 33 | u64 serial_number; |
Viresh Kumar | 3944a45 | 2015-08-12 09:19:31 +0530 | [diff] [blame] | 34 | |
Viresh Kumar | d39bf70 | 2015-12-28 11:59:01 +0530 | [diff] [blame] | 35 | u16 version_major; |
| 36 | u16 version_minor; |
| 37 | |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 38 | struct gb_host_device *hd; |
Viresh Kumar | 1575ef1 | 2015-10-07 15:40:24 -0400 | [diff] [blame] | 39 | |
| 40 | /* The interface needs to boot over unipro */ |
| 41 | bool boot_over_unipro; |
Johan Hovold | 141af4f | 2015-12-15 15:28:57 +0100 | [diff] [blame] | 42 | bool disconnected; |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 43 | }; |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 44 | #define to_gb_interface(d) container_of(d, struct gb_interface, dev) |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 45 | |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 46 | static inline void gb_interface_set_drvdata(struct gb_interface *intf, |
| 47 | void *data) |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 48 | { |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 49 | dev_set_drvdata(&intf->dev, data); |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 50 | } |
| 51 | |
Viresh Kumar | 9ee2b61 | 2015-03-19 17:02:48 +0530 | [diff] [blame] | 52 | static inline void *gb_interface_get_drvdata(struct gb_interface *intf) |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 53 | { |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 54 | return dev_get_drvdata(&intf->dev); |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 55 | } |
| 56 | |
Greg Kroah-Hartman | 4ec7b07 | 2014-12-11 17:10:56 -0500 | [diff] [blame] | 57 | /* Greybus "private" definitions */ |
| 58 | |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 59 | struct gb_interface *gb_interface_find(struct gb_host_device *hd, |
Viresh Kumar | c9d9d0d | 2015-04-01 20:31:58 +0530 | [diff] [blame] | 60 | u8 interface_id); |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 61 | |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 62 | struct gb_interface *gb_interface_create(struct gb_host_device *hd, |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 63 | u8 interface_id); |
Alex Elder | bfb287a | 2015-08-03 12:57:09 -0500 | [diff] [blame] | 64 | void gb_interface_destroy(struct gb_interface *intf); |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 65 | int gb_interface_init(struct gb_interface *intf, u8 device_id); |
Viresh Kumar | 80d1ede | 2015-09-23 16:48:10 -0700 | [diff] [blame] | 66 | void gb_interface_remove(struct gb_interface *intf); |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 67 | void gb_interfaces_remove(struct gb_host_device *hd); |
Greg Kroah-Hartman | 13e6aac | 2014-12-19 14:56:35 -0800 | [diff] [blame] | 68 | |
Greg Kroah-Hartman | a93938a | 2014-12-19 14:56:30 -0800 | [diff] [blame] | 69 | #endif /* __INTERFACE_H */ |