Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'regulator-v3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into next

Pull regulator updates from Mark Brown:
"The bulk of the changes for this release are a few new drivers however
there are a couple of noticable core changes and the usual stream of
cleanups and fixes:

- move disable of unused regulators later in init so it comes after
deferred probe has iterated making startup smoother.
- fixes to reference counting of the DT nodes for constraints from
Charles Keepax. This has little practical impact since all real
users of the regulator bindings use FDT which doesn't need the
reference counting.
- lots of cleanups, especially to the Samsung drivers.
- support for Linear Technologies LTC3589, Texas Instruments
TPS658640 and X-Powers AXP20x"

* tag 'regulator-v3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (64 commits)
regulator: pbias: remove unnecessary OOM messages
regulator: max8649: remove unnecessary OOM messages
regulator: core: Fix the init of DT defined fixed regulators
regulator: core: Disable unused regulators after deferred probing is done
regulator: Don't disable unused regulators we don't have permission for
regulator: axp20x: Use regulator_map_voltage_ascend for LDO4
regulator: use of_property_read_{bool|u32}()
regulator: Fix regulator_get_{optional,exclusive}() documentation
regulators: Add definition of regulator_set_voltage_time() for !CONFIG_REGULATOR
regulator: arizona-ldo1: add missing #include
regulator: pfuze100: Support enable/disable for fixed regulator
regulator: ltc3589: Remove ltc3589_list_voltage_fixed function
regulator: ltc3589: Fix module dependency
regulator: tps6586x: Remove unused to_tps6586x_dev() function
regulator: tps65218: Convert to use regulator_set_voltage_time_sel
regulator: tps6586x: Add support for the TPS658640
regulator: tps6586x: Prepare supporting fixed regulators
regulator: pfuze100: Don't allocate an invalid gpio
regulator: pfuze100: Support SWB enable/disable
regulator: fixed: use of_property_read_{bool|u32}()
...

+1833 -419
+3 -1
Documentation/devicetree/bindings/mfd/bcm590xx.txt
··· 19 19 The valid regulator node names for BCM59056 are: 20 20 rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo, 21 21 mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo, 22 - csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr 22 + csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr, 23 + gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6, 24 + vbus 23 25 24 26 Example: 25 27 pmu: bcm59056@8 {
+14
Documentation/devicetree/bindings/mfd/s2mps11.txt
··· 56 56 Grouping of BUCKs sharing ramp rate setting is as follow : BUCK[1, 6], 57 57 BUCK[3, 4], and BUCK[7, 8, 10] 58 58 59 + On S2MPS14 the LDO10, LDO11 and LDO12 can be configured to external control 60 + over GPIO. To turn this feature on this property must be added to the regulator 61 + sub-node: 62 + - samsung,ext-control-gpios: GPIO specifier for one GPIO 63 + controlling this regulator (enable/disable); 64 + Example: 65 + LDO12 { 66 + regulator-name = "V_EMMC_2.8V"; 67 + regulator-min-microvolt = <2800000>; 68 + regulator-max-microvolt = <2800000>; 69 + samsung,ext-control-gpios = <&gpk0 2 0>; 70 + }; 71 + 72 + 59 73 The regulator constraints inside the regulator nodes use the standard regulator 60 74 bindings which are documented elsewhere. 61 75
+99
Documentation/devicetree/bindings/regulator/ltc3589.txt
··· 1 + Linear Technology LTC3589, LTC3589-1, and LTC3589-2 8-output regulators 2 + 3 + Required properties: 4 + - compatible: "lltc,ltc3589", "lltc,ltc3589-1" or "lltc,ltc3589-2" 5 + - reg: I2C slave address 6 + 7 + Required child node: 8 + - regulators: Contains eight regulator child nodes sw1, sw2, sw3, bb-out, 9 + ldo1, ldo2, ldo3, and ldo4, specifying the initialization data as 10 + documented in Documentation/devicetree/bindings/regulator/regulator.txt. 11 + 12 + Each regulator is defined using the standard binding for regulators. The 13 + nodes for sw1, sw2, sw3, bb-out, ldo1, and ldo2 additionally need to specify 14 + the resistor values of their external feedback voltage dividers: 15 + 16 + Required properties (not on ldo3, ldo4): 17 + - lltc,fb-voltage-divider: An array of two integers containing the resistor 18 + values R1 and R2 of the feedback voltage divider in ohms. 19 + 20 + Regulators sw1, sw2, sw3, and ldo2 can regulate the feedback reference from 21 + 0.3625 V to 0.75 V in 12.5 mV steps. The output voltage thus ranges between 22 + 0.3625 * (1 + R1/R2) V and 0.75 * (1 + R1/R2) V. Regulators bb-out and ldo1 23 + have a fixed 0.8 V reference and thus output 0.8 * (1 + R1/R2) V. The ldo3 24 + regulator is fixed to 1.8 V on LTC3589 and to 2.8 V on LTC3589-1,2. The ldo4 25 + regulator can output between 1.8 V and 3.3 V on LTC3589 and between 1.2 V 26 + and 3.2 V on LTC3589-1,2 in four steps. The ldo1 standby regulator can not 27 + be disabled and thus should have the regulator-always-on property set. 28 + 29 + Example: 30 + 31 + ltc3589: pmic@34 { 32 + compatible = "lltc,ltc3589-1"; 33 + reg = <0x34>; 34 + 35 + regulators { 36 + sw1_reg: sw1 { 37 + regulator-min-microvolt = <591930>; 38 + regulator-max-microvolt = <1224671>; 39 + lltc,fb-voltage-divider = <100000 158000>; 40 + regulator-ramp-delay = <7000>; 41 + regulator-boot-on; 42 + regulator-always-on; 43 + }; 44 + 45 + sw2_reg: sw2 { 46 + regulator-min-microvolt = <704123>; 47 + regulator-max-microvolt = <1456803>; 48 + lltc,fb-voltage-divider = <180000 191000>; 49 + regulator-ramp-delay = <7000>; 50 + regulator-boot-on; 51 + regulator-always-on; 52 + }; 53 + 54 + sw3_reg: sw3 { 55 + regulator-min-microvolt = <1341250>; 56 + regulator-max-microvolt = <2775000>; 57 + lltc,fb-voltage-divider = <270000 100000>; 58 + regulator-ramp-delay = <7000>; 59 + regulator-boot-on; 60 + regulator-always-on; 61 + }; 62 + 63 + bb_out_reg: bb-out { 64 + regulator-min-microvolt = <3387341>; 65 + regulator-max-microvolt = <3387341>; 66 + lltc,fb-voltage-divider = <511000 158000>; 67 + regulator-boot-on; 68 + regulator-always-on; 69 + }; 70 + 71 + ldo1_reg: ldo1 { 72 + regulator-min-microvolt = <1306329>; 73 + regulator-max-microvolt = <1306329>; 74 + lltc,fb-voltage-divider = <100000 158000>; 75 + regulator-boot-on; 76 + regulator-always-on; 77 + }; 78 + 79 + ldo2_reg: ldo2 { 80 + regulator-min-microvolt = <704123>; 81 + regulator-max-microvolt = <1456806>; 82 + lltc,fb-voltage-divider = <180000 191000>; 83 + regulator-ramp-delay = <7000>; 84 + regulator-boot-on; 85 + regulator-always-on; 86 + }; 87 + 88 + ldo3_reg: ldo3 { 89 + regulator-min-microvolt = <2800000>; 90 + regulator-max-microvolt = <2800000>; 91 + regulator-boot-on; 92 + }; 93 + 94 + ldo4_reg: ldo4 { 95 + regulator-min-microvolt = <1200000>; 96 + regulator-max-microvolt = <3200000>; 97 + }; 98 + }; 99 + };
+4
Documentation/devicetree/bindings/regulator/tps65090.txt
··· 21 21 number should be provided. If it is externally controlled and no GPIO 22 22 entry then driver will just configure this rails as external control 23 23 and will not provide any enable/disable APIs. 24 + - ti,overcurrent-wait: This is applicable to FET registers, which have a 25 + poorly defined "overcurrent wait" field. If this property is present it 26 + should be between 0 - 3. If this property isn't present we won't touch the 27 + "overcurrent wait" field and we'll leave it to the BIOS/EC to deal with. 24 28 25 29 Each regulator is defined using the standard binding for regulators. 26 30
+1
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 74 74 lg LG Corporation 75 75 linux Linux-specific binding 76 76 lsi LSI Corp. (LSI Logic) 77 + lltc Linear Technology Corporation 77 78 marvell Marvell Technology Group Ltd. 78 79 maxim Maxim Integrated Products 79 80 microchip Microchip Technology Inc.
+24 -17
drivers/mfd/arizona-core.c
··· 508 508 } 509 509 EXPORT_SYMBOL_GPL(arizona_of_get_type); 510 510 511 + int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop, 512 + bool mandatory) 513 + { 514 + int gpio; 515 + 516 + gpio = of_get_named_gpio(arizona->dev->of_node, prop, 0); 517 + if (gpio < 0) { 518 + if (mandatory) 519 + dev_err(arizona->dev, 520 + "Mandatory DT gpio %s missing/malformed: %d\n", 521 + prop, gpio); 522 + 523 + gpio = 0; 524 + } 525 + 526 + return gpio; 527 + } 528 + EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio); 529 + 511 530 static int arizona_of_get_core_pdata(struct arizona *arizona) 512 531 { 532 + struct arizona_pdata *pdata = &arizona->pdata; 513 533 int ret, i; 514 534 515 - arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node, 516 - "wlf,reset", 0); 517 - if (arizona->pdata.reset < 0) 518 - arizona->pdata.reset = 0; 519 - 520 - arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node, 521 - "wlf,ldoena", 0); 522 - if (arizona->pdata.ldoena < 0) 523 - arizona->pdata.ldoena = 0; 535 + pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true); 524 536 525 537 ret = of_property_read_u32_array(arizona->dev->of_node, 526 538 "wlf,gpio-defaults", ··· 663 651 arizona->type); 664 652 return -EINVAL; 665 653 } 654 + 655 + /* Mark DCVDD as external, LDO1 driver will clear if internal */ 656 + arizona->external_dcvdd = true; 666 657 667 658 ret = mfd_add_devices(arizona->dev, -1, early_devs, 668 659 ARRAY_SIZE(early_devs), NULL, 0, NULL); ··· 865 850 regmap_write(arizona->regmap, ARIZONA_GPIO1_CTRL + i, 866 851 arizona->pdata.gpio_defaults[i]); 867 852 } 868 - 869 - /* 870 - * LDO1 can only be used to supply DCVDD so if it has no 871 - * consumers then DCVDD is supplied externally. 872 - */ 873 - if (arizona->pdata.ldo1 && 874 - arizona->pdata.ldo1->num_consumer_supplies == 0) 875 - arizona->external_dcvdd = true; 876 853 877 854 pm_runtime_set_autosuspend_delay(arizona->dev, 100); 878 855 pm_runtime_use_autosuspend(arizona->dev);
+47 -15
drivers/mfd/bcm590xx.c
··· 28 28 }, 29 29 }; 30 30 31 - static const struct regmap_config bcm590xx_regmap_config = { 31 + static const struct regmap_config bcm590xx_regmap_config_pri = { 32 32 .reg_bits = 8, 33 33 .val_bits = 8, 34 - .max_register = BCM590XX_MAX_REGISTER, 34 + .max_register = BCM590XX_MAX_REGISTER_PRI, 35 35 .cache_type = REGCACHE_RBTREE, 36 36 }; 37 37 38 - static int bcm590xx_i2c_probe(struct i2c_client *i2c, 38 + static const struct regmap_config bcm590xx_regmap_config_sec = { 39 + .reg_bits = 8, 40 + .val_bits = 8, 41 + .max_register = BCM590XX_MAX_REGISTER_SEC, 42 + .cache_type = REGCACHE_RBTREE, 43 + }; 44 + 45 + static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri, 39 46 const struct i2c_device_id *id) 40 47 { 41 48 struct bcm590xx *bcm590xx; 42 49 int ret; 43 50 44 - bcm590xx = devm_kzalloc(&i2c->dev, sizeof(*bcm590xx), GFP_KERNEL); 51 + bcm590xx = devm_kzalloc(&i2c_pri->dev, sizeof(*bcm590xx), GFP_KERNEL); 45 52 if (!bcm590xx) 46 53 return -ENOMEM; 47 54 48 - i2c_set_clientdata(i2c, bcm590xx); 49 - bcm590xx->dev = &i2c->dev; 50 - bcm590xx->i2c_client = i2c; 55 + i2c_set_clientdata(i2c_pri, bcm590xx); 56 + bcm590xx->dev = &i2c_pri->dev; 57 + bcm590xx->i2c_pri = i2c_pri; 51 58 52 - bcm590xx->regmap = devm_regmap_init_i2c(i2c, &bcm590xx_regmap_config); 53 - if (IS_ERR(bcm590xx->regmap)) { 54 - ret = PTR_ERR(bcm590xx->regmap); 55 - dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); 59 + bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri, 60 + &bcm590xx_regmap_config_pri); 61 + if (IS_ERR(bcm590xx->regmap_pri)) { 62 + ret = PTR_ERR(bcm590xx->regmap_pri); 63 + dev_err(&i2c_pri->dev, "primary regmap init failed: %d\n", ret); 56 64 return ret; 57 65 } 58 66 59 - ret = mfd_add_devices(&i2c->dev, -1, bcm590xx_devs, 60 - ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL); 61 - if (ret < 0) 62 - dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret); 67 + /* Secondary I2C slave address is the base address with A(2) asserted */ 68 + bcm590xx->i2c_sec = i2c_new_dummy(i2c_pri->adapter, 69 + i2c_pri->addr | BIT(2)); 70 + if (IS_ERR_OR_NULL(bcm590xx->i2c_sec)) { 71 + dev_err(&i2c_pri->dev, "failed to add secondary I2C device\n"); 72 + return -ENODEV; 73 + } 74 + i2c_set_clientdata(bcm590xx->i2c_sec, bcm590xx); 63 75 76 + bcm590xx->regmap_sec = devm_regmap_init_i2c(bcm590xx->i2c_sec, 77 + &bcm590xx_regmap_config_sec); 78 + if (IS_ERR(bcm590xx->regmap_sec)) { 79 + ret = PTR_ERR(bcm590xx->regmap_sec); 80 + dev_err(&bcm590xx->i2c_sec->dev, 81 + "secondary regmap init failed: %d\n", ret); 82 + goto err; 83 + } 84 + 85 + ret = mfd_add_devices(&i2c_pri->dev, -1, bcm590xx_devs, 86 + ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL); 87 + if (ret < 0) { 88 + dev_err(&i2c_pri->dev, "failed to add sub-devices: %d\n", ret); 89 + goto err; 90 + } 91 + 92 + return 0; 93 + 94 + err: 95 + i2c_unregister_device(bcm590xx->i2c_sec); 64 96 return ret; 65 97 } 66 98
+25 -16
drivers/mfd/tps65090.c
··· 32 32 #define NUM_INT_REG 2 33 33 #define TOTAL_NUM_REG 0x18 34 34 35 - /* interrupt status registers */ 36 - #define TPS65090_INT_STS 0x0 37 - #define TPS65090_INT_STS2 0x1 38 - 39 - /* interrupt mask registers */ 40 - #define TPS65090_INT_MSK 0x2 41 - #define TPS65090_INT_MSK2 0x3 42 - 43 35 #define TPS65090_INT1_MASK_VAC_STATUS_CHANGE 1 44 36 #define TPS65090_INT1_MASK_VSYS_STATUS_CHANGE 2 45 37 #define TPS65090_INT1_MASK_BAT_STATUS_CHANGE 3 ··· 56 64 } 57 65 }; 58 66 59 - static const struct mfd_cell tps65090s[] = { 60 - { 67 + enum tps65090_cells { 68 + PMIC = 0, 69 + CHARGER = 1, 70 + }; 71 + 72 + static struct mfd_cell tps65090s[] = { 73 + [PMIC] = { 61 74 .name = "tps65090-pmic", 62 75 }, 63 - { 76 + [CHARGER] = { 64 77 .name = "tps65090-charger", 65 78 .num_resources = ARRAY_SIZE(charger_resources), 66 79 .resources = &charger_resources[0], ··· 136 139 .irqs = tps65090_irqs, 137 140 .num_irqs = ARRAY_SIZE(tps65090_irqs), 138 141 .num_regs = NUM_INT_REG, 139 - .status_base = TPS65090_INT_STS, 140 - .mask_base = TPS65090_INT_MSK, 142 + .status_base = TPS65090_REG_INTR_STS, 143 + .mask_base = TPS65090_REG_INTR_MASK, 141 144 .mask_invert = true, 142 145 }; 143 146 144 147 static bool is_volatile_reg(struct device *dev, unsigned int reg) 145 148 { 146 - if ((reg == TPS65090_INT_STS) || (reg == TPS65090_INT_STS2)) 147 - return true; 148 - else 149 + /* Nearly all registers have status bits mixed in, except a few */ 150 + switch (reg) { 151 + case TPS65090_REG_INTR_MASK: 152 + case TPS65090_REG_INTR_MASK2: 153 + case TPS65090_REG_CG_CTRL0: 154 + case TPS65090_REG_CG_CTRL1: 155 + case TPS65090_REG_CG_CTRL2: 156 + case TPS65090_REG_CG_CTRL3: 157 + case TPS65090_REG_CG_CTRL4: 158 + case TPS65090_REG_CG_CTRL5: 149 159 return false; 160 + } 161 + return true; 150 162 } 151 163 152 164 static const struct regmap_config tps65090_regmap_config = { ··· 217 211 "IRQ init failed with err: %d\n", ret); 218 212 return ret; 219 213 } 214 + } else { 215 + /* Don't tell children they have an IRQ that'll never fire */ 216 + tps65090s[CHARGER].num_resources = 0; 220 217 } 221 218 222 219 ret = mfd_add_devices(tps65090->dev, -1, tps65090s,
+4
drivers/mfd/tps6586x.c
··· 495 495 case TPS658623: 496 496 name = "TPS658623"; 497 497 break; 498 + case TPS658640: 499 + case TPS658640v2: 500 + name = "TPS658640"; 501 + break; 498 502 case TPS658643: 499 503 name = "TPS658643"; 500 504 break;
-11
drivers/power/tps65090-charger.c
··· 28 28 29 29 #include <linux/mfd/tps65090.h> 30 30 31 - #define TPS65090_REG_INTR_STS 0x00 32 - #define TPS65090_REG_INTR_MASK 0x02 33 - #define TPS65090_REG_CG_CTRL0 0x04 34 - #define TPS65090_REG_CG_CTRL1 0x05 35 - #define TPS65090_REG_CG_CTRL2 0x06 36 - #define TPS65090_REG_CG_CTRL3 0x07 37 - #define TPS65090_REG_CG_CTRL4 0x08 38 - #define TPS65090_REG_CG_CTRL5 0x09 39 - #define TPS65090_REG_CG_STATUS1 0x0a 40 - #define TPS65090_REG_CG_STATUS2 0x0b 41 - 42 31 #define TPS65090_CHARGER_ENABLE BIT(0) 43 32 #define TPS65090_VACG BIT(1) 44 33 #define TPS65090_NOITERM BIT(5)
+15
drivers/regulator/Kconfig
··· 139 139 AS3722 PMIC. This will enable support for all the software 140 140 controllable DCDC/LDO regulators. 141 141 142 + config REGULATOR_AXP20X 143 + tristate "X-POWERS AXP20X PMIC Regulators" 144 + depends on MFD_AXP20X 145 + help 146 + This driver provides support for the voltage regulators on the 147 + AXP20X PMIC. 148 + 142 149 config REGULATOR_BCM590XX 143 150 tristate "Broadcom BCM590xx PMU Regulators" 144 151 depends on MFD_BCM590XX ··· 271 264 depends on MFD_LP8788 272 265 help 273 266 This driver supports LP8788 voltage regulator chip. 267 + 268 + config REGULATOR_LTC3589 269 + tristate "LTC3589 8-output voltage regulator" 270 + depends on I2C 271 + select REGMAP_I2C 272 + help 273 + This enables support for the LTC3589, LTC3589-1, and LTC3589-2 274 + 8-output regulators controlled via I2C. 274 275 275 276 config REGULATOR_MAX14577 276 277 tristate "Maxim 14577/77836 regulator"
+2
drivers/regulator/Makefile
··· 20 20 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o 21 21 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o 22 22 obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o 23 + obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o 23 24 obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o 24 25 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o 25 26 obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o ··· 38 37 obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o 39 38 obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o 40 39 obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o 40 + obj-$(CONFIG_REGULATOR_LTC3589) += ltc3589.o 41 41 obj-$(CONFIG_REGULATOR_MAX14577) += max14577.o 42 42 obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o 43 43 obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o
+1 -1
drivers/regulator/anatop-regulator.c
··· 300 300 return 0; 301 301 } 302 302 303 - static struct of_device_id of_anatop_regulator_match_tbl[] = { 303 + static const struct of_device_id of_anatop_regulator_match_tbl[] = { 304 304 { .compatible = "fsl,anatop-regulator", }, 305 305 { /* end */ } 306 306 };
+58
drivers/regulator/arizona-ldo1.c
··· 16 16 #include <linux/init.h> 17 17 #include <linux/bitops.h> 18 18 #include <linux/err.h> 19 + #include <linux/of.h> 19 20 #include <linux/platform_device.h> 20 21 #include <linux/regulator/driver.h> 21 22 #include <linux/regulator/machine.h> 23 + #include <linux/regulator/of_regulator.h> 22 24 #include <linux/gpio.h> 23 25 #include <linux/slab.h> 24 26 ··· 180 178 .num_consumer_supplies = 1, 181 179 }; 182 180 181 + static int arizona_ldo1_of_get_pdata(struct arizona *arizona, 182 + struct regulator_config *config) 183 + { 184 + struct arizona_pdata *pdata = &arizona->pdata; 185 + struct arizona_ldo1 *ldo1 = config->driver_data; 186 + struct device_node *init_node, *dcvdd_node; 187 + struct regulator_init_data *init_data; 188 + 189 + pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true); 190 + 191 + init_node = of_get_child_by_name(arizona->dev->of_node, "ldo1"); 192 + dcvdd_node = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0); 193 + 194 + if (init_node) { 195 + config->of_node = init_node; 196 + 197 + init_data = of_get_regulator_init_data(arizona->dev, init_node); 198 + 199 + if (init_data) { 200 + init_data->consumer_supplies = &ldo1->supply; 201 + init_data->num_consumer_supplies = 1; 202 + 203 + if (dcvdd_node && dcvdd_node != init_node) 204 + arizona->external_dcvdd = true; 205 + 206 + pdata->ldo1 = init_data; 207 + } 208 + } else if (dcvdd_node) { 209 + arizona->external_dcvdd = true; 210 + } 211 + 212 + of_node_put(dcvdd_node); 213 + 214 + return 0; 215 + } 216 + 183 217 static int arizona_ldo1_probe(struct platform_device *pdev) 184 218 { 185 219 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); ··· 223 185 struct regulator_config config = { }; 224 186 struct arizona_ldo1 *ldo1; 225 187 int ret; 188 + 189 + arizona->external_dcvdd = false; 226 190 227 191 ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL); 228 192 if (!ldo1) ··· 256 216 config.dev = arizona->dev; 257 217 config.driver_data = ldo1; 258 218 config.regmap = arizona->regmap; 219 + 220 + if (IS_ENABLED(CONFIG_OF)) { 221 + if (!dev_get_platdata(arizona->dev)) { 222 + ret = arizona_ldo1_of_get_pdata(arizona, &config); 223 + if (ret < 0) 224 + return ret; 225 + } 226 + } 227 + 259 228 config.ena_gpio = arizona->pdata.ldoena; 260 229 261 230 if (arizona->pdata.ldo1) 262 231 config.init_data = arizona->pdata.ldo1; 263 232 else 264 233 config.init_data = &ldo1->init_data; 234 + 235 + /* 236 + * LDO1 can only be used to supply DCVDD so if it has no 237 + * consumers then DCVDD is supplied externally. 238 + */ 239 + if (config.init_data->num_consumer_supplies == 0) 240 + arizona->external_dcvdd = true; 265 241 266 242 ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); 267 243 if (IS_ERR(ldo1->regulator)) { ··· 286 230 ret); 287 231 return ret; 288 232 } 233 + 234 + of_node_put(config.of_node); 289 235 290 236 platform_set_drvdata(pdev, ldo1); 291 237
+38
drivers/regulator/arizona-micsupp.c
··· 16 16 #include <linux/init.h> 17 17 #include <linux/bitops.h> 18 18 #include <linux/err.h> 19 + #include <linux/of.h> 19 20 #include <linux/platform_device.h> 20 21 #include <linux/regulator/driver.h> 21 22 #include <linux/regulator/machine.h> 23 + #include <linux/regulator/of_regulator.h> 22 24 #include <linux/gpio.h> 23 25 #include <linux/slab.h> 24 26 #include <linux/workqueue.h> ··· 197 195 .num_consumer_supplies = 1, 198 196 }; 199 197 198 + static int arizona_micsupp_of_get_pdata(struct arizona *arizona, 199 + struct regulator_config *config) 200 + { 201 + struct arizona_pdata *pdata = &arizona->pdata; 202 + struct arizona_micsupp *micsupp = config->driver_data; 203 + struct device_node *np; 204 + struct regulator_init_data *init_data; 205 + 206 + np = of_get_child_by_name(arizona->dev->of_node, "micvdd"); 207 + 208 + if (np) { 209 + config->of_node = np; 210 + 211 + init_data = of_get_regulator_init_data(arizona->dev, np); 212 + 213 + if (init_data) { 214 + init_data->consumer_supplies = &micsupp->supply; 215 + init_data->num_consumer_supplies = 1; 216 + 217 + pdata->micvdd = init_data; 218 + } 219 + } 220 + 221 + return 0; 222 + } 223 + 200 224 static int arizona_micsupp_probe(struct platform_device *pdev) 201 225 { 202 226 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); ··· 262 234 config.driver_data = micsupp; 263 235 config.regmap = arizona->regmap; 264 236 237 + if (IS_ENABLED(CONFIG_OF)) { 238 + if (!dev_get_platdata(arizona->dev)) { 239 + ret = arizona_micsupp_of_get_pdata(arizona, &config); 240 + if (ret < 0) 241 + return ret; 242 + } 243 + } 244 + 265 245 if (arizona->pdata.micvdd) 266 246 config.init_data = arizona->pdata.micvdd; 267 247 else ··· 288 252 ret); 289 253 return ret; 290 254 } 255 + 256 + of_node_put(config.of_node); 291 257 292 258 platform_set_drvdata(pdev, micsupp); 293 259
+286
drivers/regulator/axp20x-regulator.c
··· 1 + /* 2 + * AXP20x regulators driver. 3 + * 4 + * Copyright (C) 2013 Carlo Caione <carlo@caione.org> 5 + * 6 + * This file is subject to the terms and conditions of the GNU General 7 + * Public License. See the file "COPYING" in the main directory of this 8 + * archive for more details. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #include <linux/err.h> 17 + #include <linux/init.h> 18 + #include <linux/module.h> 19 + #include <linux/of.h> 20 + #include <linux/of_device.h> 21 + #include <linux/platform_device.h> 22 + #include <linux/regmap.h> 23 + #include <linux/mfd/axp20x.h> 24 + #include <linux/regulator/driver.h> 25 + #include <linux/regulator/of_regulator.h> 26 + 27 + #define AXP20X_IO_ENABLED 0x03 28 + #define AXP20X_IO_DISABLED 0x07 29 + 30 + #define AXP20X_WORKMODE_DCDC2_MASK BIT(2) 31 + #define AXP20X_WORKMODE_DCDC3_MASK BIT(1) 32 + 33 + #define AXP20X_FREQ_DCDC_MASK 0x0f 34 + 35 + #define AXP20X_DESC_IO(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \ 36 + _emask, _enable_val, _disable_val) \ 37 + [AXP20X_##_id] = { \ 38 + .name = #_id, \ 39 + .supply_name = (_supply), \ 40 + .type = REGULATOR_VOLTAGE, \ 41 + .id = AXP20X_##_id, \ 42 + .n_voltages = (((_max) - (_min)) / (_step) + 1), \ 43 + .owner = THIS_MODULE, \ 44 + .min_uV = (_min) * 1000, \ 45 + .uV_step = (_step) * 1000, \ 46 + .vsel_reg = (_vreg), \ 47 + .vsel_mask = (_vmask), \ 48 + .enable_reg = (_ereg), \ 49 + .enable_mask = (_emask), \ 50 + .enable_val = (_enable_val), \ 51 + .disable_val = (_disable_val), \ 52 + .ops = &axp20x_ops, \ 53 + } 54 + 55 + #define AXP20X_DESC(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \ 56 + _emask) \ 57 + [AXP20X_##_id] = { \ 58 + .name = #_id, \ 59 + .supply_name = (_supply), \ 60 + .type = REGULATOR_VOLTAGE, \ 61 + .id = AXP20X_##_id, \ 62 + .n_voltages = (((_max) - (_min)) / (_step) + 1), \ 63 + .owner = THIS_MODULE, \ 64 + .min_uV = (_min) * 1000, \ 65 + .uV_step = (_step) * 1000, \ 66 + .vsel_reg = (_vreg), \ 67 + .vsel_mask = (_vmask), \ 68 + .enable_reg = (_ereg), \ 69 + .enable_mask = (_emask), \ 70 + .ops = &axp20x_ops, \ 71 + } 72 + 73 + #define AXP20X_DESC_FIXED(_id, _supply, _volt) \ 74 + [AXP20X_##_id] = { \ 75 + .name = #_id, \ 76 + .supply_name = (_supply), \ 77 + .type = REGULATOR_VOLTAGE, \ 78 + .id = AXP20X_##_id, \ 79 + .n_voltages = 1, \ 80 + .owner = THIS_MODULE, \ 81 + .min_uV = (_volt) * 1000, \ 82 + .ops = &axp20x_ops_fixed \ 83 + } 84 + 85 + #define AXP20X_DESC_TABLE(_id, _supply, _table, _vreg, _vmask, _ereg, _emask) \ 86 + [AXP20X_##_id] = { \ 87 + .name = #_id, \ 88 + .supply_name = (_supply), \ 89 + .type = REGULATOR_VOLTAGE, \ 90 + .id = AXP20X_##_id, \ 91 + .n_voltages = ARRAY_SIZE(_table), \ 92 + .owner = THIS_MODULE, \ 93 + .vsel_reg = (_vreg), \ 94 + .vsel_mask = (_vmask), \ 95 + .enable_reg = (_ereg), \ 96 + .enable_mask = (_emask), \ 97 + .volt_table = (_table), \ 98 + .ops = &axp20x_ops_table, \ 99 + } 100 + 101 + static const int axp20x_ldo4_data[] = { 1250000, 1300000, 1400000, 1500000, 1600000, 102 + 1700000, 1800000, 1900000, 2000000, 2500000, 103 + 2700000, 2800000, 3000000, 3100000, 3200000, 104 + 3300000 }; 105 + 106 + static struct regulator_ops axp20x_ops_fixed = { 107 + .list_voltage = regulator_list_voltage_linear, 108 + }; 109 + 110 + static struct regulator_ops axp20x_ops_table = { 111 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 112 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 113 + .list_voltage = regulator_list_voltage_table, 114 + .map_voltage = regulator_map_voltage_ascend, 115 + .enable = regulator_enable_regmap, 116 + .disable = regulator_disable_regmap, 117 + .is_enabled = regulator_is_enabled_regmap, 118 + }; 119 + 120 + static struct regulator_ops axp20x_ops = { 121 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 122 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 123 + .list_voltage = regulator_list_voltage_linear, 124 + .enable = regulator_enable_regmap, 125 + .disable = regulator_disable_regmap, 126 + .is_enabled = regulator_is_enabled_regmap, 127 + }; 128 + 129 + static const struct regulator_desc axp20x_regulators[] = { 130 + AXP20X_DESC(DCDC2, "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT, 0x3f, 131 + AXP20X_PWR_OUT_CTRL, 0x10), 132 + AXP20X_DESC(DCDC3, "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT, 0x7f, 133 + AXP20X_PWR_OUT_CTRL, 0x02), 134 + AXP20X_DESC_FIXED(LDO1, "acin", 1300), 135 + AXP20X_DESC(LDO2, "ldo24in", 1800, 3300, 100, AXP20X_LDO24_V_OUT, 0xf0, 136 + AXP20X_PWR_OUT_CTRL, 0x04), 137 + AXP20X_DESC(LDO3, "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT, 0x7f, 138 + AXP20X_PWR_OUT_CTRL, 0x40), 139 + AXP20X_DESC_TABLE(LDO4, "ldo24in", axp20x_ldo4_data, AXP20X_LDO24_V_OUT, 0x0f, 140 + AXP20X_PWR_OUT_CTRL, 0x08), 141 + AXP20X_DESC_IO(LDO5, "ldo5in", 1800, 3300, 100, AXP20X_LDO5_V_OUT, 0xf0, 142 + AXP20X_GPIO0_CTRL, 0x07, AXP20X_IO_ENABLED, 143 + AXP20X_IO_DISABLED), 144 + }; 145 + 146 + #define AXP_MATCH(_name, _id) \ 147 + [AXP20X_##_id] = { \ 148 + .name = #_name, \ 149 + .driver_data = (void *) &axp20x_regulators[AXP20X_##_id], \ 150 + } 151 + 152 + static struct of_regulator_match axp20x_matches[] = { 153 + AXP_MATCH(dcdc2, DCDC2), 154 + AXP_MATCH(dcdc3, DCDC3), 155 + AXP_MATCH(ldo1, LDO1), 156 + AXP_MATCH(ldo2, LDO2), 157 + AXP_MATCH(ldo3, LDO3), 158 + AXP_MATCH(ldo4, LDO4), 159 + AXP_MATCH(ldo5, LDO5), 160 + }; 161 + 162 + static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) 163 + { 164 + struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); 165 + 166 + if (dcdcfreq < 750) { 167 + dcdcfreq = 750; 168 + dev_warn(&pdev->dev, "DCDC frequency too low. Set to 750kHz\n"); 169 + } 170 + 171 + if (dcdcfreq > 1875) { 172 + dcdcfreq = 1875; 173 + dev_warn(&pdev->dev, "DCDC frequency too high. Set to 1875kHz\n"); 174 + } 175 + 176 + dcdcfreq = (dcdcfreq - 750) / 75; 177 + 178 + return regmap_update_bits(axp20x->regmap, AXP20X_DCDC_FREQ, 179 + AXP20X_FREQ_DCDC_MASK, dcdcfreq); 180 + } 181 + 182 + static int axp20x_regulator_parse_dt(struct platform_device *pdev) 183 + { 184 + struct device_node *np, *regulators; 185 + int ret; 186 + u32 dcdcfreq; 187 + 188 + np = of_node_get(pdev->dev.parent->of_node); 189 + if (!np) 190 + return 0; 191 + 192 + regulators = of_get_child_by_name(np, "regulators"); 193 + if (!regulators) { 194 + dev_warn(&pdev->dev, "regulators node not found\n"); 195 + } else { 196 + ret = of_regulator_match(&pdev->dev, regulators, axp20x_matches, 197 + ARRAY_SIZE(axp20x_matches)); 198 + if (ret < 0) { 199 + dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret); 200 + return ret; 201 + } 202 + 203 + dcdcfreq = 1500; 204 + of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); 205 + ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); 206 + if (ret < 0) { 207 + dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret); 208 + return ret; 209 + } 210 + 211 + of_node_put(regulators); 212 + } 213 + 214 + return 0; 215 + } 216 + 217 + static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode) 218 + { 219 + unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK; 220 + 221 + if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3)) 222 + return -EINVAL; 223 + 224 + if (id == AXP20X_DCDC3) 225 + mask = AXP20X_WORKMODE_DCDC3_MASK; 226 + 227 + workmode <<= ffs(mask) - 1; 228 + 229 + return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode); 230 + } 231 + 232 + static int axp20x_regulator_probe(struct platform_device *pdev) 233 + { 234 + struct regulator_dev *rdev; 235 + struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); 236 + struct regulator_config config = { }; 237 + struct regulator_init_data *init_data; 238 + int ret, i; 239 + u32 workmode; 240 + 241 + ret = axp20x_regulator_parse_dt(pdev); 242 + if (ret) 243 + return ret; 244 + 245 + for (i = 0; i < AXP20X_REG_ID_MAX; i++) { 246 + init_data = axp20x_matches[i].init_data; 247 + 248 + config.dev = &pdev->dev; 249 + config.init_data = init_data; 250 + config.regmap = axp20x->regmap; 251 + config.of_node = axp20x_matches[i].of_node; 252 + 253 + rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], 254 + &config); 255 + if (IS_ERR(rdev)) { 256 + dev_err(&pdev->dev, "Failed to register %s\n", 257 + axp20x_regulators[i].name); 258 + 259 + return PTR_ERR(rdev); 260 + } 261 + 262 + ret = of_property_read_u32(axp20x_matches[i].of_node, "x-powers,dcdc-workmode", 263 + &workmode); 264 + if (!ret) { 265 + if (axp20x_set_dcdc_workmode(rdev, i, workmode)) 266 + dev_err(&pdev->dev, "Failed to set workmode on %s\n", 267 + axp20x_regulators[i].name); 268 + } 269 + } 270 + 271 + return 0; 272 + } 273 + 274 + static struct platform_driver axp20x_regulator_driver = { 275 + .probe = axp20x_regulator_probe, 276 + .driver = { 277 + .name = "axp20x-regulator", 278 + .owner = THIS_MODULE, 279 + }, 280 + }; 281 + 282 + module_platform_driver(axp20x_regulator_driver); 283 + 284 + MODULE_LICENSE("GPL v2"); 285 + MODULE_AUTHOR("Carlo Caione <carlo@caione.org>"); 286 + MODULE_DESCRIPTION("Regulator Driver for AXP20X PMIC");
+82 -10
drivers/regulator/bcm590xx-regulator.c
··· 22 22 #include <linux/regulator/of_regulator.h> 23 23 #include <linux/slab.h> 24 24 25 - /* Register defs */ 25 + /* I2C slave 0 registers */ 26 26 #define BCM590XX_RFLDOPMCTRL1 0x60 27 27 #define BCM590XX_IOSR1PMCTRL1 0x7a 28 28 #define BCM590XX_IOSR2PMCTRL1 0x7c ··· 31 31 #define BCM590XX_SDSR2PMCTRL1 0x86 32 32 #define BCM590XX_MSRPMCTRL1 0x8a 33 33 #define BCM590XX_VSRPMCTRL1 0x8e 34 - #define BCM590XX_REG_ENABLE BIT(7) 35 - 36 34 #define BCM590XX_RFLDOCTRL 0x96 37 35 #define BCM590XX_CSRVOUT1 0xc0 36 + 37 + /* I2C slave 1 registers */ 38 + #define BCM590XX_GPLDO5PMCTRL1 0x16 39 + #define BCM590XX_GPLDO6PMCTRL1 0x18 40 + #define BCM590XX_GPLDO1CTRL 0x1a 41 + #define BCM590XX_GPLDO2CTRL 0x1b 42 + #define BCM590XX_GPLDO3CTRL 0x1c 43 + #define BCM590XX_GPLDO4CTRL 0x1d 44 + #define BCM590XX_GPLDO5CTRL 0x1e 45 + #define BCM590XX_GPLDO6CTRL 0x1f 46 + #define BCM590XX_OTG_CTRL 0x40 47 + #define BCM590XX_GPLDO1PMCTRL1 0x57 48 + #define BCM590XX_GPLDO2PMCTRL1 0x59 49 + #define BCM590XX_GPLDO3PMCTRL1 0x5b 50 + #define BCM590XX_GPLDO4PMCTRL1 0x5d 51 + 52 + #define BCM590XX_REG_ENABLE BIT(7) 53 + #define BCM590XX_VBUS_ENABLE BIT(2) 38 54 #define BCM590XX_LDO_VSEL_MASK GENMASK(5, 3) 39 55 #define BCM590XX_SR_VSEL_MASK GENMASK(5, 0) 56 + 57 + /* 58 + * RFLDO to VSR regulators are 59 + * accessed via I2C slave 0 60 + */ 40 61 41 62 /* LDO regulator IDs */ 42 63 #define BCM590XX_REG_RFLDO 0 ··· 83 62 #define BCM590XX_REG_SDSR2 18 84 63 #define BCM590XX_REG_VSR 19 85 64 86 - #define BCM590XX_NUM_REGS 20 65 + /* 66 + * GPLDO1 to VBUS regulators are 67 + * accessed via I2C slave 1 68 + */ 69 + 70 + #define BCM590XX_REG_GPLDO1 20 71 + #define BCM590XX_REG_GPLDO2 21 72 + #define BCM590XX_REG_GPLDO3 22 73 + #define BCM590XX_REG_GPLDO4 23 74 + #define BCM590XX_REG_GPLDO5 24 75 + #define BCM590XX_REG_GPLDO6 25 76 + #define BCM590XX_REG_VBUS 26 77 + 78 + #define BCM590XX_NUM_REGS 27 87 79 88 80 #define BCM590XX_REG_IS_LDO(n) (n < BCM590XX_REG_CSR) 81 + #define BCM590XX_REG_IS_GPLDO(n) \ 82 + ((n > BCM590XX_REG_VSR) && (n < BCM590XX_REG_VBUS)) 83 + #define BCM590XX_REG_IS_VBUS(n) (n == BCM590XX_REG_VBUS) 89 84 90 85 struct bcm590xx_board { 91 86 struct regulator_init_data *bcm590xx_pmu_init_data[BCM590XX_NUM_REGS]; ··· 186 149 BCM590XX_REG_RANGES(sdsr1, dcdc_sdsr1_ranges), 187 150 BCM590XX_REG_RANGES(sdsr2, dcdc_iosr1_ranges), 188 151 BCM590XX_REG_RANGES(vsr, dcdc_iosr1_ranges), 152 + BCM590XX_REG_TABLE(gpldo1, ldo_a_table), 153 + BCM590XX_REG_TABLE(gpldo2, ldo_a_table), 154 + BCM590XX_REG_TABLE(gpldo3, ldo_a_table), 155 + BCM590XX_REG_TABLE(gpldo4, ldo_a_table), 156 + BCM590XX_REG_TABLE(gpldo5, ldo_a_table), 157 + BCM590XX_REG_TABLE(gpldo6, ldo_a_table), 189 158 }; 190 159 191 160 struct bcm590xx_reg { ··· 204 161 { 205 162 if (BCM590XX_REG_IS_LDO(id)) 206 163 return BCM590XX_RFLDOCTRL + id; 164 + else if (BCM590XX_REG_IS_GPLDO(id)) 165 + return BCM590XX_GPLDO1CTRL + id; 207 166 else 208 167 return BCM590XX_CSRVOUT1 + (id - BCM590XX_REG_CSR) * 3; 209 168 } ··· 216 171 217 172 if (BCM590XX_REG_IS_LDO(id)) 218 173 reg = BCM590XX_RFLDOPMCTRL1 + id * 2; 174 + else if (BCM590XX_REG_IS_GPLDO(id)) 175 + reg = BCM590XX_GPLDO1PMCTRL1 + id * 2; 219 176 else 220 177 switch (id) { 221 178 case BCM590XX_REG_CSR: ··· 238 191 case BCM590XX_REG_SDSR2: 239 192 reg = BCM590XX_SDSR2PMCTRL1; 240 193 break; 194 + case BCM590XX_REG_VBUS: 195 + reg = BCM590XX_OTG_CTRL; 241 196 }; 197 + 242 198 243 199 return reg; 244 200 } ··· 264 214 .set_voltage_sel = regulator_set_voltage_sel_regmap, 265 215 .list_voltage = regulator_list_voltage_linear_range, 266 216 .map_voltage = regulator_map_voltage_linear_range, 217 + }; 218 + 219 + static struct regulator_ops bcm590xx_ops_vbus = { 220 + .is_enabled = regulator_is_enabled_regmap, 221 + .enable = regulator_enable_regmap, 222 + .disable = regulator_disable_regmap, 267 223 }; 268 224 269 225 #define BCM590XX_MATCH(_name, _id) \ ··· 299 243 BCM590XX_MATCH(sdsr1, SDSR1), 300 244 BCM590XX_MATCH(sdsr2, SDSR2), 301 245 BCM590XX_MATCH(vsr, VSR), 246 + BCM590XX_MATCH(gpldo1, GPLDO1), 247 + BCM590XX_MATCH(gpldo2, GPLDO2), 248 + BCM590XX_MATCH(gpldo3, GPLDO3), 249 + BCM590XX_MATCH(gpldo4, GPLDO4), 250 + BCM590XX_MATCH(gpldo5, GPLDO5), 251 + BCM590XX_MATCH(gpldo6, GPLDO6), 252 + BCM590XX_MATCH(vbus, VBUS), 302 253 }; 303 254 304 255 static struct bcm590xx_board *bcm590xx_parse_dt_reg_data( ··· 416 353 pmu->desc[i].linear_ranges = info->linear_ranges; 417 354 pmu->desc[i].n_linear_ranges = info->n_linear_ranges; 418 355 419 - if (BCM590XX_REG_IS_LDO(i)) { 356 + if ((BCM590XX_REG_IS_LDO(i)) || (BCM590XX_REG_IS_GPLDO(i))) { 420 357 pmu->desc[i].ops = &bcm590xx_ops_ldo; 421 358 pmu->desc[i].vsel_mask = BCM590XX_LDO_VSEL_MASK; 422 - } else { 359 + } else if (BCM590XX_REG_IS_VBUS(i)) 360 + pmu->desc[i].ops = &bcm590xx_ops_vbus; 361 + else { 423 362 pmu->desc[i].ops = &bcm590xx_ops_dcdc; 424 363 pmu->desc[i].vsel_mask = BCM590XX_SR_VSEL_MASK; 425 364 } 426 365 427 - pmu->desc[i].vsel_reg = bcm590xx_get_vsel_register(i); 428 - pmu->desc[i].enable_is_inverted = true; 429 - pmu->desc[i].enable_mask = BCM590XX_REG_ENABLE; 366 + if (BCM590XX_REG_IS_VBUS(i)) 367 + pmu->desc[i].enable_mask = BCM590XX_VBUS_ENABLE; 368 + else { 369 + pmu->desc[i].vsel_reg = bcm590xx_get_vsel_register(i); 370 + pmu->desc[i].enable_is_inverted = true; 371 + pmu->desc[i].enable_mask = BCM590XX_REG_ENABLE; 372 + } 430 373 pmu->desc[i].enable_reg = bcm590xx_get_enable_register(i); 431 374 pmu->desc[i].type = REGULATOR_VOLTAGE; 432 375 pmu->desc[i].owner = THIS_MODULE; ··· 440 371 config.dev = bcm590xx->dev; 441 372 config.init_data = reg_data; 442 373 config.driver_data = pmu; 443 - config.regmap = bcm590xx->regmap; 374 + if (BCM590XX_REG_IS_GPLDO(i) || BCM590XX_REG_IS_VBUS(i)) 375 + config.regmap = bcm590xx->regmap_sec; 376 + else 377 + config.regmap = bcm590xx->regmap_pri; 444 378 445 379 if (bcm590xx_reg_matches) 446 380 config.of_node = bcm590xx_reg_matches[i].of_node;
+37 -21
drivers/regulator/core.c
··· 844 844 /* do we need to apply the constraint voltage */ 845 845 if (rdev->constraints->apply_uV && 846 846 rdev->constraints->min_uV == rdev->constraints->max_uV) { 847 - ret = _regulator_do_set_voltage(rdev, 848 - rdev->constraints->min_uV, 849 - rdev->constraints->max_uV); 850 - if (ret < 0) { 851 - rdev_err(rdev, "failed to apply %duV constraint\n", 852 - rdev->constraints->min_uV); 853 - return ret; 847 + int current_uV = _regulator_get_voltage(rdev); 848 + if (current_uV < 0) { 849 + rdev_err(rdev, "failed to get the current voltage\n"); 850 + return current_uV; 851 + } 852 + if (current_uV < rdev->constraints->min_uV || 853 + current_uV > rdev->constraints->max_uV) { 854 + ret = _regulator_do_set_voltage( 855 + rdev, rdev->constraints->min_uV, 856 + rdev->constraints->max_uV); 857 + if (ret < 0) { 858 + rdev_err(rdev, 859 + "failed to apply %duV constraint\n", 860 + rdev->constraints->min_uV); 861 + return ret; 862 + } 854 863 } 855 864 } 856 865 ··· 1439 1430 * 1440 1431 * Returns a struct regulator corresponding to the regulator producer, 1441 1432 * or IS_ERR() condition containing errno. Other consumers will be 1442 - * unable to obtain this reference is held and the use count for the 1443 - * regulator will be initialised to reflect the current state of the 1444 - * regulator. 1433 + * unable to obtain this regulator while this reference is held and the 1434 + * use count for the regulator will be initialised to reflect the current 1435 + * state of the regulator. 1445 1436 * 1446 1437 * This is intended for use by consumers which cannot tolerate shared 1447 1438 * use of the regulator such as those which need to force the ··· 1465 1456 * @id: Supply name or regulator ID. 1466 1457 * 1467 1458 * Returns a struct regulator corresponding to the regulator producer, 1468 - * or IS_ERR() condition containing errno. Other consumers will be 1469 - * unable to obtain this reference is held and the use count for the 1470 - * regulator will be initialised to reflect the current state of the 1471 - * regulator. 1459 + * or IS_ERR() condition containing errno. 1472 1460 * 1473 1461 * This is intended for use by consumers for devices which can have 1474 1462 * some supplies unconnected in normal use, such as some MMC devices. ··· 1603 1597 * registered any aliases that were registered will be removed 1604 1598 * before returning to the caller. 1605 1599 */ 1606 - int regulator_bulk_register_supply_alias(struct device *dev, const char **id, 1600 + int regulator_bulk_register_supply_alias(struct device *dev, 1601 + const char *const *id, 1607 1602 struct device *alias_dev, 1608 - const char **alias_id, 1603 + const char *const *alias_id, 1609 1604 int num_id) 1610 1605 { 1611 1606 int i; ··· 1644 1637 * aliases in one operation. 1645 1638 */ 1646 1639 void regulator_bulk_unregister_supply_alias(struct device *dev, 1647 - const char **id, 1640 + const char *const *id, 1648 1641 int num_id) 1649 1642 { 1650 1643 int i; ··· 2327 2320 if (rdev->desc->ops->list_voltage == 2328 2321 regulator_list_voltage_linear) 2329 2322 ret = regulator_map_voltage_linear(rdev, 2323 + min_uV, max_uV); 2324 + else if (rdev->desc->ops->list_voltage == 2325 + regulator_list_voltage_linear_range) 2326 + ret = regulator_map_voltage_linear_range(rdev, 2330 2327 min_uV, max_uV); 2331 2328 else 2332 2329 ret = regulator_map_voltage_iterate(rdev, ··· 3458 3447 3459 3448 /* register with sysfs */ 3460 3449 rdev->dev.class = &regulator_class; 3461 - rdev->dev.of_node = config->of_node; 3450 + rdev->dev.of_node = of_node_get(config->of_node); 3462 3451 rdev->dev.parent = dev; 3463 3452 dev_set_name(&rdev->dev, "regulator.%d", 3464 3453 atomic_inc_return(&regulator_no) - 1); ··· 3600 3589 list_del(&rdev->list); 3601 3590 kfree(rdev->constraints); 3602 3591 regulator_ena_gpio_free(rdev); 3592 + of_node_put(rdev->dev.of_node); 3603 3593 device_unregister(&rdev->dev); 3604 3594 mutex_unlock(&regulator_list_mutex); 3605 3595 } ··· 3831 3819 mutex_lock(&regulator_list_mutex); 3832 3820 3833 3821 /* If we have a full configuration then disable any regulators 3834 - * which are not in use or always_on. This will become the 3835 - * default behaviour in the future. 3822 + * we have permission to change the status for and which are 3823 + * not in use or always_on. This is effectively the default 3824 + * for DT and ACPI as they have full constraints. 3836 3825 */ 3837 3826 list_for_each_entry(rdev, &regulator_list, list) { 3838 3827 ops = rdev->desc->ops; 3839 3828 c = rdev->constraints; 3840 3829 3841 3830 if (c && c->always_on) 3831 + continue; 3832 + 3833 + if (c && !(c->valid_ops_mask & REGULATOR_CHANGE_STATUS)) 3842 3834 continue; 3843 3835 3844 3836 mutex_lock(&rdev->mutex); ··· 3883 3867 3884 3868 return 0; 3885 3869 } 3886 - late_initcall(regulator_init_complete); 3870 + late_initcall_sync(regulator_init_complete);
+3 -3
drivers/regulator/devres.c
··· 360 360 * will be removed before returning to the caller. 361 361 */ 362 362 int devm_regulator_bulk_register_supply_alias(struct device *dev, 363 - const char **id, 363 + const char *const *id, 364 364 struct device *alias_dev, 365 - const char **alias_id, 365 + const char *const *alias_id, 366 366 int num_id) 367 367 { 368 368 int i; ··· 404 404 * will ensure that the resource is freed. 405 405 */ 406 406 void devm_regulator_bulk_unregister_supply_alias(struct device *dev, 407 - const char **id, 407 + const char *const *id, 408 408 int num_id) 409 409 { 410 410 int i;
+4 -9
drivers/regulator/fixed.c
··· 50 50 { 51 51 struct fixed_voltage_config *config; 52 52 struct device_node *np = dev->of_node; 53 - const __be32 *delay; 54 53 struct regulator_init_data *init_data; 55 54 56 55 config = devm_kzalloc(dev, sizeof(struct fixed_voltage_config), ··· 90 91 if ((config->gpio == -ENODEV) || (config->gpio == -EPROBE_DEFER)) 91 92 return ERR_PTR(-EPROBE_DEFER); 92 93 93 - delay = of_get_property(np, "startup-delay-us", NULL); 94 - if (delay) 95 - config->startup_delay = be32_to_cpu(*delay); 94 + of_property_read_u32(np, "startup-delay-us", &config->startup_delay); 96 95 97 - if (of_find_property(np, "enable-active-high", NULL)) 98 - config->enable_high = true; 99 - 100 - if (of_find_property(np, "gpio-open-drain", NULL)) 101 - config->gpio_is_open_drain = true; 96 + config->enable_high = of_property_read_bool(np, "enable-active-high"); 97 + config->gpio_is_open_drain = of_property_read_bool(np, 98 + "gpio-open-drain"); 102 99 103 100 if (of_find_property(np, "vin-supply", NULL)) 104 101 config->input_supply = "vin";
+554
drivers/regulator/ltc3589.c
··· 1 + /* 2 + * Linear Technology LTC3589,LTC3589-1 regulator support 3 + * 4 + * Copyright (c) 2014 Philipp Zabel <p.zabel@pengutronix.de>, Pengutronix 5 + * 6 + * See file CREDITS for list of people who contributed to this 7 + * project. 8 + * 9 + * This program is free software; you can redistribute it and/or modify 10 + * it under the terms of the GNU General Public License version 2 11 + * as published by the Free Software Foundation. 12 + * 13 + * This program is distributed in the hope that it will be useful, 14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + * GNU General Public License for more details. 17 + * 18 + */ 19 + #include <linux/i2c.h> 20 + #include <linux/init.h> 21 + #include <linux/interrupt.h> 22 + #include <linux/module.h> 23 + #include <linux/kernel.h> 24 + #include <linux/of.h> 25 + #include <linux/regmap.h> 26 + #include <linux/regulator/driver.h> 27 + #include <linux/regulator/of_regulator.h> 28 + 29 + #define DRIVER_NAME "ltc3589" 30 + 31 + #define LTC3589_IRQSTAT 0x02 32 + #define LTC3589_SCR1 0x07 33 + #define LTC3589_OVEN 0x10 34 + #define LTC3589_SCR2 0x12 35 + #define LTC3589_PGSTAT 0x13 36 + #define LTC3589_VCCR 0x20 37 + #define LTC3589_CLIRQ 0x21 38 + #define LTC3589_B1DTV1 0x23 39 + #define LTC3589_B1DTV2 0x24 40 + #define LTC3589_VRRCR 0x25 41 + #define LTC3589_B2DTV1 0x26 42 + #define LTC3589_B2DTV2 0x27 43 + #define LTC3589_B3DTV1 0x29 44 + #define LTC3589_B3DTV2 0x2a 45 + #define LTC3589_L2DTV1 0x32 46 + #define LTC3589_L2DTV2 0x33 47 + 48 + #define LTC3589_IRQSTAT_PGOOD_TIMEOUT BIT(3) 49 + #define LTC3589_IRQSTAT_UNDERVOLT_WARN BIT(4) 50 + #define LTC3589_IRQSTAT_UNDERVOLT_FAULT BIT(5) 51 + #define LTC3589_IRQSTAT_THERMAL_WARN BIT(6) 52 + #define LTC3589_IRQSTAT_THERMAL_FAULT BIT(7) 53 + 54 + #define LTC3589_OVEN_SW1 BIT(0) 55 + #define LTC3589_OVEN_SW2 BIT(1) 56 + #define LTC3589_OVEN_SW3 BIT(2) 57 + #define LTC3589_OVEN_BB_OUT BIT(3) 58 + #define LTC3589_OVEN_LDO2 BIT(4) 59 + #define LTC3589_OVEN_LDO3 BIT(5) 60 + #define LTC3589_OVEN_LDO4 BIT(6) 61 + #define LTC3589_OVEN_SW_CTRL BIT(7) 62 + 63 + #define LTC3589_VCCR_SW1_GO BIT(0) 64 + #define LTC3589_VCCR_SW2_GO BIT(2) 65 + #define LTC3589_VCCR_SW3_GO BIT(4) 66 + #define LTC3589_VCCR_LDO2_GO BIT(6) 67 + 68 + enum ltc3589_variant { 69 + LTC3589, 70 + LTC3589_1, 71 + LTC3589_2, 72 + }; 73 + 74 + enum ltc3589_reg { 75 + LTC3589_SW1, 76 + LTC3589_SW2, 77 + LTC3589_SW3, 78 + LTC3589_BB_OUT, 79 + LTC3589_LDO1, 80 + LTC3589_LDO2, 81 + LTC3589_LDO3, 82 + LTC3589_LDO4, 83 + LTC3589_NUM_REGULATORS, 84 + }; 85 + 86 + struct ltc3589_regulator { 87 + struct regulator_desc desc; 88 + 89 + /* External feedback voltage divider */ 90 + unsigned int r1; 91 + unsigned int r2; 92 + }; 93 + 94 + struct ltc3589 { 95 + struct regmap *regmap; 96 + struct device *dev; 97 + enum ltc3589_variant variant; 98 + struct ltc3589_regulator regulator_descs[LTC3589_NUM_REGULATORS]; 99 + struct regulator_dev *regulators[LTC3589_NUM_REGULATORS]; 100 + }; 101 + 102 + static const int ltc3589_ldo4[] = { 103 + 2800000, 2500000, 1800000, 3300000, 104 + }; 105 + 106 + static const int ltc3589_12_ldo4[] = { 107 + 1200000, 1800000, 2500000, 3200000, 108 + }; 109 + 110 + static int ltc3589_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) 111 + { 112 + struct ltc3589 *ltc3589 = rdev_get_drvdata(rdev); 113 + int sel, shift; 114 + 115 + if (unlikely(ramp_delay <= 0)) 116 + return -EINVAL; 117 + 118 + /* VRRCR slew rate offsets are the same as VCCR go bit offsets */ 119 + shift = ffs(rdev->desc->apply_bit) - 1; 120 + 121 + /* The slew rate can be set to 0.88, 1.75, 3.5, or 7 mV/uS */ 122 + for (sel = 0; sel < 4; sel++) { 123 + if ((880 << sel) >= ramp_delay) { 124 + return regmap_update_bits(ltc3589->regmap, 125 + LTC3589_VRRCR, 126 + 0x3 << shift, sel << shift); 127 + } 128 + } 129 + return -EINVAL; 130 + } 131 + 132 + static int ltc3589_set_suspend_voltage(struct regulator_dev *rdev, int uV) 133 + { 134 + struct ltc3589 *ltc3589 = rdev_get_drvdata(rdev); 135 + int sel; 136 + 137 + sel = regulator_map_voltage_linear(rdev, uV, uV); 138 + if (sel < 0) 139 + return sel; 140 + 141 + /* DTV2 register follows right after the corresponding DTV1 register */ 142 + return regmap_update_bits(ltc3589->regmap, rdev->desc->vsel_reg + 1, 143 + rdev->desc->vsel_mask, sel); 144 + } 145 + 146 + static int ltc3589_set_suspend_mode(struct regulator_dev *rdev, 147 + unsigned int mode) 148 + { 149 + struct ltc3589 *ltc3589 = rdev_get_drvdata(rdev); 150 + int mask, bit = 0; 151 + 152 + /* VCCR reference selects are right next to the VCCR go bits */ 153 + mask = rdev->desc->apply_bit << 1; 154 + 155 + if (mode == REGULATOR_MODE_STANDBY) 156 + bit = mask; /* Select DTV2 */ 157 + 158 + mask |= rdev->desc->apply_bit; 159 + bit |= rdev->desc->apply_bit; 160 + return regmap_update_bits(ltc3589->regmap, LTC3589_VCCR, mask, bit); 161 + } 162 + 163 + /* SW1, SW2, SW3, LDO2 */ 164 + static struct regulator_ops ltc3589_linear_regulator_ops = { 165 + .enable = regulator_enable_regmap, 166 + .disable = regulator_disable_regmap, 167 + .is_enabled = regulator_is_enabled_regmap, 168 + .list_voltage = regulator_list_voltage_linear, 169 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 170 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 171 + .set_ramp_delay = ltc3589_set_ramp_delay, 172 + .set_voltage_time_sel = regulator_set_voltage_time_sel, 173 + .set_suspend_voltage = ltc3589_set_suspend_voltage, 174 + .set_suspend_mode = ltc3589_set_suspend_mode, 175 + }; 176 + 177 + /* BB_OUT, LDO3 */ 178 + static struct regulator_ops ltc3589_fixed_regulator_ops = { 179 + .enable = regulator_enable_regmap, 180 + .disable = regulator_disable_regmap, 181 + .is_enabled = regulator_is_enabled_regmap, 182 + }; 183 + 184 + /* LDO1 */ 185 + static struct regulator_ops ltc3589_fixed_standby_regulator_ops = { 186 + }; 187 + 188 + /* LDO4 */ 189 + static struct regulator_ops ltc3589_table_regulator_ops = { 190 + .enable = regulator_enable_regmap, 191 + .disable = regulator_disable_regmap, 192 + .is_enabled = regulator_is_enabled_regmap, 193 + .list_voltage = regulator_list_voltage_table, 194 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 195 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 196 + }; 197 + 198 + 199 + #define LTC3589_REG(_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit) \ 200 + [LTC3589_ ## _name] = { \ 201 + .desc = { \ 202 + .name = #_name, \ 203 + .n_voltages = (dtv_mask) + 1, \ 204 + .min_uV = (go_bit) ? 362500 : 0, \ 205 + .uV_step = (go_bit) ? 12500 : 0, \ 206 + .ramp_delay = (go_bit) ? 1750 : 0, \ 207 + .fixed_uV = (dtv_mask) ? 0 : 800000, \ 208 + .ops = &ltc3589_ ## _ops ## _regulator_ops, \ 209 + .type = REGULATOR_VOLTAGE, \ 210 + .id = LTC3589_ ## _name, \ 211 + .owner = THIS_MODULE, \ 212 + .vsel_reg = (dtv1_reg), \ 213 + .vsel_mask = (dtv_mask), \ 214 + .apply_reg = (go_bit) ? LTC3589_VCCR : 0, \ 215 + .apply_bit = (go_bit), \ 216 + .enable_reg = (en_bit) ? LTC3589_OVEN : 0, \ 217 + .enable_mask = (en_bit), \ 218 + }, \ 219 + } 220 + 221 + #define LTC3589_LINEAR_REG(_name, _dtv1) \ 222 + LTC3589_REG(_name, linear, LTC3589_OVEN_ ## _name, \ 223 + LTC3589_ ## _dtv1, 0x1f, \ 224 + LTC3589_VCCR_ ## _name ## _GO) 225 + 226 + #define LTC3589_FIXED_REG(_name) \ 227 + LTC3589_REG(_name, fixed, LTC3589_OVEN_ ## _name, 0, 0, 0) 228 + 229 + static struct ltc3589_regulator ltc3589_regulators[LTC3589_NUM_REGULATORS] = { 230 + LTC3589_LINEAR_REG(SW1, B1DTV1), 231 + LTC3589_LINEAR_REG(SW2, B2DTV1), 232 + LTC3589_LINEAR_REG(SW3, B3DTV1), 233 + LTC3589_FIXED_REG(BB_OUT), 234 + LTC3589_REG(LDO1, fixed_standby, 0, 0, 0, 0), 235 + LTC3589_LINEAR_REG(LDO2, L2DTV1), 236 + LTC3589_FIXED_REG(LDO3), 237 + LTC3589_REG(LDO4, table, LTC3589_OVEN_LDO4, LTC3589_L2DTV2, 0x60, 0), 238 + }; 239 + 240 + #ifdef CONFIG_OF 241 + static struct of_regulator_match ltc3589_matches[LTC3589_NUM_REGULATORS] = { 242 + { .name = "sw1", }, 243 + { .name = "sw2", }, 244 + { .name = "sw3", }, 245 + { .name = "bb-out", }, 246 + { .name = "ldo1", }, /* standby */ 247 + { .name = "ldo2", }, 248 + { .name = "ldo3", }, 249 + { .name = "ldo4", }, 250 + }; 251 + 252 + static int ltc3589_parse_regulators_dt(struct ltc3589 *ltc3589) 253 + { 254 + struct device *dev = ltc3589->dev; 255 + struct device_node *node; 256 + int i, ret; 257 + 258 + node = of_find_node_by_name(dev->of_node, "regulators"); 259 + if (!node) { 260 + dev_err(dev, "regulators node not found\n"); 261 + return -EINVAL; 262 + } 263 + 264 + ret = of_regulator_match(dev, node, ltc3589_matches, 265 + ARRAY_SIZE(ltc3589_matches)); 266 + of_node_put(node); 267 + if (ret < 0) { 268 + dev_err(dev, "Error parsing regulator init data: %d\n", ret); 269 + return ret; 270 + } 271 + if (ret != LTC3589_NUM_REGULATORS) { 272 + dev_err(dev, "Only %d regulators described in device tree\n", 273 + ret); 274 + return -EINVAL; 275 + } 276 + 277 + /* Parse feedback voltage dividers. LDO3 and LDO4 don't have them */ 278 + for (i = 0; i < LTC3589_LDO3; i++) { 279 + struct ltc3589_regulator *desc = &ltc3589->regulator_descs[i]; 280 + struct device_node *np = ltc3589_matches[i].of_node; 281 + u32 vdiv[2]; 282 + 283 + ret = of_property_read_u32_array(np, "lltc,fb-voltage-divider", 284 + vdiv, 2); 285 + if (ret) { 286 + dev_err(dev, "Failed to parse voltage divider: %d\n", 287 + ret); 288 + return ret; 289 + } 290 + 291 + desc->r1 = vdiv[0]; 292 + desc->r2 = vdiv[1]; 293 + } 294 + 295 + return 0; 296 + } 297 + 298 + static inline struct regulator_init_data *match_init_data(int index) 299 + { 300 + return ltc3589_matches[index].init_data; 301 + } 302 + 303 + static inline struct device_node *match_of_node(int index) 304 + { 305 + return ltc3589_matches[index].of_node; 306 + } 307 + #else 308 + static inline int ltc3589_parse_regulators_dt(struct ltc3589 *ltc3589) 309 + { 310 + return 0; 311 + } 312 + 313 + static inline struct regulator_init_data *match_init_data(int index) 314 + { 315 + return NULL; 316 + } 317 + 318 + static inline struct device_node *match_of_node(int index) 319 + { 320 + return NULL; 321 + } 322 + #endif 323 + 324 + static bool ltc3589_writeable_reg(struct device *dev, unsigned int reg) 325 + { 326 + switch (reg) { 327 + case LTC3589_IRQSTAT: 328 + case LTC3589_SCR1: 329 + case LTC3589_OVEN: 330 + case LTC3589_SCR2: 331 + case LTC3589_VCCR: 332 + case LTC3589_CLIRQ: 333 + case LTC3589_B1DTV1: 334 + case LTC3589_B1DTV2: 335 + case LTC3589_VRRCR: 336 + case LTC3589_B2DTV1: 337 + case LTC3589_B2DTV2: 338 + case LTC3589_B3DTV1: 339 + case LTC3589_B3DTV2: 340 + case LTC3589_L2DTV1: 341 + case LTC3589_L2DTV2: 342 + return true; 343 + } 344 + return false; 345 + } 346 + 347 + static bool ltc3589_readable_reg(struct device *dev, unsigned int reg) 348 + { 349 + switch (reg) { 350 + case LTC3589_IRQSTAT: 351 + case LTC3589_SCR1: 352 + case LTC3589_OVEN: 353 + case LTC3589_SCR2: 354 + case LTC3589_PGSTAT: 355 + case LTC3589_VCCR: 356 + case LTC3589_B1DTV1: 357 + case LTC3589_B1DTV2: 358 + case LTC3589_VRRCR: 359 + case LTC3589_B2DTV1: 360 + case LTC3589_B2DTV2: 361 + case LTC3589_B3DTV1: 362 + case LTC3589_B3DTV2: 363 + case LTC3589_L2DTV1: 364 + case LTC3589_L2DTV2: 365 + return true; 366 + } 367 + return false; 368 + } 369 + 370 + static bool ltc3589_volatile_reg(struct device *dev, unsigned int reg) 371 + { 372 + switch (reg) { 373 + case LTC3589_IRQSTAT: 374 + case LTC3589_PGSTAT: 375 + return true; 376 + } 377 + return false; 378 + } 379 + 380 + struct reg_default ltc3589_reg_defaults[] = { 381 + { LTC3589_SCR1, 0x00 }, 382 + { LTC3589_OVEN, 0x00 }, 383 + { LTC3589_SCR2, 0x00 }, 384 + { LTC3589_VCCR, 0x00 }, 385 + { LTC3589_B1DTV1, 0x19 }, 386 + { LTC3589_B1DTV2, 0x19 }, 387 + { LTC3589_VRRCR, 0xff }, 388 + { LTC3589_B2DTV1, 0x19 }, 389 + { LTC3589_B2DTV2, 0x19 }, 390 + { LTC3589_B3DTV1, 0x19 }, 391 + { LTC3589_B3DTV2, 0x19 }, 392 + { LTC3589_L2DTV1, 0x19 }, 393 + { LTC3589_L2DTV2, 0x19 }, 394 + }; 395 + 396 + static const struct regmap_config ltc3589_regmap_config = { 397 + .reg_bits = 8, 398 + .val_bits = 8, 399 + .writeable_reg = ltc3589_writeable_reg, 400 + .readable_reg = ltc3589_readable_reg, 401 + .volatile_reg = ltc3589_volatile_reg, 402 + .max_register = LTC3589_L2DTV2, 403 + .reg_defaults = ltc3589_reg_defaults, 404 + .num_reg_defaults = ARRAY_SIZE(ltc3589_reg_defaults), 405 + .use_single_rw = true, 406 + .cache_type = REGCACHE_RBTREE, 407 + }; 408 + 409 + 410 + static irqreturn_t ltc3589_isr(int irq, void *dev_id) 411 + { 412 + struct ltc3589 *ltc3589 = dev_id; 413 + unsigned int i, irqstat, event; 414 + 415 + regmap_read(ltc3589->regmap, LTC3589_IRQSTAT, &irqstat); 416 + 417 + if (irqstat & LTC3589_IRQSTAT_THERMAL_WARN) { 418 + event = REGULATOR_EVENT_OVER_TEMP; 419 + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) 420 + regulator_notifier_call_chain(ltc3589->regulators[i], 421 + event, NULL); 422 + } 423 + 424 + if (irqstat & LTC3589_IRQSTAT_UNDERVOLT_WARN) { 425 + event = REGULATOR_EVENT_UNDER_VOLTAGE; 426 + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) 427 + regulator_notifier_call_chain(ltc3589->regulators[i], 428 + event, NULL); 429 + } 430 + 431 + /* Clear warning condition */ 432 + regmap_write(ltc3589->regmap, LTC3589_CLIRQ, 0); 433 + 434 + return IRQ_HANDLED; 435 + } 436 + 437 + static inline unsigned int ltc3589_scale(unsigned int uV, u32 r1, u32 r2) 438 + { 439 + uint64_t tmp; 440 + if (uV == 0) 441 + return 0; 442 + tmp = (uint64_t)uV * r1; 443 + do_div(tmp, r2); 444 + return uV + (unsigned int)tmp; 445 + } 446 + 447 + static void ltc3589_apply_fb_voltage_divider(struct ltc3589_regulator *rdesc) 448 + { 449 + struct regulator_desc *desc = &rdesc->desc; 450 + 451 + if (!rdesc->r1 || !rdesc->r2) 452 + return; 453 + 454 + desc->min_uV = ltc3589_scale(desc->min_uV, rdesc->r1, rdesc->r2); 455 + desc->uV_step = ltc3589_scale(desc->uV_step, rdesc->r1, rdesc->r2); 456 + desc->fixed_uV = ltc3589_scale(desc->fixed_uV, rdesc->r1, rdesc->r2); 457 + } 458 + 459 + static int ltc3589_probe(struct i2c_client *client, 460 + const struct i2c_device_id *id) 461 + { 462 + struct device *dev = &client->dev; 463 + struct ltc3589_regulator *descs; 464 + struct ltc3589 *ltc3589; 465 + int i, ret; 466 + 467 + ltc3589 = devm_kzalloc(dev, sizeof(*ltc3589), GFP_KERNEL); 468 + if (!ltc3589) 469 + return -ENOMEM; 470 + 471 + i2c_set_clientdata(client, ltc3589); 472 + ltc3589->variant = id->driver_data; 473 + ltc3589->dev = dev; 474 + 475 + descs = ltc3589->regulator_descs; 476 + memcpy(descs, ltc3589_regulators, sizeof(ltc3589_regulators)); 477 + if (ltc3589->variant == LTC3589) { 478 + descs[LTC3589_LDO3].desc.fixed_uV = 1800000; 479 + descs[LTC3589_LDO4].desc.volt_table = ltc3589_ldo4; 480 + } else { 481 + descs[LTC3589_LDO3].desc.fixed_uV = 2800000; 482 + descs[LTC3589_LDO4].desc.volt_table = ltc3589_12_ldo4; 483 + } 484 + 485 + ltc3589->regmap = devm_regmap_init_i2c(client, &ltc3589_regmap_config); 486 + if (IS_ERR(ltc3589->regmap)) { 487 + ret = PTR_ERR(ltc3589->regmap); 488 + dev_err(dev, "failed to initialize regmap: %d\n", ret); 489 + return ret; 490 + } 491 + 492 + ret = ltc3589_parse_regulators_dt(ltc3589); 493 + if (ret) 494 + return ret; 495 + 496 + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { 497 + struct ltc3589_regulator *rdesc = &ltc3589->regulator_descs[i]; 498 + struct regulator_desc *desc = &rdesc->desc; 499 + struct regulator_init_data *init_data; 500 + struct regulator_config config = { }; 501 + 502 + init_data = match_init_data(i); 503 + 504 + if (i < LTC3589_LDO3) 505 + ltc3589_apply_fb_voltage_divider(rdesc); 506 + 507 + config.dev = dev; 508 + config.init_data = init_data; 509 + config.driver_data = ltc3589; 510 + config.of_node = match_of_node(i); 511 + 512 + ltc3589->regulators[i] = devm_regulator_register(dev, desc, 513 + &config); 514 + if (IS_ERR(ltc3589->regulators[i])) { 515 + ret = PTR_ERR(ltc3589->regulators[i]); 516 + dev_err(dev, "failed to register regulator %s: %d\n", 517 + desc->name, ret); 518 + return ret; 519 + } 520 + } 521 + 522 + ret = devm_request_threaded_irq(dev, client->irq, NULL, ltc3589_isr, 523 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 524 + client->name, ltc3589); 525 + if (ret) { 526 + dev_err(dev, "Failed to request IRQ: %d\n", ret); 527 + return ret; 528 + } 529 + 530 + return 0; 531 + } 532 + 533 + static struct i2c_device_id ltc3589_i2c_id[] = { 534 + { "ltc3589", LTC3589 }, 535 + { "ltc3589-1", LTC3589_1 }, 536 + { "ltc3589-2", LTC3589_2 }, 537 + { } 538 + }; 539 + MODULE_DEVICE_TABLE(i2c, ltc3589_i2c_id); 540 + 541 + static struct i2c_driver ltc3589_driver = { 542 + .driver = { 543 + .name = DRIVER_NAME, 544 + .owner = THIS_MODULE, 545 + }, 546 + .probe = ltc3589_probe, 547 + .id_table = ltc3589_i2c_id, 548 + }; 549 + module_i2c_driver(ltc3589_driver); 550 + 551 + MODULE_AUTHOR("Philipp Zabel <p.zabel@pengutronix.de>"); 552 + MODULE_DESCRIPTION("Regulator driver for Linear Technology LTC3589(-1,2)"); 553 + MODULE_LICENSE("GPL v2"); 554 + MODULE_ALIAS("i2c:ltc3589");
+1 -3
drivers/regulator/max8649.c
··· 161 161 162 162 info = devm_kzalloc(&client->dev, sizeof(struct max8649_regulator_info), 163 163 GFP_KERNEL); 164 - if (!info) { 165 - dev_err(&client->dev, "No enough memory\n"); 164 + if (!info) 166 165 return -ENOMEM; 167 - } 168 166 169 167 info->regmap = devm_regmap_init_i2c(client, &max8649_regmap_config); 170 168 if (IS_ERR(info->regmap)) {
+1 -1
drivers/regulator/max8952.c
··· 129 129 }; 130 130 131 131 #ifdef CONFIG_OF 132 - static struct of_device_id max8952_dt_match[] = { 132 + static const struct of_device_id max8952_dt_match[] = { 133 133 { .compatible = "maxim,max8952" }, 134 134 {}, 135 135 };
+43 -25
drivers/regulator/of_regulator.c
··· 19 19 static void of_get_regulation_constraints(struct device_node *np, 20 20 struct regulator_init_data **init_data) 21 21 { 22 - const __be32 *min_uV, *max_uV, *uV_offset; 23 - const __be32 *min_uA, *max_uA, *ramp_delay; 24 - struct property *prop; 22 + const __be32 *min_uV, *max_uV; 25 23 struct regulation_constraints *constraints = &(*init_data)->constraints; 26 24 int ret; 27 25 u32 pval; ··· 40 42 if (min_uV && max_uV && constraints->min_uV == constraints->max_uV) 41 43 constraints->apply_uV = true; 42 44 43 - uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL); 44 - if (uV_offset) 45 - constraints->uV_offset = be32_to_cpu(*uV_offset); 46 - min_uA = of_get_property(np, "regulator-min-microamp", NULL); 47 - if (min_uA) 48 - constraints->min_uA = be32_to_cpu(*min_uA); 49 - max_uA = of_get_property(np, "regulator-max-microamp", NULL); 50 - if (max_uA) 51 - constraints->max_uA = be32_to_cpu(*max_uA); 45 + if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval)) 46 + constraints->uV_offset = pval; 47 + if (!of_property_read_u32(np, "regulator-min-microamp", &pval)) 48 + constraints->min_uA = pval; 49 + if (!of_property_read_u32(np, "regulator-max-microamp", &pval)) 50 + constraints->max_uA = pval; 52 51 53 52 /* Current change possible? */ 54 53 if (constraints->min_uA != constraints->max_uA) 55 54 constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; 56 55 57 - if (of_find_property(np, "regulator-boot-on", NULL)) 58 - constraints->boot_on = true; 59 - 60 - if (of_find_property(np, "regulator-always-on", NULL)) 61 - constraints->always_on = true; 62 - else /* status change should be possible if not always on. */ 56 + constraints->boot_on = of_property_read_bool(np, "regulator-boot-on"); 57 + constraints->always_on = of_property_read_bool(np, "regulator-always-on"); 58 + if (!constraints->always_on) /* status change should be possible. */ 63 59 constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; 64 60 65 61 if (of_property_read_bool(np, "regulator-allow-bypass")) 66 62 constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; 67 63 68 - prop = of_find_property(np, "regulator-ramp-delay", NULL); 69 - if (prop && prop->value) { 70 - ramp_delay = prop->value; 71 - if (*ramp_delay) 72 - constraints->ramp_delay = be32_to_cpu(*ramp_delay); 64 + ret = of_property_read_u32(np, "regulator-ramp-delay", &pval); 65 + if (!ret) { 66 + if (pval) 67 + constraints->ramp_delay = pval; 73 68 else 74 69 constraints->ramp_disable = true; 75 70 } ··· 97 106 } 98 107 EXPORT_SYMBOL_GPL(of_get_regulator_init_data); 99 108 109 + struct devm_of_regulator_matches { 110 + struct of_regulator_match *matches; 111 + unsigned int num_matches; 112 + }; 113 + 114 + static void devm_of_regulator_put_matches(struct device *dev, void *res) 115 + { 116 + struct devm_of_regulator_matches *devm_matches = res; 117 + int i; 118 + 119 + for (i = 0; i < devm_matches->num_matches; i++) 120 + of_node_put(devm_matches->matches[i].of_node); 121 + } 122 + 100 123 /** 101 124 * of_regulator_match - extract multiple regulator init data from device tree. 102 125 * @dev: device requesting the data ··· 124 119 * regulator. The data parsed from a child node will be matched to a regulator 125 120 * based on either the deprecated property regulator-compatible if present, 126 121 * or otherwise the child node's name. Note that the match table is modified 127 - * in place. 122 + * in place and an additional of_node reference is taken for each matched 123 + * regulator. 128 124 * 129 125 * Returns the number of matches found or a negative error code on failure. 130 126 */ ··· 137 131 unsigned int i; 138 132 const char *name; 139 133 struct device_node *child; 134 + struct devm_of_regulator_matches *devm_matches; 140 135 141 136 if (!dev || !node) 142 137 return -EINVAL; 138 + 139 + devm_matches = devres_alloc(devm_of_regulator_put_matches, 140 + sizeof(struct devm_of_regulator_matches), 141 + GFP_KERNEL); 142 + if (!devm_matches) 143 + return -ENOMEM; 144 + 145 + devm_matches->matches = matches; 146 + devm_matches->num_matches = num_matches; 147 + 148 + devres_add(dev, devm_matches); 143 149 144 150 for (i = 0; i < num_matches; i++) { 145 151 struct of_regulator_match *match = &matches[i]; ··· 180 162 child->name); 181 163 return -EINVAL; 182 164 } 183 - match->of_node = child; 165 + match->of_node = of_node_get(child); 184 166 count++; 185 167 break; 186 168 }
+27 -133
drivers/regulator/palmas-regulator.c
··· 36 36 int sleep_id; 37 37 }; 38 38 39 + static const struct regulator_linear_range smps_low_ranges[] = { 40 + REGULATOR_LINEAR_RANGE(500000, 0x1, 0x6, 0), 41 + REGULATOR_LINEAR_RANGE(510000, 0x7, 0x79, 10000), 42 + REGULATOR_LINEAR_RANGE(1650000, 0x7A, 0x7f, 0), 43 + }; 44 + 45 + static const struct regulator_linear_range smps_high_ranges[] = { 46 + REGULATOR_LINEAR_RANGE(1000000, 0x1, 0x6, 0), 47 + REGULATOR_LINEAR_RANGE(1020000, 0x7, 0x79, 20000), 48 + REGULATOR_LINEAR_RANGE(3300000, 0x7A, 0x7f, 0), 49 + }; 50 + 39 51 static const struct regs_info palmas_regs_info[] = { 40 52 { 41 53 .name = "SMPS12", ··· 292 280 return regmap_write(palmas->regmap[REGULATOR_SLAVE], addr, value); 293 281 } 294 282 295 - static int palmas_is_enabled_smps(struct regulator_dev *dev) 296 - { 297 - struct palmas_pmic *pmic = rdev_get_drvdata(dev); 298 - int id = rdev_get_id(dev); 299 - unsigned int reg; 300 - 301 - palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg); 302 - 303 - reg &= PALMAS_SMPS12_CTRL_STATUS_MASK; 304 - reg >>= PALMAS_SMPS12_CTRL_STATUS_SHIFT; 305 - 306 - return !!(reg); 307 - } 308 - 309 - static int palmas_enable_smps(struct regulator_dev *dev) 310 - { 311 - struct palmas_pmic *pmic = rdev_get_drvdata(dev); 312 - int id = rdev_get_id(dev); 313 - unsigned int reg; 314 - 315 - palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg); 316 - 317 - reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; 318 - if (pmic->current_reg_mode[id]) 319 - reg |= pmic->current_reg_mode[id]; 320 - else 321 - reg |= SMPS_CTRL_MODE_ON; 322 - 323 - palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); 324 - 325 - return 0; 326 - } 327 - 328 - static int palmas_disable_smps(struct regulator_dev *dev) 329 - { 330 - struct palmas_pmic *pmic = rdev_get_drvdata(dev); 331 - int id = rdev_get_id(dev); 332 - unsigned int reg; 333 - 334 - palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg); 335 - 336 - reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; 337 - 338 - palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); 339 - 340 - return 0; 341 - } 342 - 343 283 static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) 344 284 { 345 285 struct palmas_pmic *pmic = rdev_get_drvdata(dev); ··· 346 382 return 0; 347 383 } 348 384 349 - static int palmas_list_voltage_smps(struct regulator_dev *dev, 350 - unsigned selector) 351 - { 352 - struct palmas_pmic *pmic = rdev_get_drvdata(dev); 353 - int id = rdev_get_id(dev); 354 - int mult = 1; 355 - 356 - /* Read the multiplier set in VSEL register to return 357 - * the correct voltage. 358 - */ 359 - if (pmic->range[id]) 360 - mult = 2; 361 - 362 - if (selector == 0) 363 - return 0; 364 - else if (selector < 6) 365 - return 500000 * mult; 366 - else 367 - /* Voltage is linear mapping starting from selector 6, 368 - * volt = (0.49V + ((selector - 5) * 0.01V)) * RANGE 369 - * RANGE is either x1 or x2 370 - */ 371 - return (490000 + ((selector - 5) * 10000)) * mult; 372 - } 373 - 374 - static int palmas_map_voltage_smps(struct regulator_dev *rdev, 375 - int min_uV, int max_uV) 376 - { 377 - struct palmas_pmic *pmic = rdev_get_drvdata(rdev); 378 - int id = rdev_get_id(rdev); 379 - int ret, voltage; 380 - 381 - if (min_uV == 0) 382 - return 0; 383 - 384 - if (pmic->range[id]) { /* RANGE is x2 */ 385 - if (min_uV < 1000000) 386 - min_uV = 1000000; 387 - ret = DIV_ROUND_UP(min_uV - 1000000, 20000) + 6; 388 - } else { /* RANGE is x1 */ 389 - if (min_uV < 500000) 390 - min_uV = 500000; 391 - ret = DIV_ROUND_UP(min_uV - 500000, 10000) + 6; 392 - } 393 - 394 - /* Map back into a voltage to verify we're still in bounds */ 395 - voltage = palmas_list_voltage_smps(rdev, ret); 396 - if (voltage < min_uV || voltage > max_uV) 397 - return -EINVAL; 398 - 399 - return ret; 400 - } 401 - 402 - static int palma_smps_set_voltage_smps_time_sel(struct regulator_dev *rdev, 403 - unsigned int old_selector, unsigned int new_selector) 404 - { 405 - struct palmas_pmic *pmic = rdev_get_drvdata(rdev); 406 - int id = rdev_get_id(rdev); 407 - int old_uv, new_uv; 408 - unsigned int ramp_delay = pmic->ramp_delay[id]; 409 - 410 - if (!ramp_delay) 411 - return 0; 412 - 413 - old_uv = palmas_list_voltage_smps(rdev, old_selector); 414 - if (old_uv < 0) 415 - return old_uv; 416 - 417 - new_uv = palmas_list_voltage_smps(rdev, new_selector); 418 - if (new_uv < 0) 419 - return new_uv; 420 - 421 - return DIV_ROUND_UP(abs(old_uv - new_uv), ramp_delay); 422 - } 423 - 424 385 static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev, 425 386 int ramp_delay) 426 387 { ··· 382 493 } 383 494 384 495 static struct regulator_ops palmas_ops_smps = { 385 - .is_enabled = palmas_is_enabled_smps, 386 - .enable = palmas_enable_smps, 387 - .disable = palmas_disable_smps, 496 + .is_enabled = regulator_is_enabled_regmap, 497 + .enable = regulator_enable_regmap, 498 + .disable = regulator_disable_regmap, 388 499 .set_mode = palmas_set_mode_smps, 389 500 .get_mode = palmas_get_mode_smps, 390 501 .get_voltage_sel = regulator_get_voltage_sel_regmap, 391 502 .set_voltage_sel = regulator_set_voltage_sel_regmap, 392 - .list_voltage = palmas_list_voltage_smps, 393 - .map_voltage = palmas_map_voltage_smps, 394 - .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel, 503 + .list_voltage = regulator_list_voltage_linear_range, 504 + .map_voltage = regulator_map_voltage_linear_range, 505 + .set_voltage_time_sel = regulator_set_voltage_time_sel, 395 506 .set_ramp_delay = palmas_smps_set_ramp_delay, 396 507 }; 397 508 ··· 400 511 .get_mode = palmas_get_mode_smps, 401 512 .get_voltage_sel = regulator_get_voltage_sel_regmap, 402 513 .set_voltage_sel = regulator_set_voltage_sel_regmap, 403 - .list_voltage = palmas_list_voltage_smps, 404 - .map_voltage = palmas_map_voltage_smps, 405 - .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel, 514 + .list_voltage = regulator_list_voltage_linear_range, 515 + .map_voltage = regulator_map_voltage_linear_range, 516 + .set_voltage_time_sel = regulator_set_voltage_time_sel, 406 517 .set_ramp_delay = palmas_smps_set_ramp_delay, 407 518 }; 408 519 ··· 931 1042 * ranges. Read the current smps mode for later use. 932 1043 */ 933 1044 addr = palmas_regs_info[id].vsel_addr; 1045 + pmic->desc[id].n_linear_ranges = 3; 934 1046 935 1047 ret = palmas_smps_read(pmic->palmas, addr, &reg); 936 1048 if (ret) 937 1049 return ret; 938 1050 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) 939 1051 pmic->range[id] = 1; 1052 + if (pmic->range[id]) 1053 + pmic->desc[id].linear_ranges = smps_high_ranges; 1054 + else 1055 + pmic->desc[id].linear_ranges = smps_low_ranges; 940 1056 941 1057 if (reg_init && reg_init->roof_floor) 942 1058 pmic->desc[id].ops = ··· 1093 1199 return 0; 1094 1200 } 1095 1201 1096 - static struct of_device_id of_palmas_match_tbl[] = { 1202 + static const struct of_device_id of_palmas_match_tbl[] = { 1097 1203 { .compatible = "ti,palmas-pmic", }, 1098 1204 { .compatible = "ti,twl6035-pmic", }, 1099 1205 { .compatible = "ti,twl6036-pmic", },
+4 -25
drivers/regulator/pbias-regulator.c
··· 49 49 3000000 50 50 }; 51 51 52 - static int pbias_regulator_enable(struct regulator_dev *rdev) 53 - { 54 - struct pbias_regulator_data *data = rdev_get_drvdata(rdev); 55 - const struct pbias_reg_info *info = data->info; 56 - 57 - return regmap_update_bits(data->syscon, rdev->desc->enable_reg, 58 - info->enable_mask, info->enable); 59 - } 60 - 61 - static int pbias_regulator_is_enable(struct regulator_dev *rdev) 62 - { 63 - struct pbias_regulator_data *data = rdev_get_drvdata(rdev); 64 - const struct pbias_reg_info *info = data->info; 65 - int value; 66 - 67 - regmap_read(data->syscon, rdev->desc->enable_reg, &value); 68 - 69 - return (value & info->enable_mask) == info->enable; 70 - } 71 - 72 52 static struct regulator_ops pbias_regulator_voltage_ops = { 73 53 .list_voltage = regulator_list_voltage_table, 74 54 .get_voltage_sel = regulator_get_voltage_sel_regmap, 75 55 .set_voltage_sel = regulator_set_voltage_sel_regmap, 76 - .enable = pbias_regulator_enable, 56 + .enable = regulator_enable_regmap, 77 57 .disable = regulator_disable_regmap, 78 - .is_enabled = pbias_regulator_is_enable, 58 + .is_enabled = regulator_is_enabled_regmap, 79 59 }; 80 60 81 61 static const struct pbias_reg_info pbias_mmc_omap2430 = { ··· 122 142 123 143 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data) 124 144 * count, GFP_KERNEL); 125 - if (drvdata == NULL) { 126 - dev_err(&pdev->dev, "Failed to allocate device data\n"); 145 + if (!drvdata) 127 146 return -ENOMEM; 128 - } 129 147 130 148 syscon = syscon_regmap_lookup_by_phandle(np, "syscon"); 131 149 if (IS_ERR(syscon)) ··· 158 180 drvdata[data_idx].desc.vsel_mask = info->vmode; 159 181 drvdata[data_idx].desc.enable_reg = res->start; 160 182 drvdata[data_idx].desc.enable_mask = info->enable_mask; 183 + drvdata[data_idx].desc.enable_val = info->enable; 161 184 162 185 cfg.init_data = pbias_matches[idx].init_data; 163 186 cfg.driver_data = &drvdata[data_idx];
+8
drivers/regulator/pfuze100-regulator.c
··· 125 125 }; 126 126 127 127 static struct regulator_ops pfuze100_fixed_regulator_ops = { 128 + .enable = regulator_enable_regmap, 129 + .disable = regulator_disable_regmap, 130 + .is_enabled = regulator_is_enabled_regmap, 128 131 .list_voltage = regulator_list_voltage_linear, 129 132 }; 130 133 ··· 140 137 }; 141 138 142 139 static struct regulator_ops pfuze100_swb_regulator_ops = { 140 + .enable = regulator_enable_regmap, 141 + .disable = regulator_disable_regmap, 143 142 .list_voltage = regulator_list_voltage_table, 144 143 .map_voltage = regulator_map_voltage_ascend, 145 144 .set_voltage_sel = regulator_set_voltage_sel_regmap, ··· 194 189 .volt_table = voltages, \ 195 190 .vsel_reg = (base), \ 196 191 .vsel_mask = (mask), \ 192 + .enable_reg = (base), \ 193 + .enable_mask = 0x48, \ 197 194 }, \ 198 195 } 199 196 ··· 509 502 config.init_data = init_data; 510 503 config.driver_data = pfuze_chip; 511 504 config.of_node = match_of_node(i); 505 + config.ena_gpio = -EINVAL; 512 506 513 507 pfuze_chip->regulators[i] = 514 508 devm_regulator_register(&client->dev, desc, &config);
+11 -8
drivers/regulator/s2mpa01.c
··· 61 61 unsigned int ramp_delay = 0; 62 62 int old_volt, new_volt; 63 63 64 - switch (rdev->desc->id) { 64 + switch (rdev_get_id(rdev)) { 65 65 case S2MPA01_BUCK2: 66 66 case S2MPA01_BUCK4: 67 67 ramp_delay = s2mpa01->ramp_delay24; ··· 102 102 unsigned int ramp_enable = 1, enable_shift = 0; 103 103 int ret; 104 104 105 - switch (rdev->desc->id) { 105 + switch (rdev_get_id(rdev)) { 106 106 case S2MPA01_BUCK1: 107 107 enable_shift = S2MPA01_BUCK1_RAMP_EN_SHIFT; 108 108 if (!ramp_delay) { ··· 116 116 ramp_delay = s2mpa01->ramp_delay16; 117 117 118 118 ramp_shift = S2MPA01_BUCK16_RAMP_SHIFT; 119 - ramp_reg = S2MPA01_REG_RAMP1; 120 119 break; 121 120 case S2MPA01_BUCK2: 122 121 enable_shift = S2MPA01_BUCK2_RAMP_EN_SHIFT; ··· 191 192 if (!ramp_enable) 192 193 goto ramp_disable; 193 194 194 - ret = regmap_update_bits(rdev->regmap, S2MPA01_REG_RAMP1, 195 - 1 << enable_shift, 1 << enable_shift); 196 - if (ret) { 197 - dev_err(&rdev->dev, "failed to enable ramp rate\n"); 198 - return ret; 195 + /* Ramp delay can be enabled/disabled only for buck[1234] */ 196 + if (rdev_get_id(rdev) >= S2MPA01_BUCK1 && 197 + rdev_get_id(rdev) <= S2MPA01_BUCK4) { 198 + ret = regmap_update_bits(rdev->regmap, S2MPA01_REG_RAMP1, 199 + 1 << enable_shift, 1 << enable_shift); 200 + if (ret) { 201 + dev_err(&rdev->dev, "failed to enable ramp rate\n"); 202 + return ret; 203 + } 199 204 } 200 205 201 206 ramp_val = get_ramp_delay(ramp_delay);
+96 -17
drivers/regulator/s2mps11.c
··· 27 27 #include <linux/regulator/driver.h> 28 28 #include <linux/regulator/machine.h> 29 29 #include <linux/regulator/of_regulator.h> 30 + #include <linux/of_gpio.h> 30 31 #include <linux/mfd/samsung/core.h> 31 32 #include <linux/mfd/samsung/s2mps11.h> 32 33 #include <linux/mfd/samsung/s2mps14.h> ··· 45 44 * was enabled. 46 45 */ 47 46 unsigned int s2mps14_suspend_state:30; 47 + /* Array of size rdev_num with GPIO-s for external sleep control */ 48 + int *ext_control_gpio; 48 49 }; 49 50 50 51 static int get_ramp_delay(int ramp_delay) ··· 205 202 if (!ramp_enable) 206 203 goto ramp_disable; 207 204 208 - ret = regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP, 209 - 1 << enable_shift, 1 << enable_shift); 210 - if (ret) { 211 - dev_err(&rdev->dev, "failed to enable ramp rate\n"); 212 - return ret; 205 + /* Ramp delay can be enabled/disabled only for buck[2346] */ 206 + if ((rdev_get_id(rdev) >= S2MPS11_BUCK2 && 207 + rdev_get_id(rdev) <= S2MPS11_BUCK4) || 208 + rdev_get_id(rdev) == S2MPS11_BUCK6) { 209 + ret = regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP, 210 + 1 << enable_shift, 1 << enable_shift); 211 + if (ret) { 212 + dev_err(&rdev->dev, "failed to enable ramp rate\n"); 213 + return ret; 214 + } 213 215 } 214 216 215 217 ramp_val = get_ramp_delay(ramp_delay); ··· 417 409 418 410 if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) 419 411 val = S2MPS14_ENABLE_SUSPEND; 412 + else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) 413 + val = S2MPS14_ENABLE_EXT_CONTROL; 420 414 else 421 415 val = rdev->desc->enable_mask; 422 416 ··· 575 565 regulator_desc_s2mps14_buck1235(5), 576 566 }; 577 567 568 + static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11, 569 + struct regulator_dev *rdev) 570 + { 571 + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 572 + rdev->desc->enable_mask, S2MPS14_ENABLE_EXT_CONTROL); 573 + } 574 + 575 + static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, 576 + struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) 577 + { 578 + int *gpio = s2mps11->ext_control_gpio; 579 + unsigned int i; 580 + unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11, 581 + S2MPS14_LDO12 }; 582 + 583 + for (i = 0; i < ARRAY_SIZE(valid_regulators); i++) { 584 + unsigned int reg = valid_regulators[i]; 585 + 586 + if (!rdata[reg].init_data || !rdata[reg].of_node) 587 + continue; 588 + 589 + gpio[reg] = of_get_named_gpio(rdata[reg].of_node, 590 + "samsung,ext-control-gpios", 0); 591 + if (gpio_is_valid(gpio[reg])) 592 + dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", 593 + gpio[reg], reg, rdata[reg].name); 594 + } 595 + } 596 + 597 + static int s2mps11_pmic_dt_parse(struct platform_device *pdev, 598 + struct of_regulator_match *rdata, struct s2mps11_info *s2mps11, 599 + enum sec_device_type dev_type) 600 + { 601 + struct device_node *reg_np; 602 + 603 + reg_np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); 604 + if (!reg_np) { 605 + dev_err(&pdev->dev, "could not find regulators sub-node\n"); 606 + return -EINVAL; 607 + } 608 + 609 + of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); 610 + if (dev_type == S2MPS14X) 611 + s2mps14_pmic_dt_parse_ext_control_gpio(pdev, rdata, s2mps11); 612 + 613 + of_node_put(reg_np); 614 + 615 + return 0; 616 + } 617 + 578 618 static int s2mps11_pmic_probe(struct platform_device *pdev) 579 619 { 580 620 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 581 - struct sec_platform_data *pdata = iodev->pdata; 621 + struct sec_platform_data *pdata = NULL; 582 622 struct of_regulator_match *rdata = NULL; 583 - struct device_node *reg_np = NULL; 584 623 struct regulator_config config = { }; 585 624 struct s2mps11_info *s2mps11; 586 625 int i, ret = 0; ··· 656 597 return -EINVAL; 657 598 }; 658 599 600 + s2mps11->ext_control_gpio = devm_kzalloc(&pdev->dev, 601 + sizeof(*s2mps11->ext_control_gpio) * s2mps11->rdev_num, 602 + GFP_KERNEL); 603 + if (!s2mps11->ext_control_gpio) 604 + return -ENOMEM; 605 + /* 606 + * 0 is a valid GPIO so initialize all GPIO-s to negative value 607 + * to indicate that external control won't be used for this regulator. 608 + */ 609 + for (i = 0; i < s2mps11->rdev_num; i++) 610 + s2mps11->ext_control_gpio[i] = -EINVAL; 611 + 659 612 if (!iodev->dev->of_node) { 660 - if (pdata) { 613 + if (iodev->pdata) { 614 + pdata = iodev->pdata; 661 615 goto common_reg; 662 616 } else { 663 617 dev_err(pdev->dev.parent, ··· 686 614 for (i = 0; i < s2mps11->rdev_num; i++) 687 615 rdata[i].name = regulators[i].name; 688 616 689 - reg_np = of_get_child_by_name(iodev->dev->of_node, "regulators"); 690 - if (!reg_np) { 691 - dev_err(&pdev->dev, "could not find regulators sub-node\n"); 692 - ret = -EINVAL; 617 + ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11, dev_type); 618 + if (ret) 693 619 goto out; 694 - } 695 - 696 - of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); 697 - of_node_put(reg_np); 698 620 699 621 common_reg: 700 622 platform_set_drvdata(pdev, s2mps11); ··· 696 630 config.dev = &pdev->dev; 697 631 config.regmap = iodev->regmap_pmic; 698 632 config.driver_data = s2mps11; 633 + config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; 699 634 for (i = 0; i < s2mps11->rdev_num; i++) { 700 635 struct regulator_dev *regulator; 701 636 702 - if (!reg_np) { 637 + if (pdata) { 703 638 config.init_data = pdata->regulators[i].initdata; 704 639 config.of_node = pdata->regulators[i].reg_node; 705 640 } else { 706 641 config.init_data = rdata[i].init_data; 707 642 config.of_node = rdata[i].of_node; 708 643 } 644 + config.ena_gpio = s2mps11->ext_control_gpio[i]; 709 645 710 646 regulator = devm_regulator_register(&pdev->dev, 711 647 &regulators[i], &config); ··· 716 648 dev_err(&pdev->dev, "regulator init failed for %d\n", 717 649 i); 718 650 goto out; 651 + } 652 + 653 + if (gpio_is_valid(s2mps11->ext_control_gpio[i])) { 654 + ret = s2mps14_pmic_enable_ext_control(s2mps11, 655 + regulator); 656 + if (ret < 0) { 657 + dev_err(&pdev->dev, 658 + "failed to enable GPIO control over %s: %d\n", 659 + regulator->desc->name, ret); 660 + goto out; 661 + } 719 662 } 720 663 } 721 664
+12 -25
drivers/regulator/s5m8767.c
··· 28 28 struct device *dev; 29 29 struct sec_pmic_dev *iodev; 30 30 int num_regulators; 31 - struct regulator_dev **rdev; 32 31 struct sec_opmode_data *opmode; 33 32 34 33 int ramp_delay; ··· 528 529 return 0; 529 530 } 530 531 531 - static void s5m8767_pmic_dt_parse_ext_control_gpio(struct sec_pmic_dev *iodev, 532 - struct sec_regulator_data *rdata, 533 - struct device_node *reg_np) 534 - { 535 - rdata->ext_control_gpio = of_get_named_gpio(reg_np, 536 - "s5m8767,pmic-ext-control-gpios", 0); 537 - if (!gpio_is_valid(rdata->ext_control_gpio)) 538 - rdata->ext_control_gpio = 0; 539 - } 540 - 541 532 static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, 542 533 struct sec_platform_data *pdata) 543 534 { ··· 576 587 continue; 577 588 } 578 589 579 - s5m8767_pmic_dt_parse_ext_control_gpio(iodev, rdata, reg_np); 590 + rdata->ext_control_gpio = of_get_named_gpio(reg_np, 591 + "s5m8767,pmic-ext-control-gpios", 0); 580 592 581 593 rdata->id = i; 582 594 rdata->initdata = of_get_regulator_init_data( ··· 685 695 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 686 696 struct sec_platform_data *pdata = iodev->pdata; 687 697 struct regulator_config config = { }; 688 - struct regulator_dev **rdev; 689 698 struct s5m8767_info *s5m8767; 690 699 int i, ret, size, buck_init; 691 700 ··· 726 737 return -ENOMEM; 727 738 728 739 size = sizeof(struct regulator_dev *) * (S5M8767_REG_MAX - 2); 729 - s5m8767->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); 730 - if (!s5m8767->rdev) 731 - return -ENOMEM; 732 740 733 - rdev = s5m8767->rdev; 734 741 s5m8767->dev = &pdev->dev; 735 742 s5m8767->iodev = iodev; 736 743 s5m8767->num_regulators = pdata->num_regulators; ··· 923 938 const struct sec_voltage_desc *desc; 924 939 int id = pdata->regulators[i].id; 925 940 int enable_reg, enable_val; 941 + struct regulator_dev *rdev; 926 942 927 943 desc = reg_voltage_map[id]; 928 944 if (desc) { ··· 950 964 config.driver_data = s5m8767; 951 965 config.regmap = iodev->regmap_pmic; 952 966 config.of_node = pdata->regulators[i].reg_node; 953 - config.ena_gpio = config.ena_gpio_flags = 0; 954 - if (pdata->regulators[i].ext_control_gpio) 967 + config.ena_gpio = -EINVAL; 968 + config.ena_gpio_flags = 0; 969 + if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) 955 970 s5m8767_regulator_config_ext_control(s5m8767, 956 971 &pdata->regulators[i], &config); 957 972 958 - rdev[i] = devm_regulator_register(&pdev->dev, &regulators[id], 973 + rdev = devm_regulator_register(&pdev->dev, &regulators[id], 959 974 &config); 960 - if (IS_ERR(rdev[i])) { 961 - ret = PTR_ERR(rdev[i]); 975 + if (IS_ERR(rdev)) { 976 + ret = PTR_ERR(rdev); 962 977 dev_err(s5m8767->dev, "regulator init failed for %d\n", 963 978 id); 964 979 return ret; 965 980 } 966 981 967 - if (pdata->regulators[i].ext_control_gpio) { 968 - ret = s5m8767_enable_ext_control(s5m8767, rdev[i]); 982 + if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { 983 + ret = s5m8767_enable_ext_control(s5m8767, rdev); 969 984 if (ret < 0) { 970 985 dev_err(s5m8767->dev, 971 986 "failed to enable gpio control over %s: %d\n", 972 - rdev[i]->desc->name, ret); 987 + rdev->desc->name, ret); 973 988 return ret; 974 989 } 975 990 }
+1 -1
drivers/regulator/st-pwm.c
··· 118 118 .duty_cycle_table = b2105_duty_cycle_table, 119 119 }; 120 120 121 - static struct of_device_id st_pwm_of_match[] = { 121 + static const struct of_device_id st_pwm_of_match[] = { 122 122 { .compatible = "st,b2105-pwm-regulator", .data = &b2105_info, }, 123 123 { }, 124 124 };
+199 -15
drivers/regulator/tps65090-regulator.c
··· 17 17 */ 18 18 19 19 #include <linux/module.h> 20 + #include <linux/delay.h> 20 21 #include <linux/init.h> 21 22 #include <linux/gpio.h> 22 23 #include <linux/of_gpio.h> ··· 29 28 #include <linux/regulator/of_regulator.h> 30 29 #include <linux/mfd/tps65090.h> 31 30 31 + #define MAX_CTRL_READ_TRIES 5 32 + #define MAX_FET_ENABLE_TRIES 1000 33 + 34 + #define CTRL_EN_BIT 0 /* Regulator enable bit, active high */ 35 + #define CTRL_WT_BIT 2 /* Regulator wait time 0 bit */ 36 + #define CTRL_PG_BIT 4 /* Regulator power good bit, 1=good */ 37 + #define CTRL_TO_BIT 7 /* Regulator timeout bit, 1=wait */ 38 + 39 + #define MAX_OVERCURRENT_WAIT 3 /* Overcurrent wait must be <= this */ 40 + 41 + /** 42 + * struct tps65090_regulator - Per-regulator data for a tps65090 regulator 43 + * 44 + * @dev: Pointer to our device. 45 + * @desc: The struct regulator_desc for the regulator. 46 + * @rdev: The struct regulator_dev for the regulator. 47 + * @overcurrent_wait_valid: True if overcurrent_wait is valid. 48 + * @overcurrent_wait: For FETs, the value to put in the WTFET bitfield. 49 + */ 50 + 32 51 struct tps65090_regulator { 33 52 struct device *dev; 34 53 struct regulator_desc *desc; 35 54 struct regulator_dev *rdev; 55 + bool overcurrent_wait_valid; 56 + int overcurrent_wait; 36 57 }; 37 58 38 59 static struct regulator_ops tps65090_ext_control_ops = { 39 60 }; 40 61 41 - static struct regulator_ops tps65090_reg_contol_ops = { 62 + /** 63 + * tps65090_reg_set_overcurrent_wait - Setup overcurrent wait 64 + * 65 + * This will set the overcurrent wait time based on what's in the regulator 66 + * info. 67 + * 68 + * @ri: Overall regulator data 69 + * @rdev: Regulator device 70 + * 71 + * Return: 0 if no error, non-zero if there was an error writing the register. 72 + */ 73 + static int tps65090_reg_set_overcurrent_wait(struct tps65090_regulator *ri, 74 + struct regulator_dev *rdev) 75 + { 76 + int ret; 77 + 78 + ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 79 + MAX_OVERCURRENT_WAIT << CTRL_WT_BIT, 80 + ri->overcurrent_wait << CTRL_WT_BIT); 81 + if (ret) { 82 + dev_err(&rdev->dev, "Error updating overcurrent wait %#x\n", 83 + rdev->desc->enable_reg); 84 + } 85 + 86 + return ret; 87 + } 88 + 89 + /** 90 + * tps65090_try_enable_fet - Try to enable a FET 91 + * 92 + * @rdev: Regulator device 93 + * 94 + * Return: 0 if ok, -ENOTRECOVERABLE if the FET power good bit did not get 95 + * set, or some other -ve value if another error occurred (e.g. i2c error) 96 + */ 97 + static int tps65090_try_enable_fet(struct regulator_dev *rdev) 98 + { 99 + unsigned int control; 100 + int ret, i; 101 + 102 + ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 103 + rdev->desc->enable_mask, 104 + rdev->desc->enable_mask); 105 + if (ret < 0) { 106 + dev_err(&rdev->dev, "Error in updating reg %#x\n", 107 + rdev->desc->enable_reg); 108 + return ret; 109 + } 110 + 111 + for (i = 0; i < MAX_CTRL_READ_TRIES; i++) { 112 + ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, 113 + &control); 114 + if (ret < 0) 115 + return ret; 116 + 117 + if (!(control & BIT(CTRL_TO_BIT))) 118 + break; 119 + 120 + usleep_range(1000, 1500); 121 + } 122 + if (!(control & BIT(CTRL_PG_BIT))) 123 + return -ENOTRECOVERABLE; 124 + 125 + return 0; 126 + } 127 + 128 + /** 129 + * tps65090_fet_enable - Enable a FET, trying a few times if it fails 130 + * 131 + * Some versions of the tps65090 have issues when turning on the FETs. 132 + * This function goes through several steps to ensure the best chance of the 133 + * FET going on. Specifically: 134 + * - We'll make sure that we bump the "overcurrent wait" to the maximum, which 135 + * increases the chances that we'll turn on properly. 136 + * - We'll retry turning the FET on multiple times (turning off in between). 137 + * 138 + * @rdev: Regulator device 139 + * 140 + * Return: 0 if ok, non-zero if it fails. 141 + */ 142 + static int tps65090_fet_enable(struct regulator_dev *rdev) 143 + { 144 + int ret, tries; 145 + 146 + /* 147 + * Try enabling multiple times until we succeed since sometimes the 148 + * first try times out. 149 + */ 150 + tries = 0; 151 + while (true) { 152 + ret = tps65090_try_enable_fet(rdev); 153 + if (!ret) 154 + break; 155 + if (ret != -ENOTRECOVERABLE || tries == MAX_FET_ENABLE_TRIES) 156 + goto err; 157 + 158 + /* Try turning the FET off (and then on again) */ 159 + ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 160 + rdev->desc->enable_mask, 0); 161 + if (ret) 162 + goto err; 163 + 164 + tries++; 165 + } 166 + 167 + if (tries) 168 + dev_warn(&rdev->dev, "reg %#x enable ok after %d tries\n", 169 + rdev->desc->enable_reg, tries); 170 + 171 + return 0; 172 + err: 173 + dev_warn(&rdev->dev, "reg %#x enable failed\n", rdev->desc->enable_reg); 174 + WARN_ON(1); 175 + 176 + return ret; 177 + } 178 + 179 + static struct regulator_ops tps65090_reg_control_ops = { 42 180 .enable = regulator_enable_regmap, 181 + .disable = regulator_disable_regmap, 182 + .is_enabled = regulator_is_enabled_regmap, 183 + }; 184 + 185 + static struct regulator_ops tps65090_fet_control_ops = { 186 + .enable = tps65090_fet_enable, 43 187 .disable = regulator_disable_regmap, 44 188 .is_enabled = regulator_is_enabled_regmap, 45 189 }; ··· 192 46 static struct regulator_ops tps65090_ldo_ops = { 193 47 }; 194 48 195 - #define tps65090_REG_DESC(_id, _sname, _en_reg, _ops) \ 49 + #define tps65090_REG_DESC(_id, _sname, _en_reg, _en_bits, _ops) \ 196 50 { \ 197 51 .name = "TPS65090_RAILS"#_id, \ 198 52 .supply_name = _sname, \ 199 53 .id = TPS65090_REGULATOR_##_id, \ 200 54 .ops = &_ops, \ 201 55 .enable_reg = _en_reg, \ 202 - .enable_mask = BIT(0), \ 56 + .enable_val = _en_bits, \ 57 + .enable_mask = _en_bits, \ 203 58 .type = REGULATOR_VOLTAGE, \ 204 59 .owner = THIS_MODULE, \ 205 60 } 206 61 207 62 static struct regulator_desc tps65090_regulator_desc[] = { 208 - tps65090_REG_DESC(DCDC1, "vsys1", 0x0C, tps65090_reg_contol_ops), 209 - tps65090_REG_DESC(DCDC2, "vsys2", 0x0D, tps65090_reg_contol_ops), 210 - tps65090_REG_DESC(DCDC3, "vsys3", 0x0E, tps65090_reg_contol_ops), 211 - tps65090_REG_DESC(FET1, "infet1", 0x0F, tps65090_reg_contol_ops), 212 - tps65090_REG_DESC(FET2, "infet2", 0x10, tps65090_reg_contol_ops), 213 - tps65090_REG_DESC(FET3, "infet3", 0x11, tps65090_reg_contol_ops), 214 - tps65090_REG_DESC(FET4, "infet4", 0x12, tps65090_reg_contol_ops), 215 - tps65090_REG_DESC(FET5, "infet5", 0x13, tps65090_reg_contol_ops), 216 - tps65090_REG_DESC(FET6, "infet6", 0x14, tps65090_reg_contol_ops), 217 - tps65090_REG_DESC(FET7, "infet7", 0x15, tps65090_reg_contol_ops), 218 - tps65090_REG_DESC(LDO1, "vsys-l1", 0, tps65090_ldo_ops), 219 - tps65090_REG_DESC(LDO2, "vsys-l2", 0, tps65090_ldo_ops), 63 + tps65090_REG_DESC(DCDC1, "vsys1", 0x0C, BIT(CTRL_EN_BIT), 64 + tps65090_reg_control_ops), 65 + tps65090_REG_DESC(DCDC2, "vsys2", 0x0D, BIT(CTRL_EN_BIT), 66 + tps65090_reg_control_ops), 67 + tps65090_REG_DESC(DCDC3, "vsys3", 0x0E, BIT(CTRL_EN_BIT), 68 + tps65090_reg_control_ops), 69 + 70 + tps65090_REG_DESC(FET1, "infet1", 0x0F, 71 + BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), 72 + tps65090_fet_control_ops), 73 + tps65090_REG_DESC(FET2, "infet2", 0x10, 74 + BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), 75 + tps65090_fet_control_ops), 76 + tps65090_REG_DESC(FET3, "infet3", 0x11, 77 + BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), 78 + tps65090_fet_control_ops), 79 + tps65090_REG_DESC(FET4, "infet4", 0x12, 80 + BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), 81 + tps65090_fet_control_ops), 82 + tps65090_REG_DESC(FET5, "infet5", 0x13, 83 + BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), 84 + tps65090_fet_control_ops), 85 + tps65090_REG_DESC(FET6, "infet6", 0x14, 86 + BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), 87 + tps65090_fet_control_ops), 88 + tps65090_REG_DESC(FET7, "infet7", 0x15, 89 + BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), 90 + tps65090_fet_control_ops), 91 + 92 + tps65090_REG_DESC(LDO1, "vsys-l1", 0, 0, 93 + tps65090_ldo_ops), 94 + tps65090_REG_DESC(LDO2, "vsys-l2", 0, 0, 95 + tps65090_ldo_ops), 220 96 }; 221 97 222 98 static inline bool is_dcdc(int id) ··· 377 209 rpdata->gpio = of_get_named_gpio(np, 378 210 "dcdc-ext-control-gpios", 0); 379 211 212 + if (of_property_read_u32(tps65090_matches[idx].of_node, 213 + "ti,overcurrent-wait", 214 + &rpdata->overcurrent_wait) == 0) 215 + rpdata->overcurrent_wait_valid = true; 216 + 380 217 tps65090_pdata->reg_pdata[idx] = rpdata; 381 218 } 382 219 return tps65090_pdata; ··· 431 258 ri = &pmic[num]; 432 259 ri->dev = &pdev->dev; 433 260 ri->desc = &tps65090_regulator_desc[num]; 261 + if (tps_pdata) { 262 + ri->overcurrent_wait_valid = 263 + tps_pdata->overcurrent_wait_valid; 264 + ri->overcurrent_wait = tps_pdata->overcurrent_wait; 265 + } 434 266 435 267 /* 436 268 * TPS5090 DCDC support the control from external digital input. ··· 476 298 return PTR_ERR(rdev); 477 299 } 478 300 ri->rdev = rdev; 301 + 302 + if (ri->overcurrent_wait_valid) { 303 + ret = tps65090_reg_set_overcurrent_wait(ri, rdev); 304 + if (ret < 0) 305 + return ret; 306 + } 479 307 480 308 /* Enable external control if it is require */ 481 309 if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data &&
+1 -3
drivers/regulator/tps65217-regulator.c
··· 134 134 .get_voltage_sel = regulator_get_voltage_sel_regmap, 135 135 .set_voltage_sel = tps65217_pmic_set_voltage_sel, 136 136 .list_voltage = regulator_list_voltage_table, 137 + .map_voltage = regulator_map_voltage_ascend, 137 138 }; 138 139 139 140 static const struct regulator_desc regulators[] = { ··· 258 257 pdev->name); 259 258 return PTR_ERR(rdev); 260 259 } 261 - 262 - /* Save regulator for cleanup */ 263 - tps->rdev[i] = rdev; 264 260 } 265 261 return 0; 266 262 }
+10 -27
drivers/regulator/tps65218-regulator.c
··· 27 27 #include <linux/regulator/machine.h> 28 28 #include <linux/mfd/tps65218.h> 29 29 30 - static unsigned int tps65218_ramp_delay = 4000; 31 - 32 30 enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, DCDC5, DCDC6, LDO1 }; 33 31 34 32 #define TPS65218_REGULATOR(_name, _id, _ops, _n, _vr, _vm, _er, _em, _t, \ 35 - _lr, _nlr) \ 33 + _lr, _nlr, _delay) \ 36 34 { \ 37 35 .name = _name, \ 38 36 .id = _id, \ ··· 45 47 .volt_table = _t, \ 46 48 .linear_ranges = _lr, \ 47 49 .n_linear_ranges = _nlr, \ 50 + .ramp_delay = _delay, \ 48 51 } \ 49 52 50 53 #define TPS65218_INFO(_id, _nm, _min, _max) \ ··· 151 152 dev->desc->enable_mask, TPS65218_PROTECT_L1); 152 153 } 153 154 154 - static int tps65218_set_voltage_time_sel(struct regulator_dev *rdev, 155 - unsigned int old_selector, unsigned int new_selector) 156 - { 157 - int old_uv, new_uv; 158 - 159 - old_uv = regulator_list_voltage_linear_range(rdev, old_selector); 160 - if (old_uv < 0) 161 - return old_uv; 162 - 163 - new_uv = regulator_list_voltage_linear_range(rdev, new_selector); 164 - if (new_uv < 0) 165 - return new_uv; 166 - 167 - return DIV_ROUND_UP(abs(old_uv - new_uv), tps65218_ramp_delay); 168 - } 169 - 170 155 /* Operations permitted on DCDC1, DCDC2 */ 171 156 static struct regulator_ops tps65218_dcdc12_ops = { 172 157 .is_enabled = regulator_is_enabled_regmap, ··· 160 177 .set_voltage_sel = tps65218_pmic_set_voltage_sel, 161 178 .list_voltage = regulator_list_voltage_linear_range, 162 179 .map_voltage = regulator_map_voltage_linear_range, 163 - .set_voltage_time_sel = tps65218_set_voltage_time_sel, 180 + .set_voltage_time_sel = regulator_set_voltage_time_sel, 164 181 }; 165 182 166 183 /* Operations permitted on DCDC3, DCDC4 and LDO1 */ ··· 186 203 TPS65218_REG_CONTROL_DCDC1, 187 204 TPS65218_CONTROL_DCDC1_MASK, 188 205 TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC1_EN, NULL, 189 - dcdc1_dcdc2_ranges, 2), 206 + dcdc1_dcdc2_ranges, 2, 4000), 190 207 TPS65218_REGULATOR("DCDC2", TPS65218_DCDC_2, tps65218_dcdc12_ops, 64, 191 208 TPS65218_REG_CONTROL_DCDC2, 192 209 TPS65218_CONTROL_DCDC2_MASK, 193 210 TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC2_EN, NULL, 194 - dcdc1_dcdc2_ranges, 2), 211 + dcdc1_dcdc2_ranges, 2, 4000), 195 212 TPS65218_REGULATOR("DCDC3", TPS65218_DCDC_3, tps65218_ldo1_dcdc34_ops, 196 213 64, TPS65218_REG_CONTROL_DCDC3, 197 214 TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, 198 215 TPS65218_ENABLE1_DC3_EN, NULL, 199 - ldo1_dcdc3_ranges, 2), 216 + ldo1_dcdc3_ranges, 2, 0), 200 217 TPS65218_REGULATOR("DCDC4", TPS65218_DCDC_4, tps65218_ldo1_dcdc34_ops, 201 218 53, TPS65218_REG_CONTROL_DCDC4, 202 219 TPS65218_CONTROL_DCDC4_MASK, 203 220 TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC4_EN, NULL, 204 - dcdc4_ranges, 2), 221 + dcdc4_ranges, 2, 0), 205 222 TPS65218_REGULATOR("DCDC5", TPS65218_DCDC_5, tps65218_dcdc56_pmic_ops, 206 223 1, -1, -1, TPS65218_REG_ENABLE1, 207 - TPS65218_ENABLE1_DC5_EN, NULL, NULL, 0), 224 + TPS65218_ENABLE1_DC5_EN, NULL, NULL, 0, 0), 208 225 TPS65218_REGULATOR("DCDC6", TPS65218_DCDC_6, tps65218_dcdc56_pmic_ops, 209 226 1, -1, -1, TPS65218_REG_ENABLE1, 210 - TPS65218_ENABLE1_DC6_EN, NULL, NULL, 0), 227 + TPS65218_ENABLE1_DC6_EN, NULL, NULL, 0, 0), 211 228 TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, tps65218_ldo1_dcdc34_ops, 64, 212 229 TPS65218_REG_CONTROL_DCDC4, 213 230 TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, 214 231 TPS65218_ENABLE2_LDO1_EN, NULL, ldo1_dcdc3_ranges, 215 - 2), 232 + 2, 0), 216 233 }; 217 234 218 235 static int tps65218_regulator_probe(struct platform_device *pdev)
+58 -10
drivers/regulator/tps6586x-regulator.c
··· 63 63 int enable_reg[2]; 64 64 }; 65 65 66 - static inline struct device *to_tps6586x_dev(struct regulator_dev *rdev) 67 - { 68 - return rdev_get_dev(rdev)->parent; 69 - } 70 - 71 - static struct regulator_ops tps6586x_regulator_ops = { 66 + static struct regulator_ops tps6586x_rw_regulator_ops = { 72 67 .list_voltage = regulator_list_voltage_table, 73 68 .map_voltage = regulator_map_voltage_ascend, 74 69 .get_voltage_sel = regulator_get_voltage_sel_regmap, 75 70 .set_voltage_sel = regulator_set_voltage_sel_regmap, 71 + 72 + .is_enabled = regulator_is_enabled_regmap, 73 + .enable = regulator_enable_regmap, 74 + .disable = regulator_disable_regmap, 75 + }; 76 + 77 + static struct regulator_ops tps6586x_ro_regulator_ops = { 78 + .list_voltage = regulator_list_voltage_table, 79 + .map_voltage = regulator_map_voltage_ascend, 80 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 76 81 77 82 .is_enabled = regulator_is_enabled_regmap, 78 83 .enable = regulator_enable_regmap, ··· 111 106 4200000, 4250000, 4300000, 4350000, 4400000, 4450000, 4500000, 4550000, 112 107 }; 113 108 109 + static int tps658640_sm2_voltages[] = { 110 + 2150000, 2200000, 2250000, 2300000, 2350000, 2400000, 2450000, 2500000, 111 + 2550000, 2600000, 2650000, 2700000, 2750000, 2800000, 2850000, 2900000, 112 + 2950000, 3000000, 3050000, 3100000, 3150000, 3200000, 3250000, 3300000, 113 + 3350000, 3400000, 3450000, 3500000, 3550000, 3600000, 3650000, 3700000, 114 + }; 115 + 114 116 static const unsigned int tps658643_sm2_voltages[] = { 115 117 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 116 118 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000, ··· 132 120 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000, 133 121 }; 134 122 135 - #define TPS6586X_REGULATOR(_id, _pin_name, vdata, vreg, shift, nbits, \ 123 + static int tps658640_rtc_voltages[] = { 124 + 2500000, 2850000, 3100000, 3300000, 125 + }; 126 + 127 + #define TPS6586X_REGULATOR(_id, _ops, _pin_name, vdata, vreg, shift, nbits, \ 136 128 ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ 137 129 .desc = { \ 138 130 .supply_name = _pin_name, \ 139 131 .name = "REG-" #_id, \ 140 - .ops = &tps6586x_regulator_ops, \ 132 + .ops = &tps6586x_## _ops ## _regulator_ops, \ 141 133 .type = REGULATOR_VOLTAGE, \ 142 134 .id = TPS6586X_ID_##_id, \ 143 135 .n_voltages = ARRAY_SIZE(vdata##_voltages), \ ··· 162 146 #define TPS6586X_LDO(_id, _pname, vdata, vreg, shift, nbits, \ 163 147 ereg0, ebit0, ereg1, ebit1) \ 164 148 { \ 165 - TPS6586X_REGULATOR(_id, _pname, vdata, vreg, shift, nbits, \ 149 + TPS6586X_REGULATOR(_id, rw, _pname, vdata, vreg, shift, nbits, \ 150 + ereg0, ebit0, ereg1, ebit1, 0, 0) \ 151 + } 152 + 153 + #define TPS6586X_FIXED_LDO(_id, _pname, vdata, vreg, shift, nbits, \ 154 + ereg0, ebit0, ereg1, ebit1) \ 155 + { \ 156 + TPS6586X_REGULATOR(_id, ro, _pname, vdata, vreg, shift, nbits, \ 166 157 ereg0, ebit0, ereg1, ebit1, 0, 0) \ 167 158 } 168 159 169 160 #define TPS6586X_DVM(_id, _pname, vdata, vreg, shift, nbits, \ 170 161 ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ 171 162 { \ 172 - TPS6586X_REGULATOR(_id, _pname, vdata, vreg, shift, nbits, \ 163 + TPS6586X_REGULATOR(_id, rw, _pname, vdata, vreg, shift, nbits, \ 173 164 ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ 174 165 } 175 166 ··· 228 205 static struct tps6586x_regulator tps658623_regulator[] = { 229 206 TPS6586X_LDO(SM_2, "vin-sm2", tps658623_sm2, SUPPLYV2, 0, 5, ENC, 7, 230 207 END, 7), 208 + }; 209 + 210 + static struct tps6586x_regulator tps658640_regulator[] = { 211 + TPS6586X_LDO(LDO_3, "vinldo23", tps6586x_ldo0, SUPPLYV4, 0, 3, 212 + ENC, 2, END, 2), 213 + TPS6586X_LDO(LDO_5, "REG-SYS", tps6586x_ldo0, SUPPLYV6, 0, 3, 214 + ENE, 6, ENE, 6), 215 + TPS6586X_LDO(LDO_6, "vinldo678", tps6586x_ldo0, SUPPLYV3, 0, 3, 216 + ENC, 4, END, 4), 217 + TPS6586X_LDO(LDO_7, "vinldo678", tps6586x_ldo0, SUPPLYV3, 3, 3, 218 + ENC, 5, END, 5), 219 + TPS6586X_LDO(LDO_8, "vinldo678", tps6586x_ldo0, SUPPLYV2, 5, 3, 220 + ENC, 6, END, 6), 221 + TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo0, SUPPLYV6, 3, 3, 222 + ENE, 7, ENE, 7), 223 + TPS6586X_LDO(SM_2, "vin-sm2", tps658640_sm2, SUPPLYV2, 0, 5, 224 + ENC, 7, END, 7), 225 + 226 + TPS6586X_FIXED_LDO(LDO_RTC, "REG-SYS", tps658640_rtc, SUPPLYV4, 3, 2, 227 + V4, 7, V4, 7), 231 228 }; 232 229 233 230 static struct tps6586x_regulator tps658643_regulator[] = { ··· 337 294 case TPS658623: 338 295 table = tps658623_regulator; 339 296 num = ARRAY_SIZE(tps658623_regulator); 297 + break; 298 + case TPS658640: 299 + case TPS658640v2: 300 + table = tps658640_regulator; 301 + num = ARRAY_SIZE(tps658640_regulator); 340 302 break; 341 303 case TPS658643: 342 304 table = tps658643_regulator;
+1 -1
drivers/regulator/vexpress.c
··· 98 98 return 0; 99 99 } 100 100 101 - static struct of_device_id vexpress_regulator_of_match[] = { 101 + static const struct of_device_id vexpress_regulator_of_match[] = { 102 102 { .compatible = "arm,vexpress-volt", }, 103 103 { } 104 104 };
+3
include/linux/mfd/arizona/core.h
··· 124 124 int wm5110_patch(struct arizona *arizona); 125 125 int wm8997_patch(struct arizona *arizona); 126 126 127 + extern int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop, 128 + bool mandatory); 129 + 127 130 #endif
+6 -3
include/linux/mfd/bcm590xx.h
··· 19 19 #include <linux/regmap.h> 20 20 21 21 /* max register address */ 22 - #define BCM590XX_MAX_REGISTER 0xe7 22 + #define BCM590XX_MAX_REGISTER_PRI 0xe7 23 + #define BCM590XX_MAX_REGISTER_SEC 0xf0 23 24 24 25 struct bcm590xx { 25 26 struct device *dev; 26 - struct i2c_client *i2c_client; 27 - struct regmap *regmap; 27 + struct i2c_client *i2c_pri; 28 + struct i2c_client *i2c_sec; 29 + struct regmap *regmap_pri; 30 + struct regmap *regmap_sec; 28 31 unsigned int id; 29 32 }; 30 33
+1 -1
include/linux/mfd/core.h
··· 63 63 /* A list of regulator supplies that should be mapped to the MFD 64 64 * device rather than the child device when requested 65 65 */ 66 - const char **parent_supplies; 66 + const char * const *parent_supplies; 67 67 int num_parent_supplies; 68 68 }; 69 69
+2
include/linux/mfd/samsung/s2mps14.h
··· 148 148 #define S2MPS14_ENABLE_SHIFT 6 149 149 /* On/Off controlled by PWREN */ 150 150 #define S2MPS14_ENABLE_SUSPEND (0x01 << S2MPS14_ENABLE_SHIFT) 151 + /* On/Off controlled by LDO10EN or EMMCEN */ 152 + #define S2MPS14_ENABLE_EXT_CONTROL (0x00 << S2MPS14_ENABLE_SHIFT) 151 153 #define S2MPS14_LDO_N_VOLTAGES (S2MPS14_LDO_VSEL_MASK + 1) 152 154 #define S2MPS14_BUCK_N_VOLTAGES (S2MPS14_BUCK_VSEL_MASK + 1) 153 155
+19
include/linux/mfd/tps65090.h
··· 64 64 TPS65090_REGULATOR_MAX, 65 65 }; 66 66 67 + /* Register addresses */ 68 + #define TPS65090_REG_INTR_STS 0x00 69 + #define TPS65090_REG_INTR_STS2 0x01 70 + #define TPS65090_REG_INTR_MASK 0x02 71 + #define TPS65090_REG_INTR_MASK2 0x03 72 + #define TPS65090_REG_CG_CTRL0 0x04 73 + #define TPS65090_REG_CG_CTRL1 0x05 74 + #define TPS65090_REG_CG_CTRL2 0x06 75 + #define TPS65090_REG_CG_CTRL3 0x07 76 + #define TPS65090_REG_CG_CTRL4 0x08 77 + #define TPS65090_REG_CG_CTRL5 0x09 78 + #define TPS65090_REG_CG_STATUS1 0x0a 79 + #define TPS65090_REG_CG_STATUS2 0x0b 80 + 67 81 struct tps65090 { 68 82 struct device *dev; 69 83 struct regmap *rmap; ··· 92 78 * DCDC1, DCDC2 and DCDC3. 93 79 * @gpio: Gpio number if external control is enabled and controlled through 94 80 * gpio. 81 + * @overcurrent_wait_valid: True if the overcurrent_wait should be applied. 82 + * @overcurrent_wait: Value to set as the overcurrent wait time. This is the 83 + * actual bitfield value, not a time in ms (valid value are 0 - 3). 95 84 */ 96 85 struct tps65090_regulator_plat_data { 97 86 struct regulator_init_data *reg_init_data; 98 87 bool enable_ext_control; 99 88 int gpio; 89 + bool overcurrent_wait_valid; 90 + int overcurrent_wait; 100 91 }; 101 92 102 93 struct tps65090_platform_data {
-1
include/linux/mfd/tps65217.h
··· 254 254 struct tps65217_board *pdata; 255 255 unsigned long id; 256 256 struct regulator_desc desc[TPS65217_NUM_REGULATOR]; 257 - struct regulator_dev *rdev[TPS65217_NUM_REGULATOR]; 258 257 struct regmap *regmap; 259 258 }; 260 259
+2
include/linux/mfd/tps6586x.h
··· 17 17 #define TPS658621A 0x15 18 18 #define TPS658621CD 0x2c 19 19 #define TPS658623 0x1b 20 + #define TPS658640 0x01 21 + #define TPS658640v2 0x02 20 22 #define TPS658643 0x03 21 23 22 24 enum {
+26 -16
include/linux/regulator/consumer.h
··· 151 151 const char *alias_id); 152 152 void regulator_unregister_supply_alias(struct device *dev, const char *id); 153 153 154 - int regulator_bulk_register_supply_alias(struct device *dev, const char **id, 154 + int regulator_bulk_register_supply_alias(struct device *dev, 155 + const char *const *id, 155 156 struct device *alias_dev, 156 - const char **alias_id, int num_id); 157 + const char *const *alias_id, 158 + int num_id); 157 159 void regulator_bulk_unregister_supply_alias(struct device *dev, 158 - const char **id, int num_id); 160 + const char * const *id, int num_id); 159 161 160 162 int devm_regulator_register_supply_alias(struct device *dev, const char *id, 161 163 struct device *alias_dev, ··· 166 164 const char *id); 167 165 168 166 int devm_regulator_bulk_register_supply_alias(struct device *dev, 169 - const char **id, 167 + const char *const *id, 170 168 struct device *alias_dev, 171 - const char **alias_id, 169 + const char *const *alias_id, 172 170 int num_id); 173 171 void devm_regulator_bulk_unregister_supply_alias(struct device *dev, 174 - const char **id, 172 + const char *const *id, 175 173 int num_id); 176 174 177 175 /* regulator output control and status */ ··· 292 290 } 293 291 294 292 static inline int regulator_bulk_register_supply_alias(struct device *dev, 295 - const char **id, 296 - struct device *alias_dev, 297 - const char **alias_id, 298 - int num_id) 293 + const char *const *id, 294 + struct device *alias_dev, 295 + const char * const *alias_id, 296 + int num_id) 299 297 { 300 298 return 0; 301 299 } 302 300 303 301 static inline void regulator_bulk_unregister_supply_alias(struct device *dev, 304 - const char **id, 305 - int num_id) 302 + const char * const *id, 303 + int num_id) 306 304 { 307 305 } 308 306 ··· 319 317 { 320 318 } 321 319 322 - static inline int devm_regulator_bulk_register_supply_alias( 323 - struct device *dev, const char **id, struct device *alias_dev, 324 - const char **alias_id, int num_id) 320 + static inline int devm_regulator_bulk_register_supply_alias(struct device *dev, 321 + const char *const *id, 322 + struct device *alias_dev, 323 + const char *const *alias_id, 324 + int num_id) 325 325 { 326 326 return 0; 327 327 } 328 328 329 329 static inline void devm_regulator_bulk_unregister_supply_alias( 330 - struct device *dev, const char **id, int num_id) 330 + struct device *dev, const char *const *id, int num_id) 331 331 { 332 332 } 333 333 ··· 397 393 398 394 static inline int regulator_set_voltage(struct regulator *regulator, 399 395 int min_uV, int max_uV) 396 + { 397 + return 0; 398 + } 399 + 400 + static inline int regulator_set_voltage_time(struct regulator *regulator, 401 + int old_uV, int new_uV) 400 402 { 401 403 return 0; 402 404 }