Lines Matching refs:pchg

133 static bool lp8788_is_charger_detected(struct lp8788_charger *pchg)  in lp8788_is_charger_detected()  argument
137 lp8788_read_byte(pchg->lp, LP8788_CHG_STATUS, &data); in lp8788_is_charger_detected()
147 struct lp8788_charger *pchg = dev_get_drvdata(psy->dev.parent); in lp8788_charger_get_property() local
152 val->intval = lp8788_is_charger_detected(pchg); in lp8788_charger_get_property()
155 lp8788_read_byte(pchg->lp, LP8788_CHG_IDCIN, &read); in lp8788_charger_get_property()
166 static int lp8788_get_battery_status(struct lp8788_charger *pchg, in lp8788_get_battery_status() argument
173 ret = lp8788_read_byte(pchg->lp, LP8788_CHG_STATUS, &data); in lp8788_get_battery_status()
199 static int lp8788_get_battery_health(struct lp8788_charger *pchg, in lp8788_get_battery_health() argument
205 ret = lp8788_read_byte(pchg->lp, LP8788_CHG_STATUS, &data); in lp8788_get_battery_health()
219 static int lp8788_get_battery_present(struct lp8788_charger *pchg, in lp8788_get_battery_present() argument
225 ret = lp8788_read_byte(pchg->lp, LP8788_CHG_STATUS, &data); in lp8788_get_battery_present()
233 static int lp8788_get_vbatt_adc(struct lp8788_charger *pchg, int *result) in lp8788_get_vbatt_adc() argument
235 struct iio_channel *channel = pchg->chan[LP8788_VBATT]; in lp8788_get_vbatt_adc()
243 static int lp8788_get_battery_voltage(struct lp8788_charger *pchg, in lp8788_get_battery_voltage() argument
246 return lp8788_get_vbatt_adc(pchg, &val->intval); in lp8788_get_battery_voltage()
249 static int lp8788_get_battery_capacity(struct lp8788_charger *pchg, in lp8788_get_battery_capacity() argument
252 struct lp8788 *lp = pchg->lp; in lp8788_get_battery_capacity()
253 struct lp8788_charger_platform_data *pdata = pchg->pdata; in lp8788_get_battery_capacity()
276 ret = lp8788_get_vbatt_adc(pchg, &vbatt); in lp8788_get_battery_capacity()
287 static int lp8788_get_battery_temperature(struct lp8788_charger *pchg, in lp8788_get_battery_temperature() argument
290 struct iio_channel *channel = pchg->chan[LP8788_BATT_TEMP]; in lp8788_get_battery_temperature()
307 static int lp8788_get_battery_charging_current(struct lp8788_charger *pchg, in lp8788_get_battery_charging_current() argument
312 lp8788_read_byte(pchg->lp, LP8788_CHG_IBATT, &read); in lp8788_get_battery_charging_current()
320 static int lp8788_get_charging_termination_voltage(struct lp8788_charger *pchg, in lp8788_get_charging_termination_voltage() argument
325 lp8788_read_byte(pchg->lp, LP8788_CHG_VTERM, &read); in lp8788_get_charging_termination_voltage()
336 struct lp8788_charger *pchg = dev_get_drvdata(psy->dev.parent); in lp8788_battery_get_property() local
340 return lp8788_get_battery_status(pchg, val); in lp8788_battery_get_property()
342 return lp8788_get_battery_health(pchg, val); in lp8788_battery_get_property()
344 return lp8788_get_battery_present(pchg, val); in lp8788_battery_get_property()
346 return lp8788_get_battery_voltage(pchg, val); in lp8788_battery_get_property()
348 return lp8788_get_battery_capacity(pchg, val); in lp8788_battery_get_property()
350 return lp8788_get_battery_temperature(pchg, val); in lp8788_battery_get_property()
352 return lp8788_get_battery_charging_current(pchg, val); in lp8788_battery_get_property()
354 return lp8788_get_charging_termination_voltage(pchg, val); in lp8788_battery_get_property()
366 struct lp8788_charger *pchg) in lp8788_update_charger_params() argument
368 struct lp8788 *lp = pchg->lp; in lp8788_update_charger_params()
369 struct lp8788_charger_platform_data *pdata = pchg->pdata; in lp8788_update_charger_params()
411 struct lp8788_charger *pchg = in lp8788_charger_event() local
413 struct lp8788_charger_platform_data *pdata = pchg->pdata; in lp8788_charger_event()
414 enum lp8788_charger_event event = lp8788_is_charger_detected(pchg); in lp8788_charger_event()
416 pdata->charger_event(pchg->lp, event); in lp8788_charger_event()
419 static bool lp8788_find_irq_id(struct lp8788_charger *pchg, int virq, int *id) in lp8788_find_irq_id() argument
424 for (i = 0; i < pchg->num_irqs; i++) { in lp8788_find_irq_id()
425 if (pchg->irqs[i].virq == virq) { in lp8788_find_irq_id()
426 *id = pchg->irqs[i].which; in lp8788_find_irq_id()
437 struct lp8788_charger *pchg = ptr; in lp8788_charger_irq_thread() local
438 struct lp8788_charger_platform_data *pdata = pchg->pdata; in lp8788_charger_irq_thread()
441 if (!lp8788_find_irq_id(pchg, virq, &id)) in lp8788_charger_irq_thread()
450 power_supply_changed(pchg->charger); in lp8788_charger_irq_thread()
451 power_supply_changed(pchg->battery); in lp8788_charger_irq_thread()
462 schedule_work(&pchg->charger_work); in lp8788_charger_irq_thread()
469 struct lp8788_charger *pchg, const char *name) in lp8788_set_irqs() argument
472 struct irq_domain *irqdm = pchg->lp->irqdm; in lp8788_set_irqs()
489 nr_irq = pchg->num_irqs; in lp8788_set_irqs()
492 pchg->irqs[nr_irq].virq = virq; in lp8788_set_irqs()
493 pchg->irqs[nr_irq].which = i; in lp8788_set_irqs()
494 pchg->num_irqs++; in lp8788_set_irqs()
498 IRQF_ONESHOT, name, pchg); in lp8788_set_irqs()
509 for (i = 0; i < pchg->num_irqs; i++) in lp8788_set_irqs()
510 free_irq(pchg->irqs[i].virq, pchg); in lp8788_set_irqs()
515 struct lp8788_charger *pchg) in lp8788_irq_register() argument
523 INIT_WORK(&pchg->charger_work, lp8788_charger_event); in lp8788_irq_register()
524 pchg->num_irqs = 0; in lp8788_irq_register()
527 ret = lp8788_set_irqs(pdev, pchg, name[i]); in lp8788_irq_register()
534 if (pchg->num_irqs > LP8788_MAX_CHG_IRQS) { in lp8788_irq_register()
536 pchg->num_irqs); in lp8788_irq_register()
545 struct lp8788_charger *pchg) in lp8788_irq_unregister() argument
550 for (i = 0; i < pchg->num_irqs; i++) { in lp8788_irq_unregister()
551 irq = pchg->irqs[i].virq; in lp8788_irq_unregister()
555 free_irq(irq, pchg); in lp8788_irq_unregister()
560 struct lp8788_charger *pchg) in lp8788_setup_adc_channel() argument
562 struct lp8788_charger_platform_data *pdata = pchg->pdata; in lp8788_setup_adc_channel()
570 pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan; in lp8788_setup_adc_channel()
574 pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan; in lp8788_setup_adc_channel()
580 struct lp8788_charger *pchg = dev_get_drvdata(dev); in lp8788_show_charger_status() local
596 lp8788_read_byte(pchg->lp, LP8788_CHG_STATUS, &data); in lp8788_show_charger_status()
605 struct lp8788_charger *pchg = dev_get_drvdata(dev); in lp8788_show_eoc_time() local
612 lp8788_read_byte(pchg->lp, LP8788_CHG_EOC, &val); in lp8788_show_eoc_time()
621 struct lp8788_charger *pchg = dev_get_drvdata(dev); in lp8788_show_eoc_level() local
632 lp8788_read_byte(pchg->lp, LP8788_CHG_EOC, &val); in lp8788_show_eoc_level()
655 struct lp8788_charger *pchg) in lp8788_psy_register() argument
663 pchg->charger = devm_power_supply_register(&pdev->dev, in lp8788_psy_register()
666 if (IS_ERR(pchg->charger)) in lp8788_psy_register()
669 pchg->battery = devm_power_supply_register(&pdev->dev, in lp8788_psy_register()
671 if (IS_ERR(pchg->battery)) in lp8788_psy_register()
680 struct lp8788_charger *pchg; in lp8788_charger_probe() local
684 pchg = devm_kzalloc(dev, sizeof(struct lp8788_charger), GFP_KERNEL); in lp8788_charger_probe()
685 if (!pchg) in lp8788_charger_probe()
688 pchg->lp = lp; in lp8788_charger_probe()
689 pchg->pdata = lp->pdata ? lp->pdata->chg_pdata : NULL; in lp8788_charger_probe()
690 platform_set_drvdata(pdev, pchg); in lp8788_charger_probe()
692 ret = lp8788_update_charger_params(pdev, pchg); in lp8788_charger_probe()
696 lp8788_setup_adc_channel(&pdev->dev, pchg); in lp8788_charger_probe()
698 ret = lp8788_psy_register(pdev, pchg); in lp8788_charger_probe()
702 ret = lp8788_irq_register(pdev, pchg); in lp8788_charger_probe()
711 struct lp8788_charger *pchg = platform_get_drvdata(pdev); in lp8788_charger_remove() local
713 flush_work(&pchg->charger_work); in lp8788_charger_remove()
714 lp8788_irq_unregister(pdev, pchg); in lp8788_charger_remove()