[linux-yocto] [PATCH 6/6] i2c: designware: enable fast and standard speed mode switching

wan.ahmad.zainie.wan.mohamad at intel.com wan.ahmad.zainie.wan.mohamad at intel.com
Mon Nov 16 18:54:20 PST 2015


From: cchew14 <chiau.ee.chew at intel.com>

This patch applies the change to both platform and pci driver

For built-in driver, insert i2c-designware-pci.force_std_mode=1
for LPSS PCI Mode or i2c-designware-platform.force_std_mode=1
for LPSS ACPI Mode in kernel boot configuration.

v3:
 - Nothing was changed patch-wise. This was just merged
   to dev branch byt_3.10.61_ltsi_dev. Consider during upstream.
v2:
 - ported this patch from 3.10.31 to 3.10.61

Signed-off-by: Chew, Chiau Ee <chiau.ee.chew at intel.com>
Signed-off-by: Maurice Petallo <mauricex.r.petallo at intel.com>
Change-Id: I69c1efc074c8357e959dc3fa18d332675a417b44
Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/4985
Reviewed-by: Wan Mohamad, Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad at intel.com>
---
 drivers/i2c/busses/i2c-designware-pcidrv.c  | 12 ++++++++++++
 drivers/i2c/busses/i2c-designware-platdrv.c |  9 ++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 9dec4be..01b55e8 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -43,6 +43,10 @@
 
 #define DRIVER_NAME "i2c-designware-pci"
 
+static bool force_std_mode;
+module_param(force_std_mode, bool, 0);
+MODULE_PARM_DESC(force_std_mode, "Force standard mode (100 kHz)");
+
 enum dw_pci_ctl_id_t {
 	moorestown_0,
 	moorestown_1,
@@ -249,6 +253,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 	struct dw_i2c_dev *dev;
 	struct i2c_adapter *adap;
 	int r;
+	u32 mode;
 	struct  dw_pci_controller *controller;
 	struct dw_scl_sda_cfg *cfg;
 
@@ -287,6 +292,13 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 	dev->functionality = controller->functionality |
 				DW_DEFAULT_FUNCTIONALITY;
 
+	mode = controller->bus_cfg & (DW_IC_CON_SPEED_STD |
+				      DW_IC_CON_SPEED_FAST);
+	if (force_std_mode && !(mode & DW_IC_CON_SPEED_STD)) {
+		controller->bus_cfg &= ~mode;
+		controller->bus_cfg |= DW_IC_CON_SPEED_STD;
+	}
+
 	dev->master_cfg =  controller->bus_cfg;
 	if (controller->scl_sda_cfg) {
 		cfg = controller->scl_sda_cfg;
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 4c1b605..36bddb8 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -43,6 +43,10 @@
 #include <linux/acpi.h>
 #include "i2c-designware-core.h"
 
+static bool force_std_mode;
+module_param(force_std_mode, bool, 0);
+MODULE_PARM_DESC(force_std_mode, "Force standard mode (100 kHz)");
+
 static struct i2c_algorithm i2c_dw_algo = {
 	.master_xfer	= i2c_dw_xfer,
 	.functionality	= i2c_dw_func,
@@ -167,7 +171,10 @@ static int dw_i2c_probe(struct platform_device *pdev)
 		I2C_FUNC_SMBUS_WORD_DATA |
 		I2C_FUNC_SMBUS_I2C_BLOCK;
 	dev->master_cfg =  DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
-		DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
+		DW_IC_CON_RESTART_EN;
+
+	dev->master_cfg |= (force_std_mode ? DW_IC_CON_SPEED_STD :
+			    DW_IC_CON_SPEED_FAST);
 
 	/* Try first if we can configure the device from ACPI */
 	r = dw_i2c_acpi_configure(pdev);
-- 
1.9.1



More information about the linux-yocto mailing list