diff options
author | Jean-Jacques Hiblot <jjhiblot@ti.com> | 2019-10-22 14:00:07 +0200 |
---|---|---|
committer | Lukasz Majewski <lukma@denx.de> | 2019-10-22 16:14:05 +0200 |
commit | 9a52be129c5b159269ac69a7ae0197eb02612f1d (patch) | |
tree | 1f2527e776aada5ab0b31d995066b69ce02ca13b /drivers/clk | |
parent | fd1ba2965244e7628ac3aa539e51653490e1b4fe (diff) | |
download | u-boot-9a52be129c5b159269ac69a7ae0197eb02612f1d.zip u-boot-9a52be129c5b159269ac69a7ae0197eb02612f1d.tar.gz u-boot-9a52be129c5b159269ac69a7ae0197eb02612f1d.tar.bz2 |
test: clk: test clock self assignment
Make sure that the clock self-assignment works by having a clock of
clk-sbox be configured automatically when clk-sbox is probed.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk_sandbox.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c index d152fd7..de6b2f7 100644 --- a/drivers/clk/clk_sandbox.c +++ b/drivers/clk/clk_sandbox.c @@ -10,6 +10,7 @@ #include <asm/clk.h> struct sandbox_clk_priv { + bool probed; ulong rate[SANDBOX_CLK_ID_COUNT]; bool enabled[SANDBOX_CLK_ID_COUNT]; bool requested[SANDBOX_CLK_ID_COUNT]; @@ -19,6 +20,9 @@ static ulong sandbox_clk_get_rate(struct clk *clk) { struct sandbox_clk_priv *priv = dev_get_priv(clk->dev); + if (!priv->probed) + return -ENODEV; + if (clk->id >= SANDBOX_CLK_ID_COUNT) return -EINVAL; @@ -30,6 +34,9 @@ static ulong sandbox_clk_set_rate(struct clk *clk, ulong rate) struct sandbox_clk_priv *priv = dev_get_priv(clk->dev); ulong old_rate; + if (!priv->probed) + return -ENODEV; + if (clk->id >= SANDBOX_CLK_ID_COUNT) return -EINVAL; @@ -46,6 +53,9 @@ static int sandbox_clk_enable(struct clk *clk) { struct sandbox_clk_priv *priv = dev_get_priv(clk->dev); + if (!priv->probed) + return -ENODEV; + if (clk->id >= SANDBOX_CLK_ID_COUNT) return -EINVAL; @@ -58,6 +68,9 @@ static int sandbox_clk_disable(struct clk *clk) { struct sandbox_clk_priv *priv = dev_get_priv(clk->dev); + if (!priv->probed) + return -ENODEV; + if (clk->id >= SANDBOX_CLK_ID_COUNT) return -EINVAL; @@ -97,6 +110,14 @@ static struct clk_ops sandbox_clk_ops = { .free = sandbox_clk_free, }; +static int sandbox_clk_probe(struct udevice *dev) +{ + struct sandbox_clk_priv *priv = dev_get_priv(dev); + + priv->probed = true; + return 0; +} + static const struct udevice_id sandbox_clk_ids[] = { { .compatible = "sandbox,clk" }, { } @@ -107,6 +128,7 @@ U_BOOT_DRIVER(clk_sandbox) = { .id = UCLASS_CLK, .of_match = sandbox_clk_ids, .ops = &sandbox_clk_ops, + .probe = sandbox_clk_probe, .priv_auto_alloc_size = sizeof(struct sandbox_clk_priv), }; |