aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ban <james.ban.opensource@diasemi.com>2015-06-30 00:39:39 -0400
committerMark Brown <broonie@kernel.org>2015-07-13 14:11:24 -0400
commit7bd393543287b921f964a350166bf2866527a1b5 (patch)
tree8e5ec4221a7f2615e58571b1ef9c34a78958c047
parentd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff)
regulator: da9211: support da9215
This is a patch for supporting da9215 buck converter. Signed-off-by: James Ban <james.ban.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/regulator/da9211.txt32
-rw-r--r--drivers/regulator/Kconfig6
-rw-r--r--drivers/regulator/da9211-regulator.c40
-rw-r--r--drivers/regulator/da9211-regulator.h18
-rw-r--r--include/linux/regulator/da9211.h19
5 files changed, 81 insertions, 34 deletions
diff --git a/Documentation/devicetree/bindings/regulator/da9211.txt b/Documentation/devicetree/bindings/regulator/da9211.txt
index eb618907c7de..c620493e8dbe 100644
--- a/Documentation/devicetree/bindings/regulator/da9211.txt
+++ b/Documentation/devicetree/bindings/regulator/da9211.txt
@@ -1,7 +1,7 @@
1* Dialog Semiconductor DA9211/DA9213 Voltage Regulator 1* Dialog Semiconductor DA9211/DA9213/DA9215 Voltage Regulator
2 2
3Required properties: 3Required properties:
4- compatible: "dlg,da9211" or "dlg,da9213". 4- compatible: "dlg,da9211" or "dlg,da9213" or "dlg,da9215"
5- reg: I2C slave address, usually 0x68. 5- reg: I2C slave address, usually 0x68.
6- interrupts: the interrupt outputs of the controller 6- interrupts: the interrupt outputs of the controller
7- regulators: A node that houses a sub-node for each regulator within the 7- regulators: A node that houses a sub-node for each regulator within the
@@ -66,3 +66,31 @@ Example 2) DA9213
66 }; 66 };
67 }; 67 };
68 }; 68 };
69
70
71Example 3) DA9215
72 pmic: da9215@68 {
73 compatible = "dlg,da9215";
74 reg = <0x68>;
75 interrupts = <3 27>;
76
77 regulators {
78 BUCKA {
79 regulator-name = "VBUCKA";
80 regulator-min-microvolt = < 300000>;
81 regulator-max-microvolt = <1570000>;
82 regulator-min-microamp = <4000000>;
83 regulator-max-microamp = <7000000>;
84 enable-gpios = <&gpio 27 0>;
85 };
86 BUCKB {
87 regulator-name = "VBUCKB";
88 regulator-min-microvolt = < 300000>;
89 regulator-max-microvolt = <1570000>;
90 regulator-min-microamp = <4000000>;
91 regulator-max-microamp = <7000000>;
92 enable-gpios = <&gpio 17 0>;
93 };
94 };
95 };
96
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index bef3bde6971b..23496da101de 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -209,13 +209,13 @@ config REGULATOR_DA9210
209 interface. 209 interface.
210 210
211config REGULATOR_DA9211 211config REGULATOR_DA9211
212 tristate "Dialog Semiconductor DA9211/DA9212/DA9213/DA9214 regulator" 212 tristate "Dialog Semiconductor DA9211/DA9212/DA9213/DA9214/DA9215 regulator"
213 depends on I2C 213 depends on I2C
214 select REGMAP_I2C 214 select REGMAP_I2C
215 help 215 help
216 Say y here to support for the Dialog Semiconductor DA9211/DA9212 216 Say y here to support for the Dialog Semiconductor DA9211/DA9212
217 /DA9213/DA9214. 217 /DA9213/DA9214/DA9215.
218 The DA9211/DA9212/DA9213/DA9214 is a multi-phase synchronous 218 The DA9211/DA9212/DA9213/DA9214/DA9215 is a multi-phase synchronous
219 step down converter 12A or 16A DC-DC Buck controlled through an I2C 219 step down converter 12A or 16A DC-DC Buck controlled through an I2C
220 interface. 220 interface.
221 221
diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c
index df79e4b1946e..0858100d2d03 100644
--- a/drivers/regulator/da9211-regulator.c
+++ b/drivers/regulator/da9211-regulator.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * da9211-regulator.c - Regulator device driver for DA9211/DA9213 2 * da9211-regulator.c - Regulator device driver for DA9211/DA9213/DA9215
3 * Copyright (C) 2014 Dialog Semiconductor Ltd. 3 * Copyright (C) 2015 Dialog Semiconductor Ltd.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
@@ -32,6 +32,7 @@
32/* DEVICE IDs */ 32/* DEVICE IDs */
33#define DA9211_DEVICE_ID 0x22 33#define DA9211_DEVICE_ID 0x22
34#define DA9213_DEVICE_ID 0x23 34#define DA9213_DEVICE_ID 0x23
35#define DA9215_DEVICE_ID 0x24
35 36
36#define DA9211_BUCK_MODE_SLEEP 1 37#define DA9211_BUCK_MODE_SLEEP 1
37#define DA9211_BUCK_MODE_SYNC 2 38#define DA9211_BUCK_MODE_SYNC 2
@@ -90,6 +91,13 @@ static const int da9213_current_limits[] = {
90 3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000, 91 3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000,
91 4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000 92 4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
92}; 93};
94/* Current limits for DA9215 buck (uA) indices
95 * corresponds with register values
96 */
97static const int da9215_current_limits[] = {
98 4000000, 4200000, 4400000, 4600000, 4800000, 5000000, 5200000, 5400000,
99 5600000, 5800000, 6000000, 6200000, 6400000, 6600000, 6800000, 7000000
100};
93 101
94static unsigned int da9211_buck_get_mode(struct regulator_dev *rdev) 102static unsigned int da9211_buck_get_mode(struct regulator_dev *rdev)
95{ 103{
@@ -157,6 +165,10 @@ static int da9211_set_current_limit(struct regulator_dev *rdev, int min,
157 current_limits = da9213_current_limits; 165 current_limits = da9213_current_limits;
158 max_size = ARRAY_SIZE(da9213_current_limits)-1; 166 max_size = ARRAY_SIZE(da9213_current_limits)-1;
159 break; 167 break;
168 case DA9215:
169 current_limits = da9215_current_limits;
170 max_size = ARRAY_SIZE(da9215_current_limits)-1;
171 break;
160 default: 172 default:
161 return -EINVAL; 173 return -EINVAL;
162 } 174 }
@@ -189,6 +201,9 @@ static int da9211_get_current_limit(struct regulator_dev *rdev)
189 case DA9213: 201 case DA9213:
190 current_limits = da9213_current_limits; 202 current_limits = da9213_current_limits;
191 break; 203 break;
204 case DA9215:
205 current_limits = da9215_current_limits;
206 break;
192 default: 207 default:
193 return -EINVAL; 208 return -EINVAL;
194 } 209 }
@@ -350,13 +365,11 @@ static int da9211_regulator_init(struct da9211 *chip)
350 /* If configuration for 1/2 bucks is different between platform data 365 /* If configuration for 1/2 bucks is different between platform data
351 * and the register, driver should exit. 366 * and the register, driver should exit.
352 */ 367 */
353 if ((chip->pdata->num_buck == 2 && data == 0x40) 368 if (chip->pdata->num_buck == 1 && data == 0x00)
354 || (chip->pdata->num_buck == 1 && data == 0x00)) { 369 chip->num_regulator = 1;
355 if (data == 0) 370 else if (chip->pdata->num_buck == 2 && data != 0x00)
356 chip->num_regulator = 1; 371 chip->num_regulator = 2;
357 else 372 else {
358 chip->num_regulator = 2;
359 } else {
360 dev_err(chip->dev, "Configuration is mismatched\n"); 373 dev_err(chip->dev, "Configuration is mismatched\n");
361 return -EINVAL; 374 return -EINVAL;
362 } 375 }
@@ -438,6 +451,9 @@ static int da9211_i2c_probe(struct i2c_client *i2c,
438 case DA9213_DEVICE_ID: 451 case DA9213_DEVICE_ID:
439 chip->chip_id = DA9213; 452 chip->chip_id = DA9213;
440 break; 453 break;
454 case DA9215_DEVICE_ID:
455 chip->chip_id = DA9215;
456 break;
441 default: 457 default:
442 dev_err(chip->dev, "Unsupported device id = 0x%x.\n", data); 458 dev_err(chip->dev, "Unsupported device id = 0x%x.\n", data);
443 return -ENODEV; 459 return -ENODEV;
@@ -478,6 +494,7 @@ static int da9211_i2c_probe(struct i2c_client *i2c,
478static const struct i2c_device_id da9211_i2c_id[] = { 494static const struct i2c_device_id da9211_i2c_id[] = {
479 {"da9211", DA9211}, 495 {"da9211", DA9211},
480 {"da9213", DA9213}, 496 {"da9213", DA9213},
497 {"da9215", DA9215},
481 {}, 498 {},
482}; 499};
483MODULE_DEVICE_TABLE(i2c, da9211_i2c_id); 500MODULE_DEVICE_TABLE(i2c, da9211_i2c_id);
@@ -486,6 +503,7 @@ MODULE_DEVICE_TABLE(i2c, da9211_i2c_id);
486static const struct of_device_id da9211_dt_ids[] = { 503static const struct of_device_id da9211_dt_ids[] = {
487 { .compatible = "dlg,da9211", .data = &da9211_i2c_id[0] }, 504 { .compatible = "dlg,da9211", .data = &da9211_i2c_id[0] },
488 { .compatible = "dlg,da9213", .data = &da9211_i2c_id[1] }, 505 { .compatible = "dlg,da9213", .data = &da9211_i2c_id[1] },
506 { .compatible = "dlg,da9215", .data = &da9211_i2c_id[2] },
489 {}, 507 {},
490}; 508};
491MODULE_DEVICE_TABLE(of, da9211_dt_ids); 509MODULE_DEVICE_TABLE(of, da9211_dt_ids);
@@ -504,5 +522,5 @@ static struct i2c_driver da9211_regulator_driver = {
504module_i2c_driver(da9211_regulator_driver); 522module_i2c_driver(da9211_regulator_driver);
505 523
506MODULE_AUTHOR("James Ban <James.Ban.opensource@diasemi.com>"); 524MODULE_AUTHOR("James Ban <James.Ban.opensource@diasemi.com>");
507MODULE_DESCRIPTION("Regulator device driver for Dialog DA9211/DA9213"); 525MODULE_DESCRIPTION("Regulator device driver for Dialog DA9211/DA9213/DA9215");
508MODULE_LICENSE("GPL v2"); 526MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/da9211-regulator.h b/drivers/regulator/da9211-regulator.h
index 93fa9df2721c..d6ad96fc64d3 100644
--- a/drivers/regulator/da9211-regulator.h
+++ b/drivers/regulator/da9211-regulator.h
@@ -1,16 +1,16 @@
1/* 1/*
2 * da9211-regulator.h - Regulator definitions for DA9211/DA9213 2 * da9211-regulator.h - Regulator definitions for DA9211/DA9213/DA9215
3 * Copyright (C) 2014 Dialog Semiconductor Ltd. 3 * Copyright (C) 2015 Dialog Semiconductor Ltd.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU General Public License
7 * License as published by the Free Software Foundation; either 7 * as published by the Free Software Foundation; either version 2
8 * version 2 of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * Library General Public License for more details. 13 * GNU General Public License for more details.
14 */ 14 */
15 15
16#ifndef __DA9211_REGISTERS_H__ 16#ifndef __DA9211_REGISTERS_H__
diff --git a/include/linux/regulator/da9211.h b/include/linux/regulator/da9211.h
index 5dd65acc2a69..a43a5ca1167b 100644
--- a/include/linux/regulator/da9211.h
+++ b/include/linux/regulator/da9211.h
@@ -1,16 +1,16 @@
1/* 1/*
2 * da9211.h - Regulator device driver for DA9211/DA9213 2 * da9211.h - Regulator device driver for DA9211/DA9213/DA9215
3 * Copyright (C) 2014 Dialog Semiconductor Ltd. 3 * Copyright (C) 2015 Dialog Semiconductor Ltd.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU General Public License
7 * License as published by the Free Software Foundation; either 7 * as published by the Free Software Foundation; either version 2
8 * version 2 of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * Library General Public License for more details. 13 * GNU General Public License for more details.
14 */ 14 */
15 15
16#ifndef __LINUX_REGULATOR_DA9211_H 16#ifndef __LINUX_REGULATOR_DA9211_H
@@ -23,6 +23,7 @@
23enum da9211_chip_id { 23enum da9211_chip_id {
24 DA9211, 24 DA9211,
25 DA9213, 25 DA9213,
26 DA9215,
26}; 27};
27 28
28struct da9211_pdata { 29struct da9211_pdata {