Skip to contentSkip to conversation

drivers: Add reset ctrl to drivers

PATCH Superseded Ley Foon Tan 3 participants 8 messages Apr 27, 2018

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover drivers: Add reset ctrl to drivers

Add reset ctrl to dwmmc socfpga, designware Ethernet and ns16550 serial drivers.

A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.

If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.

This is preparation to upstream Intel Stratix 10 SoC support in [1].

[1]: https://patchwork.ozlabs.org/cover/900499/

Ley Foon Tan (3):
mmc: dwmmc: socfpga: Add reset ctrl to driver
serial: ns16550: Add reset ctrl to driver
net: designware: Add reset ctrl to driver

 drivers/mmc/socfpga_dw_mmc.c |   19 +++++++++++++++++++
 drivers/net/designware.c     |   13 +++++++++++++
 drivers/serial/ns16550.c     |   12 ++++++++++++
 3 files changed, 44 insertions(+), 0 deletions(-)
#1 lore raw

PATCH 1/3 mmc: dwmmc: socfpga: Add reset ctrl to driver

Add code to reset all reset signals as in mmc DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.

If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.

---
 drivers/mmc/socfpga_dw_mmc.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
drivers/mmc/socfpga_dw_mmc.c +19 -0
index 9ace505..3a110a8 100644
@@ -14,6 +14,7 @@
 #include <linux/libfdt.h>
 #include <linux/err.h>
 #include <malloc.h>
+#include <reset.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,22 @@ struct dwmci_socfpga_priv_data {
 	unsigned int		smplsel;
 };
 
+static void socfpga_dwmci_reset(struct udevice *dev)
+{
+#ifdef CONFIG_DM_RESET
+	struct reset_ctl_bulk reset_bulk;
+	int ret;
+
+	ret = reset_get_bulk(dev, &reset_bulk);
+	if (ret) {
+		dev_warn(dev, "Can't get reset: %d\n", ret);
+		return;
+	}
+
+	reset_deassert_bulk(&reset_bulk);
+#endif
+}
+
 static void socfpga_dwmci_clksel(struct dwmci_host *host)
 {
 	struct dwmci_socfpga_priv_data *priv = host->priv;
@@ -110,6 +127,8 @@ static int socfpga_dwmmc_probe(struct udevice *dev)
 	struct dwmci_socfpga_priv_data *priv = dev_get_priv(dev);
 	struct dwmci_host *host = &priv->host;
 
+	socfpga_dwmci_reset(dev);
+
 #ifdef CONFIG_BLK
 	dwmci_setup_cfg(&plat->cfg, host, host->bus_hz, 400000);
 	host->mmc = &plat->mmc;
Signature · 1 line
1.7.1
#4 lore raw

PATCH 2/3 serial: ns16550: Add reset ctrl to driver

In reply to Ley Foon Tan

Add code to reset all reset signals as in serial DT node. A reset property is an optional feature, so do not fail if a reset property is not present.

If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.

---
 drivers/serial/ns16550.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/serial/ns16550.c +12 -0
index 53550bf..457b636 100644
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <ns16550.h>
+#include <reset.h>
 #include <serial.h>
 #include <watchdog.h>
 #include <linux/types.h>
@@ -177,6 +178,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 #if defined(CONFIG_ARCH_OMAP2PLUS)
 	serial_out(0x7, &com_port->mdr1);	/* mode select reset TL16C750*/
 #endif
+
 	serial_out(UART_MCRVAL, &com_port->mcr);
 	serial_out(ns16550_getfcr(com_port), &com_port->fcr);
 	if (baud_divisor != -1)
@@ -371,6 +373,16 @@ int ns16550_serial_probe(struct udevice *dev)
 {
 	struct NS16550 *const com_port = dev_get_priv(dev);
 
+#ifdef CONFIG_DM_RESET
+	struct reset_ctl_bulk reset_bulk;
+	int ret;
+
+	ret = reset_get_bulk(dev, &reset_bulk);
+	if (!ret)
+		reset_deassert_bulk(&reset_bulk);
+
+#endif
+
 	com_port->plat = dev_get_platdata(dev);
 	NS16550_init(com_port, -1);
 
Signature · 1 line
1.7.1
#6 lore raw

PATCH 3/3 net: designware: Add reset ctrl to driver

In reply to Ley Foon Tan

Add code to reset all reset signals as in Ethernet DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.

If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.

---
 drivers/net/designware.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/net/designware.c +13 -0
index 43670a7..e34f3fb 100644
@@ -16,6 +16,7 @@
 #include <miiphy.h>
 #include <malloc.h>
 #include <pci.h>
+#include <reset.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
@@ -713,6 +714,18 @@ int designware_eth_probe(struct udevice *dev)
 	}
 #endif
 
+#ifdef CONFIG_DM_RESET
+	struct reset_ctl_bulk reset_bulk;
+
+	ret = reset_get_bulk(dev, &reset_bulk);
+	if (ret) {
+		dev_warn(dev, "Can't get reset: %d\n", ret);
+		return;
+	}
+
+	reset_deassert_bulk(&reset_bulk);
+#endif
+
 #ifdef CONFIG_DM_PCI
 	/*
 	 * If we are on PCI bus, either directly attached to a PCI root port,
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/3 mmc: dwmmc: socfpga: Add reset ctrl to driver

In reply to Ley Foon Tan
Quoted 9 lines · Ley Foon Tan

Add code to reset all reset signals as in mmc DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.

If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.

---
 drivers/mmc/socfpga_dw_mmc.c |   19 +++++++++++++++++++

Isn't this generic to the DWMMC core driver ?

Quoted 47 lines
 1 files changed, 19 insertions(+), 0 deletions(-)
drivers/mmc/socfpga_dw_mmc.c +19 -0
index 9ace505..3a110a8 100644
@@ -14,6 +14,7 @@
 #include <linux/libfdt.h>
 #include <linux/err.h>
 #include <malloc.h>
+#include <reset.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,22 @@ struct dwmci_socfpga_priv_data {
 	unsigned int		smplsel;
 };
 
+static void socfpga_dwmci_reset(struct udevice *dev)
+{
+#ifdef CONFIG_DM_RESET
+	struct reset_ctl_bulk reset_bulk;
+	int ret;
+
+	ret = reset_get_bulk(dev, &reset_bulk);
+	if (ret) {
+		dev_warn(dev, "Can't get reset: %d\n", ret);
+		return;
+	}
+
+	reset_deassert_bulk(&reset_bulk);
+#endif
+}
+
 static void socfpga_dwmci_clksel(struct dwmci_host *host)
 {
 	struct dwmci_socfpga_priv_data *priv = host->priv;
@@ -110,6 +127,8 @@ static int socfpga_dwmmc_probe(struct udevice *dev)
 	struct dwmci_socfpga_priv_data *priv = dev_get_priv(dev);
 	struct dwmci_host *host = &priv->host;
 
+	socfpga_dwmci_reset(dev);
+
 #ifdef CONFIG_BLK
 	dwmci_setup_cfg(&plat->cfg, host, host->bus_hz, 400000);
 	host->mmc = &plat->mmc;
Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH 2/3 serial: ns16550: Add reset ctrl to driver

In reply to Ley Foon Tan
Quoted 7 lines · Ley Foon Tan

Add code to reset all reset signals as in serial DT node. A reset property is an optional feature, so do not fail if a reset property is not present.

If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.

Quoted 42 lines
---
 drivers/serial/ns16550.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/serial/ns16550.c +12 -0
index 53550bf..457b636 100644
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <ns16550.h>
+#include <reset.h>
 #include <serial.h>
 #include <watchdog.h>
 #include <linux/types.h>
@@ -177,6 +178,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 #if defined(CONFIG_ARCH_OMAP2PLUS)
 	serial_out(0x7, &com_port->mdr1);	/* mode select reset TL16C750*/
 #endif
+
 	serial_out(UART_MCRVAL, &com_port->mcr);
 	serial_out(ns16550_getfcr(com_port), &com_port->fcr);
 	if (baud_divisor != -1)
@@ -371,6 +373,16 @@ int ns16550_serial_probe(struct udevice *dev)
 {
 	struct NS16550 *const com_port = dev_get_priv(dev);
 
+#ifdef CONFIG_DM_RESET
+	struct reset_ctl_bulk reset_bulk;
+	int ret;
+
+	ret = reset_get_bulk(dev, &reset_bulk);
+	if (!ret)
+		reset_deassert_bulk(&reset_bulk);
+
+#endif
+
 	com_port->plat = dev_get_platdata(dev);
 	NS16550_init(com_port, -1);
 
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH 1/3 mmc: dwmmc: socfpga: Add reset ctrl to driver

In reply to Marek Vasut
Quoted 4 lines · Marek Vasut
Quoted 3 lines · Ley Foon Tan

Add code to reset all reset signals as in mmc DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.

Quoted 8 lines
Quoted 6 lines

If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.

---
 drivers/mmc/socfpga_dw_mmc.c |   19 +++++++++++++++++++

Isn't this generic to the DWMMC core driver ?

Yes, can add to DWMMC core for all platforms. Will update this. Thanks.

Regards
Ley Foon

#7 lore raw

PATCH 3/3 net: designware: Add reset ctrl to driver

In reply to Ley Foon Tan
Quoted 24 lines · Ley Foon Tan

Add code to reset all reset signals as in Ethernet DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.

If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.

---
 drivers/net/designware.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/net/designware.c +1 -0
index 43670a7..e34f3fb 100644
@@ -16,6 +16,7 @@
 #include <miiphy.h>
 #include <malloc.h>
 #include <pci.h>
+#include <reset.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <linux/kernel.h>

drivers/net/designware.c int designware_eth_probe(struct udevice *dev) · line 723

Quoted 10 lines
drivers/net/designware.c +7 -0
@@ -713,6 +714,18 @@ int designware_eth_probe(struct udevice *dev)
        }
 #endif
 
+#ifdef CONFIG_DM_RESET
+       struct reset_ctl_bulk reset_bulk;
+
+       ret = reset_get_bulk(dev, &reset_bulk);
+       if (ret) {
+               dev_warn(dev, "Can't get reset: %d\n", ret);
+               return;

Shouldn't return here, will fix in next revision.

Quoted 11 lines
drivers/net/designware.c +5 -1
+       }
+
+       reset_deassert_bulk(&reset_bulk);
+#endif
+
 #ifdef CONFIG_DM_PCI
        /*
         * If we are on PCI bus, either directly attached to a PCI root port,
--

1.7.1

Regards
Ley Foon