aboutsummaryrefslogtreecommitdiff
path: root/drivers/clk/clk_sandbox.c
diff options
context:
space:
mode:
authorJean-Jacques Hiblot2019-10-22 14:00:05 +0200
committerLukasz Majewski2019-10-22 16:14:05 +0200
commitdd2e0ce2a408c527b1146a9159b68565596cef56 (patch)
treec7f64b2b791942206e4e2aa7d9afd4bb2a725c2b /drivers/clk/clk_sandbox.c
parent52720c536ffdbe0e6aece79840e2791d87204cf7 (diff)
test: clk: Update tests to also check the managed API
Add a few more clocks the clk_sandbox clock provider and get them using the managed API. Make sure they are released when the device is removed. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Diffstat (limited to 'drivers/clk/clk_sandbox.c')
-rw-r--r--drivers/clk/clk_sandbox.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index 1d5cbb589ad..d152fd7e5b8 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -12,6 +12,7 @@
struct sandbox_clk_priv {
ulong rate[SANDBOX_CLK_ID_COUNT];
bool enabled[SANDBOX_CLK_ID_COUNT];
+ bool requested[SANDBOX_CLK_ID_COUNT];
};
static ulong sandbox_clk_get_rate(struct clk *clk)
@@ -65,11 +66,35 @@ static int sandbox_clk_disable(struct clk *clk)
return 0;
}
+static int sandbox_clk_request(struct clk *clk)
+{
+ struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
+
+ if (clk->id >= SANDBOX_CLK_ID_COUNT)
+ return -EINVAL;
+
+ priv->requested[clk->id] = true;
+ return 0;
+}
+
+static int sandbox_clk_free(struct clk *clk)
+{
+ struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
+
+ if (clk->id >= SANDBOX_CLK_ID_COUNT)
+ return -EINVAL;
+
+ priv->requested[clk->id] = false;
+ return 0;
+}
+
static struct clk_ops sandbox_clk_ops = {
.get_rate = sandbox_clk_get_rate,
.set_rate = sandbox_clk_set_rate,
.enable = sandbox_clk_enable,
.disable = sandbox_clk_disable,
+ .request = sandbox_clk_request,
+ .free = sandbox_clk_free,
};
static const struct udevice_id sandbox_clk_ids[] = {
@@ -104,3 +129,12 @@ int sandbox_clk_query_enable(struct udevice *dev, int id)
return priv->enabled[id];
}
+
+int sandbox_clk_query_requested(struct udevice *dev, int id)
+{
+ struct sandbox_clk_priv *priv = dev_get_priv(dev);
+
+ if (id < 0 || id >= SANDBOX_CLK_ID_COUNT)
+ return -EINVAL;
+ return priv->requested[id];
+}