Lines Matching +full:charger +full:- +full:thermistor

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Battery and Power Management code for the Sharp SL-6000x
17 #include <asm/mach-types.h>
54 if (!bat->gpiod_bat || bat->adc_bat < 0) in tosa_read_bat()
58 gpiod_set_value(bat->gpiod_bat, 1); in tosa_read_bat()
60 value = wm97xx_read_aux_adc(dev_get_drvdata(bat->psy->dev.parent), in tosa_read_bat()
61 bat->adc_bat); in tosa_read_bat()
62 gpiod_set_value(bat->gpiod_bat, 0); in tosa_read_bat()
65 value = value * 1000000 / bat->adc_bat_divider; in tosa_read_bat()
74 if (!bat->gpiod_temp || bat->adc_temp < 0) in tosa_read_temp()
78 gpiod_set_value(bat->gpiod_temp, 1); in tosa_read_temp()
80 value = wm97xx_read_aux_adc(dev_get_drvdata(bat->psy->dev.parent), in tosa_read_temp()
81 bat->adc_temp); in tosa_read_temp()
82 gpiod_set_value(bat->gpiod_temp, 0); in tosa_read_temp()
85 value = value * 10000 / bat->adc_temp_divider; in tosa_read_temp()
97 if (bat->is_present && !bat->is_present(bat) in tosa_bat_get_property()
99 return -ENODEV; in tosa_bat_get_property()
104 val->intval = bat->status; in tosa_bat_get_property()
107 val->intval = bat->technology; in tosa_bat_get_property()
110 val->intval = tosa_read_bat(bat); in tosa_bat_get_property()
113 if (bat->full_chrg == -1) in tosa_bat_get_property()
114 val->intval = bat->bat_max; in tosa_bat_get_property()
116 val->intval = bat->full_chrg; in tosa_bat_get_property()
119 val->intval = bat->bat_max; in tosa_bat_get_property()
122 val->intval = bat->bat_min; in tosa_bat_get_property()
125 val->intval = tosa_read_temp(bat); in tosa_bat_get_property()
128 val->intval = bat->is_present ? bat->is_present(bat) : 1; in tosa_bat_get_property()
131 ret = -EINVAL; in tosa_bat_get_property()
157 struct power_supply *psy = bat->psy; in tosa_bat_update()
159 mutex_lock(&bat->work_lock); in tosa_bat_update()
161 old = bat->status; in tosa_bat_update()
163 if (bat->is_present && !bat->is_present(bat)) { in tosa_bat_update()
164 printk(KERN_NOTICE "%s not present\n", psy->desc->name); in tosa_bat_update()
165 bat->status = POWER_SUPPLY_STATUS_UNKNOWN; in tosa_bat_update()
166 bat->full_chrg = -1; in tosa_bat_update()
168 if (bat->status == POWER_SUPPLY_STATUS_DISCHARGING) { in tosa_bat_update()
169 gpiod_set_value(bat->gpiod_charge_off, 0); in tosa_bat_update()
173 if (gpiod_get_value(bat->gpiod_full)) { in tosa_bat_update()
175 bat->full_chrg == -1) in tosa_bat_update()
176 bat->full_chrg = tosa_read_bat(bat); in tosa_bat_update()
178 gpiod_set_value(bat->gpiod_charge_off, 1); in tosa_bat_update()
179 bat->status = POWER_SUPPLY_STATUS_FULL; in tosa_bat_update()
181 gpiod_set_value(bat->gpiod_charge_off, 0); in tosa_bat_update()
182 bat->status = POWER_SUPPLY_STATUS_CHARGING; in tosa_bat_update()
185 gpiod_set_value(bat->gpiod_charge_off, 1); in tosa_bat_update()
186 bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in tosa_bat_update()
189 if (old != bat->status) in tosa_bat_update()
192 mutex_unlock(&bat->work_lock); in tosa_bat_update()
222 .name = "main-battery",
232 .name = "jacket-battery",
241 .name = "backup-battery",
251 .full_chrg = -1,
272 .full_chrg = -1,
294 .full_chrg = -1,
307 .adc_temp = -1,
308 .adc_temp_divider = -1,
336 struct device *dev = &pdev->dev; in tosa_bat_probe()
340 return -ENODEV; in tosa_bat_probe()
346 "no main charger GPIO\n"); in tosa_bat_probe()
350 "no jacket charger GPIO\n"); in tosa_bat_probe()
352 /* Per-battery output check (routes battery voltage to ADC) */ in tosa_bat_probe()
376 /* Battery temperature GPIOs (routes thermistor voltage to ADC) */ in tosa_bat_probe()
499 .driver.name = "wm97xx-battery",
512 MODULE_ALIAS("platform:wm97xx-battery");