diff mbox series

[v3,05/30] sunxi: musb: Enable OTG device clock for H3

Message ID 1517156391-11353-6-git-send-email-jagan@amarulasolutions.com
State New
Headers show
Series [v3,01/30] sunxi: h3: Sync OTG and HCI nodes from Linux DT | expand

Commit Message

Jagan Teki Jan. 28, 2018, 4:19 p.m. UTC
From: Jun Nie <jun.nie@linaro.org>

Enable OTG clock and deassert reset

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

Comments

Marek Vasut Jan. 28, 2018, 4:35 p.m. UTC | #1
On 01/28/2018 05:19 PM, Jagan Teki wrote:
> From: Jun Nie <jun.nie@linaro.org>
> 
> Enable OTG clock and deassert reset
> 
> Signed-off-by: Jun Nie <jun.nie@linaro.org>
> [jagan: fixed AHB_GATE_OFFSET_OTG_DEVICE to use H3/H5/A64]
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> Reviewed-by: Jagan Teki <jagan@openedev.com>
> Cc: Marek Vasut <marex@denx.de>

Same concern about DT and ifdefs here ...

> ---
>  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);
>
diff mbox series

Patch

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);