Lines Matching refs:adc_bat
60 struct gab *adc_bat = to_generic_bat(psy); in gab_ext_power_changed() local
62 schedule_delayed_work(&adc_bat->bat_work, msecs_to_jiffies(0)); in gab_ext_power_changed()
80 static bool gab_charge_finished(struct gab *adc_bat) in gab_charge_finished() argument
82 if (!adc_bat->charge_finished) in gab_charge_finished()
84 return gpiod_get_value(adc_bat->charge_finished); in gab_charge_finished()
87 static int gab_read_channel(struct gab *adc_bat, enum gab_chan_type channel, in gab_read_channel() argument
92 ret = iio_read_channel_processed(adc_bat->channel[channel], result); in gab_read_channel()
94 dev_err(&adc_bat->psy->dev, "read channel error: %d\n", ret); in gab_read_channel()
104 struct gab *adc_bat = to_generic_bat(psy); in gab_get_property() local
108 val->intval = adc_bat->status; in gab_get_property()
111 return gab_read_channel(adc_bat, GAB_VOLTAGE, &val->intval); in gab_get_property()
113 return gab_read_channel(adc_bat, GAB_CURRENT, &val->intval); in gab_get_property()
115 return gab_read_channel(adc_bat, GAB_POWER, &val->intval); in gab_get_property()
117 return gab_read_channel(adc_bat, GAB_TEMP, &val->intval); in gab_get_property()
125 struct gab *adc_bat; in gab_work() local
130 adc_bat = container_of(delayed_work, struct gab, bat_work); in gab_work()
131 status = adc_bat->status; in gab_work()
133 if (!power_supply_am_i_supplied(adc_bat->psy)) in gab_work()
134 adc_bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in gab_work()
135 else if (gab_charge_finished(adc_bat)) in gab_work()
136 adc_bat->status = POWER_SUPPLY_STATUS_NOT_CHARGING; in gab_work()
138 adc_bat->status = POWER_SUPPLY_STATUS_CHARGING; in gab_work()
140 if (status != adc_bat->status) in gab_work()
141 power_supply_changed(adc_bat->psy); in gab_work()
146 struct gab *adc_bat = dev_id; in gab_charged() local
148 schedule_delayed_work(&adc_bat->bat_work, in gab_charged()
156 struct gab *adc_bat; in gab_probe() local
165 adc_bat = devm_kzalloc(&pdev->dev, sizeof(*adc_bat), GFP_KERNEL); in gab_probe()
166 if (!adc_bat) in gab_probe()
170 psy_cfg.drv_data = adc_bat; in gab_probe()
171 psy_desc = &adc_bat->psy_desc; in gab_probe()
175 adc_bat->status = POWER_SUPPLY_STATUS_DISCHARGING; in gab_probe()
199 adc_bat->channel[chan] = devm_iio_channel_get(&pdev->dev, gab_chan_name[chan]); in gab_probe()
200 if (IS_ERR(adc_bat->channel[chan])) { in gab_probe()
201 ret = PTR_ERR(adc_bat->channel[chan]); in gab_probe()
204 adc_bat->channel[chan] = NULL; in gab_probe()
205 } else if (adc_bat->channel[chan]) { in gab_probe()
232 adc_bat->psy = devm_power_supply_register(&pdev->dev, psy_desc, &psy_cfg); in gab_probe()
233 if (IS_ERR(adc_bat->psy)) in gab_probe()
234 …return dev_err_probe(&pdev->dev, PTR_ERR(adc_bat->psy), "Failed to register power-supply device\n"… in gab_probe()
236 ret = devm_delayed_work_autocancel(&pdev->dev, &adc_bat->bat_work, gab_work); in gab_probe()
240 adc_bat->charge_finished = devm_gpiod_get_optional(&pdev->dev, "charged", GPIOD_IN); in gab_probe()
241 if (adc_bat->charge_finished) { in gab_probe()
244 irq = gpiod_to_irq(adc_bat->charge_finished); in gab_probe()
247 "battery charged", adc_bat); in gab_probe()
252 platform_set_drvdata(pdev, adc_bat); in gab_probe()
255 schedule_delayed_work(&adc_bat->bat_work, in gab_probe()
262 struct gab *adc_bat = dev_get_drvdata(dev); in gab_suspend() local
264 cancel_delayed_work_sync(&adc_bat->bat_work); in gab_suspend()
265 adc_bat->status = POWER_SUPPLY_STATUS_UNKNOWN; in gab_suspend()
271 struct gab *adc_bat = dev_get_drvdata(dev); in gab_resume() local
274 schedule_delayed_work(&adc_bat->bat_work, in gab_resume()