Lines Matching full:charger
3 * DA9150 Charger Driver
42 static inline int da9150_charger_supply_online(struct da9150_charger *charger, in da9150_charger_supply_online() argument
46 val->intval = (psy == charger->supply_online) ? 1 : 0; in da9150_charger_supply_online()
51 /* Charger Properties */
52 static int da9150_charger_vbus_voltage_now(struct da9150_charger *charger, in da9150_charger_vbus_voltage_now() argument
58 ret = iio_read_channel_processed(charger->vbus_chan, &v_val); in da9150_charger_vbus_voltage_now()
68 static int da9150_charger_ibus_current_avg(struct da9150_charger *charger, in da9150_charger_ibus_current_avg() argument
74 ret = iio_read_channel_processed(charger->ibus_chan, &i_val); in da9150_charger_ibus_current_avg()
84 static int da9150_charger_tjunc_temp(struct da9150_charger *charger, in da9150_charger_tjunc_temp() argument
90 ret = iio_read_channel_processed(charger->tjunc_chan, &t_val); in da9150_charger_tjunc_temp()
111 struct da9150_charger *charger = dev_get_drvdata(psy->dev.parent); in da9150_charger_get_prop() local
116 ret = da9150_charger_supply_online(charger, psy, val); in da9150_charger_get_prop()
119 ret = da9150_charger_vbus_voltage_now(charger, val); in da9150_charger_get_prop()
122 ret = da9150_charger_ibus_current_avg(charger, val); in da9150_charger_get_prop()
125 ret = da9150_charger_tjunc_temp(charger, val); in da9150_charger_get_prop()
136 static int da9150_charger_battery_status(struct da9150_charger *charger, in da9150_charger_battery_status() argument
142 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_H); in da9150_charger_battery_status()
151 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_J); in da9150_charger_battery_status()
179 static int da9150_charger_battery_health(struct da9150_charger *charger, in da9150_charger_battery_health() argument
184 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_J); in da9150_charger_battery_health()
215 static int da9150_charger_battery_present(struct da9150_charger *charger, in da9150_charger_battery_present() argument
221 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_J); in da9150_charger_battery_present()
230 static int da9150_charger_battery_charge_type(struct da9150_charger *charger, in da9150_charger_battery_charge_type() argument
235 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_J); in da9150_charger_battery_charge_type()
254 static int da9150_charger_battery_voltage_min(struct da9150_charger *charger, in da9150_charger_battery_voltage_min() argument
259 reg = da9150_reg_read(charger->da9150, DA9150_PPR_CHGCTRL_C); in da9150_charger_battery_voltage_min()
267 static int da9150_charger_battery_voltage_now(struct da9150_charger *charger, in da9150_charger_battery_voltage_now() argument
273 ret = iio_read_channel_processed(charger->vbat_chan, &v_val); in da9150_charger_battery_voltage_now()
282 static int da9150_charger_battery_current_max(struct da9150_charger *charger, in da9150_charger_battery_current_max() argument
287 reg = da9150_reg_read(charger->da9150, DA9150_PPR_CHGCTRL_D); in da9150_charger_battery_current_max()
295 static int da9150_charger_battery_voltage_max(struct da9150_charger *charger, in da9150_charger_battery_voltage_max() argument
300 reg = da9150_reg_read(charger->da9150, DA9150_PPR_CHGCTRL_B); in da9150_charger_battery_voltage_max()
323 struct da9150_charger *charger = dev_get_drvdata(psy->dev.parent); in da9150_charger_battery_get_prop() local
328 ret = da9150_charger_battery_status(charger, val); in da9150_charger_battery_get_prop()
331 ret = da9150_charger_supply_online(charger, psy, val); in da9150_charger_battery_get_prop()
334 ret = da9150_charger_battery_health(charger, val); in da9150_charger_battery_get_prop()
337 ret = da9150_charger_battery_present(charger, val); in da9150_charger_battery_get_prop()
340 ret = da9150_charger_battery_charge_type(charger, val); in da9150_charger_battery_get_prop()
343 ret = da9150_charger_battery_voltage_min(charger, val); in da9150_charger_battery_get_prop()
346 ret = da9150_charger_battery_voltage_now(charger, val); in da9150_charger_battery_get_prop()
349 ret = da9150_charger_battery_current_max(charger, val); in da9150_charger_battery_get_prop()
352 ret = da9150_charger_battery_voltage_max(charger, val); in da9150_charger_battery_get_prop()
364 struct da9150_charger *charger = data; in da9150_charger_chg_irq() local
366 power_supply_changed(charger->battery); in da9150_charger_chg_irq()
373 struct da9150_charger *charger = data; in da9150_charger_tjunc_irq() local
376 dev_crit(charger->dev, "TJunc over temperature!!!\n"); in da9150_charger_tjunc_irq()
377 power_supply_changed(charger->usb); in da9150_charger_tjunc_irq()
384 struct da9150_charger *charger = data; in da9150_charger_vfault_irq() local
387 dev_crit(charger->dev, "VSYS under voltage!!!\n"); in da9150_charger_vfault_irq()
388 power_supply_changed(charger->usb); in da9150_charger_vfault_irq()
389 power_supply_changed(charger->battery); in da9150_charger_vfault_irq()
396 struct da9150_charger *charger = data; in da9150_charger_vbus_irq() local
399 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_H); in da9150_charger_vbus_irq()
401 /* Charger plugged in or battery only */ in da9150_charger_vbus_irq()
405 charger->supply_online = charger->battery; in da9150_charger_vbus_irq()
408 charger->supply_online = charger->usb; in da9150_charger_vbus_irq()
411 dev_warn(charger->dev, "Unknown VBUS state - reg = 0x%x\n", in da9150_charger_vbus_irq()
413 charger->supply_online = NULL; in da9150_charger_vbus_irq()
417 power_supply_changed(charger->usb); in da9150_charger_vbus_irq()
418 power_supply_changed(charger->battery); in da9150_charger_vbus_irq()
425 struct da9150_charger *charger = in da9150_charger_otg_work() local
428 switch (charger->usb_event) { in da9150_charger_otg_work()
431 da9150_set_bits(charger->da9150, DA9150_PPR_BKCTRL_A, in da9150_charger_otg_work()
436 power_supply_changed(charger->usb); in da9150_charger_otg_work()
437 power_supply_changed(charger->battery); in da9150_charger_otg_work()
438 da9150_set_bits(charger->da9150, DA9150_PPR_BKCTRL_A, in da9150_charger_otg_work()
447 struct da9150_charger *charger = in da9150_charger_otg_ncb() local
450 dev_dbg(charger->dev, "DA9150 OTG notify %lu\n", val); in da9150_charger_otg_ncb()
452 charger->usb_event = val; in da9150_charger_otg_ncb()
453 schedule_work(&charger->otg_work); in da9150_charger_otg_ncb()
463 struct da9150_charger *charger = platform_get_drvdata(pdev); in da9150_charger_register_irq() local
471 charger); in da9150_charger_register_irq()
481 struct da9150_charger *charger = platform_get_drvdata(pdev); in da9150_charger_unregister_irq() local
488 free_irq(irq, charger); in da9150_charger_unregister_irq()
511 struct da9150_charger *charger; in da9150_charger_probe() local
515 charger = devm_kzalloc(dev, sizeof(struct da9150_charger), GFP_KERNEL); in da9150_charger_probe()
516 if (!charger) in da9150_charger_probe()
519 platform_set_drvdata(pdev, charger); in da9150_charger_probe()
520 charger->da9150 = da9150; in da9150_charger_probe()
521 charger->dev = dev; in da9150_charger_probe()
524 charger->ibus_chan = devm_iio_channel_get(dev, "CHAN_IBUS"); in da9150_charger_probe()
525 if (IS_ERR(charger->ibus_chan)) in da9150_charger_probe()
526 return PTR_ERR(charger->ibus_chan); in da9150_charger_probe()
528 charger->vbus_chan = devm_iio_channel_get(dev, "CHAN_VBUS"); in da9150_charger_probe()
529 if (IS_ERR(charger->vbus_chan)) in da9150_charger_probe()
530 return PTR_ERR(charger->vbus_chan); in da9150_charger_probe()
532 charger->tjunc_chan = devm_iio_channel_get(dev, "CHAN_TJUNC"); in da9150_charger_probe()
533 if (IS_ERR(charger->tjunc_chan)) in da9150_charger_probe()
534 return PTR_ERR(charger->tjunc_chan); in da9150_charger_probe()
536 charger->vbat_chan = devm_iio_channel_get(dev, "CHAN_VBAT"); in da9150_charger_probe()
537 if (IS_ERR(charger->vbat_chan)) in da9150_charger_probe()
538 return PTR_ERR(charger->vbat_chan); in da9150_charger_probe()
541 charger->usb = devm_power_supply_register(dev, &usb_desc, NULL); in da9150_charger_probe()
542 if (IS_ERR(charger->usb)) in da9150_charger_probe()
543 return PTR_ERR(charger->usb); in da9150_charger_probe()
545 charger->battery = devm_power_supply_register(dev, &battery_desc, NULL); in da9150_charger_probe()
546 if (IS_ERR(charger->battery)) in da9150_charger_probe()
547 return PTR_ERR(charger->battery); in da9150_charger_probe()
555 charger->supply_online = charger->battery; in da9150_charger_probe()
558 charger->supply_online = charger->usb; in da9150_charger_probe()
562 charger->supply_online = NULL; in da9150_charger_probe()
567 charger->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in da9150_charger_probe()
568 if (!IS_ERR_OR_NULL(charger->usb_phy)) { in da9150_charger_probe()
569 INIT_WORK(&charger->otg_work, da9150_charger_otg_work); in da9150_charger_probe()
570 charger->otg_nb.notifier_call = da9150_charger_otg_ncb; in da9150_charger_probe()
571 usb_register_notifier(charger->usb_phy, &charger->otg_nb); in da9150_charger_probe()
605 if (!IS_ERR_OR_NULL(charger->usb_phy)) in da9150_charger_probe()
606 usb_unregister_notifier(charger->usb_phy, &charger->otg_nb); in da9150_charger_probe()
613 struct da9150_charger *charger = platform_get_drvdata(pdev); in da9150_charger_remove() local
618 free_irq(irq, charger); in da9150_charger_remove()
621 free_irq(irq, charger); in da9150_charger_remove()
624 free_irq(irq, charger); in da9150_charger_remove()
627 free_irq(irq, charger); in da9150_charger_remove()
629 if (!IS_ERR_OR_NULL(charger->usb_phy)) in da9150_charger_remove()
630 usb_unregister_notifier(charger->usb_phy, &charger->otg_nb); in da9150_charger_remove()
631 cancel_work_sync(&charger->otg_work); in da9150_charger_remove()
636 .name = "da9150-charger",
644 MODULE_DESCRIPTION("Charger Driver for DA9150");