blob: 4168a5752808996117f9859b18926facf4f37326 [file] [log] [blame]
Alex Eldere1e9dbd2014-10-01 21:54:11 -05001/*
Greg Kroah-Hartman4ec7b072014-12-11 17:10:56 -05002 * Greybus Interface Block code
Alex Eldere1e9dbd2014-10-01 21:54:11 -05003 *
4 * Copyright 2014 Google Inc.
Alex Eldera46e9672014-12-12 12:08:42 -06005 * Copyright 2014 Linaro Ltd.
Alex Eldere1e9dbd2014-10-01 21:54:11 -05006 *
7 * Released under the GPLv2 only.
8 */
9
Greg Kroah-Hartmana93938a2014-12-19 14:56:30 -080010#ifndef __INTERFACE_H
11#define __INTERFACE_H
Alex Eldere1e9dbd2014-10-01 21:54:11 -050012
Greg Kroah-Hartman4ec7b072014-12-11 17:10:56 -050013/* Greybus "public" definitions" */
Greg Kroah-Hartman4ab9b3c2014-12-19 14:56:31 -080014struct gb_interface {
Alex Eldere1e9dbd2014-10-01 21:54:11 -050015 struct device dev;
Viresh Kumarcdee4f72015-06-22 16:42:26 +053016 struct gb_control *control;
Alex Eldere1e9dbd2014-10-01 21:54:11 -050017
Greg Kroah-Hartmane232b792014-12-19 14:56:29 -080018 struct list_head bundles;
Johan Hovold25376362015-11-03 18:03:23 +010019 struct list_head links; /* gb_host_device->interfaces */
Greg Kroah-Hartman86cad662014-12-23 15:16:50 -080020 struct list_head manifest_descs;
Greg Kroah-Hartmandf671552014-12-21 14:10:26 -080021 u8 interface_id; /* Physical location within the Endo */
Viresh Kumarc3add782015-07-01 12:13:58 +053022 u8 device_id; /* Device id allocated for the interface block by the SVC */
Alex Eldere1e9dbd2014-10-01 21:54:11 -050023
Viresh Kumara93db2d2015-04-01 20:32:02 +053024 /* Information taken from the manifest descriptor */
Alex Elderb09c94a2014-10-01 21:54:16 -050025 char *vendor_string;
26 char *product_string;
27
Viresh Kumar3944a452015-08-12 09:19:31 +053028 /* Information taken from the hotplug event */
Viresh Kumarb32a5c52015-12-22 22:04:33 +053029 u32 ddbl1_manufacturer_id;
30 u32 ddbl1_product_id;
Johan Hovold9f592632015-11-25 15:58:56 +010031 u32 vendor_id;
32 u32 product_id;
Viresh Kumar57c6bcc2015-12-28 11:59:00 +053033 u64 serial_number;
Viresh Kumar3944a452015-08-12 09:19:31 +053034
Viresh Kumard39bf702015-12-28 11:59:01 +053035 u16 version_major;
36 u16 version_minor;
37
Johan Hovold25376362015-11-03 18:03:23 +010038 struct gb_host_device *hd;
Viresh Kumar1575ef12015-10-07 15:40:24 -040039
40 /* The interface needs to boot over unipro */
41 bool boot_over_unipro;
Johan Hovold141af4f2015-12-15 15:28:57 +010042 bool disconnected;
Alex Eldere1e9dbd2014-10-01 21:54:11 -050043};
Greg Kroah-Hartman4ab9b3c2014-12-19 14:56:31 -080044#define to_gb_interface(d) container_of(d, struct gb_interface, dev)
Alex Eldere1e9dbd2014-10-01 21:54:11 -050045
Greg Kroah-Hartman4ab9b3c2014-12-19 14:56:31 -080046static inline void gb_interface_set_drvdata(struct gb_interface *intf,
47 void *data)
Alex Eldere1e9dbd2014-10-01 21:54:11 -050048{
Greg Kroah-Hartman4ab9b3c2014-12-19 14:56:31 -080049 dev_set_drvdata(&intf->dev, data);
Alex Eldere1e9dbd2014-10-01 21:54:11 -050050}
51
Viresh Kumar9ee2b612015-03-19 17:02:48 +053052static inline void *gb_interface_get_drvdata(struct gb_interface *intf)
Alex Eldere1e9dbd2014-10-01 21:54:11 -050053{
Greg Kroah-Hartman4ab9b3c2014-12-19 14:56:31 -080054 return dev_get_drvdata(&intf->dev);
Alex Eldere1e9dbd2014-10-01 21:54:11 -050055}
56
Greg Kroah-Hartman4ec7b072014-12-11 17:10:56 -050057/* Greybus "private" definitions */
58
Johan Hovold25376362015-11-03 18:03:23 +010059struct gb_interface *gb_interface_find(struct gb_host_device *hd,
Viresh Kumarc9d9d0d2015-04-01 20:31:58 +053060 u8 interface_id);
Alex Eldere1e9dbd2014-10-01 21:54:11 -050061
Johan Hovold25376362015-11-03 18:03:23 +010062struct gb_interface *gb_interface_create(struct gb_host_device *hd,
Viresh Kumar6c68da22015-06-22 16:42:27 +053063 u8 interface_id);
Alex Elderbfb287a2015-08-03 12:57:09 -050064void gb_interface_destroy(struct gb_interface *intf);
Viresh Kumar6c68da22015-06-22 16:42:27 +053065int gb_interface_init(struct gb_interface *intf, u8 device_id);
Viresh Kumar80d1ede2015-09-23 16:48:10 -070066void gb_interface_remove(struct gb_interface *intf);
Johan Hovold25376362015-11-03 18:03:23 +010067void gb_interfaces_remove(struct gb_host_device *hd);
Greg Kroah-Hartman13e6aac2014-12-19 14:56:35 -080068
Greg Kroah-Hartmana93938a2014-12-19 14:56:30 -080069#endif /* __INTERFACE_H */