mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 06:57:57 +00:00
79 lines
2.5 KiB
Diff
79 lines
2.5 KiB
Diff
|
From d75b267a431f5afd20cfea90021bb63cc8ecfc6b Mon Sep 17 00:00:00 2001
|
||
|
From: Maxime Ripard <maxime@cerno.tech>
|
||
|
Date: Fri, 15 Apr 2022 15:00:44 +0200
|
||
|
Subject: [PATCH] clk: tests: Add missing test case for ranges
|
||
|
|
||
|
Let's add a test on the rate range after a reparenting. This fails for
|
||
|
now, but it's worth having it to document the corner cases we don't
|
||
|
support yet.
|
||
|
|
||
|
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||
|
---
|
||
|
drivers/clk/clk_test.c | 52 ++++++++++++++++++++++++++++++++++++++++++
|
||
|
1 file changed, 52 insertions(+)
|
||
|
|
||
|
--- a/drivers/clk/clk_test.c
|
||
|
+++ b/drivers/clk/clk_test.c
|
||
|
@@ -488,9 +488,61 @@ clk_test_multiple_parents_mux_has_parent
|
||
|
KUNIT_EXPECT_TRUE(test, clk_has_parent(clk, ctx->parents_ctx[1].hw.clk));
|
||
|
}
|
||
|
|
||
|
+/*
|
||
|
+ * Test that for a clock with a multiple parents, if we set a range on
|
||
|
+ * that clock and the parent is changed, its rate after the reparenting
|
||
|
+ * is still within the range we asked for.
|
||
|
+ *
|
||
|
+ * FIXME: clk_set_parent() only does the reparenting but doesn't
|
||
|
+ * reevaluate whether the new clock rate is within its boundaries or
|
||
|
+ * not.
|
||
|
+ */
|
||
|
+static void
|
||
|
+clk_test_multiple_parents_mux_set_range_set_parent_get_rate(struct kunit *test)
|
||
|
+{
|
||
|
+ struct clk_multiple_parent_ctx *ctx = test->priv;
|
||
|
+ struct clk_hw *hw = &ctx->hw;
|
||
|
+ struct clk *clk = hw->clk;
|
||
|
+ struct clk *parent1, *parent2;
|
||
|
+ unsigned long rate;
|
||
|
+ int ret;
|
||
|
+
|
||
|
+ kunit_skip(test, "This needs to be fixed in the core.");
|
||
|
+
|
||
|
+ parent1 = clk_hw_get_clk(&ctx->parents_ctx[0].hw, NULL);
|
||
|
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent1);
|
||
|
+ KUNIT_ASSERT_TRUE(test, clk_is_match(clk_get_parent(clk), parent1));
|
||
|
+
|
||
|
+ parent2 = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL);
|
||
|
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent2);
|
||
|
+
|
||
|
+ ret = clk_set_rate(parent1, DUMMY_CLOCK_RATE_1);
|
||
|
+ KUNIT_ASSERT_EQ(test, ret, 0);
|
||
|
+
|
||
|
+ ret = clk_set_rate(parent2, DUMMY_CLOCK_RATE_2);
|
||
|
+ KUNIT_ASSERT_EQ(test, ret, 0);
|
||
|
+
|
||
|
+ ret = clk_set_rate_range(clk,
|
||
|
+ DUMMY_CLOCK_RATE_1 - 1000,
|
||
|
+ DUMMY_CLOCK_RATE_1 + 1000);
|
||
|
+ KUNIT_ASSERT_EQ(test, ret, 0);
|
||
|
+
|
||
|
+ ret = clk_set_parent(clk, parent2);
|
||
|
+ KUNIT_ASSERT_EQ(test, ret, 0);
|
||
|
+
|
||
|
+ rate = clk_get_rate(clk);
|
||
|
+ KUNIT_ASSERT_GT(test, rate, 0);
|
||
|
+ KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 - 1000);
|
||
|
+ KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
|
||
|
+
|
||
|
+ clk_put(parent2);
|
||
|
+ clk_put(parent1);
|
||
|
+}
|
||
|
+
|
||
|
static struct kunit_case clk_multiple_parents_mux_test_cases[] = {
|
||
|
KUNIT_CASE(clk_test_multiple_parents_mux_get_parent),
|
||
|
KUNIT_CASE(clk_test_multiple_parents_mux_has_parent),
|
||
|
+ KUNIT_CASE(clk_test_multiple_parents_mux_set_range_set_parent_get_rate),
|
||
|
{}
|
||
|
};
|
||
|
|