GNU Linux-libre 4.19.286-gnu1
[releases.git] / drivers / staging / greybus / interface.h
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Greybus Interface Block code
4  *
5  * Copyright 2014 Google Inc.
6  * Copyright 2014 Linaro Ltd.
7  */
8
9 #ifndef __INTERFACE_H
10 #define __INTERFACE_H
11
12 enum gb_interface_type {
13         GB_INTERFACE_TYPE_INVALID = 0,
14         GB_INTERFACE_TYPE_UNKNOWN,
15         GB_INTERFACE_TYPE_DUMMY,
16         GB_INTERFACE_TYPE_UNIPRO,
17         GB_INTERFACE_TYPE_GREYBUS,
18 };
19
20 #define GB_INTERFACE_QUIRK_NO_CPORT_FEATURES            BIT(0)
21 #define GB_INTERFACE_QUIRK_NO_INIT_STATUS               BIT(1)
22 #define GB_INTERFACE_QUIRK_NO_GMP_IDS                   BIT(2)
23 #define GB_INTERFACE_QUIRK_FORCED_DISABLE               BIT(3)
24 #define GB_INTERFACE_QUIRK_LEGACY_MODE_SWITCH           BIT(4)
25 #define GB_INTERFACE_QUIRK_NO_BUNDLE_ACTIVATE           BIT(5)
26 #define GB_INTERFACE_QUIRK_NO_PM                        BIT(6)
27
28 struct gb_interface {
29         struct device dev;
30         struct gb_control *control;
31
32         struct list_head bundles;
33         struct list_head module_node;
34         struct list_head manifest_descs;
35         u8 interface_id;        /* Physical location within the Endo */
36         u8 device_id;
37         u8 features;            /* Feature flags set in the manifest */
38
39         enum gb_interface_type type;
40
41         u32 ddbl1_manufacturer_id;
42         u32 ddbl1_product_id;
43         u32 vendor_id;
44         u32 product_id;
45         u64 serial_number;
46
47         struct gb_host_device *hd;
48         struct gb_module *module;
49
50         unsigned long quirks;
51
52         struct mutex mutex;
53
54         bool disconnected;
55
56         bool ejected;
57         bool removed;
58         bool active;
59         bool enabled;
60         bool mode_switch;
61         bool dme_read;
62
63         struct work_struct mode_switch_work;
64         struct completion mode_switch_completion;
65 };
66 #define to_gb_interface(d) container_of(d, struct gb_interface, dev)
67
68 struct gb_interface *gb_interface_create(struct gb_module *module,
69                                          u8 interface_id);
70 int gb_interface_activate(struct gb_interface *intf);
71 void gb_interface_deactivate(struct gb_interface *intf);
72 int gb_interface_enable(struct gb_interface *intf);
73 void gb_interface_disable(struct gb_interface *intf);
74 int gb_interface_add(struct gb_interface *intf);
75 void gb_interface_del(struct gb_interface *intf);
76 void gb_interface_put(struct gb_interface *intf);
77 void gb_interface_mailbox_event(struct gb_interface *intf, u16 result,
78                                                                 u32 mailbox);
79
80 int gb_interface_request_mode_switch(struct gb_interface *intf);
81
82 #endif /* __INTERFACE_H */