ar71xx: Chipidea USB device support
[oweals/openwrt.git] / target / linux / ar71xx / patches-4.4 / 930-chipidea-pullup.patch
1 Index: linux-4.4.4/drivers/usb/chipidea/ci.h
2 ===================================================================
3 --- linux-4.4.4.orig/drivers/usb/chipidea/ci.h  2016-03-31 21:39:23.571126980 +0300
4 +++ linux-4.4.4/drivers/usb/chipidea/ci.h       2016-03-31 21:39:23.567126980 +0300
5 @@ -199,6 +199,7 @@
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 @@ -248,6 +249,7 @@
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.4.4/drivers/usb/chipidea/core.c
22 ===================================================================
23 --- linux-4.4.4.orig/drivers/usb/chipidea/core.c        2016-03-31 21:39:23.571126980 +0300
24 +++ linux-4.4.4/drivers/usb/chipidea/core.c     2016-03-31 21:41:33.159130168 +0300
25 @@ -883,7 +883,7 @@
26  {
27         ci_hdrc_gadget_destroy(ci);
28         ci_hdrc_host_destroy(ci);
29 -       if (ci->is_otg)
30 +       if (!ci->dp_always_pullup && ci->roles[CI_ROLE_GADGET])
31                 ci_hdrc_otg_destroy(ci);
32  }
33  
34 @@ -933,6 +933,9 @@
35         ci->supports_runtime_pm = !!(ci->platdata->flags &
36                 CI_HDRC_SUPPORTS_RUNTIME_PM);
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 @@ -998,7 +1001,7 @@
45                 goto deinit_phy;
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.4.4/drivers/usb/chipidea/otg.c
54 ===================================================================
55 --- linux-4.4.4.orig/drivers/usb/chipidea/otg.c 2016-03-31 21:39:23.571126980 +0300
56 +++ linux-4.4.4/drivers/usb/chipidea/otg.c      2016-03-31 21:39:23.567126980 +0300
57 @@ -95,8 +95,10 @@
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))
68                 usb_gadget_vbus_connect(&ci->gadget);
69 Index: linux-4.4.4/include/linux/usb/chipidea.h
70 ===================================================================
71 --- linux-4.4.4.orig/include/linux/usb/chipidea.h       2016-03-31 21:39:23.571126980 +0300
72 +++ linux-4.4.4/include/linux/usb/chipidea.h    2016-03-31 21:39:23.567126980 +0300
73 @@ -55,6 +55,7 @@
74  #define CI_HDRC_OVERRIDE_AHB_BURST     BIT(9)
75  #define CI_HDRC_OVERRIDE_TX_BURST      BIT(10)
76  #define CI_HDRC_OVERRIDE_RX_BURST      BIT(11)
77 +#define CI_HDRC_DP_ALWAYS_PULLUP BIT(12)
78         enum usb_dr_mode        dr_mode;
79  #define CI_HDRC_CONTROLLER_RESET_EVENT         0
80  #define CI_HDRC_CONTROLLER_STOPPED_EVENT       1