power: supply: cpcap-battery: Add a battery driver
Subsystems (2)
PATCH 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.
--- .../bindings/power/supply/cpcap-battery.txt | 27 + drivers/power/supply/Kconfig | 8 + drivers/power/supply/Makefile | 1 + drivers/power/supply/cpcap-battery.c | 641 +++++++++++++++++++++ 4 files changed, 677 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 +641 -0
641 lines not on this page · raw message
Signature · 1 line
2.13.0
Quoted 3 lines · Tony Lindgren
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.
...
Quoted 20 lines
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +17
-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
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt line 27
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +10
-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"; +};
I guess we should leave out the interrupts in the binding for now too. Or at least move them to optional properties.
Anyways, below is the related dts patch I've been using.
Regards,
Tony
8< -------------------------
Quoted 1 line
From tony Mon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Fri, 19 May 2017 14:23:25 -0700
Subject: [PATCH] ARM: dts: omap4-droid4: Configure CPCAP battery driver
Configure CPCAP battery driver.
--- arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi +15 -0
@@ -26,6 +26,21 @@ #io-channel-cells = <1>; }; + 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"; + }; + cpcap_charger: charger { compatible = "motorola,mapphone-cpcap-charger"; interrupts-extended = <
Signature · 1 line
2.13.0
Quoted 30 lines · Tony Lindgren
Quoted 3 lines · Tony Lindgren
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.
...
Quoted 25 lines
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +22
-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";
Quoted 8 lines
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt line 27
Quoted 5 lines
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt new file +5
-0+ io-channels = <&cpcap_adc 0 &cpcap_adc 1 + &cpcap_adc 5 &cpcap_adc 6>; + io-channel-names = "battdetb", "battp", + "chg_isense", "batti"; +};I guess we should leave out the interrupts in the binding for now too. Or at least move them to optional properties.
Never mind, I got the battery low interrupts finally working. Will post v2 with interrupts shortly.
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
Hi,
Quoted 28 lines · Tony Lindgren
I guess we should leave out the interrupts in the binding for now too. Or at least move them to optional properties.
Anyways, below is the related dts patch I've been using.
8< -------------------------
From tony Mon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Fri, 19 May 2017 14:23:25 -0700
Subject: [PATCH] ARM: dts: omap4-droid4: Configure CPCAP battery driverConfigure CPCAP battery driver.
Signed-off-by Tony Lindgren <[email protected]>--- arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+)arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi +3
-0@@ -26,6 +26,21 @@ #io-channel-cells = <1>; }; + cpcap_battery: battery { + compatible = "motorola,cpcap-battery"; + interrupts-extended = <
arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi line 41
Quoted 10 lines
arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi +10
-0+ &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";
missing
power-supplies = <&cpcap_charger>;
arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi line 46
Quoted 5 lines
arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi +2
-0+ }; + cpcap_charger: charger { compatible = "motorola,mapphone-cpcap-charger"; interrupts-extended = <
-- Sebastian
Quoted 4 lines · Sebastian Reichel
On Sat, May 20, 2017 at 10:05:33AM -0700, Tony Lindgren wrote:
missingpower-supplies = <
&cpcap_charger>;
OK thanks will post an incremental patch as this seems to be in next already.
Regards,
Tony