diff options
author | Simon Glass <sjg@chromium.org> | 2021-03-15 07:25:24 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-03-26 07:03:08 +0300 |
commit | 8813986dfde89ae2eab2a2315e1d23e4784c3d88 (patch) | |
tree | 5190de0581e5accc73701318124a1fe23e218853 /drivers/clk | |
parent | 4ddc91b32f9fc2292686dffe0159e2679362f78b (diff) | |
download | u-boot-8813986dfde89ae2eab2a2315e1d23e4784c3d88.tar.xz |
clk: sandbox: Create a special fixed-rate driver
Create a version of this driver for sandbox so that it can use the
of-platdata struct.
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk_sandbox.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c index e1313f6d88..57acf7d855 100644 --- a/drivers/clk/clk_sandbox.c +++ b/drivers/clk/clk_sandbox.c @@ -9,6 +9,7 @@ #include <errno.h> #include <malloc.h> #include <asm/clk.h> +#include <linux/clk-provider.h> static ulong sandbox_clk_get_rate(struct clk *clk) { @@ -171,3 +172,35 @@ int sandbox_clk_query_requested(struct udevice *dev, int id) return -EINVAL; return priv->requested[id]; } + +int clk_fixed_rate_of_to_plat(struct udevice *dev) +{ + struct clk_fixed_rate *cplat; + +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct sandbox_clk_fixed_rate_plat *plat = dev_get_plat(dev); + + cplat = &plat->fixed; + cplat->fixed_rate = plat->dtplat.clock_frequency; +#else + cplat = to_clk_fixed_rate(dev); +#endif + clk_fixed_rate_ofdata_to_plat_(dev, cplat); + + return 0; +} + +static const struct udevice_id sandbox_clk_fixed_rate_match[] = { + { .compatible = "sandbox,fixed-clock" }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(sandbox_fixed_clock) = { + .name = "sandbox_fixed_clock", + .id = UCLASS_CLK, + .of_match = sandbox_clk_fixed_rate_match, + .of_to_plat = clk_fixed_rate_of_to_plat, + .plat_auto = sizeof(struct sandbox_clk_fixed_rate_plat), + .ops = &clk_fixed_rate_ops, + .flags = DM_FLAG_PRE_RELOC, +}; |