Lines Matching +full:ocv +full:- +full:capacity +full:- +full:table +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0+
12 #include <linux/devm-helpers.h>
68 * soc - state of charge - like the BSP this is stored as a percentage,
78 * Capacity of battery when fully charged, equal or less than design
79 * capacity depending upon wear. BSP kernel saves to nvram in mAh,
118 #define CHARGE_TO_ADC(capacity, res_div) \ argument
119 (capacity * res_div * 3600 / 172 * 1000)
143 return -EINVAL; in rk817_chg_cur_to_reg()
166 return -EINVAL; in rk817_chg_cur_from_reg()
177 regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_VCALIB0_H, in rk817_bat_calib_vol()
181 regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_VCALIB1_H, in rk817_bat_calib_vol()
186 charger->voltage_k = (4025 - 2300) * 1000 / in rk817_bat_calib_vol()
187 ((vcalib1 - vcalib0) ? (vcalib1 - vcalib0) : 1); in rk817_bat_calib_vol()
188 charger->voltage_b = 4025 - (charger->voltage_k * vcalib1) / 1000; in rk817_bat_calib_vol()
196 regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_IOFFSET_H, in rk817_bat_calib_cur()
198 regmap_bulk_write(charger->rk808->regmap, RK817_GAS_GAUGE_CAL_OFFSET_H, in rk817_bat_calib_cur()
215 put_unaligned_le24(charger->soc, bulk_reg); in rk817_record_battery_nvram_values()
216 ret = regmap_bulk_write(charger->rk808->regmap, RK817_GAS_GAUGE_BAT_R1, in rk817_record_battery_nvram_values()
221 * write the remaining capacity in mah to the nvram location used by in rk817_record_battery_nvram_values()
224 rsoc = (charger->soc * charger->fcc_mah) / 100000; in rk817_record_battery_nvram_values()
226 ret = regmap_bulk_write(charger->rk808->regmap, RK817_GAS_GAUGE_DATA0, in rk817_record_battery_nvram_values()
231 put_unaligned_le24(charger->fcc_mah, bulk_reg); in rk817_record_battery_nvram_values()
232 ret = regmap_bulk_write(charger->rk808->regmap, RK817_GAS_GAUGE_DATA3, in rk817_record_battery_nvram_values()
242 struct rk808 *rk808 = charger->rk808; in rk817_bat_calib_cap()
248 if (charger->charge_status == CHARGE_FINISH && (!charger->soc_cal)) { in rk817_bat_calib_cap()
251 * charge capacity. Note that if the device is unplugged for a in rk817_bat_calib_cap()
260 charger->soc = 100000; in rk817_bat_calib_cap()
261 charge_now_adc = CHARGE_TO_ADC(charger->fcc_mah, in rk817_bat_calib_cap()
262 charger->res_div); in rk817_bat_calib_cap()
264 regmap_bulk_write(rk808->regmap, RK817_GAS_GAUGE_Q_INIT_H3, in rk817_bat_calib_cap()
267 charger->soc_cal = 1; in rk817_bat_calib_cap()
268 dev_dbg(charger->dev, in rk817_bat_calib_cap()
269 "Fully charged. SOC is %d, full capacity is %d\n", in rk817_bat_calib_cap()
270 charger->soc, charger->fcc_mah * 1000); in rk817_bat_calib_cap()
277 if (charger->charge_status == CHARGE_FINISH && charger->soc_cal) { in rk817_bat_calib_cap()
278 regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3, in rk817_bat_calib_cap()
284 charger->res_div); in rk817_bat_calib_cap()
287 * Re-init columb counter with updated values to correct drift. in rk817_bat_calib_cap()
289 if (charge_now / 1000 > charger->fcc_mah) { in rk817_bat_calib_cap()
290 dev_dbg(charger->dev, in rk817_bat_calib_cap()
298 charge_now_adc = CHARGE_TO_ADC(charger->fcc_mah, in rk817_bat_calib_cap()
299 charger->res_div); in rk817_bat_calib_cap()
301 regmap_bulk_write(rk808->regmap, in rk817_bat_calib_cap()
308 * Calibrate the fully charged capacity when we previously had a full in rk817_bat_calib_cap()
309 * battery (soc_cal = 1) and are now empty (at or below minimum design in rk817_bat_calib_cap()
313 * design capacity). in rk817_bat_calib_cap()
315 regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_BAT_VOL_H, in rk817_bat_calib_cap()
318 volt_avg = (charger->voltage_k * tmp) + 1000 * charger->voltage_b; in rk817_bat_calib_cap()
319 if (volt_avg <= charger->bat_voltage_min_design_uv && in rk817_bat_calib_cap()
320 charger->soc_cal) { in rk817_bat_calib_cap()
321 regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3, in rk817_bat_calib_cap()
325 charger->res_div); in rk817_bat_calib_cap()
331 charger->fcc_mah = charger->fcc_mah - (charge_now / 1000); in rk817_bat_calib_cap()
333 dev_dbg(charger->dev, in rk817_bat_calib_cap()
334 "Recalibrating full charge capacity to %d uah\n", in rk817_bat_calib_cap()
335 charger->fcc_mah * 1000); in rk817_bat_calib_cap()
341 if (volt_avg <= charger->bat_voltage_min_design_uv) { in rk817_bat_calib_cap()
342 charger->soc = 0; in rk817_bat_calib_cap()
343 charge_now_adc = CHARGE_TO_ADC(0, charger->res_div); in rk817_bat_calib_cap()
345 regmap_bulk_write(rk808->regmap, in rk817_bat_calib_cap()
347 dev_warn(charger->dev, in rk817_bat_calib_cap()
349 volt_avg, charger->bat_voltage_min_design_uv); in rk817_bat_calib_cap()
366 * is 1, but you clear the status by writing a 1 to bit 7. in rk817_read_props()
368 regmap_read(charger->rk808->regmap, RK817_GAS_GAUGE_ADC_CONFIG1, ®); in rk817_read_props()
372 regmap_write_bits(charger->rk808->regmap, in rk817_read_props()
379 regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3, in rk817_read_props()
382 charger->charge_now_uah = ADC_TO_CHARGE_UAH(tmp, charger->res_div); in rk817_read_props()
383 if (charger->charge_now_uah < 0) in rk817_read_props()
384 charger->charge_now_uah = 0; in rk817_read_props()
385 if (charger->charge_now_uah > charger->fcc_mah * 1000) in rk817_read_props()
386 charger->charge_now_uah = charger->fcc_mah * 1000; in rk817_read_props()
389 charger->soc = charger->charge_now_uah * 100 / charger->fcc_mah; in rk817_read_props()
392 regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_BAT_VOL_H, in rk817_read_props()
395 charger->volt_avg_uv = (charger->voltage_k * tmp) + 1000 * in rk817_read_props()
396 charger->voltage_b; in rk817_read_props()
402 regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_BAT_CUR_H, in rk817_read_props()
405 charger->cur_avg_ua = ADC_TO_CURRENT(tmp, charger->res_div); in rk817_read_props()
412 regmap_read(charger->rk808->regmap, RK817_PMIC_CHRG_OUT, ®); in rk817_read_props()
413 charger->max_chg_cur_ua = in rk817_read_props()
420 regmap_read(charger->rk808->regmap, RK817_PMIC_CHRG_OUT, ®); in rk817_read_props()
421 charger->max_chg_volt_uv = ((((reg & RK817_CHRG_VOL_SEL) >> 4) * in rk817_read_props()
425 regmap_read(charger->rk808->regmap, RK817_PMIC_CHRG_STS, ®); in rk817_read_props()
426 charger->battery_present = (reg & RK817_BAT_EXS); in rk817_read_props()
429 regmap_read(charger->rk808->regmap, RK817_PMIC_CHRG_STS, ®); in rk817_read_props()
430 charger->charge_status = (reg >> 4) & 0x07; in rk817_read_props()
444 regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_USB_VOL_H, in rk817_read_props()
447 if (reg > 1) { in rk817_read_props()
448 tmp = ((charger->voltage_k * reg / 1000 + charger->voltage_b) * in rk817_read_props()
450 charger->charger_input_volt_avg_uv = tmp * 1000; in rk817_read_props()
452 charger->charger_input_volt_avg_uv = 0; in rk817_read_props()
455 /* Calibrate battery capacity and soc. */ in rk817_read_props()
467 val->intval = charger->battery_present; in rk817_bat_get_prop()
470 if (charger->cur_avg_ua < 0) { in rk817_bat_get_prop()
471 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in rk817_bat_get_prop()
474 switch (charger->charge_status) { in rk817_bat_get_prop()
476 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in rk817_bat_get_prop()
480 * observed it but assume it's a pre-charge for a dead in rk817_bat_get_prop()
486 val->intval = POWER_SUPPLY_STATUS_CHARGING; in rk817_bat_get_prop()
489 val->intval = POWER_SUPPLY_STATUS_FULL; in rk817_bat_get_prop()
492 val->intval = POWER_SUPPLY_STATUS_UNKNOWN; in rk817_bat_get_prop()
493 return -EINVAL; in rk817_bat_get_prop()
498 switch (charger->charge_status) { in rk817_bat_get_prop()
501 val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; in rk817_bat_get_prop()
504 val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; in rk817_bat_get_prop()
508 val->intval = POWER_SUPPLY_CHARGE_TYPE_STANDARD; in rk817_bat_get_prop()
511 val->intval = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; in rk817_bat_get_prop()
516 val->intval = charger->fcc_mah * 1000; in rk817_bat_get_prop()
519 val->intval = charger->bat_charge_full_design_uah; in rk817_bat_get_prop()
522 val->intval = 0; in rk817_bat_get_prop()
525 val->intval = charger->charge_now_uah; in rk817_bat_get_prop()
528 val->intval = charger->bat_voltage_min_design_uv; in rk817_bat_get_prop()
532 val->intval = (charger->soc + 500) / 1000; in rk817_bat_get_prop()
533 if (val->intval > 100) in rk817_bat_get_prop()
534 val->intval = 100; in rk817_bat_get_prop()
535 if (val->intval < 0) in rk817_bat_get_prop()
536 val->intval = 0; in rk817_bat_get_prop()
539 val->intval = charger->volt_avg_uv; in rk817_bat_get_prop()
542 val->intval = charger->cur_avg_ua; in rk817_bat_get_prop()
545 val->intval = charger->max_chg_cur_ua; in rk817_bat_get_prop()
548 val->intval = charger->max_chg_volt_uv; in rk817_bat_get_prop()
551 val->intval = charger->bat_voltage_max_design_uv; in rk817_bat_get_prop()
554 return -EINVAL; in rk817_bat_get_prop()
567 val->intval = charger->plugged_in; in rk817_chg_get_prop()
571 val->intval = 5500000; in rk817_chg_get_prop()
575 val->intval = 3800000; in rk817_chg_get_prop()
578 val->intval = charger->charger_input_volt_avg_uv; in rk817_chg_get_prop()
586 val->intval = POWER_SUPPLY_USB_TYPE_DCP; in rk817_chg_get_prop()
589 return -EINVAL; in rk817_chg_get_prop()
600 charger->plugged_in = 1; in rk817_plug_in_isr()
601 power_supply_changed(charger->chg_ps); in rk817_plug_in_isr()
602 power_supply_changed(charger->bat_ps); in rk817_plug_in_isr()
603 /* try to recalibrate capacity if we hit full charge. */ in rk817_plug_in_isr()
604 charger->soc_cal = 0; in rk817_plug_in_isr()
608 dev_dbg(charger->dev, "Power Cord Inserted\n"); in rk817_plug_in_isr()
619 rk808 = charger->rk808; in rk817_plug_out_isr()
620 charger->plugged_in = 0; in rk817_plug_out_isr()
621 power_supply_changed(charger->bat_ps); in rk817_plug_out_isr()
622 power_supply_changed(charger->chg_ps); in rk817_plug_out_isr()
630 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_IN, in rk817_plug_out_isr()
632 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_IN, RK817_USB_VLIM_EN, in rk817_plug_out_isr()
639 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_IN, in rk817_plug_out_isr()
641 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_IN, RK817_USB_ILIM_EN, in rk817_plug_out_isr()
646 dev_dbg(charger->dev, "Power Cord Removed\n"); in rk817_plug_out_isr()
677 .name = "rk817-battery",
685 .name = "rk817-charger",
699 /* Read the nvram data for full charge capacity. */ in rk817_read_battery_nvram_values()
700 ret = regmap_bulk_read(charger->rk808->regmap, in rk817_read_battery_nvram_values()
704 charger->fcc_mah = get_unaligned_le24(bulk_reg); in rk817_read_battery_nvram_values()
712 if ((charger->fcc_mah < 500) || in rk817_read_battery_nvram_values()
713 ((charger->fcc_mah * 1000) > charger->bat_charge_full_design_uah)) { in rk817_read_battery_nvram_values()
714 dev_info(charger->dev, in rk817_read_battery_nvram_values()
716 charger->bat_charge_full_design_uah); in rk817_read_battery_nvram_values()
717 charger->fcc_mah = charger->bat_charge_full_design_uah / 1000; in rk817_read_battery_nvram_values()
723 * U-Boot, or even i2cset) can write to this register. If the value is in rk817_read_battery_nvram_values()
727 ret = regmap_bulk_read(charger->rk808->regmap, in rk817_read_battery_nvram_values()
731 charger->soc = get_unaligned_le24(bulk_reg); in rk817_read_battery_nvram_values()
732 if (charger->soc > 10000) in rk817_read_battery_nvram_values()
733 charger->soc = 10000; in rk817_read_battery_nvram_values()
734 if (charger->soc < 0) in rk817_read_battery_nvram_values()
735 charger->soc = 0; in rk817_read_battery_nvram_values()
744 struct rk808 *rk808 = charger->rk808; in rk817_read_or_set_full_charge_on_boot()
754 ret = regmap_read(rk808->regmap, RK817_GAS_GAUGE_GG_STS, ®); in rk817_read_or_set_full_charge_on_boot()
759 * If the battery is uninitialized, use the poweron voltage and an ocv in rk817_read_or_set_full_charge_on_boot()
764 regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_PWRON_VOL_H, in rk817_read_or_set_full_charge_on_boot()
767 boot_voltage = (charger->voltage_k * tmp) + in rk817_read_or_set_full_charge_on_boot()
768 1000 * charger->voltage_b; in rk817_read_or_set_full_charge_on_boot()
771 * 20C for OCV lookup. If lookup fails, report error with OCV in rk817_read_or_set_full_charge_on_boot()
772 * table. in rk817_read_or_set_full_charge_on_boot()
774 charger->soc = power_supply_batinfo_ocv2cap(bat_info, in rk817_read_or_set_full_charge_on_boot()
777 if (charger->soc < 0) in rk817_read_or_set_full_charge_on_boot()
778 charger->soc = 0; in rk817_read_or_set_full_charge_on_boot()
780 /* Guess that full charge capacity is the design capacity */ in rk817_read_or_set_full_charge_on_boot()
781 charger->fcc_mah = charger->bat_charge_full_design_uah / 1000; in rk817_read_or_set_full_charge_on_boot()
784 * though datasheet claims it's a read-only value. in rk817_read_or_set_full_charge_on_boot()
786 regmap_write_bits(rk808->regmap, RK817_GAS_GAUGE_GG_STS, in rk817_read_or_set_full_charge_on_boot()
797 regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3, in rk817_read_or_set_full_charge_on_boot()
803 charger->res_div) / 1000; in rk817_read_or_set_full_charge_on_boot()
806 * minutes as it tends to drift downward. If so, re-init soc in rk817_read_or_set_full_charge_on_boot()
809 * counting at 2550 (0xFF) minutes. BSP kernel used OCV, but in rk817_read_or_set_full_charge_on_boot()
815 regmap_read(rk808->regmap, RK817_GAS_GAUGE_OFF_CNT, &off_time); in rk817_read_or_set_full_charge_on_boot()
817 regmap_bulk_read(rk808->regmap, in rk817_read_or_set_full_charge_on_boot()
821 boot_voltage = (charger->voltage_k * tmp) + in rk817_read_or_set_full_charge_on_boot()
822 1000 * charger->voltage_b; in rk817_read_or_set_full_charge_on_boot()
823 charger->soc = in rk817_read_or_set_full_charge_on_boot()
828 charger->soc = (boot_charge_mah * 1000 * 100 / in rk817_read_or_set_full_charge_on_boot()
829 charger->fcc_mah); in rk817_read_or_set_full_charge_on_boot()
834 * Now we have our full charge capacity and soc, init the columb in rk817_read_or_set_full_charge_on_boot()
837 boot_charge_mah = charger->soc * charger->fcc_mah / 100 / 1000; in rk817_read_or_set_full_charge_on_boot()
838 if (boot_charge_mah > charger->fcc_mah) in rk817_read_or_set_full_charge_on_boot()
839 boot_charge_mah = charger->fcc_mah; in rk817_read_or_set_full_charge_on_boot()
840 tmp = CHARGE_TO_ADC(boot_charge_mah, charger->res_div); in rk817_read_or_set_full_charge_on_boot()
842 ret = regmap_bulk_write(rk808->regmap, RK817_GAS_GAUGE_Q_INIT_H3, in rk817_read_or_set_full_charge_on_boot()
847 /* Set QMAX value to max design capacity. */ in rk817_read_or_set_full_charge_on_boot()
848 tmp = CHARGE_TO_ADC((charger->bat_charge_full_design_uah / 1000), in rk817_read_or_set_full_charge_on_boot()
849 charger->res_div); in rk817_read_or_set_full_charge_on_boot()
851 ret = regmap_bulk_write(rk808->regmap, RK817_GAS_GAUGE_Q_MAX_H3, in rk817_read_or_set_full_charge_on_boot()
862 struct rk808 *rk808 = charger->rk808; in rk817_battery_init()
869 regmap_read(rk808->regmap, RK817_SYS_STS, &tmp); in rk817_battery_init()
870 charger->plugged_in = (tmp & RK817_PLUG_IN_STS); in rk817_battery_init()
877 regmap_write(rk808->regmap, RK817_GAS_GAUGE_ADC_CONFIG0, 0xfc); in rk817_battery_init()
884 regmap_write(rk808->regmap, RK817_GAS_GAUGE_GG_CON, 0x04); in rk817_battery_init()
890 tmp = CURRENT_TO_ADC(charger->sleep_enter_current_ua, in rk817_battery_init()
891 charger->res_div); in rk817_battery_init()
893 regmap_bulk_write(rk808->regmap, RK817_GAS_GAUGE_RELAX_THRE_H, in rk817_battery_init()
897 tmp = CURRENT_TO_ADC(charger->sleep_filter_current_ua, in rk817_battery_init()
898 charger->res_div); in rk817_battery_init()
900 regmap_bulk_write(rk808->regmap, RK817_GAS_GAUGE_SLEEP_CON_SAMP_CUR_H, in rk817_battery_init()
904 regmap_write_bits(rk808->regmap, RK817_GAS_GAUGE_GG_STS, in rk817_battery_init()
908 * Set OCV Threshold Voltage to 127.5mV. This was hard coded like this in rk817_battery_init()
911 regmap_write(rk808->regmap, RK817_GAS_GAUGE_OCV_THRE_VOL, 0xff); in rk817_battery_init()
918 max_chg_vol_mv = bat_info->constant_charge_voltage_max_uv / 1000; in rk817_battery_init()
919 max_chg_cur_ma = bat_info->constant_charge_current_max_ua / 1000; in rk817_battery_init()
922 return dev_err_probe(charger->dev, -EINVAL, in rk817_battery_init()
927 dev_info(charger->dev, in rk817_battery_init()
933 return dev_err_probe(charger->dev, -EINVAL, in rk817_battery_init()
938 dev_info(charger->dev, in rk817_battery_init()
947 max_chg_vol_reg = (max_chg_vol_mv - 4100) / 50; in rk817_battery_init()
952 return dev_err_probe(charger->dev, -EINVAL, in rk817_battery_init()
957 return dev_err_probe(charger->dev, -EINVAL, in rk817_battery_init()
966 ret = regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_OUT, in rk817_battery_init()
969 dev_emerg(charger->dev, in rk817_battery_init()
974 ret = regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_OUT, in rk817_battery_init()
977 dev_emerg(charger->dev, in rk817_battery_init()
983 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_TERM, in rk817_battery_init()
990 chg_term_ma = bat_info->charge_term_current_ua / 1000; in rk817_battery_init()
992 dev_warn(charger->dev, in rk817_battery_init()
1002 chg_term_i_reg = (chg_term_ma - 100) / 100; in rk817_battery_init()
1003 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_TERM, in rk817_battery_init()
1014 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_IN, in rk817_battery_init()
1016 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_IN, RK817_USB_VLIM_EN, in rk817_battery_init()
1023 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_IN, in rk817_battery_init()
1025 regmap_write_bits(rk808->regmap, RK817_PMIC_CHRG_IN, RK817_USB_ILIM_EN, in rk817_battery_init()
1040 queue_delayed_work(system_wq, &charger->work, msecs_to_jiffies(8000)); in rk817_charging_monitor()
1052 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); in rk817_charger_probe()
1056 struct device *dev = &pdev->dev; in rk817_charger_probe()
1062 node = of_get_child_by_name(dev->parent->of_node, "charger"); in rk817_charger_probe()
1064 return -ENODEV; in rk817_charger_probe()
1066 ret = devm_add_action_or_reset(&pdev->dev, rk817_cleanup_node, node); in rk817_charger_probe()
1070 charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL); in rk817_charger_probe()
1072 return -ENOMEM; in rk817_charger_probe()
1074 charger->rk808 = rk808; in rk817_charger_probe()
1076 charger->dev = &pdev->dev; in rk817_charger_probe()
1089 ret = of_property_read_u32(node, "rockchip,resistor-sense-micro-ohms", in rk817_charger_probe()
1096 * Store as a 1 or a 2, since all we really use the value for is as a in rk817_charger_probe()
1099 charger->res_div = (of_value == 20000) ? 2 : 1; in rk817_charger_probe()
1106 "rockchip,sleep-enter-current-microamp", in rk817_charger_probe()
1112 charger->sleep_enter_current_ua = of_value; in rk817_charger_probe()
1116 "rockchip,sleep-filter-current-microamp", in rk817_charger_probe()
1123 charger->sleep_filter_current_ua = of_value; in rk817_charger_probe()
1125 charger->bat_ps = devm_power_supply_register(&pdev->dev, in rk817_charger_probe()
1127 if (IS_ERR(charger->bat_ps)) in rk817_charger_probe()
1128 return dev_err_probe(dev, -EINVAL, in rk817_charger_probe()
1131 charger->chg_ps = devm_power_supply_register(&pdev->dev, in rk817_charger_probe()
1133 if (IS_ERR(charger->chg_ps)) in rk817_charger_probe()
1134 return dev_err_probe(dev, -EINVAL, in rk817_charger_probe()
1137 ret = power_supply_get_battery_info(charger->bat_ps, in rk817_charger_probe()
1144 if ((bat_info->charge_full_design_uah <= 0) || in rk817_charger_probe()
1145 (bat_info->voltage_min_design_uv <= 0) || in rk817_charger_probe()
1146 (bat_info->voltage_max_design_uv <= 0) || in rk817_charger_probe()
1147 (bat_info->constant_charge_voltage_max_uv <= 0) || in rk817_charger_probe()
1148 (bat_info->constant_charge_current_max_ua <= 0) || in rk817_charger_probe()
1149 (bat_info->charge_term_current_ua <= 0)) { in rk817_charger_probe()
1150 return dev_err_probe(dev, -EINVAL, in rk817_charger_probe()
1154 charger->bat_charge_full_design_uah = bat_info->charge_full_design_uah; in rk817_charger_probe()
1155 charger->bat_voltage_min_design_uv = bat_info->voltage_min_design_uv; in rk817_charger_probe()
1156 charger->bat_voltage_max_design_uv = bat_info->voltage_max_design_uv; in rk817_charger_probe()
1166 power_supply_put_battery_info(charger->bat_ps, bat_info); in rk817_charger_probe()
1172 plugout_irq = platform_get_irq(pdev, 1); in rk817_charger_probe()
1176 ret = devm_request_threaded_irq(charger->dev, plugin_irq, NULL, in rk817_charger_probe()
1181 return dev_err_probe(&pdev->dev, ret, in rk817_charger_probe()
1185 ret = devm_request_threaded_irq(charger->dev, plugout_irq, NULL, in rk817_charger_probe()
1190 return dev_err_probe(&pdev->dev, ret, in rk817_charger_probe()
1194 ret = devm_delayed_work_autocancel(&pdev->dev, &charger->work, in rk817_charger_probe()
1200 mod_delayed_work(system_wq, &charger->work, 0); in rk817_charger_probe()
1211 mod_delayed_work(system_wq, &charger->work, 0); in rk817_resume()
1221 .name = "rk817-charger",
1231 MODULE_ALIAS("platform:rk817-charger");