blob: d05597b4e40f5a613271f8bf0021560508e15997 [file] [log] [blame]
Balaji Raof5714dc2009-01-09 01:50:55 +01001/* NXP PCF50633 Main Battery Charger Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090019#include <linux/slab.h>
Balaji Raof5714dc2009-01-09 01:50:55 +010020#include <linux/init.h>
21#include <linux/types.h>
22#include <linux/device.h>
23#include <linux/sysfs.h>
24#include <linux/platform_device.h>
25#include <linux/power_supply.h>
26
27#include <linux/mfd/pcf50633/core.h>
28#include <linux/mfd/pcf50633/mbc.h>
29
30struct pcf50633_mbc {
31 struct pcf50633 *pcf;
32
Balaji Raof5714dc2009-01-09 01:50:55 +010033 int adapter_online;
Balaji Raof5714dc2009-01-09 01:50:55 +010034 int usb_online;
35
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010036 struct power_supply *usb;
37 struct power_supply *adapter;
38 struct power_supply *ac;
Balaji Raof5714dc2009-01-09 01:50:55 +010039};
40
41int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
42{
43 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
44 int ret = 0;
45 u8 bits;
Balaji Rao9705ecc2009-01-27 19:23:12 +053046 int charging_start = 1;
47 u8 mbcs2, chgmod;
Balaji Rao31b4ff02009-11-05 00:24:55 +030048 unsigned int mbcc5;
Balaji Raof5714dc2009-01-09 01:50:55 +010049
Balaji Rao31b4ff02009-11-05 00:24:55 +030050 if (ma >= 1000) {
Balaji Raof5714dc2009-01-09 01:50:55 +010051 bits = PCF50633_MBCC7_USB_1000mA;
Balaji Rao31b4ff02009-11-05 00:24:55 +030052 ma = 1000;
53 } else if (ma >= 500) {
Balaji Raof5714dc2009-01-09 01:50:55 +010054 bits = PCF50633_MBCC7_USB_500mA;
Balaji Rao31b4ff02009-11-05 00:24:55 +030055 ma = 500;
56 } else if (ma >= 100) {
Balaji Raof5714dc2009-01-09 01:50:55 +010057 bits = PCF50633_MBCC7_USB_100mA;
Balaji Rao31b4ff02009-11-05 00:24:55 +030058 ma = 100;
59 } else {
Balaji Raof5714dc2009-01-09 01:50:55 +010060 bits = PCF50633_MBCC7_USB_SUSPEND;
Balaji Rao9705ecc2009-01-27 19:23:12 +053061 charging_start = 0;
Balaji Rao31b4ff02009-11-05 00:24:55 +030062 ma = 0;
Balaji Rao9705ecc2009-01-27 19:23:12 +053063 }
Balaji Raof5714dc2009-01-09 01:50:55 +010064
65 ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC7,
66 PCF50633_MBCC7_USB_MASK, bits);
67 if (ret)
68 dev_err(pcf->dev, "error setting usb curlim to %d mA\n", ma);
69 else
70 dev_info(pcf->dev, "usb curlim to %d mA\n", ma);
71
Balaji Rao31b4ff02009-11-05 00:24:55 +030072 /*
73 * We limit the charging current to be the USB current limit.
74 * The reason is that on pcf50633, when it enters PMU Standby mode,
75 * which it does when the device goes "off", the USB current limit
76 * reverts to the variant default. In at least one common case, that
77 * default is 500mA. By setting the charging current to be the same
78 * as the USB limit we set here before PMU standby, we enforce it only
79 * using the correct amount of current even when the USB current limit
80 * gets reset to the wrong thing
81 */
82
83 if (mbc->pcf->pdata->charger_reference_current_ma) {
84 mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma;
85 if (mbcc5 > 255)
86 mbcc5 = 255;
87 pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
88 }
89
Paul Fertserc3297952009-11-05 00:24:59 +030090 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2);
Balaji Rao9705ecc2009-01-27 19:23:12 +053091 chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
92
93 /* If chgmod == BATFULL, setting chgena has no effect.
Paul Fertser1282b352009-11-05 00:24:58 +030094 * Datasheet says we need to set resume instead but when autoresume is
95 * used resume doesn't work. Clear and set chgena instead.
Balaji Rao9705ecc2009-01-27 19:23:12 +053096 */
97 if (chgmod != PCF50633_MBCS2_MBC_BAT_FULL)
98 pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC1,
99 PCF50633_MBCC1_CHGENA, PCF50633_MBCC1_CHGENA);
Paul Fertser1282b352009-11-05 00:24:58 +0300100 else {
101 pcf50633_reg_clear_bits(pcf, PCF50633_REG_MBCC1,
102 PCF50633_MBCC1_CHGENA);
Balaji Rao9705ecc2009-01-27 19:23:12 +0530103 pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC1,
Paul Fertser1282b352009-11-05 00:24:58 +0300104 PCF50633_MBCC1_CHGENA, PCF50633_MBCC1_CHGENA);
105 }
Balaji Rao9705ecc2009-01-27 19:23:12 +0530106
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100107 power_supply_changed(mbc->usb);
Balaji Raof5714dc2009-01-09 01:50:55 +0100108
109 return ret;
110}
111EXPORT_SYMBOL_GPL(pcf50633_mbc_usb_curlim_set);
112
113int pcf50633_mbc_get_status(struct pcf50633 *pcf)
114{
115 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
116 int status = 0;
Paul Fertserc3297952009-11-05 00:24:59 +0300117 u8 chgmod;
118
119 if (!mbc)
120 return 0;
121
122 chgmod = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2)
123 & PCF50633_MBCS2_MBC_MASK;
Balaji Raof5714dc2009-01-09 01:50:55 +0100124
125 if (mbc->usb_online)
126 status |= PCF50633_MBC_USB_ONLINE;
Paul Fertserc3297952009-11-05 00:24:59 +0300127 if (chgmod == PCF50633_MBCS2_MBC_USB_PRE ||
128 chgmod == PCF50633_MBCS2_MBC_USB_PRE_WAIT ||
129 chgmod == PCF50633_MBCS2_MBC_USB_FAST ||
130 chgmod == PCF50633_MBCS2_MBC_USB_FAST_WAIT)
Balaji Raof5714dc2009-01-09 01:50:55 +0100131 status |= PCF50633_MBC_USB_ACTIVE;
132 if (mbc->adapter_online)
133 status |= PCF50633_MBC_ADAPTER_ONLINE;
Paul Fertserc3297952009-11-05 00:24:59 +0300134 if (chgmod == PCF50633_MBCS2_MBC_ADP_PRE ||
135 chgmod == PCF50633_MBCS2_MBC_ADP_PRE_WAIT ||
136 chgmod == PCF50633_MBCS2_MBC_ADP_FAST ||
137 chgmod == PCF50633_MBCS2_MBC_ADP_FAST_WAIT)
Balaji Raof5714dc2009-01-09 01:50:55 +0100138 status |= PCF50633_MBC_ADAPTER_ACTIVE;
139
140 return status;
141}
142EXPORT_SYMBOL_GPL(pcf50633_mbc_get_status);
143
Paul Fertserc3297952009-11-05 00:24:59 +0300144int pcf50633_mbc_get_usb_online_status(struct pcf50633 *pcf)
145{
146 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
147
148 if (!mbc)
149 return 0;
150
151 return mbc->usb_online;
152}
153EXPORT_SYMBOL_GPL(pcf50633_mbc_get_usb_online_status);
154
Balaji Raof5714dc2009-01-09 01:50:55 +0100155static ssize_t
156show_chgmode(struct device *dev, struct device_attribute *attr, char *buf)
157{
158 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
159
160 u8 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2);
161 u8 chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
162
163 return sprintf(buf, "%d\n", chgmod);
164}
165static DEVICE_ATTR(chgmode, S_IRUGO, show_chgmode, NULL);
166
167static ssize_t
168show_usblim(struct device *dev, struct device_attribute *attr, char *buf)
169{
170 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
171 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
172 PCF50633_MBCC7_USB_MASK;
173 unsigned int ma;
174
175 if (usblim == PCF50633_MBCC7_USB_1000mA)
176 ma = 1000;
177 else if (usblim == PCF50633_MBCC7_USB_500mA)
178 ma = 500;
179 else if (usblim == PCF50633_MBCC7_USB_100mA)
180 ma = 100;
181 else
182 ma = 0;
183
184 return sprintf(buf, "%u\n", ma);
185}
186
187static ssize_t set_usblim(struct device *dev,
188 struct device_attribute *attr, const char *buf, size_t count)
189{
190 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
191 unsigned long ma;
192 int ret;
193
Jingoo Han4b43eb62013-06-03 18:05:05 +0900194 ret = kstrtoul(buf, 10, &ma);
Balaji Raof5714dc2009-01-09 01:50:55 +0100195 if (ret)
Jingoo Han4b43eb62013-06-03 18:05:05 +0900196 return ret;
Balaji Raof5714dc2009-01-09 01:50:55 +0100197
198 pcf50633_mbc_usb_curlim_set(mbc->pcf, ma);
199
200 return count;
201}
202
203static DEVICE_ATTR(usb_curlim, S_IRUGO | S_IWUSR, show_usblim, set_usblim);
204
Balaji Rao31b4ff02009-11-05 00:24:55 +0300205static ssize_t
206show_chglim(struct device *dev, struct device_attribute *attr, char *buf)
207{
208 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
209 u8 mbcc5 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC5);
210 unsigned int ma;
211
212 if (!mbc->pcf->pdata->charger_reference_current_ma)
213 return -ENODEV;
214
215 ma = (mbc->pcf->pdata->charger_reference_current_ma * mbcc5) >> 8;
216
217 return sprintf(buf, "%u\n", ma);
218}
219
220static ssize_t set_chglim(struct device *dev,
221 struct device_attribute *attr, const char *buf, size_t count)
222{
223 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
224 unsigned long ma;
225 unsigned int mbcc5;
226 int ret;
227
228 if (!mbc->pcf->pdata->charger_reference_current_ma)
229 return -ENODEV;
230
Jingoo Han4b43eb62013-06-03 18:05:05 +0900231 ret = kstrtoul(buf, 10, &ma);
Balaji Rao31b4ff02009-11-05 00:24:55 +0300232 if (ret)
Jingoo Han4b43eb62013-06-03 18:05:05 +0900233 return ret;
Balaji Rao31b4ff02009-11-05 00:24:55 +0300234
235 mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma;
236 if (mbcc5 > 255)
237 mbcc5 = 255;
238 pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
239
240 return count;
241}
242
243/*
244 * This attribute allows to change MBC charging limit on the fly
245 * independently of usb current limit. It also gets set automatically every
246 * time usb current limit is changed.
247 */
248static DEVICE_ATTR(chg_curlim, S_IRUGO | S_IWUSR, show_chglim, set_chglim);
249
Balaji Raof5714dc2009-01-09 01:50:55 +0100250static struct attribute *pcf50633_mbc_sysfs_entries[] = {
251 &dev_attr_chgmode.attr,
252 &dev_attr_usb_curlim.attr,
Balaji Rao31b4ff02009-11-05 00:24:55 +0300253 &dev_attr_chg_curlim.attr,
Balaji Raof5714dc2009-01-09 01:50:55 +0100254 NULL,
255};
256
257static struct attribute_group mbc_attr_group = {
258 .name = NULL, /* put in device directory */
259 .attrs = pcf50633_mbc_sysfs_entries,
260};
261
262static void
263pcf50633_mbc_irq_handler(int irq, void *data)
264{
265 struct pcf50633_mbc *mbc = data;
266
267 /* USB */
268 if (irq == PCF50633_IRQ_USBINS) {
269 mbc->usb_online = 1;
270 } else if (irq == PCF50633_IRQ_USBREM) {
271 mbc->usb_online = 0;
Balaji Raof5714dc2009-01-09 01:50:55 +0100272 pcf50633_mbc_usb_curlim_set(mbc->pcf, 0);
273 }
274
275 /* Adapter */
Paul Fertserc3297952009-11-05 00:24:59 +0300276 if (irq == PCF50633_IRQ_ADPINS)
Balaji Raof5714dc2009-01-09 01:50:55 +0100277 mbc->adapter_online = 1;
Paul Fertserc3297952009-11-05 00:24:59 +0300278 else if (irq == PCF50633_IRQ_ADPREM)
Balaji Raof5714dc2009-01-09 01:50:55 +0100279 mbc->adapter_online = 0;
Balaji Raof5714dc2009-01-09 01:50:55 +0100280
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100281 power_supply_changed(mbc->ac);
282 power_supply_changed(mbc->usb);
283 power_supply_changed(mbc->adapter);
Balaji Raof5714dc2009-01-09 01:50:55 +0100284
285 if (mbc->pcf->pdata->mbc_event_callback)
286 mbc->pcf->pdata->mbc_event_callback(mbc->pcf, irq);
287}
288
289static int adapter_get_property(struct power_supply *psy,
290 enum power_supply_property psp,
291 union power_supply_propval *val)
292{
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100293 struct pcf50633_mbc *mbc = power_supply_get_drvdata(psy);
Balaji Raof5714dc2009-01-09 01:50:55 +0100294 int ret = 0;
295
296 switch (psp) {
297 case POWER_SUPPLY_PROP_ONLINE:
298 val->intval = mbc->adapter_online;
299 break;
300 default:
301 ret = -EINVAL;
302 break;
303 }
304 return ret;
305}
306
307static int usb_get_property(struct power_supply *psy,
308 enum power_supply_property psp,
309 union power_supply_propval *val)
310{
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100311 struct pcf50633_mbc *mbc = power_supply_get_drvdata(psy);
Balaji Raof5714dc2009-01-09 01:50:55 +0100312 int ret = 0;
Sean McNeil7677f332009-11-05 00:24:54 +0300313 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
314 PCF50633_MBCC7_USB_MASK;
Balaji Raof5714dc2009-01-09 01:50:55 +0100315
316 switch (psp) {
317 case POWER_SUPPLY_PROP_ONLINE:
Sean McNeil7677f332009-11-05 00:24:54 +0300318 val->intval = mbc->usb_online &&
319 (usblim <= PCF50633_MBCC7_USB_500mA);
320 break;
321 default:
322 ret = -EINVAL;
323 break;
324 }
325 return ret;
326}
327
328static int ac_get_property(struct power_supply *psy,
329 enum power_supply_property psp,
330 union power_supply_propval *val)
331{
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100332 struct pcf50633_mbc *mbc = power_supply_get_drvdata(psy);
Sean McNeil7677f332009-11-05 00:24:54 +0300333 int ret = 0;
334 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
335 PCF50633_MBCC7_USB_MASK;
336
337 switch (psp) {
338 case POWER_SUPPLY_PROP_ONLINE:
339 val->intval = mbc->usb_online &&
340 (usblim == PCF50633_MBCC7_USB_1000mA);
Balaji Raof5714dc2009-01-09 01:50:55 +0100341 break;
342 default:
343 ret = -EINVAL;
344 break;
345 }
346 return ret;
347}
348
349static enum power_supply_property power_props[] = {
350 POWER_SUPPLY_PROP_ONLINE,
351};
352
353static const u8 mbc_irq_handlers[] = {
354 PCF50633_IRQ_ADPINS,
355 PCF50633_IRQ_ADPREM,
356 PCF50633_IRQ_USBINS,
357 PCF50633_IRQ_USBREM,
358 PCF50633_IRQ_BATFULL,
359 PCF50633_IRQ_CHGHALT,
360 PCF50633_IRQ_THLIMON,
361 PCF50633_IRQ_THLIMOFF,
362 PCF50633_IRQ_USBLIMON,
363 PCF50633_IRQ_USBLIMOFF,
364 PCF50633_IRQ_LOWSYS,
365 PCF50633_IRQ_LOWBAT,
366};
367
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100368static const struct power_supply_desc pcf50633_mbc_adapter_desc = {
369 .name = "adapter",
370 .type = POWER_SUPPLY_TYPE_MAINS,
371 .properties = power_props,
372 .num_properties = ARRAY_SIZE(power_props),
373 .get_property = &adapter_get_property,
374};
375
376static const struct power_supply_desc pcf50633_mbc_usb_desc = {
377 .name = "usb",
378 .type = POWER_SUPPLY_TYPE_USB,
379 .properties = power_props,
380 .num_properties = ARRAY_SIZE(power_props),
381 .get_property = usb_get_property,
382};
383
384static const struct power_supply_desc pcf50633_mbc_ac_desc = {
385 .name = "ac",
386 .type = POWER_SUPPLY_TYPE_MAINS,
387 .properties = power_props,
388 .num_properties = ARRAY_SIZE(power_props),
389 .get_property = ac_get_property,
390};
391
Bill Pembertonc8afa642012-11-19 13:22:23 -0500392static int pcf50633_mbc_probe(struct platform_device *pdev)
Balaji Raof5714dc2009-01-09 01:50:55 +0100393{
Krzysztof Kozlowski2dc92152015-03-12 08:44:02 +0100394 struct power_supply_config psy_cfg = {};
Balaji Raof5714dc2009-01-09 01:50:55 +0100395 struct pcf50633_mbc *mbc;
Balaji Raof5714dc2009-01-09 01:50:55 +0100396 int ret;
397 int i;
398 u8 mbcs1;
399
Jingoo Hanc09dd7d2013-03-11 15:35:38 +0900400 mbc = devm_kzalloc(&pdev->dev, sizeof(*mbc), GFP_KERNEL);
Balaji Raof5714dc2009-01-09 01:50:55 +0100401 if (!mbc)
402 return -ENOMEM;
403
404 platform_set_drvdata(pdev, mbc);
Lars-Peter Clausen68d641e2009-10-14 02:12:33 +0400405 mbc->pcf = dev_to_pcf50633(pdev->dev.parent);
Balaji Raof5714dc2009-01-09 01:50:55 +0100406
407 /* Set up IRQ handlers */
408 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
409 pcf50633_register_irq(mbc->pcf, mbc_irq_handlers[i],
410 pcf50633_mbc_irq_handler, mbc);
411
Krzysztof Kozlowski2dc92152015-03-12 08:44:02 +0100412 psy_cfg.supplied_to = mbc->pcf->pdata->batteries;
413 psy_cfg.num_supplicants = mbc->pcf->pdata->num_batteries;
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100414 psy_cfg.drv_data = mbc;
Krzysztof Kozlowski2dc92152015-03-12 08:44:02 +0100415
Balaji Raof5714dc2009-01-09 01:50:55 +0100416 /* Create power supplies */
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100417 mbc->adapter = power_supply_register(&pdev->dev,
418 &pcf50633_mbc_adapter_desc,
419 &psy_cfg);
420 if (IS_ERR(mbc->adapter)) {
Balaji Raof5714dc2009-01-09 01:50:55 +0100421 dev_err(mbc->pcf->dev, "failed to register adapter\n");
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100422 ret = PTR_ERR(mbc->adapter);
Balaji Raof5714dc2009-01-09 01:50:55 +0100423 return ret;
424 }
425
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100426 mbc->usb = power_supply_register(&pdev->dev, &pcf50633_mbc_usb_desc,
427 &psy_cfg);
428 if (IS_ERR(mbc->usb)) {
Balaji Raof5714dc2009-01-09 01:50:55 +0100429 dev_err(mbc->pcf->dev, "failed to register usb\n");
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100430 power_supply_unregister(mbc->adapter);
431 ret = PTR_ERR(mbc->usb);
Balaji Raof5714dc2009-01-09 01:50:55 +0100432 return ret;
433 }
434
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100435 mbc->ac = power_supply_register(&pdev->dev, &pcf50633_mbc_ac_desc,
436 &psy_cfg);
437 if (IS_ERR(mbc->ac)) {
Sean McNeil7677f332009-11-05 00:24:54 +0300438 dev_err(mbc->pcf->dev, "failed to register ac\n");
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100439 power_supply_unregister(mbc->adapter);
440 power_supply_unregister(mbc->usb);
441 ret = PTR_ERR(mbc->ac);
Sean McNeil7677f332009-11-05 00:24:54 +0300442 return ret;
443 }
Balaji Rao9705ecc2009-01-27 19:23:12 +0530444
Balaji Raof5714dc2009-01-09 01:50:55 +0100445 ret = sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group);
446 if (ret)
447 dev_err(mbc->pcf->dev, "failed to create sysfs entries\n");
448
449 mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1);
450 if (mbcs1 & PCF50633_MBCS1_USBPRES)
451 pcf50633_mbc_irq_handler(PCF50633_IRQ_USBINS, mbc);
452 if (mbcs1 & PCF50633_MBCS1_ADAPTPRES)
453 pcf50633_mbc_irq_handler(PCF50633_IRQ_ADPINS, mbc);
454
455 return 0;
456}
457
Bill Pemberton415ec692012-11-19 13:26:07 -0500458static int pcf50633_mbc_remove(struct platform_device *pdev)
Balaji Raof5714dc2009-01-09 01:50:55 +0100459{
460 struct pcf50633_mbc *mbc = platform_get_drvdata(pdev);
461 int i;
462
463 /* Remove IRQ handlers */
464 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
465 pcf50633_free_irq(mbc->pcf, mbc_irq_handlers[i]);
466
Axel Lin305da8f2010-09-21 16:35:57 +0800467 sysfs_remove_group(&pdev->dev.kobj, &mbc_attr_group);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100468 power_supply_unregister(mbc->usb);
469 power_supply_unregister(mbc->adapter);
470 power_supply_unregister(mbc->ac);
Balaji Rao9705ecc2009-01-27 19:23:12 +0530471
Balaji Raof5714dc2009-01-09 01:50:55 +0100472 return 0;
473}
474
475static struct platform_driver pcf50633_mbc_driver = {
476 .driver = {
477 .name = "pcf50633-mbc",
478 },
479 .probe = pcf50633_mbc_probe,
Bill Pemberton28ea73f2012-11-19 13:20:40 -0500480 .remove = pcf50633_mbc_remove,
Balaji Raof5714dc2009-01-09 01:50:55 +0100481};
482
Axel Lin300bac72011-11-26 12:01:10 +0800483module_platform_driver(pcf50633_mbc_driver);
Balaji Raof5714dc2009-01-09 01:50:55 +0100484
485MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
486MODULE_DESCRIPTION("PCF50633 mbc driver");
487MODULE_LICENSE("GPL");
488MODULE_ALIAS("platform:pcf50633-mbc");