Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: scmi: Port driver to the new scmi_clk_proto_ops interface

Port the scmi clock driver to the new SCMI clock interface based on
protocol handles and common devm_get_ops().

Link: https://lore.kernel.org/r/20210316124903.35011-19-cristian.marussi@arm.com
Link: https://lore.kernel.org/r/20210326132844.33360-1-cristian.marussi@arm.com
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

authored by

Cristian Marussi and committed by
Sudeep Holla
beb076bb 887281c7

+18 -10
+18 -10
drivers/clk/clk-scmi.c
··· 2 2 /* 3 3 * System Control and Power Interface (SCMI) Protocol based clock driver 4 4 * 5 - * Copyright (C) 2018 ARM Ltd. 5 + * Copyright (C) 2018-2021 ARM Ltd. 6 6 */ 7 7 8 8 #include <linux/clk-provider.h> ··· 13 13 #include <linux/scmi_protocol.h> 14 14 #include <asm/div64.h> 15 15 16 + static const struct scmi_clk_proto_ops *scmi_proto_clk_ops; 17 + 16 18 struct scmi_clk { 17 19 u32 id; 18 20 struct clk_hw hw; 19 21 const struct scmi_clock_info *info; 20 - const struct scmi_handle *handle; 22 + const struct scmi_protocol_handle *ph; 21 23 }; 22 24 23 25 #define to_scmi_clk(clk) container_of(clk, struct scmi_clk, hw) ··· 31 29 u64 rate; 32 30 struct scmi_clk *clk = to_scmi_clk(hw); 33 31 34 - ret = clk->handle->clk_ops->rate_get(clk->handle, clk->id, &rate); 32 + ret = scmi_proto_clk_ops->rate_get(clk->ph, clk->id, &rate); 35 33 if (ret) 36 34 return 0; 37 35 return rate; ··· 71 69 { 72 70 struct scmi_clk *clk = to_scmi_clk(hw); 73 71 74 - return clk->handle->clk_ops->rate_set(clk->handle, clk->id, rate); 72 + return scmi_proto_clk_ops->rate_set(clk->ph, clk->id, rate); 75 73 } 76 74 77 75 static int scmi_clk_enable(struct clk_hw *hw) 78 76 { 79 77 struct scmi_clk *clk = to_scmi_clk(hw); 80 78 81 - return clk->handle->clk_ops->enable(clk->handle, clk->id); 79 + return scmi_proto_clk_ops->enable(clk->ph, clk->id); 82 80 } 83 81 84 82 static void scmi_clk_disable(struct clk_hw *hw) 85 83 { 86 84 struct scmi_clk *clk = to_scmi_clk(hw); 87 85 88 - clk->handle->clk_ops->disable(clk->handle, clk->id); 86 + scmi_proto_clk_ops->disable(clk->ph, clk->id); 89 87 } 90 88 91 89 static const struct clk_ops scmi_clk_ops = { ··· 144 142 struct device *dev = &sdev->dev; 145 143 struct device_node *np = dev->of_node; 146 144 const struct scmi_handle *handle = sdev->handle; 145 + struct scmi_protocol_handle *ph; 147 146 148 - if (!handle || !handle->clk_ops) 147 + if (!handle) 149 148 return -ENODEV; 150 149 151 - count = handle->clk_ops->count_get(handle); 150 + scmi_proto_clk_ops = 151 + handle->devm_protocol_get(sdev, SCMI_PROTOCOL_CLOCK, &ph); 152 + if (IS_ERR(scmi_proto_clk_ops)) 153 + return PTR_ERR(scmi_proto_clk_ops); 154 + 155 + count = scmi_proto_clk_ops->count_get(ph); 152 156 if (count < 0) { 153 157 dev_err(dev, "%pOFn: invalid clock output count\n", np); 154 158 return -EINVAL; ··· 175 167 if (!sclk) 176 168 return -ENOMEM; 177 169 178 - sclk->info = handle->clk_ops->info_get(handle, idx); 170 + sclk->info = scmi_proto_clk_ops->info_get(ph, idx); 179 171 if (!sclk->info) { 180 172 dev_dbg(dev, "invalid clock info for idx %d\n", idx); 181 173 continue; 182 174 } 183 175 184 176 sclk->id = idx; 185 - sclk->handle = handle; 177 + sclk->ph = ph; 186 178 187 179 err = scmi_clk_ops_init(dev, sclk); 188 180 if (err) {