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
24 #include <linux/regulator/driver.h>
25 #include <linux/regulator/fixed.h>
29 #include <linux/regulator/of_regulator.h>
30 #include <linux/regulator/machine.h>
55 ret = clk_prepare_enable(priv->enable_clock); in reg_clock_enable()
59 priv->enable_counter++; in reg_clock_enable()
68 clk_disable_unprepare(priv->enable_clock); in reg_clock_disable()
69 priv->enable_counter--; in reg_clock_disable()
77 struct device *dev = rdev->dev.parent; in reg_domain_enable()
80 ret = dev_pm_genpd_set_performance_state(dev, priv->performance_state); in reg_domain_enable()
84 priv->enable_counter++; in reg_domain_enable()
92 struct device *dev = rdev->dev.parent; in reg_domain_disable()
99 priv->enable_counter--; in reg_domain_disable()
108 return priv->enable_counter > 0; in reg_is_enabled()
114 struct regulator_dev *rdev = priv->dev; in reg_fixed_under_voltage_irq_handler()
123 * reg_fixed_get_irqs - Get and register the optional IRQ for fixed voltage
124 * regulator.
140 /* This is optional IRQ. If not found we will get -EINVAL */ in reg_fixed_get_irqs()
141 if (ret == -EINVAL) in reg_fixed_get_irqs()
148 IRQF_ONESHOT, "under-voltage", priv); in reg_fixed_get_irqs()
156 * of_get_fixed_voltage_config - extract fixed_voltage_config structure info
158 * @desc: regulator description
169 struct device_node *np = dev->of_node; in of_get_fixed_voltage_config()
175 return ERR_PTR(-ENOMEM); in of_get_fixed_voltage_config()
177 config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc); in of_get_fixed_voltage_config()
178 if (!config->init_data) in of_get_fixed_voltage_config()
179 return ERR_PTR(-EINVAL); in of_get_fixed_voltage_config()
181 init_data = config->init_data; in of_get_fixed_voltage_config()
182 init_data->constraints.apply_uV = 0; in of_get_fixed_voltage_config()
184 config->supply_name = init_data->constraints.name; in of_get_fixed_voltage_config()
185 if (init_data->constraints.min_uV == init_data->constraints.max_uV) { in of_get_fixed_voltage_config()
186 config->microvolts = init_data->constraints.min_uV; in of_get_fixed_voltage_config()
189 "Fixed regulator specified with variable voltages\n"); in of_get_fixed_voltage_config()
190 return ERR_PTR(-EINVAL); in of_get_fixed_voltage_config()
193 if (init_data->constraints.boot_on) in of_get_fixed_voltage_config()
194 config->enabled_at_boot = true; in of_get_fixed_voltage_config()
196 of_property_read_u32(np, "startup-delay-us", &config->startup_delay); in of_get_fixed_voltage_config()
197 of_property_read_u32(np, "off-on-delay-us", &config->off_on_delay); in of_get_fixed_voltage_config()
199 if (of_property_present(np, "vin-supply")) in of_get_fixed_voltage_config()
200 config->input_supply = "vin"; in of_get_fixed_voltage_config()
222 struct device *dev = &pdev->dev; in reg_fixed_voltage_probe()
230 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), in reg_fixed_voltage_probe()
233 return -ENOMEM; in reg_fixed_voltage_probe()
235 if (pdev->dev.of_node) { in reg_fixed_voltage_probe()
236 config = of_get_fixed_voltage_config(&pdev->dev, in reg_fixed_voltage_probe()
237 &drvdata->desc); in reg_fixed_voltage_probe()
241 config = dev_get_platdata(&pdev->dev); in reg_fixed_voltage_probe()
245 return -ENOMEM; in reg_fixed_voltage_probe()
247 drvdata->desc.name = devm_kstrdup(&pdev->dev, in reg_fixed_voltage_probe()
248 config->supply_name, in reg_fixed_voltage_probe()
250 if (drvdata->desc.name == NULL) { in reg_fixed_voltage_probe()
251 dev_err(&pdev->dev, "Failed to allocate supply name\n"); in reg_fixed_voltage_probe()
252 return -ENOMEM; in reg_fixed_voltage_probe()
254 drvdata->desc.type = REGULATOR_VOLTAGE; in reg_fixed_voltage_probe()
255 drvdata->desc.owner = THIS_MODULE; in reg_fixed_voltage_probe()
257 if (drvtype && drvtype->has_enable_clock) { in reg_fixed_voltage_probe()
258 drvdata->desc.ops = &fixed_voltage_clkenabled_ops; in reg_fixed_voltage_probe()
260 drvdata->enable_clock = devm_clk_get(dev, NULL); in reg_fixed_voltage_probe()
261 if (IS_ERR(drvdata->enable_clock)) { in reg_fixed_voltage_probe()
262 dev_err(dev, "Can't get enable-clock from devicetree\n"); in reg_fixed_voltage_probe()
263 return PTR_ERR(drvdata->enable_clock); in reg_fixed_voltage_probe()
265 } else if (drvtype && drvtype->has_performance_state) { in reg_fixed_voltage_probe()
266 drvdata->desc.ops = &fixed_voltage_domain_ops; in reg_fixed_voltage_probe()
268 drvdata->performance_state = of_get_required_opp_performance_state(dev->of_node, 0); in reg_fixed_voltage_probe()
269 if (drvdata->performance_state < 0) { in reg_fixed_voltage_probe()
271 return drvdata->performance_state; in reg_fixed_voltage_probe()
274 drvdata->desc.ops = &fixed_voltage_ops; in reg_fixed_voltage_probe()
277 drvdata->desc.enable_time = config->startup_delay; in reg_fixed_voltage_probe()
278 drvdata->desc.off_on_delay = config->off_on_delay; in reg_fixed_voltage_probe()
280 if (config->input_supply) { in reg_fixed_voltage_probe()
281 drvdata->desc.supply_name = devm_kstrdup(&pdev->dev, in reg_fixed_voltage_probe()
282 config->input_supply, in reg_fixed_voltage_probe()
284 if (!drvdata->desc.supply_name) in reg_fixed_voltage_probe()
285 return -ENOMEM; in reg_fixed_voltage_probe()
288 if (config->microvolts) in reg_fixed_voltage_probe()
289 drvdata->desc.n_voltages = 1; in reg_fixed_voltage_probe()
291 drvdata->desc.fixed_uV = config->microvolts; in reg_fixed_voltage_probe()
297 if (config->enabled_at_boot) in reg_fixed_voltage_probe()
303 * Some fixed regulators share the enable line between two in reg_fixed_voltage_probe()
316 * Do not use devm* here: the regulator core takes over the in reg_fixed_voltage_probe()
319 cfg.ena_gpiod = gpiod_get_optional(&pdev->dev, NULL, gflags); in reg_fixed_voltage_probe()
321 return dev_err_probe(&pdev->dev, PTR_ERR(cfg.ena_gpiod), in reg_fixed_voltage_probe()
324 cfg.dev = &pdev->dev; in reg_fixed_voltage_probe()
325 cfg.init_data = config->init_data; in reg_fixed_voltage_probe()
327 cfg.of_node = pdev->dev.of_node; in reg_fixed_voltage_probe()
329 drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc, in reg_fixed_voltage_probe()
331 if (IS_ERR(drvdata->dev)) { in reg_fixed_voltage_probe()
332 ret = dev_err_probe(&pdev->dev, PTR_ERR(drvdata->dev), in reg_fixed_voltage_probe()
333 "Failed to register regulator: %ld\n", in reg_fixed_voltage_probe()
334 PTR_ERR(drvdata->dev)); in reg_fixed_voltage_probe()
340 dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, in reg_fixed_voltage_probe()
341 drvdata->desc.fixed_uV); in reg_fixed_voltage_probe()
365 .compatible = "regulator-fixed",
369 .compatible = "regulator-fixed-clock",
373 .compatible = "regulator-fixed-domain",
385 .name = "reg-fixed-voltage",
404 MODULE_DESCRIPTION("Fixed voltage regulator");
406 MODULE_ALIAS("platform:reg-fixed-voltage");