bq27xxx_battery partial series
Subsystems (4)
cover bq27xxx_battery partial series
Latest changes (including 12.6):
Only DM update RAM chips by default
Add config_battery_bq27xxx_dt_updates_nvm. If defined, update NVM chips
and add module param dt_monitored_battery_updates_nvm
Fixed checkpatch errors and most warnings
Switched from -ENOSYS to -PERM, due to checkpatch warning
Add Copyright notice
unseal() returns error on key==0
Skip reset on non-cfgupdate chips if not updated
Emit warning if no dm_regs table
Map orig ID to chip ID via bq27xxx_chips[]
Drop "prototypes" in enum comments
Rename dupes detector bq27xxx_battery_dbg_regs_dupes()
^.^ ^.^ ^.^ - We has hungry for test!
PATCH 3/10 power: power_supply: Add power_supply_battery_info and API
From: Liam Breck <[email protected]>
power_supply_get_battery_info() reads battery data from devicetree. struct power_supply_battery_info provides battery data to drivers. Drivers may surface battery data in sysfs via corresponding POWER_SUPPLY_PROP_* fields.
--- Documentation/power/power_supply_class.txt | 12 ++++++++ drivers/power/supply/power_supply_core.c | 45 ++++++++++++++++++++++++++++++ include/linux/power_supply.h | 18 ++++++++++++ 3 files changed, 75 insertions(+)
Documentation/power/power_supply_class.txt +12 -0
@@ -174,6 +174,18 @@ issued by external power supply will notify supplicants via external_power_changed callback. +Devicetree battery characteristics +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Drivers should call power_supply_get_battery_info() to obtain battery +characteristics from a devicetree battery node, defined in +Documentation/devicetree/bindings/power/supply/battery.txt. This is +implemented in drivers/power/supply/bq27xxx_battery.c. + +Properties in struct power_supply_battery_info and their counterparts in the +battery node have names corresponding to elements in enum power_supply_property, +for naming consistency between sysfs attributes and battery node properties. + + QA ~~ Q: Where is POWER_SUPPLY_PROP_XYZ attribute?
drivers/power/supply/power_supply_core.c +45 -0
57 lines not on this page · raw message
include/linux/power_supply.h +18 -0
@@ -288,6 +288,21 @@ struct power_supply_info {int use_for_apm; }; +/* +* This is the recommended struct to manage static battery parameters, +* populated by power_supply_get_battery_info(). Most platform drivers should +* use these for consistency. +* Its field names must correspond to elements in enum power_supply_property. +* The default field value is -EINVAL. +* Power supply class itself doesn't use this. +*/ + +struct power_supply_battery_info { +int energy_full_design_uwh;/* microWatt-hours */ +int charge_full_design_uah;/* microAmp-hours */ +int voltage_min_design_uv;/* microVolts */ +}; +extern struct atomic_notifier_head power_supply_notifier;extern int power_supply_reg_notifier (struct notifier_block *nb);extern void power_supply_unreg_notifier (struct notifier_block *nb);
@@ -306,6 +321,9 @@ static inline struct power_supply * devm_power_supply_get_by_phandle(struct device *dev, const char *property) {return NULL ; }#endif /* CONFIG_OF */ + +extern int power_supply_get_battery_info (struct power_supply *psy, +struct power_supply_battery_info *info);extern void power_supply_changed (struct power_supply *psy);extern int power_supply_am_i_supplied (struct power_supply *psy);extern int power_supply_set_battery_charged (struct power_supply *psy);
Signature · 1 line
2.9.3
PATCH 5/10 power: bq27xxx_battery: Add bulk transfer bus methods
In reply to Liam BreckFrom: Matt Ranostay <[email protected]>
Declare bus.write/read_bulk/write_bulk().
Add I2C write/read_bulk/write_bulk() to implement the above. Add bq27xxx_write/read_block/write_block() helpers to call the above.
--- drivers/power/supply/bq27xxx_battery.c | 67 +++++++++++++++++++++++- drivers/power/supply/bq27xxx_battery_i2c.c | 82 +++++++++++++++++++++++++++++- include/linux/power/bq27xxx_battery.h | 3 ++ 3 files changed, 149 insertions(+), 3 deletions(-)
drivers/power/supply/bq27xxx_battery.c +65 -2
@@ -794,11 +794,74 @@ MODULE_PARM_DESC(poll_interval,static inline int bq27xxx_read (struct bq27xxx_device_info *di,int reg_index,bool single) { -/* Reports EINVAL for invalid/missing registers */ +int ret; +if (!di || di->regs[reg_index] ==INVALID_REG_ADDR )return -EINVAL ; -return di->bus.read (di, di->regs[reg_index], single); + ret = di->bus.read (di, di->regs[reg_index], single); +if (ret <0 ) +dev_dbg (di->dev,"failed to read register 0x%02x (index %d)\n" , + di->regs[reg_index], reg_index); + +return ret; +} + +static inline int bq27xxx_write (struct bq27xxx_device_info *di,int reg_index, +u16 value,bool single) +{ +int ret; + +if (!di || di->regs[reg_index] ==INVALID_REG_ADDR ) +return -EINVAL ; + +if (!di->bus.write) +return -EPERM ; + + ret = di->bus.write (di, di->regs[reg_index], value, single); +if (ret <0 ) +dev_dbg (di->dev,"failed to write register 0x%02x (index %d)\n" , + di->regs[reg_index], reg_index); + +return ret; +} + +static inline int bq27xxx_read_block (struct bq27xxx_device_info *di,int reg_index, +u8 *data,int len) +{ +int ret; + +if (!di || di->regs[reg_index] ==INVALID_REG_ADDR ) +return -EINVAL ; + +if (!di->bus.read_bulk) +return -EPERM ; + + ret = di->bus.read_bulk (di, di->regs[reg_index], data, len); +if (ret <0 ) +dev_dbg (di->dev,"failed to read_bulk register 0x%02x (index %d)\n" , + di->regs[reg_index], reg_index); + +return ret; +} + +static inline int bq27xxx_write_block (struct bq27xxx_device_info *di,int reg_index, +u8 *data,int len) +{ +int ret; + +if (!di || di->regs[reg_index] ==INVALID_REG_ADDR ) +return -EINVAL ; + +if (!di->bus.write_bulk) +return -EPERM ; + + ret = di->bus.write_bulk (di, di->regs[reg_index], data, len); +if (ret <0 ) +dev_dbg (di->dev,"failed to write_bulk register 0x%02x (index %d)\n" , + di->regs[reg_index], reg_index); + +return ret; }/*
drivers/power/supply/bq27xxx_battery_i2c.c +81 -1
101 lines not on this page · raw message
include/linux/power/bq27xxx_battery.h +3 -0
@@ -40,6 +40,9 @@ struct bq27xxx_platform_data {struct bq27xxx_device_info ;struct bq27xxx_access_methods {int (*read)(struct bq27xxx_device_info *di,u8 reg,bool single); +int (*write)(struct bq27xxx_device_info *di,u8 reg,int value,bool single); +int (*read_bulk)(struct bq27xxx_device_info *di,u8 reg,u8 *data,int len); +int (*write_bulk)(struct bq27xxx_device_info *di,u8 reg,u8 *data,int len); };struct bq27xxx_reg_cache {
Signature · 1 line
2.9.3
PATCH 6/10 power: bq27xxx_battery: Add chip data memory read/write support
In reply to Liam BreckFrom: Liam Breck <[email protected]>
Add these to enable read/write of chip data memory RAM/NVM/flash:
bq27xxx_battery_seal()
bq27xxx_battery_unseal() bq27xxx_battery_set_cfgupdate() bq27xxx_battery_read_dm_block() bq27xxx_battery_write_dm_block() bq27xxx_battery_checksum_dm_block()
--- drivers/power/supply/bq27xxx_battery.c | 253 +++++++++++++++++++++++++++++++++ include/linux/power/bq27xxx_battery.h | 1 + 2 files changed, 254 insertions(+)
drivers/power/supply/bq27xxx_battery.c +253 -0
@@ -5,6 +5,7 @@* Copyright (C) 2008 Eurotech S.p.A. <[email protected]> * Copyright (C) 2010-2011 Lars-Peter Clausen <[email protected]> * Copyright (C) 2011 Pali Rohár <[email protected]> +* Copyright (C) 2017 Liam Breck <[email protected]> * * Based on a previous work by Copyright (C) 2008 Texas Instruments, Inc. *
@@ -65,6 +66,7 @@#define BQ27XXX_FLAG_DSC BIT(0)#define BQ27XXX_FLAG_SOCF BIT(1)/* State-of-Charge threshold final */ #define BQ27XXX_FLAG_SOC1 BIT(2)/* State-of-Charge threshold 1 */ +#define BQ27XXX_FLAG_CFGUP BIT(4)#define BQ27XXX_FLAG_FC BIT(9)#define BQ27XXX_FLAG_OTD BIT(14)#define BQ27XXX_FLAG_OTC BIT(15)
@@ -78,6 +80,12 @@#define BQ27000_FLAG_FC BIT(5)#define BQ27000_FLAG_CHGS BIT(7)/* Charge state flag */ +/* control register params */ +#define BQ27XXX_SEALED 0x20 +#define BQ27XXX_SET_CFGUPDATE 0x13 +#define BQ27XXX_SOFT_RESET 0x42 +#define BQ27XXX_RESET 0x41 +#define BQ27XXX_RS (20)/* Resistor sense mOhm */ #define BQ27XXX_POWER_CONSTANT (29200)/* 29.2 µV^2 * 1000 */ #define BQ27XXX_CURRENT_CONSTANT (3570)/* 3.57 µV * 1000 */
@@ -108,9 +116,21 @@ enum bq27xxx_reg_index {BQ27XXX_REG_SOC ,/* State-of-Charge */ BQ27XXX_REG_DCAP ,/* Design Capacity */ BQ27XXX_REG_AP ,/* Average Power */ +BQ27XXX_DM_CTRL ,/* Block Data Control */ +BQ27XXX_DM_CLASS ,/* Data Class */ +BQ27XXX_DM_BLOCK ,/* Data Block */ +BQ27XXX_DM_DATA ,/* Block Data */ +BQ27XXX_DM_CKSUM ,/* Block Data Checksum */ BQ27XXX_REG_MAX, /* sentinel */ }; +#define BQ27XXX_DM_REG_ROWS \ + [BQ27XXX_DM_CTRL] = 0x61, \ + [BQ27XXX_DM_CLASS] = 0x3e, \ + [BQ27XXX_DM_BLOCK] = 0x3f, \ + [BQ27XXX_DM_DATA] = 0x40, \ + [BQ27XXX_DM_CKSUM] = 0x60 +/* Register mappings */ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX ] = { [BQ27000 ] = {
@@ -131,6 +151,11 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x0b, [BQ27XXX_REG_DCAP] = 0x76, [BQ27XXX_REG_AP] = 0x24, + [BQ27XXX_DM_CTRL] = INVALID_REG_ADDR, + [BQ27XXX_DM_CLASS] = INVALID_REG_ADDR, + [BQ27XXX_DM_BLOCK] = INVALID_REG_ADDR, + [BQ27XXX_DM_DATA] = INVALID_REG_ADDR, + [BQ27XXX_DM_CKSUM ] =INVALID_REG_ADDR , }, [BQ27010] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -150,6 +175,11 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x0b, [BQ27XXX_REG_DCAP] = 0x76, [BQ27XXX_REG_AP] = INVALID_REG_ADDR, + [BQ27XXX_DM_CTRL] = INVALID_REG_ADDR, + [BQ27XXX_DM_CLASS] = INVALID_REG_ADDR, + [BQ27XXX_DM_BLOCK] = INVALID_REG_ADDR, + [BQ27XXX_DM_DATA] = INVALID_REG_ADDR, + [BQ27XXX_DM_CKSUM ] =INVALID_REG_ADDR , }, [BQ2750X] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -169,6 +199,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP ] =INVALID_REG_ADDR , +BQ27XXX_DM_REG_ROWS , }, [BQ2751X] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -188,6 +219,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x20, [BQ27XXX_REG_DCAP] = 0x2e, [BQ27XXX_REG_AP ] =INVALID_REG_ADDR , +BQ27XXX_DM_REG_ROWS , }, [BQ27500] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -207,6 +239,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27510G1] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -226,6 +259,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27510G2] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -245,6 +279,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27510G3] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -264,6 +299,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x20, [BQ27XXX_REG_DCAP] = 0x2e, [BQ27XXX_REG_AP ] =INVALID_REG_ADDR , +BQ27XXX_DM_REG_ROWS , }, [BQ27520G1] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -283,6 +319,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27520G2] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -302,6 +339,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27520G3] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -321,6 +359,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27520G4] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -340,6 +379,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x20, [BQ27XXX_REG_DCAP] = INVALID_REG_ADDR, [BQ27XXX_REG_AP ] =INVALID_REG_ADDR , +BQ27XXX_DM_REG_ROWS , }, [BQ27530] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -359,6 +399,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = INVALID_REG_ADDR, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27541] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -378,6 +419,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27545] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -397,6 +439,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = INVALID_REG_ADDR, [BQ27XXX_REG_AP ] =0x24 , +BQ27XXX_DM_REG_ROWS , }, [BQ27421] = { [BQ27XXX_REG_CTRL ] =0x00 ,
@@ -416,6 +459,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_SOC] = 0x1c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP] = 0x18, + BQ27XXX_DM_REG_ROWS, }, };
@@ -757,6 +801,28 @@ static struct {static DEFINE_MUTEX (bq27xxx_list_lock);static LIST_HEAD (bq27xxx_battery_devices); +#define BQ27XXX_MSLEEP (i) usleep_range((i)*1000, (i)*1000+500) + +#define BQ27XXX_DM_SZ 32 + +/** +* struct bq27xxx_dm_buf - chip data memory buffer +* @class: data memory subclass_id +* @block: data memory block number +* @data: data from/for the block +* @has_data: true if data has been filled by read +* @dirty: true if data has changed since last read/write +* +* Encapsulates info required to manage chip data memory blocks. +*/ +struct bq27xxx_dm_buf { +u8 class; +u8 block; +u8 data[BQ27XXX_DM_SZ ]; +bool has_data, dirty; +}; + +static int poll_interval_param_set (const char *val,const struct kernel_param *kp) {struct bq27xxx_device_info *di;
@@ -864,6 +930,193 @@ static inline int bq27xxx_write_block(struct bq27xxx_device_info *di, int reg_inreturn ret; } +static int bq27xxx_battery_seal (struct bq27xxx_device_info *di) +{ +int ret; + + ret =bq27xxx_write (di,BQ27XXX_REG_CTRL ,BQ27XXX_SEALED , false); +if (ret <0 ) { +dev_err (di->dev,"bus error on seal: %d\n" , ret); +return ret; + } + +return 0 ; +} + +static int bq27xxx_battery_unseal (struct bq27xxx_device_info *di) +{ +int ret; + +if (di->unseal_key ==0 ) { +dev_err (di->dev,"unseal failed due to missing key\n" ); +return -EINVAL ; + } + + ret =bq27xxx_write (di,BQ27XXX_REG_CTRL , (u16)(di->unseal_key >>16 ), false); +if (ret <0 ) + goto out; + + ret =bq27xxx_write (di,BQ27XXX_REG_CTRL , (u16 )di->unseal_key, false); +if (ret <0 ) + goto out; + +return 0 ; + +out: +dev_err (di->dev,"bus error on unseal: %d\n" , ret); +return ret; +} + +static u8 bq27xxx_battery_checksum_dm_block (struct bq27xxx_dm_buf *buf) +{ +u16 sum =0 ; +int i; + +for (i =0 ; i <BQ27XXX_DM_SZ ; i++) + sum += buf->data[i]; + sum &=0xff ; + +return 0xff - sum; +} + +static int bq27xxx_battery_read_dm_block (struct bq27xxx_device_info *di, +struct bq27xxx_dm_buf *buf) +{ +int ret; + + buf->has_data = false; + + ret =bq27xxx_write (di,BQ27XXX_DM_CLASS , buf->class, true); +if (ret <0 ) + goto out; + + ret =bq27xxx_write (di,BQ27XXX_DM_BLOCK , buf->block, true); +if (ret <0 ) + goto out; + +BQ27XXX_MSLEEP (1 ); + + ret =bq27xxx_read_block (di,BQ27XXX_DM_DATA , buf->data,BQ27XXX_DM_SZ ); +if (ret <0 ) + goto out; + + ret =bq27xxx_read (di,BQ27XXX_DM_CKSUM , true); +if (ret <0 ) + goto out; + +if ((u8 )ret !=bq27xxx_battery_checksum_dm_block (buf)) { + ret = -EINVAL ; + goto out; + } + + buf->has_data = true; + buf->dirty = false; + +return 0 ; + +out: +dev_err (di->dev,"bus error reading chip memory: %d\n" , ret); +return ret; +} + +static int bq27xxx_battery_set_cfgupdate (struct bq27xxx_device_info *di,u16 state) +{ +const int limit =100 ; +int ret, try = limit; + + ret =bq27xxx_write (di,BQ27XXX_REG_CTRL , + state ?BQ27XXX_SET_CFGUPDATE :BQ27XXX_SOFT_RESET , + false); +if (ret <0 ) + goto out; + +do { +BQ27XXX_MSLEEP (25 ); + ret = di->bus.read (di, di->regs[BQ27XXX_REG_FLAGS ], false); +if (ret <0 ) + goto out; + }while ((ret &BQ27XXX_FLAG_CFGUP ) != state && --try); + +if (!try) { +dev_err (di->dev,"timed out waiting for cfgupdate flag %d\n" , !!state); +return -EINVAL ; + } + +if (limit-try >3 ) +dev_warn (di->dev,"cfgupdate %d, retries %d\n" , !!state, limit-try); + +return 0 ; + +out: +dev_err (di->dev,"bus error on %s: %d\n" , state ?"set_cfgupdate" :"soft_reset" , ret); +return ret; +} + +static int bq27xxx_battery_write_dm_block (struct bq27xxx_device_info *di, +struct bq27xxx_dm_buf *buf) +{ +bool cfgup = di->chip ==BQ27421 ;/* assume group supports cfgupdate */ +int ret; + +if (!buf->dirty) +return 0 ; + +if (cfgup) { + ret =bq27xxx_battery_set_cfgupdate (di,BQ27XXX_FLAG_CFGUP ); +if (ret <0 ) +return ret; + } + + ret =bq27xxx_write (di,BQ27XXX_DM_CTRL ,0 , true); +if (ret <0 ) + goto out; + + ret =bq27xxx_write (di,BQ27XXX_DM_CLASS , buf->class, true); +if (ret <0 ) + goto out; + + ret =bq27xxx_write (di,BQ27XXX_DM_BLOCK , buf->block, true); +if (ret <0 ) + goto out; + +BQ27XXX_MSLEEP (1 ); + + ret =bq27xxx_write_block (di,BQ27XXX_DM_DATA , buf->data,BQ27XXX_DM_SZ ); +if (ret <0 ) + goto out; + + ret =bq27xxx_write (di,BQ27XXX_DM_CKSUM , +bq27xxx_battery_checksum_dm_block (buf), true); +if (ret <0 ) + goto out; + +/* DO NOT read BQ27XXX_DM_CKSUM here to verify it! That may cause NVM +* corruption on the '425 chip (and perhaps others), which can damage +* the chip. See TI bqtool for what not to do: +* http://git.ti.com/bms-linux/bqtool/blobs/master/gauge.c#line328 +*/ + +if (cfgup) { +BQ27XXX_MSLEEP (1 ); + ret =bq27xxx_battery_set_cfgupdate (di,0 ); +if (ret <0 ) +return ret; + }else { +BQ27XXX_MSLEEP (100 );/* flash DM updates in <100ms */ + } + + buf->dirty = false; + +return 0 ; + +out: +if (cfgup) +bq27xxx_battery_set_cfgupdate (di,0 ); + +dev_err (di->dev,"bus error writing chip memory: %d\n" , ret); +return ret; +} +/* * Return the battery State-of-Charge * Or < 0 if something fails.
include/linux/power/bq27xxx_battery.h +1 -0
@@ -64,6 +64,7 @@ struct bq27xxx_device_info {int id;enum bq27xxx_chip chip;const char *name; +u32 unseal_key;struct bq27xxx_access_methods bus;struct bq27xxx_reg_cache cache;int charge_design_full;
Signature · 1 line
2.9.3
PATCH 7/10 power: bq27xxx_battery: Add power_supply_battery_info support
In reply to Liam BreckFrom: Liam Breck <[email protected]>
Previously there was no way to configure these chips in the event that the defaults didn't match the battery in question.
For chips with RAM data memory (and also those with flash/NVM data memory if CONFIG_BATTERY_BQ27XXX_DT_UPDATES_NVM is defined and the user has not set module param dt_monitored_battery_updates_nvm=0) we now call power_supply_get_battery_info(), check its values, and write battery properties to chip data memory if there is a dm_regs table for the chip.
--- drivers/power/supply/Kconfig | 9 ++ drivers/power/supply/bq27xxx_battery.c | 199 ++++++++++++++++++++++++++++++++- include/linux/power/bq27xxx_battery.h | 2 + 3 files changed, 209 insertions(+), 1 deletion(-)
drivers/power/supply/Kconfig +9 -0
@@ -178,6 +178,15 @@ config BATTERY_BQ27XXX_I2C Say Y here to enable support for batteries with BQ27xxx chips connected over an I2C bus. +config BATTERY_BQ27XXX_DT_UPDATES_NVM + bool "BQ27xxx support for update of NVM/flash data memory" + depends on BATTERY_BQ27XXX_I2C + help + Say Y here to enable devicetree monitored-battery config to update + NVM/flash data memory. Only enable this option for devices with a + fuel gauge mounted on the circuit board, and a battery that cannot + be replaced with one of a different type. + config BATTERY_DA9030 tristate "DA9030 battery driver" depends on PMIC_DA903X
drivers/power/supply/bq27xxx_battery.c +198 -1
241 lines not on this page · raw message
include/linux/power/bq27xxx_battery.h +2 -0
@@ -63,7 +63,9 @@ struct bq27xxx_device_info {struct device *dev;int id;enum bq27xxx_chip chip; +bool ram_chip;const char *name; +struct bq27xxx_dm_reg *dm_regs;u32 unseal_key;struct bq27xxx_access_methods bus;struct bq27xxx_reg_cache cache;
Signature · 1 line
2.9.3
PATCH 8/10 power: bq27xxx_battery: Enable data memory update for certain chips
In reply to Liam BreckFrom: Liam Breck <[email protected]>
Support data memory update on BQ27500, 545, 425, 421, 441, 621.
Create IDs for for previously unID'd chips, to index arrays for unseal keys and data memory register tables.
--- drivers/power/supply/bq27xxx_battery.c | 90 ++++++++++++++++++++++++++++-- drivers/power/supply/bq27xxx_battery_i2c.c | 16 +++--- include/linux/power/bq27xxx_battery.h | 13 +++++ 3 files changed, 107 insertions(+), 12 deletions(-)
drivers/power/supply/bq27xxx_battery.c +86 -4
@@ -58,7 +58,7 @@#include <linux/power/bq27xxx_battery.h> -#define DRIVER_VERSION "1.2.0" +#define DRIVER_VERSION "1.3.0"#define BQ27XXX_MANUFACTURER "Texas Instruments"
@@ -132,7 +132,7 @@ enum bq27xxx_reg_index { [BQ27XXX_DM_CKSUM] = 0x60 /* Register mappings */ -static u8 bq27xxx_regs[][BQ27XXX_REG_MAX ] = { +static u8 bq27xxx_regs[BQ27MAX ][BQ27XXX_REG_MAX ] = { [BQ27000 ] = { [BQ27XXX_REG_CTRL ] =0x00 , [BQ27XXX_REG_TEMP ] =0x06 ,
@@ -779,7 +779,7 @@ static enum power_supply_property bq27421_battery_props[] = {static struct {enum power_supply_property *props;size_t size; -} bq27xxx_battery_props[] = { +} bq27xxx_battery_props[BQ27MAX ] = {BQ27XXX_PROP (BQ27000 , bq27000_battery_props),BQ27XXX_PROP (BQ27010 , bq27010_battery_props),BQ27XXX_PROP (BQ2750X , bq2750x_battery_props),
@@ -798,6 +798,33 @@ static struct { BQ27XXX_PROP(BQ27421, bq27421_battery_props), }; +static enum bq27xxx_chip bq27xxx_chips[] = { + [BQ27000 ] =BQ27000 , + [BQ27010 ] =BQ27010 , + [BQ2750X ] =BQ2750X , + [BQ2751X ] =BQ2751X , + [BQ2752X ] =BQ2751X , + [BQ27500 ] =BQ27500 , + [BQ27510G1 ] =BQ27510G1 , + [BQ27510G2 ] =BQ27510G2 , + [BQ27510G3 ] =BQ27510G3 , + [BQ27520G1 ] =BQ27520G1 , + [BQ27520G2 ] =BQ27520G2 , + [BQ27520G3 ] =BQ27520G3 , + [BQ27520G4 ] =BQ27520G4 , + [BQ27530 ] =BQ27530 , + [BQ27531 ] =BQ27530 , + [BQ27541 ] =BQ27541 , + [BQ27542 ] =BQ27541 , + [BQ27546 ] =BQ27541 , + [BQ27742 ] =BQ27541 , + [BQ27545 ] =BQ27545 , + [BQ27421 ] =BQ27421 , + [BQ27425 ] =BQ27421 , + [BQ27441 ] =BQ27421 , + [BQ27621 ] =BQ27421 , +}; +static DEFINE_MUTEX (bq27xxx_list_lock);static LIST_HEAD (bq27xxx_battery_devices);
@@ -856,6 +883,54 @@ static const char * const bq27xxx_dm_reg_name[] = { [BQ27XXX_DM_TERMINATE_VOLTAGE] = "terminate-voltage", }; +static struct bq27xxx_dm_reg bq27500_dm_regs[] = { + [BQ27XXX_DM_DESIGN_CAPACITY ] = {48 ,10 ,2 ,0 ,65535 }, + [BQ27XXX_DM_DESIGN_ENERGY ] = { },/* missing on chip */ + [BQ27XXX_DM_TERMINATE_VOLTAGE ] = {80 ,48 ,2 ,1000 ,32767 }, +}; + +static struct bq27xxx_dm_reg bq27545_dm_regs[] = { + [BQ27XXX_DM_DESIGN_CAPACITY ] = {48 ,23 ,2 ,0 ,32767 }, + [BQ27XXX_DM_DESIGN_ENERGY ] = {48 ,25 ,2 ,0 ,32767 }, + [BQ27XXX_DM_TERMINATE_VOLTAGE ] = {80 ,67 ,2 ,2800 ,3700 }, +}; + +static struct bq27xxx_dm_reg bq27421_dm_regs[] = { + [BQ27XXX_DM_DESIGN_CAPACITY ] = {82 ,10 ,2 ,0 ,8000 }, + [BQ27XXX_DM_DESIGN_ENERGY ] = {82 ,12 ,2 ,0 ,32767 }, + [BQ27XXX_DM_TERMINATE_VOLTAGE ] = {82 ,16 ,2 ,2500 ,3700 }, +}; + +static struct bq27xxx_dm_reg bq27425_dm_regs[] = { + [BQ27XXX_DM_DESIGN_CAPACITY ] = {82 ,12 ,2 ,0 ,32767 }, + [BQ27XXX_DM_DESIGN_ENERGY ] = {82 ,14 ,2 ,0 ,32767 }, + [BQ27XXX_DM_TERMINATE_VOLTAGE ] = {82 ,18 ,2 ,2800 ,3700 }, +}; + +static struct bq27xxx_dm_reg bq27621_dm_regs[] = { + [BQ27XXX_DM_DESIGN_CAPACITY ] = {82 ,3 ,2 ,0 ,8000 }, + [BQ27XXX_DM_DESIGN_ENERGY ] = {82 ,5 ,2 ,0 ,32767 }, + [BQ27XXX_DM_TERMINATE_VOLTAGE ] = {82 ,9 ,2 ,2500 ,3700 }, +}; + +static struct bq27xxx_dm_reg *bq27xxx_dm_regs[] = { + [BQ27500 ] = bq27500_dm_regs, + [BQ27545 ] = bq27545_dm_regs, + [BQ27421 ] = bq27421_dm_regs, + [BQ27425 ] = bq27425_dm_regs, + [BQ27441 ] = bq27421_dm_regs, + [BQ27621 ] = bq27621_dm_regs, +}; + +static u32 bq27xxx_unseal_keys[] = { + [BQ27500 ] =0x04143672 , + [BQ27545 ] =0x04143672 , + [BQ27421 ] =0x80008000 , + [BQ27425 ] =0x04143672 , + [BQ27441 ] =0x80008000 , + [BQ27621 ] =0x80008000 , +}; +#ifdef CONFIG_BATTERY_BQ27XXX_DT_UPDATES_NVM static bool bq27xxx_dt_to_nvm = true;
@@ -1865,9 +1940,16 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di) .drv_data = di, }; + di->ram_chip = di->chip ==BQ27421 || di->chip ==BQ27441 || di->chip ==BQ27621 ; + + di->unseal_key = bq27xxx_unseal_keys[di->chip]; + di->dm_regs = bq27xxx_dm_regs[di->chip]; + di->chip = bq27xxx_chips[di->chip]; + + di->regs = bq27xxx_regs[di->chip]; +INIT_DELAYED_WORK (&di->work, bq27xxx_battery_poll);mutex_init (&di->lock); - di->regs = bq27xxx_regs[di->chip]; psy_desc =devm_kzalloc (di->dev,sizeof (*psy_desc),GFP_KERNEL );if (!psy_desc)
drivers/power/supply/bq27xxx_battery_i2c.c +8 -8
@@ -230,7 +230,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = { { "bq27210", BQ27010 }, { "bq27500", BQ2750X }, { "bq27510", BQ2751X }, - { "bq27520", BQ2751X }, + { "bq27520", BQ2752X }, { "bq27500-1", BQ27500 }, { "bq27510g1", BQ27510G1 }, { "bq27510g2", BQ27510G2 },
@@ -240,16 +240,16 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = { { "bq27520g3", BQ27520G3 }, { "bq27520g4", BQ27520G4 }, { "bq27530", BQ27530 }, - { "bq27531", BQ27530 }, + { "bq27531", BQ27531 }, { "bq27541", BQ27541 }, - { "bq27542", BQ27541 }, - { "bq27546", BQ27541 }, - { "bq27742", BQ27541 }, + { "bq27542", BQ27542 }, + { "bq27546", BQ27546 }, + { "bq27742", BQ27742 }, { "bq27545", BQ27545 }, { "bq27421", BQ27421 }, - { "bq27425", BQ27421 }, - { "bq27441", BQ27421 }, - { "bq27621", BQ27421 }, + { "bq27425", BQ27425 }, + { "bq27441", BQ27441 }, + { "bq27621", BQ27621 }, {}, };MODULE_DEVICE_TABLE (i2c, bq27xxx_i2c_id_table);
include/linux/power/bq27xxx_battery.h +13 -0
@@ -2,6 +2,8 @@#define __LINUX_BQ27X00_BATTERY_H__enum bq27xxx_chip { +/* these index bq27xxx_regs[] & bq27xxx_battery_props[] */ +/* and map to themselves in bq27xxx_chips[] */ BQ27000 =1 ,/* bq27000, bq27200 */ BQ27010 ,/* bq27010, bq27210 */ BQ2750X ,/* bq27500 deprecated alias */
@@ -18,6 +20,17 @@ enum bq27xxx_chip {BQ27541 ,/* bq27541, bq27542, bq27546, bq27742 */ BQ27545 ,/* bq27545 */ BQ27421 ,/* bq27421, bq27425, bq27441, bq27621 */ +BQ27MAX , + +/* these map to above in bq27xxx_chips[] */ +BQ2752X ,/* deprecated alias */ +BQ27531 , +BQ27542 , +BQ27546 , +BQ27742 , +BQ27425 , +BQ27441 , + BQ27621, };/**
Signature · 1 line
2.9.3
PATCH 9/10 power: bq27xxx_battery: Flag identical register maps when in debug mode
In reply to Liam BreckFrom: Liam Breck <[email protected]>
We tie multiple chips to unique register maps. When supporting a new chip, it's easy to add a duplicate map by mistake.
In debug mode we now scan the register maps for duplicates.
--- drivers/power/supply/bq27xxx_battery.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/power/supply/bq27xxx_battery.c +21 -0
@@ -1932,6 +1932,25 @@ static void bq27xxx_external_power_changed(struct power_supply *psy)schedule_delayed_work (&di->work,0 ); } +#ifdef DEBUG +static void bq27xxx_battery_dbg_regs_dupes (struct bq27xxx_device_info *di) +{ +const size_t max =ARRAY_SIZE (bq27xxx_regs); +int a, b; + +for (a =1 ; a < max-1 ; a++) { +for (b = a+1 ; b < max; b++) { +if (!memcmp (bq27xxx_regs[a], bq27xxx_regs[b], +sizeof (bq27xxx_regs[0 ]))) +dev_warn (di->dev, +"bq27xxx_regs[%d] & [%d] are identical\n" , a, b); + } + } +} +#else +static inline void bq27xxx_battery_dbg_regs_dupes (struct bq27xxx_device_info *di) {} +#endif +int bq27xxx_battery_setup (struct bq27xxx_device_info *di) {struct power_supply_desc *psy_desc;
@@ -1940,6 +1959,8 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di) .drv_data = di, }; +bq27xxx_battery_dbg_regs_dupes (di); + di->ram_chip = di->chip ==BQ27421 || di->chip ==BQ27441 || di->chip ==BQ27621 ; di->unseal_key = bq27xxx_unseal_keys[di->chip];
Signature · 1 line
2.9.3
PATCH 10/10 power: bq27xxx_battery: Remove duplicate register arrays
In reply to Liam BreckFrom: Liam Breck <[email protected]>
BQ2751X & BQ27510G3 are identical. BQ27500 & BQ27510G1 & BQ27510G2 are identical. Make BQ2751X & BQ27510G1/2 aliases. Remove the duplicate arrays, etc.
--- drivers/power/supply/bq27xxx_battery.c | 134 +-------------------------------- include/linux/power/bq27xxx_battery.h | 12 +-- 2 files changed, 10 insertions(+), 136 deletions(-)
drivers/power/supply/bq27xxx_battery.c +4 -130
@@ -201,26 +201,6 @@ static u8 bq27xxx_regs[BQ27MAX][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_AP ] =INVALID_REG_ADDR ,BQ27XXX_DM_REG_ROWS , }, - [BQ2751X] = { - [BQ27XXX_REG_CTRL ] =0x00 , - [BQ27XXX_REG_TEMP ] =0x06 , - [BQ27XXX_REG_INT_TEMP ] =0x28 , - [BQ27XXX_REG_VOLT ] =0x08 , - [BQ27XXX_REG_AI ] =0x14 , - [BQ27XXX_REG_FLAGS ] =0x0a , - [BQ27XXX_REG_TTE ] =0x16 , - [BQ27XXX_REG_TTF ] =INVALID_REG_ADDR , - [BQ27XXX_REG_TTES ] =0x1a , - [BQ27XXX_REG_TTECP ] =INVALID_REG_ADDR , - [BQ27XXX_REG_NAC ] =0x0c , - [BQ27XXX_REG_FCC ] =0x12 , - [BQ27XXX_REG_CYCT ] =0x1e , - [BQ27XXX_REG_AE ] =INVALID_REG_ADDR , - [BQ27XXX_REG_SOC ] =0x20 , - [BQ27XXX_REG_DCAP ] =0x2e , - [BQ27XXX_REG_AP ] =INVALID_REG_ADDR , -BQ27XXX_DM_REG_ROWS , - }, [BQ27500] = { [BQ27XXX_REG_CTRL ] =0x00 , [BQ27XXX_REG_TEMP ] =0x06 ,
@@ -241,46 +221,6 @@ static u8 bq27xxx_regs[BQ27MAX][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_AP ] =0x24 ,BQ27XXX_DM_REG_ROWS , }, - [BQ27510G1] = { - [BQ27XXX_REG_CTRL ] =0x00 , - [BQ27XXX_REG_TEMP ] =0x06 , - [BQ27XXX_REG_INT_TEMP ] =INVALID_REG_ADDR , - [BQ27XXX_REG_VOLT ] =0x08 , - [BQ27XXX_REG_AI ] =0x14 , - [BQ27XXX_REG_FLAGS ] =0x0a , - [BQ27XXX_REG_TTE ] =0x16 , - [BQ27XXX_REG_TTF ] =0x18 , - [BQ27XXX_REG_TTES ] =0x1c , - [BQ27XXX_REG_TTECP ] =0x26 , - [BQ27XXX_REG_NAC ] =0x0c , - [BQ27XXX_REG_FCC ] =0x12 , - [BQ27XXX_REG_CYCT ] =0x2a , - [BQ27XXX_REG_AE ] =0x22 , - [BQ27XXX_REG_SOC ] =0x2c , - [BQ27XXX_REG_DCAP ] =0x3c , - [BQ27XXX_REG_AP ] =0x24 , -BQ27XXX_DM_REG_ROWS , - }, - [BQ27510G2 ] = { - [BQ27XXX_REG_CTRL ] =0x00 , - [BQ27XXX_REG_TEMP ] =0x06 , - [BQ27XXX_REG_INT_TEMP ] =INVALID_REG_ADDR , - [BQ27XXX_REG_VOLT ] =0x08 , - [BQ27XXX_REG_AI ] =0x14 , - [BQ27XXX_REG_FLAGS ] =0x0a , - [BQ27XXX_REG_TTE ] =0x16 , - [BQ27XXX_REG_TTF ] =0x18 , - [BQ27XXX_REG_TTES ] =0x1c , - [BQ27XXX_REG_TTECP ] =0x26 , - [BQ27XXX_REG_NAC ] =0x0c , - [BQ27XXX_REG_FCC ] =0x12 , - [BQ27XXX_REG_CYCT ] =0x2a , - [BQ27XXX_REG_AE ] =0x22 , - [BQ27XXX_REG_SOC ] =0x2c , - [BQ27XXX_REG_DCAP ] =0x3c , - [BQ27XXX_REG_AP ] =0x24 , -BQ27XXX_DM_REG_ROWS , - }, [BQ27510G3] = { [BQ27XXX_REG_CTRL ] =0x00 , [BQ27XXX_REG_TEMP ] =0x06 ,
@@ -523,24 +463,6 @@ static enum power_supply_property bq2750x_battery_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, }; -static enum power_supply_property bq2751x_battery_props[] = { -POWER_SUPPLY_PROP_STATUS , -POWER_SUPPLY_PROP_PRESENT , -POWER_SUPPLY_PROP_VOLTAGE_NOW , -POWER_SUPPLY_PROP_CURRENT_NOW , -POWER_SUPPLY_PROP_CAPACITY , -POWER_SUPPLY_PROP_CAPACITY_LEVEL , -POWER_SUPPLY_PROP_TEMP , -POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW , -POWER_SUPPLY_PROP_TECHNOLOGY , -POWER_SUPPLY_PROP_CHARGE_FULL , -POWER_SUPPLY_PROP_CHARGE_NOW , -POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN , -POWER_SUPPLY_PROP_CYCLE_COUNT , -POWER_SUPPLY_PROP_HEALTH , -POWER_SUPPLY_PROP_MANUFACTURER , -}; -static enum power_supply_property bq27500_battery_props[] = {POWER_SUPPLY_PROP_STATUS ,POWER_SUPPLY_PROP_PRESENT ,
@@ -562,48 +484,6 @@ static enum power_supply_property bq27500_battery_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, }; -static enum power_supply_property bq27510g1_battery_props[] = { -POWER_SUPPLY_PROP_STATUS , -POWER_SUPPLY_PROP_PRESENT , -POWER_SUPPLY_PROP_VOLTAGE_NOW , -POWER_SUPPLY_PROP_CURRENT_NOW , -POWER_SUPPLY_PROP_CAPACITY , -POWER_SUPPLY_PROP_CAPACITY_LEVEL , -POWER_SUPPLY_PROP_TEMP , -POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW , -POWER_SUPPLY_PROP_TIME_TO_FULL_NOW , -POWER_SUPPLY_PROP_TECHNOLOGY , -POWER_SUPPLY_PROP_CHARGE_FULL , -POWER_SUPPLY_PROP_CHARGE_NOW , -POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN , -POWER_SUPPLY_PROP_CYCLE_COUNT , -POWER_SUPPLY_PROP_ENERGY_NOW , -POWER_SUPPLY_PROP_POWER_AVG , -POWER_SUPPLY_PROP_HEALTH , -POWER_SUPPLY_PROP_MANUFACTURER , -}; - -static enum power_supply_property bq27510g2_battery_props[] = { -POWER_SUPPLY_PROP_STATUS , -POWER_SUPPLY_PROP_PRESENT , -POWER_SUPPLY_PROP_VOLTAGE_NOW , -POWER_SUPPLY_PROP_CURRENT_NOW , -POWER_SUPPLY_PROP_CAPACITY , -POWER_SUPPLY_PROP_CAPACITY_LEVEL , -POWER_SUPPLY_PROP_TEMP , -POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW , -POWER_SUPPLY_PROP_TIME_TO_FULL_NOW , -POWER_SUPPLY_PROP_TECHNOLOGY , -POWER_SUPPLY_PROP_CHARGE_FULL , -POWER_SUPPLY_PROP_CHARGE_NOW , -POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN , -POWER_SUPPLY_PROP_CYCLE_COUNT , -POWER_SUPPLY_PROP_ENERGY_NOW , -POWER_SUPPLY_PROP_POWER_AVG , -POWER_SUPPLY_PROP_HEALTH , -POWER_SUPPLY_PROP_MANUFACTURER , -}; -static enum power_supply_property bq27510g3_battery_props[] = {POWER_SUPPLY_PROP_STATUS ,POWER_SUPPLY_PROP_PRESENT ,
@@ -783,10 +663,7 @@ static struct {BQ27XXX_PROP (BQ27000 , bq27000_battery_props),BQ27XXX_PROP (BQ27010 , bq27010_battery_props),BQ27XXX_PROP (BQ2750X , bq2750x_battery_props), -BQ27XXX_PROP (BQ2751X , bq2751x_battery_props),BQ27XXX_PROP (BQ27500 , bq27500_battery_props), -BQ27XXX_PROP (BQ27510G1 , bq27510g1_battery_props), -BQ27XXX_PROP (BQ27510G2 , bq27510g2_battery_props),BQ27XXX_PROP (BQ27510G3 , bq27510g3_battery_props),BQ27XXX_PROP (BQ27520G1 , bq27520g1_battery_props), BQ27XXX_PROP(BQ27520G2, bq27520g2_battery_props),
@@ -802,11 +679,11 @@ static enum bq27xxx_chip bq27xxx_chips[] = { [BQ27000] = BQ27000, [BQ27010] = BQ27010, [BQ2750X] = BQ2750X, - [BQ2751X] = BQ2751X, - [BQ2752X] = BQ2751X, + [BQ2751X] = BQ27510G3, + [BQ2752X] = BQ27510G3, [BQ27500] = BQ27500, - [BQ27510G1] = BQ27510G1, - [BQ27510G2] = BQ27510G2, + [BQ27510G1] = BQ27500, + [BQ27510G2] = BQ27500, [BQ27510G3] = BQ27510G3, [BQ27520G1] = BQ27520G1, [BQ27520G2] = BQ27520G2,
@@ -1578,10 +1455,7 @@ static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags) {switch (di->chip) {case BQ2750X : -case BQ2751X :case BQ27500 : -case BQ27510G1 : -case BQ27510G2 :case BQ27510G3 :case BQ27520G1 :case BQ27520G2 :
include/linux/power/bq27xxx_battery.h +6 -6
@@ -7,11 +7,8 @@ enum bq27xxx_chip {BQ27000 =1 ,/* bq27000, bq27200 */ BQ27010 ,/* bq27010, bq27210 */ BQ2750X ,/* bq27500 deprecated alias */ -BQ2751X ,/* bq27510, bq27520 deprecated alias */ -BQ27500 ,/* bq27500/1 */ -BQ27510G1 ,/* bq27510G1 */ -BQ27510G2 ,/* bq27510G2 */ -BQ27510G3 ,/* bq27510G3 */ +BQ27500 ,/* bq27500/1, bq27510G1, bq27510G2 */ +BQ27510G3 ,/* bq27510G3, bq27510, bq27520 */ BQ27520G1 ,/* bq27520G1 */ BQ27520G2 ,/* bq27520G2 */ BQ27520G3, /* bq27520G3 */
@@ -23,7 +20,10 @@ enum bq27xxx_chip {BQ27MAX ,/* these map to above in bq27xxx_chips[] */ -BQ2752X ,/* deprecated alias */ +BQ2751X ,/* bq27510 deprecated alias */ +BQ2752X ,/* bq27520 deprecated alias */ +BQ27510G1 , +BQ27510G2 ,BQ27531 ,BQ27542 , BQ27546,
Signature · 1 line
2.9.3
Hi Liam,
Quoted 19 lines · Liam Breck
Latest changes (including 12.6):
Only DM update RAM chips by default
Add
config_battery_bq27xxx_dt_updates_nvm. If defined, update NVM chips
and add module paramdt_monitored_battery_updates_nvmFixed checkpatch errors and most warnings
Switched from
-ENOSYSto -PERM, due to checkpatch warningAdd Copyright notice
unseal()returns error on key==0Skip reset on non-cfgupdate chips if not updated
Emit warning if no
dm_regstable
Quoted 7 lines
Map orig ID to chip ID via bq27xxx_chips[]
Drop "prototypes" in enum comments
Rename dupes detector
bq27xxx_battery_dbg_regs_dupes()^.^ ^.^ ^.^ - We has hungry for test!
I queued everything up to patch 7 (including). That way any rebasing should be less problematic. With the unseal keys not yet applied all new features are not yet be used, but its much easier to follow development. Also your work on using the new interface in charger driver is unblocked.
I plan to send this for 4.12 towards the end of next week and would like to queue the remaining patches early during 4.13 period (i.e. sometime mid-end of May), so that they get much time in linux-next. This will also give Andrew some time to test this.
-- Sebastian
[resend as plain-text]
Hi Sebastian,
Quoted 36 lines · Sebastian Reichel
Hi Liam,
Quoted 19 lines · Liam Breck
Latest changes (including 12.6):
Only DM update RAM chips by default
Add
config_battery_bq27xxx_dt_updates_nvm. If defined, update NVM chips
and add module paramdt_monitored_battery_updates_nvmFixed checkpatch errors and most warnings
Switched from
-ENOSYSto -PERM, due to checkpatch warningAdd Copyright notice
unseal()returns error on key==0Skip reset on non-cfgupdate chips if not updated
Emit warning if no
dm_regstableQuoted 7 lines
Map orig ID to chip ID via bq27xxx_chips[]
Drop "prototypes" in enum comments
Rename dupes detector
bq27xxx_battery_dbg_regs_dupes()^.^ ^.^ ^.^ - We has hungry for test!
I queued everything up to patch 7 (including). That way any rebasing should be less problematic. With the unseal keys not yet applied all new features are not yet be used, but its much easier to follow development. Also your work on using the new interface in charger driver is unblocked.
Quoted 4 lines
I plan to send this for 4.12 towards the end of next week and would like to queue the remaining patches early during 4.13 period (i.e. sometime mid-end of May), so that they get much time in linux-next. This will also give Andrew some time to test this.
I have pending changes in v13 for patches 1-4, and I think we should let Andrew ack the others. Can you drop 1-7 for now?
I can post v13 this week, as I believe I've cleared all his comments. I'll rev the patch titles as you did.
I don't think this series will have spent enough/any time in -next to qualify for 4.12? There's no known effects without patches 8+, but even so :-)
Re patch 7, do you have any thoughts on the naming of:
config option: config_battery_bq27xxx_dt_updates_nvm module param: dt_monitored_battery_updates_nvm
Thanks