15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21c9af653SMichael Grzeschik /*
31c9af653SMichael Grzeschik * OF helpers for usb devices.
41c9af653SMichael Grzeschik */
51c9af653SMichael Grzeschik
61c9af653SMichael Grzeschik #ifndef __LINUX_USB_OF_H
71c9af653SMichael Grzeschik #define __LINUX_USB_OF_H
81c9af653SMichael Grzeschik
9*82e82130SStephen Boyd #include <linux/usb.h>
101494a1f6SFelipe Balbi #include <linux/usb/ch9.h>
111c9af653SMichael Grzeschik #include <linux/usb/otg.h>
121c9af653SMichael Grzeschik #include <linux/usb/phy.h>
131c9af653SMichael Grzeschik
141a7e3948SJohan Hovold struct usb_device;
151a7e3948SJohan Hovold
16848d5b91SPeter Chen #if IS_ENABLED(CONFIG_OF)
17ce15ed4cSHans de Goede enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0);
1805f8b35aSPeter Chen bool of_usb_host_tpl_support(struct device_node *np);
19929412d9SLi Jun int of_usb_update_otg_caps(struct device_node *np,
20929412d9SLi Jun struct usb_otg_caps *otg_caps);
21*82e82130SStephen Boyd enum usb_port_connect_type usb_of_get_connect_type(struct usb_device *hub, int port1);
227739376eSJohan Hovold struct device_node *usb_of_get_device_node(struct usb_device *hub, int port1);
231a7e3948SJohan Hovold bool usb_of_has_combined_node(struct usb_device *udev);
241a7e3948SJohan Hovold struct device_node *usb_of_get_interface_node(struct usb_device *udev,
251a7e3948SJohan Hovold u8 config, u8 ifnum);
265095cb89SYoshihiro Shimoda struct device *usb_of_get_companion_dev(struct device *dev);
271c9af653SMichael Grzeschik #else
28be99c843SFelipe Balbi static inline enum usb_dr_mode
of_usb_get_dr_mode_by_phy(struct device_node * np,int arg0)29ce15ed4cSHans de Goede of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0)
3098bfb394SBin Liu {
3198bfb394SBin Liu return USB_DR_MODE_UNKNOWN;
3298bfb394SBin Liu }
of_usb_host_tpl_support(struct device_node * np)3305f8b35aSPeter Chen static inline bool of_usb_host_tpl_support(struct device_node *np)
3405f8b35aSPeter Chen {
3505f8b35aSPeter Chen return false;
3605f8b35aSPeter Chen }
of_usb_update_otg_caps(struct device_node * np,struct usb_otg_caps * otg_caps)37929412d9SLi Jun static inline int of_usb_update_otg_caps(struct device_node *np,
38929412d9SLi Jun struct usb_otg_caps *otg_caps)
39929412d9SLi Jun {
40929412d9SLi Jun return 0;
41929412d9SLi Jun }
42*82e82130SStephen Boyd static inline enum usb_port_connect_type
usb_of_get_connect_type(const struct usb_device * hub,int port1)43*82e82130SStephen Boyd usb_of_get_connect_type(const struct usb_device *hub, int port1)
44*82e82130SStephen Boyd {
45*82e82130SStephen Boyd return USB_PORT_CONNECT_TYPE_UNKNOWN;
46*82e82130SStephen Boyd }
477739376eSJohan Hovold static inline struct device_node *
usb_of_get_device_node(struct usb_device * hub,int port1)487739376eSJohan Hovold usb_of_get_device_node(struct usb_device *hub, int port1)
4969bec725SPeter Chen {
5069bec725SPeter Chen return NULL;
5169bec725SPeter Chen }
usb_of_has_combined_node(struct usb_device * udev)521a7e3948SJohan Hovold static inline bool usb_of_has_combined_node(struct usb_device *udev)
531a7e3948SJohan Hovold {
541a7e3948SJohan Hovold return false;
551a7e3948SJohan Hovold }
561a7e3948SJohan Hovold static inline struct device_node *
usb_of_get_interface_node(struct usb_device * udev,u8 config,u8 ifnum)571a7e3948SJohan Hovold usb_of_get_interface_node(struct usb_device *udev, u8 config, u8 ifnum)
581a7e3948SJohan Hovold {
591a7e3948SJohan Hovold return NULL;
601a7e3948SJohan Hovold }
usb_of_get_companion_dev(struct device * dev)615095cb89SYoshihiro Shimoda static inline struct device *usb_of_get_companion_dev(struct device *dev)
625095cb89SYoshihiro Shimoda {
635095cb89SYoshihiro Shimoda return NULL;
645095cb89SYoshihiro Shimoda }
65848d5b91SPeter Chen #endif
66848d5b91SPeter Chen
679cf7b244SFelipe Balbi #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)
68848d5b91SPeter Chen enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np);
69848d5b91SPeter Chen #else
of_usb_get_phy_mode(struct device_node * np)701c9af653SMichael Grzeschik static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
711c9af653SMichael Grzeschik {
721c9af653SMichael Grzeschik return USBPHY_INTERFACE_MODE_UNKNOWN;
731c9af653SMichael Grzeschik }
741c9af653SMichael Grzeschik
751c9af653SMichael Grzeschik #endif
761c9af653SMichael Grzeschik
771c9af653SMichael Grzeschik #endif /* __LINUX_USB_OF_H */
78