Lines Matching +full:init +full:- +full:b +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0+
10 #include <linux/init.h>
84 const struct da9055_regulator_info *info = regulator->info; in da9055_buck_get_mode()
87 ret = da9055_reg_read(regulator->da9055, info->mode.reg); in da9055_buck_get_mode()
91 switch ((ret & info->mode.mask) >> info->mode.shift) { in da9055_buck_get_mode()
110 const struct da9055_regulator_info *info = regulator->info; in da9055_buck_set_mode()
115 val = DA9055_BUCK_MODE_SYNC << info->mode.shift; in da9055_buck_set_mode()
118 val = DA9055_BUCK_MODE_AUTO << info->mode.shift; in da9055_buck_set_mode()
121 val = DA9055_BUCK_MODE_SLEEP << info->mode.shift; in da9055_buck_set_mode()
125 return da9055_reg_update(regulator->da9055, info->mode.reg, in da9055_buck_set_mode()
126 info->mode.mask, val); in da9055_buck_set_mode()
132 const struct da9055_regulator_info *info = regulator->info; in da9055_ldo_get_mode()
135 ret = da9055_reg_read(regulator->da9055, info->volt.reg_b); in da9055_ldo_get_mode()
139 if (ret >> info->volt.sl_shift) in da9055_ldo_get_mode()
148 const struct da9055_regulator_info *info = regulator->info; in da9055_ldo_set_mode()
149 struct da9055_volt_reg volt = info->volt; in da9055_ldo_set_mode()
162 return da9055_reg_update(regulator->da9055, volt.reg_b, in da9055_ldo_set_mode()
170 const struct da9055_regulator_info *info = regulator->info; in da9055_regulator_get_voltage_sel()
171 struct da9055_volt_reg volt = info->volt; in da9055_regulator_get_voltage_sel()
175 * There are two voltage register set A & B for voltage ramping but in da9055_regulator_get_voltage_sel()
179 ret = da9055_reg_read(regulator->da9055, info->conf.reg); in da9055_regulator_get_voltage_sel()
183 ret &= info->conf.sel_mask; in da9055_regulator_get_voltage_sel()
185 /* Get the voltage for the active register set A/B */ in da9055_regulator_get_voltage_sel()
187 ret = da9055_reg_read(regulator->da9055, volt.reg_a); in da9055_regulator_get_voltage_sel()
189 ret = da9055_reg_read(regulator->da9055, volt.reg_b); in da9055_regulator_get_voltage_sel()
202 const struct da9055_regulator_info *info = regulator->info; in da9055_regulator_set_voltage_sel()
206 * Regulator register set A/B is not selected through GPIO therefore in da9055_regulator_set_voltage_sel()
209 if (regulator->reg_rselect == NO_GPIO) { in da9055_regulator_set_voltage_sel()
211 ret = da9055_reg_update(regulator->da9055, info->conf.reg, in da9055_regulator_set_voltage_sel()
212 info->conf.sel_mask, DA9055_SEL_REG_A); in da9055_regulator_set_voltage_sel()
217 return da9055_reg_update(regulator->da9055, info->volt.reg_a, in da9055_regulator_set_voltage_sel()
218 info->volt.v_mask, selector); in da9055_regulator_set_voltage_sel()
222 * Here regulator register set A/B is selected through GPIO. in da9055_regulator_set_voltage_sel()
223 * Therefore we first determine the selected register set A/B and in da9055_regulator_set_voltage_sel()
224 * then set the desired voltage for that register set A/B. in da9055_regulator_set_voltage_sel()
226 ret = da9055_reg_read(regulator->da9055, info->conf.reg); in da9055_regulator_set_voltage_sel()
230 ret &= info->conf.sel_mask; in da9055_regulator_set_voltage_sel()
234 return da9055_reg_update(regulator->da9055, info->volt.reg_a, in da9055_regulator_set_voltage_sel()
235 info->volt.v_mask, selector); in da9055_regulator_set_voltage_sel()
237 return da9055_reg_update(regulator->da9055, info->volt.reg_b, in da9055_regulator_set_voltage_sel()
238 info->volt.v_mask, selector); in da9055_regulator_set_voltage_sel()
245 const struct da9055_regulator_info *info = regulator->info; in da9055_regulator_set_suspend_voltage()
248 /* Select register set B for suspend voltage ramping. */ in da9055_regulator_set_suspend_voltage()
249 if (regulator->reg_rselect == NO_GPIO) { in da9055_regulator_set_suspend_voltage()
250 ret = da9055_reg_update(regulator->da9055, info->conf.reg, in da9055_regulator_set_suspend_voltage()
251 info->conf.sel_mask, DA9055_SEL_REG_B); in da9055_regulator_set_suspend_voltage()
260 return da9055_reg_update(regulator->da9055, info->volt.reg_b, in da9055_regulator_set_suspend_voltage()
261 info->volt.v_mask, ret); in da9055_regulator_set_suspend_voltage()
267 const struct da9055_regulator_info *info = regulator->info; in da9055_suspend_enable()
269 /* Select register set B for voltage ramping. */ in da9055_suspend_enable()
270 if (regulator->reg_rselect == NO_GPIO) in da9055_suspend_enable()
271 return da9055_reg_update(regulator->da9055, info->conf.reg, in da9055_suspend_enable()
272 info->conf.sel_mask, DA9055_SEL_REG_B); in da9055_suspend_enable()
280 const struct da9055_regulator_info *info = regulator->info; in da9055_suspend_disable()
282 /* Diselect register set B. */ in da9055_suspend_disable()
283 if (regulator->reg_rselect == NO_GPIO) in da9055_suspend_disable()
284 return da9055_reg_update(regulator->da9055, info->conf.reg, in da9055_suspend_disable()
285 info->conf.sel_mask, DA9055_SEL_REG_A); in da9055_suspend_disable()
339 .n_voltages = (max - min) / step + 1 + (voffset), \
356 .v_mask = (1 << (vbits)) - 1,\
369 .n_voltages = (max - min) / step + 1 + (voffset), \
390 .v_mask = (1 << (vbits)) - 1,\
413 * set A/B for voltage ramping.
420 const struct da9055_regulator_info *info = regulator->info; in da9055_gpio_init()
426 /* Look for "regulator-enable-gpios" GPIOs in the regulator node */ in da9055_gpio_init()
427 ren = devm_gpiod_get_optional(dev, "regulator-enable", GPIOD_IN); in da9055_gpio_init()
437 config->ena_gpiod = ena; in da9055_gpio_init()
449 ret = da9055_reg_update(regulator->da9055, info->conf.reg, in da9055_gpio_init()
451 pdata->reg_ren[id] in da9055_gpio_init()
457 /* Look for "regulator-select-gpios" GPIOs in the regulator node */ in da9055_gpio_init()
458 rsel = devm_gpiod_get_optional(dev, "regulator-select", GPIOD_IN); in da9055_gpio_init()
463 regulator->reg_rselect = pdata->reg_rsel[id]; in da9055_gpio_init()
467 * regulator register set A/B for voltage ramping. in da9055_gpio_init()
472 * Let the regulator know that its register set A/B in da9055_gpio_init()
475 ret = da9055_reg_update(regulator->da9055, info->conf.reg, in da9055_gpio_init()
477 pdata->reg_rsel[id] in da9055_gpio_init()
488 regulator_notifier_call_chain(regulator->rdev, in da9055_ldo5_6_oc_irq()
501 if (info->reg_desc.id == id) in find_regulator_info()
512 struct da9055 *da9055 = dev_get_drvdata(pdev->dev.parent); in da9055_regulator_probe()
513 struct da9055_pdata *pdata = dev_get_platdata(da9055->dev); in da9055_regulator_probe()
516 regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9055_regulator), in da9055_regulator_probe()
519 return -ENOMEM; in da9055_regulator_probe()
521 regulator->info = find_regulator_info(pdev->id); in da9055_regulator_probe()
522 if (regulator->info == NULL) { in da9055_regulator_probe()
523 dev_err(&pdev->dev, "invalid regulator ID specified\n"); in da9055_regulator_probe()
524 return -EINVAL; in da9055_regulator_probe()
527 regulator->da9055 = da9055; in da9055_regulator_probe()
528 config.dev = da9055->dev; in da9055_regulator_probe()
530 config.regmap = da9055->regmap; in da9055_regulator_probe()
533 config.init_data = pdata->regulators[pdev->id]; in da9055_regulator_probe()
535 ret = da9055_gpio_init(&pdev->dev, regulator, &config, pdata, pdev->id); in da9055_regulator_probe()
539 regulator->rdev = devm_regulator_register(&pdev->dev, in da9055_regulator_probe()
540 &regulator->info->reg_desc, in da9055_regulator_probe()
542 if (IS_ERR(regulator->rdev)) { in da9055_regulator_probe()
543 dev_err(&pdev->dev, "Failed to register regulator %s\n", in da9055_regulator_probe()
544 regulator->info->reg_desc.name); in da9055_regulator_probe()
545 return PTR_ERR(regulator->rdev); in da9055_regulator_probe()
549 if (pdev->id == DA9055_ID_LDO5 || pdev->id == DA9055_ID_LDO6) { in da9055_regulator_probe()
554 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, in da9055_regulator_probe()
559 pdev->name, regulator); in da9055_regulator_probe()
561 if (ret != -EBUSY) { in da9055_regulator_probe()
562 dev_err(&pdev->dev, in da9055_regulator_probe()
578 .name = "da9055-regulator",
598 MODULE_ALIAS("platform:da9055-regulator");