blob: a7d30550bb5fb0960d0f350e570169ce1ce5c70b [file] [log] [blame]
Kim, Miloade75152012-07-18 14:32:57 +00001/*
2 * TI LP8788 MFD - buck regulator driver
3 *
4 * Copyright 2012 Texas Instruments
5 *
6 * Author: Milo(Woogyom) Kim <milo.kim@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/slab.h>
16#include <linux/err.h>
17#include <linux/platform_device.h>
18#include <linux/regulator/driver.h>
19#include <linux/mfd/lp8788.h>
20#include <linux/gpio.h>
21
22/* register address */
23#define LP8788_EN_BUCK 0x0C
24#define LP8788_BUCK_DVS_SEL 0x1D
25#define LP8788_BUCK1_VOUT0 0x1E
26#define LP8788_BUCK1_VOUT1 0x1F
27#define LP8788_BUCK1_VOUT2 0x20
28#define LP8788_BUCK1_VOUT3 0x21
29#define LP8788_BUCK2_VOUT0 0x22
30#define LP8788_BUCK2_VOUT1 0x23
31#define LP8788_BUCK2_VOUT2 0x24
32#define LP8788_BUCK2_VOUT3 0x25
33#define LP8788_BUCK3_VOUT 0x26
34#define LP8788_BUCK4_VOUT 0x27
35#define LP8788_BUCK1_TIMESTEP 0x28
36#define LP8788_BUCK_PWM 0x2D
37
38/* mask/shift bits */
39#define LP8788_EN_BUCK1_M BIT(0) /* Addr 0Ch */
40#define LP8788_EN_BUCK2_M BIT(1)
41#define LP8788_EN_BUCK3_M BIT(2)
42#define LP8788_EN_BUCK4_M BIT(3)
43#define LP8788_BUCK1_DVS_SEL_M 0x04 /* Addr 1Dh */
44#define LP8788_BUCK1_DVS_M 0x03
45#define LP8788_BUCK1_DVS_S 0
46#define LP8788_BUCK2_DVS_SEL_M 0x40
47#define LP8788_BUCK2_DVS_M 0x30
48#define LP8788_BUCK2_DVS_S 4
49#define LP8788_BUCK1_DVS_I2C BIT(2)
50#define LP8788_BUCK2_DVS_I2C BIT(6)
51#define LP8788_BUCK1_DVS_PIN (0 << 2)
52#define LP8788_BUCK2_DVS_PIN (0 << 6)
53#define LP8788_VOUT_M 0x1F /* Addr 1Eh ~ 27h */
54#define LP8788_STARTUP_TIME_M 0xF8 /* Addr 28h ~ 2Bh */
55#define LP8788_STARTUP_TIME_S 3
56#define LP8788_FPWM_BUCK1_M BIT(0) /* Addr 2Dh */
57#define LP8788_FPWM_BUCK1_S 0
58#define LP8788_FPWM_BUCK2_M BIT(1)
59#define LP8788_FPWM_BUCK2_S 1
60#define LP8788_FPWM_BUCK3_M BIT(2)
61#define LP8788_FPWM_BUCK3_S 2
62#define LP8788_FPWM_BUCK4_M BIT(3)
63#define LP8788_FPWM_BUCK4_S 3
64
65#define INVALID_ADDR 0xFF
66#define LP8788_FORCE_PWM 1
67#define LP8788_AUTO_PWM 0
68#define PIN_LOW 0
69#define PIN_HIGH 1
70#define ENABLE_TIME_USEC 32
71
Axel Lin0f4c46d2012-07-20 23:10:55 +080072#define BUCK_FPWM_MASK(x) (1 << (x))
73#define BUCK_FPWM_SHIFT(x) (x)
74
Kim, Miloade75152012-07-18 14:32:57 +000075enum lp8788_dvs_state {
76 DVS_LOW = GPIOF_OUT_INIT_LOW,
77 DVS_HIGH = GPIOF_OUT_INIT_HIGH,
78};
79
80enum lp8788_dvs_mode {
81 REGISTER,
82 EXTPIN,
83};
84
85enum lp8788_buck_id {
86 BUCK1,
87 BUCK2,
88 BUCK3,
89 BUCK4,
90};
91
Kim, Miloade75152012-07-18 14:32:57 +000092struct lp8788_buck {
93 struct lp8788 *lp;
94 struct regulator_dev *regulator;
Kim, Miloade75152012-07-18 14:32:57 +000095 void *dvs;
96};
97
Axel Lin7932a882019-02-10 10:48:45 +080098/* BUCK 1 ~ 4 voltage ranges */
99static const struct regulator_linear_range buck_volt_ranges[] = {
100 REGULATOR_LINEAR_RANGE(500000, 0, 0, 0),
101 REGULATOR_LINEAR_RANGE(800000, 1, 25, 50000),
Kim, Miloade75152012-07-18 14:32:57 +0000102};
103
Kim, Miloade75152012-07-18 14:32:57 +0000104static void lp8788_buck1_set_dvs(struct lp8788_buck *buck)
105{
106 struct lp8788_buck1_dvs *dvs = (struct lp8788_buck1_dvs *)buck->dvs;
107 enum lp8788_dvs_state pinstate;
108
109 if (!dvs)
110 return;
111
112 pinstate = dvs->vsel == DVS_SEL_V0 ? DVS_LOW : DVS_HIGH;
113 if (gpio_is_valid(dvs->gpio))
114 gpio_set_value(dvs->gpio, pinstate);
115}
116
117static void lp8788_buck2_set_dvs(struct lp8788_buck *buck)
118{
119 struct lp8788_buck2_dvs *dvs = (struct lp8788_buck2_dvs *)buck->dvs;
120 enum lp8788_dvs_state pin1, pin2;
121
122 if (!dvs)
123 return;
124
125 switch (dvs->vsel) {
126 case DVS_SEL_V0:
127 pin1 = DVS_LOW;
128 pin2 = DVS_LOW;
129 break;
130 case DVS_SEL_V1:
131 pin1 = DVS_HIGH;
132 pin2 = DVS_LOW;
133 break;
134 case DVS_SEL_V2:
135 pin1 = DVS_LOW;
136 pin2 = DVS_HIGH;
137 break;
138 case DVS_SEL_V3:
139 pin1 = DVS_HIGH;
140 pin2 = DVS_HIGH;
141 break;
142 default:
143 return;
144 }
145
146 if (gpio_is_valid(dvs->gpio[0]))
147 gpio_set_value(dvs->gpio[0], pin1);
148
149 if (gpio_is_valid(dvs->gpio[1]))
150 gpio_set_value(dvs->gpio[1], pin2);
151}
152
153static void lp8788_set_dvs(struct lp8788_buck *buck, enum lp8788_buck_id id)
154{
155 switch (id) {
156 case BUCK1:
157 lp8788_buck1_set_dvs(buck);
158 break;
159 case BUCK2:
160 lp8788_buck2_set_dvs(buck);
161 break;
162 default:
163 break;
164 }
165}
166
167static enum lp8788_dvs_mode
168lp8788_get_buck_dvs_ctrl_mode(struct lp8788_buck *buck, enum lp8788_buck_id id)
169{
170 u8 val, mask;
171
172 switch (id) {
173 case BUCK1:
174 mask = LP8788_BUCK1_DVS_SEL_M;
175 break;
176 case BUCK2:
177 mask = LP8788_BUCK2_DVS_SEL_M;
178 break;
179 default:
180 return REGISTER;
181 }
182
183 lp8788_read_byte(buck->lp, LP8788_BUCK_DVS_SEL, &val);
184
185 return val & mask ? REGISTER : EXTPIN;
186}
187
188static bool lp8788_is_valid_buck_addr(u8 addr)
189{
190 switch (addr) {
191 case LP8788_BUCK1_VOUT0:
192 case LP8788_BUCK1_VOUT1:
193 case LP8788_BUCK1_VOUT2:
194 case LP8788_BUCK1_VOUT3:
195 case LP8788_BUCK2_VOUT0:
196 case LP8788_BUCK2_VOUT1:
197 case LP8788_BUCK2_VOUT2:
198 case LP8788_BUCK2_VOUT3:
199 return true;
200 default:
201 return false;
202 }
203}
204
205static u8 lp8788_select_buck_vout_addr(struct lp8788_buck *buck,
206 enum lp8788_buck_id id)
207{
208 enum lp8788_dvs_mode mode = lp8788_get_buck_dvs_ctrl_mode(buck, id);
209 struct lp8788_buck1_dvs *b1_dvs;
210 struct lp8788_buck2_dvs *b2_dvs;
211 u8 val, idx, addr;
212 int pin1, pin2;
213
214 switch (id) {
215 case BUCK1:
216 if (mode == EXTPIN) {
217 b1_dvs = (struct lp8788_buck1_dvs *)buck->dvs;
218 if (!b1_dvs)
219 goto err;
220
221 idx = gpio_get_value(b1_dvs->gpio) ? 1 : 0;
222 } else {
223 lp8788_read_byte(buck->lp, LP8788_BUCK_DVS_SEL, &val);
224 idx = (val & LP8788_BUCK1_DVS_M) >> LP8788_BUCK1_DVS_S;
225 }
Axel Line69995d2013-01-17 09:57:46 +0800226 addr = LP8788_BUCK1_VOUT0 + idx;
Kim, Miloade75152012-07-18 14:32:57 +0000227 break;
228 case BUCK2:
229 if (mode == EXTPIN) {
230 b2_dvs = (struct lp8788_buck2_dvs *)buck->dvs;
231 if (!b2_dvs)
232 goto err;
233
234 pin1 = gpio_get_value(b2_dvs->gpio[0]);
235 pin2 = gpio_get_value(b2_dvs->gpio[1]);
236
237 if (pin1 == PIN_LOW && pin2 == PIN_LOW)
238 idx = 0;
239 else if (pin1 == PIN_LOW && pin2 == PIN_HIGH)
240 idx = 2;
241 else if (pin1 == PIN_HIGH && pin2 == PIN_LOW)
242 idx = 1;
243 else
244 idx = 3;
245 } else {
246 lp8788_read_byte(buck->lp, LP8788_BUCK_DVS_SEL, &val);
247 idx = (val & LP8788_BUCK2_DVS_M) >> LP8788_BUCK2_DVS_S;
248 }
Axel Line69995d2013-01-17 09:57:46 +0800249 addr = LP8788_BUCK2_VOUT0 + idx;
Kim, Miloade75152012-07-18 14:32:57 +0000250 break;
251 default:
252 goto err;
253 }
254
255 return addr;
256err:
257 return INVALID_ADDR;
258}
259
260static int lp8788_buck12_set_voltage_sel(struct regulator_dev *rdev,
261 unsigned selector)
262{
263 struct lp8788_buck *buck = rdev_get_drvdata(rdev);
264 enum lp8788_buck_id id = rdev_get_id(rdev);
265 u8 addr;
266
267 if (buck->dvs)
268 lp8788_set_dvs(buck, id);
269
270 addr = lp8788_select_buck_vout_addr(buck, id);
271 if (!lp8788_is_valid_buck_addr(addr))
272 return -EINVAL;
273
274 return lp8788_update_bits(buck->lp, addr, LP8788_VOUT_M, selector);
275}
276
277static int lp8788_buck12_get_voltage_sel(struct regulator_dev *rdev)
278{
279 struct lp8788_buck *buck = rdev_get_drvdata(rdev);
280 enum lp8788_buck_id id = rdev_get_id(rdev);
281 int ret;
282 u8 val, addr;
283
284 addr = lp8788_select_buck_vout_addr(buck, id);
285 if (!lp8788_is_valid_buck_addr(addr))
286 return -EINVAL;
287
288 ret = lp8788_read_byte(buck->lp, addr, &val);
289 if (ret)
290 return ret;
291
292 return val & LP8788_VOUT_M;
293}
294
295static int lp8788_buck_enable_time(struct regulator_dev *rdev)
296{
297 struct lp8788_buck *buck = rdev_get_drvdata(rdev);
298 enum lp8788_buck_id id = rdev_get_id(rdev);
299 u8 val, addr = LP8788_BUCK1_TIMESTEP + id;
300
301 if (lp8788_read_byte(buck->lp, addr, &val))
302 return -EINVAL;
303
304 val = (val & LP8788_STARTUP_TIME_M) >> LP8788_STARTUP_TIME_S;
305
306 return ENABLE_TIME_USEC * val;
307}
308
309static int lp8788_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
310{
311 struct lp8788_buck *buck = rdev_get_drvdata(rdev);
Axel Lin0f4c46d2012-07-20 23:10:55 +0800312 enum lp8788_buck_id id = rdev_get_id(rdev);
313 u8 mask, val;
Kim, Miloade75152012-07-18 14:32:57 +0000314
Axel Lin0f4c46d2012-07-20 23:10:55 +0800315 mask = BUCK_FPWM_MASK(id);
Kim, Miloade75152012-07-18 14:32:57 +0000316 switch (mode) {
317 case REGULATOR_MODE_FAST:
Axel Lin0f4c46d2012-07-20 23:10:55 +0800318 val = LP8788_FORCE_PWM << BUCK_FPWM_SHIFT(id);
Kim, Miloade75152012-07-18 14:32:57 +0000319 break;
320 case REGULATOR_MODE_NORMAL:
Axel Lin0f4c46d2012-07-20 23:10:55 +0800321 val = LP8788_AUTO_PWM << BUCK_FPWM_SHIFT(id);
Kim, Miloade75152012-07-18 14:32:57 +0000322 break;
323 default:
324 return -EINVAL;
325 }
326
Axel Lin0f4c46d2012-07-20 23:10:55 +0800327 return lp8788_update_bits(buck->lp, LP8788_BUCK_PWM, mask, val);
Kim, Miloade75152012-07-18 14:32:57 +0000328}
329
330static unsigned int lp8788_buck_get_mode(struct regulator_dev *rdev)
331{
332 struct lp8788_buck *buck = rdev_get_drvdata(rdev);
Axel Lin0f4c46d2012-07-20 23:10:55 +0800333 enum lp8788_buck_id id = rdev_get_id(rdev);
Kim, Miloade75152012-07-18 14:32:57 +0000334 u8 val;
335 int ret;
336
Kim, Miloade75152012-07-18 14:32:57 +0000337 ret = lp8788_read_byte(buck->lp, LP8788_BUCK_PWM, &val);
338 if (ret)
339 return ret;
340
Axel Lin0f4c46d2012-07-20 23:10:55 +0800341 return val & BUCK_FPWM_MASK(id) ?
342 REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL;
Kim, Miloade75152012-07-18 14:32:57 +0000343}
344
Julia Lawall95dfead2015-12-19 16:43:22 +0100345static const struct regulator_ops lp8788_buck12_ops = {
Axel Lin7932a882019-02-10 10:48:45 +0800346 .list_voltage = regulator_list_voltage_linear_range,
347 .map_voltage = regulator_map_voltage_linear_range,
Kim, Miloade75152012-07-18 14:32:57 +0000348 .set_voltage_sel = lp8788_buck12_set_voltage_sel,
349 .get_voltage_sel = lp8788_buck12_get_voltage_sel,
350 .enable = regulator_enable_regmap,
351 .disable = regulator_disable_regmap,
352 .is_enabled = regulator_is_enabled_regmap,
353 .enable_time = lp8788_buck_enable_time,
354 .set_mode = lp8788_buck_set_mode,
355 .get_mode = lp8788_buck_get_mode,
356};
357
Julia Lawall95dfead2015-12-19 16:43:22 +0100358static const struct regulator_ops lp8788_buck34_ops = {
Axel Lin7932a882019-02-10 10:48:45 +0800359 .list_voltage = regulator_list_voltage_linear_range,
360 .map_voltage = regulator_map_voltage_linear_range,
Kim, Miloade75152012-07-18 14:32:57 +0000361 .set_voltage_sel = regulator_set_voltage_sel_regmap,
362 .get_voltage_sel = regulator_get_voltage_sel_regmap,
363 .enable = regulator_enable_regmap,
364 .disable = regulator_disable_regmap,
365 .is_enabled = regulator_is_enabled_regmap,
366 .enable_time = lp8788_buck_enable_time,
367 .set_mode = lp8788_buck_set_mode,
368 .get_mode = lp8788_buck_get_mode,
369};
370
Axel Linb1333052019-01-26 11:39:06 +0800371static const struct regulator_desc lp8788_buck_desc[] = {
Kim, Miloade75152012-07-18 14:32:57 +0000372 {
373 .name = "buck1",
374 .id = BUCK1,
375 .ops = &lp8788_buck12_ops,
Axel Lin7932a882019-02-10 10:48:45 +0800376 .n_voltages = 26,
377 .linear_ranges = buck_volt_ranges,
378 .n_linear_ranges = ARRAY_SIZE(buck_volt_ranges),
Kim, Miloade75152012-07-18 14:32:57 +0000379 .type = REGULATOR_VOLTAGE,
380 .owner = THIS_MODULE,
381 .enable_reg = LP8788_EN_BUCK,
382 .enable_mask = LP8788_EN_BUCK1_M,
383 },
384 {
385 .name = "buck2",
386 .id = BUCK2,
387 .ops = &lp8788_buck12_ops,
Axel Lin7932a882019-02-10 10:48:45 +0800388 .n_voltages = 26,
389 .linear_ranges = buck_volt_ranges,
390 .n_linear_ranges = ARRAY_SIZE(buck_volt_ranges),
Kim, Miloade75152012-07-18 14:32:57 +0000391 .type = REGULATOR_VOLTAGE,
392 .owner = THIS_MODULE,
393 .enable_reg = LP8788_EN_BUCK,
394 .enable_mask = LP8788_EN_BUCK2_M,
395 },
396 {
397 .name = "buck3",
398 .id = BUCK3,
399 .ops = &lp8788_buck34_ops,
Axel Lin7932a882019-02-10 10:48:45 +0800400 .n_voltages = 26,
401 .linear_ranges = buck_volt_ranges,
402 .n_linear_ranges = ARRAY_SIZE(buck_volt_ranges),
Kim, Miloade75152012-07-18 14:32:57 +0000403 .type = REGULATOR_VOLTAGE,
404 .owner = THIS_MODULE,
405 .vsel_reg = LP8788_BUCK3_VOUT,
406 .vsel_mask = LP8788_VOUT_M,
407 .enable_reg = LP8788_EN_BUCK,
408 .enable_mask = LP8788_EN_BUCK3_M,
409 },
410 {
411 .name = "buck4",
412 .id = BUCK4,
413 .ops = &lp8788_buck34_ops,
Axel Lin7932a882019-02-10 10:48:45 +0800414 .n_voltages = 26,
415 .linear_ranges = buck_volt_ranges,
416 .n_linear_ranges = ARRAY_SIZE(buck_volt_ranges),
Kim, Miloade75152012-07-18 14:32:57 +0000417 .type = REGULATOR_VOLTAGE,
418 .owner = THIS_MODULE,
419 .vsel_reg = LP8788_BUCK4_VOUT,
420 .vsel_mask = LP8788_VOUT_M,
421 .enable_reg = LP8788_EN_BUCK,
422 .enable_mask = LP8788_EN_BUCK4_M,
423 },
424};
425
Kim, Milo38d8f672013-01-03 06:31:57 +0000426static int lp8788_dvs_gpio_request(struct platform_device *pdev,
427 struct lp8788_buck *buck,
Kim, Miloade75152012-07-18 14:32:57 +0000428 enum lp8788_buck_id id)
429{
430 struct lp8788_platform_data *pdata = buck->lp->pdata;
431 char *b1_name = "LP8788_B1_DVS";
432 char *b2_name[] = { "LP8788_B2_DVS1", "LP8788_B2_DVS2" };
433 int i, gpio, ret;
434
435 switch (id) {
436 case BUCK1:
437 gpio = pdata->buck1_dvs->gpio;
Kim, Milo38d8f672013-01-03 06:31:57 +0000438 ret = devm_gpio_request_one(&pdev->dev, gpio, DVS_LOW,
Axel Lin131a5b92012-12-07 17:25:13 +0800439 b1_name);
Kim, Miloade75152012-07-18 14:32:57 +0000440 if (ret)
441 return ret;
442
443 buck->dvs = pdata->buck1_dvs;
444 break;
445 case BUCK2:
Kim, Milo1ef01e72013-01-03 06:32:03 +0000446 for (i = 0; i < LP8788_NUM_BUCK2_DVS; i++) {
Kim, Miloade75152012-07-18 14:32:57 +0000447 gpio = pdata->buck2_dvs->gpio[i];
Kim, Milo38d8f672013-01-03 06:31:57 +0000448 ret = devm_gpio_request_one(&pdev->dev, gpio,
Axel Lin131a5b92012-12-07 17:25:13 +0800449 DVS_LOW, b2_name[i]);
Kim, Miloade75152012-07-18 14:32:57 +0000450 if (ret)
451 return ret;
452 }
453 buck->dvs = pdata->buck2_dvs;
454 break;
455 default:
456 break;
457 }
458
459 return 0;
460}
461
Kim, Milo38d8f672013-01-03 06:31:57 +0000462static int lp8788_init_dvs(struct platform_device *pdev,
463 struct lp8788_buck *buck, enum lp8788_buck_id id)
Kim, Miloade75152012-07-18 14:32:57 +0000464{
465 struct lp8788_platform_data *pdata = buck->lp->pdata;
466 u8 mask[] = { LP8788_BUCK1_DVS_SEL_M, LP8788_BUCK2_DVS_SEL_M };
467 u8 val[] = { LP8788_BUCK1_DVS_PIN, LP8788_BUCK2_DVS_PIN };
Axel Linc42ea5c2012-07-20 22:22:20 +0800468 u8 default_dvs_mode[] = { LP8788_BUCK1_DVS_I2C, LP8788_BUCK2_DVS_I2C };
Kim, Miloade75152012-07-18 14:32:57 +0000469
470 /* no dvs for buck3, 4 */
Axel Lineb758de2013-01-10 10:33:06 +0800471 if (id > BUCK2)
Kim, Miloade75152012-07-18 14:32:57 +0000472 return 0;
473
474 /* no dvs platform data, then dvs will be selected by I2C registers */
475 if (!pdata)
476 goto set_default_dvs_mode;
477
478 if ((id == BUCK1 && !pdata->buck1_dvs) ||
479 (id == BUCK2 && !pdata->buck2_dvs))
480 goto set_default_dvs_mode;
481
Kim, Milo38d8f672013-01-03 06:31:57 +0000482 if (lp8788_dvs_gpio_request(pdev, buck, id))
Kim, Miloade75152012-07-18 14:32:57 +0000483 goto set_default_dvs_mode;
484
485 return lp8788_update_bits(buck->lp, LP8788_BUCK_DVS_SEL, mask[id],
486 val[id]);
487
488set_default_dvs_mode:
Axel Linc42ea5c2012-07-20 22:22:20 +0800489 return lp8788_update_bits(buck->lp, LP8788_BUCK_DVS_SEL, mask[id],
490 default_dvs_mode[id]);
Kim, Miloade75152012-07-18 14:32:57 +0000491}
492
Bill Pembertona5023572012-11-19 13:22:22 -0500493static int lp8788_buck_probe(struct platform_device *pdev)
Kim, Miloade75152012-07-18 14:32:57 +0000494{
495 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
496 int id = pdev->id;
497 struct lp8788_buck *buck;
498 struct regulator_config cfg = { };
499 struct regulator_dev *rdev;
500 int ret;
501
Axel Lineb758de2013-01-10 10:33:06 +0800502 if (id >= LP8788_NUM_BUCKS)
503 return -EINVAL;
504
Kim, Milo3b0e8f12013-01-03 06:31:02 +0000505 buck = devm_kzalloc(&pdev->dev, sizeof(struct lp8788_buck), GFP_KERNEL);
Kim, Miloade75152012-07-18 14:32:57 +0000506 if (!buck)
507 return -ENOMEM;
508
509 buck->lp = lp;
Kim, Miloade75152012-07-18 14:32:57 +0000510
Kim, Milo38d8f672013-01-03 06:31:57 +0000511 ret = lp8788_init_dvs(pdev, buck, id);
Kim, Miloade75152012-07-18 14:32:57 +0000512 if (ret)
513 return ret;
514
Kim, Milo3b0e8f12013-01-03 06:31:02 +0000515 cfg.dev = pdev->dev.parent;
Kim, Miloade75152012-07-18 14:32:57 +0000516 cfg.init_data = lp->pdata ? lp->pdata->buck_data[id] : NULL;
517 cfg.driver_data = buck;
518 cfg.regmap = lp->regmap;
519
Jingoo Han3343fa12013-09-30 09:55:12 +0900520 rdev = devm_regulator_register(&pdev->dev, &lp8788_buck_desc[id], &cfg);
Kim, Miloade75152012-07-18 14:32:57 +0000521 if (IS_ERR(rdev)) {
522 ret = PTR_ERR(rdev);
Kim, Milo3b0e8f12013-01-03 06:31:02 +0000523 dev_err(&pdev->dev, "BUCK%d regulator register err = %d\n",
Kim, Miloade75152012-07-18 14:32:57 +0000524 id + 1, ret);
525 return ret;
526 }
527
528 buck->regulator = rdev;
529 platform_set_drvdata(pdev, buck);
530
531 return 0;
532}
533
Kim, Miloade75152012-07-18 14:32:57 +0000534static struct platform_driver lp8788_buck_driver = {
535 .probe = lp8788_buck_probe,
Kim, Miloade75152012-07-18 14:32:57 +0000536 .driver = {
537 .name = LP8788_DEV_BUCK,
Kim, Miloade75152012-07-18 14:32:57 +0000538 },
539};
540
541static int __init lp8788_buck_init(void)
542{
543 return platform_driver_register(&lp8788_buck_driver);
544}
545subsys_initcall(lp8788_buck_init);
546
547static void __exit lp8788_buck_exit(void)
548{
549 platform_driver_unregister(&lp8788_buck_driver);
550}
551module_exit(lp8788_buck_exit);
552
553MODULE_DESCRIPTION("TI LP8788 BUCK Driver");
554MODULE_AUTHOR("Milo Kim");
555MODULE_LICENSE("GPL");
556MODULE_ALIAS("platform:lp8788-buck");