• Home
  • Raw
  • Download

Lines Matching +full:regulator +full:- +full:fixed +full:- +full:domain

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * fixed.c
10 * Roger Quadros <ext-roger.quadros@nokia.com>
13 * non-controllable regulators, as well as for allowing testing on
23 #include <linux/regulator/driver.h>
24 #include <linux/regulator/fixed.h>
28 #include <linux/regulator/of_regulator.h>
29 #include <linux/regulator/machine.h>
52 ret = clk_prepare_enable(priv->enable_clock); in reg_clock_enable()
56 priv->enable_counter++; in reg_clock_enable()
65 clk_disable_unprepare(priv->enable_clock); in reg_clock_disable()
66 priv->enable_counter--; in reg_clock_disable()
74 struct device *dev = rdev->dev.parent; in reg_domain_enable()
77 ret = dev_pm_genpd_set_performance_state(dev, priv->performance_state); in reg_domain_enable()
81 priv->enable_counter++; in reg_domain_enable()
89 struct device *dev = rdev->dev.parent; in reg_domain_disable()
96 priv->enable_counter--; in reg_domain_disable()
105 return priv->enable_counter > 0; in reg_is_enabled()
110 * of_get_fixed_voltage_config - extract fixed_voltage_config structure info
112 * @desc: regulator description
123 struct device_node *np = dev->of_node; in of_get_fixed_voltage_config()
129 return ERR_PTR(-ENOMEM); in of_get_fixed_voltage_config()
131 config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc); in of_get_fixed_voltage_config()
132 if (!config->init_data) in of_get_fixed_voltage_config()
133 return ERR_PTR(-EINVAL); in of_get_fixed_voltage_config()
135 init_data = config->init_data; in of_get_fixed_voltage_config()
136 init_data->constraints.apply_uV = 0; in of_get_fixed_voltage_config()
138 config->supply_name = init_data->constraints.name; in of_get_fixed_voltage_config()
139 if (init_data->constraints.min_uV == init_data->constraints.max_uV) { in of_get_fixed_voltage_config()
140 config->microvolts = init_data->constraints.min_uV; in of_get_fixed_voltage_config()
143 "Fixed regulator specified with variable voltages\n"); in of_get_fixed_voltage_config()
144 return ERR_PTR(-EINVAL); in of_get_fixed_voltage_config()
147 if (init_data->constraints.boot_on) in of_get_fixed_voltage_config()
148 config->enabled_at_boot = true; in of_get_fixed_voltage_config()
150 of_property_read_u32(np, "startup-delay-us", &config->startup_delay); in of_get_fixed_voltage_config()
151 of_property_read_u32(np, "off-on-delay-us", &config->off_on_delay); in of_get_fixed_voltage_config()
153 if (of_property_present(np, "vin-supply")) in of_get_fixed_voltage_config()
154 config->input_supply = "vin"; in of_get_fixed_voltage_config()
176 struct device *dev = &pdev->dev; in reg_fixed_voltage_probe()
184 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), in reg_fixed_voltage_probe()
187 return -ENOMEM; in reg_fixed_voltage_probe()
189 if (pdev->dev.of_node) { in reg_fixed_voltage_probe()
190 config = of_get_fixed_voltage_config(&pdev->dev, in reg_fixed_voltage_probe()
191 &drvdata->desc); in reg_fixed_voltage_probe()
195 config = dev_get_platdata(&pdev->dev); in reg_fixed_voltage_probe()
199 return -ENOMEM; in reg_fixed_voltage_probe()
201 drvdata->desc.name = devm_kstrdup(&pdev->dev, in reg_fixed_voltage_probe()
202 config->supply_name, in reg_fixed_voltage_probe()
204 if (drvdata->desc.name == NULL) { in reg_fixed_voltage_probe()
205 dev_err(&pdev->dev, "Failed to allocate supply name\n"); in reg_fixed_voltage_probe()
206 return -ENOMEM; in reg_fixed_voltage_probe()
208 drvdata->desc.type = REGULATOR_VOLTAGE; in reg_fixed_voltage_probe()
209 drvdata->desc.owner = THIS_MODULE; in reg_fixed_voltage_probe()
211 if (drvtype && drvtype->has_enable_clock) { in reg_fixed_voltage_probe()
212 drvdata->desc.ops = &fixed_voltage_clkenabled_ops; in reg_fixed_voltage_probe()
214 drvdata->enable_clock = devm_clk_get(dev, NULL); in reg_fixed_voltage_probe()
215 if (IS_ERR(drvdata->enable_clock)) { in reg_fixed_voltage_probe()
216 dev_err(dev, "Can't get enable-clock from devicetree\n"); in reg_fixed_voltage_probe()
217 return PTR_ERR(drvdata->enable_clock); in reg_fixed_voltage_probe()
219 } else if (drvtype && drvtype->has_performance_state) { in reg_fixed_voltage_probe()
220 drvdata->desc.ops = &fixed_voltage_domain_ops; in reg_fixed_voltage_probe()
222 drvdata->performance_state = of_get_required_opp_performance_state(dev->of_node, 0); in reg_fixed_voltage_probe()
223 if (drvdata->performance_state < 0) { in reg_fixed_voltage_probe()
225 return drvdata->performance_state; in reg_fixed_voltage_probe()
228 drvdata->desc.ops = &fixed_voltage_ops; in reg_fixed_voltage_probe()
231 drvdata->desc.enable_time = config->startup_delay; in reg_fixed_voltage_probe()
232 drvdata->desc.off_on_delay = config->off_on_delay; in reg_fixed_voltage_probe()
234 if (config->input_supply) { in reg_fixed_voltage_probe()
235 drvdata->desc.supply_name = devm_kstrdup(&pdev->dev, in reg_fixed_voltage_probe()
236 config->input_supply, in reg_fixed_voltage_probe()
238 if (!drvdata->desc.supply_name) in reg_fixed_voltage_probe()
239 return -ENOMEM; in reg_fixed_voltage_probe()
242 if (config->microvolts) in reg_fixed_voltage_probe()
243 drvdata->desc.n_voltages = 1; in reg_fixed_voltage_probe()
245 drvdata->desc.fixed_uV = config->microvolts; in reg_fixed_voltage_probe()
251 if (config->enabled_at_boot) in reg_fixed_voltage_probe()
257 * Some fixed regulators share the enable line between two in reg_fixed_voltage_probe()
270 * Do not use devm* here: the regulator core takes over the in reg_fixed_voltage_probe()
273 cfg.ena_gpiod = gpiod_get_optional(&pdev->dev, NULL, gflags); in reg_fixed_voltage_probe()
275 return dev_err_probe(&pdev->dev, PTR_ERR(cfg.ena_gpiod), in reg_fixed_voltage_probe()
278 cfg.dev = &pdev->dev; in reg_fixed_voltage_probe()
279 cfg.init_data = config->init_data; in reg_fixed_voltage_probe()
281 cfg.of_node = pdev->dev.of_node; in reg_fixed_voltage_probe()
283 drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc, in reg_fixed_voltage_probe()
285 if (IS_ERR(drvdata->dev)) { in reg_fixed_voltage_probe()
286 ret = dev_err_probe(&pdev->dev, PTR_ERR(drvdata->dev), in reg_fixed_voltage_probe()
287 "Failed to register regulator: %ld\n", in reg_fixed_voltage_probe()
288 PTR_ERR(drvdata->dev)); in reg_fixed_voltage_probe()
294 dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, in reg_fixed_voltage_probe()
295 drvdata->desc.fixed_uV); in reg_fixed_voltage_probe()
315 .compatible = "regulator-fixed",
319 .compatible = "regulator-fixed-clock",
323 .compatible = "regulator-fixed-domain",
335 .name = "reg-fixed-voltage",
354 MODULE_DESCRIPTION("Fixed voltage regulator");
356 MODULE_ALIAS("platform:reg-fixed-voltage");