power: bq24735-charger: chromebook fixes
Subsystems (2)
cover power: bq24735-charger: chromebook fixes
On Acer Chromebook 13 (CB5-311) this module fails to load if the charger is not inserted, and will error when it is removed.
These fixes are adapted from Acer's downstream kernel.
Jonathan Tinkham (3):
power: bq24735-charger: fix failed i2c with ac-detect
power: bq24735-charger: add 'ti,external-control' option
power: bq24735-charger: document 'ti,external-control' option
.../bindings/power_supply/ti,bq24735.txt | 3 ++ drivers/power/bq24735-charger.c | 56 ++++++++++++++-------- include/linux/power/bq24735-charger.h | 2 + 3 files changed, 40 insertions(+), 21 deletions(-)
Signature · 6 lines
2.7.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1454479426-6437-1-git-send-email-sctincman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/3 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.
--- drivers/power/bq24735-charger.c | 45 ++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/power/bq24735-charger.c +24 -21
@@ -293,27 +293,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,
@@ -327,6 +306,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" );
Signature · 6 lines
2.7.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/3 power: bq24735-charger: add 'ti,external-control' option
In reply to a message not in the archiveImplement an 'ti,external-control' option for when the charger shouldn't be configured by the host.
--- drivers/power/bq24735-charger.c | 11 +++++++++++ include/linux/power/bq24735-charger.h | 2 ++ 2 files changed, 13 insertions(+)
drivers/power/bq24735-charger.c +11 -0
@@ -90,6 +90,9 @@ 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 );
@@ -97,6 +100,9 @@ static inline int bq24735_enable_charging(struct bq24735 *charger)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 );
@@ -108,6 +114,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 ;
@@ -239,6 +248,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; }
include/linux/power/bq24735-charger.h +2 -0
@@ -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; };
Signature · 6 lines
2.7.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/3 power: bq24735-charger: document 'ti,external-control' option
In reply to Jonathan TinkhamImplement an 'external-control' option for when the charger shouldn't be configured by the kernel.
--- Documentation/devicetree/bindings/power_supply/ti,bq24735.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt +3 -0
@@ -22,6 +22,9 @@ Optional properties : value must be between 128mA and 8.064A with a 128mA step resolution. The POR value is 0x1000h. This number is in mA (e.g. 8064), see the spec for more information about the InputCurrent (0x3fh) register. + - ti,external-control : Indicates that the charger is configured externally + and that the host should not attempt to enable/disable charging or set the + charge voltage/current. Example:
Signature · 1 line
2.7.0
Re: [PATCH 3/3] power: bq24735-charger: document 'ti,external-control' option
Quoted 7 lines · Jonathan Tinkham
Implement an 'external-control' option for when the charger shouldn't be configured by the kernel.
Signed-off-by Jonathan Tinkham <[email protected]>--- Documentation/devicetree/bindings/power_supply/ti,bq24735.txt | 3 +++ 1 file changed, 3 insertions(+)
Sebastian Reichel
maintainerHi,
Quoted 4 lines · Jonathan Tinkham
On Acer Chromebook 13 (CB5-311) this module fails to load if the charger is not inserted, and will error when it is removed.
These fixes are adapted from Acer's downstream kernel.
Thanks, queued for 4.6.
-- Sebastian