df6825771e20729dcd3322a6936321e9fc9258dd
[openwrt/openwrt.git] / target / linux / ar71xx / patches-3.10 / 525-MIPS-ath79-enable-qca-usb-quirks.patch
1 --- a/arch/mips/ath79/dev-usb.c
2 +++ b/arch/mips/ath79/dev-usb.c
3 @@ -37,6 +37,8 @@ static struct usb_ehci_pdata ath79_ehci_
4 static struct usb_ehci_pdata ath79_ehci_pdata_v2 = {
5 .caps_offset = 0x100,
6 .has_tt = 1,
7 + .qca_force_host_mode = 1,
8 + .qca_force_16bit_ptw = 1,
9 };
10
11 static void __init ath79_usb_register(const char *name, int id,
12 @@ -182,14 +184,34 @@ static void __init ar933x_usb_setup(void
13 &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
14 }
15
16 -static void __init ar934x_usb_setup(void)
17 +static void enable_tx_tx_idp_violation_fix(unsigned base)
18 {
19 - u32 bootstrap;
20 + void __iomem *phy_reg;
21 + u32 t;
22
23 - bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
24 - if (bootstrap & AR934X_BOOTSTRAP_USB_MODE_DEVICE)
25 + phy_reg = ioremap(base, 4);
26 + if (!phy_reg)
27 return;
28
29 + t = ioread32(phy_reg);
30 + t &= ~0xff;
31 + t |= 0x58;
32 + iowrite32(t, phy_reg);
33 +
34 + iounmap(phy_reg);
35 +}
36 +
37 +static void ar934x_usb_reset_notifier(struct platform_device *pdev)
38 +{
39 + if (pdev->id != -1)
40 + return;
41 +
42 + enable_tx_tx_idp_violation_fix(0x18116c94);
43 + dev_info(&pdev->dev, "TX-TX IDP fix enabled\n");
44 +}
45 +
46 +static void __init ar934x_usb_setup(void)
47 +{
48 ath79_device_reset_set(AR934X_RESET_USBSUS_OVERRIDE);
49 udelay(1000);
50
51 @@ -202,14 +224,40 @@ static void __init ar934x_usb_setup(void
52 ath79_device_reset_clear(AR934X_RESET_USB_HOST);
53 udelay(1000);
54
55 + if (ath79_soc_rev >= 3)
56 + ath79_ehci_pdata_v2.reset_notifier = ar934x_usb_reset_notifier;
57 +
58 ath79_usb_register("ehci-platform", -1,
59 AR934X_EHCI_BASE, AR934X_EHCI_SIZE,
60 ATH79_CPU_IRQ(3),
61 &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
62 }
63
64 +static void qca955x_usb_reset_notifier(struct platform_device *pdev)
65 +{
66 + u32 base;
67 +
68 + switch (pdev->id) {
69 + case 0:
70 + base = 0x18116c94;
71 + break;
72 +
73 + case 1:
74 + base = 0x18116e54;
75 + break;
76 +
77 + default:
78 + return;
79 + }
80 +
81 + enable_tx_tx_idp_violation_fix(base);
82 + dev_info(&pdev->dev, "TX-TX IDP fix enabled\n");
83 +}
84 +
85 static void __init qca955x_usb_setup(void)
86 {
87 + ath79_ehci_pdata_v2.reset_notifier = qca955x_usb_reset_notifier;
88 +
89 ath79_usb_register("ehci-platform", 0,
90 QCA955X_EHCI0_BASE, QCA955X_EHCI_SIZE,
91 ATH79_IP3_IRQ(0),