[PATCH 04/17] gpio: dwapb_gpio: Enable all clocks

Ralph Siemsen <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
On some SoC (such as RZ/N1) it is necessary to enable clocks prior to
using the register interface.

Signed-off-by: Ralph Siemsen <[email protected]>
---
 drivers/gpio/dwapb_gpio.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 7ab48780332..6fa50a2c2af 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -7,6 +7,7 @@
 
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <clk.h>
 #include <dm/device.h>
 #include <dm/device-internal.h>
 #include <dm/device_compat.h>
@@ -28,6 +29,7 @@
 
 struct gpio_dwapb_priv {
 	struct reset_ctl_bulk	resets;
+	struct clk_bulk		clks;
 };
 
 struct gpio_dwapb_plat {
@@ -136,8 +138,13 @@ static int gpio_dwapb_probe(struct udevice *dev)
 {
 	struct gpio_dev_priv *priv = dev_get_uclass_priv(dev);
 	struct gpio_dwapb_plat *plat = dev_get_plat(dev);
+	struct gpio_dwapb_priv *dw_priv = dev_get_priv(dev);
 
 	if (!plat) {
+		/* Enable clocks on parent device only */
+		if (clk_get_bulk(dev, &dw_priv->clks) == 0)
+			clk_enable_bulk(&dw_priv->clks);
+
 		/* Reset on parent device only */
 		return gpio_dwapb_reset(dev);
 	}
@@ -214,8 +221,10 @@ static int gpio_dwapb_remove(struct udevice *dev)
 	struct gpio_dwapb_plat *plat = dev_get_plat(dev);
 	struct gpio_dwapb_priv *priv = dev_get_priv(dev);
 
-	if (!plat && priv)
+	if (!plat && priv) {
+		clk_release_bulk(&priv->clks);
 		return reset_release_bulk(&priv->resets);
+	}
 
 	return 0;
 }

-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.