Lines Matching refs:bat

30 	bool (*is_present)(struct tosa_bat *bat);
50 static unsigned long tosa_read_bat(struct tosa_bat *bat) in tosa_read_bat() argument
54 if (bat->gpio_bat < 0 || bat->adc_bat < 0) in tosa_read_bat()
58 gpio_set_value(bat->gpio_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 gpio_set_value(bat->gpio_bat, 0); in tosa_read_bat()
65 value = value * 1000000 / bat->adc_bat_divider; in tosa_read_bat()
70 static unsigned long tosa_read_temp(struct tosa_bat *bat) in tosa_read_temp() argument
74 if (bat->gpio_temp < 0 || bat->adc_temp < 0) in tosa_read_temp()
78 gpio_set_value(bat->gpio_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 gpio_set_value(bat->gpio_temp, 0); in tosa_read_temp()
85 value = value * 10000 / bat->adc_temp_divider; in tosa_read_temp()
95 struct tosa_bat *bat = power_supply_get_drvdata(psy); in tosa_bat_get_property() local
97 if (bat->is_present && !bat->is_present(bat) 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()
137 static bool tosa_jacket_bat_is_present(struct tosa_bat *bat) in tosa_jacket_bat_is_present() argument
154 static void tosa_bat_update(struct tosa_bat *bat) in tosa_bat_update() argument
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()
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 gpio_set_value(bat->gpio_charge_off, 0); in tosa_bat_update()
173 if (gpio_get_value(bat->gpio_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 gpio_set_value(bat->gpio_charge_off, 1); in tosa_bat_update()
179 bat->status = POWER_SUPPLY_STATUS_FULL; in tosa_bat_update()
181 gpio_set_value(bat->gpio_charge_off, 0); in tosa_bat_update()
182 bat->status = POWER_SUPPLY_STATUS_CHARGING; in tosa_bat_update()
185 gpio_set_value(bat->gpio_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()