From e5154eb349e50ee43203592ba7f65707efcdd6d9 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 6 Dec 2016 17:26:55 -0800 Subject: [PATCH 01/10] power: bq24190_charger: set system params from dts ti,sys_min - minimum system voltage in mV ti,iprechg - pre-charge current in mA ti,iterm - termination current in mA --- drivers/power/bq24190_charger.c | 67 +++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c index cc7227a7251e72..04bb1f5f32d7e3 100644 --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -156,6 +156,9 @@ struct bq24190_dev_info { kernel_ulong_t model; unsigned int gpio_int; unsigned int irq; + u16 sys_min; + u16 iprechg; + u16 iterm; rwlock_t f_reg_lock; bool initialized; bool irq_event; @@ -480,19 +483,20 @@ static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi) static inline void bq24190_sysfs_remove_group(struct bq24190_dev_info *bdi) {} #endif -/* - * According to the "Host Mode and default Mode" section of the - * manual, a write to any register causes the bq24190 to switch - * from default mode to host mode. It will switch back to default - * mode after a WDT timeout unless the WDT is turned off as well. - * So, by simply turning off the WDT, we accomplish both with the - * same write. - */ -static int bq24190_set_mode_host(struct bq24190_dev_info *bdi) +static int bq24190_set_operating_params(struct bq24190_dev_info *bdi) { int ret; u8 v; + /* + * According to the "Host Mode and default Mode" section of the + * manual, a write to any register causes the bq24190 to switch + * from default mode to host mode. It will switch back to default + * mode after a WDT timeout unless the WDT is turned off as well. + * So, by simply turning off the WDT, we accomplish both with the + * same write. + */ + ret = bq24190_read(bdi, BQ24190_REG_CTTC, &v); if (ret < 0) return ret; @@ -501,7 +505,41 @@ static int bq24190_set_mode_host(struct bq24190_dev_info *bdi) BQ24190_REG_CTTC_WATCHDOG_SHIFT); v &= ~BQ24190_REG_CTTC_WATCHDOG_MASK; - return bq24190_write(bdi, BQ24190_REG_CTTC, v); + ret = bq24190_write(bdi, BQ24190_REG_CTTC, v); + if (ret < 0) + return ret; + + if (bdi->sys_min >= 3000 && bdi->sys_min <= 3700) { + v = bdi->sys_min / 100 - 30; // manual section 9.5.1.2, table 9 + ret = ba24190_write_mask(bdi, BQ24190_REG_POC, + BQ24190_REG_POC_SYS_MIN_MASK, + BQ24190_REG_POC_SYS_MIN_SHIFT, + v); + if (ret < 0) + return ret; + } + + if (bdi->iprechg >= 128 && bdi->iprechg <= 2048) { + v = (bdi->iprechg - 128) / 128; // manual section 9.5.1.4, table 11 + ret = ba24190_write_mask(bdi, BQ24190_REG_PCTCC, + BQ24190_REG_PCTCC_IPRECHG_MASK, + BQ24190_REG_PCTCC_IPRECHG_SHIFT, + v); + if (ret < 0) + return ret; + } + + if (bdi->iterm >= 128 && bdi->iterm <= 2048) { + v = (bdi->iterm - 128) / 128; // manual section 9.5.1.4, table 11 + ret = ba24190_write_mask(bdi, BQ24190_REG_PCTCC, + BQ24190_REG_PCTCC_ITERM_MASK, + BQ24190_REG_PCTCC_ITERM_SHIFT, + v); + if (ret < 0) + return ret; + } + + return 0; } static int bq24190_register_reset(struct bq24190_dev_info *bdi) @@ -1277,7 +1315,7 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi) if (ret < 0) goto out; - ret = bq24190_set_mode_host(bdi); + ret = bq24190_set_operating_params(bdi); if (ret < 0) goto out; @@ -1294,6 +1332,10 @@ static int bq24190_setup_dt(struct bq24190_dev_info *bdi) if (bdi->irq <= 0) return -1; + of_property_read_u16(bdi->dev->of_node, "ti,sys_min", &bdi->sys_min); + of_property_read_u16(bdi->dev->of_node, "ti,iprechg", &bdi->iprechg); + of_property_read_u16(bdi->dev->of_node, "ti,iterm", &bdi->iterm); + return 0; } #else @@ -1356,6 +1398,7 @@ static int bq24190_probe(struct i2c_client *client, bdi->dev = dev; bdi->model = id->driver_data; strncpy(bdi->model_name, id->name, I2C_NAME_SIZE); + bdi->sys_min = bdi->iprechg = bdi->iterm = 0; rwlock_init(&bdi->f_reg_lock); bdi->f_reg = 0; bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; @@ -1507,7 +1550,7 @@ static int bq24190_pm_resume(struct device *dev) pm_runtime_get_sync(bdi->dev); bq24190_register_reset(bdi); - bq24190_set_mode_host(bdi); + bq24190_set_operating_params(bdi); bq24190_read(bdi, BQ24190_REG_SS, &bdi->ss_reg); pm_runtime_put_sync(bdi->dev); From 1b3512d05e212e46ae5904164e98287a346bdce3 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 6 Dec 2016 18:14:46 -0800 Subject: [PATCH 02/10] power: bq24190_charger: set system params from dts (squash into previous commit) --- drivers/power/bq24190_charger.c | 34 ++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c index 04bb1f5f32d7e3..1ce6a85fa3260b 100644 --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -509,9 +509,9 @@ static int bq24190_set_operating_params(struct bq24190_dev_info *bdi) if (ret < 0) return ret; - if (bdi->sys_min >= 3000 && bdi->sys_min <= 3700) { + if (bdi->sys_min) { v = bdi->sys_min / 100 - 30; // manual section 9.5.1.2, table 9 - ret = ba24190_write_mask(bdi, BQ24190_REG_POC, + ret = bq24190_write_mask(bdi, BQ24190_REG_POC, BQ24190_REG_POC_SYS_MIN_MASK, BQ24190_REG_POC_SYS_MIN_SHIFT, v); @@ -519,9 +519,9 @@ static int bq24190_set_operating_params(struct bq24190_dev_info *bdi) return ret; } - if (bdi->iprechg >= 128 && bdi->iprechg <= 2048) { + if (bdi->iprechg) { v = (bdi->iprechg - 128) / 128; // manual section 9.5.1.4, table 11 - ret = ba24190_write_mask(bdi, BQ24190_REG_PCTCC, + ret = bq24190_write_mask(bdi, BQ24190_REG_PCTCC, BQ24190_REG_PCTCC_IPRECHG_MASK, BQ24190_REG_PCTCC_IPRECHG_SHIFT, v); @@ -529,9 +529,9 @@ static int bq24190_set_operating_params(struct bq24190_dev_info *bdi) return ret; } - if (bdi->iterm >= 128 && bdi->iterm <= 2048) { + if (bdi->iterm) { v = (bdi->iterm - 128) / 128; // manual section 9.5.1.4, table 11 - ret = ba24190_write_mask(bdi, BQ24190_REG_PCTCC, + ret = bq24190_write_mask(bdi, BQ24190_REG_PCTCC, BQ24190_REG_PCTCC_ITERM_MASK, BQ24190_REG_PCTCC_ITERM_SHIFT, v); @@ -1328,13 +1328,29 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi) #ifdef CONFIG_OF static int bq24190_setup_dt(struct bq24190_dev_info *bdi) { + u16 input; + bdi->irq = irq_of_parse_and_map(bdi->dev->of_node, 0); if (bdi->irq <= 0) return -1; - of_property_read_u16(bdi->dev->of_node, "ti,sys_min", &bdi->sys_min); - of_property_read_u16(bdi->dev->of_node, "ti,iprechg", &bdi->iprechg); - of_property_read_u16(bdi->dev->of_node, "ti,iterm", &bdi->iterm); + if (of_property_read_u16(bdi->dev->of_node, "ti,sys_min", &input)) + if (input >= 3000 && input <= 3700) + bdi->sys_min = input; + else + dev_err(bdi->dev, "invalid value for ti,sys_min\n"); + + if (of_property_read_u16(bdi->dev->of_node, "ti,iprechg", &input)) + if (input >= 128 && input <= 2048) + bdi->iprechg = input; + else + dev_err(bdi->dev, "invalid value for ti,iprechg\n"); + + if (of_property_read_u16(bdi->dev->of_node, "ti,iterm", &input)) + if (input >= 128 && input <= 2048) + bdi->iterm = input; + else + dev_err(bdi->dev, "invalid value for ti,iterm\n"); return 0; } From f80d58e7ffc344f9b528037c751adec911258039 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 6 Dec 2016 21:13:14 -0800 Subject: [PATCH 03/10] power: bq24190_charger: set system params from dts (squash into previous commit) --- drivers/power/bq24190_charger.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c index 1ce6a85fa3260b..1b7d8109dd1c95 100644 --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -1334,23 +1334,26 @@ static int bq24190_setup_dt(struct bq24190_dev_info *bdi) if (bdi->irq <= 0) return -1; - if (of_property_read_u16(bdi->dev->of_node, "ti,sys_min", &input)) + if (of_property_read_u16(bdi->dev->of_node, "ti,sys_min", &input)) { if (input >= 3000 && input <= 3700) bdi->sys_min = input; else dev_err(bdi->dev, "invalid value for ti,sys_min\n"); + } - if (of_property_read_u16(bdi->dev->of_node, "ti,iprechg", &input)) + if (of_property_read_u16(bdi->dev->of_node, "ti,iprechg", &input)) { if (input >= 128 && input <= 2048) bdi->iprechg = input; else dev_err(bdi->dev, "invalid value for ti,iprechg\n"); + } - if (of_property_read_u16(bdi->dev->of_node, "ti,iterm", &input)) + if (of_property_read_u16(bdi->dev->of_node, "ti,iterm", &input)) { if (input >= 128 && input <= 2048) bdi->iterm = input; else dev_err(bdi->dev, "invalid value for ti,iterm\n"); + } return 0; } From dce6823f73c0781c90902cc458d2fd274820e32b Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 6 Dec 2016 21:42:33 -0800 Subject: [PATCH 04/10] power: bq24190_charger: set system params from dts (squash into previous commit) --- drivers/power/bq24190_charger.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c index 1b7d8109dd1c95..8b9bd6c309b0a9 100644 --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -44,6 +44,8 @@ #define BQ24190_REG_POC_SYS_MIN_SHIFT 1 #define BQ24190_REG_POC_BOOST_LIM_MASK BIT(0) #define BQ24190_REG_POC_BOOST_LIM_SHIFT 0 +#define BQ24190_REG_POC_SYS_MIN_MIN 3000 +#define BQ24190_REG_POC_SYS_MIN_MAX 3700 #define BQ24190_REG_CCC 0x02 /* Charge Current Control */ #define BQ24190_REG_CCC_ICHG_MASK (BIT(7) | BIT(6) | BIT(5) | \ @@ -59,6 +61,10 @@ #define BQ24190_REG_PCTCC_ITERM_MASK (BIT(3) | BIT(2) | BIT(1) | \ BIT(0)) #define BQ24190_REG_PCTCC_ITERM_SHIFT 0 +#define BQ24190_REG_PCTCC_IPRECHG_MIN 128 +#define BQ24190_REG_PCTCC_IPRECHG_MAX 2048 +#define BQ24190_REG_PCTCC_ITERM_MIN 128 +#define BQ24190_REG_PCTCC_ITERM_MAX 2048 #define BQ24190_REG_CVC 0x04 /* Charge Voltage Control */ #define BQ24190_REG_CVC_VREG_MASK (BIT(7) | BIT(6) | BIT(5) | \ @@ -1329,27 +1335,30 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi) static int bq24190_setup_dt(struct bq24190_dev_info *bdi) { u16 input; - + bdi->irq = irq_of_parse_and_map(bdi->dev->of_node, 0); if (bdi->irq <= 0) return -1; if (of_property_read_u16(bdi->dev->of_node, "ti,sys_min", &input)) { - if (input >= 3000 && input <= 3700) + if (input >= BQ24190_REG_POC_SYS_MIN_MIN + && input <= BQ24190_REG_POC_SYS_MIN_MAX) bdi->sys_min = input; else dev_err(bdi->dev, "invalid value for ti,sys_min\n"); } if (of_property_read_u16(bdi->dev->of_node, "ti,iprechg", &input)) { - if (input >= 128 && input <= 2048) + if (input >= BQ24190_REG_PCTCC_IPRECHG_MIN + && input <= BQ24190_REG_PCTCC_IPRECHG_MAX) bdi->iprechg = input; else dev_err(bdi->dev, "invalid value for ti,iprechg\n"); } if (of_property_read_u16(bdi->dev->of_node, "ti,iterm", &input)) { - if (input >= 128 && input <= 2048) + if (input >= BQ24190_REG_PCTCC_ITERM_MIN + && input <= BQ24190_REG_PCTCC_ITERM_MAX) bdi->iterm = input; else dev_err(bdi->dev, "invalid value for ti,iterm\n"); @@ -1569,7 +1578,7 @@ static int bq24190_pm_resume(struct device *dev) pm_runtime_get_sync(bdi->dev); bq24190_register_reset(bdi); - bq24190_set_operating_params(bdi); + bq24190_set_operating_params(bdi); bq24190_read(bdi, BQ24190_REG_SS, &bdi->ss_reg); pm_runtime_put_sync(bdi->dev); From 2e4960d79e97b520eb5134dea3dce30d3091835a Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 7 Dec 2016 12:51:05 -0800 Subject: [PATCH 05/10] power: bq24190_charger: set system params from dts (squash into previous) --- .../bindings/power/supply/bq24190.txt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt new file mode 100644 index 00000000000000..f61a13d8c279d1 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt @@ -0,0 +1,27 @@ +Binding for TI BQ24190 Li-Ion Battery Charger + +Required properties: +- compatible: Should contain one of the following: + * "ti,bq24190" +- reg: integer, i2c address of the device. + +Optional properties: +- ti,precharge-current: integer in mA, maximum charge current during precharge + phase (typically 20% of battery capacity); +- ti,termination-current: integer in mA, a charge cycle terminates when the + battery voltage is above recharge threshold, and the current is below + this setting (typically 10% of battery capacity); +- ti,minimum-sys-voltage: integer in mV, when power is connected and the battery + is below minimum system voltage, the system will be regulated above this + setting; + +Example: + +bq24190 { + compatible = "ti,bq25890"; + reg = <0x6a>; + // interrupt configuration here + ti,precharge-current = <256>; + ti,termination-current = <128>; + ti,minimum-sys-voltage = <3200>; +}; From 7b43cdd7dc259f1d507ad410044d93f9874d8502 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 7 Dec 2016 12:59:36 -0800 Subject: [PATCH 06/10] power: bq24190_charger: set system params from dts (squash into previous) --- drivers/power/bq24190_charger.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c index 8b9bd6c309b0a9..7c7db2d09ba84a 100644 --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -1340,28 +1340,28 @@ static int bq24190_setup_dt(struct bq24190_dev_info *bdi) if (bdi->irq <= 0) return -1; - if (of_property_read_u16(bdi->dev->of_node, "ti,sys_min", &input)) { + if (of_property_read_u16(bdi->dev->of_node, "ti,minimum-sys-voltage", &input)) { if (input >= BQ24190_REG_POC_SYS_MIN_MIN && input <= BQ24190_REG_POC_SYS_MIN_MAX) bdi->sys_min = input; else - dev_err(bdi->dev, "invalid value for ti,sys_min\n"); + dev_err(bdi->dev, "invalid value for ti,minimum-sys-voltage\n"); } - if (of_property_read_u16(bdi->dev->of_node, "ti,iprechg", &input)) { + if (of_property_read_u16(bdi->dev->of_node, "ti,precharge-current", &input)) { if (input >= BQ24190_REG_PCTCC_IPRECHG_MIN && input <= BQ24190_REG_PCTCC_IPRECHG_MAX) bdi->iprechg = input; else - dev_err(bdi->dev, "invalid value for ti,iprechg\n"); + dev_err(bdi->dev, "invalid value for ti,precharge-current\n"); } - if (of_property_read_u16(bdi->dev->of_node, "ti,iterm", &input)) { + if (of_property_read_u16(bdi->dev->of_node, "ti,termination-current", &input)) { if (input >= BQ24190_REG_PCTCC_ITERM_MIN && input <= BQ24190_REG_PCTCC_ITERM_MAX) bdi->iterm = input; else - dev_err(bdi->dev, "invalid value for ti,iterm\n"); + dev_err(bdi->dev, "invalid value for ti,termination-current\n"); } return 0; From f84e74b1ff6429dffeccacdccc81db32d04017a6 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 7 Dec 2016 20:27:59 -0800 Subject: [PATCH 07/10] power: bq24190_charger: set system params from dts (squash into previous) --- Documentation/devicetree/bindings/power/supply/bq24190.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt index f61a13d8c279d1..16b461978d9922 100644 --- a/Documentation/devicetree/bindings/power/supply/bq24190.txt +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt @@ -18,7 +18,7 @@ Optional properties: Example: bq24190 { - compatible = "ti,bq25890"; + compatible = "ti,bq24190"; reg = <0x6a>; // interrupt configuration here ti,precharge-current = <256>; From cff0aafc33e0be7aa999702c92941ca254695c82 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 8 Dec 2016 07:04:33 -0800 Subject: [PATCH 08/10] power: bq24190_charger: set system params from dts (squash into previous) --- drivers/power/bq24190_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c index 7c7db2d09ba84a..859c5131c84154 100644 --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -526,7 +526,7 @@ static int bq24190_set_operating_params(struct bq24190_dev_info *bdi) } if (bdi->iprechg) { - v = (bdi->iprechg - 128) / 128; // manual section 9.5.1.4, table 11 + v = bdi->iprechg / 128 - 1; // manual section 9.5.1.4, table 11 ret = bq24190_write_mask(bdi, BQ24190_REG_PCTCC, BQ24190_REG_PCTCC_IPRECHG_MASK, BQ24190_REG_PCTCC_IPRECHG_SHIFT, @@ -536,7 +536,7 @@ static int bq24190_set_operating_params(struct bq24190_dev_info *bdi) } if (bdi->iterm) { - v = (bdi->iterm - 128) / 128; // manual section 9.5.1.4, table 11 + v = bdi->iterm / 128 - 1; // manual section 9.5.1.4, table 11 ret = bq24190_write_mask(bdi, BQ24190_REG_PCTCC, BQ24190_REG_PCTCC_ITERM_MASK, BQ24190_REG_PCTCC_ITERM_SHIFT, From 745db5870842e24ec75c5f3fed800145e275f528 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 10 Dec 2016 10:57:05 -0800 Subject: [PATCH 09/10] power: bq24190_charger: set system params from dts (squash into previous) --- .../bindings/power/supply/bq24190.txt | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt deleted file mode 100644 index 16b461978d9922..00000000000000 --- a/Documentation/devicetree/bindings/power/supply/bq24190.txt +++ /dev/null @@ -1,27 +0,0 @@ -Binding for TI BQ24190 Li-Ion Battery Charger - -Required properties: -- compatible: Should contain one of the following: - * "ti,bq24190" -- reg: integer, i2c address of the device. - -Optional properties: -- ti,precharge-current: integer in mA, maximum charge current during precharge - phase (typically 20% of battery capacity); -- ti,termination-current: integer in mA, a charge cycle terminates when the - battery voltage is above recharge threshold, and the current is below - this setting (typically 10% of battery capacity); -- ti,minimum-sys-voltage: integer in mV, when power is connected and the battery - is below minimum system voltage, the system will be regulated above this - setting; - -Example: - -bq24190 { - compatible = "ti,bq24190"; - reg = <0x6a>; - // interrupt configuration here - ti,precharge-current = <256>; - ti,termination-current = <128>; - ti,minimum-sys-voltage = <3200>; -}; From 0ebc4224de625446dc28c335844850891a085059 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 10 Dec 2016 21:44:16 -0800 Subject: [PATCH 10/10] power: bq24190_charger: set system params from dts (squash into previous) --- drivers/power/bq24190_charger.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c index 859c5131c84154..8d101c074186cc 100644 --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -1334,34 +1334,34 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi) #ifdef CONFIG_OF static int bq24190_setup_dt(struct bq24190_dev_info *bdi) { - u16 input; + u32 input; bdi->irq = irq_of_parse_and_map(bdi->dev->of_node, 0); if (bdi->irq <= 0) return -1; - if (of_property_read_u16(bdi->dev->of_node, "ti,minimum-sys-voltage", &input)) { + if (of_property_read_u32(bdi->dev->of_node, "ti,minimum-sys-voltage", &input) == 0) { if (input >= BQ24190_REG_POC_SYS_MIN_MIN && input <= BQ24190_REG_POC_SYS_MIN_MAX) bdi->sys_min = input; else - dev_err(bdi->dev, "invalid value for ti,minimum-sys-voltage\n"); + dev_err(bdi->dev, "invalid value for ti,minimum-sys-voltage: %u\n", input); } - if (of_property_read_u16(bdi->dev->of_node, "ti,precharge-current", &input)) { + if (of_property_read_u32(bdi->dev->of_node, "ti,precharge-current", &input) == 0) { if (input >= BQ24190_REG_PCTCC_IPRECHG_MIN && input <= BQ24190_REG_PCTCC_IPRECHG_MAX) bdi->iprechg = input; else - dev_err(bdi->dev, "invalid value for ti,precharge-current\n"); + dev_err(bdi->dev, "invalid value for ti,precharge-current: %u\n", input); } - if (of_property_read_u16(bdi->dev->of_node, "ti,termination-current", &input)) { + if (of_property_read_u32(bdi->dev->of_node, "ti,termination-current", &input) == 0) { if (input >= BQ24190_REG_PCTCC_ITERM_MIN && input <= BQ24190_REG_PCTCC_ITERM_MAX) bdi->iterm = input; else - dev_err(bdi->dev, "invalid value for ti,termination-current\n"); + dev_err(bdi->dev, "invalid value for ti,termination-current: %u\n", input); } return 0;