All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagan Teki <jagannadh.teki@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 06/34] musb: sunxi: Add OTG device clkgate and reset for H3/H5
Date: Tue,  6 Feb 2018 19:55:36 +0530	[thread overview]
Message-ID: <1517927164-18197-7-git-send-email-jagan@amarulasolutions.com> (raw)
In-Reply-To: <1517927164-18197-1-git-send-email-jagan@amarulasolutions.com>

Enable OTG device clkgate and reset for H3/H5

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Suggested-by: Jun Nie <jun.nie@linaro.org>
---
Note:
Since the driver is dm-driver, we even add SOC changes based on
compatible or driver_data but here few of the reset and clock bits
and register offset memebers are in SOC includes files.

I even try to add driver code by adding config structure in .data
but that eventually increasing size.
All these code will anyway move to clock and reset framework
once dm support added.

 arch/arm/include/asm/arch-sunxi/clock_sun6i.h |  1 +
 drivers/usb/musb-new/sunxi.c                  | 24 ++++++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index d794e16..6569883 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -288,6 +288,7 @@ struct sunxi_ccm_reg {
 #define AHB_GATE_OFFSET_USB_EHCI1	27
 #define AHB_GATE_OFFSET_USB_EHCI0	26
 #endif
+#define AHB_GATE_OFFSET_OTG_DEVICE	23
 #ifdef CONFIG_MACH_SUN50I
 #define AHB_GATE_OFFSET_USB0		23
 #elif !defined(CONFIG_MACH_SUN8I_R40)
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 562d311..7d94936 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -80,6 +80,8 @@ struct sunxi_glue {
 	struct musb_host_data mdata;
 	struct sunxi_ccm_reg *ccm;
 	struct device dev;
+	u32 rst_bit;
+	u32 clkgate_bit;
 };
 #define to_sunxi_glue(d)	container_of(d, struct sunxi_glue, dev)
 
@@ -269,10 +271,13 @@ static int sunxi_musb_init(struct musb *musb)
 
 	musb->isr = sunxi_musb_interrupt;
 
-	setbits_le32(&glue->ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0);
+	setbits_le32(&glue->ccm->ahb_gate0,
+		     BIT(AHB_GATE_OFFSET_USB0) | glue->clkgate_bit);
 #ifdef CONFIG_SUNXI_GEN_SUN6I
-	setbits_le32(&glue->ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0);
+	setbits_le32(&glue->ccm->ahb_reset0_cfg,
+		     BIT(AHB_GATE_OFFSET_USB0) | glue->rst_bit);
 #endif
+
 	sunxi_usb_phy_init(0);
 
 	USBC_ConfigFIFO_Base();
@@ -367,10 +372,15 @@ static int musb_usb_probe(struct udevice *dev)
 
 	pdata.power = 250;
 	pdata.platform_ops = &sunxi_musb_ops;
-	if (!device_is_compatible(dev, "allwinner,sun8i-h3-musb"))
+	if (!device_is_compatible(dev, "allwinner,sun8i-h3-musb")) {
 		pdata.config = &musb_config;
-	else
+	} else {
 		pdata.config = &musb_config_h3;
+#ifdef CONFIG_MACH_SUNXI_H3_H5
+		glue->rst_bit = BIT(AHB_GATE_OFFSET_OTG_DEVICE);
+		glue->clkgate_bit = BIT(AHB_GATE_OFFSET_OTG_DEVICE);
+#endif
+	}
 
 #ifdef CONFIG_USB_MUSB_HOST
 	pdata.mode = MUSB_HOST;
@@ -400,9 +410,11 @@ static int musb_usb_remove(struct udevice *dev)
 
 	sunxi_usb_phy_exit(0);
 #ifdef CONFIG_SUNXI_GEN_SUN6I
-	clrbits_le32(&glue->ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0);
+	clrbits_le32(&glue->ccm->ahb_reset0_cfg,
+		     BIT(AHB_GATE_OFFSET_USB0) | glue->rst_bit);
 #endif
-	clrbits_le32(&glue->ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0);
+	clrbits_le32(&glue->ccm->ahb_gate0,
+		     BIT(AHB_GATE_OFFSET_USB0) | glue->clkgate_bit);
 
 	free(host->host);
 	host->host = NULL;
-- 
2.7.4

  parent reply	other threads:[~2018-02-06 14:25 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06 14:25 [U-Boot] [PATCH v4 00/34] phy: sunxi: Add Allwinner sun4i USB PHY Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 01/34] usb: sunxi: Simplify ccm reg base code Jagan Teki
2018-02-06 14:37   ` Marek Vasut
2018-02-11 10:39     ` Jagan Teki
2018-02-11 11:24       ` Marek Vasut
2018-02-06 14:25 ` [U-Boot] [PATCH v4 02/34] musb: sunxi: Add proper macros instead of numericals Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 03/34] musb: sunxi: Use simple way to fill musb_hdrc pdata Jagan Teki
2018-02-06 14:39   ` Marek Vasut
2018-02-11 10:44     ` Jagan Teki
2018-02-11 11:25       ` Marek Vasut
2018-02-06 14:25 ` [U-Boot] [PATCH v4 04/34] musb: sunxi: Add fifo config Jagan Teki
2018-02-06 14:41   ` Marek Vasut
2018-02-11 10:59     ` Jagan Teki
2018-02-11 11:29       ` Marek Vasut
2018-02-06 14:25 ` [U-Boot] [PATCH v4 05/34] sunxi: clock: Fix clock gating for H3/H5/A64 Jagan Teki
2018-02-06 14:25 ` Jagan Teki [this message]
2018-02-06 14:43   ` [U-Boot] [PATCH v4 06/34] musb: sunxi: Add OTG device clkgate and reset for H3/H5 Marek Vasut
2018-02-06 14:25 ` [U-Boot] [PATCH v4 07/34] sunxi: clock: Fix OHCI clock gating " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 08/34] musb: sunxi: Add support for H3/H5A64 Jagan Teki
2018-02-06 14:44   ` Marek Vasut
2018-02-06 14:25 ` [U-Boot] [PATCH v4 09/34] phy: Add Allwinner A64 USB PHY driver Jagan Teki
2018-02-06 14:47   ` Marek Vasut
2018-02-06 14:25 ` [U-Boot] [PATCH v4 10/34] phy: sun4i-usb: Add id_detect and vbus_detect ops Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 11/34] phy: sun4i-usb: Add H3/H5 PHY config Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 12/34] phy: sun4i-usb: Add V3S " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 13/34] phy: sun4i-usb: Add A83T USB " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 14/34] phy: sun4i-usb: Add A10/A13/A20 " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 15/34] phy: sun4i-usb: Add A31 " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 16/34] phy: sun4i-usb: Add A33 USB " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 17/34] phy: sun4i-usb: Add A23 " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 18/34] device-tree-bindings: phy: Sync sun4i-usb-phy bindings Jagan Teki
2018-02-06 14:49   ` Marek Vasut
2018-02-06 14:25 ` [U-Boot] [PATCH v4 19/34] board: sunxi: Use generic-phy for board_usb_cable_connected Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 20/34] phy: sun4i-usb: Add a sunxi specific function for setting squelch-detect Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 21/34] usb: sunxi: Switch to use generic-phy Jagan Teki
2018-02-06 14:51   ` Marek Vasut
2018-02-06 14:25 ` [U-Boot] [PATCH v4 22/34] sunxi: Drop legacy usb_phy.c Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 23/34] sunxi: h3: Sync OTG and HCI nodes from Linux DT Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 24/34] arm64: allwinner: a64: bananapi-m64: Sync usb_otg node from Linux Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 25/34] configs: bananapi-m64: Enable USB OTG peripheral mode Jagan Teki
2018-02-06 15:47   ` Maxime Ripard
2018-02-06 14:25 ` [U-Boot] [PATCH v4 26/34] ARM: dts: sun8i: a83t: Sync usbphy node from Linux Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 27/34] arm64: allwinner: a64: bananapi-m64: Sync usb host nodes " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 28/34] ARM: dts: sun8i-h3: bananapi-m2-plus: Sync usb otg " Jagan Teki
2018-02-06 14:25 ` [U-Boot] [PATCH v4 29/34] configs: bananapi-m2-plus: Enable USB OTG peripheral mode Jagan Teki
2018-02-06 14:26 ` [U-Boot] [PATCH v4 30/34] arm64: allwinner: h5: orangepi-pc2: Order nodes in alphabetic Jagan Teki
2018-02-06 14:26 ` [U-Boot] [PATCH v4 31/34] arm64: allwinner: h5: orangepi-pc2: Sync usb otg nodes from Linux Jagan Teki
2018-02-06 14:26 ` [U-Boot] [PATCH v4 32/34] configs: orangepi-pc2: Enable USB OTG peripheral mode Jagan Teki
2018-02-06 14:26 ` [U-Boot] [PATCH v4 33/34] arm64: allwinner: h5: orangepi-prime: Sync usb otg nodes from Linux Jagan Teki
2018-02-06 14:26 ` [U-Boot] [PATCH v4 34/34] configs: orangepi-prime: Enable USB OTG peripheral mode Jagan Teki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517927164-18197-7-git-send-email-jagan@amarulasolutions.com \
    --to=jagannadh.teki@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.