usb: gadget: HSIC wake from suspend workaround

For some MSM targets, there is an HW limitation that doesn't
allow wakeing up from USB bus suspend, when certain USB core
clocks are turned off as part of runtime suspend.
When this workaround is turned ON, the clocks that are mandatory
will not be disabled on runtime suspend.

Change-Id: Iab397c4f3b2918a5aa5eef7a60123bf7ede58d81
Signed-off-by: Amit Blay <ablay@codeaurora.org>
diff --git a/drivers/usb/gadget/ci13xxx_msm_hsic.c b/drivers/usb/gadget/ci13xxx_msm_hsic.c
index eeacceb..39d4720 100644
--- a/drivers/usb/gadget/ci13xxx_msm_hsic.c
+++ b/drivers/usb/gadget/ci13xxx_msm_hsic.c
@@ -65,6 +65,7 @@
 	struct msm_xo_voter	*xo_handle;
 	struct workqueue_struct *wq;
 	struct work_struct	suspend_w;
+	struct msm_hsic_peripheral_platform_data *pdata;
 };
 
 static int msm_hsic_init_vddcx(struct msm_hsic_per *mhsic, int init)
@@ -365,8 +366,10 @@
 	 */
 	mb();
 
-	clk_disable(mhsic->iface_clk);
-	clk_disable(mhsic->core_clk);
+	if (!mhsic->pdata->keep_core_clk_on_suspend_workaround) {
+		clk_disable(mhsic->iface_clk);
+		clk_disable(mhsic->core_clk);
+	}
 	clk_disable(mhsic->phy_clk);
 	clk_disable(mhsic->cal_clk);
 
@@ -416,8 +419,10 @@
 		dev_err(mhsic->dev, "%s failed to vote for TCXO %d\n",
 				__func__, ret);
 
-	clk_enable(mhsic->iface_clk);
-	clk_enable(mhsic->core_clk);
+	if (!mhsic->pdata->keep_core_clk_on_suspend_workaround) {
+		clk_enable(mhsic->iface_clk);
+		clk_enable(mhsic->core_clk);
+	}
 	clk_enable(mhsic->phy_clk);
 	clk_enable(mhsic->cal_clk);
 
@@ -611,9 +616,17 @@
 	struct resource *res;
 	struct msm_hsic_per *mhsic;
 	int ret = 0;
+	struct msm_hsic_peripheral_platform_data *pdata;
 
 	dev_dbg(&pdev->dev, "msm-hsic probe\n");
 
+	if (!pdev->dev.platform_data) {
+		dev_err(&pdev->dev, "No platform data given. Bailing out\n");
+		return -ENODEV;
+	} else {
+		pdata = pdev->dev.platform_data;
+	}
+
 	mhsic = kzalloc(sizeof(struct msm_hsic_per), GFP_KERNEL);
 	if (!mhsic) {
 		dev_err(&pdev->dev, "unable to allocate msm_hsic\n");
@@ -622,6 +635,7 @@
 	the_mhsic = mhsic;
 	platform_set_drvdata(pdev, mhsic);
 	mhsic->dev = &pdev->dev;
+	mhsic->pdata = pdata;
 
 	mhsic->irq = platform_get_irq(pdev, 0);
 	if (mhsic->irq < 0) {