Lines Matching +full:fixed +full:- +full:rate

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
10 #include <linux/clk-provider.h>
11 #include <linux/interconnect-clk.h>
12 #include <linux/reset-controller.h>
16 #include "clk-rcg.h"
17 #include "clk-regmap.h"
28 struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate) in qcom_find_freq() argument
33 if (!f->freq) in qcom_find_freq()
36 for (; f->freq; f++) in qcom_find_freq()
37 if (rate <= f->freq) in qcom_find_freq()
40 /* Default to our fastest rate */ in qcom_find_freq()
41 return f - 1; in qcom_find_freq()
46 unsigned long rate) in qcom_find_freq_multi() argument
51 if (!f->freq) in qcom_find_freq_multi()
54 for (; f->freq; f++) in qcom_find_freq_multi()
55 if (rate <= f->freq) in qcom_find_freq_multi()
58 /* Default to our fastest rate */ in qcom_find_freq_multi()
59 return f - 1; in qcom_find_freq_multi()
64 unsigned long rate) in qcom_find_freq_floor() argument
68 for ( ; f->freq; f++) { in qcom_find_freq_floor()
69 if (rate >= f->freq) in qcom_find_freq_floor()
87 return -ENOENT; in qcom_find_src_index()
99 return -ENOENT; in qcom_find_cfg_index()
107 struct device *dev = &pdev->dev; in qcom_cc_map()
113 return devm_regmap_init_mmio(dev, base, desc->config); in qcom_cc_map()
123 /* De-assert reset to FSM */ in qcom_pll_set_fsm_mode()
144 * Backwards compatibility with old DTs. Register a pass-through factor 1/1
146 * clk as a fixed rate clock if it isn't present.
149 const char *name, unsigned long rate, in _qcom_cc_register_board_clk() argument
155 struct clk_fixed_rate *fixed; in _qcom_cc_register_board_clk() local
166 fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL); in _qcom_cc_register_board_clk()
167 if (!fixed) in _qcom_cc_register_board_clk()
168 return -EINVAL; in _qcom_cc_register_board_clk()
170 fixed->fixed_rate = rate; in _qcom_cc_register_board_clk()
171 fixed->hw.init = &init_data; in _qcom_cc_register_board_clk()
176 ret = devm_clk_hw_register(dev, &fixed->hw); in _qcom_cc_register_board_clk()
185 return -EINVAL; in _qcom_cc_register_board_clk()
187 factor->mult = factor->div = 1; in _qcom_cc_register_board_clk()
188 factor->hw.init = &init_data; in _qcom_cc_register_board_clk()
196 ret = devm_clk_hw_register(dev, &factor->hw); in _qcom_cc_register_board_clk()
205 const char *name, unsigned long rate) in qcom_cc_register_board_clk() argument
215 return _qcom_cc_register_board_clk(dev, path, name, rate, add_factor); in qcom_cc_register_board_clk()
226 /* Drop 'protected-clocks' from the list of clocks to register */
229 struct device_node *np = dev->of_node; in qcom_cc_drop_protected()
232 of_property_for_each_u32(np, "protected-clocks", i) { in qcom_cc_drop_protected()
233 if (i >= cc->num_rclks) in qcom_cc_drop_protected()
236 cc->rclks[i] = NULL; in qcom_cc_drop_protected()
244 unsigned int idx = clkspec->args[0]; in qcom_cc_clk_hw_get()
246 if (idx >= cc->num_rclks) { in qcom_cc_clk_hw_get()
248 return ERR_PTR(-EINVAL); in qcom_cc_clk_hw_get()
251 return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; in qcom_cc_clk_hw_get()
264 if (!desc->icc_hws) in qcom_cc_icc_register()
267 icd = devm_kcalloc(dev, desc->num_icc_hws, sizeof(*icd), GFP_KERNEL); in qcom_cc_icc_register()
269 return -ENOMEM; in qcom_cc_icc_register()
271 for (i = 0; i < desc->num_icc_hws; i++) { in qcom_cc_icc_register()
272 icd[i].master_id = desc->icc_hws[i].master_id; in qcom_cc_icc_register()
273 icd[i].slave_id = desc->icc_hws[i].slave_id; in qcom_cc_icc_register()
274 hws = &desc->clks[desc->icc_hws[i].clk_id]->hw; in qcom_cc_icc_register()
277 return dev_err_probe(dev, -ENOENT, in qcom_cc_icc_register()
282 return devm_icc_clk_register(dev, desc->icc_first_node_id, in qcom_cc_icc_register()
283 desc->num_icc_hws, icd); in qcom_cc_icc_register()
293 size_t num_clks = desc->num_clks; in qcom_cc_really_probe()
294 struct clk_regmap **rclks = desc->clks; in qcom_cc_really_probe()
295 size_t num_clk_hws = desc->num_clk_hws; in qcom_cc_really_probe()
296 struct clk_hw **clk_hws = desc->clk_hws; in qcom_cc_really_probe()
300 return -ENOMEM; in qcom_cc_really_probe()
302 reset = &cc->reset; in qcom_cc_really_probe()
303 reset->rcdev.of_node = dev->of_node; in qcom_cc_really_probe()
304 reset->rcdev.ops = &qcom_reset_ops; in qcom_cc_really_probe()
305 reset->rcdev.owner = dev->driver->owner; in qcom_cc_really_probe()
306 reset->rcdev.nr_resets = desc->num_resets; in qcom_cc_really_probe()
307 reset->regmap = regmap; in qcom_cc_really_probe()
308 reset->reset_map = desc->resets; in qcom_cc_really_probe()
310 ret = devm_reset_controller_register(dev, &reset->rcdev); in qcom_cc_really_probe()
314 if (desc->gdscs && desc->num_gdscs) { in qcom_cc_really_probe()
317 return -ENOMEM; in qcom_cc_really_probe()
318 scd->dev = dev; in qcom_cc_really_probe()
319 scd->scs = desc->gdscs; in qcom_cc_really_probe()
320 scd->num = desc->num_gdscs; in qcom_cc_really_probe()
321 ret = gdsc_register(scd, &reset->rcdev, regmap); in qcom_cc_really_probe()
330 cc->rclks = rclks; in qcom_cc_really_probe()
331 cc->num_rclks = num_clks; in qcom_cc_really_probe()
366 return qcom_cc_really_probe(&pdev->dev, desc, regmap); in qcom_cc_probe()
378 return -ENOMEM; in qcom_cc_probe_by_index()
380 regmap = devm_regmap_init_mmio(&pdev->dev, base, desc->config); in qcom_cc_probe_by_index()
384 return qcom_cc_really_probe(&pdev->dev, desc, regmap); in qcom_cc_probe_by_index()