Lines Matching full:charger

3  * DA9150 Charger Driver
44 static inline int da9150_charger_supply_online(struct da9150_charger *charger, in da9150_charger_supply_online() argument
48 val->intval = (psy == charger->supply_online) ? 1 : 0; in da9150_charger_supply_online()
53 /* Charger Properties */
54 static int da9150_charger_vbus_voltage_now(struct da9150_charger *charger, in da9150_charger_vbus_voltage_now() argument
60 ret = iio_read_channel_processed(charger->vbus_chan, &v_val); in da9150_charger_vbus_voltage_now()
70 static int da9150_charger_ibus_current_avg(struct da9150_charger *charger, in da9150_charger_ibus_current_avg() argument
76 ret = iio_read_channel_processed(charger->ibus_chan, &i_val); in da9150_charger_ibus_current_avg()
86 static int da9150_charger_tjunc_temp(struct da9150_charger *charger, in da9150_charger_tjunc_temp() argument
92 ret = iio_read_channel_processed(charger->tjunc_chan, &t_val); in da9150_charger_tjunc_temp()
113 struct da9150_charger *charger = dev_get_drvdata(psy->dev.parent); in da9150_charger_get_prop() local
118 ret = da9150_charger_supply_online(charger, psy, val); in da9150_charger_get_prop()
121 ret = da9150_charger_vbus_voltage_now(charger, val); in da9150_charger_get_prop()
124 ret = da9150_charger_ibus_current_avg(charger, val); in da9150_charger_get_prop()
127 ret = da9150_charger_tjunc_temp(charger, val); in da9150_charger_get_prop()
138 static int da9150_charger_battery_status(struct da9150_charger *charger, in da9150_charger_battery_status() argument
144 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_H); in da9150_charger_battery_status()
153 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_J); in da9150_charger_battery_status()
181 static int da9150_charger_battery_health(struct da9150_charger *charger, in da9150_charger_battery_health() argument
186 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_J); in da9150_charger_battery_health()
217 static int da9150_charger_battery_present(struct da9150_charger *charger, in da9150_charger_battery_present() argument
223 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_J); in da9150_charger_battery_present()
232 static int da9150_charger_battery_charge_type(struct da9150_charger *charger, in da9150_charger_battery_charge_type() argument
237 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_J); in da9150_charger_battery_charge_type()
256 static int da9150_charger_battery_voltage_min(struct da9150_charger *charger, in da9150_charger_battery_voltage_min() argument
261 reg = da9150_reg_read(charger->da9150, DA9150_PPR_CHGCTRL_C); in da9150_charger_battery_voltage_min()
269 static int da9150_charger_battery_voltage_now(struct da9150_charger *charger, in da9150_charger_battery_voltage_now() argument
275 ret = iio_read_channel_processed(charger->vbat_chan, &v_val); in da9150_charger_battery_voltage_now()
284 static int da9150_charger_battery_current_max(struct da9150_charger *charger, in da9150_charger_battery_current_max() argument
289 reg = da9150_reg_read(charger->da9150, DA9150_PPR_CHGCTRL_D); in da9150_charger_battery_current_max()
297 static int da9150_charger_battery_voltage_max(struct da9150_charger *charger, in da9150_charger_battery_voltage_max() argument
302 reg = da9150_reg_read(charger->da9150, DA9150_PPR_CHGCTRL_B); in da9150_charger_battery_voltage_max()
325 struct da9150_charger *charger = dev_get_drvdata(psy->dev.parent); in da9150_charger_battery_get_prop() local
330 ret = da9150_charger_battery_status(charger, val); in da9150_charger_battery_get_prop()
333 ret = da9150_charger_supply_online(charger, psy, val); in da9150_charger_battery_get_prop()
336 ret = da9150_charger_battery_health(charger, val); in da9150_charger_battery_get_prop()
339 ret = da9150_charger_battery_present(charger, val); in da9150_charger_battery_get_prop()
342 ret = da9150_charger_battery_charge_type(charger, val); in da9150_charger_battery_get_prop()
345 ret = da9150_charger_battery_voltage_min(charger, val); in da9150_charger_battery_get_prop()
348 ret = da9150_charger_battery_voltage_now(charger, val); in da9150_charger_battery_get_prop()
351 ret = da9150_charger_battery_current_max(charger, val); in da9150_charger_battery_get_prop()
354 ret = da9150_charger_battery_voltage_max(charger, val); in da9150_charger_battery_get_prop()
366 struct da9150_charger *charger = data; in da9150_charger_chg_irq() local
368 power_supply_changed(charger->battery); in da9150_charger_chg_irq()
375 struct da9150_charger *charger = data; in da9150_charger_tjunc_irq() local
378 dev_crit(charger->dev, "TJunc over temperature!!!\n"); in da9150_charger_tjunc_irq()
379 power_supply_changed(charger->usb); in da9150_charger_tjunc_irq()
386 struct da9150_charger *charger = data; in da9150_charger_vfault_irq() local
389 dev_crit(charger->dev, "VSYS under voltage!!!\n"); in da9150_charger_vfault_irq()
390 power_supply_changed(charger->usb); in da9150_charger_vfault_irq()
391 power_supply_changed(charger->battery); in da9150_charger_vfault_irq()
398 struct da9150_charger *charger = data; in da9150_charger_vbus_irq() local
401 reg = da9150_reg_read(charger->da9150, DA9150_STATUS_H); in da9150_charger_vbus_irq()
403 /* Charger plugged in or battery only */ in da9150_charger_vbus_irq()
407 charger->supply_online = charger->battery; in da9150_charger_vbus_irq()
410 charger->supply_online = charger->usb; in da9150_charger_vbus_irq()
413 dev_warn(charger->dev, "Unknown VBUS state - reg = 0x%x\n", in da9150_charger_vbus_irq()
415 charger->supply_online = NULL; in da9150_charger_vbus_irq()
419 power_supply_changed(charger->usb); in da9150_charger_vbus_irq()
420 power_supply_changed(charger->battery); in da9150_charger_vbus_irq()
427 struct da9150_charger *charger = in da9150_charger_otg_work() local
430 switch (charger->usb_event) { in da9150_charger_otg_work()
433 da9150_set_bits(charger->da9150, DA9150_PPR_BKCTRL_A, in da9150_charger_otg_work()
438 power_supply_changed(charger->usb); in da9150_charger_otg_work()
439 power_supply_changed(charger->battery); in da9150_charger_otg_work()
440 da9150_set_bits(charger->da9150, DA9150_PPR_BKCTRL_A, in da9150_charger_otg_work()
449 struct da9150_charger *charger = in da9150_charger_otg_ncb() local
452 dev_dbg(charger->dev, "DA9150 OTG notify %lu\n", val); in da9150_charger_otg_ncb()
454 charger->usb_event = val; in da9150_charger_otg_ncb()
455 schedule_work(&charger->otg_work); in da9150_charger_otg_ncb()
465 struct da9150_charger *charger = platform_get_drvdata(pdev); in da9150_charger_register_irq() local
475 charger); in da9150_charger_register_irq()
486 struct da9150_charger *charger = platform_get_drvdata(pdev); in da9150_charger_unregister_irq() local
495 free_irq(irq, charger); in da9150_charger_unregister_irq()
518 struct da9150_charger *charger; in da9150_charger_probe() local
522 charger = devm_kzalloc(dev, sizeof(struct da9150_charger), GFP_KERNEL); in da9150_charger_probe()
523 if (!charger) in da9150_charger_probe()
526 platform_set_drvdata(pdev, charger); in da9150_charger_probe()
527 charger->da9150 = da9150; in da9150_charger_probe()
528 charger->dev = dev; in da9150_charger_probe()
531 charger->ibus_chan = iio_channel_get(dev, "CHAN_IBUS"); in da9150_charger_probe()
532 if (IS_ERR(charger->ibus_chan)) { in da9150_charger_probe()
533 ret = PTR_ERR(charger->ibus_chan); in da9150_charger_probe()
537 charger->vbus_chan = iio_channel_get(dev, "CHAN_VBUS"); in da9150_charger_probe()
538 if (IS_ERR(charger->vbus_chan)) { in da9150_charger_probe()
539 ret = PTR_ERR(charger->vbus_chan); in da9150_charger_probe()
543 charger->tjunc_chan = iio_channel_get(dev, "CHAN_TJUNC"); in da9150_charger_probe()
544 if (IS_ERR(charger->tjunc_chan)) { in da9150_charger_probe()
545 ret = PTR_ERR(charger->tjunc_chan); in da9150_charger_probe()
549 charger->vbat_chan = iio_channel_get(dev, "CHAN_VBAT"); in da9150_charger_probe()
550 if (IS_ERR(charger->vbat_chan)) { in da9150_charger_probe()
551 ret = PTR_ERR(charger->vbat_chan); in da9150_charger_probe()
556 charger->usb = power_supply_register(dev, &usb_desc, NULL); in da9150_charger_probe()
557 if (IS_ERR(charger->usb)) { in da9150_charger_probe()
558 ret = PTR_ERR(charger->usb); in da9150_charger_probe()
562 charger->battery = power_supply_register(dev, &battery_desc, NULL); in da9150_charger_probe()
563 if (IS_ERR(charger->battery)) { in da9150_charger_probe()
564 ret = PTR_ERR(charger->battery); in da9150_charger_probe()
574 charger->supply_online = charger->battery; in da9150_charger_probe()
577 charger->supply_online = charger->usb; in da9150_charger_probe()
581 charger->supply_online = NULL; in da9150_charger_probe()
586 charger->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in da9150_charger_probe()
587 if (!IS_ERR_OR_NULL(charger->usb_phy)) { in da9150_charger_probe()
588 INIT_WORK(&charger->otg_work, da9150_charger_otg_work); in da9150_charger_probe()
589 charger->otg_nb.notifier_call = da9150_charger_otg_ncb; in da9150_charger_probe()
590 usb_register_notifier(charger->usb_phy, &charger->otg_nb); in da9150_charger_probe()
624 if (!IS_ERR_OR_NULL(charger->usb_phy)) in da9150_charger_probe()
625 usb_unregister_notifier(charger->usb_phy, &charger->otg_nb); in da9150_charger_probe()
627 power_supply_unregister(charger->usb); in da9150_charger_probe()
630 iio_channel_release(charger->vbat_chan); in da9150_charger_probe()
633 iio_channel_release(charger->tjunc_chan); in da9150_charger_probe()
636 iio_channel_release(charger->vbus_chan); in da9150_charger_probe()
639 iio_channel_release(charger->ibus_chan); in da9150_charger_probe()
647 struct da9150_charger *charger = platform_get_drvdata(pdev); in da9150_charger_remove() local
652 free_irq(irq, charger); in da9150_charger_remove()
655 free_irq(irq, charger); in da9150_charger_remove()
658 free_irq(irq, charger); in da9150_charger_remove()
661 free_irq(irq, charger); in da9150_charger_remove()
663 if (!IS_ERR_OR_NULL(charger->usb_phy)) in da9150_charger_remove()
664 usb_unregister_notifier(charger->usb_phy, &charger->otg_nb); in da9150_charger_remove()
666 power_supply_unregister(charger->battery); in da9150_charger_remove()
667 power_supply_unregister(charger->usb); in da9150_charger_remove()
670 iio_channel_release(charger->ibus_chan); in da9150_charger_remove()
671 iio_channel_release(charger->vbus_chan); in da9150_charger_remove()
672 iio_channel_release(charger->tjunc_chan); in da9150_charger_remove()
673 iio_channel_release(charger->vbat_chan); in da9150_charger_remove()
680 .name = "da9150-charger",
688 MODULE_DESCRIPTION("Charger Driver for DA9150");