Lines Matching refs:bat

37 	bool (*is_present)(struct collie_bat *bat);
56 static unsigned long collie_read_bat(struct collie_bat *bat) in collie_read_bat() argument
60 if (bat->gpio_bat < 0 || bat->adc_bat < 0) in collie_read_bat()
63 gpio_set_value(bat->gpio_bat, 1); in collie_read_bat()
66 value = ucb1x00_adc_read(ucb, bat->adc_bat, UCB_SYNC); in collie_read_bat()
68 gpio_set_value(bat->gpio_bat, 0); in collie_read_bat()
70 value = value * 1000000 / bat->adc_bat_divider; in collie_read_bat()
75 static unsigned long collie_read_temp(struct collie_bat *bat) in collie_read_temp() argument
78 if (bat->gpio_temp < 0 || bat->adc_temp < 0) in collie_read_temp()
82 gpio_set_value(bat->gpio_temp, 1); in collie_read_temp()
85 value = ucb1x00_adc_read(ucb, bat->adc_temp, UCB_SYNC); in collie_read_temp()
87 gpio_set_value(bat->gpio_temp, 0); in collie_read_temp()
90 value = value * 10000 / bat->adc_temp_divider; in collie_read_temp()
100 struct collie_bat *bat = container_of(psy, struct collie_bat, psy); in collie_bat_get_property() local
102 if (bat->is_present && !bat->is_present(bat) in collie_bat_get_property()
109 val->intval = bat->status; in collie_bat_get_property()
112 val->intval = bat->technology; in collie_bat_get_property()
115 val->intval = collie_read_bat(bat); in collie_bat_get_property()
118 if (bat->full_chrg == -1) in collie_bat_get_property()
119 val->intval = bat->bat_max; in collie_bat_get_property()
121 val->intval = bat->full_chrg; in collie_bat_get_property()
124 val->intval = bat->bat_max; in collie_bat_get_property()
127 val->intval = bat->bat_min; in collie_bat_get_property()
130 val->intval = collie_read_temp(bat); in collie_bat_get_property()
133 val->intval = bat->is_present ? bat->is_present(bat) : 1; in collie_bat_get_property()
154 static void collie_bat_update(struct collie_bat *bat) in collie_bat_update() argument
157 struct power_supply *psy = &bat->psy; in collie_bat_update()
159 mutex_lock(&bat->work_lock); in collie_bat_update()
161 old = bat->status; in collie_bat_update()
163 if (bat->is_present && !bat->is_present(bat)) { in collie_bat_update()
165 bat->status = POWER_SUPPLY_STATUS_UNKNOWN; in collie_bat_update()
166 bat->full_chrg = -1; in collie_bat_update()
168 if (bat->status == POWER_SUPPLY_STATUS_DISCHARGING) { in collie_bat_update()
169 gpio_set_value(bat->gpio_charge_on, 1); in collie_bat_update()
173 if (gpio_get_value(bat->gpio_full)) { in collie_bat_update()
175 bat->full_chrg == -1) in collie_bat_update()
176 bat->full_chrg = collie_read_bat(bat); in collie_bat_update()
178 gpio_set_value(bat->gpio_charge_on, 0); in collie_bat_update()
179 bat->status = POWER_SUPPLY_STATUS_FULL; in collie_bat_update()
181 gpio_set_value(bat->gpio_charge_on, 1); in collie_bat_update()
182 bat->status = POWER_SUPPLY_STATUS_CHARGING; in collie_bat_update()
185 gpio_set_value(bat->gpio_charge_on, 0); in collie_bat_update()
186 bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in collie_bat_update()
189 if (old != bat->status) in collie_bat_update()
192 mutex_unlock(&bat->work_lock); in collie_bat_update()