mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-5.4 / 820-usb-0002-MLK-14285-1-usb-phy-add-usb-mode-for-usb_phy.patch
1 From ec89a34069e9d33dd8f809c02a12ffb619d67e1f Mon Sep 17 00:00:00 2001
2 From: Li Jun <jun.li@nxp.com>
3 Date: Wed, 12 Apr 2017 05:31:17 +0800
4 Subject: [PATCH] MLK-14285-1 usb: phy: add usb mode for usb_phy
5
6 USB phy driver may need to know the current working mode of
7 the controller, and does some different settings according to
8 host mode or device mode.
9
10 Signed-off-by: Li Jun <jun.li@nxp.com>
11 (cherry picked from commit 2286cb30feedd6f4a5cb82a0f0af5aa3a04ab698)
12 Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
13 Signed-off-by: Srikanth Krishnakar <Srikanth_Krishnakar@mentor.com>
14 ---
15 include/linux/usb/phy.h | 19 +++++++++++++++++++
16 1 file changed, 19 insertions(+)
17
18 --- a/include/linux/usb/phy.h
19 +++ b/include/linux/usb/phy.h
20 @@ -63,6 +63,13 @@ enum usb_otg_state {
21 OTG_STATE_A_VBUS_ERR,
22 };
23
24 +/* The usb role of phy to be working with */
25 +enum usb_current_mode {
26 + CUR_USB_MODE_NONE,
27 + CUR_USB_MODE_HOST,
28 + CUR_USB_MODE_DEVICE,
29 +};
30 +
31 struct usb_phy;
32 struct usb_otg;
33
34 @@ -161,6 +168,9 @@ struct usb_phy {
35 int (*notify_resume)(struct usb_phy *x,
36 enum usb_device_speed speed);
37
38 + int (*set_mode)(struct usb_phy *x,
39 + enum usb_current_mode mode);
40 +
41 };
42
43 /* for board-specific init logic */
44 @@ -219,6 +229,15 @@ usb_phy_vbus_off(struct usb_phy *x)
45 return x->set_vbus(x, false);
46 }
47
48 +static inline int
49 +usb_phy_set_mode(struct usb_phy *x, enum usb_current_mode mode)
50 +{
51 + if (!x || !x->set_mode)
52 + return 0;
53 +
54 + return x->set_mode(x, mode);
55 +}
56 +
57 /* for usb host and peripheral controller drivers */
58 #if IS_ENABLED(CONFIG_USB_PHY)
59 extern struct usb_phy *usb_get_phy(enum usb_phy_type type);