EHCI: HSIC: Pass interrupt threshold value as platform data

Interrupt threshold value is the maximum rate at which HSIC
controller will issue interrupts to processor. Increasing
this value results in fewer interrupts which may save power
as processor has to handle fewer interrupts. Side effect of
increasing this value is higher data latency. For fusion3,
set the ITC(interrupt threshold control) to 5 and default
for other targets. Also, allow ehci stack to set ITC value
per controller basis.

CRs-Fixed: 374661
Change-Id: I0e6bc210679ef211c2850ffbe1dfc80da2f65bf0
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-8064.c b/arch/arm/mach-msm/board-8064.c
index ab9004f..0e05407 100644
--- a/arch/arm/mach-msm/board-8064.c
+++ b/arch/arm/mach-msm/board-8064.c
@@ -2950,6 +2950,7 @@
 			ARRAY_SIZE(common_not_mpq_devices));
 	enable_ddr3_regulator();
 	if (machine_is_apq8064_mtp()) {
+		msm_hsic_pdata.log2_irq_thresh = 5,
 		apq8064_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
 		device_initialize(&apq8064_device_hsic_host.dev);
 	}
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 7309438..8d967cd 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -691,8 +691,7 @@
 	hw->hw_alt_next = QTD_NEXT(ehci, ehci->async->dummy->qtd_dma);
 
 	/* clear interrupt enables, set irq latency */
-	if (ehci->max_log2_irq_thresh)
-		log2_irq_thresh = ehci->max_log2_irq_thresh;
+	log2_irq_thresh = ehci->log2_irq_thresh;
 
 	if (log2_irq_thresh < 0 || log2_irq_thresh > 6)
 		log2_irq_thresh = 0;
diff --git a/drivers/usb/host/ehci-msm-hsic.c b/drivers/usb/host/ehci-msm-hsic.c
index 73389ee..3273d56 100644
--- a/drivers/usb/host/ehci-msm-hsic.c
+++ b/drivers/usb/host/ehci-msm-hsic.c
@@ -1519,13 +1519,15 @@
 
 	mehci = hcd_to_hsic(hcd);
 	mehci->dev = &pdev->dev;
+	pdata = mehci->dev->platform_data;
 
 	mehci->ehci.susp_sof_bug = 1;
 	mehci->ehci.reset_sof_bug = 1;
 
 	mehci->ehci.resume_sof_bug = 1;
 
-	mehci->ehci.max_log2_irq_thresh = 6;
+	if (pdata)
+		mehci->ehci.log2_irq_thresh = pdata->log2_irq_thresh;
 
 	res = platform_get_resource_byname(pdev,
 			IORESOURCE_IRQ,
@@ -1611,7 +1613,6 @@
 		dev_dbg(&pdev->dev, "mode debugfs file is"
 			"not available\n");
 
-	pdata = mehci->dev->platform_data;
 	if (pdata && pdata->bus_scale_table) {
 		mehci->bus_perf_client =
 		    msm_bus_scale_register_client(pdata->bus_scale_table);
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index a0f995c..f8b884a 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -135,7 +135,7 @@
 	ktime_t			last_periodic_enable;
 	u32			command;
 
-	unsigned		max_log2_irq_thresh;
+	unsigned		log2_irq_thresh;
 
 	/* SILICON QUIRKS */
 	unsigned		no_selective_suspend:1;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 54e7e97..21cb5d6 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -379,6 +379,7 @@
 	unsigned strobe;
 	unsigned data;
 	struct msm_bus_scale_pdata *bus_scale_table;
+	unsigned log2_irq_thresh;
 };
 
 struct msm_usb_host_platform_data {