ar71xx: refresh 4.1 patches
[openwrt/openwrt.git] / target / linux / ar71xx / patches-4.1 / 490-usb-ehci-add-quirks-for-qca-socs.patch
1 --- a/drivers/usb/host/ehci-hcd.c
2 +++ b/drivers/usb/host/ehci-hcd.c
3 @@ -252,6 +252,37 @@ static int ehci_reset (struct ehci_hcd *
4 command |= CMD_RESET;
5 dbg_cmd (ehci, "reset", command);
6 ehci_writel(ehci, command, &ehci->regs->command);
7 +
8 + if (ehci->qca_force_host_mode) {
9 + u32 usbmode;
10 +
11 + udelay(1000);
12 +
13 + usbmode = ehci_readl(ehci, &ehci->regs->usbmode);
14 + usbmode |= USBMODE_CM_HC | (1 << 4);
15 + ehci_writel(ehci, usbmode, &ehci->regs->usbmode);
16 +
17 + ehci_dbg(ehci, "forced host mode, usbmode: %08x\n",
18 + ehci_readl(ehci, &ehci->regs->usbmode));
19 + }
20 +
21 + if (ehci->qca_force_16bit_ptw) {
22 + u32 port_status;
23 +
24 + udelay(1000);
25 +
26 + /* enable 16-bit UTMI interface */
27 + port_status = ehci_readl(ehci, &ehci->regs->port_status[0]);
28 + port_status |= BIT(28);
29 + ehci_writel(ehci, port_status, &ehci->regs->port_status[0]);
30 +
31 + ehci_dbg(ehci, "16-bit UTMI interface enabled, status: %08x\n",
32 + ehci_readl(ehci, &ehci->regs->port_status[0]));
33 + }
34 +
35 + if (ehci->reset_notifier)
36 + ehci->reset_notifier(ehci_to_hcd(ehci));
37 +
38 ehci->rh_state = EHCI_RH_HALTED;
39 ehci->next_statechange = jiffies;
40 retval = ehci_handshake(ehci, &ehci->regs->command,
41 --- a/drivers/usb/host/ehci.h
42 +++ b/drivers/usb/host/ehci.h
43 @@ -227,6 +227,10 @@ struct ehci_hcd { /* one per controlle
44 unsigned need_oc_pp_cycle:1; /* MPC834X port power */
45 unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
46 unsigned ignore_oc:1;
47 + unsigned qca_force_host_mode:1;
48 + unsigned qca_force_16bit_ptw:1; /* force 16 bit UTMI */
49 +
50 + void (*reset_notifier)(struct usb_hcd *hcd);
51
52 /* required for usb32 quirk */
53 #define OHCI_CTRL_HCFS (3 << 6)
54 --- a/include/linux/usb/ehci_pdriver.h
55 +++ b/include/linux/usb/ehci_pdriver.h
56 @@ -50,6 +50,8 @@ struct usb_ehci_pdata {
57 unsigned reset_on_resume:1;
58 unsigned dma_mask_64:1;
59 unsigned ignore_oc:1;
60 + unsigned qca_force_host_mode:1;
61 + unsigned qca_force_16bit_ptw:1;
62
63 /* Turn on all power and clocks */
64 int (*power_on)(struct platform_device *pdev);
65 @@ -59,6 +61,7 @@ struct usb_ehci_pdata {
66 * turn off everything else */
67 void (*power_suspend)(struct platform_device *pdev);
68 int (*pre_setup)(struct usb_hcd *hcd);
69 + void (*reset_notifier)(struct platform_device *pdev);
70 };
71
72 #endif /* __USB_CORE_EHCI_PDRIVER_H */
73 --- a/drivers/usb/host/ehci-platform.c
74 +++ b/drivers/usb/host/ehci-platform.c
75 @@ -49,6 +49,14 @@ struct ehci_platform_priv {
76
77 static const char hcd_name[] = "ehci-platform";
78
79 +static void ehci_platform_reset_notifier(struct usb_hcd *hcd)
80 +{
81 + struct platform_device *pdev = to_platform_device(hcd->self.controller);
82 + struct usb_ehci_pdata *pdata = pdev->dev.platform_data;
83 +
84 + pdata->reset_notifier(pdev);
85 +}
86 +
87 static int ehci_platform_reset(struct usb_hcd *hcd)
88 {
89 struct platform_device *pdev = to_platform_device(hcd->self.controller);
90 @@ -266,6 +274,13 @@ static int ehci_platform_probe(struct pl
91 ehci->big_endian_mmio = 1;
92 if (pdata->ignore_oc)
93 ehci->ignore_oc = 1;
94 + if (pdata->qca_force_host_mode)
95 + ehci->qca_force_host_mode = 1;
96 + if (pdata->qca_force_16bit_ptw)
97 + ehci->qca_force_16bit_ptw = 1;
98 +
99 + if (pdata->reset_notifier)
100 + ehci->reset_notifier = ehci_platform_reset_notifier;
101
102 #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
103 if (ehci->big_endian_mmio) {