Lines Matching full:test
3 * Kunit test for clk rate management
11 #include <kunit/test.h>
167 static int clk_test_init_with_ops(struct kunit *test, const struct clk_ops *ops) in clk_test_init_with_ops() argument
173 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_test_init_with_ops()
177 test->priv = ctx; in clk_test_init_with_ops()
190 static int clk_test_init(struct kunit *test) in clk_test_init() argument
192 return clk_test_init_with_ops(test, &clk_dummy_rate_ops); in clk_test_init()
195 static int clk_maximize_test_init(struct kunit *test) in clk_maximize_test_init() argument
197 return clk_test_init_with_ops(test, &clk_dummy_maximize_rate_ops); in clk_maximize_test_init()
200 static int clk_minimize_test_init(struct kunit *test) in clk_minimize_test_init() argument
202 return clk_test_init_with_ops(test, &clk_dummy_minimize_rate_ops); in clk_minimize_test_init()
205 static void clk_test_exit(struct kunit *test) in clk_test_exit() argument
207 struct clk_dummy_context *ctx = test->priv; in clk_test_exit()
213 * Test that the actual rate matches what is returned by clk_get_rate()
215 static void clk_test_get_rate(struct kunit *test) in clk_test_get_rate() argument
217 struct clk_dummy_context *ctx = test->priv; in clk_test_get_rate()
223 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_get_rate()
224 KUNIT_EXPECT_EQ(test, rate, ctx->rate); in clk_test_get_rate()
230 * Test that, after a call to clk_set_rate(), the rate returned by
236 static void clk_test_set_get_rate(struct kunit *test) in clk_test_set_get_rate() argument
238 struct clk_dummy_context *ctx = test->priv; in clk_test_set_get_rate()
243 KUNIT_ASSERT_EQ(test, in clk_test_set_get_rate()
248 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_set_get_rate()
249 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_set_get_rate()
255 * Test that, after several calls to clk_set_rate(), the rate returned
261 static void clk_test_set_set_get_rate(struct kunit *test) in clk_test_set_set_get_rate() argument
263 struct clk_dummy_context *ctx = test->priv; in clk_test_set_set_get_rate()
268 KUNIT_ASSERT_EQ(test, in clk_test_set_set_get_rate()
272 KUNIT_ASSERT_EQ(test, in clk_test_set_set_get_rate()
277 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_set_set_get_rate()
278 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_set_set_get_rate()
284 * Test that clk_round_rate and clk_set_rate are consitent and will
287 static void clk_test_round_set_get_rate(struct kunit *test) in clk_test_round_set_get_rate() argument
289 struct clk_dummy_context *ctx = test->priv; in clk_test_round_set_get_rate()
296 KUNIT_ASSERT_GT(test, rounded_rate, 0); in clk_test_round_set_get_rate()
297 KUNIT_EXPECT_EQ(test, rounded_rate, DUMMY_CLOCK_RATE_1); in clk_test_round_set_get_rate()
299 KUNIT_ASSERT_EQ(test, in clk_test_round_set_get_rate()
304 KUNIT_ASSERT_GT(test, set_rate, 0); in clk_test_round_set_get_rate()
305 KUNIT_EXPECT_EQ(test, rounded_rate, set_rate); in clk_test_round_set_get_rate()
319 * Test suite for a basic rate clock, without any parent.
324 .name = "clk-test",
330 static int clk_uncached_test_init(struct kunit *test) in clk_uncached_test_init() argument
335 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_uncached_test_init()
338 test->priv = ctx; in clk_uncached_test_init()
341 ctx->hw.init = CLK_HW_INIT_NO_PARENT("test-clk", in clk_uncached_test_init()
353 * Test that for an uncached clock, the clock framework doesn't cache
357 static void clk_test_uncached_get_rate(struct kunit *test) in clk_test_uncached_get_rate() argument
359 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_get_rate()
365 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_uncached_get_rate()
366 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE); in clk_test_uncached_get_rate()
371 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_uncached_get_rate()
372 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_uncached_get_rate()
378 * Test that for an uncached clock, clk_set_rate_range() will work
381 static void clk_test_uncached_set_range(struct kunit *test) in clk_test_uncached_set_range() argument
383 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_set_range()
388 KUNIT_ASSERT_EQ(test, in clk_test_uncached_set_range()
395 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_uncached_set_range()
396 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_uncached_set_range()
397 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_uncached_set_range()
403 * Test that for an uncached clock, clk_set_rate_range() will work
410 static void clk_test_uncached_updated_rate_set_range(struct kunit *test) in clk_test_uncached_updated_rate_set_range() argument
412 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_updated_rate_set_range()
419 KUNIT_ASSERT_EQ(test, in clk_test_uncached_updated_rate_set_range()
426 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_uncached_updated_rate_set_range()
427 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_uncached_updated_rate_set_range()
440 * Test suite for a basic, uncached, rate clock, without any parent.
445 .name = "clk-uncached-test",
452 clk_multiple_parents_mux_test_init(struct kunit *test) in clk_multiple_parents_mux_test_init() argument
458 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_multiple_parents_mux_test_init()
461 test->priv = ctx; in clk_multiple_parents_mux_test_init()
480 ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents, in clk_multiple_parents_mux_test_init()
491 clk_multiple_parents_mux_test_exit(struct kunit *test) in clk_multiple_parents_mux_test_exit() argument
493 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_multiple_parents_mux_test_exit()
501 * Test that for a clock with multiple parents, clk_get_parent()
505 clk_test_multiple_parents_mux_get_parent(struct kunit *test) in clk_test_multiple_parents_mux_get_parent() argument
507 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_get_parent()
512 KUNIT_EXPECT_TRUE(test, clk_is_match(clk_get_parent(clk), parent)); in clk_test_multiple_parents_mux_get_parent()
519 * Test that for a clock with a multiple parents, clk_has_parent()
523 clk_test_multiple_parents_mux_has_parent(struct kunit *test) in clk_test_multiple_parents_mux_has_parent() argument
525 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_has_parent()
531 KUNIT_EXPECT_TRUE(test, clk_has_parent(clk, parent)); in clk_test_multiple_parents_mux_has_parent()
535 KUNIT_EXPECT_TRUE(test, clk_has_parent(clk, parent)); in clk_test_multiple_parents_mux_has_parent()
542 * Test that for a clock with a multiple parents, if we set a range on
551 clk_test_multiple_parents_mux_set_range_set_parent_get_rate(struct kunit *test) in clk_test_multiple_parents_mux_set_range_set_parent_get_rate() argument
553 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
560 kunit_skip(test, "This needs to be fixed in the core."); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
563 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent1); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
564 KUNIT_ASSERT_TRUE(test, clk_is_match(clk_get_parent(clk), parent1)); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
567 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent2); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
570 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
573 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
578 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
581 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
584 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
585 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 - 1000); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
586 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
601 * Test suite for a basic mux clock with two parents, with
609 .name = "clk-multiple-parents-mux-test",
616 clk_orphan_transparent_multiple_parent_mux_test_init(struct kunit *test) in clk_orphan_transparent_multiple_parent_mux_test_init() argument
622 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_orphan_transparent_multiple_parent_mux_test_init()
625 test->priv = ctx; in clk_orphan_transparent_multiple_parent_mux_test_init()
635 ctx->hw.init = CLK_HW_INIT_PARENTS("test-orphan-mux", parents, in clk_orphan_transparent_multiple_parent_mux_test_init()
646 clk_orphan_transparent_multiple_parent_mux_test_exit(struct kunit *test) in clk_orphan_transparent_multiple_parent_mux_test_exit() argument
648 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_orphan_transparent_multiple_parent_mux_test_exit()
655 * Test that, for a mux whose current parent hasn't been registered yet and is
659 clk_test_orphan_transparent_multiple_parent_mux_get_parent(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_get_parent() argument
661 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_get_parent()
665 KUNIT_EXPECT_PTR_EQ(test, clk_get_parent(clk), NULL); in clk_test_orphan_transparent_multiple_parent_mux_get_parent()
671 * Test that, for a mux whose current parent hasn't been registered yet,
676 clk_test_orphan_transparent_multiple_parent_mux_set_parent(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_parent() argument
678 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
685 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
688 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
691 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
692 KUNIT_EXPECT_TRUE(test, clk_is_match(parent, new_parent)); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
699 * Test that, for a mux that started orphan but got switched to a valid
704 clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range() argument
706 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
714 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
717 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
720 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
723 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
726 KUNIT_ASSERT_GT(test, new_parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
727 KUNIT_EXPECT_EQ(test, parent_rate, new_parent_rate); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
734 * Test that, for a mux that started orphan but got switched to a valid
738 clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate() argument
740 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
748 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
751 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
754 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
757 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
758 KUNIT_EXPECT_EQ(test, parent_rate, rate); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
765 * Test that, for a mux that started orphan but got switched to a valid
769 clk_test_orphan_transparent_multiple_parent_mux_set_parent_put(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put() argument
771 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
777 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
780 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
783 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
786 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
791 KUNIT_ASSERT_GT(test, new_parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
792 KUNIT_EXPECT_EQ(test, parent_rate, new_parent_rate); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
798 * Test that, for a mux that started orphan but got switched to a valid
803 clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified() argument
805 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
813 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
816 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
819 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
822 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
823 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
824 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
831 * Test that, for a mux that started orphan but got switched to a valid
836 clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched() argument
838 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
846 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
849 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
852 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
857 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
860 KUNIT_ASSERT_GT(test, new_parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
861 KUNIT_EXPECT_EQ(test, parent_rate, new_parent_rate); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
868 * Test that, for a mux whose current parent hasn't been registered yet,
873 clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate() argument
875 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
882 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
885 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
886 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
887 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
893 * Test that, for a mux that started orphan, was assigned and rate and
902 clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate() argument
904 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
911 kunit_skip(test, "This needs to be fixed in the core."); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
916 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
919 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
922 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
923 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
924 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
944 * Test suite for a basic mux clock with two parents. The default parent
953 .name = "clk-orphan-transparent-multiple-parent-mux-test",
964 static int clk_single_parent_mux_test_init(struct kunit *test) in clk_single_parent_mux_test_init() argument
969 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_single_parent_mux_test_init()
972 test->priv = ctx; in clk_single_parent_mux_test_init()
984 ctx->hw.init = CLK_HW_INIT("test-clk", "parent-clk", in clk_single_parent_mux_test_init()
996 clk_single_parent_mux_test_exit(struct kunit *test) in clk_single_parent_mux_test_exit() argument
998 struct clk_single_parent_ctx *ctx = test->priv; in clk_single_parent_mux_test_exit()
1005 * Test that for a clock with a single parent, clk_get_parent() actually
1009 clk_test_single_parent_mux_get_parent(struct kunit *test) in clk_test_single_parent_mux_get_parent() argument
1011 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_get_parent()
1016 KUNIT_EXPECT_TRUE(test, clk_is_match(clk_get_parent(clk), parent)); in clk_test_single_parent_mux_get_parent()
1023 * Test that for a clock with a single parent, clk_has_parent() actually
1027 clk_test_single_parent_mux_has_parent(struct kunit *test) in clk_test_single_parent_mux_has_parent() argument
1029 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_has_parent()
1034 KUNIT_EXPECT_TRUE(test, clk_has_parent(clk, parent)); in clk_test_single_parent_mux_has_parent()
1041 * Test that for a clock that can't modify its rate and with a single
1050 clk_test_single_parent_mux_set_range_disjoint_child_last(struct kunit *test) in clk_test_single_parent_mux_set_range_disjoint_child_last() argument
1052 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_disjoint_child_last()
1058 kunit_skip(test, "This needs to be fixed in the core."); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1061 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1064 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1067 KUNIT_EXPECT_LT(test, ret, 0); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1073 * Test that for a clock that can't modify its rate and with a single
1082 clk_test_single_parent_mux_set_range_disjoint_parent_last(struct kunit *test) in clk_test_single_parent_mux_set_range_disjoint_parent_last() argument
1084 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1090 kunit_skip(test, "This needs to be fixed in the core."); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1093 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1096 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1099 KUNIT_EXPECT_LT(test, ret, 0); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1105 * Test that for a clock that can't modify its rate and with a single
1111 clk_test_single_parent_mux_set_range_round_rate_parent_only(struct kunit *test) in clk_test_single_parent_mux_set_range_round_rate_parent_only() argument
1113 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1121 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1124 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1127 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1128 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1129 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1135 * Test that for a clock that can't modify its rate and with a single
1141 clk_test_single_parent_mux_set_range_round_rate_child_smaller(struct kunit *test) in clk_test_single_parent_mux_set_range_round_rate_child_smaller() argument
1143 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1151 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1154 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1157 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1160 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1161 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1162 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1165 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1166 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1167 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1173 * Test that for a clock that can't modify its rate and with a single
1179 clk_test_single_parent_mux_set_range_round_rate_parent_smaller(struct kunit *test) in clk_test_single_parent_mux_set_range_round_rate_parent_smaller() argument
1181 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1189 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1192 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1195 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1198 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1199 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1200 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1203 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1204 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1205 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1222 * Test suite for a basic mux clock with one parent, with
1230 .name = "clk-single-parent-mux-test",
1236 static int clk_orphan_transparent_single_parent_mux_test_init(struct kunit *test) in clk_orphan_transparent_single_parent_mux_test_init() argument
1243 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_orphan_transparent_single_parent_mux_test_init()
1246 test->priv = ctx; in clk_orphan_transparent_single_parent_mux_test_init()
1273 * Test that a mux-only clock, with an initial rate within a range,
1279 static void clk_test_orphan_transparent_parent_mux_set_range(struct kunit *test) in clk_test_orphan_transparent_parent_mux_set_range() argument
1281 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_parent_mux_set_range()
1287 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_parent_mux_set_range()
1289 KUNIT_ASSERT_EQ(test, in clk_test_orphan_transparent_parent_mux_set_range()
1296 KUNIT_ASSERT_GT(test, new_rate, 0); in clk_test_orphan_transparent_parent_mux_set_range()
1297 KUNIT_EXPECT_EQ(test, rate, new_rate); in clk_test_orphan_transparent_parent_mux_set_range()
1308 * Test suite for a basic mux clock with one parent. The parent is
1316 .name = "clk-orphan-transparent-single-parent-test",
1329 clk_orphan_two_level_root_last_test_init(struct kunit *test) in clk_orphan_two_level_root_last_test_init() argument
1334 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_orphan_two_level_root_last_test_init()
1337 test->priv = ctx; in clk_orphan_two_level_root_last_test_init()
1349 CLK_HW_INIT("test-clk", "intermediate-parent", in clk_orphan_two_level_root_last_test_init()
1369 clk_orphan_two_level_root_last_test_exit(struct kunit *test) in clk_orphan_two_level_root_last_test_exit() argument
1371 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_exit()
1379 * Test that, for a clock whose parent used to be orphan, clk_get_rate()
1383 clk_orphan_two_level_root_last_test_get_rate(struct kunit *test) in clk_orphan_two_level_root_last_test_get_rate() argument
1385 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_get_rate()
1391 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE); in clk_orphan_two_level_root_last_test_get_rate()
1397 * Test that, for a clock whose parent used to be orphan,
1405 clk_orphan_two_level_root_last_test_set_range(struct kunit *test) in clk_orphan_two_level_root_last_test_set_range() argument
1407 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_set_range()
1416 KUNIT_ASSERT_EQ(test, ret, 0); in clk_orphan_two_level_root_last_test_set_range()
1419 KUNIT_ASSERT_GT(test, rate, 0); in clk_orphan_two_level_root_last_test_set_range()
1420 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE); in clk_orphan_two_level_root_last_test_set_range()
1433 * Test suite for a basic, transparent, clock with a parent that is also
1446 .name = "clk-orphan-two-level-root-last-test",
1453 * Test that clk_set_rate_range won't return an error for a valid range
1457 static void clk_range_test_set_range(struct kunit *test) in clk_range_test_set_range() argument
1459 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range()
1464 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range()
1471 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range()
1472 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range()
1473 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range()
1479 * Test that calling clk_set_rate_range with a minimum rate higher than
1482 static void clk_range_test_set_range_invalid(struct kunit *test) in clk_range_test_set_range_invalid() argument
1484 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_invalid()
1488 KUNIT_EXPECT_LT(test, in clk_range_test_set_range_invalid()
1498 * Test that users can't set multiple, disjoints, range that would be
1501 static void clk_range_test_multiple_disjoints_range(struct kunit *test) in clk_range_test_multiple_disjoints_range() argument
1503 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_disjoints_range()
1508 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_disjoints_range()
1511 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_disjoints_range()
1513 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_disjoints_range()
1517 KUNIT_EXPECT_LT(test, in clk_range_test_multiple_disjoints_range()
1526 * Test that if our clock has some boundaries and we try to round a rate
1529 static void clk_range_test_set_range_round_rate_lower(struct kunit *test) in clk_range_test_set_range_round_rate_lower() argument
1531 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_round_rate_lower()
1536 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_round_rate_lower()
1543 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_round_rate_lower()
1544 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_round_rate_lower()
1545 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_round_rate_lower()
1551 * Test that if our clock has some boundaries and we try to set a rate
1554 static void clk_range_test_set_range_set_rate_lower(struct kunit *test) in clk_range_test_set_range_set_rate_lower() argument
1556 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_rate_lower()
1561 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_rate_lower()
1567 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_rate_lower()
1572 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_set_rate_lower()
1573 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_set_rate_lower()
1574 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_set_rate_lower()
1580 * Test that if our clock has some boundaries and we try to round and
1585 static void clk_range_test_set_range_set_round_rate_consistent_lower(struct kunit *test) in clk_range_test_set_range_set_round_rate_consistent_lower() argument
1587 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_round_rate_consistent_lower()
1592 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_round_rate_consistent_lower()
1599 KUNIT_ASSERT_GT(test, rounded, 0); in clk_range_test_set_range_set_round_rate_consistent_lower()
1601 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_round_rate_consistent_lower()
1605 KUNIT_EXPECT_EQ(test, rounded, clk_get_rate(clk)); in clk_range_test_set_range_set_round_rate_consistent_lower()
1611 * Test that if our clock has some boundaries and we try to round a rate
1614 static void clk_range_test_set_range_round_rate_higher(struct kunit *test) in clk_range_test_set_range_round_rate_higher() argument
1616 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_round_rate_higher()
1621 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_round_rate_higher()
1628 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_round_rate_higher()
1629 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_round_rate_higher()
1630 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_round_rate_higher()
1636 * Test that if our clock has some boundaries and we try to set a rate
1639 static void clk_range_test_set_range_set_rate_higher(struct kunit *test) in clk_range_test_set_range_set_rate_higher() argument
1641 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_rate_higher()
1646 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_rate_higher()
1652 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_rate_higher()
1657 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_set_rate_higher()
1658 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_set_rate_higher()
1659 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_set_rate_higher()
1665 * Test that if our clock has some boundaries and we try to round and
1670 static void clk_range_test_set_range_set_round_rate_consistent_higher(struct kunit *test) in clk_range_test_set_range_set_round_rate_consistent_higher() argument
1672 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_round_rate_consistent_higher()
1677 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_round_rate_consistent_higher()
1684 KUNIT_ASSERT_GT(test, rounded, 0); in clk_range_test_set_range_set_round_rate_consistent_higher()
1686 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_round_rate_consistent_higher()
1690 KUNIT_EXPECT_EQ(test, rounded, clk_get_rate(clk)); in clk_range_test_set_range_set_round_rate_consistent_higher()
1696 * Test that if our clock has a rate lower than the minimum set by a
1703 static void clk_range_test_set_range_get_rate_raised(struct kunit *test) in clk_range_test_set_range_get_rate_raised() argument
1705 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_get_rate_raised()
1710 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_get_rate_raised()
1714 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_get_rate_raised()
1721 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_get_rate_raised()
1722 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_get_rate_raised()
1728 * Test that if our clock has a rate higher than the maximum set by a
1735 static void clk_range_test_set_range_get_rate_lowered(struct kunit *test) in clk_range_test_set_range_get_rate_lowered() argument
1737 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_get_rate_lowered()
1742 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_get_rate_lowered()
1746 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_get_rate_lowered()
1753 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_get_rate_lowered()
1754 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_get_rate_lowered()
1775 * Test suite for a basic rate clock, without any parent.
1781 .name = "clk-range-test",
1788 * Test that if we have several subsequent calls to
1795 static void clk_range_test_set_range_rate_maximized(struct kunit *test) in clk_range_test_set_range_rate_maximized() argument
1797 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_rate_maximized()
1802 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_maximized()
1806 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_maximized()
1813 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_maximized()
1814 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_rate_maximized()
1816 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_maximized()
1823 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_maximized()
1824 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_range_test_set_range_rate_maximized()
1826 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_maximized()
1833 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_maximized()
1834 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_rate_maximized()
1840 * Test that if we have several subsequent calls to
1847 static void clk_range_test_multiple_set_range_rate_maximized(struct kunit *test) in clk_range_test_multiple_set_range_rate_maximized() argument
1849 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_maximized()
1856 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_set_range_rate_maximized()
1859 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_set_range_rate_maximized()
1861 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_maximized()
1865 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_maximized()
1872 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_maximized()
1873 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_maximized()
1875 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_maximized()
1882 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_maximized()
1883 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_maximized()
1885 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_maximized()
1890 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_maximized()
1891 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_maximized()
1899 * Test that if we have several subsequent calls to
1906 static void clk_range_test_multiple_set_range_rate_put_maximized(struct kunit *test) in clk_range_test_multiple_set_range_rate_put_maximized() argument
1908 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_put_maximized()
1915 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_set_range_rate_put_maximized()
1918 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_set_range_rate_put_maximized()
1920 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_maximized()
1924 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_maximized()
1931 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_maximized()
1932 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_put_maximized()
1934 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_maximized()
1941 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_maximized()
1942 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_put_maximized()
1947 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_maximized()
1948 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_put_maximized()
1962 * Test suite for a basic rate clock, without any parent.
1969 .name = "clk-range-maximize-test",
1976 * Test that if we have several subsequent calls to
1983 static void clk_range_test_set_range_rate_minimized(struct kunit *test) in clk_range_test_set_range_rate_minimized() argument
1985 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_rate_minimized()
1990 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_minimized()
1994 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_minimized()
2001 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_minimized()
2002 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_rate_minimized()
2004 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_minimized()
2011 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_minimized()
2012 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_range_test_set_range_rate_minimized()
2014 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_minimized()
2021 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_minimized()
2022 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_rate_minimized()
2028 * Test that if we have several subsequent calls to
2035 static void clk_range_test_multiple_set_range_rate_minimized(struct kunit *test) in clk_range_test_multiple_set_range_rate_minimized() argument
2037 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_minimized()
2044 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_set_range_rate_minimized()
2047 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_set_range_rate_minimized()
2049 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_minimized()
2056 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_minimized()
2057 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_minimized()
2059 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_minimized()
2066 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_minimized()
2067 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_minimized()
2069 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_minimized()
2074 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_minimized()
2075 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_minimized()
2083 * Test that if we have several subsequent calls to
2090 static void clk_range_test_multiple_set_range_rate_put_minimized(struct kunit *test) in clk_range_test_multiple_set_range_rate_put_minimized() argument
2092 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_put_minimized()
2099 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_set_range_rate_put_minimized()
2102 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_set_range_rate_put_minimized()
2104 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_minimized()
2111 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_minimized()
2112 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_put_minimized()
2114 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_minimized()
2121 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_minimized()
2122 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_put_minimized()
2127 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_minimized()
2128 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_put_minimized()
2142 * Test suite for a basic rate clock, without any parent.
2149 .name = "clk-range-minimize-test",
2161 clk_leaf_mux_set_rate_parent_test_init(struct kunit *test) in clk_leaf_mux_set_rate_parent_test_init() argument
2167 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_leaf_mux_set_rate_parent_test_init()
2170 test->priv = ctx; in clk_leaf_mux_set_rate_parent_test_init()
2189 ctx->mux_ctx.hw.init = CLK_HW_INIT_PARENTS("test-mux", top_parents, in clk_leaf_mux_set_rate_parent_test_init()
2196 ctx->hw.init = CLK_HW_INIT_HW("test-clock", &ctx->mux_ctx.hw, in clk_leaf_mux_set_rate_parent_test_init()
2206 static void clk_leaf_mux_set_rate_parent_test_exit(struct kunit *test) in clk_leaf_mux_set_rate_parent_test_exit() argument
2208 struct clk_leaf_mux_ctx *ctx = test->priv; in clk_leaf_mux_set_rate_parent_test_exit()
2217 * Test that, for a clock that will forward any rate request to its
2221 static void clk_leaf_mux_set_rate_parent_determine_rate(struct kunit *test) in clk_leaf_mux_set_rate_parent_determine_rate() argument
2223 struct clk_leaf_mux_ctx *ctx = test->priv; in clk_leaf_mux_set_rate_parent_determine_rate()
2231 KUNIT_ASSERT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_leaf_mux_set_rate_parent_determine_rate()
2236 KUNIT_ASSERT_EQ(test, ret, 0); in clk_leaf_mux_set_rate_parent_determine_rate()
2238 KUNIT_EXPECT_EQ(test, req.rate, DUMMY_CLOCK_RATE_2); in clk_leaf_mux_set_rate_parent_determine_rate()
2239 KUNIT_EXPECT_EQ(test, req.best_parent_rate, DUMMY_CLOCK_RATE_2); in clk_leaf_mux_set_rate_parent_determine_rate()
2240 KUNIT_EXPECT_PTR_EQ(test, req.best_parent_hw, &ctx->mux_ctx.hw); in clk_leaf_mux_set_rate_parent_determine_rate()
2251 * Test suite for a clock whose parent is a mux with multiple parents.
2308 static int clk_mux_notifier_test_init(struct kunit *test) in clk_mux_notifier_test_init() argument
2314 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_mux_notifier_test_init()
2317 test->priv = ctx; in clk_mux_notifier_test_init()
2339 ctx->mux_ctx.hw.init = CLK_HW_INIT_PARENTS("test-mux", top_parents, in clk_mux_notifier_test_init()
2354 static void clk_mux_notifier_test_exit(struct kunit *test) in clk_mux_notifier_test_exit() argument
2356 struct clk_mux_notifier_ctx *ctx = test->priv; in clk_mux_notifier_test_exit()
2368 * Test that if the we have a notifier registered on a mux, the core
2372 static void clk_mux_notifier_set_parent_test(struct kunit *test) in clk_mux_notifier_set_parent_test() argument
2374 struct clk_mux_notifier_ctx *ctx = test->priv; in clk_mux_notifier_set_parent_test()
2381 KUNIT_ASSERT_EQ(test, ret, 0); in clk_mux_notifier_set_parent_test()
2386 KUNIT_ASSERT_GT(test, ret, 0); in clk_mux_notifier_set_parent_test()
2388 KUNIT_EXPECT_EQ(test, ctx->pre_rate_change.old_rate, DUMMY_CLOCK_RATE_1); in clk_mux_notifier_set_parent_test()
2389 KUNIT_EXPECT_EQ(test, ctx->pre_rate_change.new_rate, DUMMY_CLOCK_RATE_2); in clk_mux_notifier_set_parent_test()
2394 KUNIT_ASSERT_GT(test, ret, 0); in clk_mux_notifier_set_parent_test()
2396 KUNIT_EXPECT_EQ(test, ctx->post_rate_change.old_rate, DUMMY_CLOCK_RATE_1); in clk_mux_notifier_set_parent_test()
2397 KUNIT_EXPECT_EQ(test, ctx->post_rate_change.new_rate, DUMMY_CLOCK_RATE_2); in clk_mux_notifier_set_parent_test()
2409 * Test suite for a mux with multiple parents, and a notifier registered
2422 clk_mux_no_reparent_test_init(struct kunit *test) in clk_mux_no_reparent_test_init() argument
2428 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_mux_no_reparent_test_init()
2431 test->priv = ctx; in clk_mux_no_reparent_test_init()
2450 ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents, in clk_mux_no_reparent_test_init()
2461 clk_mux_no_reparent_test_exit(struct kunit *test) in clk_mux_no_reparent_test_exit() argument
2463 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_test_exit()
2471 * Test that if the we have a mux that cannot change parent and we call
2475 static void clk_mux_no_reparent_round_rate(struct kunit *test) in clk_mux_no_reparent_round_rate() argument
2477 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_round_rate()
2486 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_mux_no_reparent_round_rate()
2489 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_mux_no_reparent_round_rate()
2492 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, other_parent); in clk_mux_no_reparent_round_rate()
2493 KUNIT_ASSERT_FALSE(test, clk_is_match(parent, other_parent)); in clk_mux_no_reparent_round_rate()
2496 KUNIT_ASSERT_GT(test, other_parent_rate, 0); in clk_mux_no_reparent_round_rate()
2500 KUNIT_ASSERT_GT(test, rounded_rate, 0); in clk_mux_no_reparent_round_rate()
2501 KUNIT_EXPECT_EQ(test, rounded_rate, parent_rate); in clk_mux_no_reparent_round_rate()
2507 * Test that if the we have a mux that cannot change parent and we call
2511 static void clk_mux_no_reparent_set_rate(struct kunit *test) in clk_mux_no_reparent_set_rate() argument
2513 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_set_rate()
2523 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_mux_no_reparent_set_rate()
2526 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_mux_no_reparent_set_rate()
2529 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, other_parent); in clk_mux_no_reparent_set_rate()
2530 KUNIT_ASSERT_FALSE(test, clk_is_match(parent, other_parent)); in clk_mux_no_reparent_set_rate()
2533 KUNIT_ASSERT_GT(test, other_parent_rate, 0); in clk_mux_no_reparent_set_rate()
2537 KUNIT_ASSERT_EQ(test, ret, 0); in clk_mux_no_reparent_set_rate()
2540 KUNIT_ASSERT_GT(test, rate, 0); in clk_mux_no_reparent_set_rate()
2541 KUNIT_EXPECT_EQ(test, rate, parent_rate); in clk_mux_no_reparent_set_rate()
2553 * Test suite for a clock mux that isn't allowed to change parent, using