Rebased from upstream / out of band repository.
[librecmc/librecmc.git] / target / linux / ar71xx / patches-4.14 / 930-chipidea-pullup.patch
1 --- a/drivers/usb/chipidea/ci.h
2 +++ b/drivers/usb/chipidea/ci.h
3 @@ -205,6 +205,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 @@ -259,6 +260,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 @@ -818,7 +818,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 @@ -923,6 +923,9 @@ static int ci_hdrc_probe(struct platform
31                 CI_HDRC_SUPPORTS_RUNTIME_PM);
32         platform_set_drvdata(pdev, ci);
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 @@ -1004,7 +1007,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 @@ -60,6 +60,7 @@ struct ci_hdrc_platform_data {
66  #define CI_HDRC_OVERRIDE_RX_BURST      BIT(11)
67  #define CI_HDRC_OVERRIDE_PHY_CONTROL   BIT(12) /* Glue layer manages phy */
68  #define CI_HDRC_REQUIRES_ALIGNED_DMA   BIT(13)
69 +#define CI_HDRC_DP_ALWAYS_PULLUP       BIT(14)
70         enum usb_dr_mode        dr_mode;
71  #define CI_HDRC_CONTROLLER_RESET_EVENT         0
72  #define CI_HDRC_CONTROLLER_STOPPED_EVENT       1