blob: 3fd44353cc80eea153fe1118c81180b5e2d21b67 [file] [log] [blame]
Chris Zhong2cd64ae2014-08-20 11:36:42 +08001/*
2 * Regulator driver for Rockchip RK808
3 *
4 * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
5 *
6 * Author: Chris Zhong <zyw@rock-chips.com>
7 * Author: Zhang Qing <zhangqing@rock-chips.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
Chris Zhong2cd64ae2014-08-20 11:36:42 +080017 */
18
19#include <linux/module.h>
Chris Zhong2cd64ae2014-08-20 11:36:42 +080020#include <linux/i2c.h>
Chris Zhong2cd64ae2014-08-20 11:36:42 +080021#include <linux/mfd/rk808.h>
Chris Zhong2cd64ae2014-08-20 11:36:42 +080022#include <linux/of_device.h>
23#include <linux/regulator/driver.h>
24#include <linux/regulator/of_regulator.h>
Chris Zhong571a4012014-09-10 09:18:06 +080025
26/* Field Definitions */
Chris Zhong2cd64ae2014-08-20 11:36:42 +080027#define RK808_BUCK_VSEL_MASK 0x3f
28#define RK808_BUCK4_VSEL_MASK 0xf
29#define RK808_LDO_VSEL_MASK 0x1f
30
Doug Anderson8af25222014-09-16 10:22:54 -070031/* Ramp rate definitions for buck1 / buck2 only */
32#define RK808_RAMP_RATE_OFFSET 3
33#define RK808_RAMP_RATE_MASK (3 << RK808_RAMP_RATE_OFFSET)
34#define RK808_RAMP_RATE_2MV_PER_US (0 << RK808_RAMP_RATE_OFFSET)
35#define RK808_RAMP_RATE_4MV_PER_US (1 << RK808_RAMP_RATE_OFFSET)
36#define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET)
37#define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET)
38
Chris Zhong251ce3182014-10-10 15:35:06 -070039/* Offset from XXX_ON_VSEL to XXX_SLP_VSEL */
40#define RK808_SLP_REG_OFFSET 1
41
42/* Offset from XXX_EN_REG to SLEEP_SET_OFF_XXX */
43#define RK808_SLP_SET_OFF_REG_OFFSET 2
44
Doug Anderson8af25222014-09-16 10:22:54 -070045static const int rk808_buck_config_regs[] = {
46 RK808_BUCK1_CONFIG_REG,
47 RK808_BUCK2_CONFIG_REG,
48 RK808_BUCK3_CONFIG_REG,
49 RK808_BUCK4_CONFIG_REG,
50};
51
Chris Zhong2cd64ae2014-08-20 11:36:42 +080052static const struct regulator_linear_range rk808_buck_voltage_ranges[] = {
Chris Zhong1575e282014-09-30 17:44:54 +080053 REGULATOR_LINEAR_RANGE(712500, 0, 63, 12500),
Chris Zhong2cd64ae2014-08-20 11:36:42 +080054};
55
56static const struct regulator_linear_range rk808_buck4_voltage_ranges[] = {
57 REGULATOR_LINEAR_RANGE(1800000, 0, 15, 100000),
58};
59
60static const struct regulator_linear_range rk808_ldo_voltage_ranges[] = {
61 REGULATOR_LINEAR_RANGE(1800000, 0, 16, 100000),
62};
63
64static const struct regulator_linear_range rk808_ldo3_voltage_ranges[] = {
65 REGULATOR_LINEAR_RANGE(800000, 0, 13, 100000),
66 REGULATOR_LINEAR_RANGE(2500000, 15, 15, 0),
67};
68
69static const struct regulator_linear_range rk808_ldo6_voltage_ranges[] = {
70 REGULATOR_LINEAR_RANGE(800000, 0, 17, 100000),
71};
72
Doug Anderson8af25222014-09-16 10:22:54 -070073static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
74{
75 unsigned int ramp_value = RK808_RAMP_RATE_10MV_PER_US;
76 unsigned int reg = rk808_buck_config_regs[rdev->desc->id -
77 RK808_ID_DCDC1];
78
79 switch (ramp_delay) {
80 case 1 ... 2000:
81 ramp_value = RK808_RAMP_RATE_2MV_PER_US;
82 break;
83 case 2001 ... 4000:
84 ramp_value = RK808_RAMP_RATE_4MV_PER_US;
85 break;
86 case 4001 ... 6000:
87 ramp_value = RK808_RAMP_RATE_6MV_PER_US;
88 break;
89 case 6001 ... 10000:
90 break;
91 default:
92 pr_warn("%s ramp_delay: %d not supported, setting 10000\n",
93 rdev->desc->name, ramp_delay);
94 }
95
96 return regmap_update_bits(rdev->regmap, reg,
97 RK808_RAMP_RATE_MASK, ramp_value);
98}
99
Wei Yongjun5cb2f032014-12-09 21:19:51 +0800100static int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv)
Chris Zhong251ce3182014-10-10 15:35:06 -0700101{
102 unsigned int reg;
103 int sel = regulator_map_voltage_linear_range(rdev, uv, uv);
104
105 if (sel < 0)
106 return -EINVAL;
107
108 reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET;
109
110 return regmap_update_bits(rdev->regmap, reg,
111 rdev->desc->vsel_mask,
112 sel);
113}
114
Wei Yongjun5cb2f032014-12-09 21:19:51 +0800115static int rk808_set_suspend_enable(struct regulator_dev *rdev)
Chris Zhong251ce3182014-10-10 15:35:06 -0700116{
117 unsigned int reg;
118
119 reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
120
121 return regmap_update_bits(rdev->regmap, reg,
122 rdev->desc->enable_mask,
123 0);
124}
125
Wei Yongjun5cb2f032014-12-09 21:19:51 +0800126static int rk808_set_suspend_disable(struct regulator_dev *rdev)
Chris Zhong251ce3182014-10-10 15:35:06 -0700127{
128 unsigned int reg;
129
130 reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
131
132 return regmap_update_bits(rdev->regmap, reg,
133 rdev->desc->enable_mask,
134 rdev->desc->enable_mask);
135}
136
Doug Anderson8af25222014-09-16 10:22:54 -0700137static struct regulator_ops rk808_buck1_2_ops = {
138 .list_voltage = regulator_list_voltage_linear_range,
139 .map_voltage = regulator_map_voltage_linear_range,
140 .get_voltage_sel = regulator_get_voltage_sel_regmap,
141 .set_voltage_sel = regulator_set_voltage_sel_regmap,
142 .enable = regulator_enable_regmap,
143 .disable = regulator_disable_regmap,
144 .is_enabled = regulator_is_enabled_regmap,
145 .set_ramp_delay = rk808_set_ramp_delay,
Chris Zhong251ce3182014-10-10 15:35:06 -0700146 .set_suspend_voltage = rk808_set_suspend_voltage,
147 .set_suspend_enable = rk808_set_suspend_enable,
148 .set_suspend_disable = rk808_set_suspend_disable,
Doug Anderson8af25222014-09-16 10:22:54 -0700149};
150
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800151static struct regulator_ops rk808_reg_ops = {
152 .list_voltage = regulator_list_voltage_linear_range,
153 .map_voltage = regulator_map_voltage_linear_range,
154 .get_voltage_sel = regulator_get_voltage_sel_regmap,
155 .set_voltage_sel = regulator_set_voltage_sel_regmap,
156 .enable = regulator_enable_regmap,
157 .disable = regulator_disable_regmap,
158 .is_enabled = regulator_is_enabled_regmap,
Chris Zhong251ce3182014-10-10 15:35:06 -0700159 .set_suspend_voltage = rk808_set_suspend_voltage,
160 .set_suspend_enable = rk808_set_suspend_enable,
161 .set_suspend_disable = rk808_set_suspend_disable,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800162};
163
164static struct regulator_ops rk808_switch_ops = {
Chris Zhong251ce3182014-10-10 15:35:06 -0700165 .enable = regulator_enable_regmap,
166 .disable = regulator_disable_regmap,
167 .is_enabled = regulator_is_enabled_regmap,
168 .set_suspend_enable = rk808_set_suspend_enable,
169 .set_suspend_disable = rk808_set_suspend_disable,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800170};
171
172static const struct regulator_desc rk808_reg[] = {
173 {
174 .name = "DCDC_REG1",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700175 .supply_name = "vcc1",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800176 .id = RK808_ID_DCDC1,
Doug Anderson8af25222014-09-16 10:22:54 -0700177 .ops = &rk808_buck1_2_ops,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800178 .type = REGULATOR_VOLTAGE,
179 .n_voltages = 64,
180 .linear_ranges = rk808_buck_voltage_ranges,
181 .n_linear_ranges = ARRAY_SIZE(rk808_buck_voltage_ranges),
182 .vsel_reg = RK808_BUCK1_ON_VSEL_REG,
183 .vsel_mask = RK808_BUCK_VSEL_MASK,
184 .enable_reg = RK808_DCDC_EN_REG,
185 .enable_mask = BIT(0),
186 .owner = THIS_MODULE,
187 }, {
188 .name = "DCDC_REG2",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700189 .supply_name = "vcc2",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800190 .id = RK808_ID_DCDC2,
Doug Anderson8af25222014-09-16 10:22:54 -0700191 .ops = &rk808_buck1_2_ops,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800192 .type = REGULATOR_VOLTAGE,
193 .n_voltages = 64,
194 .linear_ranges = rk808_buck_voltage_ranges,
195 .n_linear_ranges = ARRAY_SIZE(rk808_buck_voltage_ranges),
196 .vsel_reg = RK808_BUCK2_ON_VSEL_REG,
197 .vsel_mask = RK808_BUCK_VSEL_MASK,
198 .enable_reg = RK808_DCDC_EN_REG,
199 .enable_mask = BIT(1),
200 .owner = THIS_MODULE,
201 }, {
202 .name = "DCDC_REG3",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700203 .supply_name = "vcc3",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800204 .id = RK808_ID_DCDC3,
205 .ops = &rk808_switch_ops,
206 .type = REGULATOR_VOLTAGE,
207 .n_voltages = 1,
208 .enable_reg = RK808_DCDC_EN_REG,
209 .enable_mask = BIT(2),
210 .owner = THIS_MODULE,
211 }, {
212 .name = "DCDC_REG4",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700213 .supply_name = "vcc4",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800214 .id = RK808_ID_DCDC4,
215 .ops = &rk808_reg_ops,
216 .type = REGULATOR_VOLTAGE,
Axel Lin5a820672014-09-02 08:47:31 +0800217 .n_voltages = 16,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800218 .linear_ranges = rk808_buck4_voltage_ranges,
219 .n_linear_ranges = ARRAY_SIZE(rk808_buck4_voltage_ranges),
220 .vsel_reg = RK808_BUCK4_ON_VSEL_REG,
221 .vsel_mask = RK808_BUCK4_VSEL_MASK,
222 .enable_reg = RK808_DCDC_EN_REG,
223 .enable_mask = BIT(3),
224 .owner = THIS_MODULE,
225 }, {
226 .name = "LDO_REG1",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700227 .supply_name = "vcc6",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800228 .id = RK808_ID_LDO1,
229 .ops = &rk808_reg_ops,
230 .type = REGULATOR_VOLTAGE,
231 .n_voltages = 17,
232 .linear_ranges = rk808_ldo_voltage_ranges,
233 .n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
234 .vsel_reg = RK808_LDO1_ON_VSEL_REG,
235 .vsel_mask = RK808_LDO_VSEL_MASK,
236 .enable_reg = RK808_LDO_EN_REG,
237 .enable_mask = BIT(0),
Doug Anderson28249b02015-02-20 16:53:38 -0800238 .enable_time = 400,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800239 .owner = THIS_MODULE,
240 }, {
241 .name = "LDO_REG2",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700242 .supply_name = "vcc6",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800243 .id = RK808_ID_LDO2,
244 .ops = &rk808_reg_ops,
245 .type = REGULATOR_VOLTAGE,
246 .n_voltages = 17,
247 .linear_ranges = rk808_ldo_voltage_ranges,
248 .n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
249 .vsel_reg = RK808_LDO2_ON_VSEL_REG,
250 .vsel_mask = RK808_LDO_VSEL_MASK,
251 .enable_reg = RK808_LDO_EN_REG,
252 .enable_mask = BIT(1),
Doug Anderson28249b02015-02-20 16:53:38 -0800253 .enable_time = 400,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800254 .owner = THIS_MODULE,
255 }, {
256 .name = "LDO_REG3",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700257 .supply_name = "vcc7",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800258 .id = RK808_ID_LDO3,
259 .ops = &rk808_reg_ops,
260 .type = REGULATOR_VOLTAGE,
261 .n_voltages = 16,
262 .linear_ranges = rk808_ldo3_voltage_ranges,
263 .n_linear_ranges = ARRAY_SIZE(rk808_ldo3_voltage_ranges),
264 .vsel_reg = RK808_LDO3_ON_VSEL_REG,
265 .vsel_mask = RK808_BUCK4_VSEL_MASK,
266 .enable_reg = RK808_LDO_EN_REG,
267 .enable_mask = BIT(2),
Doug Anderson28249b02015-02-20 16:53:38 -0800268 .enable_time = 400,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800269 .owner = THIS_MODULE,
270 }, {
271 .name = "LDO_REG4",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700272 .supply_name = "vcc9",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800273 .id = RK808_ID_LDO4,
274 .ops = &rk808_reg_ops,
275 .type = REGULATOR_VOLTAGE,
276 .n_voltages = 17,
277 .linear_ranges = rk808_ldo_voltage_ranges,
278 .n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
279 .vsel_reg = RK808_LDO4_ON_VSEL_REG,
280 .vsel_mask = RK808_LDO_VSEL_MASK,
281 .enable_reg = RK808_LDO_EN_REG,
282 .enable_mask = BIT(3),
Doug Anderson28249b02015-02-20 16:53:38 -0800283 .enable_time = 400,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800284 .owner = THIS_MODULE,
285 }, {
286 .name = "LDO_REG5",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700287 .supply_name = "vcc9",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800288 .id = RK808_ID_LDO5,
289 .ops = &rk808_reg_ops,
290 .type = REGULATOR_VOLTAGE,
291 .n_voltages = 17,
292 .linear_ranges = rk808_ldo_voltage_ranges,
293 .n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
294 .vsel_reg = RK808_LDO5_ON_VSEL_REG,
295 .vsel_mask = RK808_LDO_VSEL_MASK,
296 .enable_reg = RK808_LDO_EN_REG,
297 .enable_mask = BIT(4),
Doug Anderson28249b02015-02-20 16:53:38 -0800298 .enable_time = 400,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800299 .owner = THIS_MODULE,
300 }, {
301 .name = "LDO_REG6",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700302 .supply_name = "vcc10",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800303 .id = RK808_ID_LDO6,
304 .ops = &rk808_reg_ops,
305 .type = REGULATOR_VOLTAGE,
306 .n_voltages = 18,
307 .linear_ranges = rk808_ldo6_voltage_ranges,
308 .n_linear_ranges = ARRAY_SIZE(rk808_ldo6_voltage_ranges),
309 .vsel_reg = RK808_LDO6_ON_VSEL_REG,
310 .vsel_mask = RK808_LDO_VSEL_MASK,
311 .enable_reg = RK808_LDO_EN_REG,
312 .enable_mask = BIT(5),
Doug Anderson28249b02015-02-20 16:53:38 -0800313 .enable_time = 400,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800314 .owner = THIS_MODULE,
315 }, {
316 .name = "LDO_REG7",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700317 .supply_name = "vcc7",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800318 .id = RK808_ID_LDO7,
319 .ops = &rk808_reg_ops,
320 .type = REGULATOR_VOLTAGE,
321 .n_voltages = 18,
322 .linear_ranges = rk808_ldo6_voltage_ranges,
323 .n_linear_ranges = ARRAY_SIZE(rk808_ldo6_voltage_ranges),
324 .vsel_reg = RK808_LDO7_ON_VSEL_REG,
325 .vsel_mask = RK808_LDO_VSEL_MASK,
326 .enable_reg = RK808_LDO_EN_REG,
327 .enable_mask = BIT(6),
Doug Anderson28249b02015-02-20 16:53:38 -0800328 .enable_time = 400,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800329 .owner = THIS_MODULE,
330 }, {
331 .name = "LDO_REG8",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700332 .supply_name = "vcc11",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800333 .id = RK808_ID_LDO8,
334 .ops = &rk808_reg_ops,
335 .type = REGULATOR_VOLTAGE,
336 .n_voltages = 17,
337 .linear_ranges = rk808_ldo_voltage_ranges,
338 .n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
339 .vsel_reg = RK808_LDO8_ON_VSEL_REG,
340 .vsel_mask = RK808_LDO_VSEL_MASK,
341 .enable_reg = RK808_LDO_EN_REG,
342 .enable_mask = BIT(7),
Doug Anderson28249b02015-02-20 16:53:38 -0800343 .enable_time = 400,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800344 .owner = THIS_MODULE,
345 }, {
346 .name = "SWITCH_REG1",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700347 .supply_name = "vcc8",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800348 .id = RK808_ID_SWITCH1,
349 .ops = &rk808_switch_ops,
350 .type = REGULATOR_VOLTAGE,
351 .enable_reg = RK808_DCDC_EN_REG,
352 .enable_mask = BIT(5),
353 .owner = THIS_MODULE,
354 }, {
355 .name = "SWITCH_REG2",
Doug Andersonb8074eb2014-09-02 09:14:28 -0700356 .supply_name = "vcc12",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800357 .id = RK808_ID_SWITCH2,
358 .ops = &rk808_switch_ops,
359 .type = REGULATOR_VOLTAGE,
360 .enable_reg = RK808_DCDC_EN_REG,
361 .enable_mask = BIT(6),
362 .owner = THIS_MODULE,
363 },
364};
365
366static struct of_regulator_match rk808_reg_matches[] = {
367 [RK808_ID_DCDC1] = { .name = "DCDC_REG1" },
368 [RK808_ID_DCDC2] = { .name = "DCDC_REG2" },
369 [RK808_ID_DCDC3] = { .name = "DCDC_REG3" },
370 [RK808_ID_DCDC4] = { .name = "DCDC_REG4" },
371 [RK808_ID_LDO1] = { .name = "LDO_REG1" },
372 [RK808_ID_LDO2] = { .name = "LDO_REG2" },
373 [RK808_ID_LDO3] = { .name = "LDO_REG3" },
374 [RK808_ID_LDO4] = { .name = "LDO_REG4" },
375 [RK808_ID_LDO5] = { .name = "LDO_REG5" },
376 [RK808_ID_LDO6] = { .name = "LDO_REG6" },
377 [RK808_ID_LDO7] = { .name = "LDO_REG7" },
378 [RK808_ID_LDO8] = { .name = "LDO_REG8" },
379 [RK808_ID_SWITCH1] = { .name = "SWITCH_REG1" },
380 [RK808_ID_SWITCH2] = { .name = "SWITCH_REG2" },
381};
382
Chris Zhong571a4012014-09-10 09:18:06 +0800383static int rk808_regulator_probe(struct platform_device *pdev)
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800384{
Chris Zhong571a4012014-09-10 09:18:06 +0800385 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
386 struct i2c_client *client = rk808->i2c;
387 struct device_node *reg_np;
388 struct regulator_config config = {};
389 struct regulator_dev *rk808_rdev;
390 int ret, i;
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800391
Chris Zhong571a4012014-09-10 09:18:06 +0800392 reg_np = of_get_child_by_name(client->dev.of_node, "regulators");
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800393 if (!reg_np)
394 return -ENXIO;
395
Axel Lin1ed3f8c2014-09-11 18:22:48 +0800396 ret = of_regulator_match(&pdev->dev, reg_np, rk808_reg_matches,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800397 RK808_NUM_REGULATORS);
Axel Lin1ed3f8c2014-09-11 18:22:48 +0800398 of_node_put(reg_np);
Chris Zhong571a4012014-09-10 09:18:06 +0800399 if (ret < 0)
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800400 return ret;
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800401
Chris Zhong571a4012014-09-10 09:18:06 +0800402 /* Instantiate the regulators */
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800403 for (i = 0; i < RK808_NUM_REGULATORS; i++) {
404 if (!rk808_reg_matches[i].init_data ||
405 !rk808_reg_matches[i].of_node)
406 continue;
407
Chris Zhongd76c3332014-08-25 21:37:06 +0800408 config.dev = &client->dev;
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800409 config.driver_data = rk808;
410 config.regmap = rk808->regmap;
Chris Zhong571a4012014-09-10 09:18:06 +0800411 config.of_node = rk808_reg_matches[i].of_node;
412 config.init_data = rk808_reg_matches[i].init_data;
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800413
414 rk808_rdev = devm_regulator_register(&pdev->dev,
415 &rk808_reg[i], &config);
416 if (IS_ERR(rk808_rdev)) {
Chris Zhongd76c3332014-08-25 21:37:06 +0800417 dev_err(&client->dev,
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800418 "failed to register %d regulator\n", i);
419 return PTR_ERR(rk808_rdev);
420 }
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800421 }
Chris Zhong571a4012014-09-10 09:18:06 +0800422
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800423 return 0;
424}
425
426static struct platform_driver rk808_regulator_driver = {
427 .probe = rk808_regulator_probe,
428 .driver = {
429 .name = "rk808-regulator",
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800430 },
431};
432
433module_platform_driver(rk808_regulator_driver);
434
435MODULE_DESCRIPTION("regulator driver for the rk808 series PMICs");
436MODULE_AUTHOR("Chris Zhong<zyw@rock-chips.com>");
Chris Zhong571a4012014-09-10 09:18:06 +0800437MODULE_AUTHOR("Zhang Qing<zhangqing@rock-chips.com>");
Chris Zhong2cd64ae2014-08-20 11:36:42 +0800438MODULE_LICENSE("GPL");
439MODULE_ALIAS("platform:rk808-regulator");