drivers: power: Add support for bq24735 charger
Subsystems (2)
PATCH v5 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.
---
v5:
- Clarified ti,charge-[current/voltage] and input-current properties in documentation
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 | 31 ++ drivers/power/Kconfig | 6 + drivers/power/Makefile | 1 + drivers/power/bq24735-charger.c | 419 ++++++++++++++++++++ include/linux/power/bq24735-charger.h | 39 ++ 5 files changed, 496 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 +31 -0
@@ -0,0 +1,31 @@ +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. This number is in mA (e.g. 8192), see spec for more information + about the ChargeCurrent (0x14h) register. + - 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. This number is in mV (e.g. 19200), see spec for more information + about the ChargeVoltage (0x15h) register. + - 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. This number is in mA (e.g. 8064), see the spec for + more information about the InputCurrent (0x3fh) register. + +Example: + + bq24735@9 { + compatible = "ti,bq24735"; + reg = <0x9>; + ti,ac-detect-gpios = <&gpio 72 0x1>; + }
drivers/power/Kconfig +6 -0
@@ -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
@@ -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
@@ -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
Quoted 7 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.
Please CC the DT bindings maintainers on patches that add DT bindings.
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt line 11
Quoted 6 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt +3
-0+Optional properties : + - ti,ac-detect-gpios : This GPIO is optionally used to read the AC adapter + presence.
Is that actually a property of the BQ24735 chip itself (i.e. is it an output signal from the chip), or part of the board/system?
Aside from that, the binding looks reasonable to me (although I'm no longer a DT bindings maintainer).
--
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
Quoted 10 lines · Stephen Warren
Quoted 7 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.
Please CC the DT bindings maintainers on patches that add DT bindings.
Oops, sorry, will do in the future.
Quoted 10 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt line 11
Quoted 7 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt +3
-0+Optional properties : + - ti,ac-detect-gpios : This GPIO is optionally used to read the AC adapter + presence.Is that actually a property of the BQ24735 chip itself (i.e. is it an output signal from the chip), or part of the board/system?
The gpio itself is actually what the IRQ line is tied to from the bq24735 -> tegra (in this case). In other words this is a Host GPIO that is configured as an input and connected to the bq24735.
-rhyland
Quoted 4 lines
Aside from that, the binding looks reasonable to me (although I'm no longer a DT bindings maintainer).
Signature · 1 line
nvpublic
Quoted 22 lines · Rhyland Klein
Quoted 10 lines · Stephen Warren
Quoted 7 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.
Please CC the DT bindings maintainers on patches that add DT bindings.
Oops, sorry, will do in the future.
Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt +3
-0+Optional properties : + - ti,ac-detect-gpios : This GPIO is optionally used to read the AC adapter + presence.
Quoted 6 lines
Quoted 2 lines
Is that actually a property of the BQ24735 chip itself (i.e. is it an output signal from the chip), or part of the board/system?
The gpio itself is actually what the IRQ line is tied to from the bq24735 -> tegra (in this case). In other words this is a Host GPIO that is configured as an input and connected to the bq24735.
Ok, so this is the ACOK output pin? In that case, it's fine. It might be worth mentioning that explicitly though.
--
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
Quoted 10 lines · Stephen Warren
Quoted 10 lines
Quoted 9 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt line 11
Quoted 6 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt +3
-0+Optional properties : + - ti,ac-detect-gpios : This GPIO is optionally used to read the AC adapter + presence.Is that actually a property of the BQ24735 chip itself (i.e. is it an output signal from the chip), or part of the board/system?
Quoted 6 lines
Quoted 3 lines
The gpio itself is actually what the IRQ line is tied to from the bq24735 -> tegra (in this case). In other words this is a Host GPIO that is configured as an input and connected to the bq24735.
Ok, so this is the ACOK output pin? In that case, it's fine. It might be worth mentioning that explicitly though.
I added the comment to the documentation and applied the patch with a "Thanks-to: Stephen Warren <[email protected]>" tag. :)
Anton
Quoted 15 lines · Anton Vorontsov
Quoted 14 lines · Stephen Warren
Quoted 13 lines
Quoted 9 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt line 11
Quoted 6 lines
Documentation/devicetree/bindings/power_supply/ti,bq24735.txt +3
-0+Optional properties : + - ti,ac-detect-gpios : This GPIO is optionally used to read the AC adapter + presence.Is that actually a property of the BQ24735 chip itself (i.e. is it an output signal from the chip), or part of the board/system?
The gpio itself is actually what the IRQ line is tied to from the bq24735 -> tegra (in this case). In other words this is a Host GPIO that is configured as an input and connected to the bq24735.
Quoted 5 lines
Quoted 2 lines
Ok, so this is the ACOK output pin? In that case, it's fine. It might be worth mentioning that explicitly though.
I added the comment to the documentation and applied the patch with a "Thanks-to: Stephen Warren <[email protected]>" tag. :)
Oh, and as well as
Thanks-to: Thierry Reding <[email protected]>
(People seem to review drivers, but do not give their Reviewed-by tags, so the thanks tag is the best thing I can legally do in such a case.)
Thanks,
Anton