Lines Matching +full:parent +full:- +full:clk

1 // SPDX-License-Identifier: GPL-2.0
3 * KUnit test for clk fixed rate basic type
5 #include <linux/clk.h>
6 #include <linux/clk-provider.h>
11 #include <kunit/clk.h>
17 #include "clk-fixed-rate_test.h"
20 * struct clk_hw_fixed_rate_kunit_params - Parameters to pass to __clk_hw_register_fixed_rate()
21 * @dev: device registering clk
22 * @np: device_node of device registering clk
23 * @name: name of clk
24 * @parent_name: parent name of clk
25 * @parent_hw: clk_hw pointer to parent of clk
26 * @parent_data: parent_data describing parent of clk
27 * @flags: clk framework flags
28 * @fixed_rate: frequency of clk
29 * @fixed_accuracy: accuracy of clk
30 * @clk_fixed_flags: fixed rate specific clk flags
51 hw = __clk_hw_register_fixed_rate(params->dev, params->np, in clk_hw_register_fixed_rate_kunit_init()
52 params->name, in clk_hw_register_fixed_rate_kunit_init()
53 params->parent_name, in clk_hw_register_fixed_rate_kunit_init()
54 params->parent_hw, in clk_hw_register_fixed_rate_kunit_init()
55 params->parent_data, in clk_hw_register_fixed_rate_kunit_init()
56 params->flags, in clk_hw_register_fixed_rate_kunit_init()
57 params->fixed_rate, in clk_hw_register_fixed_rate_kunit_init()
58 params->fixed_accuracy, in clk_hw_register_fixed_rate_kunit_init()
59 params->clk_fixed_flags, in clk_hw_register_fixed_rate_kunit_init()
64 res->data = hw; in clk_hw_register_fixed_rate_kunit_init()
71 struct clk_hw *hw = res->data; in clk_hw_register_fixed_rate_kunit_exit()
77 * clk_hw_register_fixed_rate_kunit() - Test managed __clk_hw_register_fixed_rate()
94 return ERR_PTR(-EINVAL); in clk_hw_register_fixed_rate_kunit()
100 * clk_hw_unregister_fixed_rate_kunit() - Test managed clk_hw_unregister_fixed_rate()
102 * @hw: fixed rate clk to unregister upon test completion
114 return -ENOMEM; in clk_hw_unregister_fixed_rate_kunit()
120 * Test that clk_get_rate() on a fixed rate clk registered with
126 struct clk *clk; in clk_fixed_rate_rate_test() local
129 hw = clk_hw_register_fixed_rate(NULL, "test-fixed-rate", NULL, 0, fixed_rate); in clk_fixed_rate_rate_test()
133 clk = clk_hw_get_clk_prepared_enabled_kunit(test, hw, __func__); in clk_fixed_rate_rate_test()
134 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_rate_test()
136 KUNIT_EXPECT_EQ(test, fixed_rate, clk_get_rate(clk)); in clk_fixed_rate_rate_test()
140 * Test that clk_get_accuracy() on a fixed rate clk registered via
146 struct clk *clk; in clk_fixed_rate_accuracy_test() local
149 hw = clk_hw_register_fixed_rate_with_accuracy(NULL, "test-fixed-rate", in clk_fixed_rate_accuracy_test()
155 clk = clk_hw_get_clk_kunit(test, hw, __func__); in clk_fixed_rate_accuracy_test()
156 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_accuracy_test()
158 KUNIT_EXPECT_EQ(test, fixed_accuracy, clk_get_accuracy(clk)); in clk_fixed_rate_accuracy_test()
161 /* Test suite for a fixed rate clk without any parent */
174 * Test that clk_get_parent() on a fixed rate clk gets the proper parent.
179 struct clk *expected_parent, *actual_parent; in clk_fixed_rate_parent_test()
180 struct clk *clk; in clk_fixed_rate_parent_test() local
181 const char *parent_name = "test-fixed-rate-parent"; in clk_fixed_rate_parent_test()
193 hw = clk_hw_register_fixed_rate(NULL, "test-fixed-rate", parent_name, 0, 0); in clk_fixed_rate_parent_test()
197 clk = clk_hw_get_clk_kunit(test, hw, __func__); in clk_fixed_rate_parent_test()
198 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_parent_test()
200 actual_parent = clk_get_parent(clk); in clk_fixed_rate_parent_test()
205 * Test that clk_get_rate() on a fixed rate clk ignores the parent rate.
210 struct clk *clk; in clk_fixed_rate_parent_rate_test() local
213 const char *parent_name = "test-fixed-rate-parent"; in clk_fixed_rate_parent_rate_test()
223 hw = clk_hw_register_fixed_rate(NULL, "test-fixed-rate", parent_name, 0, in clk_fixed_rate_parent_rate_test()
228 clk = clk_hw_get_clk_prepared_enabled_kunit(test, hw, __func__); in clk_fixed_rate_parent_rate_test()
229 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_parent_rate_test()
231 KUNIT_EXPECT_EQ(test, expected_rate, clk_get_rate(clk)); in clk_fixed_rate_parent_rate_test()
235 * Test that clk_get_accuracy() on a fixed rate clk ignores the parent accuracy.
240 struct clk *clk; in clk_fixed_rate_parent_accuracy_test() local
243 const char *parent_name = "test-fixed-rate-parent"; in clk_fixed_rate_parent_accuracy_test()
253 hw = clk_hw_register_fixed_rate_with_accuracy(NULL, "test-fixed-rate", in clk_fixed_rate_parent_accuracy_test()
259 clk = clk_hw_get_clk_kunit(test, hw, __func__); in clk_fixed_rate_parent_accuracy_test()
260 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_parent_accuracy_test()
262 KUNIT_EXPECT_EQ(test, expected_accuracy, clk_get_accuracy(clk)); in clk_fixed_rate_parent_accuracy_test()
265 /* Test suite for a fixed rate clk with a parent */
287 return container_of(to_platform_driver(pdev->dev.driver), in pdev_to_clk_fixed_rate_of_test_context()
293 * Test that of_fixed_clk_setup() registers a fixed rate clk with the proper
298 struct clk_fixed_rate_of_test_context *ctx = test->priv; in clk_fixed_rate_of_probe_test()
299 struct device *dev = ctx->dev; in clk_fixed_rate_of_probe_test()
300 struct clk *clk; in clk_fixed_rate_of_probe_test() local
302 clk = clk_get_kunit(test, dev, NULL); in clk_fixed_rate_of_probe_test()
303 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_of_probe_test()
305 KUNIT_ASSERT_EQ(test, 0, clk_prepare_enable_kunit(test, clk)); in clk_fixed_rate_of_probe_test()
306 KUNIT_EXPECT_EQ(test, TEST_FIXED_FREQUENCY, clk_get_rate(clk)); in clk_fixed_rate_of_probe_test()
310 * Test that of_fixed_clk_setup() registers a fixed rate clk with the proper
315 struct clk_fixed_rate_of_test_context *ctx = test->priv; in clk_fixed_rate_of_accuracy_test()
316 struct device *dev = ctx->dev; in clk_fixed_rate_of_accuracy_test()
317 struct clk *clk; in clk_fixed_rate_of_accuracy_test() local
319 clk = clk_get_kunit(test, dev, NULL); in clk_fixed_rate_of_accuracy_test()
320 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, clk); in clk_fixed_rate_of_accuracy_test()
322 KUNIT_EXPECT_EQ(test, TEST_FIXED_ACCURACY, clk_get_accuracy(clk)); in clk_fixed_rate_of_accuracy_test()
336 ctx->dev = &pdev->dev; in clk_fixed_rate_of_test_probe()
337 complete(&ctx->probed); in clk_fixed_rate_of_test_probe()
346 { .compatible = "test,single-clk-consumer" }, in clk_fixed_rate_of_init()
354 test->priv = ctx; in clk_fixed_rate_of_init()
356 ctx->pdrv.probe = clk_fixed_rate_of_test_probe; in clk_fixed_rate_of_init()
357 ctx->pdrv.driver.of_match_table = match_table; in clk_fixed_rate_of_init()
358 ctx->pdrv.driver.name = __func__; in clk_fixed_rate_of_init()
359 ctx->pdrv.driver.owner = THIS_MODULE; in clk_fixed_rate_of_init()
360 init_completion(&ctx->probed); in clk_fixed_rate_of_init()
362 KUNIT_ASSERT_EQ(test, 0, kunit_platform_driver_register(test, &ctx->pdrv)); in clk_fixed_rate_of_init()
363 KUNIT_ASSERT_NE(test, 0, wait_for_completion_timeout(&ctx->probed, HZ)); in clk_fixed_rate_of_init()
380 MODULE_DESCRIPTION("KUnit test for clk fixed rate basic type");