From: Jun Nie <jun....@linaro.org>

Enable OTG clock and deassert reset

Signed-off-by: Jun Nie <jun....@linaro.org>
[jagan: fixed AHB_GATE_OFFSET_OTG_DEVICE to use H3/H5/A64]
Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
Reviewed-by: Jagan Teki <ja...@openedev.com>
Cc: Marek Vasut <ma...@denx.de>
---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 1 +
 drivers/usb/musb-new/sunxi.c                  | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h 
b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index 2c82d0a..624d624 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -279,6 +279,7 @@ struct sunxi_ccm_reg {
 #define AHB_GATE_OFFSET_USB_EHCI2      26
 #define AHB_GATE_OFFSET_USB_EHCI1      25
 #define AHB_GATE_OFFSET_USB_EHCI0      24
+#define AHB_GATE_OFFSET_OTG_DEVICE     23
 #else
 #define AHB_GATE_OFFSET_USB_OHCI1      30
 #define AHB_GATE_OFFSET_USB_OHCI0      29
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 46c8bd2..c3b8fa4 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -266,6 +266,11 @@ static int sunxi_musb_init(struct musb *musb)
 #ifdef CONFIG_SUNXI_GEN_SUN6I
        setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0);
 #endif
+#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
+       setbits_le32(&ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_OTG_DEVICE));
+       setbits_le32(&ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_OTG_DEVICE));
+#endif
+
        sunxi_usb_phy_init(0);
 
        USBC_ConfigFIFO_Base();
@@ -380,6 +385,9 @@ static int musb_usb_remove(struct udevice *dev)
 #ifdef CONFIG_SUNXI_GEN_SUN6I
        clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0);
 #endif
+#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
+       clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_OTG_DEVICE);
+#endif
        clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0);
 
        free(host->host);
-- 
2.7.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to