clk: add sandbox test for bulk API
authorNeil Armstrong <narmstrong@baylibre.com>
Tue, 3 Apr 2018 09:44:19 +0000 (11:44 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 10 Apr 2018 19:18:56 +0000 (15:18 -0400)
This patch adds the bulk clock API tests for the sandbox test suite.

It's very similar to the main test but only uses the _bulk() API and
checks if the clocks are correctly enabled/disabled.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/include/asm/clk.h
drivers/clk/clk_sandbox_test.c
test/dm/clk.c

index 9dc6c8184b30c23b2585c30fe8a5466cc1138310..01b5ba4e0773ddc5a8e46ca01e790276ab4a85a2 100644 (file)
@@ -63,6 +63,14 @@ int sandbox_clk_query_enable(struct udevice *dev, int id);
  * @return:    0 if OK, or a negative error code.
  */
 int sandbox_clk_test_get(struct udevice *dev);
+/**
+ * sandbox_clk_test_get_bulk - Ask the sandbox clock test device to request its
+ * clocks with the bulk clk API.
+ *
+ * @dev:       The sandbox clock test (client) devivce.
+ * @return:    0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_get_bulk(struct udevice *dev);
 /**
  * sandbox_clk_test_get_rate - Ask the sandbox clock test device to query a
  * clock's rate.
@@ -90,6 +98,14 @@ ulong sandbox_clk_test_set_rate(struct udevice *dev, int id, ulong rate);
  * @return:    0 if OK, or a negative error code.
  */
 int sandbox_clk_test_enable(struct udevice *dev, int id);
+/**
+ * sandbox_clk_test_enable_bulk - Ask the sandbox clock test device to enable
+ * all clocks in it's clock bulk struct.
+ *
+ * @dev:       The sandbox clock test (client) devivce.
+ * @return:    0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_enable_bulk(struct udevice *dev);
 /**
  * sandbox_clk_test_disable - Ask the sandbox clock test device to disable a
  * clock.
@@ -99,6 +115,14 @@ int sandbox_clk_test_enable(struct udevice *dev, int id);
  * @return:    0 if OK, or a negative error code.
  */
 int sandbox_clk_test_disable(struct udevice *dev, int id);
+/**
+ * sandbox_clk_test_disable_bulk - Ask the sandbox clock test device to disable
+ * all clocks in it's clock bulk struct.
+ *
+ * @dev:       The sandbox clock test (client) devivce.
+ * @return:    0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_disable_bulk(struct udevice *dev);
 /**
  * sandbox_clk_test_free - Ask the sandbox clock test device to free its
  * clocks.
@@ -107,5 +131,13 @@ int sandbox_clk_test_disable(struct udevice *dev, int id);
  * @return:    0 if OK, or a negative error code.
  */
 int sandbox_clk_test_free(struct udevice *dev);
+/**
+ * sandbox_clk_test_release_bulk - Ask the sandbox clock test device to release
+ * all clocks in it's clock bulk struct.
+ *
+ * @dev:       The sandbox clock test (client) devivce.
+ * @return:    0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_release_bulk(struct udevice *dev);
 
 #endif
index 999100de9d2f26b8acf263b01a1ccfe6272d2b45..d0898815b396de7f57444fc606fa8a8c61a36029 100644 (file)
@@ -11,6 +11,7 @@
 
 struct sandbox_clk_test {
        struct clk clks[SANDBOX_CLK_TEST_ID_COUNT];
+       struct clk_bulk bulk;
 };
 
 static const char * const sandbox_clk_test_names[] = {
@@ -34,6 +35,13 @@ int sandbox_clk_test_get(struct udevice *dev)
        return 0;
 }
 
+int sandbox_clk_test_get_bulk(struct udevice *dev)
+{
+       struct sandbox_clk_test *sbct = dev_get_priv(dev);
+
+       return clk_get_bulk(dev, &sbct->bulk);
+}
+
 ulong sandbox_clk_test_get_rate(struct udevice *dev, int id)
 {
        struct sandbox_clk_test *sbct = dev_get_priv(dev);
@@ -64,6 +72,13 @@ int sandbox_clk_test_enable(struct udevice *dev, int id)
        return clk_enable(&sbct->clks[id]);
 }
 
+int sandbox_clk_test_enable_bulk(struct udevice *dev)
+{
+       struct sandbox_clk_test *sbct = dev_get_priv(dev);
+
+       return clk_enable_bulk(&sbct->bulk);
+}
+
 int sandbox_clk_test_disable(struct udevice *dev, int id)
 {
        struct sandbox_clk_test *sbct = dev_get_priv(dev);
@@ -74,6 +89,13 @@ int sandbox_clk_test_disable(struct udevice *dev, int id)
        return clk_disable(&sbct->clks[id]);
 }
 
+int sandbox_clk_test_disable_bulk(struct udevice *dev)
+{
+       struct sandbox_clk_test *sbct = dev_get_priv(dev);
+
+       return clk_disable_bulk(&sbct->bulk);
+}
+
 int sandbox_clk_test_free(struct udevice *dev)
 {
        struct sandbox_clk_test *sbct = dev_get_priv(dev);
@@ -88,6 +110,13 @@ int sandbox_clk_test_free(struct udevice *dev)
        return 0;
 }
 
+int sandbox_clk_test_release_bulk(struct udevice *dev)
+{
+       struct sandbox_clk_test *sbct = dev_get_priv(dev);
+
+       return clk_release_bulk(&sbct->bulk);
+}
+
 static const struct udevice_id sandbox_clk_test_ids[] = {
        { .compatible = "sandbox,clk-test" },
        { }
index 712a1e674a5550c975f2e886f4ed5273cb074897..d3649103ee6f0c63c9c9745dd98516b1f11db707 100644 (file)
@@ -101,3 +101,40 @@ static int dm_test_clk(struct unit_test_state *uts)
        return 0;
 }
 DM_TEST(dm_test_clk, DM_TESTF_SCAN_FDT);
+
+static int dm_test_clk_bulk(struct unit_test_state *uts)
+{
+       struct udevice *dev_clk, *dev_test;
+
+       ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-sbox",
+                                             &dev_clk));
+       ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test",
+                                             &dev_test));
+       ut_assertok(sandbox_clk_test_get_bulk(dev_test));
+
+       ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
+       ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));
+
+       /* Fixed clock does not support enable, thus should not fail */
+       ut_assertok(sandbox_clk_test_enable_bulk(dev_test));
+       ut_asserteq(1, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
+       ut_asserteq(1, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));
+
+       /* Fixed clock does not support disable, thus should not fail */
+       ut_assertok(sandbox_clk_test_disable_bulk(dev_test));
+       ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
+       ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));
+
+       /* Fixed clock does not support enable, thus should not fail */
+       ut_assertok(sandbox_clk_test_enable_bulk(dev_test));
+       ut_asserteq(1, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
+       ut_asserteq(1, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));
+
+       /* Fixed clock does not support disable, thus should not fail */
+       ut_assertok(sandbox_clk_test_release_bulk(dev_test));
+       ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
+       ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));
+
+       return 0;
+}
+DM_TEST(dm_test_clk_bulk, DM_TESTF_SCAN_FDT);