Lines Matching +full:gpio +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0-or-later
10 * Roger Quadros <ext-roger.quadros@nokia.com>
13 * non-controllable regulators, as well as for allowing testing on
26 #include <linux/gpio/consumer.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
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
171 struct device_node *np = dev->of_node; in of_get_fixed_voltage_config()
177 return ERR_PTR(-ENOMEM); in of_get_fixed_voltage_config()
179 config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc); in of_get_fixed_voltage_config()
180 if (!config->init_data) in of_get_fixed_voltage_config()
181 return ERR_PTR(-EINVAL); in of_get_fixed_voltage_config()
183 init_data = config->init_data; in of_get_fixed_voltage_config()
184 init_data->constraints.apply_uV = 0; in of_get_fixed_voltage_config()
186 config->supply_name = init_data->constraints.name; in of_get_fixed_voltage_config()
187 if (init_data->constraints.min_uV == init_data->constraints.max_uV) { in of_get_fixed_voltage_config()
188 config->microvolts = init_data->constraints.min_uV; in of_get_fixed_voltage_config()
192 return ERR_PTR(-EINVAL); in of_get_fixed_voltage_config()
195 if (init_data->constraints.boot_on) in of_get_fixed_voltage_config()
196 config->enabled_at_boot = true; in of_get_fixed_voltage_config()
198 of_property_read_u32(np, "startup-delay-us", &config->startup_delay); in of_get_fixed_voltage_config()
199 of_property_read_u32(np, "off-on-delay-us", &config->off_on_delay); in of_get_fixed_voltage_config()
201 if (of_property_present(np, "vin-supply")) in of_get_fixed_voltage_config()
202 config->input_supply = "vin"; in of_get_fixed_voltage_config()
224 struct device *dev = &pdev->dev; in reg_fixed_voltage_probe()
228 struct regulator_config cfg = { }; in reg_fixed_voltage_probe() local
232 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), in reg_fixed_voltage_probe()
235 return -ENOMEM; in reg_fixed_voltage_probe()
237 if (pdev->dev.of_node) { in reg_fixed_voltage_probe()
238 config = of_get_fixed_voltage_config(&pdev->dev, in reg_fixed_voltage_probe()
239 &drvdata->desc); in reg_fixed_voltage_probe()
243 config = dev_get_platdata(&pdev->dev); in reg_fixed_voltage_probe()
247 return -ENOMEM; in reg_fixed_voltage_probe()
249 drvdata->desc.name = devm_kstrdup(&pdev->dev, in reg_fixed_voltage_probe()
250 config->supply_name, in reg_fixed_voltage_probe()
252 if (drvdata->desc.name == NULL) { in reg_fixed_voltage_probe()
253 dev_err(&pdev->dev, "Failed to allocate supply name\n"); in reg_fixed_voltage_probe()
254 return -ENOMEM; in reg_fixed_voltage_probe()
256 drvdata->desc.type = REGULATOR_VOLTAGE; in reg_fixed_voltage_probe()
257 drvdata->desc.owner = THIS_MODULE; in reg_fixed_voltage_probe()
259 if (drvtype && drvtype->has_enable_clock) { in reg_fixed_voltage_probe()
260 drvdata->desc.ops = &fixed_voltage_clkenabled_ops; in reg_fixed_voltage_probe()
262 drvdata->enable_clock = devm_clk_get(dev, NULL); in reg_fixed_voltage_probe()
263 if (IS_ERR(drvdata->enable_clock)) { in reg_fixed_voltage_probe()
264 dev_err(dev, "Can't get enable-clock from devicetree\n"); in reg_fixed_voltage_probe()
265 return PTR_ERR(drvdata->enable_clock); in reg_fixed_voltage_probe()
267 } else if (drvtype && drvtype->has_performance_state) { in reg_fixed_voltage_probe()
268 drvdata->desc.ops = &fixed_voltage_domain_ops; in reg_fixed_voltage_probe()
270 drvdata->performance_state = of_get_required_opp_performance_state(dev->of_node, 0); in reg_fixed_voltage_probe()
271 if (drvdata->performance_state < 0) { in reg_fixed_voltage_probe()
273 return drvdata->performance_state; in reg_fixed_voltage_probe()
276 drvdata->desc.ops = &fixed_voltage_ops; in reg_fixed_voltage_probe()
279 drvdata->desc.enable_time = config->startup_delay; in reg_fixed_voltage_probe()
280 drvdata->desc.off_on_delay = config->off_on_delay; in reg_fixed_voltage_probe()
282 if (config->input_supply) { in reg_fixed_voltage_probe()
283 drvdata->desc.supply_name = devm_kstrdup(&pdev->dev, in reg_fixed_voltage_probe()
284 config->input_supply, in reg_fixed_voltage_probe()
286 if (!drvdata->desc.supply_name) in reg_fixed_voltage_probe()
287 return -ENOMEM; in reg_fixed_voltage_probe()
290 if (config->microvolts) in reg_fixed_voltage_probe()
291 drvdata->desc.n_voltages = 1; in reg_fixed_voltage_probe()
293 drvdata->desc.fixed_uV = config->microvolts; in reg_fixed_voltage_probe()
296 * The signal will be inverted by the GPIO core if flagged so in the in reg_fixed_voltage_probe()
299 if (config->enabled_at_boot) in reg_fixed_voltage_probe()
308 * the GPIO descriptor, but only the first call will initialize in reg_fixed_voltage_probe()
319 * lifecycle management of the GPIO descriptor. in reg_fixed_voltage_probe()
321 cfg.ena_gpiod = gpiod_get_optional(&pdev->dev, NULL, gflags); in reg_fixed_voltage_probe()
322 if (IS_ERR(cfg.ena_gpiod)) in reg_fixed_voltage_probe()
323 return dev_err_probe(&pdev->dev, PTR_ERR(cfg.ena_gpiod), in reg_fixed_voltage_probe()
324 "can't get GPIO\n"); in reg_fixed_voltage_probe()
326 cfg.dev = &pdev->dev; in reg_fixed_voltage_probe()
327 cfg.init_data = config->init_data; in reg_fixed_voltage_probe()
328 cfg.driver_data = drvdata; in reg_fixed_voltage_probe()
329 cfg.of_node = pdev->dev.of_node; in reg_fixed_voltage_probe()
331 drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc, in reg_fixed_voltage_probe()
332 &cfg); in reg_fixed_voltage_probe()
333 if (IS_ERR(drvdata->dev)) { in reg_fixed_voltage_probe()
334 ret = dev_err_probe(&pdev->dev, PTR_ERR(drvdata->dev), in reg_fixed_voltage_probe()
336 PTR_ERR(drvdata->dev)); in reg_fixed_voltage_probe()
342 dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, in reg_fixed_voltage_probe()
343 drvdata->desc.fixed_uV); in reg_fixed_voltage_probe()
367 .compatible = "regulator-fixed",
371 .compatible = "regulator-fixed-clock",
375 .compatible = "regulator-fixed-domain",
387 .name = "reg-fixed-voltage",
408 MODULE_ALIAS("platform:reg-fixed-voltage");