Skip to contentSkip to conversation

i2c: designware: Convert driver to multibus/multiadapter framework

PATCH New Stefan Roese 3 participants 4 messages Oct 23, 2014 – Oct 24, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: designware: Convert driver to multibus/multiadapter framework

In preparation for the SoCFPGA support of the designware I2C driver, convert this driver to the common CONFIG_SYS_I2C framework.

This patch converts all users of this driver, this is:

- ST spearxxx boards
- AXS101 (ARC700 platform)

I couldn't test this patch on those boards. Only compile tested for all spear boards. And tested on SoCFPGA.

Cc Heiko Schocher <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Vipin Kumar <[email protected]>
Cc Alexey Brodkin <[email protected]>
---
 arch/arm/cpu/arm926ejs/spear/cpu.c |   2 +-
 drivers/i2c/Makefile               |   2 +-
 drivers/i2c/designware_i2c.c       | 294 ++++++++++++++++---------------------
 include/configs/axs101.h           |   9 +-
 include/configs/spear-common.h     |   4 +-
 include/configs/x600.h             |   4 +-
 6 files changed, 142 insertions(+), 173 deletions(-)
arch/arm/cpu/arm926ejs/spear/cpu.c +1 -1
index 3757ffb..697e094 100644
@@ -38,7 +38,7 @@ int arch_cpu_init(void)
 #if defined(CONFIG_DW_UDC)
 	periph1_clken |= MISC_USBDENB;
 #endif
-#if defined(CONFIG_DW_I2C)
+#if defined(CONFIG_SYS_I2C_DW)
 	periph1_clken |= MISC_I2CENB;
 #endif
 #if defined(CONFIG_ST_SMI)
drivers/i2c/Makefile +1 -1
index 416ea4f..b38327c 100644
@@ -6,7 +6,6 @@
 #
 
 obj-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
-obj-$(CONFIG_DW_I2C) += designware_i2c.o
 obj-$(CONFIG_I2C_MV) += mv_i2c.o
 obj-$(CONFIG_I2C_MXS) += mxs_i2c.o
 obj-$(CONFIG_PCA9564_I2C) += pca9564_i2c.o
@@ -15,6 +14,7 @@ obj-$(CONFIG_U8500_I2C) += u8500_i2c.o
 obj-$(CONFIG_SH_SH7734_I2C) += sh_sh7734_i2c.o
 obj-$(CONFIG_SYS_I2C) += i2c_core.o
 obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
+obj-$(CONFIG_SYS_I2C_DW) += designware_i2c.o
 obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
 obj-$(CONFIG_SYS_I2C_FTI2C010) += fti2c010.o
 obj-$(CONFIG_SYS_I2C_IHS) += ihs_i2c.o
drivers/i2c/designware_i2c.c +130 -164

513 lines not on this page · raw message

include/configs/axs101.h +6 -3
index 1bf8390..6e8c56c 100644
@@ -83,12 +83,15 @@
 /*
  * I2C configuration
  */
-#define CONFIG_HARD_I2C
-#define CONFIG_DW_I2C
-#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_DW
 #define CONFIG_I2C_ENV_EEPROM_BUS	2
 #define CONFIG_SYS_I2C_SPEED		100000
+#define CONFIG_SYS_I2C_SPEED1		100000
+#define CONFIG_SYS_I2C_SPEED2		100000
 #define CONFIG_SYS_I2C_SLAVE		0
+#define CONFIG_SYS_I2C_SLAVE1		0
+#define CONFIG_SYS_I2C_SLAVE2		0
 #define CONFIG_SYS_I2C_BASE		0xE001D000
 #define CONFIG_SYS_I2C_BASE1		0xE001E000
 #define CONFIG_SYS_I2C_BASE2		0xE001F000
include/configs/spear-common.h +2 -2
index c0eba37..a11f4ed 100644
@@ -37,8 +37,8 @@
 #define CONFIG_EXTRA_ENV_USBTTY			"usbtty=cdc_acm\0"
 
 /* I2C driver configuration */
-#define CONFIG_HARD_I2C
-#define CONFIG_DW_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_DW
 #if defined(CONFIG_SPEAR600)
 #define CONFIG_SYS_I2C_BASE			0xD0200000
 #elif defined(CONFIG_SPEAR300)
include/configs/x600.h +2 -2
index 71373e9..d39a0f8 100644
@@ -83,8 +83,8 @@
 #define CONFIG_SPEAR_GPIO
 
 /* I2C config options */
-#define CONFIG_HARD_I2C
-#define CONFIG_DW_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_DW
 #define CONFIG_SYS_I2C_BASE			0xD0200000
 #define CONFIG_SYS_I2C_SPEED			400000
 #define CONFIG_SYS_I2C_SLAVE			0x02
Signature · 1 line
2.1.2
#1 lore raw

PATCH 1/1 i2c: designware: Convert driver to multibus/multiadapter framework

Quoted 8 lines · Stefan Roese

In preparation for the SoCFPGA support of the designware I2C driver, convert this driver to the common CONFIG_SYS_I2C framework.

This patch converts all users of this driver, this is:

- ST spearxxx boards
- AXS101 (ARC700 platform)

Quoted 8 lines

I couldn't test this patch on those boards. Only compile tested for all spear boards. And tested on SoCFPGA.

Cc Heiko Schocher <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Vipin Kumar <[email protected]>
Cc Alexey Brodkin <[email protected]>

I don't see any obvious problems:

Best regards,
Marek Vasut

#2 lore raw

PATCH 1/1 i2c: designware: Convert driver to multibus/multiadapter framework

In reply to Stefan Roese

Hi Stefan,

Quoted 25 lines · Stefan Roese

In preparation for the SoCFPGA support of the designware I2C driver, convert this driver to the common CONFIG_SYS_I2C framework.

This patch converts all users of this driver, this is:

- ST spearxxx boards
- AXS101 (ARC700 platform)

I couldn't test this patch on those boards. Only compile tested for all spear boards. And tested on SoCFPGA.

Cc Heiko Schocher <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Vipin Kumar <[email protected]>
Cc Alexey Brodkin <[email protected]>
---
 arch/arm/cpu/arm926ejs/spear/cpu.c |   2 +-
 drivers/i2c/Makefile               |   2 +-
 drivers/i2c/designware_i2c.c       | 294 ++++++++++++++++---------------------
 include/configs/axs101.h           |   9 +-
 include/configs/spear-common.h     |   4 +-
 include/configs/x600.h             |   4 +-
 6 files changed, 142 insertions(+), 173 deletions(-)

drivers/i2c/designware_i2c.c line 33

Quoted 5 lines
drivers/i2c/designware_i2c.c +3 -2
-static struct i2c_regs *i2c_regs_p =
-    (struct i2c_regs *)CONFIG_SYS_I2C_BASE;
+	default:
+		printf("wrong hwadapnr: %d\n", adap->hwadapnr);
+	}

Well, I'd say "wrong hwadapnr" is not very informative. Maybe something more human-friendly?

Anyway this is just a nitpicking.

I tried updated driver on AXS101 and it builds and works for me fine.

So please add:

-Alexey

#3 lore raw

PATCH 1/1 i2c: designware: Convert driver to multibus/multiadapter framework

Hi Alexey,

Quoted 26 lines · Alexey Brodkin
Quoted 24 lines · Stefan Roese

In preparation for the SoCFPGA support of the designware I2C driver, convert this driver to the common CONFIG_SYS_I2C framework.

This patch converts all users of this driver, this is:

- ST spearxxx boards
- AXS101 (ARC700 platform)

I couldn't test this patch on those boards. Only compile tested for all spear boards. And tested on SoCFPGA.

Cc Heiko Schocher <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Vipin Kumar <[email protected]>
Cc Alexey Brodkin <[email protected]>
---
  arch/arm/cpu/arm926ejs/spear/cpu.c |   2 +-
  drivers/i2c/Makefile               |   2 +-
  drivers/i2c/designware_i2c.c       | 294 ++++++++++++++++---------------------
  include/configs/axs101.h           |   9 +-
  include/configs/spear-common.h     |   4 +-
  include/configs/x600.h             |   4 +-
  6 files changed, 142 insertions(+), 173 deletions(-)
Quoted 8 lines

drivers/i2c/designware_i2c.c line 33

Quoted 5 lines
drivers/i2c/designware_i2c.c +3 -2
-static struct i2c_regs *i2c_regs_p =
-    (struct i2c_regs *)CONFIG_SYS_I2C_BASE;
+	default:
+		printf("wrong hwadapnr: %d\n", adap->hwadapnr);
+	}

Well, I'd say "wrong hwadapnr" is not very informative. Maybe something more human-friendly?

Yes, now that you mention it, this really is ugly. Copy-n-pasted from some other driver. I'll change it in the next version.

Thanks,
Stefan