Skip to contentSkip to conversation

drivers: power: Add support for bq24735 charger

PATCH Superseded Rhyland Klein 2 participants 2 messages Sep 26, 2013 – Oct 1, 2013

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

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

From: Darbha Sriharsha <[email protected]>

Adds support for the bq24735 charger chipset. The bq24735 is a high-efficiency, synchronous battery charger.

It allows control of the charging current, input current, and the charger voltage DAC's through SMBus.

---
v4:
- Added GPIO # to dev_err when gpio_request fails, for verbosity.

v3:
*Note: I decided to maintain non-DT support, but tried to do it in the most clean manner using the suggestions from Thierry Reding.

- Simplified devicetree bindings for charger current/voltage and input current
- added optional interrupts property for setting client->irq
- renamed ti,ac-detect to ti,ac-detect-gpios
- modeled Kconfig entry after TI BQ24190 entry
- cleaned up whitespace/sorting review comments
- moved register/bit definitions to .c file
- renamed gpio_active_low to status_gpio_active_low
- added status_gpio_valid to handle gpio = 0 as valid
- simplified the struct bq24735_charger -> struct bq24735 and removed dev and irq fields
- made bq24735[write/read]_word inline functions with error checking at caller sites
- fixed support for enable/disable and added calls into isr as appropriate
- moved charger present logic into separate function
- moved devm_request_threaded_irq after power_supply_register so we can't get into the isr with an unregistered power_supply
- removed ifdeffery around CONFIG_OF, using IS_ENABLED() instead

v2:
- gpio_request -> devm_gpio_request

 .../bindings/power_supply/ti,bq24735.txt           |   28 ++
 drivers/power/Kconfig                              |    6 +
 drivers/power/Makefile                             |    1 +
 drivers/power/bq24735-charger.c                    |  419 ++++++++++++++++++++
 include/linux/power/bq24735-charger.h              |   39 ++
 5 files changed, 493 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 +28 -0
new file mode 100644
index 0000000..67ff4a0
@@ -0,0 +1,28 @@
+TI BQ24735 Charge Controller
+~~~~~~~~~~
+
+Required properties :
+ - compatible : "ti,bq24735"
+
+Optional properties :
+ - interrupts : Specify the interrupt to be used to trigger when the AC
+   adapter is either plugged in or removed.
+ - ti,ac-detect-gpios : 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 be between 128mA and 8.128A with a 64mA step resolution. The POR value
+   is 0x0000h. See spec for more details.
+ - ti,charge-voltage : Used to control and set the charging voltage. This value
+   must be between 1.024V and 19.2V with a 16mV step resolution. The POR value
+   is 0x0000h. See spec for more details.
+ - ti,input-current : Used to control and set the charger input current. This
+   value must be between 128mA and 8.064A with a 128mA step resolution. The
+   POR value is 0x1000h. See spec for more details.
+
+Example:
+
+	bq24735@9 {
+		compatible = "ti,bq24735";
+		reg = <0x9>;
+		ti,ac-detect-gpios = <&gpio 72 0x1>;
+	}
drivers/power/Kconfig +6 -0
index e8970a6..655e8bf 100644
@@ -340,6 +340,12 @@ config CHARGER_BQ24190
 	help
 	  Say Y to enable support for the TI BQ24190 battery charger.
 
+config CHARGER_BQ24735
+	tristate "TI BQ24735 battery charger support"
+	depends on I2C && GPIOLIB
+	help
+	  Say Y to enable support for the TI BQ24735 battery charger.
+
 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 +419 -0

419 lines not on this page · raw message

include/linux/power/bq24735-charger.h new file +39 -0
new file mode 100644
index 0000000..f536164
@@ -0,0 +1,39 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __CHARGER_BQ24735_H_
+#define __CHARGER_BQ24735_H_
+
+#include <linux/types.h>
+#include <linux/power_supply.h>
+
+struct bq24735_platform {
+	uint32_t charge_current;
+	uint32_t charge_voltage;
+	uint32_t input_current;
+
+	const char *name;
+
+	int status_gpio;
+	int status_gpio_active_low;
+	bool status_gpio_valid;
+
+	char **supplied_to;
+	size_t num_supplicants;
+};
+
+#endif /* __CHARGER_BQ24735_H_ */
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
Quoted 11 lines · Rhyland Klein

From: Darbha Sriharsha <[email protected]>

Adds support for the bq24735 charger chipset. The bq24735 is a high-efficiency, synchronous battery charger.

It allows control of the charging current, input current, and the charger voltage DAC's through SMBus.

Documentation/devicetree/bindings/power_supply/ti,bq24735.txt +1 -0
 
+Optional properties :

Documentation/devicetree/bindings/power_supply/ti,bq24735.txt line 20

Quoted 10 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt +9 -0
 
+ - ti,charge-current : Used to control and set the charging current. This value
+   must be between 128mA and 8.128A with a 64mA step resolution. The POR value
+   is 0x0000h. See spec for more details.
+ - ti,charge-voltage : Used to control and set the charging voltage. This value
+   must be between 1.024V and 19.2V with a 16mV step resolution. The POR value
+   is 0x0000h. See spec for more details.
+ - ti,input-current : Used to control and set the charger input current. This
+   value must be between 128mA and 8.064A with a 128mA step resolution. The
+   POR value is 0x1000h. See spec for more details.

What units and representation do those properties use? I assume it's mA and mV, without any shift or register encoding, but the text doesn't make it clear. It'd be best to reference a specific register name rather than just saying "see the spec".
--
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