Skip to content

Commit

Permalink
power: bq24735-charger: add 'ti,external-control' option
Browse files Browse the repository at this point in the history
Implement an 'ti,external-control' option for when the charger
shouldn't be configured by the host.

Signed-off-by: Jonathan Tinkham <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
  • Loading branch information
sctincman authored and sre committed Feb 15, 2016
1 parent a60da83 commit 64024ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/power/bq24735-charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,19 @@ static int bq24735_update_word(struct i2c_client *client, u8 reg,

static inline int bq24735_enable_charging(struct bq24735 *charger)
{
if (charger->pdata->ext_control)
return 0;

return bq24735_update_word(charger->client, BQ24735_CHG_OPT,
BQ24735_CHG_OPT_CHARGE_DISABLE,
~BQ24735_CHG_OPT_CHARGE_DISABLE);
}

static inline int bq24735_disable_charging(struct bq24735 *charger)
{
if (charger->pdata->ext_control)
return 0;

return bq24735_update_word(charger->client, BQ24735_CHG_OPT,
BQ24735_CHG_OPT_CHARGE_DISABLE,
BQ24735_CHG_OPT_CHARGE_DISABLE);
Expand All @@ -124,6 +130,9 @@ static int bq24735_config_charger(struct bq24735 *charger)
int ret;
u16 value;

if (pdata->ext_control)
return 0;

if (pdata->charge_current) {
value = pdata->charge_current & BQ24735_CHARGE_CURRENT_MASK;

Expand Down Expand Up @@ -322,6 +331,8 @@ static struct bq24735_platform *bq24735_parse_dt_data(struct i2c_client *client)
if (!ret)
pdata->input_current = val;

pdata->ext_control = of_property_read_bool(np, "ti,external-control");

return pdata;
}

Expand Down
2 changes: 2 additions & 0 deletions include/linux/power/bq24735-charger.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct bq24735_platform {
int status_gpio_active_low;
bool status_gpio_valid;

bool ext_control;

char **supplied_to;
size_t num_supplicants;
};
Expand Down

0 comments on commit 64024ac

Please sign in to comment.