greybus: APBridge: move APBridge request protocol to a common .h file
[cascardo/linux.git] / drivers / staging / greybus / interface.h
1 /*
2  * Greybus Interface Block code
3  *
4  * Copyright 2014 Google Inc.
5  * Copyright 2014 Linaro Ltd.
6  *
7  * Released under the GPLv2 only.
8  */
9
10 #ifndef __INTERFACE_H
11 #define __INTERFACE_H
12
13 /* Greybus "public" definitions" */
14 struct gb_interface {
15         struct device dev;
16         struct gb_control *control;
17
18         struct list_head bundles;
19         struct list_head links; /* gb_host_device->interfaces */
20         struct list_head manifest_descs;
21         u8 interface_id;        /* Physical location within the Endo */
22         u8 device_id;           /* Device id allocated for the interface block by the SVC */
23
24         /* Information taken from the manifest descriptor */
25         char *vendor_string;
26         char *product_string;
27
28         /* Information taken from the hotplug event */
29         u32 ddbl1_manufacturer_id;
30         u32 ddbl1_product_id;
31         u32 vendor_id;
32         u32 product_id;
33         u64 serial_number;
34
35         u16 version_major;
36         u16 version_minor;
37
38         struct gb_host_device *hd;
39
40         /* The interface needs to boot over unipro */
41         bool boot_over_unipro;
42         bool disconnected;
43 };
44 #define to_gb_interface(d) container_of(d, struct gb_interface, dev)
45
46 static inline void gb_interface_set_drvdata(struct gb_interface *intf,
47                                             void *data)
48 {
49         dev_set_drvdata(&intf->dev, data);
50 }
51
52 static inline void *gb_interface_get_drvdata(struct gb_interface *intf)
53 {
54         return dev_get_drvdata(&intf->dev);
55 }
56
57 /* Greybus "private" definitions */
58
59 struct gb_interface *gb_interface_find(struct gb_host_device *hd,
60                                        u8 interface_id);
61
62 struct gb_interface *gb_interface_create(struct gb_host_device *hd,
63                                          u8 interface_id);
64 void gb_interface_destroy(struct gb_interface *intf);
65 int gb_interface_init(struct gb_interface *intf, u8 device_id);
66 void gb_interface_remove(struct gb_interface *intf);
67 void gb_interfaces_remove(struct gb_host_device *hd);
68
69 #endif /* __INTERFACE_H */