Lines Matching full:charger

29 static unsigned long z2_read_bat(struct z2_charger *charger)  in z2_read_bat()  argument
32 data = i2c_smbus_read_byte_data(charger->client, in z2_read_bat()
33 charger->info->batt_I2C_reg); in z2_read_bat()
37 return data * charger->info->batt_mult / charger->info->batt_div; in z2_read_bat()
44 struct z2_charger *charger = power_supply_get_drvdata(batt_ps); in z2_batt_get_property() local
45 struct z2_battery_info *info = charger->info; in z2_batt_get_property()
49 val->intval = charger->bat_status; in z2_batt_get_property()
56 val->intval = z2_read_bat(charger); in z2_batt_get_property()
84 struct z2_charger *charger = power_supply_get_drvdata(batt_ps); in z2_batt_ext_power_changed() local
86 schedule_work(&charger->bat_work); in z2_batt_ext_power_changed()
89 static void z2_batt_update(struct z2_charger *charger) in z2_batt_update() argument
91 int old_status = charger->bat_status; in z2_batt_update()
94 info = charger->info; in z2_batt_update()
96 mutex_lock(&charger->work_lock); in z2_batt_update()
98 charger->bat_status = (info->charge_gpio >= 0) ? in z2_batt_update()
104 if (old_status != charger->bat_status) { in z2_batt_update()
105 pr_debug("%s: %i -> %i\n", charger->batt_ps->desc->name, in z2_batt_update()
107 charger->bat_status); in z2_batt_update()
108 power_supply_changed(charger->batt_ps); in z2_batt_update()
111 mutex_unlock(&charger->work_lock); in z2_batt_update()
116 struct z2_charger *charger; in z2_batt_work() local
117 charger = container_of(work, struct z2_charger, bat_work); in z2_batt_work()
118 z2_batt_update(charger); in z2_batt_work()
123 struct z2_charger *charger = devid; in z2_charge_switch_irq() local
124 schedule_work(&charger->bat_work); in z2_charge_switch_irq()
128 static int z2_batt_ps_init(struct z2_charger *charger, int props) in z2_batt_ps_init() argument
132 struct z2_battery_info *info = charger->info; in z2_batt_ps_init()
162 dev_info(&charger->client->dev, in z2_batt_ps_init()
166 charger->batt_ps_desc.name = Z2_DEFAULT_NAME; in z2_batt_ps_init()
168 charger->batt_ps_desc.name = info->batt_name; in z2_batt_ps_init()
170 charger->batt_ps_desc.properties = prop; in z2_batt_ps_init()
171 charger->batt_ps_desc.num_properties = props; in z2_batt_ps_init()
172 charger->batt_ps_desc.type = POWER_SUPPLY_TYPE_BATTERY; in z2_batt_ps_init()
173 charger->batt_ps_desc.get_property = z2_batt_get_property; in z2_batt_ps_init()
174 charger->batt_ps_desc.external_power_changed = in z2_batt_ps_init()
176 charger->batt_ps_desc.use_for_apm = 1; in z2_batt_ps_init()
186 struct z2_charger *charger; in z2_batt_probe() local
197 charger = kzalloc(sizeof(*charger), GFP_KERNEL); in z2_batt_probe()
198 if (charger == NULL) in z2_batt_probe()
201 charger->bat_status = POWER_SUPPLY_STATUS_UNKNOWN; in z2_batt_probe()
202 charger->info = info; in z2_batt_probe()
203 charger->client = client; in z2_batt_probe()
204 i2c_set_clientdata(client, charger); in z2_batt_probe()
205 psy_cfg.drv_data = charger; in z2_batt_probe()
207 mutex_init(&charger->work_lock); in z2_batt_probe()
222 "AC Detect", charger); in z2_batt_probe()
227 ret = z2_batt_ps_init(charger, props); in z2_batt_probe()
231 INIT_WORK(&charger->bat_work, z2_batt_work); in z2_batt_probe()
233 charger->batt_ps = power_supply_register(&client->dev, in z2_batt_probe()
234 &charger->batt_ps_desc, in z2_batt_probe()
236 if (IS_ERR(charger->batt_ps)) { in z2_batt_probe()
237 ret = PTR_ERR(charger->batt_ps); in z2_batt_probe()
241 schedule_work(&charger->bat_work); in z2_batt_probe()
246 kfree(charger->batt_ps_desc.properties); in z2_batt_probe()
249 free_irq(gpio_to_irq(info->charge_gpio), charger); in z2_batt_probe()
254 kfree(charger); in z2_batt_probe()
260 struct z2_charger *charger = i2c_get_clientdata(client); in z2_batt_remove() local
261 struct z2_battery_info *info = charger->info; in z2_batt_remove()
263 cancel_work_sync(&charger->bat_work); in z2_batt_remove()
264 power_supply_unregister(charger->batt_ps); in z2_batt_remove()
266 kfree(charger->batt_ps_desc.properties); in z2_batt_remove()
268 free_irq(gpio_to_irq(info->charge_gpio), charger); in z2_batt_remove()
272 kfree(charger); in z2_batt_remove()
281 struct z2_charger *charger = i2c_get_clientdata(client); in z2_batt_suspend() local
283 flush_work(&charger->bat_work); in z2_batt_suspend()
290 struct z2_charger *charger = i2c_get_clientdata(client); in z2_batt_resume() local
292 schedule_work(&charger->bat_work); in z2_batt_resume()