blob: b5567bc99000b1abe1ec392b0bdac86c26c06627 [file] [log] [blame]
Woogyom Kim2165c8a2012-01-04 08:27:43 +04001/*
Kim, Milof7bae492012-01-26 22:59:08 -08002 * Driver for LP8727 Micro/Mini USB IC with integrated charger
Woogyom Kim2165c8a2012-01-04 08:27:43 +04003 *
Kim, Miloe39b8282012-01-29 17:28:18 -08004 * Copyright (C) 2011 Texas Instruments
Woogyom Kim2165c8a2012-01-04 08:27:43 +04005 * Copyright (C) 2011 National Semiconductor
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12
13#include <linux/module.h>
14#include <linux/slab.h>
15#include <linux/interrupt.h>
16#include <linux/i2c.h>
17#include <linux/power_supply.h>
Kim, Milo1aebb092012-07-03 01:19:03 +000018#include <linux/platform_data/lp8727.h>
Woogyom Kim2165c8a2012-01-04 08:27:43 +040019
Kim, Milo638555d2012-08-31 09:24:09 +000020#define LP8788_NUM_INTREGS 2
Kim, Milo60fd57e2012-08-31 09:23:25 +000021#define DEFAULT_DEBOUNCE_MSEC 270
Woogyom Kim2165c8a2012-01-04 08:27:43 +040022
23/* Registers */
24#define CTRL1 0x1
25#define CTRL2 0x2
26#define SWCTRL 0x3
27#define INT1 0x4
28#define INT2 0x5
29#define STATUS1 0x6
Kim, Milo73368802012-01-26 22:58:51 -080030#define STATUS2 0x7
Woogyom Kim2165c8a2012-01-04 08:27:43 +040031#define CHGCTRL2 0x9
32
33/* CTRL1 register */
34#define CP_EN (1 << 0)
35#define ADC_EN (1 << 1)
36#define ID200_EN (1 << 4)
37
38/* CTRL2 register */
39#define CHGDET_EN (1 << 1)
40#define INT_EN (1 << 6)
41
42/* SWCTRL register */
43#define SW_DM1_DM (0x0 << 0)
44#define SW_DM1_U1 (0x1 << 0)
45#define SW_DM1_HiZ (0x7 << 0)
46#define SW_DP2_DP (0x0 << 3)
47#define SW_DP2_U2 (0x1 << 3)
48#define SW_DP2_HiZ (0x7 << 3)
49
50/* INT1 register */
51#define IDNO (0xF << 0)
52#define VBUS (1 << 4)
53
54/* STATUS1 register */
55#define CHGSTAT (3 << 4)
56#define CHPORT (1 << 6)
57#define DCPORT (1 << 7)
58
59/* STATUS2 register */
60#define TEMP_STAT (3 << 5)
61
62enum lp8727_dev_id {
63 ID_NONE,
64 ID_TA,
65 ID_DEDICATED_CHG,
66 ID_USB_CHG,
67 ID_USB_DS,
68 ID_MAX,
69};
70
71enum lp8727_chg_stat {
72 PRECHG,
73 CC,
74 CV,
75 EOC,
76};
77
78struct lp8727_psy {
79 struct power_supply ac;
80 struct power_supply usb;
81 struct power_supply batt;
82};
83
84struct lp8727_chg {
85 struct device *dev;
86 struct i2c_client *client;
87 struct mutex xfer_lock;
88 struct delayed_work work;
Woogyom Kim2165c8a2012-01-04 08:27:43 +040089 struct lp8727_platform_data *pdata;
90 struct lp8727_psy *psy;
91 struct lp8727_chg_param *chg_parm;
92 enum lp8727_dev_id devid;
Kim, Milo60fd57e2012-08-31 09:23:25 +000093 unsigned long debounce_jiffies;
Kim, Milod71fda02012-08-31 09:23:57 +000094 int irq;
Woogyom Kim2165c8a2012-01-04 08:27:43 +040095};
96
Kim, Milo27aefa32012-01-26 22:58:39 -080097static int lp8727_read_bytes(struct lp8727_chg *pchg, u8 reg, u8 *data, u8 len)
Woogyom Kim2165c8a2012-01-04 08:27:43 +040098{
99 s32 ret;
100
101 mutex_lock(&pchg->xfer_lock);
102 ret = i2c_smbus_read_i2c_block_data(pchg->client, reg, len, data);
103 mutex_unlock(&pchg->xfer_lock);
104
105 return (ret != len) ? -EIO : 0;
106}
107
Kim, Milo27aefa32012-01-26 22:58:39 -0800108static inline int lp8727_read_byte(struct lp8727_chg *pchg, u8 reg, u8 *data)
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400109{
Kim, Milo27aefa32012-01-26 22:58:39 -0800110 return lp8727_read_bytes(pchg, reg, data, 1);
111}
112
113static int lp8727_write_byte(struct lp8727_chg *pchg, u8 reg, u8 data)
114{
115 int ret;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400116
117 mutex_lock(&pchg->xfer_lock);
Kim, Milo27aefa32012-01-26 22:58:39 -0800118 ret = i2c_smbus_write_byte_data(pchg->client, reg, data);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400119 mutex_unlock(&pchg->xfer_lock);
120
121 return ret;
122}
123
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400124static int lp8727_is_charger_attached(const char *name, int id)
125{
126 if (name) {
127 if (!strcmp(name, "ac"))
128 return (id == ID_TA || id == ID_DEDICATED_CHG) ? 1 : 0;
129 else if (!strcmp(name, "usb"))
130 return (id == ID_USB_CHG) ? 1 : 0;
131 }
132
133 return (id >= ID_TA && id <= ID_USB_CHG) ? 1 : 0;
134}
135
Kim, Milo7da63342012-01-26 22:58:30 -0800136static int lp8727_init_device(struct lp8727_chg *pchg)
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400137{
138 u8 val;
Kim, Milo7da63342012-01-26 22:58:30 -0800139 int ret;
Kim, Milo638555d2012-08-31 09:24:09 +0000140 u8 intstat[LP8788_NUM_INTREGS];
141
142 /* clear interrupts */
143 ret = lp8727_read_bytes(pchg, INT1, intstat, LP8788_NUM_INTREGS);
144 if (ret)
145 return ret;
146
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400147
148 val = ID200_EN | ADC_EN | CP_EN;
Kim, Milo27aefa32012-01-26 22:58:39 -0800149 ret = lp8727_write_byte(pchg, CTRL1, val);
Kim, Milo7da63342012-01-26 22:58:30 -0800150 if (ret)
151 return ret;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400152
153 val = INT_EN | CHGDET_EN;
Kim, Milo27aefa32012-01-26 22:58:39 -0800154 ret = lp8727_write_byte(pchg, CTRL2, val);
Kim, Milo7da63342012-01-26 22:58:30 -0800155 if (ret)
156 return ret;
157
158 return 0;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400159}
160
161static int lp8727_is_dedicated_charger(struct lp8727_chg *pchg)
162{
163 u8 val;
Kim, Milo27aefa32012-01-26 22:58:39 -0800164 lp8727_read_byte(pchg, STATUS1, &val);
Kim, Milo73368802012-01-26 22:58:51 -0800165 return val & DCPORT;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400166}
167
168static int lp8727_is_usb_charger(struct lp8727_chg *pchg)
169{
170 u8 val;
Kim, Milo27aefa32012-01-26 22:58:39 -0800171 lp8727_read_byte(pchg, STATUS1, &val);
Kim, Milo73368802012-01-26 22:58:51 -0800172 return val & CHPORT;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400173}
174
175static void lp8727_ctrl_switch(struct lp8727_chg *pchg, u8 sw)
176{
Kim, Milo27aefa32012-01-26 22:58:39 -0800177 lp8727_write_byte(pchg, SWCTRL, sw);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400178}
179
180static void lp8727_id_detection(struct lp8727_chg *pchg, u8 id, int vbusin)
181{
Kim, Milo318cb382012-08-31 09:23:12 +0000182 struct lp8727_platform_data *pdata = pchg->pdata;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400183 u8 devid = ID_NONE;
184 u8 swctrl = SW_DM1_HiZ | SW_DP2_HiZ;
185
186 switch (id) {
187 case 0x5:
188 devid = ID_TA;
Kim, Milo318cb382012-08-31 09:23:12 +0000189 pchg->chg_parm = pdata ? pdata->ac : NULL;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400190 break;
191 case 0xB:
192 if (lp8727_is_dedicated_charger(pchg)) {
Kim, Milo318cb382012-08-31 09:23:12 +0000193 pchg->chg_parm = pdata ? pdata->ac : NULL;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400194 devid = ID_DEDICATED_CHG;
195 } else if (lp8727_is_usb_charger(pchg)) {
Kim, Milo318cb382012-08-31 09:23:12 +0000196 pchg->chg_parm = pdata ? pdata->usb : NULL;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400197 devid = ID_USB_CHG;
198 swctrl = SW_DM1_DM | SW_DP2_DP;
199 } else if (vbusin) {
200 devid = ID_USB_DS;
201 swctrl = SW_DM1_DM | SW_DP2_DP;
202 }
203 break;
204 default:
205 devid = ID_NONE;
206 pchg->chg_parm = NULL;
207 break;
208 }
209
210 pchg->devid = devid;
211 lp8727_ctrl_switch(pchg, swctrl);
212}
213
214static void lp8727_enable_chgdet(struct lp8727_chg *pchg)
215{
216 u8 val;
217
Kim, Milo27aefa32012-01-26 22:58:39 -0800218 lp8727_read_byte(pchg, CTRL2, &val);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400219 val |= CHGDET_EN;
Kim, Milo27aefa32012-01-26 22:58:39 -0800220 lp8727_write_byte(pchg, CTRL2, val);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400221}
222
223static void lp8727_delayed_func(struct work_struct *_work)
224{
225 u8 intstat[2], idno, vbus;
226 struct lp8727_chg *pchg =
227 container_of(_work, struct lp8727_chg, work.work);
228
Kim, Milo27aefa32012-01-26 22:58:39 -0800229 if (lp8727_read_bytes(pchg, INT1, intstat, 2)) {
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400230 dev_err(pchg->dev, "can not read INT registers\n");
231 return;
232 }
233
234 idno = intstat[0] & IDNO;
235 vbus = intstat[0] & VBUS;
236
237 lp8727_id_detection(pchg, idno, vbus);
238 lp8727_enable_chgdet(pchg);
239
240 power_supply_changed(&pchg->psy->ac);
241 power_supply_changed(&pchg->psy->usb);
242 power_supply_changed(&pchg->psy->batt);
243}
244
245static irqreturn_t lp8727_isr_func(int irq, void *ptr)
246{
247 struct lp8727_chg *pchg = ptr;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400248
Kim, Milo2a092582012-08-31 09:23:41 +0000249 schedule_delayed_work(&pchg->work, pchg->debounce_jiffies);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400250 return IRQ_HANDLED;
251}
252
Kim, Milod71fda02012-08-31 09:23:57 +0000253static int lp8727_setup_irq(struct lp8727_chg *pchg)
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400254{
Kim, Milod71fda02012-08-31 09:23:57 +0000255 int ret;
256 int irq = pchg->client->irq;
Kim, Milo60fd57e2012-08-31 09:23:25 +0000257 unsigned delay_msec = pchg->pdata ? pchg->pdata->debounce_msec :
258 DEFAULT_DEBOUNCE_MSEC;
259
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400260 INIT_DELAYED_WORK(&pchg->work, lp8727_delayed_func);
261
Kim, Milod71fda02012-08-31 09:23:57 +0000262 if (irq <= 0) {
263 dev_warn(pchg->dev, "invalid irq number: %d\n", irq);
264 return 0;
265 }
266
267 ret = request_threaded_irq(irq, NULL, lp8727_isr_func,
268 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
269 "lp8727_irq", pchg);
270
271 if (ret)
272 return ret;
273
274 pchg->irq = irq;
Kim, Milo60fd57e2012-08-31 09:23:25 +0000275 pchg->debounce_jiffies = msecs_to_jiffies(delay_msec);
276
Kim, Milod71fda02012-08-31 09:23:57 +0000277 return 0;
278}
279
280static void lp8727_release_irq(struct lp8727_chg *pchg)
281{
282 cancel_delayed_work_sync(&pchg->work);
283
284 if (pchg->irq)
285 free_irq(pchg->irq, pchg);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400286}
287
288static enum power_supply_property lp8727_charger_prop[] = {
289 POWER_SUPPLY_PROP_ONLINE,
290};
291
292static enum power_supply_property lp8727_battery_prop[] = {
293 POWER_SUPPLY_PROP_STATUS,
294 POWER_SUPPLY_PROP_HEALTH,
295 POWER_SUPPLY_PROP_PRESENT,
296 POWER_SUPPLY_PROP_VOLTAGE_NOW,
297 POWER_SUPPLY_PROP_CAPACITY,
298 POWER_SUPPLY_PROP_TEMP,
299};
300
301static char *battery_supplied_to[] = {
302 "main_batt",
303};
304
305static int lp8727_charger_get_property(struct power_supply *psy,
306 enum power_supply_property psp,
307 union power_supply_propval *val)
308{
309 struct lp8727_chg *pchg = dev_get_drvdata(psy->dev->parent);
310
Kim, Miloce09aff2012-01-04 09:03:18 +0400311 if (psp == POWER_SUPPLY_PROP_ONLINE)
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400312 val->intval = lp8727_is_charger_attached(psy->name,
313 pchg->devid);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400314
315 return 0;
316}
317
318static int lp8727_battery_get_property(struct power_supply *psy,
319 enum power_supply_property psp,
320 union power_supply_propval *val)
321{
322 struct lp8727_chg *pchg = dev_get_drvdata(psy->dev->parent);
Kim, Milo318cb382012-08-31 09:23:12 +0000323 struct lp8727_platform_data *pdata = pchg->pdata;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400324 u8 read;
325
326 switch (psp) {
327 case POWER_SUPPLY_PROP_STATUS:
328 if (lp8727_is_charger_attached(psy->name, pchg->devid)) {
Kim, Milo27aefa32012-01-26 22:58:39 -0800329 lp8727_read_byte(pchg, STATUS1, &read);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400330 if (((read & CHGSTAT) >> 4) == EOC)
331 val->intval = POWER_SUPPLY_STATUS_FULL;
332 else
333 val->intval = POWER_SUPPLY_STATUS_CHARGING;
334 } else {
335 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
336 }
337 break;
338 case POWER_SUPPLY_PROP_HEALTH:
Kim, Milo27aefa32012-01-26 22:58:39 -0800339 lp8727_read_byte(pchg, STATUS2, &read);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400340 read = (read & TEMP_STAT) >> 5;
341 if (read >= 0x1 && read <= 0x3)
342 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
343 else
344 val->intval = POWER_SUPPLY_HEALTH_GOOD;
345 break;
346 case POWER_SUPPLY_PROP_PRESENT:
Kim, Milo318cb382012-08-31 09:23:12 +0000347 if (!pdata)
348 return -EINVAL;
349
350 if (pdata->get_batt_present)
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400351 val->intval = pchg->pdata->get_batt_present();
352 break;
353 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
Kim, Milo318cb382012-08-31 09:23:12 +0000354 if (!pdata)
355 return -EINVAL;
356
357 if (pdata->get_batt_level)
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400358 val->intval = pchg->pdata->get_batt_level();
359 break;
360 case POWER_SUPPLY_PROP_CAPACITY:
Kim, Milo318cb382012-08-31 09:23:12 +0000361 if (!pdata)
362 return -EINVAL;
363
364 if (pdata->get_batt_capacity)
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400365 val->intval = pchg->pdata->get_batt_capacity();
366 break;
367 case POWER_SUPPLY_PROP_TEMP:
Kim, Milo318cb382012-08-31 09:23:12 +0000368 if (!pdata)
369 return -EINVAL;
370
371 if (pdata->get_batt_temp)
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400372 val->intval = pchg->pdata->get_batt_temp();
373 break;
374 default:
375 break;
376 }
377
378 return 0;
379}
380
381static void lp8727_charger_changed(struct power_supply *psy)
382{
383 struct lp8727_chg *pchg = dev_get_drvdata(psy->dev->parent);
384 u8 val;
385 u8 eoc_level, ichg;
386
387 if (lp8727_is_charger_attached(psy->name, pchg->devid)) {
388 if (pchg->chg_parm) {
389 eoc_level = pchg->chg_parm->eoc_level;
390 ichg = pchg->chg_parm->ichg;
391 val = (ichg << 4) | eoc_level;
Kim, Milo27aefa32012-01-26 22:58:39 -0800392 lp8727_write_byte(pchg, CHGCTRL2, val);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400393 }
394 }
395}
396
397static int lp8727_register_psy(struct lp8727_chg *pchg)
398{
399 struct lp8727_psy *psy;
400
Kim, Milo74727c52012-08-31 09:22:46 +0000401 psy = devm_kzalloc(pchg->dev, sizeof(*psy), GFP_KERNEL);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400402 if (!psy)
Devendra Naga6297b5e2012-07-29 23:31:55 +0545403 return -ENOMEM;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400404
405 pchg->psy = psy;
406
407 psy->ac.name = "ac";
408 psy->ac.type = POWER_SUPPLY_TYPE_MAINS;
409 psy->ac.properties = lp8727_charger_prop;
410 psy->ac.num_properties = ARRAY_SIZE(lp8727_charger_prop);
411 psy->ac.get_property = lp8727_charger_get_property;
412 psy->ac.supplied_to = battery_supplied_to;
413 psy->ac.num_supplicants = ARRAY_SIZE(battery_supplied_to);
414
415 if (power_supply_register(pchg->dev, &psy->ac))
Devendra Naga6297b5e2012-07-29 23:31:55 +0545416 goto err_psy_ac;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400417
418 psy->usb.name = "usb";
419 psy->usb.type = POWER_SUPPLY_TYPE_USB;
420 psy->usb.properties = lp8727_charger_prop;
421 psy->usb.num_properties = ARRAY_SIZE(lp8727_charger_prop);
422 psy->usb.get_property = lp8727_charger_get_property;
423 psy->usb.supplied_to = battery_supplied_to;
424 psy->usb.num_supplicants = ARRAY_SIZE(battery_supplied_to);
425
426 if (power_supply_register(pchg->dev, &psy->usb))
Devendra Naga6297b5e2012-07-29 23:31:55 +0545427 goto err_psy_usb;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400428
429 psy->batt.name = "main_batt";
430 psy->batt.type = POWER_SUPPLY_TYPE_BATTERY;
431 psy->batt.properties = lp8727_battery_prop;
432 psy->batt.num_properties = ARRAY_SIZE(lp8727_battery_prop);
433 psy->batt.get_property = lp8727_battery_get_property;
434 psy->batt.external_power_changed = lp8727_charger_changed;
435
436 if (power_supply_register(pchg->dev, &psy->batt))
Devendra Naga6297b5e2012-07-29 23:31:55 +0545437 goto err_psy_batt;
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400438
439 return 0;
440
Devendra Naga6297b5e2012-07-29 23:31:55 +0545441err_psy_batt:
442 power_supply_unregister(&psy->usb);
443err_psy_usb:
444 power_supply_unregister(&psy->ac);
445err_psy_ac:
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400446 return -EPERM;
447}
448
449static void lp8727_unregister_psy(struct lp8727_chg *pchg)
450{
451 struct lp8727_psy *psy = pchg->psy;
452
Kim, Miloce09aff2012-01-04 09:03:18 +0400453 if (!psy)
454 return;
455
456 power_supply_unregister(&psy->ac);
457 power_supply_unregister(&psy->usb);
458 power_supply_unregister(&psy->batt);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400459}
460
461static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
462{
463 struct lp8727_chg *pchg;
464 int ret;
465
Kim, Milo998a8e72011-11-17 21:43:06 -0800466 if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
467 return -EIO;
468
Kim, Milo74727c52012-08-31 09:22:46 +0000469 pchg = devm_kzalloc(&cl->dev, sizeof(*pchg), GFP_KERNEL);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400470 if (!pchg)
471 return -ENOMEM;
472
473 pchg->client = cl;
474 pchg->dev = &cl->dev;
475 pchg->pdata = cl->dev.platform_data;
476 i2c_set_clientdata(cl, pchg);
477
478 mutex_init(&pchg->xfer_lock);
479
Kim, Milo7da63342012-01-26 22:58:30 -0800480 ret = lp8727_init_device(pchg);
481 if (ret) {
482 dev_err(pchg->dev, "i2c communication err: %d", ret);
Kim, Milofb9adc52012-08-31 09:23:03 +0000483 return ret;
Kim, Milo7da63342012-01-26 22:58:30 -0800484 }
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400485
486 ret = lp8727_register_psy(pchg);
Kim, Milo7da63342012-01-26 22:58:30 -0800487 if (ret) {
488 dev_err(pchg->dev, "power supplies register err: %d", ret);
Kim, Milofb9adc52012-08-31 09:23:03 +0000489 return ret;
490 }
491
Kim, Milod71fda02012-08-31 09:23:57 +0000492 ret = lp8727_setup_irq(pchg);
Kim, Milofb9adc52012-08-31 09:23:03 +0000493 if (ret) {
494 dev_err(pchg->dev, "irq handler err: %d", ret);
495 lp8727_unregister_psy(pchg);
496 return ret;
Kim, Milo7da63342012-01-26 22:58:30 -0800497 }
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400498
499 return 0;
500}
501
502static int __devexit lp8727_remove(struct i2c_client *cl)
503{
504 struct lp8727_chg *pchg = i2c_get_clientdata(cl);
505
Kim, Milod71fda02012-08-31 09:23:57 +0000506 lp8727_release_irq(pchg);
Kim, Milofb9adc52012-08-31 09:23:03 +0000507 lp8727_unregister_psy(pchg);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400508 return 0;
509}
510
511static const struct i2c_device_id lp8727_ids[] = {
512 {"lp8727", 0},
Axel Lin455a0e22012-01-16 13:48:20 +0800513 { }
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400514};
Axel Line2c5f7d2012-01-12 20:45:02 +0800515MODULE_DEVICE_TABLE(i2c, lp8727_ids);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400516
517static struct i2c_driver lp8727_driver = {
518 .driver = {
519 .name = "lp8727",
520 },
521 .probe = lp8727_probe,
522 .remove = __devexit_p(lp8727_remove),
523 .id_table = lp8727_ids,
524};
Axel Lin5ff92e72012-01-21 14:42:54 +0800525module_i2c_driver(lp8727_driver);
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400526
Kim, Miloe39b8282012-01-29 17:28:18 -0800527MODULE_DESCRIPTION("TI/National Semiconductor LP8727 charger driver");
Kim, Milo73368802012-01-26 22:58:51 -0800528MODULE_AUTHOR("Woogyom Kim <milo.kim@ti.com>, "
529 "Daniel Jeong <daniel.jeong@ti.com>");
Woogyom Kim2165c8a2012-01-04 08:27:43 +0400530MODULE_LICENSE("GPL");