Unified · Split
| @@ -4,16 +4,30 @@ Required properties: · 3 unmodified lines | ||
| 4 | 4 | - compatible : Must be "regulator-gpio". |
| 5 | 5 | - regulator-name : Defined in regulator.txt as optional, but required |
| 6 | 6 | here. |
| 7 | −- states : Selection of available voltages and GPIO configs. | |
| 8 | − if there are no states, then use a fixed regulator | |
| 7 | +- gpios : Array of one or more GPIO pins used to select the | |
| 8 | + regulator voltage/current listed in "states". | |
| 9 | +- states : Selection of available voltages/currents provided by | |
| 10 | + this regulator and matching GPIO configurations to | |
| 11 | + achieve them. If there are no states in the "states" | |
| 12 | + array, use a fixed regulator instead. | |
| 9 | 13 | |
| 10 | 14 | Optional properties: |
| 11 | −- enable-gpio : GPIO to use to enable/disable the regulator. | |
| 12 | −- gpios : GPIO group used to control voltage. | |
| 13 | −- gpios-states : gpios pin's initial states array. 0: LOW, 1: HIGH. | |
| 14 | − defualt is LOW if nothing is specified. | |
| 15 | +- enable-gpios : GPIO used to enable/disable the regulator. | |
| 16 | + Warning, the GPIO phandle flags are ignored and the | |
| 17 | + GPIO polarity is controlled solely by the presence | |
| 18 | + of "enable-active-high" DT property. This is due to | |
| 19 | + compatibility with old DTs. | |
| 20 | +- enable-active-high : Polarity of "enable-gpio" GPIO is active HIGH. | |
| 21 | + Default is active LOW. | |
| 22 | +- gpios-states : On operating systems, that don't support reading back | |
| 23 | + gpio values in output mode (most notably linux), this | |
| 24 | + array provides the state of GPIO pins set when | |
| 25 | + requesting them from the gpio controller. Systems, | |
| 26 | + that are capable of preserving state when requesting | |
| 27 | + the lines, are free to ignore this property. | |
| 28 | + 0: LOW, 1: HIGH. Default is LOW if nothing else | |
| 29 | + is specified. | |
| 15 | 30 | - startup-delay-us : Startup time in microseconds. |
| 16 | −- enable-active-high : Polarity of GPIO is active high (default is low). | |
| 17 | 31 | - regulator-type : Specifies what is being regulated, must be either |
| 18 | 32 | "voltage" or "current", defaults to voltage. |
| 19 | 33 | |
| @@ -30,7 +44,7 @@ Example: · 10 unmodified lines | ||
| 30 | 44 | regulator-max-microvolt = <2600000>; |
| 31 | 45 | regulator-boot-on; |
| 32 | 46 | |
| 33 | − enable-gpio = <&gpio0 23 0x4>; | |
| 47 | + enable-gpios = <&gpio0 23 0x4>; | |
| 34 | 48 | gpios = <&gpio0 24 0x4 |
| 35 | 49 | &gpio0 25 0x4>; |
| 36 | 50 | states = <1800000 0x3 |
| @@ -0,0 +1,43 @@ | ||
| 1 | +STM32MP1 PWR Regulators | |
| 2 | +----------------------- | |
| 3 | + | |
| 4 | +Available Regulators in STM32MP1 PWR block are: | |
| 5 | + - reg11 for regulator 1V1 | |
| 6 | + - reg18 for regulator 1V8 | |
| 7 | + - usb33 for the swtich USB3V3 | |
| 8 | + | |
| 9 | +Required properties: | |
| 10 | +- compatible: Must be "st,stm32mp1,pwr-reg" | |
| 11 | +- list of child nodes that specify the regulator reg11, reg18 or usb33 | |
| 12 | + initialization data for defined regulators. The definition for each of | |
| 13 | + these nodes is defined using the standard binding for regulators found at | |
| 14 | + Documentation/devicetree/bindings/regulator/regulator.txt. | |
| 15 | +- vdd-supply: phandle to the parent supply/regulator node for vdd input | |
| 16 | +- vdd_3v3_usbfs-supply: phandle to the parent supply/regulator node for usb33 | |
| 17 | + | |
| 18 | +Example: | |
| 19 | + | |
| 20 | +pwr_regulators: pwr@50001000 { | |
| 21 | + compatible = "st,stm32mp1,pwr-reg"; | |
| 22 | + reg = <0x50001000 0x10>; | |
| 23 | + vdd-supply = <&vdd>; | |
| 24 | + vdd_3v3_usbfs-supply = <&vdd_usb>; | |
| 25 | + | |
| 26 | + reg11: reg11 { | |
| 27 | + regulator-name = "reg11"; | |
| 28 | + regulator-min-microvolt = <1100000>; | |
| 29 | + regulator-max-microvolt = <1100000>; | |
| 30 | + }; | |
| 31 | + | |
| 32 | + reg18: reg18 { | |
| 33 | + regulator-name = "reg18"; | |
| 34 | + regulator-min-microvolt = <1800000>; | |
| 35 | + regulator-max-microvolt = <1800000>; | |
| 36 | + }; | |
| 37 | + | |
| 38 | + usb33: usb33 { | |
| 39 | + regulator-name = "usb33"; | |
| 40 | + regulator-min-microvolt = <3300000>; | |
| 41 | + regulator-max-microvolt = <3300000>; | |
| 42 | + }; | |
| 43 | +}; | |
| @@ -34,7 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | /* Current settings - values are 2*2^(reg_val/4) microamps. These are |
| 35 | 35 | * exported since they are used by multiple drivers. |
| 36 | 36 | */ |
| 37 | −int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = { | |
| 37 | +const unsigned int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = { | |
| 38 | 38 | 2, |
| 39 | 39 | 2, |
| 40 | 40 | 3, |
| @@ -35,12 +35,6 @@ static bool wm8400_volatile(struct device *dev, unsigned int reg) · 34 unmodified lines | ||
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | −int wm8400_block_read(struct wm8400 *wm8400, u8 reg, int count, u16 *data) | |
| 39 | −{ | |
| 40 | − return regmap_bulk_read(wm8400->regmap, reg, data, count); | |
| 41 | −} | |
| 42 | −EXPORT_SYMBOL_GPL(wm8400_block_read); | |
| 43 | − | |
| 44 | 38 | static int wm8400_register_codec(struct wm8400 *wm8400) |
| 45 | 39 | { |
| 46 | 40 | const struct mfd_cell cell = { |
| @@ -77,11 +77,6 @@ struct pm800_regulator_info { · 76 unmodified lines | ||
| 77 | 77 | int max_ua; |
| 78 | 78 | }; |
| 79 | 79 | |
| 80 | −struct pm800_regulators { | |
| 81 | − struct pm80x_chip *chip; | |
| 82 | − struct regmap *map; | |
| 83 | −}; | |
| 84 | − | |
| 85 | 80 | /* |
| 86 | 81 | * vreg - the buck regs string. |
| 87 | 82 | * ereg - the string for the enable register. |
| @@ -235,7 +230,6 @@ static int pm800_regulator_probe(struct platform_device *pdev) · 147 unmodified lines | ||
| 235 | 230 | { |
| 236 | 231 | struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent); |
| 237 | 232 | struct pm80x_platform_data *pdata = dev_get_platdata(pdev->dev.parent); |
| 238 | − struct pm800_regulators *pm800_data; | |
| 239 | 233 | struct regulator_config config = { }; |
| 240 | 234 | struct regulator_init_data *init_data; |
| 241 | 235 | int i, ret; |
| @@ -252,18 +246,8 @@ static int pm800_regulator_probe(struct platform_device *pdev) · 10 unmodified lines | ||
| 252 | 246 | return -EINVAL; |
| 253 | 247 | } |
| 254 | 248 | |
| 255 | − pm800_data = devm_kzalloc(&pdev->dev, sizeof(*pm800_data), | |
| 256 | − GFP_KERNEL); | |
| 257 | − if (!pm800_data) | |
| 258 | − return -ENOMEM; | |
| 259 | − | |
| 260 | − pm800_data->map = chip->subchip->regmap_power; | |
| 261 | − pm800_data->chip = chip; | |
| 262 | − | |
| 263 | − platform_set_drvdata(pdev, pm800_data); | |
| 264 | − | |
| 265 | 249 | config.dev = chip->dev; |
| 266 | − config.regmap = pm800_data->map; | |
| 250 | + config.regmap = chip->subchip->regmap_power; | |
| 267 | 251 | for (i = 0; i < PM800_ID_RG_MAX; i++) { |
| 268 | 252 | struct regulator_dev *regulator; |
| 269 | 253 | |
| @@ -235,6 +235,8 @@ static const struct regulator_ops pm8606_preg_ops = { · 234 unmodified lines | ||
| 235 | 235 | { \ |
| 236 | 236 | .desc = { \ |
| 237 | 237 | .name = "PREG", \ |
| 238 | + .of_match = of_match_ptr("PREG"), \ | |
| 239 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 238 | 240 | .ops = &pm8606_preg_ops, \ |
| 239 | 241 | .type = REGULATOR_CURRENT, \ |
| 240 | 242 | .id = PM8606_ID_PREG, \ |
| @@ -249,6 +251,8 @@ static const struct regulator_ops pm8606_preg_ops = { · 8 unmodified lines | ||
| 249 | 251 | { \ |
| 250 | 252 | .desc = { \ |
| 251 | 253 | .name = #vreg, \ |
| 254 | + .of_match = of_match_ptr(#vreg), \ | |
| 255 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 252 | 256 | .ops = &pm8607_regulator_ops, \ |
| 253 | 257 | .type = REGULATOR_VOLTAGE, \ |
| 254 | 258 | .id = PM8607_ID_##vreg, \ |
| @@ -270,6 +274,8 @@ static const struct regulator_ops pm8606_preg_ops = { · 15 unmodified lines | ||
| 270 | 274 | { \ |
| 271 | 275 | .desc = { \ |
| 272 | 276 | .name = "LDO" #_id, \ |
| 277 | + .of_match = of_match_ptr("LDO" #_id), \ | |
| 278 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 273 | 279 | .ops = &pm8607_regulator_ops, \ |
| 274 | 280 | .type = REGULATOR_VOLTAGE, \ |
| 275 | 281 | .id = PM8607_ID_LDO##_id, \ |
| @@ -309,36 +315,6 @@ static struct pm8607_regulator_info pm8606_regulator_info[] = { · 33 unmodified lines | ||
| 309 | 315 | PM8606_PREG(PREREGULATORB, 5), |
| 310 | 316 | }; |
| 311 | 317 | |
| 312 | −#ifdef CONFIG_OF | |
| 313 | −static int pm8607_regulator_dt_init(struct platform_device *pdev, | |
| 314 | − struct pm8607_regulator_info *info, | |
| 315 | − struct regulator_config *config) | |
| 316 | −{ | |
| 317 | − struct device_node *nproot, *np; | |
| 318 | − nproot = pdev->dev.parent->of_node; | |
| 319 | − if (!nproot) | |
| 320 | − return -ENODEV; | |
| 321 | − nproot = of_get_child_by_name(nproot, "regulators"); | |
| 322 | − if (!nproot) { | |
| 323 | − dev_err(&pdev->dev, "failed to find regulators node\n"); | |
| 324 | − return -ENODEV; | |
| 325 | − } | |
| 326 | − for_each_child_of_node(nproot, np) { | |
| 327 | − if (of_node_name_eq(np, info->desc.name)) { | |
| 328 | − config->init_data = | |
| 329 | − of_get_regulator_init_data(&pdev->dev, np, | |
| 330 | − &info->desc); | |
| 331 | − config->of_node = np; | |
| 332 | − break; | |
| 333 | − } | |
| 334 | − } | |
| 335 | − of_node_put(nproot); | |
| 336 | − return 0; | |
| 337 | −} | |
| 338 | −#else | |
| 339 | −#define pm8607_regulator_dt_init(x, y, z) (-1) | |
| 340 | −#endif | |
| 341 | − | |
| 342 | 318 | static int pm8607_regulator_probe(struct platform_device *pdev) |
| 343 | 319 | { |
| 344 | 320 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); |
| @@ -373,12 +349,11 @@ static int pm8607_regulator_probe(struct platform_device *pdev) · 28 unmodified lines | ||
| 373 | 349 | if ((i == PM8607_ID_BUCK3) && chip->buck3_double) |
| 374 | 350 | info->slope_double = 1; |
| 375 | 351 | |
| 376 | − config.dev = &pdev->dev; | |
| 352 | + config.dev = chip->dev; | |
| 377 | 353 | config.driver_data = info; |
| 378 | 354 | |
| 379 | − if (pm8607_regulator_dt_init(pdev, info, &config)) | |
| 380 | − if (pdata) | |
| 381 | − config.init_data = pdata; | |
| 355 | + if (pdata) | |
| 356 | + config.init_data = pdata; | |
| 382 | 357 | |
| 383 | 358 | if (chip->id == CHIP_PM8607) |
| 384 | 359 | config.regmap = chip->regmap; |
| @@ -223,6 +223,7 @@ config REGULATOR_CPCAP · 222 unmodified lines | ||
| 223 | 223 | config REGULATOR_DA903X |
| 224 | 224 | tristate "Dialog Semiconductor DA9030/DA9034 regulators" |
| 225 | 225 | depends on PMIC_DA903X |
| 226 | + depends on !CC_IS_CLANG # https://bugs.llvm.org/show_bug.cgi?id=38789 | |
| 226 | 227 | help |
| 227 | 228 | Say y here to support the BUCKs and LDOs regulators found on |
| 228 | 229 | Dialog Semiconductor DA9030/DA9034 PMIC. |
| @@ -839,6 +840,13 @@ config REGULATOR_STM32_VREFBUF · 610 unmodified lines | ||
| 839 | 840 | This driver can also be built as a module. If so, the module |
| 840 | 841 | will be called stm32-vrefbuf. |
| 841 | 842 | |
| 843 | +config REGULATOR_STM32_PWR | |
| 844 | + bool "STMicroelectronics STM32 PWR" | |
| 845 | + depends on ARCH_STM32 || COMPILE_TEST | |
| 846 | + help | |
| 847 | + This driver supports internal regulators (1V1, 1V8, 3V3) in the | |
| 848 | + STMicroelectronics STM32 chips. | |
| 849 | + | |
| 842 | 850 | config REGULATOR_STPMIC1 |
| 843 | 851 | tristate "STMicroelectronics STPMIC1 PMIC Regulators" |
| 844 | 852 | depends on MFD_STPMIC1 |
| @@ -1010,7 +1018,8 @@ config REGULATOR_TWL4030 · 165 unmodified lines | ||
| 1010 | 1018 | config REGULATOR_UNIPHIER |
| 1011 | 1019 | tristate "UniPhier regulator driver" |
| 1012 | 1020 | depends on ARCH_UNIPHIER || COMPILE_TEST |
| 1013 | − depends on OF && MFD_SYSCON | |
| 1021 | + depends on OF | |
| 1022 | + select REGMAP_MMIO | |
| 1014 | 1023 | default ARCH_UNIPHIER |
| 1015 | 1024 | help |
| 1016 | 1025 | Support for regulators implemented on Socionext UniPhier SoCs. |
| @@ -105,6 +105,7 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o · 104 unmodified lines | ||
| 105 | 105 | obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o |
| 106 | 106 | obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o |
| 107 | 107 | obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o |
| 108 | +obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o | |
| 108 | 109 | obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o |
| 109 | 110 | obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o |
| 110 | 111 | obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o |
| @@ -48,7 +48,6 @@ · 47 unmodified lines | ||
| 48 | 48 | * @regreg: regulator register number in the AB3100 |
| 49 | 49 | */ |
| 50 | 50 | struct ab3100_regulator { |
| 51 | − struct regulator_dev *rdev; | |
| 52 | 51 | struct device *dev; |
| 53 | 52 | struct ab3100_platform_data *plfdata; |
| 54 | 53 | u8 regreg; |
| @@ -354,14 +353,13 @@ static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg) · 299 unmodified lines | ||
| 354 | 353 | return 0; |
| 355 | 354 | } |
| 356 | 355 | |
| 357 | −static struct regulator_ops regulator_ops_fixed = { | |
| 358 | − .list_voltage = regulator_list_voltage_linear, | |
| 356 | +static const struct regulator_ops regulator_ops_fixed = { | |
| 359 | 357 | .enable = ab3100_enable_regulator, |
| 360 | 358 | .disable = ab3100_disable_regulator, |
| 361 | 359 | .is_enabled = ab3100_is_enabled_regulator, |
| 362 | 360 | }; |
| 363 | 361 | |
| 364 | −static struct regulator_ops regulator_ops_variable = { | |
| 362 | +static const struct regulator_ops regulator_ops_variable = { | |
| 365 | 363 | .enable = ab3100_enable_regulator, |
| 366 | 364 | .disable = ab3100_disable_regulator, |
| 367 | 365 | .is_enabled = ab3100_is_enabled_regulator, |
| @@ -370,7 +368,7 @@ static struct regulator_ops regulator_ops_variable = { · 2 unmodified lines | ||
| 370 | 368 | .list_voltage = regulator_list_voltage_table, |
| 371 | 369 | }; |
| 372 | 370 | |
| 373 | −static struct regulator_ops regulator_ops_variable_sleepable = { | |
| 371 | +static const struct regulator_ops regulator_ops_variable_sleepable = { | |
| 374 | 372 | .enable = ab3100_enable_regulator, |
| 375 | 373 | .disable = ab3100_disable_regulator, |
| 376 | 374 | .is_enabled = ab3100_is_enabled_regulator, |
| @@ -386,14 +384,14 @@ static struct regulator_ops regulator_ops_variable_sleepable = { · 9 unmodified lines | ||
| 386 | 384 | * is an on/off switch plain an simple. The external |
| 387 | 385 | * voltage is defined in the board set-up if any. |
| 388 | 386 | */ |
| 389 | −static struct regulator_ops regulator_ops_external = { | |
| 387 | +static const struct regulator_ops regulator_ops_external = { | |
| 390 | 388 | .enable = ab3100_enable_regulator, |
| 391 | 389 | .disable = ab3100_disable_regulator, |
| 392 | 390 | .is_enabled = ab3100_is_enabled_regulator, |
| 393 | 391 | .get_voltage = ab3100_get_voltage_regulator_external, |
| 394 | 392 | }; |
| 395 | 393 | |
| 396 | −static struct regulator_desc | |
| 394 | +static const struct regulator_desc | |
| 397 | 395 | ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { |
| 398 | 396 | { |
| 399 | 397 | .name = "LDO_A", |
| @@ -402,7 +400,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { · 2 unmodified lines | ||
| 402 | 400 | .n_voltages = 1, |
| 403 | 401 | .type = REGULATOR_VOLTAGE, |
| 404 | 402 | .owner = THIS_MODULE, |
| 405 | − .min_uV = LDO_A_VOLTAGE, | |
| 403 | + .fixed_uV = LDO_A_VOLTAGE, | |
| 406 | 404 | .enable_time = 200, |
| 407 | 405 | }, |
| 408 | 406 | { |
| @@ -412,7 +410,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 412 | 410 | .n_voltages = 1, |
| 413 | 411 | .type = REGULATOR_VOLTAGE, |
| 414 | 412 | .owner = THIS_MODULE, |
| 415 | − .min_uV = LDO_C_VOLTAGE, | |
| 413 | + .fixed_uV = LDO_C_VOLTAGE, | |
| 416 | 414 | .enable_time = 200, |
| 417 | 415 | }, |
| 418 | 416 | { |
| @@ -422,7 +420,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 422 | 420 | .n_voltages = 1, |
| 423 | 421 | .type = REGULATOR_VOLTAGE, |
| 424 | 422 | .owner = THIS_MODULE, |
| 425 | − .min_uV = LDO_D_VOLTAGE, | |
| 423 | + .fixed_uV = LDO_D_VOLTAGE, | |
| 426 | 424 | .enable_time = 200, |
| 427 | 425 | }, |
| 428 | 426 | { |
| @@ -500,7 +498,7 @@ static int ab3100_regulator_register(struct platform_device *pdev, · 71 unmodified lines | ||
| 500 | 498 | struct device_node *np, |
| 501 | 499 | unsigned long id) |
| 502 | 500 | { |
| 503 | − struct regulator_desc *desc; | |
| 501 | + const struct regulator_desc *desc; | |
| 504 | 502 | struct ab3100_regulator *reg; |
| 505 | 503 | struct regulator_dev *rdev; |
| 506 | 504 | struct regulator_config config = { }; |
| @@ -545,8 +543,6 @@ static int ab3100_regulator_register(struct platform_device *pdev, · 38 unmodified lines | ||
| 545 | 543 | return err; |
| 546 | 544 | } |
| 547 | 545 | |
| 548 | − /* Then set a pointer back to the registered regulator */ | |
| 549 | − reg->rdev = rdev; | |
| 550 | 546 | return 0; |
| 551 | 547 | } |
| 552 | 548 | |
| @@ -609,18 +605,6 @@ static const u8 ab3100_reg_initvals[] = { · 56 unmodified lines | ||
| 609 | 605 | LDO_D_SETTING, |
| 610 | 606 | }; |
| 611 | 607 | |
| 612 | −static int ab3100_regulators_remove(struct platform_device *pdev) | |
| 613 | −{ | |
| 614 | − int i; | |
| 615 | − | |
| 616 | − for (i = 0; i < AB3100_NUM_REGULATORS; i++) { | |
| 617 | − struct ab3100_regulator *reg = &ab3100_regulators[i]; | |
| 618 | − | |
| 619 | − reg->rdev = NULL; | |
| 620 | − } | |
| 621 | − return 0; | |
| 622 | −} | |
| 623 | − | |
| 624 | 608 | static int |
| 625 | 609 | ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np) |
| 626 | 610 | { |
| @@ -647,10 +631,8 @@ ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np) · 20 unmodified lines | ||
| 647 | 631 | pdev, NULL, ab3100_regulator_matches[i].init_data, |
| 648 | 632 | ab3100_regulator_matches[i].of_node, |
| 649 | 633 | (unsigned long)ab3100_regulator_matches[i].driver_data); |
| 650 | − if (err) { | |
| 651 | − ab3100_regulators_remove(pdev); | |
| 634 | + if (err) | |
| 652 | 635 | return err; |
| 653 | − } | |
| 654 | 636 | } |
| 655 | 637 | |
| 656 | 638 | return 0; |
| @@ -705,14 +687,12 @@ static int ab3100_regulators_probe(struct platform_device *pdev) · 48 unmodified lines | ||
| 705 | 687 | |
| 706 | 688 | /* Register the regulators */ |
| 707 | 689 | for (i = 0; i < AB3100_NUM_REGULATORS; i++) { |
| 708 | − struct regulator_desc *desc = &ab3100_regulator_desc[i]; | |
| 690 | + const struct regulator_desc *desc = &ab3100_regulator_desc[i]; | |
| 709 | 691 | |
| 710 | 692 | err = ab3100_regulator_register(pdev, plfdata, NULL, NULL, |
| 711 | 693 | desc->id); |
| 712 | − if (err) { | |
| 713 | − ab3100_regulators_remove(pdev); | |
| 694 | + if (err) | |
| 714 | 695 | return err; |
| 715 | − } | |
| 716 | 696 | } |
| 717 | 697 | |
| 718 | 698 | return 0; |
| @@ -723,7 +703,6 @@ static struct platform_driver ab3100_regulators_driver = { · 4 unmodified lines | ||
| 723 | 703 | .name = "ab3100-regulators", |
| 724 | 704 | }, |
| 725 | 705 | .probe = ab3100_regulators_probe, |
| 726 | − .remove = ab3100_regulators_remove, | |
| 727 | 706 | }; |
| 728 | 707 | |
| 729 | 708 | static __init int ab3100_regulators_init(void) |
| @@ -479,7 +479,6 @@ static struct ab8500_regulator_platform_data ab8500_regulator_plat_data = { · 478 unmodified lines | ||
| 479 | 479 | * struct ab8500_ext_regulator_info - ab8500 regulator information |
| 480 | 480 | * @dev: device pointer |
| 481 | 481 | * @desc: regulator description |
| 482 | − * @rdev: regulator device | |
| 483 | 482 | * @cfg: regulator configuration (extension of regulator FW configuration) |
| 484 | 483 | * @update_bank: bank to control on/off |
| 485 | 484 | * @update_reg: register to control on/off |
| @@ -495,7 +494,6 @@ static struct ab8500_regulator_platform_data ab8500_regulator_plat_data = { · 9 unmodified lines | ||
| 495 | 494 | struct ab8500_ext_regulator_info { |
| 496 | 495 | struct device *dev; |
| 497 | 496 | struct regulator_desc desc; |
| 498 | − struct regulator_dev *rdev; | |
| 499 | 497 | struct ab8500_ext_regulator_cfg *cfg; |
| 500 | 498 | u8 update_bank; |
| 501 | 499 | u8 update_reg; |
| @@ -530,7 +528,7 @@ static int ab8500_ext_regulator_enable(struct regulator_dev *rdev) · 28 unmodified lines | ||
| 530 | 528 | info->update_bank, info->update_reg, |
| 531 | 529 | info->update_mask, regval); |
| 532 | 530 | if (ret < 0) { |
| 533 | − dev_err(rdev_get_dev(info->rdev), | |
| 531 | + dev_err(rdev_get_dev(rdev), | |
| 534 | 532 | "couldn't set enable bits for regulator\n"); |
| 535 | 533 | return ret; |
| 536 | 534 | } |
| @@ -566,7 +564,7 @@ static int ab8500_ext_regulator_disable(struct regulator_dev *rdev) · 29 unmodified lines | ||
| 566 | 564 | info->update_bank, info->update_reg, |
| 567 | 565 | info->update_mask, regval); |
| 568 | 566 | if (ret < 0) { |
| 569 | − dev_err(rdev_get_dev(info->rdev), | |
| 567 | + dev_err(rdev_get_dev(rdev), | |
| 570 | 568 | "couldn't set disable bits for regulator\n"); |
| 571 | 569 | return ret; |
| 572 | 570 | } |
| @@ -720,7 +718,7 @@ static int ab8500_ext_list_voltage(struct regulator_dev *rdev, · 147 unmodified lines | ||
| 720 | 718 | return -EINVAL; |
| 721 | 719 | } |
| 722 | 720 | |
| 723 | −static struct regulator_ops ab8500_ext_regulator_ops = { | |
| 721 | +static const struct regulator_ops ab8500_ext_regulator_ops = { | |
| 724 | 722 | .enable = ab8500_ext_regulator_enable, |
| 725 | 723 | .disable = ab8500_ext_regulator_disable, |
| 726 | 724 | .is_enabled = ab8500_ext_regulator_is_enabled, |
| @@ -735,6 +733,7 @@ static struct ab8500_ext_regulator_info · 8 unmodified lines | ||
| 735 | 733 | [AB8500_EXT_SUPPLY1] = { |
| 736 | 734 | .desc = { |
| 737 | 735 | .name = "VEXTSUPPLY1", |
| 736 | + .of_match = of_match_ptr("ab8500_ext1"), | |
| 738 | 737 | .ops = &ab8500_ext_regulator_ops, |
| 739 | 738 | .type = REGULATOR_VOLTAGE, |
| 740 | 739 | .id = AB8500_EXT_SUPPLY1, |
| @@ -752,6 +751,7 @@ static struct ab8500_ext_regulator_info · 11 unmodified lines | ||
| 752 | 751 | [AB8500_EXT_SUPPLY2] = { |
| 753 | 752 | .desc = { |
| 754 | 753 | .name = "VEXTSUPPLY2", |
| 754 | + .of_match = of_match_ptr("ab8500_ext2"), | |
| 755 | 755 | .ops = &ab8500_ext_regulator_ops, |
| 756 | 756 | .type = REGULATOR_VOLTAGE, |
| 757 | 757 | .id = AB8500_EXT_SUPPLY2, |
| @@ -769,6 +769,7 @@ static struct ab8500_ext_regulator_info · 11 unmodified lines | ||
| 769 | 769 | [AB8500_EXT_SUPPLY3] = { |
| 770 | 770 | .desc = { |
| 771 | 771 | .name = "VEXTSUPPLY3", |
| 772 | + .of_match = of_match_ptr("ab8500_ext3"), | |
| 772 | 773 | .ops = &ab8500_ext_regulator_ops, |
| 773 | 774 | .type = REGULATOR_VOLTAGE, |
| 774 | 775 | .id = AB8500_EXT_SUPPLY3, |
| @@ -785,30 +786,13 @@ static struct ab8500_ext_regulator_info · 10 unmodified lines | ||
| 785 | 786 | }, |
| 786 | 787 | }; |
| 787 | 788 | |
| 788 | −static struct of_regulator_match ab8500_ext_regulator_match[] = { | |
| 789 | − { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, }, | |
| 790 | − { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, }, | |
| 791 | − { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, }, | |
| 792 | −}; | |
| 793 | − | |
| 794 | 789 | static int ab8500_ext_regulator_probe(struct platform_device *pdev) |
| 795 | 790 | { |
| 796 | 791 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
| 797 | 792 | struct ab8500_regulator_platform_data *pdata = &ab8500_regulator_plat_data; |
| 798 | − struct device_node *np = pdev->dev.of_node; | |
| 799 | 793 | struct regulator_config config = { }; |
| 800 | − int i, err; | |
| 801 | − | |
| 802 | − if (np) { | |
| 803 | − err = of_regulator_match(&pdev->dev, np, | |
| 804 | − ab8500_ext_regulator_match, | |
| 805 | − ARRAY_SIZE(ab8500_ext_regulator_match)); | |
| 806 | − if (err < 0) { | |
| 807 | − dev_err(&pdev->dev, | |
| 808 | − "Error parsing regulator init data: %d\n", err); | |
| 809 | − return err; | |
| 810 | − } | |
| 811 | − } | |
| 794 | + struct regulator_dev *rdev; | |
| 795 | + int i; | |
| 812 | 796 | |
| 813 | 797 | if (!ab8500) { |
| 814 | 798 | dev_err(&pdev->dev, "null mfd parent\n"); |
| @@ -844,23 +828,18 @@ static int ab8500_ext_regulator_probe(struct platform_device *pdev) · 29 unmodified lines | ||
| 844 | 828 | |
| 845 | 829 | config.dev = &pdev->dev; |
| 846 | 830 | config.driver_data = info; |
| 847 | − config.of_node = ab8500_ext_regulator_match[i].of_node; | |
| 848 | − config.init_data = (np) ? | |
| 849 | − ab8500_ext_regulator_match[i].init_data : | |
| 850 | − &pdata->ext_regulator[i]; | |
| 831 | + config.init_data = &pdata->ext_regulator[i]; | |
| 851 | 832 | |
| 852 | 833 | /* register regulator with framework */ |
| 853 | − info->rdev = devm_regulator_register(&pdev->dev, &info->desc, | |
| 854 | − &config); | |
| 855 | − if (IS_ERR(info->rdev)) { | |
| 856 | − err = PTR_ERR(info->rdev); | |
| 834 | + rdev = devm_regulator_register(&pdev->dev, &info->desc, | |
| 835 | + &config); | |
| 836 | + if (IS_ERR(rdev)) { | |
| 857 | 837 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 858 | 838 | info->desc.name); |
| 859 | − return err; | |
| 839 | + return PTR_ERR(rdev); | |
| 860 | 840 | } |
| 861 | 841 | |
| 862 | − dev_dbg(rdev_get_dev(info->rdev), | |
| 863 | − "%s-probed\n", info->desc.name); | |
| 842 | + dev_dbg(&pdev->dev, "%s-probed\n", info->desc.name); | |
| 864 | 843 | } |
| 865 | 844 | |
| 866 | 845 | return 0; |
| @@ -44,7 +44,6 @@ struct ab8500_shared_mode { · 43 unmodified lines | ||
| 44 | 44 | * struct ab8500_regulator_info - ab8500 regulator information |
| 45 | 45 | * @dev: device pointer |
| 46 | 46 | * @desc: regulator description |
| 47 | − * @regulator_dev: regulator device | |
| 48 | 47 | * @shared_mode: used when mode is shared between two regulators |
| 49 | 48 | * @load_lp_uA: maximum load in idle (low power) mode |
| 50 | 49 | * @update_bank: bank to control on/off |
| @@ -65,7 +64,6 @@ struct ab8500_shared_mode { · 14 unmodified lines | ||
| 65 | 64 | struct ab8500_regulator_info { |
| 66 | 65 | struct device *dev; |
| 67 | 66 | struct regulator_desc desc; |
| 68 | − struct regulator_dev *regulator; | |
| 69 | 67 | struct ab8500_shared_mode *shared_mode; |
| 70 | 68 | int load_lp_uA; |
| 71 | 69 | u8 update_bank; |
| @@ -510,7 +508,7 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, · 438 unmodified lines | ||
| 510 | 508 | return ret; |
| 511 | 509 | } |
| 512 | 510 | |
| 513 | −static struct regulator_ops ab8500_regulator_volt_mode_ops = { | |
| 511 | +static const struct regulator_ops ab8500_regulator_volt_mode_ops = { | |
| 514 | 512 | .enable = ab8500_regulator_enable, |
| 515 | 513 | .disable = ab8500_regulator_disable, |
| 516 | 514 | .is_enabled = ab8500_regulator_is_enabled, |
| @@ -522,7 +520,7 @@ static struct regulator_ops ab8500_regulator_volt_mode_ops = { · 5 unmodified lines | ||
| 522 | 520 | .list_voltage = regulator_list_voltage_table, |
| 523 | 521 | }; |
| 524 | 522 | |
| 525 | −static struct regulator_ops ab8500_regulator_volt_ops = { | |
| 523 | +static const struct regulator_ops ab8500_regulator_volt_ops = { | |
| 526 | 524 | .enable = ab8500_regulator_enable, |
| 527 | 525 | .disable = ab8500_regulator_disable, |
| 528 | 526 | .is_enabled = ab8500_regulator_is_enabled, |
| @@ -531,7 +529,7 @@ static struct regulator_ops ab8500_regulator_volt_ops = { · 2 unmodified lines | ||
| 531 | 529 | .list_voltage = regulator_list_voltage_table, |
| 532 | 530 | }; |
| 533 | 531 | |
| 534 | −static struct regulator_ops ab8500_regulator_mode_ops = { | |
| 532 | +static const struct regulator_ops ab8500_regulator_mode_ops = { | |
| 535 | 533 | .enable = ab8500_regulator_enable, |
| 536 | 534 | .disable = ab8500_regulator_disable, |
| 537 | 535 | .is_enabled = ab8500_regulator_is_enabled, |
| @@ -541,14 +539,14 @@ static struct regulator_ops ab8500_regulator_mode_ops = { · 3 unmodified lines | ||
| 541 | 539 | .list_voltage = regulator_list_voltage_table, |
| 542 | 540 | }; |
| 543 | 541 | |
| 544 | −static struct regulator_ops ab8500_regulator_ops = { | |
| 542 | +static const struct regulator_ops ab8500_regulator_ops = { | |
| 545 | 543 | .enable = ab8500_regulator_enable, |
| 546 | 544 | .disable = ab8500_regulator_disable, |
| 547 | 545 | .is_enabled = ab8500_regulator_is_enabled, |
| 548 | 546 | .list_voltage = regulator_list_voltage_table, |
| 549 | 547 | }; |
| 550 | 548 | |
| 551 | −static struct regulator_ops ab8500_regulator_anamic_mode_ops = { | |
| 549 | +static const struct regulator_ops ab8500_regulator_anamic_mode_ops = { | |
| 552 | 550 | .enable = ab8500_regulator_enable, |
| 553 | 551 | .disable = ab8500_regulator_disable, |
| 554 | 552 | .is_enabled = ab8500_regulator_is_enabled, |
| @@ -1600,6 +1598,7 @@ static int ab8500_regulator_register(struct platform_device *pdev, · 1045 unmodified lines | ||
| 1600 | 1598 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
| 1601 | 1599 | struct ab8500_regulator_info *info = NULL; |
| 1602 | 1600 | struct regulator_config config = { }; |
| 1601 | + struct regulator_dev *rdev; | |
| 1603 | 1602 | |
| 1604 | 1603 | /* assign per-regulator data */ |
| 1605 | 1604 | info = &abx500_regulator.info[id]; |
| @@ -1621,12 +1620,11 @@ static int ab8500_regulator_register(struct platform_device *pdev, · 15 unmodified lines | ||
| 1621 | 1620 | } |
| 1622 | 1621 | |
| 1623 | 1622 | /* register regulator with framework */ |
| 1624 | − info->regulator = devm_regulator_register(&pdev->dev, &info->desc, | |
| 1625 | − &config); | |
| 1626 | − if (IS_ERR(info->regulator)) { | |
| 1623 | + rdev = devm_regulator_register(&pdev->dev, &info->desc, &config); | |
| 1624 | + if (IS_ERR(rdev)) { | |
| 1627 | 1625 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 1628 | 1626 | info->desc.name); |
| 1629 | − return PTR_ERR(info->regulator); | |
| 1627 | + return PTR_ERR(rdev); | |
| 1630 | 1628 | } |
| 1631 | 1629 | |
| 1632 | 1630 | return 0; |
| @@ -226,7 +226,7 @@ static const struct regulator_linear_range act8600_sudcdc_voltage_ranges[] = { · 225 unmodified lines | ||
| 226 | 226 | REGULATOR_LINEAR_RANGE(41400000, 248, 255, 0), |
| 227 | 227 | }; |
| 228 | 228 | |
| 229 | −static struct regulator_ops act8865_ops = { | |
| 229 | +static const struct regulator_ops act8865_ops = { | |
| 230 | 230 | .list_voltage = regulator_list_voltage_linear_range, |
| 231 | 231 | .map_voltage = regulator_map_voltage_linear_range, |
| 232 | 232 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| @@ -236,7 +236,7 @@ static struct regulator_ops act8865_ops = { · 3 unmodified lines | ||
| 236 | 236 | .is_enabled = regulator_is_enabled_regmap, |
| 237 | 237 | }; |
| 238 | 238 | |
| 239 | −static struct regulator_ops act8865_ldo_ops = { | |
| 239 | +static const struct regulator_ops act8865_ldo_ops = { | |
| 240 | 240 | .enable = regulator_enable_regmap, |
| 241 | 241 | .disable = regulator_disable_regmap, |
| 242 | 242 | .is_enabled = regulator_is_enabled_regmap, |
| @@ -245,6 +245,8 @@ static struct regulator_ops act8865_ldo_ops = { · 2 unmodified lines | ||
| 245 | 245 | #define ACT88xx_REG(_name, _family, _id, _vsel_reg, _supply) \ |
| 246 | 246 | [_family##_ID_##_id] = { \ |
| 247 | 247 | .name = _name, \ |
| 248 | + .of_match = of_match_ptr(_name), \ | |
| 249 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 248 | 250 | .supply_name = _supply, \ |
| 249 | 251 | .id = _family##_ID_##_id, \ |
| 250 | 252 | .type = REGULATOR_VOLTAGE, \ |
| @@ -265,6 +267,8 @@ static const struct regulator_desc act8600_regulators[] = { · 14 unmodified lines | ||
| 265 | 267 | ACT88xx_REG("DCDC3", ACT8600, DCDC3, VSET, "vp3"), |
| 266 | 268 | { |
| 267 | 269 | .name = "SUDCDC_REG4", |
| 270 | + .of_match = of_match_ptr("SUDCDC_REG4"), | |
| 271 | + .regulators_node = of_match_ptr("regulators"), | |
| 268 | 272 | .id = ACT8600_ID_SUDCDC4, |
| 269 | 273 | .ops = &act8865_ops, |
| 270 | 274 | .type = REGULATOR_VOLTAGE, |
| @@ -283,6 +287,8 @@ static const struct regulator_desc act8600_regulators[] = { · 12 unmodified lines | ||
| 283 | 287 | ACT88xx_REG("LDO8", ACT8600, LDO8, VSET, "inl"), |
| 284 | 288 | { |
| 285 | 289 | .name = "LDO_REG9", |
| 290 | + .of_match = of_match_ptr("LDO_REG9"), | |
| 291 | + .regulators_node = of_match_ptr("regulators"), | |
| 286 | 292 | .id = ACT8600_ID_LDO9, |
| 287 | 293 | .ops = &act8865_ldo_ops, |
| 288 | 294 | .type = REGULATOR_VOLTAGE, |
| @@ -294,6 +300,8 @@ static const struct regulator_desc act8600_regulators[] = { · 5 unmodified lines | ||
| 294 | 300 | }, |
| 295 | 301 | { |
| 296 | 302 | .name = "LDO_REG10", |
| 303 | + .of_match = of_match_ptr("LDO_REG10"), | |
| 304 | + .regulators_node = of_match_ptr("regulators"), | |
| 297 | 305 | .id = ACT8600_ID_LDO10, |
| 298 | 306 | .ops = &act8865_ldo_ops, |
| 299 | 307 | .type = REGULATOR_VOLTAGE, |
| @@ -348,110 +356,6 @@ static const struct of_device_id act8865_dt_ids[] = { · 48 unmodified lines | ||
| 348 | 356 | { } |
| 349 | 357 | }; |
| 350 | 358 | MODULE_DEVICE_TABLE(of, act8865_dt_ids); |
| 351 | − | |
| 352 | −static struct of_regulator_match act8846_matches[] = { | |
| 353 | − [ACT8846_ID_REG1] = { .name = "REG1" }, | |
| 354 | − [ACT8846_ID_REG2] = { .name = "REG2" }, | |
| 355 | − [ACT8846_ID_REG3] = { .name = "REG3" }, | |
| 356 | − [ACT8846_ID_REG4] = { .name = "REG4" }, | |
| 357 | − [ACT8846_ID_REG5] = { .name = "REG5" }, | |
| 358 | − [ACT8846_ID_REG6] = { .name = "REG6" }, | |
| 359 | − [ACT8846_ID_REG7] = { .name = "REG7" }, | |
| 360 | − [ACT8846_ID_REG8] = { .name = "REG8" }, | |
| 361 | − [ACT8846_ID_REG9] = { .name = "REG9" }, | |
| 362 | − [ACT8846_ID_REG10] = { .name = "REG10" }, | |
| 363 | − [ACT8846_ID_REG11] = { .name = "REG11" }, | |
| 364 | − [ACT8846_ID_REG12] = { .name = "REG12" }, | |
| 365 | −}; | |
| 366 | − | |
| 367 | −static struct of_regulator_match act8865_matches[] = { | |
| 368 | − [ACT8865_ID_DCDC1] = { .name = "DCDC_REG1"}, | |
| 369 | − [ACT8865_ID_DCDC2] = { .name = "DCDC_REG2"}, | |
| 370 | − [ACT8865_ID_DCDC3] = { .name = "DCDC_REG3"}, | |
| 371 | − [ACT8865_ID_LDO1] = { .name = "LDO_REG1"}, | |
| 372 | − [ACT8865_ID_LDO2] = { .name = "LDO_REG2"}, | |
| 373 | − [ACT8865_ID_LDO3] = { .name = "LDO_REG3"}, | |
| 374 | − [ACT8865_ID_LDO4] = { .name = "LDO_REG4"}, | |
| 375 | −}; | |
| 376 | − | |
| 377 | −static struct of_regulator_match act8600_matches[] = { | |
| 378 | − [ACT8600_ID_DCDC1] = { .name = "DCDC_REG1"}, | |
| 379 | − [ACT8600_ID_DCDC2] = { .name = "DCDC_REG2"}, | |
| 380 | − [ACT8600_ID_DCDC3] = { .name = "DCDC_REG3"}, | |
| 381 | − [ACT8600_ID_SUDCDC4] = { .name = "SUDCDC_REG4"}, | |
| 382 | − [ACT8600_ID_LDO5] = { .name = "LDO_REG5"}, | |
| 383 | − [ACT8600_ID_LDO6] = { .name = "LDO_REG6"}, | |
| 384 | − [ACT8600_ID_LDO7] = { .name = "LDO_REG7"}, | |
| 385 | − [ACT8600_ID_LDO8] = { .name = "LDO_REG8"}, | |
| 386 | − [ACT8600_ID_LDO9] = { .name = "LDO_REG9"}, | |
| 387 | − [ACT8600_ID_LDO10] = { .name = "LDO_REG10"}, | |
| 388 | −}; | |
| 389 | − | |
| 390 | −static int act8865_pdata_from_dt(struct device *dev, | |
| 391 | − struct act8865_platform_data *pdata, | |
| 392 | − unsigned long type) | |
| 393 | −{ | |
| 394 | − int matched, i, num_matches; | |
| 395 | − struct device_node *np; | |
| 396 | − struct act8865_regulator_data *regulator; | |
| 397 | − struct of_regulator_match *matches; | |
| 398 | − | |
| 399 | − switch (type) { | |
| 400 | − case ACT8600: | |
| 401 | − matches = act8600_matches; | |
| 402 | − num_matches = ARRAY_SIZE(act8600_matches); | |
| 403 | − break; | |
| 404 | − case ACT8846: | |
| 405 | − matches = act8846_matches; | |
| 406 | − num_matches = ARRAY_SIZE(act8846_matches); | |
| 407 | − break; | |
| 408 | − case ACT8865: | |
| 409 | − matches = act8865_matches; | |
| 410 | − num_matches = ARRAY_SIZE(act8865_matches); | |
| 411 | − break; | |
| 412 | − default: | |
| 413 | − dev_err(dev, "invalid device id %lu\n", type); | |
| 414 | − return -EINVAL; | |
| 415 | − } | |
| 416 | − | |
| 417 | − np = of_get_child_by_name(dev->of_node, "regulators"); | |
| 418 | − if (!np) { | |
| 419 | − dev_err(dev, "missing 'regulators' subnode in DT\n"); | |
| 420 | − return -EINVAL; | |
| 421 | − } | |
| 422 | − | |
| 423 | − matched = of_regulator_match(dev, np, matches, num_matches); | |
| 424 | − of_node_put(np); | |
| 425 | − if (matched <= 0) | |
| 426 | − return matched; | |
| 427 | − | |
| 428 | − pdata->regulators = devm_kcalloc(dev, | |
| 429 | − num_matches, | |
| 430 | − sizeof(struct act8865_regulator_data), | |
| 431 | − GFP_KERNEL); | |
| 432 | − if (!pdata->regulators) | |
| 433 | − return -ENOMEM; | |
| 434 | − | |
| 435 | − pdata->num_regulators = num_matches; | |
| 436 | − regulator = pdata->regulators; | |
| 437 | − | |
| 438 | − for (i = 0; i < num_matches; i++) { | |
| 439 | − regulator->id = i; | |
| 440 | − regulator->name = matches[i].name; | |
| 441 | − regulator->init_data = matches[i].init_data; | |
| 442 | − regulator->of_node = matches[i].of_node; | |
| 443 | − regulator++; | |
| 444 | − } | |
| 445 | − | |
| 446 | − return 0; | |
| 447 | −} | |
| 448 | −#else | |
| 449 | −static inline int act8865_pdata_from_dt(struct device *dev, | |
| 450 | − struct act8865_platform_data *pdata, | |
| 451 | − unsigned long type) | |
| 452 | −{ | |
| 453 | − return 0; | |
| 454 | −} | |
| 455 | 359 | #endif |
| 456 | 360 | |
| 457 | 361 | static struct act8865_regulator_data *act8865_get_regulator_data( |
| @@ -459,9 +363,6 @@ static struct act8865_regulator_data *act8865_get_regulator_data( · 1 unmodified line | ||
| 459 | 363 | { |
| 460 | 364 | int i; |
| 461 | 365 | |
| 462 | − if (!pdata) | |
| 463 | − return NULL; | |
| 464 | − | |
| 465 | 366 | for (i = 0; i < pdata->num_regulators; i++) { |
| 466 | 367 | if (pdata->regulators[i].id == id) |
| 467 | 368 | return &pdata->regulators[i]; |
| @@ -484,7 +385,7 @@ static int act8865_pmic_probe(struct i2c_client *client, · 16 unmodified lines | ||
| 484 | 385 | const struct i2c_device_id *i2c_id) |
| 485 | 386 | { |
| 486 | 387 | const struct regulator_desc *regulators; |
| 487 | − struct act8865_platform_data pdata_of, *pdata; | |
| 388 | + struct act8865_platform_data *pdata = NULL; | |
| 488 | 389 | struct device *dev = &client->dev; |
| 489 | 390 | int i, ret, num_regulators; |
| 490 | 391 | struct act8865 *act8865; |
| @@ -493,9 +394,7 @@ static int act8865_pmic_probe(struct i2c_client *client, · 2 unmodified lines | ||
| 493 | 394 | int off_reg, off_mask; |
| 494 | 395 | int voltage_select = 0; |
| 495 | 396 | |
| 496 | − pdata = dev_get_platdata(dev); | |
| 497 | − | |
| 498 | − if (dev->of_node && !pdata) { | |
| 397 | + if (dev->of_node) { | |
| 499 | 398 | const struct of_device_id *id; |
| 500 | 399 | |
| 501 | 400 | id = of_match_device(of_match_ptr(act8865_dt_ids), dev); |
| @@ -509,6 +408,7 @@ static int act8865_pmic_probe(struct i2c_client *client, · 7 unmodified lines | ||
| 509 | 408 | NULL); |
| 510 | 409 | } else { |
| 511 | 410 | type = i2c_id->driver_data; |
| 411 | + pdata = dev_get_platdata(dev); | |
| 512 | 412 | } |
| 513 | 413 | |
| 514 | 414 | switch (type) { |
| @@ -543,14 +443,6 @@ static int act8865_pmic_probe(struct i2c_client *client, · 28 unmodified lines | ||
| 543 | 443 | return -EINVAL; |
| 544 | 444 | } |
| 545 | 445 | |
| 546 | − if (dev->of_node && !pdata) { | |
| 547 | − ret = act8865_pdata_from_dt(dev, &pdata_of, type); | |
| 548 | − if (ret < 0) | |
| 549 | − return ret; | |
| 550 | − | |
| 551 | − pdata = &pdata_of; | |
| 552 | − } | |
| 553 | − | |
| 554 | 446 | act8865 = devm_kzalloc(dev, sizeof(struct act8865), GFP_KERNEL); |
| 555 | 447 | if (!act8865) |
| 556 | 448 | return -ENOMEM; |
| @@ -577,17 +469,20 @@ static int act8865_pmic_probe(struct i2c_client *client, · 20 unmodified lines | ||
| 577 | 469 | for (i = 0; i < num_regulators; i++) { |
| 578 | 470 | const struct regulator_desc *desc = ®ulators[i]; |
| 579 | 471 | struct regulator_config config = { }; |
| 580 | − struct act8865_regulator_data *rdata; | |
| 581 | 472 | struct regulator_dev *rdev; |
| 582 | 473 | |
| 583 | 474 | config.dev = dev; |
| 584 | 475 | config.driver_data = act8865; |
| 585 | 476 | config.regmap = act8865->regmap; |
| 586 | 477 | |
| 587 | − rdata = act8865_get_regulator_data(desc->id, pdata); | |
| 588 | − if (rdata) { | |
| 589 | − config.init_data = rdata->init_data; | |
| 590 | − config.of_node = rdata->of_node; | |
| 478 | + if (pdata) { | |
| 479 | + struct act8865_regulator_data *rdata; | |
| 480 | + | |
| 481 | + rdata = act8865_get_regulator_data(desc->id, pdata); | |
| 482 | + if (rdata) { | |
| 483 | + config.init_data = rdata->init_data; | |
| 484 | + config.of_node = rdata->of_node; | |
| 485 | + } | |
| 591 | 486 | } |
| 592 | 487 | |
| 593 | 488 | rdev = devm_regulator_register(dev, desc, &config); |
| @@ -23,18 +23,10 @@ · 22 unmodified lines | ||
| 23 | 23 | #define LDO_FET_FULL_ON 0x1f |
| 24 | 24 | |
| 25 | 25 | struct anatop_regulator { |
| 26 | − u32 control_reg; | |
| 27 | − struct regmap *anatop; | |
| 28 | − int vol_bit_shift; | |
| 29 | − int vol_bit_width; | |
| 30 | 26 | u32 delay_reg; |
| 31 | 27 | int delay_bit_shift; |
| 32 | 28 | int delay_bit_width; |
| 33 | − int min_bit_val; | |
| 34 | − int min_voltage; | |
| 35 | − int max_voltage; | |
| 36 | 29 | struct regulator_desc rdesc; |
| 37 | − struct regulator_init_data *initdata; | |
| 38 | 30 | bool bypass; |
| 39 | 31 | int sel; |
| 40 | 32 | }; |
| @@ -55,7 +47,7 @@ static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg, · 14 unmodified lines | ||
| 55 | 47 | * to calculate how many steps LDO need to |
| 56 | 48 | * ramp up, and how much delay needed. (us) |
| 57 | 49 | */ |
| 58 | − regmap_read(anatop_reg->anatop, anatop_reg->delay_reg, &val); | |
| 50 | + regmap_read(reg->regmap, anatop_reg->delay_reg, &val); | |
| 59 | 51 | val = (val >> anatop_reg->delay_bit_shift) & |
| 60 | 52 | ((1 << anatop_reg->delay_bit_width) - 1); |
| 61 | 53 | ret = (new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES << |
| @@ -170,6 +162,13 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 108 unmodified lines | ||
| 170 | 162 | struct anatop_regulator *sreg; |
| 171 | 163 | struct regulator_init_data *initdata; |
| 172 | 164 | struct regulator_config config = { }; |
| 165 | + struct regmap *regmap; | |
| 166 | + u32 control_reg; | |
| 167 | + u32 vol_bit_shift; | |
| 168 | + u32 vol_bit_width; | |
| 169 | + u32 min_bit_val; | |
| 170 | + u32 min_voltage; | |
| 171 | + u32 max_voltage; | |
| 173 | 172 | int ret = 0; |
| 174 | 173 | u32 val; |
| 175 | 174 | |
| @@ -192,48 +191,41 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 16 unmodified lines | ||
| 192 | 191 | return -ENOMEM; |
| 193 | 192 | |
| 194 | 193 | initdata->supply_regulator = "vin"; |
| 195 | − sreg->initdata = initdata; | |
| 196 | 194 | |
| 197 | 195 | anatop_np = of_get_parent(np); |
| 198 | 196 | if (!anatop_np) |
| 199 | 197 | return -ENODEV; |
| 200 | − sreg->anatop = syscon_node_to_regmap(anatop_np); | |
| 198 | + regmap = syscon_node_to_regmap(anatop_np); | |
| 201 | 199 | of_node_put(anatop_np); |
| 202 | − if (IS_ERR(sreg->anatop)) | |
| 203 | − return PTR_ERR(sreg->anatop); | |
| 200 | + if (IS_ERR(regmap)) | |
| 201 | + return PTR_ERR(regmap); | |
| 204 | 202 | |
| 205 | − ret = of_property_read_u32(np, "anatop-reg-offset", | |
| 206 | − &sreg->control_reg); | |
| 203 | + ret = of_property_read_u32(np, "anatop-reg-offset", &control_reg); | |
| 207 | 204 | if (ret) { |
| 208 | 205 | dev_err(dev, "no anatop-reg-offset property set\n"); |
| 209 | 206 | return ret; |
| 210 | 207 | } |
| 211 | − ret = of_property_read_u32(np, "anatop-vol-bit-width", | |
| 212 | − &sreg->vol_bit_width); | |
| 208 | + ret = of_property_read_u32(np, "anatop-vol-bit-width", &vol_bit_width); | |
| 213 | 209 | if (ret) { |
| 214 | 210 | dev_err(dev, "no anatop-vol-bit-width property set\n"); |
| 215 | 211 | return ret; |
| 216 | 212 | } |
| 217 | − ret = of_property_read_u32(np, "anatop-vol-bit-shift", | |
| 218 | − &sreg->vol_bit_shift); | |
| 213 | + ret = of_property_read_u32(np, "anatop-vol-bit-shift", &vol_bit_shift); | |
| 219 | 214 | if (ret) { |
| 220 | 215 | dev_err(dev, "no anatop-vol-bit-shift property set\n"); |
| 221 | 216 | return ret; |
| 222 | 217 | } |
| 223 | − ret = of_property_read_u32(np, "anatop-min-bit-val", | |
| 224 | − &sreg->min_bit_val); | |
| 218 | + ret = of_property_read_u32(np, "anatop-min-bit-val", &min_bit_val); | |
| 225 | 219 | if (ret) { |
| 226 | 220 | dev_err(dev, "no anatop-min-bit-val property set\n"); |
| 227 | 221 | return ret; |
| 228 | 222 | } |
| 229 | − ret = of_property_read_u32(np, "anatop-min-voltage", | |
| 230 | − &sreg->min_voltage); | |
| 223 | + ret = of_property_read_u32(np, "anatop-min-voltage", &min_voltage); | |
| 231 | 224 | if (ret) { |
| 232 | 225 | dev_err(dev, "no anatop-min-voltage property set\n"); |
| 233 | 226 | return ret; |
| 234 | 227 | } |
| 235 | − ret = of_property_read_u32(np, "anatop-max-voltage", | |
| 236 | − &sreg->max_voltage); | |
| 228 | + ret = of_property_read_u32(np, "anatop-max-voltage", &max_voltage); | |
| 237 | 229 | if (ret) { |
| 238 | 230 | dev_err(dev, "no anatop-max-voltage property set\n"); |
| 239 | 231 | return ret; |
| @@ -247,24 +239,23 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 247 | 239 | of_property_read_u32(np, "anatop-delay-bit-shift", |
| 248 | 240 | &sreg->delay_bit_shift); |
| 249 | 241 | |
| 250 | − rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 | |
| 251 | − + sreg->min_bit_val; | |
| 252 | − rdesc->min_uV = sreg->min_voltage; | |
| 242 | + rdesc->n_voltages = (max_voltage - min_voltage) / 25000 + 1 | |
| 243 | + + min_bit_val; | |
| 244 | + rdesc->min_uV = min_voltage; | |
| 253 | 245 | rdesc->uV_step = 25000; |
| 254 | − rdesc->linear_min_sel = sreg->min_bit_val; | |
| 255 | − rdesc->vsel_reg = sreg->control_reg; | |
| 256 | − rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) << | |
| 257 | − sreg->vol_bit_shift; | |
| 246 | + rdesc->linear_min_sel = min_bit_val; | |
| 247 | + rdesc->vsel_reg = control_reg; | |
| 248 | + rdesc->vsel_mask = ((1 << vol_bit_width) - 1) << vol_bit_shift; | |
| 258 | 249 | rdesc->min_dropout_uV = 125000; |
| 259 | 250 | |
| 260 | 251 | config.dev = &pdev->dev; |
| 261 | 252 | config.init_data = initdata; |
| 262 | 253 | config.driver_data = sreg; |
| 263 | 254 | config.of_node = pdev->dev.of_node; |
| 264 | − config.regmap = sreg->anatop; | |
| 255 | + config.regmap = regmap; | |
| 265 | 256 | |
| 266 | 257 | /* Only core regulators have the ramp up delay configuration. */ |
| 267 | − if (sreg->control_reg && sreg->delay_bit_width) { | |
| 258 | + if (control_reg && sreg->delay_bit_width) { | |
| 268 | 259 | rdesc->ops = &anatop_core_rops; |
| 269 | 260 | |
| 270 | 261 | ret = regmap_read(config.regmap, rdesc->vsel_reg, &val); |
| @@ -273,7 +264,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 273 | 264 | return ret; |
| 274 | 265 | } |
| 275 | 266 | |
| 276 | − sreg->sel = (val & rdesc->vsel_mask) >> sreg->vol_bit_shift; | |
| 267 | + sreg->sel = (val & rdesc->vsel_mask) >> vol_bit_shift; | |
| 277 | 268 | if (sreg->sel == LDO_FET_FULL_ON) { |
| 278 | 269 | sreg->sel = 0; |
| 279 | 270 | sreg->bypass = true; |
| @@ -306,7 +297,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 26 unmodified lines | ||
| 306 | 297 | anatop_rops.disable = regulator_disable_regmap; |
| 307 | 298 | anatop_rops.is_enabled = regulator_is_enabled_regmap; |
| 308 | 299 | |
| 309 | − rdesc->enable_reg = sreg->control_reg; | |
| 300 | + rdesc->enable_reg = control_reg; | |
| 310 | 301 | rdesc->enable_mask = BIT(enable_bit); |
| 311 | 302 | } |
| 312 | 303 | } |
| @@ -1,15 +1,10 @@ | ||
| 1 | −/* | |
| 2 | − * arizona-ldo1.c -- LDO1 supply for Arizona devices | |
| 3 | − * | |
| 4 | − * Copyright 2012 Wolfson Microelectronics PLC. | |
| 5 | − * | |
| 6 | − * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 7 | − * | |
| 8 | − * This program is free software; you can redistribute it and/or modify it | |
| 9 | − * under the terms of the GNU General Public License as published by the | |
| 10 | − * Free Software Foundation; either version 2 of the License, or (at your | |
| 11 | − * option) any later version. | |
| 12 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// arizona-ldo1.c -- LDO1 supply for Arizona devices | |
| 4 | +// | |
| 5 | +// Copyright 2012 Wolfson Microelectronics PLC. | |
| 6 | +// | |
| 7 | +// Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 13 | 8 | |
| 14 | 9 | #include <linux/module.h> |
| 15 | 10 | #include <linux/moduleparam.h> |
| @@ -1,15 +1,10 @@ | ||
| 1 | −/* | |
| 2 | − * arizona-micsupp.c -- Microphone supply for Arizona devices | |
| 3 | − * | |
| 4 | − * Copyright 2012 Wolfson Microelectronics PLC. | |
| 5 | − * | |
| 6 | − * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 7 | − * | |
| 8 | − * This program is free software; you can redistribute it and/or modify it | |
| 9 | − * under the terms of the GNU General Public License as published by the | |
| 10 | − * Free Software Foundation; either version 2 of the License, or (at your | |
| 11 | − * option) any later version. | |
| 12 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// arizona-micsupp.c -- Microphone supply for Arizona devices | |
| 4 | +// | |
| 5 | +// Copyright 2012 Wolfson Microelectronics PLC. | |
| 6 | +// | |
| 7 | +// Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 13 | 8 | |
| 14 | 9 | #include <linux/module.h> |
| 15 | 10 | #include <linux/moduleparam.h> |
| @@ -17,14 +17,6 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <linux/regulator/of_regulator.h> |
| 18 | 18 | #include <linux/slab.h> |
| 19 | 19 | |
| 20 | −struct as3711_regulator_info { | |
| 21 | − struct regulator_desc desc; | |
| 22 | −}; | |
| 23 | − | |
| 24 | −struct as3711_regulator { | |
| 25 | − struct as3711_regulator_info *reg_info; | |
| 26 | −}; | |
| 27 | − | |
| 28 | 20 | /* |
| 29 | 21 | * The regulator API supports 4 modes of operataion: FAST, NORMAL, IDLE and |
| 30 | 22 | * STANDBY. We map them in the following way to AS3711 SD1-4 DCDC modes: |
| @@ -129,7 +121,6 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = { · 98 unmodified lines | ||
| 129 | 121 | |
| 130 | 122 | #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _sfx) \ |
| 131 | 123 | [AS3711_REGULATOR_ ## _id] = { \ |
| 132 | − .desc = { \ | |
| 133 | 124 | .name = "as3711-regulator-" # _id, \ |
| 134 | 125 | .id = AS3711_REGULATOR_ ## _id, \ |
| 135 | 126 | .n_voltages = (_vmask + 1), \ |
| @@ -142,10 +133,9 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = { · 6 unmodified lines | ||
| 142 | 133 | .enable_mask = BIT(_en_bit), \ |
| 143 | 134 | .linear_ranges = as3711_ ## _sfx ## _ranges, \ |
| 144 | 135 | .n_linear_ranges = ARRAY_SIZE(as3711_ ## _sfx ## _ranges), \ |
| 145 | − }, \ | |
| 146 | 136 | } |
| 147 | 137 | |
| 148 | −static struct as3711_regulator_info as3711_reg_info[] = { | |
| 138 | +static const struct regulator_desc as3711_reg_desc[] = { | |
| 149 | 139 | AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, sd), |
| 150 | 140 | AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, sd), |
| 151 | 141 | AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, sd), |
| @@ -161,7 +151,7 @@ static struct as3711_regulator_info as3711_reg_info[] = { · 9 unmodified lines | ||
| 161 | 151 | /* StepUp output voltage depends on supplying regulator */ |
| 162 | 152 | }; |
| 163 | 153 | |
| 164 | −#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info) | |
| 154 | +#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_desc) | |
| 165 | 155 | |
| 166 | 156 | static struct of_regulator_match |
| 167 | 157 | as3711_regulator_matches[AS3711_REGULATOR_NUM] = { |
| @@ -215,11 +205,8 @@ static int as3711_regulator_probe(struct platform_device *pdev) · 47 unmodified lines | ||
| 215 | 205 | struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev); |
| 216 | 206 | struct as3711 *as3711 = dev_get_drvdata(pdev->dev.parent); |
| 217 | 207 | struct regulator_config config = {.dev = &pdev->dev,}; |
| 218 | − struct as3711_regulator *reg = NULL; | |
| 219 | − struct as3711_regulator *regs; | |
| 220 | 208 | struct device_node *of_node[AS3711_REGULATOR_NUM] = {}; |
| 221 | 209 | struct regulator_dev *rdev; |
| 222 | − struct as3711_regulator_info *ri; | |
| 223 | 210 | int ret; |
| 224 | 211 | int id; |
| 225 | 212 | |
| @@ -236,30 +223,20 @@ static int as3711_regulator_probe(struct platform_device *pdev) · 10 unmodified lines | ||
| 236 | 223 | } |
| 237 | 224 | } |
| 238 | 225 | |
| 239 | − regs = devm_kcalloc(&pdev->dev, | |
| 240 | − AS3711_REGULATOR_NUM, | |
| 241 | − sizeof(struct as3711_regulator), | |
| 242 | − GFP_KERNEL); | |
| 243 | − if (!regs) | |
| 244 | − return -ENOMEM; | |
| 245 | − | |
| 246 | − for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) { | |
| 247 | − reg = ®s[id]; | |
| 248 | − reg->reg_info = ri; | |
| 249 | − | |
| 226 | + for (id = 0; id < AS3711_REGULATOR_NUM; id++) { | |
| 250 | 227 | config.init_data = pdata->init_data[id]; |
| 251 | − config.driver_data = reg; | |
| 252 | 228 | config.regmap = as3711->regmap; |
| 253 | 229 | config.of_node = of_node[id]; |
| 254 | 230 | |
| 255 | − rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); | |
| 231 | + rdev = devm_regulator_register(&pdev->dev, &as3711_reg_desc[id], | |
| 232 | + &config); | |
| 256 | 233 | if (IS_ERR(rdev)) { |
| 257 | 234 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
| 258 | − ri->desc.name); | |
| 235 | + as3711_reg_desc[id].name); | |
| 259 | 236 | return PTR_ERR(rdev); |
| 260 | 237 | } |
| 261 | 238 | } |
| 262 | − platform_set_drvdata(pdev, regs); | |
| 239 | + | |
| 263 | 240 | return 0; |
| 264 | 241 | } |
| 265 | 242 | |
| @@ -81,7 +81,6 @@ struct as3722_regulator_config_data { · 80 unmodified lines | ||
| 81 | 81 | struct as3722_regulators { |
| 82 | 82 | struct device *dev; |
| 83 | 83 | struct as3722 *as3722; |
| 84 | − struct regulator_dev *rdevs[AS3722_REGULATOR_ID_MAX]; | |
| 85 | 84 | struct regulator_desc desc[AS3722_REGULATOR_ID_MAX]; |
| 86 | 85 | struct as3722_regulator_config_data |
| 87 | 86 | reg_config_data[AS3722_REGULATOR_ID_MAX]; |
| @@ -314,63 +313,10 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { · 226 unmodified lines | ||
| 314 | 313 | }, |
| 315 | 314 | }; |
| 316 | 315 | |
| 317 | − | |
| 318 | −static const int as3722_ldo_current[] = { 150000, 300000 }; | |
| 319 | −static const int as3722_sd016_current[] = { 2500000, 3000000, 3500000 }; | |
| 320 | − | |
| 321 | −static int as3722_current_to_index(int min_uA, int max_uA, | |
| 322 | − const int *curr_table, int n_currents) | |
| 323 | −{ | |
| 324 | − int i; | |
| 325 | − | |
| 326 | − for (i = n_currents - 1; i >= 0; i--) { | |
| 327 | − if ((min_uA <= curr_table[i]) && (curr_table[i] <= max_uA)) | |
| 328 | − return i; | |
| 329 | − } | |
| 330 | − return -EINVAL; | |
| 331 | −} | |
| 332 | − | |
| 333 | −static int as3722_ldo_get_current_limit(struct regulator_dev *rdev) | |
| 334 | −{ | |
| 335 | − struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | |
| 336 | − struct as3722 *as3722 = as3722_regs->as3722; | |
| 337 | − int id = rdev_get_id(rdev); | |
| 338 | − u32 val; | |
| 339 | − int ret; | |
| 340 | − | |
| 341 | − ret = as3722_read(as3722, as3722_reg_lookup[id].vsel_reg, &val); | |
| 342 | − if (ret < 0) { | |
| 343 | − dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", | |
| 344 | − as3722_reg_lookup[id].vsel_reg, ret); | |
| 345 | − return ret; | |
| 346 | − } | |
| 347 | − if (val & AS3722_LDO_ILIMIT_MASK) | |
| 348 | − return 300000; | |
| 349 | − return 150000; | |
| 350 | −} | |
| 351 | − | |
| 352 | −static int as3722_ldo_set_current_limit(struct regulator_dev *rdev, | |
| 353 | − int min_uA, int max_uA) | |
| 354 | −{ | |
| 355 | − struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | |
| 356 | − struct as3722 *as3722 = as3722_regs->as3722; | |
| 357 | − int id = rdev_get_id(rdev); | |
| 358 | − int ret; | |
| 359 | − u32 reg = 0; | |
| 360 | − | |
| 361 | − ret = as3722_current_to_index(min_uA, max_uA, as3722_ldo_current, | |
| 362 | − ARRAY_SIZE(as3722_ldo_current)); | |
| 363 | − if (ret < 0) { | |
| 364 | − dev_err(as3722_regs->dev, | |
| 365 | − "Current range min:max = %d:%d does not support\n", | |
| 366 | − min_uA, max_uA); | |
| 367 | − return ret; | |
| 368 | − } | |
| 369 | − if (ret) | |
| 370 | − reg = AS3722_LDO_ILIMIT_BIT; | |
| 371 | − return as3722_update_bits(as3722, as3722_reg_lookup[id].vsel_reg, | |
| 372 | − AS3722_LDO_ILIMIT_MASK, reg); | |
| 373 | −} | |
| 316 | +static const unsigned int as3722_ldo_current[] = { 150000, 300000 }; | |
| 317 | +static const unsigned int as3722_sd016_current[] = { | |
| 318 | + 2500000, 3000000, 3500000 | |
| 319 | +}; | |
| 374 | 320 | |
| 375 | 321 | static const struct regulator_ops as3722_ldo0_ops = { |
| 376 | 322 | .is_enabled = regulator_is_enabled_regmap, |
| @@ -379,16 +325,16 @@ static const struct regulator_ops as3722_ldo0_ops = { · 2 unmodified lines | ||
| 379 | 325 | .list_voltage = regulator_list_voltage_linear, |
| 380 | 326 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 381 | 327 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 382 | − .get_current_limit = as3722_ldo_get_current_limit, | |
| 383 | − .set_current_limit = as3722_ldo_set_current_limit, | |
| 328 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 329 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 384 | 330 | }; |
| 385 | 331 | |
| 386 | 332 | static const struct regulator_ops as3722_ldo0_extcntrl_ops = { |
| 387 | 333 | .list_voltage = regulator_list_voltage_linear, |
| 388 | 334 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 389 | 335 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 390 | − .get_current_limit = as3722_ldo_get_current_limit, | |
| 391 | − .set_current_limit = as3722_ldo_set_current_limit, | |
| 336 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 337 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 392 | 338 | }; |
| 393 | 339 | |
| 394 | 340 | static int as3722_ldo3_set_tracking_mode(struct as3722_regulators *as3722_reg, |
| @@ -440,8 +386,8 @@ static const struct regulator_ops as3722_ldo6_ops = { · 45 unmodified lines | ||
| 440 | 386 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 441 | 387 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 442 | 388 | .list_voltage = regulator_list_voltage_linear_range, |
| 443 | − .get_current_limit = as3722_ldo_get_current_limit, | |
| 444 | − .set_current_limit = as3722_ldo_set_current_limit, | |
| 389 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 390 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 445 | 391 | .get_bypass = regulator_get_bypass_regmap, |
| 446 | 392 | .set_bypass = regulator_set_bypass_regmap, |
| 447 | 393 | }; |
| @@ -451,8 +397,8 @@ static const struct regulator_ops as3722_ldo6_extcntrl_ops = { · 3 unmodified lines | ||
| 451 | 397 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 452 | 398 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 453 | 399 | .list_voltage = regulator_list_voltage_linear_range, |
| 454 | − .get_current_limit = as3722_ldo_get_current_limit, | |
| 455 | − .set_current_limit = as3722_ldo_set_current_limit, | |
| 400 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 401 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 456 | 402 | .get_bypass = regulator_get_bypass_regmap, |
| 457 | 403 | .set_bypass = regulator_set_bypass_regmap, |
| 458 | 404 | }; |
| @@ -471,8 +417,8 @@ static const struct regulator_ops as3722_ldo_ops = { · 12 unmodified lines | ||
| 471 | 417 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 472 | 418 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 473 | 419 | .list_voltage = regulator_list_voltage_linear_range, |
| 474 | − .get_current_limit = as3722_ldo_get_current_limit, | |
| 475 | − .set_current_limit = as3722_ldo_set_current_limit, | |
| 420 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 421 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 476 | 422 | }; |
| 477 | 423 | |
| 478 | 424 | static const struct regulator_ops as3722_ldo_extcntrl_ops = { |
| @@ -480,8 +426,8 @@ static const struct regulator_ops as3722_ldo_extcntrl_ops = { · 1 unmodified line | ||
| 480 | 426 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 481 | 427 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 482 | 428 | .list_voltage = regulator_list_voltage_linear_range, |
| 483 | − .get_current_limit = as3722_ldo_get_current_limit, | |
| 484 | − .set_current_limit = as3722_ldo_set_current_limit, | |
| 429 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 430 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 485 | 431 | }; |
| 486 | 432 | |
| 487 | 433 | static unsigned int as3722_sd_get_mode(struct regulator_dev *rdev) |
| @@ -539,85 +485,6 @@ static int as3722_sd_set_mode(struct regulator_dev *rdev, · 51 unmodified lines | ||
| 539 | 485 | return ret; |
| 540 | 486 | } |
| 541 | 487 | |
| 542 | −static int as3722_sd016_get_current_limit(struct regulator_dev *rdev) | |
| 543 | −{ | |
| 544 | − struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | |
| 545 | − struct as3722 *as3722 = as3722_regs->as3722; | |
| 546 | − int id = rdev_get_id(rdev); | |
| 547 | − u32 val, reg; | |
| 548 | − int mask; | |
| 549 | − int ret; | |
| 550 | − | |
| 551 | − switch (id) { | |
| 552 | − case AS3722_REGULATOR_ID_SD0: | |
| 553 | − reg = AS3722_OVCURRENT_REG; | |
| 554 | − mask = AS3722_OVCURRENT_SD0_TRIP_MASK; | |
| 555 | − break; | |
| 556 | − case AS3722_REGULATOR_ID_SD1: | |
| 557 | − reg = AS3722_OVCURRENT_REG; | |
| 558 | − mask = AS3722_OVCURRENT_SD1_TRIP_MASK; | |
| 559 | − break; | |
| 560 | − case AS3722_REGULATOR_ID_SD6: | |
| 561 | − reg = AS3722_OVCURRENT_DEB_REG; | |
| 562 | − mask = AS3722_OVCURRENT_SD6_TRIP_MASK; | |
| 563 | − break; | |
| 564 | − default: | |
| 565 | − return -EINVAL; | |
| 566 | − } | |
| 567 | − ret = as3722_read(as3722, reg, &val); | |
| 568 | − if (ret < 0) { | |
| 569 | − dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", | |
| 570 | − reg, ret); | |
| 571 | − return ret; | |
| 572 | − } | |
| 573 | − val &= mask; | |
| 574 | − val >>= ffs(mask) - 1; | |
| 575 | − if (val == 3) | |
| 576 | − return -EINVAL; | |
| 577 | − return as3722_sd016_current[val]; | |
| 578 | −} | |
| 579 | − | |
| 580 | −static int as3722_sd016_set_current_limit(struct regulator_dev *rdev, | |
| 581 | − int min_uA, int max_uA) | |
| 582 | −{ | |
| 583 | − struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); | |
| 584 | − struct as3722 *as3722 = as3722_regs->as3722; | |
| 585 | − int id = rdev_get_id(rdev); | |
| 586 | − int ret; | |
| 587 | − int val; | |
| 588 | − int mask; | |
| 589 | − u32 reg; | |
| 590 | − | |
| 591 | − ret = as3722_current_to_index(min_uA, max_uA, as3722_sd016_current, | |
| 592 | − ARRAY_SIZE(as3722_sd016_current)); | |
| 593 | − if (ret < 0) { | |
| 594 | − dev_err(as3722_regs->dev, | |
| 595 | − "Current range min:max = %d:%d does not support\n", | |
| 596 | − min_uA, max_uA); | |
| 597 | − return ret; | |
| 598 | − } | |
| 599 | − | |
| 600 | − switch (id) { | |
| 601 | − case AS3722_REGULATOR_ID_SD0: | |
| 602 | − reg = AS3722_OVCURRENT_REG; | |
| 603 | − mask = AS3722_OVCURRENT_SD0_TRIP_MASK; | |
| 604 | − break; | |
| 605 | − case AS3722_REGULATOR_ID_SD1: | |
| 606 | − reg = AS3722_OVCURRENT_REG; | |
| 607 | − mask = AS3722_OVCURRENT_SD1_TRIP_MASK; | |
| 608 | − break; | |
| 609 | − case AS3722_REGULATOR_ID_SD6: | |
| 610 | − reg = AS3722_OVCURRENT_DEB_REG; | |
| 611 | − mask = AS3722_OVCURRENT_SD6_TRIP_MASK; | |
| 612 | − break; | |
| 613 | − default: | |
| 614 | − return -EINVAL; | |
| 615 | − } | |
| 616 | − ret <<= ffs(mask) - 1; | |
| 617 | − val = ret & mask; | |
| 618 | − return as3722_update_bits(as3722, reg, mask, val); | |
| 619 | −} | |
| 620 | − | |
| 621 | 488 | static bool as3722_sd0_is_low_voltage(struct as3722_regulators *as3722_regs) |
| 622 | 489 | { |
| 623 | 490 | int err; |
| @@ -649,8 +516,8 @@ static const struct regulator_ops as3722_sd016_ops = { · 25 unmodified lines | ||
| 649 | 516 | .map_voltage = regulator_map_voltage_linear, |
| 650 | 517 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 651 | 518 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 652 | − .get_current_limit = as3722_sd016_get_current_limit, | |
| 653 | − .set_current_limit = as3722_sd016_set_current_limit, | |
| 519 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 520 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 654 | 521 | .get_mode = as3722_sd_get_mode, |
| 655 | 522 | .set_mode = as3722_sd_set_mode, |
| 656 | 523 | }; |
| @@ -660,8 +527,8 @@ static const struct regulator_ops as3722_sd016_extcntrl_ops = { · 3 unmodified lines | ||
| 660 | 527 | .map_voltage = regulator_map_voltage_linear, |
| 661 | 528 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 662 | 529 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 663 | − .get_current_limit = as3722_sd016_get_current_limit, | |
| 664 | − .set_current_limit = as3722_sd016_set_current_limit, | |
| 530 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 531 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 665 | 532 | .get_mode = as3722_sd_get_mode, |
| 666 | 533 | .set_mode = as3722_sd_set_mode, |
| 667 | 534 | }; |
| @@ -807,42 +674,45 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 139 unmodified lines | ||
| 807 | 674 | config.regmap = as3722->regmap; |
| 808 | 675 | |
| 809 | 676 | for (id = 0; id < AS3722_REGULATOR_ID_MAX; id++) { |
| 677 | + struct regulator_desc *desc; | |
| 678 | + | |
| 679 | + desc = &as3722_regs->desc[id]; | |
| 810 | 680 | reg_config = &as3722_regs->reg_config_data[id]; |
| 811 | 681 | |
| 812 | − as3722_regs->desc[id].name = as3722_reg_lookup[id].name; | |
| 813 | − as3722_regs->desc[id].supply_name = as3722_reg_lookup[id].sname; | |
| 814 | − as3722_regs->desc[id].id = as3722_reg_lookup[id].regulator_id; | |
| 815 | − as3722_regs->desc[id].n_voltages = | |
| 816 | − as3722_reg_lookup[id].n_voltages; | |
| 817 | − as3722_regs->desc[id].type = REGULATOR_VOLTAGE; | |
| 818 | − as3722_regs->desc[id].owner = THIS_MODULE; | |
| 819 | − as3722_regs->desc[id].enable_reg = | |
| 820 | − as3722_reg_lookup[id].enable_reg; | |
| 821 | − as3722_regs->desc[id].enable_mask = | |
| 822 | − as3722_reg_lookup[id].enable_mask; | |
| 823 | − as3722_regs->desc[id].vsel_reg = as3722_reg_lookup[id].vsel_reg; | |
| 824 | − as3722_regs->desc[id].vsel_mask = | |
| 825 | − as3722_reg_lookup[id].vsel_mask; | |
| 682 | + desc->name = as3722_reg_lookup[id].name; | |
| 683 | + desc->supply_name = as3722_reg_lookup[id].sname; | |
| 684 | + desc->id = as3722_reg_lookup[id].regulator_id; | |
| 685 | + desc->n_voltages = as3722_reg_lookup[id].n_voltages; | |
| 686 | + desc->type = REGULATOR_VOLTAGE; | |
| 687 | + desc->owner = THIS_MODULE; | |
| 688 | + desc->enable_reg = as3722_reg_lookup[id].enable_reg; | |
| 689 | + desc->enable_mask = as3722_reg_lookup[id].enable_mask; | |
| 690 | + desc->vsel_reg = as3722_reg_lookup[id].vsel_reg; | |
| 691 | + desc->vsel_mask = as3722_reg_lookup[id].vsel_mask; | |
| 826 | 692 | switch (id) { |
| 827 | 693 | case AS3722_REGULATOR_ID_LDO0: |
| 828 | 694 | if (reg_config->ext_control) |
| 829 | 695 | ops = &as3722_ldo0_extcntrl_ops; |
| 830 | 696 | else |
| 831 | 697 | ops = &as3722_ldo0_ops; |
| 832 | − as3722_regs->desc[id].min_uV = 825000; | |
| 833 | − as3722_regs->desc[id].uV_step = 25000; | |
| 834 | − as3722_regs->desc[id].linear_min_sel = 1; | |
| 835 | − as3722_regs->desc[id].enable_time = 500; | |
| 698 | + desc->min_uV = 825000; | |
| 699 | + desc->uV_step = 25000; | |
| 700 | + desc->linear_min_sel = 1; | |
| 701 | + desc->enable_time = 500; | |
| 702 | + desc->curr_table = as3722_ldo_current; | |
| 703 | + desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current); | |
| 704 | + desc->csel_reg = as3722_reg_lookup[id].vsel_reg; | |
| 705 | + desc->csel_mask = AS3722_LDO_ILIMIT_MASK; | |
| 836 | 706 | break; |
| 837 | 707 | case AS3722_REGULATOR_ID_LDO3: |
| 838 | 708 | if (reg_config->ext_control) |
| 839 | 709 | ops = &as3722_ldo3_extcntrl_ops; |
| 840 | 710 | else |
| 841 | 711 | ops = &as3722_ldo3_ops; |
| 842 | − as3722_regs->desc[id].min_uV = 620000; | |
| 843 | − as3722_regs->desc[id].uV_step = 20000; | |
| 844 | − as3722_regs->desc[id].linear_min_sel = 1; | |
| 845 | − as3722_regs->desc[id].enable_time = 500; | |
| 712 | + desc->min_uV = 620000; | |
| 713 | + desc->uV_step = 20000; | |
| 714 | + desc->linear_min_sel = 1; | |
| 715 | + desc->enable_time = 500; | |
| 846 | 716 | if (reg_config->enable_tracking) { |
| 847 | 717 | ret = as3722_ldo3_set_tracking_mode(as3722_regs, |
| 848 | 718 | id, AS3722_LDO3_MODE_PMOS_TRACKING); |
| @@ -859,18 +729,17 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 10 unmodified lines | ||
| 859 | 729 | ops = &as3722_ldo6_extcntrl_ops; |
| 860 | 730 | else |
| 861 | 731 | ops = &as3722_ldo6_ops; |
| 862 | − as3722_regs->desc[id].enable_time = 500; | |
| 863 | − as3722_regs->desc[id].bypass_reg = | |
| 864 | − AS3722_LDO6_VOLTAGE_REG; | |
| 865 | − as3722_regs->desc[id].bypass_mask = | |
| 866 | − AS3722_LDO_VSEL_MASK; | |
| 867 | − as3722_regs->desc[id].bypass_val_on = | |
| 868 | − AS3722_LDO6_VSEL_BYPASS; | |
| 869 | − as3722_regs->desc[id].bypass_val_off = | |
| 870 | − AS3722_LDO6_VSEL_BYPASS; | |
| 871 | − as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges; | |
| 872 | − as3722_regs->desc[id].n_linear_ranges = | |
| 873 | − ARRAY_SIZE(as3722_ldo_ranges); | |
| 732 | + desc->enable_time = 500; | |
| 733 | + desc->bypass_reg = AS3722_LDO6_VOLTAGE_REG; | |
| 734 | + desc->bypass_mask = AS3722_LDO_VSEL_MASK; | |
| 735 | + desc->bypass_val_on = AS3722_LDO6_VSEL_BYPASS; | |
| 736 | + desc->bypass_val_off = AS3722_LDO6_VSEL_BYPASS; | |
| 737 | + desc->linear_ranges = as3722_ldo_ranges; | |
| 738 | + desc->n_linear_ranges = ARRAY_SIZE(as3722_ldo_ranges); | |
| 739 | + desc->curr_table = as3722_ldo_current; | |
| 740 | + desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current); | |
| 741 | + desc->csel_reg = as3722_reg_lookup[id].vsel_reg; | |
| 742 | + desc->csel_mask = AS3722_LDO_ILIMIT_MASK; | |
| 874 | 743 | break; |
| 875 | 744 | case AS3722_REGULATOR_ID_SD0: |
| 876 | 745 | case AS3722_REGULATOR_ID_SD1: |
| @@ -889,9 +758,25 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 12 unmodified lines | ||
| 889 | 758 | AS3722_SD0_VSEL_MAX + 1; |
| 890 | 759 | as3722_regs->desc[id].min_uV = 610000; |
| 891 | 760 | } |
| 892 | − as3722_regs->desc[id].uV_step = 10000; | |
| 893 | − as3722_regs->desc[id].linear_min_sel = 1; | |
| 894 | − as3722_regs->desc[id].enable_time = 600; | |
| 761 | + desc->uV_step = 10000; | |
| 762 | + desc->linear_min_sel = 1; | |
| 763 | + desc->enable_time = 600; | |
| 764 | + desc->curr_table = as3722_sd016_current; | |
| 765 | + desc->n_current_limits = | |
| 766 | + ARRAY_SIZE(as3722_sd016_current); | |
| 767 | + if (id == AS3722_REGULATOR_ID_SD0) { | |
| 768 | + desc->csel_reg = AS3722_OVCURRENT_REG; | |
| 769 | + desc->csel_mask = | |
| 770 | + AS3722_OVCURRENT_SD0_TRIP_MASK; | |
| 771 | + } else if (id == AS3722_REGULATOR_ID_SD1) { | |
| 772 | + desc->csel_reg = AS3722_OVCURRENT_REG; | |
| 773 | + desc->csel_mask = | |
| 774 | + AS3722_OVCURRENT_SD1_TRIP_MASK; | |
| 775 | + } else if (id == AS3722_REGULATOR_ID_SD6) { | |
| 776 | + desc->csel_reg = AS3722_OVCURRENT_DEB_REG; | |
| 777 | + desc->csel_mask = | |
| 778 | + AS3722_OVCURRENT_SD6_TRIP_MASK; | |
| 779 | + } | |
| 895 | 780 | break; |
| 896 | 781 | case AS3722_REGULATOR_ID_SD2: |
| 897 | 782 | case AS3722_REGULATOR_ID_SD3: |
| @@ -901,9 +786,8 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 901 | 786 | ops = &as3722_sd2345_extcntrl_ops; |
| 902 | 787 | else |
| 903 | 788 | ops = &as3722_sd2345_ops; |
| 904 | − as3722_regs->desc[id].linear_ranges = | |
| 905 | − as3722_sd2345_ranges; | |
| 906 | − as3722_regs->desc[id].n_linear_ranges = | |
| 789 | + desc->linear_ranges = as3722_sd2345_ranges; | |
| 790 | + desc->n_linear_ranges = | |
| 907 | 791 | ARRAY_SIZE(as3722_sd2345_ranges); |
| 908 | 792 | break; |
| 909 | 793 | default: |
| @@ -911,17 +795,19 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 911 | 795 | ops = &as3722_ldo_extcntrl_ops; |
| 912 | 796 | else |
| 913 | 797 | ops = &as3722_ldo_ops; |
| 914 | − as3722_regs->desc[id].enable_time = 500; | |
| 915 | − as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges; | |
| 916 | − as3722_regs->desc[id].n_linear_ranges = | |
| 917 | − ARRAY_SIZE(as3722_ldo_ranges); | |
| 798 | + desc->enable_time = 500; | |
| 799 | + desc->linear_ranges = as3722_ldo_ranges; | |
| 800 | + desc->n_linear_ranges = ARRAY_SIZE(as3722_ldo_ranges); | |
| 801 | + desc->curr_table = as3722_ldo_current; | |
| 802 | + desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current); | |
| 803 | + desc->csel_reg = as3722_reg_lookup[id].vsel_reg; | |
| 804 | + desc->csel_mask = AS3722_LDO_ILIMIT_MASK; | |
| 918 | 805 | break; |
| 919 | 806 | } |
| 920 | − as3722_regs->desc[id].ops = ops; | |
| 807 | + desc->ops = ops; | |
| 921 | 808 | config.init_data = reg_config->reg_init; |
| 922 | 809 | config.of_node = as3722_regulator_matches[id].of_node; |
| 923 | − rdev = devm_regulator_register(&pdev->dev, | |
| 924 | − &as3722_regs->desc[id], &config); | |
| 810 | + rdev = devm_regulator_register(&pdev->dev, desc, &config); | |
| 925 | 811 | if (IS_ERR(rdev)) { |
| 926 | 812 | ret = PTR_ERR(rdev); |
| 927 | 813 | dev_err(&pdev->dev, "regulator %d register failed %d\n", |
| @@ -929,7 +815,6 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 929 | 815 | return ret; |
| 930 | 816 | } |
| 931 | 817 | |
| 932 | − as3722_regs->rdevs[id] = rdev; | |
| 933 | 818 | if (reg_config->ext_control) { |
| 934 | 819 | ret = regulator_enable_regmap(rdev); |
| 935 | 820 | if (ret < 0) { |
| @@ -367,16 +367,14 @@ static const int axp209_dcdc2_ldo3_slew_rates[] = { · 366 unmodified lines | ||
| 367 | 367 | static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) |
| 368 | 368 | { |
| 369 | 369 | struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); |
| 370 | − const struct regulator_desc *desc; | |
| 370 | + int id = rdev_get_id(rdev); | |
| 371 | 371 | u8 reg, mask, enable, cfg = 0xff; |
| 372 | 372 | const int *slew_rates; |
| 373 | 373 | int rate_count = 0; |
| 374 | 374 | |
| 375 | − desc = rdev->desc; | |
| 376 | − | |
| 377 | 375 | switch (axp20x->variant) { |
| 378 | 376 | case AXP209_ID: |
| 379 | − if (desc->id == AXP20X_DCDC2) { | |
| 377 | + if (id == AXP20X_DCDC2) { | |
| 380 | 378 | slew_rates = axp209_dcdc2_ldo3_slew_rates; |
| 381 | 379 | rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); |
| 382 | 380 | reg = AXP20X_DCDC2_LDO3_V_RAMP; |
| @@ -388,7 +386,7 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) · 5 unmodified lines | ||
| 388 | 386 | break; |
| 389 | 387 | } |
| 390 | 388 | |
| 391 | − if (desc->id == AXP20X_LDO3) { | |
| 389 | + if (id == AXP20X_LDO3) { | |
| 392 | 390 | slew_rates = axp209_dcdc2_ldo3_slew_rates; |
| 393 | 391 | rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); |
| 394 | 392 | reg = AXP20X_DCDC2_LDO3_V_RAMP; |
| @@ -435,16 +433,11 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) · 40 unmodified lines | ||
| 435 | 433 | static int axp20x_regulator_enable_regmap(struct regulator_dev *rdev) |
| 436 | 434 | { |
| 437 | 435 | struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); |
| 438 | − const struct regulator_desc *desc; | |
| 439 | − | |
| 440 | − if (!rdev) | |
| 441 | − return -EINVAL; | |
| 442 | − | |
| 443 | − desc = rdev->desc; | |
| 436 | + int id = rdev_get_id(rdev); | |
| 444 | 437 | |
| 445 | 438 | switch (axp20x->variant) { |
| 446 | 439 | case AXP209_ID: |
| 447 | − if ((desc->id == AXP20X_LDO3) && | |
| 440 | + if ((id == AXP20X_LDO3) && | |
| 448 | 441 | rdev->constraints && rdev->constraints->soft_start) { |
| 449 | 442 | int v_out; |
| 450 | 443 | int ret; |
| @@ -1028,7 +1021,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) · 577 unmodified lines | ||
| 1028 | 1021 | * (See include/linux/mfd/axp20x.h) |
| 1029 | 1022 | */ |
| 1030 | 1023 | reg = AXP803_DCDC_FREQ_CTRL; |
| 1031 | − /* Fall through to the check below.*/ | |
| 1024 | + /* Fall through - to the check below.*/ | |
| 1032 | 1025 | case AXP806_ID: |
| 1033 | 1026 | /* |
| 1034 | 1027 | * AXP806 also have DCDC work frequency setting register at a |
| @@ -1119,12 +1112,12 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work · 84 unmodified lines | ||
| 1119 | 1112 | break; |
| 1120 | 1113 | |
| 1121 | 1114 | case AXP806_ID: |
| 1122 | − reg = AXP806_DCDC_MODE_CTRL2; | |
| 1123 | 1115 | /* |
| 1124 | 1116 | * AXP806 DCDC regulator IDs have the same range as AXP22X. |
| 1125 | − * Fall through to the check below. | |
| 1126 | 1117 | * (See include/linux/mfd/axp20x.h) |
| 1127 | 1118 | */ |
| 1119 | + reg = AXP806_DCDC_MODE_CTRL2; | |
| 1120 | + /* Fall through - to the check below. */ | |
| 1128 | 1121 | case AXP221_ID: |
| 1129 | 1122 | case AXP223_ID: |
| 1130 | 1123 | case AXP809_ID: |
| @@ -103,10 +103,6 @@ · 102 unmodified lines | ||
| 103 | 103 | ((n > BCM590XX_REG_VSR) && (n < BCM590XX_REG_VBUS)) |
| 104 | 104 | #define BCM590XX_REG_IS_VBUS(n) (n == BCM590XX_REG_VBUS) |
| 105 | 105 | |
| 106 | −struct bcm590xx_board { | |
| 107 | − struct regulator_init_data *bcm590xx_pmu_init_data[BCM590XX_NUM_REGS]; | |
| 108 | −}; | |
| 109 | − | |
| 110 | 106 | /* LDO group A: supported voltages in microvolts */ |
| 111 | 107 | static const unsigned int ldo_a_table[] = { |
| 112 | 108 | 1200000, 1800000, 2500000, 2700000, 2800000, |
| @@ -280,105 +276,15 @@ static const struct regulator_ops bcm590xx_ops_vbus = { · 167 unmodified lines | ||
| 280 | 276 | .disable = regulator_disable_regmap, |
| 281 | 277 | }; |
| 282 | 278 | |
| 283 | −#define BCM590XX_MATCH(_name, _id) \ | |
| 284 | − { \ | |
| 285 | − .name = #_name, \ | |
| 286 | − .driver_data = (void *)&bcm590xx_regs[BCM590XX_REG_##_id], \ | |
| 287 | − } | |
| 288 | − | |
| 289 | −static struct of_regulator_match bcm590xx_matches[] = { | |
| 290 | − BCM590XX_MATCH(rfldo, RFLDO), | |
| 291 | − BCM590XX_MATCH(camldo1, CAMLDO1), | |
| 292 | − BCM590XX_MATCH(camldo2, CAMLDO2), | |
| 293 | − BCM590XX_MATCH(simldo1, SIMLDO1), | |
| 294 | − BCM590XX_MATCH(simldo2, SIMLDO2), | |
| 295 | − BCM590XX_MATCH(sdldo, SDLDO), | |
| 296 | − BCM590XX_MATCH(sdxldo, SDXLDO), | |
| 297 | − BCM590XX_MATCH(mmcldo1, MMCLDO1), | |
| 298 | − BCM590XX_MATCH(mmcldo2, MMCLDO2), | |
| 299 | − BCM590XX_MATCH(audldo, AUDLDO), | |
| 300 | − BCM590XX_MATCH(micldo, MICLDO), | |
| 301 | − BCM590XX_MATCH(usbldo, USBLDO), | |
| 302 | − BCM590XX_MATCH(vibldo, VIBLDO), | |
| 303 | − BCM590XX_MATCH(csr, CSR), | |
| 304 | − BCM590XX_MATCH(iosr1, IOSR1), | |
| 305 | − BCM590XX_MATCH(iosr2, IOSR2), | |
| 306 | − BCM590XX_MATCH(msr, MSR), | |
| 307 | − BCM590XX_MATCH(sdsr1, SDSR1), | |
| 308 | − BCM590XX_MATCH(sdsr2, SDSR2), | |
| 309 | − BCM590XX_MATCH(vsr, VSR), | |
| 310 | − BCM590XX_MATCH(gpldo1, GPLDO1), | |
| 311 | − BCM590XX_MATCH(gpldo2, GPLDO2), | |
| 312 | − BCM590XX_MATCH(gpldo3, GPLDO3), | |
| 313 | − BCM590XX_MATCH(gpldo4, GPLDO4), | |
| 314 | − BCM590XX_MATCH(gpldo5, GPLDO5), | |
| 315 | − BCM590XX_MATCH(gpldo6, GPLDO6), | |
| 316 | − BCM590XX_MATCH(vbus, VBUS), | |
| 317 | −}; | |
| 318 | − | |
| 319 | −static struct bcm590xx_board *bcm590xx_parse_dt_reg_data( | |
| 320 | − struct platform_device *pdev, | |
| 321 | − struct of_regulator_match **bcm590xx_reg_matches) | |
| 322 | −{ | |
| 323 | − struct bcm590xx_board *data; | |
| 324 | − struct device_node *np = pdev->dev.parent->of_node; | |
| 325 | − struct device_node *regulators; | |
| 326 | − struct of_regulator_match *matches = bcm590xx_matches; | |
| 327 | − int count = ARRAY_SIZE(bcm590xx_matches); | |
| 328 | − int idx = 0; | |
| 329 | − int ret; | |
| 330 | − | |
| 331 | − if (!np) { | |
| 332 | − dev_err(&pdev->dev, "of node not found\n"); | |
| 333 | − return NULL; | |
| 334 | − } | |
| 335 | − | |
| 336 | − data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | |
| 337 | − if (!data) | |
| 338 | − return NULL; | |
| 339 | − | |
| 340 | − np = of_node_get(np); | |
| 341 | − regulators = of_get_child_by_name(np, "regulators"); | |
| 342 | − if (!regulators) { | |
| 343 | − dev_warn(&pdev->dev, "regulator node not found\n"); | |
| 344 | − return NULL; | |
| 345 | − } | |
| 346 | − | |
| 347 | − ret = of_regulator_match(&pdev->dev, regulators, matches, count); | |
| 348 | − of_node_put(regulators); | |
| 349 | − if (ret < 0) { | |
| 350 | − dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", | |
| 351 | − ret); | |
| 352 | − return NULL; | |
| 353 | − } | |
| 354 | − | |
| 355 | − *bcm590xx_reg_matches = matches; | |
| 356 | − | |
| 357 | − for (idx = 0; idx < count; idx++) { | |
| 358 | − if (!matches[idx].init_data || !matches[idx].of_node) | |
| 359 | − continue; | |
| 360 | − | |
| 361 | − data->bcm590xx_pmu_init_data[idx] = matches[idx].init_data; | |
| 362 | − } | |
| 363 | − | |
| 364 | − return data; | |
| 365 | −} | |
| 366 | − | |
| 367 | 279 | static int bcm590xx_probe(struct platform_device *pdev) |
| 368 | 280 | { |
| 369 | 281 | struct bcm590xx *bcm590xx = dev_get_drvdata(pdev->dev.parent); |
| 370 | − struct bcm590xx_board *pmu_data = NULL; | |
| 371 | 282 | struct bcm590xx_reg *pmu; |
| 372 | 283 | struct regulator_config config = { }; |
| 373 | 284 | struct bcm590xx_info *info; |
| 374 | − struct regulator_init_data *reg_data; | |
| 375 | 285 | struct regulator_dev *rdev; |
| 376 | − struct of_regulator_match *bcm590xx_reg_matches = NULL; | |
| 377 | 286 | int i; |
| 378 | 287 | |
| 379 | − pmu_data = bcm590xx_parse_dt_reg_data(pdev, | |
| 380 | − &bcm590xx_reg_matches); | |
| 381 | − | |
| 382 | 288 | pmu = devm_kzalloc(&pdev->dev, sizeof(*pmu), GFP_KERNEL); |
| 383 | 289 | if (!pmu) |
| 384 | 290 | return -ENOMEM; |
| @@ -397,13 +303,10 @@ static int bcm590xx_probe(struct platform_device *pdev) · 12 unmodified lines | ||
| 397 | 303 | info = bcm590xx_regs; |
| 398 | 304 | |
| 399 | 305 | for (i = 0; i < BCM590XX_NUM_REGS; i++, info++) { |
| 400 | − if (pmu_data) | |
| 401 | − reg_data = pmu_data->bcm590xx_pmu_init_data[i]; | |
| 402 | − else | |
| 403 | − reg_data = NULL; | |
| 404 | − | |
| 405 | 306 | /* Register the regulators */ |
| 406 | 307 | pmu->desc[i].name = info->name; |
| 308 | + pmu->desc[i].of_match = of_match_ptr(info->name); | |
| 309 | + pmu->desc[i].regulators_node = of_match_ptr("regulators"); | |
| 407 | 310 | pmu->desc[i].supply_name = info->vin_name; |
| 408 | 311 | pmu->desc[i].id = i; |
| 409 | 312 | pmu->desc[i].volt_table = info->volt_table; |
| @@ -433,16 +336,12 @@ static int bcm590xx_probe(struct platform_device *pdev) · 23 unmodified lines | ||
| 433 | 336 | pmu->desc[i].owner = THIS_MODULE; |
| 434 | 337 | |
| 435 | 338 | config.dev = bcm590xx->dev; |
| 436 | − config.init_data = reg_data; | |
| 437 | 339 | config.driver_data = pmu; |
| 438 | 340 | if (BCM590XX_REG_IS_GPLDO(i) || BCM590XX_REG_IS_VBUS(i)) |
| 439 | 341 | config.regmap = bcm590xx->regmap_sec; |
| 440 | 342 | else |
| 441 | 343 | config.regmap = bcm590xx->regmap_pri; |
| 442 | 344 | |
| 443 | − if (bcm590xx_reg_matches) | |
| 444 | − config.of_node = bcm590xx_reg_matches[i].of_node; | |
| 445 | − | |
| 446 | 345 | rdev = devm_regulator_register(&pdev->dev, &pmu->desc[i], |
| 447 | 346 | &config); |
| 448 | 347 | if (IS_ERR(rdev)) { |
| @@ -27,8 +27,8 @@ · 26 unmodified lines | ||
| 27 | 27 | static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev, |
| 28 | 28 | int ramp_delay) |
| 29 | 29 | { |
| 30 | − int id = rdev->desc->id; | |
| 31 | − unsigned int ramp_value = BUCK_RAMPRATE_10P00MV; | |
| 30 | + int id = rdev_get_id(rdev); | |
| 31 | + unsigned int ramp_value; | |
| 32 | 32 | |
| 33 | 33 | dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1, |
| 34 | 34 | ramp_delay); |
| @@ -1339,9 +1339,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, · 1338 unmodified lines | ||
| 1339 | 1339 | * We'll only apply the initial system load if an |
| 1340 | 1340 | * initial mode wasn't specified. |
| 1341 | 1341 | */ |
| 1342 | − regulator_lock(rdev); | |
| 1343 | 1342 | drms_uA_update(rdev); |
| 1344 | − regulator_unlock(rdev); | |
| 1345 | 1343 | } |
| 1346 | 1344 | |
| 1347 | 1345 | if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable) |
| @@ -3005,7 +3003,7 @@ EXPORT_SYMBOL_GPL(regulator_get_linear_step); · 1657 unmodified lines | ||
| 3005 | 3003 | * @min_uV: Minimum required voltage in uV. |
| 3006 | 3004 | * @max_uV: Maximum required voltage in uV. |
| 3007 | 3005 | * |
| 3008 | − * Returns a boolean or a negative error code. | |
| 3006 | + * Returns a boolean. | |
| 3009 | 3007 | */ |
| 3010 | 3008 | int regulator_is_supported_voltage(struct regulator *regulator, |
| 3011 | 3009 | int min_uV, int max_uV) |
| @@ -3029,7 +3027,7 @@ int regulator_is_supported_voltage(struct regulator *regulator, · 17 unmodified lines | ||
| 3029 | 3027 | |
| 3030 | 3028 | ret = regulator_count_voltages(regulator); |
| 3031 | 3029 | if (ret < 0) |
| 3032 | − return ret; | |
| 3030 | + return 0; | |
| 3033 | 3031 | voltages = ret; |
| 3034 | 3032 | |
| 3035 | 3033 | for (i = 0; i < voltages; i++) { |
| @@ -4345,8 +4343,6 @@ int regulator_bulk_get(struct device *dev, int num_consumers, · 1309 unmodified lines | ||
| 4345 | 4343 | consumers[i].supply); |
| 4346 | 4344 | if (IS_ERR(consumers[i].consumer)) { |
| 4347 | 4345 | ret = PTR_ERR(consumers[i].consumer); |
| 4348 | − dev_err(dev, "Failed to get supply '%s': %d\n", | |
| 4349 | − consumers[i].supply, ret); | |
| 4350 | 4346 | consumers[i].consumer = NULL; |
| 4351 | 4347 | goto err; |
| 4352 | 4348 | } |
| @@ -4355,6 +4351,13 @@ int regulator_bulk_get(struct device *dev, int num_consumers, · 2 unmodified lines | ||
| 4355 | 4351 | return 0; |
| 4356 | 4352 | |
| 4357 | 4353 | err: |
| 4354 | + if (ret != -EPROBE_DEFER) | |
| 4355 | + dev_err(dev, "Failed to get supply '%s': %d\n", | |
| 4356 | + consumers[i].supply, ret); | |
| 4357 | + else | |
| 4358 | + dev_dbg(dev, "Failed to get supply '%s', deferring\n", | |
| 4359 | + consumers[i].supply); | |
| 4360 | + | |
| 4358 | 4361 | while (--i >= 0) |
| 4359 | 4362 | regulator_put(consumers[i].consumer); |
| 4360 | 4363 | |
| @@ -505,17 +505,12 @@ MODULE_DEVICE_TABLE(of, cpcap_regulator_id_table); · 504 unmodified lines | ||
| 505 | 505 | static int cpcap_regulator_probe(struct platform_device *pdev) |
| 506 | 506 | { |
| 507 | 507 | struct cpcap_ddata *ddata; |
| 508 | − const struct of_device_id *match; | |
| 508 | + const struct cpcap_regulator *match_data; | |
| 509 | 509 | struct regulator_config config; |
| 510 | − struct regulator_init_data init_data; | |
| 511 | 510 | int i; |
| 512 | 511 | |
| 513 | − match = of_match_device(of_match_ptr(cpcap_regulator_id_table), | |
| 514 | − &pdev->dev); | |
| 515 | − if (!match) | |
| 516 | − return -EINVAL; | |
| 517 | − | |
| 518 | − if (!match->data) { | |
| 512 | + match_data = of_device_get_match_data(&pdev->dev); | |
| 513 | + if (!match_data) { | |
| 519 | 514 | dev_err(&pdev->dev, "no configuration data found\n"); |
| 520 | 515 | |
| 521 | 516 | return -ENODEV; |
| @@ -530,14 +525,12 @@ static int cpcap_regulator_probe(struct platform_device *pdev) · 8 unmodified lines | ||
| 530 | 525 | return -ENODEV; |
| 531 | 526 | |
| 532 | 527 | ddata->dev = &pdev->dev; |
| 533 | − ddata->soc = match->data; | |
| 528 | + ddata->soc = match_data; | |
| 534 | 529 | platform_set_drvdata(pdev, ddata); |
| 535 | 530 | |
| 536 | 531 | memset(&config, 0, sizeof(config)); |
| 537 | − memset(&init_data, 0, sizeof(init_data)); | |
| 538 | 532 | config.dev = &pdev->dev; |
| 539 | 533 | config.regmap = ddata->reg; |
| 540 | − config.init_data = &init_data; | |
| 541 | 534 | |
| 542 | 535 | for (i = 0; i < CPCAP_NR_REGULATORS; i++) { |
| 543 | 536 | const struct cpcap_regulator *regulator = &ddata->soc[i]; |
| @@ -1,13 +1,9 @@ | ||
| 1 | −/* | |
| 2 | − * Regulators driver for Dialog Semiconductor DA903x | |
| 3 | − * | |
| 4 | − * Copyright (C) 2006-2008 Marvell International Ltd. | |
| 5 | − * Copyright (C) 2008 Compulab Ltd. | |
| 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 version 2 as | |
| 9 | − * published by the Free Software Foundation. | |
| 10 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Regulators driver for Dialog Semiconductor DA903x | |
| 4 | +// | |
| 5 | +// Copyright (C) 2006-2008 Marvell International Ltd. | |
| 6 | +// Copyright (C) 2008 Compulab Ltd. | |
| 11 | 7 | |
| 12 | 8 | #include <linux/kernel.h> |
| 13 | 9 | #include <linux/init.h> |
| @@ -1,16 +1,10 @@ | ||
| 1 | −/* | |
| 2 | −* da9052-regulator.c: Regulator driver for DA9052 | |
| 3 | −* | |
| 4 | −* Copyright(c) 2011 Dialog Semiconductor Ltd. | |
| 5 | −* | |
| 6 | −* Author: David Dajun Chen <dchen@diasemi.com> | |
| 7 | −* | |
| 8 | −* This program is free software; you can redistribute it and/or modify | |
| 9 | −* it under the terms of the GNU General Public License as published by | |
| 10 | −* the Free Software Foundation; either version 2 of the License, or | |
| 11 | −* (at your option) any later version. | |
| 12 | −* | |
| 13 | −*/ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// da9052-regulator.c: Regulator driver for DA9052 | |
| 4 | +// | |
| 5 | +// Copyright(c) 2011 Dialog Semiconductor Ltd. | |
| 6 | +// | |
| 7 | +// Author: David Dajun Chen <dchen@diasemi.com> | |
| 14 | 8 | |
| 15 | 9 | #include <linux/module.h> |
| 16 | 10 | #include <linux/moduleparam.h> |
| @@ -19,10 +13,8 @@ · 2 unmodified lines | ||
| 19 | 13 | #include <linux/platform_device.h> |
| 20 | 14 | #include <linux/regulator/driver.h> |
| 21 | 15 | #include <linux/regulator/machine.h> |
| 22 | −#ifdef CONFIG_OF | |
| 23 | 16 | #include <linux/of.h> |
| 24 | 17 | #include <linux/regulator/of_regulator.h> |
| 25 | −#endif | |
| 26 | 18 | |
| 27 | 19 | #include <linux/mfd/da9052/da9052.h> |
| 28 | 20 | #include <linux/mfd/da9052/reg.h> |
| @@ -294,6 +286,8 @@ static const struct regulator_ops da9052_ldo_ops = { · 265 unmodified lines | ||
| 294 | 286 | {\ |
| 295 | 287 | .reg_desc = {\ |
| 296 | 288 | .name = #_name,\ |
| 289 | + .of_match = of_match_ptr(#_name),\ | |
| 290 | + .regulators_node = of_match_ptr("regulators"),\ | |
| 297 | 291 | .ops = &da9052_ldo_ops,\ |
| 298 | 292 | .type = REGULATOR_VOLTAGE,\ |
| 299 | 293 | .id = DA9052_ID_##_id,\ |
| @@ -314,6 +308,8 @@ static const struct regulator_ops da9052_ldo_ops = { · 14 unmodified lines | ||
| 314 | 308 | {\ |
| 315 | 309 | .reg_desc = {\ |
| 316 | 310 | .name = #_name,\ |
| 311 | + .of_match = of_match_ptr(#_name),\ | |
| 312 | + .regulators_node = of_match_ptr("regulators"),\ | |
| 317 | 313 | .ops = &da9052_dcdc_ops,\ |
| 318 | 314 | .type = REGULATOR_VOLTAGE,\ |
| 319 | 315 | .id = DA9052_ID_##_id,\ |
| @@ -417,36 +413,11 @@ static int da9052_regulator_probe(struct platform_device *pdev) · 97 unmodified lines | ||
| 417 | 413 | return -EINVAL; |
| 418 | 414 | } |
| 419 | 415 | |
| 420 | − config.dev = &pdev->dev; | |
| 416 | + config.dev = da9052->dev; | |
| 421 | 417 | config.driver_data = regulator; |
| 422 | 418 | config.regmap = da9052->regmap; |
| 423 | − if (pdata) { | |
| 419 | + if (pdata) | |
| 424 | 420 | config.init_data = pdata->regulators[cell->id]; |
| 425 | − } else { | |
| 426 | −#ifdef CONFIG_OF | |
| 427 | − struct device_node *nproot = da9052->dev->of_node; | |
| 428 | − struct device_node *np; | |
| 429 | − | |
| 430 | − if (!nproot) | |
| 431 | − return -ENODEV; | |
| 432 | − | |
| 433 | − nproot = of_get_child_by_name(nproot, "regulators"); | |
| 434 | − if (!nproot) | |
| 435 | − return -ENODEV; | |
| 436 | − | |
| 437 | − for_each_child_of_node(nproot, np) { | |
| 438 | − if (of_node_name_eq(np, | |
| 439 | − regulator->info->reg_desc.name)) { | |
| 440 | − config.init_data = of_get_regulator_init_data( | |
| 441 | − &pdev->dev, np, | |
| 442 | − ®ulator->info->reg_desc); | |
| 443 | − config.of_node = np; | |
| 444 | − break; | |
| 445 | − } | |
| 446 | − } | |
| 447 | − of_node_put(nproot); | |
| 448 | −#endif | |
| 449 | − } | |
| 450 | 421 | |
| 451 | 422 | regulator->rdev = devm_regulator_register(&pdev->dev, |
| 452 | 423 | ®ulator->info->reg_desc, |
| @@ -1,16 +1,10 @@ | ||
| 1 | −/* | |
| 2 | −* Regulator driver for DA9055 PMIC | |
| 3 | −* | |
| 4 | −* Copyright(c) 2012 Dialog Semiconductor Ltd. | |
| 5 | −* | |
| 6 | −* Author: David Dajun Chen <dchen@diasemi.com> | |
| 7 | −* | |
| 8 | −* This program is free software; you can redistribute it and/or modify | |
| 9 | −* it under the terms of the GNU General Public License as published by | |
| 10 | −* the Free Software Foundation; either version 2 of the License, or | |
| 11 | −* (at your option) any later version. | |
| 12 | −* | |
| 13 | −*/ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// Regulator driver for DA9055 PMIC | |
| 4 | +// | |
| 5 | +// Copyright(c) 2012 Dialog Semiconductor Ltd. | |
| 6 | +// | |
| 7 | +// Author: David Dajun Chen <dchen@diasemi.com> | |
| 14 | 8 | |
| 15 | 9 | #include <linux/module.h> |
| 16 | 10 | #include <linux/init.h> |
| @@ -338,6 +332,8 @@ static const struct regulator_ops da9055_ldo_ops = { · 321 unmodified lines | ||
| 338 | 332 | {\ |
| 339 | 333 | .reg_desc = {\ |
| 340 | 334 | .name = #_id,\ |
| 335 | + .of_match = of_match_ptr(#_id),\ | |
| 336 | + .regulators_node = of_match_ptr("regulators"),\ | |
| 341 | 337 | .ops = &da9055_ldo_ops,\ |
| 342 | 338 | .type = REGULATOR_VOLTAGE,\ |
| 343 | 339 | .id = DA9055_ID_##_id,\ |
| @@ -366,6 +362,8 @@ static const struct regulator_ops da9055_ldo_ops = { · 22 unmodified lines | ||
| 366 | 362 | {\ |
| 367 | 363 | .reg_desc = {\ |
| 368 | 364 | .name = #_id,\ |
| 365 | + .of_match = of_match_ptr(#_id),\ | |
| 366 | + .regulators_node = of_match_ptr("regulators"),\ | |
| 369 | 367 | .ops = &da9055_buck_ops,\ |
| 370 | 368 | .type = REGULATOR_VOLTAGE,\ |
| 371 | 369 | .id = DA9055_ID_##_id,\ |
| @@ -487,8 +485,10 @@ static irqreturn_t da9055_ldo5_6_oc_irq(int irq, void *data) · 115 unmodified lines | ||
| 487 | 485 | { |
| 488 | 486 | struct da9055_regulator *regulator = data; |
| 489 | 487 | |
| 488 | + regulator_lock(regulator->rdev); | |
| 490 | 489 | regulator_notifier_call_chain(regulator->rdev, |
| 491 | 490 | REGULATOR_EVENT_OVER_CURRENT, NULL); |
| 491 | + regulator_unlock(regulator->rdev); | |
| 492 | 492 | |
| 493 | 493 | return IRQ_HANDLED; |
| 494 | 494 | } |
| @@ -507,59 +507,6 @@ static inline struct da9055_regulator_info *find_regulator_info(int id) · 12 unmodified lines | ||
| 507 | 507 | return NULL; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | −#ifdef CONFIG_OF | |
| 511 | −static struct of_regulator_match da9055_reg_matches[] = { | |
| 512 | − { .name = "BUCK1", }, | |
| 513 | − { .name = "BUCK2", }, | |
| 514 | − { .name = "LDO1", }, | |
| 515 | − { .name = "LDO2", }, | |
| 516 | − { .name = "LDO3", }, | |
| 517 | − { .name = "LDO4", }, | |
| 518 | − { .name = "LDO5", }, | |
| 519 | − { .name = "LDO6", }, | |
| 520 | −}; | |
| 521 | − | |
| 522 | −static int da9055_regulator_dt_init(struct platform_device *pdev, | |
| 523 | − struct da9055_regulator *regulator, | |
| 524 | − struct regulator_config *config, | |
| 525 | − int regid) | |
| 526 | −{ | |
| 527 | − struct device_node *nproot, *np; | |
| 528 | − int ret; | |
| 529 | − | |
| 530 | − nproot = of_node_get(pdev->dev.parent->of_node); | |
| 531 | − if (!nproot) | |
| 532 | − return -ENODEV; | |
| 533 | − | |
| 534 | − np = of_get_child_by_name(nproot, "regulators"); | |
| 535 | − if (!np) | |
| 536 | − return -ENODEV; | |
| 537 | − | |
| 538 | − ret = of_regulator_match(&pdev->dev, np, &da9055_reg_matches[regid], 1); | |
| 539 | − of_node_put(nproot); | |
| 540 | − if (ret < 0) { | |
| 541 | − dev_err(&pdev->dev, "Error matching regulator: %d\n", ret); | |
| 542 | − return ret; | |
| 543 | − } | |
| 544 | − | |
| 545 | − config->init_data = da9055_reg_matches[regid].init_data; | |
| 546 | − config->of_node = da9055_reg_matches[regid].of_node; | |
| 547 | − | |
| 548 | − if (!config->of_node) | |
| 549 | − return -ENODEV; | |
| 550 | − | |
| 551 | − return 0; | |
| 552 | −} | |
| 553 | −#else | |
| 554 | −static inline int da9055_regulator_dt_init(struct platform_device *pdev, | |
| 555 | − struct da9055_regulator *regulator, | |
| 556 | − struct regulator_config *config, | |
| 557 | − int regid) | |
| 558 | −{ | |
| 559 | − return -ENODEV; | |
| 560 | −} | |
| 561 | −#endif /* CONFIG_OF */ | |
| 562 | − | |
| 563 | 510 | static int da9055_regulator_probe(struct platform_device *pdev) |
| 564 | 511 | { |
| 565 | 512 | struct regulator_config config = { }; |
| @@ -580,18 +527,12 @@ static int da9055_regulator_probe(struct platform_device *pdev) · 14 unmodified lines | ||
| 580 | 527 | } |
| 581 | 528 | |
| 582 | 529 | regulator->da9055 = da9055; |
| 583 | − config.dev = &pdev->dev; | |
| 530 | + config.dev = da9055->dev; | |
| 584 | 531 | config.driver_data = regulator; |
| 585 | 532 | config.regmap = da9055->regmap; |
| 586 | 533 | |
| 587 | − if (pdata) { | |
| 534 | + if (pdata) | |
| 588 | 535 | config.init_data = pdata->regulators[pdev->id]; |
| 589 | − } else { | |
| 590 | − ret = da9055_regulator_dt_init(pdev, regulator, &config, | |
| 591 | − pdev->id); | |
| 592 | − if (ret < 0) | |
| 593 | − return ret; | |
| 594 | − } | |
| 595 | 536 | |
| 596 | 537 | ret = da9055_gpio_init(regulator, &config, pdata, pdev->id); |
| 597 | 538 | if (ret < 0) |
| @@ -1,17 +1,8 @@ | ||
| 1 | −/* | |
| 2 | − * Regulator device driver for DA9061 and DA9062. | |
| 3 | − * Copyright (C) 2015-2017 Dialog Semiconductor | |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or | |
| 6 | − * modify it under the terms of the GNU General Public License | |
| 7 | − * as published by the Free Software Foundation; either version 2 | |
| 8 | − * of the License, or (at your option) any later version. | |
| 9 | − * | |
| 10 | − * This program is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | − * GNU General Public License for more details. | |
| 14 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// Regulator device driver for DA9061 and DA9062. | |
| 4 | +// Copyright (C) 2015-2017 Dialog Semiconductor | |
| 5 | + | |
| 15 | 6 | #include <linux/kernel.h> |
| 16 | 7 | #include <linux/module.h> |
| 17 | 8 | #include <linux/init.h> |
| @@ -53,16 +44,12 @@ enum { · 35 unmodified lines | ||
| 53 | 44 | /* Regulator capabilities and registers description */ |
| 54 | 45 | struct da9062_regulator_info { |
| 55 | 46 | struct regulator_desc desc; |
| 56 | − /* Current limiting */ | |
| 57 | − unsigned int n_current_limits; | |
| 58 | − const int *current_limits; | |
| 59 | 47 | /* Main register fields */ |
| 60 | 48 | struct reg_field mode; |
| 61 | 49 | struct reg_field suspend; |
| 62 | 50 | struct reg_field sleep; |
| 63 | 51 | struct reg_field suspend_sleep; |
| 64 | 52 | unsigned int suspend_vsel_reg; |
| 65 | − struct reg_field ilimit; | |
| 66 | 53 | /* Event detection bit */ |
| 67 | 54 | struct reg_field oc_event; |
| 68 | 55 | }; |
| @@ -78,7 +65,6 @@ struct da9062_regulator { · 9 unmodified lines | ||
| 78 | 65 | struct regmap_field *suspend; |
| 79 | 66 | struct regmap_field *sleep; |
| 80 | 67 | struct regmap_field *suspend_sleep; |
| 81 | − struct regmap_field *ilimit; | |
| 82 | 68 | }; |
| 83 | 69 | |
| 84 | 70 | /* Encapsulates all information for the regulators driver */ |
| @@ -104,7 +90,7 @@ enum { · 19 unmodified lines | ||
| 104 | 90 | * - DA9062_ID_[BUCK1|BUCK2|BUCK4] |
| 105 | 91 | * Entry indexes corresponds to register values. |
| 106 | 92 | */ |
| 107 | −static const int da9062_buck_a_limits[] = { | |
| 93 | +static const unsigned int da9062_buck_a_limits[] = { | |
| 108 | 94 | 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, |
| 109 | 95 | 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000 |
| 110 | 96 | }; |
| @@ -114,44 +100,11 @@ static const int da9062_buck_a_limits[] = { · 3 unmodified lines | ||
| 114 | 100 | * - DA9062_ID_BUCK3 |
| 115 | 101 | * Entry indexes corresponds to register values. |
| 116 | 102 | */ |
| 117 | −static const int da9062_buck_b_limits[] = { | |
| 103 | +static const unsigned int da9062_buck_b_limits[] = { | |
| 118 | 104 | 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000, |
| 119 | 105 | 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 |
| 120 | 106 | }; |
| 121 | 107 | |
| 122 | −static int da9062_set_current_limit(struct regulator_dev *rdev, | |
| 123 | − int min_ua, int max_ua) | |
| 124 | −{ | |
| 125 | − struct da9062_regulator *regl = rdev_get_drvdata(rdev); | |
| 126 | − const struct da9062_regulator_info *rinfo = regl->info; | |
| 127 | − int n, tval; | |
| 128 | − | |
| 129 | − for (n = rinfo->n_current_limits - 1; n >= 0; n--) { | |
| 130 | − tval = rinfo->current_limits[n]; | |
| 131 | − if (tval >= min_ua && tval <= max_ua) | |
| 132 | − return regmap_field_write(regl->ilimit, n); | |
| 133 | − } | |
| 134 | − | |
| 135 | − return -EINVAL; | |
| 136 | −} | |
| 137 | − | |
| 138 | −static int da9062_get_current_limit(struct regulator_dev *rdev) | |
| 139 | −{ | |
| 140 | − struct da9062_regulator *regl = rdev_get_drvdata(rdev); | |
| 141 | − const struct da9062_regulator_info *rinfo = regl->info; | |
| 142 | − unsigned int sel; | |
| 143 | − int ret; | |
| 144 | − | |
| 145 | − ret = regmap_field_read(regl->ilimit, &sel); | |
| 146 | − if (ret < 0) | |
| 147 | − return ret; | |
| 148 | − | |
| 149 | − if (sel >= rinfo->n_current_limits) | |
| 150 | − sel = rinfo->n_current_limits - 1; | |
| 151 | − | |
| 152 | − return rinfo->current_limits[sel]; | |
| 153 | −} | |
| 154 | − | |
| 155 | 108 | static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode) |
| 156 | 109 | { |
| 157 | 110 | struct da9062_regulator *regl = rdev_get_drvdata(rdev); |
| @@ -395,8 +348,8 @@ static const struct regulator_ops da9062_buck_ops = { · 237 unmodified lines | ||
| 395 | 348 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 396 | 349 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 397 | 350 | .list_voltage = regulator_list_voltage_linear, |
| 398 | − .set_current_limit = da9062_set_current_limit, | |
| 399 | − .get_current_limit = da9062_get_current_limit, | |
| 351 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 352 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 400 | 353 | .set_mode = da9062_buck_set_mode, |
| 401 | 354 | .get_mode = da9062_buck_get_mode, |
| 402 | 355 | .get_status = da9062_buck_get_status, |
| @@ -433,8 +386,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 30 unmodified lines | ||
| 433 | 386 | .desc.min_uV = (300) * 1000, |
| 434 | 387 | .desc.uV_step = (10) * 1000, |
| 435 | 388 | .desc.n_voltages = ((1570) - (300))/(10) + 1, |
| 436 | − .current_limits = da9062_buck_a_limits, | |
| 437 | − .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 389 | + .desc.curr_table = da9062_buck_a_limits, | |
| 390 | + .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 391 | + .desc.csel_reg = DA9062AA_BUCK_ILIM_C, | |
| 392 | + .desc.csel_mask = DA9062AA_BUCK1_ILIM_MASK, | |
| 438 | 393 | .desc.enable_reg = DA9062AA_BUCK1_CONT, |
| 439 | 394 | .desc.enable_mask = DA9062AA_BUCK1_EN_MASK, |
| 440 | 395 | .desc.vsel_reg = DA9062AA_VBUCK1_A, |
| @@ -457,10 +412,6 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 16 unmodified lines | ||
| 457 | 412 | __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1, |
| 458 | 413 | sizeof(unsigned int) * 8 - |
| 459 | 414 | __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1), |
| 460 | − .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C, | |
| 461 | − __builtin_ffs((int)DA9062AA_BUCK1_ILIM_MASK) - 1, | |
| 462 | − sizeof(unsigned int) * 8 - | |
| 463 | − __builtin_clz((DA9062AA_BUCK1_ILIM_MASK)) - 1), | |
| 464 | 415 | }, |
| 465 | 416 | { |
| 466 | 417 | .desc.id = DA9061_ID_BUCK2, |
| @@ -471,8 +422,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 4 unmodified lines | ||
| 471 | 422 | .desc.min_uV = (800) * 1000, |
| 472 | 423 | .desc.uV_step = (20) * 1000, |
| 473 | 424 | .desc.n_voltages = ((3340) - (800))/(20) + 1, |
| 474 | − .current_limits = da9062_buck_b_limits, | |
| 475 | − .n_current_limits = ARRAY_SIZE(da9062_buck_b_limits), | |
| 425 | + .desc.curr_table = da9062_buck_b_limits, | |
| 426 | + .desc.n_current_limits = ARRAY_SIZE(da9062_buck_b_limits), | |
| 427 | + .desc.csel_reg = DA9062AA_BUCK_ILIM_A, | |
| 428 | + .desc.csel_mask = DA9062AA_BUCK3_ILIM_MASK, | |
| 476 | 429 | .desc.enable_reg = DA9062AA_BUCK3_CONT, |
| 477 | 430 | .desc.enable_mask = DA9062AA_BUCK3_EN_MASK, |
| 478 | 431 | .desc.vsel_reg = DA9062AA_VBUCK3_A, |
| @@ -495,10 +448,6 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 16 unmodified lines | ||
| 495 | 448 | __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1, |
| 496 | 449 | sizeof(unsigned int) * 8 - |
| 497 | 450 | __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1), |
| 498 | − .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_A, | |
| 499 | − __builtin_ffs((int)DA9062AA_BUCK3_ILIM_MASK) - 1, | |
| 500 | − sizeof(unsigned int) * 8 - | |
| 501 | − __builtin_clz((DA9062AA_BUCK3_ILIM_MASK)) - 1), | |
| 502 | 451 | }, |
| 503 | 452 | { |
| 504 | 453 | .desc.id = DA9061_ID_BUCK3, |
| @@ -509,8 +458,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 4 unmodified lines | ||
| 509 | 458 | .desc.min_uV = (530) * 1000, |
| 510 | 459 | .desc.uV_step = (10) * 1000, |
| 511 | 460 | .desc.n_voltages = ((1800) - (530))/(10) + 1, |
| 512 | − .current_limits = da9062_buck_a_limits, | |
| 513 | − .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 461 | + .desc.curr_table = da9062_buck_a_limits, | |
| 462 | + .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 463 | + .desc.csel_reg = DA9062AA_BUCK_ILIM_B, | |
| 464 | + .desc.csel_mask = DA9062AA_BUCK4_ILIM_MASK, | |
| 514 | 465 | .desc.enable_reg = DA9062AA_BUCK4_CONT, |
| 515 | 466 | .desc.enable_mask = DA9062AA_BUCK4_EN_MASK, |
| 516 | 467 | .desc.vsel_reg = DA9062AA_VBUCK4_A, |
| @@ -533,10 +484,6 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 16 unmodified lines | ||
| 533 | 484 | __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1, |
| 534 | 485 | sizeof(unsigned int) * 8 - |
| 535 | 486 | __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1), |
| 536 | − .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_B, | |
| 537 | − __builtin_ffs((int)DA9062AA_BUCK4_ILIM_MASK) - 1, | |
| 538 | − sizeof(unsigned int) * 8 - | |
| 539 | − __builtin_clz((DA9062AA_BUCK4_ILIM_MASK)) - 1), | |
| 540 | 487 | }, |
| 541 | 488 | { |
| 542 | 489 | .desc.id = DA9061_ID_LDO1, |
| @@ -679,8 +626,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 136 unmodified lines | ||
| 679 | 626 | .desc.min_uV = (300) * 1000, |
| 680 | 627 | .desc.uV_step = (10) * 1000, |
| 681 | 628 | .desc.n_voltages = ((1570) - (300))/(10) + 1, |
| 682 | − .current_limits = da9062_buck_a_limits, | |
| 683 | − .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 629 | + .desc.curr_table = da9062_buck_a_limits, | |
| 630 | + .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 631 | + .desc.csel_reg = DA9062AA_BUCK_ILIM_C, | |
| 632 | + .desc.csel_mask = DA9062AA_BUCK1_ILIM_MASK, | |
| 684 | 633 | .desc.enable_reg = DA9062AA_BUCK1_CONT, |
| 685 | 634 | .desc.enable_mask = DA9062AA_BUCK1_EN_MASK, |
| 686 | 635 | .desc.vsel_reg = DA9062AA_VBUCK1_A, |
| @@ -703,10 +652,6 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 16 unmodified lines | ||
| 703 | 652 | __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1, |
| 704 | 653 | sizeof(unsigned int) * 8 - |
| 705 | 654 | __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1), |
| 706 | − .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C, | |
| 707 | − __builtin_ffs((int)DA9062AA_BUCK1_ILIM_MASK) - 1, | |
| 708 | − sizeof(unsigned int) * 8 - | |
| 709 | − __builtin_clz((DA9062AA_BUCK1_ILIM_MASK)) - 1), | |
| 710 | 655 | }, |
| 711 | 656 | { |
| 712 | 657 | .desc.id = DA9062_ID_BUCK2, |
| @@ -717,8 +662,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 4 unmodified lines | ||
| 717 | 662 | .desc.min_uV = (300) * 1000, |
| 718 | 663 | .desc.uV_step = (10) * 1000, |
| 719 | 664 | .desc.n_voltages = ((1570) - (300))/(10) + 1, |
| 720 | − .current_limits = da9062_buck_a_limits, | |
| 721 | − .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 665 | + .desc.curr_table = da9062_buck_a_limits, | |
| 666 | + .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 667 | + .desc.csel_reg = DA9062AA_BUCK_ILIM_C, | |
| 668 | + .desc.csel_mask = DA9062AA_BUCK2_ILIM_MASK, | |
| 722 | 669 | .desc.enable_reg = DA9062AA_BUCK2_CONT, |
| 723 | 670 | .desc.enable_mask = DA9062AA_BUCK2_EN_MASK, |
| 724 | 671 | .desc.vsel_reg = DA9062AA_VBUCK2_A, |
| @@ -741,10 +688,6 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 16 unmodified lines | ||
| 741 | 688 | __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1, |
| 742 | 689 | sizeof(unsigned int) * 8 - |
| 743 | 690 | __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1), |
| 744 | − .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C, | |
| 745 | − __builtin_ffs((int)DA9062AA_BUCK2_ILIM_MASK) - 1, | |
| 746 | − sizeof(unsigned int) * 8 - | |
| 747 | − __builtin_clz((DA9062AA_BUCK2_ILIM_MASK)) - 1), | |
| 748 | 691 | }, |
| 749 | 692 | { |
| 750 | 693 | .desc.id = DA9062_ID_BUCK3, |
| @@ -755,8 +698,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 4 unmodified lines | ||
| 755 | 698 | .desc.min_uV = (800) * 1000, |
| 756 | 699 | .desc.uV_step = (20) * 1000, |
| 757 | 700 | .desc.n_voltages = ((3340) - (800))/(20) + 1, |
| 758 | − .current_limits = da9062_buck_b_limits, | |
| 759 | − .n_current_limits = ARRAY_SIZE(da9062_buck_b_limits), | |
| 701 | + .desc.curr_table = da9062_buck_b_limits, | |
| 702 | + .desc.n_current_limits = ARRAY_SIZE(da9062_buck_b_limits), | |
| 703 | + .desc.csel_reg = DA9062AA_BUCK_ILIM_A, | |
| 704 | + .desc.csel_mask = DA9062AA_BUCK3_ILIM_MASK, | |
| 760 | 705 | .desc.enable_reg = DA9062AA_BUCK3_CONT, |
| 761 | 706 | .desc.enable_mask = DA9062AA_BUCK3_EN_MASK, |
| 762 | 707 | .desc.vsel_reg = DA9062AA_VBUCK3_A, |
| @@ -779,10 +724,6 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 16 unmodified lines | ||
| 779 | 724 | __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1, |
| 780 | 725 | sizeof(unsigned int) * 8 - |
| 781 | 726 | __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1), |
| 782 | − .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_A, | |
| 783 | − __builtin_ffs((int)DA9062AA_BUCK3_ILIM_MASK) - 1, | |
| 784 | − sizeof(unsigned int) * 8 - | |
| 785 | − __builtin_clz((DA9062AA_BUCK3_ILIM_MASK)) - 1), | |
| 786 | 727 | }, |
| 787 | 728 | { |
| 788 | 729 | .desc.id = DA9062_ID_BUCK4, |
| @@ -793,8 +734,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 4 unmodified lines | ||
| 793 | 734 | .desc.min_uV = (530) * 1000, |
| 794 | 735 | .desc.uV_step = (10) * 1000, |
| 795 | 736 | .desc.n_voltages = ((1800) - (530))/(10) + 1, |
| 796 | − .current_limits = da9062_buck_a_limits, | |
| 797 | − .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 737 | + .desc.curr_table = da9062_buck_a_limits, | |
| 738 | + .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | |
| 739 | + .desc.csel_reg = DA9062AA_BUCK_ILIM_B, | |
| 740 | + .desc.csel_mask = DA9062AA_BUCK4_ILIM_MASK, | |
| 798 | 741 | .desc.enable_reg = DA9062AA_BUCK4_CONT, |
| 799 | 742 | .desc.enable_mask = DA9062AA_BUCK4_EN_MASK, |
| 800 | 743 | .desc.vsel_reg = DA9062AA_VBUCK4_A, |
| @@ -817,10 +760,6 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 16 unmodified lines | ||
| 817 | 760 | __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1, |
| 818 | 761 | sizeof(unsigned int) * 8 - |
| 819 | 762 | __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1), |
| 820 | − .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_B, | |
| 821 | − __builtin_ffs((int)DA9062AA_BUCK4_ILIM_MASK) - 1, | |
| 822 | − sizeof(unsigned int) * 8 - | |
| 823 | − __builtin_clz((DA9062AA_BUCK4_ILIM_MASK)) - 1), | |
| 824 | 763 | }, |
| 825 | 764 | { |
| 826 | 765 | .desc.id = DA9062_ID_LDO1, |
| @@ -974,8 +913,10 @@ static irqreturn_t da9062_ldo_lim_event(int irq, void *data) · 147 unmodified lines | ||
| 974 | 913 | continue; |
| 975 | 914 | |
| 976 | 915 | if (BIT(regl->info->oc_event.lsb) & bits) { |
| 916 | + regulator_lock(regl->rdev); | |
| 977 | 917 | regulator_notifier_call_chain(regl->rdev, |
| 978 | 918 | REGULATOR_EVENT_OVER_CURRENT, NULL); |
| 919 | + regulator_unlock(regl->rdev); | |
| 979 | 920 | handled = IRQ_HANDLED; |
| 980 | 921 | } |
| 981 | 922 | } |
| @@ -1063,15 +1004,6 @@ static int da9062_regulator_probe(struct platform_device *pdev) · 81 unmodified lines | ||
| 1063 | 1004 | return PTR_ERR(regl->suspend_sleep); |
| 1064 | 1005 | } |
| 1065 | 1006 | |
| 1066 | − if (regl->info->ilimit.reg) { | |
| 1067 | − regl->ilimit = devm_regmap_field_alloc( | |
| 1068 | − &pdev->dev, | |
| 1069 | − chip->regmap, | |
| 1070 | − regl->info->ilimit); | |
| 1071 | − if (IS_ERR(regl->ilimit)) | |
| 1072 | − return PTR_ERR(regl->ilimit); | |
| 1073 | − } | |
| 1074 | − | |
| 1075 | 1007 | /* Register regulator */ |
| 1076 | 1008 | memset(&config, 0, sizeof(config)); |
| 1077 | 1009 | config.dev = chip->dev; |
| @@ -1,18 +1,12 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// Regulator driver for DA9063 PMIC series | |
| 4 | +// | |
| 5 | +// Copyright 2012 Dialog Semiconductors Ltd. | |
| 6 | +// Copyright 2013 Philipp Zabel, Pengutronix | |
| 7 | +// | |
| 8 | +// Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com> | |
| 1 | 9 | |
| 2 | −/* | |
| 3 | − * Regulator driver for DA9063 PMIC series | |
| 4 | − * | |
| 5 | − * Copyright 2012 Dialog Semiconductors Ltd. | |
| 6 | − * Copyright 2013 Philipp Zabel, Pengutronix | |
| 7 | − * | |
| 8 | − * Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com> | |
| 9 | − * | |
| 10 | − * This program is free software; you can redistribute it and/or modify it | |
| 11 | − * under the terms of the GNU General Public License as published by the | |
| 12 | − * Free Software Foundation; either version 2 of the License, or (at your | |
| 13 | − * option) any later version. | |
| 14 | − * | |
| 15 | − */ | |
| 16 | 10 | #include <linux/kernel.h> |
| 17 | 11 | #include <linux/module.h> |
| 18 | 12 | #include <linux/init.h> |
| @@ -38,17 +32,12 @@ · 19 unmodified lines | ||
| 38 | 32 | struct da9063_regulator_info { |
| 39 | 33 | struct regulator_desc desc; |
| 40 | 34 | |
| 41 | − /* Current limiting */ | |
| 42 | − unsigned n_current_limits; | |
| 43 | − const int *current_limits; | |
| 44 | − | |
| 45 | 35 | /* DA9063 main register fields */ |
| 46 | 36 | struct reg_field mode; /* buck mode of operation */ |
| 47 | 37 | struct reg_field suspend; |
| 48 | 38 | struct reg_field sleep; |
| 49 | 39 | struct reg_field suspend_sleep; |
| 50 | 40 | unsigned int suspend_vsel_reg; |
| 51 | − struct reg_field ilimit; | |
| 52 | 41 | |
| 53 | 42 | /* DA9063 event detection bit */ |
| 54 | 43 | struct reg_field oc_event; |
| @@ -73,15 +62,18 @@ struct da9063_regulator_info { · 18 unmodified lines | ||
| 73 | 62 | .suspend_vsel_reg = DA9063_REG_V##regl_name##_B |
| 74 | 63 | |
| 75 | 64 | /* Macros for voltage DC/DC converters (BUCKs) */ |
| 76 | −#define DA9063_BUCK(chip, regl_name, min_mV, step_mV, max_mV, limits_array) \ | |
| 65 | +#define DA9063_BUCK(chip, regl_name, min_mV, step_mV, max_mV, limits_array, \ | |
| 66 | + creg, cmask) \ | |
| 77 | 67 | .desc.id = chip##_ID_##regl_name, \ |
| 78 | 68 | .desc.name = __stringify(chip##_##regl_name), \ |
| 79 | 69 | .desc.ops = &da9063_buck_ops, \ |
| 80 | 70 | .desc.min_uV = (min_mV) * 1000, \ |
| 81 | 71 | .desc.uV_step = (step_mV) * 1000, \ |
| 82 | 72 | .desc.n_voltages = ((max_mV) - (min_mV))/(step_mV) + 1, \ |
| 83 | − .current_limits = limits_array, \ | |
| 84 | − .n_current_limits = ARRAY_SIZE(limits_array) | |
| 73 | + .desc.csel_reg = (creg), \ | |
| 74 | + .desc.csel_mask = (cmask), \ | |
| 75 | + .desc.curr_table = limits_array, \ | |
| 76 | + .desc.n_current_limits = ARRAY_SIZE(limits_array) | |
| 85 | 77 | |
| 86 | 78 | #define DA9063_BUCK_COMMON_FIELDS(regl_name) \ |
| 87 | 79 | .desc.enable_reg = DA9063_REG_##regl_name##_CONT, \ |
| @@ -112,7 +104,6 @@ struct da9063_regulator { · 24 unmodified lines | ||
| 112 | 104 | struct regmap_field *suspend; |
| 113 | 105 | struct regmap_field *sleep; |
| 114 | 106 | struct regmap_field *suspend_sleep; |
| 115 | − struct regmap_field *ilimit; | |
| 116 | 107 | }; |
| 117 | 108 | |
| 118 | 109 | /* Encapsulates all information for the regulators driver */ |
| @@ -134,65 +125,32 @@ enum { · 15 unmodified lines | ||
| 134 | 125 | |
| 135 | 126 | /* Current limits array (in uA) for BCORE1, BCORE2, BPRO. |
| 136 | 127 | Entry indexes corresponds to register values. */ |
| 137 | −static const int da9063_buck_a_limits[] = { | |
| 128 | +static const unsigned int da9063_buck_a_limits[] = { | |
| 138 | 129 | 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, |
| 139 | 130 | 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000 |
| 140 | 131 | }; |
| 141 | 132 | |
| 142 | 133 | /* Current limits array (in uA) for BMEM, BIO, BPERI. |
| 143 | 134 | Entry indexes corresponds to register values. */ |
| 144 | −static const int da9063_buck_b_limits[] = { | |
| 135 | +static const unsigned int da9063_buck_b_limits[] = { | |
| 145 | 136 | 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000, |
| 146 | 137 | 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 |
| 147 | 138 | }; |
| 148 | 139 | |
| 149 | 140 | /* Current limits array (in uA) for merged BCORE1 and BCORE2. |
| 150 | 141 | Entry indexes corresponds to register values. */ |
| 151 | −static const int da9063_bcores_merged_limits[] = { | |
| 142 | +static const unsigned int da9063_bcores_merged_limits[] = { | |
| 152 | 143 | 1000000, 1200000, 1400000, 1600000, 1800000, 2000000, 2200000, 2400000, |
| 153 | 144 | 2600000, 2800000, 3000000, 3200000, 3400000, 3600000, 3800000, 4000000 |
| 154 | 145 | }; |
| 155 | 146 | |
| 156 | 147 | /* Current limits array (in uA) for merged BMEM and BIO. |
| 157 | 148 | Entry indexes corresponds to register values. */ |
| 158 | −static const int da9063_bmem_bio_merged_limits[] = { | |
| 149 | +static const unsigned int da9063_bmem_bio_merged_limits[] = { | |
| 159 | 150 | 3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000, |
| 160 | 151 | 4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000 |
| 161 | 152 | }; |
| 162 | 153 | |
| 163 | −static int da9063_set_current_limit(struct regulator_dev *rdev, | |
| 164 | − int min_uA, int max_uA) | |
| 165 | −{ | |
| 166 | − struct da9063_regulator *regl = rdev_get_drvdata(rdev); | |
| 167 | − const struct da9063_regulator_info *rinfo = regl->info; | |
| 168 | − int n, tval; | |
| 169 | − | |
| 170 | − for (n = rinfo->n_current_limits - 1; n >= 0; n--) { | |
| 171 | − tval = rinfo->current_limits[n]; | |
| 172 | − if (tval >= min_uA && tval <= max_uA) | |
| 173 | − return regmap_field_write(regl->ilimit, n); | |
| 174 | − } | |
| 175 | − | |
| 176 | − return -EINVAL; | |
| 177 | −} | |
| 178 | − | |
| 179 | −static int da9063_get_current_limit(struct regulator_dev *rdev) | |
| 180 | −{ | |
| 181 | − struct da9063_regulator *regl = rdev_get_drvdata(rdev); | |
| 182 | − const struct da9063_regulator_info *rinfo = regl->info; | |
| 183 | − unsigned int sel; | |
| 184 | − int ret; | |
| 185 | − | |
| 186 | − ret = regmap_field_read(regl->ilimit, &sel); | |
| 187 | − if (ret < 0) | |
| 188 | − return ret; | |
| 189 | − | |
| 190 | − if (sel >= rinfo->n_current_limits) | |
| 191 | − sel = rinfo->n_current_limits - 1; | |
| 192 | − | |
| 193 | − return rinfo->current_limits[sel]; | |
| 194 | −} | |
| 195 | − | |
| 196 | 154 | static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned mode) |
| 197 | 155 | { |
| 198 | 156 | struct da9063_regulator *regl = rdev_get_drvdata(rdev); |
| @@ -434,8 +392,8 @@ static const struct regulator_ops da9063_buck_ops = { · 235 unmodified lines | ||
| 434 | 392 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 435 | 393 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 436 | 394 | .list_voltage = regulator_list_voltage_linear, |
| 437 | − .set_current_limit = da9063_set_current_limit, | |
| 438 | − .get_current_limit = da9063_get_current_limit, | |
| 395 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 396 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 439 | 397 | .set_mode = da9063_buck_set_mode, |
| 440 | 398 | .get_mode = da9063_buck_get_mode, |
| 441 | 399 | .get_status = da9063_buck_get_status, |
| @@ -465,69 +423,61 @@ static const struct regulator_ops da9063_ldo_ops = { · 23 unmodified lines | ||
| 465 | 423 | static const struct da9063_regulator_info da9063_regulator_info[] = { |
| 466 | 424 | { |
| 467 | 425 | DA9063_BUCK(DA9063, BCORE1, 300, 10, 1570, |
| 468 | − da9063_buck_a_limits), | |
| 426 | + da9063_buck_a_limits, | |
| 427 | + DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK), | |
| 469 | 428 | DA9063_BUCK_COMMON_FIELDS(BCORE1), |
| 470 | 429 | .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL), |
| 471 | − .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C, | |
| 472 | − DA9063_BCORE1_ILIM_MASK), | |
| 473 | 430 | }, |
| 474 | 431 | { |
| 475 | 432 | DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570, |
| 476 | − da9063_buck_a_limits), | |
| 433 | + da9063_buck_a_limits, | |
| 434 | + DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK), | |
| 477 | 435 | DA9063_BUCK_COMMON_FIELDS(BCORE2), |
| 478 | 436 | .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE2_SEL), |
| 479 | − .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C, | |
| 480 | − DA9063_BCORE2_ILIM_MASK), | |
| 481 | 437 | }, |
| 482 | 438 | { |
| 483 | 439 | DA9063_BUCK(DA9063, BPRO, 530, 10, 1800, |
| 484 | − da9063_buck_a_limits), | |
| 440 | + da9063_buck_a_limits, | |
| 441 | + DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK), | |
| 485 | 442 | DA9063_BUCK_COMMON_FIELDS(BPRO), |
| 486 | 443 | .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPRO_SEL), |
| 487 | − .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_B, | |
| 488 | − DA9063_BPRO_ILIM_MASK), | |
| 489 | 444 | }, |
| 490 | 445 | { |
| 491 | 446 | DA9063_BUCK(DA9063, BMEM, 800, 20, 3340, |
| 492 | − da9063_buck_b_limits), | |
| 447 | + da9063_buck_b_limits, | |
| 448 | + DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK), | |
| 493 | 449 | DA9063_BUCK_COMMON_FIELDS(BMEM), |
| 494 | 450 | .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL), |
| 495 | − .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A, | |
| 496 | − DA9063_BMEM_ILIM_MASK), | |
| 497 | 451 | }, |
| 498 | 452 | { |
| 499 | 453 | DA9063_BUCK(DA9063, BIO, 800, 20, 3340, |
| 500 | − da9063_buck_b_limits), | |
| 454 | + da9063_buck_b_limits, | |
| 455 | + DA9063_REG_BUCK_ILIM_A, DA9063_BIO_ILIM_MASK), | |
| 501 | 456 | DA9063_BUCK_COMMON_FIELDS(BIO), |
| 502 | 457 | .suspend = BFIELD(DA9063_REG_DVC_2, DA9063_VBIO_SEL), |
| 503 | − .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A, | |
| 504 | − DA9063_BIO_ILIM_MASK), | |
| 505 | 458 | }, |
| 506 | 459 | { |
| 507 | 460 | DA9063_BUCK(DA9063, BPERI, 800, 20, 3340, |
| 508 | − da9063_buck_b_limits), | |
| 461 | + da9063_buck_b_limits, | |
| 462 | + DA9063_REG_BUCK_ILIM_B, DA9063_BPERI_ILIM_MASK), | |
| 509 | 463 | DA9063_BUCK_COMMON_FIELDS(BPERI), |
| 510 | 464 | .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPERI_SEL), |
| 511 | − .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_B, | |
| 512 | − DA9063_BPERI_ILIM_MASK), | |
| 513 | 465 | }, |
| 514 | 466 | { |
| 515 | 467 | DA9063_BUCK(DA9063, BCORES_MERGED, 300, 10, 1570, |
| 516 | − da9063_bcores_merged_limits), | |
| 468 | + da9063_bcores_merged_limits, | |
| 469 | + DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK), | |
| 517 | 470 | /* BCORES_MERGED uses the same register fields as BCORE1 */ |
| 518 | 471 | DA9063_BUCK_COMMON_FIELDS(BCORE1), |
| 519 | 472 | .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL), |
| 520 | − .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C, | |
| 521 | − DA9063_BCORE1_ILIM_MASK), | |
| 522 | 473 | }, |
| 523 | 474 | { |
| 524 | 475 | DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340, |
| 525 | − da9063_bmem_bio_merged_limits), | |
| 476 | + da9063_bmem_bio_merged_limits, | |
| 477 | + DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK), | |
| 526 | 478 | /* BMEM_BIO_MERGED uses the same register fields as BMEM */ |
| 527 | 479 | DA9063_BUCK_COMMON_FIELDS(BMEM), |
| 528 | 480 | .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL), |
| 529 | − .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A, | |
| 530 | − DA9063_BMEM_ILIM_MASK), | |
| 531 | 481 | }, |
| 532 | 482 | { |
| 533 | 483 | DA9063_LDO(DA9063, LDO3, 900, 20, 3440), |
| @@ -615,9 +565,12 @@ static irqreturn_t da9063_ldo_lim_event(int irq, void *data) · 81 unmodified lines | ||
| 615 | 565 | if (regl->info->oc_event.reg != DA9063_REG_STATUS_D) |
| 616 | 566 | continue; |
| 617 | 567 | |
| 618 | − if (BIT(regl->info->oc_event.lsb) & bits) | |
| 568 | + if (BIT(regl->info->oc_event.lsb) & bits) { | |
| 569 | + regulator_lock(regl->rdev); | |
| 619 | 570 | regulator_notifier_call_chain(regl->rdev, |
| 620 | 571 | REGULATOR_EVENT_OVER_CURRENT, NULL); |
| 572 | + regulator_unlock(regl->rdev); | |
| 573 | + } | |
| 621 | 574 | } |
| 622 | 575 | |
| 623 | 576 | return IRQ_HANDLED; |
| @@ -861,13 +814,6 @@ static int da9063_regulator_probe(struct platform_device *pdev) · 237 unmodified lines | ||
| 861 | 814 | return PTR_ERR(regl->suspend_sleep); |
| 862 | 815 | } |
| 863 | 816 | |
| 864 | − if (regl->info->ilimit.reg) { | |
| 865 | − regl->ilimit = devm_regmap_field_alloc(&pdev->dev, | |
| 866 | − da9063->regmap, regl->info->ilimit); | |
| 867 | − if (IS_ERR(regl->ilimit)) | |
| 868 | − return PTR_ERR(regl->ilimit); | |
| 869 | − } | |
| 870 | − | |
| 871 | 817 | /* Register regulator */ |
| 872 | 818 | memset(&config, 0, sizeof(config)); |
| 873 | 819 | config.dev = &pdev->dev; |
| @@ -1,22 +1,7 @@ | ||
| 1 | −/* | |
| 2 | − * da9210-regulator.c - Regulator device driver for DA9210 | |
| 3 | − * Copyright (C) 2013 Dialog Semiconductor Ltd. | |
| 4 | − * | |
| 5 | − * This library is free software; you can redistribute it and/or | |
| 6 | − * modify it under the terms of the GNU Library General Public | |
| 7 | − * License as published by the Free Software Foundation; either | |
| 8 | − * version 2 of the License, or (at your option) any later version. | |
| 9 | − * | |
| 10 | − * This library is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | − * Library General Public License for more details. | |
| 14 | − * | |
| 15 | − * You should have received a copy of the GNU Library General Public | |
| 16 | − * License along with this library; if not, write to the | |
| 17 | − * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, | |
| 18 | − * Boston, MA 02110-1301, USA. | |
| 19 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// da9210-regulator.c - Regulator device driver for DA9210 | |
| 4 | +// Copyright (C) 2013 Dialog Semiconductor Ltd. | |
| 20 | 5 | |
| 21 | 6 | #include <linux/err.h> |
| 22 | 7 | #include <linux/i2c.h> |
| @@ -1,22 +1,7 @@ | ||
| 1 | − | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 2 | 2 | /* |
| 3 | 3 | * da9210-regulator.h - Regulator definitions for DA9210 |
| 4 | 4 | * Copyright (C) 2013 Dialog Semiconductor Ltd. |
| 5 | − * | |
| 6 | − * This library is free software; you can redistribute it and/or | |
| 7 | − * modify it under the terms of the GNU Library General Public | |
| 8 | − * License as published by the Free Software Foundation; either | |
| 9 | − * version 2 of the License, or (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This library is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | − * Library General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU Library General Public | |
| 17 | − * License along with this library; if not, write to the | |
| 18 | − * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, | |
| 19 | − * Boston, MA 02110-1301, USA. | |
| 20 | 5 | */ |
| 21 | 6 | |
| 22 | 7 | #ifndef __DA9210_REGISTERS_H__ |
| @@ -1,18 +1,8 @@ | ||
| 1 | −/* | |
| 2 | − * da9211-regulator.c - Regulator device driver for DA9211/DA9212 | |
| 3 | − * /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225 | |
| 4 | − * Copyright (C) 2015 Dialog Semiconductor Ltd. | |
| 5 | − * | |
| 6 | − * This library is free software; you can redistribute it and/or | |
| 7 | − * modify it under the terms of the GNU Library General Public | |
| 8 | − * License as published by the Free Software Foundation; either | |
| 9 | − * version 2 of the License, or (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This library is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | − * Library General Public License for more details. | |
| 15 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// da9211-regulator.c - Regulator device driver for DA9211/DA9212 | |
| 4 | +// /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225 | |
| 5 | +// Copyright (C) 2015 Dialog Semiconductor Ltd. | |
| 16 | 6 | |
| 17 | 7 | #include <linux/err.h> |
| 18 | 8 | #include <linux/i2c.h> |
| @@ -322,8 +312,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) · 303 unmodified lines | ||
| 322 | 312 | goto error_i2c; |
| 323 | 313 | |
| 324 | 314 | if (reg_val & DA9211_E_OV_CURR_A) { |
| 315 | + regulator_lock(chip->rdev[0]); | |
| 325 | 316 | regulator_notifier_call_chain(chip->rdev[0], |
| 326 | 317 | REGULATOR_EVENT_OVER_CURRENT, NULL); |
| 318 | + regulator_unlock(chip->rdev[0]); | |
| 327 | 319 | |
| 328 | 320 | err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, |
| 329 | 321 | DA9211_E_OV_CURR_A); |
| @@ -334,8 +326,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) · 4 unmodified lines | ||
| 334 | 326 | } |
| 335 | 327 | |
| 336 | 328 | if (reg_val & DA9211_E_OV_CURR_B) { |
| 329 | + regulator_lock(chip->rdev[1]); | |
| 337 | 330 | regulator_notifier_call_chain(chip->rdev[1], |
| 338 | 331 | REGULATOR_EVENT_OVER_CURRENT, NULL); |
| 332 | + regulator_unlock(chip->rdev[1]); | |
| 339 | 333 | |
| 340 | 334 | err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, |
| 341 | 335 | DA9211_E_OV_CURR_B); |
| @@ -1,17 +1,8 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 1 | 2 | /* |
| 2 | 3 | * da9211-regulator.h - Regulator definitions for DA9211/DA9212 |
| 3 | 4 | * /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225 |
| 4 | 5 | * Copyright (C) 2015 Dialog Semiconductor Ltd. |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or | |
| 7 | − * modify it under the terms of the GNU General Public License | |
| 8 | − * as published by the Free Software Foundation; either version 2 | |
| 9 | − * of the License, or (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | 6 | */ |
| 16 | 7 | |
| 17 | 8 | #ifndef __DA9211_REGISTERS_H__ |
| @@ -75,7 +75,7 @@ static int db8500_regulator_is_enabled(struct regulator_dev *rdev) · 74 unmodified lines | ||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /* db8500 regulator operations */ |
| 78 | −static struct regulator_ops db8500_regulator_ops = { | |
| 78 | +static const struct regulator_ops db8500_regulator_ops = { | |
| 79 | 79 | .enable = db8500_regulator_enable, |
| 80 | 80 | .disable = db8500_regulator_disable, |
| 81 | 81 | .is_enabled = db8500_regulator_is_enabled, |
| @@ -200,7 +200,7 @@ static int db8500_regulator_switch_is_enabled(struct regulator_dev *rdev) · 118 unmodified lines | ||
| 200 | 200 | return info->is_enabled; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | −static struct regulator_ops db8500_regulator_switch_ops = { | |
| 203 | +static const struct regulator_ops db8500_regulator_switch_ops = { | |
| 204 | 204 | .enable = db8500_regulator_switch_enable, |
| 205 | 205 | .disable = db8500_regulator_switch_disable, |
| 206 | 206 | .is_enabled = db8500_regulator_switch_is_enabled, |
| @@ -214,6 +214,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 7 unmodified lines | ||
| 214 | 214 | [DB8500_REGULATOR_VAPE] = { |
| 215 | 215 | .desc = { |
| 216 | 216 | .name = "db8500-vape", |
| 217 | + .of_match = of_match_ptr("db8500_vape"), | |
| 217 | 218 | .id = DB8500_REGULATOR_VAPE, |
| 218 | 219 | .ops = &db8500_regulator_ops, |
| 219 | 220 | .type = REGULATOR_VOLTAGE, |
| @@ -223,6 +224,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 223 | 224 | [DB8500_REGULATOR_VARM] = { |
| 224 | 225 | .desc = { |
| 225 | 226 | .name = "db8500-varm", |
| 227 | + .of_match = of_match_ptr("db8500_varm"), | |
| 226 | 228 | .id = DB8500_REGULATOR_VARM, |
| 227 | 229 | .ops = &db8500_regulator_ops, |
| 228 | 230 | .type = REGULATOR_VOLTAGE, |
| @@ -232,6 +234,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 232 | 234 | [DB8500_REGULATOR_VMODEM] = { |
| 233 | 235 | .desc = { |
| 234 | 236 | .name = "db8500-vmodem", |
| 237 | + .of_match = of_match_ptr("db8500_vmodem"), | |
| 235 | 238 | .id = DB8500_REGULATOR_VMODEM, |
| 236 | 239 | .ops = &db8500_regulator_ops, |
| 237 | 240 | .type = REGULATOR_VOLTAGE, |
| @@ -241,6 +244,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 241 | 244 | [DB8500_REGULATOR_VPLL] = { |
| 242 | 245 | .desc = { |
| 243 | 246 | .name = "db8500-vpll", |
| 247 | + .of_match = of_match_ptr("db8500_vpll"), | |
| 244 | 248 | .id = DB8500_REGULATOR_VPLL, |
| 245 | 249 | .ops = &db8500_regulator_ops, |
| 246 | 250 | .type = REGULATOR_VOLTAGE, |
| @@ -250,6 +254,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 250 | 254 | [DB8500_REGULATOR_VSMPS1] = { |
| 251 | 255 | .desc = { |
| 252 | 256 | .name = "db8500-vsmps1", |
| 257 | + .of_match = of_match_ptr("db8500_vsmps1"), | |
| 253 | 258 | .id = DB8500_REGULATOR_VSMPS1, |
| 254 | 259 | .ops = &db8500_regulator_ops, |
| 255 | 260 | .type = REGULATOR_VOLTAGE, |
| @@ -259,6 +264,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 259 | 264 | [DB8500_REGULATOR_VSMPS2] = { |
| 260 | 265 | .desc = { |
| 261 | 266 | .name = "db8500-vsmps2", |
| 267 | + .of_match = of_match_ptr("db8500_vsmps2"), | |
| 262 | 268 | .id = DB8500_REGULATOR_VSMPS2, |
| 263 | 269 | .ops = &db8500_regulator_ops, |
| 264 | 270 | .type = REGULATOR_VOLTAGE, |
| @@ -271,6 +277,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 6 unmodified lines | ||
| 271 | 277 | [DB8500_REGULATOR_VSMPS3] = { |
| 272 | 278 | .desc = { |
| 273 | 279 | .name = "db8500-vsmps3", |
| 280 | + .of_match = of_match_ptr("db8500_vsmps3"), | |
| 274 | 281 | .id = DB8500_REGULATOR_VSMPS3, |
| 275 | 282 | .ops = &db8500_regulator_ops, |
| 276 | 283 | .type = REGULATOR_VOLTAGE, |
| @@ -280,6 +287,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 280 | 287 | [DB8500_REGULATOR_VRF1] = { |
| 281 | 288 | .desc = { |
| 282 | 289 | .name = "db8500-vrf1", |
| 290 | + .of_match = of_match_ptr("db8500_vrf1"), | |
| 283 | 291 | .id = DB8500_REGULATOR_VRF1, |
| 284 | 292 | .ops = &db8500_regulator_ops, |
| 285 | 293 | .type = REGULATOR_VOLTAGE, |
| @@ -289,6 +297,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines | ||
| 289 | 297 | [DB8500_REGULATOR_SWITCH_SVAMMDSP] = { |
| 290 | 298 | .desc = { |
| 291 | 299 | .name = "db8500-sva-mmdsp", |
| 300 | + .of_match = of_match_ptr("db8500_sva_mmdsp"), | |
| 292 | 301 | .id = DB8500_REGULATOR_SWITCH_SVAMMDSP, |
| 293 | 302 | .ops = &db8500_regulator_switch_ops, |
| 294 | 303 | .type = REGULATOR_VOLTAGE, |
| @@ -299,6 +308,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines | ||
| 299 | 308 | [DB8500_REGULATOR_SWITCH_SVAMMDSPRET] = { |
| 300 | 309 | .desc = { |
| 301 | 310 | .name = "db8500-sva-mmdsp-ret", |
| 311 | + .of_match = of_match_ptr("db8500_sva_mmdsp_ret"), | |
| 302 | 312 | .id = DB8500_REGULATOR_SWITCH_SVAMMDSPRET, |
| 303 | 313 | .ops = &db8500_regulator_switch_ops, |
| 304 | 314 | .type = REGULATOR_VOLTAGE, |
| @@ -310,6 +320,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines | ||
| 310 | 320 | [DB8500_REGULATOR_SWITCH_SVAPIPE] = { |
| 311 | 321 | .desc = { |
| 312 | 322 | .name = "db8500-sva-pipe", |
| 323 | + .of_match = of_match_ptr("db8500_sva_pipe"), | |
| 313 | 324 | .id = DB8500_REGULATOR_SWITCH_SVAPIPE, |
| 314 | 325 | .ops = &db8500_regulator_switch_ops, |
| 315 | 326 | .type = REGULATOR_VOLTAGE, |
| @@ -320,6 +331,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines | ||
| 320 | 331 | [DB8500_REGULATOR_SWITCH_SIAMMDSP] = { |
| 321 | 332 | .desc = { |
| 322 | 333 | .name = "db8500-sia-mmdsp", |
| 334 | + .of_match = of_match_ptr("db8500_sia_mmdsp"), | |
| 323 | 335 | .id = DB8500_REGULATOR_SWITCH_SIAMMDSP, |
| 324 | 336 | .ops = &db8500_regulator_switch_ops, |
| 325 | 337 | .type = REGULATOR_VOLTAGE, |
| @@ -330,6 +342,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines | ||
| 330 | 342 | [DB8500_REGULATOR_SWITCH_SIAMMDSPRET] = { |
| 331 | 343 | .desc = { |
| 332 | 344 | .name = "db8500-sia-mmdsp-ret", |
| 345 | + .of_match = of_match_ptr("db8500_sia_mmdsp_ret"), | |
| 333 | 346 | .id = DB8500_REGULATOR_SWITCH_SIAMMDSPRET, |
| 334 | 347 | .ops = &db8500_regulator_switch_ops, |
| 335 | 348 | .type = REGULATOR_VOLTAGE, |
| @@ -341,6 +354,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines | ||
| 341 | 354 | [DB8500_REGULATOR_SWITCH_SIAPIPE] = { |
| 342 | 355 | .desc = { |
| 343 | 356 | .name = "db8500-sia-pipe", |
| 357 | + .of_match = of_match_ptr("db8500_sia_pipe"), | |
| 344 | 358 | .id = DB8500_REGULATOR_SWITCH_SIAPIPE, |
| 345 | 359 | .ops = &db8500_regulator_switch_ops, |
| 346 | 360 | .type = REGULATOR_VOLTAGE, |
| @@ -351,6 +365,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines | ||
| 351 | 365 | [DB8500_REGULATOR_SWITCH_SGA] = { |
| 352 | 366 | .desc = { |
| 353 | 367 | .name = "db8500-sga", |
| 368 | + .of_match = of_match_ptr("db8500_sga"), | |
| 354 | 369 | .id = DB8500_REGULATOR_SWITCH_SGA, |
| 355 | 370 | .ops = &db8500_regulator_switch_ops, |
| 356 | 371 | .type = REGULATOR_VOLTAGE, |
| @@ -361,6 +376,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines | ||
| 361 | 376 | [DB8500_REGULATOR_SWITCH_B2R2_MCDE] = { |
| 362 | 377 | .desc = { |
| 363 | 378 | .name = "db8500-b2r2-mcde", |
| 379 | + .of_match = of_match_ptr("db8500_b2r2_mcde"), | |
| 364 | 380 | .id = DB8500_REGULATOR_SWITCH_B2R2_MCDE, |
| 365 | 381 | .ops = &db8500_regulator_switch_ops, |
| 366 | 382 | .type = REGULATOR_VOLTAGE, |
| @@ -371,6 +387,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines | ||
| 371 | 387 | [DB8500_REGULATOR_SWITCH_ESRAM12] = { |
| 372 | 388 | .desc = { |
| 373 | 389 | .name = "db8500-esram12", |
| 390 | + .of_match = of_match_ptr("db8500_esram12"), | |
| 374 | 391 | .id = DB8500_REGULATOR_SWITCH_ESRAM12, |
| 375 | 392 | .ops = &db8500_regulator_switch_ops, |
| 376 | 393 | .type = REGULATOR_VOLTAGE, |
| @@ -382,6 +399,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines | ||
| 382 | 399 | [DB8500_REGULATOR_SWITCH_ESRAM12RET] = { |
| 383 | 400 | .desc = { |
| 384 | 401 | .name = "db8500-esram12-ret", |
| 402 | + .of_match = of_match_ptr("db8500_esram12_ret"), | |
| 385 | 403 | .id = DB8500_REGULATOR_SWITCH_ESRAM12RET, |
| 386 | 404 | .ops = &db8500_regulator_switch_ops, |
| 387 | 405 | .type = REGULATOR_VOLTAGE, |
| @@ -393,6 +411,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines | ||
| 393 | 411 | [DB8500_REGULATOR_SWITCH_ESRAM34] = { |
| 394 | 412 | .desc = { |
| 395 | 413 | .name = "db8500-esram34", |
| 414 | + .of_match = of_match_ptr("db8500_esram34"), | |
| 396 | 415 | .id = DB8500_REGULATOR_SWITCH_ESRAM34, |
| 397 | 416 | .ops = &db8500_regulator_switch_ops, |
| 398 | 417 | .type = REGULATOR_VOLTAGE, |
| @@ -404,6 +423,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines | ||
| 404 | 423 | [DB8500_REGULATOR_SWITCH_ESRAM34RET] = { |
| 405 | 424 | .desc = { |
| 406 | 425 | .name = "db8500-esram34-ret", |
| 426 | + .of_match = of_match_ptr("db8500_esram34_ret"), | |
| 407 | 427 | .id = DB8500_REGULATOR_SWITCH_ESRAM34RET, |
| 408 | 428 | .ops = &db8500_regulator_switch_ops, |
| 409 | 429 | .type = REGULATOR_VOLTAGE, |
| @@ -414,113 +434,38 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines | ||
| 414 | 434 | }, |
| 415 | 435 | }; |
| 416 | 436 | |
| 417 | −static int db8500_regulator_register(struct platform_device *pdev, | |
| 418 | − struct regulator_init_data *init_data, | |
| 419 | − int id, | |
| 420 | − struct device_node *np) | |
| 437 | +static int db8500_regulator_probe(struct platform_device *pdev) | |
| 421 | 438 | { |
| 439 | + struct regulator_init_data *db8500_init_data; | |
| 422 | 440 | struct dbx500_regulator_info *info; |
| 423 | 441 | struct regulator_config config = { }; |
| 424 | − int err; | |
| 425 | − | |
| 426 | − /* assign per-regulator data */ | |
| 427 | − info = &dbx500_regulator_info[id]; | |
| 428 | − info->dev = &pdev->dev; | |
| 429 | − | |
| 430 | − config.dev = &pdev->dev; | |
| 431 | − config.init_data = init_data; | |
| 432 | − config.driver_data = info; | |
| 433 | − config.of_node = np; | |
| 434 | − | |
| 435 | − /* register with the regulator framework */ | |
| 436 | − info->rdev = devm_regulator_register(&pdev->dev, &info->desc, &config); | |
| 437 | − if (IS_ERR(info->rdev)) { | |
| 438 | − err = PTR_ERR(info->rdev); | |
| 439 | − dev_err(&pdev->dev, "failed to register %s: err %i\n", | |
| 440 | − info->desc.name, err); | |
| 441 | − return err; | |
| 442 | − } | |
| 443 | − | |
| 444 | − dev_dbg(rdev_get_dev(info->rdev), | |
| 445 | − "regulator-%s-probed\n", info->desc.name); | |
| 442 | + struct regulator_dev *rdev; | |
| 443 | + int err, i; | |
| 446 | 444 | |
| 447 | − return 0; | |
| 448 | −} | |
| 449 | − | |
| 450 | −static struct of_regulator_match db8500_regulator_matches[] = { | |
| 451 | − { .name = "db8500_vape", .driver_data = (void *) DB8500_REGULATOR_VAPE, }, | |
| 452 | − { .name = "db8500_varm", .driver_data = (void *) DB8500_REGULATOR_VARM, }, | |
| 453 | − { .name = "db8500_vmodem", .driver_data = (void *) DB8500_REGULATOR_VMODEM, }, | |
| 454 | − { .name = "db8500_vpll", .driver_data = (void *) DB8500_REGULATOR_VPLL, }, | |
| 455 | − { .name = "db8500_vsmps1", .driver_data = (void *) DB8500_REGULATOR_VSMPS1, }, | |
| 456 | − { .name = "db8500_vsmps2", .driver_data = (void *) DB8500_REGULATOR_VSMPS2, }, | |
| 457 | − { .name = "db8500_vsmps3", .driver_data = (void *) DB8500_REGULATOR_VSMPS3, }, | |
| 458 | − { .name = "db8500_vrf1", .driver_data = (void *) DB8500_REGULATOR_VRF1, }, | |
| 459 | − { .name = "db8500_sva_mmdsp", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSP, }, | |
| 460 | − { .name = "db8500_sva_mmdsp_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSPRET, }, | |
| 461 | − { .name = "db8500_sva_pipe", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAPIPE, }, | |
| 462 | − { .name = "db8500_sia_mmdsp", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSP, }, | |
| 463 | − { .name = "db8500_sia_mmdsp_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSPRET, }, | |
| 464 | − { .name = "db8500_sia_pipe", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAPIPE, }, | |
| 465 | − { .name = "db8500_sga", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SGA, }, | |
| 466 | − { .name = "db8500_b2r2_mcde", .driver_data = (void *) DB8500_REGULATOR_SWITCH_B2R2_MCDE, }, | |
| 467 | − { .name = "db8500_esram12", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12, }, | |
| 468 | − { .name = "db8500_esram12_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12RET, }, | |
| 469 | − { .name = "db8500_esram34", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34, }, | |
| 470 | − { .name = "db8500_esram34_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34RET, }, | |
| 471 | −}; | |
| 472 | − | |
| 473 | −static int | |
| 474 | −db8500_regulator_of_probe(struct platform_device *pdev, | |
| 475 | − struct device_node *np) | |
| 476 | −{ | |
| 477 | − int i, err; | |
| 445 | + db8500_init_data = dev_get_platdata(&pdev->dev); | |
| 478 | 446 | |
| 479 | 447 | for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) { |
| 480 | − err = db8500_regulator_register( | |
| 481 | − pdev, db8500_regulator_matches[i].init_data, | |
| 482 | − i, db8500_regulator_matches[i].of_node); | |
| 483 | − if (err) | |
| 448 | + /* assign per-regulator data */ | |
| 449 | + info = &dbx500_regulator_info[i]; | |
| 450 | + | |
| 451 | + config.driver_data = info; | |
| 452 | + config.dev = &pdev->dev; | |
| 453 | + if (db8500_init_data) | |
| 454 | + config.init_data = &db8500_init_data[i]; | |
| 455 | + | |
| 456 | + rdev = devm_regulator_register(&pdev->dev, &info->desc, | |
| 457 | + &config); | |
| 458 | + if (IS_ERR(rdev)) { | |
| 459 | + err = PTR_ERR(rdev); | |
| 460 | + dev_err(&pdev->dev, "failed to register %s: err %i\n", | |
| 461 | + info->desc.name, err); | |
| 484 | 462 | return err; |
| 485 | − } | |
| 486 | − | |
| 487 | − return 0; | |
| 488 | −} | |
| 489 | − | |
| 490 | −static int db8500_regulator_probe(struct platform_device *pdev) | |
| 491 | −{ | |
| 492 | − struct regulator_init_data *db8500_init_data = | |
| 493 | − dev_get_platdata(&pdev->dev); | |
| 494 | − struct device_node *np = pdev->dev.of_node; | |
| 495 | − int i, err; | |
| 496 | − | |
| 497 | − /* register all regulators */ | |
| 498 | − if (np) { | |
| 499 | − err = of_regulator_match(&pdev->dev, np, | |
| 500 | − db8500_regulator_matches, | |
| 501 | − ARRAY_SIZE(db8500_regulator_matches)); | |
| 502 | − if (err < 0) { | |
| 503 | − dev_err(&pdev->dev, | |
| 504 | − "Error parsing regulator init data: %d\n", err); | |
| 505 | − return err; | |
| 506 | − } | |
| 507 | − | |
| 508 | − err = db8500_regulator_of_probe(pdev, np); | |
| 509 | − if (err) | |
| 510 | − return err; | |
| 511 | − } else { | |
| 512 | − for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) { | |
| 513 | − err = db8500_regulator_register(pdev, | |
| 514 | − &db8500_init_data[i], | |
| 515 | − i, NULL); | |
| 516 | − if (err) | |
| 517 | − return err; | |
| 518 | 463 | } |
| 464 | + dev_dbg(&pdev->dev, "regulator-%s-probed\n", info->desc.name); | |
| 519 | 465 | } |
| 520 | 466 | |
| 521 | − err = ux500_regulator_debug_init(pdev, | |
| 522 | − dbx500_regulator_info, | |
| 523 | − ARRAY_SIZE(dbx500_regulator_info)); | |
| 467 | + ux500_regulator_debug_init(pdev, dbx500_regulator_info, | |
| 468 | + ARRAY_SIZE(dbx500_regulator_info)); | |
| 524 | 469 | return 0; |
| 525 | 470 | } |
| 526 | 471 | |
| @@ -15,18 +15,14 @@ · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * struct dbx500_regulator_info - dbx500 regulator information |
| 18 | − * @dev: device pointer | |
| 19 | 18 | * @desc: regulator description |
| 20 | − * @rdev: regulator device pointer | |
| 21 | 19 | * @is_enabled: status of the regulator |
| 22 | 20 | * @epod_id: id for EPOD (power domain) |
| 23 | 21 | * @is_ramret: RAM retention switch for EPOD (power domain) |
| 24 | 22 | * |
| 25 | 23 | */ |
| 26 | 24 | struct dbx500_regulator_info { |
| 27 | − struct device *dev; | |
| 28 | 25 | struct regulator_desc desc; |
| 29 | − struct regulator_dev *rdev; | |
| 30 | 26 | bool is_enabled; |
| 31 | 27 | u16 epod_id; |
| 32 | 28 | bool is_ramret; |
| @@ -1,17 +1,13 @@ | ||
| 1 | −/* | |
| 2 | − * FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver. | |
| 3 | − * | |
| 4 | − * Supported Part Numbers: | |
| 5 | − * FAN53555UC00X/01X/03X/04X/05X | |
| 6 | − * | |
| 7 | − * Copyright (c) 2012 Marvell Technology Ltd. | |
| 8 | − * Yunfan Zhang <yfzhang@marvell.com> | |
| 9 | − * | |
| 10 | − * This package is free software; you can redistribute it and/or modify | |
| 11 | − * it under the terms of the GNU General Public License version 2 as | |
| 12 | − * published by the Free Software Foundation. | |
| 13 | − * | |
| 14 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver. | |
| 4 | +// | |
| 5 | +// Supported Part Numbers: | |
| 6 | +// FAN53555UC00X/01X/03X/04X/05X | |
| 7 | +// | |
| 8 | +// Copyright (c) 2012 Marvell Technology Ltd. | |
| 9 | +// Yunfan Zhang <yfzhang@marvell.com> | |
| 10 | + | |
| 15 | 11 | #include <linux/module.h> |
| 16 | 12 | #include <linux/param.h> |
| 17 | 13 | #include <linux/err.h> |
| @@ -91,10 +87,8 @@ enum { · 73 unmodified lines | ||
| 91 | 87 | |
| 92 | 88 | struct fan53555_device_info { |
| 93 | 89 | enum fan53555_vendor vendor; |
| 94 | − struct regmap *regmap; | |
| 95 | 90 | struct device *dev; |
| 96 | 91 | struct regulator_desc desc; |
| 97 | − struct regulator_dev *rdev; | |
| 98 | 92 | struct regulator_init_data *regulator; |
| 99 | 93 | /* IC Type and Rev */ |
| 100 | 94 | int chip_id; |
| @@ -106,8 +100,6 @@ struct fan53555_device_info { · 5 unmodified lines | ||
| 106 | 100 | unsigned int vsel_min; |
| 107 | 101 | unsigned int vsel_step; |
| 108 | 102 | unsigned int vsel_count; |
| 109 | − /* Voltage slew rate limiting */ | |
| 110 | − unsigned int slew_rate; | |
| 111 | 103 | /* Mode */ |
| 112 | 104 | unsigned int mode_reg; |
| 113 | 105 | unsigned int mode_mask; |
| @@ -125,7 +117,7 @@ static int fan53555_set_suspend_voltage(struct regulator_dev *rdev, int uV) · 11 unmodified lines | ||
| 125 | 117 | ret = regulator_map_voltage_linear(rdev, uV, uV); |
| 126 | 118 | if (ret < 0) |
| 127 | 119 | return ret; |
| 128 | − ret = regmap_update_bits(di->regmap, di->sleep_reg, | |
| 120 | + ret = regmap_update_bits(rdev->regmap, di->sleep_reg, | |
| 129 | 121 | di->desc.vsel_mask, ret); |
| 130 | 122 | if (ret < 0) |
| 131 | 123 | return ret; |
| @@ -140,7 +132,7 @@ static int fan53555_set_suspend_enable(struct regulator_dev *rdev) · 8 unmodified lines | ||
| 140 | 132 | { |
| 141 | 133 | struct fan53555_device_info *di = rdev_get_drvdata(rdev); |
| 142 | 134 | |
| 143 | − return regmap_update_bits(di->regmap, di->sleep_reg, | |
| 135 | + return regmap_update_bits(rdev->regmap, di->sleep_reg, | |
| 144 | 136 | VSEL_BUCK_EN, VSEL_BUCK_EN); |
| 145 | 137 | } |
| 146 | 138 | |
| @@ -148,7 +140,7 @@ static int fan53555_set_suspend_disable(struct regulator_dev *rdev) · 1 unmodified line | ||
| 148 | 140 | { |
| 149 | 141 | struct fan53555_device_info *di = rdev_get_drvdata(rdev); |
| 150 | 142 | |
| 151 | − return regmap_update_bits(di->regmap, di->sleep_reg, | |
| 143 | + return regmap_update_bits(rdev->regmap, di->sleep_reg, | |
| 152 | 144 | VSEL_BUCK_EN, 0); |
| 153 | 145 | } |
| 154 | 146 | |
| @@ -158,11 +150,11 @@ static int fan53555_set_mode(struct regulator_dev *rdev, unsigned int mode) · 3 unmodified lines | ||
| 158 | 150 | |
| 159 | 151 | switch (mode) { |
| 160 | 152 | case REGULATOR_MODE_FAST: |
| 161 | − regmap_update_bits(di->regmap, di->mode_reg, | |
| 153 | + regmap_update_bits(rdev->regmap, di->mode_reg, | |
| 162 | 154 | di->mode_mask, di->mode_mask); |
| 163 | 155 | break; |
| 164 | 156 | case REGULATOR_MODE_NORMAL: |
| 165 | − regmap_update_bits(di->regmap, di->vol_reg, di->mode_mask, 0); | |
| 157 | + regmap_update_bits(rdev->regmap, di->vol_reg, di->mode_mask, 0); | |
| 166 | 158 | break; |
| 167 | 159 | default: |
| 168 | 160 | return -EINVAL; |
| @@ -176,7 +168,7 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev) · 7 unmodified lines | ||
| 176 | 168 | unsigned int val; |
| 177 | 169 | int ret = 0; |
| 178 | 170 | |
| 179 | − ret = regmap_read(di->regmap, di->mode_reg, &val); | |
| 171 | + ret = regmap_read(rdev->regmap, di->mode_reg, &val); | |
| 180 | 172 | if (ret < 0) |
| 181 | 173 | return ret; |
| 182 | 174 | if (val & di->mode_mask) |
| @@ -213,7 +205,7 @@ static int fan53555_set_ramp(struct regulator_dev *rdev, int ramp) · 30 unmodified lines | ||
| 213 | 205 | return -EINVAL; |
| 214 | 206 | } |
| 215 | 207 | |
| 216 | − return regmap_update_bits(di->regmap, FAN53555_CONTROL, | |
| 208 | + return regmap_update_bits(rdev->regmap, FAN53555_CONTROL, | |
| 217 | 209 | CTL_SLEW_MASK, regval << CTL_SLEW_SHIFT); |
| 218 | 210 | } |
| 219 | 211 | |
| @@ -396,6 +388,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, · 176 unmodified lines | ||
| 396 | 388 | struct regulator_config *config) |
| 397 | 389 | { |
| 398 | 390 | struct regulator_desc *rdesc = &di->desc; |
| 391 | + struct regulator_dev *rdev; | |
| 399 | 392 | |
| 400 | 393 | rdesc->name = "fan53555-reg"; |
| 401 | 394 | rdesc->supply_name = "vin"; |
| @@ -410,8 +403,8 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, · 8 unmodified lines | ||
| 410 | 403 | rdesc->vsel_mask = di->vsel_count - 1; |
| 411 | 404 | rdesc->owner = THIS_MODULE; |
| 412 | 405 | |
| 413 | − di->rdev = devm_regulator_register(di->dev, &di->desc, config); | |
| 414 | − return PTR_ERR_OR_ZERO(di->rdev); | |
| 406 | + rdev = devm_regulator_register(di->dev, &di->desc, config); | |
| 407 | + return PTR_ERR_OR_ZERO(rdev); | |
| 415 | 408 | } |
| 416 | 409 | |
| 417 | 410 | static const struct regmap_config fan53555_regmap_config = { |
| @@ -466,6 +459,7 @@ static int fan53555_regulator_probe(struct i2c_client *client, · 48 unmodified lines | ||
| 466 | 459 | struct fan53555_device_info *di; |
| 467 | 460 | struct fan53555_platform_data *pdata; |
| 468 | 461 | struct regulator_config config = { }; |
| 462 | + struct regmap *regmap; | |
| 469 | 463 | unsigned int val; |
| 470 | 464 | int ret; |
| 471 | 465 | |
| @@ -502,22 +496,22 @@ static int fan53555_regulator_probe(struct i2c_client *client, · 30 unmodified lines | ||
| 502 | 496 | di->vendor = id->driver_data; |
| 503 | 497 | } |
| 504 | 498 | |
| 505 | − di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config); | |
| 506 | − if (IS_ERR(di->regmap)) { | |
| 499 | + regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config); | |
| 500 | + if (IS_ERR(regmap)) { | |
| 507 | 501 | dev_err(&client->dev, "Failed to allocate regmap!\n"); |
| 508 | − return PTR_ERR(di->regmap); | |
| 502 | + return PTR_ERR(regmap); | |
| 509 | 503 | } |
| 510 | 504 | di->dev = &client->dev; |
| 511 | 505 | i2c_set_clientdata(client, di); |
| 512 | 506 | /* Get chip ID */ |
| 513 | − ret = regmap_read(di->regmap, FAN53555_ID1, &val); | |
| 507 | + ret = regmap_read(regmap, FAN53555_ID1, &val); | |
| 514 | 508 | if (ret < 0) { |
| 515 | 509 | dev_err(&client->dev, "Failed to get chip ID!\n"); |
| 516 | 510 | return ret; |
| 517 | 511 | } |
| 518 | 512 | di->chip_id = val & DIE_ID; |
| 519 | 513 | /* Get chip revision */ |
| 520 | − ret = regmap_read(di->regmap, FAN53555_ID2, &val); | |
| 514 | + ret = regmap_read(regmap, FAN53555_ID2, &val); | |
| 521 | 515 | if (ret < 0) { |
| 522 | 516 | dev_err(&client->dev, "Failed to get chip Rev!\n"); |
| 523 | 517 | return ret; |
| @@ -534,7 +528,7 @@ static int fan53555_regulator_probe(struct i2c_client *client, · 10 unmodified lines | ||
| 534 | 528 | /* Register regulator */ |
| 535 | 529 | config.dev = di->dev; |
| 536 | 530 | config.init_data = di->regulator; |
| 537 | − config.regmap = di->regmap; | |
| 531 | + config.regmap = regmap; | |
| 538 | 532 | config.driver_data = di; |
| 539 | 533 | config.of_node = np; |
| 540 | 534 | |
| @@ -36,7 +36,6 @@ · 35 unmodified lines | ||
| 36 | 36 | |
| 37 | 37 | struct gpio_regulator_data { |
| 38 | 38 | struct regulator_desc desc; |
| 39 | − struct regulator_dev *dev; | |
| 40 | 39 | |
| 41 | 40 | struct gpio_desc **gpiods; |
| 42 | 41 | int nr_gpios; |
| @@ -125,7 +124,7 @@ static int gpio_regulator_set_current_limit(struct regulator_dev *dev, · 82 unmodified lines | ||
| 125 | 124 | return 0; |
| 126 | 125 | } |
| 127 | 126 | |
| 128 | −static struct regulator_ops gpio_regulator_voltage_ops = { | |
| 127 | +static const struct regulator_ops gpio_regulator_voltage_ops = { | |
| 129 | 128 | .get_voltage = gpio_regulator_get_value, |
| 130 | 129 | .set_voltage = gpio_regulator_set_voltage, |
| 131 | 130 | .list_voltage = gpio_regulator_list_voltage, |
| @@ -221,7 +220,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, · 89 unmodified lines | ||
| 221 | 220 | return config; |
| 222 | 221 | } |
| 223 | 222 | |
| 224 | −static struct regulator_ops gpio_regulator_current_ops = { | |
| 223 | +static const struct regulator_ops gpio_regulator_current_ops = { | |
| 225 | 224 | .get_current_limit = gpio_regulator_get_value, |
| 226 | 225 | .set_current_limit = gpio_regulator_set_current_limit, |
| 227 | 226 | }; |
| @@ -233,6 +232,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 233 | 232 | struct device_node *np = dev->of_node; |
| 234 | 233 | struct gpio_regulator_data *drvdata; |
| 235 | 234 | struct regulator_config cfg = { }; |
| 235 | + struct regulator_dev *rdev; | |
| 236 | 236 | enum gpiod_flags gflags; |
| 237 | 237 | int ptr, ret, state, i; |
| 238 | 238 | |
| @@ -326,9 +326,9 @@ static int gpio_regulator_probe(struct platform_device *pdev) · 87 unmodified lines | ||
| 326 | 326 | if (IS_ERR(cfg.ena_gpiod)) |
| 327 | 327 | return PTR_ERR(cfg.ena_gpiod); |
| 328 | 328 | |
| 329 | − drvdata->dev = regulator_register(&drvdata->desc, &cfg); | |
| 330 | − if (IS_ERR(drvdata->dev)) { | |
| 331 | − ret = PTR_ERR(drvdata->dev); | |
| 329 | + rdev = devm_regulator_register(dev, &drvdata->desc, &cfg); | |
| 330 | + if (IS_ERR(rdev)) { | |
| 331 | + ret = PTR_ERR(rdev); | |
| 332 | 332 | dev_err(dev, "Failed to register regulator: %d\n", ret); |
| 333 | 333 | return ret; |
| 334 | 334 | } |
| @@ -338,15 +338,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 338 | 338 | return 0; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | −static int gpio_regulator_remove(struct platform_device *pdev) | |
| 342 | −{ | |
| 343 | − struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev); | |
| 344 | − | |
| 345 | − regulator_unregister(drvdata->dev); | |
| 346 | − | |
| 347 | − return 0; | |
| 348 | −} | |
| 349 | − | |
| 350 | 341 | #if defined(CONFIG_OF) |
| 351 | 342 | static const struct of_device_id regulator_gpio_of_match[] = { |
| 352 | 343 | { .compatible = "regulator-gpio", }, |
| @@ -357,7 +348,6 @@ MODULE_DEVICE_TABLE(of, regulator_gpio_of_match); · 4 unmodified lines | ||
| 357 | 348 | |
| 358 | 349 | static struct platform_driver gpio_regulator_driver = { |
| 359 | 350 | .probe = gpio_regulator_probe, |
| 360 | − .remove = gpio_regulator_remove, | |
| 361 | 351 | .driver = { |
| 362 | 352 | .name = "gpio-regulator", |
| 363 | 353 | .of_match_table = of_match_ptr(regulator_gpio_of_match), |
| @@ -1,17 +1,13 @@ | ||
| 1 | −/* | |
| 2 | − * Device driver for regulators in Hi6421 IC | |
| 3 | − * | |
| 4 | − * Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd. | |
| 5 | − * http://www.hisilicon.com | |
| 6 | − * Copyright (c) <2013-2014> Linaro Ltd. | |
| 7 | − * http://www.linaro.org | |
| 8 | − * | |
| 9 | − * Author: Guodong Xu <guodong.xu@linaro.org> | |
| 10 | − * | |
| 11 | − * This program is free software; you can redistribute it and/or modify | |
| 12 | − * it under the terms of the GNU General Public License version 2 as | |
| 13 | − * published by the Free Software Foundation. | |
| 14 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Device driver for regulators in Hi6421 IC | |
| 4 | +// | |
| 5 | +// Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd. | |
| 6 | +// http://www.hisilicon.com | |
| 7 | +// Copyright (c) <2013-2014> Linaro Ltd. | |
| 8 | +// http://www.linaro.org | |
| 9 | +// | |
| 10 | +// Author: Guodong Xu <guodong.xu@linaro.org> | |
| 15 | 11 | |
| 16 | 12 | #include <linux/slab.h> |
| 17 | 13 | #include <linux/device.h> |
| @@ -78,43 +74,6 @@ enum hi6421_regulator_id { · 60 unmodified lines | ||
| 78 | 74 | HI6421_NUM_REGULATORS, |
| 79 | 75 | }; |
| 80 | 76 | |
| 81 | −#define HI6421_REGULATOR_OF_MATCH(_name, id) \ | |
| 82 | −{ \ | |
| 83 | − .name = #_name, \ | |
| 84 | − .driver_data = (void *) HI6421_##id, \ | |
| 85 | −} | |
| 86 | − | |
| 87 | −static struct of_regulator_match hi6421_regulator_match[] = { | |
| 88 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout0, LDO0), | |
| 89 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout1, LDO1), | |
| 90 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout2, LDO2), | |
| 91 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout3, LDO3), | |
| 92 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout4, LDO4), | |
| 93 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout5, LDO5), | |
| 94 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout6, LDO6), | |
| 95 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout7, LDO7), | |
| 96 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout8, LDO8), | |
| 97 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout9, LDO9), | |
| 98 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout10, LDO10), | |
| 99 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout11, LDO11), | |
| 100 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout12, LDO12), | |
| 101 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout13, LDO13), | |
| 102 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout14, LDO14), | |
| 103 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout15, LDO15), | |
| 104 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout16, LDO16), | |
| 105 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout17, LDO17), | |
| 106 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout18, LDO18), | |
| 107 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout19, LDO19), | |
| 108 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout20, LDO20), | |
| 109 | − HI6421_REGULATOR_OF_MATCH(hi6421_vout_audio, LDOAUDIO), | |
| 110 | − HI6421_REGULATOR_OF_MATCH(hi6421_buck0, BUCK0), | |
| 111 | − HI6421_REGULATOR_OF_MATCH(hi6421_buck1, BUCK1), | |
| 112 | − HI6421_REGULATOR_OF_MATCH(hi6421_buck2, BUCK2), | |
| 113 | − HI6421_REGULATOR_OF_MATCH(hi6421_buck3, BUCK3), | |
| 114 | − HI6421_REGULATOR_OF_MATCH(hi6421_buck4, BUCK4), | |
| 115 | − HI6421_REGULATOR_OF_MATCH(hi6421_buck5, BUCK5), | |
| 116 | −}; | |
| 117 | − | |
| 118 | 77 | /* LDO 0, 4~7, 9~14, 16~20 have same voltage table. */ |
| 119 | 78 | static const unsigned int ldo_0_voltages[] = { |
| 120 | 79 | 1500000, 1800000, 2400000, 2500000, |
| @@ -157,6 +116,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 36 unmodified lines | ||
| 157 | 116 | #define HI6421_LDO_ENABLE_TIME (350) |
| 158 | 117 | /* |
| 159 | 118 | * _id - LDO id name string |
| 119 | + * _match - of match name string | |
| 160 | 120 | * v_table - voltage table |
| 161 | 121 | * vreg - voltage select register |
| 162 | 122 | * vmask - voltage select mask |
| @@ -166,11 +126,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 3 unmodified lines | ||
| 166 | 126 | * ecomask - eco mode mask |
| 167 | 127 | * ecoamp - eco mode load uppler limit in uA |
| 168 | 128 | */ |
| 169 | −#define HI6421_LDO(_id, v_table, vreg, vmask, ereg, emask, \ | |
| 129 | +#define HI6421_LDO(_id, _match, v_table, vreg, vmask, ereg, emask, \ | |
| 170 | 130 | odelay, ecomask, ecoamp) \ |
| 171 | 131 | [HI6421_##_id] = { \ |
| 172 | 132 | .desc = { \ |
| 173 | 133 | .name = #_id, \ |
| 134 | + .of_match = of_match_ptr(#_match), \ | |
| 135 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 174 | 136 | .ops = &hi6421_ldo_ops, \ |
| 175 | 137 | .type = REGULATOR_VOLTAGE, \ |
| 176 | 138 | .id = HI6421_##_id, \ |
| @@ -191,6 +153,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 14 unmodified lines | ||
| 191 | 153 | /* HI6421 LDO1~3 are linear voltage regulators at fixed uV_step |
| 192 | 154 | * |
| 193 | 155 | * _id - LDO id name string |
| 156 | + * _match - of match name string | |
| 194 | 157 | * _min_uV - minimum voltage supported in uV |
| 195 | 158 | * n_volt - number of votages available |
| 196 | 159 | * vstep - voltage increase in each linear step in uV |
| @@ -202,11 +165,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 5 unmodified lines | ||
| 202 | 165 | * ecomask - eco mode mask |
| 203 | 166 | * ecoamp - eco mode load uppler limit in uA |
| 204 | 167 | */ |
| 205 | −#define HI6421_LDO_LINEAR(_id, _min_uV, n_volt, vstep, vreg, vmask, \ | |
| 168 | +#define HI6421_LDO_LINEAR(_id, _match, _min_uV, n_volt, vstep, vreg, vmask,\ | |
| 206 | 169 | ereg, emask, odelay, ecomask, ecoamp) \ |
| 207 | 170 | [HI6421_##_id] = { \ |
| 208 | 171 | .desc = { \ |
| 209 | 172 | .name = #_id, \ |
| 173 | + .of_match = of_match_ptr(#_match), \ | |
| 174 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 210 | 175 | .ops = &hi6421_ldo_linear_ops, \ |
| 211 | 176 | .type = REGULATOR_VOLTAGE, \ |
| 212 | 177 | .id = HI6421_##_id, \ |
| @@ -228,6 +193,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 15 unmodified lines | ||
| 228 | 193 | /* HI6421 LDOAUDIO is a linear voltage regulator with two 4-step ranges |
| 229 | 194 | * |
| 230 | 195 | * _id - LDO id name string |
| 196 | + * _match - of match name string | |
| 231 | 197 | * n_volt - number of votages available |
| 232 | 198 | * volt_ranges - array of regulator_linear_range |
| 233 | 199 | * vstep - voltage increase in each linear step in uV |
| @@ -239,11 +205,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 5 unmodified lines | ||
| 239 | 205 | * ecomask - eco mode mask |
| 240 | 206 | * ecoamp - eco mode load uppler limit in uA |
| 241 | 207 | */ |
| 242 | −#define HI6421_LDO_LINEAR_RANGE(_id, n_volt, volt_ranges, vreg, vmask, \ | |
| 208 | +#define HI6421_LDO_LINEAR_RANGE(_id, _match, n_volt, volt_ranges, vreg, vmask,\ | |
| 243 | 209 | ereg, emask, odelay, ecomask, ecoamp) \ |
| 244 | 210 | [HI6421_##_id] = { \ |
| 245 | 211 | .desc = { \ |
| 246 | 212 | .name = #_id, \ |
| 213 | + .of_match = of_match_ptr(#_match), \ | |
| 214 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 247 | 215 | .ops = &hi6421_ldo_linear_range_ops, \ |
| 248 | 216 | .type = REGULATOR_VOLTAGE, \ |
| 249 | 217 | .id = HI6421_##_id, \ |
| @@ -265,6 +233,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 15 unmodified lines | ||
| 265 | 233 | /* HI6421 BUCK0/1/2 are linear voltage regulators at fixed uV_step |
| 266 | 234 | * |
| 267 | 235 | * _id - BUCK0/1/2 id name string |
| 236 | + * _match - of match name string | |
| 268 | 237 | * vreg - voltage select register |
| 269 | 238 | * vmask - voltage select mask |
| 270 | 239 | * ereg - enable register |
| @@ -273,11 +242,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 2 unmodified lines | ||
| 273 | 242 | * etime - enable time |
| 274 | 243 | * odelay - off/on delay time in uS |
| 275 | 244 | */ |
| 276 | −#define HI6421_BUCK012(_id, vreg, vmask, ereg, emask, sleepmask, \ | |
| 245 | +#define HI6421_BUCK012(_id, _match, vreg, vmask, ereg, emask, sleepmask,\ | |
| 277 | 246 | etime, odelay) \ |
| 278 | 247 | [HI6421_##_id] = { \ |
| 279 | 248 | .desc = { \ |
| 280 | 249 | .name = #_id, \ |
| 250 | + .of_match = of_match_ptr(#_match), \ | |
| 251 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 281 | 252 | .ops = &hi6421_buck012_ops, \ |
| 282 | 253 | .type = REGULATOR_VOLTAGE, \ |
| 283 | 254 | .id = HI6421_##_id, \ |
| @@ -299,6 +270,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 15 unmodified lines | ||
| 299 | 270 | * that it supports SLEEP mode, so has different .ops. |
| 300 | 271 | * |
| 301 | 272 | * _id - LDO id name string |
| 273 | + * _match - of match name string | |
| 302 | 274 | * v_table - voltage table |
| 303 | 275 | * vreg - voltage select register |
| 304 | 276 | * vmask - voltage select mask |
| @@ -307,11 +279,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 2 unmodified lines | ||
| 307 | 279 | * odelay - off/on delay time in uS |
| 308 | 280 | * sleepmask - mask of sleep mode |
| 309 | 281 | */ |
| 310 | −#define HI6421_BUCK345(_id, v_table, vreg, vmask, ereg, emask, \ | |
| 282 | +#define HI6421_BUCK345(_id, _match, v_table, vreg, vmask, ereg, emask, \ | |
| 311 | 283 | odelay, sleepmask) \ |
| 312 | 284 | [HI6421_##_id] = { \ |
| 313 | 285 | .desc = { \ |
| 314 | 286 | .name = #_id, \ |
| 287 | + .of_match = of_match_ptr(#_match), \ | |
| 288 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 315 | 289 | .ops = &hi6421_buck345_ops, \ |
| 316 | 290 | .type = REGULATOR_VOLTAGE, \ |
| 317 | 291 | .id = HI6421_##_id, \ |
| @@ -331,59 +305,63 @@ static const struct regulator_ops hi6421_buck345_ops; · 13 unmodified lines | ||
| 331 | 305 | /* HI6421 regulator information */ |
| 332 | 306 | static struct hi6421_regulator_info |
| 333 | 307 | hi6421_regulator_info[HI6421_NUM_REGULATORS] = { |
| 334 | − HI6421_LDO(LDO0, ldo_0_voltages, 0x20, 0x07, 0x20, 0x10, | |
| 308 | + HI6421_LDO(LDO0, hi6421_vout0, ldo_0_voltages, 0x20, 0x07, 0x20, 0x10, | |
| 335 | 309 | 10000, 0x20, 8000), |
| 336 | − HI6421_LDO_LINEAR(LDO1, 1700000, 4, 100000, 0x21, 0x03, 0x21, 0x10, | |
| 337 | − 10000, 0x20, 5000), | |
| 338 | − HI6421_LDO_LINEAR(LDO2, 1050000, 8, 50000, 0x22, 0x07, 0x22, 0x10, | |
| 339 | − 20000, 0x20, 8000), | |
| 340 | − HI6421_LDO_LINEAR(LDO3, 1050000, 8, 50000, 0x23, 0x07, 0x23, 0x10, | |
| 341 | − 20000, 0x20, 8000), | |
| 342 | − HI6421_LDO(LDO4, ldo_0_voltages, 0x24, 0x07, 0x24, 0x10, | |
| 310 | + HI6421_LDO_LINEAR(LDO1, hi6421_vout1, 1700000, 4, 100000, 0x21, 0x03, | |
| 311 | + 0x21, 0x10, 10000, 0x20, 5000), | |
| 312 | + HI6421_LDO_LINEAR(LDO2, hi6421_vout2, 1050000, 8, 50000, 0x22, 0x07, | |
| 313 | + 0x22, 0x10, 20000, 0x20, 8000), | |
| 314 | + HI6421_LDO_LINEAR(LDO3, hi6421_vout3, 1050000, 8, 50000, 0x23, 0x07, | |
| 315 | + 0x23, 0x10, 20000, 0x20, 8000), | |
| 316 | + HI6421_LDO(LDO4, hi6421_vout4, ldo_0_voltages, 0x24, 0x07, 0x24, 0x10, | |
| 343 | 317 | 20000, 0x20, 8000), |
| 344 | − HI6421_LDO(LDO5, ldo_0_voltages, 0x25, 0x07, 0x25, 0x10, | |
| 318 | + HI6421_LDO(LDO5, hi6421_vout5, ldo_0_voltages, 0x25, 0x07, 0x25, 0x10, | |
| 345 | 319 | 20000, 0x20, 8000), |
| 346 | − HI6421_LDO(LDO6, ldo_0_voltages, 0x26, 0x07, 0x26, 0x10, | |
| 320 | + HI6421_LDO(LDO6, hi6421_vout6, ldo_0_voltages, 0x26, 0x07, 0x26, 0x10, | |
| 347 | 321 | 20000, 0x20, 8000), |
| 348 | − HI6421_LDO(LDO7, ldo_0_voltages, 0x27, 0x07, 0x27, 0x10, | |
| 322 | + HI6421_LDO(LDO7, hi6421_vout7, ldo_0_voltages, 0x27, 0x07, 0x27, 0x10, | |
| 349 | 323 | 20000, 0x20, 5000), |
| 350 | − HI6421_LDO(LDO8, ldo_8_voltages, 0x28, 0x07, 0x28, 0x10, | |
| 324 | + HI6421_LDO(LDO8, hi6421_vout8, ldo_8_voltages, 0x28, 0x07, 0x28, 0x10, | |
| 351 | 325 | 20000, 0x20, 8000), |
| 352 | − HI6421_LDO(LDO9, ldo_0_voltages, 0x29, 0x07, 0x29, 0x10, | |
| 326 | + HI6421_LDO(LDO9, hi6421_vout9, ldo_0_voltages, 0x29, 0x07, 0x29, 0x10, | |
| 353 | 327 | 40000, 0x20, 8000), |
| 354 | − HI6421_LDO(LDO10, ldo_0_voltages, 0x2a, 0x07, 0x2a, 0x10, | |
| 328 | + HI6421_LDO(LDO10, hi6421_vout10, ldo_0_voltages, 0x2a, 0x07, 0x2a, 0x10, | |
| 355 | 329 | 40000, 0x20, 8000), |
| 356 | − HI6421_LDO(LDO11, ldo_0_voltages, 0x2b, 0x07, 0x2b, 0x10, | |
| 330 | + HI6421_LDO(LDO11, hi6421_vout11, ldo_0_voltages, 0x2b, 0x07, 0x2b, 0x10, | |
| 357 | 331 | 40000, 0x20, 8000), |
| 358 | − HI6421_LDO(LDO12, ldo_0_voltages, 0x2c, 0x07, 0x2c, 0x10, | |
| 332 | + HI6421_LDO(LDO12, hi6421_vout12, ldo_0_voltages, 0x2c, 0x07, 0x2c, 0x10, | |
| 359 | 333 | 40000, 0x20, 8000), |
| 360 | − HI6421_LDO(LDO13, ldo_0_voltages, 0x2d, 0x07, 0x2d, 0x10, | |
| 334 | + HI6421_LDO(LDO13, hi6421_vout13, ldo_0_voltages, 0x2d, 0x07, 0x2d, 0x10, | |
| 361 | 335 | 40000, 0x20, 8000), |
| 362 | − HI6421_LDO(LDO14, ldo_0_voltages, 0x2e, 0x07, 0x2e, 0x10, | |
| 336 | + HI6421_LDO(LDO14, hi6421_vout14, ldo_0_voltages, 0x2e, 0x07, 0x2e, 0x10, | |
| 363 | 337 | 40000, 0x20, 8000), |
| 364 | − HI6421_LDO(LDO15, ldo_8_voltages, 0x2f, 0x07, 0x2f, 0x10, | |
| 338 | + HI6421_LDO(LDO15, hi6421_vout15, ldo_8_voltages, 0x2f, 0x07, 0x2f, 0x10, | |
| 365 | 339 | 40000, 0x20, 8000), |
| 366 | − HI6421_LDO(LDO16, ldo_0_voltages, 0x30, 0x07, 0x30, 0x10, | |
| 340 | + HI6421_LDO(LDO16, hi6421_vout16, ldo_0_voltages, 0x30, 0x07, 0x30, 0x10, | |
| 367 | 341 | 40000, 0x20, 8000), |
| 368 | − HI6421_LDO(LDO17, ldo_0_voltages, 0x31, 0x07, 0x31, 0x10, | |
| 342 | + HI6421_LDO(LDO17, hi6421_vout17, ldo_0_voltages, 0x31, 0x07, 0x31, 0x10, | |
| 369 | 343 | 40000, 0x20, 8000), |
| 370 | − HI6421_LDO(LDO18, ldo_0_voltages, 0x32, 0x07, 0x32, 0x10, | |
| 344 | + HI6421_LDO(LDO18, hi6421_vout18, ldo_0_voltages, 0x32, 0x07, 0x32, 0x10, | |
| 371 | 345 | 40000, 0x20, 8000), |
| 372 | − HI6421_LDO(LDO19, ldo_0_voltages, 0x33, 0x07, 0x33, 0x10, | |
| 346 | + HI6421_LDO(LDO19, hi6421_vout19, ldo_0_voltages, 0x33, 0x07, 0x33, 0x10, | |
| 373 | 347 | 40000, 0x20, 8000), |
| 374 | − HI6421_LDO(LDO20, ldo_0_voltages, 0x34, 0x07, 0x34, 0x10, | |
| 348 | + HI6421_LDO(LDO20, hi6421_vout20, ldo_0_voltages, 0x34, 0x07, 0x34, 0x10, | |
| 375 | 349 | 40000, 0x20, 8000), |
| 376 | − HI6421_LDO_LINEAR_RANGE(LDOAUDIO, 8, ldo_audio_volt_range, 0x36, | |
| 377 | − 0x70, 0x36, 0x01, 40000, 0x02, 5000), | |
| 378 | − HI6421_BUCK012(BUCK0, 0x0d, 0x7f, 0x0c, 0x01, 0x10, 400, 20000), | |
| 379 | − HI6421_BUCK012(BUCK1, 0x0f, 0x7f, 0x0e, 0x01, 0x10, 400, 20000), | |
| 380 | − HI6421_BUCK012(BUCK2, 0x11, 0x7f, 0x10, 0x01, 0x10, 350, 100), | |
| 381 | − HI6421_BUCK345(BUCK3, buck_3_voltages, 0x13, 0x07, 0x12, 0x01, | |
| 382 | − 20000, 0x10), | |
| 383 | − HI6421_BUCK345(BUCK4, buck_4_voltages, 0x15, 0x07, 0x14, 0x01, | |
| 384 | − 20000, 0x10), | |
| 385 | − HI6421_BUCK345(BUCK5, buck_5_voltages, 0x17, 0x07, 0x16, 0x01, | |
| 386 | − 20000, 0x10), | |
| 350 | + HI6421_LDO_LINEAR_RANGE(LDOAUDIO, hi6421_vout_audio, 8, | |
| 351 | + ldo_audio_volt_range, 0x36, 0x70, 0x36, 0x01, | |
| 352 | + 40000, 0x02, 5000), | |
| 353 | + HI6421_BUCK012(BUCK0, hi6421_buck0, 0x0d, 0x7f, 0x0c, 0x01, 0x10, 400, | |
| 354 | + 20000), | |
| 355 | + HI6421_BUCK012(BUCK1, hi6421_buck1, 0x0f, 0x7f, 0x0e, 0x01, 0x10, 400, | |
| 356 | + 20000), | |
| 357 | + HI6421_BUCK012(BUCK2, hi6421_buck2, 0x11, 0x7f, 0x10, 0x01, 0x10, 350, | |
| 358 | + 100), | |
| 359 | + HI6421_BUCK345(BUCK3, hi6421_buck3, buck_3_voltages, 0x13, 0x07, 0x12, | |
| 360 | + 0x01, 20000, 0x10), | |
| 361 | + HI6421_BUCK345(BUCK4, hi6421_buck4, buck_4_voltages, 0x15, 0x07, 0x14, | |
| 362 | + 0x01, 20000, 0x10), | |
| 363 | + HI6421_BUCK345(BUCK5, hi6421_buck5, buck_5_voltages, 0x17, 0x07, 0x16, | |
| 364 | + 0x01, 20000, 0x10), | |
| 387 | 365 | }; |
| 388 | 366 | |
| 389 | 367 | static int hi6421_regulator_enable(struct regulator_dev *rdev) |
| @@ -552,42 +530,14 @@ static const struct regulator_ops hi6421_buck345_ops = { · 162 unmodified lines | ||
| 552 | 530 | .set_mode = hi6421_regulator_buck_set_mode, |
| 553 | 531 | }; |
| 554 | 532 | |
| 555 | −static int hi6421_regulator_register(struct platform_device *pdev, | |
| 556 | − struct regmap *rmap, | |
| 557 | − struct regulator_init_data *init_data, | |
| 558 | − int id, struct device_node *np) | |
| 559 | −{ | |
| 560 | − struct hi6421_regulator_info *info = NULL; | |
| 561 | − struct regulator_config config = { }; | |
| 562 | − struct regulator_dev *rdev; | |
| 563 | − | |
| 564 | − /* assign per-regulator data */ | |
| 565 | − info = &hi6421_regulator_info[id]; | |
| 566 | − | |
| 567 | − config.dev = &pdev->dev; | |
| 568 | − config.init_data = init_data; | |
| 569 | − config.driver_data = info; | |
| 570 | − config.regmap = rmap; | |
| 571 | − config.of_node = np; | |
| 572 | − | |
| 573 | − /* register regulator with framework */ | |
| 574 | − rdev = devm_regulator_register(&pdev->dev, &info->desc, &config); | |
| 575 | − if (IS_ERR(rdev)) { | |
| 576 | − dev_err(&pdev->dev, "failed to register regulator %s\n", | |
| 577 | − info->desc.name); | |
| 578 | − return PTR_ERR(rdev); | |
| 579 | − } | |
| 580 | − | |
| 581 | − return 0; | |
| 582 | −} | |
| 583 | − | |
| 584 | 533 | static int hi6421_regulator_probe(struct platform_device *pdev) |
| 585 | 534 | { |
| 586 | − struct device *dev = &pdev->dev; | |
| 587 | − struct device_node *np; | |
| 588 | − struct hi6421_pmic *pmic; | |
| 535 | + struct hi6421_pmic *pmic = dev_get_drvdata(pdev->dev.parent); | |
| 589 | 536 | struct hi6421_regulator_pdata *pdata; |
| 590 | − int i, ret = 0; | |
| 537 | + struct hi6421_regulator_info *info; | |
| 538 | + struct regulator_config config = { }; | |
| 539 | + struct regulator_dev *rdev; | |
| 540 | + int i; | |
| 591 | 541 | |
| 592 | 542 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
| 593 | 543 | if (!pdata) |
| @@ -595,27 +545,21 @@ static int hi6421_regulator_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 595 | 545 | mutex_init(&pdata->lock); |
| 596 | 546 | platform_set_drvdata(pdev, pdata); |
| 597 | 547 | |
| 598 | − np = of_get_child_by_name(dev->parent->of_node, "regulators"); | |
| 599 | − if (!np) | |
| 600 | − return -ENODEV; | |
| 601 | − | |
| 602 | − ret = of_regulator_match(dev, np, | |
| 603 | − hi6421_regulator_match, | |
| 604 | − ARRAY_SIZE(hi6421_regulator_match)); | |
| 605 | − of_node_put(np); | |
| 606 | − if (ret < 0) { | |
| 607 | − dev_err(dev, "Error parsing regulator init data: %d\n", ret); | |
| 608 | − return ret; | |
| 609 | − } | |
| 610 | − | |
| 611 | − pmic = dev_get_drvdata(dev->parent); | |
| 612 | − | |
| 613 | 548 | for (i = 0; i < ARRAY_SIZE(hi6421_regulator_info); i++) { |
| 614 | − ret = hi6421_regulator_register(pdev, pmic->regmap, | |
| 615 | − hi6421_regulator_match[i].init_data, i, | |
| 616 | − hi6421_regulator_match[i].of_node); | |
| 617 | − if (ret) | |
| 618 | − return ret; | |
| 549 | + /* assign per-regulator data */ | |
| 550 | + info = &hi6421_regulator_info[i]; | |
| 551 | + | |
| 552 | + config.dev = pdev->dev.parent; | |
| 553 | + config.driver_data = info; | |
| 554 | + config.regmap = pmic->regmap; | |
| 555 | + | |
| 556 | + rdev = devm_regulator_register(&pdev->dev, &info->desc, | |
| 557 | + &config); | |
| 558 | + if (IS_ERR(rdev)) { | |
| 559 | + dev_err(&pdev->dev, "failed to register regulator %s\n", | |
| 560 | + info->desc.name); | |
| 561 | + return PTR_ERR(rdev); | |
| 562 | + } | |
| 619 | 563 | } |
| 620 | 564 | |
| 621 | 565 | return 0; |
| @@ -1,18 +1,14 @@ | ||
| 1 | −/* | |
| 2 | − * Device driver for regulators in Hi6421V530 IC | |
| 3 | − * | |
| 4 | − * Copyright (c) <2017> HiSilicon Technologies Co., Ltd. | |
| 5 | − * http://www.hisilicon.com | |
| 6 | − * Copyright (c) <2017> Linaro Ltd. | |
| 7 | − * http://www.linaro.org | |
| 8 | − * | |
| 9 | − * Author: Wang Xiaoyin <hw.wangxiaoyin@hisilicon.com> | |
| 10 | − * Guodong Xu <guodong.xu@linaro.org> | |
| 11 | − * | |
| 12 | − * This program is free software; you can redistribute it and/or modify | |
| 13 | − * it under the terms of the GNU General Public License version 2 as | |
| 14 | − * published by the Free Software Foundation. | |
| 15 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Device driver for regulators in Hi6421V530 IC | |
| 4 | +// | |
| 5 | +// Copyright (c) <2017> HiSilicon Technologies Co., Ltd. | |
| 6 | +// http://www.hisilicon.com | |
| 7 | +// Copyright (c) <2017> Linaro Ltd. | |
| 8 | +// http://www.linaro.org | |
| 9 | +// | |
| 10 | +// Author: Wang Xiaoyin <hw.wangxiaoyin@hisilicon.com> | |
| 11 | +// Guodong Xu <guodong.xu@linaro.org> | |
| 16 | 12 | |
| 17 | 13 | #include <linux/mfd/hi6421-pmic.h> |
| 18 | 14 | #include <linux/module.h> |
| @@ -1,16 +1,12 @@ | ||
| 1 | −/* | |
| 2 | − * Device driver for regulators in Hi655x IC | |
| 3 | − * | |
| 4 | − * Copyright (c) 2016 Hisilicon. | |
| 5 | − * | |
| 6 | − * Authors: | |
| 7 | − * Chen Feng <puck.chen@hisilicon.com> | |
| 8 | − * Fei Wang <w.f@huawei.com> | |
| 9 | − * | |
| 10 | − * This program is free software; you can redistribute it and/or modify | |
| 11 | − * it under the terms of the GNU General Public License version 2 as | |
| 12 | − * published by the Free Software Foundation. | |
| 13 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Device driver for regulators in Hi655x IC | |
| 4 | +// | |
| 5 | +// Copyright (c) 2016 Hisilicon. | |
| 6 | +// | |
| 7 | +// Authors: | |
| 8 | +// Chen Feng <puck.chen@hisilicon.com> | |
| 9 | +// Fei Wang <w.f@huawei.com> | |
| 14 | 10 | |
| 15 | 11 | #include <linux/bitops.h> |
| 16 | 12 | #include <linux/device.h> |
| @@ -28,7 +24,6 @@ · 11 unmodified lines | ||
| 28 | 24 | struct hi655x_regulator { |
| 29 | 25 | unsigned int disable_reg; |
| 30 | 26 | unsigned int status_reg; |
| 31 | − unsigned int ctrl_mask; | |
| 32 | 27 | struct regulator_desc rdesc; |
| 33 | 28 | }; |
| 34 | 29 | |
| @@ -77,22 +72,18 @@ enum hi655x_regulator_id { · 42 unmodified lines | ||
| 77 | 72 | static int hi655x_is_enabled(struct regulator_dev *rdev) |
| 78 | 73 | { |
| 79 | 74 | unsigned int value = 0; |
| 80 | − | |
| 81 | 75 | struct hi655x_regulator *regulator = rdev_get_drvdata(rdev); |
| 82 | 76 | |
| 83 | 77 | regmap_read(rdev->regmap, regulator->status_reg, &value); |
| 84 | − return (value & BIT(regulator->ctrl_mask)); | |
| 78 | + return (value & rdev->desc->enable_mask); | |
| 85 | 79 | } |
| 86 | 80 | |
| 87 | 81 | static int hi655x_disable(struct regulator_dev *rdev) |
| 88 | 82 | { |
| 89 | − int ret = 0; | |
| 90 | − | |
| 91 | 83 | struct hi655x_regulator *regulator = rdev_get_drvdata(rdev); |
| 92 | 84 | |
| 93 | − ret = regmap_write(rdev->regmap, regulator->disable_reg, | |
| 94 | − BIT(regulator->ctrl_mask)); | |
| 95 | − return ret; | |
| 85 | + return regmap_write(rdev->regmap, regulator->disable_reg, | |
| 86 | + rdev->desc->enable_mask); | |
| 96 | 87 | } |
| 97 | 88 | |
| 98 | 89 | static const struct regulator_ops hi655x_regulator_ops = { |
| @@ -132,7 +123,6 @@ static const struct regulator_ops hi655x_ldo_linear_ops = { · 33 unmodified lines | ||
| 132 | 123 | }, \ |
| 133 | 124 | .disable_reg = HI655X_BUS_ADDR(dreg), \ |
| 134 | 125 | .status_reg = HI655X_BUS_ADDR(sreg), \ |
| 135 | − .ctrl_mask = cmask, \ | |
| 136 | 126 | } |
| 137 | 127 | |
| 138 | 128 | #define HI655X_LDO_LINEAR(_ID, vreg, vmask, ereg, dreg, \ |
| @@ -155,10 +145,9 @@ static const struct regulator_ops hi655x_ldo_linear_ops = { · 16 unmodified lines | ||
| 155 | 145 | }, \ |
| 156 | 146 | .disable_reg = HI655X_BUS_ADDR(dreg), \ |
| 157 | 147 | .status_reg = HI655X_BUS_ADDR(sreg), \ |
| 158 | − .ctrl_mask = cmask, \ | |
| 159 | 148 | } |
| 160 | 149 | |
| 161 | −static struct hi655x_regulator regulators[] = { | |
| 150 | +static const struct hi655x_regulator regulators[] = { | |
| 162 | 151 | HI655X_LDO_LINEAR(LDO2, 0x72, 0x07, 0x29, 0x2a, 0x2b, 0x01, |
| 163 | 152 | 2500000, 8, 100000), |
| 164 | 153 | HI655X_LDO(LDO7, 0x78, 0x07, 0x29, 0x2a, 0x2b, 0x06, ldo7_voltages), |
| @@ -48,7 +48,7 @@ static const int ldo_cont_enable_time[] = { · 47 unmodified lines | ||
| 48 | 48 | static int lm363x_regulator_enable_time(struct regulator_dev *rdev) |
| 49 | 49 | { |
| 50 | 50 | enum lm363x_regulator_id id = rdev_get_id(rdev); |
| 51 | − u8 val, addr, mask; | |
| 51 | + unsigned int val, addr, mask; | |
| 52 | 52 | |
| 53 | 53 | switch (id) { |
| 54 | 54 | case LM3631_LDO_CONT: |
| @@ -71,7 +71,7 @@ static int lm363x_regulator_enable_time(struct regulator_dev *rdev) · 16 unmodified lines | ||
| 71 | 71 | return 0; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | − if (regmap_read(rdev->regmap, addr, (unsigned int *)&val)) | |
| 74 | + if (regmap_read(rdev->regmap, addr, &val)) | |
| 75 | 75 | return -EINVAL; |
| 76 | 76 | |
| 77 | 77 | val = (val & mask) >> LM3631_ENTIME_SHIFT; |
| @@ -82,13 +82,13 @@ static int lm363x_regulator_enable_time(struct regulator_dev *rdev) · 4 unmodified lines | ||
| 82 | 82 | return ENABLE_TIME_USEC * val; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | −static struct regulator_ops lm363x_boost_voltage_table_ops = { | |
| 85 | +static const struct regulator_ops lm363x_boost_voltage_table_ops = { | |
| 86 | 86 | .list_voltage = regulator_list_voltage_linear, |
| 87 | 87 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 88 | 88 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 89 | 89 | }; |
| 90 | 90 | |
| 91 | −static struct regulator_ops lm363x_regulator_voltage_table_ops = { | |
| 91 | +static const struct regulator_ops lm363x_regulator_voltage_table_ops = { | |
| 92 | 92 | .list_voltage = regulator_list_voltage_linear, |
| 93 | 93 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 94 | 94 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| @@ -372,10 +372,13 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data) · 371 unmodified lines | ||
| 372 | 372 | for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) |
| 373 | 373 | if ((flag0 & (0x4 << icnt)) |
| 374 | 374 | && (pchip->irqmask & (0x04 << icnt)) |
| 375 | − && (pchip->rdev[icnt] != NULL)) | |
| 375 | + && (pchip->rdev[icnt] != NULL)) { | |
| 376 | + regulator_lock(pchip->rdev[icnt]); | |
| 376 | 377 | regulator_notifier_call_chain(pchip->rdev[icnt], |
| 377 | 378 | LP8755_EVENT_PWR_FAULT, |
| 378 | 379 | NULL); |
| 380 | + regulator_unlock(pchip->rdev[icnt]); | |
| 381 | + } | |
| 379 | 382 | |
| 380 | 383 | /* read flag1 register */ |
| 381 | 384 | ret = lp8755_read(pchip, 0x0E, &flag1); |
| @@ -389,18 +392,24 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data) · 7 unmodified lines | ||
| 389 | 392 | /* send OCP event to all regulator devices */ |
| 390 | 393 | if ((flag1 & 0x01) && (pchip->irqmask & 0x01)) |
| 391 | 394 | for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) |
| 392 | − if (pchip->rdev[icnt] != NULL) | |
| 395 | + if (pchip->rdev[icnt] != NULL) { | |
| 396 | + regulator_lock(pchip->rdev[icnt]); | |
| 393 | 397 | regulator_notifier_call_chain(pchip->rdev[icnt], |
| 394 | 398 | LP8755_EVENT_OCP, |
| 395 | 399 | NULL); |
| 400 | + regulator_unlock(pchip->rdev[icnt]); | |
| 401 | + } | |
| 396 | 402 | |
| 397 | 403 | /* send OVP event to all regulator devices */ |
| 398 | 404 | if ((flag1 & 0x02) && (pchip->irqmask & 0x02)) |
| 399 | 405 | for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) |
| 400 | − if (pchip->rdev[icnt] != NULL) | |
| 406 | + if (pchip->rdev[icnt] != NULL) { | |
| 407 | + regulator_lock(pchip->rdev[icnt]); | |
| 401 | 408 | regulator_notifier_call_chain(pchip->rdev[icnt], |
| 402 | 409 | LP8755_EVENT_OVP, |
| 403 | 410 | NULL); |
| 411 | + regulator_unlock(pchip->rdev[icnt]); | |
| 412 | + } | |
| 404 | 413 | return IRQ_HANDLED; |
| 405 | 414 | |
| 406 | 415 | err_i2c: |
| @@ -34,6 +34,10 @@ · 33 unmodified lines | ||
| 34 | 34 | .ramp_delay = _delay, \ |
| 35 | 35 | .linear_ranges = _lr, \ |
| 36 | 36 | .n_linear_ranges = ARRAY_SIZE(_lr), \ |
| 37 | + .curr_table = lp87565_buck_uA, \ | |
| 38 | + .n_current_limits = ARRAY_SIZE(lp87565_buck_uA),\ | |
| 39 | + .csel_reg = (_cr), \ | |
| 40 | + .csel_mask = LP87565_BUCK_CTRL_2_ILIM, \ | |
| 37 | 41 | }, \ |
| 38 | 42 | .ctrl2_reg = _cr, \ |
| 39 | 43 | } |
| @@ -102,44 +106,7 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev *rdev, · 62 unmodified lines | ||
| 102 | 106 | return 0; |
| 103 | 107 | } |
| 104 | 108 | |
| 105 | −static int lp87565_buck_set_current_limit(struct regulator_dev *rdev, | |
| 106 | − int min_uA, int max_uA) | |
| 107 | −{ | |
| 108 | − int id = rdev_get_id(rdev); | |
| 109 | − struct lp87565 *lp87565 = rdev_get_drvdata(rdev); | |
| 110 | − int i; | |
| 111 | − | |
| 112 | − for (i = ARRAY_SIZE(lp87565_buck_uA) - 1; i >= 0; i--) { | |
| 113 | − if (lp87565_buck_uA[i] >= min_uA && | |
| 114 | − lp87565_buck_uA[i] <= max_uA) | |
| 115 | − return regmap_update_bits(lp87565->regmap, | |
| 116 | − regulators[id].ctrl2_reg, | |
| 117 | − LP87565_BUCK_CTRL_2_ILIM, | |
| 118 | − i << __ffs(LP87565_BUCK_CTRL_2_ILIM)); | |
| 119 | − } | |
| 120 | − | |
| 121 | − return -EINVAL; | |
| 122 | −} | |
| 123 | − | |
| 124 | −static int lp87565_buck_get_current_limit(struct regulator_dev *rdev) | |
| 125 | −{ | |
| 126 | − int id = rdev_get_id(rdev); | |
| 127 | − struct lp87565 *lp87565 = rdev_get_drvdata(rdev); | |
| 128 | − int ret; | |
| 129 | − unsigned int val; | |
| 130 | − | |
| 131 | − ret = regmap_read(lp87565->regmap, regulators[id].ctrl2_reg, &val); | |
| 132 | − if (ret) | |
| 133 | − return ret; | |
| 134 | − | |
| 135 | − val = (val & LP87565_BUCK_CTRL_2_ILIM) >> | |
| 136 | − __ffs(LP87565_BUCK_CTRL_2_ILIM); | |
| 137 | − | |
| 138 | − return (val < ARRAY_SIZE(lp87565_buck_uA)) ? | |
| 139 | − lp87565_buck_uA[val] : -EINVAL; | |
| 140 | −} | |
| 141 | − | |
| 142 | −/* Operations permitted on BUCK0, BUCK1 */ | |
| 109 | +/* Operations permitted on BUCKs */ | |
| 143 | 110 | static const struct regulator_ops lp87565_buck_ops = { |
| 144 | 111 | .is_enabled = regulator_is_enabled_regmap, |
| 145 | 112 | .enable = regulator_enable_regmap, |
| @@ -150,8 +117,8 @@ static const struct regulator_ops lp87565_buck_ops = { · 4 unmodified lines | ||
| 150 | 117 | .map_voltage = regulator_map_voltage_linear_range, |
| 151 | 118 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
| 152 | 119 | .set_ramp_delay = lp87565_buck_set_ramp_delay, |
| 153 | − .set_current_limit = lp87565_buck_set_current_limit, | |
| 154 | − .get_current_limit = lp87565_buck_get_current_limit, | |
| 120 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 121 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 155 | 122 | }; |
| 156 | 123 | |
| 157 | 124 | static const struct lp87565_regulator regulators[] = { |
| @@ -193,7 +160,7 @@ static int lp87565_regulator_probe(struct platform_device *pdev) · 35 unmodified lines | ||
| 193 | 160 | struct lp87565 *lp87565 = dev_get_drvdata(pdev->dev.parent); |
| 194 | 161 | struct regulator_config config = { }; |
| 195 | 162 | struct regulator_dev *rdev; |
| 196 | − int i, min_idx = LP87565_BUCK_1, max_idx = LP87565_BUCK_3; | |
| 163 | + int i, min_idx = LP87565_BUCK_0, max_idx = LP87565_BUCK_3; | |
| 197 | 164 | |
| 198 | 165 | platform_set_drvdata(pdev, lp87565); |
| 199 | 166 | |
| @@ -1,21 +1,9 @@ | ||
| 1 | −/* | |
| 2 | − * Linear Technology LTC3589,LTC3589-1 regulator support | |
| 3 | − * | |
| 4 | − * Copyright (c) 2014 Philipp Zabel <p.zabel@pengutronix.de>, Pengutronix | |
| 5 | − * | |
| 6 | − * See file CREDITS for list of people who contributed to this | |
| 7 | − * project. | |
| 8 | − * | |
| 9 | − * This program is free software; you can redistribute it and/or modify | |
| 10 | − * it under the terms of the GNU General Public License version 2 | |
| 11 | − * as published by the Free Software Foundation. | |
| 12 | − * | |
| 13 | − * This program is distributed in the hope that it will be useful, | |
| 14 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | − * GNU General Public License for more details. | |
| 17 | − * | |
| 18 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Linear Technology LTC3589,LTC3589-1 regulator support | |
| 4 | +// | |
| 5 | +// Copyright (c) 2014 Philipp Zabel <p.zabel@pengutronix.de>, Pengutronix | |
| 6 | + | |
| 19 | 7 | #include <linux/i2c.h> |
| 20 | 8 | #include <linux/init.h> |
| 21 | 9 | #include <linux/interrupt.h> |
| @@ -84,19 +72,11 @@ enum ltc3589_reg { · 62 unmodified lines | ||
| 84 | 72 | LTC3589_NUM_REGULATORS, |
| 85 | 73 | }; |
| 86 | 74 | |
| 87 | −struct ltc3589_regulator { | |
| 88 | − struct regulator_desc desc; | |
| 89 | − | |
| 90 | − /* External feedback voltage divider */ | |
| 91 | − unsigned int r1; | |
| 92 | − unsigned int r2; | |
| 93 | −}; | |
| 94 | − | |
| 95 | 75 | struct ltc3589 { |
| 96 | 76 | struct regmap *regmap; |
| 97 | 77 | struct device *dev; |
| 98 | 78 | enum ltc3589_variant variant; |
| 99 | − struct ltc3589_regulator regulator_descs[LTC3589_NUM_REGULATORS]; | |
| 79 | + struct regulator_desc regulator_descs[LTC3589_NUM_REGULATORS]; | |
| 100 | 80 | struct regulator_dev *regulators[LTC3589_NUM_REGULATORS]; |
| 101 | 81 | }; |
| 102 | 82 | |
| @@ -196,131 +176,90 @@ static const struct regulator_ops ltc3589_table_regulator_ops = { · 93 unmodified lines | ||
| 196 | 176 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 197 | 177 | }; |
| 198 | 178 | |
| 179 | +static inline unsigned int ltc3589_scale(unsigned int uV, u32 r1, u32 r2) | |
| 180 | +{ | |
| 181 | + uint64_t tmp; | |
| 199 | 182 | |
| 200 | −#define LTC3589_REG(_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit) \ | |
| 201 | − [LTC3589_ ## _name] = { \ | |
| 202 | − .desc = { \ | |
| 203 | − .name = #_name, \ | |
| 204 | − .n_voltages = (dtv_mask) + 1, \ | |
| 205 | − .min_uV = (go_bit) ? 362500 : 0, \ | |
| 206 | − .uV_step = (go_bit) ? 12500 : 0, \ | |
| 207 | − .ramp_delay = (go_bit) ? 1750 : 0, \ | |
| 208 | − .fixed_uV = (dtv_mask) ? 0 : 800000, \ | |
| 209 | − .ops = <c3589_ ## _ops ## _regulator_ops, \ | |
| 210 | − .type = REGULATOR_VOLTAGE, \ | |
| 211 | − .id = LTC3589_ ## _name, \ | |
| 212 | − .owner = THIS_MODULE, \ | |
| 213 | − .vsel_reg = (dtv1_reg), \ | |
| 214 | − .vsel_mask = (dtv_mask), \ | |
| 215 | − .apply_reg = (go_bit) ? LTC3589_VCCR : 0, \ | |
| 216 | − .apply_bit = (go_bit), \ | |
| 217 | − .enable_reg = (en_bit) ? LTC3589_OVEN : 0, \ | |
| 218 | − .enable_mask = (en_bit), \ | |
| 219 | − }, \ | |
| 220 | − } | |
| 221 | − | |
| 222 | −#define LTC3589_LINEAR_REG(_name, _dtv1) \ | |
| 223 | − LTC3589_REG(_name, linear, LTC3589_OVEN_ ## _name, \ | |
| 224 | − LTC3589_ ## _dtv1, 0x1f, \ | |
| 225 | − LTC3589_VCCR_ ## _name ## _GO) | |
| 226 | − | |
| 227 | −#define LTC3589_FIXED_REG(_name) \ | |
| 228 | − LTC3589_REG(_name, fixed, LTC3589_OVEN_ ## _name, 0, 0, 0) | |
| 229 | − | |
| 230 | −static struct ltc3589_regulator ltc3589_regulators[LTC3589_NUM_REGULATORS] = { | |
| 231 | − LTC3589_LINEAR_REG(SW1, B1DTV1), | |
| 232 | − LTC3589_LINEAR_REG(SW2, B2DTV1), | |
| 233 | − LTC3589_LINEAR_REG(SW3, B3DTV1), | |
| 234 | − LTC3589_FIXED_REG(BB_OUT), | |
| 235 | − LTC3589_REG(LDO1, fixed_standby, 0, 0, 0, 0), | |
| 236 | − LTC3589_LINEAR_REG(LDO2, L2DTV1), | |
| 237 | − LTC3589_FIXED_REG(LDO3), | |
| 238 | − LTC3589_REG(LDO4, table, LTC3589_OVEN_LDO4, LTC3589_L2DTV2, 0x60, 0), | |
| 239 | −}; | |
| 183 | + if (uV == 0) | |
| 184 | + return 0; | |
| 240 | 185 | |
| 241 | −#ifdef CONFIG_OF | |
| 242 | −static struct of_regulator_match ltc3589_matches[LTC3589_NUM_REGULATORS] = { | |
| 243 | − { .name = "sw1", }, | |
| 244 | − { .name = "sw2", }, | |
| 245 | − { .name = "sw3", }, | |
| 246 | − { .name = "bb-out", }, | |
| 247 | − { .name = "ldo1", }, /* standby */ | |
| 248 | − { .name = "ldo2", }, | |
| 249 | − { .name = "ldo3", }, | |
| 250 | − { .name = "ldo4", }, | |
| 251 | −}; | |
| 186 | + tmp = (uint64_t)uV * r1; | |
| 187 | + do_div(tmp, r2); | |
| 188 | + return uV + (unsigned int)tmp; | |
| 189 | +} | |
| 252 | 190 | |
| 253 | −static int ltc3589_parse_regulators_dt(struct ltc3589 *ltc3589) | |
| 191 | +static int ltc3589_of_parse_cb(struct device_node *np, | |
| 192 | + const struct regulator_desc *desc, | |
| 193 | + struct regulator_config *config) | |
| 254 | 194 | { |
| 255 | − struct device *dev = ltc3589->dev; | |
| 256 | − struct device_node *node; | |
| 257 | − int i, ret; | |
| 195 | + struct ltc3589 *ltc3589 = config->driver_data; | |
| 196 | + struct regulator_desc *rdesc = <c3589->regulator_descs[desc->id]; | |
| 197 | + u32 r[2]; | |
| 198 | + int ret; | |
| 258 | 199 | |
| 259 | − node = of_get_child_by_name(dev->of_node, "regulators"); | |
| 260 | − if (!node) { | |
| 261 | − dev_err(dev, "regulators node not found\n"); | |
| 262 | − return -EINVAL; | |
| 263 | − } | |
| 200 | + /* Parse feedback voltage dividers. LDO3 and LDO4 don't have them */ | |
| 201 | + if (desc->id >= LTC3589_LDO3) | |
| 202 | + return 0; | |
| 264 | 203 | |
| 265 | − ret = of_regulator_match(dev, node, ltc3589_matches, | |
| 266 | − ARRAY_SIZE(ltc3589_matches)); | |
| 267 | − of_node_put(node); | |
| 268 | − if (ret < 0) { | |
| 269 | − dev_err(dev, "Error parsing regulator init data: %d\n", ret); | |
| 270 | − return ret; | |
| 271 | − } | |
| 272 | − if (ret != LTC3589_NUM_REGULATORS) { | |
| 273 | − dev_err(dev, "Only %d regulators described in device tree\n", | |
| 204 | + ret = of_property_read_u32_array(np, "lltc,fb-voltage-divider", r, 2); | |
| 205 | + if (ret) { | |
| 206 | + dev_err(ltc3589->dev, "Failed to parse voltage divider: %d\n", | |
| 274 | 207 | ret); |
| 275 | − return -EINVAL; | |
| 208 | + return ret; | |
| 276 | 209 | } |
| 277 | 210 | |
| 278 | − /* Parse feedback voltage dividers. LDO3 and LDO4 don't have them */ | |
| 279 | − for (i = 0; i < LTC3589_LDO3; i++) { | |
| 280 | − struct ltc3589_regulator *desc = <c3589->regulator_descs[i]; | |
| 281 | − struct device_node *np = ltc3589_matches[i].of_node; | |
| 282 | − u32 vdiv[2]; | |
| 283 | − | |
| 284 | − ret = of_property_read_u32_array(np, "lltc,fb-voltage-divider", | |
| 285 | − vdiv, 2); | |
| 286 | − if (ret) { | |
| 287 | − dev_err(dev, "Failed to parse voltage divider: %d\n", | |
| 288 | − ret); | |
| 289 | − return ret; | |
| 290 | − } | |
| 211 | + if (!r[0] || !r[1]) | |
| 212 | + return 0; | |
| 291 | 213 | |
| 292 | − desc->r1 = vdiv[0]; | |
| 293 | − desc->r2 = vdiv[1]; | |
| 294 | − } | |
| 214 | + rdesc->min_uV = ltc3589_scale(desc->min_uV, r[0], r[1]); | |
| 215 | + rdesc->uV_step = ltc3589_scale(desc->uV_step, r[0], r[1]); | |
| 216 | + rdesc->fixed_uV = ltc3589_scale(desc->fixed_uV, r[0], r[1]); | |
| 295 | 217 | |
| 296 | 218 | return 0; |
| 297 | 219 | } |
| 298 | 220 | |
| 299 | −static inline struct regulator_init_data *match_init_data(int index) | |
| 300 | −{ | |
| 301 | − return ltc3589_matches[index].init_data; | |
| 302 | −} | |
| 303 | − | |
| 304 | −static inline struct device_node *match_of_node(int index) | |
| 305 | −{ | |
| 306 | − return ltc3589_matches[index].of_node; | |
| 307 | −} | |
| 308 | −#else | |
| 309 | −static inline int ltc3589_parse_regulators_dt(struct ltc3589 *ltc3589) | |
| 310 | −{ | |
| 311 | − return 0; | |
| 312 | −} | |
| 221 | +#define LTC3589_REG(_name, _of_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit)\ | |
| 222 | + [LTC3589_ ## _name] = { \ | |
| 223 | + .name = #_name, \ | |
| 224 | + .of_match = of_match_ptr(#_of_name), \ | |
| 225 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 226 | + .of_parse_cb = ltc3589_of_parse_cb, \ | |
| 227 | + .n_voltages = (dtv_mask) + 1, \ | |
| 228 | + .min_uV = (go_bit) ? 362500 : 0, \ | |
| 229 | + .uV_step = (go_bit) ? 12500 : 0, \ | |
| 230 | + .ramp_delay = (go_bit) ? 1750 : 0, \ | |
| 231 | + .fixed_uV = (dtv_mask) ? 0 : 800000, \ | |
| 232 | + .ops = <c3589_ ## _ops ## _regulator_ops, \ | |
| 233 | + .type = REGULATOR_VOLTAGE, \ | |
| 234 | + .id = LTC3589_ ## _name, \ | |
| 235 | + .owner = THIS_MODULE, \ | |
| 236 | + .vsel_reg = (dtv1_reg), \ | |
| 237 | + .vsel_mask = (dtv_mask), \ | |
| 238 | + .apply_reg = (go_bit) ? LTC3589_VCCR : 0, \ | |
| 239 | + .apply_bit = (go_bit), \ | |
| 240 | + .enable_reg = (en_bit) ? LTC3589_OVEN : 0, \ | |
| 241 | + .enable_mask = (en_bit), \ | |
| 242 | + } | |
| 313 | 243 | |
| 314 | −static inline struct regulator_init_data *match_init_data(int index) | |
| 315 | −{ | |
| 316 | − return NULL; | |
| 317 | −} | |
| 244 | +#define LTC3589_LINEAR_REG(_name, _of_name, _dtv1) \ | |
| 245 | + LTC3589_REG(_name, _of_name, linear, LTC3589_OVEN_ ## _name, \ | |
| 246 | + LTC3589_ ## _dtv1, 0x1f, \ | |
| 247 | + LTC3589_VCCR_ ## _name ## _GO) | |
| 318 | 248 | |
| 319 | −static inline struct device_node *match_of_node(int index) | |
| 320 | −{ | |
| 321 | − return NULL; | |
| 322 | −} | |
| 323 | −#endif | |
| 249 | +#define LTC3589_FIXED_REG(_name, _of_name) \ | |
| 250 | + LTC3589_REG(_name, _of_name, fixed, LTC3589_OVEN_ ## _name, 0, 0, 0) | |
| 251 | + | |
| 252 | +static const struct regulator_desc ltc3589_regulators[] = { | |
| 253 | + LTC3589_LINEAR_REG(SW1, sw1, B1DTV1), | |
| 254 | + LTC3589_LINEAR_REG(SW2, sw2, B2DTV1), | |
| 255 | + LTC3589_LINEAR_REG(SW3, sw3, B3DTV1), | |
| 256 | + LTC3589_FIXED_REG(BB_OUT, bb-out), | |
| 257 | + LTC3589_REG(LDO1, ldo1, fixed_standby, 0, 0, 0, 0), | |
| 258 | + LTC3589_LINEAR_REG(LDO2, ldo2, L2DTV1), | |
| 259 | + LTC3589_FIXED_REG(LDO3, ldo3), | |
| 260 | + LTC3589_REG(LDO4, ldo4, table, LTC3589_OVEN_LDO4, LTC3589_L2DTV2, | |
| 261 | + 0x60, 0), | |
| 262 | +}; | |
| 324 | 263 | |
| 325 | 264 | static bool ltc3589_writeable_reg(struct device *dev, unsigned int reg) |
| 326 | 265 | { |
| @@ -409,7 +348,6 @@ static const struct regmap_config ltc3589_regmap_config = { · 82 unmodified lines | ||
| 409 | 348 | .cache_type = REGCACHE_RBTREE, |
| 410 | 349 | }; |
| 411 | 350 | |
| 412 | − | |
| 413 | 351 | static irqreturn_t ltc3589_isr(int irq, void *dev_id) |
| 414 | 352 | { |
| 415 | 353 | struct ltc3589 *ltc3589 = dev_id; |
| @@ -419,16 +357,22 @@ static irqreturn_t ltc3589_isr(int irq, void *dev_id) · 3 unmodified lines | ||
| 419 | 357 | |
| 420 | 358 | if (irqstat & LTC3589_IRQSTAT_THERMAL_WARN) { |
| 421 | 359 | event = REGULATOR_EVENT_OVER_TEMP; |
| 422 | − for (i = 0; i < LTC3589_NUM_REGULATORS; i++) | |
| 360 | + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { | |
| 361 | + regulator_lock(ltc3589->regulators[i]); | |
| 423 | 362 | regulator_notifier_call_chain(ltc3589->regulators[i], |
| 424 | 363 | event, NULL); |
| 364 | + regulator_unlock(ltc3589->regulators[i]); | |
| 365 | + } | |
| 425 | 366 | } |
| 426 | 367 | |
| 427 | 368 | if (irqstat & LTC3589_IRQSTAT_UNDERVOLT_WARN) { |
| 428 | 369 | event = REGULATOR_EVENT_UNDER_VOLTAGE; |
| 429 | − for (i = 0; i < LTC3589_NUM_REGULATORS; i++) | |
| 370 | + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { | |
| 371 | + regulator_lock(ltc3589->regulators[i]); | |
| 430 | 372 | regulator_notifier_call_chain(ltc3589->regulators[i], |
| 431 | 373 | event, NULL); |
| 374 | + regulator_unlock(ltc3589->regulators[i]); | |
| 375 | + } | |
| 432 | 376 | } |
| 433 | 377 | |
| 434 | 378 | /* Clear warning condition */ |
| @@ -437,33 +381,11 @@ static irqreturn_t ltc3589_isr(int irq, void *dev_id) · 2 unmodified lines | ||
| 437 | 381 | return IRQ_HANDLED; |
| 438 | 382 | } |
| 439 | 383 | |
| 440 | −static inline unsigned int ltc3589_scale(unsigned int uV, u32 r1, u32 r2) | |
| 441 | −{ | |
| 442 | − uint64_t tmp; | |
| 443 | − if (uV == 0) | |
| 444 | − return 0; | |
| 445 | − tmp = (uint64_t)uV * r1; | |
| 446 | − do_div(tmp, r2); | |
| 447 | − return uV + (unsigned int)tmp; | |
| 448 | −} | |
| 449 | − | |
| 450 | −static void ltc3589_apply_fb_voltage_divider(struct ltc3589_regulator *rdesc) | |
| 451 | −{ | |
| 452 | − struct regulator_desc *desc = &rdesc->desc; | |
| 453 | − | |
| 454 | − if (!rdesc->r1 || !rdesc->r2) | |
| 455 | − return; | |
| 456 | − | |
| 457 | − desc->min_uV = ltc3589_scale(desc->min_uV, rdesc->r1, rdesc->r2); | |
| 458 | − desc->uV_step = ltc3589_scale(desc->uV_step, rdesc->r1, rdesc->r2); | |
| 459 | − desc->fixed_uV = ltc3589_scale(desc->fixed_uV, rdesc->r1, rdesc->r2); | |
| 460 | −} | |
| 461 | − | |
| 462 | 384 | static int ltc3589_probe(struct i2c_client *client, |
| 463 | 385 | const struct i2c_device_id *id) |
| 464 | 386 | { |
| 465 | 387 | struct device *dev = &client->dev; |
| 466 | − struct ltc3589_regulator *descs; | |
| 388 | + struct regulator_desc *descs; | |
| 467 | 389 | struct ltc3589 *ltc3589; |
| 468 | 390 | int i, ret; |
| 469 | 391 | |
| @@ -482,11 +404,11 @@ static int ltc3589_probe(struct i2c_client *client, · 12 unmodified lines | ||
| 482 | 404 | descs = ltc3589->regulator_descs; |
| 483 | 405 | memcpy(descs, ltc3589_regulators, sizeof(ltc3589_regulators)); |
| 484 | 406 | if (ltc3589->variant == LTC3589) { |
| 485 | − descs[LTC3589_LDO3].desc.fixed_uV = 1800000; | |
| 486 | − descs[LTC3589_LDO4].desc.volt_table = ltc3589_ldo4; | |
| 407 | + descs[LTC3589_LDO3].fixed_uV = 1800000; | |
| 408 | + descs[LTC3589_LDO4].volt_table = ltc3589_ldo4; | |
| 487 | 409 | } else { |
| 488 | − descs[LTC3589_LDO3].desc.fixed_uV = 2800000; | |
| 489 | − descs[LTC3589_LDO4].desc.volt_table = ltc3589_12_ldo4; | |
| 410 | + descs[LTC3589_LDO3].fixed_uV = 2800000; | |
| 411 | + descs[LTC3589_LDO4].volt_table = ltc3589_12_ldo4; | |
| 490 | 412 | } |
| 491 | 413 | |
| 492 | 414 | ltc3589->regmap = devm_regmap_init_i2c(client, <c3589_regmap_config); |
| @@ -496,25 +418,12 @@ static int ltc3589_probe(struct i2c_client *client, · 3 unmodified lines | ||
| 496 | 418 | return ret; |
| 497 | 419 | } |
| 498 | 420 | |
| 499 | − ret = ltc3589_parse_regulators_dt(ltc3589); | |
| 500 | − if (ret) | |
| 501 | − return ret; | |
| 502 | − | |
| 503 | 421 | for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { |
| 504 | − struct ltc3589_regulator *rdesc = <c3589->regulator_descs[i]; | |
| 505 | − struct regulator_desc *desc = &rdesc->desc; | |
| 506 | − struct regulator_init_data *init_data; | |
| 422 | + struct regulator_desc *desc = <c3589->regulator_descs[i]; | |
| 507 | 423 | struct regulator_config config = { }; |
| 508 | 424 | |
| 509 | − init_data = match_init_data(i); | |
| 510 | − | |
| 511 | − if (i < LTC3589_LDO3) | |
| 512 | − ltc3589_apply_fb_voltage_divider(rdesc); | |
| 513 | − | |
| 514 | 425 | config.dev = dev; |
| 515 | − config.init_data = init_data; | |
| 516 | 426 | config.driver_data = ltc3589; |
| 517 | − config.of_node = match_of_node(i); | |
| 518 | 427 | |
| 519 | 428 | ltc3589->regulators[i] = devm_regulator_register(dev, desc, |
| 520 | 429 | &config); |
| @@ -285,17 +285,23 @@ static irqreturn_t ltc3676_isr(int irq, void *dev_id) · 284 unmodified lines | ||
| 285 | 285 | if (irqstat & LTC3676_IRQSTAT_THERMAL_WARN) { |
| 286 | 286 | dev_warn(dev, "Over-temperature Warning\n"); |
| 287 | 287 | event = REGULATOR_EVENT_OVER_TEMP; |
| 288 | − for (i = 0; i < LTC3676_NUM_REGULATORS; i++) | |
| 288 | + for (i = 0; i < LTC3676_NUM_REGULATORS; i++) { | |
| 289 | + regulator_lock(ltc3676->regulators[i]); | |
| 289 | 290 | regulator_notifier_call_chain(ltc3676->regulators[i], |
| 290 | 291 | event, NULL); |
| 292 | + regulator_unlock(ltc3676->regulators[i]); | |
| 293 | + } | |
| 291 | 294 | } |
| 292 | 295 | |
| 293 | 296 | if (irqstat & LTC3676_IRQSTAT_UNDERVOLT_WARN) { |
| 294 | 297 | dev_info(dev, "Undervoltage Warning\n"); |
| 295 | 298 | event = REGULATOR_EVENT_UNDER_VOLTAGE; |
| 296 | − for (i = 0; i < LTC3676_NUM_REGULATORS; i++) | |
| 299 | + for (i = 0; i < LTC3676_NUM_REGULATORS; i++) { | |
| 300 | + regulator_lock(ltc3676->regulators[i]); | |
| 297 | 301 | regulator_notifier_call_chain(ltc3676->regulators[i], |
| 298 | 302 | event, NULL); |
| 303 | + regulator_unlock(ltc3676->regulators[i]); | |
| 304 | + } | |
| 299 | 305 | } |
| 300 | 306 | |
| 301 | 307 | /* Clear warning condition */ |
| @@ -155,58 +155,6 @@ static const struct regulator_desc max77836_supported_regulators[] = { · 154 unmodified lines | ||
| 155 | 155 | [MAX77836_LDO2] = MAX77836_LDO_REG(2), |
| 156 | 156 | }; |
| 157 | 157 | |
| 158 | −#ifdef CONFIG_OF | |
| 159 | −static struct of_regulator_match max14577_regulator_matches[] = { | |
| 160 | − { .name = "SAFEOUT", }, | |
| 161 | − { .name = "CHARGER", }, | |
| 162 | −}; | |
| 163 | − | |
| 164 | −static struct of_regulator_match max77836_regulator_matches[] = { | |
| 165 | − { .name = "SAFEOUT", }, | |
| 166 | − { .name = "CHARGER", }, | |
| 167 | − { .name = "LDO1", }, | |
| 168 | − { .name = "LDO2", }, | |
| 169 | −}; | |
| 170 | − | |
| 171 | −static inline struct regulator_init_data *match_init_data(int index, | |
| 172 | − enum maxim_device_type dev_type) | |
| 173 | −{ | |
| 174 | − switch (dev_type) { | |
| 175 | − case MAXIM_DEVICE_TYPE_MAX77836: | |
| 176 | − return max77836_regulator_matches[index].init_data; | |
| 177 | − | |
| 178 | − case MAXIM_DEVICE_TYPE_MAX14577: | |
| 179 | − default: | |
| 180 | − return max14577_regulator_matches[index].init_data; | |
| 181 | − } | |
| 182 | −} | |
| 183 | − | |
| 184 | −static inline struct device_node *match_of_node(int index, | |
| 185 | − enum maxim_device_type dev_type) | |
| 186 | −{ | |
| 187 | − switch (dev_type) { | |
| 188 | − case MAXIM_DEVICE_TYPE_MAX77836: | |
| 189 | − return max77836_regulator_matches[index].of_node; | |
| 190 | − | |
| 191 | − case MAXIM_DEVICE_TYPE_MAX14577: | |
| 192 | − default: | |
| 193 | − return max14577_regulator_matches[index].of_node; | |
| 194 | − } | |
| 195 | −} | |
| 196 | −#else /* CONFIG_OF */ | |
| 197 | −static inline struct regulator_init_data *match_init_data(int index, | |
| 198 | − enum maxim_device_type dev_type) | |
| 199 | −{ | |
| 200 | − return NULL; | |
| 201 | −} | |
| 202 | − | |
| 203 | −static inline struct device_node *match_of_node(int index, | |
| 204 | − enum maxim_device_type dev_type) | |
| 205 | −{ | |
| 206 | − return NULL; | |
| 207 | −} | |
| 208 | −#endif /* CONFIG_OF */ | |
| 209 | − | |
| 210 | 158 | /** |
| 211 | 159 | * Registers for regulators of max77836 use different I2C slave addresses so |
| 212 | 160 | * different regmaps must be used for them. |
| @@ -265,9 +213,6 @@ static int max14577_regulator_probe(struct platform_device *pdev) · 52 unmodified lines | ||
| 265 | 213 | if (pdata && pdata->regulators) { |
| 266 | 214 | config.init_data = pdata->regulators[i].initdata; |
| 267 | 215 | config.of_node = pdata->regulators[i].of_node; |
| 268 | − } else { | |
| 269 | − config.init_data = match_init_data(i, dev_type); | |
| 270 | − config.of_node = match_of_node(i, dev_type); | |
| 271 | 216 | } |
| 272 | 217 | config.regmap = max14577_get_regmap(max14577, |
| 273 | 218 | supported_regulators[i].id); |
| @@ -41,7 +41,7 @@ struct max77650_regulator_desc { · 40 unmodified lines | ||
| 41 | 41 | unsigned int regB; |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | −static const u32 max77651_sbb1_regulator_volt_table[] = { | |
| 44 | +static const unsigned int max77651_sbb1_regulator_volt_table[] = { | |
| 45 | 45 | 2400000, 3200000, 4000000, 4800000, |
| 46 | 46 | 2450000, 3250000, 4050000, 4850000, |
| 47 | 47 | 2500000, 3300000, 4100000, 4900000, |
| @@ -159,6 +159,8 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { · 158 unmodified lines | ||
| 159 | 159 | { \ |
| 160 | 160 | .desc = { \ |
| 161 | 161 | .name = "SDV" #_id, \ |
| 162 | + .of_match = of_match_ptr("SDV" #_id), \ | |
| 163 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 162 | 164 | .ops = &max8925_regulator_sdv_ops, \ |
| 163 | 165 | .type = REGULATOR_VOLTAGE, \ |
| 164 | 166 | .id = MAX8925_ID_SD##_id, \ |
| @@ -175,6 +177,8 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { · 10 unmodified lines | ||
| 175 | 177 | { \ |
| 176 | 178 | .desc = { \ |
| 177 | 179 | .name = "LDO" #_id, \ |
| 180 | + .of_match = of_match_ptr("LDO" #_id), \ | |
| 181 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 178 | 182 | .ops = &max8925_regulator_ldo_ops, \ |
| 179 | 183 | .type = REGULATOR_VOLTAGE, \ |
| 180 | 184 | .id = MAX8925_ID_LDO##_id, \ |
| @@ -187,34 +191,6 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { · 6 unmodified lines | ||
| 187 | 191 | .enable_reg = MAX8925_LDOCTL##_id, \ |
| 188 | 192 | } |
| 189 | 193 | |
| 190 | −#ifdef CONFIG_OF | |
| 191 | −static struct of_regulator_match max8925_regulator_matches[] = { | |
| 192 | − { .name = "SDV1",}, | |
| 193 | − { .name = "SDV2",}, | |
| 194 | − { .name = "SDV3",}, | |
| 195 | − { .name = "LDO1",}, | |
| 196 | − { .name = "LDO2",}, | |
| 197 | − { .name = "LDO3",}, | |
| 198 | − { .name = "LDO4",}, | |
| 199 | − { .name = "LDO5",}, | |
| 200 | − { .name = "LDO6",}, | |
| 201 | − { .name = "LDO7",}, | |
| 202 | − { .name = "LDO8",}, | |
| 203 | − { .name = "LDO9",}, | |
| 204 | − { .name = "LDO10",}, | |
| 205 | − { .name = "LDO11",}, | |
| 206 | − { .name = "LDO12",}, | |
| 207 | − { .name = "LDO13",}, | |
| 208 | − { .name = "LDO14",}, | |
| 209 | − { .name = "LDO15",}, | |
| 210 | − { .name = "LDO16",}, | |
| 211 | − { .name = "LDO17",}, | |
| 212 | − { .name = "LDO18",}, | |
| 213 | − { .name = "LDO19",}, | |
| 214 | − { .name = "LDO20",}, | |
| 215 | −}; | |
| 216 | −#endif | |
| 217 | − | |
| 218 | 194 | static struct max8925_regulator_info max8925_regulator_info[] = { |
| 219 | 195 | MAX8925_SDV(1, 637.5, 1425, 12.5), |
| 220 | 196 | MAX8925_SDV(2, 650, 2225, 25), |
| @@ -242,37 +218,6 @@ static struct max8925_regulator_info max8925_regulator_info[] = { · 21 unmodified lines | ||
| 242 | 218 | MAX8925_LDO(20, 750, 3900, 50), |
| 243 | 219 | }; |
| 244 | 220 | |
| 245 | −#ifdef CONFIG_OF | |
| 246 | −static int max8925_regulator_dt_init(struct platform_device *pdev, | |
| 247 | − struct regulator_config *config, | |
| 248 | − int ridx) | |
| 249 | −{ | |
| 250 | − struct device_node *nproot, *np; | |
| 251 | − int rcount; | |
| 252 | − | |
| 253 | − nproot = pdev->dev.parent->of_node; | |
| 254 | − if (!nproot) | |
| 255 | − return -ENODEV; | |
| 256 | − np = of_get_child_by_name(nproot, "regulators"); | |
| 257 | − if (!np) { | |
| 258 | − dev_err(&pdev->dev, "failed to find regulators node\n"); | |
| 259 | − return -ENODEV; | |
| 260 | − } | |
| 261 | − | |
| 262 | − rcount = of_regulator_match(&pdev->dev, np, | |
| 263 | − &max8925_regulator_matches[ridx], 1); | |
| 264 | − of_node_put(np); | |
| 265 | − if (rcount < 0) | |
| 266 | − return rcount; | |
| 267 | − config->init_data = max8925_regulator_matches[ridx].init_data; | |
| 268 | − config->of_node = max8925_regulator_matches[ridx].of_node; | |
| 269 | − | |
| 270 | − return 0; | |
| 271 | −} | |
| 272 | −#else | |
| 273 | −#define max8925_regulator_dt_init(x, y, z) (-1) | |
| 274 | −#endif | |
| 275 | − | |
| 276 | 221 | static int max8925_regulator_probe(struct platform_device *pdev) |
| 277 | 222 | { |
| 278 | 223 | struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); |
| @@ -281,7 +226,7 @@ static int max8925_regulator_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 281 | 226 | struct max8925_regulator_info *ri; |
| 282 | 227 | struct resource *res; |
| 283 | 228 | struct regulator_dev *rdev; |
| 284 | − int i, regulator_idx; | |
| 229 | + int i; | |
| 285 | 230 | |
| 286 | 231 | res = platform_get_resource(pdev, IORESOURCE_REG, 0); |
| 287 | 232 | if (!res) { |
| @@ -290,10 +235,8 @@ static int max8925_regulator_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 290 | 235 | } |
| 291 | 236 | for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) { |
| 292 | 237 | ri = &max8925_regulator_info[i]; |
| 293 | − if (ri->vol_reg == res->start) { | |
| 294 | − regulator_idx = i; | |
| 238 | + if (ri->vol_reg == res->start) | |
| 295 | 239 | break; |
| 296 | − } | |
| 297 | 240 | } |
| 298 | 241 | |
| 299 | 242 | if (i == ARRAY_SIZE(max8925_regulator_info)) { |
| @@ -303,12 +246,11 @@ static int max8925_regulator_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 303 | 246 | } |
| 304 | 247 | ri->i2c = chip->i2c; |
| 305 | 248 | |
| 306 | − config.dev = &pdev->dev; | |
| 249 | + config.dev = chip->dev; | |
| 307 | 250 | config.driver_data = ri; |
| 308 | 251 | |
| 309 | − if (max8925_regulator_dt_init(pdev, &config, regulator_idx)) | |
| 310 | − if (pdata) | |
| 311 | − config.init_data = pdata; | |
| 252 | + if (pdata) | |
| 253 | + config.init_data = pdata; | |
| 312 | 254 | |
| 313 | 255 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
| 314 | 256 | if (IS_ERR(rdev)) { |
| @@ -33,72 +33,6 @@ struct max8998_data { · 32 unmodified lines | ||
| 33 | 33 | unsigned int buck2_idx; |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | −struct voltage_map_desc { | |
| 37 | − int min; | |
| 38 | − int max; | |
| 39 | − int step; | |
| 40 | −}; | |
| 41 | − | |
| 42 | −/* Voltage maps in uV*/ | |
| 43 | −static const struct voltage_map_desc ldo23_voltage_map_desc = { | |
| 44 | − .min = 800000, .step = 50000, .max = 1300000, | |
| 45 | −}; | |
| 46 | −static const struct voltage_map_desc ldo456711_voltage_map_desc = { | |
| 47 | − .min = 1600000, .step = 100000, .max = 3600000, | |
| 48 | −}; | |
| 49 | −static const struct voltage_map_desc ldo8_voltage_map_desc = { | |
| 50 | − .min = 3000000, .step = 100000, .max = 3600000, | |
| 51 | −}; | |
| 52 | −static const struct voltage_map_desc ldo9_voltage_map_desc = { | |
| 53 | − .min = 2800000, .step = 100000, .max = 3100000, | |
| 54 | −}; | |
| 55 | −static const struct voltage_map_desc ldo10_voltage_map_desc = { | |
| 56 | − .min = 950000, .step = 50000, .max = 1300000, | |
| 57 | −}; | |
| 58 | −static const struct voltage_map_desc ldo1213_voltage_map_desc = { | |
| 59 | − .min = 800000, .step = 100000, .max = 3300000, | |
| 60 | −}; | |
| 61 | −static const struct voltage_map_desc ldo1415_voltage_map_desc = { | |
| 62 | − .min = 1200000, .step = 100000, .max = 3300000, | |
| 63 | −}; | |
| 64 | −static const struct voltage_map_desc ldo1617_voltage_map_desc = { | |
| 65 | − .min = 1600000, .step = 100000, .max = 3600000, | |
| 66 | −}; | |
| 67 | −static const struct voltage_map_desc buck12_voltage_map_desc = { | |
| 68 | − .min = 750000, .step = 25000, .max = 1525000, | |
| 69 | −}; | |
| 70 | −static const struct voltage_map_desc buck3_voltage_map_desc = { | |
| 71 | − .min = 1600000, .step = 100000, .max = 3600000, | |
| 72 | −}; | |
| 73 | −static const struct voltage_map_desc buck4_voltage_map_desc = { | |
| 74 | − .min = 800000, .step = 100000, .max = 2300000, | |
| 75 | −}; | |
| 76 | − | |
| 77 | −static const struct voltage_map_desc *ldo_voltage_map[] = { | |
| 78 | − NULL, | |
| 79 | − NULL, | |
| 80 | − &ldo23_voltage_map_desc, /* LDO2 */ | |
| 81 | − &ldo23_voltage_map_desc, /* LDO3 */ | |
| 82 | − &ldo456711_voltage_map_desc, /* LDO4 */ | |
| 83 | − &ldo456711_voltage_map_desc, /* LDO5 */ | |
| 84 | − &ldo456711_voltage_map_desc, /* LDO6 */ | |
| 85 | − &ldo456711_voltage_map_desc, /* LDO7 */ | |
| 86 | − &ldo8_voltage_map_desc, /* LDO8 */ | |
| 87 | − &ldo9_voltage_map_desc, /* LDO9 */ | |
| 88 | − &ldo10_voltage_map_desc, /* LDO10 */ | |
| 89 | − &ldo456711_voltage_map_desc, /* LDO11 */ | |
| 90 | − &ldo1213_voltage_map_desc, /* LDO12 */ | |
| 91 | − &ldo1213_voltage_map_desc, /* LDO13 */ | |
| 92 | − &ldo1415_voltage_map_desc, /* LDO14 */ | |
| 93 | − &ldo1415_voltage_map_desc, /* LDO15 */ | |
| 94 | − &ldo1617_voltage_map_desc, /* LDO16 */ | |
| 95 | − &ldo1617_voltage_map_desc, /* LDO17 */ | |
| 96 | − &buck12_voltage_map_desc, /* BUCK1 */ | |
| 97 | − &buck12_voltage_map_desc, /* BUCK2 */ | |
| 98 | − &buck3_voltage_map_desc, /* BUCK3 */ | |
| 99 | − &buck4_voltage_map_desc, /* BUCK4 */ | |
| 100 | −}; | |
| 101 | − | |
| 102 | 36 | static int max8998_get_enable_register(struct regulator_dev *rdev, |
| 103 | 37 | int *reg, int *shift) |
| 104 | 38 | { |
| @@ -400,7 +334,6 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev, · 295 unmodified lines | ||
| 400 | 334 | { |
| 401 | 335 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
| 402 | 336 | struct i2c_client *i2c = max8998->iodev->i2c; |
| 403 | − const struct voltage_map_desc *desc; | |
| 404 | 337 | int buck = rdev_get_id(rdev); |
| 405 | 338 | u8 val = 0; |
| 406 | 339 | int difference, ret; |
| @@ -408,8 +341,6 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev, · 1 unmodified line | ||
| 408 | 341 | if (buck < MAX8998_BUCK1 || buck > MAX8998_BUCK4) |
| 409 | 342 | return -EINVAL; |
| 410 | 343 | |
| 411 | − desc = ldo_voltage_map[buck]; | |
| 412 | − | |
| 413 | 344 | /* Voltage stabilization */ |
| 414 | 345 | ret = max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val); |
| 415 | 346 | if (ret) |
| @@ -420,14 +351,14 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev, · 4 unmodified lines | ||
| 420 | 351 | if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP)) |
| 421 | 352 | return 0; |
| 422 | 353 | |
| 423 | − difference = (new_selector - old_selector) * desc->step / 1000; | |
| 354 | + difference = (new_selector - old_selector) * rdev->desc->uV_step / 1000; | |
| 424 | 355 | if (difference > 0) |
| 425 | 356 | return DIV_ROUND_UP(difference, (val & 0x0f) + 1); |
| 426 | 357 | |
| 427 | 358 | return 0; |
| 428 | 359 | } |
| 429 | 360 | |
| 430 | −static struct regulator_ops max8998_ldo_ops = { | |
| 361 | +static const struct regulator_ops max8998_ldo_ops = { | |
| 431 | 362 | .list_voltage = regulator_list_voltage_linear, |
| 432 | 363 | .map_voltage = regulator_map_voltage_linear, |
| 433 | 364 | .is_enabled = max8998_ldo_is_enabled, |
| @@ -437,7 +368,7 @@ static struct regulator_ops max8998_ldo_ops = { · 3 unmodified lines | ||
| 437 | 368 | .set_voltage_sel = max8998_set_voltage_ldo_sel, |
| 438 | 369 | }; |
| 439 | 370 | |
| 440 | −static struct regulator_ops max8998_buck_ops = { | |
| 371 | +static const struct regulator_ops max8998_buck_ops = { | |
| 441 | 372 | .list_voltage = regulator_list_voltage_linear, |
| 442 | 373 | .map_voltage = regulator_map_voltage_linear, |
| 443 | 374 | .is_enabled = max8998_ldo_is_enabled, |
| @@ -448,164 +379,59 @@ static struct regulator_ops max8998_buck_ops = { · 4 unmodified lines | ||
| 448 | 379 | .set_voltage_time_sel = max8998_set_voltage_buck_time_sel, |
| 449 | 380 | }; |
| 450 | 381 | |
| 451 | −static struct regulator_ops max8998_others_ops = { | |
| 382 | +static const struct regulator_ops max8998_others_ops = { | |
| 452 | 383 | .is_enabled = max8998_ldo_is_enabled, |
| 453 | 384 | .enable = max8998_ldo_enable, |
| 454 | 385 | .disable = max8998_ldo_disable, |
| 455 | 386 | }; |
| 456 | 387 | |
| 457 | −static struct regulator_desc regulators[] = { | |
| 458 | − { | |
| 459 | − .name = "LDO2", | |
| 460 | − .id = MAX8998_LDO2, | |
| 461 | − .ops = &max8998_ldo_ops, | |
| 462 | − .type = REGULATOR_VOLTAGE, | |
| 463 | − .owner = THIS_MODULE, | |
| 464 | − }, { | |
| 465 | − .name = "LDO3", | |
| 466 | − .id = MAX8998_LDO3, | |
| 467 | − .ops = &max8998_ldo_ops, | |
| 468 | − .type = REGULATOR_VOLTAGE, | |
| 469 | − .owner = THIS_MODULE, | |
| 470 | − }, { | |
| 471 | − .name = "LDO4", | |
| 472 | − .id = MAX8998_LDO4, | |
| 473 | − .ops = &max8998_ldo_ops, | |
| 474 | − .type = REGULATOR_VOLTAGE, | |
| 475 | − .owner = THIS_MODULE, | |
| 476 | − }, { | |
| 477 | − .name = "LDO5", | |
| 478 | − .id = MAX8998_LDO5, | |
| 479 | − .ops = &max8998_ldo_ops, | |
| 480 | − .type = REGULATOR_VOLTAGE, | |
| 481 | − .owner = THIS_MODULE, | |
| 482 | − }, { | |
| 483 | − .name = "LDO6", | |
| 484 | − .id = MAX8998_LDO6, | |
| 485 | − .ops = &max8998_ldo_ops, | |
| 486 | − .type = REGULATOR_VOLTAGE, | |
| 487 | − .owner = THIS_MODULE, | |
| 488 | − }, { | |
| 489 | − .name = "LDO7", | |
| 490 | − .id = MAX8998_LDO7, | |
| 491 | − .ops = &max8998_ldo_ops, | |
| 492 | − .type = REGULATOR_VOLTAGE, | |
| 493 | − .owner = THIS_MODULE, | |
| 494 | − }, { | |
| 495 | − .name = "LDO8", | |
| 496 | − .id = MAX8998_LDO8, | |
| 497 | − .ops = &max8998_ldo_ops, | |
| 498 | − .type = REGULATOR_VOLTAGE, | |
| 499 | − .owner = THIS_MODULE, | |
| 500 | − }, { | |
| 501 | − .name = "LDO9", | |
| 502 | − .id = MAX8998_LDO9, | |
| 503 | − .ops = &max8998_ldo_ops, | |
| 504 | − .type = REGULATOR_VOLTAGE, | |
| 505 | − .owner = THIS_MODULE, | |
| 506 | − }, { | |
| 507 | − .name = "LDO10", | |
| 508 | − .id = MAX8998_LDO10, | |
| 509 | − .ops = &max8998_ldo_ops, | |
| 510 | − .type = REGULATOR_VOLTAGE, | |
| 511 | − .owner = THIS_MODULE, | |
| 512 | − }, { | |
| 513 | − .name = "LDO11", | |
| 514 | − .id = MAX8998_LDO11, | |
| 515 | − .ops = &max8998_ldo_ops, | |
| 516 | − .type = REGULATOR_VOLTAGE, | |
| 517 | − .owner = THIS_MODULE, | |
| 518 | − }, { | |
| 519 | − .name = "LDO12", | |
| 520 | − .id = MAX8998_LDO12, | |
| 521 | − .ops = &max8998_ldo_ops, | |
| 522 | − .type = REGULATOR_VOLTAGE, | |
| 523 | − .owner = THIS_MODULE, | |
| 524 | − }, { | |
| 525 | − .name = "LDO13", | |
| 526 | − .id = MAX8998_LDO13, | |
| 527 | − .ops = &max8998_ldo_ops, | |
| 528 | − .type = REGULATOR_VOLTAGE, | |
| 529 | − .owner = THIS_MODULE, | |
| 530 | − }, { | |
| 531 | − .name = "LDO14", | |
| 532 | − .id = MAX8998_LDO14, | |
| 533 | − .ops = &max8998_ldo_ops, | |
| 534 | − .type = REGULATOR_VOLTAGE, | |
| 535 | − .owner = THIS_MODULE, | |
| 536 | − }, { | |
| 537 | − .name = "LDO15", | |
| 538 | − .id = MAX8998_LDO15, | |
| 539 | − .ops = &max8998_ldo_ops, | |
| 540 | − .type = REGULATOR_VOLTAGE, | |
| 541 | − .owner = THIS_MODULE, | |
| 542 | − }, { | |
| 543 | − .name = "LDO16", | |
| 544 | − .id = MAX8998_LDO16, | |
| 545 | − .ops = &max8998_ldo_ops, | |
| 546 | − .type = REGULATOR_VOLTAGE, | |
| 547 | − .owner = THIS_MODULE, | |
| 548 | − }, { | |
| 549 | − .name = "LDO17", | |
| 550 | − .id = MAX8998_LDO17, | |
| 551 | − .ops = &max8998_ldo_ops, | |
| 552 | − .type = REGULATOR_VOLTAGE, | |
| 553 | − .owner = THIS_MODULE, | |
| 554 | − }, { | |
| 555 | − .name = "BUCK1", | |
| 556 | − .id = MAX8998_BUCK1, | |
| 557 | − .ops = &max8998_buck_ops, | |
| 558 | − .type = REGULATOR_VOLTAGE, | |
| 559 | − .owner = THIS_MODULE, | |
| 560 | − }, { | |
| 561 | − .name = "BUCK2", | |
| 562 | − .id = MAX8998_BUCK2, | |
| 563 | − .ops = &max8998_buck_ops, | |
| 564 | − .type = REGULATOR_VOLTAGE, | |
| 565 | − .owner = THIS_MODULE, | |
| 566 | − }, { | |
| 567 | − .name = "BUCK3", | |
| 568 | − .id = MAX8998_BUCK3, | |
| 569 | − .ops = &max8998_buck_ops, | |
| 570 | − .type = REGULATOR_VOLTAGE, | |
| 571 | − .owner = THIS_MODULE, | |
| 572 | − }, { | |
| 573 | − .name = "BUCK4", | |
| 574 | − .id = MAX8998_BUCK4, | |
| 575 | − .ops = &max8998_buck_ops, | |
| 576 | − .type = REGULATOR_VOLTAGE, | |
| 577 | − .owner = THIS_MODULE, | |
| 578 | − }, { | |
| 579 | − .name = "EN32KHz-AP", | |
| 580 | − .id = MAX8998_EN32KHZ_AP, | |
| 581 | − .ops = &max8998_others_ops, | |
| 582 | − .type = REGULATOR_VOLTAGE, | |
| 583 | − .owner = THIS_MODULE, | |
| 584 | − }, { | |
| 585 | − .name = "EN32KHz-CP", | |
| 586 | − .id = MAX8998_EN32KHZ_CP, | |
| 587 | − .ops = &max8998_others_ops, | |
| 588 | − .type = REGULATOR_VOLTAGE, | |
| 589 | − .owner = THIS_MODULE, | |
| 590 | − }, { | |
| 591 | − .name = "ENVICHG", | |
| 592 | − .id = MAX8998_ENVICHG, | |
| 593 | − .ops = &max8998_others_ops, | |
| 594 | − .type = REGULATOR_VOLTAGE, | |
| 595 | − .owner = THIS_MODULE, | |
| 596 | − }, { | |
| 597 | − .name = "ESAFEOUT1", | |
| 598 | − .id = MAX8998_ESAFEOUT1, | |
| 599 | − .ops = &max8998_others_ops, | |
| 600 | − .type = REGULATOR_VOLTAGE, | |
| 601 | − .owner = THIS_MODULE, | |
| 602 | − }, { | |
| 603 | − .name = "ESAFEOUT2", | |
| 604 | − .id = MAX8998_ESAFEOUT2, | |
| 605 | − .ops = &max8998_others_ops, | |
| 606 | − .type = REGULATOR_VOLTAGE, | |
| 607 | − .owner = THIS_MODULE, | |
| 388 | +#define MAX8998_LINEAR_REG(_name, _ops, _min, _step, _max) \ | |
| 389 | + { \ | |
| 390 | + .name = #_name, \ | |
| 391 | + .id = MAX8998_##_name, \ | |
| 392 | + .ops = _ops, \ | |
| 393 | + .min_uV = (_min), \ | |
| 394 | + .uV_step = (_step), \ | |
| 395 | + .n_voltages = ((_max) - (_min)) / (_step) + 1, \ | |
| 396 | + .type = REGULATOR_VOLTAGE, \ | |
| 397 | + .owner = THIS_MODULE, \ | |
| 608 | 398 | } |
| 399 | + | |
| 400 | +#define MAX8998_OTHERS_REG(_name, _id) \ | |
| 401 | + { \ | |
| 402 | + .name = #_name, \ | |
| 403 | + .id = _id, \ | |
| 404 | + .ops = &max8998_others_ops, \ | |
| 405 | + .type = REGULATOR_VOLTAGE, \ | |
| 406 | + .owner = THIS_MODULE, \ | |
| 407 | + } | |
| 408 | + | |
| 409 | +static const struct regulator_desc regulators[] = { | |
| 410 | + MAX8998_LINEAR_REG(LDO2, &max8998_ldo_ops, 800000, 50000, 1300000), | |
| 411 | + MAX8998_LINEAR_REG(LDO3, &max8998_ldo_ops, 800000, 50000, 1300000), | |
| 412 | + MAX8998_LINEAR_REG(LDO4, &max8998_ldo_ops, 1600000, 100000, 3600000), | |
| 413 | + MAX8998_LINEAR_REG(LDO5, &max8998_ldo_ops, 1600000, 100000, 3600000), | |
| 414 | + MAX8998_LINEAR_REG(LDO6, &max8998_ldo_ops, 1600000, 100000, 3600000), | |
| 415 | + MAX8998_LINEAR_REG(LDO7, &max8998_ldo_ops, 1600000, 100000, 3600000), | |
| 416 | + MAX8998_LINEAR_REG(LDO8, &max8998_ldo_ops, 3000000, 100000, 3600000), | |
| 417 | + MAX8998_LINEAR_REG(LDO9, &max8998_ldo_ops, 2800000, 100000, 3100000), | |
| 418 | + MAX8998_LINEAR_REG(LDO10, &max8998_ldo_ops, 950000, 50000, 1300000), | |
| 419 | + MAX8998_LINEAR_REG(LDO11, &max8998_ldo_ops, 1600000, 100000, 3600000), | |
| 420 | + MAX8998_LINEAR_REG(LDO12, &max8998_ldo_ops, 800000, 100000, 3300000), | |
| 421 | + MAX8998_LINEAR_REG(LDO13, &max8998_ldo_ops, 800000, 100000, 3300000), | |
| 422 | + MAX8998_LINEAR_REG(LDO14, &max8998_ldo_ops, 1200000, 100000, 3300000), | |
| 423 | + MAX8998_LINEAR_REG(LDO15, &max8998_ldo_ops, 1200000, 100000, 3300000), | |
| 424 | + MAX8998_LINEAR_REG(LDO16, &max8998_ldo_ops, 1600000, 100000, 3600000), | |
| 425 | + MAX8998_LINEAR_REG(LDO17, &max8998_ldo_ops, 1600000, 100000, 3600000), | |
| 426 | + MAX8998_LINEAR_REG(BUCK1, &max8998_buck_ops, 750000, 25000, 1525000), | |
| 427 | + MAX8998_LINEAR_REG(BUCK2, &max8998_buck_ops, 750000, 25000, 1525000), | |
| 428 | + MAX8998_LINEAR_REG(BUCK3, &max8998_buck_ops, 1600000, 100000, 3600000), | |
| 429 | + MAX8998_LINEAR_REG(BUCK4, &max8998_buck_ops, 800000, 100000, 2300000), | |
| 430 | + MAX8998_OTHERS_REG(EN32KHz-AP, MAX8998_EN32KHZ_AP), | |
| 431 | + MAX8998_OTHERS_REG(EN32KHz-CP, MAX8998_EN32KHZ_CP), | |
| 432 | + MAX8998_OTHERS_REG(ENVICHG, MAX8998_ENVICHG), | |
| 433 | + MAX8998_OTHERS_REG(ESAFEOUT1, MAX8998_ESAFEOUT1), | |
| 434 | + MAX8998_OTHERS_REG(ESAFEOUT2, MAX8998_ESAFEOUT2), | |
| 609 | 435 | }; |
| 610 | 436 | |
| 611 | 437 | static int max8998_pmic_dt_parse_dvs_gpio(struct max8998_dev *iodev, |
| @@ -796,9 +622,11 @@ static int max8998_pmic_probe(struct platform_device *pdev) · 184 unmodified lines | ||
| 796 | 622 | |
| 797 | 623 | /* Set predefined values for BUCK1 registers */ |
| 798 | 624 | for (v = 0; v < ARRAY_SIZE(pdata->buck1_voltage); ++v) { |
| 625 | + int index = MAX8998_BUCK1 - MAX8998_LDO2; | |
| 626 | + | |
| 799 | 627 | i = 0; |
| 800 | − while (buck12_voltage_map_desc.min + | |
| 801 | − buck12_voltage_map_desc.step*i | |
| 628 | + while (regulators[index].min_uV + | |
| 629 | + regulators[index].uV_step * i | |
| 802 | 630 | < pdata->buck1_voltage[v]) |
| 803 | 631 | i++; |
| 804 | 632 | |
| @@ -824,9 +652,11 @@ static int max8998_pmic_probe(struct platform_device *pdev) · 19 unmodified lines | ||
| 824 | 652 | |
| 825 | 653 | /* Set predefined values for BUCK2 registers */ |
| 826 | 654 | for (v = 0; v < ARRAY_SIZE(pdata->buck2_voltage); ++v) { |
| 655 | + int index = MAX8998_BUCK2 - MAX8998_LDO2; | |
| 656 | + | |
| 827 | 657 | i = 0; |
| 828 | − while (buck12_voltage_map_desc.min + | |
| 829 | − buck12_voltage_map_desc.step*i | |
| 658 | + while (regulators[index].min_uV + | |
| 659 | + regulators[index].uV_step * i | |
| 830 | 660 | < pdata->buck2_voltage[v]) |
| 831 | 661 | i++; |
| 832 | 662 | |
| @@ -839,18 +669,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) · 6 unmodified lines | ||
| 839 | 669 | } |
| 840 | 670 | |
| 841 | 671 | for (i = 0; i < pdata->num_regulators; i++) { |
| 842 | − const struct voltage_map_desc *desc; | |
| 843 | − int id = pdata->regulators[i].id; | |
| 844 | − int index = id - MAX8998_LDO2; | |
| 845 | − | |
| 846 | − desc = ldo_voltage_map[id]; | |
| 847 | − if (desc && regulators[index].ops != &max8998_others_ops) { | |
| 848 | − int count = (desc->max - desc->min) / desc->step + 1; | |
| 849 | − | |
| 850 | − regulators[index].n_voltages = count; | |
| 851 | − regulators[index].min_uV = desc->min; | |
| 852 | − regulators[index].uV_step = desc->step; | |
| 853 | − } | |
| 672 | + int index = pdata->regulators[i].id - MAX8998_LDO2; | |
| 854 | 673 | |
| 855 | 674 | config.dev = max8998->dev; |
| 856 | 675 | config.of_node = pdata->regulators[i].reg_node; |
| @@ -867,7 +686,6 @@ static int max8998_pmic_probe(struct platform_device *pdev) · 10 unmodified lines | ||
| 867 | 686 | } |
| 868 | 687 | } |
| 869 | 688 | |
| 870 | − | |
| 871 | 689 | return 0; |
| 872 | 690 | } |
| 873 | 691 | |
| @@ -119,8 +119,6 @@ enum { · 118 unmodified lines | ||
| 119 | 119 | * @lpm: LPM GPIO descriptor |
| 120 | 120 | */ |
| 121 | 121 | struct mcp16502 { |
| 122 | − struct regulator_dev *rdev[NUM_REGULATORS]; | |
| 123 | − struct regmap *rmap; | |
| 124 | 122 | struct gpio_desc *lpm; |
| 125 | 123 | }; |
| 126 | 124 | |
| @@ -179,13 +177,12 @@ static unsigned int mcp16502_get_mode(struct regulator_dev *rdev) · 52 unmodified lines | ||
| 179 | 177 | { |
| 180 | 178 | unsigned int val; |
| 181 | 179 | int ret, reg; |
| 182 | − struct mcp16502 *mcp = rdev_get_drvdata(rdev); | |
| 183 | 180 | |
| 184 | 181 | reg = mcp16502_get_reg(rdev, MCP16502_OPMODE_ACTIVE); |
| 185 | 182 | if (reg < 0) |
| 186 | 183 | return reg; |
| 187 | 184 | |
| 188 | − ret = regmap_read(mcp->rmap, reg, &val); | |
| 185 | + ret = regmap_read(rdev->regmap, reg, &val); | |
| 189 | 186 | if (ret) |
| 190 | 187 | return ret; |
| 191 | 188 | |
| @@ -211,7 +208,6 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode, · 19 unmodified lines | ||
| 211 | 208 | { |
| 212 | 209 | int val; |
| 213 | 210 | int reg; |
| 214 | − struct mcp16502 *mcp = rdev_get_drvdata(rdev); | |
| 215 | 211 | |
| 216 | 212 | reg = mcp16502_get_reg(rdev, op_mode); |
| 217 | 213 | if (reg < 0) |
| @@ -228,7 +224,7 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode, · 10 unmodified lines | ||
| 228 | 224 | return -EINVAL; |
| 229 | 225 | } |
| 230 | 226 | |
| 231 | − reg = regmap_update_bits(mcp->rmap, reg, MCP16502_MODE, val); | |
| 227 | + reg = regmap_update_bits(rdev->regmap, reg, MCP16502_MODE, val); | |
| 232 | 228 | return reg; |
| 233 | 229 | } |
| 234 | 230 | |
| @@ -247,9 +243,8 @@ static int mcp16502_get_status(struct regulator_dev *rdev) · 12 unmodified lines | ||
| 247 | 243 | { |
| 248 | 244 | int ret; |
| 249 | 245 | unsigned int val; |
| 250 | − struct mcp16502 *mcp = rdev_get_drvdata(rdev); | |
| 251 | 246 | |
| 252 | − ret = regmap_read(mcp->rmap, MCP16502_STAT_BASE(rdev_get_id(rdev)), | |
| 247 | + ret = regmap_read(rdev->regmap, MCP16502_STAT_BASE(rdev_get_id(rdev)), | |
| 253 | 248 | &val); |
| 254 | 249 | if (ret) |
| 255 | 250 | return ret; |
| @@ -290,7 +285,6 @@ static int mcp16502_suspend_get_target_reg(struct regulator_dev *rdev) · 34 unmodified lines | ||
| 290 | 285 | */ |
| 291 | 286 | static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV) |
| 292 | 287 | { |
| 293 | − struct mcp16502 *mcp = rdev_get_drvdata(rdev); | |
| 294 | 288 | int sel = regulator_map_voltage_linear_range(rdev, uV, uV); |
| 295 | 289 | int reg = mcp16502_suspend_get_target_reg(rdev); |
| 296 | 290 | |
| @@ -300,7 +294,7 @@ static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV) · 3 unmodified lines | ||
| 300 | 294 | if (reg < 0) |
| 301 | 295 | return reg; |
| 302 | 296 | |
| 303 | − return regmap_update_bits(mcp->rmap, reg, MCP16502_VSEL, sel); | |
| 297 | + return regmap_update_bits(rdev->regmap, reg, MCP16502_VSEL, sel); | |
| 304 | 298 | } |
| 305 | 299 | |
| 306 | 300 | /* |
| @@ -328,13 +322,12 @@ static int mcp16502_set_suspend_mode(struct regulator_dev *rdev, · 21 unmodified lines | ||
| 328 | 322 | */ |
| 329 | 323 | static int mcp16502_set_suspend_enable(struct regulator_dev *rdev) |
| 330 | 324 | { |
| 331 | − struct mcp16502 *mcp = rdev_get_drvdata(rdev); | |
| 332 | 325 | int reg = mcp16502_suspend_get_target_reg(rdev); |
| 333 | 326 | |
| 334 | 327 | if (reg < 0) |
| 335 | 328 | return reg; |
| 336 | 329 | |
| 337 | − return regmap_update_bits(mcp->rmap, reg, MCP16502_EN, MCP16502_EN); | |
| 330 | + return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, MCP16502_EN); | |
| 338 | 331 | } |
| 339 | 332 | |
| 340 | 333 | /* |
| @@ -342,13 +335,12 @@ static int mcp16502_set_suspend_enable(struct regulator_dev *rdev) · 1 unmodified line | ||
| 342 | 335 | */ |
| 343 | 336 | static int mcp16502_set_suspend_disable(struct regulator_dev *rdev) |
| 344 | 337 | { |
| 345 | − struct mcp16502 *mcp = rdev_get_drvdata(rdev); | |
| 346 | 338 | int reg = mcp16502_suspend_get_target_reg(rdev); |
| 347 | 339 | |
| 348 | 340 | if (reg < 0) |
| 349 | 341 | return reg; |
| 350 | 342 | |
| 351 | − return regmap_update_bits(mcp->rmap, reg, MCP16502_EN, 0); | |
| 343 | + return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, 0); | |
| 352 | 344 | } |
| 353 | 345 | #endif /* CONFIG_SUSPEND */ |
| 354 | 346 | |
| @@ -435,36 +427,15 @@ static const struct regmap_config mcp16502_regmap_config = { · 80 unmodified lines | ||
| 435 | 427 | .wr_table = &mcp16502_yes_reg_table, |
| 436 | 428 | }; |
| 437 | 429 | |
| 438 | −/* | |
| 439 | − * set_up_regulators() - initialize all regulators | |
| 440 | − */ | |
| 441 | −static int setup_regulators(struct mcp16502 *mcp, struct device *dev, | |
| 442 | − struct regulator_config config) | |
| 443 | −{ | |
| 444 | − int i; | |
| 445 | − | |
| 446 | − for (i = 0; i < NUM_REGULATORS; i++) { | |
| 447 | − mcp->rdev[i] = devm_regulator_register(dev, | |
| 448 | − &mcp16502_desc[i], | |
| 449 | − &config); | |
| 450 | − if (IS_ERR(mcp->rdev[i])) { | |
| 451 | − dev_err(dev, | |
| 452 | − "failed to register %s regulator %ld\n", | |
| 453 | − mcp16502_desc[i].name, PTR_ERR(mcp->rdev[i])); | |
| 454 | − return PTR_ERR(mcp->rdev[i]); | |
| 455 | − } | |
| 456 | − } | |
| 457 | − | |
| 458 | − return 0; | |
| 459 | −} | |
| 460 | − | |
| 461 | 430 | static int mcp16502_probe(struct i2c_client *client, |
| 462 | 431 | const struct i2c_device_id *id) |
| 463 | 432 | { |
| 464 | 433 | struct regulator_config config = { }; |
| 434 | + struct regulator_dev *rdev; | |
| 465 | 435 | struct device *dev; |
| 466 | 436 | struct mcp16502 *mcp; |
| 467 | − int ret = 0; | |
| 437 | + struct regmap *rmap; | |
| 438 | + int i, ret; | |
| 468 | 439 | |
| 469 | 440 | dev = &client->dev; |
| 470 | 441 | config.dev = dev; |
| @@ -473,15 +444,15 @@ static int mcp16502_probe(struct i2c_client *client, · 2 unmodified lines | ||
| 473 | 444 | if (!mcp) |
| 474 | 445 | return -ENOMEM; |
| 475 | 446 | |
| 476 | − mcp->rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config); | |
| 477 | − if (IS_ERR(mcp->rmap)) { | |
| 478 | − ret = PTR_ERR(mcp->rmap); | |
| 447 | + rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config); | |
| 448 | + if (IS_ERR(rmap)) { | |
| 449 | + ret = PTR_ERR(rmap); | |
| 479 | 450 | dev_err(dev, "regmap init failed: %d\n", ret); |
| 480 | 451 | return ret; |
| 481 | 452 | } |
| 482 | 453 | |
| 483 | 454 | i2c_set_clientdata(client, mcp); |
| 484 | − config.regmap = mcp->rmap; | |
| 455 | + config.regmap = rmap; | |
| 485 | 456 | config.driver_data = mcp; |
| 486 | 457 | |
| 487 | 458 | mcp->lpm = devm_gpiod_get(dev, "lpm", GPIOD_OUT_LOW); |
| @@ -490,9 +461,15 @@ static int mcp16502_probe(struct i2c_client *client, · 2 unmodified lines | ||
| 490 | 461 | return PTR_ERR(mcp->lpm); |
| 491 | 462 | } |
| 492 | 463 | |
| 493 | − ret = setup_regulators(mcp, dev, config); | |
| 494 | − if (ret != 0) | |
| 495 | − return ret; | |
| 464 | + for (i = 0; i < NUM_REGULATORS; i++) { | |
| 465 | + rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config); | |
| 466 | + if (IS_ERR(rdev)) { | |
| 467 | + dev_err(dev, | |
| 468 | + "failed to register %s regulator %ld\n", | |
| 469 | + mcp16502_desc[i].name, PTR_ERR(rdev)); | |
| 470 | + return PTR_ERR(rdev); | |
| 471 | + } | |
| 472 | + } | |
| 496 | 473 | |
| 497 | 474 | mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE); |
| 498 | 475 | |
| @@ -1,16 +1,7 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright (c) 2015 MediaTek Inc. | |
| 3 | − * Author: Henry Chen <henryc.chen@mediatek.com> | |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or modify | |
| 6 | − * it under the terms of the GNU General Public License version 2 as | |
| 7 | − * published by the Free Software Foundation. | |
| 8 | − * | |
| 9 | − * This program is distributed in the hope that it will be useful, | |
| 10 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | − * GNU General Public License for more details. | |
| 13 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Copyright (c) 2015 MediaTek Inc. | |
| 4 | +// Author: Henry Chen <henryc.chen@mediatek.com> | |
| 14 | 5 | |
| 15 | 6 | #include <linux/err.h> |
| 16 | 7 | #include <linux/gpio.h> |
| @@ -1,15 +1,7 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 1 | 2 | /* |
| 2 | 3 | * Copyright (c) 2015 MediaTek Inc. |
| 3 | 4 | * Author: Henry Chen <henryc.chen@mediatek.com> |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or modify | |
| 6 | − * it under the terms of the GNU General Public License version 2 as | |
| 7 | − * published by the Free Software Foundation. | |
| 8 | − * | |
| 9 | − * This program is distributed in the hope that it will be useful, | |
| 10 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | − * GNU General Public License for more details. | |
| 13 | 5 | */ |
| 14 | 6 | |
| 15 | 7 | #ifndef __MT6311_REGULATOR_H__ |
| @@ -1,11 +1,7 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright (c) 2016 MediaTek Inc. | |
| 3 | − * Author: Chen Zhong <chen.zhong@mediatek.com> | |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or modify | |
| 6 | − * it under the terms of the GNU General Public License version 2 as | |
| 7 | − * published by the Free Software Foundation. | |
| 8 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Copyright (c) 2016 MediaTek Inc. | |
| 4 | +// Author: Chen Zhong <chen.zhong@mediatek.com> | |
| 9 | 5 | |
| 10 | 6 | #include <linux/module.h> |
| 11 | 7 | #include <linux/of.h> |
| @@ -118,43 +114,43 @@ static const struct regulator_linear_range buck_volt_range3[] = { · 106 unmodified lines | ||
| 118 | 114 | REGULATOR_LINEAR_RANGE(500000, 0, 0x3f, 50000), |
| 119 | 115 | }; |
| 120 | 116 | |
| 121 | −static const u32 ldo_volt_table1[] = { | |
| 117 | +static const unsigned int ldo_volt_table1[] = { | |
| 122 | 118 | 3300000, 3400000, 3500000, 3600000, |
| 123 | 119 | }; |
| 124 | 120 | |
| 125 | −static const u32 ldo_volt_table2[] = { | |
| 121 | +static const unsigned int ldo_volt_table2[] = { | |
| 126 | 122 | 1500000, 1800000, 2500000, 2800000, |
| 127 | 123 | }; |
| 128 | 124 | |
| 129 | −static const u32 ldo_volt_table3[] = { | |
| 125 | +static const unsigned int ldo_volt_table3[] = { | |
| 130 | 126 | 1800000, 3300000, |
| 131 | 127 | }; |
| 132 | 128 | |
| 133 | −static const u32 ldo_volt_table4[] = { | |
| 129 | +static const unsigned int ldo_volt_table4[] = { | |
| 134 | 130 | 3000000, 3300000, |
| 135 | 131 | }; |
| 136 | 132 | |
| 137 | −static const u32 ldo_volt_table5[] = { | |
| 133 | +static const unsigned int ldo_volt_table5[] = { | |
| 138 | 134 | 1200000, 1300000, 1500000, 1800000, 2000000, 2800000, 3000000, 3300000, |
| 139 | 135 | }; |
| 140 | 136 | |
| 141 | −static const u32 ldo_volt_table6[] = { | |
| 137 | +static const unsigned int ldo_volt_table6[] = { | |
| 142 | 138 | 1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 2000000, |
| 143 | 139 | }; |
| 144 | 140 | |
| 145 | −static const u32 ldo_volt_table7[] = { | |
| 141 | +static const unsigned int ldo_volt_table7[] = { | |
| 146 | 142 | 1200000, 1300000, 1500000, 1800000, |
| 147 | 143 | }; |
| 148 | 144 | |
| 149 | −static const u32 ldo_volt_table8[] = { | |
| 145 | +static const unsigned int ldo_volt_table8[] = { | |
| 150 | 146 | 1800000, 3000000, |
| 151 | 147 | }; |
| 152 | 148 | |
| 153 | −static const u32 ldo_volt_table9[] = { | |
| 149 | +static const unsigned int ldo_volt_table9[] = { | |
| 154 | 150 | 1200000, 1350000, 1500000, 1800000, |
| 155 | 151 | }; |
| 156 | 152 | |
| 157 | −static const u32 ldo_volt_table10[] = { | |
| 153 | +static const unsigned int ldo_volt_table10[] = { | |
| 158 | 154 | 1200000, 1300000, 1500000, 1800000, |
| 159 | 155 | }; |
| 160 | 156 | |
| @@ -1,16 +1,7 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright (c) 2017 MediaTek Inc. | |
| 3 | − * Author: Chenglin Xu <chenglin.xu@mediatek.com> | |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or modify | |
| 6 | − * it under the terms of the GNU General Public License version 2 as | |
| 7 | − * published by the Free Software Foundation. | |
| 8 | − * | |
| 9 | − * This program is distributed in the hope that it will be useful, | |
| 10 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | − * GNU General Public License for more details. | |
| 13 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Copyright (c) 2017 MediaTek Inc. | |
| 4 | +// Author: Chenglin Xu <chenglin.xu@mediatek.com> | |
| 14 | 5 | |
| 15 | 6 | #include <linux/module.h> |
| 16 | 7 | #include <linux/of.h> |
| @@ -173,19 +164,19 @@ static const struct regulator_linear_range buck_volt_range3[] = { · 156 unmodified lines | ||
| 173 | 164 | REGULATOR_LINEAR_RANGE(1200000, 0, 0x3c, 25000), |
| 174 | 165 | }; |
| 175 | 166 | |
| 176 | −static const u32 ldo_volt_table1[] = { | |
| 167 | +static const unsigned int ldo_volt_table1[] = { | |
| 177 | 168 | 1400000, 1350000, 1300000, 1250000, 1200000, 1150000, 1100000, 1050000, |
| 178 | 169 | }; |
| 179 | 170 | |
| 180 | −static const u32 ldo_volt_table2[] = { | |
| 171 | +static const unsigned int ldo_volt_table2[] = { | |
| 181 | 172 | 2200000, 3300000, |
| 182 | 173 | }; |
| 183 | 174 | |
| 184 | −static const u32 ldo_volt_table3[] = { | |
| 175 | +static const unsigned int ldo_volt_table3[] = { | |
| 185 | 176 | 1240000, 1390000, 1540000, 1840000, |
| 186 | 177 | }; |
| 187 | 178 | |
| 188 | −static const u32 ldo_volt_table4[] = { | |
| 179 | +static const unsigned int ldo_volt_table4[] = { | |
| 189 | 180 | 2200000, 3300000, |
| 190 | 181 | }; |
| 191 | 182 | |
| @@ -1,16 +1,7 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright (c) 2014 MediaTek Inc. | |
| 3 | − * Author: Flora Fu <flora.fu@mediatek.com> | |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or modify | |
| 6 | − * it under the terms of the GNU General Public License version 2 as | |
| 7 | − * published by the Free Software Foundation. | |
| 8 | − * | |
| 9 | − * This program is distributed in the hope that it will be useful, | |
| 10 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | − * GNU General Public License for more details. | |
| 13 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Copyright (c) 2014 MediaTek Inc. | |
| 4 | +// Author: Flora Fu <flora.fu@mediatek.com> | |
| 14 | 5 | |
| 15 | 6 | #include <linux/module.h> |
| 16 | 7 | #include <linux/of.h> |
| @@ -123,35 +114,35 @@ static const struct regulator_linear_range buck_volt_range3[] = { · 106 unmodified lines | ||
| 123 | 114 | REGULATOR_LINEAR_RANGE(1500000, 0, 0x1f, 20000), |
| 124 | 115 | }; |
| 125 | 116 | |
| 126 | −static const u32 ldo_volt_table1[] = { | |
| 117 | +static const unsigned int ldo_volt_table1[] = { | |
| 127 | 118 | 1500000, 1800000, 2500000, 2800000, |
| 128 | 119 | }; |
| 129 | 120 | |
| 130 | −static const u32 ldo_volt_table2[] = { | |
| 121 | +static const unsigned int ldo_volt_table2[] = { | |
| 131 | 122 | 1800000, 3300000, |
| 132 | 123 | }; |
| 133 | 124 | |
| 134 | −static const u32 ldo_volt_table3[] = { | |
| 125 | +static const unsigned int ldo_volt_table3[] = { | |
| 135 | 126 | 3000000, 3300000, |
| 136 | 127 | }; |
| 137 | 128 | |
| 138 | −static const u32 ldo_volt_table4[] = { | |
| 129 | +static const unsigned int ldo_volt_table4[] = { | |
| 139 | 130 | 1220000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000, |
| 140 | 131 | }; |
| 141 | 132 | |
| 142 | −static const u32 ldo_volt_table5[] = { | |
| 133 | +static const unsigned int ldo_volt_table5[] = { | |
| 143 | 134 | 1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000, |
| 144 | 135 | }; |
| 145 | 136 | |
| 146 | −static const u32 ldo_volt_table5_v2[] = { | |
| 137 | +static const unsigned int ldo_volt_table5_v2[] = { | |
| 147 | 138 | 1200000, 1000000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000, |
| 148 | 139 | }; |
| 149 | 140 | |
| 150 | −static const u32 ldo_volt_table6[] = { | |
| 141 | +static const unsigned int ldo_volt_table6[] = { | |
| 151 | 142 | 1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 2000000, |
| 152 | 143 | }; |
| 153 | 144 | |
| 154 | −static const u32 ldo_volt_table7[] = { | |
| 145 | +static const unsigned int ldo_volt_table7[] = { | |
| 155 | 146 | 1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000, |
| 156 | 147 | }; |
| 157 | 148 | |
| @@ -371,8 +371,9 @@ int of_regulator_match(struct device *dev, struct device_node *node, · 370 unmodified lines | ||
| 371 | 371 | } |
| 372 | 372 | EXPORT_SYMBOL_GPL(of_regulator_match); |
| 373 | 373 | |
| 374 | −struct device_node *regulator_of_get_init_node(struct device *dev, | |
| 375 | − const struct regulator_desc *desc) | |
| 374 | +static struct | |
| 375 | +device_node *regulator_of_get_init_node(struct device *dev, | |
| 376 | + const struct regulator_desc *desc) | |
| 376 | 377 | { |
| 377 | 378 | struct device_node *search, *child; |
| 378 | 379 | const char *name; |
| @@ -991,9 +991,6 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic, · 990 unmodified lines | ||
| 991 | 991 | return PTR_ERR(rdev); |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | − /* Save regulator for cleanup */ | |
| 995 | − pmic->rdev[id] = rdev; | |
| 996 | − | |
| 997 | 994 | /* Initialise sleep/init values from platform data */ |
| 998 | 995 | if (pdata) { |
| 999 | 996 | reg_init = pdata->reg_init[id]; |
| @@ -1101,9 +1098,6 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic, · 101 unmodified lines | ||
| 1101 | 1098 | return PTR_ERR(rdev); |
| 1102 | 1099 | } |
| 1103 | 1100 | |
| 1104 | − /* Save regulator for cleanup */ | |
| 1105 | − pmic->rdev[id] = rdev; | |
| 1106 | − | |
| 1107 | 1101 | /* Initialise sleep/init values from platform data */ |
| 1108 | 1102 | if (pdata) { |
| 1109 | 1103 | reg_init = pdata->reg_init[id]; |
| @@ -1288,9 +1282,6 @@ static int palmas_smps_registration(struct palmas_pmic *pmic, · 178 unmodified lines | ||
| 1288 | 1282 | pdev_name); |
| 1289 | 1283 | return PTR_ERR(rdev); |
| 1290 | 1284 | } |
| 1291 | − | |
| 1292 | − /* Save regulator for cleanup */ | |
| 1293 | − pmic->rdev[id] = rdev; | |
| 1294 | 1285 | } |
| 1295 | 1286 | |
| 1296 | 1287 | return 0; |
| @@ -1395,9 +1386,6 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic, · 98 unmodified lines | ||
| 1395 | 1386 | pdev_name); |
| 1396 | 1387 | return PTR_ERR(rdev); |
| 1397 | 1388 | } |
| 1398 | − | |
| 1399 | − /* Save regulator for cleanup */ | |
| 1400 | − pmic->rdev[id] = rdev; | |
| 1401 | 1389 | } |
| 1402 | 1390 | |
| 1403 | 1391 | return 0; |
| @@ -1,17 +1,7 @@ | ||
| 1 | −/* | |
| 2 | − * pv88060-regulator.c - Regulator device driver for PV88060 | |
| 3 | − * Copyright (C) 2015 Powerventure Semiconductor Ltd. | |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or | |
| 6 | − * modify it under the terms of the GNU General Public License | |
| 7 | − * as published by the Free Software Foundation; either version 2 | |
| 8 | − * of the License, or (at your option) any later version. | |
| 9 | − * | |
| 10 | − * This program is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | − * GNU General Public License for more details. | |
| 14 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// pv88060-regulator.c - Regulator device driver for PV88060 | |
| 4 | +// Copyright (C) 2015 Powerventure Semiconductor Ltd. | |
| 15 | 5 | |
| 16 | 6 | #include <linux/err.h> |
| 17 | 7 | #include <linux/i2c.h> |
| @@ -244,9 +234,11 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data) · 226 unmodified lines | ||
| 244 | 234 | if (reg_val & PV88060_E_VDD_FLT) { |
| 245 | 235 | for (i = 0; i < PV88060_MAX_REGULATORS; i++) { |
| 246 | 236 | if (chip->rdev[i] != NULL) { |
| 237 | + regulator_lock(chip->rdev[i]); | |
| 247 | 238 | regulator_notifier_call_chain(chip->rdev[i], |
| 248 | 239 | REGULATOR_EVENT_UNDER_VOLTAGE, |
| 249 | 240 | NULL); |
| 241 | + regulator_unlock(chip->rdev[i]); | |
| 250 | 242 | } |
| 251 | 243 | } |
| 252 | 244 | |
| @@ -261,9 +253,11 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data) · 8 unmodified lines | ||
| 261 | 253 | if (reg_val & PV88060_E_OVER_TEMP) { |
| 262 | 254 | for (i = 0; i < PV88060_MAX_REGULATORS; i++) { |
| 263 | 255 | if (chip->rdev[i] != NULL) { |
| 256 | + regulator_lock(chip->rdev[i]); | |
| 264 | 257 | regulator_notifier_call_chain(chip->rdev[i], |
| 265 | 258 | REGULATOR_EVENT_OVER_TEMP, |
| 266 | 259 | NULL); |
| 260 | + regulator_unlock(chip->rdev[i]); | |
| 267 | 261 | } |
| 268 | 262 | } |
| 269 | 263 | |
| @@ -1,16 +1,7 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 1 | 2 | /* |
| 2 | 3 | * pv88060-regulator.h - Regulator definitions for PV88060 |
| 3 | 4 | * Copyright (C) 2015 Powerventure Semiconductor Ltd. |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or | |
| 6 | − * modify it under the terms of the GNU General Public License | |
| 7 | − * as published by the Free Software Foundation; either version 2 | |
| 8 | − * of the License, or (at your option) any later version. | |
| 9 | − * | |
| 10 | − * This program is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | − * GNU General Public License for more details. | |
| 14 | 5 | */ |
| 15 | 6 | |
| 16 | 7 | #ifndef __PV88060_REGISTERS_H__ |
| @@ -1,17 +1,7 @@ | ||
| 1 | −/* | |
| 2 | − * pv88080-regulator.c - Regulator device driver for PV88080 | |
| 3 | − * Copyright (C) 2016 Powerventure Semiconductor Ltd. | |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or | |
| 6 | − * modify it under the terms of the GNU General Public License | |
| 7 | − * as published by the Free Software Foundation; either version 2 | |
| 8 | − * of the License, or (at your option) any later version. | |
| 9 | − * | |
| 10 | − * This program is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | − * GNU General Public License for more details. | |
| 14 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// pv88080-regulator.c - Regulator device driver for PV88080 | |
| 4 | +// Copyright (C) 2016 Powerventure Semiconductor Ltd. | |
| 15 | 5 | |
| 16 | 6 | #include <linux/err.h> |
| 17 | 7 | #include <linux/i2c.h> |
| @@ -345,9 +335,11 @@ static irqreturn_t pv88080_irq_handler(int irq, void *data) · 327 unmodified lines | ||
| 345 | 335 | if (reg_val & PV88080_E_VDD_FLT) { |
| 346 | 336 | for (i = 0; i < PV88080_MAX_REGULATORS; i++) { |
| 347 | 337 | if (chip->rdev[i] != NULL) { |
| 338 | + regulator_lock(chip->rdev[i]); | |
| 348 | 339 | regulator_notifier_call_chain(chip->rdev[i], |
| 349 | 340 | REGULATOR_EVENT_UNDER_VOLTAGE, |
| 350 | 341 | NULL); |
| 342 | + regulator_unlock(chip->rdev[i]); | |
| 351 | 343 | } |
| 352 | 344 | } |
| 353 | 345 | |
| @@ -362,9 +354,11 @@ static irqreturn_t pv88080_irq_handler(int irq, void *data) · 8 unmodified lines | ||
| 362 | 354 | if (reg_val & PV88080_E_OVER_TEMP) { |
| 363 | 355 | for (i = 0; i < PV88080_MAX_REGULATORS; i++) { |
| 364 | 356 | if (chip->rdev[i] != NULL) { |
| 357 | + regulator_lock(chip->rdev[i]); | |
| 365 | 358 | regulator_notifier_call_chain(chip->rdev[i], |
| 366 | 359 | REGULATOR_EVENT_OVER_TEMP, |
| 367 | 360 | NULL); |
| 361 | + regulator_unlock(chip->rdev[i]); | |
| 368 | 362 | } |
| 369 | 363 | } |
| 370 | 364 | |
| @@ -1,16 +1,7 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 1 | 2 | /* |
| 2 | 3 | * pv88080-regulator.h - Regulator definitions for PV88080 |
| 3 | 4 | * Copyright (C) 2016 Powerventure Semiconductor Ltd. |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or | |
| 6 | − * modify it under the terms of the GNU General Public License | |
| 7 | − * as published by the Free Software Foundation; either version 2 | |
| 8 | − * of the License, or (at your option) any later version. | |
| 9 | − * | |
| 10 | − * This program is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | − * GNU General Public License for more details. | |
| 14 | 5 | */ |
| 15 | 6 | |
| 16 | 7 | #ifndef __PV88080_REGISTERS_H__ |
| @@ -1,17 +1,7 @@ | ||
| 1 | −/* | |
| 2 | − * pv88090-regulator.c - Regulator device driver for PV88090 | |
| 3 | − * Copyright (C) 2015 Powerventure Semiconductor Ltd. | |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or | |
| 6 | − * modify it under the terms of the GNU General Public License | |
| 7 | − * as published by the Free Software Foundation; either version 2 | |
| 8 | − * of the License, or (at your option) any later version. | |
| 9 | − * | |
| 10 | − * This program is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | − * GNU General Public License for more details. | |
| 14 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// pv88090-regulator.c - Regulator device driver for PV88090 | |
| 4 | +// Copyright (C) 2015 Powerventure Semiconductor Ltd. | |
| 15 | 5 | |
| 16 | 6 | #include <linux/err.h> |
| 17 | 7 | #include <linux/i2c.h> |
| @@ -237,9 +227,11 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data) · 219 unmodified lines | ||
| 237 | 227 | if (reg_val & PV88090_E_VDD_FLT) { |
| 238 | 228 | for (i = 0; i < PV88090_MAX_REGULATORS; i++) { |
| 239 | 229 | if (chip->rdev[i] != NULL) { |
| 230 | + regulator_lock(chip->rdev[i]); | |
| 240 | 231 | regulator_notifier_call_chain(chip->rdev[i], |
| 241 | 232 | REGULATOR_EVENT_UNDER_VOLTAGE, |
| 242 | 233 | NULL); |
| 234 | + regulator_unlock(chip->rdev[i]); | |
| 243 | 235 | } |
| 244 | 236 | } |
| 245 | 237 | |
| @@ -254,9 +246,11 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data) · 8 unmodified lines | ||
| 254 | 246 | if (reg_val & PV88090_E_OVER_TEMP) { |
| 255 | 247 | for (i = 0; i < PV88090_MAX_REGULATORS; i++) { |
| 256 | 248 | if (chip->rdev[i] != NULL) { |
| 249 | + regulator_lock(chip->rdev[i]); | |
| 257 | 250 | regulator_notifier_call_chain(chip->rdev[i], |
| 258 | 251 | REGULATOR_EVENT_OVER_TEMP, |
| 259 | 252 | NULL); |
| 253 | + regulator_unlock(chip->rdev[i]); | |
| 260 | 254 | } |
| 261 | 255 | } |
| 262 | 256 | |
| @@ -1,16 +1,7 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 1 | 2 | /* |
| 2 | 3 | * pv88090-regulator.h - Regulator definitions for PV88090 |
| 3 | 4 | * Copyright (C) 2015 Powerventure Semiconductor Ltd. |
| 4 | − * | |
| 5 | − * This program is free software; you can redistribute it and/or | |
| 6 | − * modify it under the terms of the GNU General Public License | |
| 7 | − * as published by the Free Software Foundation; either version 2 | |
| 8 | − * of the License, or (at your option) any later version. | |
| 9 | − * | |
| 10 | − * This program is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | − * GNU General Public License for more details. | |
| 14 | 5 | */ |
| 15 | 6 | |
| 16 | 7 | #ifndef __PV88090_REGISTERS_H__ |
| @@ -47,18 +47,13 @@ struct rc5t583_regulator_info { · 46 unmodified lines | ||
| 47 | 47 | struct regulator_desc desc; |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | −struct rc5t583_regulator { | |
| 51 | − struct rc5t583_regulator_info *reg_info; | |
| 52 | − struct regulator_dev *rdev; | |
| 53 | −}; | |
| 54 | − | |
| 55 | 50 | static int rc5t583_regulator_enable_time(struct regulator_dev *rdev) |
| 56 | 51 | { |
| 57 | − struct rc5t583_regulator *reg = rdev_get_drvdata(rdev); | |
| 52 | + struct rc5t583_regulator_info *reg_info = rdev_get_drvdata(rdev); | |
| 58 | 53 | int vsel = regulator_get_voltage_sel_regmap(rdev); |
| 59 | 54 | int curr_uV = regulator_list_voltage_linear(rdev, vsel); |
| 60 | 55 | |
| 61 | − return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us); | |
| 56 | + return DIV_ROUND_UP(curr_uV, reg_info->enable_uv_per_us); | |
| 62 | 57 | } |
| 63 | 58 | |
| 64 | 59 | static const struct regulator_ops rc5t583_ops = { |
| @@ -120,8 +115,6 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) · 55 unmodified lines | ||
| 120 | 115 | struct rc5t583 *rc5t583 = dev_get_drvdata(pdev->dev.parent); |
| 121 | 116 | struct rc5t583_platform_data *pdata = dev_get_platdata(rc5t583->dev); |
| 122 | 117 | struct regulator_config config = { }; |
| 123 | − struct rc5t583_regulator *reg = NULL; | |
| 124 | − struct rc5t583_regulator *regs; | |
| 125 | 118 | struct regulator_dev *rdev; |
| 126 | 119 | struct rc5t583_regulator_info *ri; |
| 127 | 120 | int ret; |
| @@ -132,18 +125,8 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) · 4 unmodified lines | ||
| 132 | 125 | return -ENODEV; |
| 133 | 126 | } |
| 134 | 127 | |
| 135 | − regs = devm_kcalloc(&pdev->dev, | |
| 136 | − RC5T583_REGULATOR_MAX, | |
| 137 | − sizeof(struct rc5t583_regulator), | |
| 138 | − GFP_KERNEL); | |
| 139 | − if (!regs) | |
| 140 | − return -ENOMEM; | |
| 141 | − | |
| 142 | − | |
| 143 | 128 | for (id = 0; id < RC5T583_REGULATOR_MAX; ++id) { |
| 144 | − reg = ®s[id]; | |
| 145 | 129 | ri = &rc5t583_reg_info[id]; |
| 146 | − reg->reg_info = ri; | |
| 147 | 130 | |
| 148 | 131 | if (ri->deepsleep_id == RC5T583_DS_NONE) |
| 149 | 132 | goto skip_ext_pwr_config; |
| @@ -163,7 +146,7 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) · 13 unmodified lines | ||
| 163 | 146 | skip_ext_pwr_config: |
| 164 | 147 | config.dev = &pdev->dev; |
| 165 | 148 | config.init_data = pdata->reg_init_data[id]; |
| 166 | − config.driver_data = reg; | |
| 149 | + config.driver_data = ri; | |
| 167 | 150 | config.regmap = rc5t583->regmap; |
| 168 | 151 | |
| 169 | 152 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
| @@ -172,9 +155,7 @@ skip_ext_pwr_config: · 2 unmodified lines | ||
| 172 | 155 | ri->desc.name); |
| 173 | 156 | return PTR_ERR(rdev); |
| 174 | 157 | } |
| 175 | − reg->rdev = rdev; | |
| 176 | 158 | } |
| 177 | − platform_set_drvdata(pdev, regs); | |
| 178 | 159 | return 0; |
| 179 | 160 | } |
| 180 | 161 | |
| @@ -46,7 +46,7 @@ static const struct regulator_ops rn5t618_reg_ops = { · 45 unmodified lines | ||
| 46 | 46 | .vsel_mask = (vmask), \ |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | −static struct regulator_desc rn5t567_regulators[] = { | |
| 49 | +static const struct regulator_desc rn5t567_regulators[] = { | |
| 50 | 50 | /* DCDC */ |
| 51 | 51 | REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500), |
| 52 | 52 | REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500), |
| @@ -63,7 +63,7 @@ static struct regulator_desc rn5t567_regulators[] = { · 10 unmodified lines | ||
| 63 | 63 | REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), |
| 64 | 64 | }; |
| 65 | 65 | |
| 66 | −static struct regulator_desc rn5t618_regulators[] = { | |
| 66 | +static const struct regulator_desc rn5t618_regulators[] = { | |
| 67 | 67 | /* DCDC */ |
| 68 | 68 | REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500), |
| 69 | 69 | REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500), |
| @@ -79,7 +79,7 @@ static struct regulator_desc rn5t618_regulators[] = { · 9 unmodified lines | ||
| 79 | 79 | REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), |
| 80 | 80 | }; |
| 81 | 81 | |
| 82 | −static struct regulator_desc rc5t619_regulators[] = { | |
| 82 | +static const struct regulator_desc rc5t619_regulators[] = { | |
| 83 | 83 | /* DCDC */ |
| 84 | 84 | REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500), |
| 85 | 85 | REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500), |
| @@ -107,7 +107,7 @@ static int rn5t618_regulator_probe(struct platform_device *pdev) · 21 unmodified lines | ||
| 107 | 107 | struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); |
| 108 | 108 | struct regulator_config config = { }; |
| 109 | 109 | struct regulator_dev *rdev; |
| 110 | − struct regulator_desc *regulators; | |
| 110 | + const struct regulator_desc *regulators; | |
| 111 | 111 | int i; |
| 112 | 112 | int num_regulators = 0; |
| 113 | 113 | |
| @@ -17,10 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <linux/mfd/samsung/core.h> |
| 18 | 18 | #include <linux/mfd/samsung/s2mpa01.h> |
| 19 | 19 | |
| 20 | −#define S2MPA01_REGULATOR_CNT ARRAY_SIZE(regulators) | |
| 21 | − | |
| 22 | 20 | struct s2mpa01_info { |
| 23 | − struct of_regulator_match rdata[S2MPA01_REGULATOR_MAX]; | |
| 24 | 21 | int ramp_delay24; |
| 25 | 22 | int ramp_delay3; |
| 26 | 23 | int ramp_delay5; |
| @@ -232,6 +229,8 @@ static const struct regulator_ops s2mpa01_buck_ops = { · 205 unmodified lines | ||
| 232 | 229 | |
| 233 | 230 | #define regulator_desc_ldo(num, step) { \ |
| 234 | 231 | .name = "LDO"#num, \ |
| 232 | + .of_match = of_match_ptr("LDO"#num), \ | |
| 233 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 235 | 234 | .id = S2MPA01_LDO##num, \ |
| 236 | 235 | .ops = &s2mpa01_ldo_ops, \ |
| 237 | 236 | .type = REGULATOR_VOLTAGE, \ |
| @@ -247,6 +246,8 @@ static const struct regulator_ops s2mpa01_buck_ops = { · 9 unmodified lines | ||
| 247 | 246 | |
| 248 | 247 | #define regulator_desc_buck1_4(num) { \ |
| 249 | 248 | .name = "BUCK"#num, \ |
| 249 | + .of_match = of_match_ptr("BUCK"#num), \ | |
| 250 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 250 | 251 | .id = S2MPA01_BUCK##num, \ |
| 251 | 252 | .ops = &s2mpa01_buck_ops, \ |
| 252 | 253 | .type = REGULATOR_VOLTAGE, \ |
| @@ -263,6 +264,8 @@ static const struct regulator_ops s2mpa01_buck_ops = { · 10 unmodified lines | ||
| 263 | 264 | |
| 264 | 265 | #define regulator_desc_buck5 { \ |
| 265 | 266 | .name = "BUCK5", \ |
| 267 | + .of_match = of_match_ptr("BUCK5"), \ | |
| 268 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 266 | 269 | .id = S2MPA01_BUCK5, \ |
| 267 | 270 | .ops = &s2mpa01_buck_ops, \ |
| 268 | 271 | .type = REGULATOR_VOLTAGE, \ |
| @@ -279,6 +282,8 @@ static const struct regulator_ops s2mpa01_buck_ops = { · 10 unmodified lines | ||
| 279 | 282 | |
| 280 | 283 | #define regulator_desc_buck6_10(num, min, step) { \ |
| 281 | 284 | .name = "BUCK"#num, \ |
| 285 | + .of_match = of_match_ptr("BUCK"#num), \ | |
| 286 | + .regulators_node = of_match_ptr("regulators"), \ | |
| 282 | 287 | .id = S2MPA01_BUCK##num, \ |
| 283 | 288 | .ops = &s2mpa01_buck_ops, \ |
| 284 | 289 | .type = REGULATOR_VOLTAGE, \ |
| @@ -336,9 +341,7 @@ static int s2mpa01_pmic_probe(struct platform_device *pdev) · 51 unmodified lines | ||
| 336 | 341 | { |
| 337 | 342 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
| 338 | 343 | struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); |
| 339 | − struct device_node *reg_np = NULL; | |
| 340 | 344 | struct regulator_config config = { }; |
| 341 | − struct of_regulator_match *rdata; | |
| 342 | 345 | struct s2mpa01_info *s2mpa01; |
| 343 | 346 | int i; |
| 344 | 347 | |
| @@ -346,39 +349,15 @@ static int s2mpa01_pmic_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 346 | 349 | if (!s2mpa01) |
| 347 | 350 | return -ENOMEM; |
| 348 | 351 | |
| 349 | − rdata = s2mpa01->rdata; | |
| 350 | − for (i = 0; i < S2MPA01_REGULATOR_CNT; i++) | |
| 351 | − rdata[i].name = regulators[i].name; | |
| 352 | − | |
| 353 | − if (iodev->dev->of_node) { | |
| 354 | − reg_np = of_get_child_by_name(iodev->dev->of_node, | |
| 355 | − "regulators"); | |
| 356 | − if (!reg_np) { | |
| 357 | − dev_err(&pdev->dev, | |
| 358 | − "could not find regulators sub-node\n"); | |
| 359 | − return -EINVAL; | |
| 360 | − } | |
| 361 | − | |
| 362 | − of_regulator_match(&pdev->dev, reg_np, rdata, | |
| 363 | − S2MPA01_REGULATOR_MAX); | |
| 364 | − of_node_put(reg_np); | |
| 365 | − } | |
| 366 | − | |
| 367 | − platform_set_drvdata(pdev, s2mpa01); | |
| 368 | − | |
| 369 | − config.dev = &pdev->dev; | |
| 352 | + config.dev = iodev->dev; | |
| 370 | 353 | config.regmap = iodev->regmap_pmic; |
| 371 | 354 | config.driver_data = s2mpa01; |
| 372 | 355 | |
| 373 | 356 | for (i = 0; i < S2MPA01_REGULATOR_MAX; i++) { |
| 374 | 357 | struct regulator_dev *rdev; |
| 358 | + | |
| 375 | 359 | if (pdata) |
| 376 | 360 | config.init_data = pdata->regulators[i].initdata; |
| 377 | − else | |
| 378 | − config.init_data = rdata[i].init_data; | |
| 379 | − | |
| 380 | − if (reg_np) | |
| 381 | − config.of_node = rdata[i].of_node; | |
| 382 | 361 | |
| 383 | 362 | rdev = devm_regulator_register(&pdev->dev, |
| 384 | 363 | ®ulators[i], &config); |
| @@ -146,7 +146,7 @@ static const struct regulator_ops sc2731_regu_linear_ops = { · 145 unmodified lines | ||
| 146 | 146 | .vsel_mask = vmask, \ |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | −static struct regulator_desc regulators[] = { | |
| 149 | +static const struct regulator_desc regulators[] = { | |
| 150 | 150 | SC2731_REGU_LINEAR(BUCK_CPU0, SC2731_POWER_PD_SW, |
| 151 | 151 | SC2731_DCDC_CPU0_PD_MASK, SC2731_DCDC_CPU0_VOL, |
| 152 | 152 | SC2731_DCDC_CPU0_VOL_MASK, 3125, 400000, 1996875), |
| @@ -1,21 +1,9 @@ | ||
| 1 | −/* | |
| 2 | − * sky81452-regulator.c SKY81452 regulator driver | |
| 3 | − * | |
| 4 | − * Copyright 2014 Skyworks Solutions Inc. | |
| 5 | − * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com> | |
| 6 | − * | |
| 7 | − * This program is free software; you can redistribute it and/or modify it | |
| 8 | − * under the terms of the GNU General Public License version 2 | |
| 9 | − * as published by the Free Software Foundation. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, but | |
| 12 | − * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | − * General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License along | |
| 17 | − * with this program; if not, see <http://www.gnu.org/licenses/>. | |
| 18 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// sky81452-regulator.c SKY81452 regulator driver | |
| 4 | +// | |
| 5 | +// Copyright 2014 Skyworks Solutions Inc. | |
| 6 | +// Author : Gyungoh Yoo <jack.yoo@skyworksinc.com> | |
| 19 | 7 | |
| 20 | 8 | #include <linux/module.h> |
| 21 | 9 | #include <linux/kernel.h> |
| @@ -34,7 +22,7 @@ · 12 unmodified lines | ||
| 34 | 22 | #define SKY81452_LEN 0x40 |
| 35 | 23 | #define SKY81452_LOUT 0x1F |
| 36 | 24 | |
| 37 | −static struct regulator_ops sky81452_reg_ops = { | |
| 25 | +static const struct regulator_ops sky81452_reg_ops = { | |
| 38 | 26 | .list_voltage = regulator_list_voltage_linear_range, |
| 39 | 27 | .map_voltage = regulator_map_voltage_linear_range, |
| 40 | 28 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| @@ -0,0 +1,186 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// Copyright (C) STMicroelectronics 2019 | |
| 3 | +// Authors: Gabriel Fernandez <gabriel.fernandez@st.com> | |
| 4 | +// Pascal Paillet <p.paillet@st.com>. | |
| 5 | + | |
| 6 | +#include <linux/io.h> | |
| 7 | +#include <linux/iopoll.h> | |
| 8 | +#include <linux/module.h> | |
| 9 | +#include <linux/of_address.h> | |
| 10 | +#include <linux/of_device.h> | |
| 11 | +#include <linux/platform_device.h> | |
| 12 | +#include <linux/regulator/driver.h> | |
| 13 | +#include <linux/regulator/of_regulator.h> | |
| 14 | + | |
| 15 | +/* | |
| 16 | + * Registers description | |
| 17 | + */ | |
| 18 | +#define REG_PWR_CR3 0x0C | |
| 19 | + | |
| 20 | +#define USB_3_3_EN BIT(24) | |
| 21 | +#define USB_3_3_RDY BIT(26) | |
| 22 | +#define REG_1_8_EN BIT(28) | |
| 23 | +#define REG_1_8_RDY BIT(29) | |
| 24 | +#define REG_1_1_EN BIT(30) | |
| 25 | +#define REG_1_1_RDY BIT(31) | |
| 26 | + | |
| 27 | +/* list of supported regulators */ | |
| 28 | +enum { | |
| 29 | + PWR_REG11, | |
| 30 | + PWR_REG18, | |
| 31 | + PWR_USB33, | |
| 32 | + STM32PWR_REG_NUM_REGS | |
| 33 | +}; | |
| 34 | + | |
| 35 | +static u32 ready_mask_table[STM32PWR_REG_NUM_REGS] = { | |
| 36 | + [PWR_REG11] = REG_1_1_RDY, | |
| 37 | + [PWR_REG18] = REG_1_8_RDY, | |
| 38 | + [PWR_USB33] = USB_3_3_RDY, | |
| 39 | +}; | |
| 40 | + | |
| 41 | +struct stm32_pwr_reg { | |
| 42 | + void __iomem *base; | |
| 43 | + u32 ready_mask; | |
| 44 | +}; | |
| 45 | + | |
| 46 | +static int stm32_pwr_reg_is_ready(struct regulator_dev *rdev) | |
| 47 | +{ | |
| 48 | + struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev); | |
| 49 | + u32 val; | |
| 50 | + | |
| 51 | + val = readl_relaxed(priv->base + REG_PWR_CR3); | |
| 52 | + | |
| 53 | + return (val & priv->ready_mask); | |
| 54 | +} | |
| 55 | + | |
| 56 | +static int stm32_pwr_reg_is_enabled(struct regulator_dev *rdev) | |
| 57 | +{ | |
| 58 | + struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev); | |
| 59 | + u32 val; | |
| 60 | + | |
| 61 | + val = readl_relaxed(priv->base + REG_PWR_CR3); | |
| 62 | + | |
| 63 | + return (val & rdev->desc->enable_mask); | |
| 64 | +} | |
| 65 | + | |
| 66 | +static int stm32_pwr_reg_enable(struct regulator_dev *rdev) | |
| 67 | +{ | |
| 68 | + struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev); | |
| 69 | + int ret; | |
| 70 | + u32 val; | |
| 71 | + | |
| 72 | + val = readl_relaxed(priv->base + REG_PWR_CR3); | |
| 73 | + val |= rdev->desc->enable_mask; | |
| 74 | + writel_relaxed(val, priv->base + REG_PWR_CR3); | |
| 75 | + | |
| 76 | + /* use an arbitrary timeout of 20ms */ | |
| 77 | + ret = readx_poll_timeout(stm32_pwr_reg_is_ready, rdev, val, val, | |
| 78 | + 100, 20 * 1000); | |
| 79 | + if (ret) | |
| 80 | + dev_err(&rdev->dev, "regulator enable timed out!\n"); | |
| 81 | + | |
| 82 | + return ret; | |
| 83 | +} | |
| 84 | + | |
| 85 | +static int stm32_pwr_reg_disable(struct regulator_dev *rdev) | |
| 86 | +{ | |
| 87 | + struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev); | |
| 88 | + int ret; | |
| 89 | + u32 val; | |
| 90 | + | |
| 91 | + val = readl_relaxed(priv->base + REG_PWR_CR3); | |
| 92 | + val &= ~rdev->desc->enable_mask; | |
| 93 | + writel_relaxed(val, priv->base + REG_PWR_CR3); | |
| 94 | + | |
| 95 | + /* use an arbitrary timeout of 20ms */ | |
| 96 | + ret = readx_poll_timeout(stm32_pwr_reg_is_ready, rdev, val, !val, | |
| 97 | + 100, 20 * 1000); | |
| 98 | + if (ret) | |
| 99 | + dev_err(&rdev->dev, "regulator disable timed out!\n"); | |
| 100 | + | |
| 101 | + return ret; | |
| 102 | +} | |
| 103 | + | |
| 104 | +static const struct regulator_ops stm32_pwr_reg_ops = { | |
| 105 | + .enable = stm32_pwr_reg_enable, | |
| 106 | + .disable = stm32_pwr_reg_disable, | |
| 107 | + .is_enabled = stm32_pwr_reg_is_enabled, | |
| 108 | +}; | |
| 109 | + | |
| 110 | +#define PWR_REG(_id, _name, _volt, _en, _supply) \ | |
| 111 | + [_id] = { \ | |
| 112 | + .id = _id, \ | |
| 113 | + .name = _name, \ | |
| 114 | + .of_match = of_match_ptr(_name), \ | |
| 115 | + .n_voltages = 1, \ | |
| 116 | + .type = REGULATOR_VOLTAGE, \ | |
| 117 | + .fixed_uV = _volt, \ | |
| 118 | + .ops = &stm32_pwr_reg_ops, \ | |
| 119 | + .enable_mask = _en, \ | |
| 120 | + .owner = THIS_MODULE, \ | |
| 121 | + .supply_name = _supply, \ | |
| 122 | + } \ | |
| 123 | + | |
| 124 | +static const struct regulator_desc stm32_pwr_desc[] = { | |
| 125 | + PWR_REG(PWR_REG11, "reg11", 1100000, REG_1_1_EN, "vdd"), | |
| 126 | + PWR_REG(PWR_REG18, "reg18", 1800000, REG_1_8_EN, "vdd"), | |
| 127 | + PWR_REG(PWR_USB33, "usb33", 3300000, USB_3_3_EN, "vdd_3v3_usbfs"), | |
| 128 | +}; | |
| 129 | + | |
| 130 | +static int stm32_pwr_regulator_probe(struct platform_device *pdev) | |
| 131 | +{ | |
| 132 | + struct device_node *np = pdev->dev.of_node; | |
| 133 | + struct stm32_pwr_reg *priv; | |
| 134 | + void __iomem *base; | |
| 135 | + struct regulator_dev *rdev; | |
| 136 | + struct regulator_config config = { }; | |
| 137 | + int i, ret = 0; | |
| 138 | + | |
| 139 | + base = of_iomap(np, 0); | |
| 140 | + if (!base) { | |
| 141 | + dev_err(&pdev->dev, "Unable to map IO memory\n"); | |
| 142 | + return -ENOMEM; | |
| 143 | + } | |
| 144 | + | |
| 145 | + config.dev = &pdev->dev; | |
| 146 | + | |
| 147 | + for (i = 0; i < STM32PWR_REG_NUM_REGS; i++) { | |
| 148 | + priv = devm_kzalloc(&pdev->dev, sizeof(struct stm32_pwr_reg), | |
| 149 | + GFP_KERNEL); | |
| 150 | + if (!priv) | |
| 151 | + return -ENOMEM; | |
| 152 | + priv->base = base; | |
| 153 | + priv->ready_mask = ready_mask_table[i]; | |
| 154 | + config.driver_data = priv; | |
| 155 | + | |
| 156 | + rdev = devm_regulator_register(&pdev->dev, | |
| 157 | + &stm32_pwr_desc[i], | |
| 158 | + &config); | |
| 159 | + if (IS_ERR(rdev)) { | |
| 160 | + ret = PTR_ERR(rdev); | |
| 161 | + dev_err(&pdev->dev, | |
| 162 | + "Failed to register regulator: %d\n", ret); | |
| 163 | + break; | |
| 164 | + } | |
| 165 | + } | |
| 166 | + return ret; | |
| 167 | +} | |
| 168 | + | |
| 169 | +static const struct of_device_id stm32_pwr_of_match[] = { | |
| 170 | + { .compatible = "st,stm32mp1,pwr-reg", }, | |
| 171 | + {}, | |
| 172 | +}; | |
| 173 | +MODULE_DEVICE_TABLE(of, stm32_pwr_of_match); | |
| 174 | + | |
| 175 | +static struct platform_driver stm32_pwr_driver = { | |
| 176 | + .probe = stm32_pwr_regulator_probe, | |
| 177 | + .driver = { | |
| 178 | + .name = "stm32-pwr-regulator", | |
| 179 | + .of_match_table = of_match_ptr(stm32_pwr_of_match), | |
| 180 | + }, | |
| 181 | +}; | |
| 182 | +module_platform_driver(stm32_pwr_driver); | |
| 183 | + | |
| 184 | +MODULE_DESCRIPTION("STM32MP1 PWR voltage regulator driver"); | |
| 185 | +MODULE_AUTHOR("Pascal Paillet <p.paillet@st.com>"); | |
| 186 | +MODULE_LICENSE("GPL v2"); | |
| @@ -22,12 +22,6 @@ · 21 unmodified lines | ||
| 22 | 22 | */ |
| 23 | 23 | #define SY8106A_GO_BIT BIT(7) |
| 24 | 24 | |
| 25 | −struct sy8106a { | |
| 26 | − struct regulator_dev *rdev; | |
| 27 | − struct regmap *regmap; | |
| 28 | − u32 fixed_voltage; | |
| 29 | −}; | |
| 30 | − | |
| 31 | 25 | static const struct regmap_config sy8106a_regmap_config = { |
| 32 | 26 | .reg_bits = 8, |
| 33 | 27 | .val_bits = 8, |
| @@ -70,36 +64,32 @@ static const struct regulator_desc sy8106a_reg = { · 36 unmodified lines | ||
| 70 | 64 | static int sy8106a_i2c_probe(struct i2c_client *i2c, |
| 71 | 65 | const struct i2c_device_id *id) |
| 72 | 66 | { |
| 73 | − struct sy8106a *chip; | |
| 74 | 67 | struct device *dev = &i2c->dev; |
| 75 | − struct regulator_dev *rdev = NULL; | |
| 68 | + struct regulator_dev *rdev; | |
| 76 | 69 | struct regulator_config config = { }; |
| 70 | + struct regmap *regmap; | |
| 77 | 71 | unsigned int reg, vsel; |
| 72 | + u32 fixed_voltage; | |
| 78 | 73 | int error; |
| 79 | 74 | |
| 80 | − chip = devm_kzalloc(&i2c->dev, sizeof(struct sy8106a), GFP_KERNEL); | |
| 81 | − if (!chip) | |
| 82 | − return -ENOMEM; | |
| 83 | − | |
| 84 | 75 | error = of_property_read_u32(dev->of_node, "silergy,fixed-microvolt", |
| 85 | − &chip->fixed_voltage); | |
| 76 | + &fixed_voltage); | |
| 86 | 77 | if (error) |
| 87 | 78 | return error; |
| 88 | 79 | |
| 89 | − if (chip->fixed_voltage < SY8106A_MIN_MV * 1000 || | |
| 90 | − chip->fixed_voltage > SY8106A_MAX_MV * 1000) | |
| 80 | + if (fixed_voltage < SY8106A_MIN_MV * 1000 || | |
| 81 | + fixed_voltage > SY8106A_MAX_MV * 1000) | |
| 91 | 82 | return -EINVAL; |
| 92 | 83 | |
| 93 | − chip->regmap = devm_regmap_init_i2c(i2c, &sy8106a_regmap_config); | |
| 94 | − if (IS_ERR(chip->regmap)) { | |
| 95 | − error = PTR_ERR(chip->regmap); | |
| 84 | + regmap = devm_regmap_init_i2c(i2c, &sy8106a_regmap_config); | |
| 85 | + if (IS_ERR(regmap)) { | |
| 86 | + error = PTR_ERR(regmap); | |
| 96 | 87 | dev_err(dev, "Failed to allocate register map: %d\n", error); |
| 97 | 88 | return error; |
| 98 | 89 | } |
| 99 | 90 | |
| 100 | 91 | config.dev = &i2c->dev; |
| 101 | − config.regmap = chip->regmap; | |
| 102 | − config.driver_data = chip; | |
| 92 | + config.regmap = regmap; | |
| 103 | 93 | |
| 104 | 94 | config.of_node = dev->of_node; |
| 105 | 95 | config.init_data = of_get_regulator_init_data(dev, dev->of_node, |
| @@ -109,15 +99,15 @@ static int sy8106a_i2c_probe(struct i2c_client *i2c, · 3 unmodified lines | ||
| 109 | 99 | return -ENOMEM; |
| 110 | 100 | |
| 111 | 101 | /* Ensure GO_BIT is enabled when probing */ |
| 112 | − error = regmap_read(chip->regmap, SY8106A_REG_VOUT1_SEL, ®); | |
| 102 | + error = regmap_read(regmap, SY8106A_REG_VOUT1_SEL, ®); | |
| 113 | 103 | if (error) |
| 114 | 104 | return error; |
| 115 | 105 | |
| 116 | 106 | if (!(reg & SY8106A_GO_BIT)) { |
| 117 | − vsel = (chip->fixed_voltage / 1000 - SY8106A_MIN_MV) / | |
| 107 | + vsel = (fixed_voltage / 1000 - SY8106A_MIN_MV) / | |
| 118 | 108 | SY8106A_STEP_MV; |
| 119 | 109 | |
| 120 | − error = regmap_write(chip->regmap, SY8106A_REG_VOUT1_SEL, | |
| 110 | + error = regmap_write(regmap, SY8106A_REG_VOUT1_SEL, | |
| 121 | 111 | vsel | SY8106A_GO_BIT); |
| 122 | 112 | if (error) |
| 123 | 113 | return error; |
| @@ -131,10 +121,6 @@ static int sy8106a_i2c_probe(struct i2c_client *i2c, · 7 unmodified lines | ||
| 131 | 121 | return error; |
| 132 | 122 | } |
| 133 | 123 | |
| 134 | − chip->rdev = rdev; | |
| 135 | − | |
| 136 | − i2c_set_clientdata(i2c, chip); | |
| 137 | − | |
| 138 | 124 | return 0; |
| 139 | 125 | } |
| 140 | 126 | |
| @@ -115,7 +115,6 @@ static struct tps_info tps6507x_pmic_regs[] = { · 114 unmodified lines | ||
| 115 | 115 | struct tps6507x_pmic { |
| 116 | 116 | struct regulator_desc desc[TPS6507X_NUM_REGULATOR]; |
| 117 | 117 | struct tps6507x_dev *mfd; |
| 118 | − struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR]; | |
| 119 | 118 | struct tps_info *info[TPS6507X_NUM_REGULATOR]; |
| 120 | 119 | struct mutex io_lock; |
| 121 | 120 | }; |
| @@ -349,7 +348,7 @@ static int tps6507x_pmic_set_voltage_sel(struct regulator_dev *dev, · 227 unmodified lines | ||
| 349 | 348 | return tps6507x_pmic_reg_write(tps, reg, data); |
| 350 | 349 | } |
| 351 | 350 | |
| 352 | −static struct regulator_ops tps6507x_pmic_ops = { | |
| 351 | +static const struct regulator_ops tps6507x_pmic_ops = { | |
| 353 | 352 | .is_enabled = tps6507x_pmic_is_enabled, |
| 354 | 353 | .enable = tps6507x_pmic_enable, |
| 355 | 354 | .disable = tps6507x_pmic_disable, |
| @@ -359,66 +358,20 @@ static struct regulator_ops tps6507x_pmic_ops = { · 3 unmodified lines | ||
| 359 | 358 | .map_voltage = regulator_map_voltage_ascend, |
| 360 | 359 | }; |
| 361 | 360 | |
| 362 | −static struct of_regulator_match tps6507x_matches[] = { | |
| 363 | − { .name = "VDCDC1"}, | |
| 364 | − { .name = "VDCDC2"}, | |
| 365 | − { .name = "VDCDC3"}, | |
| 366 | − { .name = "LDO1"}, | |
| 367 | − { .name = "LDO2"}, | |
| 368 | −}; | |
| 369 | − | |
| 370 | −static struct tps6507x_board *tps6507x_parse_dt_reg_data( | |
| 371 | − struct platform_device *pdev, | |
| 372 | − struct of_regulator_match **tps6507x_reg_matches) | |
| 361 | +static int tps6507x_pmic_of_parse_cb(struct device_node *np, | |
| 362 | + const struct regulator_desc *desc, | |
| 363 | + struct regulator_config *config) | |
| 373 | 364 | { |
| 374 | − struct tps6507x_board *tps_board; | |
| 375 | − struct device_node *np = pdev->dev.parent->of_node; | |
| 376 | − struct device_node *regulators; | |
| 377 | − struct of_regulator_match *matches; | |
| 378 | − struct regulator_init_data *reg_data; | |
| 379 | − int idx = 0, count, ret; | |
| 380 | − | |
| 381 | − tps_board = devm_kzalloc(&pdev->dev, sizeof(*tps_board), | |
| 382 | − GFP_KERNEL); | |
| 383 | − if (!tps_board) | |
| 384 | − return NULL; | |
| 385 | − | |
| 386 | − regulators = of_get_child_by_name(np, "regulators"); | |
| 387 | − if (!regulators) { | |
| 388 | − dev_err(&pdev->dev, "regulator node not found\n"); | |
| 389 | − return NULL; | |
| 390 | − } | |
| 391 | − | |
| 392 | − count = ARRAY_SIZE(tps6507x_matches); | |
| 393 | − matches = tps6507x_matches; | |
| 394 | − | |
| 395 | − ret = of_regulator_match(&pdev->dev, regulators, matches, count); | |
| 396 | − of_node_put(regulators); | |
| 397 | − if (ret < 0) { | |
| 398 | − dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", | |
| 399 | − ret); | |
| 400 | − return NULL; | |
| 401 | − } | |
| 365 | + struct tps6507x_pmic *tps = config->driver_data; | |
| 366 | + struct tps_info *info = tps->info[desc->id]; | |
| 367 | + u32 prop; | |
| 368 | + int ret; | |
| 402 | 369 | |
| 403 | − *tps6507x_reg_matches = matches; | |
| 404 | − | |
| 405 | − reg_data = devm_kzalloc(&pdev->dev, (sizeof(struct regulator_init_data) | |
| 406 | − * TPS6507X_NUM_REGULATOR), GFP_KERNEL); | |
| 407 | − if (!reg_data) | |
| 408 | − return NULL; | |
| 409 | − | |
| 410 | − tps_board->tps6507x_pmic_init_data = reg_data; | |
| 411 | − | |
| 412 | − for (idx = 0; idx < count; idx++) { | |
| 413 | − if (!matches[idx].init_data || !matches[idx].of_node) | |
| 414 | − continue; | |
| 415 | − | |
| 416 | − memcpy(®_data[idx], matches[idx].init_data, | |
| 417 | − sizeof(struct regulator_init_data)); | |
| 418 | − | |
| 419 | − } | |
| 370 | + ret = of_property_read_u32(np, "ti,defdcdc_default", &prop); | |
| 371 | + if (!ret) | |
| 372 | + info->defdcdc_default = prop; | |
| 420 | 373 | |
| 421 | − return tps_board; | |
| 374 | + return 0; | |
| 422 | 375 | } |
| 423 | 376 | |
| 424 | 377 | static int tps6507x_pmic_probe(struct platform_device *pdev) |
| @@ -426,14 +379,11 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 426 | 379 | struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); |
| 427 | 380 | struct tps_info *info = &tps6507x_pmic_regs[0]; |
| 428 | 381 | struct regulator_config config = { }; |
| 429 | − struct regulator_init_data *init_data; | |
| 382 | + struct regulator_init_data *init_data = NULL; | |
| 430 | 383 | struct regulator_dev *rdev; |
| 431 | 384 | struct tps6507x_pmic *tps; |
| 432 | 385 | struct tps6507x_board *tps_board; |
| 433 | − struct of_regulator_match *tps6507x_reg_matches = NULL; | |
| 434 | 386 | int i; |
| 435 | − int error; | |
| 436 | − unsigned int prop; | |
| 437 | 387 | |
| 438 | 388 | /** |
| 439 | 389 | * tps_board points to pmic related constants |
| @@ -441,20 +391,8 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 441 | 391 | */ |
| 442 | 392 | |
| 443 | 393 | tps_board = dev_get_platdata(tps6507x_dev->dev); |
| 444 | − if (IS_ENABLED(CONFIG_OF) && !tps_board && | |
| 445 | − tps6507x_dev->dev->of_node) | |
| 446 | − tps_board = tps6507x_parse_dt_reg_data(pdev, | |
| 447 | − &tps6507x_reg_matches); | |
| 448 | − if (!tps_board) | |
| 449 | − return -EINVAL; | |
| 450 | − | |
| 451 | − /** | |
| 452 | − * init_data points to array of regulator_init structures | |
| 453 | − * coming from the board-evm file. | |
| 454 | − */ | |
| 455 | − init_data = tps_board->tps6507x_pmic_init_data; | |
| 456 | − if (!init_data) | |
| 457 | − return -EINVAL; | |
| 394 | + if (tps_board) | |
| 395 | + init_data = tps_board->tps6507x_pmic_init_data; | |
| 458 | 396 | |
| 459 | 397 | tps = devm_kzalloc(&pdev->dev, sizeof(*tps), GFP_KERNEL); |
| 460 | 398 | if (!tps) |
| @@ -468,13 +406,16 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 468 | 406 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) { |
| 469 | 407 | /* Register the regulators */ |
| 470 | 408 | tps->info[i] = info; |
| 471 | − if (init_data->driver_data) { | |
| 409 | + if (init_data && init_data->driver_data) { | |
| 472 | 410 | struct tps6507x_reg_platform_data *data = |
| 473 | 411 | init_data->driver_data; |
| 474 | − tps->info[i]->defdcdc_default = data->defdcdc_default; | |
| 412 | + info->defdcdc_default = data->defdcdc_default; | |
| 475 | 413 | } |
| 476 | 414 | |
| 477 | 415 | tps->desc[i].name = info->name; |
| 416 | + tps->desc[i].of_match = of_match_ptr(info->name); | |
| 417 | + tps->desc[i].regulators_node = of_match_ptr("regulators"); | |
| 418 | + tps->desc[i].of_parse_cb = tps6507x_pmic_of_parse_cb; | |
| 478 | 419 | tps->desc[i].id = i; |
| 479 | 420 | tps->desc[i].n_voltages = info->table_len; |
| 480 | 421 | tps->desc[i].volt_table = info->table; |
| @@ -486,17 +427,6 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 486 | 427 | config.init_data = init_data; |
| 487 | 428 | config.driver_data = tps; |
| 488 | 429 | |
| 489 | − if (tps6507x_reg_matches) { | |
| 490 | − error = of_property_read_u32( | |
| 491 | − tps6507x_reg_matches[i].of_node, | |
| 492 | − "ti,defdcdc_default", &prop); | |
| 493 | − | |
| 494 | − if (!error) | |
| 495 | − tps->info[i]->defdcdc_default = prop; | |
| 496 | − | |
| 497 | − config.of_node = tps6507x_reg_matches[i].of_node; | |
| 498 | − } | |
| 499 | − | |
| 500 | 430 | rdev = devm_regulator_register(&pdev->dev, &tps->desc[i], |
| 501 | 431 | &config); |
| 502 | 432 | if (IS_ERR(rdev)) { |
| @@ -505,9 +435,6 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 505 | 435 | pdev->name); |
| 506 | 436 | return PTR_ERR(rdev); |
| 507 | 437 | } |
| 508 | − | |
| 509 | − /* Save regulator for cleanup */ | |
| 510 | − tps->rdev[i] = rdev; | |
| 511 | 438 | } |
| 512 | 439 | |
| 513 | 440 | tps6507x_dev->pmic = tps; |
| @@ -90,8 +90,8 @@ static const struct regulator_linear_range tps65086_buck345_25mv_ranges[] = { · 89 unmodified lines | ||
| 90 | 90 | static const struct regulator_linear_range tps65086_ldoa1_ranges[] = { |
| 91 | 91 | REGULATOR_LINEAR_RANGE(1350000, 0x0, 0x0, 0), |
| 92 | 92 | REGULATOR_LINEAR_RANGE(1500000, 0x1, 0x7, 100000), |
| 93 | − REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xA, 100000), | |
| 94 | − REGULATOR_LINEAR_RANGE(2700000, 0xB, 0xD, 150000), | |
| 93 | + REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xB, 100000), | |
| 94 | + REGULATOR_LINEAR_RANGE(2850000, 0xC, 0xD, 150000), | |
| 95 | 95 | REGULATOR_LINEAR_RANGE(3300000, 0xE, 0xE, 0), |
| 96 | 96 | }; |
| 97 | 97 | |
| @@ -55,10 +55,7 @@ struct tps65132_reg_pdata { · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | struct tps65132_regulator { |
| 57 | 57 | struct device *dev; |
| 58 | − struct regmap *rmap; | |
| 59 | − struct regulator_desc *rdesc[TPS65132_MAX_REGULATORS]; | |
| 60 | 58 | struct tps65132_reg_pdata reg_pdata[TPS65132_MAX_REGULATORS]; |
| 61 | − struct regulator_dev *rdev[TPS65132_MAX_REGULATORS]; | |
| 62 | 59 | }; |
| 63 | 60 | |
| 64 | 61 | static int tps65132_regulator_enable(struct regulator_dev *rdev) |
| @@ -120,7 +117,7 @@ static int tps65132_regulator_is_enabled(struct regulator_dev *rdev) · 55 unmodified lines | ||
| 120 | 117 | return 1; |
| 121 | 118 | } |
| 122 | 119 | |
| 123 | −static struct regulator_ops tps65132_regulator_ops = { | |
| 120 | +static const struct regulator_ops tps65132_regulator_ops = { | |
| 124 | 121 | .enable = tps65132_regulator_enable, |
| 125 | 122 | .disable = tps65132_regulator_disable, |
| 126 | 123 | .is_enabled = tps65132_regulator_is_enabled, |
| @@ -196,7 +193,7 @@ static int tps65132_of_parse_cb(struct device_node *np, · 69 unmodified lines | ||
| 196 | 193 | .owner = THIS_MODULE, \ |
| 197 | 194 | } |
| 198 | 195 | |
| 199 | −static struct regulator_desc tps_regs_desc[TPS65132_MAX_REGULATORS] = { | |
| 196 | +static const struct regulator_desc tps_regs_desc[TPS65132_MAX_REGULATORS] = { | |
| 200 | 197 | TPS65132_REGULATOR_DESC(VPOS, outp), |
| 201 | 198 | TPS65132_REGULATOR_DESC(VNEG, outn), |
| 202 | 199 | }; |
| @@ -225,6 +222,8 @@ static int tps65132_probe(struct i2c_client *client, · 22 unmodified lines | ||
| 225 | 222 | { |
| 226 | 223 | struct device *dev = &client->dev; |
| 227 | 224 | struct tps65132_regulator *tps; |
| 225 | + struct regulator_dev *rdev; | |
| 226 | + struct regmap *rmap; | |
| 228 | 227 | struct regulator_config config = { }; |
| 229 | 228 | int id; |
| 230 | 229 | int ret; |
| @@ -233,9 +232,9 @@ static int tps65132_probe(struct i2c_client *client, · 2 unmodified lines | ||
| 233 | 232 | if (!tps) |
| 234 | 233 | return -ENOMEM; |
| 235 | 234 | |
| 236 | − tps->rmap = devm_regmap_init_i2c(client, &tps65132_regmap_config); | |
| 237 | − if (IS_ERR(tps->rmap)) { | |
| 238 | − ret = PTR_ERR(tps->rmap); | |
| 235 | + rmap = devm_regmap_init_i2c(client, &tps65132_regmap_config); | |
| 236 | + if (IS_ERR(rmap)) { | |
| 237 | + ret = PTR_ERR(rmap); | |
| 239 | 238 | dev_err(dev, "regmap init failed: %d\n", ret); |
| 240 | 239 | return ret; |
| 241 | 240 | } |
| @@ -244,18 +243,16 @@ static int tps65132_probe(struct i2c_client *client, · 2 unmodified lines | ||
| 244 | 243 | tps->dev = dev; |
| 245 | 244 | |
| 246 | 245 | for (id = 0; id < TPS65132_MAX_REGULATORS; ++id) { |
| 247 | − tps->rdesc[id] = &tps_regs_desc[id]; | |
| 248 | − | |
| 249 | − config.regmap = tps->rmap; | |
| 246 | + config.regmap = rmap; | |
| 250 | 247 | config.dev = dev; |
| 251 | 248 | config.driver_data = tps; |
| 252 | 249 | |
| 253 | − tps->rdev[id] = devm_regulator_register(dev, | |
| 254 | − tps->rdesc[id], &config); | |
| 255 | − if (IS_ERR(tps->rdev[id])) { | |
| 256 | − ret = PTR_ERR(tps->rdev[id]); | |
| 250 | + rdev = devm_regulator_register(dev, &tps_regs_desc[id], | |
| 251 | + &config); | |
| 252 | + if (IS_ERR(rdev)) { | |
| 253 | + ret = PTR_ERR(rdev); | |
| 257 | 254 | dev_err(dev, "regulator %s register failed: %d\n", |
| 258 | − tps->rdesc[id]->name, ret); | |
| 255 | + tps_regs_desc[id].name, ret); | |
| 259 | 256 | return ret; |
| 260 | 257 | } |
| 261 | 258 | } |
| @@ -58,8 +58,7 @@ static const unsigned int LDO1_VSEL_table[] = { · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | static const struct regulator_linear_range tps65217_uv1_ranges[] = { |
| 60 | 60 | REGULATOR_LINEAR_RANGE(900000, 0, 24, 25000), |
| 61 | − REGULATOR_LINEAR_RANGE(1550000, 25, 30, 50000), | |
| 62 | − REGULATOR_LINEAR_RANGE(1850000, 31, 52, 50000), | |
| 61 | + REGULATOR_LINEAR_RANGE(1550000, 25, 52, 50000), | |
| 63 | 62 | REGULATOR_LINEAR_RANGE(3000000, 53, 55, 100000), |
| 64 | 63 | REGULATOR_LINEAR_RANGE(3300000, 56, 63, 0), |
| 65 | 64 | }; |
| @@ -150,7 +149,7 @@ static int tps65217_pmic_set_suspend_disable(struct regulator_dev *dev) · 84 unmodified lines | ||
| 150 | 149 | } |
| 151 | 150 | |
| 152 | 151 | /* Operations permitted on DCDCx, LDO2, LDO3 and LDO4 */ |
| 153 | −static struct regulator_ops tps65217_pmic_ops = { | |
| 152 | +static const struct regulator_ops tps65217_pmic_ops = { | |
| 154 | 153 | .is_enabled = regulator_is_enabled_regmap, |
| 155 | 154 | .enable = tps65217_pmic_enable, |
| 156 | 155 | .disable = tps65217_pmic_disable, |
| @@ -163,7 +162,7 @@ static struct regulator_ops tps65217_pmic_ops = { · 6 unmodified lines | ||
| 163 | 162 | }; |
| 164 | 163 | |
| 165 | 164 | /* Operations permitted on LDO1 */ |
| 166 | −static struct regulator_ops tps65217_pmic_ldo1_ops = { | |
| 165 | +static const struct regulator_ops tps65217_pmic_ldo1_ops = { | |
| 167 | 166 | .is_enabled = regulator_is_enabled_regmap, |
| 168 | 167 | .enable = tps65217_pmic_enable, |
| 169 | 168 | .disable = tps65217_pmic_disable, |
| @@ -29,7 +29,8 @@ · 28 unmodified lines | ||
| 29 | 29 | #include <linux/mfd/tps65218.h> |
| 30 | 30 | |
| 31 | 31 | #define TPS65218_REGULATOR(_name, _of, _id, _type, _ops, _n, _vr, _vm, _er, \ |
| 32 | − _em, _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm) \ | |
| 32 | + _em, _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm, \ | |
| 33 | + _ct, _ncl) \ | |
| 33 | 34 | { \ |
| 34 | 35 | .name = _name, \ |
| 35 | 36 | .of_match = _of, \ |
| @@ -42,6 +43,8 @@ · 6 unmodified lines | ||
| 42 | 43 | .vsel_mask = _vm, \ |
| 43 | 44 | .csel_reg = _cr, \ |
| 44 | 45 | .csel_mask = _cm, \ |
| 46 | + .curr_table = _ct, \ | |
| 47 | + .n_current_limits = _ncl, \ | |
| 45 | 48 | .enable_reg = _er, \ |
| 46 | 49 | .enable_mask = _em, \ |
| 47 | 50 | .volt_table = NULL, \ |
| @@ -162,7 +165,7 @@ static int tps65218_pmic_set_suspend_disable(struct regulator_dev *dev) · 114 unmodified lines | ||
| 162 | 165 | } |
| 163 | 166 | |
| 164 | 167 | /* Operations permitted on DCDC1, DCDC2 */ |
| 165 | −static struct regulator_ops tps65218_dcdc12_ops = { | |
| 168 | +static const struct regulator_ops tps65218_dcdc12_ops = { | |
| 166 | 169 | .is_enabled = regulator_is_enabled_regmap, |
| 167 | 170 | .enable = tps65218_pmic_enable, |
| 168 | 171 | .disable = tps65218_pmic_disable, |
| @@ -176,7 +179,7 @@ static struct regulator_ops tps65218_dcdc12_ops = { · 7 unmodified lines | ||
| 176 | 179 | }; |
| 177 | 180 | |
| 178 | 181 | /* Operations permitted on DCDC3, DCDC4 and LDO1 */ |
| 179 | −static struct regulator_ops tps65218_ldo1_dcdc34_ops = { | |
| 182 | +static const struct regulator_ops tps65218_ldo1_dcdc34_ops = { | |
| 180 | 183 | .is_enabled = regulator_is_enabled_regmap, |
| 181 | 184 | .enable = tps65218_pmic_enable, |
| 182 | 185 | .disable = tps65218_pmic_disable, |
| @@ -188,8 +191,7 @@ static struct regulator_ops tps65218_ldo1_dcdc34_ops = { · 5 unmodified lines | ||
| 188 | 191 | .set_suspend_disable = tps65218_pmic_set_suspend_disable, |
| 189 | 192 | }; |
| 190 | 193 | |
| 191 | −static const int ls3_currents[] = { 100000, 200000, 500000, 1000000 }; | |
| 192 | − | |
| 194 | +static const unsigned int ls3_currents[] = { 100000, 200000, 500000, 1000000 }; | |
| 193 | 195 | |
| 194 | 196 | static int tps65218_pmic_set_input_current_lim(struct regulator_dev *dev, |
| 195 | 197 | int lim_uA) |
| @@ -229,33 +231,17 @@ static int tps65218_pmic_set_current_limit(struct regulator_dev *dev, · 33 unmodified lines | ||
| 229 | 231 | TPS65218_PROTECT_L1); |
| 230 | 232 | } |
| 231 | 233 | |
| 232 | −static int tps65218_pmic_get_current_limit(struct regulator_dev *dev) | |
| 233 | −{ | |
| 234 | − int retval; | |
| 235 | − unsigned int index; | |
| 236 | − struct tps65218 *tps = rdev_get_drvdata(dev); | |
| 237 | − | |
| 238 | − retval = regmap_read(tps->regmap, dev->desc->csel_reg, &index); | |
| 239 | − if (retval < 0) | |
| 240 | − return retval; | |
| 241 | − | |
| 242 | − index = (index & dev->desc->csel_mask) >> | |
| 243 | − __builtin_ctz(dev->desc->csel_mask); | |
| 244 | − | |
| 245 | − return ls3_currents[index]; | |
| 246 | −} | |
| 247 | − | |
| 248 | −static struct regulator_ops tps65218_ls23_ops = { | |
| 234 | +static const struct regulator_ops tps65218_ls23_ops = { | |
| 249 | 235 | .is_enabled = regulator_is_enabled_regmap, |
| 250 | 236 | .enable = tps65218_pmic_enable, |
| 251 | 237 | .disable = tps65218_pmic_disable, |
| 252 | 238 | .set_input_current_limit = tps65218_pmic_set_input_current_lim, |
| 253 | 239 | .set_current_limit = tps65218_pmic_set_current_limit, |
| 254 | − .get_current_limit = tps65218_pmic_get_current_limit, | |
| 240 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 255 | 241 | }; |
| 256 | 242 | |
| 257 | 243 | /* Operations permitted on DCDC5, DCDC6 */ |
| 258 | −static struct regulator_ops tps65218_dcdc56_pmic_ops = { | |
| 244 | +static const struct regulator_ops tps65218_dcdc56_pmic_ops = { | |
| 259 | 245 | .is_enabled = regulator_is_enabled_regmap, |
| 260 | 246 | .enable = tps65218_pmic_enable, |
| 261 | 247 | .disable = tps65218_pmic_disable, |
| @@ -270,53 +256,57 @@ static const struct regulator_desc regulators[] = { · 8 unmodified lines | ||
| 270 | 256 | TPS65218_CONTROL_DCDC1_MASK, TPS65218_REG_ENABLE1, |
| 271 | 257 | TPS65218_ENABLE1_DC1_EN, 0, 0, dcdc1_dcdc2_ranges, |
| 272 | 258 | 2, 4000, 0, TPS65218_REG_SEQ3, |
| 273 | − TPS65218_SEQ3_DC1_SEQ_MASK), | |
| 259 | + TPS65218_SEQ3_DC1_SEQ_MASK, NULL, 0), | |
| 274 | 260 | TPS65218_REGULATOR("DCDC2", "regulator-dcdc2", TPS65218_DCDC_2, |
| 275 | 261 | REGULATOR_VOLTAGE, tps65218_dcdc12_ops, 64, |
| 276 | 262 | TPS65218_REG_CONTROL_DCDC2, |
| 277 | 263 | TPS65218_CONTROL_DCDC2_MASK, TPS65218_REG_ENABLE1, |
| 278 | 264 | TPS65218_ENABLE1_DC2_EN, 0, 0, dcdc1_dcdc2_ranges, |
| 279 | 265 | 2, 4000, 0, TPS65218_REG_SEQ3, |
| 280 | − TPS65218_SEQ3_DC2_SEQ_MASK), | |
| 266 | + TPS65218_SEQ3_DC2_SEQ_MASK, NULL, 0), | |
| 281 | 267 | TPS65218_REGULATOR("DCDC3", "regulator-dcdc3", TPS65218_DCDC_3, |
| 282 | 268 | REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 64, |
| 283 | 269 | TPS65218_REG_CONTROL_DCDC3, |
| 284 | 270 | TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, |
| 285 | 271 | TPS65218_ENABLE1_DC3_EN, 0, 0, ldo1_dcdc3_ranges, 2, |
| 286 | − 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK), | |
| 272 | + 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK, | |
| 273 | + NULL, 0), | |
| 287 | 274 | TPS65218_REGULATOR("DCDC4", "regulator-dcdc4", TPS65218_DCDC_4, |
| 288 | 275 | REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 53, |
| 289 | 276 | TPS65218_REG_CONTROL_DCDC4, |
| 290 | 277 | TPS65218_CONTROL_DCDC4_MASK, TPS65218_REG_ENABLE1, |
| 291 | 278 | TPS65218_ENABLE1_DC4_EN, 0, 0, dcdc4_ranges, 2, |
| 292 | − 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC4_SEQ_MASK), | |
| 279 | + 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC4_SEQ_MASK, | |
| 280 | + NULL, 0), | |
| 293 | 281 | TPS65218_REGULATOR("DCDC5", "regulator-dcdc5", TPS65218_DCDC_5, |
| 294 | 282 | REGULATOR_VOLTAGE, tps65218_dcdc56_pmic_ops, 1, -1, |
| 295 | 283 | -1, TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC5_EN, 0, |
| 296 | 284 | 0, NULL, 0, 0, 1000000, TPS65218_REG_SEQ5, |
| 297 | − TPS65218_SEQ5_DC5_SEQ_MASK), | |
| 285 | + TPS65218_SEQ5_DC5_SEQ_MASK, NULL, 0), | |
| 298 | 286 | TPS65218_REGULATOR("DCDC6", "regulator-dcdc6", TPS65218_DCDC_6, |
| 299 | 287 | REGULATOR_VOLTAGE, tps65218_dcdc56_pmic_ops, 1, -1, |
| 300 | 288 | -1, TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC6_EN, 0, |
| 301 | 289 | 0, NULL, 0, 0, 1800000, TPS65218_REG_SEQ5, |
| 302 | − TPS65218_SEQ5_DC6_SEQ_MASK), | |
| 290 | + TPS65218_SEQ5_DC6_SEQ_MASK, NULL, 0), | |
| 303 | 291 | TPS65218_REGULATOR("LDO1", "regulator-ldo1", TPS65218_LDO_1, |
| 304 | 292 | REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 64, |
| 305 | 293 | TPS65218_REG_CONTROL_LDO1, |
| 306 | 294 | TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, |
| 307 | 295 | TPS65218_ENABLE2_LDO1_EN, 0, 0, ldo1_dcdc3_ranges, |
| 308 | 296 | 2, 0, 0, TPS65218_REG_SEQ6, |
| 309 | − TPS65218_SEQ6_LDO1_SEQ_MASK), | |
| 297 | + TPS65218_SEQ6_LDO1_SEQ_MASK, NULL, 0), | |
| 310 | 298 | TPS65218_REGULATOR("LS2", "regulator-ls2", TPS65218_LS_2, |
| 311 | 299 | REGULATOR_CURRENT, tps65218_ls23_ops, 0, 0, 0, |
| 312 | 300 | TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS2_EN, |
| 313 | 301 | TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS2ILIM_MASK, |
| 314 | − NULL, 0, 0, 0, 0, 0), | |
| 302 | + NULL, 0, 0, 0, 0, 0, ls3_currents, | |
| 303 | + ARRAY_SIZE(ls3_currents)), | |
| 315 | 304 | TPS65218_REGULATOR("LS3", "regulator-ls3", TPS65218_LS_3, |
| 316 | 305 | REGULATOR_CURRENT, tps65218_ls23_ops, 0, 0, 0, |
| 317 | 306 | TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS3_EN, |
| 318 | 307 | TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS3ILIM_MASK, |
| 319 | − NULL, 0, 0, 0, 0, 0), | |
| 308 | + NULL, 0, 0, 0, 0, 0, ls3_currents, | |
| 309 | + ARRAY_SIZE(ls3_currents)), | |
| 320 | 310 | }; |
| 321 | 311 | |
| 322 | 312 | static int tps65218_regulator_probe(struct platform_device *pdev) |
| @@ -137,7 +137,6 @@ struct tps6524x { · 136 unmodified lines | ||
| 137 | 137 | struct spi_device *spi; |
| 138 | 138 | struct mutex lock; |
| 139 | 139 | struct regulator_desc desc[N_REGULATORS]; |
| 140 | − struct regulator_dev *rdev[N_REGULATORS]; | |
| 141 | 140 | }; |
| 142 | 141 | |
| 143 | 142 | static int __read_reg(struct tps6524x *hw, int reg) |
| @@ -565,7 +564,7 @@ static int is_supply_enabled(struct regulator_dev *rdev) · 421 unmodified lines | ||
| 565 | 564 | return read_field(hw, &info->enable); |
| 566 | 565 | } |
| 567 | 566 | |
| 568 | −static struct regulator_ops regulator_ops = { | |
| 567 | +static const struct regulator_ops regulator_ops = { | |
| 569 | 568 | .is_enabled = is_supply_enabled, |
| 570 | 569 | .enable = enable_supply, |
| 571 | 570 | .disable = disable_supply, |
| @@ -584,6 +583,7 @@ static int pmic_probe(struct spi_device *spi) · 12 unmodified lines | ||
| 584 | 583 | const struct supply_info *info = supply_info; |
| 585 | 584 | struct regulator_init_data *init_data; |
| 586 | 585 | struct regulator_config config = { }; |
| 586 | + struct regulator_dev *rdev; | |
| 587 | 587 | int i; |
| 588 | 588 | |
| 589 | 589 | init_data = dev_get_platdata(dev); |
| @@ -616,10 +616,9 @@ static int pmic_probe(struct spi_device *spi) · 26 unmodified lines | ||
| 616 | 616 | config.init_data = init_data; |
| 617 | 617 | config.driver_data = hw; |
| 618 | 618 | |
| 619 | − hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i], | |
| 620 | − &config); | |
| 621 | − if (IS_ERR(hw->rdev[i])) | |
| 622 | − return PTR_ERR(hw->rdev[i]); | |
| 619 | + rdev = devm_regulator_register(dev, &hw->desc[i], &config); | |
| 620 | + if (IS_ERR(rdev)) | |
| 621 | + return PTR_ERR(rdev); | |
| 623 | 622 | } |
| 624 | 623 | |
| 625 | 624 | return 0; |
| @@ -1,27 +1,13 @@ | ||
| 1 | −/* | |
| 2 | − * tps80031-regulator.c -- TI TPS80031 regulator driver. | |
| 3 | − * | |
| 4 | − * Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power | |
| 5 | − * Management with Power Path and Battery Charger. | |
| 6 | − * | |
| 7 | − * Copyright (c) 2012, NVIDIA Corporation. | |
| 8 | − * | |
| 9 | − * Author: Laxman Dewangan <ldewangan@nvidia.com> | |
| 10 | − * | |
| 11 | − * This program is free software; you can redistribute it and/or | |
| 12 | − * modify it under the terms of the GNU General Public License as | |
| 13 | − * published by the Free Software Foundation version 2. | |
| 14 | − * | |
| 15 | − * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, | |
| 16 | − * whether express or implied; without even the implied warranty of | |
| 17 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 18 | − * General Public License for more details. | |
| 19 | − * | |
| 20 | − * You should have received a copy of the GNU General Public License | |
| 21 | − * along with this program; if not, write to the Free Software | |
| 22 | − * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
| 23 | − * 02111-1307, USA | |
| 24 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// tps80031-regulator.c -- TI TPS80031 regulator driver. | |
| 4 | +// | |
| 5 | +// Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power | |
| 6 | +// Management with Power Path and Battery Charger. | |
| 7 | +// | |
| 8 | +// Copyright (c) 2012, NVIDIA Corporation. | |
| 9 | +// | |
| 10 | +// Author: Laxman Dewangan <ldewangan@nvidia.com> | |
| 25 | 11 | |
| 26 | 12 | #include <linux/delay.h> |
| 27 | 13 | #include <linux/err.h> |
| @@ -85,7 +71,6 @@ struct tps80031_regulator_info { · 57 unmodified lines | ||
| 85 | 71 | |
| 86 | 72 | struct tps80031_regulator { |
| 87 | 73 | struct device *dev; |
| 88 | − struct regulator_dev *rdev; | |
| 89 | 74 | struct tps80031_regulator_info *rinfo; |
| 90 | 75 | |
| 91 | 76 | u8 device_flags; |
| @@ -155,7 +140,7 @@ static int tps80031_reg_disable(struct regulator_dev *rdev) · 63 unmodified lines | ||
| 155 | 140 | } |
| 156 | 141 | |
| 157 | 142 | /* DCDC voltages for the selector of 58 to 63 */ |
| 158 | −static int tps80031_dcdc_voltages[4][5] = { | |
| 143 | +static const int tps80031_dcdc_voltages[4][5] = { | |
| 159 | 144 | { 1350, 1500, 1800, 1900, 2100}, |
| 160 | 145 | { 1350, 1500, 1800, 1900, 2100}, |
| 161 | 146 | { 2084, 2315, 2778, 2932, 3241}, |
| @@ -378,7 +363,7 @@ static int tps80031_vbus_disable(struct regulator_dev *rdev) · 216 unmodified lines | ||
| 378 | 363 | return ret; |
| 379 | 364 | } |
| 380 | 365 | |
| 381 | −static struct regulator_ops tps80031_dcdc_ops = { | |
| 366 | +static const struct regulator_ops tps80031_dcdc_ops = { | |
| 382 | 367 | .list_voltage = tps80031_dcdc_list_voltage, |
| 383 | 368 | .set_voltage_sel = tps80031_dcdc_set_voltage_sel, |
| 384 | 369 | .get_voltage_sel = tps80031_dcdc_get_voltage_sel, |
| @@ -387,7 +372,7 @@ static struct regulator_ops tps80031_dcdc_ops = { · 2 unmodified lines | ||
| 387 | 372 | .is_enabled = tps80031_reg_is_enabled, |
| 388 | 373 | }; |
| 389 | 374 | |
| 390 | −static struct regulator_ops tps80031_ldo_ops = { | |
| 375 | +static const struct regulator_ops tps80031_ldo_ops = { | |
| 391 | 376 | .list_voltage = tps80031_ldo_list_voltage, |
| 392 | 377 | .map_voltage = tps80031_ldo_map_voltage, |
| 393 | 378 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| @@ -397,18 +382,18 @@ static struct regulator_ops tps80031_ldo_ops = { · 3 unmodified lines | ||
| 397 | 382 | .is_enabled = tps80031_reg_is_enabled, |
| 398 | 383 | }; |
| 399 | 384 | |
| 400 | −static struct regulator_ops tps80031_vbus_sw_ops = { | |
| 385 | +static const struct regulator_ops tps80031_vbus_sw_ops = { | |
| 401 | 386 | .list_voltage = regulator_list_voltage_linear, |
| 402 | 387 | .enable = tps80031_vbus_enable, |
| 403 | 388 | .disable = tps80031_vbus_disable, |
| 404 | 389 | .is_enabled = tps80031_vbus_is_enabled, |
| 405 | 390 | }; |
| 406 | 391 | |
| 407 | −static struct regulator_ops tps80031_vbus_hw_ops = { | |
| 392 | +static const struct regulator_ops tps80031_vbus_hw_ops = { | |
| 408 | 393 | .list_voltage = regulator_list_voltage_linear, |
| 409 | 394 | }; |
| 410 | 395 | |
| 411 | −static struct regulator_ops tps80031_ext_reg_ops = { | |
| 396 | +static const struct regulator_ops tps80031_ext_reg_ops = { | |
| 412 | 397 | .list_voltage = regulator_list_voltage_linear, |
| 413 | 398 | .enable = tps80031_reg_enable, |
| 414 | 399 | .disable = tps80031_reg_disable, |
| @@ -736,7 +721,6 @@ static int tps80031_regulator_probe(struct platform_device *pdev) · 321 unmodified lines | ||
| 736 | 721 | ri->rinfo->desc.name); |
| 737 | 722 | return PTR_ERR(rdev); |
| 738 | 723 | } |
| 739 | − ri->rdev = rdev; | |
| 740 | 724 | } |
| 741 | 725 | |
| 742 | 726 | platform_set_drvdata(pdev, pmic); |
| @@ -392,7 +392,7 @@ static int twl4030ldo_get_voltage_sel(struct regulator_dev *rdev) · 391 unmodified lines | ||
| 392 | 392 | return vsel; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | −static struct regulator_ops twl4030ldo_ops = { | |
| 395 | +static const struct regulator_ops twl4030ldo_ops = { | |
| 396 | 396 | .list_voltage = twl4030ldo_list_voltage, |
| 397 | 397 | |
| 398 | 398 | .set_voltage_sel = twl4030ldo_set_voltage_sel, |
| @@ -430,14 +430,14 @@ static int twl4030smps_get_voltage(struct regulator_dev *rdev) · 31 unmodified lines | ||
| 430 | 430 | return vsel * 12500 + 600000; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | −static struct regulator_ops twl4030smps_ops = { | |
| 433 | +static const struct regulator_ops twl4030smps_ops = { | |
| 434 | 434 | .set_voltage = twl4030smps_set_voltage, |
| 435 | 435 | .get_voltage = twl4030smps_get_voltage, |
| 436 | 436 | }; |
| 437 | 437 | |
| 438 | 438 | /*----------------------------------------------------------------------*/ |
| 439 | 439 | |
| 440 | −static struct regulator_ops twl4030fixed_ops = { | |
| 440 | +static const struct regulator_ops twl4030fixed_ops = { | |
| 441 | 441 | .list_voltage = regulator_list_voltage_linear, |
| 442 | 442 | |
| 443 | 443 | .enable = twl4030reg_enable, |
| @@ -334,10 +334,8 @@ static int vctrl_init_vtable(struct platform_device *pdev) · 333 unmodified lines | ||
| 334 | 334 | ctrl_uV = regulator_list_voltage(ctrl_reg, i); |
| 335 | 335 | |
| 336 | 336 | if (ctrl_uV < vrange_ctrl->min_uV || |
| 337 | − ctrl_uV > vrange_ctrl->max_uV) { | |
| 337 | + ctrl_uV > vrange_ctrl->max_uV) | |
| 338 | 338 | rdesc->n_voltages--; |
| 339 | − continue; | |
| 340 | − } | |
| 341 | 339 | } |
| 342 | 340 | |
| 343 | 341 | if (rdesc->n_voltages == 0) { |
| @@ -1,15 +1,6 @@ | ||
| 1 | −/* | |
| 2 | − * This program is free software; you can redistribute it and/or modify | |
| 3 | − * it under the terms of the GNU General Public License version 2 as | |
| 4 | − * published by the Free Software Foundation. | |
| 5 | − * | |
| 6 | − * This program is distributed in the hope that it will be useful, | |
| 7 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 8 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 9 | − * GNU General Public License for more details. | |
| 10 | − * | |
| 11 | − * Copyright (C) 2012 ARM Limited | |
| 12 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +// | |
| 3 | +// Copyright (C) 2012 ARM Limited | |
| 13 | 4 | |
| 14 | 5 | #define DRVNAME "vexpress-regulator" |
| 15 | 6 | #define pr_fmt(fmt) DRVNAME ": " fmt |
| @@ -23,17 +14,10 @@ · 7 unmodified lines | ||
| 23 | 14 | #include <linux/regulator/of_regulator.h> |
| 24 | 15 | #include <linux/vexpress.h> |
| 25 | 16 | |
| 26 | −struct vexpress_regulator { | |
| 27 | − struct regulator_desc desc; | |
| 28 | − struct regulator_dev *regdev; | |
| 29 | − struct regmap *regmap; | |
| 30 | −}; | |
| 31 | − | |
| 32 | 17 | static int vexpress_regulator_get_voltage(struct regulator_dev *regdev) |
| 33 | 18 | { |
| 34 | − struct vexpress_regulator *reg = rdev_get_drvdata(regdev); | |
| 35 | − u32 uV; | |
| 36 | − int err = regmap_read(reg->regmap, 0, &uV); | |
| 19 | + unsigned int uV; | |
| 20 | + int err = regmap_read(regdev->regmap, 0, &uV); | |
| 37 | 21 | |
| 38 | 22 | return err ? err : uV; |
| 39 | 23 | } |
| @@ -41,60 +25,58 @@ static int vexpress_regulator_get_voltage(struct regulator_dev *regdev) · 1 unmodified line | ||
| 41 | 25 | static int vexpress_regulator_set_voltage(struct regulator_dev *regdev, |
| 42 | 26 | int min_uV, int max_uV, unsigned *selector) |
| 43 | 27 | { |
| 44 | − struct vexpress_regulator *reg = rdev_get_drvdata(regdev); | |
| 45 | − | |
| 46 | − return regmap_write(reg->regmap, 0, min_uV); | |
| 28 | + return regmap_write(regdev->regmap, 0, min_uV); | |
| 47 | 29 | } |
| 48 | 30 | |
| 49 | −static struct regulator_ops vexpress_regulator_ops_ro = { | |
| 31 | +static const struct regulator_ops vexpress_regulator_ops_ro = { | |
| 50 | 32 | .get_voltage = vexpress_regulator_get_voltage, |
| 51 | 33 | }; |
| 52 | 34 | |
| 53 | −static struct regulator_ops vexpress_regulator_ops = { | |
| 35 | +static const struct regulator_ops vexpress_regulator_ops = { | |
| 54 | 36 | .get_voltage = vexpress_regulator_get_voltage, |
| 55 | 37 | .set_voltage = vexpress_regulator_set_voltage, |
| 56 | 38 | }; |
| 57 | 39 | |
| 58 | 40 | static int vexpress_regulator_probe(struct platform_device *pdev) |
| 59 | 41 | { |
| 60 | − struct vexpress_regulator *reg; | |
| 42 | + struct regulator_desc *desc; | |
| 61 | 43 | struct regulator_init_data *init_data; |
| 62 | 44 | struct regulator_config config = { }; |
| 45 | + struct regulator_dev *rdev; | |
| 46 | + struct regmap *regmap; | |
| 63 | 47 | |
| 64 | − reg = devm_kzalloc(&pdev->dev, sizeof(*reg), GFP_KERNEL); | |
| 65 | − if (!reg) | |
| 48 | + desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL); | |
| 49 | + if (!desc) | |
| 66 | 50 | return -ENOMEM; |
| 67 | 51 | |
| 68 | − reg->regmap = devm_regmap_init_vexpress_config(&pdev->dev); | |
| 69 | − if (IS_ERR(reg->regmap)) | |
| 70 | − return PTR_ERR(reg->regmap); | |
| 52 | + regmap = devm_regmap_init_vexpress_config(&pdev->dev); | |
| 53 | + if (IS_ERR(regmap)) | |
| 54 | + return PTR_ERR(regmap); | |
| 71 | 55 | |
| 72 | − reg->desc.name = dev_name(&pdev->dev); | |
| 73 | − reg->desc.type = REGULATOR_VOLTAGE; | |
| 74 | − reg->desc.owner = THIS_MODULE; | |
| 75 | − reg->desc.continuous_voltage_range = true; | |
| 56 | + desc->name = dev_name(&pdev->dev); | |
| 57 | + desc->type = REGULATOR_VOLTAGE; | |
| 58 | + desc->owner = THIS_MODULE; | |
| 59 | + desc->continuous_voltage_range = true; | |
| 76 | 60 | |
| 77 | 61 | init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, |
| 78 | − ®->desc); | |
| 62 | + desc); | |
| 79 | 63 | if (!init_data) |
| 80 | 64 | return -EINVAL; |
| 81 | 65 | |
| 82 | 66 | init_data->constraints.apply_uV = 0; |
| 83 | 67 | if (init_data->constraints.min_uV && init_data->constraints.max_uV) |
| 84 | − reg->desc.ops = &vexpress_regulator_ops; | |
| 68 | + desc->ops = &vexpress_regulator_ops; | |
| 85 | 69 | else |
| 86 | − reg->desc.ops = &vexpress_regulator_ops_ro; | |
| 70 | + desc->ops = &vexpress_regulator_ops_ro; | |
| 87 | 71 | |
| 72 | + config.regmap = regmap; | |
| 88 | 73 | config.dev = &pdev->dev; |
| 89 | 74 | config.init_data = init_data; |
| 90 | − config.driver_data = reg; | |
| 91 | 75 | config.of_node = pdev->dev.of_node; |
| 92 | 76 | |
| 93 | − reg->regdev = devm_regulator_register(&pdev->dev, ®->desc, &config); | |
| 94 | − if (IS_ERR(reg->regdev)) | |
| 95 | − return PTR_ERR(reg->regdev); | |
| 96 | − | |
| 97 | − platform_set_drvdata(pdev, reg); | |
| 77 | + rdev = devm_regulator_register(&pdev->dev, desc, &config); | |
| 78 | + if (IS_ERR(rdev)) | |
| 79 | + return PTR_ERR(rdev); | |
| 98 | 80 | |
| 99 | 81 | return 0; |
| 100 | 82 | } |
| @@ -1,15 +1,10 @@ | ||
| 1 | −/* | |
| 2 | − * wm831x-dcdc.c -- DC-DC buck convertor driver for the WM831x series | |
| 3 | − * | |
| 4 | − * Copyright 2009 Wolfson Microelectronics PLC. | |
| 5 | − * | |
| 6 | − * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 7 | − * | |
| 8 | − * This program is free software; you can redistribute it and/or modify it | |
| 9 | − * under the terms of the GNU General Public License as published by the | |
| 10 | − * Free Software Foundation; either version 2 of the License, or (at your | |
| 11 | − * option) any later version. | |
| 12 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// wm831x-dcdc.c -- DC-DC buck converter driver for the WM831x series | |
| 4 | +// | |
| 5 | +// Copyright 2009 Wolfson Microelectronics PLC. | |
| 6 | +// | |
| 7 | +// Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 13 | 8 | |
| 14 | 9 | #include <linux/module.h> |
| 15 | 10 | #include <linux/moduleparam.h> |
| @@ -183,9 +178,11 @@ static irqreturn_t wm831x_dcdc_uv_irq(int irq, void *data) · 167 unmodified lines | ||
| 183 | 178 | { |
| 184 | 179 | struct wm831x_dcdc *dcdc = data; |
| 185 | 180 | |
| 181 | + regulator_lock(dcdc->regulator); | |
| 186 | 182 | regulator_notifier_call_chain(dcdc->regulator, |
| 187 | 183 | REGULATOR_EVENT_UNDER_VOLTAGE, |
| 188 | 184 | NULL); |
| 185 | + regulator_unlock(dcdc->regulator); | |
| 189 | 186 | |
| 190 | 187 | return IRQ_HANDLED; |
| 191 | 188 | } |
| @@ -194,9 +191,11 @@ static irqreturn_t wm831x_dcdc_oc_irq(int irq, void *data) · 2 unmodified lines | ||
| 194 | 191 | { |
| 195 | 192 | struct wm831x_dcdc *dcdc = data; |
| 196 | 193 | |
| 194 | + regulator_lock(dcdc->regulator); | |
| 197 | 195 | regulator_notifier_call_chain(dcdc->regulator, |
| 198 | 196 | REGULATOR_EVENT_OVER_CURRENT, |
| 199 | 197 | NULL); |
| 198 | + regulator_unlock(dcdc->regulator); | |
| 200 | 199 | |
| 201 | 200 | return IRQ_HANDLED; |
| 202 | 201 | } |
| @@ -1,15 +1,10 @@ | ||
| 1 | −/* | |
| 2 | − * wm831x-isink.c -- Current sink driver for the WM831x series | |
| 3 | − * | |
| 4 | − * Copyright 2009 Wolfson Microelectronics PLC. | |
| 5 | − * | |
| 6 | − * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 7 | − * | |
| 8 | − * This program is free software; you can redistribute it and/or modify it | |
| 9 | − * under the terms of the GNU General Public License as published by the | |
| 10 | − * Free Software Foundation; either version 2 of the License, or (at your | |
| 11 | − * option) any later version. | |
| 12 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// wm831x-isink.c -- Current sink driver for the WM831x series | |
| 4 | +// | |
| 5 | +// Copyright 2009 Wolfson Microelectronics PLC. | |
| 6 | +// | |
| 7 | +// Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 13 | 8 | |
| 14 | 9 | #include <linux/module.h> |
| 15 | 10 | #include <linux/moduleparam.h> |
| @@ -92,57 +87,23 @@ static int wm831x_isink_is_enabled(struct regulator_dev *rdev) · 76 unmodified lines | ||
| 92 | 87 | return 0; |
| 93 | 88 | } |
| 94 | 89 | |
| 95 | −static int wm831x_isink_set_current(struct regulator_dev *rdev, | |
| 96 | − int min_uA, int max_uA) | |
| 97 | −{ | |
| 98 | − struct wm831x_isink *isink = rdev_get_drvdata(rdev); | |
| 99 | − struct wm831x *wm831x = isink->wm831x; | |
| 100 | − int ret, i; | |
| 101 | − | |
| 102 | − for (i = 0; i < ARRAY_SIZE(wm831x_isinkv_values); i++) { | |
| 103 | − int val = wm831x_isinkv_values[i]; | |
| 104 | − if (min_uA <= val && val <= max_uA) { | |
| 105 | − ret = wm831x_set_bits(wm831x, isink->reg, | |
| 106 | − WM831X_CS1_ISEL_MASK, i); | |
| 107 | − return ret; | |
| 108 | − } | |
| 109 | − } | |
| 110 | − | |
| 111 | − return -EINVAL; | |
| 112 | −} | |
| 113 | − | |
| 114 | −static int wm831x_isink_get_current(struct regulator_dev *rdev) | |
| 115 | −{ | |
| 116 | − struct wm831x_isink *isink = rdev_get_drvdata(rdev); | |
| 117 | − struct wm831x *wm831x = isink->wm831x; | |
| 118 | − int ret; | |
| 119 | − | |
| 120 | − ret = wm831x_reg_read(wm831x, isink->reg); | |
| 121 | − if (ret < 0) | |
| 122 | − return ret; | |
| 123 | − | |
| 124 | − ret &= WM831X_CS1_ISEL_MASK; | |
| 125 | − if (ret > WM831X_ISINK_MAX_ISEL) | |
| 126 | − ret = WM831X_ISINK_MAX_ISEL; | |
| 127 | − | |
| 128 | − return wm831x_isinkv_values[ret]; | |
| 129 | −} | |
| 130 | − | |
| 131 | 90 | static const struct regulator_ops wm831x_isink_ops = { |
| 132 | 91 | .is_enabled = wm831x_isink_is_enabled, |
| 133 | 92 | .enable = wm831x_isink_enable, |
| 134 | 93 | .disable = wm831x_isink_disable, |
| 135 | − .set_current_limit = wm831x_isink_set_current, | |
| 136 | − .get_current_limit = wm831x_isink_get_current, | |
| 94 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 95 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 137 | 96 | }; |
| 138 | 97 | |
| 139 | 98 | static irqreturn_t wm831x_isink_irq(int irq, void *data) |
| 140 | 99 | { |
| 141 | 100 | struct wm831x_isink *isink = data; |
| 142 | 101 | |
| 102 | + regulator_lock(isink->regulator); | |
| 143 | 103 | regulator_notifier_call_chain(isink->regulator, |
| 144 | 104 | REGULATOR_EVENT_OVER_CURRENT, |
| 145 | 105 | NULL); |
| 106 | + regulator_unlock(isink->regulator); | |
| 146 | 107 | |
| 147 | 108 | return IRQ_HANDLED; |
| 148 | 109 | } |
| @@ -187,10 +148,15 @@ static int wm831x_isink_probe(struct platform_device *pdev) · 38 unmodified lines | ||
| 187 | 148 | isink->desc.ops = &wm831x_isink_ops; |
| 188 | 149 | isink->desc.type = REGULATOR_CURRENT; |
| 189 | 150 | isink->desc.owner = THIS_MODULE; |
| 151 | + isink->desc.curr_table = wm831x_isinkv_values, | |
| 152 | + isink->desc.n_current_limits = ARRAY_SIZE(wm831x_isinkv_values), | |
| 153 | + isink->desc.csel_reg = isink->reg, | |
| 154 | + isink->desc.csel_mask = WM831X_CS1_ISEL_MASK, | |
| 190 | 155 | |
| 191 | 156 | config.dev = pdev->dev.parent; |
| 192 | 157 | config.init_data = pdata->isink[id]; |
| 193 | 158 | config.driver_data = isink; |
| 159 | + config.regmap = wm831x->regmap; | |
| 194 | 160 | |
| 195 | 161 | isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc, |
| 196 | 162 | &config); |
| @@ -1,15 +1,10 @@ | ||
| 1 | −/* | |
| 2 | − * wm831x-ldo.c -- LDO driver for the WM831x series | |
| 3 | − * | |
| 4 | − * Copyright 2009 Wolfson Microelectronics PLC. | |
| 5 | − * | |
| 6 | − * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 7 | − * | |
| 8 | − * This program is free software; you can redistribute it and/or modify it | |
| 9 | − * under the terms of the GNU General Public License as published by the | |
| 10 | − * Free Software Foundation; either version 2 of the License, or (at your | |
| 11 | − * option) any later version. | |
| 12 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// wm831x-ldo.c -- LDO driver for the WM831x series | |
| 4 | +// | |
| 5 | +// Copyright 2009 Wolfson Microelectronics PLC. | |
| 6 | +// | |
| 7 | +// Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 13 | 8 | |
| 14 | 9 | #include <linux/module.h> |
| 15 | 10 | #include <linux/moduleparam.h> |
| @@ -51,9 +46,11 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data) · 35 unmodified lines | ||
| 51 | 46 | { |
| 52 | 47 | struct wm831x_ldo *ldo = data; |
| 53 | 48 | |
| 49 | + regulator_lock(ldo->regulator); | |
| 54 | 50 | regulator_notifier_call_chain(ldo->regulator, |
| 55 | 51 | REGULATOR_EVENT_UNDER_VOLTAGE, |
| 56 | 52 | NULL); |
| 53 | + regulator_unlock(ldo->regulator); | |
| 57 | 54 | |
| 58 | 55 | return IRQ_HANDLED; |
| 59 | 56 | } |
| @@ -1,16 +1,11 @@ | ||
| 1 | −/* | |
| 2 | − * wm8350.c -- Voltage and current regulation for the Wolfson WM8350 PMIC | |
| 3 | − * | |
| 4 | − * Copyright 2007, 2008 Wolfson Microelectronics PLC. | |
| 5 | − * | |
| 6 | − * Author: Liam Girdwood | |
| 7 | − * linux@wolfsonmicro.com | |
| 8 | − * | |
| 9 | − * This program is free software; you can redistribute it and/or modify it | |
| 10 | − * under the terms of the GNU General Public License as published by the | |
| 11 | − * Free Software Foundation; either version 2 of the License, or (at your | |
| 12 | − * option) any later version. | |
| 13 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// wm8350.c -- Voltage and current regulation for the Wolfson WM8350 PMIC | |
| 4 | +// | |
| 5 | +// Copyright 2007, 2008 Wolfson Microelectronics PLC. | |
| 6 | +// | |
| 7 | +// Author: Liam Girdwood | |
| 8 | +// linux@wolfsonmicro.com | |
| 14 | 9 | |
| 15 | 10 | #include <linux/module.h> |
| 16 | 11 | #include <linux/moduleparam.h> |
| @@ -28,7 +23,7 @@ · 11 unmodified lines | ||
| 28 | 23 | #define WM8350_DCDC_MAX_VSEL 0x66 |
| 29 | 24 | |
| 30 | 25 | /* Microamps */ |
| 31 | −static const int isink_cur[] = { | |
| 26 | +static const unsigned int isink_cur[] = { | |
| 32 | 27 | 4, |
| 33 | 28 | 5, |
| 34 | 29 | 6, |
| @@ -95,73 +90,6 @@ static const int isink_cur[] = { · 60 unmodified lines | ||
| 95 | 90 | 223191 |
| 96 | 91 | }; |
| 97 | 92 | |
| 98 | −static int get_isink_val(int min_uA, int max_uA, u16 *setting) | |
| 99 | −{ | |
| 100 | − int i; | |
| 101 | − | |
| 102 | − for (i = 0; i < ARRAY_SIZE(isink_cur); i++) { | |
| 103 | − if (min_uA <= isink_cur[i] && max_uA >= isink_cur[i]) { | |
| 104 | − *setting = i; | |
| 105 | − return 0; | |
| 106 | − } | |
| 107 | − } | |
| 108 | − return -EINVAL; | |
| 109 | −} | |
| 110 | − | |
| 111 | −static int wm8350_isink_set_current(struct regulator_dev *rdev, int min_uA, | |
| 112 | − int max_uA) | |
| 113 | −{ | |
| 114 | − struct wm8350 *wm8350 = rdev_get_drvdata(rdev); | |
| 115 | − int isink = rdev_get_id(rdev); | |
| 116 | − u16 val, setting; | |
| 117 | − int ret; | |
| 118 | − | |
| 119 | − ret = get_isink_val(min_uA, max_uA, &setting); | |
| 120 | − if (ret != 0) | |
| 121 | − return ret; | |
| 122 | − | |
| 123 | − switch (isink) { | |
| 124 | − case WM8350_ISINK_A: | |
| 125 | − val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_A) & | |
| 126 | − ~WM8350_CS1_ISEL_MASK; | |
| 127 | − wm8350_reg_write(wm8350, WM8350_CURRENT_SINK_DRIVER_A, | |
| 128 | − val | setting); | |
| 129 | − break; | |
| 130 | − case WM8350_ISINK_B: | |
| 131 | − val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_B) & | |
| 132 | − ~WM8350_CS1_ISEL_MASK; | |
| 133 | − wm8350_reg_write(wm8350, WM8350_CURRENT_SINK_DRIVER_B, | |
| 134 | − val | setting); | |
| 135 | − break; | |
| 136 | − default: | |
| 137 | − return -EINVAL; | |
| 138 | − } | |
| 139 | − | |
| 140 | − return 0; | |
| 141 | −} | |
| 142 | − | |
| 143 | −static int wm8350_isink_get_current(struct regulator_dev *rdev) | |
| 144 | −{ | |
| 145 | − struct wm8350 *wm8350 = rdev_get_drvdata(rdev); | |
| 146 | − int isink = rdev_get_id(rdev); | |
| 147 | − u16 val; | |
| 148 | − | |
| 149 | − switch (isink) { | |
| 150 | − case WM8350_ISINK_A: | |
| 151 | − val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_A) & | |
| 152 | − WM8350_CS1_ISEL_MASK; | |
| 153 | − break; | |
| 154 | − case WM8350_ISINK_B: | |
| 155 | − val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_B) & | |
| 156 | − WM8350_CS1_ISEL_MASK; | |
| 157 | − break; | |
| 158 | − default: | |
| 159 | − return 0; | |
| 160 | − } | |
| 161 | − | |
| 162 | − return isink_cur[val]; | |
| 163 | −} | |
| 164 | − | |
| 165 | 93 | /* turn on ISINK followed by DCDC */ |
| 166 | 94 | static int wm8350_isink_enable(struct regulator_dev *rdev) |
| 167 | 95 | { |
| @@ -982,8 +910,8 @@ static const struct regulator_ops wm8350_ldo_ops = { · 814 unmodified lines | ||
| 982 | 910 | }; |
| 983 | 911 | |
| 984 | 912 | static const struct regulator_ops wm8350_isink_ops = { |
| 985 | − .set_current_limit = wm8350_isink_set_current, | |
| 986 | − .get_current_limit = wm8350_isink_get_current, | |
| 913 | + .set_current_limit = regulator_set_current_limit_regmap, | |
| 914 | + .get_current_limit = regulator_get_current_limit_regmap, | |
| 987 | 915 | .enable = wm8350_isink_enable, |
| 988 | 916 | .disable = wm8350_isink_disable, |
| 989 | 917 | .is_enabled = wm8350_isink_is_enabled, |
| @@ -1138,6 +1066,10 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = { · 148 unmodified lines | ||
| 1138 | 1066 | .irq = WM8350_IRQ_CS1, |
| 1139 | 1067 | .type = REGULATOR_CURRENT, |
| 1140 | 1068 | .owner = THIS_MODULE, |
| 1069 | + .curr_table = isink_cur, | |
| 1070 | + .n_current_limits = ARRAY_SIZE(isink_cur), | |
| 1071 | + .csel_reg = WM8350_CURRENT_SINK_DRIVER_A, | |
| 1072 | + .csel_mask = WM8350_CS1_ISEL_MASK, | |
| 1141 | 1073 | }, |
| 1142 | 1074 | { |
| 1143 | 1075 | .name = "ISINKB", |
| @@ -1146,6 +1078,10 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = { · 2 unmodified lines | ||
| 1146 | 1078 | .irq = WM8350_IRQ_CS2, |
| 1147 | 1079 | .type = REGULATOR_CURRENT, |
| 1148 | 1080 | .owner = THIS_MODULE, |
| 1081 | + .curr_table = isink_cur, | |
| 1082 | + .n_current_limits = ARRAY_SIZE(isink_cur), | |
| 1083 | + .csel_reg = WM8350_CURRENT_SINK_DRIVER_B, | |
| 1084 | + .csel_mask = WM8350_CS2_ISEL_MASK, | |
| 1149 | 1085 | }, |
| 1150 | 1086 | }; |
| 1151 | 1087 | |
| @@ -1,16 +1,10 @@ | ||
| 1 | −/* | |
| 2 | − * Regulator support for WM8400 | |
| 3 | − * | |
| 4 | − * Copyright 2008 Wolfson Microelectronics PLC. | |
| 5 | − * | |
| 6 | − * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 7 | − * | |
| 8 | − * This program is free software; you can redistribute it and/or | |
| 9 | − * modify it under the terms of the GNU General Public License as | |
| 10 | − * published by the Free Software Foundation; either version 2 of the | |
| 11 | − * License, or (at your option) any later version. | |
| 12 | − * | |
| 13 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// Regulator support for WM8400 | |
| 4 | +// | |
| 5 | +// Copyright 2008 Wolfson Microelectronics PLC. | |
| 6 | +// | |
| 7 | +// Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 14 | 8 | |
| 15 | 9 | #include <linux/bug.h> |
| 16 | 10 | #include <linux/err.h> |
| @@ -36,13 +30,12 @@ static const struct regulator_ops wm8400_ldo_ops = { · 19 unmodified lines | ||
| 36 | 30 | |
| 37 | 31 | static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev) |
| 38 | 32 | { |
| 39 | − struct wm8400 *wm8400 = rdev_get_drvdata(dev); | |
| 33 | + struct regmap *rmap = rdev_get_regmap(dev); | |
| 40 | 34 | int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2; |
| 41 | 35 | u16 data[2]; |
| 42 | 36 | int ret; |
| 43 | 37 | |
| 44 | − ret = wm8400_block_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset, 2, | |
| 45 | − data); | |
| 38 | + ret = regmap_bulk_read(rmap, WM8400_DCDC1_CONTROL_1 + offset, data, 2); | |
| 46 | 39 | if (ret != 0) |
| 47 | 40 | return 0; |
| 48 | 41 | |
| @@ -63,36 +56,36 @@ static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev) · 14 unmodified lines | ||
| 63 | 56 | |
| 64 | 57 | static int wm8400_dcdc_set_mode(struct regulator_dev *dev, unsigned int mode) |
| 65 | 58 | { |
| 66 | − struct wm8400 *wm8400 = rdev_get_drvdata(dev); | |
| 59 | + struct regmap *rmap = rdev_get_regmap(dev); | |
| 67 | 60 | int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2; |
| 68 | 61 | int ret; |
| 69 | 62 | |
| 70 | 63 | switch (mode) { |
| 71 | 64 | case REGULATOR_MODE_FAST: |
| 72 | 65 | /* Datasheet: active with force PWM */ |
| 73 | − ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset, | |
| 66 | + ret = regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_2 + offset, | |
| 74 | 67 | WM8400_DC1_FRC_PWM, WM8400_DC1_FRC_PWM); |
| 75 | 68 | if (ret != 0) |
| 76 | 69 | return ret; |
| 77 | 70 | |
| 78 | − return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, | |
| 71 | + return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset, | |
| 79 | 72 | WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP, |
| 80 | 73 | WM8400_DC1_ACTIVE); |
| 81 | 74 | |
| 82 | 75 | case REGULATOR_MODE_NORMAL: |
| 83 | 76 | /* Datasheet: active */ |
| 84 | − ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset, | |
| 77 | + ret = regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_2 + offset, | |
| 85 | 78 | WM8400_DC1_FRC_PWM, 0); |
| 86 | 79 | if (ret != 0) |
| 87 | 80 | return ret; |
| 88 | 81 | |
| 89 | − return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, | |
| 82 | + return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset, | |
| 90 | 83 | WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP, |
| 91 | 84 | WM8400_DC1_ACTIVE); |
| 92 | 85 | |
| 93 | 86 | case REGULATOR_MODE_IDLE: |
| 94 | 87 | /* Datasheet: standby */ |
| 95 | − return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, | |
| 88 | + return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset, | |
| 96 | 89 | WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP, 0); |
| 97 | 90 | default: |
| 98 | 91 | return -EINVAL; |
| @@ -195,7 +188,7 @@ static struct regulator_desc regulators[] = { · 96 unmodified lines | ||
| 195 | 188 | .id = WM8400_DCDC2, |
| 196 | 189 | .ops = &wm8400_dcdc_ops, |
| 197 | 190 | .enable_reg = WM8400_DCDC2_CONTROL_1, |
| 198 | − .enable_mask = WM8400_DC1_ENA_MASK, | |
| 191 | + .enable_mask = WM8400_DC2_ENA_MASK, | |
| 199 | 192 | .n_voltages = WM8400_DC2_VSEL_MASK + 1, |
| 200 | 193 | .vsel_reg = WM8400_DCDC2_CONTROL_1, |
| 201 | 194 | .vsel_mask = WM8400_DC2_VSEL_MASK, |
| @@ -1,15 +1,10 @@ | ||
| 1 | −/* | |
| 2 | − * wm8994-regulator.c -- Regulator driver for the WM8994 | |
| 3 | − * | |
| 4 | − * Copyright 2009 Wolfson Microelectronics PLC. | |
| 5 | − * | |
| 6 | − * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 7 | − * | |
| 8 | − * This program is free software; you can redistribute it and/or modify it | |
| 9 | − * under the terms of the GNU General Public License as published by the | |
| 10 | − * Free Software Foundation; either version 2 of the License, or (at your | |
| 11 | − * option) any later version. | |
| 12 | − */ | |
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 2 | +// | |
| 3 | +// wm8994-regulator.c -- Regulator driver for the WM8994 | |
| 4 | +// | |
| 5 | +// Copyright 2009 Wolfson Microelectronics PLC. | |
| 6 | +// | |
| 7 | +// Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
| 13 | 8 | |
| 14 | 9 | #include <linux/module.h> |
| 15 | 10 | #include <linux/moduleparam.h> |
| @@ -553,7 +553,6 @@ struct palmas_pmic { · 552 unmodified lines | ||
| 553 | 553 | struct palmas *palmas; |
| 554 | 554 | struct device *dev; |
| 555 | 555 | struct regulator_desc desc[PALMAS_NUM_REGS]; |
| 556 | − struct regulator_dev *rdev[PALMAS_NUM_REGS]; | |
| 557 | 556 | struct mutex mutex; |
| 558 | 557 | |
| 559 | 558 | int smps123; |
| @@ -1213,6 +1213,6 @@ · 1212 unmodified lines | ||
| 1213 | 1213 | #define WM831X_LDO1_OK_WIDTH 1 /* LDO1_OK */ |
| 1214 | 1214 | |
| 1215 | 1215 | #define WM831X_ISINK_MAX_ISEL 55 |
| 1216 | −extern int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1]; | |
| 1216 | +extern const unsigned int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1]; | |
| 1217 | 1217 | |
| 1218 | 1218 | #endif |
| @@ -923,12 +923,4 @@ struct wm8400 { · 922 unmodified lines | ||
| 923 | 923 | #define WM8400_LINE_CMP_VTHD_SHIFT 0 /* LINE_CMP_VTHD - [3:0] */ |
| 924 | 924 | #define WM8400_LINE_CMP_VTHD_WIDTH 4 /* LINE_CMP_VTHD - [3:0] */ |
| 925 | 925 | |
| 926 | −int wm8400_block_read(struct wm8400 *wm8400, u8 reg, int count, u16 *data); | |
| 927 | − | |
| 928 | −static inline int wm8400_set_bits(struct wm8400 *wm8400, u8 reg, | |
| 929 | − u16 mask, u16 val) | |
| 930 | −{ | |
| 931 | − return regmap_update_bits(wm8400->regmap, reg, mask, val); | |
| 932 | −} | |
| 933 | − | |
| 934 | 926 | #endif |
| @@ -478,6 +478,11 @@ static inline int regulator_is_supported_voltage(struct regulator *regulator, · 477 unmodified lines | ||
| 478 | 478 | return 0; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | +static inline unsigned int regulator_get_linear_step(struct regulator *regulator) | |
| 482 | +{ | |
| 483 | + return 0; | |
| 484 | +} | |
| 485 | + | |
| 481 | 486 | static inline int regulator_set_current_limit(struct regulator *regulator, |
| 482 | 487 | int min_uA, int max_uA) |
| 483 | 488 | { |
| @@ -1062,10 +1062,10 @@ static void anc_iir(struct snd_soc_component *component, unsigned int bnk, · 1061 unmodified lines | ||
| 1062 | 1062 | snd_soc_component_update_bits(component, AB8500_ANCCONF1, |
| 1063 | 1063 | BIT(AB8500_ANCCONF1_ANCIIRINIT), |
| 1064 | 1064 | BIT(AB8500_ANCCONF1_ANCIIRINIT)); |
| 1065 | − usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY); | |
| 1065 | + usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY*2); | |
| 1066 | 1066 | snd_soc_component_update_bits(component, AB8500_ANCCONF1, |
| 1067 | 1067 | BIT(AB8500_ANCCONF1_ANCIIRINIT), 0); |
| 1068 | − usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY); | |
| 1068 | + usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY*2); | |
| 1069 | 1069 | } else { |
| 1070 | 1070 | snd_soc_component_update_bits(component, AB8500_ANCCONF1, |
| 1071 | 1071 | BIT(AB8500_ANCCONF1_ANCIIRUPDATE), |