Skip to contentSkip to conversation

usb: sunxi: don't touch reset bits in ccm if CONFIG_SUNXI_GEN_SUN6I is not defined

PATCH New Vasily Khoruzhick 3 participants 6 messages Jun 14, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: sunxi: don't touch reset bits in ccm if CONFIG_SUNXI_GEN_SUN6I is not defined

CCM in sun4i and sun5i doesn't have reset.

Fixes commit 1ed9c1118 ("usb: sunxi: ehci: get rid of ifdefs") and commit 56830cee3 ("usb: sunxi: ohci: get rid of ifdefs")

---
 drivers/usb/host/ehci-sunxi.c | 10 ++++++++--
 drivers/usb/host/ohci-sunxi.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
drivers/usb/host/ehci-sunxi.c +8 -2
index 35fbe03331..f5b661ef12 100644
@@ -85,9 +85,12 @@ no_phy:
 
 	setbits_le32(&priv->ccm->ahb_gate0,
 		     priv->ahb_gate_mask | extra_ahb_gate_mask);
-	if (priv->cfg->has_reset)
+	if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I
 		setbits_le32(&priv->ccm->ahb_reset0_cfg,
 			     priv->ahb_gate_mask | extra_ahb_gate_mask);
+#endif
+	}
 
 	hcor = (struct ehci_hcor *)((uintptr_t)hccr +
 				    HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
@@ -112,8 +115,11 @@ static int ehci_usb_remove(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	if (priv->cfg->has_reset)
+	if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I
 		clrbits_le32(&priv->ccm->ahb_reset0_cfg, priv->ahb_gate_mask);
+#endif
+	}
 	clrbits_le32(&priv->ccm->ahb_gate0, priv->ahb_gate_mask);
 
 	return 0;
drivers/usb/host/ohci-sunxi.c +8 -2
index 2b99169da6..c8c9e1d2fe 100644
@@ -92,9 +92,12 @@ no_phy:
 		     priv->ahb_gate_mask | extra_ahb_gate_mask);
 	setbits_le32(&priv->ccm->usb_clk_cfg,
 		     priv->usb_gate_mask | priv->cfg->extra_usb_gate_mask);
-	if (priv->cfg->has_reset)
+	if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I
 		setbits_le32(&priv->ccm->ahb_reset0_cfg,
 			     priv->ahb_gate_mask | extra_ahb_gate_mask);
+#endif
+	}
 
 	return ohci_register(dev, regs);
 }
@@ -116,8 +119,11 @@ static int ohci_usb_remove(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	if (priv->cfg->has_reset)
+	if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I
 		clrbits_le32(&priv->ccm->ahb_reset0_cfg, priv->ahb_gate_mask);
+#endif
+	}
 	clrbits_le32(&priv->ccm->usb_clk_cfg, priv->usb_gate_mask);
 	clrbits_le32(&priv->ccm->ahb_gate0, priv->ahb_gate_mask);
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 usb: sunxi: don't touch reset bits in ccm if CONFIG_SUNXI_GEN_SUN6I is not defined

Quoted 16 lines · Vasily Khoruzhick

CCM in sun4i and sun5i doesn't have reset.

Fixes commit 1ed9c1118 ("usb: sunxi: ehci: get rid of ifdefs") and commit 56830cee3 ("usb: sunxi: ohci: get rid of ifdefs")

---
 drivers/usb/host/ehci-sunxi.c | 10 ++++++++--
 drivers/usb/host/ohci-sunxi.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
drivers/usb/host/ehci-sunxi.c +0 -0
index 35fbe03331..f5b661ef12 100644

drivers/usb/host/ehci-sunxi.c no_phy: · line 89

Quoted 6 lines
drivers/usb/host/ehci-sunxi.c +2 -1
@@ -85,9 +85,12 @@ no_phy:
 
        setbits_le32(&priv->ccm->ahb_gate0,
                     priv->ahb_gate_mask | extra_ahb_gate_mask);
-       if (priv->cfg->has_reset)
+       if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I

The "has_reset" field is supposed to deal with this. Is it not working?

ChenYu

Quoted 58 lines
drivers/usb/host/ehci-sunxi.c +6 -1
                setbits_le32(&priv->ccm->ahb_reset0_cfg,
                             priv->ahb_gate_mask | extra_ahb_gate_mask);
+#endif
+       }
 
        hcor = (struct ehci_hcor *)((uintptr_t)hccr +
                                    HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
@@ -112,8 +115,11 @@ static int ehci_usb_remove(struct udevice *dev)
        if (ret)
                return ret;
 
-       if (priv->cfg->has_reset)
+       if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I
                clrbits_le32(&priv->ccm->ahb_reset0_cfg, priv->ahb_gate_mask);
+#endif
+       }
        clrbits_le32(&priv->ccm->ahb_gate0, priv->ahb_gate_mask);
 
        return 0;
drivers/usb/host/ohci-sunxi.c +8 -3
index 2b99169da6..c8c9e1d2fe 100644
@@ -92,9 +92,12 @@ no_phy:
                     priv->ahb_gate_mask | extra_ahb_gate_mask);
        setbits_le32(&priv->ccm->usb_clk_cfg,
                     priv->usb_gate_mask | priv->cfg->extra_usb_gate_mask);
-       if (priv->cfg->has_reset)
+       if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I
                setbits_le32(&priv->ccm->ahb_reset0_cfg,
                             priv->ahb_gate_mask | extra_ahb_gate_mask);
+#endif
+       }
 
        return ohci_register(dev, regs);
 }
@@ -116,8 +119,11 @@ static int ohci_usb_remove(struct udevice *dev)
        if (ret)
                return ret;
 
-       if (priv->cfg->has_reset)
+       if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I
                clrbits_le32(&priv->ccm->ahb_reset0_cfg, priv->ahb_gate_mask);
+#endif
+       }
        clrbits_le32(&priv->ccm->usb_clk_cfg, priv->usb_gate_mask);
        clrbits_le32(&priv->ccm->ahb_gate0, priv->ahb_gate_mask);
 
--

2.17.1

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

#2 lore raw

PATCH 1/1 usb: sunxi: don't touch reset bits in ccm if CONFIG_SUNXI_GEN_SUN6I is not defined

Quoted 4 lines · Chen-Yu Tsai

Review

Quoted 2 lines
(quoted diff) +2 -0
+       if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I

The "has_reset" field is supposed to deal with this. Is it not working?

There's no ahb_reset0_cfg in ccm on sun4i and sun5i, so compilation fails with

drivers/usb/host/ohci-sunxi.c:96:26: error: 'struct sunxi_ccm_reg' has no member named 'ahb_reset0_cfg'

(And similar error for ehci-sunxi.c)

#3 lore raw

PATCH 1/1 usb: sunxi: don't touch reset bits in ccm if CONFIG_SUNXI_GEN_SUN6I is not defined

Quoted 11 lines · Vasily Khoruzhick
Quoted 4 lines · Chen-Yu Tsai

Review

Quoted 2 lines
(quoted diff) +2 -0
+       if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I

The "has_reset" field is supposed to deal with this. Is it not working?

There's no ahb_reset0_cfg in ccm on sun4i and sun5i, so compilation fails with

drivers/usb/host/ohci-sunxi.c:96:26: error: 'struct sunxi_ccm_reg' has no member named 'ahb_reset0_cfg'

Add reset0_cfg_off on driver_data for sun6i. and check the same while writing.

#4 lore raw

PATCH 1/1 usb: sunxi: don't touch reset bits in ccm if CONFIG_SUNXI_GEN_SUN6I is not defined

Quoted 6 lines · Jagan Teki
Quoted 5 lines · Vasily Khoruzhick
Quoted 3 lines · Chen-Yu Tsai
Quoted 2 lines
(quoted diff) +2 -0
+       if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

The "has_reset" field is supposed to deal with this. Is it not working?

There's no ahb_reset0_cfg in ccm on sun4i and sun5i, so compilation fails with

drivers/usb/host/ohci-sunxi.c:96:26: error: 'struct sunxi_ccm_reg' has no member named 'ahb_reset0_cfg'

Add reset0_cfg_off on driver_data for sun6i. and check the same while writing.

I don't think that hardcoding ahb_reset0_cfg offset here is a good idea. Using offsetof() isn't possible without ifdef, since this field won't be present in struct sunxi_ccm_reg for sun4i and sun5i.

#5 lore raw

PATCH 1/1 usb: sunxi: don't touch reset bits in ccm if CONFIG_SUNXI_GEN_SUN6I is not defined

Quoted 11 lines · Vasily Khoruzhick
Quoted 10 lines · Jagan Teki
Quoted 9 lines · Vasily Khoruzhick
Quoted 4 lines · Chen-Yu Tsai

Review

Quoted 2 lines
(quoted diff) +2 -0
+       if (priv->cfg->has_reset) {
+#ifdef CONFIG_SUNXI_GEN_SUN6I

The "has_reset" field is supposed to deal with this. Is it not working?

There's no ahb_reset0_cfg in ccm on sun4i and sun5i, so compilation fails with

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

drivers/usb/host/ohci-sunxi.c:96:26: error: 'struct sunxi_ccm_reg' has no member named 'ahb_reset0_cfg'

Add reset0_cfg_off on driver_data for sun6i. and check the same while writing.

I don't think that hardcoding ahb_reset0_cfg offset here is a good idea. Using offsetof() isn't possible without ifdef, since this field won't be present in struct sunxi_ccm_reg for sun4i and sun5i.

ie reason I've mentioned to add offset field for sun6i, this is what we do with phyctl_offset in phy driver. I won't recommend #ifdef again.