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