Lines Matching refs:bat

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