Commit 1a3adce1 authored by Jonathan Tinkham's avatar Jonathan Tinkham Committed by Sebastian Reichel

power: bq24735-charger: fix failed i2c with ac-detect

When an ac-detect pin exists, but the charger is not plugged in,
the chip will not respond to i2c messages, causing the module to
fail when inserted.
Signed-off-by: default avatarJonathan Tinkham <sctincman@gmail.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 4f4bfe6b
...@@ -381,6 +381,21 @@ static int bq24735_charger_probe(struct i2c_client *client, ...@@ -381,6 +381,21 @@ static int bq24735_charger_probe(struct i2c_client *client,
i2c_set_clientdata(client, charger); i2c_set_clientdata(client, charger);
if (gpio_is_valid(charger->pdata->status_gpio)) {
ret = devm_gpio_request(&client->dev,
charger->pdata->status_gpio,
name);
if (ret) {
dev_err(&client->dev,
"Failed GPIO request for GPIO %d: %d\n",
charger->pdata->status_gpio, ret);
}
charger->pdata->status_gpio_valid = !ret;
}
if (!charger->pdata->status_gpio_valid
|| bq24735_charger_is_present(charger)) {
ret = bq24735_read_word(client, BQ24735_MANUFACTURER_ID); ret = bq24735_read_word(client, BQ24735_MANUFACTURER_ID);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "Failed to read manufacturer id : %d\n", dev_err(&client->dev, "Failed to read manufacturer id : %d\n",
...@@ -401,18 +416,6 @@ static int bq24735_charger_probe(struct i2c_client *client, ...@@ -401,18 +416,6 @@ static int bq24735_charger_probe(struct i2c_client *client,
"device id mismatch. 0x000b != 0x%04x\n", ret); "device id mismatch. 0x000b != 0x%04x\n", ret);
return -ENODEV; return -ENODEV;
} }
if (gpio_is_valid(charger->pdata->status_gpio)) {
ret = devm_gpio_request(&client->dev,
charger->pdata->status_gpio,
name);
if (ret) {
dev_err(&client->dev,
"Failed GPIO request for GPIO %d: %d\n",
charger->pdata->status_gpio, ret);
}
charger->pdata->status_gpio_valid = !ret;
} }
ret = bq24735_config_charger(charger); ret = bq24735_config_charger(charger);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment