USB: OTG: msm: Fix wall charger compliance issues
Battery charging spec 1.2 mandates portable devices to enable VDP_SRC while charging from dedicated charger port. Enable VDP_SRC after detecting the charger as wall charger and enter low power mode. PHY can not drive VDP_SRC in retention. Vote against PHY retention and PHY power collapse. Disable primary detection circuit and wait for 20msec before enabling secondary detection circuit. This would allow complete discharge of voltage on the DM. The DP/DM voltage source on time is taken as 40msec. The spec allows any value greater than 40msec. Increase this timeout value to 50msec for passing compliance tests correctly. CRs-fixed: 330227 Change-Id: I0bc72b2098ff52644daab3a902b5ba099bb83667 Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
This commit is contained in:
committed by
Linux Build Service Account
parent
ed1e2dd6d8
commit
283146fe67
@@ -608,7 +608,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
|
||||
struct usb_bus *bus = otg->host;
|
||||
struct msm_otg_platform_data *pdata = motg->pdata;
|
||||
int cnt = 0;
|
||||
bool host_bus_suspend;
|
||||
bool host_bus_suspend, dcp;
|
||||
u32 phy_ctrl_val = 0, cmd_val;
|
||||
u32 portsc;
|
||||
|
||||
@@ -617,6 +617,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
|
||||
|
||||
disable_irq(motg->irq);
|
||||
host_bus_suspend = otg->host && !test_bit(ID, &motg->inputs);
|
||||
dcp = motg->chg_type == USB_DCP_CHARGER;
|
||||
/*
|
||||
* Chipidea 45-nm PHY suspend sequence:
|
||||
*
|
||||
@@ -689,7 +690,11 @@ static int msm_otg_suspend(struct msm_otg *motg)
|
||||
cmd_val |= ULPI_STP_CTRL;
|
||||
writel_relaxed(cmd_val, USB_USBCMD);
|
||||
|
||||
if (motg->caps & ALLOW_PHY_RETENTION && !host_bus_suspend) {
|
||||
/*
|
||||
* BC1.2 spec mandates PD to enable VDP_SRC when charging from DCP.
|
||||
* PHY retention and collapse can not happen with VDP_SRC enabled.
|
||||
*/
|
||||
if (motg->caps & ALLOW_PHY_RETENTION && !host_bus_suspend && !dcp) {
|
||||
phy_ctrl_val = readl_relaxed(USB_PHY_CTRL);
|
||||
if (motg->pdata->otg_control == OTG_PHY_CONTROL)
|
||||
/* Enable PHY HV interrupts to wake MPM/Link */
|
||||
@@ -708,7 +713,8 @@ static int msm_otg_suspend(struct msm_otg *motg)
|
||||
/* usb phy no more require TCXO clock, hence vote for TCXO disable */
|
||||
clk_disable_unprepare(motg->xo_handle);
|
||||
|
||||
if (motg->caps & ALLOW_PHY_POWER_COLLAPSE && !host_bus_suspend) {
|
||||
if (motg->caps & ALLOW_PHY_POWER_COLLAPSE &&
|
||||
!host_bus_suspend && !dcp) {
|
||||
msm_hsusb_ldo_enable(motg, 0);
|
||||
motg->lpm_flags |= PHY_PWR_COLLAPSED;
|
||||
}
|
||||
@@ -1433,6 +1439,9 @@ static void msm_chg_enable_secondary_det(struct msm_otg *motg)
|
||||
ulpi_write(otg, chg_det, 0x34);
|
||||
break;
|
||||
case SNPS_28NM_INTEGRATED_PHY:
|
||||
/* Turn off VDP_SRC */
|
||||
ulpi_write(otg, 0x3, 0x86);
|
||||
msleep(20);
|
||||
/*
|
||||
* Configure DM as current source, DP as current sink
|
||||
* and enable battery charging comparators.
|
||||
@@ -1634,8 +1643,8 @@ static const char *chg_to_string(enum usb_chg_type chg_type)
|
||||
|
||||
#define MSM_CHG_DCD_POLL_TIME (100 * HZ/1000) /* 100 msec */
|
||||
#define MSM_CHG_DCD_MAX_RETRIES 6 /* Tdcd_tmout = 6 * 100 msec */
|
||||
#define MSM_CHG_PRIMARY_DET_TIME (40 * HZ/1000) /* TVDPSRC_ON */
|
||||
#define MSM_CHG_SECONDARY_DET_TIME (40 * HZ/1000) /* TVDMSRC_ON */
|
||||
#define MSM_CHG_PRIMARY_DET_TIME (50 * HZ/1000) /* TVDPSRC_ON */
|
||||
#define MSM_CHG_SECONDARY_DET_TIME (50 * HZ/1000) /* TVDMSRC_ON */
|
||||
static void msm_chg_detect_work(struct work_struct *w)
|
||||
{
|
||||
struct msm_otg *motg = container_of(w, struct msm_otg, chg_work.work);
|
||||
@@ -1852,6 +1861,8 @@ static void msm_otg_sm_work(struct work_struct *w)
|
||||
case USB_CHG_STATE_DETECTED:
|
||||
switch (motg->chg_type) {
|
||||
case USB_DCP_CHARGER:
|
||||
/* Enable VDP_SRC */
|
||||
ulpi_write(otg, 0x2, 0x85);
|
||||
msm_otg_notify_charger(motg,
|
||||
IDEV_CHG_MAX);
|
||||
pm_runtime_put_noidle(otg->dev);
|
||||
|
||||
Reference in New Issue
Block a user