Skip to contentSkip to conversation

Battery charging, battery status on Nokia N9, N950

PATCH Pavel Machek 2 participants 5 messages Nov 3, 2017 – Nov 7, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hi!

I'm fighting with battery status & battery charging on Nokia N9/N950. https://elinux.org/N950 contains enough info to get battery status (and below is first attempt at kernel implementation), but I'm not sure what needs to be done to charge the battery (or at least power phone from USB).

Any ideas?

Thanks,
Pavel

commit ef0a23a4d522489c4aa7be114bbc1acb604b35b6

Author: Pavel <[email protected]>
Date:   Fri Nov 3 21:34:53 2017 +0100

Add support for bq27521 battery gauge.

arch/arm/boot/dts/omap3-n950-n9.dtsi +20 -0
index 6fc1acc..b42a265 100644
@@ -276,6 +276,26 @@
 
 &i2c2 {
 	clock-frequency = <400000>;
+
+	bq27521: bq27521 at 55 {
+		compatible = "ti,bq27521";
+		reg = <0x55>;
+	};
+
+
+	bq24153a at 6b {
+		compatible = "ti,bq24150a";
+ 		reg = <0x6b>;
+
+                ti,current-limit = <100>;
+ 		ti,weak-battery-voltage = <3400>;
+ 		ti,battery-regulation-voltage = <4000>; /* FIXME: 4200 */
+ 		ti,charge-current = <500>; /* FIXME: 650 */
+ 		ti,termination-current = <100>;
+
+		ti,resistor-sense = <68>;
+ 		ti,usb-charger-detection = <&twl_power>;
+	};
 };
 
 &i2c3 {
drivers/power/supply/bq27xxx_battery.c +47 -0

96 lines not on this page · raw message

drivers/power/supply/bq27xxx_battery_i2c.c +2 -0
index a597221..fd9b989 100644
@@ -239,6 +239,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
 	{ "bq27520g2", BQ27520G2 },
 	{ "bq27520g3", BQ27520G3 },
 	{ "bq27520g4", BQ27520G4 },
+	{ "bq27521", BQ27521 },
 	{ "bq27530", BQ27530 },
 	{ "bq27531", BQ27530 },
 	{ "bq27541", BQ27541 },
@@ -269,6 +270,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
 	{ .compatible = "ti,bq27520g2" },
 	{ .compatible = "ti,bq27520g3" },
 	{ .compatible = "ti,bq27520g4" },
+	{ .compatible = "ti,bq27521" },
 	{ .compatible = "ti,bq27530" },
 	{ .compatible = "ti,bq27531" },
 	{ .compatible = "ti,bq27541" },
include/linux/power/bq27xxx_battery.h +1 -0
index 11e1168..1e80931 100644
@@ -14,6 +14,7 @@ enum bq27xxx_chip {
 	BQ27520G2, /* bq27520G2 */
 	BQ27520G3, /* bq27520G3 */
 	BQ27520G4, /* bq27520G4 */
+	BQ27521, /* bq27521 */	
 	BQ27530, /* bq27530, bq27531 */
 	BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
 	BQ27545, /* bq27545 */
Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171103/bc22fcf5/attachment-0001.sig>
#1 lore raw

Hi!

Quoted 5 lines

I'm fighting with battery status & battery charging on Nokia N9/N950. https://elinux.org/N950 contains enough info to get battery status (and below is first attempt at kernel implementation), but I'm not sure what needs to be done to charge the battery (or at least power phone from USB).

Nemo recovery system (2824336 Jul 25 2016 zImage-moslo) seems to either charge phone from USB or at power it from USB.

But 4.13 does not; it seems there are two separate issue.

First, something needs to be done to enable system power from the USB. I'm not sure what that one would be :-(. Then, it should be possible to ask bq24153 to charge the battery.

Best regards,
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171107/be8b935e/attachment.sig>
#2 lore raw

Hi!

Quoted 7 lines
Quoted 6 lines

I'm fighting with battery status & battery charging on Nokia N9/N950. https://elinux.org/N950 contains enough info to get battery status (and below is first attempt at kernel implementation), but I'm not sure what needs to be done to charge the battery (or at least power phone from USB).

Quoted 8 lines

Nemo recovery system (2824336 Jul 25 2016 zImage-moslo) seems to either charge phone from USB or at power it from USB.

But 4.13 does not; it seems there are two separate issue.

First, something needs to be done to enable system power from the USB. I'm not sure what that one would be :-(. Then, it should be possible to ask bq24153 to charge the battery.

If someone has schematics or pointer to them.. for N9 or N950, that would be useful :-).

Thanks,
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171107/a4127a03/attachment.sig>
#3 lore raw

Hi Pavel

Quoted 12 lines · Pavel Machek

Hi!

Quoted 10 lines
Quoted 6 lines

I'm fighting with battery status & battery charging on Nokia N9/N950. https://elinux.org/N950 contains enough info to get battery status (and below is first attempt at kernel implementation), but I'm not sure what needs to be done to charge the battery (or at least power phone from USB).

Nemo recovery system (2824336 Jul 25 2016 zImage-moslo) seems to either charge phone from USB or at power it from USB.

Quoted 9 lines
Quoted 5 lines

But 4.13 does not; it seems there are two separate issue.

First, something needs to be done to enable system power from the USB. I'm not sure what that one would be :-(. Then, it should be possible to ask bq24153 to charge the battery.

If someone has schematics or pointer to them.. for N9 or N950, that would be useful :-).

You can dump pinctrl and configuration and check if some gpio are used. From reference schematic of this charger you have OTG and CD. Those pins can be just used to enable/disable and boost charging. You should dig a bit in sysfs to figure it out ;)

Michael

Quoted 6 lines

Thanks,
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

#4 lore raw
Quoted 21 lines · Michael Nazzareno Trimarchi

Hi Pavel

Quoted 18 lines · Pavel Machek

Hi!

Quoted 15 lines
Quoted 6 lines

I'm fighting with battery status & battery charging on Nokia N9/N950. https://elinux.org/N950 contains enough info to get battery status (and below is first attempt at kernel implementation), but I'm not sure what needs to be done to charge the battery (or at least power phone from USB).

Nemo recovery system (2824336 Jul 25 2016 zImage-moslo) seems to either charge phone from USB or at power it from USB.

But 4.13 does not; it seems there are two separate issue.

First, something needs to be done to enable system power from the USB. I'm not sure what that one would be :-(. Then, it should be possible to ask bq24153 to charge the battery.

Quoted 8 lines
Quoted 3 lines

If someone has schematics or pointer to them.. for N9 or N950, that would be useful :-).

You can dump pinctrl and configuration and check if some gpio are used. From reference schematic of this charger you have OTG and CD. Those pins can be just used to enable/disable and boost charging. You should dig a bit in sysfs to figure it out ;)

I tried to search old board file from working version -- seemed better than randomly toggling stuff in /sys. But I could not find anything suspicious.

If someone has the schematics, that would be useful.

Best regards,
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171107/b8c1c535/attachment.sig>