* [PATCH v5 0/2] Add new ti,no-thermistor property
@ 2023-05-04 9:30 Hermes Zhang
2023-05-04 9:30 ` [PATCH v5 1/2] dt-bindings: power: supply: bq256xx: Add " Hermes Zhang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hermes Zhang @ 2023-05-04 9:30 UTC (permalink / raw)
To: sre, krzysztof.kozlowski+dt; +Cc: linux-kernel, kernel, Hermes Zhang
The TS pin is used to detect the temperature and suspend the charging
when it's voltage out of range. If the NTC is not connect in HW, the
TS_IGNORE bit need to be set to 1 to make charge work. The new
"ti,no-thermistor" is used to set TS_IGNORE to 1 when HW doesn't work
with NTC.
Description from datasheet:
Battery temperature qualification voltage input. Connect a negative temperature
coefficient thermistor (NTC). Program temperature window with a resistor divider
from REGN to TS to GND. Charge and Boost mode suspend when TS pin voltage is
out of range. When TS pin is not used, connect a 10-kΩ resistor from REGN to TS
and a 10-kΩ resistor from TS to GND or set TS_IGNORE to HIGH to ignore TS pin.
It is recommended to use a 103AT-2 thermistor.
Notes:
v2: change property name to ti,no-thermistor
v3: drop "|" in property description
v4: rebase bq256xx_charger.c
v5: add Reviewed-by tag from Krzysztof Kozlowski
Hermes Zhang (2):
dt-bindings: power: supply: bq256xx: Add ti,no-thermistor property
power: supply: bq256xx: Apply TS_IGNORE from devicetree
.../bindings/power/supply/bq256xx.yaml | 18 ++++++++++++
drivers/power/supply/bq256xx_charger.c | 28 +++++++++++++++++++
2 files changed, 46 insertions(+)
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v5 1/2] dt-bindings: power: supply: bq256xx: Add ti,no-thermistor property
2023-05-04 9:30 [PATCH v5 0/2] Add new ti,no-thermistor property Hermes Zhang
@ 2023-05-04 9:30 ` Hermes Zhang
2023-05-04 9:30 ` [PATCH v5 2/2] power: supply: bq256xx: Apply TS_IGNORE from devicetree Hermes Zhang
2023-05-08 12:18 ` [PATCH v5 0/2] Add new ti,no-thermistor property Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Hermes Zhang @ 2023-05-04 9:30 UTC (permalink / raw)
To: sre, krzysztof.kozlowski+dt, Rob Herring, Andrew Davis
Cc: linux-kernel, kernel, Hermes Zhang, Krzysztof Kozlowski,
linux-pm, devicetree
Add a new property ti,no-thermistor to indicate that no thermistor is
connected to the TS pin of the chip.
Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
Notes:
v2: change property name to ti,no-thermistor
v3: drop "|" in property description
v4: rebase bq256xx_charger.c
v5: add Reviewed-by tag from Krzysztof Kozlowski
.../bindings/power/supply/bq256xx.yaml | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml
index 82f382a7ffb3..4fe9c3705265 100644
--- a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml
+++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml
@@ -68,11 +68,29 @@ properties:
Interrupt sends an active low, 256 μs pulse to host to report the charger
device status and faults.
+ ti,no-thermistor:
+ type: boolean
+ description: Indicates that no thermistor is connected to the TS pin
+
required:
- compatible
- reg
- monitored-battery
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - ti,bq25600
+ - ti,bq25601
+ - ti,bq25600d
+ - ti,bq25601d
+ then:
+ properties:
+ ti,no-thermistor: false
+
additionalProperties: false
examples:
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v5 2/2] power: supply: bq256xx: Apply TS_IGNORE from devicetree
2023-05-04 9:30 [PATCH v5 0/2] Add new ti,no-thermistor property Hermes Zhang
2023-05-04 9:30 ` [PATCH v5 1/2] dt-bindings: power: supply: bq256xx: Add " Hermes Zhang
@ 2023-05-04 9:30 ` Hermes Zhang
2023-05-08 12:18 ` [PATCH v5 0/2] Add new ti,no-thermistor property Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Hermes Zhang @ 2023-05-04 9:30 UTC (permalink / raw)
To: sre, krzysztof.kozlowski+dt; +Cc: linux-kernel, kernel, Hermes Zhang, linux-pm
TS_IGNORE is default off in bq256xx chip. For some HW which doesn't have
the NTC, we need to set TS_IGNORE to 1 to make the charge work. The new
"ti,no-thermistor" is introduced to toggle it.
Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
---
Notes:
v2: change property name to ti,no-thermistor
v3: drop "|" in property description
v4: rebase bq256xx_charger.c
v5: add Reviewed-by tag from Krzysztof Kozlowski
drivers/power/supply/bq256xx_charger.c | 28 ++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c
index 9cf4936440c9..cacaae1d559b 100644
--- a/drivers/power/supply/bq256xx_charger.c
+++ b/drivers/power/supply/bq256xx_charger.c
@@ -41,6 +41,9 @@
#define BQ256XX_IINDPM_MAX_uA 3200000
#define BQ256XX_IINDPM_DEF_uA 2400000
+#define BQ256XX_TS_IGNORE BIT(6)
+#define BQ256XX_TS_IGNORE_SHIFT 6
+
#define BQ256XX_VINDPM_MASK GENMASK(3, 0)
#define BQ256XX_VINDPM_STEP_uV 100000
#define BQ256XX_VINDPM_OFFSET_uV 3900000
@@ -156,6 +159,7 @@
* @vindpm: input voltage limit
* @ichg_max: maximum fast charge current
* @vbatreg_max: maximum charge voltage
+ * @ts_ignore: TS_IGNORE flag
*/
struct bq256xx_init_data {
u32 ichg;
@@ -166,6 +170,7 @@ struct bq256xx_init_data {
u32 vindpm;
u32 ichg_max;
u32 vbatreg_max;
+ bool ts_ignore;
};
/**
@@ -263,6 +268,7 @@ struct bq256xx_device {
* @bq256xx_set_iprechg: pointer to instance specific set_iprechg function
* @bq256xx_set_vindpm: pointer to instance specific set_vindpm function
* @bq256xx_set_charge_type: pointer to instance specific set_charge_type function
+ * @bq256xx_set_ts_ignore: pointer to instance specific set_ts_ignore function
*
* @bq256xx_def_ichg: default ichg value in microamps
* @bq256xx_def_iindpm: default iindpm value in microamps
@@ -295,6 +301,7 @@ struct bq256xx_chip_info {
int (*bq256xx_set_iprechg)(struct bq256xx_device *bq, int iprechg);
int (*bq256xx_set_vindpm)(struct bq256xx_device *bq, int vindpm);
int (*bq256xx_set_charge_type)(struct bq256xx_device *bq, int type);
+ int (*bq256xx_set_ts_ignore)(struct bq256xx_device *bq, bool ts_ignore);
int bq256xx_def_ichg;
int bq256xx_def_iindpm;
@@ -696,6 +703,12 @@ static int bq25601d_set_chrg_volt(struct bq256xx_device *bq, int vbatreg)
BQ256XX_VBATREG_BIT_SHIFT);
}
+static int bq256xx_set_ts_ignore(struct bq256xx_device *bq, bool ts_ignore)
+{
+ return regmap_update_bits(bq->regmap, BQ256XX_INPUT_CURRENT_LIMIT,
+ BQ256XX_TS_IGNORE, (ts_ignore ? 1 : 0) << BQ256XX_TS_IGNORE_SHIFT);
+}
+
static int bq256xx_get_prechrg_curr(struct bq256xx_device *bq)
{
unsigned int prechg_and_term_curr_lim;
@@ -1312,6 +1325,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_get_iterm = bq256xx_get_term_curr,
.bq256xx_get_iprechg = bq256xx_get_prechrg_curr,
.bq256xx_get_vindpm = bq256xx_get_input_volt_lim,
+ .bq256xx_set_ts_ignore = NULL,
.bq256xx_set_ichg = bq256xx_set_ichg_curr,
.bq256xx_set_iindpm = bq256xx_set_input_curr_lim,
@@ -1351,6 +1365,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,
+ .bq256xx_set_ts_ignore = NULL,
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1382,6 +1397,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,
+ .bq256xx_set_ts_ignore = NULL,
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1413,6 +1429,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,
+ .bq256xx_set_ts_ignore = NULL,
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1444,6 +1461,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,
+ .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore,
.bq256xx_def_ichg = BQ25611D_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1475,6 +1493,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq25618_619_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,
+ .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore,
.bq256xx_def_ichg = BQ25618_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1506,6 +1525,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq25618_619_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,
+ .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore,
.bq256xx_def_ichg = BQ25618_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1622,6 +1642,12 @@ static int bq256xx_hw_init(struct bq256xx_device *bq)
if (ret)
return ret;
+ if (bq->chip_info->bq256xx_set_ts_ignore) {
+ ret = bq->chip_info->bq256xx_set_ts_ignore(bq, bq->init_data.ts_ignore);
+ if (ret)
+ return ret;
+ }
+
power_supply_put_battery_info(bq->charger, bat_info);
return 0;
@@ -1656,6 +1682,8 @@ static int bq256xx_parse_dt(struct bq256xx_device *bq,
if (ret)
bq->init_data.iindpm = bq->chip_info->bq256xx_def_iindpm;
+ bq->init_data.ts_ignore = device_property_read_bool(bq->dev, "ti,no-thermistor");
+
return 0;
}
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v5 0/2] Add new ti,no-thermistor property
2023-05-04 9:30 [PATCH v5 0/2] Add new ti,no-thermistor property Hermes Zhang
2023-05-04 9:30 ` [PATCH v5 1/2] dt-bindings: power: supply: bq256xx: Add " Hermes Zhang
2023-05-04 9:30 ` [PATCH v5 2/2] power: supply: bq256xx: Apply TS_IGNORE from devicetree Hermes Zhang
@ 2023-05-08 12:18 ` Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2023-05-08 12:18 UTC (permalink / raw)
To: Hermes Zhang; +Cc: krzysztof.kozlowski+dt, linux-kernel, kernel
[-- Attachment #1: Type: text/plain, Size: 1458 bytes --]
Hi,
On Thu, May 04, 2023 at 05:30:35PM +0800, Hermes Zhang wrote:
> The TS pin is used to detect the temperature and suspend the charging
> when it's voltage out of range. If the NTC is not connect in HW, the
> TS_IGNORE bit need to be set to 1 to make charge work. The new
> "ti,no-thermistor" is used to set TS_IGNORE to 1 when HW doesn't work
> with NTC.
>
> Description from datasheet:
> Battery temperature qualification voltage input. Connect a negative temperature
> coefficient thermistor (NTC). Program temperature window with a resistor divider
> from REGN to TS to GND. Charge and Boost mode suspend when TS pin voltage is
> out of range. When TS pin is not used, connect a 10-kΩ resistor from REGN to TS
> and a 10-kΩ resistor from TS to GND or set TS_IGNORE to HIGH to ignore TS pin.
> It is recommended to use a 103AT-2 thermistor.
>
> Notes:
> v2: change property name to ti,no-thermistor
>
> v3: drop "|" in property description
>
> v4: rebase bq256xx_charger.c
>
> v5: add Reviewed-by tag from Krzysztof Kozlowski
>
> Hermes Zhang (2):
> dt-bindings: power: supply: bq256xx: Add ti,no-thermistor property
> power: supply: bq256xx: Apply TS_IGNORE from devicetree
>
> .../bindings/power/supply/bq256xx.yaml | 18 ++++++++++++
> drivers/power/supply/bq256xx_charger.c | 28 +++++++++++++++++++
> 2 files changed, 46 insertions(+)
Thanks, queued.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-08 16:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 9:30 [PATCH v5 0/2] Add new ti,no-thermistor property Hermes Zhang
2023-05-04 9:30 ` [PATCH v5 1/2] dt-bindings: power: supply: bq256xx: Add " Hermes Zhang
2023-05-04 9:30 ` [PATCH v5 2/2] power: supply: bq256xx: Apply TS_IGNORE from devicetree Hermes Zhang
2023-05-08 12:18 ` [PATCH v5 0/2] Add new ti,no-thermistor property Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®