aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2013-06-24 06:50:16 -0400
committerMark Brown <broonie@linaro.org>2013-06-24 10:22:26 -0400
commit42dc30231ba35939213c33378c17cb81c31b0a37 (patch)
treef908d61307859878cc5d2e926c10cf08da2e3c61
parentdb892ff6c0f49708f13d9dff3957034f2f90e1c1 (diff)
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>
-rw-r--r--Documentation/devicetree/bindings/regulator/max8973-regulator.txt21
-rw-r--r--drivers/regulator/max8973-regulator.c37
2 files changed, 46 insertions, 12 deletions
diff --git a/Documentation/devicetree/bindings/regulator/max8973-regulator.txt b/Documentation/devicetree/bindings/regulator/max8973-regulator.txt
new file mode 100644
index 000000000000..8d38ab2acac5
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/max8973-regulator.txt
@@ -0,0 +1,21 @@
1* Maxim MAX8973 Voltage Regulator
2
3Required properties:
4
5- compatible: must be "maxium,max8973"
6- reg: the i2c slave address of the regulator. It should be 0x1b.
7
8Any standard regulator properties can be used to configure the single max8973
9DCDC.
10
11Example:
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 };
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index b2dbdd70cab1..0c5195a842e2 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -26,10 +26,12 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/of.h>
29#include <linux/platform_device.h> 30#include <linux/platform_device.h>
30#include <linux/regulator/driver.h> 31#include <linux/regulator/driver.h>
31#include <linux/regulator/machine.h> 32#include <linux/regulator/machine.h>
32#include <linux/regulator/max8973-regulator.h> 33#include <linux/regulator/max8973-regulator.h>
34#include <linux/regulator/of_regulator.h>
33#include <linux/gpio.h> 35#include <linux/gpio.h>
34#include <linux/i2c.h> 36#include <linux/i2c.h>
35#include <linux/slab.h> 37#include <linux/slab.h>
@@ -370,7 +372,8 @@ static int max8973_probe(struct i2c_client *client,
370 int ret; 372 int ret;
371 373
372 pdata = client->dev.platform_data; 374 pdata = client->dev.platform_data;
373 if (!pdata) { 375
376 if (!pdata && !client->dev.of_node) {
374 dev_err(&client->dev, "No Platform data"); 377 dev_err(&client->dev, "No Platform data");
375 return -EIO; 378 return -EIO;
376 } 379 }
@@ -400,7 +403,7 @@ static int max8973_probe(struct i2c_client *client,
400 max->desc.uV_step = MAX8973_VOLATGE_STEP; 403 max->desc.uV_step = MAX8973_VOLATGE_STEP;
401 max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; 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 max->desc.enable_reg = MAX8973_VOUT; 407 max->desc.enable_reg = MAX8973_VOUT;
405 max->desc.enable_mask = MAX8973_VOUT_ENABLE; 408 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
406 max->ops.enable = regulator_enable_regmap; 409 max->ops.enable = regulator_enable_regmap;
@@ -408,12 +411,17 @@ static int max8973_probe(struct i2c_client *client,
408 max->ops.is_enabled = regulator_is_enabled_regmap; 411 max->ops.is_enabled = regulator_is_enabled_regmap;
409 } 412 }
410 413
411 max->enable_external_control = pdata->enable_ext_control; 414 if (pdata) {
412 max->dvs_gpio = pdata->dvs_gpio; 415 max->dvs_gpio = pdata->dvs_gpio;
413 max->curr_gpio_val = pdata->dvs_def_state; 416 max->enable_external_control = pdata->enable_ext_control;
414 max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; 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 max->lru_index[0] = max->curr_vout_reg; 424 max->lru_index[0] = max->curr_vout_reg;
416 max->valid_dvs_gpio = false;
417 425
418 if (gpio_is_valid(max->dvs_gpio)) { 426 if (gpio_is_valid(max->dvs_gpio)) {
419 int gpio_flags; 427 int gpio_flags;
@@ -439,16 +447,21 @@ static int max8973_probe(struct i2c_client *client,
439 max->lru_index[i] = i; 447 max->lru_index[i] = i;
440 max->lru_index[0] = max->curr_vout_reg; 448 max->lru_index[0] = max->curr_vout_reg;
441 max->lru_index[max->curr_vout_reg] = 0; 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); 454 if (pdata) {
445 if (ret < 0) { 455 ret = max8973_init_dcdc(max, pdata);
446 dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); 456 if (ret < 0) {
447 return ret; 457 dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret);
458 return ret;
459 }
448 } 460 }
449 461
450 config.dev = &client->dev; 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 config.driver_data = max; 465 config.driver_data = max;
453 config.of_node = client->dev.of_node; 466 config.of_node = client->dev.of_node;
454 config.regmap = max->regmap; 467 config.regmap = max->regmap;