1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index bc6ef06..df7aa70 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -28,6 +28,7 @@
#define DRIVER_VERSION "1.0.0"
+#define BQ27x00_REG_MODE 0x00
#define BQ27x00_REG_TEMP 0x06
#define BQ27x00_REG_VOLT 0x08
#define BQ27x00_REG_RSOC 0x0B /* Relative State-of-Charge */
@@ -65,6 +66,7 @@ static enum power_supply_property bq27x00_battery_props[] = {
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_TEMP,
+ POWER_SUPPLY_PROP_ONLINE,
};
/*
@@ -83,6 +85,22 @@ static int bq27x00_read(u8 reg, int *rt_value, int b_single,
}
/*
+ * Return the GPIO status (0 or 1)
+ * Or < 0 if something fails.
+ */
+static int bq27x00_gpio(struct bq27x00_device_info *di)
+{
+ int ret;
+ int gpio = 0;
+
+ ret = bq27x00_read(BQ27x00_REG_MODE, &gpio, 0, di);
+ if (ret)
+ return ret;
+
+ return (gpio & 0x40) >> 6;
+}
+
+/*
* Return the battery temperature in Celcius degrees
* Or < 0 if something fails.
*/
@@ -184,6 +202,9 @@ static int bq27x00_battery_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_TEMP:
val->intval = bq27x00_battery_temperature(di);
break;
+ case POWER_SUPPLY_PROP_ONLINE:
+ val->intval = bq27x00_gpio(di);
+ break;
default:
return -EINVAL;
}
|