blob: 0294ccac4f1d62842a2727883946991cd0a3a46f [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: GPL-2.0
Michael Grzeschik1c9af652013-06-13 17:59:55 +03002/*
3 * OF helpers for usb devices.
4 *
5 * This file is released under the GPLv2
6 */
7
8#ifndef __LINUX_USB_OF_H
9#define __LINUX_USB_OF_H
10
Felipe Balbi1494a1f2013-06-30 13:56:45 +030011#include <linux/usb/ch9.h>
Michael Grzeschik1c9af652013-06-13 17:59:55 +030012#include <linux/usb/otg.h>
13#include <linux/usb/phy.h>
14
Johan Hovold1a7e3942017-11-09 18:07:21 +010015struct usb_device;
16
Peter Chen848d5b92013-06-24 09:25:59 +080017#if IS_ENABLED(CONFIG_OF)
Hans de Goedece15ed42016-06-10 11:46:25 +020018enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0);
Peter Chen05f8b352014-08-19 09:51:55 +080019bool of_usb_host_tpl_support(struct device_node *np);
Li Jun929412d2015-07-09 15:18:44 +080020int of_usb_update_otg_caps(struct device_node *np,
21 struct usb_otg_caps *otg_caps);
Peter Chen69bec722016-02-19 17:26:15 +080022struct device_node *usb_of_get_child_node(struct device_node *parent,
23 int portnum);
Johan Hovold1a7e3942017-11-09 18:07:21 +010024bool usb_of_has_combined_node(struct usb_device *udev);
25struct device_node *usb_of_get_interface_node(struct usb_device *udev,
26 u8 config, u8 ifnum);
Yoshihiro Shimoda5095cb82017-02-21 19:59:47 +090027struct device *usb_of_get_companion_dev(struct device *dev);
Michael Grzeschik1c9af652013-06-13 17:59:55 +030028#else
Felipe Balbibe99c842015-12-17 09:55:41 -060029static inline enum usb_dr_mode
Hans de Goedece15ed42016-06-10 11:46:25 +020030of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0)
Bin Liu98bfb392015-11-03 11:51:15 -060031{
32 return USB_DR_MODE_UNKNOWN;
33}
Peter Chen05f8b352014-08-19 09:51:55 +080034static inline bool of_usb_host_tpl_support(struct device_node *np)
35{
36 return false;
37}
Li Jun929412d2015-07-09 15:18:44 +080038static inline int of_usb_update_otg_caps(struct device_node *np,
39 struct usb_otg_caps *otg_caps)
40{
41 return 0;
42}
Peter Chen69bec722016-02-19 17:26:15 +080043static inline struct device_node *usb_of_get_child_node
44 (struct device_node *parent, int portnum)
45{
46 return NULL;
47}
Johan Hovold1a7e3942017-11-09 18:07:21 +010048static inline bool usb_of_has_combined_node(struct usb_device *udev)
49{
50 return false;
51}
52static inline struct device_node *
53usb_of_get_interface_node(struct usb_device *udev, u8 config, u8 ifnum)
54{
55 return NULL;
56}
Yoshihiro Shimoda5095cb82017-02-21 19:59:47 +090057static inline struct device *usb_of_get_companion_dev(struct device *dev)
58{
59 return NULL;
60}
Peter Chen848d5b92013-06-24 09:25:59 +080061#endif
62
Felipe Balbi9cf7b242013-07-30 09:09:15 +030063#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)
Peter Chen848d5b92013-06-24 09:25:59 +080064enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np);
65#else
Michael Grzeschik1c9af652013-06-13 17:59:55 +030066static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
67{
68 return USBPHY_INTERFACE_MODE_UNKNOWN;
69}
70
Michael Grzeschik1c9af652013-06-13 17:59:55 +030071#endif
72
73#endif /* __LINUX_USB_OF_H */