Lines Matching refs:adc_bat
64 struct gab *adc_bat = to_generic_bat(psy); in gab_ext_power_changed() local
66 schedule_delayed_work(&adc_bat->bat_work, msecs_to_jiffies(0)); in gab_ext_power_changed()
92 static bool gab_charge_finished(struct gab *adc_bat) in gab_charge_finished() argument
94 struct gab_platform_data *pdata = adc_bat->pdata; in gab_charge_finished()
103 static int gab_get_status(struct gab *adc_bat) in gab_get_status() argument
105 struct gab_platform_data *pdata = adc_bat->pdata; in gab_get_status()
109 if (adc_bat->level == bat_info->charge_full_design) in gab_get_status()
111 return adc_bat->status; in gab_get_status()
130 static int read_channel(struct gab *adc_bat, enum power_supply_property psp, in read_channel() argument
137 ret = iio_read_channel_processed(adc_bat->channel[chan_index], in read_channel()
147 struct gab *adc_bat; in gab_get_property() local
153 adc_bat = to_generic_bat(psy); in gab_get_property()
154 if (!adc_bat) { in gab_get_property()
158 pdata = adc_bat->pdata; in gab_get_property()
163 val->intval = gab_get_status(adc_bat); in gab_get_property()
174 ret = read_channel(adc_bat, psp, &result); in gab_get_property()
203 struct gab *adc_bat; in gab_work() local
209 adc_bat = container_of(delayed_work, struct gab, bat_work); in gab_work()
210 status = adc_bat->status; in gab_work()
212 is_plugged = power_supply_am_i_supplied(adc_bat->psy); in gab_work()
213 adc_bat->cable_plugged = is_plugged; in gab_work()
216 adc_bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in gab_work()
217 else if (gab_charge_finished(adc_bat)) in gab_work()
218 adc_bat->status = POWER_SUPPLY_STATUS_NOT_CHARGING; in gab_work()
220 adc_bat->status = POWER_SUPPLY_STATUS_CHARGING; in gab_work()
222 if (status != adc_bat->status) in gab_work()
223 power_supply_changed(adc_bat->psy); in gab_work()
228 struct gab *adc_bat = dev_id; in gab_charged() local
229 struct gab_platform_data *pdata = adc_bat->pdata; in gab_charged()
233 schedule_delayed_work(&adc_bat->bat_work, in gab_charged()
240 struct gab *adc_bat; in gab_probe() local
250 adc_bat = devm_kzalloc(&pdev->dev, sizeof(*adc_bat), GFP_KERNEL); in gab_probe()
251 if (!adc_bat) { in gab_probe()
256 psy_cfg.drv_data = adc_bat; in gab_probe()
257 psy_desc = &adc_bat->psy_desc; in gab_probe()
261 adc_bat->cable_plugged = false; in gab_probe()
262 adc_bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in gab_probe()
266 adc_bat->pdata = pdata; in gab_probe()
288 adc_bat->channel[chan] = iio_channel_get(&pdev->dev, in gab_probe()
290 if (IS_ERR(adc_bat->channel[chan])) { in gab_probe()
291 ret = PTR_ERR(adc_bat->channel[chan]); in gab_probe()
292 adc_bat->channel[chan] = NULL; in gab_probe()
322 adc_bat->psy = power_supply_register(&pdev->dev, psy_desc, &psy_cfg); in gab_probe()
323 if (IS_ERR(adc_bat->psy)) { in gab_probe()
324 ret = PTR_ERR(adc_bat->psy); in gab_probe()
328 INIT_DELAYED_WORK(&adc_bat->bat_work, gab_work); in gab_probe()
339 "battery charged", adc_bat); in gab_probe()
344 platform_set_drvdata(pdev, adc_bat); in gab_probe()
347 schedule_delayed_work(&adc_bat->bat_work, in gab_probe()
354 power_supply_unregister(adc_bat->psy); in gab_probe()
357 if (adc_bat->channel[chan]) in gab_probe()
358 iio_channel_release(adc_bat->channel[chan]); in gab_probe()
369 struct gab *adc_bat = platform_get_drvdata(pdev); in gab_remove() local
370 struct gab_platform_data *pdata = adc_bat->pdata; in gab_remove()
372 power_supply_unregister(adc_bat->psy); in gab_remove()
375 free_irq(gpio_to_irq(pdata->gpio_charge_finished), adc_bat); in gab_remove()
380 if (adc_bat->channel[chan]) in gab_remove()
381 iio_channel_release(adc_bat->channel[chan]); in gab_remove()
384 kfree(adc_bat->psy_desc.properties); in gab_remove()
385 cancel_delayed_work(&adc_bat->bat_work); in gab_remove()
391 struct gab *adc_bat = dev_get_drvdata(dev); in gab_suspend() local
393 cancel_delayed_work_sync(&adc_bat->bat_work); in gab_suspend()
394 adc_bat->status = POWER_SUPPLY_STATUS_UNKNOWN; in gab_suspend()
400 struct gab *adc_bat = dev_get_drvdata(dev); in gab_resume() local
401 struct gab_platform_data *pdata = adc_bat->pdata; in gab_resume()
407 schedule_delayed_work(&adc_bat->bat_work, in gab_resume()