Bluetooth: Remove unneeded initializer for management command table
[linux/fpc-iii.git] / drivers / power / max77693_charger.c
blobb042970fdeafa787ab4b464cdcc2175aebd3423a
1 /*
2 * max77693_charger.c - Battery charger driver for the Maxim 77693
4 * Copyright (C) 2014 Samsung Electronics
5 * Krzysztof Kozlowski <k.kozlowski@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/module.h>
19 #include <linux/platform_device.h>
20 #include <linux/power_supply.h>
21 #include <linux/regmap.h>
22 #include <linux/mfd/max77693.h>
23 #include <linux/mfd/max77693-private.h>
25 static const char *max77693_charger_name = "max77693-charger";
26 static const char *max77693_charger_model = "MAX77693";
27 static const char *max77693_charger_manufacturer = "Maxim Integrated";
29 struct max77693_charger {
30 struct device *dev;
31 struct max77693_dev *max77693;
32 struct power_supply charger;
34 u32 constant_volt;
35 u32 min_system_volt;
36 u32 thermal_regulation_temp;
37 u32 batttery_overcurrent;
38 u32 charge_input_threshold_volt;
41 static int max77693_get_charger_state(struct regmap *regmap)
43 int state;
44 unsigned int data;
46 if (regmap_read(regmap, MAX77693_CHG_REG_CHG_DETAILS_01, &data) < 0)
47 return POWER_SUPPLY_STATUS_UNKNOWN;
49 data &= CHG_DETAILS_01_CHG_MASK;
50 data >>= CHG_DETAILS_01_CHG_SHIFT;
52 switch (data) {
53 case MAX77693_CHARGING_PREQUALIFICATION:
54 case MAX77693_CHARGING_FAST_CONST_CURRENT:
55 case MAX77693_CHARGING_FAST_CONST_VOLTAGE:
56 case MAX77693_CHARGING_TOP_OFF:
57 /* In high temp the charging current is reduced, but still charging */
58 case MAX77693_CHARGING_HIGH_TEMP:
59 state = POWER_SUPPLY_STATUS_CHARGING;
60 break;
61 case MAX77693_CHARGING_DONE:
62 state = POWER_SUPPLY_STATUS_FULL;
63 break;
64 case MAX77693_CHARGING_TIMER_EXPIRED:
65 case MAX77693_CHARGING_THERMISTOR_SUSPEND:
66 state = POWER_SUPPLY_STATUS_NOT_CHARGING;
67 break;
68 case MAX77693_CHARGING_OFF:
69 case MAX77693_CHARGING_OVER_TEMP:
70 case MAX77693_CHARGING_WATCHDOG_EXPIRED:
71 state = POWER_SUPPLY_STATUS_DISCHARGING;
72 break;
73 case MAX77693_CHARGING_RESERVED:
74 default:
75 state = POWER_SUPPLY_STATUS_UNKNOWN;
78 return state;
81 static int max77693_get_charge_type(struct regmap *regmap)
83 int state;
84 unsigned int data;
86 if (regmap_read(regmap, MAX77693_CHG_REG_CHG_DETAILS_01, &data) < 0)
87 return POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
89 data &= CHG_DETAILS_01_CHG_MASK;
90 data >>= CHG_DETAILS_01_CHG_SHIFT;
92 switch (data) {
93 case MAX77693_CHARGING_PREQUALIFICATION:
95 * Top-off: trickle or fast? In top-off the current varies between
96 * 100 and 250 mA. It is higher than prequalification current.
98 case MAX77693_CHARGING_TOP_OFF:
99 state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
100 break;
101 case MAX77693_CHARGING_FAST_CONST_CURRENT:
102 case MAX77693_CHARGING_FAST_CONST_VOLTAGE:
103 /* In high temp the charging current is reduced, but still charging */
104 case MAX77693_CHARGING_HIGH_TEMP:
105 state = POWER_SUPPLY_CHARGE_TYPE_FAST;
106 break;
107 case MAX77693_CHARGING_DONE:
108 case MAX77693_CHARGING_TIMER_EXPIRED:
109 case MAX77693_CHARGING_THERMISTOR_SUSPEND:
110 case MAX77693_CHARGING_OFF:
111 case MAX77693_CHARGING_OVER_TEMP:
112 case MAX77693_CHARGING_WATCHDOG_EXPIRED:
113 state = POWER_SUPPLY_CHARGE_TYPE_NONE;
114 break;
115 case MAX77693_CHARGING_RESERVED:
116 default:
117 state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
120 return state;
124 * Supported health statuses:
125 * - POWER_SUPPLY_HEALTH_DEAD
126 * - POWER_SUPPLY_HEALTH_GOOD
127 * - POWER_SUPPLY_HEALTH_OVERVOLTAGE
128 * - POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE
129 * - POWER_SUPPLY_HEALTH_UNKNOWN
130 * - POWER_SUPPLY_HEALTH_UNSPEC_FAILURE
132 static int max77693_get_battery_health(struct regmap *regmap)
134 int state;
135 unsigned int data;
137 if (regmap_read(regmap, MAX77693_CHG_REG_CHG_DETAILS_01, &data) < 0)
138 return POWER_SUPPLY_HEALTH_UNKNOWN;
140 data &= CHG_DETAILS_01_BAT_MASK;
141 data >>= CHG_DETAILS_01_BAT_SHIFT;
143 switch (data) {
144 case MAX77693_BATTERY_NOBAT:
145 state = POWER_SUPPLY_HEALTH_DEAD;
146 break;
147 case MAX77693_BATTERY_PREQUALIFICATION:
148 case MAX77693_BATTERY_GOOD:
149 case MAX77693_BATTERY_LOWVOLTAGE:
150 state = POWER_SUPPLY_HEALTH_GOOD;
151 break;
152 case MAX77693_BATTERY_TIMER_EXPIRED:
154 * Took longer to charge than expected, charging suspended.
155 * Damaged battery?
157 state = POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE;
158 break;
159 case MAX77693_BATTERY_OVERVOLTAGE:
160 state = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
161 break;
162 case MAX77693_BATTERY_OVERCURRENT:
163 state = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
164 break;
165 case MAX77693_BATTERY_RESERVED:
166 default:
167 state = POWER_SUPPLY_HEALTH_UNKNOWN;
168 break;
171 return state;
174 static int max77693_get_present(struct regmap *regmap)
176 unsigned int data;
179 * Read CHG_INT_OK register. High DETBAT bit here should be
180 * equal to value 0x0 in CHG_DETAILS_01/BAT field.
182 regmap_read(regmap, MAX77693_CHG_REG_CHG_INT_OK, &data);
183 if (data & CHG_INT_OK_DETBAT_MASK)
184 return 0;
185 return 1;
188 static int max77693_get_online(struct regmap *regmap)
190 unsigned int data;
192 regmap_read(regmap, MAX77693_CHG_REG_CHG_INT_OK, &data);
193 if (data & CHG_INT_OK_CHGIN_MASK)
194 return 1;
195 return 0;
198 static enum power_supply_property max77693_charger_props[] = {
199 POWER_SUPPLY_PROP_STATUS,
200 POWER_SUPPLY_PROP_CHARGE_TYPE,
201 POWER_SUPPLY_PROP_HEALTH,
202 POWER_SUPPLY_PROP_PRESENT,
203 POWER_SUPPLY_PROP_ONLINE,
204 POWER_SUPPLY_PROP_MODEL_NAME,
205 POWER_SUPPLY_PROP_MANUFACTURER,
208 static int max77693_charger_get_property(struct power_supply *psy,
209 enum power_supply_property psp,
210 union power_supply_propval *val)
212 struct max77693_charger *chg = container_of(psy,
213 struct max77693_charger,
214 charger);
215 struct regmap *regmap = chg->max77693->regmap;
216 int ret = 0;
218 switch (psp) {
219 case POWER_SUPPLY_PROP_STATUS:
220 val->intval = max77693_get_charger_state(regmap);
221 break;
222 case POWER_SUPPLY_PROP_CHARGE_TYPE:
223 val->intval = max77693_get_charge_type(regmap);
224 break;
225 case POWER_SUPPLY_PROP_HEALTH:
226 val->intval = max77693_get_battery_health(regmap);
227 break;
228 case POWER_SUPPLY_PROP_PRESENT:
229 val->intval = max77693_get_present(regmap);
230 break;
231 case POWER_SUPPLY_PROP_ONLINE:
232 val->intval = max77693_get_online(regmap);
233 break;
234 case POWER_SUPPLY_PROP_MODEL_NAME:
235 val->strval = max77693_charger_model;
236 break;
237 case POWER_SUPPLY_PROP_MANUFACTURER:
238 val->strval = max77693_charger_manufacturer;
239 break;
240 default:
241 return -EINVAL;
244 return ret;
247 static ssize_t device_attr_store(struct device *dev,
248 struct device_attribute *attr, const char *buf, size_t count,
249 int (*fn)(struct max77693_charger *, unsigned long))
251 struct max77693_charger *chg = dev_get_drvdata(dev);
252 unsigned long val;
253 int ret;
255 ret = kstrtoul(buf, 10, &val);
256 if (ret)
257 return ret;
259 ret = fn(chg, val);
260 if (ret)
261 return ret;
263 return count;
266 static ssize_t fast_charge_timer_show(struct device *dev,
267 struct device_attribute *attr, char *buf)
269 struct max77693_charger *chg = dev_get_drvdata(dev);
270 unsigned int data, val;
271 int ret;
273 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_01,
274 &data);
275 if (ret < 0)
276 return ret;
278 data &= CHG_CNFG_01_FCHGTIME_MASK;
279 data >>= CHG_CNFG_01_FCHGTIME_SHIFT;
280 switch (data) {
281 case 0x1 ... 0x7:
282 /* Starting from 4 hours, step by 2 hours */
283 val = 4 + (data - 1) * 2;
284 break;
285 case 0x0:
286 default:
287 val = 0;
288 break;
291 return scnprintf(buf, PAGE_SIZE, "%u\n", val);
294 static int max77693_set_fast_charge_timer(struct max77693_charger *chg,
295 unsigned long hours)
297 unsigned int data;
300 * 0x00 - disable
301 * 0x01 - 4h
302 * 0x02 - 6h
303 * ...
304 * 0x07 - 16h
305 * Round down odd values.
307 switch (hours) {
308 case 4 ... 16:
309 data = (hours - 4) / 2 + 1;
310 break;
311 case 0:
312 /* Disable */
313 data = 0;
314 break;
315 default:
316 return -EINVAL;
318 data <<= CHG_CNFG_01_FCHGTIME_SHIFT;
320 return regmap_update_bits(chg->max77693->regmap,
321 MAX77693_CHG_REG_CHG_CNFG_01,
322 CHG_CNFG_01_FCHGTIME_MASK, data);
325 static ssize_t fast_charge_timer_store(struct device *dev,
326 struct device_attribute *attr, const char *buf, size_t count)
328 return device_attr_store(dev, attr, buf, count,
329 max77693_set_fast_charge_timer);
332 static ssize_t top_off_threshold_current_show(struct device *dev,
333 struct device_attribute *attr, char *buf)
335 struct max77693_charger *chg = dev_get_drvdata(dev);
336 unsigned int data, val;
337 int ret;
339 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_03,
340 &data);
341 if (ret < 0)
342 return ret;
344 data &= CHG_CNFG_03_TOITH_MASK;
345 data >>= CHG_CNFG_03_TOITH_SHIFT;
347 if (data <= 0x04)
348 val = 100000 + data * 25000;
349 else
350 val = data * 50000;
352 return scnprintf(buf, PAGE_SIZE, "%u\n", val);
355 static int max77693_set_top_off_threshold_current(struct max77693_charger *chg,
356 unsigned long uamp)
358 unsigned int data;
360 if (uamp < 100000 || uamp > 350000)
361 return -EINVAL;
363 if (uamp <= 200000)
364 data = (uamp - 100000) / 25000;
365 else
366 /* (200000, 350000> */
367 data = uamp / 50000;
369 data <<= CHG_CNFG_03_TOITH_SHIFT;
371 return regmap_update_bits(chg->max77693->regmap,
372 MAX77693_CHG_REG_CHG_CNFG_03,
373 CHG_CNFG_03_TOITH_MASK, data);
376 static ssize_t top_off_threshold_current_store(struct device *dev,
377 struct device_attribute *attr, const char *buf, size_t count)
379 return device_attr_store(dev, attr, buf, count,
380 max77693_set_top_off_threshold_current);
383 static ssize_t top_off_timer_show(struct device *dev,
384 struct device_attribute *attr, char *buf)
386 struct max77693_charger *chg = dev_get_drvdata(dev);
387 unsigned int data, val;
388 int ret;
390 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_03,
391 &data);
392 if (ret < 0)
393 return ret;
395 data &= CHG_CNFG_03_TOTIME_MASK;
396 data >>= CHG_CNFG_03_TOTIME_SHIFT;
398 val = data * 10;
400 return scnprintf(buf, PAGE_SIZE, "%u\n", val);
403 static int max77693_set_top_off_timer(struct max77693_charger *chg,
404 unsigned long minutes)
406 unsigned int data;
408 if (minutes > 70)
409 return -EINVAL;
411 data = minutes / 10;
412 data <<= CHG_CNFG_03_TOTIME_SHIFT;
414 return regmap_update_bits(chg->max77693->regmap,
415 MAX77693_CHG_REG_CHG_CNFG_03,
416 CHG_CNFG_03_TOTIME_MASK, data);
419 static ssize_t top_off_timer_store(struct device *dev,
420 struct device_attribute *attr, const char *buf, size_t count)
422 return device_attr_store(dev, attr, buf, count,
423 max77693_set_top_off_timer);
426 static DEVICE_ATTR_RW(fast_charge_timer);
427 static DEVICE_ATTR_RW(top_off_threshold_current);
428 static DEVICE_ATTR_RW(top_off_timer);
430 static int max77693_set_constant_volt(struct max77693_charger *chg,
431 unsigned int uvolt)
433 unsigned int data;
436 * 0x00 - 3.650 V
437 * 0x01 - 3.675 V
438 * ...
439 * 0x1b - 4.325 V
440 * 0x1c - 4.340 V
441 * 0x1d - 4.350 V
442 * 0x1e - 4.375 V
443 * 0x1f - 4.400 V
445 if (uvolt >= 3650000 && uvolt < 4340000)
446 data = (uvolt - 3650000) / 25000;
447 else if (uvolt >= 4340000 && uvolt < 4350000)
448 data = 0x1c;
449 else if (uvolt >= 4350000 && uvolt <= 4400000)
450 data = 0x1d + (uvolt - 4350000) / 25000;
451 else {
452 dev_err(chg->dev, "Wrong value for charging constant voltage\n");
453 return -EINVAL;
456 data <<= CHG_CNFG_04_CHGCVPRM_SHIFT;
458 dev_dbg(chg->dev, "Charging constant voltage: %u (0x%x)\n", uvolt,
459 data);
461 return regmap_update_bits(chg->max77693->regmap,
462 MAX77693_CHG_REG_CHG_CNFG_04,
463 CHG_CNFG_04_CHGCVPRM_MASK, data);
466 static int max77693_set_min_system_volt(struct max77693_charger *chg,
467 unsigned int uvolt)
469 unsigned int data;
471 if (uvolt < 3000000 || uvolt > 3700000) {
472 dev_err(chg->dev, "Wrong value for minimum system regulation voltage\n");
473 return -EINVAL;
476 data = (uvolt - 3000000) / 100000;
478 data <<= CHG_CNFG_04_MINVSYS_SHIFT;
480 dev_dbg(chg->dev, "Minimum system regulation voltage: %u (0x%x)\n",
481 uvolt, data);
483 return regmap_update_bits(chg->max77693->regmap,
484 MAX77693_CHG_REG_CHG_CNFG_04,
485 CHG_CNFG_04_MINVSYS_MASK, data);
488 static int max77693_set_thermal_regulation_temp(struct max77693_charger *chg,
489 unsigned int cels)
491 unsigned int data;
493 switch (cels) {
494 case 70:
495 case 85:
496 case 100:
497 case 115:
498 data = (cels - 70) / 15;
499 break;
500 default:
501 dev_err(chg->dev, "Wrong value for thermal regulation loop temperature\n");
502 return -EINVAL;
505 data <<= CHG_CNFG_07_REGTEMP_SHIFT;
507 dev_dbg(chg->dev, "Thermal regulation loop temperature: %u (0x%x)\n",
508 cels, data);
510 return regmap_update_bits(chg->max77693->regmap,
511 MAX77693_CHG_REG_CHG_CNFG_07,
512 CHG_CNFG_07_REGTEMP_MASK, data);
515 static int max77693_set_batttery_overcurrent(struct max77693_charger *chg,
516 unsigned int uamp)
518 unsigned int data;
520 if (uamp && (uamp < 2000000 || uamp > 3500000)) {
521 dev_err(chg->dev, "Wrong value for battery overcurrent\n");
522 return -EINVAL;
525 if (uamp)
526 data = ((uamp - 2000000) / 250000) + 1;
527 else
528 data = 0; /* disable */
530 data <<= CHG_CNFG_12_B2SOVRC_SHIFT;
532 dev_dbg(chg->dev, "Battery overcurrent: %u (0x%x)\n", uamp, data);
534 return regmap_update_bits(chg->max77693->regmap,
535 MAX77693_CHG_REG_CHG_CNFG_12,
536 CHG_CNFG_12_B2SOVRC_MASK, data);
539 static int max77693_set_charge_input_threshold_volt(struct max77693_charger *chg,
540 unsigned int uvolt)
542 unsigned int data;
544 switch (uvolt) {
545 case 4300000:
546 data = 0x0;
547 break;
548 case 4700000:
549 case 4800000:
550 case 4900000:
551 data = (uvolt - 4700000) / 100000;
552 default:
553 dev_err(chg->dev, "Wrong value for charge input voltage regulation threshold\n");
554 return -EINVAL;
557 data <<= CHG_CNFG_12_VCHGINREG_SHIFT;
559 dev_dbg(chg->dev, "Charge input voltage regulation threshold: %u (0x%x)\n",
560 uvolt, data);
562 return regmap_update_bits(chg->max77693->regmap,
563 MAX77693_CHG_REG_CHG_CNFG_12,
564 CHG_CNFG_12_VCHGINREG_MASK, data);
568 * Sets charger registers to proper and safe default values.
570 static int max77693_reg_init(struct max77693_charger *chg)
572 int ret;
573 unsigned int data;
575 /* Unlock charger register protection */
576 data = (0x3 << CHG_CNFG_06_CHGPROT_SHIFT);
577 ret = regmap_update_bits(chg->max77693->regmap,
578 MAX77693_CHG_REG_CHG_CNFG_06,
579 CHG_CNFG_06_CHGPROT_MASK, data);
580 if (ret) {
581 dev_err(chg->dev, "Error unlocking registers: %d\n", ret);
582 return ret;
585 ret = max77693_set_fast_charge_timer(chg, DEFAULT_FAST_CHARGE_TIMER);
586 if (ret)
587 return ret;
589 ret = max77693_set_top_off_threshold_current(chg,
590 DEFAULT_TOP_OFF_THRESHOLD_CURRENT);
591 if (ret)
592 return ret;
594 ret = max77693_set_top_off_timer(chg, DEFAULT_TOP_OFF_TIMER);
595 if (ret)
596 return ret;
598 ret = max77693_set_constant_volt(chg, chg->constant_volt);
599 if (ret)
600 return ret;
602 ret = max77693_set_min_system_volt(chg, chg->min_system_volt);
603 if (ret)
604 return ret;
606 ret = max77693_set_thermal_regulation_temp(chg,
607 chg->thermal_regulation_temp);
608 if (ret)
609 return ret;
611 ret = max77693_set_batttery_overcurrent(chg, chg->batttery_overcurrent);
612 if (ret)
613 return ret;
615 return max77693_set_charge_input_threshold_volt(chg,
616 chg->charge_input_threshold_volt);
619 #ifdef CONFIG_OF
620 static int max77693_dt_init(struct device *dev, struct max77693_charger *chg)
622 struct device_node *np = dev->of_node;
624 if (!np) {
625 dev_err(dev, "no charger OF node\n");
626 return -EINVAL;
629 if (of_property_read_u32(np, "maxim,constant-microvolt",
630 &chg->constant_volt))
631 chg->constant_volt = DEFAULT_CONSTANT_VOLT;
633 if (of_property_read_u32(np, "maxim,min-system-microvolt",
634 &chg->min_system_volt))
635 chg->min_system_volt = DEFAULT_MIN_SYSTEM_VOLT;
637 if (of_property_read_u32(np, "maxim,thermal-regulation-celsius",
638 &chg->thermal_regulation_temp))
639 chg->thermal_regulation_temp = DEFAULT_THERMAL_REGULATION_TEMP;
641 if (of_property_read_u32(np, "maxim,battery-overcurrent-microamp",
642 &chg->batttery_overcurrent))
643 chg->batttery_overcurrent = DEFAULT_BATTERY_OVERCURRENT;
645 if (of_property_read_u32(np, "maxim,charge-input-threshold-microvolt",
646 &chg->charge_input_threshold_volt))
647 chg->charge_input_threshold_volt =
648 DEFAULT_CHARGER_INPUT_THRESHOLD_VOLT;
650 return 0;
652 #else /* CONFIG_OF */
653 static int max77693_dt_init(struct device *dev, struct max77693_charger *chg)
655 return 0;
657 #endif /* CONFIG_OF */
659 static int max77693_charger_probe(struct platform_device *pdev)
661 struct max77693_charger *chg;
662 struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent);
663 int ret;
665 chg = devm_kzalloc(&pdev->dev, sizeof(*chg), GFP_KERNEL);
666 if (!chg)
667 return -ENOMEM;
669 platform_set_drvdata(pdev, chg);
670 chg->dev = &pdev->dev;
671 chg->max77693 = max77693;
673 ret = max77693_dt_init(&pdev->dev, chg);
674 if (ret)
675 return ret;
677 ret = max77693_reg_init(chg);
678 if (ret)
679 return ret;
681 chg->charger.name = max77693_charger_name;
682 chg->charger.type = POWER_SUPPLY_TYPE_BATTERY;
683 chg->charger.properties = max77693_charger_props;
684 chg->charger.num_properties = ARRAY_SIZE(max77693_charger_props);
685 chg->charger.get_property = max77693_charger_get_property;
687 ret = device_create_file(&pdev->dev, &dev_attr_fast_charge_timer);
688 if (ret) {
689 dev_err(&pdev->dev, "failed: create fast charge timer sysfs entry\n");
690 goto err;
693 ret = device_create_file(&pdev->dev,
694 &dev_attr_top_off_threshold_current);
695 if (ret) {
696 dev_err(&pdev->dev, "failed: create top off current sysfs entry\n");
697 goto err;
700 ret = device_create_file(&pdev->dev, &dev_attr_top_off_timer);
701 if (ret) {
702 dev_err(&pdev->dev, "failed: create top off timer sysfs entry\n");
703 goto err;
706 ret = power_supply_register(&pdev->dev, &chg->charger);
707 if (ret) {
708 dev_err(&pdev->dev, "failed: power supply register\n");
709 goto err;
712 return 0;
714 err:
715 device_remove_file(&pdev->dev, &dev_attr_top_off_timer);
716 device_remove_file(&pdev->dev, &dev_attr_top_off_threshold_current);
717 device_remove_file(&pdev->dev, &dev_attr_fast_charge_timer);
719 return ret;
722 static int max77693_charger_remove(struct platform_device *pdev)
724 struct max77693_charger *chg = platform_get_drvdata(pdev);
726 device_remove_file(&pdev->dev, &dev_attr_top_off_timer);
727 device_remove_file(&pdev->dev, &dev_attr_top_off_threshold_current);
728 device_remove_file(&pdev->dev, &dev_attr_fast_charge_timer);
730 power_supply_unregister(&chg->charger);
732 return 0;
735 static const struct platform_device_id max77693_charger_id[] = {
736 { "max77693-charger", 0, },
739 MODULE_DEVICE_TABLE(platform, max77693_charger_id);
741 static struct platform_driver max77693_charger_driver = {
742 .driver = {
743 .name = "max77693-charger",
745 .probe = max77693_charger_probe,
746 .remove = max77693_charger_remove,
747 .id_table = max77693_charger_id,
749 module_platform_driver(max77693_charger_driver);
751 MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>");
752 MODULE_DESCRIPTION("Maxim 77693 charger driver");
753 MODULE_LICENSE("GPL");