USB: serial: option: add Quectel BG95 modem
[linux-2.6-microblaze.git] / include / linux / usb / typec_mux.h
1 // SPDX-License-Identifier: GPL-2.0
2
3 #ifndef __USB_TYPEC_MUX
4 #define __USB_TYPEC_MUX
5
6 #include <linux/property.h>
7 #include <linux/usb/typec.h>
8
9 struct device;
10 struct typec_mux;
11 struct typec_switch;
12 struct typec_altmode;
13 struct fwnode_handle;
14
15 typedef int (*typec_switch_set_fn_t)(struct typec_switch *sw,
16                                      enum typec_orientation orientation);
17
18 struct typec_switch_desc {
19         struct fwnode_handle *fwnode;
20         typec_switch_set_fn_t set;
21         const char *name;
22         void *drvdata;
23 };
24
25 struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode);
26 void typec_switch_put(struct typec_switch *sw);
27 int typec_switch_set(struct typec_switch *sw,
28                      enum typec_orientation orientation);
29
30 static inline struct typec_switch *typec_switch_get(struct device *dev)
31 {
32         return fwnode_typec_switch_get(dev_fwnode(dev));
33 }
34
35 struct typec_switch *
36 typec_switch_register(struct device *parent,
37                       const struct typec_switch_desc *desc);
38 void typec_switch_unregister(struct typec_switch *sw);
39
40 void typec_switch_set_drvdata(struct typec_switch *sw, void *data);
41 void *typec_switch_get_drvdata(struct typec_switch *sw);
42
43 struct typec_mux_state {
44         struct typec_altmode *alt;
45         unsigned long mode;
46         void *data;
47 };
48
49 typedef int (*typec_mux_set_fn_t)(struct typec_mux *mux,
50                                   struct typec_mux_state *state);
51
52 struct typec_mux_desc {
53         struct fwnode_handle *fwnode;
54         typec_mux_set_fn_t set;
55         const char *name;
56         void *drvdata;
57 };
58
59 struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode,
60                                        const struct typec_altmode_desc *desc);
61 void typec_mux_put(struct typec_mux *mux);
62 int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state);
63
64 static inline struct typec_mux *
65 typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc)
66 {
67         return fwnode_typec_mux_get(dev_fwnode(dev), desc);
68 }
69
70 struct typec_mux *
71 typec_mux_register(struct device *parent, const struct typec_mux_desc *desc);
72 void typec_mux_unregister(struct typec_mux *mux);
73
74 void typec_mux_set_drvdata(struct typec_mux *mux, void *data);
75 void *typec_mux_get_drvdata(struct typec_mux *mux);
76
77 #endif /* __USB_TYPEC_MUX */