xref: /linux/include/linux/usb/typec_retimer.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __USB_TYPEC_RETIMER
4 #define __USB_TYPEC_RETIMER
5 
6 #include <linux/property.h>
7 #include <linux/usb/typec.h>
8 
9 struct device;
10 struct typec_retimer;
11 struct typec_altmode;
12 struct fwnode_handle;
13 
14 struct typec_retimer_state {
15 	struct typec_altmode *alt;
16 	unsigned long mode;
17 	void *data;
18 };
19 
20 typedef int (*typec_retimer_set_fn_t)(struct typec_retimer *retimer,
21 				      struct typec_retimer_state *state);
22 
23 struct typec_retimer_desc {
24 	struct fwnode_handle *fwnode;
25 	typec_retimer_set_fn_t set;
26 	const char *name;
27 	void *drvdata;
28 };
29 
30 struct typec_retimer *fwnode_typec_retimer_get(struct fwnode_handle *fwnode);
31 void typec_retimer_put(struct typec_retimer *retimer);
32 int typec_retimer_set(struct typec_retimer *retimer, struct typec_retimer_state *state);
33 
typec_retimer_get(struct device * dev)34 static inline struct typec_retimer *typec_retimer_get(struct device *dev)
35 {
36 	return fwnode_typec_retimer_get(dev_fwnode(dev));
37 }
38 
39 struct typec_retimer *
40 typec_retimer_register(struct device *parent, const struct typec_retimer_desc *desc);
41 void typec_retimer_unregister(struct typec_retimer *retimer);
42 
43 void *typec_retimer_get_drvdata(struct typec_retimer *retimer);
44 
45 #endif /* __USB_TYPEC_RETIMER */
46