Skip to content
Snippets Groups Projects
Commit 9a52be12 authored by Jean-Jacques Hiblot's avatar Jean-Jacques Hiblot Committed by Lukasz Majewski
Browse files

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: default avatarJean-Jacques Hiblot <jjhiblot@ti.com>
parent fd1ba296
No related branches found
No related tags found
No related merge requests found
......@@ -226,6 +226,8 @@
clk_sandbox: clk-sbox {
compatible = "sandbox,clk";
#clock-cells = <1>;
assigned-clocks = <&clk_sandbox 3>;
assigned-clock-rates = <321>;
};
clk-test {
......
......@@ -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),
};
......
......@@ -74,8 +74,8 @@ static int dm_test_clk(struct unit_test_state *uts)
SANDBOX_CLK_TEST_ID_SPI));
ut_asserteq(0, sandbox_clk_test_get_rate(dev_test,
SANDBOX_CLK_TEST_ID_I2C));
ut_asserteq(0, sandbox_clk_test_get_rate(dev_test,
SANDBOX_CLK_TEST_ID_DEVM1));
ut_asserteq(321, sandbox_clk_test_get_rate(dev_test,
SANDBOX_CLK_TEST_ID_DEVM1));
ut_asserteq(0, sandbox_clk_test_get_rate(dev_test,
SANDBOX_CLK_TEST_ID_DEVM2));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment