power: supply: ltc2941-battery-gauge: Support LTC2942
Subsystems (2)
v4 cover power: supply: ltc2941-battery-gauge: Support LTC2942
This is 4th version of patch.
Changelog:
- v2: reworked voltage computing to not overflow and keep presision
- v3: update devicetree binding documentation
- v4: add ltc2942 devicetree compatible
LTC2942 is pin compatible with LTC2941 providing few more registers holding information about battery voltage and temperature. It can be runtime detected using bit A7 in the Status register.
PATCH 1/2 defines LTC2942 registers with no functional changes while 2/2 does actually the job.
I'm not sure, whenever splitting support into two patches makes sense, but it just makes reviewing easier. I'd happily squash patches together.
Comments welcome,
ladis
PATCH v4 1/2 power: supply: ltc2941-battery-gauge: Define LTC2942 registers
In order to support LTC2942 which has temperature registers at different offsets than LTC2943 use following register naming scheme (prefixes):
- LTC294X_ common registers
- LTC2942_ chips specific registers
- LTC2943_ specific registers
There are no functional changes.
---
Changes:
- v2: None
- v3: Extend commit message
- v4: None
drivers/power/supply/ltc2941-battery-gauge.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/power/supply/ltc2941-battery-gauge.c +13 -14
@@ -34,16 +34,14 @@ enum ltc294x_reg {LTC294X_REG_CONTROL =0x01 ,LTC294X_REG_ACC_CHARGE_MSB =0x02 ,LTC294X_REG_ACC_CHARGE_LSB =0x03 , -LTC294X_REG_THRESH_HIGH_MSB =0x04 , -LTC294X_REG_THRESH_HIGH_LSB =0x05 , -LTC294X_REG_THRESH_LOW_MSB =0x06 , -LTC294X_REG_THRESH_LOW_LSB =0x07 , -LTC294X_REG_VOLTAGE_MSB =0x08 , -LTC294X_REG_VOLTAGE_LSB =0x09 , -LTC294X_REG_CURRENT_MSB =0x0E , -LTC294X_REG_CURRENT_LSB =0x0F , -LTC294X_REG_TEMPERATURE_MSB =0x14 , - LTC294X_REG_TEMPERATURE_LSB = 0x15, +LTC294X_REG_VOLTAGE_MSB =0x08 , +LTC294X_REG_VOLTAGE_LSB =0x09 , +LTC2942_REG_TEMPERATURE_MSB =0x0C , +LTC2942_REG_TEMPERATURE_LSB =0x0D , +LTC2943_REG_CURRENT_MSB =0x0E , +LTC2943_REG_CURRENT_LSB =0x0F , +LTC2943_REG_TEMPERATURE_MSB =0x14 , + LTC2943_REG_TEMPERATURE_LSB = 0x15, };#define LTC2943_REG_CONTROL_MODE_MASK (BIT(7) | BIT(6))
@@ -55,6 +53,7 @@ enum ltc294x_reg {#define LTC294X_REG_CONTROL_ALCC_CONFIG_DISABLED 0#define LTC2941_NUM_REGS 0x08 +#define LTC2942_NUM_REGS 0x10#define LTC2943_NUM_REGS 0x18struct ltc294x_info {
@@ -263,7 +262,7 @@ static int ltc294x_get_current(const struct ltc294x_info *info, int *val)s32 value; ret =ltc294x_read_regs (info->client, -LTC294X_REG_CURRENT_MSB , &datar[0 ],2 ); +LTC2943_REG_CURRENT_MSB , &datar[0 ],2 ); value = (datar[0 ] <<8 ) | datar[1 ]; value -=0x7FFF ;/* Value is in range -32k..+32k, r_sense is usually 10..50 mOhm,
@@ -280,7 +279,7 @@ static int ltc294x_get_temperature(const struct ltc294x_info *info, int *val)u32 value; ret =ltc294x_read_regs (info->client, -LTC294X_REG_TEMPERATURE_MSB , &datar[0 ],2 ); +LTC2943_REG_TEMPERATURE_MSB , &datar[0 ],2 ); value = (datar[0 ] <<8 ) | datar[1 ];/* Full-scale is 510 Kelvin, convert to centidegrees */ *val = (((51000 * value) /0xFFFF ) -27215 );
@@ -424,10 +423,10 @@ static int ltc294x_i2c_probe(struct i2c_client *client, info->client = client; info->supply_desc.type =POWER_SUPPLY_TYPE_BATTERY ; info->supply_desc.properties = ltc294x_properties; -if (info->num_regs >=LTC294X_REG_TEMPERATURE_LSB ) +if (info->num_regs >=LTC2943_REG_TEMPERATURE_LSB ) info->supply_desc.num_properties =ARRAY_SIZE (ltc294x_properties); -else if (info->num_regs >=LTC294X_REG_CURRENT_LSB ) +else if (info->num_regs >=LTC2943_REG_CURRENT_LSB ) info->supply_desc.num_properties =ARRAY_SIZE (ltc294x_properties) -1 ;else if (info->num_regs >=LTC294X_REG_VOLTAGE_LSB )
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 2/2 power: supply: ltc2941-battery-gauge: Add support for LTC2942
In reply to Ladislav MichlLTC2942 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.
---
Changes:
- v2: reworked voltage computing to not overflow and keep presision
- v3: update devicetree binding documentation
- v4: add ltc2942 devicetree compatible
.../devicetree/bindings/power/supply/ltc2941.txt | 15 ++-- drivers/power/supply/ltc2941-battery-gauge.c | 85 +++++++++++++++++----- 2 files changed, 74 insertions(+), 26 deletions(-)
Documentation/devicetree/bindings/power/supply/ltc2941.txt +8 -7
@@ -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
drivers/power/supply/ltc2941-battery-gauge.c +66 -19
161 lines not on this page · raw message
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 2/2] power: supply: ltc2941-battery-gauge: Add support for LTC2942
Quoted 4 lines · Ladislav Michl
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.
Quoted 8 lines
Signed-off-by Ladislav Michl <[email protected]>---
Changes:
- v2: reworked voltage computing to not overflow and keep presision
- v3: update devicetree binding documentation
- v4: add ltc2942 devicetree compatible.../devicetree/bindings/power/supply/ltc2941.txt | 15 ++--
Quoted 2 lines
drivers/power/supply/ltc2941-battery-gauge.c | 85 +++++++++++++++++----- 2 files changed, 74 insertions(+), 26 deletions(-)