|
@@ -129,10 +129,6 @@
|
|
|
|
|
|
#define AXP288_EXTCON_DEV_NAME "axp288_extcon"
|
|
#define AXP288_EXTCON_DEV_NAME "axp288_extcon"
|
|
|
|
|
|
-#define AXP288_EXTCON_SLOW_CHARGER "SLOW-CHARGER"
|
|
|
|
-#define AXP288_EXTCON_DOWNSTREAM_CHARGER "CHARGE-DOWNSTREAM"
|
|
|
|
-#define AXP288_EXTCON_FAST_CHARGER "FAST-CHARGER"
|
|
|
|
-
|
|
|
|
enum {
|
|
enum {
|
|
VBUS_OV_IRQ = 0,
|
|
VBUS_OV_IRQ = 0,
|
|
CHARGE_DONE_IRQ,
|
|
CHARGE_DONE_IRQ,
|
|
@@ -158,7 +154,7 @@ struct axp288_chrg_info {
|
|
/* OTG/Host mode */
|
|
/* OTG/Host mode */
|
|
struct {
|
|
struct {
|
|
struct work_struct work;
|
|
struct work_struct work;
|
|
- struct extcon_specific_cable_nb cable;
|
|
|
|
|
|
+ struct extcon_dev *cable;
|
|
struct notifier_block id_nb;
|
|
struct notifier_block id_nb;
|
|
bool id_short;
|
|
bool id_short;
|
|
} otg;
|
|
} otg;
|
|
@@ -586,17 +582,15 @@ static void axp288_charger_extcon_evt_worker(struct work_struct *work)
|
|
bool old_connected = info->cable.connected;
|
|
bool old_connected = info->cable.connected;
|
|
|
|
|
|
/* Determine cable/charger type */
|
|
/* Determine cable/charger type */
|
|
- if (extcon_get_cable_state(edev, AXP288_EXTCON_SLOW_CHARGER) > 0) {
|
|
|
|
|
|
+ if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_SDP) > 0) {
|
|
dev_dbg(&info->pdev->dev, "USB SDP charger is connected");
|
|
dev_dbg(&info->pdev->dev, "USB SDP charger is connected");
|
|
info->cable.connected = true;
|
|
info->cable.connected = true;
|
|
info->cable.chg_type = POWER_SUPPLY_TYPE_USB;
|
|
info->cable.chg_type = POWER_SUPPLY_TYPE_USB;
|
|
- } else if (extcon_get_cable_state(edev,
|
|
|
|
- AXP288_EXTCON_DOWNSTREAM_CHARGER) > 0) {
|
|
|
|
|
|
+ } else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_CDP) > 0) {
|
|
dev_dbg(&info->pdev->dev, "USB CDP charger is connected");
|
|
dev_dbg(&info->pdev->dev, "USB CDP charger is connected");
|
|
info->cable.connected = true;
|
|
info->cable.connected = true;
|
|
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP;
|
|
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP;
|
|
- } else if (extcon_get_cable_state(edev,
|
|
|
|
- AXP288_EXTCON_FAST_CHARGER) > 0) {
|
|
|
|
|
|
+ } else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_DCP) > 0) {
|
|
dev_dbg(&info->pdev->dev, "USB DCP charger is connected");
|
|
dev_dbg(&info->pdev->dev, "USB DCP charger is connected");
|
|
info->cable.connected = true;
|
|
info->cable.connected = true;
|
|
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP;
|
|
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP;
|
|
@@ -692,8 +686,8 @@ static int axp288_charger_handle_otg_evt(struct notifier_block *nb,
|
|
{
|
|
{
|
|
struct axp288_chrg_info *info =
|
|
struct axp288_chrg_info *info =
|
|
container_of(nb, struct axp288_chrg_info, otg.id_nb);
|
|
container_of(nb, struct axp288_chrg_info, otg.id_nb);
|
|
- struct extcon_dev *edev = param;
|
|
|
|
- int usb_host = extcon_get_cable_state(edev, "USB-Host");
|
|
|
|
|
|
+ struct extcon_dev *edev = info->otg.cable;
|
|
|
|
+ int usb_host = extcon_get_cable_state_(edev, EXTCON_USB_HOST);
|
|
|
|
|
|
dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n",
|
|
dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n",
|
|
usb_host ? "attached" : "detached");
|
|
usb_host ? "attached" : "detached");
|
|
@@ -848,10 +842,33 @@ static int axp288_charger_probe(struct platform_device *pdev)
|
|
/* Register for extcon notification */
|
|
/* Register for extcon notification */
|
|
INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker);
|
|
INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker);
|
|
info->cable.nb.notifier_call = axp288_charger_handle_cable_evt;
|
|
info->cable.nb.notifier_call = axp288_charger_handle_cable_evt;
|
|
- ret = extcon_register_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb);
|
|
|
|
|
|
+ ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
|
|
|
|
+ &info->cable.nb);
|
|
|
|
+ if (ret) {
|
|
|
|
+ dev_err(&info->pdev->dev,
|
|
|
|
+ "failed to register extcon notifier for SDP %d\n", ret);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
|
|
|
|
+ &info->cable.nb);
|
|
|
|
+ if (ret) {
|
|
|
|
+ dev_err(&info->pdev->dev,
|
|
|
|
+ "failed to register extcon notifier for CDP %d\n", ret);
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev,
|
|
|
|
+ EXTCON_CHG_USB_SDP, &info->cable.nb);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
|
|
|
|
+ &info->cable.nb);
|
|
if (ret) {
|
|
if (ret) {
|
|
dev_err(&info->pdev->dev,
|
|
dev_err(&info->pdev->dev,
|
|
- "failed to register extcon notifier %d\n", ret);
|
|
|
|
|
|
+ "failed to register extcon notifier for DCP %d\n", ret);
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev,
|
|
|
|
+ EXTCON_CHG_USB_SDP, &info->cable.nb);
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev,
|
|
|
|
+ EXTCON_CHG_USB_CDP, &info->cable.nb);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -871,14 +888,14 @@ static int axp288_charger_probe(struct platform_device *pdev)
|
|
/* Register for OTG notification */
|
|
/* Register for OTG notification */
|
|
INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker);
|
|
INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker);
|
|
info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt;
|
|
info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt;
|
|
- ret = extcon_register_interest(&info->otg.cable, NULL, "USB-Host",
|
|
|
|
|
|
+ ret = extcon_register_notifier(info->otg.cable, EXTCON_USB_HOST,
|
|
&info->otg.id_nb);
|
|
&info->otg.id_nb);
|
|
if (ret)
|
|
if (ret)
|
|
dev_warn(&pdev->dev, "failed to register otg notifier\n");
|
|
dev_warn(&pdev->dev, "failed to register otg notifier\n");
|
|
|
|
|
|
- if (info->otg.cable.edev)
|
|
|
|
- info->otg.id_short = extcon_get_cable_state(
|
|
|
|
- info->otg.cable.edev, "USB-Host");
|
|
|
|
|
|
+ if (info->otg.cable)
|
|
|
|
+ info->otg.id_short = extcon_get_cable_state_(
|
|
|
|
+ info->otg.cable, EXTCON_USB_HOST);
|
|
|
|
|
|
/* Register charger interrupts */
|
|
/* Register charger interrupts */
|
|
for (i = 0; i < CHRG_INTR_END; i++) {
|
|
for (i = 0; i < CHRG_INTR_END; i++) {
|
|
@@ -905,11 +922,17 @@ static int axp288_charger_probe(struct platform_device *pdev)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
intr_reg_failed:
|
|
intr_reg_failed:
|
|
- if (info->otg.cable.edev)
|
|
|
|
- extcon_unregister_interest(&info->otg.cable);
|
|
|
|
|
|
+ if (info->otg.cable)
|
|
|
|
+ extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST,
|
|
|
|
+ &info->otg.id_nb);
|
|
power_supply_unregister(info->psy_usb);
|
|
power_supply_unregister(info->psy_usb);
|
|
psy_reg_failed:
|
|
psy_reg_failed:
|
|
- extcon_unregister_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb);
|
|
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
|
|
|
|
+ &info->cable.nb);
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
|
|
|
|
+ &info->cable.nb);
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
|
|
|
|
+ &info->cable.nb);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -917,10 +940,16 @@ static int axp288_charger_remove(struct platform_device *pdev)
|
|
{
|
|
{
|
|
struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev);
|
|
struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev);
|
|
|
|
|
|
- if (info->otg.cable.edev)
|
|
|
|
- extcon_unregister_interest(&info->otg.cable);
|
|
|
|
|
|
+ if (info->otg.cable)
|
|
|
|
+ extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST,
|
|
|
|
+ &info->otg.id_nb);
|
|
|
|
|
|
- extcon_unregister_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb);
|
|
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
|
|
|
|
+ &info->cable.nb);
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
|
|
|
|
+ &info->cable.nb);
|
|
|
|
+ extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
|
|
|
|
+ &info->cable.nb);
|
|
power_supply_unregister(info->psy_usb);
|
|
power_supply_unregister(info->psy_usb);
|
|
|
|
|
|
return 0;
|
|
return 0;
|