Pull regulator updates from Mark Brown: "A quiet release for the regulator API, conference season must've been slowing everyone down: - a new interface allowing drivers to provide an interface for reading a more detailed description of error conditions which allows devices using these regulators to build - ACPI support for the fixed voltage regulator. - cleanups for the TI TWL drivers to reduce code duplication" * tag 'regulator-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (24 commits) regulator: tps65086: Fix 25mV ranges for BUCK regulators 1, 2, and 6 regulator: Fix regulator_get_error_flags() signature mismatch regulator: core: add newline in debug message regulator: tps65086: Fix 25mV ranges for BUCK regulators regulator: core: Correct type of mode in regulator_mode_constrain regulator: max77620: add documentation for MPOK property regulator: max77620: add support to configure MPOK regulator: twl6030: Remove unused fields from struct twlreg_info regulator: twl: Remove unused fields from struct twlreg_info regulator: twl: split twl6030 logic into its own file regulator: twl: kill unused functions regulator: twl: make driver DT only regulator: twl-regulator: rework fixed regulator definition regulator: max77620: remove unused variable regulator: pwm: Add missing quotes to DT example regulator: stw481x-vmmc: fix ages old enable error regulator: gpio: properly check return value of of_get_named_gpio regulator: lp873x: Add support for populating input supply regulator: axp20x: Fix axp809 ldo_io registration error on cold boot regulators: helpers: Fix handling of bypass_val_on in get_bypass_regmap ...
Unified · Split
| @@ -7,6 +7,9 @@ Required properties: · 6 unmodified lines | ||
| 7 | 7 | - #gpio-cells: Should be two. The first cell is the pin number and |
| 8 | 8 | the second cell is used to specify flags. |
| 9 | 9 | See ../gpio/gpio.txt for more information. |
| 10 | + - xxx-in-supply: Phandle to parent supply node of each regulator | |
| 11 | + populated under regulators node. xxx can be | |
| 12 | + buck0, buck1, ldo0 or ldo1. | |
| 10 | 13 | - regulators: List of child nodes that specify the regulator |
| 11 | 14 | initialization data. |
| 12 | 15 | Example: |
| @@ -17,6 +20,11 @@ pmic: lp8733@60 { · 4 unmodified lines | ||
| 17 | 20 | gpio-controller; |
| 18 | 21 | #gpio-cells = <2>; |
| 19 | 22 | |
| 23 | + buck0-in-supply = <&vsys_3v3>; | |
| 24 | + buck1-in-supply = <&vsys_3v3>; | |
| 25 | + ldo0-in-supply = <&vsys_3v3>; | |
| 26 | + ldo1-in-supply = <&vsys_3v3>; | |
| 27 | + | |
| 20 | 28 | regulators { |
| 21 | 29 | lp8733_buck0: buck0 { |
| 22 | 30 | regulator-name = "lp8733-buck0"; |
| @@ -106,6 +106,18 @@ Here supported time periods by device in microseconds are as follows: · 105 unmodified lines | ||
| 106 | 106 | MAX77620 supports 40, 80, 160, 320, 640, 1280, 2560 and 5120 microseconds. |
| 107 | 107 | MAX20024 supports 20, 40, 80, 160, 320, 640, 1280 and 2540 microseconds. |
| 108 | 108 | |
| 109 | +-maxim,power-ok-control: configure map power ok bit | |
| 110 | + 1: Enables POK(Power OK) to control nRST_IO and GPIO1 | |
| 111 | + POK function. | |
| 112 | + 0: Disables POK control. | |
| 113 | + if property missing, do not configure MPOK bit. | |
| 114 | + If POK mapping is enabled for GPIO1/nRST_IO then, | |
| 115 | + GPIO1/nRST_IO pins are HIGH only if all rails | |
| 116 | + that have POK control enabled are HIGH. | |
| 117 | + If any of the rails goes down(which are enabled for POK | |
| 118 | + control) then, GPIO1/nRST_IO goes LOW. | |
| 119 | + this property is valid for max20024 only. | |
| 120 | + | |
| 109 | 121 | For DT binding details of different sub modules like GPIO, pincontrol, |
| 110 | 122 | regulator, power, please refer respective device-tree binding document |
| 111 | 123 | under their respective sub-system directories. |
| @@ -23,7 +23,7 @@ Required properties: · 22 unmodified lines | ||
| 23 | 23 | defined below. |
| 24 | 24 | |
| 25 | 25 | Optional regulator properties: |
| 26 | − - ti,regulator-step-size-25mv : This is applicable for buck[1,2,6], set this | |
| 26 | + - ti,regulator-step-size-25mv : This is applicable for buck[1-6], set this | |
| 27 | 27 | if the regulator is factory set with a 25mv |
| 28 | 28 | step voltage mapping. |
| 29 | 29 | - ti,regulator-decay : This is applicable for buck[1-6], set this if |
| @@ -59,7 +59,7 @@ Any property defined as part of the core regulator binding can also be used. · 58 unmodified lines | ||
| 59 | 59 | |
| 60 | 60 | Continuous Voltage With Enable GPIO Example: |
| 61 | 61 | pwm_regulator { |
| 62 | − compatible = "pwm-regulator; | |
| 62 | + compatible = "pwm-regulator"; | |
| 63 | 63 | pwms = <&pwm1 0 8448 0>; |
| 64 | 64 | enable-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; |
| 65 | 65 | regulator-min-microvolt = <1016000>; |
| @@ -76,7 +76,7 @@ Continuous Voltage With Enable GPIO Example: · 10 unmodified lines | ||
| 76 | 76 | |
| 77 | 77 | Voltage Table Example: |
| 78 | 78 | pwm_regulator { |
| 79 | − compatible = "pwm-regulator; | |
| 79 | + compatible = "pwm-regulator"; | |
| 80 | 80 | pwms = <&pwm1 0 8448 0>; |
| 81 | 81 | regulator-min-microvolt = <1016000>; |
| 82 | 82 | regulator-max-microvolt = <1114000>; |
| @@ -8761,6 +8761,7 @@ F: drivers/regulator/tps65217-regulator.c · 8760 unmodified lines | ||
| 8761 | 8761 | F: drivers/regulator/tps65218-regulator.c |
| 8762 | 8762 | F: drivers/regulator/tps65910-regulator.c |
| 8763 | 8763 | F: drivers/regulator/twl-regulator.c |
| 8764 | +F: drivers/regulator/twl6030-regulator.c | |
| 8764 | 8765 | F: include/linux/i2c-omap.h |
| 8765 | 8766 | |
| 8766 | 8767 | OMAP DEVICE TREE SUPPORT |
| @@ -104,7 +104,7 @@ obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o · 103 unmodified lines | ||
| 104 | 104 | obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o |
| 105 | 105 | obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o |
| 106 | 106 | obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o |
| 107 | −obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o | |
| 107 | +obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o twl6030-regulator.o | |
| 108 | 108 | obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress-regulator.o |
| 109 | 109 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o |
| 110 | 110 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o |
| @@ -130,6 +130,7 @@ static const struct regulator_desc arizona_ldo1_hc = { · 129 unmodified lines | ||
| 130 | 130 | .uV_step = 50000, |
| 131 | 131 | .n_voltages = 8, |
| 132 | 132 | .enable_time = 1500, |
| 133 | + .ramp_delay = 24000, | |
| 133 | 134 | |
| 134 | 135 | .owner = THIS_MODULE, |
| 135 | 136 | }; |
| @@ -153,6 +154,7 @@ static const struct regulator_desc arizona_ldo1 = { · 17 unmodified lines | ||
| 153 | 154 | .uV_step = 25000, |
| 154 | 155 | .n_voltages = 13, |
| 155 | 156 | .enable_time = 500, |
| 157 | + .ramp_delay = 24000, | |
| 156 | 158 | |
| 157 | 159 | .owner = THIS_MODULE, |
| 158 | 160 | }; |
| @@ -337,10 +337,18 @@ static const struct regulator_desc axp809_regulators[] = { · 336 unmodified lines | ||
| 337 | 337 | AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)), |
| 338 | 338 | AXP_DESC(AXP809, ELDO3, "eldo3", "eldoin", 700, 3300, 100, |
| 339 | 339 | AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)), |
| 340 | − AXP_DESC_IO(AXP809, LDO_IO0, "ldo_io0", "ips", 700, 3300, 100, | |
| 340 | + /* | |
| 341 | + * Note the datasheet only guarantees reliable operation up to | |
| 342 | + * 3.3V, this needs to be enforced via dts provided constraints | |
| 343 | + */ | |
| 344 | + AXP_DESC_IO(AXP809, LDO_IO0, "ldo_io0", "ips", 700, 3800, 100, | |
| 341 | 345 | AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07, |
| 342 | 346 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
| 343 | − AXP_DESC_IO(AXP809, LDO_IO1, "ldo_io1", "ips", 700, 3300, 100, | |
| 347 | + /* | |
| 348 | + * Note the datasheet only guarantees reliable operation up to | |
| 349 | + * 3.3V, this needs to be enforced via dts provided constraints | |
| 350 | + */ | |
| 351 | + AXP_DESC_IO(AXP809, LDO_IO1, "ldo_io1", "ips", 700, 3800, 100, | |
| 344 | 352 | AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07, |
| 345 | 353 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
| 346 | 354 | AXP_DESC_FIXED(AXP809, RTC_LDO, "rtc_ldo", "ips", 1800), |
| @@ -204,7 +204,7 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp · 203 unmodified lines | ||
| 204 | 204 | regnode = of_parse_phandle(dev->of_node, prop_name, 0); |
| 205 | 205 | |
| 206 | 206 | if (!regnode) { |
| 207 | − dev_dbg(dev, "Looking up %s property in node %s failed", | |
| 207 | + dev_dbg(dev, "Looking up %s property in node %s failed\n", | |
| 208 | 208 | prop_name, dev->of_node->full_name); |
| 209 | 209 | return NULL; |
| 210 | 210 | } |
| @@ -293,7 +293,8 @@ static int regulator_check_current_limit(struct regulator_dev *rdev, · 82 unmodified lines | ||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /* operating mode constraint check */ |
| 296 | −static int regulator_mode_constrain(struct regulator_dev *rdev, int *mode) | |
| 296 | +static int regulator_mode_constrain(struct regulator_dev *rdev, | |
| 297 | + unsigned int *mode) | |
| 297 | 298 | { |
| 298 | 299 | switch (*mode) { |
| 299 | 300 | case REGULATOR_MODE_FAST: |
| @@ -3359,6 +3360,39 @@ unsigned int regulator_get_mode(struct regulator *regulator) · 3059 unmodified lines | ||
| 3359 | 3360 | } |
| 3360 | 3361 | EXPORT_SYMBOL_GPL(regulator_get_mode); |
| 3361 | 3362 | |
| 3363 | +static int _regulator_get_error_flags(struct regulator_dev *rdev, | |
| 3364 | + unsigned int *flags) | |
| 3365 | +{ | |
| 3366 | + int ret; | |
| 3367 | + | |
| 3368 | + mutex_lock(&rdev->mutex); | |
| 3369 | + | |
| 3370 | + /* sanity check */ | |
| 3371 | + if (!rdev->desc->ops->get_error_flags) { | |
| 3372 | + ret = -EINVAL; | |
| 3373 | + goto out; | |
| 3374 | + } | |
| 3375 | + | |
| 3376 | + ret = rdev->desc->ops->get_error_flags(rdev, flags); | |
| 3377 | +out: | |
| 3378 | + mutex_unlock(&rdev->mutex); | |
| 3379 | + return ret; | |
| 3380 | +} | |
| 3381 | + | |
| 3382 | +/** | |
| 3383 | + * regulator_get_error_flags - get regulator error information | |
| 3384 | + * @regulator: regulator source | |
| 3385 | + * @flags: pointer to store error flags | |
| 3386 | + * | |
| 3387 | + * Get the current regulator error information. | |
| 3388 | + */ | |
| 3389 | +int regulator_get_error_flags(struct regulator *regulator, | |
| 3390 | + unsigned int *flags) | |
| 3391 | +{ | |
| 3392 | + return _regulator_get_error_flags(regulator->rdev, flags); | |
| 3393 | +} | |
| 3394 | +EXPORT_SYMBOL_GPL(regulator_get_error_flags); | |
| 3395 | + | |
| 3362 | 3396 | /** |
| 3363 | 3397 | * regulator_set_load - set regulator load |
| 3364 | 3398 | * @regulator: regulator source |
| @@ -30,6 +30,9 @@ · 29 unmodified lines | ||
| 30 | 30 | #include <linux/of_gpio.h> |
| 31 | 31 | #include <linux/regulator/of_regulator.h> |
| 32 | 32 | #include <linux/regulator/machine.h> |
| 33 | +#include <linux/acpi.h> | |
| 34 | +#include <linux/property.h> | |
| 35 | +#include <linux/gpio/consumer.h> | |
| 33 | 36 | |
| 34 | 37 | struct fixed_voltage_data { |
| 35 | 38 | struct regulator_desc desc; |
| @@ -94,6 +97,44 @@ of_get_fixed_voltage_config(struct device *dev, · 58 unmodified lines | ||
| 94 | 97 | return config; |
| 95 | 98 | } |
| 96 | 99 | |
| 100 | +/** | |
| 101 | + * acpi_get_fixed_voltage_config - extract fixed_voltage_config structure info | |
| 102 | + * @dev: device requesting for fixed_voltage_config | |
| 103 | + * @desc: regulator description | |
| 104 | + * | |
| 105 | + * Populates fixed_voltage_config structure by extracting data through ACPI | |
| 106 | + * interface, returns a pointer to the populated structure of NULL if memory | |
| 107 | + * alloc fails. | |
| 108 | + */ | |
| 109 | +static struct fixed_voltage_config * | |
| 110 | +acpi_get_fixed_voltage_config(struct device *dev, | |
| 111 | + const struct regulator_desc *desc) | |
| 112 | +{ | |
| 113 | + struct fixed_voltage_config *config; | |
| 114 | + const char *supply_name; | |
| 115 | + struct gpio_desc *gpiod; | |
| 116 | + int ret; | |
| 117 | + | |
| 118 | + config = devm_kzalloc(dev, sizeof(*config), GFP_KERNEL); | |
| 119 | + if (!config) | |
| 120 | + return ERR_PTR(-ENOMEM); | |
| 121 | + | |
| 122 | + ret = device_property_read_string(dev, "supply-name", &supply_name); | |
| 123 | + if (!ret) | |
| 124 | + config->supply_name = supply_name; | |
| 125 | + | |
| 126 | + gpiod = gpiod_get(dev, "gpio", GPIOD_ASIS); | |
| 127 | + if (IS_ERR(gpiod)) | |
| 128 | + return ERR_PTR(-ENODEV); | |
| 129 | + | |
| 130 | + config->gpio = desc_to_gpio(gpiod); | |
| 131 | + config->enable_high = device_property_read_bool(dev, | |
| 132 | + "enable-active-high"); | |
| 133 | + gpiod_put(gpiod); | |
| 134 | + | |
| 135 | + return config; | |
| 136 | +} | |
| 137 | + | |
| 97 | 138 | static struct regulator_ops fixed_voltage_ops = { |
| 98 | 139 | }; |
| 99 | 140 | |
| @@ -114,6 +155,11 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) · 14 unmodified lines | ||
| 114 | 155 | &drvdata->desc); |
| 115 | 156 | if (IS_ERR(config)) |
| 116 | 157 | return PTR_ERR(config); |
| 158 | + } else if (ACPI_HANDLE(&pdev->dev)) { | |
| 159 | + config = acpi_get_fixed_voltage_config(&pdev->dev, | |
| 160 | + &drvdata->desc); | |
| 161 | + if (IS_ERR(config)) | |
| 162 | + return PTR_ERR(config); | |
| 117 | 163 | } else { |
| 118 | 164 | config = dev_get_platdata(&pdev->dev); |
| 119 | 165 | } |
| @@ -162,8 +162,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, · 161 unmodified lines | ||
| 162 | 162 | of_property_read_u32(np, "startup-delay-us", &config->startup_delay); |
| 163 | 163 | |
| 164 | 164 | config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0); |
| 165 | − if (config->enable_gpio == -EPROBE_DEFER) | |
| 166 | − return ERR_PTR(-EPROBE_DEFER); | |
| 165 | + if (config->enable_gpio < 0 && config->enable_gpio != -ENOENT) | |
| 166 | + return ERR_PTR(config->enable_gpio); | |
| 167 | 167 | |
| 168 | 168 | /* Fetch GPIOs. - optional property*/ |
| 169 | 169 | ret = of_gpio_count(np); |
| @@ -190,8 +190,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, · 20 unmodified lines | ||
| 190 | 190 | |
| 191 | 191 | for (i = 0; i < config->nr_gpios; i++) { |
| 192 | 192 | gpio = of_get_named_gpio(np, "gpios", i); |
| 193 | − if (gpio < 0) | |
| 193 | + if (gpio < 0) { | |
| 194 | + if (gpio != -ENOENT) | |
| 195 | + return ERR_PTR(gpio); | |
| 194 | 196 | break; |
| 197 | + } | |
| 195 | 198 | config->gpios[i].gpio = gpio; |
| 196 | 199 | if (proplen > 0) { |
| 197 | 200 | of_property_read_u32_index(np, "gpios-states", |
| @@ -454,13 +454,17 @@ EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap); · 453 unmodified lines | ||
| 454 | 454 | int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) |
| 455 | 455 | { |
| 456 | 456 | unsigned int val; |
| 457 | + unsigned int val_on = rdev->desc->bypass_val_on; | |
| 457 | 458 | int ret; |
| 458 | 459 | |
| 459 | 460 | ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val); |
| 460 | 461 | if (ret != 0) |
| 461 | 462 | return ret; |
| 462 | 463 | |
| 463 | − *enable = (val & rdev->desc->bypass_mask) == rdev->desc->bypass_val_on; | |
| 464 | + if (!val_on) | |
| 465 | + val_on = rdev->desc->bypass_mask; | |
| 466 | + | |
| 467 | + *enable = (val & rdev->desc->bypass_mask) == val_on; | |
| 464 | 468 | |
| 465 | 469 | return 0; |
| 466 | 470 | } |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | [_id] = { \ |
| 25 | 25 | .desc = { \ |
| 26 | 26 | .name = _name, \ |
| 27 | + .supply_name = _of "-in", \ | |
| 27 | 28 | .id = _id, \ |
| 28 | 29 | .of_match = of_match_ptr(_of), \ |
| 29 | 30 | .regulators_node = of_match_ptr("regulators"),\ |
| @@ -73,7 +73,6 @@ struct max77620_regulator_info { · 72 unmodified lines | ||
| 73 | 73 | }; |
| 74 | 74 | |
| 75 | 75 | struct max77620_regulator_pdata { |
| 76 | − struct regulator_init_data *reg_idata; | |
| 77 | 76 | int active_fps_src; |
| 78 | 77 | int active_fps_pd_slot; |
| 79 | 78 | int active_fps_pu_slot; |
| @@ -81,6 +80,7 @@ struct max77620_regulator_pdata { · 1 unmodified line | ||
| 81 | 80 | int suspend_fps_pd_slot; |
| 82 | 81 | int suspend_fps_pu_slot; |
| 83 | 82 | int current_mode; |
| 83 | + int power_ok; | |
| 84 | 84 | int ramp_rate_setting; |
| 85 | 85 | }; |
| 86 | 86 | |
| @@ -351,11 +351,48 @@ static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id, · 264 unmodified lines | ||
| 351 | 351 | return 0; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | +static int max77620_config_power_ok(struct max77620_regulator *pmic, int id) | |
| 355 | +{ | |
| 356 | + struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; | |
| 357 | + struct max77620_regulator_info *rinfo = pmic->rinfo[id]; | |
| 358 | + struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent); | |
| 359 | + u8 val, mask; | |
| 360 | + int ret; | |
| 361 | + | |
| 362 | + switch (chip->chip_id) { | |
| 363 | + case MAX20024: | |
| 364 | + if (rpdata->power_ok >= 0) { | |
| 365 | + if (rinfo->type == MAX77620_REGULATOR_TYPE_SD) | |
| 366 | + mask = MAX20024_SD_CFG1_MPOK_MASK; | |
| 367 | + else | |
| 368 | + mask = MAX20024_LDO_CFG2_MPOK_MASK; | |
| 369 | + | |
| 370 | + val = rpdata->power_ok ? mask : 0; | |
| 371 | + | |
| 372 | + ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr, | |
| 373 | + mask, val); | |
| 374 | + if (ret < 0) { | |
| 375 | + dev_err(pmic->dev, "Reg 0x%02x update failed %d\n", | |
| 376 | + rinfo->cfg_addr, ret); | |
| 377 | + return ret; | |
| 378 | + } | |
| 379 | + } | |
| 380 | + break; | |
| 381 | + | |
| 382 | + default: | |
| 383 | + break; | |
| 384 | + } | |
| 385 | + | |
| 386 | + return 0; | |
| 387 | +} | |
| 388 | + | |
| 354 | 389 | static int max77620_init_pmic(struct max77620_regulator *pmic, int id) |
| 355 | 390 | { |
| 356 | 391 | struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; |
| 357 | 392 | int ret; |
| 358 | 393 | |
| 394 | + max77620_config_power_ok(pmic, id); | |
| 395 | + | |
| 359 | 396 | /* Update power mode */ |
| 360 | 397 | ret = max77620_regulator_get_power_mode(pmic, id); |
| 361 | 398 | if (ret < 0) |
| @@ -595,6 +632,12 @@ static int max77620_of_parse_cb(struct device_node *np, · 233 unmodified lines | ||
| 595 | 632 | np, "maxim,suspend-fps-power-down-slot", &pval); |
| 596 | 633 | rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1; |
| 597 | 634 | |
| 635 | + ret = of_property_read_u32(np, "maxim,power-ok-control", &pval); | |
| 636 | + if (!ret) | |
| 637 | + rpdata->power_ok = pval; | |
| 638 | + else | |
| 639 | + rpdata->power_ok = -1; | |
| 640 | + | |
| 598 | 641 | ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval); |
| 599 | 642 | rpdata->ramp_rate_setting = (!ret) ? pval : 0; |
| 600 | 643 | |
| @@ -807,6 +850,8 @@ static int max77620_regulator_resume(struct device *dev) · 206 unmodified lines | ||
| 807 | 850 | for (id = 0; id < MAX77620_NUM_REGS; id++) { |
| 808 | 851 | reg_pdata = &pmic->reg_pdata[id]; |
| 809 | 852 | |
| 853 | + max77620_config_power_ok(pmic, id); | |
| 854 | + | |
| 810 | 855 | max77620_regulator_set_fps_slots(pmic, id, false); |
| 811 | 856 | if (reg_pdata->active_fps_src < 0) |
| 812 | 857 | continue; |
| @@ -47,7 +47,8 @@ static struct regulator_desc vmmc_regulator = { · 46 unmodified lines | ||
| 47 | 47 | .volt_table = stw481x_vmmc_voltages, |
| 48 | 48 | .enable_time = 200, /* FIXME: look this up */ |
| 49 | 49 | .enable_reg = STW_CONF1, |
| 50 | − .enable_mask = STW_CONF1_PDN_VMMC, | |
| 50 | + .enable_mask = STW_CONF1_PDN_VMMC | STW_CONF1_MMC_LS_STATUS, | |
| 51 | + .enable_val = STW_CONF1_PDN_VMMC, | |
| 51 | 52 | .vsel_reg = STW_CONF1, |
| 52 | 53 | .vsel_mask = STW_CONF1_VMMC_MASK, |
| 53 | 54 | }; |
| @@ -375,7 +375,7 @@ static struct tps6507x_board *tps6507x_parse_dt_reg_data( · 374 unmodified lines | ||
| 375 | 375 | struct device_node *np = pdev->dev.parent->of_node; |
| 376 | 376 | struct device_node *regulators; |
| 377 | 377 | struct of_regulator_match *matches; |
| 378 | − static struct regulator_init_data *reg_data; | |
| 378 | + struct regulator_init_data *reg_data; | |
| 379 | 379 | int idx = 0, count, ret; |
| 380 | 380 | |
| 381 | 381 | tps_board = devm_kzalloc(&pdev->dev, sizeof(*tps_board), |
| @@ -71,7 +71,7 @@ struct tps65086_regulator { · 70 unmodified lines | ||
| 71 | 71 | unsigned int decay_mask; |
| 72 | 72 | }; |
| 73 | 73 | |
| 74 | −static const struct regulator_linear_range tps65086_buck126_10mv_ranges[] = { | |
| 74 | +static const struct regulator_linear_range tps65086_10mv_ranges[] = { | |
| 75 | 75 | REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), |
| 76 | 76 | REGULATOR_LINEAR_RANGE(410000, 0x1, 0x7F, 10000), |
| 77 | 77 | }; |
| @@ -82,7 +82,7 @@ static const struct regulator_linear_range tps65086_buck126_25mv_ranges[] = { · 4 unmodified lines | ||
| 82 | 82 | REGULATOR_LINEAR_RANGE(1025000, 0x19, 0x7F, 25000), |
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | −static const struct regulator_linear_range tps65086_buck345_ranges[] = { | |
| 85 | +static const struct regulator_linear_range tps65086_buck345_25mv_ranges[] = { | |
| 86 | 86 | REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0), |
| 87 | 87 | REGULATOR_LINEAR_RANGE(425000, 0x1, 0x7F, 25000), |
| 88 | 88 | }; |
| @@ -125,27 +125,27 @@ static int tps65086_of_parse_cb(struct device_node *dev, · 36 unmodified lines | ||
| 125 | 125 | static struct tps65086_regulator regulators[] = { |
| 126 | 126 | TPS65086_REGULATOR("BUCK1", "buck1", BUCK1, 0x80, TPS65086_BUCK1CTRL, |
| 127 | 127 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(0), |
| 128 | − tps65086_buck126_10mv_ranges, TPS65086_BUCK1CTRL, | |
| 128 | + tps65086_10mv_ranges, TPS65086_BUCK1CTRL, | |
| 129 | 129 | BIT(0)), |
| 130 | 130 | TPS65086_REGULATOR("BUCK2", "buck2", BUCK2, 0x80, TPS65086_BUCK2CTRL, |
| 131 | 131 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(1), |
| 132 | − tps65086_buck126_10mv_ranges, TPS65086_BUCK2CTRL, | |
| 132 | + tps65086_10mv_ranges, TPS65086_BUCK2CTRL, | |
| 133 | 133 | BIT(0)), |
| 134 | 134 | TPS65086_REGULATOR("BUCK3", "buck3", BUCK3, 0x80, TPS65086_BUCK3VID, |
| 135 | 135 | BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(2), |
| 136 | − tps65086_buck345_ranges, TPS65086_BUCK3DECAY, | |
| 136 | + tps65086_10mv_ranges, TPS65086_BUCK3DECAY, | |
| 137 | 137 | BIT(0)), |
| 138 | 138 | TPS65086_REGULATOR("BUCK4", "buck4", BUCK4, 0x80, TPS65086_BUCK4VID, |
| 139 | 139 | BUCK_VID_MASK, TPS65086_BUCK4CTRL, BIT(0), |
| 140 | − tps65086_buck345_ranges, TPS65086_BUCK4VID, | |
| 140 | + tps65086_10mv_ranges, TPS65086_BUCK4VID, | |
| 141 | 141 | BIT(0)), |
| 142 | 142 | TPS65086_REGULATOR("BUCK5", "buck5", BUCK5, 0x80, TPS65086_BUCK5VID, |
| 143 | 143 | BUCK_VID_MASK, TPS65086_BUCK5CTRL, BIT(0), |
| 144 | − tps65086_buck345_ranges, TPS65086_BUCK5CTRL, | |
| 144 | + tps65086_10mv_ranges, TPS65086_BUCK5CTRL, | |
| 145 | 145 | BIT(0)), |
| 146 | 146 | TPS65086_REGULATOR("BUCK6", "buck6", BUCK6, 0x80, TPS65086_BUCK6VID, |
| 147 | 147 | BUCK_VID_MASK, TPS65086_BUCK6CTRL, BIT(0), |
| 148 | − tps65086_buck126_10mv_ranges, TPS65086_BUCK6CTRL, | |
| 148 | + tps65086_10mv_ranges, TPS65086_BUCK6CTRL, | |
| 149 | 149 | BIT(0)), |
| 150 | 150 | TPS65086_REGULATOR("LDOA1", "ldoa1", LDOA1, 0xF, TPS65086_LDOA1CTRL, |
| 151 | 151 | VDOA1_VID_MASK, TPS65086_LDOA1CTRL, BIT(0), |
| @@ -162,18 +162,6 @@ static struct tps65086_regulator regulators[] = { · 10 unmodified lines | ||
| 162 | 162 | TPS65086_SWITCH("VTT", "vtt", VTT, TPS65086_SWVTT_EN, BIT(4)), |
| 163 | 163 | }; |
| 164 | 164 | |
| 165 | −static inline bool has_25mv_mode(int id) | |
| 166 | −{ | |
| 167 | − switch (id) { | |
| 168 | − case BUCK1: | |
| 169 | − case BUCK2: | |
| 170 | − case BUCK6: | |
| 171 | − return true; | |
| 172 | − default: | |
| 173 | − return false; | |
| 174 | − } | |
| 175 | −} | |
| 176 | − | |
| 177 | 165 | static int tps65086_of_parse_cb(struct device_node *dev, |
| 178 | 166 | const struct regulator_desc *desc, |
| 179 | 167 | struct regulator_config *config) |
| @@ -181,12 +169,27 @@ static int tps65086_of_parse_cb(struct device_node *dev, · 1 unmodified line | ||
| 181 | 169 | int ret; |
| 182 | 170 | |
| 183 | 171 | /* Check for 25mV step mode */ |
| 184 | − if (has_25mv_mode(desc->id) && | |
| 185 | − of_property_read_bool(config->of_node, "ti,regulator-step-size-25mv")) { | |
| 186 | − regulators[desc->id].desc.linear_ranges = | |
| 172 | + if (of_property_read_bool(config->of_node, "ti,regulator-step-size-25mv")) { | |
| 173 | + switch (desc->id) { | |
| 174 | + case BUCK1: | |
| 175 | + case BUCK2: | |
| 176 | + case BUCK6: | |
| 177 | + regulators[desc->id].desc.linear_ranges = | |
| 187 | 178 | tps65086_buck126_25mv_ranges; |
| 188 | − regulators[desc->id].desc.n_linear_ranges = | |
| 179 | + regulators[desc->id].desc.n_linear_ranges = | |
| 189 | 180 | ARRAY_SIZE(tps65086_buck126_25mv_ranges); |
| 181 | + break; | |
| 182 | + case BUCK3: | |
| 183 | + case BUCK4: | |
| 184 | + case BUCK5: | |
| 185 | + regulators[desc->id].desc.linear_ranges = | |
| 186 | + tps65086_buck345_25mv_ranges; | |
| 187 | + regulators[desc->id].desc.n_linear_ranges = | |
| 188 | + ARRAY_SIZE(tps65086_buck345_25mv_ranges); | |
| 189 | + break; | |
| 190 | + default: | |
| 191 | + dev_warn(config->dev, "25mV step mode only valid for BUCK regulators\n"); | |
| 192 | + } | |
| 190 | 193 | } |
| 191 | 194 | |
| 192 | 195 | /* Check for decay mode */ |
| @@ -24,7 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include <linux/delay.h> |
| 25 | 25 | |
| 26 | 26 | /* |
| 27 | − * The TWL4030/TW5030/TPS659x0/TWL6030 family chips include power management, a | |
| 27 | + * The TWL4030/TW5030/TPS659x0 family chips include power management, a | |
| 28 | 28 | * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions |
| 29 | 29 | * include an audio codec, battery charger, and more voltage regulators. |
| 30 | 30 | * These chips are often used in OMAP-based systems. |
| @@ -48,25 +48,12 @@ struct twlreg_info { · 17 unmodified lines | ||
| 48 | 48 | /* State REMAP default configuration */ |
| 49 | 49 | u8 remap; |
| 50 | 50 | |
| 51 | − /* chip constraints on regulator behavior */ | |
| 52 | − u16 min_mV; | |
| 53 | − u16 max_mV; | |
| 54 | − | |
| 55 | − u8 flags; | |
| 56 | − | |
| 57 | 51 | /* used by regulator core */ |
| 58 | 52 | struct regulator_desc desc; |
| 59 | 53 | |
| 60 | 54 | /* chip specific features */ |
| 61 | 55 | unsigned long features; |
| 62 | 56 | |
| 63 | − /* | |
| 64 | − * optional override functions for voltage set/get | |
| 65 | − * these are currently only used for SMPS regulators | |
| 66 | − */ | |
| 67 | − int (*get_voltage)(void *data); | |
| 68 | − int (*set_voltage)(void *data, int target_uV); | |
| 69 | − | |
| 70 | 57 | /* data passed from board for external get/set voltage */ |
| 71 | 58 | void *data; |
| 72 | 59 | }; |
| @@ -88,33 +75,6 @@ struct twlreg_info { · 15 unmodified lines | ||
| 88 | 75 | #define VREG_STATE 2 |
| 89 | 76 | #define VREG_VOLTAGE 3 |
| 90 | 77 | #define VREG_VOLTAGE_SMPS 4 |
| 91 | −/* TWL6030 Misc register offsets */ | |
| 92 | −#define VREG_BC_ALL 1 | |
| 93 | −#define VREG_BC_REF 2 | |
| 94 | −#define VREG_BC_PROC 3 | |
| 95 | −#define VREG_BC_CLK_RST 4 | |
| 96 | − | |
| 97 | −/* TWL6030 LDO register values for CFG_STATE */ | |
| 98 | −#define TWL6030_CFG_STATE_OFF 0x00 | |
| 99 | −#define TWL6030_CFG_STATE_ON 0x01 | |
| 100 | −#define TWL6030_CFG_STATE_OFF2 0x02 | |
| 101 | −#define TWL6030_CFG_STATE_SLEEP 0x03 | |
| 102 | −#define TWL6030_CFG_STATE_GRP_SHIFT 5 | |
| 103 | −#define TWL6030_CFG_STATE_APP_SHIFT 2 | |
| 104 | −#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT) | |
| 105 | −#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\ | |
| 106 | − TWL6030_CFG_STATE_APP_SHIFT) | |
| 107 | − | |
| 108 | −/* Flags for SMPS Voltage reading */ | |
| 109 | −#define SMPS_OFFSET_EN BIT(0) | |
| 110 | −#define SMPS_EXTENDED_EN BIT(1) | |
| 111 | − | |
| 112 | −/* twl6032 SMPS EPROM values */ | |
| 113 | −#define TWL6030_SMPS_OFFSET 0xB0 | |
| 114 | −#define TWL6030_SMPS_MULT 0xB3 | |
| 115 | −#define SMPS_MULTOFFSET_SMPS4 BIT(0) | |
| 116 | −#define SMPS_MULTOFFSET_VIO BIT(1) | |
| 117 | −#define SMPS_MULTOFFSET_SMPS3 BIT(6) | |
| 118 | 78 | |
| 119 | 79 | static inline int |
| 120 | 80 | twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) |
| @@ -168,26 +128,6 @@ static int twl4030reg_is_enabled(struct regulator_dev *rdev) · 47 unmodified lines | ||
| 168 | 128 | return state & P1_GRP_4030; |
| 169 | 129 | } |
| 170 | 130 | |
| 171 | −static int twl6030reg_is_enabled(struct regulator_dev *rdev) | |
| 172 | −{ | |
| 173 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 174 | − int grp = 0, val; | |
| 175 | − | |
| 176 | − if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) { | |
| 177 | − grp = twlreg_grp(rdev); | |
| 178 | − if (grp < 0) | |
| 179 | − return grp; | |
| 180 | − grp &= P1_GRP_6030; | |
| 181 | − } else { | |
| 182 | − grp = 1; | |
| 183 | − } | |
| 184 | − | |
| 185 | − val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); | |
| 186 | − val = TWL6030_CFG_STATE_APP(val); | |
| 187 | − | |
| 188 | − return grp && (val == TWL6030_CFG_STATE_ON); | |
| 189 | −} | |
| 190 | − | |
| 191 | 131 | #define PB_I2C_BUSY BIT(0) |
| 192 | 132 | #define PB_I2C_BWEN BIT(1) |
| 193 | 133 | |
| @@ -273,23 +213,6 @@ static int twl4030reg_enable(struct regulator_dev *rdev) · 79 unmodified lines | ||
| 273 | 213 | return ret; |
| 274 | 214 | } |
| 275 | 215 | |
| 276 | −static int twl6030reg_enable(struct regulator_dev *rdev) | |
| 277 | −{ | |
| 278 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 279 | − int grp = 0; | |
| 280 | − int ret; | |
| 281 | − | |
| 282 | − if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | |
| 283 | − grp = twlreg_grp(rdev); | |
| 284 | − if (grp < 0) | |
| 285 | − return grp; | |
| 286 | − | |
| 287 | − ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, | |
| 288 | − grp << TWL6030_CFG_STATE_GRP_SHIFT | | |
| 289 | − TWL6030_CFG_STATE_ON); | |
| 290 | − return ret; | |
| 291 | −} | |
| 292 | − | |
| 293 | 216 | static int twl4030reg_disable(struct regulator_dev *rdev) |
| 294 | 217 | { |
| 295 | 218 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| @@ -307,23 +230,6 @@ static int twl4030reg_disable(struct regulator_dev *rdev) · 11 unmodified lines | ||
| 307 | 230 | return ret; |
| 308 | 231 | } |
| 309 | 232 | |
| 310 | −static int twl6030reg_disable(struct regulator_dev *rdev) | |
| 311 | −{ | |
| 312 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 313 | − int grp = 0; | |
| 314 | − int ret; | |
| 315 | − | |
| 316 | − if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | |
| 317 | − grp = P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030; | |
| 318 | − | |
| 319 | − /* For 6030, set the off state for all grps enabled */ | |
| 320 | − ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, | |
| 321 | − (grp) << TWL6030_CFG_STATE_GRP_SHIFT | | |
| 322 | − TWL6030_CFG_STATE_OFF); | |
| 323 | − | |
| 324 | − return ret; | |
| 325 | −} | |
| 326 | − | |
| 327 | 233 | static int twl4030reg_get_status(struct regulator_dev *rdev) |
| 328 | 234 | { |
| 329 | 235 | int state = twlreg_grp(rdev); |
| @@ -340,33 +246,6 @@ static int twl4030reg_get_status(struct regulator_dev *rdev) · 10 unmodified lines | ||
| 340 | 246 | : REGULATOR_STATUS_STANDBY; |
| 341 | 247 | } |
| 342 | 248 | |
| 343 | −static int twl6030reg_get_status(struct regulator_dev *rdev) | |
| 344 | −{ | |
| 345 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 346 | − int val; | |
| 347 | − | |
| 348 | − val = twlreg_grp(rdev); | |
| 349 | − if (val < 0) | |
| 350 | − return val; | |
| 351 | − | |
| 352 | − val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); | |
| 353 | − | |
| 354 | − switch (TWL6030_CFG_STATE_APP(val)) { | |
| 355 | − case TWL6030_CFG_STATE_ON: | |
| 356 | − return REGULATOR_STATUS_NORMAL; | |
| 357 | − | |
| 358 | − case TWL6030_CFG_STATE_SLEEP: | |
| 359 | − return REGULATOR_STATUS_STANDBY; | |
| 360 | − | |
| 361 | − case TWL6030_CFG_STATE_OFF: | |
| 362 | − case TWL6030_CFG_STATE_OFF2: | |
| 363 | − default: | |
| 364 | − break; | |
| 365 | − } | |
| 366 | − | |
| 367 | − return REGULATOR_STATUS_OFF; | |
| 368 | −} | |
| 369 | − | |
| 370 | 249 | static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode) |
| 371 | 250 | { |
| 372 | 251 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| @@ -399,36 +278,6 @@ static inline unsigned int twl4030reg_map_mode(unsigned int mode) · 26 unmodified lines | ||
| 399 | 278 | } |
| 400 | 279 | } |
| 401 | 280 | |
| 402 | −static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode) | |
| 403 | −{ | |
| 404 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 405 | − int grp = 0; | |
| 406 | − int val; | |
| 407 | − | |
| 408 | − if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | |
| 409 | − grp = twlreg_grp(rdev); | |
| 410 | − | |
| 411 | − if (grp < 0) | |
| 412 | − return grp; | |
| 413 | − | |
| 414 | − /* Compose the state register settings */ | |
| 415 | − val = grp << TWL6030_CFG_STATE_GRP_SHIFT; | |
| 416 | − /* We can only set the mode through state machine commands... */ | |
| 417 | − switch (mode) { | |
| 418 | − case REGULATOR_MODE_NORMAL: | |
| 419 | − val |= TWL6030_CFG_STATE_ON; | |
| 420 | − break; | |
| 421 | − case REGULATOR_MODE_STANDBY: | |
| 422 | − val |= TWL6030_CFG_STATE_SLEEP; | |
| 423 | − break; | |
| 424 | − | |
| 425 | − default: | |
| 426 | − return -EINVAL; | |
| 427 | − } | |
| 428 | − | |
| 429 | − return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val); | |
| 430 | −} | |
| 431 | − | |
| 432 | 281 | /*----------------------------------------------------------------------*/ |
| 433 | 282 | |
| 434 | 283 | /* |
| @@ -565,12 +414,7 @@ twl4030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, · 130 unmodified lines | ||
| 565 | 414 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 566 | 415 | int vsel = DIV_ROUND_UP(min_uV - 600000, 12500); |
| 567 | 416 | |
| 568 | − if (info->set_voltage) { | |
| 569 | − return info->set_voltage(info->data, min_uV); | |
| 570 | − } else { | |
| 571 | − twlreg_write(info, TWL_MODULE_PM_RECEIVER, | |
| 572 | − VREG_VOLTAGE_SMPS_4030, vsel); | |
| 573 | − } | |
| 417 | + twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS_4030, vsel); | |
| 574 | 418 | |
| 575 | 419 | return 0; |
| 576 | 420 | } |
| @@ -580,9 +424,6 @@ static int twl4030smps_get_voltage(struct regulator_dev *rdev) · 3 unmodified lines | ||
| 580 | 424 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 581 | 425 | int vsel; |
| 582 | 426 | |
| 583 | − if (info->get_voltage) | |
| 584 | − return info->get_voltage(info->data); | |
| 585 | − | |
| 586 | 427 | vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, |
| 587 | 428 | VREG_VOLTAGE_SMPS_4030); |
| 588 | 429 | |
| @@ -594,85 +435,6 @@ static struct regulator_ops twl4030smps_ops = { · 5 unmodified lines | ||
| 594 | 435 | .get_voltage = twl4030smps_get_voltage, |
| 595 | 436 | }; |
| 596 | 437 | |
| 597 | −static int twl6030coresmps_set_voltage(struct regulator_dev *rdev, int min_uV, | |
| 598 | − int max_uV, unsigned *selector) | |
| 599 | −{ | |
| 600 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 601 | − | |
| 602 | − if (info->set_voltage) | |
| 603 | − return info->set_voltage(info->data, min_uV); | |
| 604 | − | |
| 605 | − return -ENODEV; | |
| 606 | −} | |
| 607 | − | |
| 608 | −static int twl6030coresmps_get_voltage(struct regulator_dev *rdev) | |
| 609 | −{ | |
| 610 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 611 | − | |
| 612 | − if (info->get_voltage) | |
| 613 | − return info->get_voltage(info->data); | |
| 614 | − | |
| 615 | − return -ENODEV; | |
| 616 | −} | |
| 617 | − | |
| 618 | −static struct regulator_ops twl6030coresmps_ops = { | |
| 619 | − .set_voltage = twl6030coresmps_set_voltage, | |
| 620 | − .get_voltage = twl6030coresmps_get_voltage, | |
| 621 | −}; | |
| 622 | − | |
| 623 | −static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned sel) | |
| 624 | −{ | |
| 625 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 626 | − | |
| 627 | − switch (sel) { | |
| 628 | − case 0: | |
| 629 | − return 0; | |
| 630 | − case 1 ... 24: | |
| 631 | − /* Linear mapping from 00000001 to 00011000: | |
| 632 | − * Absolute voltage value = 1.0 V + 0.1 V × (sel – 00000001) | |
| 633 | − */ | |
| 634 | − return (info->min_mV + 100 * (sel - 1)) * 1000; | |
| 635 | − case 25 ... 30: | |
| 636 | − return -EINVAL; | |
| 637 | − case 31: | |
| 638 | − return 2750000; | |
| 639 | − default: | |
| 640 | − return -EINVAL; | |
| 641 | − } | |
| 642 | −} | |
| 643 | − | |
| 644 | −static int | |
| 645 | −twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) | |
| 646 | −{ | |
| 647 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 648 | − | |
| 649 | − return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, | |
| 650 | − selector); | |
| 651 | −} | |
| 652 | − | |
| 653 | −static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev) | |
| 654 | −{ | |
| 655 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 656 | − int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE); | |
| 657 | − | |
| 658 | − return vsel; | |
| 659 | −} | |
| 660 | − | |
| 661 | −static struct regulator_ops twl6030ldo_ops = { | |
| 662 | − .list_voltage = twl6030ldo_list_voltage, | |
| 663 | − | |
| 664 | − .set_voltage_sel = twl6030ldo_set_voltage_sel, | |
| 665 | − .get_voltage_sel = twl6030ldo_get_voltage_sel, | |
| 666 | − | |
| 667 | − .enable = twl6030reg_enable, | |
| 668 | − .disable = twl6030reg_disable, | |
| 669 | − .is_enabled = twl6030reg_is_enabled, | |
| 670 | − | |
| 671 | − .set_mode = twl6030reg_set_mode, | |
| 672 | − | |
| 673 | − .get_status = twl6030reg_get_status, | |
| 674 | −}; | |
| 675 | − | |
| 676 | 438 | /*----------------------------------------------------------------------*/ |
| 677 | 439 | |
| 678 | 440 | static struct regulator_ops twl4030fixed_ops = { |
| @@ -687,226 +449,8 @@ static struct regulator_ops twl4030fixed_ops = { · 8 unmodified lines | ||
| 687 | 449 | .get_status = twl4030reg_get_status, |
| 688 | 450 | }; |
| 689 | 451 | |
| 690 | −static struct regulator_ops twl6030fixed_ops = { | |
| 691 | − .list_voltage = regulator_list_voltage_linear, | |
| 692 | − | |
| 693 | − .enable = twl6030reg_enable, | |
| 694 | − .disable = twl6030reg_disable, | |
| 695 | − .is_enabled = twl6030reg_is_enabled, | |
| 696 | − | |
| 697 | − .set_mode = twl6030reg_set_mode, | |
| 698 | − | |
| 699 | − .get_status = twl6030reg_get_status, | |
| 700 | −}; | |
| 701 | − | |
| 702 | −/* | |
| 703 | − * SMPS status and control | |
| 704 | − */ | |
| 705 | − | |
| 706 | −static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index) | |
| 707 | −{ | |
| 708 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 709 | − | |
| 710 | − int voltage = 0; | |
| 711 | − | |
| 712 | − switch (info->flags) { | |
| 713 | − case SMPS_OFFSET_EN: | |
| 714 | − voltage = 100000; | |
| 715 | − /* fall through */ | |
| 716 | − case 0: | |
| 717 | − switch (index) { | |
| 718 | − case 0: | |
| 719 | − voltage = 0; | |
| 720 | − break; | |
| 721 | − case 58: | |
| 722 | − voltage = 1350 * 1000; | |
| 723 | − break; | |
| 724 | − case 59: | |
| 725 | − voltage = 1500 * 1000; | |
| 726 | − break; | |
| 727 | − case 60: | |
| 728 | − voltage = 1800 * 1000; | |
| 729 | − break; | |
| 730 | − case 61: | |
| 731 | − voltage = 1900 * 1000; | |
| 732 | − break; | |
| 733 | − case 62: | |
| 734 | − voltage = 2100 * 1000; | |
| 735 | − break; | |
| 736 | − default: | |
| 737 | − voltage += (600000 + (12500 * (index - 1))); | |
| 738 | − } | |
| 739 | − break; | |
| 740 | − case SMPS_EXTENDED_EN: | |
| 741 | − switch (index) { | |
| 742 | − case 0: | |
| 743 | − voltage = 0; | |
| 744 | − break; | |
| 745 | − case 58: | |
| 746 | − voltage = 2084 * 1000; | |
| 747 | − break; | |
| 748 | − case 59: | |
| 749 | − voltage = 2315 * 1000; | |
| 750 | − break; | |
| 751 | − case 60: | |
| 752 | − voltage = 2778 * 1000; | |
| 753 | − break; | |
| 754 | − case 61: | |
| 755 | − voltage = 2932 * 1000; | |
| 756 | − break; | |
| 757 | − case 62: | |
| 758 | − voltage = 3241 * 1000; | |
| 759 | − break; | |
| 760 | − default: | |
| 761 | − voltage = (1852000 + (38600 * (index - 1))); | |
| 762 | − } | |
| 763 | − break; | |
| 764 | − case SMPS_OFFSET_EN | SMPS_EXTENDED_EN: | |
| 765 | − switch (index) { | |
| 766 | − case 0: | |
| 767 | − voltage = 0; | |
| 768 | − break; | |
| 769 | − case 58: | |
| 770 | − voltage = 4167 * 1000; | |
| 771 | − break; | |
| 772 | − case 59: | |
| 773 | − voltage = 2315 * 1000; | |
| 774 | − break; | |
| 775 | − case 60: | |
| 776 | − voltage = 2778 * 1000; | |
| 777 | − break; | |
| 778 | − case 61: | |
| 779 | − voltage = 2932 * 1000; | |
| 780 | − break; | |
| 781 | − case 62: | |
| 782 | − voltage = 3241 * 1000; | |
| 783 | − break; | |
| 784 | − default: | |
| 785 | − voltage = (2161000 + (38600 * (index - 1))); | |
| 786 | − } | |
| 787 | − break; | |
| 788 | − } | |
| 789 | − | |
| 790 | − return voltage; | |
| 791 | −} | |
| 792 | − | |
| 793 | −static int twl6030smps_map_voltage(struct regulator_dev *rdev, int min_uV, | |
| 794 | − int max_uV) | |
| 795 | −{ | |
| 796 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 797 | − int vsel = 0; | |
| 798 | − | |
| 799 | − switch (info->flags) { | |
| 800 | − case 0: | |
| 801 | − if (min_uV == 0) | |
| 802 | − vsel = 0; | |
| 803 | − else if ((min_uV >= 600000) && (min_uV <= 1300000)) { | |
| 804 | − vsel = DIV_ROUND_UP(min_uV - 600000, 12500); | |
| 805 | − vsel++; | |
| 806 | − } | |
| 807 | − /* Values 1..57 for vsel are linear and can be calculated | |
| 808 | − * values 58..62 are non linear. | |
| 809 | − */ | |
| 810 | − else if ((min_uV > 1900000) && (min_uV <= 2100000)) | |
| 811 | − vsel = 62; | |
| 812 | − else if ((min_uV > 1800000) && (min_uV <= 1900000)) | |
| 813 | − vsel = 61; | |
| 814 | − else if ((min_uV > 1500000) && (min_uV <= 1800000)) | |
| 815 | − vsel = 60; | |
| 816 | − else if ((min_uV > 1350000) && (min_uV <= 1500000)) | |
| 817 | − vsel = 59; | |
| 818 | − else if ((min_uV > 1300000) && (min_uV <= 1350000)) | |
| 819 | − vsel = 58; | |
| 820 | − else | |
| 821 | − return -EINVAL; | |
| 822 | − break; | |
| 823 | − case SMPS_OFFSET_EN: | |
| 824 | − if (min_uV == 0) | |
| 825 | − vsel = 0; | |
| 826 | − else if ((min_uV >= 700000) && (min_uV <= 1420000)) { | |
| 827 | − vsel = DIV_ROUND_UP(min_uV - 700000, 12500); | |
| 828 | − vsel++; | |
| 829 | − } | |
| 830 | − /* Values 1..57 for vsel are linear and can be calculated | |
| 831 | − * values 58..62 are non linear. | |
| 832 | − */ | |
| 833 | − else if ((min_uV > 1900000) && (min_uV <= 2100000)) | |
| 834 | − vsel = 62; | |
| 835 | − else if ((min_uV > 1800000) && (min_uV <= 1900000)) | |
| 836 | − vsel = 61; | |
| 837 | − else if ((min_uV > 1350000) && (min_uV <= 1800000)) | |
| 838 | − vsel = 60; | |
| 839 | − else if ((min_uV > 1350000) && (min_uV <= 1500000)) | |
| 840 | − vsel = 59; | |
| 841 | − else if ((min_uV > 1300000) && (min_uV <= 1350000)) | |
| 842 | − vsel = 58; | |
| 843 | − else | |
| 844 | − return -EINVAL; | |
| 845 | − break; | |
| 846 | − case SMPS_EXTENDED_EN: | |
| 847 | − if (min_uV == 0) { | |
| 848 | − vsel = 0; | |
| 849 | − } else if ((min_uV >= 1852000) && (max_uV <= 4013600)) { | |
| 850 | − vsel = DIV_ROUND_UP(min_uV - 1852000, 38600); | |
| 851 | − vsel++; | |
| 852 | − } | |
| 853 | − break; | |
| 854 | − case SMPS_OFFSET_EN|SMPS_EXTENDED_EN: | |
| 855 | − if (min_uV == 0) { | |
| 856 | − vsel = 0; | |
| 857 | − } else if ((min_uV >= 2161000) && (min_uV <= 4321000)) { | |
| 858 | − vsel = DIV_ROUND_UP(min_uV - 2161000, 38600); | |
| 859 | − vsel++; | |
| 860 | − } | |
| 861 | − break; | |
| 862 | − } | |
| 863 | − | |
| 864 | − return vsel; | |
| 865 | −} | |
| 866 | − | |
| 867 | −static int twl6030smps_set_voltage_sel(struct regulator_dev *rdev, | |
| 868 | − unsigned int selector) | |
| 869 | −{ | |
| 870 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 871 | − | |
| 872 | − return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS, | |
| 873 | − selector); | |
| 874 | −} | |
| 875 | − | |
| 876 | −static int twl6030smps_get_voltage_sel(struct regulator_dev *rdev) | |
| 877 | −{ | |
| 878 | − struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 879 | − | |
| 880 | − return twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS); | |
| 881 | −} | |
| 882 | − | |
| 883 | −static struct regulator_ops twlsmps_ops = { | |
| 884 | − .list_voltage = twl6030smps_list_voltage, | |
| 885 | − .map_voltage = twl6030smps_map_voltage, | |
| 886 | − | |
| 887 | − .set_voltage_sel = twl6030smps_set_voltage_sel, | |
| 888 | − .get_voltage_sel = twl6030smps_get_voltage_sel, | |
| 889 | − | |
| 890 | − .enable = twl6030reg_enable, | |
| 891 | − .disable = twl6030reg_disable, | |
| 892 | − .is_enabled = twl6030reg_is_enabled, | |
| 893 | − | |
| 894 | − .set_mode = twl6030reg_set_mode, | |
| 895 | − | |
| 896 | − .get_status = twl6030reg_get_status, | |
| 897 | −}; | |
| 898 | − | |
| 899 | 452 | /*----------------------------------------------------------------------*/ |
| 900 | 453 | |
| 901 | −#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | |
| 902 | − remap_conf) \ | |
| 903 | − TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | |
| 904 | − remap_conf, TWL4030, twl4030fixed_ops, \ | |
| 905 | − twl4030reg_map_mode) | |
| 906 | −#define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \ | |
| 907 | − TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \ | |
| 908 | − 0x0, TWL6030, twl6030fixed_ops, NULL) | |
| 909 | − | |
| 910 | 454 | #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \ |
| 911 | 455 | static const struct twlreg_info TWL4030_INFO_##label = { \ |
| 912 | 456 | .base = offset, \ |
| @@ -942,79 +486,22 @@ static const struct twlreg_info TWL4030_INFO_##label = { \ · 29 unmodified lines | ||
| 942 | 486 | }, \ |
| 943 | 487 | } |
| 944 | 488 | |
| 945 | −#define TWL6030_ADJUSTABLE_SMPS(label) \ | |
| 946 | −static const struct twlreg_info TWL6030_INFO_##label = { \ | |
| 947 | − .desc = { \ | |
| 948 | − .name = #label, \ | |
| 949 | − .id = TWL6030_REG_##label, \ | |
| 950 | − .ops = &twl6030coresmps_ops, \ | |
| 951 | − .type = REGULATOR_VOLTAGE, \ | |
| 952 | − .owner = THIS_MODULE, \ | |
| 953 | − }, \ | |
| 954 | − } | |
| 955 | − | |
| 956 | −#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \ | |
| 957 | −static const struct twlreg_info TWL6030_INFO_##label = { \ | |
| 958 | − .base = offset, \ | |
| 959 | − .min_mV = min_mVolts, \ | |
| 960 | − .max_mV = max_mVolts, \ | |
| 961 | − .desc = { \ | |
| 962 | − .name = #label, \ | |
| 963 | − .id = TWL6030_REG_##label, \ | |
| 964 | − .n_voltages = 32, \ | |
| 965 | − .ops = &twl6030ldo_ops, \ | |
| 966 | − .type = REGULATOR_VOLTAGE, \ | |
| 967 | − .owner = THIS_MODULE, \ | |
| 968 | − }, \ | |
| 969 | − } | |
| 970 | − | |
| 971 | −#define TWL6032_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \ | |
| 972 | −static const struct twlreg_info TWL6032_INFO_##label = { \ | |
| 973 | − .base = offset, \ | |
| 974 | − .min_mV = min_mVolts, \ | |
| 975 | − .max_mV = max_mVolts, \ | |
| 976 | − .desc = { \ | |
| 977 | − .name = #label, \ | |
| 978 | − .id = TWL6032_REG_##label, \ | |
| 979 | − .n_voltages = 32, \ | |
| 980 | − .ops = &twl6030ldo_ops, \ | |
| 981 | − .type = REGULATOR_VOLTAGE, \ | |
| 982 | − .owner = THIS_MODULE, \ | |
| 983 | − }, \ | |
| 984 | − } | |
| 985 | − | |
| 986 | −#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ | |
| 987 | − family, operations, map_mode) \ | |
| 489 | +#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | |
| 490 | + remap_conf) \ | |
| 988 | 491 | static const struct twlreg_info TWLFIXED_INFO_##label = { \ |
| 989 | 492 | .base = offset, \ |
| 990 | 493 | .id = num, \ |
| 991 | − .min_mV = mVolts, \ | |
| 992 | 494 | .remap = remap_conf, \ |
| 993 | 495 | .desc = { \ |
| 994 | 496 | .name = #label, \ |
| 995 | − .id = family##_REG_##label, \ | |
| 497 | + .id = TWL4030##_REG_##label, \ | |
| 996 | 498 | .n_voltages = 1, \ |
| 997 | − .ops = &operations, \ | |
| 499 | + .ops = &twl4030fixed_ops, \ | |
| 998 | 500 | .type = REGULATOR_VOLTAGE, \ |
| 999 | 501 | .owner = THIS_MODULE, \ |
| 1000 | 502 | .min_uV = mVolts * 1000, \ |
| 1001 | 503 | .enable_time = turnon_delay, \ |
| 1002 | − .of_map_mode = map_mode, \ | |
| 1003 | − }, \ | |
| 1004 | − } | |
| 1005 | − | |
| 1006 | −#define TWL6032_ADJUSTABLE_SMPS(label, offset) \ | |
| 1007 | −static const struct twlreg_info TWLSMPS_INFO_##label = { \ | |
| 1008 | − .base = offset, \ | |
| 1009 | − .min_mV = 600, \ | |
| 1010 | − .max_mV = 2100, \ | |
| 1011 | − .desc = { \ | |
| 1012 | − .name = #label, \ | |
| 1013 | − .id = TWL6032_REG_##label, \ | |
| 1014 | − .n_voltages = 63, \ | |
| 1015 | − .ops = &twlsmps_ops, \ | |
| 1016 | − .type = REGULATOR_VOLTAGE, \ | |
| 1017 | − .owner = THIS_MODULE, \ | |
| 504 | + .of_map_mode = twl4030reg_map_mode, \ | |
| 1018 | 505 | }, \ |
| 1019 | 506 | } |
| 1020 | 507 | |
| @@ -1038,60 +525,11 @@ TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08); · 17 unmodified lines | ||
| 1038 | 525 | TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08); |
| 1039 | 526 | TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08); |
| 1040 | 527 | /* VUSBCP is managed *only* by the USB subchip */ |
| 1041 | −/* 6030 REG with base as PMC Slave Misc : 0x0030 */ | |
| 1042 | −/* Turnon-delay and remap configuration values for 6030 are not | |
| 1043 | − verified since the specification is not public */ | |
| 1044 | −TWL6030_ADJUSTABLE_SMPS(VDD1); | |
| 1045 | −TWL6030_ADJUSTABLE_SMPS(VDD2); | |
| 1046 | −TWL6030_ADJUSTABLE_SMPS(VDD3); | |
| 1047 | −TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300); | |
| 1048 | −TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300); | |
| 1049 | −TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300); | |
| 1050 | −TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300); | |
| 1051 | −TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300); | |
| 1052 | −TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300); | |
| 1053 | −/* 6025 are renamed compared to 6030 versions */ | |
| 1054 | −TWL6032_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300); | |
| 1055 | −TWL6032_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300); | |
| 1056 | −TWL6032_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300); | |
| 1057 | −TWL6032_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300); | |
| 1058 | −TWL6032_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300); | |
| 1059 | −TWL6032_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300); | |
| 1060 | −TWL6032_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300); | |
| 1061 | −TWL6032_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300); | |
| 1062 | −TWL6032_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300); | |
| 1063 | 528 | TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08); |
| 1064 | 529 | TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08); |
| 1065 | 530 | TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08); |
| 1066 | 531 | TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08); |
| 1067 | 532 | TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08); |
| 1068 | −TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0); | |
| 1069 | −TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0); | |
| 1070 | −TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0); | |
| 1071 | −TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0); | |
| 1072 | −TWL6030_FIXED_LDO(V1V8, 0x16, 1800, 0); | |
| 1073 | −TWL6030_FIXED_LDO(V2V1, 0x1c, 2100, 0); | |
| 1074 | −TWL6032_ADJUSTABLE_SMPS(SMPS3, 0x34); | |
| 1075 | −TWL6032_ADJUSTABLE_SMPS(SMPS4, 0x10); | |
| 1076 | −TWL6032_ADJUSTABLE_SMPS(VIO, 0x16); | |
| 1077 | − | |
| 1078 | −static u8 twl_get_smps_offset(void) | |
| 1079 | −{ | |
| 1080 | − u8 value; | |
| 1081 | − | |
| 1082 | − twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value, | |
| 1083 | − TWL6030_SMPS_OFFSET); | |
| 1084 | − return value; | |
| 1085 | −} | |
| 1086 | − | |
| 1087 | −static u8 twl_get_smps_mult(void) | |
| 1088 | −{ | |
| 1089 | − u8 value; | |
| 1090 | − | |
| 1091 | − twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value, | |
| 1092 | − TWL6030_SMPS_MULT); | |
| 1093 | − return value; | |
| 1094 | −} | |
| 1095 | 533 | |
| 1096 | 534 | #define TWL_OF_MATCH(comp, family, label) \ |
| 1097 | 535 | { \ |
| @@ -1121,81 +559,37 @@ static const struct of_device_id twl_of_match[] = { · 23 unmodified lines | ||
| 1121 | 559 | TWL4030_OF_MATCH("ti,twl4030-vio", VIO), |
| 1122 | 560 | TWL4030_OF_MATCH("ti,twl4030-vdd1", VDD1), |
| 1123 | 561 | TWL4030_OF_MATCH("ti,twl4030-vdd2", VDD2), |
| 1124 | − TWL6030_OF_MATCH("ti,twl6030-vdd1", VDD1), | |
| 1125 | − TWL6030_OF_MATCH("ti,twl6030-vdd2", VDD2), | |
| 1126 | − TWL6030_OF_MATCH("ti,twl6030-vdd3", VDD3), | |
| 1127 | − TWL6030_OF_MATCH("ti,twl6030-vaux1", VAUX1_6030), | |
| 1128 | − TWL6030_OF_MATCH("ti,twl6030-vaux2", VAUX2_6030), | |
| 1129 | − TWL6030_OF_MATCH("ti,twl6030-vaux3", VAUX3_6030), | |
| 1130 | − TWL6030_OF_MATCH("ti,twl6030-vmmc", VMMC), | |
| 1131 | − TWL6030_OF_MATCH("ti,twl6030-vpp", VPP), | |
| 1132 | − TWL6030_OF_MATCH("ti,twl6030-vusim", VUSIM), | |
| 1133 | − TWL6032_OF_MATCH("ti,twl6032-ldo2", LDO2), | |
| 1134 | − TWL6032_OF_MATCH("ti,twl6032-ldo4", LDO4), | |
| 1135 | − TWL6032_OF_MATCH("ti,twl6032-ldo3", LDO3), | |
| 1136 | − TWL6032_OF_MATCH("ti,twl6032-ldo5", LDO5), | |
| 1137 | − TWL6032_OF_MATCH("ti,twl6032-ldo1", LDO1), | |
| 1138 | − TWL6032_OF_MATCH("ti,twl6032-ldo7", LDO7), | |
| 1139 | − TWL6032_OF_MATCH("ti,twl6032-ldo6", LDO6), | |
| 1140 | − TWL6032_OF_MATCH("ti,twl6032-ldoln", LDOLN), | |
| 1141 | − TWL6032_OF_MATCH("ti,twl6032-ldousb", LDOUSB), | |
| 1142 | 562 | TWLFIXED_OF_MATCH("ti,twl4030-vintana1", VINTANA1), |
| 1143 | 563 | TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG), |
| 1144 | 564 | TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5), |
| 1145 | 565 | TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8), |
| 1146 | 566 | TWLFIXED_OF_MATCH("ti,twl4030-vusb3v1", VUSB3V1), |
| 1147 | − TWLFIXED_OF_MATCH("ti,twl6030-vana", VANA), | |
| 1148 | − TWLFIXED_OF_MATCH("ti,twl6030-vcxio", VCXIO), | |
| 1149 | − TWLFIXED_OF_MATCH("ti,twl6030-vdac", VDAC), | |
| 1150 | − TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB), | |
| 1151 | − TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8), | |
| 1152 | − TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1), | |
| 1153 | − TWLSMPS_OF_MATCH("ti,twl6032-smps3", SMPS3), | |
| 1154 | − TWLSMPS_OF_MATCH("ti,twl6032-smps4", SMPS4), | |
| 1155 | − TWLSMPS_OF_MATCH("ti,twl6032-vio", VIO), | |
| 1156 | 567 | {}, |
| 1157 | 568 | }; |
| 1158 | 569 | MODULE_DEVICE_TABLE(of, twl_of_match); |
| 1159 | 570 | |
| 1160 | 571 | static int twlreg_probe(struct platform_device *pdev) |
| 1161 | 572 | { |
| 1162 | − int i, id; | |
| 573 | + int id; | |
| 1163 | 574 | struct twlreg_info *info; |
| 1164 | 575 | const struct twlreg_info *template; |
| 1165 | 576 | struct regulator_init_data *initdata; |
| 1166 | 577 | struct regulation_constraints *c; |
| 1167 | 578 | struct regulator_dev *rdev; |
| 1168 | − struct twl_regulator_driver_data *drvdata; | |
| 1169 | 579 | const struct of_device_id *match; |
| 1170 | 580 | struct regulator_config config = { }; |
| 1171 | 581 | |
| 1172 | 582 | match = of_match_device(twl_of_match, &pdev->dev); |
| 1173 | − if (match) { | |
| 1174 | − template = match->data; | |
| 1175 | − id = template->desc.id; | |
| 1176 | − initdata = of_get_regulator_init_data(&pdev->dev, | |
| 1177 | − pdev->dev.of_node, | |
| 1178 | − &template->desc); | |
| 1179 | − drvdata = NULL; | |
| 1180 | − } else { | |
| 1181 | − id = pdev->id; | |
| 1182 | − initdata = dev_get_platdata(&pdev->dev); | |
| 1183 | − for (i = 0, template = NULL; i < ARRAY_SIZE(twl_of_match); i++) { | |
| 1184 | − template = twl_of_match[i].data; | |
| 1185 | − if (template && template->desc.id == id) | |
| 1186 | − break; | |
| 1187 | − } | |
| 1188 | − if (i == ARRAY_SIZE(twl_of_match)) | |
| 1189 | − return -ENODEV; | |
| 1190 | − | |
| 1191 | − drvdata = initdata->driver_data; | |
| 1192 | − if (!drvdata) | |
| 1193 | − return -EINVAL; | |
| 1194 | − } | |
| 583 | + if (!match) | |
| 584 | + return -ENODEV; | |
| 1195 | 585 | |
| 586 | + template = match->data; | |
| 1196 | 587 | if (!template) |
| 1197 | 588 | return -ENODEV; |
| 1198 | 589 | |
| 590 | + id = template->desc.id; | |
| 591 | + initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, | |
| 592 | + &template->desc); | |
| 1199 | 593 | if (!initdata) |
| 1200 | 594 | return -EINVAL; |
| 1201 | 595 | |
| @@ -1203,14 +597,6 @@ static int twlreg_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 1203 | 597 | if (!info) |
| 1204 | 598 | return -ENOMEM; |
| 1205 | 599 | |
| 1206 | − if (drvdata) { | |
| 1207 | − /* copy the driver data into regulator data */ | |
| 1208 | − info->features = drvdata->features; | |
| 1209 | − info->data = drvdata->data; | |
| 1210 | − info->set_voltage = drvdata->set_voltage; | |
| 1211 | − info->get_voltage = drvdata->get_voltage; | |
| 1212 | − } | |
| 1213 | − | |
| 1214 | 600 | /* Constrain board-specific capabilities according to what |
| 1215 | 601 | * this driver and the chip itself can actually do. |
| 1216 | 602 | */ |
| @@ -1233,27 +619,6 @@ static int twlreg_probe(struct platform_device *pdev) · 16 unmodified lines | ||
| 1233 | 619 | break; |
| 1234 | 620 | } |
| 1235 | 621 | |
| 1236 | − switch (id) { | |
| 1237 | − case TWL6032_REG_SMPS3: | |
| 1238 | − if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3) | |
| 1239 | − info->flags |= SMPS_EXTENDED_EN; | |
| 1240 | − if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS3) | |
| 1241 | − info->flags |= SMPS_OFFSET_EN; | |
| 1242 | − break; | |
| 1243 | − case TWL6032_REG_SMPS4: | |
| 1244 | − if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS4) | |
| 1245 | − info->flags |= SMPS_EXTENDED_EN; | |
| 1246 | − if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS4) | |
| 1247 | − info->flags |= SMPS_OFFSET_EN; | |
| 1248 | − break; | |
| 1249 | − case TWL6032_REG_VIO: | |
| 1250 | − if (twl_get_smps_mult() & SMPS_MULTOFFSET_VIO) | |
| 1251 | − info->flags |= SMPS_EXTENDED_EN; | |
| 1252 | − if (twl_get_smps_offset() & SMPS_MULTOFFSET_VIO) | |
| 1253 | − info->flags |= SMPS_OFFSET_EN; | |
| 1254 | − break; | |
| 1255 | − } | |
| 1256 | − | |
| 1257 | 622 | config.dev = &pdev->dev; |
| 1258 | 623 | config.init_data = initdata; |
| 1259 | 624 | config.driver_data = info; |
| @@ -1267,9 +632,7 @@ static int twlreg_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 1267 | 632 | } |
| 1268 | 633 | platform_set_drvdata(pdev, rdev); |
| 1269 | 634 | |
| 1270 | − if (twl_class_is_4030()) | |
| 1271 | − twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP, | |
| 1272 | − info->remap); | |
| 635 | + twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP, info->remap); | |
| 1273 | 636 | |
| 1274 | 637 | /* NOTE: many regulators support short-circuit IRQs (presentable |
| 1275 | 638 | * as REGULATOR_OVER_CURRENT notifications?) configured via: |
| @@ -1282,7 +645,7 @@ static int twlreg_probe(struct platform_device *pdev) · 6 unmodified lines | ||
| 1282 | 645 | return 0; |
| 1283 | 646 | } |
| 1284 | 647 | |
| 1285 | −MODULE_ALIAS("platform:twl_reg"); | |
| 648 | +MODULE_ALIAS("platform:twl4030_reg"); | |
| 1286 | 649 | |
| 1287 | 650 | static struct platform_driver twlreg_driver = { |
| 1288 | 651 | .probe = twlreg_probe, |
| @@ -1290,7 +653,7 @@ static struct platform_driver twlreg_driver = { · 1 unmodified line | ||
| 1290 | 653 | * "twl_regulator.12" (and friends) to "twl_regulator.1". |
| 1291 | 654 | */ |
| 1292 | 655 | .driver = { |
| 1293 | − .name = "twl_reg", | |
| 656 | + .name = "twl4030_reg", | |
| 1294 | 657 | .of_match_table = of_match_ptr(twl_of_match), |
| 1295 | 658 | }, |
| 1296 | 659 | }; |
| @@ -1307,5 +670,5 @@ static void __exit twlreg_exit(void) · 10 unmodified lines | ||
| 1307 | 670 | } |
| 1308 | 671 | module_exit(twlreg_exit) |
| 1309 | 672 | |
| 1310 | −MODULE_DESCRIPTION("TWL regulator driver"); | |
| 673 | +MODULE_DESCRIPTION("TWL4030 regulator driver"); | |
| 1311 | 674 | MODULE_LICENSE("GPL"); |
| @@ -0,0 +1,793 @@ | ||
| 1 | +/* | |
| 2 | + * Split TWL6030 logic from twl-regulator.c: | |
| 3 | + * Copyright (C) 2008 David Brownell | |
| 4 | + * | |
| 5 | + * Copyright (C) 2016 Nicolae Rosia <nicolae.rosia@gmail.com> | |
| 6 | + * | |
| 7 | + * This program is free software; you can redistribute it and/or modify | |
| 8 | + * it under the terms of the GNU General Public License as published by | |
| 9 | + * the Free Software Foundation; either version 2 of the License, or | |
| 10 | + * (at your option) any later version. | |
| 11 | + */ | |
| 12 | + | |
| 13 | +#include <linux/module.h> | |
| 14 | +#include <linux/string.h> | |
| 15 | +#include <linux/slab.h> | |
| 16 | +#include <linux/init.h> | |
| 17 | +#include <linux/err.h> | |
| 18 | +#include <linux/platform_device.h> | |
| 19 | +#include <linux/of.h> | |
| 20 | +#include <linux/of_device.h> | |
| 21 | +#include <linux/regulator/driver.h> | |
| 22 | +#include <linux/regulator/machine.h> | |
| 23 | +#include <linux/regulator/of_regulator.h> | |
| 24 | +#include <linux/i2c/twl.h> | |
| 25 | +#include <linux/delay.h> | |
| 26 | + | |
| 27 | +struct twlreg_info { | |
| 28 | + /* start of regulator's PM_RECEIVER control register bank */ | |
| 29 | + u8 base; | |
| 30 | + | |
| 31 | + /* twl resource ID, for resource control state machine */ | |
| 32 | + u8 id; | |
| 33 | + | |
| 34 | + /* chip constraints on regulator behavior */ | |
| 35 | + u16 min_mV; | |
| 36 | + | |
| 37 | + u8 flags; | |
| 38 | + | |
| 39 | + /* used by regulator core */ | |
| 40 | + struct regulator_desc desc; | |
| 41 | + | |
| 42 | + /* chip specific features */ | |
| 43 | + unsigned long features; | |
| 44 | + | |
| 45 | + /* data passed from board for external get/set voltage */ | |
| 46 | + void *data; | |
| 47 | +}; | |
| 48 | + | |
| 49 | + | |
| 50 | +/* LDO control registers ... offset is from the base of its register bank. | |
| 51 | + * The first three registers of all power resource banks help hardware to | |
| 52 | + * manage the various resource groups. | |
| 53 | + */ | |
| 54 | +/* Common offset in TWL4030/6030 */ | |
| 55 | +#define VREG_GRP 0 | |
| 56 | +/* TWL6030 register offsets */ | |
| 57 | +#define VREG_TRANS 1 | |
| 58 | +#define VREG_STATE 2 | |
| 59 | +#define VREG_VOLTAGE 3 | |
| 60 | +#define VREG_VOLTAGE_SMPS 4 | |
| 61 | +/* TWL6030 Misc register offsets */ | |
| 62 | +#define VREG_BC_ALL 1 | |
| 63 | +#define VREG_BC_REF 2 | |
| 64 | +#define VREG_BC_PROC 3 | |
| 65 | +#define VREG_BC_CLK_RST 4 | |
| 66 | + | |
| 67 | +/* TWL6030 LDO register values for CFG_STATE */ | |
| 68 | +#define TWL6030_CFG_STATE_OFF 0x00 | |
| 69 | +#define TWL6030_CFG_STATE_ON 0x01 | |
| 70 | +#define TWL6030_CFG_STATE_OFF2 0x02 | |
| 71 | +#define TWL6030_CFG_STATE_SLEEP 0x03 | |
| 72 | +#define TWL6030_CFG_STATE_GRP_SHIFT 5 | |
| 73 | +#define TWL6030_CFG_STATE_APP_SHIFT 2 | |
| 74 | +#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT) | |
| 75 | +#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\ | |
| 76 | + TWL6030_CFG_STATE_APP_SHIFT) | |
| 77 | + | |
| 78 | +/* Flags for SMPS Voltage reading */ | |
| 79 | +#define SMPS_OFFSET_EN BIT(0) | |
| 80 | +#define SMPS_EXTENDED_EN BIT(1) | |
| 81 | + | |
| 82 | +/* twl6032 SMPS EPROM values */ | |
| 83 | +#define TWL6030_SMPS_OFFSET 0xB0 | |
| 84 | +#define TWL6030_SMPS_MULT 0xB3 | |
| 85 | +#define SMPS_MULTOFFSET_SMPS4 BIT(0) | |
| 86 | +#define SMPS_MULTOFFSET_VIO BIT(1) | |
| 87 | +#define SMPS_MULTOFFSET_SMPS3 BIT(6) | |
| 88 | + | |
| 89 | +static inline int | |
| 90 | +twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) | |
| 91 | +{ | |
| 92 | + u8 value; | |
| 93 | + int status; | |
| 94 | + | |
| 95 | + status = twl_i2c_read_u8(slave_subgp, | |
| 96 | + &value, info->base + offset); | |
| 97 | + return (status < 0) ? status : value; | |
| 98 | +} | |
| 99 | + | |
| 100 | +static inline int | |
| 101 | +twlreg_write(struct twlreg_info *info, unsigned slave_subgp, unsigned offset, | |
| 102 | + u8 value) | |
| 103 | +{ | |
| 104 | + return twl_i2c_write_u8(slave_subgp, | |
| 105 | + value, info->base + offset); | |
| 106 | +} | |
| 107 | + | |
| 108 | +/* generic power resource operations, which work on all regulators */ | |
| 109 | +static int twlreg_grp(struct regulator_dev *rdev) | |
| 110 | +{ | |
| 111 | + return twlreg_read(rdev_get_drvdata(rdev), TWL_MODULE_PM_RECEIVER, | |
| 112 | + VREG_GRP); | |
| 113 | +} | |
| 114 | + | |
| 115 | +/* | |
| 116 | + * Enable/disable regulators by joining/leaving the P1 (processor) group. | |
| 117 | + * We assume nobody else is updating the DEV_GRP registers. | |
| 118 | + */ | |
| 119 | +/* definition for 6030 family */ | |
| 120 | +#define P3_GRP_6030 BIT(2) /* secondary processor, modem, etc */ | |
| 121 | +#define P2_GRP_6030 BIT(1) /* "peripherals" */ | |
| 122 | +#define P1_GRP_6030 BIT(0) /* CPU/Linux */ | |
| 123 | + | |
| 124 | +static int twl6030reg_is_enabled(struct regulator_dev *rdev) | |
| 125 | +{ | |
| 126 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 127 | + int grp = 0, val; | |
| 128 | + | |
| 129 | + if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) { | |
| 130 | + grp = twlreg_grp(rdev); | |
| 131 | + if (grp < 0) | |
| 132 | + return grp; | |
| 133 | + grp &= P1_GRP_6030; | |
| 134 | + } else { | |
| 135 | + grp = 1; | |
| 136 | + } | |
| 137 | + | |
| 138 | + val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); | |
| 139 | + val = TWL6030_CFG_STATE_APP(val); | |
| 140 | + | |
| 141 | + return grp && (val == TWL6030_CFG_STATE_ON); | |
| 142 | +} | |
| 143 | + | |
| 144 | +#define PB_I2C_BUSY BIT(0) | |
| 145 | +#define PB_I2C_BWEN BIT(1) | |
| 146 | + | |
| 147 | + | |
| 148 | +static int twl6030reg_enable(struct regulator_dev *rdev) | |
| 149 | +{ | |
| 150 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 151 | + int grp = 0; | |
| 152 | + int ret; | |
| 153 | + | |
| 154 | + if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | |
| 155 | + grp = twlreg_grp(rdev); | |
| 156 | + if (grp < 0) | |
| 157 | + return grp; | |
| 158 | + | |
| 159 | + ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, | |
| 160 | + grp << TWL6030_CFG_STATE_GRP_SHIFT | | |
| 161 | + TWL6030_CFG_STATE_ON); | |
| 162 | + return ret; | |
| 163 | +} | |
| 164 | + | |
| 165 | +static int twl6030reg_disable(struct regulator_dev *rdev) | |
| 166 | +{ | |
| 167 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 168 | + int grp = 0; | |
| 169 | + int ret; | |
| 170 | + | |
| 171 | + if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | |
| 172 | + grp = P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030; | |
| 173 | + | |
| 174 | + /* For 6030, set the off state for all grps enabled */ | |
| 175 | + ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, | |
| 176 | + (grp) << TWL6030_CFG_STATE_GRP_SHIFT | | |
| 177 | + TWL6030_CFG_STATE_OFF); | |
| 178 | + | |
| 179 | + return ret; | |
| 180 | +} | |
| 181 | + | |
| 182 | +static int twl6030reg_get_status(struct regulator_dev *rdev) | |
| 183 | +{ | |
| 184 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 185 | + int val; | |
| 186 | + | |
| 187 | + val = twlreg_grp(rdev); | |
| 188 | + if (val < 0) | |
| 189 | + return val; | |
| 190 | + | |
| 191 | + val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); | |
| 192 | + | |
| 193 | + switch (TWL6030_CFG_STATE_APP(val)) { | |
| 194 | + case TWL6030_CFG_STATE_ON: | |
| 195 | + return REGULATOR_STATUS_NORMAL; | |
| 196 | + | |
| 197 | + case TWL6030_CFG_STATE_SLEEP: | |
| 198 | + return REGULATOR_STATUS_STANDBY; | |
| 199 | + | |
| 200 | + case TWL6030_CFG_STATE_OFF: | |
| 201 | + case TWL6030_CFG_STATE_OFF2: | |
| 202 | + default: | |
| 203 | + break; | |
| 204 | + } | |
| 205 | + | |
| 206 | + return REGULATOR_STATUS_OFF; | |
| 207 | +} | |
| 208 | + | |
| 209 | +static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode) | |
| 210 | +{ | |
| 211 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 212 | + int grp = 0; | |
| 213 | + int val; | |
| 214 | + | |
| 215 | + if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | |
| 216 | + grp = twlreg_grp(rdev); | |
| 217 | + | |
| 218 | + if (grp < 0) | |
| 219 | + return grp; | |
| 220 | + | |
| 221 | + /* Compose the state register settings */ | |
| 222 | + val = grp << TWL6030_CFG_STATE_GRP_SHIFT; | |
| 223 | + /* We can only set the mode through state machine commands... */ | |
| 224 | + switch (mode) { | |
| 225 | + case REGULATOR_MODE_NORMAL: | |
| 226 | + val |= TWL6030_CFG_STATE_ON; | |
| 227 | + break; | |
| 228 | + case REGULATOR_MODE_STANDBY: | |
| 229 | + val |= TWL6030_CFG_STATE_SLEEP; | |
| 230 | + break; | |
| 231 | + | |
| 232 | + default: | |
| 233 | + return -EINVAL; | |
| 234 | + } | |
| 235 | + | |
| 236 | + return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val); | |
| 237 | +} | |
| 238 | + | |
| 239 | +static int twl6030coresmps_set_voltage(struct regulator_dev *rdev, int min_uV, | |
| 240 | + int max_uV, unsigned *selector) | |
| 241 | +{ | |
| 242 | + return -ENODEV; | |
| 243 | +} | |
| 244 | + | |
| 245 | +static int twl6030coresmps_get_voltage(struct regulator_dev *rdev) | |
| 246 | +{ | |
| 247 | + return -ENODEV; | |
| 248 | +} | |
| 249 | + | |
| 250 | +static struct regulator_ops twl6030coresmps_ops = { | |
| 251 | + .set_voltage = twl6030coresmps_set_voltage, | |
| 252 | + .get_voltage = twl6030coresmps_get_voltage, | |
| 253 | +}; | |
| 254 | + | |
| 255 | +static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned sel) | |
| 256 | +{ | |
| 257 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 258 | + | |
| 259 | + switch (sel) { | |
| 260 | + case 0: | |
| 261 | + return 0; | |
| 262 | + case 1 ... 24: | |
| 263 | + /* Linear mapping from 00000001 to 00011000: | |
| 264 | + * Absolute voltage value = 1.0 V + 0.1 V × (sel – 00000001) | |
| 265 | + */ | |
| 266 | + return (info->min_mV + 100 * (sel - 1)) * 1000; | |
| 267 | + case 25 ... 30: | |
| 268 | + return -EINVAL; | |
| 269 | + case 31: | |
| 270 | + return 2750000; | |
| 271 | + default: | |
| 272 | + return -EINVAL; | |
| 273 | + } | |
| 274 | +} | |
| 275 | + | |
| 276 | +static int | |
| 277 | +twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) | |
| 278 | +{ | |
| 279 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 280 | + | |
| 281 | + return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, | |
| 282 | + selector); | |
| 283 | +} | |
| 284 | + | |
| 285 | +static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev) | |
| 286 | +{ | |
| 287 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 288 | + int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE); | |
| 289 | + | |
| 290 | + return vsel; | |
| 291 | +} | |
| 292 | + | |
| 293 | +static struct regulator_ops twl6030ldo_ops = { | |
| 294 | + .list_voltage = twl6030ldo_list_voltage, | |
| 295 | + | |
| 296 | + .set_voltage_sel = twl6030ldo_set_voltage_sel, | |
| 297 | + .get_voltage_sel = twl6030ldo_get_voltage_sel, | |
| 298 | + | |
| 299 | + .enable = twl6030reg_enable, | |
| 300 | + .disable = twl6030reg_disable, | |
| 301 | + .is_enabled = twl6030reg_is_enabled, | |
| 302 | + | |
| 303 | + .set_mode = twl6030reg_set_mode, | |
| 304 | + | |
| 305 | + .get_status = twl6030reg_get_status, | |
| 306 | +}; | |
| 307 | + | |
| 308 | +static struct regulator_ops twl6030fixed_ops = { | |
| 309 | + .list_voltage = regulator_list_voltage_linear, | |
| 310 | + | |
| 311 | + .enable = twl6030reg_enable, | |
| 312 | + .disable = twl6030reg_disable, | |
| 313 | + .is_enabled = twl6030reg_is_enabled, | |
| 314 | + | |
| 315 | + .set_mode = twl6030reg_set_mode, | |
| 316 | + | |
| 317 | + .get_status = twl6030reg_get_status, | |
| 318 | +}; | |
| 319 | + | |
| 320 | +/* | |
| 321 | + * SMPS status and control | |
| 322 | + */ | |
| 323 | + | |
| 324 | +static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index) | |
| 325 | +{ | |
| 326 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 327 | + | |
| 328 | + int voltage = 0; | |
| 329 | + | |
| 330 | + switch (info->flags) { | |
| 331 | + case SMPS_OFFSET_EN: | |
| 332 | + voltage = 100000; | |
| 333 | + /* fall through */ | |
| 334 | + case 0: | |
| 335 | + switch (index) { | |
| 336 | + case 0: | |
| 337 | + voltage = 0; | |
| 338 | + break; | |
| 339 | + case 58: | |
| 340 | + voltage = 1350 * 1000; | |
| 341 | + break; | |
| 342 | + case 59: | |
| 343 | + voltage = 1500 * 1000; | |
| 344 | + break; | |
| 345 | + case 60: | |
| 346 | + voltage = 1800 * 1000; | |
| 347 | + break; | |
| 348 | + case 61: | |
| 349 | + voltage = 1900 * 1000; | |
| 350 | + break; | |
| 351 | + case 62: | |
| 352 | + voltage = 2100 * 1000; | |
| 353 | + break; | |
| 354 | + default: | |
| 355 | + voltage += (600000 + (12500 * (index - 1))); | |
| 356 | + } | |
| 357 | + break; | |
| 358 | + case SMPS_EXTENDED_EN: | |
| 359 | + switch (index) { | |
| 360 | + case 0: | |
| 361 | + voltage = 0; | |
| 362 | + break; | |
| 363 | + case 58: | |
| 364 | + voltage = 2084 * 1000; | |
| 365 | + break; | |
| 366 | + case 59: | |
| 367 | + voltage = 2315 * 1000; | |
| 368 | + break; | |
| 369 | + case 60: | |
| 370 | + voltage = 2778 * 1000; | |
| 371 | + break; | |
| 372 | + case 61: | |
| 373 | + voltage = 2932 * 1000; | |
| 374 | + break; | |
| 375 | + case 62: | |
| 376 | + voltage = 3241 * 1000; | |
| 377 | + break; | |
| 378 | + default: | |
| 379 | + voltage = (1852000 + (38600 * (index - 1))); | |
| 380 | + } | |
| 381 | + break; | |
| 382 | + case SMPS_OFFSET_EN | SMPS_EXTENDED_EN: | |
| 383 | + switch (index) { | |
| 384 | + case 0: | |
| 385 | + voltage = 0; | |
| 386 | + break; | |
| 387 | + case 58: | |
| 388 | + voltage = 4167 * 1000; | |
| 389 | + break; | |
| 390 | + case 59: | |
| 391 | + voltage = 2315 * 1000; | |
| 392 | + break; | |
| 393 | + case 60: | |
| 394 | + voltage = 2778 * 1000; | |
| 395 | + break; | |
| 396 | + case 61: | |
| 397 | + voltage = 2932 * 1000; | |
| 398 | + break; | |
| 399 | + case 62: | |
| 400 | + voltage = 3241 * 1000; | |
| 401 | + break; | |
| 402 | + default: | |
| 403 | + voltage = (2161000 + (38600 * (index - 1))); | |
| 404 | + } | |
| 405 | + break; | |
| 406 | + } | |
| 407 | + | |
| 408 | + return voltage; | |
| 409 | +} | |
| 410 | + | |
| 411 | +static int twl6030smps_map_voltage(struct regulator_dev *rdev, int min_uV, | |
| 412 | + int max_uV) | |
| 413 | +{ | |
| 414 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 415 | + int vsel = 0; | |
| 416 | + | |
| 417 | + switch (info->flags) { | |
| 418 | + case 0: | |
| 419 | + if (min_uV == 0) | |
| 420 | + vsel = 0; | |
| 421 | + else if ((min_uV >= 600000) && (min_uV <= 1300000)) { | |
| 422 | + vsel = DIV_ROUND_UP(min_uV - 600000, 12500); | |
| 423 | + vsel++; | |
| 424 | + } | |
| 425 | + /* Values 1..57 for vsel are linear and can be calculated | |
| 426 | + * values 58..62 are non linear. | |
| 427 | + */ | |
| 428 | + else if ((min_uV > 1900000) && (min_uV <= 2100000)) | |
| 429 | + vsel = 62; | |
| 430 | + else if ((min_uV > 1800000) && (min_uV <= 1900000)) | |
| 431 | + vsel = 61; | |
| 432 | + else if ((min_uV > 1500000) && (min_uV <= 1800000)) | |
| 433 | + vsel = 60; | |
| 434 | + else if ((min_uV > 1350000) && (min_uV <= 1500000)) | |
| 435 | + vsel = 59; | |
| 436 | + else if ((min_uV > 1300000) && (min_uV <= 1350000)) | |
| 437 | + vsel = 58; | |
| 438 | + else | |
| 439 | + return -EINVAL; | |
| 440 | + break; | |
| 441 | + case SMPS_OFFSET_EN: | |
| 442 | + if (min_uV == 0) | |
| 443 | + vsel = 0; | |
| 444 | + else if ((min_uV >= 700000) && (min_uV <= 1420000)) { | |
| 445 | + vsel = DIV_ROUND_UP(min_uV - 700000, 12500); | |
| 446 | + vsel++; | |
| 447 | + } | |
| 448 | + /* Values 1..57 for vsel are linear and can be calculated | |
| 449 | + * values 58..62 are non linear. | |
| 450 | + */ | |
| 451 | + else if ((min_uV > 1900000) && (min_uV <= 2100000)) | |
| 452 | + vsel = 62; | |
| 453 | + else if ((min_uV > 1800000) && (min_uV <= 1900000)) | |
| 454 | + vsel = 61; | |
| 455 | + else if ((min_uV > 1350000) && (min_uV <= 1800000)) | |
| 456 | + vsel = 60; | |
| 457 | + else if ((min_uV > 1350000) && (min_uV <= 1500000)) | |
| 458 | + vsel = 59; | |
| 459 | + else if ((min_uV > 1300000) && (min_uV <= 1350000)) | |
| 460 | + vsel = 58; | |
| 461 | + else | |
| 462 | + return -EINVAL; | |
| 463 | + break; | |
| 464 | + case SMPS_EXTENDED_EN: | |
| 465 | + if (min_uV == 0) { | |
| 466 | + vsel = 0; | |
| 467 | + } else if ((min_uV >= 1852000) && (max_uV <= 4013600)) { | |
| 468 | + vsel = DIV_ROUND_UP(min_uV - 1852000, 38600); | |
| 469 | + vsel++; | |
| 470 | + } | |
| 471 | + break; | |
| 472 | + case SMPS_OFFSET_EN|SMPS_EXTENDED_EN: | |
| 473 | + if (min_uV == 0) { | |
| 474 | + vsel = 0; | |
| 475 | + } else if ((min_uV >= 2161000) && (min_uV <= 4321000)) { | |
| 476 | + vsel = DIV_ROUND_UP(min_uV - 2161000, 38600); | |
| 477 | + vsel++; | |
| 478 | + } | |
| 479 | + break; | |
| 480 | + } | |
| 481 | + | |
| 482 | + return vsel; | |
| 483 | +} | |
| 484 | + | |
| 485 | +static int twl6030smps_set_voltage_sel(struct regulator_dev *rdev, | |
| 486 | + unsigned int selector) | |
| 487 | +{ | |
| 488 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 489 | + | |
| 490 | + return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS, | |
| 491 | + selector); | |
| 492 | +} | |
| 493 | + | |
| 494 | +static int twl6030smps_get_voltage_sel(struct regulator_dev *rdev) | |
| 495 | +{ | |
| 496 | + struct twlreg_info *info = rdev_get_drvdata(rdev); | |
| 497 | + | |
| 498 | + return twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS); | |
| 499 | +} | |
| 500 | + | |
| 501 | +static struct regulator_ops twlsmps_ops = { | |
| 502 | + .list_voltage = twl6030smps_list_voltage, | |
| 503 | + .map_voltage = twl6030smps_map_voltage, | |
| 504 | + | |
| 505 | + .set_voltage_sel = twl6030smps_set_voltage_sel, | |
| 506 | + .get_voltage_sel = twl6030smps_get_voltage_sel, | |
| 507 | + | |
| 508 | + .enable = twl6030reg_enable, | |
| 509 | + .disable = twl6030reg_disable, | |
| 510 | + .is_enabled = twl6030reg_is_enabled, | |
| 511 | + | |
| 512 | + .set_mode = twl6030reg_set_mode, | |
| 513 | + | |
| 514 | + .get_status = twl6030reg_get_status, | |
| 515 | +}; | |
| 516 | + | |
| 517 | +/*----------------------------------------------------------------------*/ | |
| 518 | + | |
| 519 | +#define TWL6030_ADJUSTABLE_SMPS(label) \ | |
| 520 | +static const struct twlreg_info TWL6030_INFO_##label = { \ | |
| 521 | + .desc = { \ | |
| 522 | + .name = #label, \ | |
| 523 | + .id = TWL6030_REG_##label, \ | |
| 524 | + .ops = &twl6030coresmps_ops, \ | |
| 525 | + .type = REGULATOR_VOLTAGE, \ | |
| 526 | + .owner = THIS_MODULE, \ | |
| 527 | + }, \ | |
| 528 | + } | |
| 529 | + | |
| 530 | +#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts) \ | |
| 531 | +static const struct twlreg_info TWL6030_INFO_##label = { \ | |
| 532 | + .base = offset, \ | |
| 533 | + .min_mV = min_mVolts, \ | |
| 534 | + .desc = { \ | |
| 535 | + .name = #label, \ | |
| 536 | + .id = TWL6030_REG_##label, \ | |
| 537 | + .n_voltages = 32, \ | |
| 538 | + .ops = &twl6030ldo_ops, \ | |
| 539 | + .type = REGULATOR_VOLTAGE, \ | |
| 540 | + .owner = THIS_MODULE, \ | |
| 541 | + }, \ | |
| 542 | + } | |
| 543 | + | |
| 544 | +#define TWL6032_ADJUSTABLE_LDO(label, offset, min_mVolts) \ | |
| 545 | +static const struct twlreg_info TWL6032_INFO_##label = { \ | |
| 546 | + .base = offset, \ | |
| 547 | + .min_mV = min_mVolts, \ | |
| 548 | + .desc = { \ | |
| 549 | + .name = #label, \ | |
| 550 | + .id = TWL6032_REG_##label, \ | |
| 551 | + .n_voltages = 32, \ | |
| 552 | + .ops = &twl6030ldo_ops, \ | |
| 553 | + .type = REGULATOR_VOLTAGE, \ | |
| 554 | + .owner = THIS_MODULE, \ | |
| 555 | + }, \ | |
| 556 | + } | |
| 557 | + | |
| 558 | +#define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \ | |
| 559 | +static const struct twlreg_info TWLFIXED_INFO_##label = { \ | |
| 560 | + .base = offset, \ | |
| 561 | + .id = 0, \ | |
| 562 | + .min_mV = mVolts, \ | |
| 563 | + .desc = { \ | |
| 564 | + .name = #label, \ | |
| 565 | + .id = TWL6030##_REG_##label, \ | |
| 566 | + .n_voltages = 1, \ | |
| 567 | + .ops = &twl6030fixed_ops, \ | |
| 568 | + .type = REGULATOR_VOLTAGE, \ | |
| 569 | + .owner = THIS_MODULE, \ | |
| 570 | + .min_uV = mVolts * 1000, \ | |
| 571 | + .enable_time = turnon_delay, \ | |
| 572 | + .of_map_mode = NULL, \ | |
| 573 | + }, \ | |
| 574 | + } | |
| 575 | + | |
| 576 | +#define TWL6032_ADJUSTABLE_SMPS(label, offset) \ | |
| 577 | +static const struct twlreg_info TWLSMPS_INFO_##label = { \ | |
| 578 | + .base = offset, \ | |
| 579 | + .min_mV = 600, \ | |
| 580 | + .desc = { \ | |
| 581 | + .name = #label, \ | |
| 582 | + .id = TWL6032_REG_##label, \ | |
| 583 | + .n_voltages = 63, \ | |
| 584 | + .ops = &twlsmps_ops, \ | |
| 585 | + .type = REGULATOR_VOLTAGE, \ | |
| 586 | + .owner = THIS_MODULE, \ | |
| 587 | + }, \ | |
| 588 | + } | |
| 589 | + | |
| 590 | +/* VUSBCP is managed *only* by the USB subchip */ | |
| 591 | +/* 6030 REG with base as PMC Slave Misc : 0x0030 */ | |
| 592 | +/* Turnon-delay and remap configuration values for 6030 are not | |
| 593 | + verified since the specification is not public */ | |
| 594 | +TWL6030_ADJUSTABLE_SMPS(VDD1); | |
| 595 | +TWL6030_ADJUSTABLE_SMPS(VDD2); | |
| 596 | +TWL6030_ADJUSTABLE_SMPS(VDD3); | |
| 597 | +TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000); | |
| 598 | +TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000); | |
| 599 | +TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000); | |
| 600 | +TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000); | |
| 601 | +TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000); | |
| 602 | +TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000); | |
| 603 | +/* 6025 are renamed compared to 6030 versions */ | |
| 604 | +TWL6032_ADJUSTABLE_LDO(LDO2, 0x54, 1000); | |
| 605 | +TWL6032_ADJUSTABLE_LDO(LDO4, 0x58, 1000); | |
| 606 | +TWL6032_ADJUSTABLE_LDO(LDO3, 0x5c, 1000); | |
| 607 | +TWL6032_ADJUSTABLE_LDO(LDO5, 0x68, 1000); | |
| 608 | +TWL6032_ADJUSTABLE_LDO(LDO1, 0x6c, 1000); | |
| 609 | +TWL6032_ADJUSTABLE_LDO(LDO7, 0x74, 1000); | |
| 610 | +TWL6032_ADJUSTABLE_LDO(LDO6, 0x60, 1000); | |
| 611 | +TWL6032_ADJUSTABLE_LDO(LDOLN, 0x64, 1000); | |
| 612 | +TWL6032_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000); | |
| 613 | +TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0); | |
| 614 | +TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0); | |
| 615 | +TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0); | |
| 616 | +TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0); | |
| 617 | +TWL6030_FIXED_LDO(V1V8, 0x16, 1800, 0); | |
| 618 | +TWL6030_FIXED_LDO(V2V1, 0x1c, 2100, 0); | |
| 619 | +TWL6032_ADJUSTABLE_SMPS(SMPS3, 0x34); | |
| 620 | +TWL6032_ADJUSTABLE_SMPS(SMPS4, 0x10); | |
| 621 | +TWL6032_ADJUSTABLE_SMPS(VIO, 0x16); | |
| 622 | + | |
| 623 | +static u8 twl_get_smps_offset(void) | |
| 624 | +{ | |
| 625 | + u8 value; | |
| 626 | + | |
| 627 | + twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value, | |
| 628 | + TWL6030_SMPS_OFFSET); | |
| 629 | + return value; | |
| 630 | +} | |
| 631 | + | |
| 632 | +static u8 twl_get_smps_mult(void) | |
| 633 | +{ | |
| 634 | + u8 value; | |
| 635 | + | |
| 636 | + twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value, | |
| 637 | + TWL6030_SMPS_MULT); | |
| 638 | + return value; | |
| 639 | +} | |
| 640 | + | |
| 641 | +#define TWL_OF_MATCH(comp, family, label) \ | |
| 642 | + { \ | |
| 643 | + .compatible = comp, \ | |
| 644 | + .data = &family##_INFO_##label, \ | |
| 645 | + } | |
| 646 | + | |
| 647 | +#define TWL6030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6030, label) | |
| 648 | +#define TWL6032_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6032, label) | |
| 649 | +#define TWLFIXED_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLFIXED, label) | |
| 650 | +#define TWLSMPS_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLSMPS, label) | |
| 651 | + | |
| 652 | +static const struct of_device_id twl_of_match[] = { | |
| 653 | + TWL6030_OF_MATCH("ti,twl6030-vdd1", VDD1), | |
| 654 | + TWL6030_OF_MATCH("ti,twl6030-vdd2", VDD2), | |
| 655 | + TWL6030_OF_MATCH("ti,twl6030-vdd3", VDD3), | |
| 656 | + TWL6030_OF_MATCH("ti,twl6030-vaux1", VAUX1_6030), | |
| 657 | + TWL6030_OF_MATCH("ti,twl6030-vaux2", VAUX2_6030), | |
| 658 | + TWL6030_OF_MATCH("ti,twl6030-vaux3", VAUX3_6030), | |
| 659 | + TWL6030_OF_MATCH("ti,twl6030-vmmc", VMMC), | |
| 660 | + TWL6030_OF_MATCH("ti,twl6030-vpp", VPP), | |
| 661 | + TWL6030_OF_MATCH("ti,twl6030-vusim", VUSIM), | |
| 662 | + TWL6032_OF_MATCH("ti,twl6032-ldo2", LDO2), | |
| 663 | + TWL6032_OF_MATCH("ti,twl6032-ldo4", LDO4), | |
| 664 | + TWL6032_OF_MATCH("ti,twl6032-ldo3", LDO3), | |
| 665 | + TWL6032_OF_MATCH("ti,twl6032-ldo5", LDO5), | |
| 666 | + TWL6032_OF_MATCH("ti,twl6032-ldo1", LDO1), | |
| 667 | + TWL6032_OF_MATCH("ti,twl6032-ldo7", LDO7), | |
| 668 | + TWL6032_OF_MATCH("ti,twl6032-ldo6", LDO6), | |
| 669 | + TWL6032_OF_MATCH("ti,twl6032-ldoln", LDOLN), | |
| 670 | + TWL6032_OF_MATCH("ti,twl6032-ldousb", LDOUSB), | |
| 671 | + TWLFIXED_OF_MATCH("ti,twl6030-vana", VANA), | |
| 672 | + TWLFIXED_OF_MATCH("ti,twl6030-vcxio", VCXIO), | |
| 673 | + TWLFIXED_OF_MATCH("ti,twl6030-vdac", VDAC), | |
| 674 | + TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB), | |
| 675 | + TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8), | |
| 676 | + TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1), | |
| 677 | + TWLSMPS_OF_MATCH("ti,twl6032-smps3", SMPS3), | |
| 678 | + TWLSMPS_OF_MATCH("ti,twl6032-smps4", SMPS4), | |
| 679 | + TWLSMPS_OF_MATCH("ti,twl6032-vio", VIO), | |
| 680 | + {}, | |
| 681 | +}; | |
| 682 | +MODULE_DEVICE_TABLE(of, twl_of_match); | |
| 683 | + | |
| 684 | +static int twlreg_probe(struct platform_device *pdev) | |
| 685 | +{ | |
| 686 | + int id; | |
| 687 | + struct twlreg_info *info; | |
| 688 | + const struct twlreg_info *template; | |
| 689 | + struct regulator_init_data *initdata; | |
| 690 | + struct regulation_constraints *c; | |
| 691 | + struct regulator_dev *rdev; | |
| 692 | + const struct of_device_id *match; | |
| 693 | + struct regulator_config config = { }; | |
| 694 | + | |
| 695 | + match = of_match_device(twl_of_match, &pdev->dev); | |
| 696 | + if (!match) | |
| 697 | + return -ENODEV; | |
| 698 | + | |
| 699 | + template = match->data; | |
| 700 | + if (!template) | |
| 701 | + return -ENODEV; | |
| 702 | + | |
| 703 | + id = template->desc.id; | |
| 704 | + initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, | |
| 705 | + &template->desc); | |
| 706 | + if (!initdata) | |
| 707 | + return -EINVAL; | |
| 708 | + | |
| 709 | + info = devm_kmemdup(&pdev->dev, template, sizeof(*info), GFP_KERNEL); | |
| 710 | + if (!info) | |
| 711 | + return -ENOMEM; | |
| 712 | + | |
| 713 | + /* Constrain board-specific capabilities according to what | |
| 714 | + * this driver and the chip itself can actually do. | |
| 715 | + */ | |
| 716 | + c = &initdata->constraints; | |
| 717 | + c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY; | |
| 718 | + c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE | |
| 719 | + | REGULATOR_CHANGE_MODE | |
| 720 | + | REGULATOR_CHANGE_STATUS; | |
| 721 | + | |
| 722 | + switch (id) { | |
| 723 | + case TWL6032_REG_SMPS3: | |
| 724 | + if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3) | |
| 725 | + info->flags |= SMPS_EXTENDED_EN; | |
| 726 | + if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS3) | |
| 727 | + info->flags |= SMPS_OFFSET_EN; | |
| 728 | + break; | |
| 729 | + case TWL6032_REG_SMPS4: | |
| 730 | + if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS4) | |
| 731 | + info->flags |= SMPS_EXTENDED_EN; | |
| 732 | + if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS4) | |
| 733 | + info->flags |= SMPS_OFFSET_EN; | |
| 734 | + break; | |
| 735 | + case TWL6032_REG_VIO: | |
| 736 | + if (twl_get_smps_mult() & SMPS_MULTOFFSET_VIO) | |
| 737 | + info->flags |= SMPS_EXTENDED_EN; | |
| 738 | + if (twl_get_smps_offset() & SMPS_MULTOFFSET_VIO) | |
| 739 | + info->flags |= SMPS_OFFSET_EN; | |
| 740 | + break; | |
| 741 | + } | |
| 742 | + | |
| 743 | + config.dev = &pdev->dev; | |
| 744 | + config.init_data = initdata; | |
| 745 | + config.driver_data = info; | |
| 746 | + config.of_node = pdev->dev.of_node; | |
| 747 | + | |
| 748 | + rdev = devm_regulator_register(&pdev->dev, &info->desc, &config); | |
| 749 | + if (IS_ERR(rdev)) { | |
| 750 | + dev_err(&pdev->dev, "can't register %s, %ld\n", | |
| 751 | + info->desc.name, PTR_ERR(rdev)); | |
| 752 | + return PTR_ERR(rdev); | |
| 753 | + } | |
| 754 | + platform_set_drvdata(pdev, rdev); | |
| 755 | + | |
| 756 | + /* NOTE: many regulators support short-circuit IRQs (presentable | |
| 757 | + * as REGULATOR_OVER_CURRENT notifications?) configured via: | |
| 758 | + * - SC_CONFIG | |
| 759 | + * - SC_DETECT1 (vintana2, vmmc1/2, vaux1/2/3/4) | |
| 760 | + * - SC_DETECT2 (vusb, vdac, vio, vdd1/2, vpll2) | |
| 761 | + * - IT_CONFIG | |
| 762 | + */ | |
| 763 | + | |
| 764 | + return 0; | |
| 765 | +} | |
| 766 | + | |
| 767 | +MODULE_ALIAS("platform:twl6030_reg"); | |
| 768 | + | |
| 769 | +static struct platform_driver twlreg_driver = { | |
| 770 | + .probe = twlreg_probe, | |
| 771 | + /* NOTE: short name, to work around driver model truncation of | |
| 772 | + * "twl_regulator.12" (and friends) to "twl_regulator.1". | |
| 773 | + */ | |
| 774 | + .driver = { | |
| 775 | + .name = "twl6030_reg", | |
| 776 | + .of_match_table = of_match_ptr(twl_of_match), | |
| 777 | + }, | |
| 778 | +}; | |
| 779 | + | |
| 780 | +static int __init twlreg_init(void) | |
| 781 | +{ | |
| 782 | + return platform_driver_register(&twlreg_driver); | |
| 783 | +} | |
| 784 | +subsys_initcall(twlreg_init); | |
| 785 | + | |
| 786 | +static void __exit twlreg_exit(void) | |
| 787 | +{ | |
| 788 | + platform_driver_unregister(&twlreg_driver); | |
| 789 | +} | |
| 790 | +module_exit(twlreg_exit) | |
| 791 | + | |
| 792 | +MODULE_DESCRIPTION("TWL6030 regulator driver"); | |
| 793 | +MODULE_LICENSE("GPL"); | |
| @@ -180,6 +180,7 @@ · 179 unmodified lines | ||
| 180 | 180 | #define MAX77620_SD_CFG1_FPWM_SD_MASK BIT(2) |
| 181 | 181 | #define MAX77620_SD_CFG1_FPWM_SD_SKIP 0 |
| 182 | 182 | #define MAX77620_SD_CFG1_FPWM_SD_FPWM BIT(2) |
| 183 | +#define MAX20024_SD_CFG1_MPOK_MASK BIT(1) | |
| 183 | 184 | #define MAX77620_SD_CFG1_FSRADE_SD_MASK BIT(0) |
| 184 | 185 | #define MAX77620_SD_CFG1_FSRADE_SD_DISABLE 0 |
| 185 | 186 | #define MAX77620_SD_CFG1_FSRADE_SD_ENABLE BIT(0) |
| @@ -187,6 +188,7 @@ · 1 unmodified line | ||
| 187 | 188 | /* LDO_CNFG2 */ |
| 188 | 189 | #define MAX77620_LDO_POWER_MODE_MASK 0xC0 |
| 189 | 190 | #define MAX77620_LDO_POWER_MODE_SHIFT 6 |
| 191 | +#define MAX20024_LDO_CFG2_MPOK_MASK BIT(2) | |
| 190 | 192 | #define MAX77620_LDO_CFG2_ADE_MASK BIT(1) |
| 191 | 193 | #define MAX77620_LDO_CFG2_ADE_DISABLE 0 |
| 192 | 194 | #define MAX77620_LDO_CFG2_ADE_ENABLE BIT(1) |
| @@ -120,6 +120,25 @@ struct regmap; · 119 unmodified lines | ||
| 120 | 120 | #define REGULATOR_EVENT_PRE_DISABLE 0x400 |
| 121 | 121 | #define REGULATOR_EVENT_ABORT_DISABLE 0x800 |
| 122 | 122 | |
| 123 | +/* | |
| 124 | + * Regulator errors that can be queried using regulator_get_error_flags | |
| 125 | + * | |
| 126 | + * UNDER_VOLTAGE Regulator output is under voltage. | |
| 127 | + * OVER_CURRENT Regulator output current is too high. | |
| 128 | + * REGULATION_OUT Regulator output is out of regulation. | |
| 129 | + * FAIL Regulator output has failed. | |
| 130 | + * OVER_TEMP Regulator over temp. | |
| 131 | + * | |
| 132 | + * NOTE: These errors can be OR'ed together. | |
| 133 | + */ | |
| 134 | + | |
| 135 | +#define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1) | |
| 136 | +#define REGULATOR_ERROR_OVER_CURRENT BIT(2) | |
| 137 | +#define REGULATOR_ERROR_REGULATION_OUT BIT(3) | |
| 138 | +#define REGULATOR_ERROR_FAIL BIT(4) | |
| 139 | +#define REGULATOR_ERROR_OVER_TEMP BIT(5) | |
| 140 | + | |
| 141 | + | |
| 123 | 142 | /** |
| 124 | 143 | * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event |
| 125 | 144 | * |
| @@ -237,6 +256,8 @@ int regulator_get_current_limit(struct regulator *regulator); · 111 unmodified lines | ||
| 237 | 256 | |
| 238 | 257 | int regulator_set_mode(struct regulator *regulator, unsigned int mode); |
| 239 | 258 | unsigned int regulator_get_mode(struct regulator *regulator); |
| 259 | +int regulator_get_error_flags(struct regulator *regulator, | |
| 260 | + unsigned int *flags); | |
| 240 | 261 | int regulator_set_load(struct regulator *regulator, int load_uA); |
| 241 | 262 | |
| 242 | 263 | int regulator_allow_bypass(struct regulator *regulator, bool allow); |
| @@ -477,6 +498,12 @@ static inline unsigned int regulator_get_mode(struct regulator *regulator) · 234 unmodified lines | ||
| 477 | 498 | return REGULATOR_MODE_NORMAL; |
| 478 | 499 | } |
| 479 | 500 | |
| 501 | +static inline int regulator_get_error_flags(struct regulator *regulator, | |
| 502 | + unsigned int *flags) | |
| 503 | +{ | |
| 504 | + return -EINVAL; | |
| 505 | +} | |
| 506 | + | |
| 480 | 507 | static inline int regulator_set_load(struct regulator *regulator, int load_uA) |
| 481 | 508 | { |
| 482 | 509 | return REGULATOR_MODE_NORMAL; |
| @@ -100,6 +100,7 @@ struct regulator_linear_range { · 99 unmodified lines | ||
| 100 | 100 | * |
| 101 | 101 | * @set_mode: Set the configured operating mode for the regulator. |
| 102 | 102 | * @get_mode: Get the configured operating mode for the regulator. |
| 103 | + * @get_error_flags: Get the current error(s) for the regulator. | |
| 103 | 104 | * @get_status: Return actual (not as-configured) status of regulator, as a |
| 104 | 105 | * REGULATOR_STATUS value (or negative errno) |
| 105 | 106 | * @get_optimum_mode: Get the most efficient operating mode for the regulator |
| @@ -169,6 +170,9 @@ struct regulator_ops { · 63 unmodified lines | ||
| 169 | 170 | int (*set_mode) (struct regulator_dev *, unsigned int mode); |
| 170 | 171 | unsigned int (*get_mode) (struct regulator_dev *); |
| 171 | 172 | |
| 173 | + /* retrieve current error flags on the regulator */ | |
| 174 | + int (*get_error_flags)(struct regulator_dev *, unsigned int *flags); | |
| 175 | + | |
| 172 | 176 | /* Time taken to enable or set voltage on the regulator */ |
| 173 | 177 | int (*enable_time) (struct regulator_dev *); |
| 174 | 178 | int (*set_ramp_delay) (struct regulator_dev *, int ramp_delay); |