Lines Matching +full:clock +full:- +full:freq +full:- +full:min +full:- +full:max
1 // SPDX-License-Identifier: GPL-2.0-only
3 * System Control and Power Interface (SCPI) Protocol based clock driver
8 #include <linux/clk-provider.h>
32 return clk->scpi_ops->clk_get_val(clk->id); in scpi_clk_recalc_rate()
41 * after the rate is set and we'll know what rate the clock is in scpi_clk_determine_rate()
52 return clk->scpi_ops->clk_set_val(clk->id, rate); in scpi_clk_set_rate()
66 const struct scpi_opp *opp = clk->info->opps; in __scpi_dvfs_round_rate()
68 for (idx = 0; idx < clk->info->count; idx++, opp++) { in __scpi_dvfs_round_rate()
69 ftmp = opp->freq; in __scpi_dvfs_round_rate()
85 int idx = clk->scpi_ops->dvfs_get_idx(clk->id); in scpi_dvfs_recalc_rate()
91 opp = clk->info->opps + idx; in scpi_dvfs_recalc_rate()
92 return opp->freq; in scpi_dvfs_recalc_rate()
100 req->rate = __scpi_dvfs_round_rate(clk, req->rate); in scpi_dvfs_determine_rate()
107 int idx, max_opp = clk->info->count; in __scpi_find_dvfs_index()
108 const struct scpi_opp *opp = clk->info->opps; in __scpi_find_dvfs_index()
111 if (opp->freq == rate) in __scpi_find_dvfs_index()
113 return -EINVAL; in __scpi_find_dvfs_index()
124 return clk->scpi_ops->dvfs_set_idx(clk->id, (u8)ret); in scpi_dvfs_set_rate()
134 { .compatible = "arm,scpi-dvfs-clocks", .data = &scpi_dvfs_ops, },
135 { .compatible = "arm,scpi-variable-clocks", .data = &scpi_clk_ops, },
144 unsigned long min = 0, max = 0; in scpi_clk_ops_init() local
150 init.ops = match->data; in scpi_clk_ops_init()
151 sclk->hw.init = &init; in scpi_clk_ops_init()
152 sclk->scpi_ops = get_scpi_ops(); in scpi_clk_ops_init()
155 sclk->info = sclk->scpi_ops->dvfs_get_info(sclk->id); in scpi_clk_ops_init()
156 if (IS_ERR(sclk->info)) in scpi_clk_ops_init()
157 return PTR_ERR(sclk->info); in scpi_clk_ops_init()
159 if (sclk->scpi_ops->clk_get_range(sclk->id, &min, &max) || !max) in scpi_clk_ops_init()
160 return -EINVAL; in scpi_clk_ops_init()
162 return -EINVAL; in scpi_clk_ops_init()
165 ret = devm_clk_hw_register(dev, &sclk->hw); in scpi_clk_ops_init()
166 if (!ret && max) in scpi_clk_ops_init()
167 clk_hw_set_rate_range(&sclk->hw, min, max); in scpi_clk_ops_init()
181 unsigned int idx = clkspec->args[0], count; in scpi_of_clk_src_get()
183 for (count = 0; count < clk_data->clk_num; count++) { in scpi_of_clk_src_get()
184 sclk = clk_data->clk[count]; in scpi_of_clk_src_get()
185 if (idx == sclk->id) in scpi_of_clk_src_get()
186 return &sclk->hw; in scpi_of_clk_src_get()
189 return ERR_PTR(-EINVAL); in scpi_of_clk_src_get()
198 count = of_property_count_strings(np, "clock-output-names"); in scpi_clk_add()
200 dev_err(dev, "%pOFn: invalid clock output count\n", np); in scpi_clk_add()
201 return -EINVAL; in scpi_clk_add()
206 return -ENOMEM; in scpi_clk_add()
208 clk_data->clk_num = count; in scpi_clk_add()
209 clk_data->clk = devm_kcalloc(dev, count, sizeof(*clk_data->clk), in scpi_clk_add()
211 if (!clk_data->clk) in scpi_clk_add()
212 return -ENOMEM; in scpi_clk_add()
221 return -ENOMEM; in scpi_clk_add()
223 if (of_property_read_string_index(np, "clock-output-names", in scpi_clk_add()
225 dev_err(dev, "invalid clock name @ %pOFn\n", np); in scpi_clk_add()
226 return -EINVAL; in scpi_clk_add()
229 if (of_property_read_u32_index(np, "clock-indices", in scpi_clk_add()
231 dev_err(dev, "invalid clock index @ %pOFn\n", np); in scpi_clk_add()
232 return -EINVAL; in scpi_clk_add()
235 sclk->id = val; in scpi_clk_add()
239 dev_err(dev, "failed to register clock '%s'\n", name); in scpi_clk_add()
243 dev_dbg(dev, "Registered clock '%s'\n", name); in scpi_clk_add()
244 clk_data->clk[idx] = sclk; in scpi_clk_add()
252 struct device *dev = &pdev->dev; in scpi_clocks_remove()
253 struct device_node *child, *np = dev->of_node; in scpi_clocks_remove()
267 struct device *dev = &pdev->dev; in scpi_clocks_probe()
268 struct device_node *child, *np = dev->of_node; in scpi_clocks_probe()
272 return -ENXIO; in scpi_clocks_probe()
285 if (match->data != &scpi_dvfs_ops) in scpi_clocks_probe()
287 /* Add the virtual cpufreq device if it's DVFS clock provider */ in scpi_clocks_probe()
288 cpufreq_dev = platform_device_register_simple("scpi-cpufreq", in scpi_clocks_probe()
289 -1, NULL, 0); in scpi_clocks_probe()
297 { .compatible = "arm,scpi-clocks", },
313 MODULE_DESCRIPTION("ARM SCPI clock driver");