From e8380680f669666c7fe13d4b419db1078e948e8d Mon Sep 17 00:00:00 2001 From: Philip Rakity Date: Tue, 11 Feb 2014 16:06:52 +0000 Subject: phy usb: add Maxim Fast Charger information Maxim 14675 charger support at the PHY layer Bug 1321188 Bug 1456402 (cherry picked from commit 2ab5c72ab40adfdc34d5334a4c2c4648ccdac42e) Change-Id: I31d672e82f9f3a4ccf5a8db75df8f7e12f30a63b Reviewed-on: http://git-master/r/400490 Signed-off-by: Philip Rakity Reviewed-on: http://git-master/r/417035 Reviewed-by: Mandar Padmawar Tested-by: Mandar Padmawar --- drivers/usb/phy/phy-tegra-usb.c | 11 ++++++++++ drivers/usb/phy/tegra11x_usb_phy.c | 42 ++++++++++++++++++++++++++++++++++++++ drivers/usb/phy/tegra_usb_phy.h | 1 + 3 files changed, 54 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index ce98e7258fc3..e16cd53991b7 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -631,6 +631,17 @@ bool tegra_usb_phy_qc2_charger_detected(struct tegra_usb_phy *phy, return status; } +bool tegra_usb_phy_maxim_charger_detected(struct tegra_usb_phy *phy) +{ + bool status = 0; + + DBG("%s(%d) inst:[%d]\n", __func__, __LINE__, phy->inst); + if (phy->ops && phy->ops->maxim_charger_14675) + status = phy->ops->maxim_charger_14675(phy); + + return status; +} + bool tegra_usb_phy_nv_charger_detected(struct tegra_usb_phy *phy) { bool status = 0; diff --git a/drivers/usb/phy/tegra11x_usb_phy.c b/drivers/usb/phy/tegra11x_usb_phy.c index 3d9afad16148..34d64d5326f9 100644 --- a/drivers/usb/phy/tegra11x_usb_phy.c +++ b/drivers/usb/phy/tegra11x_usb_phy.c @@ -281,6 +281,9 @@ #define TDP_SRC_ON_MS 100 #define TDPSRC_CON_MS 40 +/* Maxim Debounce Timer */ +#define MAXIM_DEBOUNCE_TIME 120 + /* Force port resume wait time in micro second on remote resume */ #define FPR_WAIT_TIME_US 25000 @@ -1563,6 +1566,44 @@ static bool cdp_charger_detection(struct tegra_usb_phy *phy) return status; } +static bool maxim_charger_detection(struct tegra_usb_phy *phy) +{ + void __iomem *base = phy->regs; + unsigned long val; + unsigned long org_flags; + int status; + + /* + * Enable charger detection logic + * 3.3V on D+, Sink D- (high speed usb) + * Maxim charger will remove short !! -- DCP will not + */ + org_flags = utmi_phy_set_dp_dm_pull_up_down(phy, + FORCE_PULLUP_DP | DISABLE_PULLUP_DM | + DISABLE_PULLDN_DP | DISABLE_PULLDN_DM); + val = readl(base + UTMIP_BAT_CHRG_CFG0); + val &= ~(UTMIP_OP_SRC_EN | UTMIP_ON_SINK_EN); + val &= ~(UTMIP_ON_SRC_EN | UTMIP_OP_SINK_EN); + val |= UTMIP_ON_SINK_EN; + writel(val, base + UTMIP_BAT_CHRG_CFG0); + + /* Source should be on at least 120 ms per Maxim spec */ + msleep(MAXIM_DEBOUNCE_TIME); + + val = readl(base + USB_PHY_VBUS_WAKEUP_ID); + if (val & VDAT_DET_STS) { + status = false; + DBG("%s: Maxim charger not found\n", __func__); + utmi_phy_set_dp_dm_pull_up_down(phy, org_flags); + } else { + status = true; + DBG("%s: Maxim Charger detected\n", __func__); + } + + disable_charger_detection(base); + return status; +} + static bool utmi_phy_qc2_charger_detect(struct tegra_usb_phy *phy, int max_voltage) { @@ -2474,6 +2515,7 @@ static struct tegra_usb_phy_ops utmi_phy_ops = { .qc2_charger_detect = utmi_phy_qc2_charger_detect, .cdp_charger_detect = cdp_charger_detection, .nv_charger_detect = utmi_phy_nv_charger_detect, + .maxim_charger_14675 = maxim_charger_detection, .apple_charger_1000ma_detect = utmi_phy_apple_charger_1000ma_detect, .apple_charger_2000ma_detect = utmi_phy_apple_charger_2000ma_detect, .apple_charger_500ma_detect = utmi_phy_apple_charger_500ma_detect, diff --git a/drivers/usb/phy/tegra_usb_phy.h b/drivers/usb/phy/tegra_usb_phy.h index 213c24e19617..2f74e48aab74 100644 --- a/drivers/usb/phy/tegra_usb_phy.h +++ b/drivers/usb/phy/tegra_usb_phy.h @@ -69,6 +69,7 @@ struct tegra_usb_phy_ops { bool (*charger_detect)(struct tegra_usb_phy *phy); bool (*cdp_charger_detect)(struct tegra_usb_phy *phy); bool (*qc2_charger_detect)(struct tegra_usb_phy *phy, int max_voltage); + bool (*maxim_charger_14675)(struct tegra_usb_phy *phy); bool (*nv_charger_detect)(struct tegra_usb_phy *phy); bool (*apple_charger_1000ma_detect)(struct tegra_usb_phy *phy); bool (*apple_charger_2000ma_detect)(struct tegra_usb_phy *phy); -- cgit v1.2.3