Re: [PATCH v2 4/4] test: dm: clk_ccf: get "i2c_root" clock from _ccf

2023-12-15 Thread Sean Anderson

On 11/18/23 17:10, Yang Xiwen via B4 Relay wrote:

From: Yang Xiwen 

get i2c_root clock from device tree. In this way we get an CCF clock and
also test ccf_clk_ops.

Signed-off-by: Yang Xiwen 
---
  test/dm/clk_ccf.c | 14 +++---
  1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index e4ebb93cda..b8be6d6572 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -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", ));
+   ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", 
_dev));
  
  	/* Test for clk_get_by_id() */

ret = clk_get_by_id(SANDBOX_CLK_ECSPI_ROOT, );
@@ -110,11 +111,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, 
_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, );
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(_ccf);
ut_assertok(ret);
  
  	ret = sandbox_clk_enable_count(clk);




This patch should be combined with patches 1 and 3. With the changes spread out
over 3 patches it is hard to see what is going on.

--Sean


[PATCH v2 4/4] test: dm: clk_ccf: get "i2c_root" clock from _ccf

2023-11-18 Thread Yang Xiwen via B4 Relay
From: Yang Xiwen 

get i2c_root clock from device tree. In this way we get an CCF clock and
also test ccf_clk_ops.

Signed-off-by: Yang Xiwen 
---
 test/dm/clk_ccf.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index e4ebb93cda..b8be6d6572 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -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", ));
+   ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", 
_dev));
 
/* Test for clk_get_by_id() */
ret = clk_get_by_id(SANDBOX_CLK_ECSPI_ROOT, );
@@ -110,11 +111,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, 
_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, );
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(_ccf);
ut_assertok(ret);
 
ret = sandbox_clk_enable_count(clk);

-- 
2.39.2