blob: b20b3e1d821a4bf679c82394199ce11e78ad8cd3 [file] [log] [blame]
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +02001/*
2 * Regulator driver for National Semiconductors LP3971 PMIC chip
3 *
4 * Copyright (C) 2009 Samsung Electronics
5 * Author: Marek Szyprowski <m.szyprowski@samsung.com>
6 *
7 * Based on wm8350.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/bug.h>
16#include <linux/err.h>
17#include <linux/i2c.h>
18#include <linux/kernel.h>
19#include <linux/regulator/driver.h>
20#include <linux/regulator/lp3971.h>
21
22struct lp3971 {
23 struct device *dev;
24 struct mutex io_lock;
25 struct i2c_client *i2c;
26 int num_regulators;
27 struct regulator_dev **rdev;
28};
29
30static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg);
31static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val);
32
33#define LP3971_SYS_CONTROL1_REG 0x07
34
35/* System control register 1 initial value,
36 bits 4 and 5 are EPROM programmable */
37#define SYS_CONTROL1_INIT_VAL 0x40
38#define SYS_CONTROL1_INIT_MASK 0xCF
39
40#define LP3971_BUCK_VOL_ENABLE_REG 0x10
41#define LP3971_BUCK_VOL_CHANGE_REG 0x20
42
43/* Voltage control registers shift:
44 LP3971_BUCK1 -> 0
45 LP3971_BUCK2 -> 4
46 LP3971_BUCK3 -> 6
47*/
Axel Lin451a73c2010-03-11 09:50:07 +080048#define BUCK_VOL_CHANGE_SHIFT(x) (((!!x) << 2) | (x & ~0x01))
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +020049#define BUCK_VOL_CHANGE_FLAG_GO 0x01
50#define BUCK_VOL_CHANGE_FLAG_TARGET 0x02
51#define BUCK_VOL_CHANGE_FLAG_MASK 0x03
52
53#define LP3971_BUCK1_BASE 0x23
54#define LP3971_BUCK2_BASE 0x29
55#define LP3971_BUCK3_BASE 0x32
56
Tobias Klauser6faa7e02009-12-23 14:13:17 +010057static const int buck_base_addr[] = {
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +020058 LP3971_BUCK1_BASE,
59 LP3971_BUCK2_BASE,
60 LP3971_BUCK3_BASE,
61};
62
63#define LP3971_BUCK_TARGET_VOL1_REG(x) (buck_base_addr[x])
64#define LP3971_BUCK_TARGET_VOL2_REG(x) (buck_base_addr[x]+1)
65
Tobias Klauser6faa7e02009-12-23 14:13:17 +010066static const int buck_voltage_map[] = {
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +020067 0, 800, 850, 900, 950, 1000, 1050, 1100,
68 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500,
69 1550, 1600, 1650, 1700, 1800, 1900, 2500, 2800,
70 3000, 3300,
71};
72
73#define BUCK_TARGET_VOL_MASK 0x3f
74#define BUCK_TARGET_VOL_MIN_IDX 0x01
75#define BUCK_TARGET_VOL_MAX_IDX 0x19
76
77#define LP3971_BUCK_RAMP_REG(x) (buck_base_addr[x]+2)
78
79#define LP3971_LDO_ENABLE_REG 0x12
80#define LP3971_LDO_VOL_CONTR_BASE 0x39
81
82/* Voltage control registers:
83 LP3971_LDO1 -> LP3971_LDO_VOL_CONTR_BASE + 0
84 LP3971_LDO2 -> LP3971_LDO_VOL_CONTR_BASE + 0
85 LP3971_LDO3 -> LP3971_LDO_VOL_CONTR_BASE + 1
86 LP3971_LDO4 -> LP3971_LDO_VOL_CONTR_BASE + 1
87 LP3971_LDO5 -> LP3971_LDO_VOL_CONTR_BASE + 2
88*/
89#define LP3971_LDO_VOL_CONTR_REG(x) (LP3971_LDO_VOL_CONTR_BASE + (x >> 1))
90
91/* Voltage control registers shift:
92 LP3971_LDO1 -> 0, LP3971_LDO2 -> 4
93 LP3971_LDO3 -> 0, LP3971_LDO4 -> 4
94 LP3971_LDO5 -> 0
95*/
96#define LDO_VOL_CONTR_SHIFT(x) ((x & 1) << 2)
97#define LDO_VOL_CONTR_MASK 0x0f
98
Tobias Klauser6faa7e02009-12-23 14:13:17 +010099static const int ldo45_voltage_map[] = {
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200100 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350,
101 1400, 1500, 1800, 1900, 2500, 2800, 3000, 3300,
102};
103
Tobias Klauser6faa7e02009-12-23 14:13:17 +0100104static const int ldo123_voltage_map[] = {
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200105 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500,
106 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300,
107};
108
Tobias Klauser6faa7e02009-12-23 14:13:17 +0100109static const int *ldo_voltage_map[] = {
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200110 ldo123_voltage_map, /* LDO1 */
111 ldo123_voltage_map, /* LDO2 */
112 ldo123_voltage_map, /* LDO3 */
113 ldo45_voltage_map, /* LDO4 */
114 ldo45_voltage_map, /* LDO5 */
115};
116
117#define LDO_VOL_VALUE_MAP(x) (ldo_voltage_map[(x - LP3971_LDO1)])
118
119#define LDO_VOL_MIN_IDX 0x00
120#define LDO_VOL_MAX_IDX 0x0f
121
122static int lp3971_ldo_list_voltage(struct regulator_dev *dev, unsigned index)
123{
124 int ldo = rdev_get_id(dev) - LP3971_LDO1;
125 return 1000 * LDO_VOL_VALUE_MAP(ldo)[index];
126}
127
128static int lp3971_ldo_is_enabled(struct regulator_dev *dev)
129{
130 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
131 int ldo = rdev_get_id(dev) - LP3971_LDO1;
132 u16 mask = 1 << (1 + ldo);
133 u16 val;
134
135 val = lp3971_reg_read(lp3971, LP3971_LDO_ENABLE_REG);
136 return (val & mask) != 0;
137}
138
139static int lp3971_ldo_enable(struct regulator_dev *dev)
140{
141 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
142 int ldo = rdev_get_id(dev) - LP3971_LDO1;
143 u16 mask = 1 << (1 + ldo);
144
145 return lp3971_set_bits(lp3971, LP3971_LDO_ENABLE_REG, mask, mask);
146}
147
148static int lp3971_ldo_disable(struct regulator_dev *dev)
149{
150 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
151 int ldo = rdev_get_id(dev) - LP3971_LDO1;
152 u16 mask = 1 << (1 + ldo);
153
154 return lp3971_set_bits(lp3971, LP3971_LDO_ENABLE_REG, mask, 0);
155}
156
157static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
158{
159 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
160 int ldo = rdev_get_id(dev) - LP3971_LDO1;
161 u16 val, reg;
162
163 reg = lp3971_reg_read(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo));
164 val = (reg >> LDO_VOL_CONTR_SHIFT(ldo)) & LDO_VOL_CONTR_MASK;
165
166 return 1000 * LDO_VOL_VALUE_MAP(ldo)[val];
167}
168
169static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
170 int min_uV, int max_uV)
171{
172 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
173 int ldo = rdev_get_id(dev) - LP3971_LDO1;
174 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
175 const int *vol_map = LDO_VOL_VALUE_MAP(ldo);
176 u16 val;
177
178 if (min_vol < vol_map[LDO_VOL_MIN_IDX] ||
179 min_vol > vol_map[LDO_VOL_MAX_IDX])
180 return -EINVAL;
181
182 for (val = LDO_VOL_MIN_IDX; val <= LDO_VOL_MAX_IDX; val++)
183 if (vol_map[val] >= min_vol)
184 break;
185
Roel Kluin62737d42010-02-12 12:30:21 +0100186 if (val > LDO_VOL_MAX_IDX || vol_map[val] > max_vol)
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200187 return -EINVAL;
188
189 return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo),
Axel Lincdb868f2010-03-09 16:53:59 +0800190 LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo),
191 val << LDO_VOL_CONTR_SHIFT(ldo));
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200192}
193
194static struct regulator_ops lp3971_ldo_ops = {
195 .list_voltage = lp3971_ldo_list_voltage,
196 .is_enabled = lp3971_ldo_is_enabled,
197 .enable = lp3971_ldo_enable,
198 .disable = lp3971_ldo_disable,
199 .get_voltage = lp3971_ldo_get_voltage,
200 .set_voltage = lp3971_ldo_set_voltage,
201};
202
203static int lp3971_dcdc_list_voltage(struct regulator_dev *dev, unsigned index)
204{
205 return 1000 * buck_voltage_map[index];
206}
207
208static int lp3971_dcdc_is_enabled(struct regulator_dev *dev)
209{
210 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
211 int buck = rdev_get_id(dev) - LP3971_DCDC1;
212 u16 mask = 1 << (buck * 2);
213 u16 val;
214
215 val = lp3971_reg_read(lp3971, LP3971_BUCK_VOL_ENABLE_REG);
216 return (val & mask) != 0;
217}
218
219static int lp3971_dcdc_enable(struct regulator_dev *dev)
220{
221 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
222 int buck = rdev_get_id(dev) - LP3971_DCDC1;
223 u16 mask = 1 << (buck * 2);
224
225 return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_ENABLE_REG, mask, mask);
226}
227
228static int lp3971_dcdc_disable(struct regulator_dev *dev)
229{
230 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
231 int buck = rdev_get_id(dev) - LP3971_DCDC1;
232 u16 mask = 1 << (buck * 2);
233
234 return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_ENABLE_REG, mask, 0);
235}
236
237static int lp3971_dcdc_get_voltage(struct regulator_dev *dev)
238{
239 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
240 int buck = rdev_get_id(dev) - LP3971_DCDC1;
241 u16 reg;
242 int val;
243
244 reg = lp3971_reg_read(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck));
245 reg &= BUCK_TARGET_VOL_MASK;
246
247 if (reg <= BUCK_TARGET_VOL_MAX_IDX)
248 val = 1000 * buck_voltage_map[reg];
249 else {
250 val = 0;
251 dev_warn(&dev->dev, "chip reported incorrect voltage value.\n");
252 }
253
254 return val;
255}
256
257static int lp3971_dcdc_set_voltage(struct regulator_dev *dev,
258 int min_uV, int max_uV)
259{
260 struct lp3971 *lp3971 = rdev_get_drvdata(dev);
261 int buck = rdev_get_id(dev) - LP3971_DCDC1;
262 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
263 const int *vol_map = buck_voltage_map;
264 u16 val;
265 int ret;
266
267 if (min_vol < vol_map[BUCK_TARGET_VOL_MIN_IDX] ||
268 min_vol > vol_map[BUCK_TARGET_VOL_MAX_IDX])
269 return -EINVAL;
270
271 for (val = BUCK_TARGET_VOL_MIN_IDX; val <= BUCK_TARGET_VOL_MAX_IDX;
272 val++)
273 if (vol_map[val] >= min_vol)
274 break;
275
Roel Kluin62737d42010-02-12 12:30:21 +0100276 if (val > BUCK_TARGET_VOL_MAX_IDX || vol_map[val] > max_vol)
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200277 return -EINVAL;
278
279 ret = lp3971_set_bits(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck),
280 BUCK_TARGET_VOL_MASK, val);
281 if (ret)
282 return ret;
283
284 ret = lp3971_set_bits(lp3971, LP3971_BUCK_VOL_CHANGE_REG,
285 BUCK_VOL_CHANGE_FLAG_MASK << BUCK_VOL_CHANGE_SHIFT(buck),
286 BUCK_VOL_CHANGE_FLAG_GO << BUCK_VOL_CHANGE_SHIFT(buck));
287 if (ret)
288 return ret;
289
290 return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_CHANGE_REG,
291 BUCK_VOL_CHANGE_FLAG_MASK << BUCK_VOL_CHANGE_SHIFT(buck),
292 0 << BUCK_VOL_CHANGE_SHIFT(buck));
293}
294
295static struct regulator_ops lp3971_dcdc_ops = {
296 .list_voltage = lp3971_dcdc_list_voltage,
297 .is_enabled = lp3971_dcdc_is_enabled,
298 .enable = lp3971_dcdc_enable,
299 .disable = lp3971_dcdc_disable,
300 .get_voltage = lp3971_dcdc_get_voltage,
301 .set_voltage = lp3971_dcdc_set_voltage,
302};
303
304static struct regulator_desc regulators[] = {
305 {
306 .name = "LDO1",
307 .id = LP3971_LDO1,
308 .ops = &lp3971_ldo_ops,
309 .n_voltages = ARRAY_SIZE(ldo123_voltage_map),
310 .type = REGULATOR_VOLTAGE,
311 .owner = THIS_MODULE,
312 },
313 {
314 .name = "LDO2",
315 .id = LP3971_LDO2,
316 .ops = &lp3971_ldo_ops,
317 .n_voltages = ARRAY_SIZE(ldo123_voltage_map),
318 .type = REGULATOR_VOLTAGE,
319 .owner = THIS_MODULE,
320 },
321 {
322 .name = "LDO3",
323 .id = LP3971_LDO3,
324 .ops = &lp3971_ldo_ops,
325 .n_voltages = ARRAY_SIZE(ldo123_voltage_map),
326 .type = REGULATOR_VOLTAGE,
327 .owner = THIS_MODULE,
328 },
329 {
330 .name = "LDO4",
331 .id = LP3971_LDO4,
332 .ops = &lp3971_ldo_ops,
333 .n_voltages = ARRAY_SIZE(ldo45_voltage_map),
334 .type = REGULATOR_VOLTAGE,
335 .owner = THIS_MODULE,
336 },
337 {
338 .name = "LDO5",
339 .id = LP3971_LDO5,
340 .ops = &lp3971_ldo_ops,
341 .n_voltages = ARRAY_SIZE(ldo45_voltage_map),
342 .type = REGULATOR_VOLTAGE,
343 .owner = THIS_MODULE,
344 },
345 {
346 .name = "DCDC1",
347 .id = LP3971_DCDC1,
348 .ops = &lp3971_dcdc_ops,
349 .n_voltages = ARRAY_SIZE(buck_voltage_map),
350 .type = REGULATOR_VOLTAGE,
351 .owner = THIS_MODULE,
352 },
353 {
354 .name = "DCDC2",
355 .id = LP3971_DCDC2,
356 .ops = &lp3971_dcdc_ops,
357 .n_voltages = ARRAY_SIZE(buck_voltage_map),
358 .type = REGULATOR_VOLTAGE,
359 .owner = THIS_MODULE,
360 },
361 {
362 .name = "DCDC3",
363 .id = LP3971_DCDC3,
364 .ops = &lp3971_dcdc_ops,
365 .n_voltages = ARRAY_SIZE(buck_voltage_map),
366 .type = REGULATOR_VOLTAGE,
367 .owner = THIS_MODULE,
368 },
369};
370
371static int lp3971_i2c_read(struct i2c_client *i2c, char reg, int count,
372 u16 *dest)
373{
374 int ret;
375
376 if (count != 1)
377 return -EIO;
378 ret = i2c_smbus_read_byte_data(i2c, reg);
379 if (ret < 0 || count != 1)
380 return -EIO;
381
382 *dest = ret;
383 return 0;
384}
385
386static int lp3971_i2c_write(struct i2c_client *i2c, char reg, int count,
387 const u16 *src)
388{
389 int ret;
390
391 if (count != 1)
392 return -EIO;
393 ret = i2c_smbus_write_byte_data(i2c, reg, *src);
394 if (ret >= 0)
395 return 0;
396
397 return ret;
398}
399
400static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg)
401{
402 u16 val = 0;
403
404 mutex_lock(&lp3971->io_lock);
405
406 lp3971_i2c_read(lp3971->i2c, reg, 1, &val);
407
408 dev_dbg(lp3971->dev, "reg read 0x%02x -> 0x%02x\n", (int)reg,
409 (unsigned)val&0xff);
410
411 mutex_unlock(&lp3971->io_lock);
412
413 return val & 0xff;
414}
415
416static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val)
417{
418 u16 tmp;
419 int ret;
420
421 mutex_lock(&lp3971->io_lock);
422
423 ret = lp3971_i2c_read(lp3971->i2c, reg, 1, &tmp);
424 tmp = (tmp & ~mask) | val;
425 if (ret == 0) {
426 ret = lp3971_i2c_write(lp3971->i2c, reg, 1, &tmp);
427 dev_dbg(lp3971->dev, "reg write 0x%02x -> 0x%02x\n", (int)reg,
428 (unsigned)val&0xff);
429 }
430 mutex_unlock(&lp3971->io_lock);
431
432 return ret;
433}
434
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800435static int __devinit setup_regulators(struct lp3971 *lp3971,
436 struct lp3971_platform_data *pdata)
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200437{
438 int i, err;
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800439
440 lp3971->num_regulators = pdata->num_regulators;
441 lp3971->rdev = kcalloc(pdata->num_regulators,
442 sizeof(struct regulator_dev *), GFP_KERNEL);
Dan Carpenter67e46f32010-03-07 15:36:45 +0300443 if (!lp3971->rdev) {
444 err = -ENOMEM;
445 goto err_nomem;
446 }
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200447
448 /* Instantiate the regulators */
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800449 for (i = 0; i < pdata->num_regulators; i++) {
450 struct lp3971_regulator_subdev *reg = &pdata->regulators[i];
451 lp3971->rdev[i] = regulator_register(&regulators[reg->id],
452 lp3971->dev, reg->initdata, lp3971);
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200453
Julia Lawalld662fc82009-11-21 22:18:44 +0100454 if (IS_ERR(lp3971->rdev[i])) {
455 err = PTR_ERR(lp3971->rdev[i]);
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200456 dev_err(lp3971->dev, "regulator init failed: %d\n",
457 err);
458 goto error;
459 }
460 }
461
462 return 0;
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800463
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200464error:
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800465 while (--i >= 0)
466 regulator_unregister(lp3971->rdev[i]);
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200467 kfree(lp3971->rdev);
468 lp3971->rdev = NULL;
Dan Carpenter67e46f32010-03-07 15:36:45 +0300469err_nomem:
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200470 return err;
471}
472
473static int __devinit lp3971_i2c_probe(struct i2c_client *i2c,
474 const struct i2c_device_id *id)
475{
476 struct lp3971 *lp3971;
477 struct lp3971_platform_data *pdata = i2c->dev.platform_data;
478 int ret;
479 u16 val;
480
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800481 if (!pdata) {
482 dev_dbg(&i2c->dev, "No platform init data supplied\n");
483 return -ENODEV;
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200484 }
485
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800486 lp3971 = kzalloc(sizeof(struct lp3971), GFP_KERNEL);
487 if (lp3971 == NULL)
488 return -ENOMEM;
489
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200490 lp3971->i2c = i2c;
491 lp3971->dev = &i2c->dev;
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200492
493 mutex_init(&lp3971->io_lock);
494
495 /* Detect LP3971 */
496 ret = lp3971_i2c_read(i2c, LP3971_SYS_CONTROL1_REG, 1, &val);
497 if (ret == 0 && (val & SYS_CONTROL1_INIT_MASK) != SYS_CONTROL1_INIT_VAL)
498 ret = -ENODEV;
499 if (ret < 0) {
500 dev_err(&i2c->dev, "failed to detect device\n");
501 goto err_detect;
502 }
503
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800504 ret = setup_regulators(lp3971, pdata);
505 if (ret < 0)
506 goto err_detect;
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200507
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800508 i2c_set_clientdata(i2c, lp3971);
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200509 return 0;
510
511err_detect:
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200512 kfree(lp3971);
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200513 return ret;
514}
515
516static int __devexit lp3971_i2c_remove(struct i2c_client *i2c)
517{
518 struct lp3971 *lp3971 = i2c_get_clientdata(i2c);
519 int i;
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800520
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200521 i2c_set_clientdata(i2c, NULL);
Dmitry Torokhovebbed042010-02-23 23:38:17 -0800522
523 for (i = 0; i < lp3971->num_regulators; i++)
524 regulator_unregister(lp3971->rdev[i]);
525
526 kfree(lp3971->rdev);
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200527 kfree(lp3971);
528
529 return 0;
530}
531
532static const struct i2c_device_id lp3971_i2c_id[] = {
533 { "lp3971", 0 },
534 { }
535};
536MODULE_DEVICE_TABLE(i2c, lp3971_i2c_id);
537
538static struct i2c_driver lp3971_i2c_driver = {
539 .driver = {
540 .name = "LP3971",
541 .owner = THIS_MODULE,
542 },
543 .probe = lp3971_i2c_probe,
Liam Girdwood6113c3a2009-05-19 11:44:37 +0100544 .remove = __devexit_p(lp3971_i2c_remove),
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200545 .id_table = lp3971_i2c_id,
546};
547
548static int __init lp3971_module_init(void)
549{
Wolfram Sang12a1d932009-09-18 22:44:45 +0200550 int ret;
Marek Szyprowski0cbdf7b2009-05-19 07:33:55 +0200551
552 ret = i2c_add_driver(&lp3971_i2c_driver);
553 if (ret != 0)
554 pr_err("Failed to register I2C driver: %d\n", ret);
555
556 return ret;
557}
558module_init(lp3971_module_init);
559
560static void __exit lp3971_module_exit(void)
561{
562 i2c_del_driver(&lp3971_i2c_driver);
563}
564module_exit(lp3971_module_exit);
565
566MODULE_LICENSE("GPL");
567MODULE_AUTHOR("Marek Szyprowski <m.szyprowski@samsung.com>");
568MODULE_DESCRIPTION("LP3971 PMIC driver");