power: supply: cpcap-battery: Add a battery driver
Subsystems (2)
PATCH v2 1/1 power: supply: cpcap-battery: Add a battery driver
On the CPCAP PMIC we can use the ADCs for monitoring the battery, and there is also a coulomb counter. So let's add basic support for the battery driver.
I did not add any capacity prediction as that should probably be done in the user space. Or at least user space should tell the kernel some battery statistics and then the kernel driver could display the capacity based on that.
Note that I left out the battery interrupt handling for now as I need to spend more time on it for the battery empty interrupts. The driver works just fine without the interrupts too.
---
Changes since v1:
- Add support for battery low interrupts
- Fix POWER_SUPPLY_STATUS during charging to not flip constantly by using average current
--- .../bindings/power/supply/cpcap-battery.txt | 27 + drivers/power/supply/Kconfig | 8 + drivers/power/supply/Makefile | 1 + drivers/power/supply/cpcap-battery.c | 808 +++++++++++++++++++++ 4 files changed, 844 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/cpcap-battery.txt create mode 100644 drivers/power/supply/cpcap-battery.c
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +27 -0
@@ -0,0 +1,27 @@ +Motorola CPCAP PMIC battery driver binding + +Required properties: +- compatible: Shall be "motorola,cpcap-battery" +- interrupts: Interrupt specifier for each name in interrupt-names +- interrupt-names: Should contain the following entries: + "lowbph", "lowbpl", "chrgcurr1", "battdetb" +- io-channels: IIO ADC channel specifier for each name in io-channel-names +- io-channel-names: Should contain the following entries: + "battdetb", "battp" + +Example: + +cpcap_battery: battery { + compatible = "motorola,cpcap-battery"; + interrupts-extended = < + &cpcap 5 0 &cpcap 3 0 + &cpcap 20 0 &cpcap 54 0 + >; + interrupt-names = + "lowbph", "lowbpl", + "chrgcurr1", "battdetb"; + io-channels = <&cpcap_adc 0 &cpcap_adc 1 + &cpcap_adc 5 &cpcap_adc 6>; + io-channel-names = "battdetb", "battp", + "chg_isense", "batti"; +};
drivers/power/supply/Kconfig +8 -0
@@ -82,6 +82,14 @@ config BATTERY_ACT8945A Say Y here to enable support for power supply provided by Active-semi ActivePath ACT8945A charger. +config BATTERY_CPCAP + tristate "Motorola CPCAP PMIC battery driver" + depends on MFD_CPCAP && IIO + default MFD_CPCAP + help + Say Y here to enable support for battery on Motorola + phones and tablets such as droid 4. + config BATTERY_DS2760 tristate "DS2760 battery driver (HP iPAQ & others)" depends on W1 && W1_SLAVE_DS2760
drivers/power/supply/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_BATTERY_88PM860X) += 88pm860x_battery.o obj-$(CONFIG_BATTERY_ACT8945A) += act8945a_charger.o obj-$(CONFIG_BATTERY_AXP20X) += axp20x_battery.o obj-$(CONFIG_CHARGER_AXP20X) += axp20x_ac_power.o +obj-$(CONFIG_BATTERY_CPCAP) += cpcap-battery.o obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o obj-$(CONFIG_BATTERY_DS2780) += ds2780_battery.o obj-$(CONFIG_BATTERY_DS2781) += ds2781_battery.o
drivers/power/supply/cpcap-battery.c new file +808 -0
808 lines not on this page · raw message
Signature · 5 lines
2.13.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
Rob Herring
maintainerQuoted 41 lines · Tony Lindgren
On the CPCAP PMIC we can use the ADCs for monitoring the battery, and there is also a coulomb counter. So let's add basic support for the battery driver.
I did not add any capacity prediction as that should probably be done in the user space. Or at least user space should tell the kernel some battery statistics and then the kernel driver could display the capacity based on that.
Note that I left out the battery interrupt handling for now as I need to spend more time on it for the battery empty interrupts. The driver works just fine without the interrupts too.
Cc Marcel Partap <[email protected]>Cc Michael Scott <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by Tony Lindgren <[email protected]>---
Changes since v1:
- Add support for battery low interrupts
- Fix
POWER_SUPPLY_STATUSduring charging to not flip constantly by using average current--- .../bindings/power/supply/cpcap-battery.txt | 27 + drivers/power/supply/Kconfig | 8 + drivers/power/supply/Makefile | 1 + drivers/power/supply/cpcap-battery.c | 808 +++++++++++++++++++++ 4 files changed, 844 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/cpcap-battery.txt create mode 100644 drivers/power/supply/cpcap-battery.cDocumentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +0
-0
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt line 10
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +10
-0@@ -0,0 +1,27 @@ +Motorola CPCAP PMIC battery driver binding + +Required properties: +- compatible: Shall be "motorola,cpcap-battery" +- interrupts: Interrupt specifier for each name in interrupt-names +- interrupt-names: Should contain the following entries: + "lowbph", "lowbpl", "chrgcurr1", "battdetb" +- io-channels: IIO ADC channel specifier for each name in io-channel-names +- io-channel-names: Should contain the following entries: + "battdetb", "battp"
Doesn't match the example.
Quoted 17 lines
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +17
-0+ +Example: + +cpcap_battery: battery { + compatible = "motorola,cpcap-battery"; + interrupts-extended = < + &cpcap 5 0 &cpcap 3 0 + &cpcap 20 0 &cpcap 54 0 + >; + interrupt-names = + "lowbph", "lowbpl", + "chrgcurr1", "battdetb"; + io-channels = <&cpcap_adc 0 &cpcap_adc 1 + &cpcap_adc 5 &cpcap_adc 6>; + io-channel-names = "battdetb", "battp", + "chg_isense", "batti"; +};
Quoted 16 lines · Rob Herring
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt line 10
Quoted 13 lines · Tony Lindgren
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +10
-0@@ -0,0 +1,27 @@ +Motorola CPCAP PMIC battery driver binding + +Required properties: +- compatible: Shall be "motorola,cpcap-battery" +- interrupts: Interrupt specifier for each name in interrupt-names +- interrupt-names: Should contain the following entries: + "lowbph", "lowbpl", "chrgcurr1", "battdetb" +- io-channels: IIO ADC channel specifier for each name in io-channel-names +- io-channel-names: Should contain the following entries: + "battdetb", "battp"Doesn't match the example.
Oops thanks for catching that. Will repost shortly with the binding as a separate patch.
Regards,
Tony
--
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