clk: microchip: mpfs: convert parent rate acquistion to get_get_rate()
Currently the clock driver for PolarFire SoC takes a very naive approach
to the relationship between clocks. It reads the dt to get an input
clock, assumes that that is fixed frequency, reads the "clock-frequency"
property & uses that to set up both the "cfg" and "periph" clocks.
Simplifying for the sake of incremental fixes, the "correct" parentage for
the clocks currently supported in U-Boot is that the "cfg" clocks should
be children of the fixed frequency clock in the dt. The AHB clock is one
of these "cfg" clocks and is the parent of the "periph" clocks.
Instead of passing the clock rate of the fixed-frequency clock to the
"cfg" and "periph" registration functions and the name of the parents,
pass their actual parents & use clk_get_rate() to determine their parents
rates.
The "periph" clocks are purely gate clocks and should not be reading the
AHB clocks registers to determine their rates, as they can simply report
the output of clk_get_rate() on their parent.
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Reviewed-by: Padmarao Begari <padmarao.begari@microchip.com>
diff --git a/drivers/clk/microchip/mpfs_clk.c b/drivers/clk/microchip/mpfs_clk.c
index 67828c9..7ba1218 100644
--- a/drivers/clk/microchip/mpfs_clk.c
+++ b/drivers/clk/microchip/mpfs_clk.c
@@ -11,34 +11,32 @@
#include <dm/device.h>
#include <dm/devres.h>
#include <dm/uclass.h>
+#include <dt-bindings/clock/microchip-mpfs-clock.h>
#include <linux/err.h>
#include "mpfs_clk.h"
static int mpfs_clk_probe(struct udevice *dev)
{
- int ret;
+ struct clk *parent_clk = dev_get_priv(dev);
+ struct clk clk_ahb = { .id = CLK_AHB };
void __iomem *base;
- u32 clk_rate;
- const char *parent_clk_name;
- struct clk *clk = dev_get_priv(dev);
+ int ret;
base = dev_read_addr_ptr(dev);
if (!base)
return -EINVAL;
- ret = clk_get_by_index(dev, 0, clk);
+ ret = clk_get_by_index(dev, 0, parent_clk);
if (ret)
return ret;
- dev_read_u32(clk->dev, "clock-frequency", &clk_rate);
- parent_clk_name = clk->dev->name;
-
- ret = mpfs_clk_register_cfgs(base, clk_rate, parent_clk_name);
+ ret = mpfs_clk_register_cfgs(base, parent_clk);
if (ret)
return ret;
- ret = mpfs_clk_register_periphs(base, clk_rate, "clk_ahb");
+ clk_request(dev, &clk_ahb);
+ ret = mpfs_clk_register_periphs(base, &clk_ahb);
return ret;
}