Lines Matching +full:parent +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0
3 * Kunit test for clk gate basic type
5 #include <linux/clk.h>
6 #include <linux/clk-provider.h>
16 pdev = platform_device_register_simple("test_gate_device", -1, NULL, 0); in clk_gate_register_test_dev()
19 ret = clk_hw_register_gate(&pdev->dev, "test_gate", NULL, 0, NULL, in clk_gate_register_test_dev()
31 struct clk_hw *parent; in clk_gate_register_test_parent_names() local
34 parent = clk_hw_register_fixed_rate(NULL, "test_parent", NULL, 0, in clk_gate_register_test_parent_names()
36 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_gate_register_test_parent_names()
41 KUNIT_EXPECT_PTR_EQ(test, parent, clk_hw_get_parent(ret)); in clk_gate_register_test_parent_names()
44 clk_hw_unregister_fixed_rate(parent); in clk_gate_register_test_parent_names()
49 struct clk_hw *parent; in clk_gate_register_test_parent_data() local
53 parent = clk_hw_register_fixed_rate(NULL, "test_parent", NULL, 0, in clk_gate_register_test_parent_data()
55 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_gate_register_test_parent_data()
56 pdata.hw = parent; in clk_gate_register_test_parent_data()
61 KUNIT_EXPECT_PTR_EQ(test, parent, clk_hw_get_parent(ret)); in clk_gate_register_test_parent_data()
64 clk_hw_unregister_fixed_rate(parent); in clk_gate_register_test_parent_data()
69 struct clk_hw *parent; in clk_gate_register_test_parent_data_legacy() local
73 parent = clk_hw_register_fixed_rate(NULL, "test_parent", NULL, 0, in clk_gate_register_test_parent_data_legacy()
75 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_gate_register_test_parent_data_legacy()
81 KUNIT_EXPECT_PTR_EQ(test, parent, clk_hw_get_parent(ret)); in clk_gate_register_test_parent_data_legacy()
84 clk_hw_unregister_fixed_rate(parent); in clk_gate_register_test_parent_data_legacy()
89 struct clk_hw *parent; in clk_gate_register_test_parent_hw() local
92 parent = clk_hw_register_fixed_rate(NULL, "test_parent", NULL, 0, in clk_gate_register_test_parent_hw()
94 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_gate_register_test_parent_hw()
96 ret = clk_hw_register_gate_parent_hw(NULL, "test_gate", parent, 0, NULL, in clk_gate_register_test_parent_hw()
99 KUNIT_EXPECT_PTR_EQ(test, parent, clk_hw_get_parent(ret)); in clk_gate_register_test_parent_hw()
102 clk_hw_unregister_fixed_rate(parent); in clk_gate_register_test_parent_hw()
126 .name = "clk-gate-register-test",
133 struct clk_hw *parent; member
141 test->priv = ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); in clk_gate_test_alloc_ctx()
143 ctx->fake_mem = (void __force __iomem *)&ctx->fake_reg; in clk_gate_test_alloc_ctx()
150 struct clk_gate_test_context *ctx = test->priv; in clk_gate_test_parent_rate()
151 struct clk_hw *parent = ctx->parent; in clk_gate_test_parent_rate() local
152 struct clk_hw *hw = ctx->hw; in clk_gate_test_parent_rate()
153 unsigned long prate = clk_hw_get_rate(parent); in clk_gate_test_parent_rate()
161 struct clk_gate_test_context *ctx = test->priv; in clk_gate_test_enable()
162 struct clk_hw *parent = ctx->parent; in clk_gate_test_enable() local
163 struct clk_hw *hw = ctx->hw; in clk_gate_test_enable()
164 struct clk *clk = hw->clk; in clk_gate_test_enable() local
167 KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); in clk_gate_test_enable()
169 KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); in clk_gate_test_enable()
172 KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); in clk_gate_test_enable()
173 KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(parent)); in clk_gate_test_enable()
178 struct clk_gate_test_context *ctx = test->priv; in clk_gate_test_disable()
179 struct clk_hw *parent = ctx->parent; in clk_gate_test_disable() local
180 struct clk_hw *hw = ctx->hw; in clk_gate_test_disable()
181 struct clk *clk = hw->clk; in clk_gate_test_disable() local
185 KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); in clk_gate_test_disable()
186 KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); in clk_gate_test_disable()
188 clk_disable_unprepare(clk); in clk_gate_test_disable()
189 KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); in clk_gate_test_disable()
192 KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); in clk_gate_test_disable()
193 KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(parent)); in clk_gate_test_disable()
205 struct clk_hw *parent; in clk_gate_test_init() local
210 parent = clk_hw_register_fixed_rate(NULL, "test_parent", NULL, 0, in clk_gate_test_init()
212 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_gate_test_init()
214 hw = clk_hw_register_gate_parent_hw(NULL, "test_gate", parent, 0, in clk_gate_test_init()
215 ctx->fake_mem, 5, 0, NULL); in clk_gate_test_init()
218 ctx->hw = hw; in clk_gate_test_init()
219 ctx->parent = parent; in clk_gate_test_init()
226 struct clk_gate_test_context *ctx = test->priv; in clk_gate_test_exit()
228 clk_hw_unregister_gate(ctx->hw); in clk_gate_test_exit()
229 clk_hw_unregister_fixed_rate(ctx->parent); in clk_gate_test_exit()
233 .name = "clk-gate-test",
241 struct clk_gate_test_context *ctx = test->priv; in clk_gate_test_invert_enable()
242 struct clk_hw *parent = ctx->parent; in clk_gate_test_invert_enable() local
243 struct clk_hw *hw = ctx->hw; in clk_gate_test_invert_enable()
244 struct clk *clk = hw->clk; in clk_gate_test_invert_enable() local
247 KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); in clk_gate_test_invert_enable()
249 KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); in clk_gate_test_invert_enable()
252 KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); in clk_gate_test_invert_enable()
253 KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(parent)); in clk_gate_test_invert_enable()
258 struct clk_gate_test_context *ctx = test->priv; in clk_gate_test_invert_disable()
259 struct clk_hw *parent = ctx->parent; in clk_gate_test_invert_disable() local
260 struct clk_hw *hw = ctx->hw; in clk_gate_test_invert_disable()
261 struct clk *clk = hw->clk; in clk_gate_test_invert_disable() local
265 KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); in clk_gate_test_invert_disable()
266 KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); in clk_gate_test_invert_disable()
268 clk_disable_unprepare(clk); in clk_gate_test_invert_disable()
269 KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); in clk_gate_test_invert_disable()
272 KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); in clk_gate_test_invert_disable()
273 KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(parent)); in clk_gate_test_invert_disable()
284 struct clk_hw *parent; in clk_gate_test_invert_init() local
289 parent = clk_hw_register_fixed_rate(NULL, "test_parent", NULL, 0, in clk_gate_test_invert_init()
291 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_gate_test_invert_init()
293 ctx->fake_reg = BIT(15); /* Default to off */ in clk_gate_test_invert_init()
294 hw = clk_hw_register_gate_parent_hw(NULL, "test_gate", parent, 0, in clk_gate_test_invert_init()
295 ctx->fake_mem, 15, in clk_gate_test_invert_init()
299 ctx->hw = hw; in clk_gate_test_invert_init()
300 ctx->parent = parent; in clk_gate_test_invert_init()
306 .name = "clk-gate-invert-test",
314 struct clk_gate_test_context *ctx = test->priv; in clk_gate_test_hiword_enable()
315 struct clk_hw *parent = ctx->parent; in clk_gate_test_hiword_enable() local
316 struct clk_hw *hw = ctx->hw; in clk_gate_test_hiword_enable()
317 struct clk *clk = hw->clk; in clk_gate_test_hiword_enable() local
320 KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); in clk_gate_test_hiword_enable()
322 KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); in clk_gate_test_hiword_enable()
325 KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); in clk_gate_test_hiword_enable()
326 KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(parent)); in clk_gate_test_hiword_enable()
331 struct clk_gate_test_context *ctx = test->priv; in clk_gate_test_hiword_disable()
332 struct clk_hw *parent = ctx->parent; in clk_gate_test_hiword_disable() local
333 struct clk_hw *hw = ctx->hw; in clk_gate_test_hiword_disable()
334 struct clk *clk = hw->clk; in clk_gate_test_hiword_disable() local
338 KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); in clk_gate_test_hiword_disable()
339 KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); in clk_gate_test_hiword_disable()
341 clk_disable_unprepare(clk); in clk_gate_test_hiword_disable()
342 KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); in clk_gate_test_hiword_disable()
345 KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); in clk_gate_test_hiword_disable()
346 KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(parent)); in clk_gate_test_hiword_disable()
357 struct clk_hw *parent; in clk_gate_test_hiword_init() local
362 parent = clk_hw_register_fixed_rate(NULL, "test_parent", NULL, 0, in clk_gate_test_hiword_init()
364 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); in clk_gate_test_hiword_init()
366 hw = clk_hw_register_gate_parent_hw(NULL, "test_gate", parent, 0, in clk_gate_test_hiword_init()
367 ctx->fake_mem, 9, in clk_gate_test_hiword_init()
371 ctx->hw = hw; in clk_gate_test_hiword_init()
372 ctx->parent = parent; in clk_gate_test_hiword_init()
378 .name = "clk-gate-hiword-test",
390 ctx->fake_reg = BIT(7); in clk_gate_test_is_enabled()
391 hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 7, in clk_gate_test_is_enabled()
405 ctx->fake_reg = BIT(4); in clk_gate_test_is_disabled()
406 hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 7, in clk_gate_test_is_disabled()
420 ctx->fake_reg = BIT(31); in clk_gate_test_is_enabled_inverted()
421 hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 2, in clk_gate_test_is_enabled_inverted()
435 ctx->fake_reg = BIT(29); in clk_gate_test_is_disabled_inverted()
436 hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 29, in clk_gate_test_is_disabled_inverted()
453 .name = "clk-gate-is_enabled-test",