[v2,09/11] power: bq25890: implement INPUT_CURRENT_LIMIT property
diff mbox series

Message ID 48d71a9b286e688ce8155449f62dc8fe0da39f17.1588517058.git.mirq-linux@rere.qmqm.pl
State Superseded
Headers show
Series
  • power: supply: bq25890: fix and extend
Related show

Commit Message

Michał Mirosław May 3, 2020, 3:21 p.m. UTC
Report REG00.IINLIM value as INPUT_CURRENT_LIMIT property.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/power/supply/bq25890_charger.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Sebastian Reichel May 3, 2020, 9:16 p.m. UTC | #1
Hi,

On Sun, May 03, 2020 at 05:21:13PM +0200, Michał Mirosław wrote:
> Report REG00.IINLIM value as INPUT_CURRENT_LIMIT property.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/power/supply/bq25890_charger.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
> index b48685009048..87c5832e23d3 100644
> --- a/drivers/power/supply/bq25890_charger.c
> +++ b/drivers/power/supply/bq25890_charger.c
> @@ -254,6 +254,7 @@ enum bq25890_table_ids {
>  	/* range tables */
>  	TBL_ICHG,
>  	TBL_ITERM,
> +	TBL_IILIM,
>  	TBL_VREG,
>  	TBL_BOOSTV,
>  	TBL_SYSVMIN,
> @@ -294,6 +295,7 @@ static const union {
>  	/* TODO: BQ25896 has max ICHG 3008 mA */
>  	[TBL_ICHG] =	{ .rt = {0,	  5056000, 64000} },	 /* uA */
>  	[TBL_ITERM] =	{ .rt = {64000,   1024000, 64000} },	 /* uA */
> +	[TBL_IILIM] =   { .rt = {50000,   3200000, 50000} },	 /* uA */
>  	[TBL_VREG] =	{ .rt = {3840000, 4608000, 16000} },	 /* uV */
>  	[TBL_BOOSTV] =	{ .rt = {4550000, 5510000, 64000} },	 /* uV */
>  	[TBL_SYSVMIN] = { .rt = {3000000, 3700000, 100000} },	 /* uV */
> @@ -505,6 +507,14 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
>  		val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM);
>  		break;
>  
> +	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
> +		ret = bq25890_field_read(bq, F_IILIM);
> +		if (ret < 0)
> +			return ret;
> +
> +		val->intval = bq25890_find_val(ret, TBL_IILIM);
> +		break;
> +
>  	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
>  		ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
>  		if (ret < 0)
> @@ -695,6 +705,7 @@ static const enum power_supply_property bq25890_power_supply_props[] = {
>  	POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
>  	POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
>  	POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
> +	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
>  	POWER_SUPPLY_PROP_VOLTAGE_NOW,
>  };
>  
> -- 
> 2.20.1
>

Patch
diff mbox series

diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index b48685009048..87c5832e23d3 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -254,6 +254,7 @@  enum bq25890_table_ids {
 	/* range tables */
 	TBL_ICHG,
 	TBL_ITERM,
+	TBL_IILIM,
 	TBL_VREG,
 	TBL_BOOSTV,
 	TBL_SYSVMIN,
@@ -294,6 +295,7 @@  static const union {
 	/* TODO: BQ25896 has max ICHG 3008 mA */
 	[TBL_ICHG] =	{ .rt = {0,	  5056000, 64000} },	 /* uA */
 	[TBL_ITERM] =	{ .rt = {64000,   1024000, 64000} },	 /* uA */
+	[TBL_IILIM] =   { .rt = {50000,   3200000, 50000} },	 /* uA */
 	[TBL_VREG] =	{ .rt = {3840000, 4608000, 16000} },	 /* uV */
 	[TBL_BOOSTV] =	{ .rt = {4550000, 5510000, 64000} },	 /* uV */
 	[TBL_SYSVMIN] = { .rt = {3000000, 3700000, 100000} },	 /* uV */
@@ -505,6 +507,14 @@  static int bq25890_power_supply_get_property(struct power_supply *psy,
 		val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM);
 		break;
 
+	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
+		ret = bq25890_field_read(bq, F_IILIM);
+		if (ret < 0)
+			return ret;
+
+		val->intval = bq25890_find_val(ret, TBL_IILIM);
+		break;
+
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 		ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
 		if (ret < 0)
@@ -695,6 +705,7 @@  static const enum power_supply_property bq25890_power_supply_props[] = {
 	POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
 	POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
 	POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
+	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 };