greybus: interface: add interface-type attribute
[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 #define GB_INTERFACE_QUIRK_NO_CPORT_FEATURES            BIT(0)
14 #define GB_INTERFACE_QUIRK_NO_INIT_STATUS               BIT(1)
15 #define GB_INTERFACE_QUIRK_NO_ARA_IDS                   BIT(2)
16 #define GB_INTERFACE_QUIRK_FORCED_DISABLE               BIT(3)
17 #define GB_INTERFACE_QUIRK_LEGACY_MODE_SWITCH           BIT(4)
18
19 struct gb_interface {
20         struct device dev;
21         struct gb_control *control;
22
23         struct list_head bundles;
24         struct list_head module_node;
25         struct list_head manifest_descs;
26         u8 interface_id;        /* Physical location within the Endo */
27         u8 device_id;
28         u8 features;            /* Feature flags set in the manifest */
29         u8 type;
30
31         u32 ddbl1_manufacturer_id;
32         u32 ddbl1_product_id;
33         u32 vendor_id;
34         u32 product_id;
35         u64 serial_number;
36
37         struct gb_host_device *hd;
38         struct gb_module *module;
39
40         unsigned long quirks;
41
42         struct mutex mutex;
43
44         bool disconnected;
45
46         bool ejected;
47         bool active;
48         bool enabled;
49         bool mode_switch;
50
51         struct work_struct mode_switch_work;
52         struct completion mode_switch_completion;
53 };
54 #define to_gb_interface(d) container_of(d, struct gb_interface, dev)
55
56 struct gb_interface *gb_interface_create(struct gb_module *module,
57                                          u8 interface_id);
58 int gb_interface_activate(struct gb_interface *intf);
59 void gb_interface_deactivate(struct gb_interface *intf);
60 int gb_interface_enable(struct gb_interface *intf);
61 void gb_interface_disable(struct gb_interface *intf);
62 int gb_interface_timesync_enable(struct gb_interface *intf, u8 count,
63                                  u64 frame_time, u32 strobe_delay, u32 refclk);
64 int gb_interface_timesync_authoritative(struct gb_interface *intf,
65                                         u64 *frame_time);
66 int gb_interface_timesync_disable(struct gb_interface *intf);
67 int gb_interface_add(struct gb_interface *intf);
68 void gb_interface_del(struct gb_interface *intf);
69 void gb_interface_put(struct gb_interface *intf);
70 void gb_interface_mailbox_event(struct gb_interface *intf, u16 result,
71                                                                 u32 mailbox);
72
73 int gb_interface_request_mode_switch(struct gb_interface *intf);
74
75 #endif /* __INTERFACE_H */