View Single Post
Posts: 61 | Thanked: 83 times | Joined on Feb 2010 @ Estonia
#73
After strugging to calibrate battery almost a year I decided to take deeper look.
Correct solution is to calibrate according to instructions. Tried this two times but failed. VDQ turned to 0 too early. Next time i'll also disable modem and maybe kill some more proccesses.
Next was to fix status-area-applet-battery or hald-addon-bme to report LMD when /sys/class/power_supply/bq27200-0/capacity is empty and LMD itself has reasonable value but I went easiest way and just disabled Pali's code in bq27x00_battery kernel module.
Works fine for me as my Last Measured Discharge (LMD) is 1155mAh. When the calibration succeeds I'll probably revert to original module so this will be temporary workaround.

If you have same problem, ie battery needs calibration but LMD is something reasonable then you can install kernel-power==1:2.6.28-10power53 and use attached bq27x00_battery.tar.gz.
After coping bq27x00_battery.ko to /lib/modules/current/ just 'rmmod bq27x00_battery && modprobe bq27x00_battery'

To revert back just reinstall kernel-power-modules

Patches to Pali's patches:
Code:
--- kernel-power.bak/debian/patches/bq27x00-fix-nac.diff    2021-08-19 14:18:10.000000000 +0300
+++ kernel-power-2.6.28/debian/patches/bq27x00-fix-nac.diff    2021-08-19 16:18:07.299138619 +0300
@@ -10,7 +10,7 @@
 +    bool is_bq27500 = di->chip == BQ27500;
 +
 +    flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500);
-+    if (flags >= 0 && !is_bq27500 && (flags & BQ27000_FLAG_CI))
++    if (0 && flags >= 0 && !is_bq27500 && (flags & BQ27000_FLAG_CI))
 +        return -ENODATA;
 +
      return bq27x00_battery_read_charge(di, BQ27x00_REG_NAC);
--- kernel-power.bak/debian/patches/bq27x00-upstream.diff    2021-08-19 14:18:10.000000000 +0300
+++ kernel-power-2.6.28/debian/patches/bq27x00-upstream.diff    2021-08-24 08:13:24.560397092 +0300
@@ -38,7 +38,7 @@
 +#include <linux/power/bq27x00_battery.h>
  
 -#define DRIVER_VERSION            "1.0.0"
-+#define DRIVER_VERSION            "1.2.0"
++#define DRIVER_VERSION            "1.2.0x"
  
  #define BQ27x00_REG_TEMP        0x06
  #define BQ27x00_REG_VOLT        0x08
@@ -362,9 +362,14 @@
 +
 +    cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, is_bq27500);
 +    if (cache.flags >= 0) {
-+        if (!is_bq27500 && (cache.flags & BQ27000_FLAG_CI)) {
++        /* We only have to read charge design full once */
++        if (di->charge_design_full <= 0)
++            di->charge_design_full = bq27x00_battery_read_ilmd(di);
++        cache.charge_full = bq27x00_battery_read_lmd(di);
++
++        if (!is_bq27500 && ((cache.flags & BQ27000_FLAG_CI) || 1) && cache.charge_full==di->charge_design_full) {
 +            dev_info(di->dev, "battery is not calibrated! ignoring capacity values\n");
-+            cache.capacity = -ENODATA;
++            cache.capacity = -ENODATA; // or BL-5J default 1320mAh ?
 +            cache.energy = -ENODATA;
 +            cache.time_to_empty = -ENODATA;
 +            cache.time_to_empty_avg = -ENODATA;
@@ -376,14 +381,9 @@
 +            cache.time_to_empty = bq27x00_battery_read_time(di, BQ27x00_REG_TTE);
 +            cache.time_to_empty_avg = bq27x00_battery_read_time(di, BQ27x00_REG_TTECP);
 +            cache.time_to_full = bq27x00_battery_read_time(di, BQ27x00_REG_TTF);
-+            cache.charge_full = bq27x00_battery_read_lmd(di);
 +        }
 +        cache.temperature = bq27x00_battery_read_temperature(di);
 +        cache.cycle_count = bq27x00_battery_read_cyct(di);
-+
-+        /* We only have to read charge design full once */
-+        if (di->charge_design_full <= 0)
-+            di->charge_design_full = bq27x00_battery_read_ilmd(di);
      }
Some useful links:
https://wiki.maemo.org/Bme_replacement
https://talk.maemo.org/showpost.php?...&postcount=846
https://talk.maemo.org/showpost.php?...93&postcount=2
https://talk.maemo.org/showthread.php?t=95816
http://maemo.org/packages/view/bnf/ // use bnf-i2c when CI=1 and using original bq27x00_battery.ko
 

The Following 2 Users Say Thank You to zod For This Useful Post: