From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/6] musb-new: sunxi: Access ahb_reset0_cfg via ccm offset
Date: Fri, 20 Jul 2018 12:43:59 +0530 [thread overview]
Message-ID: <20180720071401.12952-5-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20180720071401.12952-1-jagan@amarulasolutions.com>
reset0 is not available for sun4i, 5i and 7i so access
the reset0 offset from ccm via driver data for relevant
Allwinner SoC. this will eventually drop the existing
ifdef for SUN6I.
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
Changes for v2:
- new patch
drivers/usb/musb-new/sunxi.c | 40 +++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index aa2880eeb9..d909b9ea53 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -76,15 +76,20 @@
* From usbc/usbc.c
******************************************************************************/
+#define OFF_SUN6I_AHB_RESET0 0x2c0
+
struct sunxi_musb_config {
struct musb_hdrc_config *config;
+ bool has_reset;
u8 rst_bit;
u8 clkgate_bit;
+ u32 off_reset0;
};
struct sunxi_glue {
struct musb_host_data mdata;
struct sunxi_ccm_reg *ccm;
+ u32 *reg_reset0;
struct sunxi_musb_config *cfg;
struct device dev;
struct phy phy;
@@ -303,12 +308,12 @@ static int sunxi_musb_init(struct musb *musb)
if (glue->cfg->clkgate_bit)
setbits_le32(&glue->ccm->ahb_gate0,
BIT(glue->cfg->clkgate_bit));
-#ifdef CONFIG_SUNXI_GEN_SUN6I
- setbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0));
+
+ if (glue->cfg->has_reset)
+ setbits_le32(glue->reg_reset0, BIT(AHB_GATE_OFFSET_USB0));
+
if (glue->cfg->rst_bit)
- setbits_le32(&glue->ccm->ahb_reset0_cfg,
- BIT(glue->cfg->rst_bit));
-#endif
+ setbits_le32(glue->reg_reset0, BIT(glue->cfg->rst_bit));
USBC_ConfigFIFO_Base();
USBC_EnableDpDmPullUp(musb->mregs);
@@ -418,6 +423,8 @@ static int musb_usb_probe(struct udevice *dev)
if (IS_ERR(glue->ccm))
return PTR_ERR(glue->ccm);
+ glue->reg_reset0 = (void *)glue->ccm + glue->cfg->off_reset0;
+
ret = generic_phy_get_by_name(dev, "usb", &glue->phy);
if (ret) {
pr_err("failed to get usb PHY\n");
@@ -468,12 +475,12 @@ static int musb_usb_remove(struct udevice *dev)
musb_stop(host->host);
-#ifdef CONFIG_SUNXI_GEN_SUN6I
- clrbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0));
+ if (glue->cfg->has_reset)
+ clrbits_le32(glue->reg_reset0, BIT(AHB_GATE_OFFSET_USB0));
+
if (glue->cfg->rst_bit)
- clrbits_le32(&glue->ccm->ahb_reset0_cfg,
- BIT(glue->cfg->rst_bit));
-#endif
+ clrbits_le32(glue->reg_reset0, BIT(glue->cfg->rst_bit));
+
clrbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0));
if (glue->cfg->clkgate_bit)
clrbits_le32(&glue->ccm->ahb_gate0,
@@ -487,21 +494,30 @@ static int musb_usb_remove(struct udevice *dev)
static const struct sunxi_musb_config sun4i_a10_cfg = {
.config = &musb_config,
+ .has_reset = false,
+};
+
+static const struct sunxi_musb_config sun6i_a31_cfg = {
+ .config = &musb_config,
+ .has_reset = true,
+ .off_reset0 = OFF_SUN6I_AHB_RESET0,
};
static const struct sunxi_musb_config sun8i_h3_cfg = {
.config = &musb_config_h3,
+ .has_reset = true,
.rst_bit = 23,
.clkgate_bit = 23,
+ .off_reset0 = OFF_SUN6I_AHB_RESET0,
};
static const struct udevice_id sunxi_musb_ids[] = {
{ .compatible = "allwinner,sun4i-a10-musb",
.data = (ulong)&sun4i_a10_cfg },
{ .compatible = "allwinner,sun6i-a31-musb",
- .data = (ulong)&sun4i_a10_cfg },
+ .data = (ulong)&sun6i_a31_cfg },
{ .compatible = "allwinner,sun8i-a33-musb",
- .data = (ulong)&sun4i_a10_cfg },
+ .data = (ulong)&sun6i_a31_cfg },
{ .compatible = "allwinner,sun8i-h3-musb",
.data = (ulong)&sun8i_h3_cfg },
{ }
--
2.17.1
next prev parent reply other threads:[~2018-07-20 7:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-20 7:13 [U-Boot] [PATCH v2 0/6] musb-new: Improve shutdown code Jagan Teki
2018-07-20 7:13 ` [U-Boot] [PATCH v2 1/6] usb: musb-new: Fix improper musb host pointer Jagan Teki
2018-07-20 7:13 ` [U-Boot] [PATCH v2 2/6] usb: musb-new: sunxi: Allocate struct phy in private Jagan Teki
2018-07-20 7:13 ` [U-Boot] [RFC PATCH v2 3/6] dm: usb: Add UCLASS_USB_DEV_GENERIC shutdown Jagan Teki
2018-07-23 23:48 ` Simon Glass
2018-08-07 7:03 ` Jagan Teki
2018-08-17 12:48 ` Simon Glass
2018-08-17 13:37 ` Jagan Teki
2018-08-21 17:31 ` Simon Glass
2018-07-20 7:13 ` Jagan Teki [this message]
2018-07-20 7:14 ` [U-Boot] [PATCH v2 5/6] usb: musb-new: sunxi: Add proper musb exit support Jagan Teki
2018-07-20 7:14 ` [U-Boot] [PATCH v2 6/6] usb: musb-new: Call musb_platform_exit from musb_stop Jagan Teki
2018-07-20 9:42 ` [U-Boot] [PATCH v2 0/6] musb-new: Improve shutdown code Marek Vasut
2018-08-13 11:03 ` Chen-Yu Tsai
2018-08-20 17:04 ` Jagan Teki
2018-08-21 13:04 ` Jagan Teki
2018-08-22 2:41 ` [U-Boot] [linux-sunxi] " Chen-Yu Tsai
2018-08-23 12:05 ` 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=20180720071401.12952-5-jagan@amarulasolutions.com \
--to=jagan@amarulasolutions.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox