sunxi: add support for kernel 4.9
[openwrt/staging/chunkeey.git] / package / boot / uboot-sunxi / patches / 015-fix-2nd-usb-ctrler-on-sun47i.patch
1 From 948603d4d637a0e04a3214253b911cfc4ed11220 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Mon, 21 Mar 2016 14:44:35 +0100
4 Subject: [PATCH] sunxi: Fix 2nd usb controller on sun4i/sun7i no longer
5 working
6
7 The 2nd usb controller on sun4i/sun7i has its base address 0x8000
8 bytes from the 1st one, rather then 0x1000. Also the ahb clk gates
9 are interleaved with the ohci clk-gates introducing a hole between
10 the clks for usb1 and usb2.
11
12 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
13 Acked-by: Ian Campbell <ijc@hellion.org.uk>
14 ---
15 drivers/usb/host/ehci-sunxi.c | 13 +++++++++++--
16 drivers/usb/host/ohci-sunxi.c | 15 ++++++++++++---
17 2 files changed, 23 insertions(+), 5 deletions(-)
18
19 --- a/drivers/usb/host/ehci-sunxi.c
20 +++ b/drivers/usb/host/ehci-sunxi.c
21 @@ -17,6 +17,14 @@
22 #include <dm.h>
23 #include "ehci.h"
24
25 +#ifdef CONFIG_SUNXI_GEN_SUN4I
26 +#define BASE_DIST 0x8000
27 +#define AHB_CLK_DIST 2
28 +#else
29 +#define BASE_DIST 0x1000
30 +#define AHB_CLK_DIST 1
31 +#endif
32 +
33 struct ehci_sunxi_priv {
34 struct ehci_ctrl ehci;
35 int ahb_gate_mask; /* Mask of ahb_gate0 clk gate bits for this hcd */
36 @@ -39,8 +47,9 @@ static int ehci_usb_probe(struct udevice
37 #ifdef CONFIG_MACH_SUN8I_H3
38 priv->ahb_gate_mask |= 1 << AHB_GATE_OFFSET_USB_OHCI0;
39 #endif
40 - priv->phy_index = ((u32)hccr - SUNXI_USB1_BASE) / 0x1000 + 1;
41 - priv->ahb_gate_mask <<= priv->phy_index - 1;
42 + priv->phy_index = ((u32)hccr - SUNXI_USB1_BASE) / BASE_DIST;
43 + priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST;
44 + priv->phy_index++; /* Non otg phys start at 1 */
45
46 setbits_le32(&ccm->ahb_gate0, priv->ahb_gate_mask);
47 #ifdef CONFIG_SUNXI_GEN_SUN6I
48 --- a/drivers/usb/host/ohci-sunxi.c
49 +++ b/drivers/usb/host/ohci-sunxi.c
50 @@ -17,6 +17,14 @@
51 #include <usb.h>
52 #include "ohci.h"
53
54 +#ifdef CONFIG_SUNXI_GEN_SUN4I
55 +#define BASE_DIST 0x8000
56 +#define AHB_CLK_DIST 2
57 +#else
58 +#define BASE_DIST 0x1000
59 +#define AHB_CLK_DIST 1
60 +#endif
61 +
62 struct ohci_sunxi_priv {
63 ohci_t ohci;
64 int ahb_gate_mask; /* Mask of ahb_gate0 clk gate bits for this hcd */
65 @@ -42,9 +50,10 @@ static int ohci_usb_probe(struct udevice
66 priv->ahb_gate_mask |= 1 << AHB_GATE_OFFSET_USB_EHCI0;
67 #endif
68 priv->usb_gate_mask = CCM_USB_CTRL_OHCI0_CLK;
69 - priv->phy_index = ((u32)regs - (SUNXI_USB1_BASE + 0x400)) / 0x1000 + 1;
70 - priv->ahb_gate_mask <<= priv->phy_index - 1;
71 - priv->usb_gate_mask <<= priv->phy_index - 1;
72 + priv->phy_index = ((u32)regs - (SUNXI_USB1_BASE + 0x400)) / BASE_DIST;
73 + priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST;
74 + priv->usb_gate_mask <<= priv->phy_index;
75 + priv->phy_index++; /* Non otg phys start at 1 */
76
77 setbits_le32(&ccm->ahb_gate0, priv->ahb_gate_mask);
78 setbits_le32(&ccm->usb_clk_cfg, priv->usb_gate_mask);