Lines Matching +full:regulator +full:- +full:active +full:- +full:discharge
2 * Copyright (C) ST-Ericsson SA 2010
8 * This file is based on drivers/regulator/ab8500.c
12 * ab8500-ext supports the following regulators:
13 * - VextSupply3
21 #include <linux/regulator/driver.h>
22 #include <linux/regulator/machine.h>
23 #include <linux/regulator/of_regulator.h>
26 #include <linux/regulator/ab8500.h>
36 REGULATOR_SUPPLY("vcc", "gpio-keys.0"),
38 REGULATOR_SUPPLY("vcc", "2-0029"),
40 REGULATOR_SUPPLY("vdd", "2-0018"),
42 REGULATOR_SUPPLY("vdd", "2-0019"),
44 REGULATOR_SUPPLY("vdd", "2-001e"),
46 REGULATOR_SUPPLY("avdd", "3-005c"),
47 REGULATOR_SUPPLY("avdd", "3-005d"),
49 REGULATOR_SUPPLY("vdd", "3-004b"),
51 REGULATOR_SUPPLY("vdd", "2-0068"),
53 REGULATOR_SUPPLY("vdd", "3-0029"),
55 REGULATOR_SUPPLY("vdd", "2-005c"),
63 /* On-board eMMC power */
66 REGULATOR_SUPPLY("vcc-N2158", "ab8500-codec.0"),
68 REGULATOR_SUPPLY("vcc-N2158", "ab8500-acc-det.0"),
69 /* AB8500 Tv-out device */
70 REGULATOR_SUPPLY("vcc-N2158", "mcde_tv_ab8500.4"),
72 REGULATOR_SUPPLY("vcc-N2158", "av8100_hdmi.3"),
76 REGULATOR_SUPPLY("v-SD-STM", "stm"),
82 /* TV-out DENC supply */
83 REGULATOR_SUPPLY("vtvout", "ab8500-denc.0"),
84 /* Internal general-purpose ADC */
85 REGULATOR_SUPPLY("vddadc", "ab8500-gpadc.0"),
87 REGULATOR_SUPPLY("vddadc", "ab8500-charger.0"),
88 /* AB8500 Tv-out device */
93 /* AB8500 audio-codec main supply */
94 REGULATOR_SUPPLY("vaud", "ab8500-codec.0"),
98 /* AB8500 audio-codec Mic1 supply */
99 REGULATOR_SUPPLY("vamic1", "ab8500-codec.0"),
103 /* AB8500 audio-codec Mic2 supply */
104 REGULATOR_SUPPLY("vamic2", "ab8500-codec.0"),
108 /* AB8500 audio-codec DMic supply */
109 REGULATOR_SUPPLY("vdmic", "ab8500-codec.0"),
114 REGULATOR_SUPPLY("v-intcore", NULL),
116 REGULATOR_SUPPLY("vddulpivio18", "ab8500-usb.0"),
118 REGULATOR_SUPPLY("v-intcore", "abx500-clk.0"),
133 /* ab8500 regulator register initialization */
240 * Vamic1_dzout = high-Z when Vamic1 is disabled
241 * Vamic2_dzout = high-Z when Vamic2 is disabled
257 * VextSupply3Regu = force HP (-> STBB2=LP and TPS=LP)
288 * Vaux1Disch = short discharge time
289 * Vaux2Disch = short discharge time
290 * Vaux3Disch = short discharge time
291 * Vintcore12Disch = short discharge time
292 * VTVoutDisch = short discharge time
293 * VaudioDisch = short discharge time
297 * VanaDisch = short discharge time
299 * VdmicDisch = short discharge time
308 .supply_regulator = "ab8500-ext-supply3",
310 .name = "V-DISPLAY",
320 /* supplies to the on-board eMMC */
322 .supply_regulator = "ab8500-ext-supply3",
324 .name = "V-eMMC1",
338 .supply_regulator = "ab8500-ext-supply3",
340 .name = "V-MMC-SD",
355 .name = "V-TVOUT",
361 /* supply for ab8500-vaudio, VAUDIO LDO */
364 .name = "V-AUD",
370 /* supply for v-anamic1 VAMic1-LDO */
373 .name = "V-AMIC1",
379 /* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */
382 .name = "V-AMIC2",
388 /* supply for v-dmic, VDMIC LDO */
391 .name = "V-DMIC",
397 /* supply for v-intcore12, VINTCORE12 LDO */
400 .name = "V-INTCORE",
414 /* supply for U8500 CSI-DSI, VANA LDO */
417 .name = "V-CSI-DSI",
428 REGULATOR_SUPPLY("vinvsim", "sim-detect.0"),
438 .name = "ab8500-ext-supply1",
449 .name = "ab8500-ext-supply2",
457 .name = "ab8500-ext-supply3",
472 .regulator = ab8500_regulators,
479 * struct ab8500_ext_regulator_info - ab8500 regulator information
481 * @desc: regulator description
482 * @rdev: regulator device
483 * @cfg: regulator configuration (extension of regulator FW configuration)
486 * @update_mask: mask to enable/disable and set mode of regulator
487 * @update_val: bits holding the regulator current mode
488 * @update_val_hp: bits to set EN pin active (LPn pin deactive)
490 * @update_val_lp: bits to set EN pin active and LPn pin active
492 * @update_val_hw: bits to set regulator pins in HW control
516 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); in ab8500_ext_regulator_enable()
517 return -EINVAL; in ab8500_ext_regulator_enable()
521 * To satisfy both HW high power request and SW request, the regulator in ab8500_ext_regulator_enable()
524 if (info->cfg && info->cfg->hwreq) in ab8500_ext_regulator_enable()
525 regval = info->update_val_hp; in ab8500_ext_regulator_enable()
527 regval = info->update_val; in ab8500_ext_regulator_enable()
529 ret = abx500_mask_and_set_register_interruptible(info->dev, in ab8500_ext_regulator_enable()
530 info->update_bank, info->update_reg, in ab8500_ext_regulator_enable()
531 info->update_mask, regval); in ab8500_ext_regulator_enable()
533 dev_err(rdev_get_dev(info->rdev), in ab8500_ext_regulator_enable()
534 "couldn't set enable bits for regulator\n"); in ab8500_ext_regulator_enable()
539 "%s-enable (bank, reg, mask, value): 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", in ab8500_ext_regulator_enable()
540 info->desc.name, info->update_bank, info->update_reg, in ab8500_ext_regulator_enable()
541 info->update_mask, regval); in ab8500_ext_regulator_enable()
553 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); in ab8500_ext_regulator_disable()
554 return -EINVAL; in ab8500_ext_regulator_disable()
558 * Set the regulator in HW request mode if configured in ab8500_ext_regulator_disable()
560 if (info->cfg && info->cfg->hwreq) in ab8500_ext_regulator_disable()
561 regval = info->update_val_hw; in ab8500_ext_regulator_disable()
565 ret = abx500_mask_and_set_register_interruptible(info->dev, in ab8500_ext_regulator_disable()
566 info->update_bank, info->update_reg, in ab8500_ext_regulator_disable()
567 info->update_mask, regval); in ab8500_ext_regulator_disable()
569 dev_err(rdev_get_dev(info->rdev), in ab8500_ext_regulator_disable()
570 "couldn't set disable bits for regulator\n"); in ab8500_ext_regulator_disable()
574 dev_dbg(rdev_get_dev(rdev), "%s-disable (bank, reg, mask, value):" in ab8500_ext_regulator_disable()
576 info->desc.name, info->update_bank, info->update_reg, in ab8500_ext_regulator_disable()
577 info->update_mask, regval); in ab8500_ext_regulator_disable()
589 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); in ab8500_ext_regulator_is_enabled()
590 return -EINVAL; in ab8500_ext_regulator_is_enabled()
593 ret = abx500_get_register_interruptible(info->dev, in ab8500_ext_regulator_is_enabled()
594 info->update_bank, info->update_reg, ®val); in ab8500_ext_regulator_is_enabled()
597 "couldn't read 0x%x register\n", info->update_reg); in ab8500_ext_regulator_is_enabled()
601 dev_dbg(rdev_get_dev(rdev), "%s-is_enabled (bank, reg, mask, value):" in ab8500_ext_regulator_is_enabled()
603 info->desc.name, info->update_bank, info->update_reg, in ab8500_ext_regulator_is_enabled()
604 info->update_mask, regval); in ab8500_ext_regulator_is_enabled()
606 if (((regval & info->update_mask) == info->update_val_lp) || in ab8500_ext_regulator_is_enabled()
607 ((regval & info->update_mask) == info->update_val_hp)) in ab8500_ext_regulator_is_enabled()
621 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); in ab8500_ext_regulator_set_mode()
622 return -EINVAL; in ab8500_ext_regulator_set_mode()
627 regval = info->update_val_hp; in ab8500_ext_regulator_set_mode()
630 regval = info->update_val_lp; in ab8500_ext_regulator_set_mode()
634 return -EINVAL; in ab8500_ext_regulator_set_mode()
637 /* If regulator is enabled and info->cfg->hwreq is set, the regulator in ab8500_ext_regulator_set_mode()
642 !(info->cfg && info->cfg->hwreq)) { in ab8500_ext_regulator_set_mode()
643 ret = abx500_mask_and_set_register_interruptible(info->dev, in ab8500_ext_regulator_set_mode()
644 info->update_bank, info->update_reg, in ab8500_ext_regulator_set_mode()
645 info->update_mask, regval); in ab8500_ext_regulator_set_mode()
648 "Could not set regulator mode.\n"); in ab8500_ext_regulator_set_mode()
653 "%s-set_mode (bank, reg, mask, value): " in ab8500_ext_regulator_set_mode()
655 info->desc.name, info->update_bank, info->update_reg, in ab8500_ext_regulator_set_mode()
656 info->update_mask, regval); in ab8500_ext_regulator_set_mode()
659 info->update_val = regval; in ab8500_ext_regulator_set_mode()
670 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); in ab8500_ext_regulator_get_mode()
671 return -EINVAL; in ab8500_ext_regulator_get_mode()
674 if (info->update_val == info->update_val_hp) in ab8500_ext_regulator_get_mode()
676 else if (info->update_val == info->update_val_lp) in ab8500_ext_regulator_get_mode()
679 ret = -EINVAL; in ab8500_ext_regulator_get_mode()
687 struct regulation_constraints *regu_constraints = rdev->constraints; in ab8500_ext_set_voltage()
690 dev_err(rdev_get_dev(rdev), "No regulator constraints\n"); in ab8500_ext_set_voltage()
691 return -EINVAL; in ab8500_ext_set_voltage()
694 if (regu_constraints->min_uV == min_uV && in ab8500_ext_set_voltage()
695 regu_constraints->max_uV == max_uV) in ab8500_ext_set_voltage()
701 regu_constraints->min_uV, regu_constraints->max_uV); in ab8500_ext_set_voltage()
703 return -EINVAL; in ab8500_ext_set_voltage()
709 struct regulation_constraints *regu_constraints = rdev->constraints; in ab8500_ext_list_voltage()
712 dev_err(rdev_get_dev(rdev), "regulator constraints null pointer\n"); in ab8500_ext_list_voltage()
713 return -EINVAL; in ab8500_ext_list_voltage()
716 if (regu_constraints->min_uV && regu_constraints->max_uV) { in ab8500_ext_list_voltage()
717 if (regu_constraints->min_uV == regu_constraints->max_uV) in ab8500_ext_list_voltage()
718 return regu_constraints->min_uV; in ab8500_ext_list_voltage()
720 return -EINVAL; in ab8500_ext_list_voltage()
796 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); in ab8500_ext_regulator_probe()
798 struct device_node *np = pdev->dev.of_node; in ab8500_ext_regulator_probe()
803 err = of_regulator_match(&pdev->dev, np, in ab8500_ext_regulator_probe()
807 dev_err(&pdev->dev, in ab8500_ext_regulator_probe()
808 "Error parsing regulator init data: %d\n", err); in ab8500_ext_regulator_probe()
814 dev_err(&pdev->dev, "null mfd parent\n"); in ab8500_ext_regulator_probe()
815 return -EINVAL; in ab8500_ext_regulator_probe()
819 if (pdata->num_ext_regulator != ARRAY_SIZE(ab8500_ext_regulator_info)) { in ab8500_ext_regulator_probe()
820 dev_err(&pdev->dev, "Configuration error: size mismatch.\n"); in ab8500_ext_regulator_probe()
821 return -EINVAL; in ab8500_ext_regulator_probe()
830 info->update_val = 0x30; in ab8500_ext_regulator_probe()
831 info->update_val_hp = 0x30; in ab8500_ext_regulator_probe()
832 info->update_val_lp = 0x10; in ab8500_ext_regulator_probe()
839 /* assign per-regulator data */ in ab8500_ext_regulator_probe()
841 info->dev = &pdev->dev; in ab8500_ext_regulator_probe()
842 info->cfg = (struct ab8500_ext_regulator_cfg *) in ab8500_ext_regulator_probe()
843 pdata->ext_regulator[i].driver_data; in ab8500_ext_regulator_probe()
845 config.dev = &pdev->dev; in ab8500_ext_regulator_probe()
850 &pdata->ext_regulator[i]; in ab8500_ext_regulator_probe()
852 /* register regulator with framework */ in ab8500_ext_regulator_probe()
853 info->rdev = devm_regulator_register(&pdev->dev, &info->desc, in ab8500_ext_regulator_probe()
855 if (IS_ERR(info->rdev)) { in ab8500_ext_regulator_probe()
856 err = PTR_ERR(info->rdev); in ab8500_ext_regulator_probe()
857 dev_err(&pdev->dev, "failed to register regulator %s\n", in ab8500_ext_regulator_probe()
858 info->desc.name); in ab8500_ext_regulator_probe()
862 dev_dbg(rdev_get_dev(info->rdev), in ab8500_ext_regulator_probe()
863 "%s-probed\n", info->desc.name); in ab8500_ext_regulator_probe()
872 .name = "ab8500-ext-regulator",
882 pr_err("Failed to register ab8500 ext regulator: %d\n", ret); in ab8500_ext_regulator_init()
896 MODULE_DESCRIPTION("AB8500 external regulator driver");
897 MODULE_ALIAS("platform:ab8500-ext-regulator");