diff mbox series

[11/14] power: supply: bq25890: show measured VBUS

Message ID 32ec8cef47cb49e02542916ae15972ba2e619e5a.1585838679.git.mirq-linux@rere.qmqm.pl (mailing list archive)
State Not Applicable, archived
Headers show
Series power: supply: bq25890: fix and extend | expand

Commit Message

Michał Mirosław April 2, 2020, 2:58 p.m. UTC
Export VBUS measurement via INPUT_VOLTAGE_NOW property.

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

Comments

kernel test robot April 3, 2020, 9:06 p.m. UTC | #1
Hi "Michał,

I love your patch! Yet something to improve:

[auto build test ERROR on power-supply/for-next]
[also build test ERROR on linus/master v5.6 next-20200403]
[cannot apply to linux/master]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Micha-Miros-aw/power-supply-bq25890-fix-and-extend/20200404-010738
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: parisc-allyesconfig (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.3.0 make.cross ARCH=parisc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/power/supply/bq25890_charger.c: In function 'bq25890_is_adc_property':
   drivers/power/supply/bq25890_charger.c:383:7: error: 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW' undeclared (first use in this function); did you mean 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT'?
     383 |  case POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW:
         |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |       POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT
   drivers/power/supply/bq25890_charger.c:383:7: note: each undeclared identifier is reported only once for each function it appears in
   drivers/power/supply/bq25890_charger.c:384:7: error: 'POWER_SUPPLY_PROP_OUTPUT_VOLTAGE_NOW' undeclared (first use in this function); did you mean 'POWER_SUPPLY_PROP_VOLTAGE_NOW'?
     384 |  case POWER_SUPPLY_PROP_OUTPUT_VOLTAGE_NOW:
         |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |       POWER_SUPPLY_PROP_VOLTAGE_NOW
   drivers/power/supply/bq25890_charger.c: In function 'bq25890_power_supply_get_property':
   drivers/power/supply/bq25890_charger.c:509:7: error: 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW' undeclared (first use in this function); did you mean 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT'?
     509 |  case POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW:
         |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |       POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT
   drivers/power/supply/bq25890_charger.c: At top level:
>> drivers/power/supply/bq25890_charger.c:726:2: error: 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW' undeclared here (not in a function); did you mean 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT'?
     726 |  POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW,
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |  POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT
   drivers/power/supply/bq25890_charger.c:738:16: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     738 |  .properties = bq25890_power_supply_props,
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~

vim +726 drivers/power/supply/bq25890_charger.c

   712	
   713	static const enum power_supply_property bq25890_power_supply_props[] = {
   714		POWER_SUPPLY_PROP_MANUFACTURER,
   715		POWER_SUPPLY_PROP_MODEL_NAME,
   716		POWER_SUPPLY_PROP_STATUS,
   717		POWER_SUPPLY_PROP_CHARGE_TYPE,
   718		POWER_SUPPLY_PROP_ONLINE,
   719		POWER_SUPPLY_PROP_HEALTH,
   720		POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
   721		POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
   722		POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
   723		POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
   724		POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
   725		POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
 > 726		POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW,
   727		POWER_SUPPLY_PROP_VOLTAGE_NOW,
   728		POWER_SUPPLY_PROP_CURRENT_NOW,
   729	};
   730	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot April 3, 2020, 11:04 p.m. UTC | #2
Hi "Michał,

I love your patch! Yet something to improve:

[auto build test ERROR on power-supply/for-next]
[also build test ERROR on linus/master v5.6 next-20200403]
[cannot apply to linux/master]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Micha-Miros-aw/power-supply-bq25890-fix-and-extend/20200404-010738
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: mips-allyesconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/power/supply/bq25890_charger.c: In function 'bq25890_is_adc_property':
   drivers/power/supply/bq25890_charger.c:383:7: error: 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW' undeclared (first use in this function); did you mean 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT'?
     383 |  case POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW:
         |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |       POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT
   drivers/power/supply/bq25890_charger.c:383:7: note: each undeclared identifier is reported only once for each function it appears in
   drivers/power/supply/bq25890_charger.c:384:7: error: 'POWER_SUPPLY_PROP_OUTPUT_VOLTAGE_NOW' undeclared (first use in this function); did you mean 'POWER_SUPPLY_PROP_VOLTAGE_NOW'?
     384 |  case POWER_SUPPLY_PROP_OUTPUT_VOLTAGE_NOW:
         |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |       POWER_SUPPLY_PROP_VOLTAGE_NOW
   drivers/power/supply/bq25890_charger.c: In function 'bq25890_power_supply_get_property':
   drivers/power/supply/bq25890_charger.c:509:7: error: 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW' undeclared (first use in this function); did you mean 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT'?
     509 |  case POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW:
         |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |       POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT
   drivers/power/supply/bq25890_charger.c: At top level:
>> drivers/power/supply/bq25890_charger.c:726:2: error: 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW' undeclared here (not in a function); did you mean 'POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT'?
     726 |  POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW,
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |  POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT
   drivers/power/supply/bq25890_charger.c:738:16: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     738 |  .properties = bq25890_power_supply_props,
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~

vim +726 drivers/power/supply/bq25890_charger.c

   712	
   713	static const enum power_supply_property bq25890_power_supply_props[] = {
   714		POWER_SUPPLY_PROP_MANUFACTURER,
   715		POWER_SUPPLY_PROP_MODEL_NAME,
   716		POWER_SUPPLY_PROP_STATUS,
   717		POWER_SUPPLY_PROP_CHARGE_TYPE,
   718		POWER_SUPPLY_PROP_ONLINE,
   719		POWER_SUPPLY_PROP_HEALTH,
   720		POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
   721		POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
   722		POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
   723		POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
   724		POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
   725		POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
 > 726		POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW,
   727		POWER_SUPPLY_PROP_VOLTAGE_NOW,
   728		POWER_SUPPLY_PROP_CURRENT_NOW,
   729	};
   730	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index 250468f3ff18..d23274d13263 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -506,6 +506,24 @@  static int bq25890_power_supply_get_property(struct power_supply *psy,
 		val->intval = bq25890_find_val(ret, TBL_IILIM);
 		break;
 
+	case POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW:
+		ret = bq25890_field_read(bq, F_VBUS_GD); /* is VBUS connected? */
+		if (ret < 0)
+			return ret;
+
+		if (!ret) {
+			val->intval = 0;
+			break;
+		}
+
+		ret = bq25890_field_read(bq, F_VBUSV); /* read measured value */
+		if (ret < 0)
+			return ret;
+
+		/* converted_val = 2.6V + ADC_val * 100mV */
+		val->intval = 2600000 + ret * 100000;
+		break;
+
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 		ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
 		if (ret < 0)
@@ -705,6 +723,7 @@  static const enum power_supply_property bq25890_power_supply_props[] = {
 	POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
 	POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
 	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
+	POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_CURRENT_NOW,
 };