Reply
Thread Tools
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#1
Since the platform driver does not register the bq27200 on i2c bus, I changed the driver to register the device itself. With this change, the bq27200 appears normally on the i2c-2 bus, and you can read it's view of battery status.

Insert the two modules:

http://my.arava.co.il/~matan/770/n900/power_supply.ko
http://my.arava.co.il/~matan/770/n90...x00_battery.ko

And you will have a directory /sys/class/power_supply/bq27200-0 containing files: capacity, current_now, temp, voltage_now.

If you wish to compile it yourself, get kernel-source package, change the file drivers/power/bq27x00_battery.c to this: http://my.arava.co.il/~matan/770/n900/bq27x00_battery.c and reconfigure kernel so that CONFIG_BATTERY_BQ27x00=m.
__________________
My repository

"N900 community support for the MeeGo-Harmattan" Is the new "Mer is Fremantle for N810".

No more Nokia devices for me.
 

The Following 14 Users Say Thank You to Matan For This Useful Post:
Posts: 1,341 | Thanked: 708 times | Joined on Feb 2010
#2
Could this issue be related to this bug?
https://bugs.maemo.org/show_bug.cgi?id=9789
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#3
Originally Posted by Matan View Post
Since the platform driver does not register the bq27200 on i2c bus, I changed the driver to register the device itself. With this change, the bq27200 appears normally on the i2c-2 bus, and you can read it's view of battery status.
How much does this differ from the bme view of battery status?
 
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#4
The voltage seems similar, though not identical.

The capacity is very different - currently bme says 86%, while bq27200 says 94%.

In addition there are two parameters - current draw (which is obviously very interesting) and temperature, which are not available through bme.
__________________
My repository

"N900 community support for the MeeGo-Harmattan" Is the new "Mer is Fremantle for N810".

No more Nokia devices for me.
 

The Following 3 Users Say Thank You to Matan For This Useful Post:
Posts: 1,258 | Thanked: 672 times | Joined on Mar 2009
#5
I've been accessing bq27200 from userspace with i2cget and some scripting.

The Capacity Inaccurate flag was set, 75 charge cycles since last learrning cycle. I charged n900 full, made a backup, discharged it until n900 shut down. bq was then giving slightly more sensible results.

However, it's worth noting that bme and bq measure different things.

The N900 shuts down at 3200mV, and bq's 6.25% charge threshold is slightly higher than that. This means that, from the user's point of view, if bq was 100% accurate, "completely empty" would be shortly after bq says 7% remaining.

bme starts the battery low warnings at aroung 3500-3580mV, and to me it seems that bme tries to give a percentage measure of remaining capacity until battery low warning.

BTW, we know of bq24150 (charger/otg booster) and bq27200 in i2c bus 2. BME has opened i2c bus 2 twice. Coincidenc? I think not. bme is probably accessing bq27200 but not using its metering capabilities. I wouldn't compile the kernel driver into kernel, or load the module before bme, if bme gets access denied to bq27200 who knows what it will do, if it just quits then dsme will reset the device...

I'm not sure how safe it's for two drivers/processes to be accessing the same hw resource simultaneously. Hopefully the i2c driver does something vaguely sane..

Where bme has a pessimistic view of the battery, not ever saying 100%, bq has iime an overly optimistic opinion showing 100% half an hour before N900 notification led turned green
 

The Following 5 Users Say Thank You to shadowjk For This Useful Post:
Posts: 310 | Thanked: 383 times | Joined on Jan 2010
#6
Anyone know what units current_now is? It seems like it should be mA, but the values I'm reading are ridiculously high; it can't possibly be drawing 3A while playing back a video; the battery would only last 30 minutes.
 
Posts: 1,258 | Thanked: 672 times | Joined on Mar 2009
#7
Originally Posted by nightfire View Post
Anyone know what units current_now is? It seems like it should be mA, but the values I'm reading are ridiculously high; it can't possibly be drawing 3A while playing back a video; the battery would only last 30 minutes.
Looking at the source file linked above, it looks like it's returning the raw value from the chip.

From memory it's in units of 3.57 microvolt. Yes, volt. Use ohms law and assume a resistance of 20 milliOhm and it could start making sense.
 

The Following User Says Thank You to shadowjk For This Useful Post:
Posts: 310 | Thanked: 383 times | Joined on Jan 2010
#8
Ah, gotcha. Voltage drop across a 20mOhm resistor.

If my math's right, that means a value of 1000 represents 179mA, which is much more believable.
 
Posts: 2,154 | Thanked: 8,464 times | Joined on May 2010
#9
Patches for driver bq27x00_battery is here: http://talk.maemo.org/showpost.php?p...&postcount=674

It has fixed resistor sence and reports more battery properties.
 

The Following 5 Users Say Thank You to pali For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 22:19.