diff options
author | Jonathan Tinkham <sctincman@gmail.com> | 2016-02-02 23:03:44 -0700 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2016-02-15 06:35:21 +0100 |
commit | 1a3adce1c2c83498f0f9285c504b380fb4182d0d (patch) | |
tree | baa38187800d0374b4d7e5c087f13fe2c48fd6a4 /drivers/power | |
parent | 4f4bfe6bf116d98e336a08ee19ac5754ba0f9f4a (diff) | |
download | linux-stable-1a3adce1c2c83498f0f9285c504b380fb4182d0d.tar.gz linux-stable-1a3adce1c2c83498f0f9285c504b380fb4182d0d.tar.bz2 linux-stable-1a3adce1c2c83498f0f9285c504b380fb4182d0d.zip |
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: Jonathan Tinkham <sctincman@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/bq24735-charger.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/power/bq24735-charger.c b/drivers/power/bq24735-charger.c index 079d1c6c2a8f..022a09ceab73 100644 --- a/drivers/power/bq24735-charger.c +++ b/drivers/power/bq24735-charger.c @@ -381,27 +381,6 @@ static int bq24735_charger_probe(struct i2c_client *client, i2c_set_clientdata(client, charger); - ret = bq24735_read_word(client, BQ24735_MANUFACTURER_ID); - if (ret < 0) { - dev_err(&client->dev, "Failed to read manufacturer id : %d\n", - ret); - return ret; - } else if (ret != 0x0040) { - dev_err(&client->dev, - "manufacturer id mismatch. 0x0040 != 0x%04x\n", ret); - return -ENODEV; - } - - ret = bq24735_read_word(client, BQ24735_DEVICE_ID); - if (ret < 0) { - dev_err(&client->dev, "Failed to read device id : %d\n", ret); - return ret; - } else if (ret != 0x000B) { - dev_err(&client->dev, - "device id mismatch. 0x000b != 0x%04x\n", ret); - return -ENODEV; - } - if (gpio_is_valid(charger->pdata->status_gpio)) { ret = devm_gpio_request(&client->dev, charger->pdata->status_gpio, @@ -415,6 +394,30 @@ static int bq24735_charger_probe(struct i2c_client *client, 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); + if (ret < 0) { + dev_err(&client->dev, "Failed to read manufacturer id : %d\n", + ret); + return ret; + } else if (ret != 0x0040) { + dev_err(&client->dev, + "manufacturer id mismatch. 0x0040 != 0x%04x\n", ret); + return -ENODEV; + } + + ret = bq24735_read_word(client, BQ24735_DEVICE_ID); + if (ret < 0) { + dev_err(&client->dev, "Failed to read device id : %d\n", ret); + return ret; + } else if (ret != 0x000B) { + dev_err(&client->dev, + "device id mismatch. 0x000b != 0x%04x\n", ret); + return -ENODEV; + } + } + ret = bq24735_config_charger(charger); if (ret < 0) { dev_err(&client->dev, "failed in configuring charger"); |