[U-Boot] [RFC 16/35] reset: sunxi: a64: Implement USB resets

Jagan Teki jagan at amarulasolutions.com
Mon Jul 16 11:28:31 UTC 2018


Implement USB reset asser, deasset, request functions for
OHCI, EHCI, OTG and USBPHY reset registers.

Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
 drivers/reset/sunxi/reset_a64.c | 60 +++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 6 deletions(-)

diff --git a/drivers/reset/sunxi/reset_a64.c b/drivers/reset/sunxi/reset_a64.c
index 595af5aa6e..389641c7cd 100644
--- a/drivers/reset/sunxi/reset_a64.c
+++ b/drivers/reset/sunxi/reset_a64.c
@@ -20,6 +20,10 @@ static int a64_reset_request(struct reset_ctl *reset_ctl)
 {
 	debug("%s(#%ld)\n", __func__, reset_ctl->id);
 
+	/* check dt-bindings/reset/sun50i-a64-ccu.h for max id */
+	if (reset_ctl->id > 50)
+		return -EINVAL;
+
 	return 0;
 }
 
@@ -32,18 +36,58 @@ static int a64_reset_free(struct reset_ctl *reset_ctl)
 
 static int a64_reset_assert(struct reset_ctl *reset_ctl)
 {
-	debug("%s(#%ld)\n", __func__, reset_ctl->id);
+	struct a64_reset_priv *priv = dev_get_priv(reset_ctl->dev);
 
-	debug("  unhandled\n");
-	return -EINVAL;
+	debug("%s(#%ld)\n", __func__, reset_ctl->id);
+	switch(reset_ctl->id) {
+	case RST_BUS_OTG:
+	case RST_BUS_EHCI0:
+	case RST_BUS_EHCI1:
+		clrbits_le32(priv->base + 0x2c0,
+			     BIT(23 + (reset_ctl->id - RST_BUS_OTG)));
+		return 0;
+	case RST_BUS_OHCI0:
+	case RST_BUS_OHCI1:
+		clrbits_le32(priv->base + 0x2c0,
+			     BIT(28 + (reset_ctl->id - RST_BUS_OHCI0)));
+		return 0;
+	case RST_USB_PHY0:
+	case RST_USB_PHY1:
+		clrbits_le32(priv->base + 0x0cc,
+			     BIT(reset_ctl->id - RST_USB_PHY0));
+		return 0;
+	default:
+		debug("%s (RST#%ld) unhandled\n", __func__, reset_ctl->id);
+		return -ENODEV;
+	}
 }
 
 static int a64_reset_deassert(struct reset_ctl *reset_ctl)
 {
-	debug("%s(#%ld)\n", __func__, reset_ctl->id);
+	struct a64_reset_priv *priv = dev_get_priv(reset_ctl->dev);
 
-	debug("  unhandled\n");
-	return -EINVAL;
+	debug("%s(#%ld)\n", __func__, reset_ctl->id);
+	switch(reset_ctl->id) {
+	case RST_BUS_OTG:
+	case RST_BUS_EHCI0:
+	case RST_BUS_EHCI1:
+		setbits_le32(priv->base + 0x2c0,
+			     BIT(23 + (reset_ctl->id - RST_BUS_OTG)));
+		return 0;
+	case RST_BUS_OHCI0:
+	case RST_BUS_OHCI1:
+		setbits_le32(priv->base + 0x2c0,
+			     BIT(28 + (reset_ctl->id - RST_BUS_OHCI0)));
+		return 0;
+	case RST_USB_PHY0:
+	case RST_USB_PHY1:
+		setbits_le32(priv->base + 0x0cc,
+			     BIT(reset_ctl->id - RST_USB_PHY0));
+		return 0;
+	default:
+		debug("%s (RST#%ld) unhandled\n", __func__, reset_ctl->id);
+		return -ENODEV;
+	}
 }
 
 struct reset_ops a64_reset_ops = {
@@ -55,6 +99,10 @@ struct reset_ops a64_reset_ops = {
 
 static int a64_reset_probe(struct udevice *dev)
 {
+	struct a64_reset_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+
 	return 0;
 }
 
-- 
2.17.1



More information about the U-Boot mailing list