[PATCH v2 1/2] power: supply: bq25980 Apply datasheet revision changes
The latest datasheet revision for BQ25980, BQ25975, and BQ25960 changed various register step sizes and offset values. This patch changes the following header file values for POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT, and POWER_SUPPLY_PROP_VOLTAGE_NOW. Additionally, this patch adjusts bq25980_get_input_curr_lim(), bq25980_set_input_curr_lim(), bq25980_get_const_charge_curr(), and bq25980_set_const_charge_curr() to perform the get/set math correctly. Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family") Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/bq25980_charger.c | 141 - drivers/power/supply/bq25980_charger.h | 77 ++ 2 files changed, 173 insertions(+), 45 deletions(-) diff --git a/drivers/power/supply/bq25980_charger.c b/drivers/power/supply/bq25980_charger.c index 530ff4025b31..7c489a9e8877 100644 --- a/drivers/power/supply/bq25980_charger.c +++ b/drivers/power/supply/bq25980_charger.c @@ -52,6 +52,10 @@ struct bq25980_chip_info { int busocp_byp_max; int busocp_sc_min; int busocp_byp_min; + int busocp_sc_step; + int busocp_byp_step; + int busocp_sc_offset; + int busocp_byp_offset; int busovp_sc_def; int busovp_byp_def; @@ -73,6 +77,20 @@ struct bq25980_chip_info { int batocp_def; int batocp_max; + int batocp_min; + int batocp_step; + + int vbus_adc_step; + int vbus_adc_offset; + + int ibus_adc_step; + int ibus_adc_offset; + + int vbat_adc_step; + int vbat_adc_offset; + + int ibat_adc_step; + int ibat_adc_offset; }; struct bq25980_init_data { @@ -275,13 +293,22 @@ static int bq25980_watchdog_time[BQ25980_NUM_WD_VAL] = {5000, 1, 5, static int bq25980_get_input_curr_lim(struct bq25980_device *bq) { unsigned int busocp_reg_code; + int offset, step; int ret; + if (bq->state.bypass) { + step = bq->chip_info->busocp_byp_step; + offset = bq->chip_info->busocp_byp_offset; + } else { + step = bq->chip_info->busocp_sc_step; + offset = bq->chip_info->busocp_sc_offset; + } + ret = regmap_read(bq->regmap, BQ25980_BUSOCP, _reg_code); if (ret) return ret; - return (busocp_reg_code * BQ25980_BUSOCP_STEP_uA) + BQ25980_BUSOCP_OFFSET_uA; + return (busocp_reg_code * step) + offset; } static int bq25980_set_hiz(struct bq25980_device *bq, int setting) @@ -293,6 +320,7 @@ static int bq25980_set_hiz(struct bq25980_device *bq, int setting) static int bq25980_set_input_curr_lim(struct bq25980_device *bq, int busocp) { unsigned int busocp_reg_code; + int step, offset; int ret; if (!busocp) @@ -303,13 +331,17 @@ static int bq25980_set_input_curr_lim(struct bq25980_device *bq, int busocp) if (busocp < BQ25980_BUSOCP_MIN_uA) busocp = BQ25980_BUSOCP_MIN_uA; - if (bq->state.bypass) + if (bq->state.bypass) { busocp = min(busocp, bq->chip_info->busocp_sc_max); - else + step = bq->chip_info->busocp_byp_step; + offset = bq->chip_info->busocp_byp_offset; + } else { busocp = min(busocp, bq->chip_info->busocp_byp_max); + step = bq->chip_info->busocp_sc_step; + offset = bq->chip_info->busocp_sc_offset; + } - busocp_reg_code = (busocp - BQ25980_BUSOCP_OFFSET_uA) - / BQ25980_BUSOCP_STEP_uA; + busocp_reg_code = (busocp - offset) / step; ret = regmap_write(bq->regmap, BQ25980_BUSOCP, busocp_reg_code); if (ret) @@ -374,6 +406,7 @@ static int bq25980_set_input_volt_lim(struct bq25980_device *bq, int busovp) static int bq25980_get_const_charge_curr(struct bq25980_device *bq) { + int step = bq->chip_info->batocp_step; unsigned int batocp_reg_code; int ret; @@ -381,19 +414,20 @@ static int bq25980_get_const_charge_curr(struct bq25980_device *bq) if (ret) return ret; - return (batocp_reg_code & BQ25980_BATOCP_MASK) * - BQ25980_BATOCP_STEP_uA; + return (batocp_reg_code & BQ25980_BATOCP_MASK) * step; } static int bq25980_set_const_charge_curr(struct bq25980_device *bq, int batocp) { + int step = bq->chip_info->batocp_step; + int max = bq->chip_info->batocp_max; + int min = bq->chip_info->batocp_min; unsigned int batocp_reg_code; int ret; - batocp = max(batocp,
[PATCH v2 2/2] power: supply: bq25980: Move props from battery node
Currently POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT and POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE are exposed on the battery node and this is incorrect. This patch exposes POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT and POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE on the charger node rather than the battery node. Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family") Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/bq25980_charger.c | 40 -- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/drivers/power/supply/bq25980_charger.c b/drivers/power/supply/bq25980_charger.c index 7c489a9e8877..ac73e2c19238 100644 --- a/drivers/power/supply/bq25980_charger.c +++ b/drivers/power/supply/bq25980_charger.c @@ -641,33 +641,6 @@ static int bq25980_get_state(struct bq25980_device *bq, return 0; } -static int bq25980_set_battery_property(struct power_supply *psy, - enum power_supply_property psp, - const union power_supply_propval *val) -{ - struct bq25980_device *bq = power_supply_get_drvdata(psy); - int ret = 0; - - switch (psp) { - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: - ret = bq25980_set_const_charge_curr(bq, val->intval); - if (ret) - return ret; - break; - - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: - ret = bq25980_set_const_charge_volt(bq, val->intval); - if (ret) - return ret; - break; - - default: - return -EINVAL; - } - - return ret; -} - static int bq25980_get_battery_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -736,6 +709,18 @@ static int bq25980_set_charger_property(struct power_supply *psy, return ret; break; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + ret = bq25980_set_const_charge_curr(bq, val->intval); + if (ret) + return ret; + break; + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + ret = bq25980_set_const_charge_volt(bq, val->intval); + if (ret) + return ret; + break; + default: return -EINVAL; } @@ -957,7 +942,6 @@ static struct power_supply_desc bq25980_battery_desc = { .name = "bq25980-battery", .type = POWER_SUPPLY_TYPE_BATTERY, .get_property = bq25980_get_battery_property, - .set_property = bq25980_set_battery_property, .properties = bq25980_battery_props, .num_properties = ARRAY_SIZE(bq25980_battery_props), .property_is_writeable = bq25980_property_is_writeable, -- 2.30.0
Re: [EXTERNAL] Re: [PATCH 2/2] power: supply: bq25980: Moves properties from battery node
On 2/10/21 2:23 AM, Krzysztof Kozlowski wrote: On Wed, 10 Feb 2021 at 00:52, Ricardo Rivera-Matos wrote: fix: exposes POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT on the charger node Why is this a fix? Why is exposing this property wrong? What is the problem here? Why do you start sentences with a small letter? Your commit message should answer such questions. ACK, I will rebase and reword this commit message Best regards, Krzysztof Best Regards, Ricardo
Re: [EXTERNAL] Re: [PATCH 1/2] power: supply: bq25980: Applies multiple fixes brought on
Krzysztof, On 2/10/21 2:20 AM, Krzysztof Kozlowski wrote: On Wed, 10 Feb 2021 at 00:52, Ricardo Rivera-Matos wrote: fix: corrects various register step size and offset values fix: corrects bq25980_get_input_curr_lim() and bq25980_set_input_curr_lim() fix: corrects bq25980_get_const_charge_curr() and bq25980_set_const_charge_curr() fix: corrects BQ25960_BATOVP_MIN_uV, BQ25960_BATOVP_OFFSET_uV, BQ25960_BATOVP_STEP_uV, and BQ25960_BATOVP_MAX_uV fix: corrects busocp_sc_min and busocp_byp_min members fix: removes unnecessary polarity check from bq25980_get_adc_ibus() fix: removes unnecessary polarity check from bq25980_get_adc_ibat() fix: clamps ibat_adc to match datasheet change Thanks for the patch. Only one fix at a time and please exactly describe what is being fixed using proper sentences (starting with capital letter, ending with a full stop... and usually description needs multiple of such sentences). You add here multiple changes without proper description of a problem being fixed. This is not the correct style of a patch. ACK, this patch is meant to implement changes brought on by a new datasheet revision. The revision tweaked the register step size and offset values to improve the accuracy. I can rebase and reword the patch if that works for you. Best regards, Krzysztof Best Regards, Ricardo
[PATCH 1/2] power: supply: bq25980: Applies multiple fixes brought on
fix: corrects various register step size and offset values fix: corrects bq25980_get_input_curr_lim() and bq25980_set_input_curr_lim() fix: corrects bq25980_get_const_charge_curr() and bq25980_set_const_charge_curr() fix: corrects BQ25960_BATOVP_MIN_uV, BQ25960_BATOVP_OFFSET_uV, BQ25960_BATOVP_STEP_uV, and BQ25960_BATOVP_MAX_uV fix: corrects busocp_sc_min and busocp_byp_min members fix: removes unnecessary polarity check from bq25980_get_adc_ibus() fix: removes unnecessary polarity check from bq25980_get_adc_ibat() fix: clamps ibat_adc to match datasheet change Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family") Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/bq25980_charger.c | 141 - drivers/power/supply/bq25980_charger.h | 77 ++ 2 files changed, 173 insertions(+), 45 deletions(-) diff --git a/drivers/power/supply/bq25980_charger.c b/drivers/power/supply/bq25980_charger.c index 530ff4025b31..7c489a9e8877 100644 --- a/drivers/power/supply/bq25980_charger.c +++ b/drivers/power/supply/bq25980_charger.c @@ -52,6 +52,10 @@ struct bq25980_chip_info { int busocp_byp_max; int busocp_sc_min; int busocp_byp_min; + int busocp_sc_step; + int busocp_byp_step; + int busocp_sc_offset; + int busocp_byp_offset; int busovp_sc_def; int busovp_byp_def; @@ -73,6 +77,20 @@ struct bq25980_chip_info { int batocp_def; int batocp_max; + int batocp_min; + int batocp_step; + + int vbus_adc_step; + int vbus_adc_offset; + + int ibus_adc_step; + int ibus_adc_offset; + + int vbat_adc_step; + int vbat_adc_offset; + + int ibat_adc_step; + int ibat_adc_offset; }; struct bq25980_init_data { @@ -275,13 +293,22 @@ static int bq25980_watchdog_time[BQ25980_NUM_WD_VAL] = {5000, 1, 5, static int bq25980_get_input_curr_lim(struct bq25980_device *bq) { unsigned int busocp_reg_code; + int offset, step; int ret; + if (bq->state.bypass) { + step = bq->chip_info->busocp_byp_step; + offset = bq->chip_info->busocp_byp_offset; + } else { + step = bq->chip_info->busocp_sc_step; + offset = bq->chip_info->busocp_sc_offset; + } + ret = regmap_read(bq->regmap, BQ25980_BUSOCP, _reg_code); if (ret) return ret; - return (busocp_reg_code * BQ25980_BUSOCP_STEP_uA) + BQ25980_BUSOCP_OFFSET_uA; + return (busocp_reg_code * step) + offset; } static int bq25980_set_hiz(struct bq25980_device *bq, int setting) @@ -293,6 +320,7 @@ static int bq25980_set_hiz(struct bq25980_device *bq, int setting) static int bq25980_set_input_curr_lim(struct bq25980_device *bq, int busocp) { unsigned int busocp_reg_code; + int step, offset; int ret; if (!busocp) @@ -303,13 +331,17 @@ static int bq25980_set_input_curr_lim(struct bq25980_device *bq, int busocp) if (busocp < BQ25980_BUSOCP_MIN_uA) busocp = BQ25980_BUSOCP_MIN_uA; - if (bq->state.bypass) + if (bq->state.bypass) { busocp = min(busocp, bq->chip_info->busocp_sc_max); - else + step = bq->chip_info->busocp_byp_step; + offset = bq->chip_info->busocp_byp_offset; + } else { busocp = min(busocp, bq->chip_info->busocp_byp_max); + step = bq->chip_info->busocp_sc_step; + offset = bq->chip_info->busocp_sc_offset; + } - busocp_reg_code = (busocp - BQ25980_BUSOCP_OFFSET_uA) - / BQ25980_BUSOCP_STEP_uA; + busocp_reg_code = (busocp - offset) / step; ret = regmap_write(bq->regmap, BQ25980_BUSOCP, busocp_reg_code); if (ret) @@ -374,6 +406,7 @@ static int bq25980_set_input_volt_lim(struct bq25980_device *bq, int busovp) static int bq25980_get_const_charge_curr(struct bq25980_device *bq) { + int step = bq->chip_info->batocp_step; unsigned int batocp_reg_code; int ret; @@ -381,19 +414,20 @@ static int bq25980_get_const_charge_curr(struct bq25980_device *bq) if (ret) return ret; - return (batocp_reg_code & BQ25980_BATOCP_MASK) * - BQ25980_BATOCP_STEP_uA; + return (batocp_reg_code & BQ25980_BATOCP_MASK) * step; } static int bq25980_set_const_charge_curr(struct bq25980_device *bq, int batocp) { + int step = bq->chip_info->batocp_step; + int max = bq->chip_info->batocp_max; + int min = bq->chip_info->batocp_min; unsigned int batocp_reg_code; int ret; - batocp = max(batocp, BQ25980_BATOCP_MIN_uA); - batoc
[PATCH 2/2] power: supply: bq25980: Moves properties from battery node
fix: exposes POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT on the charger node fix: exposes POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE on the charger node fix: eliminates unnecessary set_property for the battery node Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family") Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/bq25980_charger.c | 40 -- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/drivers/power/supply/bq25980_charger.c b/drivers/power/supply/bq25980_charger.c index 7c489a9e8877..ac73e2c19238 100644 --- a/drivers/power/supply/bq25980_charger.c +++ b/drivers/power/supply/bq25980_charger.c @@ -641,33 +641,6 @@ static int bq25980_get_state(struct bq25980_device *bq, return 0; } -static int bq25980_set_battery_property(struct power_supply *psy, - enum power_supply_property psp, - const union power_supply_propval *val) -{ - struct bq25980_device *bq = power_supply_get_drvdata(psy); - int ret = 0; - - switch (psp) { - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: - ret = bq25980_set_const_charge_curr(bq, val->intval); - if (ret) - return ret; - break; - - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: - ret = bq25980_set_const_charge_volt(bq, val->intval); - if (ret) - return ret; - break; - - default: - return -EINVAL; - } - - return ret; -} - static int bq25980_get_battery_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -736,6 +709,18 @@ static int bq25980_set_charger_property(struct power_supply *psy, return ret; break; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + ret = bq25980_set_const_charge_curr(bq, val->intval); + if (ret) + return ret; + break; + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + ret = bq25980_set_const_charge_volt(bq, val->intval); + if (ret) + return ret; + break; + default: return -EINVAL; } @@ -957,7 +942,6 @@ static struct power_supply_desc bq25980_battery_desc = { .name = "bq25980-battery", .type = POWER_SUPPLY_TYPE_BATTERY, .get_property = bq25980_get_battery_property, - .set_property = bq25980_set_battery_property, .properties = bq25980_battery_props, .num_properties = ARRAY_SIZE(bq25980_battery_props), .property_is_writeable = bq25980_property_is_writeable, -- 2.30.0
[PATCH v5 2/2] power: supply: bq25790: Introduce the BQ25790 charger driver
From: Dan Murphy BQ25790 is a highly integrated switch-mode buck-boost charger for 1-4 cell Li-ion battery and Li-polymer battery. Signed-off-by: Ricardo Rivera-Matos Signed-off-by: Dan Murphy --- drivers/power/supply/Kconfig |8 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq25790_charger.c | 1100 drivers/power/supply/bq25790_charger.h | 148 4 files changed, 1257 insertions(+) create mode 100644 drivers/power/supply/bq25790_charger.c create mode 100644 drivers/power/supply/bq25790_charger.h diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 006b95eca673..d0ecbe76b720 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -638,6 +638,14 @@ config CHARGER_BQ2515X rail, ADC for battery and system monitoring, and push-button controller. +config CHARGER_BQ25790 + tristate "TI BQ25790 battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ25790 battery charger. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index 5e5fdbbef531..fa18d4fa9e6a 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -84,6 +84,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o +obj-$(CONFIG_CHARGER_BQ25790) += bq25790_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_BQ25980) += bq25980_charger.o obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o diff --git a/drivers/power/supply/bq25790_charger.c b/drivers/power/supply/bq25790_charger.c new file mode 100644 index ..2a2305b985df --- /dev/null +++ b/drivers/power/supply/bq25790_charger.c @@ -0,0 +1,1100 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ25790 driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "bq25790_charger.h" + +#define BQ25790_NUM_WD_VAL 8 + +struct bq25790_init_data { + u32 ichg; + u32 ilim; + u32 vreg; + u32 iterm; + u32 iprechg; + u32 vlim; + u32 ichg_max; + u32 vreg_max; +}; + +struct bq25790_state { + bool online; + u8 chrg_status; + u8 chrg_type; + u8 health; + u8 chrg_fault; + u8 vsys_status; + u8 vbus_status; + u8 fault_0; + u8 fault_1; + u32 vbat_adc; + u32 vbus_adc; + u32 ibat_adc; +}; + +enum bq25790_id { + BQ25790, + BQ25792, +}; + +struct bq25790_device { + struct i2c_client *client; + struct device *dev; + struct power_supply *charger; + struct power_supply *battery; + struct mutex lock; + + struct usb_phy *usb2_phy; + struct usb_phy *usb3_phy; + struct notifier_block usb_nb; + struct work_struct usb_work; + unsigned long usb_event; + struct regmap *regmap; + + char model_name[I2C_NAME_SIZE]; + int device_id; + + struct bq25790_init_data init_data; + struct bq25790_state state; + int watchdog_timer; +}; + +static struct reg_default bq25790_reg_defs[] = { + {BQ25790_INPUT_V_LIM, 0x24}, + {BQ25790_INPUT_I_LIM_MSB, 0x01}, + {BQ25790_INPUT_I_LIM_LSB, 0x2c}, + {BQ25790_PRECHRG_CTRL, 0xc3}, + {BQ25790_TERM_CTRL, 0x5}, + {BQ25790_VOTG_REG, 0xdc}, + {BQ25790_IOTG_REG, 0x4b}, + {BQ25790_TIMER_CTRL, 0x3d}, + {BQ25790_CHRG_CTRL_0, 0xa2}, + {BQ25790_CHRG_CTRL_1, 0x85}, + {BQ25790_CHRG_CTRL_2, 0x40}, + {BQ25790_CHRG_CTRL_3, 0x12}, + {BQ25790_CHRG_CTRL_5, 0x16}, + {BQ25790_MPPT_CTRL, 0xaa}, + {BQ25790_TEMP_CTRL, 0xc0}, + {BQ25790_NTC_CTRL_0, 0x7a}, + {BQ25790_NTC_CTRL_1, 0x54}, + {BQ25790_ICO_I_LIM, 0x0}, + {BQ25790_CHRG_STAT_0, 0x0}, + {BQ25790_CHRG_STAT_1, 0x0}, + {BQ25790_CHRG_STAT_2, 0x0}, + {BQ25790_CHRG_STAT_3, 0x0}, + {BQ25790_CHRG_STAT_4, 0x0}, + {BQ25790_FAULT_STAT_0, 0x0}, + {BQ25790_FAULT_STAT_1, 0x0}, + {BQ25790_CHRG_FLAG_0, 0x0}, + {BQ25790_CHRG_FLAG_1, 0x0}, + {BQ25790_CHRG_FLAG_2, 0x0}, + {BQ25790_CHRG_FLAG_3, 0x0}, + {BQ25790_FAULT_FLAG_0, 0x0}, + {BQ25790_FAULT_FLAG_1, 0x0}, + {BQ25790_CHRG_MSK_0, 0x0}, + {BQ25790_CHRG_MSK_1, 0x0}, + {BQ25790_CHRG_MSK_2, 0x0}, + {BQ25790_CHRG_MSK_3, 0x0}, + {BQ25790_FAULT_MSK_0, 0x0}, + {BQ25790_FAULT_MSK_1, 0x0}, +
[PATCH v5 0/2] Introduce the BQ25790 charger driver
Hello, This patchset introduces the BQ25790 integrated buck-boost charging IC. Dan Murphy (2): dt-bindings: power: Add the bq25790 dt bindings power: supply: bq25790: Introduce the BQ25790 charger driver .../bindings/power/supply/bq25790.yaml| 95 ++ drivers/power/supply/Kconfig |8 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq25790_charger.c| 1100 + drivers/power/supply/bq25790_charger.h| 148 +++ 5 files changed, 1352 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq25790.yaml create mode 100644 drivers/power/supply/bq25790_charger.c create mode 100644 drivers/power/supply/bq25790_charger.h -- 2.30.0
[PATCH v5 1/2] dt-bindings: power: Add the bq25790 dt bindings
From: Dan Murphy Add the bindings for the bq25790. Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos Signed-off-by: Dan Murphy --- .../bindings/power/supply/bq25790.yaml| 95 +++ 1 file changed, 95 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq25790.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq25790.yaml b/Documentation/devicetree/bindings/power/supply/bq25790.yaml new file mode 100644 index ..6d9178ce5a2b --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq25790.yaml @@ -0,0 +1,95 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq25790.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI BQ25790 Switch Mode Buck-Boost Charger + +maintainers: + - Dan Murphy + +description: | + BQ25790 is a highly integrated switch-mode buck-boost charger for 1-4 cell + Li-ion batteries and Li-polymer batteries. The device charges a battery from a + wide range of input sources including legacy USB adapters to high voltage USB + PD adapters and traditional barrel adapters. + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: +enum: + - ti,bq25790 + - ti,bq25792 + + reg: +maxItems: 1 + + ti,watchdog-timeout-ms: +default: 0 +description: | + Watchdog timer in milli seconds. 0 (default) disables the watchdog. +minimum: 0 +maximum: 16 +enum: [ 0, 500, 1000, 2000, 2, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in micro volts with a 10 micro volt step. +minimum: 360 +maximum: 2200 + + input-current-limit-microamp: +description: | + Maximum input current limit in micro amps with a 10 micro amp step. +minimum: 10 +maximum: 330 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + + interrupts: +maxItems: 1 +description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +unevaluatedProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <200>; + constant-charge-voltage-max-microvolt = <420>; + precharge-current-microamp = <16>; + charge-term-current-microamp = <16>; +}; +#include +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25790: charger@6b { + compatible = "ti,bq25790"; + reg = <0x6b>; + interrupt-parent = <>; + interrupts = <16 IRQ_TYPE_EDGE_FALLING>; + ti,watchdog-timeout-ms = <2000>; + input-current-limit-microamp = <300>; + input-voltage-limit-microvolt = <450>; + monitored-battery = <>; + }; +}; + +... -- 2.30.0
Re: [EXTERNAL] Re: [PATCH v4 2/2] power: supply: bq25790: Introduce the BQ25790 charger driver
Sebastian, On 12/27/20 12:46 PM, Sebastian Reichel wrote: Hi, Sorry, took me a lot longer than expected... On Fri, Oct 09, 2020 at 09:41:12AM -0500, Dan Murphy wrote: BQ25790 is a highly integrated switch-mode buck-boost charger for 1-4 cell Li-ion battery and Li-polymer battery. Signed-off-by: Ricardo Rivera-Matos Signed-off-by: Dan Murphy --- drivers/power/supply/Kconfig |8 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq25790_charger.c | 1121 drivers/power/supply/bq25790_charger.h | 150 4 files changed, 1280 insertions(+) create mode 100644 drivers/power/supply/bq25790_charger.c create mode 100644 drivers/power/supply/bq25790_charger.h diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index eec646c568b7..1cc361238d9a 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -628,6 +628,14 @@ config CHARGER_BQ2515X rail, ADC for battery and system monitoring, and push-button controller. +config CHARGER_BQ25790 + tristate "TI BQ25790 battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ25790 battery charger. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index dd4b86318cd9..29b71cc92550 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o +obj-$(CONFIG_CHARGER_BQ25790) += bq25790_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_BQ25980) += bq25980_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o diff --git a/drivers/power/supply/bq25790_charger.c b/drivers/power/supply/bq25790_charger.c new file mode 100644 index ..838a49c2f9f0 --- /dev/null +++ b/drivers/power/supply/bq25790_charger.c @@ -0,0 +1,1121 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ25790 driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "bq25790_charger.h" + +#define BQ25790_NUM_WD_VAL 8 + +struct bq25790_init_data { + u32 ichg; + u32 ilim; + u32 vreg; + u32 iterm; + u32 iprechg; + u32 vlim; + u32 ichg_max; + u32 vreg_max; +}; + +struct bq25790_state { + bool online; + u8 chrg_status; + u8 chrg_type; + u8 health; + u8 chrg_fault; + u8 vsys_status; + u8 vbus_status; + u8 fault_0; + u8 fault_1; + u32 vbat_adc; + u32 vbus_adc; + u32 ibat_adc; +}; + +struct bq25790_device { + struct i2c_client *client; + struct device *dev; + struct power_supply *charger; + struct power_supply *battery; + struct mutex lock; + + struct usb_phy *usb2_phy; + struct usb_phy *usb3_phy; + struct notifier_block usb_nb; + struct work_struct usb_work; + unsigned long usb_event; + struct regmap *regmap; + + char model_name[I2C_NAME_SIZE]; + int device_id; + + struct bq25790_init_data init_data; + struct bq25790_state state; + int watchdog_timer; +}; + +static struct reg_default bq25790_reg_defs[] = { + {BQ25790_INPUT_V_LIM, 0x24}, + {BQ25790_INPUT_I_LIM_MSB, 0x01}, + {BQ25790_INPUT_I_LIM_LSB, 0x2c}, + {BQ25790_PRECHRG_CTRL, 0xc3}, + {BQ25790_TERM_CTRL, 0x5}, + {BQ25790_VOTG_REG, 0xdc}, + {BQ25790_IOTG_REG, 0x4b}, + {BQ25790_TIMER_CTRL, 0x3d}, + {BQ25790_CHRG_CTRL_0, 0xa2}, + {BQ25790_CHRG_CTRL_1, 0x85}, + {BQ25790_CHRG_CTRL_2, 0x40}, + {BQ25790_CHRG_CTRL_3, 0x12}, + {BQ25790_CHRG_CTRL_5, 0x16}, + {BQ25790_MPPT_CTRL, 0xaa}, + {BQ25790_TEMP_CTRL, 0xc0}, + {BQ25790_NTC_CTRL_0, 0x7a}, + {BQ25790_NTC_CTRL_1, 0x54}, + {BQ25790_ICO_I_LIM, 0x0}, + {BQ25790_CHRG_STAT_0, 0x0}, + {BQ25790_CHRG_STAT_1, 0x0}, + {BQ25790_CHRG_STAT_2, 0x0}, + {BQ25790_CHRG_STAT_3, 0x0}, + {BQ25790_CHRG_STAT_4, 0x0}, + {BQ25790_FAULT_STAT_0, 0x0}, + {BQ25790_FAULT_STAT_1, 0x0}, + {BQ25790_CHRG_FLAG_0, 0x0}, + {BQ25790_CHRG_FLAG_1, 0x0}, + {BQ25790_CHRG_FLAG_2, 0x0}, + {BQ25790_CHRG_FLAG_3, 0x0}, + {BQ25790_FAULT_FLAG_0, 0x0}, + {BQ25790_FAULT_FLAG_1, 0x0}, + {BQ25790_CHRG_MSK_0, 0x0}, + {BQ25790_CHRG_MSK_1, 0x0}, + {BQ25790_CHRG_MSK_2, 0x0}, +
[PATCH] power: supply: bq256xx: Fix BQ256XX_NUM_WD_VAL and bq256xx_watchdog_time[] overrun
Corrects BQ256XX_NUM_WD_VAL from value of "8" to "4" and fixes the issue when 'i' is equal to array size then array index over runs the array Fixes: 32e4978bb92 ("power: supply: bq256xx: Introduce the BQ256XX charger driver") Reported-by: Dan Carpenter Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/bq256xx_charger.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c index dc74c44618af..8414472083a6 100644 --- a/drivers/power/supply/bq256xx_charger.c +++ b/drivers/power/supply/bq256xx_charger.c @@ -135,7 +135,7 @@ #define BQ256XX_NTC_FAULT_COLD (BIT(2) | BIT(0)) #define BQ256XX_NTC_FAULT_HOT (BIT(2) | BIT(1)) -#define BQ256XX_NUM_WD_VAL 8 +#define BQ256XX_NUM_WD_VAL 4 #define BQ256XX_WATCHDOG_MASK GENMASK(5, 4) #define BQ256XX_WATCHDOG_MAX 160 #define BQ256XX_WATCHDOG_DIS 0 @@ -1508,6 +1508,10 @@ static int bq256xx_hw_init(struct bq256xx_device *bq) int i; for (i = 0; i < BQ256XX_NUM_WD_VAL; i++) { + if (bq->watchdog_timer == bq256xx_watchdog_time[i]) { + wd_reg_val = i; + break; + } if (bq->watchdog_timer > bq256xx_watchdog_time[i] && bq->watchdog_timer < bq256xx_watchdog_time[i + 1]) wd_reg_val = i; -- 2.30.0
[PATCH v10 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml| 110 ++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..18b54783e11a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timeout-ms: +$ref: /schemas/types.yaml#/definitions/uint32 +default: 0 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + + interrupts: +maxItems: 1 +description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +ti,watchdog-timeout-ms = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.30.0
[PATCH v10 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos --- v9 - resolves two warnings issued by kernel test robot v10 - passes psy_cfg by reference drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1745 3 files changed, 1757 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index eec646c568b7..cedef501e683 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -645,6 +645,17 @@ config CHARGER_BQ25980 Say Y to enable support for the TI BQ25980, BQ25975 and BQ25960 series of fast battery chargers. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB3XX Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index dd4b86318cd9..ae322b1da1ed 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -85,6 +85,7 @@ obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_BQ25980) += bq25980_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..dc74c44618af --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1745 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THR
[PATCH v10 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 110 ++ drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1745 + 4 files changed, 1867 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.30.0
Re: [EXTERNAL] Re: [PATCH v9 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
Sebastian, On 1/5/21 3:26 PM, Sebastian Reichel wrote: Hi, On Tue, Jan 05, 2021 at 02:29:49PM -0600, Ricardo Rivera-Matos wrote: The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos v9 - resolves two warnings issued by kernel test robot changelog needs to be below --- btw. (so that git am does not pick it up :)) ACK --- [...] + ret = bq256xx_parse_dt(bq, psy_cfg, dev); + if (ret) { + dev_err(dev, "Failed to read device tree properties%d\n", ret); + return ret; + } [...] If you want to change psy_cfg, you need to pass it by reference and not by value (i.e. use _cfg here and a pointer as argument of bq256xx_parse_dt). Providing psy_cfg like this creates a copy of the struct. ACK, understood. Did you runtime test this version? It should crash when accessing the properties because of psy_cfg.drv_data being NULL. ACK, I did not, my mistake. v10 will get tested on the actual hardware. [...] + ret = bq256xx_power_supply_init(bq, psy_cfg, dev); + if (ret) { + dev_err(dev, "Failed to register power supply\n"); + return ret; + } Here it's also better to just provide the address of psy_cfg (but not strictly necessary). -- Sebastian Thanks, Ricardo
[PATCH v9 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml| 110 ++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..18b54783e11a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timeout-ms: +$ref: /schemas/types.yaml#/definitions/uint32 +default: 0 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + + interrupts: +maxItems: 1 +description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +ti,watchdog-timeout-ms = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.30.0
[PATCH v9 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 110 ++ drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1745 + 4 files changed, 1867 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.30.0
[PATCH v9 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos v9 - resolves two warnings issued by kernel test robot --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1745 3 files changed, 1757 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index eec646c568b7..cedef501e683 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -645,6 +645,17 @@ config CHARGER_BQ25980 Say Y to enable support for the TI BQ25980, BQ25975 and BQ25960 series of fast battery chargers. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB3XX Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index dd4b86318cd9..ae322b1da1ed 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -85,6 +85,7 @@ obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_BQ25980) += bq25980_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..32d6e99e0443 --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1745 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THRESH_uV 430 + +#define BQ256XX_IT
Re: [EXTERNAL] Re: [PATCH v8 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
Sebastian, On 1/5/21 8:18 AM, Sebastian Reichel wrote: Hi Ricardo, On Tue, Jan 05, 2021 at 11:24:18AM +0800, kernel test robot wrote: Hi Ricardo, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on power-supply/for-next] [also build test WARNING on robh/for-next v5.11-rc2 next-20210104] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Ricardo-Rivera-Matos/Introduce-the-BQ256XX-family-of-chargers/20210105-043028 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next config: powerpc64-randconfig-r034-20210105 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 5c951623bc8965fa1e89660f2f5f4a2944e4981a) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install powerpc64 cross compiling tool for clang build # apt-get install binutils-powerpc64-linux-gnu # https://github.com/0day-ci/linux/commit/82436c2c6d99c4effb187bbd09b47c4dc59a1f3d git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Ricardo-Rivera-Matos/Introduce-the-BQ256XX-family-of-chargers/20210105-043028 git checkout 82436c2c6d99c4effb187bbd09b47c4dc59a1f3d # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): drivers/power/supply/bq256xx_charger.c:1644:29: warning: variable 'psy_cfg' is uninitialized when used here [-Wuninitialized] ret = bq256xx_parse_dt(bq, psy_cfg, dev); ^~~ drivers/power/supply/bq256xx_charger.c:1618:37: note: initialize the variable 'psy_cfg' to silence this warning struct power_supply_config *psy_cfg; ^ = NULL bah, I missed this serious issue during review :( FWIW the compiler provided wrong solution. It would result in dereferencing a NULL pointer afterwards since you never allocate any memory for psy_cfg. You could of course allocate memory for it, but power_supply_config is only needed during device registration. Proper solution is to initialize it as variable instead of pointer, so that it ends up on the stack. Also you should initialize it with {} to make sure any fields not explicitly configured are 0. ACK drivers/power/supply/bq256xx_charger.c:1720:36: warning: unused variable 'bq256xx_acpi_match' [-Wunused-const-variable] static const struct acpi_device_id bq256xx_acpi_match[] = { For this one just change .acpi_match_table = ACPI_PTR(bq256xx_acpi_match), into .acpi_match_table = bq256xx_acpi_match, ACK 2 warnings generated. vim +/bq256xx_acpi_match +1720 drivers/power/supply/bq256xx_charger.c 1719 1720static const struct acpi_device_id bq256xx_acpi_match[] = { 1721 { "bq25600", BQ25600 }, 1722 { "bq25600d", BQ25600D }, 1723 { "bq25601", BQ25601 }, 1724 { "bq25601d", BQ25601D }, 1725 { "bq25611d", BQ25611D }, 1726 { "bq25618", BQ25618 }, 1727 { "bq25619", BQ25619 }, 1728 {}, 1729 }; 1730 MODULE_DEVICE_TABLE(acpi, bq256xx_acpi_match); 1731 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org Thanks, -- Sebastian Thanks for the feedback on this! Ricardo
[PATCH v8 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml| 110 ++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..18b54783e11a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timeout-ms: +$ref: /schemas/types.yaml#/definitions/uint32 +default: 0 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + + interrupts: +maxItems: 1 +description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +ti,watchdog-timeout-ms = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0
[PATCH v8 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1745 3 files changed, 1757 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index eec646c568b7..cedef501e683 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -645,6 +645,17 @@ config CHARGER_BQ25980 Say Y to enable support for the TI BQ25980, BQ25975 and BQ25960 series of fast battery chargers. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB3XX Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index dd4b86318cd9..ae322b1da1ed 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -85,6 +85,7 @@ obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_BQ25980) += bq25980_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..a6aa0ab2315f --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1745 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THRESH_uV 430 + +#define BQ256XX_ITERM_MASK GENMASK(3, 0) +#define BQ256X
[PATCH v8 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 110 ++ drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1745 + 4 files changed, 1867 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.28.0
Re: [EXTERNAL] Re: [PATCH v7 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
Sebastian On 1/2/21 7:26 PM, Sebastian Reichel wrote: Hi Ricardo, On Wed, Dec 30, 2020 at 05:01:16PM -0600, Ricardo Rivera-Matos wrote: The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos v5 - adds power_supply_put_battery_info() and devm_add_action_or_rest() calls v6 - implements bq256xx_remove function v7 - applies various fixes - implements clamp() API - implements memcmp() API - changes cache_type to REGACHE_FLAT - changes bq256xx_probe to properly unregister device Signed-off-by: Ricardo Rivera-Matos --- Thanks, looks mostly good now. Cool :) drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1747 3 files changed, 1759 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C Please rebase to current power-supply for-next branch, Kconfig and Makefile diff does not apply because of one additional BQ device. ACK [...] +static void bq256xx_usb_work(struct work_struct *data) +{ + struct bq256xx_device *bq = + container_of(data, struct bq256xx_device, usb_work); + + switch (bq->usb_event) { + case USB_EVENT_ID: + break; + spurious newline, please remove! ACK + case USB_EVENT_NONE: + power_supply_changed(bq->charger); + break; + default: + dev_err(bq->dev, "Error switching to charger mode.\n"); + break; + } +} + [...] +static int bq256xx_hw_init(struct bq256xx_device *bq) +{ + struct power_supply_battery_info bat_info = { }; + int wd_reg_val = BQ256XX_WATCHDOG_DIS; + int ret = 0; + int i; + + for (i = 0; i < BQ256XX_NUM_WD_VAL; i++) { + if (bq->watchdog_timer > bq256xx_watchdog_time[i] && + bq->watchdog_timer < bq256xx_watchdog_time[i + 1]) + wd_reg_val = i; + } + ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1, +BQ256XX_WATCHDOG_MASK, wd_reg_val << + BQ256XX_WDT_BIT_SHIFT); + + ret = power_supply_get_battery_info(bq->charger, _info); + if (ret) { + dev_warn(bq->dev, "battery info missing, default values will be applied\n"); + + bat_info.constant_charge_current_max_ua = + bq->chip_info->bq256xx_def_ichg; + + bat_info.constant_charge_voltage_max_uv = + bq->chip_info->bq256xx_def_vbatreg; + + bat_info.precharge_current_ua = + bq->chip_info->bq256xx_def_iprechg; + + bat_info.charge_term_current_ua = + bq->chip_info->bq256xx_def_iterm; + + bq->init_data.ichg_max = + bq->chip_info->bq256xx_max_ichg; + + bq->init_data.vbatreg_max = + bq->chip_info->bq256xx_max_vbatreg; + } else { + bq->init_data.ichg_max = + bat_info.constant_charge_current_max_ua; + + bq->init_data.vbatreg_max = + bat_info.constant_charge_voltage_max_uv; + } + + ret = bq->chip_info->bq256xx_set_vindpm(bq, bq->init_data.vindpm); + if (ret) + goto err_out; + + ret = bq->chip_info->bq256xx_set_iindpm(bq, bq->init_data.iindpm); + if (ret) + goto err_out; + + ret = bq->chip_info->bq256xx_set_ichg(bq, + bat_info.constant_charge_current_max_ua); + if (ret) + goto err_out; + + ret = bq->chip_info->bq256xx_set_iprechg(bq,
[PATCH v7 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos v4 - documents monitored-battery and interrupts, fixes example for ti,watchdog-timeout-ms --- .../bindings/power/supply/bq256xx.yaml| 110 ++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..18b54783e11a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timeout-ms: +$ref: /schemas/types.yaml#/definitions/uint32 +default: 0 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + + interrupts: +maxItems: 1 +description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +ti,watchdog-timeout-ms = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0
[PATCH v7 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 110 ++ drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1747 + 4 files changed, 1869 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.28.0
[PATCH v7 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos v5 - adds power_supply_put_battery_info() and devm_add_action_or_rest() calls v6 - implements bq256xx_remove function v7 - applies various fixes - implements clamp() API - implements memcmp() API - changes cache_type to REGACHE_FLAT - changes bq256xx_probe to properly unregister device Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1747 3 files changed, 1759 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..e762442c7cc6 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..4a5973524a70 --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1747 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_M
Re: [EXTERNAL] Re: [PATCH v6 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
Sebastian, On 10/19/20 4:53 PM, Sebastian Reichel wrote: Hi Ricardo, On Mon, Oct 05, 2020 at 04:47:09PM -0500, Ricardo Rivera-Matos wrote: The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos v5 - adds power_supply_put_battery_info() and devm_add_action_or_rest() calls v6 - implements bq256xx_remove function v6 unfortunately makes things worse. You might want to read some background information about managed resources: https://lwn.net/Articles/222860/ https://www.kernel.org/doc/html/latest/driver-api/driver-model/devres.html ACK --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1803 3 files changed, 1815 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..e762442c7cc6 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090)+= tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217)+= tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..b9caec10c456 --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1803 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG
[PATCH v6 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos v5 - adds power_supply_put_battery_info() and devm_add_action_or_rest() calls v6 - implements bq256xx_remove function --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1803 3 files changed, 1815 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..e762442c7cc6 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..b9caec10c456 --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1803 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THR
[PATCH v6 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 110 + drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1803 + 4 files changed, 1925 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.28.0
[PATCH v6 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos v4 - documents monitored-battery and interrupts, fixes example for ti,watchdog-timeout-ms --- .../bindings/power/supply/bq256xx.yaml| 110 ++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..18b54783e11a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timeout-ms: +$ref: /schemas/types.yaml#/definitions/uint32 +default: 0 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + + interrupts: +maxItems: 1 +description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +ti,watchdog-timeout-ms = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0
Re: [EXTERNAL] Re: [PATCH v5 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
Sebastian, On 10/3/20 5:54 AM, Sebastian Reichel wrote: Hi Ricardo, On Thu, Oct 01, 2020 at 04:40:34PM -0500, Ricardo Rivera-Matos wrote: The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos v5 - adds power_supply_put_battery_info() and devm_add_action_or_reset() calls --- changes look good, but you are still missing usb_unregister_notifier() calls on drival removal. ACK, I will add a driver removal function and make the appropriate usb_unregister_notifier() calls. -- Sebastian Ricardo
[PATCH v5 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos v4 - documents monitored-battery and interrupts, fixes example for ti,watchdog-timeout-ms --- .../bindings/power/supply/bq256xx.yaml| 110 ++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..18b54783e11a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timeout-ms: +$ref: /schemas/types.yaml#/definitions/uint32 +default: 0 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + + interrupts: +maxItems: 1 +description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +ti,watchdog-timeout-ms = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0
[PATCH v5 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 110 + drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1785 + 4 files changed, 1907 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.28.0
[PATCH v5 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos v5 - adds power_supply_put_battery_info() and devm_add_action_or_rest() calls --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1785 3 files changed, 1797 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..e762442c7cc6 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..0226d8dc914e --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1785 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THRESH_uV 430 + +#define BQ256XX_ITERM
Re: [EXTERNAL] Re: [PATCH v4 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
Sebastian On 9/30/20 6:47 PM, Sebastian Reichel wrote: Hi, You are leaking some resources, otherwise LGTM. ACK On Wed, Sep 23, 2020 at 10:24:16AM -0500, Ricardo Rivera-Matos wrote: [...] +static int bq256xx_hw_init(struct bq256xx_device *bq) +{ + struct power_supply_battery_info bat_info = { }; + int wd_reg_val = BQ256XX_WATCHDOG_DIS; + int ret = 0; + int i; + + for (i = 0; i < BQ256XX_NUM_WD_VAL; i++) { + if (bq->watchdog_timer > bq256xx_watchdog_time[i] && + bq->watchdog_timer < bq256xx_watchdog_time[i + 1]) + wd_reg_val = i; + } + ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1, +BQ256XX_WATCHDOG_MASK, wd_reg_val << + BQ256XX_WDT_BIT_SHIFT); + + ret = power_supply_get_battery_info(bq->charger, _info); + if (ret) { + dev_warn(bq->dev, "battery info missing, default values will be applied\n"); + + bat_info.constant_charge_current_max_ua = + bq->chip_info->bq256xx_def_ichg; + + bat_info.constant_charge_voltage_max_uv = + bq->chip_info->bq256xx_def_vbatreg; + + bat_info.precharge_current_ua = + bq->chip_info->bq256xx_def_iprechg; + + bat_info.charge_term_current_ua = + bq->chip_info->bq256xx_def_iterm; + + bq->init_data.ichg_max = + bq->chip_info->bq256xx_max_ichg; + + bq->init_data.vbatreg_max = + bq->chip_info->bq256xx_max_vbatreg; + } else { + bq->init_data.ichg_max = + bat_info.constant_charge_current_max_ua; + + bq->init_data.vbatreg_max = + bat_info.constant_charge_voltage_max_uv; + } + + ret = bq->chip_info->bq256xx_set_vindpm(bq, bq->init_data.vindpm); + if (ret) + goto err_out; + + ret = bq->chip_info->bq256xx_set_iindpm(bq, bq->init_data.iindpm); + if (ret) + goto err_out; + + ret = bq->chip_info->bq256xx_set_ichg(bq, + bat_info.constant_charge_current_max_ua); + if (ret) + goto err_out; + + ret = bq->chip_info->bq256xx_set_iprechg(bq, + bat_info.precharge_current_ua); + if (ret) + goto err_out; + + ret = bq->chip_info->bq256xx_set_vbatreg(bq, + bat_info.constant_charge_voltage_max_uv); + if (ret) + goto err_out; + + ret = bq->chip_info->bq256xx_set_iterm(bq, + bat_info.charge_term_current_ua); + if (ret) + goto err_out; You need to power_supply_put_battery_info(). ACK + + return 0; + +err_out: + return ret; +} + +static int bq256xx_parse_dt(struct bq256xx_device *bq) +{ + int ret = 0; + + ret = device_property_read_u32(bq->dev, "ti,watchdog-timeout-ms", + >watchdog_timer); + if (ret) + bq->watchdog_timer = BQ256XX_WATCHDOG_DIS; + + if (bq->watchdog_timer > BQ256XX_WATCHDOG_MAX || + bq->watchdog_timer < BQ256XX_WATCHDOG_DIS) + return -EINVAL; + + ret = device_property_read_u32(bq->dev, + "input-voltage-limit-microvolt", + >init_data.vindpm); + if (ret) + bq->init_data.vindpm = bq->chip_info->bq256xx_def_vindpm; + + ret = device_property_read_u32(bq->dev, + "input-current-limit-microamp", + >init_data.iindpm); + if (ret) + bq->init_data.iindpm = bq->chip_info->bq256xx_def_iindpm; + + return 0; +} + +static int bq256xx_probe(struct i2c_client *client, +const struct i2c_device_id *id) +{ + struct device *dev = >dev; + struct bq256xx_device *bq; + int ret; + + bq = devm_kzalloc(dev, sizeof(*bq), GFP_KERNEL); + if (!bq) + return -ENOMEM; + + bq->client = client; + bq->dev = dev; + bq->chip_info = _chip_info_tbl[id->driver_data]; + + mutex_init(>lock); + + strncpy(bq->model_name, id->name, I2C_NAME_SIZE); + + bq->regmap = devm_regmap_init_i2c(client, + bq->chip_info->bq256xx_regmap_config); + + if (IS_ERR(bq->regmap)) { + dev_err(dev, "F
[PATCH v4 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1769 3 files changed, 1781 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..e762442c7cc6 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..2b76e859a204 --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1769 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THRESH_uV 430 + +#define BQ256XX_ITERM_MASK GENMASK(3, 0) +#define BQ256XX_ITERM_STEP_uA 6 +#
[PATCH v4 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Signed-off-by: Ricardo Rivera-Matos --- v4 - documents monitored-battery and interrupts, fixes example for ti,watchdog-timeout-ms .../bindings/power/supply/bq256xx.yaml| 110 ++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..18b54783e11a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timeout-ms: +$ref: /schemas/types.yaml#/definitions/uint32 +default: 0 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + + interrupts: +maxItems: 1 +description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +ti,watchdog-timeout-ms = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0
[PATCH v4 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 110 + drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1769 + 4 files changed, 1891 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.28.0
Re: [EXTERNAL] Re: [PATCH v3 1/2] dt-bindings: power: Add the bq256xx dt bindings
Dan On 9/22/20 8:05 PM, Dan Murphy wrote: RIcardo On 9/22/20 5:56 PM, Ricardo Rivera-Matos wrote: Rob On 9/22/20 5:22 PM, Rob Herring wrote: On Thu, Sep 10, 2020 at 11:45:33AM -0500, Ricardo Rivera-Matos wrote: Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml | 97 +++ 1 file changed, 97 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..8cc2242f7df0 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,97 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: + - https://www.ti.com/lit/ds/symlink/bq25600.pdf + - https://www.ti.com/lit/ds/symlink/bq25601.pdf + - https://www.ti.com/lit/ds/symlink/bq25600d.pdf + - https://www.ti.com/lit/ds/symlink/bq25601d.pdf + - https://www.ti.com/lit/ds/symlink/bq25611d.pdf + - https://www.ti.com/lit/ds/symlink/bq25618.pdf + - https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: + enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: + maxItems: 1 + + ti,watchdog-timer: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Watchdog timer in ms. 0 (default) disables the watchdog + minimum: 0 + maximum: 16 + enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: + description: | + Minimum input voltage limit in µV with a 10 µV step + minimum: 390 + maximum: 540 + + input-current-limit-microamp: + description: | + Maximum input current limit in µA with a 10 µA step + minimum: 10 + maximum: 320 + +required: + - compatible + - reg + - monitored-battery additionalProperties: false And then fix what breaks in the example. ACK. I will document the monitored-battery and interrupts properties and fix the example. Is ti,watchdog-timer okay as it is currently documented? For TI consistency please use ti,watchdog-timeout-ms ACK, thanks. Dan Ricardo
Re: [EXTERNAL] Re: [PATCH v3 1/2] dt-bindings: power: Add the bq256xx dt bindings
Rob On 9/22/20 5:22 PM, Rob Herring wrote: On Thu, Sep 10, 2020 at 11:45:33AM -0500, Ricardo Rivera-Matos wrote: Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml| 97 +++ 1 file changed, 97 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..8cc2242f7df0 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,97 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timer: +$ref: /schemas/types.yaml#/definitions/uint32 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + +required: + - compatible + - reg + - monitored-battery additionalProperties: false And then fix what breaks in the example. ACK. I will document the monitored-battery and interrupts properties and fix the example. Is ti,watchdog-timer okay as it is currently documented? + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +watchdog-timer = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0 Ricardo
[PATCH v3 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 97 + drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1769 + 4 files changed, 1878 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.28.0
[PATCH v3 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1769 3 files changed, 1781 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..e762442c7cc6 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..2b76e859a204 --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1769 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THRESH_uV 430 + +#define BQ256XX_ITERM_MASK GENMASK(3, 0) +#define BQ256XX_ITERM_STEP_uA 6 +#
[PATCH v3 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml| 97 +++ 1 file changed, 97 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..8cc2242f7df0 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,97 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timer: +$ref: /schemas/types.yaml#/definitions/uint32 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + +required: + - compatible + - reg + - monitored-battery + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + charge-term-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +watchdog-timer = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0
[PATCH v2 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 97 + drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1769 + 4 files changed, 1878 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.28.0
[PATCH v2 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml| 97 +++ 1 file changed, 97 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..9c6989581f9c --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,97 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timer: +$ref: /schemas/types.yaml#/definitions/uint32 +description: | + Watchdog timer in ms. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in µV with a 10 µV step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in µA with a 10 µA step +minimum: 10 +maximum: 320 + +required: + - compatible + - reg + - monitored-battery + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + termination-current-microamp = <18>; +}; +#include +#include +i2c { + + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +watchdog-timer = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0
[PATCH v2 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1769 3 files changed, 1781 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..e762442c7cc6 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..2b76e859a204 --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1769 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THRESH_uV 430 + +#define BQ256XX_ITERM_MASK GENMASK(3, 0) +#define BQ256XX_ITERM_STEP_uA 6 +#
Re: [EXTERNAL] Re: [PATCH v1 1/2] dt-bindings: power: Add the bq256xx dt bindings
Rob On 8/18/20 11:43 AM, Rob Herring wrote: On Mon, Aug 17, 2020 at 02:17:22PM -0500, Ricardo Rivera-Matos wrote: Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml| 99 +++ 1 file changed, 99 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..67db4ba9fdb6 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timer: Poorly named since we have 'ti,watchdog-timers' already and is completely different. ACK, will use ti,watchdog-timeout-ms instead +$ref: /schemas/types.yaml#/definitions/uint32 +description: | + Watchdog timer in milli seconds. 0 (default) disables the watchdog If you have units, then you should use standard unit suffix. ACK +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in micro volts with a 10 micro volt step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in micro amps with a 10 micro amp step +minimum: 10 +maximum: 320 Aren't these properties of the battery, not the charger? These are input current and voltage limit for the charger, not the battery + +required: + - compatible + - reg monitored-battery not required? ACK Add: additionalProperties: false additionalProperties: false or unevaluatedProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + termination-current-microamp = <18>; +}; +#include +#include +i2c0 { i2c { ACK + pinctrl-names = "default"; + pinctrl-0 = <_pins>; Not relevant to the example. ACK + + status = "okay"; Don't show status in examples. ACK + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + bq25601@6b { charger@6b ACK +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +watchdog-timer = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0 Ricardo
[PATCH v1 2/2] power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers for single cell batteries. Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c | 1769 3 files changed, 1781 insertions(+) create mode 100644 drivers/power/supply/bq256xx_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..87d852914bc2 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -618,6 +618,17 @@ config CHARGER_BQ25890 help Say Y to enable support for the TI BQ25890 battery charger. +config CHARGER_BQ256XX + tristate "TI BQ256XX battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ256XX battery chargers. The + BQ256XX family of devices are highly-integrated, switch-mode battery + charge management and system power path management devices for single + cell Li-ion and Li-polymer batteries. + config CHARGER_SMB347 tristate "Summit Microelectronics SMB347 Battery Charger" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..e762442c7cc6 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c new file mode 100644 index ..57ec875d7c1a --- /dev/null +++ b/drivers/power/supply/bq256xx_charger.c @@ -0,0 +1,1769 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ256XX Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ256XX_MANUFACTURER "Texas Instruments" + +#define BQ256XX_INPUT_CURRENT_LIMIT0x00 +#define BQ256XX_CHARGER_CONTROL_0 0x01 +#define BQ256XX_CHARGE_CURRENT_LIMIT 0x02 +#define BQ256XX_PRECHG_AND_TERM_CURR_LIM 0x03 +#define BQ256XX_BATTERY_VOLTAGE_LIMIT 0x04 +#define BQ256XX_CHARGER_CONTROL_1 0x05 +#define BQ256XX_CHARGER_CONTROL_2 0x06 +#define BQ256XX_CHARGER_CONTROL_3 0x07 +#define BQ256XX_CHARGER_STATUS_0 0x08 +#define BQ256XX_CHARGER_STATUS_1 0x09 +#define BQ256XX_CHARGER_STATUS_2 0x0a +#define BQ256XX_PART_INFORMATION 0x0b +#define BQ256XX_CHARGER_CONTROL_4 0x0c + +#define BQ256XX_IINDPM_MASKGENMASK(4, 0) +#define BQ256XX_IINDPM_STEP_uA 10 +#define BQ256XX_IINDPM_OFFSET_uA 10 +#define BQ256XX_IINDPM_MIN_uA 10 +#define BQ256XX_IINDPM_MAX_uA 320 +#define BQ256XX_IINDPM_DEF_uA 240 + +#define BQ256XX_VINDPM_MASKGENMASK(3, 0) +#define BQ256XX_VINDPM_STEP_uV 10 +#define BQ256XX_VINDPM_OFFSET_uV 390 +#define BQ256XX_VINDPM_MIN_uV 390 +#define BQ256XX_VINDPM_MAX_uV 540 +#define BQ256XX_VINDPM_DEF_uV 450 + +#define BQ256XX_VBATREG_MASK GENMASK(7, 3) +#define BQ2560X_VBATREG_STEP_uV32000 +#define BQ2560X_VBATREG_OFFSET_uV 3856000 +#define BQ2560X_VBATREG_MIN_uV 3856000 +#define BQ2560X_VBATREG_MAX_uV 4624000 +#define BQ2560X_VBATREG_DEF_uV 4208000 +#define BQ25601D_VBATREG_OFFSET_uV 3847000 +#define BQ25601D_VBATREG_MIN_uV3847000 +#define BQ25601D_VBATREG_MAX_uV4615000 +#define BQ25601D_VBATREG_DEF_uV4199000 +#define BQ2561X_VBATREG_STEP_uV1 +#define BQ25611D_VBATREG_MIN_uV3494000 +#define BQ25611D_VBATREG_MAX_uV451 +#define BQ25611D_VBATREG_DEF_uV419 +#define BQ25618_VBATREG_MIN_uV 3504000 +#define BQ25618_VBATREG_MAX_uV 450 +#define BQ25618_VBATREG_DEF_uV 420 +#define BQ256XX_VBATREG_BIT_SHIFT 3 +#define BQ2561X_VBATREG_THRESH 0x8 +#define BQ25611D_VBATREG_THRESH_uV 429 +#define BQ25618_VBATREG_THRESH_uV 430 + +#define BQ256XX_ITERM_MASK GENMASK(3, 0) +#define BQ256XX_ITERM_STEP_uA 6 +#
[PATCH v1 1/2] dt-bindings: power: Add the bq256xx dt bindings
Add the bindings for the bq256xx series of battery charging ICs. Datasheets: - https://www.ti.com/lit/ds/symlink/bq25600.pdf - https://www.ti.com/lit/ds/symlink/bq25601.pdf - https://www.ti.com/lit/ds/symlink/bq25600d.pdf - https://www.ti.com/lit/ds/symlink/bq25601d.pdf - https://www.ti.com/lit/ds/symlink/bq25611d.pdf - https://www.ti.com/lit/ds/symlink/bq25618.pdf - https://www.ti.com/lit/ds/symlink/bq25619.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq256xx.yaml| 99 +++ 1 file changed, 99 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml new file mode 100644 index ..67db4ba9fdb6 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq256xx.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq256xx Switch Mode Buck Charger + +maintainers: + - Ricardo Rivera-Matos + +description: | + The bq256xx devices are a family of highly-integrated battery charge + management and system power management ICs for single cell Li-ion and Li- + polymer batteries. + + Datasheets: +- https://www.ti.com/lit/ds/symlink/bq25600.pdf +- https://www.ti.com/lit/ds/symlink/bq25601.pdf +- https://www.ti.com/lit/ds/symlink/bq25600d.pdf +- https://www.ti.com/lit/ds/symlink/bq25601d.pdf +- https://www.ti.com/lit/ds/symlink/bq25611d.pdf +- https://www.ti.com/lit/ds/symlink/bq25618.pdf +- https://www.ti.com/lit/ds/symlink/bq25619.pdf + +properties: + compatible: +enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + - ti,bq25611d + - ti,bq25618 + - ti,bq25619 + + reg: +maxItems: 1 + + ti,watchdog-timer: +$ref: /schemas/types.yaml#/definitions/uint32 +description: | + Watchdog timer in milli seconds. 0 (default) disables the watchdog +minimum: 0 +maximum: 16 +enum: [ 0, 4, 8, 16] + + input-voltage-limit-microvolt: +description: | + Minimum input voltage limit in micro volts with a 10 micro volt step +minimum: 390 +maximum: 540 + + input-current-limit-microamp: +description: | + Maximum input current limit in micro amps with a 10 micro amp step +minimum: 10 +maximum: 320 + +required: + - compatible + - reg + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <204>; + constant-charge-voltage-max-microvolt = <4352000>; + precharge-current-microamp = <18>; + termination-current-microamp = <18>; +}; +#include +#include +i2c0 { + pinctrl-names = "default"; + pinctrl-0 = <_pins>; + + status = "okay"; + clock-frequency = <40>; + + #address-cells = <1>; + #size-cells = <0>; + + bq25601@6b { +compatible = "ti,bq25601"; +reg = <0x6b>; +monitored-battery = <>; + +interrupt-parent = <>; +interrupts = <16 IRQ_TYPE_EDGE_FALLING>; +watchdog-timer = <4>; + +input-voltage-limit-microvolt = <450>; +input-current-limit-microamp = <240>; + }; +}; +... -- 2.28.0
[PATCH v1 0/2] Introduce the BQ256XX family of chargers
Hello, This patchset introduces the bq256xx family of charging ICs. The bq256xx ICs are highly integrated, buck, switching chargers intended for use in smartphones, tablets, and portable electronics. Ricardo Rivera-Matos (2): dt-bindings: power: Add the bq256xx dt bindings power: supply: bq256xx: Introduce the BQ256XX charger driver .../bindings/power/supply/bq256xx.yaml| 99 + drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq256xx_charger.c| 1769 + 4 files changed, 1880 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq256xx.yaml create mode 100644 drivers/power/supply/bq256xx_charger.c -- 2.28.0
Re: [PATCH 2/2] power: supply: bq25790: Introduce the BQ25790 charger driver
Signed-off-by: Ricardo Rivera-Matos On 7/30/20 9:58 AM, Dan Murphy wrote: BQ25790 is a highly integrated switch-mode buck-boost charger for 1-4 cell Li-ion battery and Li-polymer battery. Signed-off-by: Dan Murphy --- drivers/power/supply/Kconfig |8 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq25790_charger.c | 1117 drivers/power/supply/bq25790_charger.h | 150 4 files changed, 1276 insertions(+) create mode 100644 drivers/power/supply/bq25790_charger.c create mode 100644 drivers/power/supply/bq25790_charger.h diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index faf2830aa152..802c644d92be 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -623,6 +623,14 @@ config CHARGER_BQ2515X rail, ADC for battery and system monitoring, and push-button controller. +config CHARGER_BQ25790 + tristate "TI BQ25790 battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ25790 battery charger. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b3c694a65114..ae269b9f624b 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -84,6 +84,7 @@ obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_BQ25790) += bq25790_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090)+= tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65217)+= tps65217_charger.o diff --git a/drivers/power/supply/bq25790_charger.c b/drivers/power/supply/bq25790_charger.c new file mode 100644 index ..92fa859ef55c --- /dev/null +++ b/drivers/power/supply/bq25790_charger.c @@ -0,0 +1,1117 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ25790 driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "bq25790_charger.h" + +#define BQ25790_NUM_WD_VAL 8 + +struct bq25790_init_data { + u32 ichg; + u32 ilim; + u32 vreg; + u32 iterm; + u32 iprechg; + u32 vlim; + u32 ichg_max; + u32 vreg_max; +}; + +struct bq25790_state { + bool online; + u8 chrg_status; + u8 chrg_type; + u8 health; + u8 chrg_fault; + u8 vsys_status; + u8 vbus_status; + u8 fault_0; + u8 fault_1; + u32 vbat_adc; + u32 vbus_adc; + u32 ibat_adc; +}; + +struct bq25790_device { + struct i2c_client *client; + struct device *dev; + struct power_supply *charger; + struct power_supply *battery; + struct mutex lock; + + struct usb_phy *usb2_phy; + struct usb_phy *usb3_phy; + struct notifier_block usb_nb; + struct work_struct usb_work; + unsigned long usb_event; + struct regmap *regmap; + + char model_name[I2C_NAME_SIZE]; + int device_id; + + struct bq25790_init_data init_data; + struct bq25790_state state; + int watchdog_timer; +}; + +static struct reg_default bq25790_reg_defs[] = { + {BQ25790_INPUT_V_LIM, 0x24}, + {BQ25790_INPUT_I_LIM_MSB, 0x01}, + {BQ25790_INPUT_I_LIM_LSB, 0x2c}, + {BQ25790_PRECHRG_CTRL, 0xc3}, + {BQ25790_TERM_CTRL, 0x5}, + {BQ25790_VOTG_REG, 0xdc}, + {BQ25790_IOTG_REG, 0x4b}, + {BQ25790_TIMER_CTRL, 0x3d}, + {BQ25790_CHRG_CTRL_0, 0xa2}, + {BQ25790_CHRG_CTRL_1, 0x85}, + {BQ25790_CHRG_CTRL_2, 0x40}, + {BQ25790_CHRG_CTRL_3, 0x12}, + {BQ25790_CHRG_CTRL_5, 0x16}, + {BQ25790_MPPT_CTRL, 0xaa}, + {BQ25790_TEMP_CTRL, 0xc0}, + {BQ25790_NTC_CTRL_0, 0x7a}, + {BQ25790_NTC_CTRL_1, 0x54}, + {BQ25790_ICO_I_LIM, 0x0}, + {BQ25790_CHRG_STAT_0, 0x0}, + {BQ25790_CHRG_STAT_1, 0x0}, + {BQ25790_CHRG_STAT_2, 0x0}, + {BQ25790_CHRG_STAT_3, 0x0}, + {BQ25790_CHRG_STAT_4, 0x0}, + {BQ25790_FAULT_STAT_0, 0x0}, + {BQ25790_FAULT_STAT_1, 0x0}, + {BQ25790_CHRG_FLAG_0, 0x0}, + {BQ25790_CHRG_FLAG_1, 0x0}, + {BQ25790_CHRG_FLAG_2, 0x0}, + {BQ25790_CHRG_FLAG_3, 0x0}, + {BQ25790_FAULT_FLAG_0, 0x0}, + {BQ25790_FAULT_FLAG_1, 0x0}, + {BQ25790_CHRG_MSK_0, 0x0}, + {BQ25790_CHRG_MSK_1, 0x0}, + {BQ25790_CHRG_MSK_2, 0x0}, + {BQ25790_CHRG_MSK_3, 0x0}, + {BQ25790_FAULT_MSK_0, 0x0}, + {BQ25790_FAULT_MSK_1, 0x0}, +
[PATCH v18 0/4] Add JEITA properties and introduce the bq2515x charger
Hello, This patchset adds additional health properties to the power_supply header. These additional properties are taken from the JEITA specification. This patchset also introduces the bq2515x family of charging ICs. Dan Murphy (2): power_supply: Add additional health properties to the header dt-bindings: power: Convert battery.txt to battery.yaml Ricardo Rivera-Matos (2): dt-bindings: power: Add the bindings for the bq2515x family of chargers. power: supply: bq25150 introduce the bq25150 Documentation/ABI/testing/sysfs-class-power |3 +- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 139 ++ .../bindings/power/supply/bq2515x.yaml| 93 ++ drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c| 1169 + drivers/power/supply/power_supply_sysfs.c |3 + include/linux/power_supply.h |3 + 9 files changed, 1424 insertions(+), 86 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml create mode 100644 drivers/power/supply/bq2515x_charger.c -- 2.27.0
[PATCH v18 4/4] power: supply: bq25150 introduce the bq25150
Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1169 3 files changed, 1183 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..faf2830aa152 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -610,6 +610,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..b3c694a65114 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..63e8e317af56 --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1169 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#define BQ2515X_TS_HOT 0x65 +#define BQ2515X_DEVICE_ID 0x6f + +#define BQ2515X_DEFAULT_ICHG_UA1 +#
[PATCH v18 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy Reviewed-by: Rob Herring --- .../bindings/power/supply/battery.txt | 86 +-- .../bindings/power/supply/battery.yaml| 139 ++ 2 files changed, 140 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..a9f80cc49068 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,87 +1,3 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. +The contents of this file has been moved to battery.yaml Please note that not all charger drivers respect all of the properties. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - over-voltage-threshold-microvolt: battery over-voltage limit - - re-charge-voltage-microvolt: limit to automatically start charging again - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - trickle-charge-current-microamp: current for trickle-charge phase - - precharge-current-microamp: current for pre-charge phase - - precharge-upper-limit-microvolt: limit when to change to constant charging - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge:
[PATCH v18 3/4] dt-bindings: power: Add the bindings for the bq2515x family of chargers.
The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: http://www.ti.com/lit/ds/symlink/bq25150.pdf http://www.ti.com/lit/ds/symlink/bq25155.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq2515x.yaml| 93 +++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq2515x.yaml b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file mode 100644 index ..75a56773be4a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq2515x 500-mA Linear charger family + +maintainers: + - Dan Murphy + - Ricardo Rivera-Matos + +description: | + The BQ2515x family is a highly integrated battery charge management IC that + integrates the most common functions for wearable devices, namely a charger, + an output voltage rail, ADC for battery and system monitoring, and + push-button controller. + + Specifications about the charger can be found at: +http://www.ti.com/lit/ds/symlink/bq25150.pdf +http://www.ti.com/lit/ds/symlink/bq25155.pdf + +properties: + compatible: +enum: + - ti,bq25150 + - ti,bq25155 + + reg: +maxItems: 1 +description: I2C address of the charger. + + ac-detect-gpios: +description: | + GPIO used for connecting the bq2515x device PG (AC Detect) + pin. +maxItems: 1 + + reset-gpios: +description: GPIO used for hardware reset. +maxItems: 1 + + powerdown-gpios: +description: GPIO used for low power mode of IC. +maxItems: 1 + + charge-enable-gpios: +description: GPIO used to turn on and off charging. +maxItems: 1 + + input-current-limit-microamp: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Maximum input current in micro Amps. +minimum: 5 +maximum: 50 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <5>; + precharge-current-microamp = <2500>; + constant-charge-voltage-max-microvolt = <400>; +}; +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25150: charger@6b { +compatible = "ti,bq25150"; +reg = <0x6b>; +monitored-battery = <>; +input-current-limit-microamp = <10>; + +ac-detect-gpios = < 28 GPIO_ACTIVE_HIGH>; +reset-gpios = < 14 GPIO_ACTIVE_HIGH>; +powerdown-gpios = < 15 GPIO_ACTIVE_HIGH>; +charge-enable-gpios = < 13 GPIO_ACTIVE_LOW>; + }; +}; -- 2.27.0
[PATCH v18 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from JEITA specification JISC8712:2015 Acked-by: Andrew F. Davis Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 3 ++- drivers/power/supply/power_supply_sysfs.c | 3 +++ include/linux/power_supply.h| 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 216d61a22f1e..40213c73bc9c 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -205,7 +205,8 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current", "Calibration required" + "Over current", "Calibration required", "Warm", + "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index bc79560229b5..4d6e1d5015d6 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -101,6 +101,9 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE] = "Safety timer expire", [POWER_SUPPLY_HEALTH_OVERCURRENT] = "Over current", [POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED] = "Calibration required", + [POWER_SUPPLY_HEALTH_WARM] = "Warm", + [POWER_SUPPLY_HEALTH_COOL] = "Cool", + [POWER_SUPPLY_HEALTH_HOT] = "Hot", }; static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ac1345a48ad0..b5ee35d3c304 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -62,6 +62,9 @@ enum { POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.27.0
Re: [EXTERNAL] Re: [PATCH v17 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
On 7/26/20 6:24 PM, Sebastian Reichel wrote: Hi, On Mon, Jul 20, 2020 at 03:43:58PM -0500, Ricardo Rivera-Matos wrote: From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. The examples were correct for the existing binding. What you did is completly changing the binding description (without modifying the code) resulting in examples and any existing users being incorrect and code not matching up with the binding. ACK Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 ++ 2 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..a9f80cc49068 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,87 +1,3 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. +The contents of this file has been moved to battery.yaml Please note that not all charger drivers respect all of the properties. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - over-voltage-threshold-microvolt: battery over-voltage limit - - re-charge-voltage-microvolt: limit to automatically start charging again - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - trickle-charge-current-microamp: current for trickle-charge phase - - precharge-current-microamp: current for pre-charge phase - - precharge-upper-limit-microvolt: limit when to change to constant charging - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>,
[PATCH v17 0/4] Add JEITA properties and introduce the bq2515x charger
Hello, This patchset adds additional health properties to the power_supply header. These additional properties are taken from the JEITA specification. This patchset also introduces the bq2515x family of charging ICs. Dan Murphy (2): power_supply: Add additional health properties to the header dt-bindings: power: Convert battery.txt to battery.yaml Ricardo Rivera-Matos (2): dt-bindings: power: Add the bindings for the bq2515x family of chargers. power: supply: bq25150 introduce the bq25150 Documentation/ABI/testing/sysfs-class-power |3 +- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 +++ .../bindings/power/supply/bq2515x.yaml| 93 ++ drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c| 1169 + drivers/power/supply/power_supply_sysfs.c |3 + include/linux/power_supply.h |3 + 9 files changed, 1442 insertions(+), 86 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml create mode 100644 drivers/power/supply/bq2515x_charger.c -- 2.27.0
[PATCH v17 3/4] dt-bindings: power: Add the bindings for the bq2515x family of chargers.
The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: http://www.ti.com/lit/ds/symlink/bq25150.pdf http://www.ti.com/lit/ds/symlink/bq25155.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq2515x.yaml| 93 +++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq2515x.yaml b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file mode 100644 index ..75a56773be4a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq2515x 500-mA Linear charger family + +maintainers: + - Dan Murphy + - Ricardo Rivera-Matos + +description: | + The BQ2515x family is a highly integrated battery charge management IC that + integrates the most common functions for wearable devices, namely a charger, + an output voltage rail, ADC for battery and system monitoring, and + push-button controller. + + Specifications about the charger can be found at: +http://www.ti.com/lit/ds/symlink/bq25150.pdf +http://www.ti.com/lit/ds/symlink/bq25155.pdf + +properties: + compatible: +enum: + - ti,bq25150 + - ti,bq25155 + + reg: +maxItems: 1 +description: I2C address of the charger. + + ac-detect-gpios: +description: | + GPIO used for connecting the bq2515x device PG (AC Detect) + pin. +maxItems: 1 + + reset-gpios: +description: GPIO used for hardware reset. +maxItems: 1 + + powerdown-gpios: +description: GPIO used for low power mode of IC. +maxItems: 1 + + charge-enable-gpios: +description: GPIO used to turn on and off charging. +maxItems: 1 + + input-current-limit-microamp: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Maximum input current in micro Amps. +minimum: 5 +maximum: 50 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <5>; + precharge-current-microamp = <2500>; + constant-charge-voltage-max-microvolt = <400>; +}; +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25150: charger@6b { +compatible = "ti,bq25150"; +reg = <0x6b>; +monitored-battery = <>; +input-current-limit-microamp = <10>; + +ac-detect-gpios = < 28 GPIO_ACTIVE_HIGH>; +reset-gpios = < 14 GPIO_ACTIVE_HIGH>; +powerdown-gpios = < 15 GPIO_ACTIVE_HIGH>; +charge-enable-gpios = < 13 GPIO_ACTIVE_LOW>; + }; +}; -- 2.27.0
[PATCH v17 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 ++ 2 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..a9f80cc49068 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,87 +1,3 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. +The contents of this file has been moved to battery.yaml Please note that not all charger drivers respect all of the properties. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - over-voltage-threshold-microvolt: battery over-voltage limit - - re-charge-voltage-microvolt: limit to automatically start charging again - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - trickle-charge-current-microamp: current for trickle-charge phase - - precharge-current-microamp: current for pre-charge phase - - precharge-upper-limit-microvolt: limit when to change to constant charging - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge: fuel-gauge@22 { -
[PATCH v17 4/4] power: supply: bq25150 introduce the bq25150
Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1169 3 files changed, 1183 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..faf2830aa152 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -610,6 +610,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..b3c694a65114 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..63e8e317af56 --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1169 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#define BQ2515X_TS_HOT 0x65 +#define BQ2515X_DEVICE_ID 0x6f + +#define BQ2515X_DEFAULT_ICHG_UA1 +#
[PATCH v17 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from JEITA specification JISC8712:2015 Acked-by: Andrew F. Davis Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 3 ++- drivers/power/supply/power_supply_sysfs.c | 3 +++ include/linux/power_supply.h| 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 216d61a22f1e..40213c73bc9c 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -205,7 +205,8 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current", "Calibration required" + "Over current", "Calibration required", "Warm", + "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index bc79560229b5..4d6e1d5015d6 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -101,6 +101,9 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE] = "Safety timer expire", [POWER_SUPPLY_HEALTH_OVERCURRENT] = "Over current", [POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED] = "Calibration required", + [POWER_SUPPLY_HEALTH_WARM] = "Warm", + [POWER_SUPPLY_HEALTH_COOL] = "Cool", + [POWER_SUPPLY_HEALTH_HOT] = "Hot", }; static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ac1345a48ad0..b5ee35d3c304 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -62,6 +62,9 @@ enum { POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.27.0
Re: [EXTERNAL] Re: [PATCH v16 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
On 7/9/20 2:35 PM, Rob Herring wrote: On Tue, Jul 07, 2020 at 04:29:12PM -0500, Ricardo Rivera-Matos wrote: From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 ++ 2 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..a9f80cc49068 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,87 +1,3 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. +The contents of this file has been moved to battery.yaml Please note that not all charger drivers respect all of the properties. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - over-voltage-threshold-microvolt: battery over-voltage limit - - re-charge-voltage-microvolt: limit to automatically start charging again - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - trickle-charge-current-microamp: current for trickle-charge phase - - precharge-current-microamp: current for pre-charge phase - - precharge-upper-limit-microvolt: limit when to change to constant charging - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, &
[PATCH v16 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from JEITA specification JISC8712:2015 Acked-by: Andrew F. Davis Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 3 ++- drivers/power/supply/power_supply_sysfs.c | 3 +++ include/linux/power_supply.h| 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 216d61a22f1e..40213c73bc9c 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -205,7 +205,8 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current", "Calibration required" + "Over current", "Calibration required", "Warm", + "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index bc79560229b5..4d6e1d5015d6 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -101,6 +101,9 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE] = "Safety timer expire", [POWER_SUPPLY_HEALTH_OVERCURRENT] = "Over current", [POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED] = "Calibration required", + [POWER_SUPPLY_HEALTH_WARM] = "Warm", + [POWER_SUPPLY_HEALTH_COOL] = "Cool", + [POWER_SUPPLY_HEALTH_HOT] = "Hot", }; static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ac1345a48ad0..b5ee35d3c304 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -62,6 +62,9 @@ enum { POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.27.0
[PATCH v16 4/4] power: supply: bq25150 introduce the bq25150
Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1169 3 files changed, 1183 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..faf2830aa152 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -610,6 +610,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..b3c694a65114 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..63e8e317af56 --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1169 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#define BQ2515X_TS_HOT 0x65 +#define BQ2515X_DEVICE_ID 0x6f + +#define BQ2515X_DEFAULT_ICHG_UA1 +#
[PATCH v16 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 ++ 2 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..a9f80cc49068 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,87 +1,3 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. +The contents of this file has been moved to battery.yaml Please note that not all charger drivers respect all of the properties. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - over-voltage-threshold-microvolt: battery over-voltage limit - - re-charge-voltage-microvolt: limit to automatically start charging again - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - trickle-charge-current-microamp: current for trickle-charge phase - - precharge-current-microamp: current for pre-charge phase - - precharge-upper-limit-microvolt: limit when to change to constant charging - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge: fuel-gauge@22 { -
[PATCH v16 3/4] dt-bindings: power: Add the bindings for the bq2515x family of chargers.
The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: http://www.ti.com/lit/ds/symlink/bq25150.pdf http://www.ti.com/lit/ds/symlink/bq25155.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq2515x.yaml| 93 +++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq2515x.yaml b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file mode 100644 index ..75a56773be4a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq2515x 500-mA Linear charger family + +maintainers: + - Dan Murphy + - Ricardo Rivera-Matos + +description: | + The BQ2515x family is a highly integrated battery charge management IC that + integrates the most common functions for wearable devices, namely a charger, + an output voltage rail, ADC for battery and system monitoring, and + push-button controller. + + Specifications about the charger can be found at: +http://www.ti.com/lit/ds/symlink/bq25150.pdf +http://www.ti.com/lit/ds/symlink/bq25155.pdf + +properties: + compatible: +enum: + - ti,bq25150 + - ti,bq25155 + + reg: +maxItems: 1 +description: I2C address of the charger. + + ac-detect-gpios: +description: | + GPIO used for connecting the bq2515x device PG (AC Detect) + pin. +maxItems: 1 + + reset-gpios: +description: GPIO used for hardware reset. +maxItems: 1 + + powerdown-gpios: +description: GPIO used for low power mode of IC. +maxItems: 1 + + charge-enable-gpios: +description: GPIO used to turn on and off charging. +maxItems: 1 + + input-current-limit-microamp: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Maximum input current in micro Amps. +minimum: 5 +maximum: 50 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <5>; + precharge-current-microamp = <2500>; + constant-charge-voltage-max-microvolt = <400>; +}; +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25150: charger@6b { +compatible = "ti,bq25150"; +reg = <0x6b>; +monitored-battery = <>; +input-current-limit-microamp = <10>; + +ac-detect-gpios = < 28 GPIO_ACTIVE_HIGH>; +reset-gpios = < 14 GPIO_ACTIVE_HIGH>; +powerdown-gpios = < 15 GPIO_ACTIVE_HIGH>; +charge-enable-gpios = < 13 GPIO_ACTIVE_LOW>; + }; +}; -- 2.27.0
[PATCH v16 0/4] Add JEITA properties and introduce the bq2515x charger
Hello, This patchset adds additional health properties to the power_supply header. These additional properties are taken from the JEITA specification. This patchset also introduces the bq2515x family of charging ICs. Dan Murphy (2): power_supply: Add additional health properties to the header dt-bindings: power: Convert battery.txt to battery.yaml Ricardo Rivera-Matos (2): dt-bindings: power: Add the bindings for the bq2515x family of chargers. power: supply: bq25150 introduce the bq25150 Documentation/ABI/testing/sysfs-class-power |3 +- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 +++ .../bindings/power/supply/bq2515x.yaml| 93 ++ drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c| 1169 + drivers/power/supply/power_supply_sysfs.c |3 + include/linux/power_supply.h |3 + 9 files changed, 1442 insertions(+), 86 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml create mode 100644 drivers/power/supply/bq2515x_charger.c -- 2.27.0
Re: [EXTERNAL] Re: [PATCH v15 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
On 7/7/20 9:40 AM, Rob Herring wrote: On Mon, Jul 6, 2020 at 12:45 PM Ricardo Rivera-Matos wrote: Rob On 7/2/20 3:53 PM, Rob Herring wrote: On Wed, 01 Jul 2020 16:10:42 -0500, Ricardo Rivera-Matos wrote: From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 ++ 2 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml My bot found errors running 'make dt_binding_check' on your patch: Unknown file referenced: [Errno 2] No such file or directory: '/usr/local/lib/python3.6/dist-packages/dtschema/schema/types.yaml' Documentation/devicetree/bindings/Makefile:20: recipe for target 'Documentation/devicetree/bindings/power/supply/battery.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/power/supply/battery.example.dts] Error 255 make[1]: *** Waiting for unfinished jobs Makefile:1347: recipe for target 'dt_binding_check' failed make: *** [dt_binding_check] Error 2 I think your bot is looking for the types.yaml in the wrong place. Really? Yet it works fine on thousands of other patches? '/usr/local/lib/python3.6/dist-packages/dtschema/schema/types.yaml' should be '/usr/local/lib/python3.6/dist-packages/dtschema/schemas/types.yaml'. I renamed might 'schemas' directory to 'schema' and my battery.yaml passed the dt_binding_check. Maybe fix the 'schema/' path in your schema file which is wrong. Oh I see. My apologies, Rob. Rob
Re: [EXTERNAL] Re: [PATCH v15 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
Rob On 7/2/20 3:53 PM, Rob Herring wrote: On Wed, 01 Jul 2020 16:10:42 -0500, Ricardo Rivera-Matos wrote: From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 ++ 2 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml My bot found errors running 'make dt_binding_check' on your patch: Unknown file referenced: [Errno 2] No such file or directory: '/usr/local/lib/python3.6/dist-packages/dtschema/schema/types.yaml' Documentation/devicetree/bindings/Makefile:20: recipe for target 'Documentation/devicetree/bindings/power/supply/battery.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/power/supply/battery.example.dts] Error 255 make[1]: *** Waiting for unfinished jobs Makefile:1347: recipe for target 'dt_binding_check' failed make: *** [dt_binding_check] Error 2 I think your bot is looking for the types.yaml in the wrong place. '/usr/local/lib/python3.6/dist-packages/dtschema/schema/types.yaml' should be '/usr/local/lib/python3.6/dist-packages/dtschema/schemas/types.yaml'. I renamed might 'schemas' directory to 'schema' and my battery.yaml passed the dt_binding_check. See https://patchwork.ozlabs.org/patch/1320813 If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date: pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade Confirmed on latest dt-schema Please check and re-submit. Thanks, Ricardo
[PATCH v15 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 ++ 2 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..a9f80cc49068 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,87 +1,3 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. +The contents of this file has been moved to battery.yaml Please note that not all charger drivers respect all of the properties. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - over-voltage-threshold-microvolt: battery over-voltage limit - - re-charge-voltage-microvolt: limit to automatically start charging again - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - trickle-charge-current-microamp: current for trickle-charge phase - - precharge-current-microamp: current for pre-charge phase - - precharge-upper-limit-microvolt: limit when to change to constant charging - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge: fuel-gauge@22 { -
[PATCH v15 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from JEITA specification JISC8712:2015 Acked-by: Andrew F. Davis Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 3 ++- drivers/power/supply/power_supply_sysfs.c | 3 +++ include/linux/power_supply.h| 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 216d61a22f1e..40213c73bc9c 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -205,7 +205,8 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current", "Calibration required" + "Over current", "Calibration required", "Warm", + "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index bc79560229b5..4d6e1d5015d6 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -101,6 +101,9 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE] = "Safety timer expire", [POWER_SUPPLY_HEALTH_OVERCURRENT] = "Over current", [POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED] = "Calibration required", + [POWER_SUPPLY_HEALTH_WARM] = "Warm", + [POWER_SUPPLY_HEALTH_COOL] = "Cool", + [POWER_SUPPLY_HEALTH_HOT] = "Hot", }; static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ac1345a48ad0..b5ee35d3c304 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -62,6 +62,9 @@ enum { POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.27.0
[PATCH v15 0/4] Add JEITA properties and introduce the bq2515x charger
Hello, This patchset adds additional health properties to the power_supply header. These additional properties are taken from the JEITA specification. This patchset also introduces the bq2515x family of charging ICs. Dan Murphy (2): power_supply: Add additional health properties to the header dt-bindings: power: Convert battery.txt to battery.yaml Ricardo Rivera-Matos (2): dt-bindings: power: Add the bindings for the bq2515x family of chargers. power: supply: bq25150 introduce the bq25150 Documentation/ABI/testing/sysfs-class-power |3 +- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 +++ .../bindings/power/supply/bq2515x.yaml| 93 ++ drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c| 1169 + drivers/power/supply/power_supply_sysfs.c |3 + include/linux/power_supply.h |3 + 9 files changed, 1442 insertions(+), 86 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml create mode 100644 drivers/power/supply/bq2515x_charger.c -- 2.27.0
[PATCH v15 4/4] power: supply: bq25150 introduce the bq25150
Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1169 3 files changed, 1183 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..faf2830aa152 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -610,6 +610,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..b3c694a65114 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..63e8e317af56 --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1169 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#define BQ2515X_TS_HOT 0x65 +#define BQ2515X_DEVICE_ID 0x6f + +#define BQ2515X_DEFAULT_ICHG_UA1 +#
[PATCH v15 3/4] dt-bindings: power: Add the bindings for the bq2515x family of chargers.
The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: http://www.ti.com/lit/ds/symlink/bq25150.pdf http://www.ti.com/lit/ds/symlink/bq25155.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq2515x.yaml| 93 +++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq2515x.yaml b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file mode 100644 index ..75a56773be4a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq2515x 500-mA Linear charger family + +maintainers: + - Dan Murphy + - Ricardo Rivera-Matos + +description: | + The BQ2515x family is a highly integrated battery charge management IC that + integrates the most common functions for wearable devices, namely a charger, + an output voltage rail, ADC for battery and system monitoring, and + push-button controller. + + Specifications about the charger can be found at: +http://www.ti.com/lit/ds/symlink/bq25150.pdf +http://www.ti.com/lit/ds/symlink/bq25155.pdf + +properties: + compatible: +enum: + - ti,bq25150 + - ti,bq25155 + + reg: +maxItems: 1 +description: I2C address of the charger. + + ac-detect-gpios: +description: | + GPIO used for connecting the bq2515x device PG (AC Detect) + pin. +maxItems: 1 + + reset-gpios: +description: GPIO used for hardware reset. +maxItems: 1 + + powerdown-gpios: +description: GPIO used for low power mode of IC. +maxItems: 1 + + charge-enable-gpios: +description: GPIO used to turn on and off charging. +maxItems: 1 + + input-current-limit-microamp: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Maximum input current in micro Amps. +minimum: 5 +maximum: 50 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <5>; + precharge-current-microamp = <2500>; + constant-charge-voltage-max-microvolt = <400>; +}; +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25150: charger@6b { +compatible = "ti,bq25150"; +reg = <0x6b>; +monitored-battery = <>; +input-current-limit-microamp = <10>; + +ac-detect-gpios = < 28 GPIO_ACTIVE_HIGH>; +reset-gpios = < 14 GPIO_ACTIVE_HIGH>; +powerdown-gpios = < 15 GPIO_ACTIVE_HIGH>; +charge-enable-gpios = < 13 GPIO_ACTIVE_LOW>; + }; +}; -- 2.27.0
Re: [EXTERNAL] Re: [PATCH v14 4/4] power: supply: bq25150 introduce the bq25150
On 6/30/20 6:33 PM, Sebastian Reichel wrote: Hi, On Tue, Jun 30, 2020 at 04:54:26PM -0500, Ricardo Rivera-Matos wrote: Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1158 3 files changed, 1172 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..faf2830aa152 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -610,6 +610,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..b3c694a65114 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090)+= tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..f386484b5035 --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1158 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#defi
[PATCH v14 3/4] dt-bindings: power: Add the bindings for the bq2515x family of chargers.
The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: http://www.ti.com/lit/ds/symlink/bq25150.pdf http://www.ti.com/lit/ds/symlink/bq25155.pdf Reviewed-by: Rob Herring Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq2515x.yaml| 93 +++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq2515x.yaml b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file mode 100644 index ..75a56773be4a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq2515x 500-mA Linear charger family + +maintainers: + - Dan Murphy + - Ricardo Rivera-Matos + +description: | + The BQ2515x family is a highly integrated battery charge management IC that + integrates the most common functions for wearable devices, namely a charger, + an output voltage rail, ADC for battery and system monitoring, and + push-button controller. + + Specifications about the charger can be found at: +http://www.ti.com/lit/ds/symlink/bq25150.pdf +http://www.ti.com/lit/ds/symlink/bq25155.pdf + +properties: + compatible: +enum: + - ti,bq25150 + - ti,bq25155 + + reg: +maxItems: 1 +description: I2C address of the charger. + + ac-detect-gpios: +description: | + GPIO used for connecting the bq2515x device PG (AC Detect) + pin. +maxItems: 1 + + reset-gpios: +description: GPIO used for hardware reset. +maxItems: 1 + + powerdown-gpios: +description: GPIO used for low power mode of IC. +maxItems: 1 + + charge-enable-gpios: +description: GPIO used to turn on and off charging. +maxItems: 1 + + input-current-limit-microamp: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Maximum input current in micro Amps. +minimum: 5 +maximum: 50 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <5>; + precharge-current-microamp = <2500>; + constant-charge-voltage-max-microvolt = <400>; +}; +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25150: charger@6b { +compatible = "ti,bq25150"; +reg = <0x6b>; +monitored-battery = <>; +input-current-limit-microamp = <10>; + +ac-detect-gpios = < 28 GPIO_ACTIVE_HIGH>; +reset-gpios = < 14 GPIO_ACTIVE_HIGH>; +powerdown-gpios = < 15 GPIO_ACTIVE_HIGH>; +charge-enable-gpios = < 13 GPIO_ACTIVE_LOW>; + }; +}; -- 2.27.0
[PATCH v14 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 ++ 2 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..a9f80cc49068 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,87 +1,3 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. +The contents of this file has been moved to battery.yaml Please note that not all charger drivers respect all of the properties. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - over-voltage-threshold-microvolt: battery over-voltage limit - - re-charge-voltage-microvolt: limit to automatically start charging again - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - trickle-charge-current-microamp: current for trickle-charge phase - - precharge-current-microamp: current for pre-charge phase - - precharge-upper-limit-microvolt: limit when to change to constant charging - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge: fuel-gauge@22 { -
[PATCH v14 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from JEITA specification JISC8712:2015 Acked-by: Andrew F. Davis Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 3 ++- drivers/power/supply/power_supply_sysfs.c | 3 +++ include/linux/power_supply.h| 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 216d61a22f1e..40213c73bc9c 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -205,7 +205,8 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current", "Calibration required" + "Over current", "Calibration required", "Warm", + "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index bc79560229b5..4d6e1d5015d6 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -101,6 +101,9 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE] = "Safety timer expire", [POWER_SUPPLY_HEALTH_OVERCURRENT] = "Over current", [POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED] = "Calibration required", + [POWER_SUPPLY_HEALTH_WARM] = "Warm", + [POWER_SUPPLY_HEALTH_COOL] = "Cool", + [POWER_SUPPLY_HEALTH_HOT] = "Hot", }; static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ac1345a48ad0..b5ee35d3c304 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -62,6 +62,9 @@ enum { POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.27.0
[PATCH v14 4/4] power: supply: bq25150 introduce the bq25150
Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1158 3 files changed, 1172 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..faf2830aa152 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -610,6 +610,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..b3c694a65114 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..f386484b5035 --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1158 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#define BQ2515X_TS_HOT 0x65 +#define BQ2515X_DEVICE_ID 0x6f + +#define BQ2515X_DEFAULT_ICHG_UA1 +#
[PATCH v14 0/4] Add JEITA properties and introduce the bq2515x charger
Hello, This patchset adds additional health properties to the power_supply header. These additional properties are taken from the JEITA specification. This patchset also introduces the bq2515x family of charging ICs. Dan Murphy (2): power_supply: Add additional health properties to the header dt-bindings: power: Convert battery.txt to battery.yaml Ricardo Rivera-Matos (2): dt-bindings: power: Add the bindings for the bq2515x family of chargers. power: supply: bq25150 introduce the bq25150 Documentation/ABI/testing/sysfs-class-power |3 +- .../bindings/power/supply/battery.txt | 86 +- .../bindings/power/supply/battery.yaml| 157 +++ .../bindings/power/supply/bq2515x.yaml| 93 ++ drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c| 1158 + drivers/power/supply/power_supply_sysfs.c |3 + include/linux/power_supply.h |3 + 9 files changed, 1431 insertions(+), 86 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml create mode 100644 drivers/power/supply/bq2515x_charger.c -- 2.27.0
[PATCH v13 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from JEITA specification JISC8712:2015 Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 3 ++- drivers/power/supply/power_supply_sysfs.c | 3 +++ include/linux/power_supply.h| 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 216d61a22f1e..40213c73bc9c 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -205,7 +205,8 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current", "Calibration required" + "Over current", "Calibration required", "Warm", + "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index bc79560229b5..4d6e1d5015d6 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -101,6 +101,9 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE] = "Safety timer expire", [POWER_SUPPLY_HEALTH_OVERCURRENT] = "Over current", [POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED] = "Calibration required", + [POWER_SUPPLY_HEALTH_WARM] = "Warm", + [POWER_SUPPLY_HEALTH_COOL] = "Cool", + [POWER_SUPPLY_HEALTH_HOT] = "Hot", }; static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ac1345a48ad0..b5ee35d3c304 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -62,6 +62,9 @@ enum { POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.27.0
[PATCH v13 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 83 +-- .../bindings/power/supply/battery.yaml| 139 ++ 2 files changed, 141 insertions(+), 81 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..4c5216fcb760 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,87 +1,8 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. +The contents of this file has been moved to battery.yaml Please note that not all charger drivers respect all of the properties. -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - over-voltage-threshold-microvolt: battery over-voltage limit - re-charge-voltage-microvolt: limit to automatically start charging again - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - trickle-charge-current-microamp: current for trickle-charge phase - - precharge-current-microamp: current for pre-charge phase - - precharge-upper-limit-microvolt: limit when to change to constant charging - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge: fuel-gauge@22 { -
[PATCH v13 4/4] power: supply: bq25150 introduce the bq25150
Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1158 3 files changed, 1172 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 44d3c8512fb8..faf2830aa152 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -610,6 +610,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index b9644663e435..b3c694a65114 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..f386484b5035 --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1158 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#define BQ2515X_TS_HOT 0x65 +#define BQ2515X_DEVICE_ID 0x6f + +#define BQ2515X_DEFAULT_ICHG_UA1 +#
[PATCH v13 3/4] dt-bindings: power: Add the bindings for the bq2515x family of chargers.
The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: http://www.ti.com/lit/ds/symlink/bq25150.pdf http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq2515x.yaml| 93 +++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq2515x.yaml b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file mode 100644 index ..75a56773be4a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq2515x 500-mA Linear charger family + +maintainers: + - Dan Murphy + - Ricardo Rivera-Matos + +description: | + The BQ2515x family is a highly integrated battery charge management IC that + integrates the most common functions for wearable devices, namely a charger, + an output voltage rail, ADC for battery and system monitoring, and + push-button controller. + + Specifications about the charger can be found at: +http://www.ti.com/lit/ds/symlink/bq25150.pdf +http://www.ti.com/lit/ds/symlink/bq25155.pdf + +properties: + compatible: +enum: + - ti,bq25150 + - ti,bq25155 + + reg: +maxItems: 1 +description: I2C address of the charger. + + ac-detect-gpios: +description: | + GPIO used for connecting the bq2515x device PG (AC Detect) + pin. +maxItems: 1 + + reset-gpios: +description: GPIO used for hardware reset. +maxItems: 1 + + powerdown-gpios: +description: GPIO used for low power mode of IC. +maxItems: 1 + + charge-enable-gpios: +description: GPIO used to turn on and off charging. +maxItems: 1 + + input-current-limit-microamp: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Maximum input current in micro Amps. +minimum: 5 +maximum: 50 + + monitored-battery: +$ref: /schemas/types.yaml#/definitions/phandle +description: phandle to the battery node being monitored + +required: + - compatible + - reg + - monitored-battery + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <5>; + precharge-current-microamp = <2500>; + constant-charge-voltage-max-microvolt = <400>; +}; +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25150: charger@6b { +compatible = "ti,bq25150"; +reg = <0x6b>; +monitored-battery = <>; +input-current-limit-microamp = <10>; + +ac-detect-gpios = < 28 GPIO_ACTIVE_HIGH>; +reset-gpios = < 14 GPIO_ACTIVE_HIGH>; +powerdown-gpios = < 15 GPIO_ACTIVE_HIGH>; +charge-enable-gpios = < 13 GPIO_ACTIVE_LOW>; + }; +}; -- 2.27.0
[PATCH v13 0/4] Add JEITA properties and introduce the bq2515x charger
This patchset adds additional health properties to the power_supply header. These additional properties are taken from the JEITA specification. This patchset also introduces the bq2515x family of charging ICs. Dan Murphy (2): power_supply: Add additional health properties to the header dt-bindings: power: Convert battery.txt to battery.yaml Ricardo Rivera-Matos (2): dt-bindings: power: Add the bindings for the bq2515x family of chargers. power: supply: bq25150 introduce the bq25150 Documentation/ABI/testing/sysfs-class-power |3 +- .../bindings/power/supply/battery.txt | 83 +- .../bindings/power/supply/battery.yaml| 139 ++ .../bindings/power/supply/bq2515x.yaml| 93 ++ drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c| 1158 + drivers/power/supply/power_supply_sysfs.c |3 + include/linux/power_supply.h |3 + 9 files changed, 1414 insertions(+), 82 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml create mode 100644 drivers/power/supply/bq2515x_charger.c -- 2.27.0
Re: [EXTERNAL] Re: [PATCH v12 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
On 5/29/20 5:16 PM, Rob Herring wrote: On Thu, May 28, 2020 at 05:53:48PM -0500, Ricardo Rivera-Matos wrote: From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 82 +- .../bindings/power/supply/battery.yaml| 143 ++ 2 files changed, 144 insertions(+), 81 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 3049cf88bdcf..b9a81621ce59 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,81 +1 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - precharge-current-microamp: current for pre-charge phase - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge: fuel-gauge@22 { - - monitored-battery = <>; - ... - }; +The contents of this file has been moved to battery.
[PATCH v12 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 82 +- .../bindings/power/supply/battery.yaml| 143 ++ 2 files changed, 144 insertions(+), 81 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 3049cf88bdcf..b9a81621ce59 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,81 +1 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - precharge-current-microamp: current for pre-charge phase - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge: fuel-gauge@22 { - - monitored-battery = <>; - ... - }; +The contents of this file has been moved to battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.yaml b/Documentation/devicetree/bindings/power/supply/battery.yaml new file mode 100644 index ..f0b544a22219 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/battery.yaml @@ -0,0 +1,143 @@ +#
[PATCH v12 0/4] Add JEITA properties and introduce the bq2515x charger
Hello, This patchset adds additional health properties to the power_supply header. These additional properties are taken from the JEITA specification. This patchset also introduces the bq2515x family of charging ICs. Dan Murphy (2): power_supply: Add additional health properties to the header dt-bindings: power: Convert battery.txt to battery.yaml Ricardo Rivera-Matos (2): dt-bindings: power: Add the bindings for the bq2515x family of chargers. power: supply: bq25150 introduce the bq25150 Documentation/ABI/testing/sysfs-class-power |2 +- .../bindings/power/supply/battery.txt | 82 +- .../bindings/power/supply/battery.yaml| 143 ++ .../bindings/power/supply/bq2515x.yaml| 91 ++ drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c| 1158 + drivers/power/supply/power_supply_sysfs.c |2 +- include/linux/power_supply.h |3 + 9 files changed, 1412 insertions(+), 83 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml create mode 100644 drivers/power/supply/bq2515x_charger.c -- 2.26.2
[PATCH v12 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from JEITA specification JISC8712:2015 Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 2 +- drivers/power/supply/power_supply_sysfs.c | 2 +- include/linux/power_supply.h| 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index bf3b48f022dc..9f3fd01a9373 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -190,7 +190,7 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current" + "Over current", "Warm", "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index f37ad4eae60b..d0d549611794 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -61,7 +61,7 @@ static const char * const power_supply_charge_type_text[] = { static const char * const power_supply_health_text[] = { "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", - "Safety timer expire", "Over current" + "Safety timer expire", "Over current", "Warm", "Cool", "Hot" }; static const char * const power_supply_technology_text[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index dcd5a71e6c67..8670e90c1d51 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -61,6 +61,9 @@ enum { POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.26.2
[PATCH v12 4/4] power: supply: bq25150 introduce the bq25150
Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1158 3 files changed, 1172 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index f3424fdce341..266193301e2d 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -589,6 +589,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index 6c7da920ea83..8fcc175a7e22 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..f386484b5035 --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1158 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#define BQ2515X_TS_HOT 0x65 +#define BQ2515X_DEVICE_ID 0x6f + +#define BQ2515X_DEFAULT_ICHG_UA1 +#
[PATCH v12 3/4] dt-bindings: power: Add the bindings for the bq2515x family of chargers.
The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: http://www.ti.com/lit/ds/symlink/bq25150.pdf http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq2515x.yaml| 91 +++ 1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq2515x.yaml b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file mode 100644 index ..19cb336d581e --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml @@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq2515x 500-mA Linear charger family + +maintainers: + - Dan Murphy + - Ricardo Rivera-Matos + +description: | + The BQ2515x family is a highly integrated battery charge management IC that + integrates the most common functions for wearable devices, namely a charger, + an output voltage rail, ADC for battery and system monitoring, and + push-button controller. + + Specifications about the charger can be found at: +http://www.ti.com/lit/ds/symlink/bq25150.pdf +http://www.ti.com/lit/ds/symlink/bq25155.pdf + +properties: + compatible: +enum: + - ti,bq25150 + - ti,bq25155 + + reg: +maxItems: 1 +description: I2C address of the charger. + + ac-detect-gpios: +description: | + GPIO used for connecting the bq2515x device PG (AC Detect) + pin. +maxItems: 1 + + reset-gpios: +description: GPIO used for hardware reset. +maxItems: 1 + + powerdown-gpios: +description: GPIO used for low power mode of IC. +maxItems: 1 + + charge-enable-gpios: +description: GPIO used to turn on and off charging. +maxItems: 1 + + input-current-limit-microamp: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Maximum input current in micro Amps. +minimum: 5 +maximum: 50 + + monitored-battery: +$ref: battery.yaml# + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <5>; + precharge-current-microamp = <2500>; + constant-charge-voltage-max-microvolt = <400>; +}; +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25150: charger@6b { +compatible = "ti,bq25150"; +reg = <0x6b>; +monitored-battery = <>; +input-current-limit-microamp = <10>; + +ac-detect-gpios = < 28 GPIO_ACTIVE_HIGH>; +reset-gpios = < 14 GPIO_ACTIVE_HIGH>; +powerdown-gpios = < 15 GPIO_ACTIVE_HIGH>; +charge-enable-gpios = < 13 GPIO_ACTIVE_LOW>; + }; +}; -- 2.26.2
Re: [PATCH v11 1/4] power_supply: Add additional health properties to the header
On 5/28/20 9:16 AM, Andrew F. Davis wrote: On 5/28/20 10:05 AM, Ricardo Rivera-Matos wrote: From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from the JEITA spec. Wouldn't hurt to list the specific version of the spec these are from, but not super important, Acked-by: Andrew F. Davis ACK. This originates from JISC8712:2015, but is more succinctly explained in "A Guide to the Safe Use of Secondary Lithium Ion Batteries in Notebook-type Personal Computer" Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 2 +- drivers/power/supply/power_supply_sysfs.c | 2 +- include/linux/power_supply.h| 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index bf3b48f022dc..9f3fd01a9373 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -190,7 +190,7 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current" + "Over current", "Warm", "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index f37ad4eae60b..d0d549611794 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -61,7 +61,7 @@ static const char * const power_supply_charge_type_text[] = { static const char * const power_supply_health_text[] = { "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", - "Safety timer expire", "Over current" + "Safety timer expire", "Over current", "Warm", "Cool", "Hot" }; static const char * const power_supply_technology_text[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index dcd5a71e6c67..8670e90c1d51 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -61,6 +61,9 @@ enum { POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum {
Re: [PATCH v11 4/4] power: supply: bq25150 introduce the bq25150
On 5/28/20 9:43 AM, Andrew F. Davis wrote: On 5/28/20 10:05 AM, Ricardo Rivera-Matos wrote: +static int bq2515x_set_precharge_current(struct bq2515x_device *bq2515x, + int val) +{ + int ret; + unsigned int pchrgctrl; + unsigned int icharge_range; + unsigned int precharge_reg_code; + u16 precharge_multiplier = BQ2515X_ICHG_RNG_1B0_UA; + u16 precharge_max_ua = BQ2515X_PRECHRG_ICHRG_RNGE_1875_UA; Why u16? looks like it gets promoted everywhere it's used anyway. ACK + + ret = regmap_read(bq2515x->regmap, BQ2515X_PCHRGCTRL, ); + if (ret) + return ret; + + icharge_range = pchrgctrl & BQ2515X_ICHARGE_RANGE; + + if (icharge_range) { + precharge_max_ua = BQ2515X_PRECHRG_ICHRG_RNGE_3750_UA; + precharge_multiplier = BQ2515X_ICHG_RNG_1B1_UA; This is a little hard to read when we have a default value overwritten in an if, it basically hides the else logic, suggest: if (icharge_range) { precharge_max_ua = BQ2515X_PRECHRG_ICHRG_RNGE_3750_UA; precharge_multiplier = BQ2515X_ICHG_RNG_1B1_UA; } else { precharge_max_ua = BQ2515X_PRECHRG_ICHRG_RNGE_1875_UA; precharge_multiplier = BQ2515X_ICHG_RNG_1B0_UA; } ACK. I originally had it as an if/else deal, but I got feedback it was too verbose. It will stay verbose. + } + if (val > precharge_max_ua || val < BQ2515X_ICHG_MIN_UA) + return -EINVAL; + + precharge_reg_code = val / precharge_multiplier; + + ret = bq2515x_set_charge_disable(bq2515x, 1); + if (ret) + return ret; + + ret = regmap_update_bits(bq2515x->regmap, BQ2515X_PCHRGCTRL, + BQ2515X_PRECHARGE_MASK, precharge_reg_code); + if (ret) + return ret; + + return bq2515x_set_charge_disable(bq2515x, 0); +} [snip] + +static int bq2515x_set_ilim_lvl(struct bq2515x_device *bq2515x, int val) +{ + int i = 0; + unsigned int array_size = ARRAY_SIZE(bq2515x_ilim_lvl_values); + + if (val >= bq2515x_ilim_lvl_values[array_size - 1]) { Isn't this check the same as is done in first iteration of the below loop? Andrew ACK + i = array_size - 1; + } else { + for (i = array_size - 1; i > 0; i--) { + if (val >= bq2515x_ilim_lvl_values[i]) + break; + } + } + return regmap_write(bq2515x->regmap, BQ2515X_ILIMCTRL, i); +} +
[PATCH v11 2/4] dt-bindings: power: Convert battery.txt to battery.yaml
From: Dan Murphy Convert the battery.txt file to yaml and fix up the examples. Signed-off-by: Dan Murphy --- .../bindings/power/supply/battery.txt | 82 +- .../bindings/power/supply/battery.yaml| 143 ++ 2 files changed, 144 insertions(+), 81 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 3049cf88bdcf..b9a81621ce59 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -1,81 +1 @@ -Battery Characteristics - -The devicetree battery node provides static battery characteristics. -In smart batteries, these are typically stored in non-volatile memory -on a fuel gauge chip. The battery node should be used where there is -no appropriate non-volatile memory, or it is unprogrammed/incorrect. - -Upstream dts files should not include battery nodes, unless the battery -represented cannot easily be replaced in the system by one of a -different type. This prevents unpredictable, potentially harmful, -behavior should a replacement that changes the battery type occur -without a corresponding update to the dtb. - -Required Properties: - - compatible: Must be "simple-battery" - -Optional Properties: - - voltage-min-design-microvolt: drained battery voltage - - voltage-max-design-microvolt: fully charged battery voltage - - energy-full-design-microwatt-hours: battery design energy - - charge-full-design-microamp-hours: battery design capacity - - precharge-current-microamp: current for pre-charge phase - - charge-term-current-microamp: current for charge termination phase - - constant-charge-current-max-microamp: maximum constant input current - - constant-charge-voltage-max-microvolt: maximum constant input voltage - - factory-internal-resistance-micro-ohms: battery factory internal resistance - - ocv-capacity-table-0: An array providing the open circuit voltage (OCV) - of the battery and corresponding battery capacity percent, which is used - to look up battery capacity according to current OCV value. And the open - circuit voltage unit is microvolt. - - ocv-capacity-table-1: Same as ocv-capacity-table-0 - .. - - ocv-capacity-table-n: Same as ocv-capacity-table-0 - - ocv-capacity-celsius: An array containing the temperature in degree Celsius, - for each of the battery capacity lookup table. The first temperature value - specifies the OCV table 0, and the second temperature value specifies the - OCV table 1, and so on. - - resistance-temp-table: An array providing the temperature in degree Celsius - and corresponding battery internal resistance percent, which is used to look - up the resistance percent according to current temperature to get a accurate - batterty internal resistance in different temperatures. - -Battery properties are named, where possible, for the corresponding -elements in enum power_supply_property, defined in -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/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 = "simple-battery"; - voltage-min-design-microvolt = <320>; - voltage-max-design-microvolt = <420>; - energy-full-design-microwatt-hours = <529>; - charge-full-design-microamp-hours = <143>; - precharge-current-microamp = <256000>; - charge-term-current-microamp = <128000>; - constant-charge-current-max-microamp = <90>; - constant-charge-voltage-max-microvolt = <420>; - factory-internal-resistance-micro-ohms = <25>; - ocv-capacity-celsius = <(-10) 0 10>; - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; - ocv-capacity-table-1 = <420 100>, <4185000 95>, <4113000 90>, ...; - ocv-capacity-table-2 = <425 100>, <420 95>, <4185000 90>, ...; - resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; - }; - - charger: charger@11 { - - monitored-battery = <>; - ... - }; - - fuel_gauge: fuel-gauge@22 { - - monitored-battery = <>; - ... - }; +The contents of this file has been moved to battery.yaml diff --git a/Documentation/devicetree/bindings/power/supply/battery.yaml b/Documentation/devicetree/bindings/power/supply/battery.yaml new file mode 100644 index ..f0b544a22219 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/battery.yaml @@ -0,0 +1,143 @@ +#
[PATCH v11 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from the JEITA spec. Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 2 +- drivers/power/supply/power_supply_sysfs.c | 2 +- include/linux/power_supply.h| 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index bf3b48f022dc..9f3fd01a9373 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -190,7 +190,7 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current" + "Over current", "Warm", "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index f37ad4eae60b..d0d549611794 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -61,7 +61,7 @@ static const char * const power_supply_charge_type_text[] = { static const char * const power_supply_health_text[] = { "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", - "Safety timer expire", "Over current" + "Safety timer expire", "Over current", "Warm", "Cool", "Hot" }; static const char * const power_supply_technology_text[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index dcd5a71e6c67..8670e90c1d51 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -61,6 +61,9 @@ enum { POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.26.2
[PATCH v11 3/4] dt-bindings: power: Add the bindings for the bq2515x family of chargers.
The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: http://www.ti.com/lit/ds/symlink/bq25150.pdf http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- .../bindings/power/supply/bq2515x.yaml| 91 +++ 1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml diff --git a/Documentation/devicetree/bindings/power/supply/bq2515x.yaml b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file mode 100644 index ..19cb336d581e --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq2515x.yaml @@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#; +$schema: "http://devicetree.org/meta-schemas/core.yaml#; + +title: TI bq2515x 500-mA Linear charger family + +maintainers: + - Dan Murphy + - Ricardo Rivera-Matos + +description: | + The BQ2515x family is a highly integrated battery charge management IC that + integrates the most common functions for wearable devices, namely a charger, + an output voltage rail, ADC for battery and system monitoring, and + push-button controller. + + Specifications about the charger can be found at: +http://www.ti.com/lit/ds/symlink/bq25150.pdf +http://www.ti.com/lit/ds/symlink/bq25155.pdf + +properties: + compatible: +enum: + - ti,bq25150 + - ti,bq25155 + + reg: +maxItems: 1 +description: I2C address of the charger. + + ac-detect-gpios: +description: | + GPIO used for connecting the bq2515x device PG (AC Detect) + pin. +maxItems: 1 + + reset-gpios: +description: GPIO used for hardware reset. +maxItems: 1 + + powerdown-gpios: +description: GPIO used for low power mode of IC. +maxItems: 1 + + charge-enable-gpios: +description: GPIO used to turn on and off charging. +maxItems: 1 + + input-current-limit-microamp: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Maximum input current in micro Amps. +minimum: 5 +maximum: 50 + + monitored-battery: +$ref: battery.yaml# + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | +bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <5>; + precharge-current-microamp = <2500>; + constant-charge-voltage-max-microvolt = <400>; +}; +#include +i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25150: charger@6b { +compatible = "ti,bq25150"; +reg = <0x6b>; +monitored-battery = <>; +input-current-limit-microamp = <10>; + +ac-detect-gpios = < 28 GPIO_ACTIVE_HIGH>; +reset-gpios = < 14 GPIO_ACTIVE_HIGH>; +powerdown-gpios = < 15 GPIO_ACTIVE_HIGH>; +charge-enable-gpios = < 13 GPIO_ACTIVE_LOW>; + }; +}; -- 2.26.2
[PATCH v11 4/4] power: supply: bq25150 introduce the bq25150
Introduce the bq2515x family of chargers. The BQ2515X family of devices are highly integrated battery management ICs that integrate the most common functions for wearable devices namely a charger, an output voltage rail, ADC for battery and system monitoring, and a push-button controller. Datasheets: bq25150 - http://www.ti.com/lit/ds/symlink/bq25150.pdf bq25155 - http://www.ti.com/lit/ds/symlink/bq25155.pdf Signed-off-by: Ricardo Rivera-Matos --- drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c | 1159 3 files changed, 1173 insertions(+) create mode 100644 drivers/power/supply/bq2515x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index f3424fdce341..266193301e2d 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -589,6 +589,19 @@ config CHARGER_BQ24735 help Say Y to enable support for the TI BQ24735 battery charger. +config CHARGER_BQ2515X + tristate "TI BQ2515X battery charger family" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ2515X family of battery + charging integrated circuits. The BQ2515X are highly integrated + battery charge management ICs that integrate the most common + functions for wearable devices, namely a charger, an output voltage + rail, ADC for battery and system monitoring, and push-button + controller. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index 6c7da920ea83..8fcc175a7e22 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c new file mode 100644 index ..3e9d221e23bb --- /dev/null +++ b/drivers/power/supply/bq2515x_charger.c @@ -0,0 +1,1159 @@ +// SPDX-License-Identifier: GPL-2.0 +// BQ2515X Battery Charger Driver +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BQ2515X_MANUFACTURER "Texas Instruments" + +#define BQ2515X_STAT0 0x00 +#define BQ2515X_STAT1 0x01 +#define BQ2515X_STAT2 0x02 +#define BQ2515X_FLAG0 0x03 +#define BQ2515X_FLAG1 0x04 +#define BQ2515X_FLAG2 0x05 +#define BQ2515X_FLAG3 0x06 +#define BQ2515X_MASK0 0x07 +#define BQ2515X_MASK1 0x08 +#define BQ2515X_MASK2 0x09 +#define BQ2515X_MASK3 0x0a +#define BQ2515X_VBAT_CTRL 0x12 +#define BQ2515X_ICHG_CTRL 0x13 +#define BQ2515X_PCHRGCTRL 0x14 +#define BQ2515X_TERMCTRL 0x15 +#define BQ2515X_BUVLO 0x16 +#define BQ2515X_CHARGERCTRL0 0x17 +#define BQ2515X_CHARGERCTRL1 0x18 +#define BQ2515X_ILIMCTRL 0x19 +#define BQ2515X_LDOCTRL0x1d +#define BQ2515X_MRCTRL 0x30 +#define BQ2515X_ICCTRL00x35 +#define BQ2515X_ICCTRL10x36 +#define BQ2515X_ICCTRL20x37 +#define BQ2515X_ADCCTRL0 0x40 +#define BQ2515X_ADCCTRL1 0x41 +#define BQ2515X_ADC_VBAT_M 0x42 +#define BQ2515X_ADC_VBAT_L 0x43 +#define BQ2515X_ADC_TS_M 0x44 +#define BQ2515X_ADC_TS_L 0x45 +#define BQ2515X_ADC_ICHG_M 0x46 +#define BQ2515X_ADC_ICHG_L 0x47 +#define BQ2515X_ADC_ADCIN_M0x48 +#define BQ2515X_ADC_ADCIN_L0x49 +#define BQ2515X_ADC_VIN_M 0x4a +#define BQ2515X_ADC_VIN_L 0x4b +#define BQ2515X_ADC_PMID_M 0x4c +#define BQ2515X_ADC_PMID_L 0x4d +#define BQ2515X_ADC_IIN_M 0x4e +#define BQ2515X_ADC_IIN_L 0x4f +#define BQ2515X_ADC_COMP1_M0x52 +#define BQ2515X_ADC_COMP1_L0X53 +#define BQ2515X_ADC_COMP2_M0X54 +#define BQ2515X_ADC_COMP2_L0x55 +#define BQ2515X_ADC_COMP3_M0x56 +#define BQ2515X_ADC_COMP3_L0x57 +#define BQ2515X_ADC_READ_EN0x58 +#define BQ2515X_TS_FASTCHGCTRL 0x61 +#define BQ2515X_TS_COLD0x62 +#define BQ2515X_TS_COOL0x63 +#define BQ2515X_TS_WARM0x64 +#define BQ2515X_TS_HOT 0x65 +#define BQ2515X_DEVICE_ID 0x6f + +#define BQ2515X_DEFAULT_ICHG_UA1 +#
[PATCH v11 0/4] Add JEITA properties and introduce the bq2515x charger
Hello, This patchset adds additional health properties to the power_supply header. These additional properties are taken from the JEITA specification. This patchset also introduces the bq2515x family of charging ICs. Dan Murphy (2): power_supply: Add additional health properties to the header dt-bindings: power: Convert battery.txt to battery.yaml Ricardo Rivera-Matos (2): dt-bindings: power: Add the bindings for the bq2515x family of chargers. power: supply: bq25150 introduce the bq25150 Documentation/ABI/testing/sysfs-class-power |2 +- .../bindings/power/supply/battery.txt | 82 +- .../bindings/power/supply/battery.yaml| 143 ++ .../bindings/power/supply/bq2515x.yaml| 91 ++ drivers/power/supply/Kconfig | 13 + drivers/power/supply/Makefile |1 + drivers/power/supply/bq2515x_charger.c| 1159 + drivers/power/supply/power_supply_sysfs.c |2 +- include/linux/power_supply.h |3 + 9 files changed, 1413 insertions(+), 83 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/battery.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml create mode 100644 drivers/power/supply/bq2515x_charger.c -- 2.26.2
[PATCH v10 1/4] power_supply: Add additional health properties to the header
From: Dan Murphy Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum. HEALTH_WARM, HEALTH_COOL, and HEALTH_HOT properties are taken from the JEITA spec. Tested-by: Guru Das Srinagesh Signed-off-by: Dan Murphy --- Documentation/ABI/testing/sysfs-class-power | 2 +- drivers/power/supply/power_supply_sysfs.c | 2 +- include/linux/power_supply.h| 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index bf3b48f022dc..9f3fd01a9373 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -190,7 +190,7 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", - "Over current" + "Over current", "Warm", "Cool", "Hot" What: /sys/class/power_supply//precharge_current Date: June 2017 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index f37ad4eae60b..d0d549611794 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -61,7 +61,7 @@ static const char * const power_supply_charge_type_text[] = { static const char * const power_supply_health_text[] = { "Unknown", "Good", "Overheat", "Dead", "Over voltage", "Unspecified failure", "Cold", "Watchdog timer expire", - "Safety timer expire", "Over current" + "Safety timer expire", "Over current", "Warm", "Cool", "Hot" }; static const char * const power_supply_technology_text[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index dcd5a71e6c67..8670e90c1d51 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -61,6 +61,9 @@ enum { POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, POWER_SUPPLY_HEALTH_OVERCURRENT, + POWER_SUPPLY_HEALTH_WARM, + POWER_SUPPLY_HEALTH_COOL, + POWER_SUPPLY_HEALTH_HOT, }; enum { -- 2.26.2