Lines Matching refs:bat

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