|
Lines 129-138
Link Here
|
| 129 |
|
129 |
|
| 130 |
#define AXP288_EXTCON_DEV_NAME "axp288_extcon" |
130 |
#define AXP288_EXTCON_DEV_NAME "axp288_extcon" |
| 131 |
|
131 |
|
| 132 |
#define AXP288_EXTCON_SLOW_CHARGER "SLOW-CHARGER" |
|
|
| 133 |
#define AXP288_EXTCON_DOWNSTREAM_CHARGER "CHARGE-DOWNSTREAM" |
| 134 |
#define AXP288_EXTCON_FAST_CHARGER "FAST-CHARGER" |
| 135 |
|
| 136 |
enum { |
132 |
enum { |
| 137 |
VBUS_OV_IRQ = 0, |
133 |
VBUS_OV_IRQ = 0, |
| 138 |
CHARGE_DONE_IRQ, |
134 |
CHARGE_DONE_IRQ, |
|
Lines 158-164
struct axp288_chrg_info {
Link Here
|
| 158 |
/* OTG/Host mode */ |
154 |
/* OTG/Host mode */ |
| 159 |
struct { |
155 |
struct { |
| 160 |
struct work_struct work; |
156 |
struct work_struct work; |
| 161 |
struct extcon_specific_cable_nb cable; |
157 |
struct extcon_dev *cable; |
| 162 |
struct notifier_block id_nb; |
158 |
struct notifier_block id_nb; |
| 163 |
bool id_short; |
159 |
bool id_short; |
| 164 |
} otg; |
160 |
} otg; |
|
Lines 586-602
static void axp288_charger_extcon_evt_worker(struct work_struct *work)
Link Here
|
| 586 |
bool old_connected = info->cable.connected; |
582 |
bool old_connected = info->cable.connected; |
| 587 |
|
583 |
|
| 588 |
/* Determine cable/charger type */ |
584 |
/* Determine cable/charger type */ |
| 589 |
if (extcon_get_cable_state(edev, AXP288_EXTCON_SLOW_CHARGER) > 0) { |
585 |
if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_SDP) > 0) { |
| 590 |
dev_dbg(&info->pdev->dev, "USB SDP charger is connected"); |
586 |
dev_dbg(&info->pdev->dev, "USB SDP charger is connected"); |
| 591 |
info->cable.connected = true; |
587 |
info->cable.connected = true; |
| 592 |
info->cable.chg_type = POWER_SUPPLY_TYPE_USB; |
588 |
info->cable.chg_type = POWER_SUPPLY_TYPE_USB; |
| 593 |
} else if (extcon_get_cable_state(edev, |
589 |
} else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_CDP) > 0) { |
| 594 |
AXP288_EXTCON_DOWNSTREAM_CHARGER) > 0) { |
|
|
| 595 |
dev_dbg(&info->pdev->dev, "USB CDP charger is connected"); |
590 |
dev_dbg(&info->pdev->dev, "USB CDP charger is connected"); |
| 596 |
info->cable.connected = true; |
591 |
info->cable.connected = true; |
| 597 |
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP; |
592 |
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP; |
| 598 |
} else if (extcon_get_cable_state(edev, |
593 |
} else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_DCP) > 0) { |
| 599 |
AXP288_EXTCON_FAST_CHARGER) > 0) { |
|
|
| 600 |
dev_dbg(&info->pdev->dev, "USB DCP charger is connected"); |
594 |
dev_dbg(&info->pdev->dev, "USB DCP charger is connected"); |
| 601 |
info->cable.connected = true; |
595 |
info->cable.connected = true; |
| 602 |
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP; |
596 |
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP; |
|
Lines 692-699
static int axp288_charger_handle_otg_evt(struct notifier_block *nb,
Link Here
|
| 692 |
{ |
686 |
{ |
| 693 |
struct axp288_chrg_info *info = |
687 |
struct axp288_chrg_info *info = |
| 694 |
container_of(nb, struct axp288_chrg_info, otg.id_nb); |
688 |
container_of(nb, struct axp288_chrg_info, otg.id_nb); |
| 695 |
struct extcon_dev *edev = param; |
689 |
struct extcon_dev *edev = info->otg.cable; |
| 696 |
int usb_host = extcon_get_cable_state(edev, "USB-Host"); |
690 |
int usb_host = extcon_get_cable_state_(edev, EXTCON_USB_HOST); |
| 697 |
|
691 |
|
| 698 |
dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n", |
692 |
dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n", |
| 699 |
usb_host ? "attached" : "detached"); |
693 |
usb_host ? "attached" : "detached"); |
|
Lines 848-857
static int axp288_charger_probe(struct platform_device *pdev)
Link Here
|
| 848 |
/* Register for extcon notification */ |
842 |
/* Register for extcon notification */ |
| 849 |
INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker); |
843 |
INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker); |
| 850 |
info->cable.nb.notifier_call = axp288_charger_handle_cable_evt; |
844 |
info->cable.nb.notifier_call = axp288_charger_handle_cable_evt; |
| 851 |
ret = extcon_register_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); |
845 |
ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_SDP, |
|
|
846 |
&info->cable.nb); |
| 847 |
if (ret) { |
| 848 |
dev_err(&info->pdev->dev, |
| 849 |
"failed to register extcon notifier for SDP %d\n", ret); |
| 850 |
return ret; |
| 851 |
} |
| 852 |
|
| 853 |
ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_CDP, |
| 854 |
&info->cable.nb); |
| 855 |
if (ret) { |
| 856 |
dev_err(&info->pdev->dev, |
| 857 |
"failed to register extcon notifier for CDP %d\n", ret); |
| 858 |
extcon_unregister_notifier(info->cable.edev, |
| 859 |
EXTCON_CHG_USB_SDP, &info->cable.nb); |
| 860 |
return ret; |
| 861 |
} |
| 862 |
|
| 863 |
ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_DCP, |
| 864 |
&info->cable.nb); |
| 852 |
if (ret) { |
865 |
if (ret) { |
| 853 |
dev_err(&info->pdev->dev, |
866 |
dev_err(&info->pdev->dev, |
| 854 |
"failed to register extcon notifier %d\n", ret); |
867 |
"failed to register extcon notifier for DCP %d\n", ret); |
|
|
868 |
extcon_unregister_notifier(info->cable.edev, |
| 869 |
EXTCON_CHG_USB_SDP, &info->cable.nb); |
| 870 |
extcon_unregister_notifier(info->cable.edev, |
| 871 |
EXTCON_CHG_USB_CDP, &info->cable.nb); |
| 855 |
return ret; |
872 |
return ret; |
| 856 |
} |
873 |
} |
| 857 |
|
874 |
|
|
Lines 871-884
static int axp288_charger_probe(struct platform_device *pdev)
Link Here
|
| 871 |
/* Register for OTG notification */ |
888 |
/* Register for OTG notification */ |
| 872 |
INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker); |
889 |
INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker); |
| 873 |
info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt; |
890 |
info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt; |
| 874 |
ret = extcon_register_interest(&info->otg.cable, NULL, "USB-Host", |
891 |
ret = extcon_register_notifier(info->otg.cable, EXTCON_USB_HOST, |
| 875 |
&info->otg.id_nb); |
892 |
&info->otg.id_nb); |
| 876 |
if (ret) |
893 |
if (ret) |
| 877 |
dev_warn(&pdev->dev, "failed to register otg notifier\n"); |
894 |
dev_warn(&pdev->dev, "failed to register otg notifier\n"); |
| 878 |
|
895 |
|
| 879 |
if (info->otg.cable.edev) |
896 |
if (info->otg.cable) |
| 880 |
info->otg.id_short = extcon_get_cable_state( |
897 |
info->otg.id_short = extcon_get_cable_state_( |
| 881 |
info->otg.cable.edev, "USB-Host"); |
898 |
info->otg.cable, EXTCON_USB_HOST); |
| 882 |
|
899 |
|
| 883 |
/* Register charger interrupts */ |
900 |
/* Register charger interrupts */ |
| 884 |
for (i = 0; i < CHRG_INTR_END; i++) { |
901 |
for (i = 0; i < CHRG_INTR_END; i++) { |
|
Lines 905-915
static int axp288_charger_probe(struct platform_device *pdev)
Link Here
|
| 905 |
return 0; |
922 |
return 0; |
| 906 |
|
923 |
|
| 907 |
intr_reg_failed: |
924 |
intr_reg_failed: |
| 908 |
if (info->otg.cable.edev) |
925 |
if (info->otg.cable) |
| 909 |
extcon_unregister_interest(&info->otg.cable); |
926 |
extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST, |
|
|
927 |
&info->otg.id_nb); |
| 910 |
power_supply_unregister(info->psy_usb); |
928 |
power_supply_unregister(info->psy_usb); |
| 911 |
psy_reg_failed: |
929 |
psy_reg_failed: |
| 912 |
extcon_unregister_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); |
930 |
extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP, |
|
|
931 |
&info->cable.nb); |
| 932 |
extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP, |
| 933 |
&info->cable.nb); |
| 934 |
extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP, |
| 935 |
&info->cable.nb); |
| 913 |
return ret; |
936 |
return ret; |
| 914 |
} |
937 |
} |
| 915 |
|
938 |
|
|
Lines 917-926
static int axp288_charger_remove(struct platform_device *pdev)
Link Here
|
| 917 |
{ |
940 |
{ |
| 918 |
struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev); |
941 |
struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev); |
| 919 |
|
942 |
|
| 920 |
if (info->otg.cable.edev) |
943 |
if (info->otg.cable) |
| 921 |
extcon_unregister_interest(&info->otg.cable); |
944 |
extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST, |
|
|
945 |
&info->otg.id_nb); |
| 922 |
|
946 |
|
| 923 |
extcon_unregister_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); |
947 |
extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP, |
|
|
948 |
&info->cable.nb); |
| 949 |
extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP, |
| 950 |
&info->cable.nb); |
| 951 |
extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP, |
| 952 |
&info->cable.nb); |
| 924 |
power_supply_unregister(info->psy_usb); |
953 |
power_supply_unregister(info->psy_usb); |
| 925 |
|
954 |
|
| 926 |
return 0; |
955 |
return 0; |
| 927 |
- |
|
|