Lines Matching +full:ldo +full:-
1 // SPDX-License-Identifier: GPL-2.0+
3 // wm831x-ldo.c -- LDO driver for the WM831x series
47 struct wm831x_ldo *ldo = data; in wm831x_ldo_uv_irq() local
49 regulator_notifier_call_chain(ldo->regulator, in wm831x_ldo_uv_irq()
68 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_gp_ldo_set_suspend_voltage() local
69 struct wm831x *wm831x = ldo->wm831x; in wm831x_gp_ldo_set_suspend_voltage()
70 int sel, reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; in wm831x_gp_ldo_set_suspend_voltage()
81 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_gp_ldo_get_mode() local
82 struct wm831x *wm831x = ldo->wm831x; in wm831x_gp_ldo_get_mode()
83 int ctrl_reg = ldo->base + WM831X_LDO_CONTROL; in wm831x_gp_ldo_get_mode()
84 int on_reg = ldo->base + WM831X_LDO_ON_CONTROL; in wm831x_gp_ldo_get_mode()
107 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_gp_ldo_set_mode() local
108 struct wm831x *wm831x = ldo->wm831x; in wm831x_gp_ldo_set_mode()
109 int ctrl_reg = ldo->base + WM831X_LDO_CONTROL; in wm831x_gp_ldo_set_mode()
110 int on_reg = ldo->base + WM831X_LDO_ON_CONTROL; in wm831x_gp_ldo_set_mode()
150 return -EINVAL; in wm831x_gp_ldo_set_mode()
158 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_gp_ldo_get_status() local
159 struct wm831x *wm831x = ldo->wm831x; in wm831x_gp_ldo_get_status()
216 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); in wm831x_gp_ldo_probe()
217 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev); in wm831x_gp_ldo_probe()
220 struct wm831x_ldo *ldo; in wm831x_gp_ldo_probe() local
224 if (pdata && pdata->wm831x_num) in wm831x_gp_ldo_probe()
225 id = (pdata->wm831x_num * 10) + 1; in wm831x_gp_ldo_probe()
228 id = pdev->id - id; in wm831x_gp_ldo_probe()
230 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); in wm831x_gp_ldo_probe()
232 ldo = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_ldo), GFP_KERNEL); in wm831x_gp_ldo_probe()
233 if (!ldo) in wm831x_gp_ldo_probe()
234 return -ENOMEM; in wm831x_gp_ldo_probe()
236 ldo->wm831x = wm831x; in wm831x_gp_ldo_probe()
240 dev_err(&pdev->dev, "No REG resource\n"); in wm831x_gp_ldo_probe()
241 ret = -EINVAL; in wm831x_gp_ldo_probe()
244 ldo->base = res->start; in wm831x_gp_ldo_probe()
246 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); in wm831x_gp_ldo_probe()
247 ldo->desc.name = ldo->name; in wm831x_gp_ldo_probe()
249 snprintf(ldo->supply_name, sizeof(ldo->supply_name), in wm831x_gp_ldo_probe()
250 "LDO%dVDD", id + 1); in wm831x_gp_ldo_probe()
251 ldo->desc.supply_name = ldo->supply_name; in wm831x_gp_ldo_probe()
253 ldo->desc.id = id; in wm831x_gp_ldo_probe()
254 ldo->desc.type = REGULATOR_VOLTAGE; in wm831x_gp_ldo_probe()
255 ldo->desc.n_voltages = 32; in wm831x_gp_ldo_probe()
256 ldo->desc.ops = &wm831x_gp_ldo_ops; in wm831x_gp_ldo_probe()
257 ldo->desc.owner = THIS_MODULE; in wm831x_gp_ldo_probe()
258 ldo->desc.vsel_reg = ldo->base + WM831X_LDO_ON_CONTROL; in wm831x_gp_ldo_probe()
259 ldo->desc.vsel_mask = WM831X_LDO1_ON_VSEL_MASK; in wm831x_gp_ldo_probe()
260 ldo->desc.enable_reg = WM831X_LDO_ENABLE; in wm831x_gp_ldo_probe()
261 ldo->desc.enable_mask = 1 << id; in wm831x_gp_ldo_probe()
262 ldo->desc.bypass_reg = ldo->base; in wm831x_gp_ldo_probe()
263 ldo->desc.bypass_mask = WM831X_LDO1_SWI; in wm831x_gp_ldo_probe()
264 ldo->desc.linear_ranges = wm831x_gp_ldo_ranges; in wm831x_gp_ldo_probe()
265 ldo->desc.n_linear_ranges = ARRAY_SIZE(wm831x_gp_ldo_ranges); in wm831x_gp_ldo_probe()
267 config.dev = pdev->dev.parent; in wm831x_gp_ldo_probe()
269 config.init_data = pdata->ldo[id]; in wm831x_gp_ldo_probe()
270 config.driver_data = ldo; in wm831x_gp_ldo_probe()
271 config.regmap = wm831x->regmap; in wm831x_gp_ldo_probe()
273 ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, in wm831x_gp_ldo_probe()
275 if (IS_ERR(ldo->regulator)) { in wm831x_gp_ldo_probe()
276 ret = PTR_ERR(ldo->regulator); in wm831x_gp_ldo_probe()
277 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", in wm831x_gp_ldo_probe()
283 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, in wm831x_gp_ldo_probe()
286 ldo->name, in wm831x_gp_ldo_probe()
287 ldo); in wm831x_gp_ldo_probe()
289 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", in wm831x_gp_ldo_probe()
294 platform_set_drvdata(pdev, ldo); in wm831x_gp_ldo_probe()
305 .name = "wm831x-ldo",
322 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_aldo_set_suspend_voltage() local
323 struct wm831x *wm831x = ldo->wm831x; in wm831x_aldo_set_suspend_voltage()
324 int sel, reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; in wm831x_aldo_set_suspend_voltage()
335 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_aldo_get_mode() local
336 struct wm831x *wm831x = ldo->wm831x; in wm831x_aldo_get_mode()
337 int on_reg = ldo->base + WM831X_LDO_ON_CONTROL; in wm831x_aldo_get_mode()
353 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_aldo_set_mode() local
354 struct wm831x *wm831x = ldo->wm831x; in wm831x_aldo_set_mode()
355 int on_reg = ldo->base + WM831X_LDO_ON_CONTROL; in wm831x_aldo_set_mode()
374 return -EINVAL; in wm831x_aldo_set_mode()
382 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_aldo_get_status() local
383 struct wm831x *wm831x = ldo->wm831x; in wm831x_aldo_get_status()
427 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); in wm831x_aldo_probe()
428 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev); in wm831x_aldo_probe()
431 struct wm831x_ldo *ldo; in wm831x_aldo_probe() local
435 if (pdata && pdata->wm831x_num) in wm831x_aldo_probe()
436 id = (pdata->wm831x_num * 10) + 1; in wm831x_aldo_probe()
439 id = pdev->id - id; in wm831x_aldo_probe()
441 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); in wm831x_aldo_probe()
443 ldo = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_ldo), GFP_KERNEL); in wm831x_aldo_probe()
444 if (!ldo) in wm831x_aldo_probe()
445 return -ENOMEM; in wm831x_aldo_probe()
447 ldo->wm831x = wm831x; in wm831x_aldo_probe()
451 dev_err(&pdev->dev, "No REG resource\n"); in wm831x_aldo_probe()
452 ret = -EINVAL; in wm831x_aldo_probe()
455 ldo->base = res->start; in wm831x_aldo_probe()
457 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); in wm831x_aldo_probe()
458 ldo->desc.name = ldo->name; in wm831x_aldo_probe()
460 snprintf(ldo->supply_name, sizeof(ldo->supply_name), in wm831x_aldo_probe()
461 "LDO%dVDD", id + 1); in wm831x_aldo_probe()
462 ldo->desc.supply_name = ldo->supply_name; in wm831x_aldo_probe()
464 ldo->desc.id = id; in wm831x_aldo_probe()
465 ldo->desc.type = REGULATOR_VOLTAGE; in wm831x_aldo_probe()
466 ldo->desc.n_voltages = 32; in wm831x_aldo_probe()
467 ldo->desc.linear_ranges = wm831x_aldo_ranges; in wm831x_aldo_probe()
468 ldo->desc.n_linear_ranges = ARRAY_SIZE(wm831x_aldo_ranges); in wm831x_aldo_probe()
469 ldo->desc.ops = &wm831x_aldo_ops; in wm831x_aldo_probe()
470 ldo->desc.owner = THIS_MODULE; in wm831x_aldo_probe()
471 ldo->desc.vsel_reg = ldo->base + WM831X_LDO_ON_CONTROL; in wm831x_aldo_probe()
472 ldo->desc.vsel_mask = WM831X_LDO7_ON_VSEL_MASK; in wm831x_aldo_probe()
473 ldo->desc.enable_reg = WM831X_LDO_ENABLE; in wm831x_aldo_probe()
474 ldo->desc.enable_mask = 1 << id; in wm831x_aldo_probe()
475 ldo->desc.bypass_reg = ldo->base; in wm831x_aldo_probe()
476 ldo->desc.bypass_mask = WM831X_LDO7_SWI; in wm831x_aldo_probe()
478 config.dev = pdev->dev.parent; in wm831x_aldo_probe()
480 config.init_data = pdata->ldo[id]; in wm831x_aldo_probe()
481 config.driver_data = ldo; in wm831x_aldo_probe()
482 config.regmap = wm831x->regmap; in wm831x_aldo_probe()
484 ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, in wm831x_aldo_probe()
486 if (IS_ERR(ldo->regulator)) { in wm831x_aldo_probe()
487 ret = PTR_ERR(ldo->regulator); in wm831x_aldo_probe()
488 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", in wm831x_aldo_probe()
494 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, in wm831x_aldo_probe()
497 ldo->name, ldo); in wm831x_aldo_probe()
499 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", in wm831x_aldo_probe()
504 platform_set_drvdata(pdev, ldo); in wm831x_aldo_probe()
515 .name = "wm831x-aldo",
521 * Alive LDO
529 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_alive_ldo_set_suspend_voltage() local
530 struct wm831x *wm831x = ldo->wm831x; in wm831x_alive_ldo_set_suspend_voltage()
531 int sel, reg = ldo->base + WM831X_ALIVE_LDO_SLEEP_CONTROL; in wm831x_alive_ldo_set_suspend_voltage()
542 struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); in wm831x_alive_ldo_get_status() local
543 struct wm831x *wm831x = ldo->wm831x; in wm831x_alive_ldo_get_status()
572 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); in wm831x_alive_ldo_probe()
573 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev); in wm831x_alive_ldo_probe()
576 struct wm831x_ldo *ldo; in wm831x_alive_ldo_probe() local
580 if (pdata && pdata->wm831x_num) in wm831x_alive_ldo_probe()
581 id = (pdata->wm831x_num * 10) + 1; in wm831x_alive_ldo_probe()
584 id = pdev->id - id; in wm831x_alive_ldo_probe()
587 dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); in wm831x_alive_ldo_probe()
589 ldo = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_ldo), GFP_KERNEL); in wm831x_alive_ldo_probe()
590 if (!ldo) in wm831x_alive_ldo_probe()
591 return -ENOMEM; in wm831x_alive_ldo_probe()
593 ldo->wm831x = wm831x; in wm831x_alive_ldo_probe()
597 dev_err(&pdev->dev, "No REG resource\n"); in wm831x_alive_ldo_probe()
598 ret = -EINVAL; in wm831x_alive_ldo_probe()
601 ldo->base = res->start; in wm831x_alive_ldo_probe()
603 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); in wm831x_alive_ldo_probe()
604 ldo->desc.name = ldo->name; in wm831x_alive_ldo_probe()
606 snprintf(ldo->supply_name, sizeof(ldo->supply_name), in wm831x_alive_ldo_probe()
607 "LDO%dVDD", id + 1); in wm831x_alive_ldo_probe()
608 ldo->desc.supply_name = ldo->supply_name; in wm831x_alive_ldo_probe()
610 ldo->desc.id = id; in wm831x_alive_ldo_probe()
611 ldo->desc.type = REGULATOR_VOLTAGE; in wm831x_alive_ldo_probe()
612 ldo->desc.n_voltages = WM831X_ALIVE_LDO_MAX_SELECTOR + 1; in wm831x_alive_ldo_probe()
613 ldo->desc.ops = &wm831x_alive_ldo_ops; in wm831x_alive_ldo_probe()
614 ldo->desc.owner = THIS_MODULE; in wm831x_alive_ldo_probe()
615 ldo->desc.vsel_reg = ldo->base + WM831X_ALIVE_LDO_ON_CONTROL; in wm831x_alive_ldo_probe()
616 ldo->desc.vsel_mask = WM831X_LDO11_ON_VSEL_MASK; in wm831x_alive_ldo_probe()
617 ldo->desc.enable_reg = WM831X_LDO_ENABLE; in wm831x_alive_ldo_probe()
618 ldo->desc.enable_mask = 1 << id; in wm831x_alive_ldo_probe()
619 ldo->desc.min_uV = 800000; in wm831x_alive_ldo_probe()
620 ldo->desc.uV_step = 50000; in wm831x_alive_ldo_probe()
621 ldo->desc.enable_time = 1000; in wm831x_alive_ldo_probe()
623 config.dev = pdev->dev.parent; in wm831x_alive_ldo_probe()
625 config.init_data = pdata->ldo[id]; in wm831x_alive_ldo_probe()
626 config.driver_data = ldo; in wm831x_alive_ldo_probe()
627 config.regmap = wm831x->regmap; in wm831x_alive_ldo_probe()
629 ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, in wm831x_alive_ldo_probe()
631 if (IS_ERR(ldo->regulator)) { in wm831x_alive_ldo_probe()
632 ret = PTR_ERR(ldo->regulator); in wm831x_alive_ldo_probe()
633 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", in wm831x_alive_ldo_probe()
638 platform_set_drvdata(pdev, ldo); in wm831x_alive_ldo_probe()
649 .name = "wm831x-alive-ldo",
674 MODULE_DESCRIPTION("WM831x LDO driver");
676 MODULE_ALIAS("platform:wm831x-ldo");
677 MODULE_ALIAS("platform:wm831x-aldo");
678 MODULE_ALIAS("platform:wm831x-aliveldo");