[U-Boot] [PATCH v1 16/19] clk: armada-37xx: Support soc_clk_dump

Marek BehĂșn marek.behun at nic.cz
Wed Mar 7 21:52:13 UTC 2018


Add support for the clk dump command on Armada 37xx.

Signed-off-by: Marek Behun <marek.behun at nic.cz>
---
 drivers/clk/mvebu/armada-37xx-periph.c | 36 +++++++++++++++++++++++++++++++++-
 drivers/clk/mvebu/armada-37xx-tbg.c    |  2 ++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c
index 94eabe5f19..b53521bb9f 100644
--- a/drivers/clk/mvebu/armada-37xx-periph.c
+++ b/drivers/clk/mvebu/armada-37xx-periph.c
@@ -336,7 +336,8 @@ static int armada_37xx_periph_clk_disable(struct clk *clk)
 	return periph_clk_enable(clk, 0);
 }
 
-int armada_37xx_periph_clk_dump(struct udevice *dev)
+#if defined(CONFIG_CMD_CLK) && defined(CONFIG_CLK_ARMADA_3720)
+static int armada_37xx_periph_clk_dump(struct udevice *dev)
 {
 	struct a37xx_periphclk *priv = dev_get_priv(dev);
 	const struct clk_periph *clks;
@@ -355,6 +356,39 @@ int armada_37xx_periph_clk_dump(struct udevice *dev)
 	return 0;
 }
 
+static int clk_dump(const char *name, int (*func)(struct udevice *))
+{
+	struct udevice *dev;
+
+	if (uclass_get_device_by_name(UCLASS_CLK, name, &dev)) {
+		printf("Cannot find device %s\n", name);
+		return -ENODEV;
+	}
+
+	return func(dev);
+}
+
+int armada_37xx_tbg_clk_dump(struct udevice *);
+
+int soc_clk_dump(void)
+{
+	printf("  xtal at %u000000 Hz\n\n", get_ref_clk());
+
+	if (clk_dump("tbg at 13200", armada_37xx_tbg_clk_dump))
+		return 1;
+
+	if (clk_dump("nb-periph-clk at 13000",
+		     armada_37xx_periph_clk_dump))
+		return 1;
+
+	if (clk_dump("sb-periph-clk at 18000",
+		     armada_37xx_periph_clk_dump))
+		return 1;
+
+	return 0;
+}
+#endif
+
 static int armada_37xx_periph_clk_probe(struct udevice *dev)
 {
 	struct a37xx_periphclk *priv = dev_get_priv(dev);
diff --git a/drivers/clk/mvebu/armada-37xx-tbg.c b/drivers/clk/mvebu/armada-37xx-tbg.c
index e8c654f1a6..3107d94494 100644
--- a/drivers/clk/mvebu/armada-37xx-tbg.c
+++ b/drivers/clk/mvebu/armada-37xx-tbg.c
@@ -94,6 +94,7 @@ static ulong armada_37xx_tbg_clk_get_rate(struct clk *clk)
 	return priv->rates[clk->id];
 }
 
+#if defined(CONFIG_CMD_CLK) && defined(CONFIG_CLK_ARMADA_3720)
 int armada_37xx_tbg_clk_dump(struct udevice *dev)
 {
 	struct a37xx_tbgclk *priv = dev_get_priv(dev);
@@ -106,6 +107,7 @@ int armada_37xx_tbg_clk_dump(struct udevice *dev)
 
 	return 0;
 }
+#endif
 
 static int armada_37xx_tbg_clk_probe(struct udevice *dev)
 {
-- 
2.16.1



More information about the U-Boot mailing list