MLK-19850-6 usb: chipidea: introduce flag for enable USB PHY charger detection
authorPeter Chen <peter.chen@nxp.com>
Mon, 8 Oct 2018 09:43:45 +0000 (17:43 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Some platforms may want to use USB PHY charger detection function
when VBUS is there, add one flag for it. The user can enable it
at firmware.

Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
drivers/usb/chipidea/core.c
drivers/usb/chipidea/udc.c
include/linux/usb/chipidea.h

index 9a6a21b..6874d75 100644 (file)
@@ -81,6 +81,7 @@ Optional properties:
   mux state of 1 indicates host mode.
 - mux-control-names: Shall be "usb_switch" if mux-controls is specified.
 - ci-disable-lpm: Some chipidea hardware need to disable low power mode
+- phy-charger-detection: enable USB PHY charger detection function
 
 i.mx specific properties
 - fsl,usbmisc: phandler of non-core register device, with one
index 27b335b..a1a8697 100644 (file)
@@ -687,6 +687,12 @@ static int ci_get_platdata(struct device *dev,
        if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL))
                platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA;
 
+       /* "imx-usb-charger-detection is legacy compatible */
+       if (of_find_property(dev->of_node, "phy-charger-detection", NULL) ||
+               of_find_property(dev->of_node, "imx-usb-charger-detection",
+                       NULL))
+               platdata->flags |= CI_HDRC_PHY_CHARGER_DETECTION;
+
        ext_id = ERR_PTR(-ENODEV);
        ext_vbus = ERR_PTR(-ENODEV);
        if (of_property_read_bool(dev->of_node, "extcon")) {
index 0464986..b4e25ab 100644 (file)
@@ -2013,6 +2013,9 @@ int ci_usb_charger_connect(struct ci_hdrc *ci, int is_active)
        if (is_active)
                pm_runtime_get_sync(ci->dev);
 
+       if (!(ci->platdata->flags & CI_HDRC_PHY_CHARGER_DETECTION))
+               goto out;
+
        if (ci->usb_phy->charger_detect) {
                usb_phy_set_charger_state(ci->usb_phy, is_active ?
                        USB_CHARGER_PRESENT : USB_CHARGER_ABSENT);
@@ -2033,6 +2036,7 @@ int ci_usb_charger_connect(struct ci_hdrc *ci, int is_active)
                }
                schedule_work(&ci->usb_phy->chg_work);
        }
+out:
 
        if (!is_active)
                pm_runtime_put_sync(ci->dev);
index 91250f5..ba2c490 100644 (file)
@@ -64,6 +64,8 @@ struct ci_hdrc_platform_data {
 #define CI_HDRC_IMX_IS_HSIC            BIT(15)
 /* need request pmqos during low power */
 #define CI_HDRC_PMQOS                  BIT(16)
+/* Using PHY's charger detection */
+#define CI_HDRC_PHY_CHARGER_DETECTION  BIT(17)
        enum usb_dr_mode        dr_mode;
 #define CI_HDRC_CONTROLLER_RESET_EVENT         0
 #define CI_HDRC_CONTROLLER_STOPPED_EVENT       1