usb: msm_otg: Allow delayed LPM upon cable disconnect

This change introduces a new module parameter,
which allows to use 1 second delay before entering Low
Power Mode, after USB cable is disconnected.

This change is needed, since for some platforms, there
are external HW blocks (e.g., A2) that interact with USB
shortly after USB cable is disconnected, and require USB
clocks to be enabled.

Change-Id: Ia63839e84ec1c7ab8816ad1b035f1026acaa1e66
Signed-off-by: Amit Blay <ablay@codeaurora.org>
This commit is contained in:
Amit Blay 2012-10-29 13:13:46 +02:00 committed by Stephen Boyd
parent 213f65697f
commit 423f803f58
3 changed files with 21 additions and 1 deletions

View file

@ -762,6 +762,7 @@ static struct msm_otg_platform_data msm_otg_pdata = {
.disable_reset_on_disconnect = true,
.enable_lpm_on_dev_suspend = true,
.core_clk_always_on_workaround = true,
.delay_lpm_on_disconnect = true,
};

View file

@ -82,6 +82,11 @@ module_param(override_phy_init, charp, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(override_phy_init,
"Override HSUSB PHY Init Settings");
unsigned int lpm_disconnect_thresh = 1000;
module_param(lpm_disconnect_thresh , uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(lpm_disconnect_thresh,
"Delay before entering LPM on USB disconnect");
static DECLARE_COMPLETION(pmic_vbus_init);
static struct msm_otg *the_msm_otg;
static bool debug_aca_enabled;
@ -2449,7 +2454,12 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_notify_charger(motg, 0);
msm_otg_reset(otg->phy);
pm_runtime_put_noidle(otg->phy->dev);
pm_runtime_suspend(otg->phy->dev);
/*
* Only if autosuspend was enabled in probe, it will be
* used here. Otherwise, no delay will be used.
*/
pm_runtime_mark_last_busy(otg->phy->dev);
pm_runtime_autosuspend(otg->phy->dev);
}
break;
case OTG_STATE_B_SRP_INIT:
@ -3998,6 +4008,12 @@ static int __init msm_otg_probe(struct platform_device *pdev)
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
if (motg->pdata->delay_lpm_on_disconnect) {
pm_runtime_set_autosuspend_delay(&pdev->dev,
lpm_disconnect_thresh);
pm_runtime_use_autosuspend(&pdev->dev);
}
if (motg->pdata->bus_scale_table) {
motg->bus_perf_client =
msm_bus_scale_register_client(motg->pdata->bus_scale_table);

View file

@ -199,6 +199,8 @@ enum usb_vdd_value {
* is connected.
* @core_clk_always_on_workaround: Don't disable core_clk when
* USB enters LPM.
* @delay_lpm_on_disconnect: Use a delay before entering LPM
* upon USB cable disconnection.
* @bus_scale_table: parameters for bus bandwidth requirements
* @mhl_dev_name: MHL device name used to register with MHL driver.
*/
@ -218,6 +220,7 @@ struct msm_otg_platform_data {
bool pnoc_errata_fix;
bool enable_lpm_on_dev_suspend;
bool core_clk_always_on_workaround;
bool delay_lpm_on_disconnect;
struct msm_bus_scale_pdata *bus_scale_table;
const char *mhl_dev_name;
};