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/reset-controller.h>
15 #include "clk-rcg.h"
16 #include "clk-regmap.h"
27 struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate) in qcom_find_freq() argument
32 if (!f->freq) in qcom_find_freq()
35 for (; f->freq; f++) in qcom_find_freq()
36 if (rate <= f->freq) in qcom_find_freq()
39 /* Default to our fastest rate */ in qcom_find_freq()
40 return f - 1; in qcom_find_freq()
45 unsigned long rate) in qcom_find_freq_floor() argument
49 for ( ; f->freq; f++) { in qcom_find_freq_floor()
50 if (rate >= f->freq) in qcom_find_freq_floor()
68 return -ENOENT; in qcom_find_src_index()
80 return -ENOENT; in qcom_find_cfg_index()
88 struct device *dev = &pdev->dev; in qcom_cc_map()
94 return devm_regmap_init_mmio(dev, base, desc->config); in qcom_cc_map()
104 /* De-assert reset to FSM */ in qcom_pll_set_fsm_mode()
125 * Backwards compatibility with old DTs. Register a pass-through factor 1/1
127 * clk as a fixed rate clock if it isn't present.
130 const char *name, unsigned long rate, in _qcom_cc_register_board_clk() argument
136 struct clk_fixed_rate *fixed; in _qcom_cc_register_board_clk() local
147 fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL); in _qcom_cc_register_board_clk()
148 if (!fixed) in _qcom_cc_register_board_clk()
149 return -EINVAL; in _qcom_cc_register_board_clk()
151 fixed->fixed_rate = rate; in _qcom_cc_register_board_clk()
152 fixed->hw.init = &init_data; in _qcom_cc_register_board_clk()
157 ret = devm_clk_hw_register(dev, &fixed->hw); in _qcom_cc_register_board_clk()
166 return -EINVAL; in _qcom_cc_register_board_clk()
168 factor->mult = factor->div = 1; in _qcom_cc_register_board_clk()
169 factor->hw.init = &init_data; in _qcom_cc_register_board_clk()
177 ret = devm_clk_hw_register(dev, &factor->hw); in _qcom_cc_register_board_clk()
186 const char *name, unsigned long rate) in qcom_cc_register_board_clk() argument
196 return _qcom_cc_register_board_clk(dev, path, name, rate, add_factor); in qcom_cc_register_board_clk()
207 /* Drop 'protected-clocks' from the list of clocks to register */
210 struct device_node *np = dev->of_node; in qcom_cc_drop_protected()
215 of_property_for_each_u32(np, "protected-clocks", prop, p, i) { in qcom_cc_drop_protected()
216 if (i >= cc->num_rclks) in qcom_cc_drop_protected()
219 cc->rclks[i] = NULL; in qcom_cc_drop_protected()
227 unsigned int idx = clkspec->args[0]; in qcom_cc_clk_hw_get()
229 if (idx >= cc->num_rclks) { in qcom_cc_clk_hw_get()
231 return ERR_PTR(-EINVAL); in qcom_cc_clk_hw_get()
234 return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; in qcom_cc_clk_hw_get()
241 struct device *dev = &pdev->dev; in qcom_cc_really_probe()
245 size_t num_clks = desc->num_clks; in qcom_cc_really_probe()
246 struct clk_regmap **rclks = desc->clks; in qcom_cc_really_probe()
247 size_t num_clk_hws = desc->num_clk_hws; in qcom_cc_really_probe()
248 struct clk_hw **clk_hws = desc->clk_hws; in qcom_cc_really_probe()
252 return -ENOMEM; in qcom_cc_really_probe()
254 reset = &cc->reset; in qcom_cc_really_probe()
255 reset->rcdev.of_node = dev->of_node; in qcom_cc_really_probe()
256 reset->rcdev.ops = &qcom_reset_ops; in qcom_cc_really_probe()
257 reset->rcdev.owner = dev->driver->owner; in qcom_cc_really_probe()
258 reset->rcdev.nr_resets = desc->num_resets; in qcom_cc_really_probe()
259 reset->regmap = regmap; in qcom_cc_really_probe()
260 reset->reset_map = desc->resets; in qcom_cc_really_probe()
262 ret = devm_reset_controller_register(dev, &reset->rcdev); in qcom_cc_really_probe()
266 if (desc->gdscs && desc->num_gdscs) { in qcom_cc_really_probe()
269 return -ENOMEM; in qcom_cc_really_probe()
270 scd->dev = dev; in qcom_cc_really_probe()
271 scd->scs = desc->gdscs; in qcom_cc_really_probe()
272 scd->num = desc->num_gdscs; in qcom_cc_really_probe()
273 ret = gdsc_register(scd, &reset->rcdev, regmap); in qcom_cc_really_probe()
282 cc->rclks = rclks; in qcom_cc_really_probe()
283 cc->num_rclks = num_clks; in qcom_cc_really_probe()
330 return -ENOMEM; in qcom_cc_probe_by_index()
332 regmap = devm_regmap_init_mmio(&pdev->dev, base, desc->config); in qcom_cc_probe_by_index()