Lines Matching full:bat

35 	bool (*is_present)(struct collie_bat *bat);
54 static unsigned long collie_read_bat(struct collie_bat *bat) in collie_read_bat() argument
58 if (!bat->gpio_bat || bat->adc_bat < 0) in collie_read_bat()
61 gpiod_set_value(bat->gpio_bat, 1); in collie_read_bat()
64 value = ucb1x00_adc_read(ucb, bat->adc_bat, UCB_SYNC); in collie_read_bat()
66 gpiod_set_value(bat->gpio_bat, 0); in collie_read_bat()
68 value = value * 1000000 / bat->adc_bat_divider; in collie_read_bat()
73 static unsigned long collie_read_temp(struct collie_bat *bat) in collie_read_temp() argument
76 if (!bat->gpio_temp || bat->adc_temp < 0) in collie_read_temp()
80 gpiod_set_value(bat->gpio_temp, 1); in collie_read_temp()
83 value = ucb1x00_adc_read(ucb, bat->adc_temp, UCB_SYNC); in collie_read_temp()
85 gpiod_set_value(bat->gpio_temp, 0); in collie_read_temp()
88 value = value * 10000 / bat->adc_temp_divider; in collie_read_temp()
98 struct collie_bat *bat = power_supply_get_drvdata(psy); in collie_bat_get_property() local
100 if (bat->is_present && !bat->is_present(bat) in collie_bat_get_property()
107 val->intval = bat->status; in collie_bat_get_property()
110 val->intval = bat->technology; in collie_bat_get_property()
113 val->intval = collie_read_bat(bat); in collie_bat_get_property()
116 if (bat->full_chrg == -1) in collie_bat_get_property()
117 val->intval = bat->bat_max; in collie_bat_get_property()
119 val->intval = bat->full_chrg; in collie_bat_get_property()
122 val->intval = bat->bat_max; in collie_bat_get_property()
125 val->intval = bat->bat_min; in collie_bat_get_property()
128 val->intval = collie_read_temp(bat); in collie_bat_get_property()
131 val->intval = bat->is_present ? bat->is_present(bat) : 1; in collie_bat_get_property()
152 static void collie_bat_update(struct collie_bat *bat) in collie_bat_update() argument
155 struct power_supply *psy = bat->psy; in collie_bat_update()
157 mutex_lock(&bat->work_lock); in collie_bat_update()
159 old = bat->status; in collie_bat_update()
161 if (bat->is_present && !bat->is_present(bat)) { in collie_bat_update()
163 bat->status = POWER_SUPPLY_STATUS_UNKNOWN; in collie_bat_update()
164 bat->full_chrg = -1; in collie_bat_update()
166 if (bat->status == POWER_SUPPLY_STATUS_DISCHARGING) { in collie_bat_update()
167 gpiod_set_value(bat->gpio_charge_on, 1); in collie_bat_update()
171 if (gpiod_get_value(bat->gpio_full)) { in collie_bat_update()
173 bat->full_chrg == -1) in collie_bat_update()
174 bat->full_chrg = collie_read_bat(bat); in collie_bat_update()
176 gpiod_set_value(bat->gpio_charge_on, 0); in collie_bat_update()
177 bat->status = POWER_SUPPLY_STATUS_FULL; in collie_bat_update()
179 gpiod_set_value(bat->gpio_charge_on, 1); in collie_bat_update()
180 bat->status = POWER_SUPPLY_STATUS_CHARGING; in collie_bat_update()
183 gpiod_set_value(bat->gpio_charge_on, 0); in collie_bat_update()
184 bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in collie_bat_update()
187 if (old != bat->status) in collie_bat_update()
190 mutex_unlock(&bat->work_lock); in collie_bat_update()