power: supply: bq2415x_charger: report online status
Subsystems (2)
PATCH 1/1 power: supply: bq2415x_charger: report online status
Provide the Online property. This chip does not have specific flags to indicate the presence of an input voltage, but this can be inferred from the reported charging status.
--- drivers/power/supply/bq2415x_charger.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/power/supply/bq2415x_charger.c +9 -0
@@ -991,6 +991,7 @@ static enum power_supply_property bq2415x_power_supply_props[] = {/* TODO: maybe add more power supply properties */ POWER_SUPPLY_PROP_STATUS ,POWER_SUPPLY_PROP_MODEL_NAME , + POWER_SUPPLY_PROP_ONLINE, }; static int bq2415x_power_supply_get_property(struct power_supply *psy,
@@ -1017,6 +1018,14 @@ static int bq2415x_power_supply_get_property(struct power_supply *psy,case POWER_SUPPLY_PROP_MODEL_NAME : val->strval = bq->model;break ; +case POWER_SUPPLY_PROP_ONLINE : + ret =bq2415x_exec_command (bq,BQ2415X_CHARGE_STATUS ); +/* Charger is Online when Charging or Full are reported. It is +* also likely online for the Unknown/Fault state too, but +* there is no way to be absolutely sure. +*/ + val->intval = (ret ==1 || ret ==2 ); +break ;default :return -EINVAL ; }
Signature · 1 line
2.43.0
Hi,
Quoted 3 lines · Sicelo A. Mhlongo
Provide the Online property. This chip does not have specific flags to indicate the presence of an input voltage, but this can be inferred from the reported charging status.
The datasheet suggests, that you can get the status from the fault bits:
011 - Poor input source or VBUS < UVLO
Greetings,
-- Sebastian
Quoted 36 lines
Signed-off-by Sicelo A. Mhlongo <[email protected]>--- drivers/power/supply/bq2415x_charger.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/power/supply/bq2415x_charger.c +9
-0@@ -991,6 +991,7 @@ static enum power_supply_property bq2415x_power_supply_props[] = {/* TODO: maybe add more power supply properties */ POWER_SUPPLY_PROP_STATUS ,POWER_SUPPLY_PROP_MODEL_NAME , + POWER_SUPPLY_PROP_ONLINE, }; static int bq2415x_power_supply_get_property(struct power_supply *psy,@@ -1017,6 +1018,14 @@ static int bq2415x_power_supply_get_property(struct power_supply *psy,case POWER_SUPPLY_PROP_MODEL_NAME : val->strval = bq->model;break ; +case POWER_SUPPLY_PROP_ONLINE : + ret =bq2415x_exec_command (bq,BQ2415X_CHARGE_STATUS ); +/* Charger is Online when Charging or Full are reported. It is +* also likely online for the Unknown/Fault state too, but +* there is no way to be absolutely sure. +*/ + val->intval = (ret ==1 || ret ==2 ); +break ;default :return -EINVAL ; }Signature · 1 line
2.43.0
Hi Sebastian
Quoted 12 lines · Sebastian Reichel
Hi,
Quoted 3 lines · Sicelo A. Mhlongo
Provide the Online property. This chip does not have specific flags to indicate the presence of an input voltage, but this can be inferred from the reported charging status.
The datasheet suggests, that you can get the status from the fault bits:
011 - Poor input source or VBUS < UVLO
Absolutely, yes. This particular state, which is a fault condition, clearly indicates VBUS is present.
However, when there are no faults at all, then those bits always read 000. On a running system, one can check this by connecting and disconnecting a charger (Nokia N900 used in my tests) while watching /sys/class/power_supply/bq24150a-0/registers. Only bit 4 changes state. In other words, the fault bits do not appear to be enough to determine the presence of an input voltage.
However, looking at them more closely seems to suggest I should respin the patch to also report VBUS online if a fault is reported instead of only during charging and charge full states.
Please let me know if this sounds correct, or if I misunderstood your reply.
Sincerely
Sicelo
Hi,
Quoted 6 lines · Sicelo
Quoted 5 lines · Sebastian Reichel
Quoted 3 lines · Sicelo A. Mhlongo
Provide the Online property. This chip does not have specific flags to indicate the presence of an input voltage, but this can be inferred from the reported charging status.
Quoted 7 lines
Quoted 5 lines
The datasheet suggests, that you can get the status from the fault bits:
011 - Poor input source or VBUS < UVLO
Absolutely, yes. This particular state, which is a fault condition, clearly indicates VBUS is present.
I assumed this might be set for a disconnected charger, considering that no input source is a poor input source / 0V is < UVLO.
Quoted 6 lines
However, when there are no faults at all, then those bits always read
000. On a running system, one can check this by connecting and disconnecting a charger (Nokia N900 used in my tests) while watching/sys/class/power_supply/bq24150a-0/registers. Only bit 4 changes state. In other words, the fault bits do not appear to be enough to determine the presence of an input voltage.
Ok.
Quoted 3 lines
However, looking at them more closely seems to suggest I should respin the patch to also report VBUS online if a fault is reported instead of only during charging and charge full states.
Right, so you can just check for BQ2415X_CHARGE_STATUS != 0.
Quoted 2 lines
Please let me know if this sounds correct, or if I misunderstood your reply.
Greetings,
-- Sebastian
Good Day
Quoted 8 lines · Sebastian Reichel
Quoted 5 lines
Quoted 3 lines
011 - Poor input source or VBUS < UVLO
Absolutely, yes. This particular state, which is a fault condition, clearly indicates VBUS is present.
I assumed this might be set for a disconnected charger, considering that no input source is a poor input source / 0V is < UVLO.
The meaning of that one can be phrased as: you are supplying VBUS, but it is not high enough for the chip to sustain charging.
Quoted 5 lines
Quoted 3 lines
However, looking at them more closely seems to suggest I should respin the patch to also report VBUS online if a fault is reported instead of only during charging and charge full states.
Right, so you can just check for
BQ2415X_CHARGE_STATUS!= 0.
Thanks. v2 sent.
Regards,
Sicelo