Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for N900 charger and fuel gauge #9

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions drivers/power/supply/bq2415x_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -1017,6 +1018,15 @@ 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:
/* VBUS is present for all charging and fault states,
* except the 'Ready' state.
*/
ret = bq2415x_exec_command(bq, BQ2415X_CHARGE_STATUS);
if (ret < 0)
return ret;
val->intval = ret > 0;
break;
default:
return -EINVAL;
}
Expand Down
15 changes: 6 additions & 9 deletions drivers/power/supply/bq27xxx_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,17 +1816,14 @@ static int bq27xxx_battery_current_and_status(
val_curr->intval = curr;

if (val_status) {
if (curr > 0) {
if (bq27xxx_battery_is_full(di, flags))
val_status->intval = POWER_SUPPLY_STATUS_FULL;
else if (curr > 0)
val_status->intval = POWER_SUPPLY_STATUS_CHARGING;
} else if (curr < 0) {
else if (curr < 0)
val_status->intval = POWER_SUPPLY_STATUS_DISCHARGING;
} else {
if (bq27xxx_battery_is_full(di, flags))
val_status->intval = POWER_SUPPLY_STATUS_FULL;
else
val_status->intval =
POWER_SUPPLY_STATUS_NOT_CHARGING;
}
else
val_status->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
}

return 0;
Expand Down