Skip to contentSkip to conversation

drivers: power: Add support for bq24735 charger

PATCH Superseded Rhyland Klein 2 participants 3 messages Sep 17, 2013 – Sep 19, 2013

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: power: Add support for bq24735 charger

From: Darbha Sriharsha <[email protected]>

Adding driver support for bq24735 charger chipset.

---
 .../bindings/power_supply/ti,bq24735.txt           |   56 +++
 drivers/power/Kconfig                              |    8 +
 drivers/power/Makefile                             |    1 +
 drivers/power/bq24735-charger.c                    |  382 ++++++++++++++++++++
 include/linux/power/bq24735-charger.h              |   68 ++++
 5 files changed, 515 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power_supply/ti,bq24735.txt
 create mode 100644 drivers/power/bq24735-charger.c
 create mode 100644 include/linux/power/bq24735-charger.h
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt new file +56 -0
new file mode 100644
index 0000000..19ea5a2
@@ -0,0 +1,56 @@
+TI BQ24735 Charge Controller
+~~~~~~~~~~
+
+Required properties :
+ - compatible : "ti,bq24735"
+
+Optional properties :
+ - ti,ac-detect: This gpio is optionally used to read the ac adapter
+   presence.
+ - ti,charge-current : Used to control and set the charging current. This value
+   must follow the below guidelines:
+	bit 0 - 5:	Not used
+	bit 6:		1 = Adds 64mA of charger current
+	bit 7:		1 = Adds 128mA of charger current
+	bit 8:		1 = Adds 256mA of charger current
+	bit 9:		1 = Adds 512mA of charger current
+	bit 10:		1 = Adds 1024mA of charger current
+	bit 11:		1 = Adds 2048mA of charger current
+	bit 12:		1 = Adds 4096mA of charger current
+	bit 13 - 15:	Not used
+   Setting the value to < 128mA or > 8.128A terminates charging.
+ - ti,charge-voltage : Used to control and set the charging voltage. This value
+   must follow the below guidelines:
+	bit 0 - 3:	Not used
+	bit 4:		1 = Adds 16mV of charger voltage
+	bit 5:		1 = Adds 32mV of charger voltage
+	bit 6:		1 = Adds 64mV of charger voltage
+	bit 7:		1 = Adds 128mV of charger voltage
+	bit 8:		1 = Adds 256mV of charger voltage
+	bit 9:		1 = Adds 512mV of charger voltage
+	bit 10:		1 = Adds 1024mV of charger voltage
+	bit 11:		1 = Adds 2048mV of charger voltage
+	bit 12:		1 = Adds 4096mV of charger voltage
+	bit 13:		1 = Adds 8192mV of charger voltage
+	bit 14:		1 = Adds 16384mV of charger voltage
+	bit 15:		Not used
+   Setting the value to < 1.024V or > 19.2V terminates charging.
+ - ti,input-current:	Used to control and set the charger input current. This
+   value must follow the below guidelines:
+	bit 0 - 6:	Not used
+	bit 7:		1 = Adds 128mA of input current
+	bit 8:		1 = Adds 256mA of input current
+	bit 9:		1 = Adds 512mA of input current
+	bit 10:		1 = Adds 1024mA of input current
+	bit 11:		1 = Adds 2048mA of input current
+	bit 12:		1 = Adds 4086mA of input current
+	bit 13 - 15:	Not used
+   Setting the value to < 128mA or > 8.064A terminates charging.
+
+Example:
+
+	bq24735@9 {
+		compatible = "ti,bq24735";
+		reg = < 0x9 >;
+		ti,ac-detect = <&gpio 72 0x1>;
+	}
drivers/power/Kconfig +8 -0
index e8970a6..380968d 100644
@@ -340,6 +340,14 @@ config CHARGER_BQ24190
 	help
 	  Say Y to enable support for the TI BQ24190 battery charger.
 
+config CHARGER_BQ24735
+	tristate "BQ24735 battery charger support"
+	depends on I2C && GPIOLIB
+	help
+	  bq24735 is the battery charger chipset.
+	  Say Y here to enable battery charging driver support for
+	  bq24735
+
 config CHARGER_SMB347
 	tristate "Summit Microelectronics SMB347 Battery Charger"
 	depends on I2C
drivers/power/Makefile +1 -0
index 4ae4533..e65487b 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
 obj-$(CONFIG_CHARGER_BQ2415X)	+= bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)	+= bq24190_charger.o
+obj-$(CONFIG_CHARGER_BQ24735)	+= bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)		+= avs/
 obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090)	+= tps65090-charger.o
drivers/power/bq24735-charger.c new file +382 -0

382 lines not on this page · raw message

include/linux/power/bq24735-charger.h new file +68 -0

68 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

--
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
#1 lore raw

Hi

Quoted 6 lines
drivers/power/bq24735-charger.c new file +6 -0
+               ret = gpio_request(charger_device->pdata->status_gpio, name);
+               if (ret) {
+                       dev_err(&client->dev, "Failed gpio request: %d\n", ret);
+                       goto err_free_name;
+               }
+       }

snip ...

drivers/power/bq24735-charger.c line 337

Quoted 6 lines
drivers/power/bq24735-charger.c new file +6 -0
+err_free_name:
+       if (name && name != charger_device->pdata->name)
+               kfree(name);
+
+       return ret;
+}

Like to know, Is there a need to free gpio which has been requested previously? Alternatively, this can be get requested using "devm_" function so that it will get
freed automatically during removal.

Quoted 4 lines
drivers/power/bq24735-charger.c new file +4 -0
+static int bq24735_charger_remove(struct i2c_client *client)
+{
+       struct bq24735_charger *charger_device = i2c_get_clientdata(client);
+

drivers/power/bq24735-charger.c line 352

Quoted 10 lines
drivers/power/bq24735-charger.c new file +10 -0
+       if (charger_device->irq)
+               devm_free_irq(charger_device->dev, charger_device->irq,
+                               &charger_device->charger);
+
+       power_supply_unregister(&charger_device->charger);
+
+       if (charger_device->charger.name != charger_device->pdata->name)
+               kfree(charger_device->charger.name);
+
+       return 0;

Ditto, If go with free_gpio.

Regards
Manish Badarkhe
--
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

#2 lore raw
Quoted 11 lines · Manish Badarkhe

Hi

Quoted 6 lines
drivers/power/bq24735-charger.c new file +6 -0
+               ret = gpio_request(charger_device->pdata->status_gpio, name);
+               if (ret) {
+                       dev_err(&client->dev, "Failed gpio request: %d\n", ret);
+                       goto err_free_name;
+               }
+       }

snip ...

Quoted 11 lines

drivers/power/bq24735-charger.c line 337

Quoted 6 lines
drivers/power/bq24735-charger.c new file +6 -0
+err_free_name:
+       if (name && name != charger_device->pdata->name)
+               kfree(name);
+
+       return ret;
+}

Like to know, Is there a need to free gpio which has been requested previously? Alternatively, this can be get requested using "devm_" function so that it will get
freed automatically during removal.

As a matter of fact yes, I meant to use the devm_ variant, which is why I don't have the cleanup. Thanks for catching this! Will fix in V2.

Quoted 19 lines
Quoted 5 lines
drivers/power/bq24735-charger.c new file +4 -0
+static int bq24735_charger_remove(struct i2c_client *client)
+{
+       struct bq24735_charger *charger_device = i2c_get_clientdata(client);
+

drivers/power/bq24735-charger.c line 352

Quoted 10 lines
drivers/power/bq24735-charger.c new file +10 -0
+       if (charger_device->irq)
+               devm_free_irq(charger_device->dev, charger_device->irq,
+                               &charger_device->charger);
+
+       power_supply_unregister(&charger_device->charger);
+
+       if (charger_device->charger.name != charger_device->pdata->name)
+               kfree(charger_device->charger.name);
+
+       return 0;

Ditto, If go with free_gpio.

Quoted 3 lines

Regards
Manish Badarkhe

Thanks!

-rhyland

Signature · 5 lines
nvpublic
--
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