]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: clk_ccf: test ccf_clk_ops
authorYang Xiwen <forbidden405@outlook.com>
Fri, 15 Dec 2023 18:28:52 +0000 (02:28 +0800)
committerSean Anderson <seanga2@gmail.com>
Fri, 15 Dec 2023 18:50:44 +0000 (13:50 -0500)
Assign ccf_clk_ops to .ops of clk_ccf driver so that it can act as an
clk provider. Also add "#clock-cells=<1>" to its device tree node.

Add "i2c_root" to clk_test in the device tree and driver for testing.

Get "i2c_root" clock in CCF unit tests and add tests for it.

Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Link: https://lore.kernel.org/r/20231111-enable_count-v3-2-08a821892fa9@outlook.com
arch/sandbox/dts/test.dts
arch/sandbox/include/asm/clk.h
drivers/clk/clk_sandbox_ccf.c
drivers/clk/clk_sandbox_test.c
test/dm/clk_ccf.c

index c7197795efbc4b13a0dc7b7bbeaa5109a99570be..a3a865d65ca5e343da85f06d58a849cf58f40f5b 100644 (file)
                clocks = <&clk_fixed>,
                         <&clk_sandbox 1>,
                         <&clk_sandbox 0>,
+                        <&ccf 11>,
                         <&clk_sandbox 3>,
                         <&clk_sandbox 2>;
-               clock-names = "fixed", "i2c", "spi", "uart2", "uart1";
+               clock-names = "fixed", "i2c", "spi", "i2c_root", "uart2", "uart1";
        };
 
        clk-test2 {
 
        ccf: clk-ccf {
                compatible = "sandbox,clk-ccf";
+               #clock-cells = <1>;
        };
 
        efi-media {
index df7156fe31742cb79f0b8ee5bc7c4f5f27e0ccc9..1daf2e7ac79ad252f178a3de9d9287b975b43861 100644 (file)
@@ -39,6 +39,7 @@ enum sandbox_clk_test_id {
        SANDBOX_CLK_TEST_ID_FIXED,
        SANDBOX_CLK_TEST_ID_SPI,
        SANDBOX_CLK_TEST_ID_I2C,
+       SANDBOX_CLK_TEST_ID_I2C_ROOT,
        SANDBOX_CLK_TEST_ID_DEVM1,
        SANDBOX_CLK_TEST_ID_DEVM2,
        SANDBOX_CLK_TEST_ID_DEVM_NULL,
index fedcdd40448bb9ebc2aaae279d66c3c88a1d01e3..38184e27aa4fe9158f35adf24f2d349f925dcb4c 100644 (file)
@@ -284,6 +284,7 @@ static int sandbox_clk_ccf_probe(struct udevice *dev)
 U_BOOT_DRIVER(sandbox_clk_ccf) = {
        .name = "sandbox_clk_ccf",
        .id = UCLASS_CLK,
+       .ops = &ccf_clk_ops,
        .probe = sandbox_clk_ccf_probe,
        .of_match = sandbox_clk_ccf_test_ids,
 };
index 5807a454f3b9319c56b4a165b00b7a87f1a42d88..c695b69321e2ecb7cb6fbc35a6d9dedb735da97e 100644 (file)
@@ -15,6 +15,7 @@ static const char * const sandbox_clk_test_names[] = {
        [SANDBOX_CLK_TEST_ID_FIXED] = "fixed",
        [SANDBOX_CLK_TEST_ID_SPI] = "spi",
        [SANDBOX_CLK_TEST_ID_I2C] = "i2c",
+       [SANDBOX_CLK_TEST_ID_I2C_ROOT] = "i2c_root",
 };
 
 int sandbox_clk_test_get(struct udevice *dev)
index 3b2398254147065e7dc90e33aaa9ef6291443f6e..99481877a8f467f4be8cccecf3e99e0071c8f501 100644 (file)
@@ -18,8 +18,8 @@
 /* Tests for Common Clock Framework driver */
 static int dm_test_clk_ccf(struct unit_test_state *uts)
 {
-       struct clk *clk, *pclk;
-       struct udevice *dev;
+       struct clk *clk, *pclk, clk_ccf;
+       struct udevice *dev, *test_dev;
        long long rate;
        int ret;
 #if CONFIG_IS_ENABLED(CLK_CCF)
@@ -29,6 +29,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
 
        /* Get the device using the clk device */
        ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-ccf", &dev));
+       ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", &test_dev));
 
        /* Test for clk_get_by_id() */
        ret = clk_get_by_id(SANDBOX_CLK_ECSPI_ROOT, &clk);
@@ -119,11 +120,18 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
 
 #if CONFIG_IS_ENABLED(CLK_CCF)
        /* Test clk tree enable/disable */
+
+       ret = clk_get_by_index(test_dev, SANDBOX_CLK_TEST_ID_I2C_ROOT, &clk_ccf);
+       ut_assertok(ret);
+       ut_asserteq_str("clk-ccf", clk_ccf.dev->name);
+       ut_asserteq(clk_ccf.id, SANDBOX_CLK_I2C_ROOT);
+
        ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
        ut_assertok(ret);
        ut_asserteq_str("i2c_root", clk->dev->name);
+       ut_asserteq(clk->id, SANDBOX_CLK_I2C_ROOT);
 
-       ret = clk_enable(clk);
+       ret = clk_enable(&clk_ccf);
        ut_assertok(ret);
 
        ret = sandbox_clk_enable_count(clk);