Devicetree battery support and client bq27xxx_battery
Subsystems (4)
v5 cover Devicetree battery support and client bq27xxx_battery
Overview:
* new devicetree battery node specifies static battery data
* fuel gauge and charger nodes shall use monitored-battery=<&battery_node>
* new power_supply_get_battery_info() reads battery data from devicetree
* new struct power_supply_battery_info provides battery data to drivers
* drivers surface battery data in sysfs via related power_supply_prop_* fields
* bq27xxx driver calls the above and writes battery data to NVRAM
Changes in v5:
* incorporate feedback into Documentation/devicetree/.../battery.txt
* use power_supply_prop_* names in devicetree and power_supply_battery_info
* add battery:voltage-max-design-microvolt
* default fields to -EINVAL in power_supply_battery_info
* power_supply_get_battery_info() always looks for "monitored-battery"
* power_supply_get_battery_info() emits a warning if !psy->of_node
* squash patches for power_supply_battery_info
* bq27xxx_battery: check power_supply_battery_info values
* bq27xxx_battery: note missing power_supply_prop_* features
* bq27xxx_battery: new patch for access methods
Changes in v4:
* add "fixed-battery" compatible field to be be more consistant with devicetree
Changes in v3:
* split i2c changes into respective patches
* add documentation for battery information for fuel gauge
* rebased documentation patches on change on the list
* abstracted the battery configuration for the state machine to an generic struct and platform data access function
Changes in v2:
* add documentation for uWh and uAh property units
* change devicetree entries to match new property units
Matt Ranostay (8):
devicetree: power: Add battery.txt
devicetree: property-units: Add uWh and uAh units
devicetree: power: bq27xxx: Add monitored-battery documentation
power: power_supply: Add power_supply_battery_info and API
power: bq27xxx_battery: Add power_supply_battery_info support
power: bq27xxx_battery_i2c: Add I2C bulk read/write functions
power: bq27xxx_battery: Define access methods to write chip registers
power: bq27xxx_battery: Add BQ27425 chip id
.../devicetree/bindings/power/supply/battery.txt | 39 +++ .../devicetree/bindings/power/supply/bq27xxx.txt | 9 + .../devicetree/bindings/property-units.txt | 2 + drivers/power/supply/bq27xxx_battery.c | 326 ++++++++++++++++++++- drivers/power/supply/bq27xxx_battery_i2c.c | 64 +++- drivers/power/supply/power_supply_core.c | 43 +++ include/linux/power/bq27xxx_battery.h | 7 +- include/linux/power_supply.h | 19 ++ 8 files changed, 505 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.txt
Signature · 1 line
2.9.3
PATCH v5 1/8 devicetree: power: Add battery.txt
From: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Documentation of static battery characteristics that can be defined for batteries which cannot self-identify. This information is required by fuel-gauge and charger chips for proper handling of the battery.
--- .../devicetree/bindings/power/supply/battery.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.txt
Documentation/devicetree/bindings/power/supply/battery.txt new file +39 -0
@@ -0,0 +1,39 @@ +Battery Characteristics + +Required Properties: + - compatible: Must be "fixed-battery" + +Optional Properties: + - voltage-min-design-microvolt: drained battery voltage + - voltage-max-design-microvolt: charged battery voltage + - energy-full-design-microwatt-hours: battery design energy + - charge-full-design-microamp-hours: battery design capacity + +Future Properties must be named for the corresponding elements in +enum power_supply_property, defined in include/linux/power_supply.h. + +Batteries must be referenced by chargers and/or fuel-gauges +using a phandle. The phandle's property should be named +"monitored-battery". + +Example: + + bat: battery { + compatible = "fixed-battery"; + voltage-min-design-microvolt = <3200000>; + voltage-max-design-microvolt = <4200000>; + energy-full-design-microwatt-hours = <5290000>; + charge-full-design-microamp-hours = <1430000>; + }; + + charger: charger@0 { + .... + monitored-battery = <&bat>; + ... + }; + + fuel_gauge: fuel_gauge@0 { + .... + monitored-battery = <&bat>; + ... + };
Signature · 1 line
2.9.3
A message that is not in the archive (sent off-list or not yet received): 20170204091603.32242-2-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org
Re: [PATCH v5 1/8] devicetree: power: Add battery.txt
Quoted 3 lines · Liam Breck
From: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
How are the double from me happening? :) Seems odds
Quoted 60 lines
Documentation of static battery characteristics that can be defined for batteries which cannot self-identify. This information is required by fuel-gauge and charger chips for proper handling of the battery.
Cc Rob Herring <[email protected]>Signed-off-by Matt Ranostay <[email protected]>Signed-off-by Liam Breck <[email protected]>--- .../devicetree/bindings/power/supply/battery.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.txtDocumentation/devicetree/bindings/power/supply/battery.txt new file +39
-1@@ -0,0 +1,39 @@ +Battery Characteristics + +Required Properties: + - compatible: Must be "fixed-battery" + +Optional Properties: + - voltage-min-design-microvolt: drained battery voltage + - voltage-max-design-microvolt: charged battery voltage + - energy-full-design-microwatt-hours: battery design energy + - charge-full-design-microamp-hours: battery design capacity + +Future Properties must be named for the corresponding elements in +enum power_supply_property, defined in include/linux/power_supply.h. + +Batteries must be referenced by chargers and/or fuel-gauges +using a phandle. The phandle's property should be named +"monitored-battery". + +Example: + + bat: battery { + compatible = "fixed-battery"; + voltage-min-design-microvolt = <3200000>; + voltage-max-design-microvolt = <4200000>; + energy-full-design-microwatt-hours = <5290000>; + charge-full-design-microamp-hours = <1430000>; + }; + + charger: charger@0 { + .... + monitored-battery = <&bat>; + ... + }; + + fuel_gauge: fuel_gauge@0 { + .... + monitored-battery = <&bat>; + ... + }; --
Quoted 2 lines
2.9.3
--
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 v5 1/8] devicetree: power: Add battery.txt
In reply to a message not in the archiveQuoted 7 lines · Liam Breck
From: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Documentation of static battery characteristics that can be defined for batteries which cannot self-identify. This information is required by fuel-gauge and charger chips for proper handling of the battery.
I hope this is a common binding and not yet another battery binding.
Quoted 16 lines
Cc Rob Herring <[email protected]>Signed-off-by Matt Ranostay <[email protected]>Signed-off-by Liam Breck <[email protected]>--- .../devicetree/bindings/power/supply/battery.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.txtDocumentation/devicetree/bindings/power/supply/battery.txt new file +0
-0
Documentation/devicetree/bindings/power/supply/battery.txt line 4
Quoted 4 lines
Documentation/devicetree/bindings/power/supply/battery.txt new file +4
-0@@ -0,0 +1,39 @@ +Battery Characteristics + +Required Properties: + - compatible: Must be "fixed-battery"
The "fixed" part seems a bit pointless. Just "battery" would be a bit generic. Don't you need to know the battery chemistry typically? Or number of cells?
Quoted 21 lines
Documentation/devicetree/bindings/power/supply/battery.txt new file +21
-0+ +Optional Properties: + - voltage-min-design-microvolt: drained battery voltage + - voltage-max-design-microvolt: charged battery voltage + - energy-full-design-microwatt-hours: battery design energy + - charge-full-design-microamp-hours: battery design capacity + +Future Properties must be named for the corresponding elements in +enum power_supply_property, defined in include/linux/power_supply.h. + +Batteries must be referenced by chargers and/or fuel-gauges +using a phandle. The phandle's property should be named +"monitored-battery". + +Example: + + bat: battery { + compatible = "fixed-battery"; + voltage-min-design-microvolt = <3200000>; + voltage-max-design-microvolt = <4200000>; + energy-full-design-microwatt-hours = <5290000>;
Documentation/devicetree/bindings/power/supply/battery.txt line 35
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/battery.txt new file +10
-0+ charge-full-design-microamp-hours = <1430000>; + }; + + charger: charger@0 { + .... + monitored-battery = <&bat>; + ... + }; + + fuel_gauge: fuel_gauge@0 {
fuel-gauge@...
Quoted 7 lines
Documentation/devicetree/bindings/power/supply/battery.txt new file +4
-0+ .... + monitored-battery = <&bat>; + ... + };Signature · 1 line
2.9.3
--
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 v5 1/8] devicetree: power: Add battery.txt
Quoted 10 lines · Rob Herring
Quoted 7 lines · Liam Breck
From: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Documentation of static battery characteristics that can be defined for batteries which cannot self-identify. This information is required by fuel-gauge and charger chips for proper handling of the battery.
I hope this is a common binding and not yet another battery binding.
Yes, Sebastian had us add support for this in power_supply_core with
int power_supply_get_battery_info(
struct power_supply *psy,
struct power_suppy_battery_info *info)
Quoted 9 lines
Quoted 9 lines
Cc Rob Herring <[email protected]>Signed-off-by Matt Ranostay <[email protected]>Signed-off-by Liam Breck <[email protected]>--- .../devicetree/bindings/power/supply/battery.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.txt
Quoted 14 lines
Documentation/devicetree/bindings/power/supply/battery.txt line 4
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/battery.txt new file +4
-0@@ -0,0 +1,39 @@ +Battery Characteristics + +Required Properties: + - compatible: Must be "fixed-battery"The "fixed" part seems a bit pointless. Just "battery" would be a bit generic. Don't you need to know the battery chemistry typically? Or number of cells?
Sebastian suggested fixed-battery to indicate a non-smart battery, i.e. a pack without self-awareness besides a protection circuit.
I don't know what compatible would have for a smart battery. That might be useful to establish now...
I'll be posting v6 shortly, with no change re compatible.
~.~
PATCH v5 2/8 devicetree: property-units: Add uWh and uAh units
In reply to Liam BreckFrom: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Add entries for microwatt-hours and microamp-hours.
--- Documentation/devicetree/bindings/property-units.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/property-units.txt +2 -0
@@ -25,8 +25,10 @@ Distance Electricity ---------------------------------------- -microamp : micro amps +-microamp-hours : micro amp-hours -ohms : Ohms -micro-ohms : micro Ohms +-microwatt-hours: micro Watt-hours -microvolt : micro volts Temperature
Signature · 6 lines
2.9.3 -- 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
A message that is not in the archive (sent off-list or not yet received): 20170204091603.32242-1-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org
PATCH v5 3/8 devicetree: power: bq27xxx: Add monitored-battery documentation
From: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Document monitored-battery = <&battery_node>
--- Documentation/devicetree/bindings/power/supply/bq27xxx.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/power/supply/bq27xxx.txt +9 -0
@@ -28,9 +28,18 @@ Required properties: * "ti,bq27621" - BQ27621 - reg: integer, i2c address of the device. +Optional properties: +- monitored-battery: phandle of battery information devicetree node + + See Documentation/devicetree/bindings/power/supply/battery.txt + If either of the referenced battery's *-full-design-*-hours properties are set, + then both must be. + Example: bq27510g3 { compatible = "ti,bq27510g3"; reg = <0x55>; + + monitored-battery = <&bat>; };
Signature · 6 lines
2.9.3 -- 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
A message that is not in the archive (sent off-list or not yet received): 20170204091603.32242-4-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org
Re: [PATCH v5 3/8] devicetree: power: bq27xxx: Add monitored-battery documentation
Quoted 22 lines · Liam Breck
From: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Document monitored-battery = <
&battery_node>Cc Rob Herring <[email protected]>Signed-off-by Matt Ranostay <[email protected]>Signed-off-by Liam Breck <[email protected]>--- Documentation/devicetree/bindings/power/supply/bq27xxx.txt | 9 +++++++++ 1 file changed, 9 insertions(+)Documentation/devicetree/bindings/power/supply/bq27xxx.txt +0
-0@@ -28,9 +28,18 @@ Required properties: * "ti,bq27621" - BQ27621 - reg: integer, i2c address of the device.
Documentation/devicetree/bindings/power/supply/bq27xxx.txt Required properties: · line 40
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/bq27xxx.txt +7
-0+Optional properties: +- monitored-battery: phandle of battery information devicetree node + + See Documentation/devicetree/bindings/power/supply/battery.txt + If either of the referenced battery's *-full-design-*-hours properties are set, + then both must be. + Example: bq27510g3 {
charger@55
Or fuel-gauge@..., I can't tell.
Quoted 8 lines
Documentation/devicetree/bindings/power/supply/bq27xxx.txt +2
-0compatible = "ti,bq27510g3"; reg = <0x55>; + + monitored-battery = <&bat>; };Signature · 1 line
2.9.3
--
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 v5 4/8 power: power_supply: Add power_supply_battery_info and API
In reply to Liam BreckFrom: Matt Ranostay <[email protected]>
From: Matt Ranostay <[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.
--- drivers/power/supply/power_supply_core.c | 43 ++++++++++++++++++++++++++++++++ include/linux/power_supply.h | 19 ++++++++++++++ 2 files changed, 62 insertions(+)
drivers/power/supply/power_supply_core.c +43 -0
@@ -17,6 +17,7 @@#include <linux/device.h> #include <linux/notifier.h> #include <linux/err.h> +#include <linux/of.h> #include <linux/power_supply.h> #include <linux/thermal.h> #include "power_supply.h"
@@ -487,6 +488,48 @@ struct power_supply *devm_power_supply_get_by_phandle(struct device *dev,EXPORT_SYMBOL_GPL (devm_power_supply_get_by_phandle);#endif /* CONFIG_OF */ +int power_supply_get_battery_info (struct power_supply *psy, +struct power_supply_battery_info *info) +{ +struct device_node *battery_np; +const char *value; +int err; + + info->energy_full_design_uwh = -EINVAL ; + info->charge_full_design_uah = -EINVAL ; + info->voltage_min_design_uv = -EINVAL ; + info->voltage_max_design_uv = -EINVAL ; + +if (!psy->of_node) { +dev_warn (&psy->dev,"%s currently only supports devicetree\n" , + __func__); +return -ENXIO ; + } + + battery_np =of_parse_phandle (psy->of_node,"monitored-battery" ,0 ); +if (!battery_np) +return -ENODEV ; + + err =of_property_read_string (battery_np,"compatible" , &value); +if (err) +return err; + +if (strcmp ("fixed-battery" , value)) +return -ENODEV ; + +of_property_read_u32 (battery_np,"energy-full-design-microwatt-hours" , + &info->energy_full_design_uwh); +of_property_read_u32 (battery_np,"charge-full-design-microamp-hours" , + &info->charge_full_design_uah); +of_property_read_u32 (battery_np,"voltage-min-design-microvolt" , + &info->voltage_min_design_uv); +of_property_read_u32 (battery_np,"voltage-max-design-microvolt" , + &info->voltage_max_design_uv); + +return 0 ; +} +EXPORT_SYMBOL_GPL (power_supply_get_battery_info); +int power_supply_get_property (struct power_supply *psy,enum power_supply_property psp,union power_supply_propval *val)
include/linux/power_supply.h +19 -0
@@ -288,6 +288,22 @@ 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 */ +int voltage_max_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 +322,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 v5 5/8 power: bq27xxx_battery: Add power_supply_battery_info support
In reply to Liam BreckFrom: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Previously there was no way to set chip registers in the event that the defaults didn't match the battery in question.
BQ27xxx driver now calls power_supply_get_battery_info, checks the inputs, and writes battery data to NVRAM.
--- drivers/power/supply/bq27xxx_battery.c | 303 ++++++++++++++++++++++++++++++++- include/linux/power/bq27xxx_battery.h | 1 + 2 files changed, 303 insertions(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +302 -1
@@ -37,6 +37,7 @@* http://www.ti.com/product/bq27621-g1 */ +#include <linux/delay.h> #include <linux/device.h> #include <linux/module.h> #include <linux/mutex.h>
@@ -432,6 +433,54 @@ static struct {static DEFINE_MUTEX (bq27xxx_list_lock);static LIST_HEAD (bq27xxx_battery_devices); +#define BQ27XXX_MIN_V_MIN 2800 +#define BQ27XXX_MIN_V_MAX 3700 +#define BQ27XXX_MAX_V_MIN 0 +#define BQ27XXX_MAX_V_MAX 5000 + +#define BQ27XXX_BLOCK_DATA_CLASS 0x3E +#define BQ27XXX_DATA_BLOCK 0x3F +#define BQ27XXX_BLOCK_DATA 0x40 +#define BQ27XXX_BLOCK_DATA_CHECKSUM 0x60 +#define BQ27XXX_BLOCK_DATA_CONTROL 0x61 +#define BQ27XXX_SET_CFGUPDATE 0x13 +#define BQ27XXX_SOFT_RESET 0x42 + +enum bq27xxx_dm_subclass_index { +BQ27XXX_DM_DESIGN_CAPACITY =0 , +BQ27XXX_DM_DESIGN_ENERGY , +BQ27XXX_DM_TERMINATE_VOLTAGE , +BQ27XXX_DM_V_AT_CHARGE_TERM , +BQ27XXX_DM_END , +}; + +struct bq27xxx_dm_regs { +unsigned int subclass_id; +unsigned int offset; +char *name; +}; + +#define BQ27XXX_GAS_GAUGING_STATE_SUBCLASS 82 + +static struct bq27xxx_dm_regs bq27425_dm_subclass_regs[] = { + [BQ27XXX_DM_DESIGN_CAPACITY ] = + {BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ,12 ,"design-capacity" }, + [BQ27XXX_DM_DESIGN_ENERGY ] = + {BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ,14 ,"design-energy" }, + [BQ27XXX_DM_TERMINATE_VOLTAGE ] = + {BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ,18 ,"terminate-voltage" }, + [BQ27XXX_DM_V_AT_CHARGE_TERM ] = + {BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ,36 ,"v-at-charge-termination" }, +}; + +static struct bq27xxx_dm_regs *bq27xxx_dm_subclass_regs[] = { + [BQ27425 ] = bq27425_dm_subclass_regs, +}; + +static unsigned int bq27xxx_unseal_keys[] = { + [BQ27425 ] =0x04143672 , +}; +static int poll_interval_param_set (const char *val,const struct kernel_param *kp) {struct bq27xxx_device_info *di;
@@ -476,6 +525,179 @@ static inline int bq27xxx_read(struct bq27xxx_device_info *di, int reg_index,return di->bus.read (di, di->regs[reg_index], single); } +static int bq27xxx_battery_set_seal_state (struct bq27xxx_device_info *di, +bool state) +{ +unsigned int key = bq27xxx_unseal_keys[di->chip]; +int ret; + +if (state) +return di->bus.write (di,BQ27XXX_REG_CTRL ,0x20 , false); + + ret = di->bus.write (di,BQ27XXX_REG_CTRL , (key >>16 ) &0xffff , false); +if (ret <0 ) +return ret; + +return di->bus.write (di,BQ27XXX_REG_CTRL , key &0xffff , false); +} + +static int bq27xxx_battery_read_dm_block (struct bq27xxx_device_info *di, +int subclass) +{ +int ret = di->bus.write (di,BQ27XXX_REG_CTRL ,0 , false); + +if (ret <0 ) +return ret; + + ret = di->bus.write (di,BQ27XXX_BLOCK_DATA_CONTROL ,0 , true); +if (ret <0 ) +return ret; + + ret = di->bus.write (di,BQ27XXX_BLOCK_DATA_CLASS , subclass, true); +if (ret <0 ) +return ret; + + ret = di->bus.write (di,BQ27XXX_DATA_BLOCK ,0 , true); +if (ret <0 ) +return ret; + +usleep_range (1000 ,1500 ); + +return di->bus.read_bulk (di,BQ27XXX_BLOCK_DATA , + (u8 *) &di->buffer,sizeof (di->buffer)); +} + +static int bq27xxx_battery_print_config (struct bq27xxx_device_info *di) +{ +struct bq27xxx_dm_regs *reg = bq27xxx_dm_subclass_regs[di->chip]; +int ret, i; + + ret =bq27xxx_battery_read_dm_block (di, +BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ); +if (ret <0 ) +return ret; + +for (i =0 ; i <BQ27XXX_DM_END ; i++) { +int val; + +if (reg->subclass_id !=BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ) +continue ; + + val =be16_to_cpup ((u16 *) &di->buffer[reg->offset]); + +dev_info (di->dev,"settings for %s set at %d\n" , reg->name, val); + + reg++; + } + +return 0 ; +} + +static bool bq27xxx_battery_update_dm_setting (struct bq27xxx_device_info *di, +unsigned int reg,unsigned int val) +{ +struct bq27xxx_dm_regs *dm_reg = &bq27xxx_dm_subclass_regs[di->chip][reg]; +u16 *prev = (u16 *) &di->buffer[dm_reg->offset]; + +if (be16_to_cpup (prev) == val) +return false; + + *prev =cpu_to_be16 (val); + +return true; +} + +static u8 bq27xxx_battery_checksum (struct bq27xxx_device_info *di) +{ +u8 *data = (u8 *) &di->buffer; +u16 sum =0 ; +int i; + +for (i =0 ; i <sizeof (di->buffer); i++) { + sum += data[i]; + sum &=0xff ; + } + +return 0xff - sum; +} + +static int bq27xxx_battery_write_nvram (struct bq27xxx_device_info *di, +unsigned int subclass) +{ +int ret; + + ret = di->bus.write (di,BQ27XXX_REG_CTRL ,BQ27XXX_SET_CFGUPDATE , false); +if (ret) +return ret; + + ret = di->bus.write (di,BQ27XXX_BLOCK_DATA_CONTROL ,0 , true); +if (ret) +return ret; + + ret = di->bus.write (di,BQ27XXX_BLOCK_DATA_CLASS , subclass, true); +if (ret) +return ret; + + ret = di->bus.write (di,BQ27XXX_DATA_BLOCK ,0 , true); +if (ret) +return ret; + + ret = di->bus.write_bulk (di,BQ27XXX_BLOCK_DATA , + (u8 *) &di->buffer,sizeof (di->buffer)); +if (ret <0 ) +return ret; + +usleep_range (1000 ,1500 ); + + di->bus.write (di,BQ27XXX_BLOCK_DATA_CHECKSUM , +bq27xxx_battery_checksum (di), true); + +usleep_range (1000 ,1500 ); + + di->bus.write (di,BQ27XXX_REG_CTRL ,BQ27XXX_SOFT_RESET , false); + +return 0 ; +} + +static int bq27xxx_battery_set_config (struct bq27xxx_device_info *di, +struct power_supply_battery_info *info) +{ +int ret; + + ret =bq27xxx_battery_read_dm_block (di, +BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ); +if (ret <0 ) +return ret; + +if (info->charge_full_design_uah != -EINVAL + && info->energy_full_design_uwh != -EINVAL ) { + ret |=bq27xxx_battery_update_dm_setting (di, +BQ27XXX_DM_DESIGN_CAPACITY , + info->charge_full_design_uah /1000 ); + ret |=bq27xxx_battery_update_dm_setting (di, +BQ27XXX_DM_DESIGN_ENERGY , + info->energy_full_design_uwh /1000 ); + } + +if (info->voltage_min_design_uv != -EINVAL ) + ret |=bq27xxx_battery_update_dm_setting (di, +BQ27XXX_DM_TERMINATE_VOLTAGE , + info->voltage_min_design_uv /1000 ); + +if (info->voltage_max_design_uv != -EINVAL ) + ret |=bq27xxx_battery_update_dm_setting (di, +BQ27XXX_DM_V_AT_CHARGE_TERM , + info->voltage_max_design_uv /1000 ); + +if (ret) { +dev_info (di->dev,"updating NVM settings\n" ); +return bq27xxx_battery_write_nvram (di, +BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ); + } + +return 0 ; +} +/* * Return the battery State-of-Charge * Or < 0 if something fails.
@@ -736,6 +958,73 @@ static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)return POWER_SUPPLY_HEALTH_GOOD ; } +void bq27xxx_battery_settings (struct bq27xxx_device_info *di) +{ +struct power_supply_battery_info info = {}; + +/* functions don't exist for writing data so abort */ +if (!di->bus.write || !di->bus.write_bulk) +return ; + +/* no settings to be set for this chipset so abort */ +if (!bq27xxx_dm_subclass_regs[di->chip]) +return ; + +bq27xxx_battery_set_seal_state (di, false); + +if (power_supply_get_battery_info (di->bat, &info) <0 ) + goto out; + +if (info.energy_full_design_uwh != info.charge_full_design_uah) { +if (info.energy_full_design_uwh == -EINVAL ) +dev_warn (di->dev, +"missing battery:energy-full-design-microwatt-hours\n" ); +else if (info.charge_full_design_uah == -EINVAL ) +dev_warn (di->dev, +"missing battery:charge-full-design-microamp-hours\n" ); + } + +if (info.energy_full_design_uwh >0x7fff *1000 ) { +dev_err (di->dev,"invalid battery:energy-full-design-microwatt-hours %d\n" , + info.energy_full_design_uwh); + info.energy_full_design_uwh = -EINVAL ; + } + +if (info.charge_full_design_uah >0x7fff *1000 ) { +dev_err (di->dev,"invalid battery:charge-full-design-microamp-hours %d\n" , + info.charge_full_design_uah); + info.charge_full_design_uah = -EINVAL ; + } + +if ((info.voltage_min_design_uv <BQ27XXX_MIN_V_MIN *1000 + || info.voltage_min_design_uv >BQ27XXX_MIN_V_MAX *1000 ) + && info.voltage_min_design_uv != -EINVAL ) { +dev_err (di->dev,"invalid battery:voltage-min-design-microvolt %d\n" , + info.voltage_min_design_uv); + info.voltage_min_design_uv = -EINVAL ; + } + +if ((info.voltage_max_design_uv <BQ27XXX_MAX_V_MIN *1000 + || info.voltage_max_design_uv >BQ27XXX_MAX_V_MAX *1000 ) + && info.voltage_max_design_uv != -EINVAL ) { +dev_err (di->dev,"invalid battery:voltage-max-design-microvolt %d\n" , + info.voltage_max_design_uv); + info.voltage_max_design_uv = -EINVAL ; + } + +if ((info.energy_full_design_uwh == -EINVAL + || info.charge_full_design_uah == -EINVAL ) + && info.voltage_min_design_uv == -EINVAL + && info.voltage_max_design_uv == -EINVAL ) + goto out; + +bq27xxx_battery_set_config (di, &info); + +out: +bq27xxx_battery_print_config (di); +bq27xxx_battery_set_seal_state (di, true); +} +void bq27xxx_battery_update (struct bq27xxx_device_info *di) {struct bq27xxx_reg_cache cache = {0 , };
@@ -985,6 +1274,14 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN : ret =bq27xxx_simple_value (di->charge_design_full, val);break ; +/* +* TODO: Implement these to make registers set from +* power_supply_battery_info visible in sysfs. +*/ +case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN : +case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN : +case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN : +return -EINVAL ;case POWER_SUPPLY_PROP_CYCLE_COUNT : ret =bq27xxx_simple_value (di->cache.cycle_count, val);break ;
@@ -1018,7 +1315,10 @@ static void bq27xxx_external_power_changed(struct power_supply *psy)int bq27xxx_battery_setup (struct bq27xxx_device_info *di) {struct power_supply_desc *psy_desc; -struct power_supply_config psy_cfg = { .drv_data = di, }; +struct power_supply_config psy_cfg = { + .of_node = di->dev->of_node, + .drv_data = di, + };INIT_DELAYED_WORK (&di->work, bq27xxx_battery_poll);mutex_init (&di->lock);
@@ -1043,6 +1343,7 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)dev_info (di->dev,"support ver. %s enabled\n" ,DRIVER_VERSION ); +bq27xxx_battery_settings (di);bq27xxx_battery_update (di);mutex_lock (&bq27xxx_list_lock);
include/linux/power/bq27xxx_battery.h +1 -0
@@ -62,6 +62,7 @@ struct bq27xxx_device_info {struct list_head list;struct mutex lock;u8 *regs; +u8 buffer[32 ]; };void bq27xxx_battery_update (struct bq27xxx_device_info *di);
Signature · 1 line
2.9.3
kbuild test robot
build botRe: [PATCH v5 5/8] power: bq27xxx_battery: Add power_supply_battery_info support
url: https://github.com/0day-ci/linux/commits/Liam-Breck/Devicetree-battery-support-and-client-bq27xxx_battery/20170204-172332 config: i386-randconfig-x004-201705 (attached as .config) compiler…
Hi Matt,
[auto build test ERROR on next-20170203]
[cannot apply to battery/master linus/master linux/master v4.9-rc8 v4.9-rc7 v4.9-rc6 v4.10-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Liam-Breck/Devicetree-battery-support-and-client-bq27xxx_battery/20170204-172332
config: i386-randconfig-x004-201705 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:
# save the attached .config to linux build tree
make ARCH=i386 Note: the linux-review/Liam-Breck/Devicetree-battery-support-and-client-bq27xxx_battery/20170204-172332 HEAD 26caaa850a9e06e4d96ba05e9bff37ca03531973 builds fine.
It only hurts bisectibility.
All error/warnings (new ones prefixed by >>):
>> drivers/power/supply/bq27xxx_battery.c:802:3: error: 'BQ27425' undeclared here (not in a function)
[BQ27425] = bq27425_dm_subclass_regs,
^~~~~~~
>> drivers/power/supply/bq27xxx_battery.c:802:3: error: array index in initializer not of integer type
drivers/power/supply/bq27xxx_battery.c:802:3: note: (near initialization for 'bq27xxx_dm_subclass_regs')
drivers/power/supply/bq27xxx_battery.c:806:3: error: array index in initializer not of integer type
[BQ27425] = 0x04143672,
^~~~~~~
drivers/power/supply/bq27xxx_battery.c:806:3: note: (near initialization for 'bq27xxx_unseal_keys')
drivers/power/supply/bq27xxx_battery.c: In function 'bq27xxx_battery_set_seal_state':
>> drivers/power/supply/bq27xxx_battery.c:860:17: error: 'struct bq27xxx_access_methods' has no member named 'write'
return di->bus.write(di, BQ27XXX_REG_CTRL, 0x20, false);
^
drivers/power/supply/bq27xxx_battery.c:862:15: error: 'struct bq27xxx_access_methods' has no member named 'write'
ret = di->bus.write(di, BQ27XXX_REG_CTRL, (key >> 16) & 0xffff, false);
^
drivers/power/supply/bq27xxx_battery.c:866:16: error: 'struct bq27xxx_access_methods' has no member named 'write'
return di->bus.write(di, BQ27XXX_REG_CTRL, key & 0xffff, false);
^
drivers/power/supply/bq27xxx_battery.c: In function 'bq27xxx_battery_read_dm_block':
drivers/power/supply/bq27xxx_battery.c:872:19: error: 'struct bq27xxx_access_methods' has no member named 'write'
int ret = di->bus.write(di, BQ27XXX_REG_CTRL, 0, false);
^
drivers/power/supply/bq27xxx_battery.c:877:15: error: 'struct bq27xxx_access_methods' has no member named 'write'
ret = di->bus.write(di, BQ27XXX_BLOCK_DATA_CONTROL, 0, true);
^
drivers/power/supply/bq27xxx_battery.c:881:15: error: 'struct bq27xxx_access_methods' has no member named 'write'
ret = di->bus.write(di, BQ27XXX_BLOCK_DATA_CLASS, subclass, true);
^
drivers/power/supply/bq27xxx_battery.c:885:15: error: 'struct bq27xxx_access_methods' has no member named 'write'
ret = di->bus.write(di, BQ27XXX_DATA_BLOCK, 0, true);
^
>> drivers/power/supply/bq27xxx_battery.c:891:16: error: 'struct bq27xxx_access_methods' has no member named 'read_bulk'
return di->bus.read_bulk(di, BQ27XXX_BLOCK_DATA,
^
drivers/power/supply/bq27xxx_battery.c: In function 'bq27xxx_battery_write_nvram':
drivers/power/supply/bq27xxx_battery.c:954:15: error: 'struct bq27xxx_access_methods' has no member named 'write'
ret = di->bus.write(di, BQ27XXX_REG_CTRL, BQ27XXX_SET_CFGUPDATE, false);
^
drivers/power/supply/bq27xxx_battery.c:958:15: error: 'struct bq27xxx_access_methods' has no member named 'write'
ret = di->bus.write(di, BQ27XXX_BLOCK_DATA_CONTROL, 0, true);
^
drivers/power/supply/bq27xxx_battery.c:962:15: error: 'struct bq27xxx_access_methods' has no member named 'write'
ret = di->bus.write(di, BQ27XXX_BLOCK_DATA_CLASS, subclass, true);
^
drivers/power/supply/bq27xxx_battery.c:966:15: error: 'struct bq27xxx_access_methods' has no member named 'write'
ret = di->bus.write(di, BQ27XXX_DATA_BLOCK, 0, true);
^
>> drivers/power/supply/bq27xxx_battery.c:970:15: error: 'struct bq27xxx_access_methods' has no member named 'write_bulk'
ret = di->bus.write_bulk(di, BQ27XXX_BLOCK_DATA,
^
drivers/power/supply/bq27xxx_battery.c:977:9: error: 'struct bq27xxx_access_methods' has no member named 'write'
di->bus.write(di, BQ27XXX_BLOCK_DATA_CHECKSUM,
^
drivers/power/supply/bq27xxx_battery.c:982:9: error: 'struct bq27xxx_access_methods' has no member named 'write'
di->bus.write(di, BQ27XXX_REG_CTRL, BQ27XXX_SOFT_RESET, false);
^
In file included from include/linux/linkage.h:4:0,
from include/linux/kernel.h:6,
from include/linux/delay.h:21,
from drivers/power/supply/bq27xxx_battery.c:46:
drivers/power/supply/bq27xxx_battery.c: In function 'bq27xxx_battery_settings':
drivers/power/supply/bq27xxx_battery.c:1299:14: error: 'struct bq27xxx_access_methods' has no member named 'write'
if (!di->bus.write || !di->bus.write_bulk)
^
include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> drivers/power/supply/bq27xxx_battery.c:1299:2: note: in expansion of macro 'if'
if (!di->bus.write || !di->bus.write_bulk)
^~
drivers/power/supply/bq27xxx_battery.c:1299:32: error: 'struct bq27xxx_access_methods' has no member named 'write_bulk'
if (!di->bus.write || !di->bus.write_bulk)
^
include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> drivers/power/supply/bq27xxx_battery.c:1299:2: note: in expansion of macro 'if'
if (!di->bus.write || !di->bus.write_bulk)
^~
drivers/power/supply/bq27xxx_battery.c:1299:14: error: 'struct bq27xxx_access_methods' has no member named 'write'
if (!di->bus.write || !di->bus.write_bulk)
^
include/linux/compiler.h:160:42: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> drivers/power/supply/bq27xxx_battery.c:1299:2: note: in expansion of macro 'if'
if (!di->bus.write || !di->bus.write_bulk)
^~
drivers/power/supply/bq27xxx_battery.c:1299:32: error: 'struct bq27xxx_access_methods' has no member named 'write_bulk'
if (!di->bus.write || !di->bus.write_bulk)
^
include/linux/compiler.h:160:42: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> drivers/power/supply/bq27xxx_battery.c:1299:2: note: in expansion of macro 'if'
if (!di->bus.write || !di->bus.write_bulk)
^~
drivers/power/supply/bq27xxx_battery.c:1299:14: error: 'struct bq27xxx_access_methods' has no member named 'write'
if (!di->bus.write || !di->bus.write_bulk)
^
include/linux/compiler.h:171:16: note: in definition of macro '__trace_if'
______r = !!(cond); \
^~~~
>> drivers/power/supply/bq27xxx_battery.c:1299:2: note: in expansion of macro 'if'
if (!di->bus.write || !di->bus.write_bulk)
^~
drivers/power/supply/bq27xxx_battery.c:1299:32: error: 'struct bq27xxx_access_methods' has no member named 'write_bulk'
if (!di->bus.write || !di->bus.write_bulk)
^
include/linux/compiler.h:171:16: note: in definition of macro '__trace_if'
______r = !!(cond); \
^~~~
>> drivers/power/supply/bq27xxx_battery.c:1299:2: note: in expansion of macro 'if'
if (!di->bus.write || !di->bus.write_bulk)
^~
drivers/power/supply/bq27xxx_battery.c: In function 'bq27xxx_battery_read_dm_block':
>> drivers/power/supply/bq27xxx_battery.c:893:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
drivers/power/supply/bq27xxx_battery.c: In function 'bq27xxx_battery_set_seal_state':
drivers/power/supply/bq27xxx_battery.c:867:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^vim +/BQ27425 +802 drivers/power/supply/bq27xxx_battery.c
796 { BQ27XXX_GAS_GAUGING_STATE_SUBCLASS, 18, "terminate-voltage" },
797 [BQ27XXX_DM_V_AT_CHARGE_TERM] =
798 { BQ27XXX_GAS_GAUGING_STATE_SUBCLASS, 36, "v-at-charge-termination" },
799 };
800
801 static struct bq27xxx_dm_regs *bq27xxx_dm_subclass_regs[] = {
> 802 [BQ27425] = bq27425_dm_subclass_regs,
803 };
804
805 static unsigned int bq27xxx_unseal_keys[] = {
806 [BQ27425] = 0x04143672,
807 };
808
809 static int poll_interval_param_set(const char *val, const struct kernel_param *kp)
810 {
811 struct bq27xxx_device_info *di;
812 unsigned int prev_val = *(unsigned int *) kp->arg;
813 int ret;
814
815 ret = param_set_uint(val, kp);
816 if (ret < 0 || prev_val == *(unsigned int *) kp->arg)
817 return ret;
818
819 mutex_lock(&bq27xxx_list_lock);
820 list_for_each_entry(di, &bq27xxx_battery_devices, list) {
821 cancel_delayed_work_sync(&di->work);
822 schedule_delayed_work(&di->work, 0);
823 }
824 mutex_unlock(&bq27xxx_list_lock);
825
826 return ret;
827 }
828
829 static const struct kernel_param_ops param_ops_poll_interval = {
830 .get = param_get_uint,
831 .set = poll_interval_param_set,
832 };
833
834 static unsigned int poll_interval = 360;
835 module_param_cb(poll_interval, ¶m_ops_poll_interval, &poll_interval, 0644);
836 MODULE_PARM_DESC(poll_interval,
837 "battery poll interval in seconds - 0 disables polling");
838
839 /*
840 * Common code for BQ27xxx devices
841 */
842
843 static inline int bq27xxx_read(struct bq27xxx_device_info *di, int reg_index,
844 bool single)
845 {
846 /* Reports EINVAL for invalid/missing registers */
847 if (!di || di->regs[reg_index] == INVALID_REG_ADDR)
848 return -EINVAL;
849
850 return di->bus.read(di, di->regs[reg_index], single);
851 }
852
853 static int bq27xxx_battery_set_seal_state(struct bq27xxx_device_info *di,
854 bool state)
855 {
856 unsigned int key = bq27xxx_unseal_keys[di->chip];
857 int ret;
858
859 if (state)
> 860 return di->bus.write(di, BQ27XXX_REG_CTRL, 0x20, false);
861
862 ret = di->bus.write(di, BQ27XXX_REG_CTRL, (key >> 16) & 0xffff, false);
863 if (ret < 0)
864 return ret;
865
866 return di->bus.write(di, BQ27XXX_REG_CTRL, key & 0xffff, false);
867 }
868
869 static int bq27xxx_battery_read_dm_block(struct bq27xxx_device_info *di,
870 int subclass)
871 {
872 int ret = di->bus.write(di, BQ27XXX_REG_CTRL, 0, false);
873
874 if (ret < 0)
875 return ret;
876
> 877 ret = di->bus.write(di, BQ27XXX_BLOCK_DATA_CONTROL, 0, true);
878 if (ret < 0)
879 return ret;
880
881 ret = di->bus.write(di, BQ27XXX_BLOCK_DATA_CLASS, subclass, true);
882 if (ret < 0)
883 return ret;
884
885 ret = di->bus.write(di, BQ27XXX_DATA_BLOCK, 0, true);
886 if (ret < 0)
887 return ret;
888
889 usleep_range(1000, 1500);
890
> 891 return di->bus.read_bulk(di, BQ27XXX_BLOCK_DATA,
892 (u8 *) &di->buffer, sizeof(di->buffer));
> 893 }
894
895 static int bq27xxx_battery_print_config(struct bq27xxx_device_info *di)
896 {
897 struct bq27xxx_dm_regs *reg = bq27xxx_dm_subclass_regs[di->chip];
898 int ret, i;
899
900 ret = bq27xxx_battery_read_dm_block(di,
901 BQ27XXX_GAS_GAUGING_STATE_SUBCLASS);
902 if (ret < 0)
903 return ret;
904
905 for (i = 0; i < BQ27XXX_DM_END; i++) {
906 int val;
907
908 if (reg->subclass_id != BQ27XXX_GAS_GAUGING_STATE_SUBCLASS)
909 continue;
910
911 val = be16_to_cpup((u16 *) &di->buffer[reg->offset]);
912
913 dev_info(di->dev, "settings for %s set at %d\n", reg->name, val);
914
915 reg++;
916 }
917
918 return 0;
919 }
920
921 static bool bq27xxx_battery_update_dm_setting(struct bq27xxx_device_info *di,
922 unsigned int reg, unsigned int val)
923 {
924 struct bq27xxx_dm_regs *dm_reg = &bq27xxx_dm_subclass_regs[di->chip][reg];
925 u16 *prev = (u16 *) &di->buffer[dm_reg->offset];
926
927 if (be16_to_cpup(prev) == val)
928 return false;
929
930 *prev = cpu_to_be16(val);
931
932 return true;
933 }
934
935 static u8 bq27xxx_battery_checksum(struct bq27xxx_device_info *di)
936 {
937 u8 *data = (u8 *) &di->buffer;
938 u16 sum = 0;
939 int i;
940
941 for (i = 0; i < sizeof(di->buffer); i++) {
942 sum += data[i];
943 sum &= 0xff;
944 }
945
946 return 0xff - sum;
947 }
948
949 static int bq27xxx_battery_write_nvram(struct bq27xxx_device_info *di,
950 unsigned int subclass)
951 {
952 int ret;
953
954 ret = di->bus.write(di, BQ27XXX_REG_CTRL, BQ27XXX_SET_CFGUPDATE, false);
955 if (ret)
956 return ret;
957
> 958 ret = di->bus.write(di, BQ27XXX_BLOCK_DATA_CONTROL, 0, true);
959 if (ret)
960 return ret;
961
962 ret = di->bus.write(di, BQ27XXX_BLOCK_DATA_CLASS, subclass, true);
963 if (ret)
964 return ret;
965
966 ret = di->bus.write(di, BQ27XXX_DATA_BLOCK, 0, true);
967 if (ret)
968 return ret;
969
> 970 ret = di->bus.write_bulk(di, BQ27XXX_BLOCK_DATA, 971 (u8 *) &di->buffer, sizeof(di->buffer));
972 if (ret < 0)
973 return ret;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v5 5/8] power: bq27xxx_battery: Add power_supply_battery_info support
In reply to Liam BreckQuoted 10 lines · Liam Breck
From: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Previously there was no way to set chip registers in the event that the defaults didn't match the battery in question.
BQ27xxx driver now calls
power_supply_get_battery_info, checks the inputs, and writes battery data to NVRAM.
I haven't had much time to review this, but have you seen our old internal version of this driver?:
http://git.ti.com/bms-linux/bms-kernel/blobs/master/drivers/power/bq27x00_battery.c
I would like that most of the NVRAM checks and sets are kept in userspace:
http://git.ti.com/bms-linux/bqtool/trees/master
In kernel don't really have a good way to know when the battery has been swapped and the DT info might not be valid for this new battery. I guess there is really no good way, but I imagine this is why we never upstreamed the rest of this driver before.
Andrew
Quoted 376 lines
Signed-off-by Matt Ranostay <[email protected]>Signed-off-by Liam Breck <[email protected]>--- drivers/power/supply/bq27xxx_battery.c | 303 ++++++++++++++++++++++++++++++++- include/linux/power/bq27xxx_battery.h | 1 + 2 files changed, 303 insertions(+), 1 deletion(-)drivers/power/supply/bq27xxx_battery.c +302
-1@@ -37,6 +37,7 @@* http://www.ti.com/product/bq27621-g1 */ +#include <linux/delay.h> #include <linux/device.h> #include <linux/module.h> #include <linux/mutex.h> @@ -432,6 +433,54 @@ static struct {static DEFINE_MUTEX (bq27xxx_list_lock);static LIST_HEAD (bq27xxx_battery_devices); +#define BQ27XXX_MIN_V_MIN 2800 +#define BQ27XXX_MIN_V_MAX 3700 +#define BQ27XXX_MAX_V_MIN 0 +#define BQ27XXX_MAX_V_MAX 5000 + +#define BQ27XXX_BLOCK_DATA_CLASS 0x3E +#define BQ27XXX_DATA_BLOCK 0x3F +#define BQ27XXX_BLOCK_DATA 0x40 +#define BQ27XXX_BLOCK_DATA_CHECKSUM 0x60 +#define BQ27XXX_BLOCK_DATA_CONTROL 0x61 +#define BQ27XXX_SET_CFGUPDATE 0x13 +#define BQ27XXX_SOFT_RESET 0x42 + +enum bq27xxx_dm_subclass_index { +BQ27XXX_DM_DESIGN_CAPACITY =0 , +BQ27XXX_DM_DESIGN_ENERGY , +BQ27XXX_DM_TERMINATE_VOLTAGE , +BQ27XXX_DM_V_AT_CHARGE_TERM , +BQ27XXX_DM_END , +}; + +struct bq27xxx_dm_regs { +unsigned int subclass_id; +unsigned int offset; +char *name; +}; + +#define BQ27XXX_GAS_GAUGING_STATE_SUBCLASS 82 + +static struct bq27xxx_dm_regs bq27425_dm_subclass_regs[] = { + [BQ27XXX_DM_DESIGN_CAPACITY ] = + {BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ,12 ,"design-capacity" }, + [BQ27XXX_DM_DESIGN_ENERGY ] = + {BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ,14 ,"design-energy" }, + [BQ27XXX_DM_TERMINATE_VOLTAGE ] = + {BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ,18 ,"terminate-voltage" }, + [BQ27XXX_DM_V_AT_CHARGE_TERM ] = + {BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ,36 ,"v-at-charge-termination" }, +}; + +static struct bq27xxx_dm_regs *bq27xxx_dm_subclass_regs[] = { + [BQ27425 ] = bq27425_dm_subclass_regs, +}; + +static unsigned int bq27xxx_unseal_keys[] = { + [BQ27425 ] =0x04143672 , +}; +static int poll_interval_param_set (const char *val,const struct kernel_param *kp) {struct bq27xxx_device_info *di;@@ -476,6 +525,179 @@ static inline int bq27xxx_read(struct bq27xxx_device_info *di, int reg_index,return di->bus.read (di, di->regs[reg_index], single); } +static int bq27xxx_battery_set_seal_state (struct bq27xxx_device_info *di, +bool state) +{ +unsigned int key = bq27xxx_unseal_keys[di->chip]; +int ret; + +if (state) +return di->bus.write (di,BQ27XXX_REG_CTRL ,0x20 , false); + + ret = di->bus.write (di,BQ27XXX_REG_CTRL , (key >>16 ) &0xffff , false); +if (ret <0 ) +return ret; + +return di->bus.write (di,BQ27XXX_REG_CTRL , key &0xffff , false); +} + +static int bq27xxx_battery_read_dm_block (struct bq27xxx_device_info *di, +int subclass) +{ +int ret = di->bus.write (di,BQ27XXX_REG_CTRL ,0 , false); + +if (ret <0 ) +return ret; + + ret = di->bus.write (di,BQ27XXX_BLOCK_DATA_CONTROL ,0 , true); +if (ret <0 ) +return ret; + + ret = di->bus.write (di,BQ27XXX_BLOCK_DATA_CLASS , subclass, true); +if (ret <0 ) +return ret; + + ret = di->bus.write (di,BQ27XXX_DATA_BLOCK ,0 , true); +if (ret <0 ) +return ret; + +usleep_range (1000 ,1500 ); + +return di->bus.read_bulk (di,BQ27XXX_BLOCK_DATA , + (u8 *) &di->buffer,sizeof (di->buffer)); +} + +static int bq27xxx_battery_print_config (struct bq27xxx_device_info *di) +{ +struct bq27xxx_dm_regs *reg = bq27xxx_dm_subclass_regs[di->chip]; +int ret, i; + + ret =bq27xxx_battery_read_dm_block (di, +BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ); +if (ret <0 ) +return ret; + +for (i =0 ; i <BQ27XXX_DM_END ; i++) { +int val; + +if (reg->subclass_id !=BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ) +continue ; + + val =be16_to_cpup ((u16 *) &di->buffer[reg->offset]); + +dev_info (di->dev,"settings for %s set at %d\n" , reg->name, val); + + reg++; + } + +return 0 ; +} + +static bool bq27xxx_battery_update_dm_setting (struct bq27xxx_device_info *di, +unsigned int reg,unsigned int val) +{ +struct bq27xxx_dm_regs *dm_reg = &bq27xxx_dm_subclass_regs[di->chip][reg]; +u16 *prev = (u16 *) &di->buffer[dm_reg->offset]; + +if (be16_to_cpup (prev) == val) +return false; + + *prev =cpu_to_be16 (val); + +return true; +} + +static u8 bq27xxx_battery_checksum (struct bq27xxx_device_info *di) +{ +u8 *data = (u8 *) &di->buffer; +u16 sum =0 ; +int i; + +for (i =0 ; i <sizeof (di->buffer); i++) { + sum += data[i]; + sum &=0xff ; + } + +return 0xff - sum; +} + +static int bq27xxx_battery_write_nvram (struct bq27xxx_device_info *di, +unsigned int subclass) +{ +int ret; + + ret = di->bus.write (di,BQ27XXX_REG_CTRL ,BQ27XXX_SET_CFGUPDATE , false); +if (ret) +return ret; + + ret = di->bus.write (di,BQ27XXX_BLOCK_DATA_CONTROL ,0 , true); +if (ret) +return ret; + + ret = di->bus.write (di,BQ27XXX_BLOCK_DATA_CLASS , subclass, true); +if (ret) +return ret; + + ret = di->bus.write (di,BQ27XXX_DATA_BLOCK ,0 , true); +if (ret) +return ret; + + ret = di->bus.write_bulk (di,BQ27XXX_BLOCK_DATA , + (u8 *) &di->buffer,sizeof (di->buffer)); +if (ret <0 ) +return ret; + +usleep_range (1000 ,1500 ); + + di->bus.write (di,BQ27XXX_BLOCK_DATA_CHECKSUM , +bq27xxx_battery_checksum (di), true); + +usleep_range (1000 ,1500 ); + + di->bus.write (di,BQ27XXX_REG_CTRL ,BQ27XXX_SOFT_RESET , false); + +return 0 ; +} + +static int bq27xxx_battery_set_config (struct bq27xxx_device_info *di, +struct power_supply_battery_info *info) +{ +int ret; + + ret =bq27xxx_battery_read_dm_block (di, +BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ); +if (ret <0 ) +return ret; + +if (info->charge_full_design_uah != -EINVAL + && info->energy_full_design_uwh != -EINVAL ) { + ret |=bq27xxx_battery_update_dm_setting (di, +BQ27XXX_DM_DESIGN_CAPACITY , + info->charge_full_design_uah /1000 ); + ret |=bq27xxx_battery_update_dm_setting (di, +BQ27XXX_DM_DESIGN_ENERGY , + info->energy_full_design_uwh /1000 ); + } + +if (info->voltage_min_design_uv != -EINVAL ) + ret |=bq27xxx_battery_update_dm_setting (di, +BQ27XXX_DM_TERMINATE_VOLTAGE , + info->voltage_min_design_uv /1000 ); + +if (info->voltage_max_design_uv != -EINVAL ) + ret |=bq27xxx_battery_update_dm_setting (di, +BQ27XXX_DM_V_AT_CHARGE_TERM , + info->voltage_max_design_uv /1000 ); + +if (ret) { +dev_info (di->dev,"updating NVM settings\n" ); +return bq27xxx_battery_write_nvram (di, +BQ27XXX_GAS_GAUGING_STATE_SUBCLASS ); + } + +return 0 ; +} +/* * Return the battery State-of-Charge * Or < 0 if something fails. @@ -736,6 +958,73 @@ static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)return POWER_SUPPLY_HEALTH_GOOD ; } +void bq27xxx_battery_settings (struct bq27xxx_device_info *di) +{ +struct power_supply_battery_info info = {}; + +/* functions don't exist for writing data so abort */ +if (!di->bus.write || !di->bus.write_bulk) +return ; + +/* no settings to be set for this chipset so abort */ +if (!bq27xxx_dm_subclass_regs[di->chip]) +return ; + +bq27xxx_battery_set_seal_state (di, false); + +if (power_supply_get_battery_info (di->bat, &info) <0 ) + goto out; + +if (info.energy_full_design_uwh != info.charge_full_design_uah) { +if (info.energy_full_design_uwh == -EINVAL ) +dev_warn (di->dev, +"missing battery:energy-full-design-microwatt-hours\n" ); +else if (info.charge_full_design_uah == -EINVAL ) +dev_warn (di->dev, +"missing battery:charge-full-design-microamp-hours\n" ); + } + +if (info.energy_full_design_uwh >0x7fff *1000 ) { +dev_err (di->dev,"invalid battery:energy-full-design-microwatt-hours %d\n" , + info.energy_full_design_uwh); + info.energy_full_design_uwh = -EINVAL ; + } + +if (info.charge_full_design_uah >0x7fff *1000 ) { +dev_err (di->dev,"invalid battery:charge-full-design-microamp-hours %d\n" , + info.charge_full_design_uah); + info.charge_full_design_uah = -EINVAL ; + } + +if ((info.voltage_min_design_uv <BQ27XXX_MIN_V_MIN *1000 + || info.voltage_min_design_uv >BQ27XXX_MIN_V_MAX *1000 ) + && info.voltage_min_design_uv != -EINVAL ) { +dev_err (di->dev,"invalid battery:voltage-min-design-microvolt %d\n" , + info.voltage_min_design_uv); + info.voltage_min_design_uv = -EINVAL ; + } + +if ((info.voltage_max_design_uv <BQ27XXX_MAX_V_MIN *1000 + || info.voltage_max_design_uv >BQ27XXX_MAX_V_MAX *1000 ) + && info.voltage_max_design_uv != -EINVAL ) { +dev_err (di->dev,"invalid battery:voltage-max-design-microvolt %d\n" , + info.voltage_max_design_uv); + info.voltage_max_design_uv = -EINVAL ; + } + +if ((info.energy_full_design_uwh == -EINVAL + || info.charge_full_design_uah == -EINVAL ) + && info.voltage_min_design_uv == -EINVAL + && info.voltage_max_design_uv == -EINVAL ) + goto out; + +bq27xxx_battery_set_config (di, &info); + +out: +bq27xxx_battery_print_config (di); +bq27xxx_battery_set_seal_state (di, true); +} +void bq27xxx_battery_update (struct bq27xxx_device_info *di) {struct bq27xxx_reg_cache cache = {0 , };@@ -985,6 +1274,14 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN : ret =bq27xxx_simple_value (di->charge_design_full, val);break ; +/* +* TODO: Implement these to make registers set from +* power_supply_battery_info visible in sysfs. +*/ +case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN : +case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN : +case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN : +return -EINVAL ;case POWER_SUPPLY_PROP_CYCLE_COUNT : ret =bq27xxx_simple_value (di->cache.cycle_count, val);break ;@@ -1018,7 +1315,10 @@ static void bq27xxx_external_power_changed(struct power_supply *psy)int bq27xxx_battery_setup (struct bq27xxx_device_info *di) {struct power_supply_desc *psy_desc; -struct power_supply_config psy_cfg = { .drv_data = di, }; +struct power_supply_config psy_cfg = { + .of_node = di->dev->of_node, + .drv_data = di, + };INIT_DELAYED_WORK (&di->work, bq27xxx_battery_poll);mutex_init (&di->lock);@@ -1043,6 +1343,7 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)dev_info (di->dev,"support ver. %s enabled\n" ,DRIVER_VERSION ); +bq27xxx_battery_settings (di);bq27xxx_battery_update (di);mutex_lock (&bq27xxx_list_lock);include/linux/power/bq27xxx_battery.h +1
-0@@ -62,6 +62,7 @@ struct bq27xxx_device_info {struct list_head list;struct mutex lock;u8 *regs; +u8 buffer[32 ]; };void bq27xxx_battery_update (struct bq27xxx_device_info *di);
Re: [PATCH v5 5/8] power: bq27xxx_battery: Add power_supply_battery_info support
Quoted 17 lines · Andrew F. Davis
Quoted 10 lines · Liam Breck
From: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
Previously there was no way to set chip registers in the event that the defaults didn't match the battery in question.
BQ27xxx driver now calls
power_supply_get_battery_info, checks the inputs, and writes battery data to NVRAM.I haven't had much time to review this, but have you seen our old internal version of this driver?:
http://git.ti.com/bms-linux/bms-kernel/blobs/master/drivers/power/bq27x00_battery.c
Quoted 8 lines
I would like that most of the NVRAM checks and sets are kept in userspace:
http://git.ti.com/bms-linux/bqtool/trees/master
In kernel don't really have a good way to know when the battery has been swapped and the DT info might not be valid for this new battery. I guess there is really no good way, but I imagine this is why we never upstreamed the rest of this driver before.
But for a huge variety of devices, changing the type of battery is not an option.
DT battery characteristics are entirely optional in this patchset; no 'monitored-battery' means no NVRAM update.
This patchset also allows field-upgrade of the NVRAM in a linux-generic way, by releasing a kernel or dtb package update.
Also I suspect fuel-gauge and charger drivers will be encouraged to support monitored-battery since it's a core feature :-)
PATCH v5 6/8 power: bq27xxx_battery_i2c: Add I2C bulk read/write functions
In reply to Liam BreckFrom: Matt Ranostay <[email protected]>
From: Matt Ranostay <[email protected]>
write(), read_bulk(), write_bulk() are required by bq27xxx_battery devicetree code.
--- drivers/power/supply/bq27xxx_battery_i2c.c | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/power/supply/bq27xxx_battery_i2c.c +62 -0
@@ -68,6 +68,64 @@ static int bq27xxx_battery_i2c_read(struct bq27xxx_device_info *di, u8 reg,return ret; } +static int bq27xxx_battery_i2c_write (struct bq27xxx_device_info *di,u8 reg, +int value,bool single) +{ +struct i2c_client *client =to_i2c_client (di->dev); +struct i2c_msg msg; +unsigned char data[4 ]; + +if (!client->adapter) +return -ENODEV ; + + data[0 ] = reg; +if (single) { + data[1 ] = (unsigned char ) value; + msg.len =2 ; + }else { +put_unaligned_le16 (value, &data[1 ]); + msg.len =3 ; + } + + msg.buf = data; + msg.addr = client->addr; + msg.flags =0 ; + +return i2c_transfer (client->adapter, &msg,1 ) ==1 ?0 : -EINVAL ; +} + +static int bq27xxx_battery_i2c_bulk_read (struct bq27xxx_device_info *di,u8 reg, +u8 *data,int len) +{ +struct i2c_client *client =to_i2c_client (di->dev); + +if (!client->adapter) +return -ENODEV ; + +return i2c_smbus_read_i2c_block_data (client, reg, len, data); +} + +static int bq27xxx_battery_i2c_bulk_write (struct bq27xxx_device_info *di, +u8 reg,u8 *data,int len) +{ +struct i2c_client *client =to_i2c_client (di->dev); +struct i2c_msg msg; +u8 buf[33 ]; + +if (!client->adapter) +return -ENODEV ; + + buf[0 ] = reg; +memcpy (&buf[1 ], data, len); + + msg.buf = buf; + msg.addr = client->addr; + msg.flags =0 ; + msg.len = len +1 ; + +return i2c_transfer (client->adapter, &msg,1 ) ==1 ?0 : -EINVAL ; +} +static int bq27xxx_battery_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id) {
@@ -95,7 +153,11 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client, di->dev = &client->dev; di->chip = id->driver_data; di->name = name; + di->bus.read = bq27xxx_battery_i2c_read; + di->bus.write = bq27xxx_battery_i2c_write; + di->bus.read_bulk = bq27xxx_battery_i2c_bulk_read; + di->bus.write_bulk = bq27xxx_battery_i2c_bulk_write; ret =bq27xxx_battery_setup (di);if (ret)
Signature · 1 line
2.9.3
PATCH v5 7/8 power: bq27xxx_battery: Define access methods to write chip registers
In reply to Liam BreckFrom: Liam <[email protected]>
From: Matt Ranostay <[email protected]>
write(), read_bulk(), write_bulk() support setting chip registers, e.g. with data obtained from power_supply_battery_info.
--- include/linux/power/bq27xxx_battery.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/power/bq27xxx_battery.h +3 -0
@@ -32,6 +32,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
Re: [PATCH v5 7/8] power: bq27xxx_battery: Define access methods to write chip registers
Quoted 9 lines · Liam Breck
From: Liam <[email protected]>
From: Matt Ranostay <[email protected]>
write(),read_bulk(),write_bulk()support setting chip registers, e.g. with data obtained frompower_supply_battery_info.Signed-off-by Matt Ranostay <[email protected]>Signed-off-by Liam Breck <[email protected]>
Pls drop the first From line; Matt's is the correct one. git-send-email doesn't check for an extant From line :-/
Re: [PATCH v5 7/8] power: bq27xxx_battery: Define access methods to write chip registers
In reply to Liam BreckQuoted 18 lines · Liam Breck
From: Liam <[email protected]>
From: Matt Ranostay <[email protected]>
write(),read_bulk(),write_bulk()support setting chip registers, e.g. with data obtained frompower_supply_battery_info.Signed-off-by Matt Ranostay <[email protected]>Signed-off-by Liam Breck <[email protected]>--- include/linux/power/bq27xxx_battery.h | 3 +++ 1 file changed, 3 insertions(+)include/linux/power/bq27xxx_battery.h +0
-0
include/linux/power/bq27xxx_battery.h struct bq27xxx_platform_data { · line 37
Quoted 6 lines
include/linux/power/bq27xxx_battery.h +3
-0@@ -32,6 +32,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);
These should have been defined way earlier in the series, this will break bisectability.
Andrew
Quoted 4 lines
include/linux/power/bq27xxx_battery.h +0
-0};struct bq27xxx_reg_cache {
PATCH v5 8/8 power: bq27xxx_battery: Add BQ27425 chip id
In reply to Liam BreckFrom: networkimprov <[email protected]>
From: Matt Ranostay <[email protected]>
This patch does not alter the function of the driver. This chip ID is referenced in the devicetree code.
--- drivers/power/supply/bq27xxx_battery.c | 23 ++++++++++++++++++++++- drivers/power/supply/bq27xxx_battery_i2c.c | 2 +- include/linux/power/bq27xxx_battery.h | 3 ++- 3 files changed, 25 insertions(+), 3 deletions(-)
drivers/power/supply/bq27xxx_battery.c +22 -1
@@ -260,6 +260,25 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = { [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP] = 0x18, }, + [BQ27425] = { + [BQ27XXX_REG_CTRL] = 0x00, + [BQ27XXX_REG_TEMP] = 0x02, + [BQ27XXX_REG_INT_TEMP] = 0x1e, + [BQ27XXX_REG_VOLT] = 0x04, + [BQ27XXX_REG_AI] = 0x10, + [BQ27XXX_REG_FLAGS] = 0x06, + [BQ27XXX_REG_TTE] = INVALID_REG_ADDR, + [BQ27XXX_REG_TTF] = INVALID_REG_ADDR, + [BQ27XXX_REG_TTES] = INVALID_REG_ADDR, + [BQ27XXX_REG_TTECP] = INVALID_REG_ADDR, + [BQ27XXX_REG_NAC] = 0x08, + [BQ27XXX_REG_FCC] = 0x0e, + [BQ27XXX_REG_CYCT] = INVALID_REG_ADDR, + [BQ27XXX_REG_AE] = INVALID_REG_ADDR, + [BQ27XXX_REG_SOC] = 0x1c, + [BQ27XXX_REG_DCAP] = 0x3c, + [BQ27XXX_REG_AP] = 0x18, + }, };static enum power_supply_property bq27000_battery_props[] = {
@@ -428,6 +447,7 @@ static struct {BQ27XXX_PROP (BQ27541 , bq27541_battery_props),BQ27XXX_PROP (BQ27545 , bq27545_battery_props),BQ27XXX_PROP (BQ27421 , bq27421_battery_props), + BQ27XXX_PROP(BQ27425, bq27421_battery_props), };static DEFINE_MUTEX (bq27xxx_list_lock);
@@ -904,6 +924,7 @@ static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)return flags & (BQ27XXX_FLAG_OTC |BQ27XXX_FLAG_OTD );case BQ27530 :case BQ27421 : +case BQ27425 :return flags &BQ27XXX_FLAG_OT ;default :return false;
@@ -915,7 +936,7 @@ static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)*/ static bool bq27xxx_battery_undertemp (struct bq27xxx_device_info *di,u16 flags) { -if (di->chip ==BQ27530 || di->chip ==BQ27421 ) +if (di->chip ==BQ27530 || di->chip ==BQ27421 || di->chip ==BQ27425 )return flags &BQ27XXX_FLAG_UT ;return false;
drivers/power/supply/bq27xxx_battery_i2c.c +1 -1
@@ -221,7 +221,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = { { "bq27742", BQ27541 }, { "bq27545", BQ27545 }, { "bq27421", BQ27421 }, - { "bq27425", BQ27421 }, + { "bq27425", BQ27425 }, { "bq27441", BQ27421 }, { "bq27621", BQ27421 }, {},
include/linux/power/bq27xxx_battery.h +2 -1
@@ -9,7 +9,8 @@ enum bq27xxx_chip {BQ27530 ,/* bq27530, bq27531 */ BQ27541 ,/* bq27541, bq27542, bq27546, bq27742 */ BQ27545 ,/* bq27545 */ - BQ27421, /* bq27421, bq27425, bq27441, bq27621 */ +BQ27421 ,/* bq27421, bq27441, bq27621 */ + BQ27425, /* bq27425 */ };/**
Signature · 1 line
2.9.3
Re: [PATCH v5 8/8] power: bq27xxx_battery: Add BQ27425 chip id
Quoted 9 lines · Liam Breck
From: networkimprov <[email protected]>
From: Matt Ranostay <[email protected]>
This patch does not alter the function of the driver. This chip ID is referenced in the devicetree code.
Signed-off-by Matt Ranostay <[email protected]>Signed-off-by Liam Breck <[email protected]>
Pls drop the first From line; Matt's is the correct one. git-send-email doesn't check for an extant From line :-/