Lines Matching +full:jz4740 +full:- +full:adc
4 * based on jz4740-battery.c
25 #include <linux/power/generic-adc-battery.h>
67 schedule_delayed_work(&adc_bat->bat_work, msecs_to_jiffies(0)); in gab_ext_power_changed()
85 * should correspond one-to-one with enum chan_type.
95 if (!adc_bat->charge_finished) in gab_charge_finished()
97 return gpiod_get_value(adc_bat->charge_finished); in gab_charge_finished()
102 struct gab_platform_data *pdata = adc_bat->pdata; in gab_get_status()
105 bat_info = &pdata->battery_info; in gab_get_status()
106 if (adc_bat->level == bat_info->charge_full_design) in gab_get_status()
108 return adc_bat->status; in gab_get_status()
134 ret = iio_read_channel_processed(adc_bat->channel[chan_index], in read_channel()
152 dev_err(&psy->dev, "no battery infos ?!\n"); in gab_get_property()
153 return -EINVAL; in gab_get_property()
155 pdata = adc_bat->pdata; in gab_get_property()
156 bat_info = &pdata->battery_info; in gab_get_property()
160 val->intval = gab_get_status(adc_bat); in gab_get_property()
163 val->intval = 0; in gab_get_property()
166 val->intval = pdata->cal_charge(result); in gab_get_property()
174 val->intval = result; in gab_get_property()
177 val->intval = bat_info->technology; in gab_get_property()
180 val->intval = bat_info->voltage_min_design; in gab_get_property()
183 val->intval = bat_info->voltage_max_design; in gab_get_property()
186 val->intval = bat_info->charge_full_design; in gab_get_property()
189 val->strval = bat_info->name; in gab_get_property()
192 return -EINVAL; in gab_get_property()
207 status = adc_bat->status; in gab_work()
209 is_plugged = power_supply_am_i_supplied(adc_bat->psy); in gab_work()
210 adc_bat->cable_plugged = is_plugged; in gab_work()
213 adc_bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in gab_work()
215 adc_bat->status = POWER_SUPPLY_STATUS_NOT_CHARGING; in gab_work()
217 adc_bat->status = POWER_SUPPLY_STATUS_CHARGING; in gab_work()
219 if (status != adc_bat->status) in gab_work()
220 power_supply_changed(adc_bat->psy); in gab_work()
226 struct gab_platform_data *pdata = adc_bat->pdata; in gab_charged()
229 delay = pdata->jitter_delay ? pdata->jitter_delay : JITTER_DEFAULT; in gab_charged()
230 schedule_delayed_work(&adc_bat->bat_work, in gab_charged()
240 struct gab_platform_data *pdata = pdev->dev.platform_data; in gab_probe()
247 adc_bat = devm_kzalloc(&pdev->dev, sizeof(*adc_bat), GFP_KERNEL); in gab_probe()
249 dev_err(&pdev->dev, "failed to allocate memory\n"); in gab_probe()
250 return -ENOMEM; in gab_probe()
254 psy_desc = &adc_bat->psy_desc; in gab_probe()
255 psy_desc->name = pdata->battery_info.name; in gab_probe()
258 adc_bat->cable_plugged = false; in gab_probe()
259 adc_bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in gab_probe()
260 psy_desc->type = POWER_SUPPLY_TYPE_BATTERY; in gab_probe()
261 psy_desc->get_property = gab_get_property; in gab_probe()
262 psy_desc->external_power_changed = gab_ext_power_changed; in gab_probe()
263 adc_bat->pdata = pdata; in gab_probe()
274 ret = -ENOMEM; in gab_probe()
285 adc_bat->channel[chan] = iio_channel_get(&pdev->dev, in gab_probe()
287 if (IS_ERR(adc_bat->channel[chan])) { in gab_probe()
288 ret = PTR_ERR(adc_bat->channel[chan]); in gab_probe()
289 adc_bat->channel[chan] = NULL; in gab_probe()
306 ret = -ENODEV; in gab_probe()
316 psy_desc->properties = properties; in gab_probe()
317 psy_desc->num_properties = index; in gab_probe()
319 adc_bat->psy = power_supply_register(&pdev->dev, psy_desc, &psy_cfg); in gab_probe()
320 if (IS_ERR(adc_bat->psy)) { in gab_probe()
321 ret = PTR_ERR(adc_bat->psy); in gab_probe()
325 INIT_DELAYED_WORK(&adc_bat->bat_work, gab_work); in gab_probe()
327 adc_bat->charge_finished = devm_gpiod_get_optional(&pdev->dev, in gab_probe()
329 if (adc_bat->charge_finished) { in gab_probe()
332 irq = gpiod_to_irq(adc_bat->charge_finished); in gab_probe()
343 schedule_delayed_work(&adc_bat->bat_work, in gab_probe()
348 power_supply_unregister(adc_bat->psy); in gab_probe()
351 if (adc_bat->channel[chan]) in gab_probe()
352 iio_channel_release(adc_bat->channel[chan]); in gab_probe()
365 power_supply_unregister(adc_bat->psy); in gab_remove()
367 if (adc_bat->charge_finished) in gab_remove()
368 free_irq(gpiod_to_irq(adc_bat->charge_finished), adc_bat); in gab_remove()
371 if (adc_bat->channel[chan]) in gab_remove()
372 iio_channel_release(adc_bat->channel[chan]); in gab_remove()
375 kfree(adc_bat->psy_desc.properties); in gab_remove()
376 cancel_delayed_work_sync(&adc_bat->bat_work); in gab_remove()
384 cancel_delayed_work_sync(&adc_bat->bat_work); in gab_suspend()
385 adc_bat->status = POWER_SUPPLY_STATUS_UNKNOWN; in gab_suspend()
392 struct gab_platform_data *pdata = adc_bat->pdata; in gab_resume()
395 delay = pdata->jitter_delay ? pdata->jitter_delay : JITTER_DEFAULT; in gab_resume()
398 schedule_delayed_work(&adc_bat->bat_work, in gab_resume()
407 .name = "generic-adc-battery",