Lines Matching +full:parent +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0
3 * Kunit test for clk rate management
5 #include <linux/clk.h>
6 #include <linux/clk-provider.h>
9 #include "clk.h"
28 return ctx->rate; in clk_dummy_recalc_rate()
45 if (req->max_rate < ULONG_MAX) in clk_dummy_maximize_rate()
46 req->rate = req->max_rate; in clk_dummy_maximize_rate()
58 if (req->min_rate > 0) in clk_dummy_minimize_rate()
59 req->rate = req->min_rate; in clk_dummy_minimize_rate()
71 ctx->rate = rate; in clk_dummy_set_rate()
78 return -EINVAL; in clk_dummy_single_set_parent()
111 * what all the parents can provide, it will return -EINVAL.
119 * between rates above the parent rate which would be rounded to
120 * what the parent can provide, but rates below will simply
140 return -EINVAL; in clk_multiple_parents_mux_set_parent()
142 ctx->current_parent = index; in clk_multiple_parents_mux_set_parent()
152 return ctx->current_parent; in clk_multiple_parents_mux_get_parent()
175 return -ENOMEM; in clk_test_init_with_ops()
176 ctx->rate = DUMMY_CLOCK_INIT_RATE; in clk_test_init_with_ops()
177 test->priv = ctx; in clk_test_init_with_ops()
181 ctx->hw.init = &init; in clk_test_init_with_ops()
183 ret = clk_hw_register(NULL, &ctx->hw); in clk_test_init_with_ops()
207 struct clk_dummy_context *ctx = test->priv; in clk_test_exit()
209 clk_hw_unregister(&ctx->hw); in clk_test_exit()
217 struct clk_dummy_context *ctx = test->priv; in clk_test_get_rate()
218 struct clk_hw *hw = &ctx->hw; in clk_test_get_rate()
219 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_get_rate() local
222 rate = clk_get_rate(clk); in clk_test_get_rate()
224 KUNIT_EXPECT_EQ(test, rate, ctx->rate); in clk_test_get_rate()
226 clk_put(clk); in clk_test_get_rate()
238 struct clk_dummy_context *ctx = test->priv; in clk_test_set_get_rate()
239 struct clk_hw *hw = &ctx->hw; in clk_test_set_get_rate()
240 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_set_get_rate() local
244 clk_set_rate(clk, DUMMY_CLOCK_RATE_1), in clk_test_set_get_rate()
247 rate = clk_get_rate(clk); in clk_test_set_get_rate()
251 clk_put(clk); in clk_test_set_get_rate()
263 struct clk_dummy_context *ctx = test->priv; in clk_test_set_set_get_rate()
264 struct clk_hw *hw = &ctx->hw; in clk_test_set_set_get_rate()
265 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_set_set_get_rate() local
269 clk_set_rate(clk, DUMMY_CLOCK_RATE_1), in clk_test_set_set_get_rate()
273 clk_set_rate(clk, DUMMY_CLOCK_RATE_2), in clk_test_set_set_get_rate()
276 rate = clk_get_rate(clk); in clk_test_set_set_get_rate()
280 clk_put(clk); in clk_test_set_set_get_rate()
289 struct clk_dummy_context *ctx = test->priv; in clk_test_round_set_get_rate()
290 struct clk_hw *hw = &ctx->hw; in clk_test_round_set_get_rate()
291 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_round_set_get_rate() local
295 rounded_rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1); in clk_test_round_set_get_rate()
300 clk_set_rate(clk, DUMMY_CLOCK_RATE_1), in clk_test_round_set_get_rate()
303 set_rate = clk_get_rate(clk); in clk_test_round_set_get_rate()
307 clk_put(clk); in clk_test_round_set_get_rate()
319 * Test suite for a basic rate clock, without any parent.
324 .name = "clk-test",
337 return -ENOMEM; in clk_uncached_test_init()
338 test->priv = ctx; in clk_uncached_test_init()
340 ctx->rate = DUMMY_CLOCK_INIT_RATE; in clk_uncached_test_init()
341 ctx->hw.init = CLK_HW_INIT_NO_PARENT("test-clk", in clk_uncached_test_init()
345 ret = clk_hw_register(NULL, &ctx->hw); in clk_uncached_test_init()
359 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_get_rate()
360 struct clk_hw *hw = &ctx->hw; in clk_test_uncached_get_rate()
361 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_uncached_get_rate() local
364 rate = clk_get_rate(clk); in clk_test_uncached_get_rate()
369 ctx->rate = DUMMY_CLOCK_RATE_1; in clk_test_uncached_get_rate()
370 rate = clk_get_rate(clk); in clk_test_uncached_get_rate()
374 clk_put(clk); in clk_test_uncached_get_rate()
383 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_set_range()
384 struct clk_hw *hw = &ctx->hw; in clk_test_uncached_set_range()
385 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_uncached_set_range() local
389 clk_set_rate_range(clk, in clk_test_uncached_set_range()
394 rate = clk_get_rate(clk); in clk_test_uncached_set_range()
399 clk_put(clk); in clk_test_uncached_set_range()
412 struct clk_dummy_context *ctx = test->priv; in clk_test_uncached_updated_rate_set_range()
413 struct clk_hw *hw = &ctx->hw; in clk_test_uncached_updated_rate_set_range()
414 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_uncached_updated_rate_set_range() local
418 ctx->rate = DUMMY_CLOCK_RATE_1 + 1000; in clk_test_uncached_updated_rate_set_range()
420 clk_set_rate_range(clk, in clk_test_uncached_updated_rate_set_range()
425 rate = clk_get_rate(clk); in clk_test_uncached_updated_rate_set_range()
429 clk_put(clk); 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",
455 const char *parents[2] = { "parent-0", "parent-1"}; in clk_multiple_parents_mux_test_init()
460 return -ENOMEM; in clk_multiple_parents_mux_test_init()
461 test->priv = ctx; in clk_multiple_parents_mux_test_init()
463 ctx->parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0", in clk_multiple_parents_mux_test_init()
466 ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; in clk_multiple_parents_mux_test_init()
467 ret = clk_hw_register(NULL, &ctx->parents_ctx[0].hw); in clk_multiple_parents_mux_test_init()
471 ctx->parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1", in clk_multiple_parents_mux_test_init()
474 ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; in clk_multiple_parents_mux_test_init()
475 ret = clk_hw_register(NULL, &ctx->parents_ctx[1].hw); in clk_multiple_parents_mux_test_init()
479 ctx->current_parent = 0; 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()
483 ret = clk_hw_register(NULL, &ctx->hw); in clk_multiple_parents_mux_test_init()
493 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_multiple_parents_mux_test_exit()
495 clk_hw_unregister(&ctx->hw); in clk_multiple_parents_mux_test_exit()
496 clk_hw_unregister(&ctx->parents_ctx[0].hw); in clk_multiple_parents_mux_test_exit()
497 clk_hw_unregister(&ctx->parents_ctx[1].hw); in clk_multiple_parents_mux_test_exit()
507 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_get_parent()
508 struct clk_hw *hw = &ctx->hw; in clk_test_multiple_parents_mux_get_parent()
509 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_multiple_parents_mux_get_parent() local
510 struct clk *parent = clk_hw_get_clk(&ctx->parents_ctx[0].hw, NULL); in clk_test_multiple_parents_mux_get_parent() local
512 KUNIT_EXPECT_TRUE(test, clk_is_match(clk_get_parent(clk), parent)); in clk_test_multiple_parents_mux_get_parent()
514 clk_put(parent); in clk_test_multiple_parents_mux_get_parent()
515 clk_put(clk); in clk_test_multiple_parents_mux_get_parent()
525 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_has_parent()
526 struct clk_hw *hw = &ctx->hw; in clk_test_multiple_parents_mux_has_parent()
527 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_multiple_parents_mux_has_parent() local
528 struct clk *parent; in clk_test_multiple_parents_mux_has_parent() local
530 parent = clk_hw_get_clk(&ctx->parents_ctx[0].hw, NULL); 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()
532 clk_put(parent); in clk_test_multiple_parents_mux_has_parent()
534 parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
536 clk_put(parent); in clk_test_multiple_parents_mux_has_parent()
538 clk_put(clk); in clk_test_multiple_parents_mux_has_parent()
543 * that clock and the parent is changed, its rate after the reparenting
553 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
554 struct clk_hw *hw = &ctx->hw; in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
555 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate() local
556 struct clk *parent1, *parent2; in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
562 parent1 = clk_hw_get_clk(&ctx->parents_ctx[0].hw, NULL); 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()
566 parent2 = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
575 ret = clk_set_rate_range(clk, in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
576 DUMMY_CLOCK_RATE_1 - 1000, in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
580 ret = clk_set_parent(clk, parent2); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
583 rate = clk_get_rate(clk); 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()
590 clk_put(clk); in clk_test_multiple_parents_mux_set_range_set_parent_get_rate()
609 .name = "clk-multiple-parents-mux-test",
619 const char *parents[2] = { "missing-parent", "proper-parent"}; in clk_orphan_transparent_multiple_parent_mux_test_init()
624 return -ENOMEM; in clk_orphan_transparent_multiple_parent_mux_test_init()
625 test->priv = ctx; in clk_orphan_transparent_multiple_parent_mux_test_init()
627 ctx->parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("proper-parent", in clk_orphan_transparent_multiple_parent_mux_test_init()
630 ctx->parents_ctx[1].rate = DUMMY_CLOCK_INIT_RATE; in clk_orphan_transparent_multiple_parent_mux_test_init()
631 ret = clk_hw_register(NULL, &ctx->parents_ctx[1].hw); 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()
638 ret = clk_hw_register(NULL, &ctx->hw); in clk_orphan_transparent_multiple_parent_mux_test_init()
648 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_orphan_transparent_multiple_parent_mux_test_exit()
650 clk_hw_unregister(&ctx->hw); in clk_orphan_transparent_multiple_parent_mux_test_exit()
651 clk_hw_unregister(&ctx->parents_ctx[1].hw); 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
661 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_get_parent()
662 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_multiple_parent_mux_get_parent()
663 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_get_parent() local
665 KUNIT_EXPECT_PTR_EQ(test, clk_get_parent(clk), NULL); in clk_test_orphan_transparent_multiple_parent_mux_get_parent()
667 clk_put(clk); in clk_test_orphan_transparent_multiple_parent_mux_get_parent()
671 * Test that, for a mux whose current parent hasn't been registered yet,
672 * calling clk_set_parent() to a valid parent will properly update the
673 * mux parent and its orphan status.
678 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
679 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
680 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_parent() local
681 struct clk *parent, *new_parent; in clk_test_orphan_transparent_multiple_parent_mux_set_parent() local
684 parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
687 ret = clk_set_parent(clk, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
690 new_parent = clk_get_parent(clk); 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()
694 clk_put(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
695 clk_put(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent()
700 * parent, calling clk_drop_range() on the mux won't affect the parent
706 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
707 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
708 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range() local
709 struct clk *parent; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range() local
713 parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
716 parent_rate = clk_get_rate(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
719 ret = clk_set_parent(clk, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
722 ret = clk_drop_range(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
725 new_parent_rate = clk_get_rate(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
729 clk_put(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
730 clk_put(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range()
735 * parent, the rate of the mux and its new parent are consistent.
740 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
741 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
742 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate() local
743 struct clk *parent; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate() local
747 parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
750 parent_rate = clk_get_rate(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
753 ret = clk_set_parent(clk, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
756 rate = clk_get_rate(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
760 clk_put(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
761 clk_put(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate()
766 * parent, calling clk_put() on the mux won't affect the parent rate.
771 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
772 struct clk *clk, *parent; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put() local
776 parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
779 clk = clk_hw_get_clk(&ctx->hw, NULL); 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()
782 parent_rate = clk_get_rate(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
785 ret = clk_set_parent(clk, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
788 clk_put(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
790 new_parent_rate = clk_get_rate(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
794 clk_put(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_put()
799 * parent, calling clk_set_rate_range() will affect the parent state if
805 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
806 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
807 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified() local
808 struct clk *parent; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified() local
812 parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
815 ret = clk_set_parent(clk, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
818 ret = clk_set_rate_range(clk, DUMMY_CLOCK_RATE_1, DUMMY_CLOCK_RATE_2); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
821 rate = clk_get_rate(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
826 clk_put(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
827 clk_put(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified()
832 * parent, calling clk_set_rate_range() won't affect the parent state if
838 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
839 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
840 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched() local
841 struct clk *parent; in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched() local
845 parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
848 parent_rate = clk_get_rate(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
851 ret = clk_set_parent(clk, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
854 ret = clk_set_rate_range(clk, in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
855 DUMMY_CLOCK_INIT_RATE - 1000, in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
859 new_parent_rate = clk_get_rate(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
863 clk_put(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched()
864 clk_put(clk); 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,
875 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
876 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
877 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate() local
881 ret = clk_set_rate_range(clk, DUMMY_CLOCK_RATE_1, DUMMY_CLOCK_RATE_2); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
884 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
889 clk_put(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate()
894 * then got switched to a valid parent, its rate is eventually within
904 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
905 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
906 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate() local
907 struct clk *parent; in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate() local
915 parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
918 ret = clk_set_parent(clk, parent); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
921 rate = clk_get_rate(clk); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
926 clk_put(parent); in clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate()
927 clk_put(clk); 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
945 * isn't registered, only the second parent is. By default, the clock
950 * parent.
953 .name = "clk-orphan-transparent-multiple-parent-mux-test",
971 return -ENOMEM; in clk_single_parent_mux_test_init()
972 test->priv = ctx; in clk_single_parent_mux_test_init()
974 ctx->parent_ctx.rate = DUMMY_CLOCK_INIT_RATE; in clk_single_parent_mux_test_init()
975 ctx->parent_ctx.hw.init = in clk_single_parent_mux_test_init()
976 CLK_HW_INIT_NO_PARENT("parent-clk", in clk_single_parent_mux_test_init()
980 ret = clk_hw_register(NULL, &ctx->parent_ctx.hw); 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()
988 ret = clk_hw_register(NULL, &ctx->hw); in clk_single_parent_mux_test_init()
998 struct clk_single_parent_ctx *ctx = test->priv; in clk_single_parent_mux_test_exit()
1000 clk_hw_unregister(&ctx->hw); in clk_single_parent_mux_test_exit()
1001 clk_hw_unregister(&ctx->parent_ctx.hw); in clk_single_parent_mux_test_exit()
1005 * Test that for a clock with a single parent, clk_get_parent() actually
1006 * returns the parent.
1011 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_get_parent()
1012 struct clk_hw *hw = &ctx->hw; in clk_test_single_parent_mux_get_parent()
1013 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_single_parent_mux_get_parent() local
1014 struct clk *parent = clk_hw_get_clk(&ctx->parent_ctx.hw, NULL); in clk_test_single_parent_mux_get_parent() local
1016 KUNIT_EXPECT_TRUE(test, clk_is_match(clk_get_parent(clk), parent)); in clk_test_single_parent_mux_get_parent()
1018 clk_put(parent); in clk_test_single_parent_mux_get_parent()
1019 clk_put(clk); in clk_test_single_parent_mux_get_parent()
1023 * Test that for a clock with a single parent, clk_has_parent() actually
1024 * reports it as a parent.
1029 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_has_parent()
1030 struct clk_hw *hw = &ctx->hw; in clk_test_single_parent_mux_has_parent()
1031 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_single_parent_mux_has_parent() local
1032 struct clk *parent = clk_hw_get_clk(&ctx->parent_ctx.hw, NULL); in clk_test_single_parent_mux_has_parent() local
1034 KUNIT_EXPECT_TRUE(test, clk_has_parent(clk, parent)); in clk_test_single_parent_mux_has_parent()
1036 clk_put(parent); in clk_test_single_parent_mux_has_parent()
1037 clk_put(clk); in clk_test_single_parent_mux_has_parent()
1042 * parent, if we set disjoints range on the parent and then the child,
1052 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_disjoint_child_last()
1053 struct clk_hw *hw = &ctx->hw; in clk_test_single_parent_mux_set_range_disjoint_child_last()
1054 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_single_parent_mux_set_range_disjoint_child_last() local
1055 struct clk *parent; in clk_test_single_parent_mux_set_range_disjoint_child_last() local
1060 parent = clk_get_parent(clk); 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()
1063 ret = clk_set_rate_range(parent, 1000, 2000); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1066 ret = clk_set_rate_range(clk, 3000, 4000); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1069 clk_put(clk); in clk_test_single_parent_mux_set_range_disjoint_child_last()
1074 * parent, if we set disjoints range on the child and then the parent,
1084 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1085 struct clk_hw *hw = &ctx->hw; in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1086 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_single_parent_mux_set_range_disjoint_parent_last() local
1087 struct clk *parent; in clk_test_single_parent_mux_set_range_disjoint_parent_last() local
1092 parent = clk_get_parent(clk); 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()
1095 ret = clk_set_rate_range(clk, 1000, 2000); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1098 ret = clk_set_rate_range(parent, 3000, 4000); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1101 clk_put(clk); in clk_test_single_parent_mux_set_range_disjoint_parent_last()
1106 * parent, if we set a range on the parent and then call
1107 * clk_round_rate(), the boundaries of the parent are taken into
1113 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1114 struct clk_hw *hw = &ctx->hw; in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1115 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_single_parent_mux_set_range_round_rate_parent_only() local
1116 struct clk *parent; in clk_test_single_parent_mux_set_range_round_rate_parent_only() local
1120 parent = clk_get_parent(clk); 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()
1123 ret = clk_set_rate_range(parent, DUMMY_CLOCK_RATE_1, DUMMY_CLOCK_RATE_2); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1126 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1131 clk_put(clk); in clk_test_single_parent_mux_set_range_round_rate_parent_only()
1136 * parent, if we set a range on the parent and a more restrictive one on
1143 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1144 struct clk_hw *hw = &ctx->hw; in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1145 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_single_parent_mux_set_range_round_rate_child_smaller() local
1146 struct clk *parent; in clk_test_single_parent_mux_set_range_round_rate_child_smaller() local
1150 parent = clk_get_parent(clk); 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()
1153 ret = clk_set_rate_range(parent, DUMMY_CLOCK_RATE_1, DUMMY_CLOCK_RATE_2); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1156 ret = clk_set_rate_range(clk, DUMMY_CLOCK_RATE_1 + 1000, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1159 rate = clk_round_rate(clk, 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()
1164 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_2 + 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()
1169 clk_put(clk); in clk_test_single_parent_mux_set_range_round_rate_child_smaller()
1174 * parent, if we set a range on the child and a more restrictive one on
1175 * the parent, and then call clk_round_rate(), the boundaries of the
1181 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1182 struct clk_hw *hw = &ctx->hw; in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1183 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller() local
1184 struct clk *parent; in clk_test_single_parent_mux_set_range_round_rate_parent_smaller() local
1188 parent = clk_get_parent(clk); 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()
1191 ret = clk_set_rate_range(parent, DUMMY_CLOCK_RATE_1 + 1000, DUMMY_CLOCK_RATE_2 - 1000); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1194 ret = clk_set_rate_range(clk, DUMMY_CLOCK_RATE_1, DUMMY_CLOCK_RATE_2); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1197 rate = clk_round_rate(clk, 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()
1202 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_2 + 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()
1207 clk_put(clk); in clk_test_single_parent_mux_set_range_round_rate_parent_smaller()
1222 * Test suite for a basic mux clock with one parent, with
1226 * child and parent are sane and consistent.
1230 .name = "clk-single-parent-mux-test",
1245 return -ENOMEM; in clk_orphan_transparent_single_parent_mux_test_init()
1246 test->priv = ctx; in clk_orphan_transparent_single_parent_mux_test_init()
1253 ctx->hw.init = &init; in clk_orphan_transparent_single_parent_mux_test_init()
1255 ret = clk_hw_register(NULL, &ctx->hw); in clk_orphan_transparent_single_parent_mux_test_init()
1262 ctx->parent_ctx.hw.init = &init; in clk_orphan_transparent_single_parent_mux_test_init()
1263 ctx->parent_ctx.rate = DUMMY_CLOCK_INIT_RATE; in clk_orphan_transparent_single_parent_mux_test_init()
1265 ret = clk_hw_register(NULL, &ctx->parent_ctx.hw); in clk_orphan_transparent_single_parent_mux_test_init()
1273 * Test that a mux-only clock, with an initial rate within a range,
1277 * https://lore.kernel.org/linux-clk/7720158d-10a7-a17b-73a4-a8615c9c6d5c@collabora.com/
1281 struct clk_single_parent_ctx *ctx = test->priv; in clk_test_orphan_transparent_parent_mux_set_range()
1282 struct clk_hw *hw = &ctx->hw; in clk_test_orphan_transparent_parent_mux_set_range()
1283 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_test_orphan_transparent_parent_mux_set_range() local
1286 rate = clk_get_rate(clk); in clk_test_orphan_transparent_parent_mux_set_range()
1290 clk_set_rate_range(clk, in clk_test_orphan_transparent_parent_mux_set_range()
1291 ctx->parent_ctx.rate - 1000, in clk_test_orphan_transparent_parent_mux_set_range()
1292 ctx->parent_ctx.rate + 1000), in clk_test_orphan_transparent_parent_mux_set_range()
1295 new_rate = clk_get_rate(clk); in clk_test_orphan_transparent_parent_mux_set_range()
1299 clk_put(clk); 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",
1336 return -ENOMEM; in clk_orphan_two_level_root_last_test_init()
1337 test->priv = ctx; in clk_orphan_two_level_root_last_test_init()
1339 ctx->parent_ctx.hw.init = in clk_orphan_two_level_root_last_test_init()
1340 CLK_HW_INIT("intermediate-parent", in clk_orphan_two_level_root_last_test_init()
1341 "root-parent", in clk_orphan_two_level_root_last_test_init()
1344 ret = clk_hw_register(NULL, &ctx->parent_ctx.hw); in clk_orphan_two_level_root_last_test_init()
1348 ctx->hw.init = 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()
1352 ret = clk_hw_register(NULL, &ctx->hw); in clk_orphan_two_level_root_last_test_init()
1356 ctx->parent_parent_ctx.rate = DUMMY_CLOCK_INIT_RATE; in clk_orphan_two_level_root_last_test_init()
1357 ctx->parent_parent_ctx.hw.init = in clk_orphan_two_level_root_last_test_init()
1358 CLK_HW_INIT_NO_PARENT("root-parent", in clk_orphan_two_level_root_last_test_init()
1361 ret = clk_hw_register(NULL, &ctx->parent_parent_ctx.hw); in clk_orphan_two_level_root_last_test_init()
1371 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_exit()
1373 clk_hw_unregister(&ctx->hw); in clk_orphan_two_level_root_last_test_exit()
1374 clk_hw_unregister(&ctx->parent_ctx.hw); in clk_orphan_two_level_root_last_test_exit()
1375 clk_hw_unregister(&ctx->parent_parent_ctx.hw); in clk_orphan_two_level_root_last_test_exit()
1379 * Test that, for a clock whose parent used to be orphan, clk_get_rate()
1385 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_get_rate()
1386 struct clk_hw *hw = &ctx->hw; in clk_orphan_two_level_root_last_test_get_rate()
1387 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_orphan_two_level_root_last_test_get_rate() local
1390 rate = clk_get_rate(clk); in clk_orphan_two_level_root_last_test_get_rate()
1393 clk_put(clk); in clk_orphan_two_level_root_last_test_get_rate()
1397 * Test that, for a clock whose parent used to be orphan,
1402 * https://lore.kernel.org/linux-clk/366a0232-bb4a-c357-6aa8-636e398e05eb@samsung.com/
1407 struct clk_single_parent_two_lvl_ctx *ctx = test->priv; in clk_orphan_two_level_root_last_test_set_range()
1408 struct clk_hw *hw = &ctx->hw; in clk_orphan_two_level_root_last_test_set_range()
1409 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_orphan_two_level_root_last_test_set_range() local
1413 ret = clk_set_rate_range(clk, in clk_orphan_two_level_root_last_test_set_range()
1414 DUMMY_CLOCK_INIT_RATE - 1000, in clk_orphan_two_level_root_last_test_set_range()
1418 rate = clk_get_rate(clk); in clk_orphan_two_level_root_last_test_set_range()
1422 clk_put(clk); in clk_orphan_two_level_root_last_test_set_range()
1433 * Test suite for a basic, transparent, clock with a parent that is also
1434 * such a clock. The parent's parent is registered last, while the
1435 * parent and its child are registered in that order. The intermediate
1437 * clock itself will always have its parent and will never be
1438 * reparented. Indeed, it's only orphan because its parent is.
1442 * parent.
1446 .name = "clk-orphan-two-level-root-last-test",
1459 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range()
1460 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range()
1461 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range() local
1465 clk_set_rate_range(clk, in clk_range_test_set_range()
1470 rate = clk_get_rate(clk); in clk_range_test_set_range()
1475 clk_put(clk); in clk_range_test_set_range()
1484 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_invalid()
1485 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_invalid()
1486 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_invalid() local
1489 clk_set_rate_range(clk, in clk_range_test_set_range_invalid()
1494 clk_put(clk); in clk_range_test_set_range_invalid()
1503 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_disjoints_range()
1504 struct clk_hw *hw = &ctx->hw; in clk_range_test_multiple_disjoints_range()
1505 struct clk *user1, *user2; in clk_range_test_multiple_disjoints_range()
1531 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_round_rate_lower()
1532 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_round_rate_lower()
1533 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_round_rate_lower() local
1537 clk_set_rate_range(clk, in clk_range_test_set_range_round_rate_lower()
1542 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000); in clk_range_test_set_range_round_rate_lower()
1547 clk_put(clk); in clk_range_test_set_range_round_rate_lower()
1556 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_rate_lower()
1557 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_set_rate_lower()
1558 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_set_rate_lower() local
1562 clk_set_rate_range(clk, in clk_range_test_set_range_set_rate_lower()
1568 clk_set_rate(clk, DUMMY_CLOCK_RATE_1 - 1000), in clk_range_test_set_range_set_rate_lower()
1571 rate = clk_get_rate(clk); in clk_range_test_set_range_set_rate_lower()
1576 clk_put(clk); in clk_range_test_set_range_set_rate_lower()
1587 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_round_rate_consistent_lower()
1588 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_set_round_rate_consistent_lower()
1589 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_set_round_rate_consistent_lower() local
1593 clk_set_rate_range(clk, in clk_range_test_set_range_set_round_rate_consistent_lower()
1598 rounded = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000); in clk_range_test_set_range_set_round_rate_consistent_lower()
1602 clk_set_rate(clk, DUMMY_CLOCK_RATE_1 - 1000), 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()
1607 clk_put(clk); in clk_range_test_set_range_set_round_rate_consistent_lower()
1616 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_round_rate_higher()
1617 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_round_rate_higher()
1618 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_round_rate_higher() local
1622 clk_set_rate_range(clk, in clk_range_test_set_range_round_rate_higher()
1627 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_2 + 1000); in clk_range_test_set_range_round_rate_higher()
1632 clk_put(clk); in clk_range_test_set_range_round_rate_higher()
1641 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_rate_higher()
1642 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_set_rate_higher()
1643 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_set_rate_higher() local
1647 clk_set_rate_range(clk, in clk_range_test_set_range_set_rate_higher()
1653 clk_set_rate(clk, DUMMY_CLOCK_RATE_2 + 1000), in clk_range_test_set_range_set_rate_higher()
1656 rate = clk_get_rate(clk); in clk_range_test_set_range_set_rate_higher()
1661 clk_put(clk); in clk_range_test_set_range_set_rate_higher()
1672 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_set_round_rate_consistent_higher()
1673 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_set_round_rate_consistent_higher()
1674 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_set_round_rate_consistent_higher() local
1678 clk_set_rate_range(clk, in clk_range_test_set_range_set_round_rate_consistent_higher()
1683 rounded = clk_round_rate(clk, DUMMY_CLOCK_RATE_2 + 1000); in clk_range_test_set_range_set_round_rate_consistent_higher()
1687 clk_set_rate(clk, DUMMY_CLOCK_RATE_2 + 1000), 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()
1692 clk_put(clk); in clk_range_test_set_range_set_round_rate_consistent_higher()
1705 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_get_rate_raised()
1706 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_get_rate_raised()
1707 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_get_rate_raised() local
1711 clk_set_rate(clk, DUMMY_CLOCK_RATE_1 - 1000), in clk_range_test_set_range_get_rate_raised()
1715 clk_set_rate_range(clk, in clk_range_test_set_range_get_rate_raised()
1720 rate = clk_get_rate(clk); in clk_range_test_set_range_get_rate_raised()
1724 clk_put(clk); in clk_range_test_set_range_get_rate_raised()
1737 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_get_rate_lowered()
1738 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_get_rate_lowered()
1739 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_get_rate_lowered() local
1743 clk_set_rate(clk, DUMMY_CLOCK_RATE_2 + 1000), in clk_range_test_set_range_get_rate_lowered()
1747 clk_set_rate_range(clk, in clk_range_test_set_range_get_rate_lowered()
1752 rate = clk_get_rate(clk); in clk_range_test_set_range_get_rate_lowered()
1756 clk_put(clk); 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",
1797 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_rate_maximized()
1798 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_rate_maximized()
1799 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_rate_maximized() local
1803 clk_set_rate(clk, DUMMY_CLOCK_RATE_2 + 1000), in clk_range_test_set_range_rate_maximized()
1807 clk_set_rate_range(clk, in clk_range_test_set_range_rate_maximized()
1812 rate = clk_get_rate(clk); in clk_range_test_set_range_rate_maximized()
1817 clk_set_rate_range(clk, in clk_range_test_set_range_rate_maximized()
1819 DUMMY_CLOCK_RATE_2 - 1000), in clk_range_test_set_range_rate_maximized()
1822 rate = clk_get_rate(clk); 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()
1827 clk_set_rate_range(clk, in clk_range_test_set_range_rate_maximized()
1832 rate = clk_get_rate(clk); in clk_range_test_set_range_rate_maximized()
1836 clk_put(clk); in clk_range_test_set_range_rate_maximized()
1849 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_maximized()
1850 struct clk_hw *hw = &ctx->hw; in clk_range_test_multiple_set_range_rate_maximized()
1851 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_multiple_set_range_rate_maximized() local
1852 struct clk *user1, *user2; in clk_range_test_multiple_set_range_rate_maximized()
1862 clk_set_rate(clk, DUMMY_CLOCK_RATE_2 + 1000), in clk_range_test_multiple_set_range_rate_maximized()
1871 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_maximized()
1881 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_maximized()
1889 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_maximized()
1895 clk_put(clk); in clk_range_test_multiple_set_range_rate_maximized()
1908 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_put_maximized()
1909 struct clk_hw *hw = &ctx->hw; in clk_range_test_multiple_set_range_rate_put_maximized()
1910 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_multiple_set_range_rate_put_maximized() local
1911 struct clk *user1, *user2; in clk_range_test_multiple_set_range_rate_put_maximized()
1921 clk_set_rate(clk, DUMMY_CLOCK_RATE_2 + 1000), in clk_range_test_multiple_set_range_rate_put_maximized()
1930 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_put_maximized()
1940 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_put_maximized()
1946 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_put_maximized()
1951 clk_put(clk); 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",
1985 struct clk_dummy_context *ctx = test->priv; in clk_range_test_set_range_rate_minimized()
1986 struct clk_hw *hw = &ctx->hw; in clk_range_test_set_range_rate_minimized()
1987 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_set_range_rate_minimized() local
1991 clk_set_rate(clk, DUMMY_CLOCK_RATE_1 - 1000), in clk_range_test_set_range_rate_minimized()
1995 clk_set_rate_range(clk, in clk_range_test_set_range_rate_minimized()
2000 rate = clk_get_rate(clk); in clk_range_test_set_range_rate_minimized()
2005 clk_set_rate_range(clk, in clk_range_test_set_range_rate_minimized()
2010 rate = clk_get_rate(clk); in clk_range_test_set_range_rate_minimized()
2015 clk_set_rate_range(clk, in clk_range_test_set_range_rate_minimized()
2020 rate = clk_get_rate(clk); in clk_range_test_set_range_rate_minimized()
2024 clk_put(clk); in clk_range_test_set_range_rate_minimized()
2037 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_minimized()
2038 struct clk_hw *hw = &ctx->hw; in clk_range_test_multiple_set_range_rate_minimized()
2039 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_multiple_set_range_rate_minimized() local
2040 struct clk *user1, *user2; in clk_range_test_multiple_set_range_rate_minimized()
2055 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_minimized()
2065 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_minimized()
2073 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_minimized()
2079 clk_put(clk); in clk_range_test_multiple_set_range_rate_minimized()
2092 struct clk_dummy_context *ctx = test->priv; in clk_range_test_multiple_set_range_rate_put_minimized()
2093 struct clk_hw *hw = &ctx->hw; in clk_range_test_multiple_set_range_rate_put_minimized()
2094 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_range_test_multiple_set_range_rate_put_minimized() local
2095 struct clk *user1, *user2; in clk_range_test_multiple_set_range_rate_put_minimized()
2110 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_put_minimized()
2120 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_put_minimized()
2126 rate = clk_get_rate(clk); in clk_range_test_multiple_set_range_rate_put_minimized()
2131 clk_put(clk); 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",
2164 const char *top_parents[2] = { "parent-0", "parent-1" }; in clk_leaf_mux_set_rate_parent_test_init()
2169 return -ENOMEM; in clk_leaf_mux_set_rate_parent_test_init()
2170 test->priv = ctx; in clk_leaf_mux_set_rate_parent_test_init()
2172 ctx->mux_ctx.parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0", in clk_leaf_mux_set_rate_parent_test_init()
2175 ctx->mux_ctx.parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; in clk_leaf_mux_set_rate_parent_test_init()
2176 ret = clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[0].hw); in clk_leaf_mux_set_rate_parent_test_init()
2180 ctx->mux_ctx.parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1", in clk_leaf_mux_set_rate_parent_test_init()
2183 ctx->mux_ctx.parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; in clk_leaf_mux_set_rate_parent_test_init()
2184 ret = clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[1].hw); in clk_leaf_mux_set_rate_parent_test_init()
2188 ctx->mux_ctx.current_parent = 0; 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()
2192 ret = clk_hw_register(NULL, &ctx->mux_ctx.hw); 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()
2199 ret = clk_hw_register(NULL, &ctx->hw); in clk_leaf_mux_set_rate_parent_test_init()
2208 struct clk_leaf_mux_ctx *ctx = test->priv; in clk_leaf_mux_set_rate_parent_test_exit()
2210 clk_hw_unregister(&ctx->hw); in clk_leaf_mux_set_rate_parent_test_exit()
2211 clk_hw_unregister(&ctx->mux_ctx.hw); in clk_leaf_mux_set_rate_parent_test_exit()
2212 clk_hw_unregister(&ctx->mux_ctx.parents_ctx[0].hw); in clk_leaf_mux_set_rate_parent_test_exit()
2213 clk_hw_unregister(&ctx->mux_ctx.parents_ctx[1].hw); in clk_leaf_mux_set_rate_parent_test_exit()
2218 * parent, the rate request structure returned by __clk_determine_rate
2223 struct clk_leaf_mux_ctx *ctx = test->priv; in clk_leaf_mux_set_rate_parent_determine_rate()
2224 struct clk_hw *hw = &ctx->hw; in clk_leaf_mux_set_rate_parent_determine_rate()
2225 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_leaf_mux_set_rate_parent_determine_rate() local
2230 rate = clk_get_rate(clk); 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()
2242 clk_put(clk); in clk_leaf_mux_set_rate_parent_determine_rate()
2251 * Test suite for a clock whose parent is a mux with multiple parents.
2253 * requests to the mux, which will then select which parent is the best
2260 .name = "clk-leaf-mux-set-rate-parent",
2275 struct clk *clk; member
2292 ctx->pre_rate_change.old_rate = clk_data->old_rate; in clk_mux_notifier_callback()
2293 ctx->pre_rate_change.new_rate = clk_data->new_rate; in clk_mux_notifier_callback()
2294 ctx->pre_rate_change.done = true; in clk_mux_notifier_callback()
2295 wake_up_interruptible(&ctx->pre_rate_change.wq); in clk_mux_notifier_callback()
2299 ctx->post_rate_change.old_rate = clk_data->old_rate; in clk_mux_notifier_callback()
2300 ctx->post_rate_change.new_rate = clk_data->new_rate; in clk_mux_notifier_callback()
2301 ctx->post_rate_change.done = true; in clk_mux_notifier_callback()
2302 wake_up_interruptible(&ctx->post_rate_change.wq); in clk_mux_notifier_callback()
2311 const char *top_parents[2] = { "parent-0", "parent-1" }; in clk_mux_notifier_test_init()
2316 return -ENOMEM; in clk_mux_notifier_test_init()
2317 test->priv = ctx; in clk_mux_notifier_test_init()
2318 ctx->clk_nb.notifier_call = clk_mux_notifier_callback; in clk_mux_notifier_test_init()
2319 init_waitqueue_head(&ctx->pre_rate_change.wq); in clk_mux_notifier_test_init()
2320 init_waitqueue_head(&ctx->post_rate_change.wq); in clk_mux_notifier_test_init()
2322 ctx->mux_ctx.parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0", in clk_mux_notifier_test_init()
2325 ctx->mux_ctx.parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; in clk_mux_notifier_test_init()
2326 ret = clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[0].hw); in clk_mux_notifier_test_init()
2330 ctx->mux_ctx.parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1", in clk_mux_notifier_test_init()
2333 ctx->mux_ctx.parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; in clk_mux_notifier_test_init()
2334 ret = clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[1].hw); in clk_mux_notifier_test_init()
2338 ctx->mux_ctx.current_parent = 0; 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()
2342 ret = clk_hw_register(NULL, &ctx->mux_ctx.hw); in clk_mux_notifier_test_init()
2346 ctx->clk = clk_hw_get_clk(&ctx->mux_ctx.hw, NULL); in clk_mux_notifier_test_init()
2347 ret = clk_notifier_register(ctx->clk, &ctx->clk_nb); in clk_mux_notifier_test_init()
2356 struct clk_mux_notifier_ctx *ctx = test->priv; in clk_mux_notifier_test_exit()
2357 struct clk *clk = ctx->clk; in clk_mux_notifier_test_exit() local
2359 clk_notifier_unregister(clk, &ctx->clk_nb); in clk_mux_notifier_test_exit()
2360 clk_put(clk); in clk_mux_notifier_test_exit()
2362 clk_hw_unregister(&ctx->mux_ctx.hw); in clk_mux_notifier_test_exit()
2363 clk_hw_unregister(&ctx->mux_ctx.parents_ctx[0].hw); in clk_mux_notifier_test_exit()
2364 clk_hw_unregister(&ctx->mux_ctx.parents_ctx[1].hw); in clk_mux_notifier_test_exit()
2369 * will notify us when we switch to another parent, and with the proper
2374 struct clk_mux_notifier_ctx *ctx = test->priv; in clk_mux_notifier_set_parent_test()
2375 struct clk_hw *hw = &ctx->mux_ctx.hw; in clk_mux_notifier_set_parent_test()
2376 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_mux_notifier_set_parent_test() local
2377 struct clk *new_parent = clk_hw_get_clk(&ctx->mux_ctx.parents_ctx[1].hw, NULL); in clk_mux_notifier_set_parent_test()
2380 ret = clk_set_parent(clk, new_parent); in clk_mux_notifier_set_parent_test()
2383 ret = wait_event_interruptible_timeout(ctx->pre_rate_change.wq, in clk_mux_notifier_set_parent_test()
2384 ctx->pre_rate_change.done, 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()
2391 ret = wait_event_interruptible_timeout(ctx->post_rate_change.wq, in clk_mux_notifier_set_parent_test()
2392 ctx->post_rate_change.done, 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()
2400 clk_put(clk); in clk_mux_notifier_set_parent_test()
2415 .name = "clk-mux-notifier",
2425 const char *parents[2] = { "parent-0", "parent-1"}; in clk_mux_no_reparent_test_init()
2430 return -ENOMEM; in clk_mux_no_reparent_test_init()
2431 test->priv = ctx; in clk_mux_no_reparent_test_init()
2433 ctx->parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0", in clk_mux_no_reparent_test_init()
2436 ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; in clk_mux_no_reparent_test_init()
2437 ret = clk_hw_register(NULL, &ctx->parents_ctx[0].hw); in clk_mux_no_reparent_test_init()
2441 ctx->parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1", in clk_mux_no_reparent_test_init()
2444 ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; in clk_mux_no_reparent_test_init()
2445 ret = clk_hw_register(NULL, &ctx->parents_ctx[1].hw); in clk_mux_no_reparent_test_init()
2449 ctx->current_parent = 0; 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()
2453 ret = clk_hw_register(NULL, &ctx->hw); in clk_mux_no_reparent_test_init()
2463 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_test_exit()
2465 clk_hw_unregister(&ctx->hw); in clk_mux_no_reparent_test_exit()
2466 clk_hw_unregister(&ctx->parents_ctx[0].hw); in clk_mux_no_reparent_test_exit()
2467 clk_hw_unregister(&ctx->parents_ctx[1].hw); in clk_mux_no_reparent_test_exit()
2471 * Test that if the we have a mux that cannot change parent and we call
2473 * parent, it won't.
2477 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_round_rate()
2478 struct clk_hw *hw = &ctx->hw; in clk_mux_no_reparent_round_rate()
2479 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_mux_no_reparent_round_rate() local
2480 struct clk *other_parent, *parent; in clk_mux_no_reparent_round_rate() local
2485 parent = clk_get_parent(clk); in clk_mux_no_reparent_round_rate()
2486 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_mux_no_reparent_round_rate()
2488 parent_rate = clk_get_rate(parent); in clk_mux_no_reparent_round_rate()
2491 other_parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
2499 rounded_rate = clk_round_rate(clk, other_parent_rate); in clk_mux_no_reparent_round_rate()
2503 clk_put(clk); in clk_mux_no_reparent_round_rate()
2507 * Test that if the we have a mux that cannot change parent and we call
2509 * parent, it won't.
2513 struct clk_multiple_parent_ctx *ctx = test->priv; in clk_mux_no_reparent_set_rate()
2514 struct clk_hw *hw = &ctx->hw; in clk_mux_no_reparent_set_rate()
2515 struct clk *clk = clk_hw_get_clk(hw, NULL); in clk_mux_no_reparent_set_rate() local
2516 struct clk *other_parent, *parent; in clk_mux_no_reparent_set_rate() local
2522 parent = clk_get_parent(clk); in clk_mux_no_reparent_set_rate()
2523 KUNIT_ASSERT_PTR_NE(test, parent, NULL); in clk_mux_no_reparent_set_rate()
2525 parent_rate = clk_get_rate(parent); in clk_mux_no_reparent_set_rate()
2528 other_parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 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()
2536 ret = clk_set_rate(clk, other_parent_rate); in clk_mux_no_reparent_set_rate()
2539 rate = clk_get_rate(clk); in clk_mux_no_reparent_set_rate()
2543 clk_put(clk); in clk_mux_no_reparent_set_rate()
2553 * Test suite for a clock mux that isn't allowed to change parent, using
2560 .name = "clk-mux-no-reparent",