Commit 42dc30231ba35939213c33378c17cb81c31b0a37
Committed by
Mark Brown
1 parent
db892ff6c0
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
regulator: max8973: initial DT support
This patch adds primitive DT support to the max8973 regulator driver. None of the configuration parameters, supported in the platform data are yet available in DT, therefore no configuration is performed if booting with no platform data. This means, that DT instantiation can only be used on boards, where no run-time configuration of the chip is required. In such cases the driver can be used to scale its output voltage. In the future support for configuration parameters should be added. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Showing 2 changed files with 46 additions and 12 deletions Side-by-side Diff
Documentation/devicetree/bindings/regulator/max8973-regulator.txt
1 | +* Maxim MAX8973 Voltage Regulator | |
2 | + | |
3 | +Required properties: | |
4 | + | |
5 | +- compatible: must be "maxium,max8973" | |
6 | +- reg: the i2c slave address of the regulator. It should be 0x1b. | |
7 | + | |
8 | +Any standard regulator properties can be used to configure the single max8973 | |
9 | +DCDC. | |
10 | + | |
11 | +Example: | |
12 | + | |
13 | + max8973@1b { | |
14 | + compatible = "maxium,max8973"; | |
15 | + reg = <0x1b>; | |
16 | + | |
17 | + regulator-min-microvolt = <935000>; | |
18 | + regulator-max-microvolt = <1200000>; | |
19 | + regulator-boot-on; | |
20 | + regulator-always-on; | |
21 | + }; |
drivers/regulator/max8973-regulator.c
... | ... | @@ -26,10 +26,12 @@ |
26 | 26 | #include <linux/module.h> |
27 | 27 | #include <linux/init.h> |
28 | 28 | #include <linux/err.h> |
29 | +#include <linux/of.h> | |
29 | 30 | #include <linux/platform_device.h> |
30 | 31 | #include <linux/regulator/driver.h> |
31 | 32 | #include <linux/regulator/machine.h> |
32 | 33 | #include <linux/regulator/max8973-regulator.h> |
34 | +#include <linux/regulator/of_regulator.h> | |
33 | 35 | #include <linux/gpio.h> |
34 | 36 | #include <linux/i2c.h> |
35 | 37 | #include <linux/slab.h> |
... | ... | @@ -370,7 +372,8 @@ |
370 | 372 | int ret; |
371 | 373 | |
372 | 374 | pdata = client->dev.platform_data; |
373 | - if (!pdata) { | |
375 | + | |
376 | + if (!pdata && !client->dev.of_node) { | |
374 | 377 | dev_err(&client->dev, "No Platform data"); |
375 | 378 | return -EIO; |
376 | 379 | } |
... | ... | @@ -400,7 +403,7 @@ |
400 | 403 | max->desc.uV_step = MAX8973_VOLATGE_STEP; |
401 | 404 | max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; |
402 | 405 | |
403 | - if (!pdata->enable_ext_control) { | |
406 | + if (!pdata || !pdata->enable_ext_control) { | |
404 | 407 | max->desc.enable_reg = MAX8973_VOUT; |
405 | 408 | max->desc.enable_mask = MAX8973_VOUT_ENABLE; |
406 | 409 | max->ops.enable = regulator_enable_regmap; |
407 | 410 | |
... | ... | @@ -408,12 +411,17 @@ |
408 | 411 | max->ops.is_enabled = regulator_is_enabled_regmap; |
409 | 412 | } |
410 | 413 | |
411 | - max->enable_external_control = pdata->enable_ext_control; | |
412 | - max->dvs_gpio = pdata->dvs_gpio; | |
413 | - max->curr_gpio_val = pdata->dvs_def_state; | |
414 | - max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; | |
414 | + if (pdata) { | |
415 | + max->dvs_gpio = pdata->dvs_gpio; | |
416 | + max->enable_external_control = pdata->enable_ext_control; | |
417 | + max->curr_gpio_val = pdata->dvs_def_state; | |
418 | + max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; | |
419 | + } else { | |
420 | + max->dvs_gpio = -EINVAL; | |
421 | + max->curr_vout_reg = MAX8973_VOUT; | |
422 | + } | |
423 | + | |
415 | 424 | max->lru_index[0] = max->curr_vout_reg; |
416 | - max->valid_dvs_gpio = false; | |
417 | 425 | |
418 | 426 | if (gpio_is_valid(max->dvs_gpio)) { |
419 | 427 | int gpio_flags; |
420 | 428 | |
421 | 429 | |
... | ... | @@ -439,16 +447,21 @@ |
439 | 447 | max->lru_index[i] = i; |
440 | 448 | max->lru_index[0] = max->curr_vout_reg; |
441 | 449 | max->lru_index[max->curr_vout_reg] = 0; |
450 | + } else { | |
451 | + max->valid_dvs_gpio = false; | |
442 | 452 | } |
443 | 453 | |
444 | - ret = max8973_init_dcdc(max, pdata); | |
445 | - if (ret < 0) { | |
446 | - dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); | |
447 | - return ret; | |
454 | + if (pdata) { | |
455 | + ret = max8973_init_dcdc(max, pdata); | |
456 | + if (ret < 0) { | |
457 | + dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); | |
458 | + return ret; | |
459 | + } | |
448 | 460 | } |
449 | 461 | |
450 | 462 | config.dev = &client->dev; |
451 | - config.init_data = pdata->reg_init_data; | |
463 | + config.init_data = pdata ? pdata->reg_init_data : | |
464 | + of_get_regulator_init_data(&client->dev, client->dev.of_node); | |
452 | 465 | config.driver_data = max; |
453 | 466 | config.of_node = client->dev.of_node; |
454 | 467 | config.regmap = max->regmap; |