Lines Matching refs:bat

33 	bool (*is_present)(struct collie_bat *bat);
52 static unsigned long collie_read_bat(struct collie_bat *bat) in collie_read_bat() argument
56 if (bat->gpio_bat < 0 || bat->adc_bat < 0) in collie_read_bat()
59 gpio_set_value(bat->gpio_bat, 1); in collie_read_bat()
62 value = ucb1x00_adc_read(ucb, bat->adc_bat, UCB_SYNC); in collie_read_bat()
64 gpio_set_value(bat->gpio_bat, 0); in collie_read_bat()
66 value = value * 1000000 / bat->adc_bat_divider; in collie_read_bat()
71 static unsigned long collie_read_temp(struct collie_bat *bat) in collie_read_temp() argument
74 if (bat->gpio_temp < 0 || bat->adc_temp < 0) in collie_read_temp()
78 gpio_set_value(bat->gpio_temp, 1); in collie_read_temp()
81 value = ucb1x00_adc_read(ucb, bat->adc_temp, UCB_SYNC); in collie_read_temp()
83 gpio_set_value(bat->gpio_temp, 0); in collie_read_temp()
86 value = value * 10000 / bat->adc_temp_divider; in collie_read_temp()
96 struct collie_bat *bat = power_supply_get_drvdata(psy); in collie_bat_get_property() local
98 if (bat->is_present && !bat->is_present(bat) in collie_bat_get_property()
105 val->intval = bat->status; in collie_bat_get_property()
108 val->intval = bat->technology; in collie_bat_get_property()
111 val->intval = collie_read_bat(bat); in collie_bat_get_property()
114 if (bat->full_chrg == -1) in collie_bat_get_property()
115 val->intval = bat->bat_max; in collie_bat_get_property()
117 val->intval = bat->full_chrg; in collie_bat_get_property()
120 val->intval = bat->bat_max; in collie_bat_get_property()
123 val->intval = bat->bat_min; in collie_bat_get_property()
126 val->intval = collie_read_temp(bat); in collie_bat_get_property()
129 val->intval = bat->is_present ? bat->is_present(bat) : 1; in collie_bat_get_property()
150 static void collie_bat_update(struct collie_bat *bat) in collie_bat_update() argument
153 struct power_supply *psy = bat->psy; in collie_bat_update()
155 mutex_lock(&bat->work_lock); in collie_bat_update()
157 old = bat->status; in collie_bat_update()
159 if (bat->is_present && !bat->is_present(bat)) { in collie_bat_update()
161 bat->status = POWER_SUPPLY_STATUS_UNKNOWN; in collie_bat_update()
162 bat->full_chrg = -1; in collie_bat_update()
164 if (bat->status == POWER_SUPPLY_STATUS_DISCHARGING) { in collie_bat_update()
165 gpio_set_value(bat->gpio_charge_on, 1); in collie_bat_update()
169 if (gpio_get_value(bat->gpio_full)) { in collie_bat_update()
171 bat->full_chrg == -1) in collie_bat_update()
172 bat->full_chrg = collie_read_bat(bat); in collie_bat_update()
174 gpio_set_value(bat->gpio_charge_on, 0); in collie_bat_update()
175 bat->status = POWER_SUPPLY_STATUS_FULL; in collie_bat_update()
177 gpio_set_value(bat->gpio_charge_on, 1); in collie_bat_update()
178 bat->status = POWER_SUPPLY_STATUS_CHARGING; in collie_bat_update()
181 gpio_set_value(bat->gpio_charge_on, 0); in collie_bat_update()
182 bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in collie_bat_update()
185 if (old != bat->status) in collie_bat_update()
188 mutex_unlock(&bat->work_lock); in collie_bat_update()