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