aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@sirena.org.uk>2013-04-27 21:13:43 -0400
committerMark Brown <broonie@sirena.org.uk>2013-04-27 21:13:43 -0400
commita2c05e91b991179d43e358d5eb9390f57a59a75f (patch)
tree6f33a25e977d47558ea914ddd96be05683f1d366
parent2e1be9f7b359d653331876968e68e849857222d3 (diff)
parent71622e15dd4d497447d19317d93292184ceb67d9 (diff)
Merge remote-tracking branch 'regulator/topic/max8952' into v3.9-rc8
-rw-r--r--Documentation/devicetree/bindings/regulator/max8952.txt52
-rw-r--r--arch/arm/mach-exynos/mach-universal_c210.c27
-rw-r--r--drivers/regulator/max8952.c75
-rw-r--r--include/linux/regulator/max8952.h10
4 files changed, 144 insertions, 20 deletions
diff --git a/Documentation/devicetree/bindings/regulator/max8952.txt b/Documentation/devicetree/bindings/regulator/max8952.txt
new file mode 100644
index 000000000000..866fcdd0f4eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/max8952.txt
@@ -0,0 +1,52 @@
1Maxim MAX8952 voltage regulator
2
3Required properties:
4- compatible: must be equal to "maxim,max8952"
5- reg: I2C slave address, usually 0x60
6- max8952,dvs-mode-microvolt: array of 4 integer values defining DVS voltages
7 in microvolts. All values must be from range <770000, 1400000>
8- any required generic properties defined in regulator.txt
9
10Optional properties:
11- max8952,vid-gpios: array of two GPIO pins used for DVS voltage selection
12- max8952,en-gpio: GPIO used to control enable status of regulator
13- max8952,default-mode: index of default DVS voltage, from <0, 3> range
14- max8952,sync-freq: sync frequency, must be one of following values:
15 - 0: 26 MHz
16 - 1: 13 MHz
17 - 2: 19.2 MHz
18 Defaults to 26 MHz if not specified.
19- max8952,ramp-speed: voltage ramp speed, must be one of following values:
20 - 0: 32mV/us
21 - 1: 16mV/us
22 - 2: 8mV/us
23 - 3: 4mV/us
24 - 4: 2mV/us
25 - 5: 1mV/us
26 - 6: 0.5mV/us
27 - 7: 0.25mV/us
28 Defaults to 32mV/us if not specified.
29- any available generic properties defined in regulator.txt
30
31Example:
32
33 vdd_arm_reg: pmic@60 {
34 compatible = "maxim,max8952";
35 reg = <0x60>;
36
37 /* max8952-specific properties */
38 max8952,vid-gpios = <&gpx0 3 0>, <&gpx0 4 0>;
39 max8952,en-gpio = <&gpx0 1 0>;
40 max8952,default-mode = <0>;
41 max8952,dvs-mode-microvolt = <1250000>, <1200000>,
42 <1050000>, <950000>;
43 max8952,sync-freq = <0>;
44 max8952,ramp-speed = <0>;
45
46 /* generic regulator properties */
47 regulator-name = "vdd_arm";
48 regulator-min-microvolt = <770000>;
49 regulator-max-microvolt = <1400000>;
50 regulator-always-on;
51 regulator-boot-on;
52 };
diff --git a/arch/arm/mach-exynos/mach-universal_c210.c b/arch/arm/mach-exynos/mach-universal_c210.c
index 497fcb793dc1..d28c7fbaba2d 100644
--- a/arch/arm/mach-exynos/mach-universal_c210.c
+++ b/arch/arm/mach-exynos/mach-universal_c210.c
@@ -97,6 +97,19 @@ static struct s3c2410_uartcfg universal_uartcfgs[] __initdata = {
97static struct regulator_consumer_supply max8952_consumer = 97static struct regulator_consumer_supply max8952_consumer =
98 REGULATOR_SUPPLY("vdd_arm", NULL); 98 REGULATOR_SUPPLY("vdd_arm", NULL);
99 99
100static struct regulator_init_data universal_max8952_reg_data = {
101 .constraints = {
102 .name = "VARM_1.2V",
103 .min_uV = 770000,
104 .max_uV = 1400000,
105 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
106 .always_on = 1,
107 .boot_on = 1,
108 },
109 .num_consumer_supplies = 1,
110 .consumer_supplies = &max8952_consumer,
111};
112
100static struct max8952_platform_data universal_max8952_pdata __initdata = { 113static struct max8952_platform_data universal_max8952_pdata __initdata = {
101 .gpio_vid0 = EXYNOS4_GPX0(3), 114 .gpio_vid0 = EXYNOS4_GPX0(3),
102 .gpio_vid1 = EXYNOS4_GPX0(4), 115 .gpio_vid1 = EXYNOS4_GPX0(4),
@@ -105,19 +118,7 @@ static struct max8952_platform_data universal_max8952_pdata __initdata = {
105 .dvs_mode = { 48, 32, 28, 18 }, /* 1.25, 1.20, 1.05, 0.95V */ 118 .dvs_mode = { 48, 32, 28, 18 }, /* 1.25, 1.20, 1.05, 0.95V */
106 .sync_freq = 0, /* default: fastest */ 119 .sync_freq = 0, /* default: fastest */
107 .ramp_speed = 0, /* default: fastest */ 120 .ramp_speed = 0, /* default: fastest */
108 121 .reg_data = &universal_max8952_reg_data,
109 .reg_data = {
110 .constraints = {
111 .name = "VARM_1.2V",
112 .min_uV = 770000,
113 .max_uV = 1400000,
114 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
115 .always_on = 1,
116 .boot_on = 1,
117 },
118 .num_consumer_supplies = 1,
119 .consumer_supplies = &max8952_consumer,
120 },
121}; 122};
122 123
123static struct regulator_consumer_supply lp3974_buck1_consumer = 124static struct regulator_consumer_supply lp3974_buck1_consumer =
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index fc7935a19e3a..5259c2fea90a 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -28,6 +28,9 @@
28#include <linux/regulator/max8952.h> 28#include <linux/regulator/max8952.h>
29#include <linux/gpio.h> 29#include <linux/gpio.h>
30#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/of.h>
32#include <linux/of_gpio.h>
33#include <linux/regulator/of_regulator.h>
31#include <linux/slab.h> 34#include <linux/slab.h>
32 35
33/* Registers */ 36/* Registers */
@@ -126,6 +129,69 @@ static const struct regulator_desc regulator = {
126 .owner = THIS_MODULE, 129 .owner = THIS_MODULE,
127}; 130};
128 131
132#ifdef CONFIG_OF
133static struct of_device_id max8952_dt_match[] = {
134 { .compatible = "maxim,max8952" },
135 {},
136};
137MODULE_DEVICE_TABLE(of, max8952_dt_match);
138
139static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
140{
141 struct max8952_platform_data *pd;
142 struct device_node *np = dev->of_node;
143 int ret;
144 int i;
145
146 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
147 if (!pd) {
148 dev_err(dev, "Failed to allocate platform data\n");
149 return NULL;
150 }
151
152 pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0);
153 pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1);
154 pd->gpio_en = of_get_named_gpio(np, "max8952,en-gpio", 0);
155
156 if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode))
157 dev_warn(dev, "Default mode not specified, assuming 0\n");
158
159 ret = of_property_read_u32_array(np, "max8952,dvs-mode-microvolt",
160 pd->dvs_mode, ARRAY_SIZE(pd->dvs_mode));
161 if (ret) {
162 dev_err(dev, "max8952,dvs-mode-microvolt property not specified");
163 return NULL;
164 }
165
166 for (i = 0; i < ARRAY_SIZE(pd->dvs_mode); ++i) {
167 if (pd->dvs_mode[i] < 770000 || pd->dvs_mode[i] > 1400000) {
168 dev_err(dev, "DVS voltage %d out of range\n", i);
169 return NULL;
170 }
171 pd->dvs_mode[i] = (pd->dvs_mode[i] - 770000) / 10000;
172 }
173
174 if (of_property_read_u32(np, "max8952,sync-freq", &pd->sync_freq))
175 dev_warn(dev, "max8952,sync-freq property not specified, defaulting to 26MHz\n");
176
177 if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed))
178 dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n");
179
180 pd->reg_data = of_get_regulator_init_data(dev, np);
181 if (!pd->reg_data) {
182 dev_err(dev, "Failed to parse regulator init data\n");
183 return NULL;
184 }
185
186 return pd;
187}
188#else
189static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
190{
191 return NULL;
192}
193#endif
194
129static int max8952_pmic_probe(struct i2c_client *client, 195static int max8952_pmic_probe(struct i2c_client *client,
130 const struct i2c_device_id *i2c_id) 196 const struct i2c_device_id *i2c_id)
131{ 197{
@@ -136,6 +202,9 @@ static int max8952_pmic_probe(struct i2c_client *client,
136 202
137 int ret = 0, err = 0; 203 int ret = 0, err = 0;
138 204
205 if (client->dev.of_node)
206 pdata = max8952_parse_dt(&client->dev);
207
139 if (!pdata) { 208 if (!pdata) {
140 dev_err(&client->dev, "Require the platform data\n"); 209 dev_err(&client->dev, "Require the platform data\n");
141 return -EINVAL; 210 return -EINVAL;
@@ -154,11 +223,12 @@ static int max8952_pmic_probe(struct i2c_client *client,
154 max8952->pdata = pdata; 223 max8952->pdata = pdata;
155 224
156 config.dev = max8952->dev; 225 config.dev = max8952->dev;
157 config.init_data = &pdata->reg_data; 226 config.init_data = pdata->reg_data;
158 config.driver_data = max8952; 227 config.driver_data = max8952;
228 config.of_node = client->dev.of_node;
159 229
160 config.ena_gpio = pdata->gpio_en; 230 config.ena_gpio = pdata->gpio_en;
161 if (pdata->reg_data.constraints.boot_on) 231 if (pdata->reg_data->constraints.boot_on)
162 config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 232 config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
163 233
164 max8952->rdev = regulator_register(&regulator, &config); 234 max8952->rdev = regulator_register(&regulator, &config);
@@ -271,6 +341,7 @@ static struct i2c_driver max8952_pmic_driver = {
271 .remove = max8952_pmic_remove, 341 .remove = max8952_pmic_remove,
272 .driver = { 342 .driver = {
273 .name = "max8952", 343 .name = "max8952",
344 .of_match_table = of_match_ptr(max8952_dt_match),
274 }, 345 },
275 .id_table = max8952_ids, 346 .id_table = max8952_ids,
276}; 347};
diff --git a/include/linux/regulator/max8952.h b/include/linux/regulator/max8952.h
index 45e42855ad05..4dbb63a1d4ab 100644
--- a/include/linux/regulator/max8952.h
+++ b/include/linux/regulator/max8952.h
@@ -122,13 +122,13 @@ struct max8952_platform_data {
122 int gpio_vid1; 122 int gpio_vid1;
123 int gpio_en; 123 int gpio_en;
124 124
125 u8 default_mode; 125 u32 default_mode;
126 u8 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */ 126 u32 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */
127 127
128 u8 sync_freq; 128 u32 sync_freq;
129 u8 ramp_speed; 129 u32 ramp_speed;
130 130
131 struct regulator_init_data reg_data; 131 struct regulator_init_data *reg_data;
132}; 132};
133 133
134 134