hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/power/supply/max8998_charger.c
....@@ -1,23 +1,9 @@
1
-/*
2
- * max8998_charger.c - Power supply consumer driver for the Maxim 8998/LP3974
3
- *
4
- * Copyright (C) 2009-2010 Samsung Electronics
5
- * MyungJoo Ham <myungjoo.ham@samsung.com>
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 as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
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.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// max8998_charger.c - Power supply consumer driver for the Maxim 8998/LP3974
4
+//
5
+// Copyright (C) 2009-2010 Samsung Electronics
6
+// MyungJoo Ham <myungjoo.ham@samsung.com>
217
228 #include <linux/err.h>
239 #include <linux/module.h>
....@@ -37,6 +23,7 @@
3723 static enum power_supply_property max8998_battery_props[] = {
3824 POWER_SUPPLY_PROP_PRESENT, /* the presence of battery */
3925 POWER_SUPPLY_PROP_ONLINE, /* charger is active or not */
26
+ POWER_SUPPLY_PROP_STATUS, /* charger is charging/discharging/full */
4027 };
4128
4229 /* Note that the charger control is done by a current regulator "CHARGER" */
....@@ -63,10 +50,28 @@
6350 ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg);
6451 if (ret)
6552 return ret;
66
- if (reg & (1 << 3))
67
- val->intval = 0;
68
- else
53
+
54
+ if (reg & (1 << 5))
6955 val->intval = 1;
56
+ else
57
+ val->intval = 0;
58
+
59
+ break;
60
+ case POWER_SUPPLY_PROP_STATUS:
61
+ ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg);
62
+ if (ret)
63
+ return ret;
64
+
65
+ if (!(reg & (1 << 5))) {
66
+ val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
67
+ } else {
68
+ if (reg & (1 << 6))
69
+ val->intval = POWER_SUPPLY_STATUS_FULL;
70
+ else if (reg & (1 << 3))
71
+ val->intval = POWER_SUPPLY_STATUS_CHARGING;
72
+ else
73
+ val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
74
+ }
7075 break;
7176 default:
7277 return -EINVAL;