ee1e84bdd9f4ae6344b3fd7edd09e239429820bc
[openwrt/staging/dedeckeh.git] / target / linux / ar71xx / patches-4.14 / 930-chipidea-pullup.patch
1 Index: linux-4.14.61/drivers/usb/chipidea/ci.h
2 ===================================================================
3 --- linux-4.14.61.orig/drivers/usb/chipidea/ci.h
4 +++ linux-4.14.61/drivers/usb/chipidea/ci.h
5 @@ -205,6 +205,7 @@ struct hw_bank {
6 * @in_lpm: if the core in low power mode
7 * @wakeup_int: if wakeup interrupt occur
8 * @rev: The revision number for controller
9 + * @dp_always_pullup: keep dp always pullup at device mode
10 */
11 struct ci_hdrc {
12 struct device *dev;
13 @@ -259,6 +260,7 @@ struct ci_hdrc {
14 bool in_lpm;
15 bool wakeup_int;
16 enum ci_revision rev;
17 + bool dp_always_pullup;
18 };
19
20 static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
21 Index: linux-4.14.61/drivers/usb/chipidea/core.c
22 ===================================================================
23 --- linux-4.14.61.orig/drivers/usb/chipidea/core.c
24 +++ linux-4.14.61/drivers/usb/chipidea/core.c
25 @@ -818,7 +818,7 @@ static inline void ci_role_destroy(struc
26 {
27 ci_hdrc_gadget_destroy(ci);
28 ci_hdrc_host_destroy(ci);
29 - if (ci->is_otg && ci->roles[CI_ROLE_GADGET])
30 + if (!ci->dp_always_pullup && ci->roles[CI_ROLE_GADGET])
31 ci_hdrc_otg_destroy(ci);
32 }
33
34 @@ -923,6 +923,9 @@ static int ci_hdrc_probe(struct platform
35 CI_HDRC_SUPPORTS_RUNTIME_PM);
36 platform_set_drvdata(pdev, ci);
37
38 + ci->dp_always_pullup = !!(ci->platdata->flags &
39 + CI_HDRC_DP_ALWAYS_PULLUP);
40 +
41 ret = hw_device_init(ci, base);
42 if (ret < 0) {
43 dev_err(dev, "can't initialize hardware\n");
44 @@ -1004,7 +1007,7 @@ static int ci_hdrc_probe(struct platform
45 goto deinit_gadget;
46 }
47
48 - if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
49 + if (!ci->dp_always_pullup && ci->roles[CI_ROLE_GADGET]) {
50 ret = ci_hdrc_otg_init(ci);
51 if (ret) {
52 dev_err(dev, "init otg fails, ret = %d\n", ret);
53 Index: linux-4.14.61/drivers/usb/chipidea/otg.c
54 ===================================================================
55 --- linux-4.14.61.orig/drivers/usb/chipidea/otg.c
56 +++ linux-4.14.61/drivers/usb/chipidea/otg.c
57 @@ -131,8 +131,10 @@ enum ci_role ci_otg_role(struct ci_hdrc
58
59 void ci_handle_vbus_change(struct ci_hdrc *ci)
60 {
61 - if (!ci->is_otg)
62 + if (ci->dp_always_pullup) {
63 + usb_gadget_vbus_connect(&ci->gadget);
64 return;
65 + }
66
67 if (hw_read_otgsc(ci, OTGSC_BSV) && !ci->vbus_active)
68 usb_gadget_vbus_connect(&ci->gadget);
69 Index: linux-4.14.61/include/linux/usb/chipidea.h
70 ===================================================================
71 --- linux-4.14.61.orig/include/linux/usb/chipidea.h
72 +++ linux-4.14.61/include/linux/usb/chipidea.h
73 @@ -60,6 +60,7 @@ struct ci_hdrc_platform_data {
74 #define CI_HDRC_OVERRIDE_RX_BURST BIT(11)
75 #define CI_HDRC_OVERRIDE_PHY_CONTROL BIT(12) /* Glue layer manages phy */
76 #define CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13)
77 +#define CI_HDRC_DP_ALWAYS_PULLUP BIT(14)
78 enum usb_dr_mode dr_mode;
79 #define CI_HDRC_CONTROLLER_RESET_EVENT 0
80 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1