aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorClaudiu Beznea2020-09-07 17:46:35 +0300
committerEugen Hristev2020-09-22 11:27:18 +0300
commit9a5d59dfc6475c4770bf702e4f30e338499310fd (patch)
tree7b29f10ea3731a74bdbfd8f8c183c33d0742106b /test
parent4d139f3838b4ee48d7df9ca9c37ccd1a57202a52 (diff)
clk: do not disable clock if it is critical
Do not disable clock if it is a critical one. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/clk_ccf.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index 1ce28d747db..e4ebb93cdad 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -24,7 +24,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
int ret;
#if CONFIG_IS_ENABLED(CLK_CCF)
const char *clkname;
- int clkid;
+ int clkid, i;
#endif
/* Get the device using the clk device */
@@ -157,6 +157,36 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
pclk = clk_get_parent(clk);
ut_assertok_ptr(pclk);
ut_asserteq_str(clkname, pclk->dev->name);
+
+ /* Test disabling critical clock. */
+ ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
+ ut_assertok(ret);
+ ut_asserteq_str("i2c_root", clk->dev->name);
+
+ /* Disable it, if any. */
+ ret = sandbox_clk_enable_count(clk);
+ for (i = 0; i < ret; i++) {
+ ret = clk_disable(clk);
+ ut_assertok(ret);
+ }
+
+ ret = sandbox_clk_enable_count(clk);
+ ut_asserteq(ret, 0);
+
+ clk->flags = CLK_IS_CRITICAL;
+ ret = clk_enable(clk);
+ ut_assertok(ret);
+
+ ret = clk_disable(clk);
+ ut_assertok(ret);
+ ret = sandbox_clk_enable_count(clk);
+ ut_asserteq(ret, 1);
+ clk->flags &= ~CLK_IS_CRITICAL;
+
+ ret = clk_disable(clk);
+ ut_assertok(ret);
+ ret = sandbox_clk_enable_count(clk);
+ ut_asserteq(ret, 0);
#endif
return 1;