Re: [RESEND 3/4 v7] power: supply: Add charger driver for Rockchip RK817

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Chris,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on lee-mfd/for-mfd-next]
[also build test WARNING on sre-power-supply/for-next rockchip/for-next linus/master v5.19-rc7 next-20220722]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chris-Morgan/power-supply-Add-Support-for-RK817-Charger/20220722-002431
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
config: parisc-allmodconfig (https://download.01.org/0day-ci/archive/20220724/202207242227.mttUkfTB-lkp@xxxxxxxxx/config)
compiler: hppa-linux-gcc (GCC) 12.1.0
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
        # https://github.com/intel-lab-lkp/linux/commit/008e6f0d590e275cbb56d4506b5638156506dd40
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Chris-Morgan/power-supply-Add-Support-for-RK817-Charger/20220722-002431
        git checkout 008e6f0d590e275cbb56d4506b5638156506dd40
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash drivers/power/supply/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   drivers/power/supply/rk817_charger.c: In function 'rk817_read_or_set_full_charge_on_boot':
>> drivers/power/supply/rk817_charger.c:701:33: warning: variable 'soc_tmp3' set but not used [-Wunused-but-set-variable]
     701 |         int soc_tmp1, soc_tmp2, soc_tmp3;
         |                                 ^~~~~~~~
>> drivers/power/supply/rk817_charger.c:701:23: warning: variable 'soc_tmp2' set but not used [-Wunused-but-set-variable]
     701 |         int soc_tmp1, soc_tmp2, soc_tmp3;
         |                       ^~~~~~~~
>> drivers/power/supply/rk817_charger.c:701:13: warning: variable 'soc_tmp1' set but not used [-Wunused-but-set-variable]
     701 |         int soc_tmp1, soc_tmp2, soc_tmp3;
         |             ^~~~~~~~


vim +/soc_tmp3 +701 drivers/power/supply/rk817_charger.c

   692	
   693	static int
   694	rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
   695					struct power_supply_battery_info *bat_info)
   696	{
   697		struct rk808 *rk808 = charger->rk808;
   698		u8 bulk_reg[4];
   699		u32 boot_voltage, boot_charge_mah, tmp;
   700		int ret, reg, off_time;
 > 701		int soc_tmp1, soc_tmp2, soc_tmp3;
   702		bool first_boot;
   703	
   704		/* Check if the battery is uninitalized. If it is, the columb counter
   705		 * needs to be set up.
   706		 */
   707		ret = regmap_read(rk808->regmap, RK817_GAS_GAUGE_GG_STS, &reg);
   708		if (ret < 0)
   709			return ret;
   710		first_boot = reg & RK817_BAT_CON;
   711		/* If the battery is uninitialized, use the poweron voltage and an ocv
   712		 * lookup to guess our charge. The number won't be very accurate until
   713		 * we hit either our minimum voltage (0%) or full charge (100%).
   714		 */
   715		if (first_boot) {
   716			regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_PWRON_VOL_H,
   717					 bulk_reg, 2);
   718			tmp = get_unaligned_be16(bulk_reg);
   719			boot_voltage = (charger->voltage_k * tmp) +
   720					1000 * charger->voltage_b;
   721			/* Since only implementation has no working thermistor, assume
   722			 * 20C for OCV lookup. If lookup fails, report error with OCV
   723			 * table.
   724			 */
   725			charger->soc = power_supply_batinfo_ocv2cap(bat_info,
   726								    boot_voltage,
   727								    20) * 1000;
   728			if (charger->soc < 0)
   729				charger->soc = 0;
   730	
   731			/* Guess that full charge capacity is the design capacity */
   732			charger->fcc_mah = charger->bat_charge_full_design_uah / 1000;
   733			/* Set battery as "set up". BSP driver uses this value even
   734			 * though datasheet claims it's a read-only value.
   735			 */
   736			regmap_write_bits(rk808->regmap, RK817_GAS_GAUGE_GG_STS,
   737					  RK817_BAT_CON, 0);
   738			/* Save nvram values */
   739			ret = rk817_record_battery_nvram_values(charger);
   740			if (ret < 0)
   741				return ret;
   742		} else {
   743			ret = rk817_read_battery_nvram_values(charger);
   744			if (ret < 0)
   745				return ret;
   746	
   747			regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
   748					 bulk_reg, 4);
   749			tmp = get_unaligned_be32(bulk_reg);
   750			if (tmp < 0)
   751				tmp = 0;
   752			boot_charge_mah = ADC_TO_CHARGE_UAH(tmp,
   753							    charger->res_div) / 1000;
   754			/* Check if the columb counter has been off for more than 300
   755			 * minutes as it tends to drift downward. If so, re-init soc
   756			 * with the boot voltage instead. Note the unit values for the
   757			 * OFF_CNT register appear to be in decaminutes and stops
   758			 * counting at 2550 (0xFF) minutes. BSP kernel used OCV, but
   759			 * for me occasionally that would show invalid values. Boot
   760			 * voltage is only accurate for me on first poweron (not
   761			 * reboots), but we shouldn't ever encounter an OFF_CNT more
   762			 * than 0 on a reboot anyway.
   763			 */
   764			regmap_read(rk808->regmap, RK817_GAS_GAUGE_OFF_CNT, &off_time);
   765			if (off_time >= 30) {
   766				regmap_bulk_read(rk808->regmap,
   767						 RK817_GAS_GAUGE_PWRON_VOL_H,
   768						 bulk_reg, 2);
   769				tmp = get_unaligned_be16(bulk_reg);
   770				boot_voltage = (charger->voltage_k * tmp) +
   771						1000 * charger->voltage_b;
   772				charger->soc =
   773					power_supply_batinfo_ocv2cap(bat_info,
   774								     boot_voltage,
   775								     20) * 1000;
   776			} else {
   777				charger->soc = (boot_charge_mah * 1000 * 100 /
   778						charger->fcc_mah);
   779			}
   780		}
   781	
   782		regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_PWRON_VOL_H,
   783				 bulk_reg, 2);
   784		tmp = get_unaligned_be16(bulk_reg);
   785		boot_voltage = (charger->voltage_k * tmp) + 1000 * charger->voltage_b;
   786		soc_tmp1 = power_supply_batinfo_ocv2cap(bat_info,
   787							boot_voltage, 20) * 1000;
   788		regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
   789				 bulk_reg, 4);
   790		tmp = get_unaligned_be32(bulk_reg);
   791		if (tmp < 0)
   792			tmp = 0;
   793		boot_charge_mah = ADC_TO_CHARGE_UAH(tmp, charger->res_div) / 1000;
   794		soc_tmp2 = (boot_charge_mah * 1000 * 100 / charger->fcc_mah);
   795		regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_OCV_VOL_H,
   796				 bulk_reg, 2);
   797		tmp = get_unaligned_be16(bulk_reg);
   798		boot_voltage = (charger->voltage_k * tmp) + 1000 * charger->voltage_b;
   799		soc_tmp3 = power_supply_batinfo_ocv2cap(bat_info,
   800							boot_voltage, 20) * 1000;
   801	
   802		/* Now we have our full charge capacity and soc, init the columb
   803		 * counter.
   804		 */
   805		boot_charge_mah = charger->soc * charger->fcc_mah / 100 / 1000;
   806		if (boot_charge_mah > charger->fcc_mah)
   807			boot_charge_mah = charger->fcc_mah;
   808		tmp = CHARGE_TO_ADC(boot_charge_mah, charger->res_div);
   809		put_unaligned_be32(tmp, bulk_reg);
   810		ret = regmap_bulk_write(rk808->regmap, RK817_GAS_GAUGE_Q_INIT_H3,
   811				  bulk_reg, 4);
   812		if (ret < 0)
   813			return ret;
   814	
   815		/* Set QMAX value to max design capacity. */
   816		tmp = CHARGE_TO_ADC((charger->bat_charge_full_design_uah / 1000),
   817				    charger->res_div);
   818		put_unaligned_be32(tmp, bulk_reg);
   819		ret = regmap_bulk_write(rk808->regmap, RK817_GAS_GAUGE_Q_MAX_H3,
   820					bulk_reg, 4);
   821		if (ret < 0)
   822			return ret;
   823	
   824		return 0;
   825	}
   826	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux