Skip to content

Commit 41307ec

Browse files
fenglinw-qcomsre
authored andcommitted
power: supply: qcom_battmgr: handle charging state change notifications
The X1E80100 battery management firmware sends a notification with code 0x83 when the battery charging state changes, such as switching between fast charge, taper charge, end of charge, or any other error charging states. The same notification code is used with bit[8] set when charging stops because the charge control end threshold is reached. Additionally, a 2-bit value is included in bit[10:9] with the same code to indicate the charging source capability, which is determined by the calculated power from voltage and current readings from PDOs: 2 means a strong charger over 60W, 1 indicates a weak charger, and 0 means there is no charging source. These 3-MSB [10:8] in the notification code is not much useful for now, hence just ignore them and trigger a power supply change event whenever 0x83 notification code is received. This helps to eliminate the unknown notification error messages. Reported-by: Sebastian Reichel <sebastian.reichel@collabora.com> Closes: https://lore.kernel.org/all/r65idyc4of5obo6untebw4iqfj2zteiggnnzabrqtlcinvtddx@xc4aig5abesu/ Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent bc7d3a0 commit 41307ec

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/power/supply/qcom_battmgr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ enum qcom_battmgr_variant {
3434
#define NOTIF_BAT_PROPERTY 0x30
3535
#define NOTIF_USB_PROPERTY 0x32
3636
#define NOTIF_WLS_PROPERTY 0x34
37-
#define NOTIF_BAT_INFO 0x81
3837
#define NOTIF_BAT_STATUS 0x80
38+
#define NOTIF_BAT_INFO 0x81
39+
#define NOTIF_BAT_CHARGING_STATE 0x83
3940

4041
#define BATTMGR_BAT_INFO 0x9
4142

@@ -1209,12 +1210,14 @@ static void qcom_battmgr_notification(struct qcom_battmgr *battmgr,
12091210
}
12101211

12111212
notification = le32_to_cpu(msg->notification);
1213+
notification &= 0xff;
12121214
switch (notification) {
12131215
case NOTIF_BAT_INFO:
12141216
battmgr->info.valid = false;
12151217
fallthrough;
12161218
case NOTIF_BAT_STATUS:
12171219
case NOTIF_BAT_PROPERTY:
1220+
case NOTIF_BAT_CHARGING_STATE:
12181221
power_supply_changed(battmgr->bat_psy);
12191222
break;
12201223
case NOTIF_USB_PROPERTY:

0 commit comments

Comments
 (0)