From a65df832f96588debbbdd93d392a4ff77d5d237c Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Sun, 16 Jul 2017 11:34:00 +0200 Subject: power: supply: ltc2941-battery-gauge: Add LTC2942 support LTC2942 is pin compatible with LTC2941 providing additional informations about battery voltage and temperature. It can be runtime detected using bit A7 in the Status register. Signed-off-by: Ladislav Michl Acked-by: Rob Herring Acked-by: Dragos Bogdan Tested-by: Dragos Bogdan Signed-off-by: Sebastian Reichel --- .../devicetree/bindings/power/supply/ltc2941.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/power/supply/ltc2941.txt b/Documentation/devicetree/bindings/power/supply/ltc2941.txt index a9d7aa60558b..8ec10366295d 100644 --- a/Documentation/devicetree/bindings/power/supply/ltc2941.txt +++ b/Documentation/devicetree/bindings/power/supply/ltc2941.txt @@ -1,13 +1,14 @@ -binding for LTC2941 and LTC2943 battery gauges +binding for LTC2941, LTC2942 and LTC2943 battery gauges -Both the LTC2941 and LTC2943 measure battery capacity. -The LTC2943 is compatible with the LTC2941, it adds voltage and -temperature monitoring, and uses a slightly different conversion -formula for the charge counter. +All chips measure battery capacity. +The LTC2942 is pin compatible with the LTC2941, it adds voltage and +temperature monitoring, and is runtime detected. LTC2943 is software +compatible, uses a slightly different conversion formula for the +charge counter and adds voltage, current and temperature monitoring. Required properties: -- compatible: Should contain "lltc,ltc2941" or "lltc,ltc2943" which also - indicates the type of I2C chip attached. +- compatible: Should contain "lltc,ltc2941", "lltc,ltc2942" or "lltc,ltc2943" + which also indicates the type of I2C chip attached. - reg: The 7-bit I2C address. - lltc,resistor-sense: The sense resistor value in milli-ohms. Can be a 32-bit negative value when the battery has been connected to the wrong end of the -- cgit v1.2.3 From 17825ff6ec6db23892e61a1496abf7d737afe9e7 Mon Sep 17 00:00:00 2001 From: Dragos Bogdan Date: Sun, 16 Jul 2017 11:35:32 +0200 Subject: power: supply: ltc2941-battery-gauge: Add LTC2944 support LTC2944 is compatible with LTC2943, but uses different voltage and current computing constants. Signed-off-by: Dragos Bogdan Signed-off-by: Ladislav Michl Tested-by: Dragos Bogdan Acked-by: Rob Herring Signed-off-by: Sebastian Reichel --- .../devicetree/bindings/power/supply/ltc2941.txt | 12 +++++----- drivers/power/supply/ltc2941-battery-gauge.c | 27 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 11 deletions(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/power/supply/ltc2941.txt b/Documentation/devicetree/bindings/power/supply/ltc2941.txt index 8ec10366295d..3b9ba147b041 100644 --- a/Documentation/devicetree/bindings/power/supply/ltc2941.txt +++ b/Documentation/devicetree/bindings/power/supply/ltc2941.txt @@ -1,14 +1,14 @@ -binding for LTC2941, LTC2942 and LTC2943 battery gauges +binding for LTC2941, LTC2942, LTC2943 and LTC2944 battery gauges All chips measure battery capacity. The LTC2942 is pin compatible with the LTC2941, it adds voltage and -temperature monitoring, and is runtime detected. LTC2943 is software -compatible, uses a slightly different conversion formula for the -charge counter and adds voltage, current and temperature monitoring. +temperature monitoring, and is runtime detected. LTC2943 and LTC2944 +is software compatible, uses a slightly different conversion formula +for the charge counter and adds voltage, current and temperature monitoring. Required properties: -- compatible: Should contain "lltc,ltc2941", "lltc,ltc2942" or "lltc,ltc2943" - which also indicates the type of I2C chip attached. +- compatible: Should contain "lltc,ltc2941", "lltc,ltc2942", "lltc,ltc2943" + or "lltc,ltc2944" which also indicates the type of I2C chip attached. - reg: The 7-bit I2C address. - lltc,resistor-sense: The sense resistor value in milli-ohms. Can be a 32-bit negative value when the battery has been connected to the wrong end of the diff --git a/drivers/power/supply/ltc2941-battery-gauge.c b/drivers/power/supply/ltc2941-battery-gauge.c index 42ff4e3daf35..08e4fd9ee607 100644 --- a/drivers/power/supply/ltc2941-battery-gauge.c +++ b/drivers/power/supply/ltc2941-battery-gauge.c @@ -1,6 +1,6 @@ /* - * I2C client/driver for the Linear Technology LTC2941, LTC2942 and LTC2943 - * Battery Gas Gauge IC + * I2C client/driver for the Linear Technology LTC2941, LTC2942, LTC2943 + * and LTC2944 Battery Gas Gauge IC * * Copyright (C) 2014 Topic Embedded Systems * @@ -48,6 +48,7 @@ enum ltc294x_id { LTC2941_ID, LTC2942_ID, LTC2943_ID, + LTC2944_ID, }; #define LTC2941_REG_STATUS_CHIP_ID BIT(7) @@ -153,7 +154,8 @@ static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp) case LTC2942_ID: /* 2942 measures every 2 sec */ control |= LTC2942_REG_CONTROL_MODE_SCAN; break; - case LTC2943_ID: /* 2943 measures every 10 sec */ + case LTC2943_ID: + case LTC2944_ID: /* 2943 and 2944 measure every 10 sec */ control |= LTC2943_REG_CONTROL_MODE_SCAN; break; default: @@ -269,6 +271,11 @@ static int ltc294x_get_voltage(const struct ltc294x_info *info, int *val) value /= 0xFFFF; value *= 1000 / 2; break; + case LTC2944_ID: + value *= 70800 / 5*4; + value /= 0xFFFF; + value *= 1000 * 5/4; + break; default: value *= 6000 * 10; value /= 0xFFFF; @@ -289,10 +296,14 @@ static int ltc294x_get_current(const struct ltc294x_info *info, int *val) LTC2943_REG_CURRENT_MSB, &datar[0], 2); value = (datar[0] << 8) | datar[1]; value -= 0x7FFF; + if (info->id == LTC2944_ID) + value *= 64000; + else + value *= 60000; /* Value is in range -32k..+32k, r_sense is usually 10..50 mOhm, * the formula below keeps everything in s32 range while preserving * enough digits */ - *val = 1000 * ((60000 * value) / (info->r_sense * 0x7FFF)); /* in uA */ + *val = 1000 * (value / (info->r_sense * 0x7FFF)); /* in uA */ return ret; } @@ -470,6 +481,7 @@ static int ltc294x_i2c_probe(struct i2c_client *client, info->supply_desc.type = POWER_SUPPLY_TYPE_BATTERY; info->supply_desc.properties = ltc294x_properties; switch (info->id) { + case LTC2944_ID: case LTC2943_ID: info->supply_desc.num_properties = ARRAY_SIZE(ltc294x_properties); @@ -543,6 +555,7 @@ static const struct i2c_device_id ltc294x_i2c_id[] = { { "ltc2941", LTC2941_ID, }, { "ltc2942", LTC2942_ID, }, { "ltc2943", LTC2943_ID, }, + { "ltc2944", LTC2944_ID, }, { }, }; MODULE_DEVICE_TABLE(i2c, ltc294x_i2c_id); @@ -560,6 +573,10 @@ static const struct of_device_id ltc294x_i2c_of_match[] = { .compatible = "lltc,ltc2943", .data = (void *)LTC2943_ID, }, + { + .compatible = "lltc,ltc2944", + .data = (void *)LTC2944_ID, + }, { }, }; MODULE_DEVICE_TABLE(of, ltc294x_i2c_of_match); @@ -578,5 +595,5 @@ module_i2c_driver(ltc294x_driver); MODULE_AUTHOR("Auryn Verwegen, Topic Embedded Systems"); MODULE_AUTHOR("Mike Looijmans, Topic Embedded Products"); -MODULE_DESCRIPTION("LTC2941/LTC2942/LTC2943 Battery Gas Gauge IC driver"); +MODULE_DESCRIPTION("LTC2941/LTC2942/LTC2943/LTC2944 Battery Gas Gauge IC driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 3c72785a323e561dc4d1be27fb4cb46a74ec9703 Mon Sep 17 00:00:00 2001 From: Liam Breck Date: Mon, 28 Aug 2017 14:23:46 -0700 Subject: dt-bindings: power: supply: Add docs for TI BQ24190 battery charger Document monitored-battery and ti,system-minimum-microvolt properties. Cc: Rob Herring Cc: devicetree@vger.kernel.org Signed-off-by: Liam Breck Acked-by: Tony Lindgren Signed-off-by: Sebastian Reichel --- .../devicetree/bindings/power/supply/bq24190.txt | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt new file mode 100644 index 000000000000..9e517d307070 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt @@ -0,0 +1,51 @@ +TI BQ24190 Li-Ion Battery Charger + +Required properties: +- compatible: contains one of the following: + * "ti,bq24190" + * "ti,bq24192i" +- reg: integer, I2C address of the charger. +- interrupts[-extended]: configuration for charger INT pin. + +Optional properties: +- monitored-battery: phandle of battery characteristics devicetree node + The charger uses the following battery properties: + + precharge-current-microamp: maximum charge current during precharge + phase (typically 20% of battery capacity). + + charge-term-current-microamp: a charge cycle terminates when the + battery voltage is above recharge threshold, and the current is below + this setting (typically 10% of battery capacity). + See also Documentation/devicetree/bindings/power/supply/battery.txt +- ti,system-minimum-microvolt: when power is connected and the battery is below + minimum system voltage, the system will be regulated above this setting. + +Notes: +- Some circuit boards wire the chip's "OTG" pin high (enabling 500mA default + charge current on USB SDP ports, among other features). To simulate this on + boards that wire the pin to a GPIO, set a gpio-hog. + +Example: + + bat: battery { + compatible = "simple-battery"; + precharge-current-microamp = <256000>; + charge-term-current-microamp = <128000>; + // etc. + }; + + bq24190: charger@6a { + compatible = "ti,bq24190"; + reg = <0x6a>; + interrupts-extended = <&gpiochip 10 IRQ_TYPE_EDGE_FALLING>; + monitored-battery = <&bat>; + ti,system-minimum-microvolt = <3200000>; + }; + + &twl_gpio { + otg { + gpio-hog; + gpios = <6 0>; + output-high; + line-name = "otg-gpio"; + }; + }; -- cgit v1.2.3