bq27x00: Fix CURRENT_NOW property
[pandora-kernel.git] / drivers / power / bq27x00_battery.c
index eff0273..1b06134 100644 (file)
@@ -44,6 +44,8 @@
 #define BQ27500_FLAG_DSC               BIT(0)
 #define BQ27500_FLAG_FC                        BIT(9)
 
+#define BQ27000_RS                     20 /* Resistor sense */
+
 /* If the system has several batteries we need a different name for each
  * of them...
  */
@@ -78,6 +80,7 @@ static enum power_supply_property bq27x00_battery_props[] = {
        POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
        POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
        POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
+       POWER_SUPPLY_PROP_TECHNOLOGY,
 };
 
 /*
@@ -108,7 +111,7 @@ static int bq27x00_battery_temperature(struct bq27x00_device_info *di)
        if (di->chip == BQ27500)
                return temp - 2731;
        else
-               return ((temp >> 2) - 273) * 10;
+               return ((temp * 5) - 5463) / 2;
 }
 
 /*
@@ -148,7 +151,7 @@ static int bq27x00_battery_current(struct bq27x00_device_info *di)
 
        if (di->chip == BQ27500) {
                /* bq27500 returns signed value */
-               curr = (int)(s16)curr;
+               curr = (int)((s16)curr) * 1000;
        } else {
                ret = bq27x00_read(BQ27x00_REG_FLAGS, &flags, 0, di);
                if (ret < 0) {
@@ -159,9 +162,10 @@ static int bq27x00_battery_current(struct bq27x00_device_info *di)
                        dev_dbg(di->dev, "negative current!\n");
                        curr = -curr;
                }
+               curr = curr * 3570 / BQ27000_RS;
        }
 
-       return curr * 1000;
+       return curr;
 }
 
 /*
@@ -277,6 +281,9 @@ static int bq27x00_battery_get_property(struct power_supply *psy,
        case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
                ret = bq27x00_battery_time(di, BQ27x00_REG_TTF, val);
                break;
+       case POWER_SUPPLY_PROP_TECHNOLOGY:
+               val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
+               break;
        default:
                return -EINVAL;
        }