firmware: arm_scmi: Simplify enable/disable clock operations
authorCristian Marussi <cristian.marussi@arm.com>
Sat, 26 Aug 2023 12:53:03 +0000 (13:53 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Wed, 20 Sep 2023 14:01:40 +0000 (15:01 +0100)
SCMI clock enable/disable operations come in 2 different flavours which
simply just differ in how the underlying SCMI transactions is carried on:
atomic or not.

Currently we expose such SCMI operations through 2 distinctly named
wrappers, that, in turn, are wrapped into another couple of similarly and
distinctly named callbacks inside SCMI clock driver user.

Reduce the churn of duplicated wrappers by adding a param to SCMI clock
enable/disable operations to ask for atomic operation while removing the
_atomic version of such operations.

No functional change.

CC: Michael Turquette <mturquette@baylibre.com>
CC: Stephen Boyd <sboyd@kernel.org>
CC: linux-clk@vger.kernel.org
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20230826125308.462328-2-cristian.marussi@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/clk/clk-scmi.c
drivers/firmware/arm_scmi/clock.c
include/linux/scmi_protocol.h

index 2c7a830ce3080f48d4c9040959a9085e1c330c0a..b7a180b3443e3dd96f56aede4fd2c54609708b2a 100644 (file)
@@ -13,6 +13,9 @@
 #include <linux/scmi_protocol.h>
 #include <asm/div64.h>
 
+#define NOT_ATOMIC     false
+#define ATOMIC         true
+
 static const struct scmi_clk_proto_ops *scmi_proto_clk_ops;
 
 struct scmi_clk {
@@ -78,28 +81,28 @@ static int scmi_clk_enable(struct clk_hw *hw)
 {
        struct scmi_clk *clk = to_scmi_clk(hw);
 
-       return scmi_proto_clk_ops->enable(clk->ph, clk->id);
+       return scmi_proto_clk_ops->enable(clk->ph, clk->id, NOT_ATOMIC);
 }
 
 static void scmi_clk_disable(struct clk_hw *hw)
 {
        struct scmi_clk *clk = to_scmi_clk(hw);
 
-       scmi_proto_clk_ops->disable(clk->ph, clk->id);
+       scmi_proto_clk_ops->disable(clk->ph, clk->id, NOT_ATOMIC);
 }
 
 static int scmi_clk_atomic_enable(struct clk_hw *hw)
 {
        struct scmi_clk *clk = to_scmi_clk(hw);
 
-       return scmi_proto_clk_ops->enable_atomic(clk->ph, clk->id);
+       return scmi_proto_clk_ops->enable(clk->ph, clk->id, ATOMIC);
 }
 
 static void scmi_clk_atomic_disable(struct clk_hw *hw)
 {
        struct scmi_clk *clk = to_scmi_clk(hw);
 
-       scmi_proto_clk_ops->disable_atomic(clk->ph, clk->id);
+       scmi_proto_clk_ops->disable(clk->ph, clk->id, ATOMIC);
 }
 
 /*
index 96060bf90a24abd63c36a9f702e6c633c01083a1..447d29b5fc72dc016ca065f812eb62c8be6f3138 100644 (file)
@@ -418,26 +418,16 @@ scmi_clock_config_set(const struct scmi_protocol_handle *ph, u32 clk_id,
        return ret;
 }
 
-static int scmi_clock_enable(const struct scmi_protocol_handle *ph, u32 clk_id)
+static int scmi_clock_enable(const struct scmi_protocol_handle *ph, u32 clk_id,
+                            bool atomic)
 {
-       return scmi_clock_config_set(ph, clk_id, CLOCK_ENABLE, false);
+       return scmi_clock_config_set(ph, clk_id, CLOCK_ENABLE, atomic);
 }
 
-static int scmi_clock_disable(const struct scmi_protocol_handle *ph, u32 clk_id)
+static int scmi_clock_disable(const struct scmi_protocol_handle *ph, u32 clk_id,
+                             bool atomic)
 {
-       return scmi_clock_config_set(ph, clk_id, 0, false);
-}
-
-static int scmi_clock_enable_atomic(const struct scmi_protocol_handle *ph,
-                                   u32 clk_id)
-{
-       return scmi_clock_config_set(ph, clk_id, CLOCK_ENABLE, true);
-}
-
-static int scmi_clock_disable_atomic(const struct scmi_protocol_handle *ph,
-                                    u32 clk_id)
-{
-       return scmi_clock_config_set(ph, clk_id, 0, true);
+       return scmi_clock_config_set(ph, clk_id, 0, atomic);
 }
 
 static int scmi_clock_count_get(const struct scmi_protocol_handle *ph)
@@ -470,8 +460,6 @@ static const struct scmi_clk_proto_ops clk_proto_ops = {
        .rate_set = scmi_clock_rate_set,
        .enable = scmi_clock_enable,
        .disable = scmi_clock_disable,
-       .enable_atomic = scmi_clock_enable_atomic,
-       .disable_atomic = scmi_clock_disable_atomic,
 };
 
 static int scmi_clk_rate_notify(const struct scmi_protocol_handle *ph,
index e6fe4f73ffe62bf5c177d261a7ea50f30bb4ad8a..b4c631a8d0ac244041cb10f81babe0ed4b403d94 100644 (file)
@@ -90,11 +90,10 @@ struct scmi_clk_proto_ops {
                        u64 *rate);
        int (*rate_set)(const struct scmi_protocol_handle *ph, u32 clk_id,
                        u64 rate);
-       int (*enable)(const struct scmi_protocol_handle *ph, u32 clk_id);
-       int (*disable)(const struct scmi_protocol_handle *ph, u32 clk_id);
-       int (*enable_atomic)(const struct scmi_protocol_handle *ph, u32 clk_id);
-       int (*disable_atomic)(const struct scmi_protocol_handle *ph,
-                             u32 clk_id);
+       int (*enable)(const struct scmi_protocol_handle *ph, u32 clk_id,
+                     bool atomic);
+       int (*disable)(const struct scmi_protocol_handle *ph, u32 clk_id,
+                      bool atomic);
 };
 
 /**