Lines Matching refs:charger
32 static unsigned long z2_read_bat(struct z2_charger *charger)
35 data = i2c_smbus_read_byte_data(charger->client,
36 charger->info->batt_I2C_reg);
40 return data * charger->info->batt_mult / charger->info->batt_div;
47 struct z2_charger *charger = container_of(batt_ps, struct z2_charger,
49 struct z2_battery_info *info = charger->info;
53 val->intval = charger->bat_status;
60 val->intval = z2_read_bat(charger);
88 struct z2_charger *charger = container_of(batt_ps, struct z2_charger,
90 schedule_work(&charger->bat_work);
93 static void z2_batt_update(struct z2_charger *charger)
95 int old_status = charger->bat_status;
98 info = charger->info;
100 mutex_lock(&charger->work_lock);
102 charger->bat_status = (info->charge_gpio >= 0) ?
108 if (old_status != charger->bat_status) {
109 pr_debug("%s: %i -> %i\n", charger->batt_ps.name, old_status,
110 charger->bat_status);
111 power_supply_changed(&charger->batt_ps);
114 mutex_unlock(&charger->work_lock);
119 struct z2_charger *charger;
120 charger = container_of(work, struct z2_charger, bat_work);
121 z2_batt_update(charger);
126 struct z2_charger *charger = devid;
127 schedule_work(&charger->bat_work);
131 static int z2_batt_ps_init(struct z2_charger *charger, int props)
135 struct z2_battery_info *info = charger->info;
163 dev_info(&charger->client->dev,
167 charger->batt_ps.name = Z2_DEFAULT_NAME;
169 charger->batt_ps.name = info->batt_name;
171 charger->batt_ps.properties = prop;
172 charger->batt_ps.num_properties = props;
173 charger->batt_ps.type = POWER_SUPPLY_TYPE_BATTERY;
174 charger->batt_ps.get_property = z2_batt_get_property;
175 charger->batt_ps.external_power_changed = z2_batt_ext_power_changed;
176 charger->batt_ps.use_for_apm = 1;
186 struct z2_charger *charger;
196 charger = kzalloc(sizeof(*charger), GFP_KERNEL);
197 if (charger == NULL)
200 charger->bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
201 charger->info = info;
202 charger->client = client;
203 i2c_set_clientdata(client, charger);
205 mutex_init(&charger->work_lock);
220 "AC Detect", charger);
225 ret = z2_batt_ps_init(charger, props);
229 INIT_WORK(&charger->bat_work, z2_batt_work);
231 ret = power_supply_register(&client->dev, &charger->batt_ps);
235 schedule_work(&charger->bat_work);
240 kfree(charger->batt_ps.properties);
243 free_irq(gpio_to_irq(info->charge_gpio), charger);
248 kfree(charger);
254 struct z2_charger *charger = i2c_get_clientdata(client);
255 struct z2_battery_info *info = charger->info;
258 power_supply_unregister(&charger->batt_ps);
260 kfree(charger->batt_ps.properties);
262 free_irq(gpio_to_irq(info->charge_gpio), charger);
266 kfree(charger);
280 struct z2_charger *charger = i2c_get_clientdata(client);
282 schedule_work(&charger->bat_work);