Lines Matching full:test
16 #include <kunit/test.h>
176 static int clk_test_init_with_ops(struct kunit *test, const struct clk_ops *ops) in clk_test_init_with_ops() argument
182 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_test_init_with_ops()
186 test->priv = ctx; in clk_test_init_with_ops()
199 static int clk_test_init(struct kunit *test) in clk_test_init() argument
201 return clk_test_init_with_ops(test, &clk_dummy_rate_ops); in clk_test_init()
204 static int clk_maximize_test_init(struct kunit *test) in clk_maximize_test_init() argument
206 return clk_test_init_with_ops(test, &clk_dummy_maximize_rate_ops); in clk_maximize_test_init()
209 static int clk_minimize_test_init(struct kunit *test) in clk_minimize_test_init() argument
211 return clk_test_init_with_ops(test, &clk_dummy_minimize_rate_ops); in clk_minimize_test_init()
214 static void clk_test_exit(struct kunit *test) in clk_test_exit() argument
216 struct clk_dummy_context *ctx = test->priv; in clk_test_exit()
222 * Test that the actual rate matches what is returned by clk_get_rate()
224 static void clk_test_get_rate(struct kunit *test) in clk_test_get_rate() argument
226 struct clk_dummy_context *ctx = test->priv; in clk_test_get_rate()
232 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_get_rate()
233 KUNIT_EXPECT_EQ(test, rate, ctx->rate); in clk_test_get_rate()
239 * Test that, after a call to clk_set_rate(), the rate returned by
245 static void clk_test_set_get_rate(struct kunit *test) in clk_test_set_get_rate() argument
247 struct clk_dummy_context *ctx = test->priv; in clk_test_set_get_rate()
252 KUNIT_ASSERT_EQ(test, in clk_test_set_get_rate()
257 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_set_get_rate()
258 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_set_get_rate()
264 * Test that, after several calls to clk_set_rate(), the rate returned
270 static void clk_test_set_set_get_rate(struct kunit *test) in clk_test_set_set_get_rate() argument
272 struct clk_dummy_context *ctx = test->priv; in clk_test_set_set_get_rate()
277 KUNIT_ASSERT_EQ(test, in clk_test_set_set_get_rate()
281 KUNIT_ASSERT_EQ(test, in clk_test_set_set_get_rate()
286 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_set_set_get_rate()
287 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_set_set_get_rate()
293 * Test that clk_round_rate and clk_set_rate are consitent and will
296 static void clk_test_round_set_get_rate(struct kunit *test) in clk_test_round_set_get_rate() argument
298 struct clk_dummy_context *ctx = test->priv; in clk_test_round_set_get_rate()
305 KUNIT_ASSERT_GT(test, rounded_rate, 0); in clk_test_round_set_get_rate()
306 KUNIT_EXPECT_EQ(test, rounded_rate, DUMMY_CLOCK_RATE_1); in clk_test_round_set_get_rate()
308 KUNIT_ASSERT_EQ(test, in clk_test_round_set_get_rate()
313 KUNIT_ASSERT_GT(test, set_rate, 0); in clk_test_round_set_get_rate()
314 KUNIT_EXPECT_EQ(test, rounded_rate, set_rate); in clk_test_round_set_get_rate()
328 * Test suite for a basic rate clock, without any parent.
333 .name = "clk-test",
339 static int clk_uncached_test_init(struct kunit *test) in clk_uncached_test_init() argument
344 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_uncached_test_init()
347 test->priv = ctx; in clk_uncached_test_init()
350 ctx->hw.init = CLK_HW_INIT_NO_PARENT("test-clk", in clk_uncached_test_init()
362 * Test that for an uncached clock, the clock framework doesn't cache
366 static void clk_test_uncached_get_rate(struct kunit *test) in clk_test_uncached_get_rate() argument
368 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_get_rate()
374 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_uncached_get_rate()
375 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE); in clk_test_uncached_get_rate()
380 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_uncached_get_rate()
381 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_uncached_get_rate()
387 * Test that for an uncached clock, clk_set_rate_range() will work
390 static void clk_test_uncached_set_range(struct kunit *test) in clk_test_uncached_set_range() argument
392 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_set_range()
397 KUNIT_ASSERT_EQ(test, in clk_test_uncached_set_range()
404 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_uncached_set_range()
405 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_uncached_set_range()
406 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_uncached_set_range()
412 * Test that for an uncached clock, clk_set_rate_range() will work
419 static void clk_test_uncached_updated_rate_set_range(struct kunit *test) in clk_test_uncached_updated_rate_set_range() argument
421 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_updated_rate_set_range()
428 KUNIT_ASSERT_EQ(test, in clk_test_uncached_updated_rate_set_range()
435 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_uncached_updated_rate_set_range()
436 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_uncached_updated_rate_set_range()
449 * Test suite for a basic, uncached, rate clock, without any parent.
454 .name = "clk-uncached-test",
461 clk_multiple_parents_mux_test_init(struct kunit *test) in clk_multiple_parents_mux_test_init() argument
467 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_multiple_parents_mux_test_init()
470 test->priv = ctx; in clk_multiple_parents_mux_test_init()
476 ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[0].hw); in clk_multiple_parents_mux_test_init()
484 ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[1].hw); in clk_multiple_parents_mux_test_init()
489 ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents, in clk_multiple_parents_mux_test_init()
492 ret = clk_hw_register_kunit(test, NULL, &ctx->hw); in clk_multiple_parents_mux_test_init()
500 * Test that for a clock with multiple parents, clk_get_parent()
504 clk_test_multiple_parents_mux_get_parent(struct kunit *test) in clk_test_multiple_parents_mux_get_parent() argument
506 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_get_parent()
511 KUNIT_EXPECT_TRUE(test, clk_is_match(clk_get_parent(clk), parent)); in clk_test_multiple_parents_mux_get_parent()
518 * Test that for a clock with a multiple parents, clk_has_parent()
522 clk_test_multiple_parents_mux_has_parent(struct kunit *test) in clk_test_multiple_parents_mux_has_parent() argument
524 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_has_parent()
530 KUNIT_EXPECT_TRUE(test, clk_has_parent(clk, parent)); in clk_test_multiple_parents_mux_has_parent()
534 KUNIT_EXPECT_TRUE(test, clk_has_parent(clk, parent)); in clk_test_multiple_parents_mux_has_parent()
541 * Test that for a clock with a multiple parents, if we set a range on
550 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
552 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
554 struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
559 kunit_skip(test, "This needs to be fixed in the core."); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
561 parent1 = clk_hw_get_clk_kunit(test, &ctx->parents_ctx[0].hw, NULL); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
562 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent1); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
563 KUNIT_ASSERT_TRUE(test, clk_is_match(clk_get_parent(clk), parent1)); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
565 parent2 = clk_hw_get_clk_kunit(test, &ctx->parents_ctx[1].hw, NULL); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
566 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent2); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
569 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
572 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
577 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
580 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
583 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
584 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 - 1000); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
585 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
596 * Test suite for a basic mux clock with two parents, with
604 .name = "clk-multiple-parents-mux-test",
610 clk_orphan_transparent_multiple_parent_mux_test_init(struct kunit *test) in clk_orphan_transparent_multiple_parent_mux_test_init() argument
616 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_orphan_transparent_multiple_parent_mux_test_init()
619 test->priv = ctx; in clk_orphan_transparent_multiple_parent_mux_test_init()
625 ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[1].hw); in clk_orphan_transparent_multiple_parent_mux_test_init()
629 ctx->hw.init = CLK_HW_INIT_PARENTS("test-orphan-mux", parents, in clk_orphan_transparent_multiple_parent_mux_test_init()
632 ret = clk_hw_register_kunit(test, NULL, &ctx->hw); in clk_orphan_transparent_multiple_parent_mux_test_init()
640 * Test that, for a mux whose current parent hasn't been registered yet and is
644 clk_test_orphan_transparent_multiple_parent_mux_get_parent(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_get_parent() argument
646 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_get_parent()
650 KUNIT_EXPECT_PTR_EQ(test, clk_get_parent(clk), NULL); in clk_test_orphan_transparent_multiple_parent_mux_get_parent()
656 * Test that, for a mux whose current parent hasn't been registered yet,
661 clk_test_orphan_transparent_multiple_parent_mux_set_parent(struct kunit *test) in clk_test_orphan_transparent_multiple_parent_mux_set_parent() argument
663 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
670 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
673 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
676 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
677 KUNIT_EXPECT_TRUE(test, clk_is_match(parent, new_parent)); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
684 * Test that, for a mux that started orphan but got switched to a valid
689 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
691 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
699 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
702 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
705 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
708 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
711 KUNIT_ASSERT_GT(test, new_parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
712 KUNIT_EXPECT_EQ(test, parent_rate, new_parent_rate); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
719 * Test that, for a mux that started orphan but got switched to a valid
723 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
725 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
733 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
736 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
739 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
742 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
743 KUNIT_EXPECT_EQ(test, parent_rate, rate); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
750 * Test that, for a mux that started orphan but got switched to a valid
754 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
756 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
762 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
765 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
768 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
771 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
776 KUNIT_ASSERT_GT(test, new_parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
777 KUNIT_EXPECT_EQ(test, parent_rate, new_parent_rate); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
783 * Test that, for a mux that started orphan but got switched to a valid
788 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
790 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
798 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
801 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
804 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
807 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
808 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
809 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
816 * Test that, for a mux that started orphan but got switched to a valid
821 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
823 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
831 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
834 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
837 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
842 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
845 KUNIT_ASSERT_GT(test, new_parent_rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
846 KUNIT_EXPECT_EQ(test, parent_rate, new_parent_rate); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
853 * Test that, for a mux whose current parent hasn't been registered yet,
858 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
860 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
867 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
870 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
871 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
872 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
878 * Test that, for a mux that started orphan, was assigned and rate and
887 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
889 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
891 struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
896 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()
900 parent = clk_hw_get_clk_kunit(test, &ctx->parents_ctx[1].hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
901 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
904 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
907 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
908 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
909 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
926 * Test suite for a basic mux clock with two parents. The default parent
935 .name = "clk-orphan-transparent-multiple-parent-mux-test",
945 static int clk_single_parent_mux_test_init(struct kunit *test) in clk_single_parent_mux_test_init() argument
950 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_single_parent_mux_test_init()
953 test->priv = ctx; in clk_single_parent_mux_test_init()
961 ret = clk_hw_register_kunit(test, NULL, &ctx->parent_ctx.hw); in clk_single_parent_mux_test_init()
965 ctx->hw.init = CLK_HW_INIT("test-clk", "parent-clk", in clk_single_parent_mux_test_init()
969 ret = clk_hw_register_kunit(test, NULL, &ctx->hw); in clk_single_parent_mux_test_init()
977 clk_single_parent_mux_test_exit(struct kunit *test) in clk_single_parent_mux_test_exit() argument
979 struct clk_single_parent_ctx *ctx = test->priv; in clk_single_parent_mux_test_exit()
986 * Test that for a clock with a single parent, clk_get_parent() actually
990 clk_test_single_parent_mux_get_parent(struct kunit *test) in clk_test_single_parent_mux_get_parent() argument
992 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_get_parent()
997 KUNIT_EXPECT_TRUE(test, clk_is_match(clk_get_parent(clk), parent)); in clk_test_single_parent_mux_get_parent()
1004 * Test that for a clock with a single parent, clk_has_parent() actually
1008 clk_test_single_parent_mux_has_parent(struct kunit *test) in clk_test_single_parent_mux_has_parent() argument
1010 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_has_parent()
1015 KUNIT_EXPECT_TRUE(test, clk_has_parent(clk, parent)); in clk_test_single_parent_mux_has_parent()
1022 * Test that for a clock that can't modify its rate and with a single
1031 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
1033 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_disjoint_child_last()
1035 struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1039 kunit_skip(test, "This needs to be fixed in the core."); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1042 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1045 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1048 KUNIT_EXPECT_LT(test, ret, 0); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1052 * Test that for a clock that can't modify its rate and with a single
1061 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
1063 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1065 struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1069 kunit_skip(test, "This needs to be fixed in the core."); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1072 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1075 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1078 KUNIT_EXPECT_LT(test, ret, 0); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1082 * Test that for a clock that can't modify its rate and with a single
1088 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
1090 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1098 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1101 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1104 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1105 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1106 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1112 * Test that for a clock that can't modify its rate and with a single
1118 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
1120 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1128 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1131 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1134 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1137 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1138 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1139 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1142 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1143 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1144 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1150 * Test that for a clock that can't modify its rate and with a single
1156 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
1158 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1166 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1169 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1172 KUNIT_ASSERT_EQ(test, ret, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1175 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1176 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1177 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1180 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1181 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1182 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1199 * Test suite for a basic mux clock with one parent, with
1207 .name = "clk-single-parent-mux-test",
1212 static int clk_orphan_transparent_single_parent_mux_test_init(struct kunit *test) in clk_orphan_transparent_single_parent_mux_test_init() argument
1219 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_orphan_transparent_single_parent_mux_test_init()
1222 test->priv = ctx; in clk_orphan_transparent_single_parent_mux_test_init()
1249 * Test that a mux-only clock, with an initial rate within a range,
1255 static void clk_test_orphan_transparent_parent_mux_set_range(struct kunit *test) in clk_test_orphan_transparent_parent_mux_set_range() argument
1257 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_parent_mux_set_range()
1263 KUNIT_ASSERT_GT(test, rate, 0); in clk_test_orphan_transparent_parent_mux_set_range()
1265 KUNIT_ASSERT_EQ(test, in clk_test_orphan_transparent_parent_mux_set_range()
1272 KUNIT_ASSERT_GT(test, new_rate, 0); in clk_test_orphan_transparent_parent_mux_set_range()
1273 KUNIT_EXPECT_EQ(test, rate, new_rate); in clk_test_orphan_transparent_parent_mux_set_range()
1284 * Test suite for a basic mux clock with one parent. The parent is
1292 .name = "clk-orphan-transparent-single-parent-test",
1305 clk_orphan_two_level_root_last_test_init(struct kunit *test) in clk_orphan_two_level_root_last_test_init() argument
1310 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_orphan_two_level_root_last_test_init()
1313 test->priv = ctx; in clk_orphan_two_level_root_last_test_init()
1325 CLK_HW_INIT("test-clk", "intermediate-parent", in clk_orphan_two_level_root_last_test_init()
1345 clk_orphan_two_level_root_last_test_exit(struct kunit *test) in clk_orphan_two_level_root_last_test_exit() argument
1347 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_exit()
1355 * Test that, for a clock whose parent used to be orphan, clk_get_rate()
1359 clk_orphan_two_level_root_last_test_get_rate(struct kunit *test) in clk_orphan_two_level_root_last_test_get_rate() argument
1361 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_get_rate()
1367 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE); in clk_orphan_two_level_root_last_test_get_rate()
1373 * Test that, for a clock whose parent used to be orphan,
1381 clk_orphan_two_level_root_last_test_set_range(struct kunit *test) in clk_orphan_two_level_root_last_test_set_range() argument
1383 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_set_range()
1392 KUNIT_ASSERT_EQ(test, ret, 0); in clk_orphan_two_level_root_last_test_set_range()
1395 KUNIT_ASSERT_GT(test, rate, 0); in clk_orphan_two_level_root_last_test_set_range()
1396 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE); in clk_orphan_two_level_root_last_test_set_range()
1409 * Test suite for a basic, transparent, clock with a parent that is also
1422 .name = "clk-orphan-two-level-root-last-test",
1429 * Test that clk_set_rate_range won't return an error for a valid range
1433 static void clk_range_test_set_range(struct kunit *test) in clk_range_test_set_range() argument
1435 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range()
1440 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range()
1447 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range()
1448 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range()
1449 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range()
1455 * Test that calling clk_set_rate_range with a minimum rate higher than
1458 static void clk_range_test_set_range_invalid(struct kunit *test) in clk_range_test_set_range_invalid() argument
1460 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_invalid()
1464 KUNIT_EXPECT_LT(test, in clk_range_test_set_range_invalid()
1474 * Test that users can't set multiple, disjoints, range that would be
1477 static void clk_range_test_multiple_disjoints_range(struct kunit *test) in clk_range_test_multiple_disjoints_range() argument
1479 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_disjoints_range()
1484 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_disjoints_range()
1487 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_disjoints_range()
1489 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_disjoints_range()
1493 KUNIT_EXPECT_LT(test, in clk_range_test_multiple_disjoints_range()
1502 * Test that if our clock has some boundaries and we try to round a rate
1505 static void clk_range_test_set_range_round_rate_lower(struct kunit *test) in clk_range_test_set_range_round_rate_lower() argument
1507 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_round_rate_lower()
1512 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_round_rate_lower()
1519 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_round_rate_lower()
1520 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_round_rate_lower()
1521 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_round_rate_lower()
1527 * Test that if our clock has some boundaries and we try to set a rate
1530 static void clk_range_test_set_range_set_rate_lower(struct kunit *test) in clk_range_test_set_range_set_rate_lower() argument
1532 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_rate_lower()
1537 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_rate_lower()
1543 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_rate_lower()
1548 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_set_rate_lower()
1549 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_set_rate_lower()
1550 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_set_rate_lower()
1556 * Test that if our clock has some boundaries and we try to round and
1561 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
1563 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_round_rate_consistent_lower()
1568 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_round_rate_consistent_lower()
1575 KUNIT_ASSERT_GT(test, rounded, 0); in clk_range_test_set_range_set_round_rate_consistent_lower()
1577 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_round_rate_consistent_lower()
1581 KUNIT_EXPECT_EQ(test, rounded, clk_get_rate(clk)); in clk_range_test_set_range_set_round_rate_consistent_lower()
1587 * Test that if our clock has some boundaries and we try to round a rate
1590 static void clk_range_test_set_range_round_rate_higher(struct kunit *test) in clk_range_test_set_range_round_rate_higher() argument
1592 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_round_rate_higher()
1597 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_round_rate_higher()
1604 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_round_rate_higher()
1605 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_round_rate_higher()
1606 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_round_rate_higher()
1612 * Test that if our clock has some boundaries and we try to set a rate
1615 static void clk_range_test_set_range_set_rate_higher(struct kunit *test) in clk_range_test_set_range_set_rate_higher() argument
1617 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_rate_higher()
1622 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_rate_higher()
1628 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_rate_higher()
1633 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_set_rate_higher()
1634 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_set_rate_higher()
1635 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_set_rate_higher()
1641 * Test that if our clock has some boundaries and we try to round and
1646 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
1648 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_round_rate_consistent_higher()
1653 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_round_rate_consistent_higher()
1660 KUNIT_ASSERT_GT(test, rounded, 0); in clk_range_test_set_range_set_round_rate_consistent_higher()
1662 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_set_round_rate_consistent_higher()
1666 KUNIT_EXPECT_EQ(test, rounded, clk_get_rate(clk)); in clk_range_test_set_range_set_round_rate_consistent_higher()
1672 * Test that if our clock has a rate lower than the minimum set by a
1679 static void clk_range_test_set_range_get_rate_raised(struct kunit *test) in clk_range_test_set_range_get_rate_raised() argument
1681 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_get_rate_raised()
1686 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_get_rate_raised()
1690 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_get_rate_raised()
1697 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_get_rate_raised()
1698 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_get_rate_raised()
1704 * Test that if our clock has a rate higher than the maximum set by a
1711 static void clk_range_test_set_range_get_rate_lowered(struct kunit *test) in clk_range_test_set_range_get_rate_lowered() argument
1713 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_get_rate_lowered()
1718 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_get_rate_lowered()
1722 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_get_rate_lowered()
1729 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_get_rate_lowered()
1730 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_get_rate_lowered()
1751 * Test suite for a basic rate clock, without any parent.
1757 .name = "clk-range-test",
1764 * Test that if we have several subsequent calls to
1771 static void clk_range_test_set_range_rate_maximized(struct kunit *test) in clk_range_test_set_range_rate_maximized() argument
1773 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_rate_maximized()
1778 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_maximized()
1782 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_maximized()
1789 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_maximized()
1790 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_rate_maximized()
1792 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_maximized()
1799 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_maximized()
1800 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2 - 1000); in clk_range_test_set_range_rate_maximized()
1802 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_maximized()
1809 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_maximized()
1810 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_set_range_rate_maximized()
1816 * Test that if we have several subsequent calls to
1823 static void clk_range_test_multiple_set_range_rate_maximized(struct kunit *test) in clk_range_test_multiple_set_range_rate_maximized() argument
1825 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_maximized()
1832 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_set_range_rate_maximized()
1835 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_set_range_rate_maximized()
1837 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_maximized()
1841 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_maximized()
1848 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_maximized()
1849 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_maximized()
1851 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_maximized()
1858 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_maximized()
1859 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_maximized()
1861 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_maximized()
1866 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_maximized()
1867 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_maximized()
1875 * Test that if we have several subsequent calls to
1882 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
1884 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_put_maximized()
1891 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_set_range_rate_put_maximized()
1894 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_set_range_rate_put_maximized()
1896 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_maximized()
1900 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_maximized()
1907 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_maximized()
1908 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_put_maximized()
1910 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_maximized()
1917 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_maximized()
1918 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_put_maximized()
1923 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_maximized()
1924 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_put_maximized()
1938 * Test suite for a basic rate clock, without any parent.
1945 .name = "clk-range-maximize-test",
1952 * Test that if we have several subsequent calls to
1959 static void clk_range_test_set_range_rate_minimized(struct kunit *test) in clk_range_test_set_range_rate_minimized() argument
1961 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_rate_minimized()
1966 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_minimized()
1970 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_minimized()
1977 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_minimized()
1978 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_rate_minimized()
1980 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_minimized()
1987 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_minimized()
1988 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1 + 1000); in clk_range_test_set_range_rate_minimized()
1990 KUNIT_ASSERT_EQ(test, in clk_range_test_set_range_rate_minimized()
1997 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_set_range_rate_minimized()
1998 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_set_range_rate_minimized()
2004 * Test that if we have several subsequent calls to
2011 static void clk_range_test_multiple_set_range_rate_minimized(struct kunit *test) in clk_range_test_multiple_set_range_rate_minimized() argument
2013 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_minimized()
2020 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_set_range_rate_minimized()
2023 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_set_range_rate_minimized()
2025 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_minimized()
2032 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_minimized()
2033 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_minimized()
2035 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_minimized()
2042 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_minimized()
2043 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_minimized()
2045 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_minimized()
2050 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_minimized()
2051 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_minimized()
2059 * Test that if we have several subsequent calls to
2066 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
2068 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_put_minimized()
2075 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); in clk_range_test_multiple_set_range_rate_put_minimized()
2078 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); in clk_range_test_multiple_set_range_rate_put_minimized()
2080 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_minimized()
2087 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_minimized()
2088 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_put_minimized()
2090 KUNIT_ASSERT_EQ(test, in clk_range_test_multiple_set_range_rate_put_minimized()
2097 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_minimized()
2098 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); in clk_range_test_multiple_set_range_rate_put_minimized()
2103 KUNIT_ASSERT_GT(test, rate, 0); in clk_range_test_multiple_set_range_rate_put_minimized()
2104 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in clk_range_test_multiple_set_range_rate_put_minimized()
2118 * Test suite for a basic rate clock, without any parent.
2125 .name = "clk-range-minimize-test",
2162 clk_leaf_mux_set_rate_parent_test_init(struct kunit *test) in clk_leaf_mux_set_rate_parent_test_init() argument
2168 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_leaf_mux_set_rate_parent_test_init()
2171 test->priv = ctx; in clk_leaf_mux_set_rate_parent_test_init()
2190 ctx->mux_ctx.hw.init = CLK_HW_INIT_PARENTS("test-mux", top_parents, in clk_leaf_mux_set_rate_parent_test_init()
2197 ctx->parent.init = CLK_HW_INIT_HW("test-parent", &ctx->mux_ctx.hw, in clk_leaf_mux_set_rate_parent_test_init()
2203 ctx->hw.init = CLK_HW_INIT_HW("test-clock", &ctx->parent, in clk_leaf_mux_set_rate_parent_test_init()
2213 static void clk_leaf_mux_set_rate_parent_test_exit(struct kunit *test) in clk_leaf_mux_set_rate_parent_test_exit() argument
2215 struct clk_leaf_mux_ctx *ctx = test->priv; in clk_leaf_mux_set_rate_parent_test_exit()
2240 * Test that __clk_determine_rate() on the parent that can't
2249 * Test that __clk_mux_determine_rate() on the parent that
2259 * Test that __clk_mux_determine_rate_closest() on the parent
2269 * Test that clk_hw_determine_rate_no_reparent() on the parent
2284 * Test that when a clk that can't change rate itself calls a function like in KUNIT_ARRAY_PARAM()
2290 static void clk_leaf_mux_set_rate_parent_determine_rate_test(struct kunit *test) in KUNIT_ARRAY_PARAM()
2292 struct clk_leaf_mux_ctx *ctx = test->priv; in KUNIT_ARRAY_PARAM()
2299 test_param = test->param_value; in KUNIT_ARRAY_PARAM()
2304 KUNIT_ASSERT_EQ(test, rate, DUMMY_CLOCK_RATE_1); in KUNIT_ARRAY_PARAM()
2305 KUNIT_ASSERT_EQ(test, DUMMY_CLOCK_RATE_2, clk_round_rate(clk, DUMMY_CLOCK_RATE_2)); in KUNIT_ARRAY_PARAM()
2307 KUNIT_EXPECT_EQ(test, req.rate, DUMMY_CLOCK_RATE_2); in KUNIT_ARRAY_PARAM()
2308 KUNIT_EXPECT_EQ(test, req.best_parent_rate, DUMMY_CLOCK_RATE_2); in KUNIT_ARRAY_PARAM()
2309 KUNIT_EXPECT_PTR_EQ(test, req.best_parent_hw, &ctx->mux_ctx.hw); in KUNIT_ARRAY_PARAM()
2321 * Test suite for a clock whose parent is a pass-through clk whose parent is a
2378 static int clk_mux_notifier_test_init(struct kunit *test) in clk_mux_notifier_test_init() argument
2384 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_mux_notifier_test_init()
2387 test->priv = ctx; in clk_mux_notifier_test_init()
2409 ctx->mux_ctx.hw.init = CLK_HW_INIT_PARENTS("test-mux", top_parents, in clk_mux_notifier_test_init()
2424 static void clk_mux_notifier_test_exit(struct kunit *test) in clk_mux_notifier_test_exit() argument
2426 struct clk_mux_notifier_ctx *ctx = test->priv; in clk_mux_notifier_test_exit()
2438 * Test that if the we have a notifier registered on a mux, the core
2442 static void clk_mux_notifier_set_parent_test(struct kunit *test) in clk_mux_notifier_set_parent_test() argument
2444 struct clk_mux_notifier_ctx *ctx = test->priv; in clk_mux_notifier_set_parent_test()
2451 KUNIT_ASSERT_EQ(test, ret, 0); in clk_mux_notifier_set_parent_test()
2456 KUNIT_ASSERT_GT(test, ret, 0); in clk_mux_notifier_set_parent_test()
2458 KUNIT_EXPECT_EQ(test, ctx->pre_rate_change.old_rate, DUMMY_CLOCK_RATE_1); in clk_mux_notifier_set_parent_test()
2459 KUNIT_EXPECT_EQ(test, ctx->pre_rate_change.new_rate, DUMMY_CLOCK_RATE_2); in clk_mux_notifier_set_parent_test()
2464 KUNIT_ASSERT_GT(test, ret, 0); in clk_mux_notifier_set_parent_test()
2466 KUNIT_EXPECT_EQ(test, ctx->post_rate_change.old_rate, DUMMY_CLOCK_RATE_1); in clk_mux_notifier_set_parent_test()
2467 KUNIT_EXPECT_EQ(test, ctx->post_rate_change.new_rate, DUMMY_CLOCK_RATE_2); in clk_mux_notifier_set_parent_test()
2479 * Test suite for a mux with multiple parents, and a notifier registered
2492 clk_mux_no_reparent_test_init(struct kunit *test) in clk_mux_no_reparent_test_init() argument
2498 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_mux_no_reparent_test_init()
2501 test->priv = ctx; in clk_mux_no_reparent_test_init()
2520 ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents, in clk_mux_no_reparent_test_init()
2531 clk_mux_no_reparent_test_exit(struct kunit *test) in clk_mux_no_reparent_test_exit() argument
2533 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_test_exit()
2541 * Test that if the we have a mux that cannot change parent and we call
2545 static void clk_mux_no_reparent_round_rate(struct kunit *test) in clk_mux_no_reparent_round_rate() argument
2547 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_round_rate()
2556 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_mux_no_reparent_round_rate()
2559 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_mux_no_reparent_round_rate()
2562 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, other_parent); in clk_mux_no_reparent_round_rate()
2563 KUNIT_ASSERT_FALSE(test, clk_is_match(parent, other_parent)); in clk_mux_no_reparent_round_rate()
2566 KUNIT_ASSERT_GT(test, other_parent_rate, 0); in clk_mux_no_reparent_round_rate()
2570 KUNIT_ASSERT_GT(test, rounded_rate, 0); in clk_mux_no_reparent_round_rate()
2571 KUNIT_EXPECT_EQ(test, rounded_rate, parent_rate); in clk_mux_no_reparent_round_rate()
2577 * Test that if the we have a mux that cannot change parent and we call
2581 static void clk_mux_no_reparent_set_rate(struct kunit *test) in clk_mux_no_reparent_set_rate() argument
2583 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_set_rate()
2593 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_mux_no_reparent_set_rate()
2596 KUNIT_ASSERT_GT(test, parent_rate, 0); in clk_mux_no_reparent_set_rate()
2599 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, other_parent); in clk_mux_no_reparent_set_rate()
2600 KUNIT_ASSERT_FALSE(test, clk_is_match(parent, other_parent)); in clk_mux_no_reparent_set_rate()
2603 KUNIT_ASSERT_GT(test, other_parent_rate, 0); in clk_mux_no_reparent_set_rate()
2607 KUNIT_ASSERT_EQ(test, ret, 0); in clk_mux_no_reparent_set_rate()
2610 KUNIT_ASSERT_GT(test, rate, 0); in clk_mux_no_reparent_set_rate()
2611 KUNIT_EXPECT_EQ(test, rate, parent_rate); in clk_mux_no_reparent_set_rate()
2623 * Test suite for a clock mux that isn't allowed to change parent, using
2652 * Test that a clk registered with a struct device_node can
2660 * Test that a clk registered with a struct device_node can
2668 * Test that a clk registered with a struct device_node can
2678 * Test that a clk registered with a struct device_node can
2688 * Test that a clk registered with a struct device_node can
2698 * Test that a clk registered with a struct device_node can
2715 * @np: device node of clk under test
2716 * @hw: clk_hw for clk under test
2723 static int clk_register_clk_parent_data_of_test_init(struct kunit *test) in clk_register_clk_parent_data_of_test_init() argument
2727 KUNIT_ASSERT_EQ(test, 0, in clk_register_clk_parent_data_of_test_init()
2728 of_overlay_apply_kunit(test, kunit_clk_parent_data_test)); in clk_register_clk_parent_data_of_test_init()
2730 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_register_clk_parent_data_of_test_init()
2733 test->priv = ctx; in clk_register_clk_parent_data_of_test_init()
2735 ctx->np = of_find_compatible_node(NULL, NULL, "test,clk-parent-data"); in clk_register_clk_parent_data_of_test_init()
2739 of_node_put_kunit(test, ctx->np); in clk_register_clk_parent_data_of_test_init()
2745 * Test that a clk registered with a struct device_node can find a parent based on
2748 static void clk_register_clk_parent_data_of_test(struct kunit *test) in clk_register_clk_parent_data_of_test() argument
2750 struct clk_register_clk_parent_data_of_ctx *ctx = test->priv; in clk_register_clk_parent_data_of_test()
2756 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->np); in clk_register_clk_parent_data_of_test()
2758 expected_parent = of_clk_get_kunit(test, ctx->np, 0); in clk_register_clk_parent_data_of_test()
2759 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, expected_parent); in clk_register_clk_parent_data_of_test()
2761 test_param = test->param_value; in clk_register_clk_parent_data_of_test()
2767 KUNIT_ASSERT_EQ(test, 0, of_clk_hw_register_kunit(test, ctx->np, &ctx->hw)); in clk_register_clk_parent_data_of_test()
2770 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent_hw); in clk_register_clk_parent_data_of_test()
2772 actual_parent = clk_hw_get_clk_kunit(test, parent_hw, __func__); in clk_register_clk_parent_data_of_test()
2773 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, actual_parent); in clk_register_clk_parent_data_of_test()
2775 KUNIT_EXPECT_TRUE(test, clk_is_match(expected_parent, actual_parent)); in clk_register_clk_parent_data_of_test()
2785 * Test suite for registering clks with struct clk_parent_data and a struct
2796 * @dev: device of clk under test
2797 * @hw: clk_hw for clk under test
2823 static void clk_register_clk_parent_data_device_driver(struct kunit *test) in clk_register_clk_parent_data_device_driver() argument
2825 struct clk_register_clk_parent_data_device_ctx *ctx = test->priv; in clk_register_clk_parent_data_device_driver()
2827 { .compatible = "test,clk-parent-data" }, in clk_register_clk_parent_data_device_driver()
2836 KUNIT_ASSERT_EQ(test, 0, kunit_platform_driver_register(test, &ctx->pdrv)); in clk_register_clk_parent_data_device_driver()
2837 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->dev); in clk_register_clk_parent_data_device_driver()
2844 * Test that a clk registered with a struct device can find a
2852 * Test that a clk registered with a struct device can find a
2860 * Test that a clk registered with a struct device can find a
2870 * Test that a clk registered with a struct device can find a
2879 * Test that a clk registered with a struct device can find a
2889 * Test that a clk registered with a struct device can find a
2905 * Test that a clk registered with a struct device can find a parent based on in KUNIT_ARRAY_PARAM()
2908 static void clk_register_clk_parent_data_device_test(struct kunit *test) in KUNIT_ARRAY_PARAM()
2916 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in KUNIT_ARRAY_PARAM()
2917 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); in KUNIT_ARRAY_PARAM()
2918 test->priv = ctx; in KUNIT_ARRAY_PARAM()
2920 clk_register_clk_parent_data_device_driver(test); in KUNIT_ARRAY_PARAM()
2922 expected_parent = clk_get_kunit(test, ctx->dev, "50"); in KUNIT_ARRAY_PARAM()
2923 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, expected_parent); in KUNIT_ARRAY_PARAM()
2925 test_param = test->param_value; in KUNIT_ARRAY_PARAM()
2931 KUNIT_ASSERT_EQ(test, 0, clk_hw_register_kunit(test, ctx->dev, &ctx->hw)); in KUNIT_ARRAY_PARAM()
2934 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent_hw); in KUNIT_ARRAY_PARAM()
2936 actual_parent = clk_hw_get_clk_kunit(test, parent_hw, __func__); in KUNIT_ARRAY_PARAM()
2937 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, actual_parent); in KUNIT_ARRAY_PARAM()
2939 KUNIT_EXPECT_TRUE(test, clk_is_match(expected_parent, actual_parent)); in KUNIT_ARRAY_PARAM()
2946 * Test that a clk registered with a struct device can find a
2955 * Test that a clk registered with a struct device can find a
2964 * Test that a clk registered with a struct device can find a
2975 * Test that a clk registered with a struct device can find a
2985 * Test that a clk registered with a struct device can find a
2995 * Test that a clk registered with a struct device can find a
3012 * Test that a clk registered with a struct device can find a in KUNIT_ARRAY_PARAM()
3015 static void clk_register_clk_parent_data_device_hw_test(struct kunit *test) in KUNIT_ARRAY_PARAM()
3024 ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in KUNIT_ARRAY_PARAM()
3025 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); in KUNIT_ARRAY_PARAM()
3026 test->priv = ctx; in KUNIT_ARRAY_PARAM()
3028 clk_register_clk_parent_data_device_driver(test); in KUNIT_ARRAY_PARAM()
3030 parent = kunit_kzalloc(test, sizeof(*parent), GFP_KERNEL); in KUNIT_ARRAY_PARAM()
3031 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in KUNIT_ARRAY_PARAM()
3037 KUNIT_ASSERT_EQ(test, 0, clk_hw_register_kunit(test, ctx->dev, parent_hw)); in KUNIT_ARRAY_PARAM()
3039 test_param = test->param_value; in KUNIT_ARRAY_PARAM()
3047 KUNIT_ASSERT_EQ(test, 0, clk_hw_register_kunit(test, ctx->dev, &ctx->hw)); in KUNIT_ARRAY_PARAM()
3049 KUNIT_EXPECT_PTR_EQ(test, parent_hw, clk_hw_get_parent(&ctx->hw)); in KUNIT_ARRAY_PARAM()
3060 static int clk_register_clk_parent_data_device_init(struct kunit *test) in clk_register_clk_parent_data_device_init() argument
3062 KUNIT_ASSERT_EQ(test, 0, in clk_register_clk_parent_data_device_init()
3063 of_overlay_apply_kunit(test, kunit_clk_parent_data_test)); in clk_register_clk_parent_data_device_init()
3069 * Test suite for registering clks with struct clk_parent_data and a struct