gro: Allow tunnel stacking in the case of FOU/GUE
[linux/fpc-iii.git] / drivers / power / max77693_charger.c
blob754879eb59f67b878fc70b6b19dc10935c15d257
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 #define 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, int *val)
43 int ret;
44 unsigned int data;
46 ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_DETAILS_01, &data);
47 if (ret < 0)
48 return ret;
50 data &= CHG_DETAILS_01_CHG_MASK;
51 data >>= CHG_DETAILS_01_CHG_SHIFT;
53 switch (data) {
54 case MAX77693_CHARGING_PREQUALIFICATION:
55 case MAX77693_CHARGING_FAST_CONST_CURRENT:
56 case MAX77693_CHARGING_FAST_CONST_VOLTAGE:
57 case MAX77693_CHARGING_TOP_OFF:
58 /* In high temp the charging current is reduced, but still charging */
59 case MAX77693_CHARGING_HIGH_TEMP:
60 *val = POWER_SUPPLY_STATUS_CHARGING;
61 break;
62 case MAX77693_CHARGING_DONE:
63 *val = POWER_SUPPLY_STATUS_FULL;
64 break;
65 case MAX77693_CHARGING_TIMER_EXPIRED:
66 case MAX77693_CHARGING_THERMISTOR_SUSPEND:
67 *val = POWER_SUPPLY_STATUS_NOT_CHARGING;
68 break;
69 case MAX77693_CHARGING_OFF:
70 case MAX77693_CHARGING_OVER_TEMP:
71 case MAX77693_CHARGING_WATCHDOG_EXPIRED:
72 *val = POWER_SUPPLY_STATUS_DISCHARGING;
73 break;
74 case MAX77693_CHARGING_RESERVED:
75 default:
76 *val = POWER_SUPPLY_STATUS_UNKNOWN;
79 return 0;
82 static int max77693_get_charge_type(struct regmap *regmap, int *val)
84 int ret;
85 unsigned int data;
87 ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_DETAILS_01, &data);
88 if (ret < 0)
89 return ret;
91 data &= CHG_DETAILS_01_CHG_MASK;
92 data >>= CHG_DETAILS_01_CHG_SHIFT;
94 switch (data) {
95 case MAX77693_CHARGING_PREQUALIFICATION:
97 * Top-off: trickle or fast? In top-off the current varies between
98 * 100 and 250 mA. It is higher than prequalification current.
100 case MAX77693_CHARGING_TOP_OFF:
101 *val = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
102 break;
103 case MAX77693_CHARGING_FAST_CONST_CURRENT:
104 case MAX77693_CHARGING_FAST_CONST_VOLTAGE:
105 /* In high temp the charging current is reduced, but still charging */
106 case MAX77693_CHARGING_HIGH_TEMP:
107 *val = POWER_SUPPLY_CHARGE_TYPE_FAST;
108 break;
109 case MAX77693_CHARGING_DONE:
110 case MAX77693_CHARGING_TIMER_EXPIRED:
111 case MAX77693_CHARGING_THERMISTOR_SUSPEND:
112 case MAX77693_CHARGING_OFF:
113 case MAX77693_CHARGING_OVER_TEMP:
114 case MAX77693_CHARGING_WATCHDOG_EXPIRED:
115 *val = POWER_SUPPLY_CHARGE_TYPE_NONE;
116 break;
117 case MAX77693_CHARGING_RESERVED:
118 default:
119 *val = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
122 return 0;
126 * Supported health statuses:
127 * - POWER_SUPPLY_HEALTH_DEAD
128 * - POWER_SUPPLY_HEALTH_GOOD
129 * - POWER_SUPPLY_HEALTH_OVERVOLTAGE
130 * - POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE
131 * - POWER_SUPPLY_HEALTH_UNKNOWN
132 * - POWER_SUPPLY_HEALTH_UNSPEC_FAILURE
134 static int max77693_get_battery_health(struct regmap *regmap, int *val)
136 int ret;
137 unsigned int data;
139 ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_DETAILS_01, &data);
140 if (ret < 0)
141 return ret;
143 data &= CHG_DETAILS_01_BAT_MASK;
144 data >>= CHG_DETAILS_01_BAT_SHIFT;
146 switch (data) {
147 case MAX77693_BATTERY_NOBAT:
148 *val = POWER_SUPPLY_HEALTH_DEAD;
149 break;
150 case MAX77693_BATTERY_PREQUALIFICATION:
151 case MAX77693_BATTERY_GOOD:
152 case MAX77693_BATTERY_LOWVOLTAGE:
153 *val = POWER_SUPPLY_HEALTH_GOOD;
154 break;
155 case MAX77693_BATTERY_TIMER_EXPIRED:
157 * Took longer to charge than expected, charging suspended.
158 * Damaged battery?
160 *val = POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE;
161 break;
162 case MAX77693_BATTERY_OVERVOLTAGE:
163 *val = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
164 break;
165 case MAX77693_BATTERY_OVERCURRENT:
166 *val = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
167 break;
168 case MAX77693_BATTERY_RESERVED:
169 default:
170 *val = POWER_SUPPLY_HEALTH_UNKNOWN;
171 break;
174 return 0;
177 static int max77693_get_present(struct regmap *regmap, int *val)
179 unsigned int data;
180 int ret;
183 * Read CHG_INT_OK register. High DETBAT bit here should be
184 * equal to value 0x0 in CHG_DETAILS_01/BAT field.
186 ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_INT_OK, &data);
187 if (ret < 0)
188 return ret;
190 *val = (data & CHG_INT_OK_DETBAT_MASK) ? 0 : 1;
192 return 0;
195 static int max77693_get_online(struct regmap *regmap, int *val)
197 unsigned int data;
198 int ret;
200 ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_INT_OK, &data);
201 if (ret < 0)
202 return ret;
204 *val = (data & CHG_INT_OK_CHGIN_MASK) ? 1 : 0;
206 return 0;
209 static enum power_supply_property max77693_charger_props[] = {
210 POWER_SUPPLY_PROP_STATUS,
211 POWER_SUPPLY_PROP_CHARGE_TYPE,
212 POWER_SUPPLY_PROP_HEALTH,
213 POWER_SUPPLY_PROP_PRESENT,
214 POWER_SUPPLY_PROP_ONLINE,
215 POWER_SUPPLY_PROP_MODEL_NAME,
216 POWER_SUPPLY_PROP_MANUFACTURER,
219 static int max77693_charger_get_property(struct power_supply *psy,
220 enum power_supply_property psp,
221 union power_supply_propval *val)
223 struct max77693_charger *chg = power_supply_get_drvdata(psy);
224 struct regmap *regmap = chg->max77693->regmap;
225 int ret = 0;
227 switch (psp) {
228 case POWER_SUPPLY_PROP_STATUS:
229 ret = max77693_get_charger_state(regmap, &val->intval);
230 break;
231 case POWER_SUPPLY_PROP_CHARGE_TYPE:
232 ret = max77693_get_charge_type(regmap, &val->intval);
233 break;
234 case POWER_SUPPLY_PROP_HEALTH:
235 ret = max77693_get_battery_health(regmap, &val->intval);
236 break;
237 case POWER_SUPPLY_PROP_PRESENT:
238 ret = max77693_get_present(regmap, &val->intval);
239 break;
240 case POWER_SUPPLY_PROP_ONLINE:
241 ret = max77693_get_online(regmap, &val->intval);
242 break;
243 case POWER_SUPPLY_PROP_MODEL_NAME:
244 val->strval = max77693_charger_model;
245 break;
246 case POWER_SUPPLY_PROP_MANUFACTURER:
247 val->strval = max77693_charger_manufacturer;
248 break;
249 default:
250 return -EINVAL;
253 return ret;
256 static const struct power_supply_desc max77693_charger_desc = {
257 .name = MAX77693_CHARGER_NAME,
258 .type = POWER_SUPPLY_TYPE_BATTERY,
259 .properties = max77693_charger_props,
260 .num_properties = ARRAY_SIZE(max77693_charger_props),
261 .get_property = max77693_charger_get_property,
264 static ssize_t device_attr_store(struct device *dev,
265 struct device_attribute *attr, const char *buf, size_t count,
266 int (*fn)(struct max77693_charger *, unsigned long))
268 struct max77693_charger *chg = dev_get_drvdata(dev);
269 unsigned long val;
270 int ret;
272 ret = kstrtoul(buf, 10, &val);
273 if (ret)
274 return ret;
276 ret = fn(chg, val);
277 if (ret)
278 return ret;
280 return count;
283 static ssize_t fast_charge_timer_show(struct device *dev,
284 struct device_attribute *attr, char *buf)
286 struct max77693_charger *chg = dev_get_drvdata(dev);
287 unsigned int data, val;
288 int ret;
290 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_01,
291 &data);
292 if (ret < 0)
293 return ret;
295 data &= CHG_CNFG_01_FCHGTIME_MASK;
296 data >>= CHG_CNFG_01_FCHGTIME_SHIFT;
297 switch (data) {
298 case 0x1 ... 0x7:
299 /* Starting from 4 hours, step by 2 hours */
300 val = 4 + (data - 1) * 2;
301 break;
302 case 0x0:
303 default:
304 val = 0;
305 break;
308 return scnprintf(buf, PAGE_SIZE, "%u\n", val);
311 static int max77693_set_fast_charge_timer(struct max77693_charger *chg,
312 unsigned long hours)
314 unsigned int data;
317 * 0x00 - disable
318 * 0x01 - 4h
319 * 0x02 - 6h
320 * ...
321 * 0x07 - 16h
322 * Round down odd values.
324 switch (hours) {
325 case 4 ... 16:
326 data = (hours - 4) / 2 + 1;
327 break;
328 case 0:
329 /* Disable */
330 data = 0;
331 break;
332 default:
333 return -EINVAL;
335 data <<= CHG_CNFG_01_FCHGTIME_SHIFT;
337 return regmap_update_bits(chg->max77693->regmap,
338 MAX77693_CHG_REG_CHG_CNFG_01,
339 CHG_CNFG_01_FCHGTIME_MASK, data);
342 static ssize_t fast_charge_timer_store(struct device *dev,
343 struct device_attribute *attr, const char *buf, size_t count)
345 return device_attr_store(dev, attr, buf, count,
346 max77693_set_fast_charge_timer);
349 static ssize_t top_off_threshold_current_show(struct device *dev,
350 struct device_attribute *attr, char *buf)
352 struct max77693_charger *chg = dev_get_drvdata(dev);
353 unsigned int data, val;
354 int ret;
356 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_03,
357 &data);
358 if (ret < 0)
359 return ret;
361 data &= CHG_CNFG_03_TOITH_MASK;
362 data >>= CHG_CNFG_03_TOITH_SHIFT;
364 if (data <= 0x04)
365 val = 100000 + data * 25000;
366 else
367 val = data * 50000;
369 return scnprintf(buf, PAGE_SIZE, "%u\n", val);
372 static int max77693_set_top_off_threshold_current(struct max77693_charger *chg,
373 unsigned long uamp)
375 unsigned int data;
377 if (uamp < 100000 || uamp > 350000)
378 return -EINVAL;
380 if (uamp <= 200000)
381 data = (uamp - 100000) / 25000;
382 else
383 /* (200000, 350000> */
384 data = uamp / 50000;
386 data <<= CHG_CNFG_03_TOITH_SHIFT;
388 return regmap_update_bits(chg->max77693->regmap,
389 MAX77693_CHG_REG_CHG_CNFG_03,
390 CHG_CNFG_03_TOITH_MASK, data);
393 static ssize_t top_off_threshold_current_store(struct device *dev,
394 struct device_attribute *attr, const char *buf, size_t count)
396 return device_attr_store(dev, attr, buf, count,
397 max77693_set_top_off_threshold_current);
400 static ssize_t top_off_timer_show(struct device *dev,
401 struct device_attribute *attr, char *buf)
403 struct max77693_charger *chg = dev_get_drvdata(dev);
404 unsigned int data, val;
405 int ret;
407 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_03,
408 &data);
409 if (ret < 0)
410 return ret;
412 data &= CHG_CNFG_03_TOTIME_MASK;
413 data >>= CHG_CNFG_03_TOTIME_SHIFT;
415 val = data * 10;
417 return scnprintf(buf, PAGE_SIZE, "%u\n", val);
420 static int max77693_set_top_off_timer(struct max77693_charger *chg,
421 unsigned long minutes)
423 unsigned int data;
425 if (minutes > 70)
426 return -EINVAL;
428 data = minutes / 10;
429 data <<= CHG_CNFG_03_TOTIME_SHIFT;
431 return regmap_update_bits(chg->max77693->regmap,
432 MAX77693_CHG_REG_CHG_CNFG_03,
433 CHG_CNFG_03_TOTIME_MASK, data);
436 static ssize_t top_off_timer_store(struct device *dev,
437 struct device_attribute *attr, const char *buf, size_t count)
439 return device_attr_store(dev, attr, buf, count,
440 max77693_set_top_off_timer);
443 static DEVICE_ATTR_RW(fast_charge_timer);
444 static DEVICE_ATTR_RW(top_off_threshold_current);
445 static DEVICE_ATTR_RW(top_off_timer);
447 static int max77693_set_constant_volt(struct max77693_charger *chg,
448 unsigned int uvolt)
450 unsigned int data;
453 * 0x00 - 3.650 V
454 * 0x01 - 3.675 V
455 * ...
456 * 0x1b - 4.325 V
457 * 0x1c - 4.340 V
458 * 0x1d - 4.350 V
459 * 0x1e - 4.375 V
460 * 0x1f - 4.400 V
462 if (uvolt >= 3650000 && uvolt < 4340000)
463 data = (uvolt - 3650000) / 25000;
464 else if (uvolt >= 4340000 && uvolt < 4350000)
465 data = 0x1c;
466 else if (uvolt >= 4350000 && uvolt <= 4400000)
467 data = 0x1d + (uvolt - 4350000) / 25000;
468 else {
469 dev_err(chg->dev, "Wrong value for charging constant voltage\n");
470 return -EINVAL;
473 data <<= CHG_CNFG_04_CHGCVPRM_SHIFT;
475 dev_dbg(chg->dev, "Charging constant voltage: %u (0x%x)\n", uvolt,
476 data);
478 return regmap_update_bits(chg->max77693->regmap,
479 MAX77693_CHG_REG_CHG_CNFG_04,
480 CHG_CNFG_04_CHGCVPRM_MASK, data);
483 static int max77693_set_min_system_volt(struct max77693_charger *chg,
484 unsigned int uvolt)
486 unsigned int data;
488 if (uvolt < 3000000 || uvolt > 3700000) {
489 dev_err(chg->dev, "Wrong value for minimum system regulation voltage\n");
490 return -EINVAL;
493 data = (uvolt - 3000000) / 100000;
495 data <<= CHG_CNFG_04_MINVSYS_SHIFT;
497 dev_dbg(chg->dev, "Minimum system regulation voltage: %u (0x%x)\n",
498 uvolt, data);
500 return regmap_update_bits(chg->max77693->regmap,
501 MAX77693_CHG_REG_CHG_CNFG_04,
502 CHG_CNFG_04_MINVSYS_MASK, data);
505 static int max77693_set_thermal_regulation_temp(struct max77693_charger *chg,
506 unsigned int cels)
508 unsigned int data;
510 switch (cels) {
511 case 70:
512 case 85:
513 case 100:
514 case 115:
515 data = (cels - 70) / 15;
516 break;
517 default:
518 dev_err(chg->dev, "Wrong value for thermal regulation loop temperature\n");
519 return -EINVAL;
522 data <<= CHG_CNFG_07_REGTEMP_SHIFT;
524 dev_dbg(chg->dev, "Thermal regulation loop temperature: %u (0x%x)\n",
525 cels, data);
527 return regmap_update_bits(chg->max77693->regmap,
528 MAX77693_CHG_REG_CHG_CNFG_07,
529 CHG_CNFG_07_REGTEMP_MASK, data);
532 static int max77693_set_batttery_overcurrent(struct max77693_charger *chg,
533 unsigned int uamp)
535 unsigned int data;
537 if (uamp && (uamp < 2000000 || uamp > 3500000)) {
538 dev_err(chg->dev, "Wrong value for battery overcurrent\n");
539 return -EINVAL;
542 if (uamp)
543 data = ((uamp - 2000000) / 250000) + 1;
544 else
545 data = 0; /* disable */
547 data <<= CHG_CNFG_12_B2SOVRC_SHIFT;
549 dev_dbg(chg->dev, "Battery overcurrent: %u (0x%x)\n", uamp, data);
551 return regmap_update_bits(chg->max77693->regmap,
552 MAX77693_CHG_REG_CHG_CNFG_12,
553 CHG_CNFG_12_B2SOVRC_MASK, data);
556 static int max77693_set_charge_input_threshold_volt(struct max77693_charger *chg,
557 unsigned int uvolt)
559 unsigned int data;
561 switch (uvolt) {
562 case 4300000:
563 data = 0x0;
564 break;
565 case 4700000:
566 case 4800000:
567 case 4900000:
568 data = (uvolt - 4700000) / 100000;
569 default:
570 dev_err(chg->dev, "Wrong value for charge input voltage regulation threshold\n");
571 return -EINVAL;
574 data <<= CHG_CNFG_12_VCHGINREG_SHIFT;
576 dev_dbg(chg->dev, "Charge input voltage regulation threshold: %u (0x%x)\n",
577 uvolt, data);
579 return regmap_update_bits(chg->max77693->regmap,
580 MAX77693_CHG_REG_CHG_CNFG_12,
581 CHG_CNFG_12_VCHGINREG_MASK, data);
585 * Sets charger registers to proper and safe default values.
587 static int max77693_reg_init(struct max77693_charger *chg)
589 int ret;
590 unsigned int data;
592 /* Unlock charger register protection */
593 data = (0x3 << CHG_CNFG_06_CHGPROT_SHIFT);
594 ret = regmap_update_bits(chg->max77693->regmap,
595 MAX77693_CHG_REG_CHG_CNFG_06,
596 CHG_CNFG_06_CHGPROT_MASK, data);
597 if (ret) {
598 dev_err(chg->dev, "Error unlocking registers: %d\n", ret);
599 return ret;
602 ret = max77693_set_fast_charge_timer(chg, DEFAULT_FAST_CHARGE_TIMER);
603 if (ret)
604 return ret;
606 ret = max77693_set_top_off_threshold_current(chg,
607 DEFAULT_TOP_OFF_THRESHOLD_CURRENT);
608 if (ret)
609 return ret;
611 ret = max77693_set_top_off_timer(chg, DEFAULT_TOP_OFF_TIMER);
612 if (ret)
613 return ret;
615 ret = max77693_set_constant_volt(chg, chg->constant_volt);
616 if (ret)
617 return ret;
619 ret = max77693_set_min_system_volt(chg, chg->min_system_volt);
620 if (ret)
621 return ret;
623 ret = max77693_set_thermal_regulation_temp(chg,
624 chg->thermal_regulation_temp);
625 if (ret)
626 return ret;
628 ret = max77693_set_batttery_overcurrent(chg, chg->batttery_overcurrent);
629 if (ret)
630 return ret;
632 return max77693_set_charge_input_threshold_volt(chg,
633 chg->charge_input_threshold_volt);
636 #ifdef CONFIG_OF
637 static int max77693_dt_init(struct device *dev, struct max77693_charger *chg)
639 struct device_node *np = dev->of_node;
641 if (!np) {
642 dev_err(dev, "no charger OF node\n");
643 return -EINVAL;
646 if (of_property_read_u32(np, "maxim,constant-microvolt",
647 &chg->constant_volt))
648 chg->constant_volt = DEFAULT_CONSTANT_VOLT;
650 if (of_property_read_u32(np, "maxim,min-system-microvolt",
651 &chg->min_system_volt))
652 chg->min_system_volt = DEFAULT_MIN_SYSTEM_VOLT;
654 if (of_property_read_u32(np, "maxim,thermal-regulation-celsius",
655 &chg->thermal_regulation_temp))
656 chg->thermal_regulation_temp = DEFAULT_THERMAL_REGULATION_TEMP;
658 if (of_property_read_u32(np, "maxim,battery-overcurrent-microamp",
659 &chg->batttery_overcurrent))
660 chg->batttery_overcurrent = DEFAULT_BATTERY_OVERCURRENT;
662 if (of_property_read_u32(np, "maxim,charge-input-threshold-microvolt",
663 &chg->charge_input_threshold_volt))
664 chg->charge_input_threshold_volt =
665 DEFAULT_CHARGER_INPUT_THRESHOLD_VOLT;
667 return 0;
669 #else /* CONFIG_OF */
670 static int max77693_dt_init(struct device *dev, struct max77693_charger *chg)
672 return 0;
674 #endif /* CONFIG_OF */
676 static int max77693_charger_probe(struct platform_device *pdev)
678 struct max77693_charger *chg;
679 struct power_supply_config psy_cfg = {};
680 struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent);
681 int ret;
683 chg = devm_kzalloc(&pdev->dev, sizeof(*chg), GFP_KERNEL);
684 if (!chg)
685 return -ENOMEM;
687 platform_set_drvdata(pdev, chg);
688 chg->dev = &pdev->dev;
689 chg->max77693 = max77693;
691 ret = max77693_dt_init(&pdev->dev, chg);
692 if (ret)
693 return ret;
695 ret = max77693_reg_init(chg);
696 if (ret)
697 return ret;
699 psy_cfg.drv_data = chg;
701 ret = device_create_file(&pdev->dev, &dev_attr_fast_charge_timer);
702 if (ret) {
703 dev_err(&pdev->dev, "failed: create fast charge timer sysfs entry\n");
704 goto err;
707 ret = device_create_file(&pdev->dev,
708 &dev_attr_top_off_threshold_current);
709 if (ret) {
710 dev_err(&pdev->dev, "failed: create top off current sysfs entry\n");
711 goto err;
714 ret = device_create_file(&pdev->dev, &dev_attr_top_off_timer);
715 if (ret) {
716 dev_err(&pdev->dev, "failed: create top off timer sysfs entry\n");
717 goto err;
720 chg->charger = power_supply_register(&pdev->dev,
721 &max77693_charger_desc,
722 &psy_cfg);
723 if (IS_ERR(chg->charger)) {
724 dev_err(&pdev->dev, "failed: power supply register\n");
725 ret = PTR_ERR(chg->charger);
726 goto err;
729 return 0;
731 err:
732 device_remove_file(&pdev->dev, &dev_attr_top_off_timer);
733 device_remove_file(&pdev->dev, &dev_attr_top_off_threshold_current);
734 device_remove_file(&pdev->dev, &dev_attr_fast_charge_timer);
736 return ret;
739 static int max77693_charger_remove(struct platform_device *pdev)
741 struct max77693_charger *chg = platform_get_drvdata(pdev);
743 device_remove_file(&pdev->dev, &dev_attr_top_off_timer);
744 device_remove_file(&pdev->dev, &dev_attr_top_off_threshold_current);
745 device_remove_file(&pdev->dev, &dev_attr_fast_charge_timer);
747 power_supply_unregister(chg->charger);
749 return 0;
752 static const struct platform_device_id max77693_charger_id[] = {
753 { "max77693-charger", 0, },
756 MODULE_DEVICE_TABLE(platform, max77693_charger_id);
758 static struct platform_driver max77693_charger_driver = {
759 .driver = {
760 .name = "max77693-charger",
762 .probe = max77693_charger_probe,
763 .remove = max77693_charger_remove,
764 .id_table = max77693_charger_id,
766 module_platform_driver(max77693_charger_driver);
768 MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>");
769 MODULE_DESCRIPTION("Maxim 77693 charger driver");
770 MODULE_LICENSE("GPL");