Skip to contentSkip to conversation

arm: socfpga: Add I2C support to SoCFPGA

PATCH New Stefan Roese 3 participants 5 messages Oct 20, 2014 – Oct 23, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: socfpga: Add I2C support to SoCFPGA

This patch adds I2C support for the SoCFPGA. Using the designware I2C controller driver. It supports all 4 I2C busses on the SoCFPGA.

Cc Marek Vasut <[email protected]>
Cc Vince Briders <[email protected]>
Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
---
 include/configs/socfpga_common.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
include/configs/socfpga_common.h +22 -0
index 49504dc..ba1e072 100644
@@ -157,6 +157,28 @@
 #define CONFIG_BAUDRATE			115200
 
 /*
+ * I2C support
+ */
+#define CONFIG_HARD_I2C
+#define CONFIG_DW_I2C
+#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C_BUS_MAX		4
+#define CONFIG_SYS_I2C_BASE		SOCFPGA_I2C0_ADDRESS
+#define CONFIG_SYS_I2C_BASE1		SOCFPGA_I2C1_ADDRESS
+#define CONFIG_SYS_I2C_BASE2		SOCFPGA_I2C2_ADDRESS
+#define CONFIG_SYS_I2C_BASE3		SOCFPGA_I2C3_ADDRESS
+/* using standard mode which the speed up to 100Kb/s */
+#define CONFIG_SYS_I2C_SPEED		100000
+/* address of device when used as slave */
+#define CONFIG_SYS_I2C_SLAVE		0x02
+#ifndef __ASSEMBLY__
+/* clock supplied to I2C controller in unit of MHz */
+unsigned int cm_get_l4_sp_clk_hz(void);
+#define IC_CLK				(cm_get_l4_sp_clk_hz() / 1000000)
+#endif
+#define CONFIG_CMD_I2C
+
+/*
  * U-Boot environment
  */
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
Signature · 1 line
2.1.2
#1 lore raw

PATCH 1/1 arm: socfpga: Add I2C support to SoCFPGA

On Monday, October 20, 2014 at 08:45:48 AM, Stefan Roese wrote:

Hi all,

Quoted 8 lines

This patch adds I2C support for the SoCFPGA. Using the designware I2C controller driver. It supports all 4 I2C busses on the SoCFPGA.

Cc Marek Vasut <[email protected]>
Cc Vince Briders <[email protected]>
Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>

+CC Heiko, the I2C custodian.

Quoted 9 lines
---
 include/configs/socfpga_common.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
(quoted diff) +0 -0

b/include/configs/socfpga_common.h index 49504dc..ba1e072 100644

include/configs/socfpga_common.h line 164

Quoted 8 lines
include/configs/socfpga_common.h +5 -0
@@ -157,6 +157,28 @@
 #define CONFIG_BAUDRATE			115200
 
 /*
+ * I2C support
+ */
+#define CONFIG_HARD_I2C
+#define CONFIG_DW_I2C
+#define CONFIG_I2C_MULTI_BUS

I presume this should be converted to CONFIG_SYS_I2C framework instead of using this I2C multibus horror, no?

include/configs/socfpga_common.h line 176

Quoted 12 lines
include/configs/socfpga_common.h +12 -0
+#define CONFIG_SYS_I2C_BUS_MAX		4
+#define CONFIG_SYS_I2C_BASE		SOCFPGA_I2C0_ADDRESS
+#define CONFIG_SYS_I2C_BASE1		SOCFPGA_I2C1_ADDRESS
+#define CONFIG_SYS_I2C_BASE2		SOCFPGA_I2C2_ADDRESS
+#define CONFIG_SYS_I2C_BASE3		SOCFPGA_I2C3_ADDRESS
+/* using standard mode which the speed up to 100Kb/s */
+#define CONFIG_SYS_I2C_SPEED		100000
+/* address of device when used as slave */
+#define CONFIG_SYS_I2C_SLAVE		0x02
+#ifndef __ASSEMBLY__
+/* clock supplied to I2C controller in unit of MHz */
+unsigned int cm_get_l4_sp_clk_hz(void);

Include clock_manager.h instead maybe ?

include/configs/socfpga_common.h line 184

Quoted 8 lines
include/configs/socfpga_common.h +5 -0
+#define IC_CLK				(cm_get_l4_sp_clk_hz() / 1000000)
+#endif
+#define CONFIG_CMD_I2C
+
+/*
  * U-Boot environment
  */
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV

Best regards,
Marek Vasut

#2 lore raw

PATCH 1/1 arm: socfpga: Add I2C support to SoCFPGA

Hello Marek,

Am 20.10.2014 16:46, schrieb Marek Vasut:

Quoted 7 lines · Stefan Roese

Hi all,

Quoted 3 lines

This patch adds I2C support for the SoCFPGA. Using the designware I2C controller driver. It supports all 4 I2C busses on the SoCFPGA.

Quoted 7 lines
Quoted 5 lines
Cc Marek Vasut<[email protected]>
Cc Vince Briders<[email protected]>
Cc Chin Liang See<[email protected]>
Cc Dinh Nguyen<[email protected]>

+CC Heiko, the I2C custodian.

Thanks! As I am just not really find time to work, I do not look into the u-boot ML ...

Quoted 11 lines
Quoted 11 lines
---
  include/configs/socfpga_common.h | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)
(quoted diff) +0 -0

b/include/configs/socfpga_common.h index 49504dc..ba1e072 100644

include/configs/socfpga_common.h +0 -0
@@ -157,6 +157,28 @@
  #define CONFIG_BAUDRATE			115200
 
Quoted 4 lines

include/configs/socfpga_common.h line 162

Quoted 4 lines
include/configs/socfpga_common.h +3 -0
  /*
+ * I2C support
+ */
+#define CONFIG_HARD_I2C

No ... do not add this define please.

Quoted 5 lines

include/configs/socfpga_common.h line 164

Quoted 2 lines
include/configs/socfpga_common.h +2 -0
+#define CONFIG_DW_I2C
+#define CONFIG_I2C_MULTI_BUS

I presume this should be converted to CONFIG_SYS_I2C framework instead of using this I2C multibus horror, no?

... Yes, please!

Which i2c driver does socfpga use? If it is the "drivers/i2c/designware_i2c.c" driver, please convert it to the "CONFIG_SYS_I2C" framework.

You may also take a look into Simons RFC patches, which introduce DM model:
http://lists.denx.de/pipermail/u-boot/2014-October/191497.html

bye,
Heiko

Quoted 27 lines

include/configs/socfpga_common.h line 176

Quoted 12 lines
include/configs/socfpga_common.h +12 -0
+#define CONFIG_SYS_I2C_BUS_MAX		4
+#define CONFIG_SYS_I2C_BASE		SOCFPGA_I2C0_ADDRESS
+#define CONFIG_SYS_I2C_BASE1		SOCFPGA_I2C1_ADDRESS
+#define CONFIG_SYS_I2C_BASE2		SOCFPGA_I2C2_ADDRESS
+#define CONFIG_SYS_I2C_BASE3		SOCFPGA_I2C3_ADDRESS
+/* using standard mode which the speed up to 100Kb/s */
+#define CONFIG_SYS_I2C_SPEED		100000
+/* address of device when used as slave */
+#define CONFIG_SYS_I2C_SLAVE		0x02
+#ifndef __ASSEMBLY__
+/* clock supplied to I2C controller in unit of MHz */
+unsigned int cm_get_l4_sp_clk_hz(void);

Include clock_manager.h instead maybe ?

include/configs/socfpga_common.h line 184

Quoted 8 lines
include/configs/socfpga_common.h +5 -0
+#define IC_CLK				(cm_get_l4_sp_clk_hz() / 1000000)
+#endif
+#define CONFIG_CMD_I2C
+
+/*
   * U-Boot environment
   */
  #define CONFIG_SYS_CONSOLE_IS_IN_ENV

Best regards,
Marek Vasut

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#3 lore raw

PATCH 1/1 arm: socfpga: Add I2C support to SoCFPGA

Hi Marek, Hi Heiko!

Quoted 14 lines · Heiko Schocher
Quoted 4 lines
Quoted 4 lines

/*
+ * I2C support
+ */
+#define CONFIG_HARD_I2C

No ... do not add this define please.

Quoted 6 lines

include/configs/socfpga_common.h line 164

Quoted 2 lines
include/configs/socfpga_common.h +2 -0
+#define CONFIG_DW_I2C
+#define CONFIG_I2C_MULTI_BUS

I presume this should be converted to CONFIG_SYS_I2C framework instead of using
this I2C multibus horror, no?

Quoted 5 lines

... Yes, please!

Which i2c driver does socfpga use? If it is the "drivers/i2c/designware_i2c.c"
driver, please convert it to the "CONFIG_SYS_I2C" framework.

Yes. Its the designware driver.

I wanted to make this I2C support for SoCFPGA least intrusive. But I see your point. Moving this driver to the new I2C framework makes sense.

Quoted 3 lines

You may also take a look into Simons RFC patches, which introduce DM model:
http://lists.denx.de/pipermail/u-boot/2014-October/191497.html

This seems a bit too early for me.

I'll try to find some time to move to the "CONFIG_SYS_I2C" framework...

Thanks,
Stefan

#4 lore raw

PATCH 1/1 arm: socfpga: Add I2C support to SoCFPGA

Quoted 1 line · Stefan Roese

Hi Marek, Hi Heiko!

Hi all!

Quoted 27 lines · Heiko Schocher
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines

/*

+ * I2C support
+ */
+#define CONFIG_HARD_I2C

No ... do not add this define please.

Quoted 6 lines

include/configs/socfpga_common.h line 164

Quoted 2 lines
include/configs/socfpga_common.h +2 -0
+#define CONFIG_DW_I2C
+#define CONFIG_I2C_MULTI_BUS

I presume this should be converted to CONFIG_SYS_I2C framework instead of using
this I2C multibus horror, no?

Quoted 5 lines

... Yes, please!

Which i2c driver does socfpga use? If it is the "drivers/i2c/designware_i2c.c"
driver, please convert it to the "CONFIG_SYS_I2C" framework.

Yes. Its the designware driver.

I wanted to make this I2C support for SoCFPGA least intrusive. But I see your point. Moving this driver to the new I2C framework makes sense.

Quoted 7 lines
Quoted 3 lines

You may also take a look into Simons RFC patches, which introduce DM model:
http://lists.denx.de/pipermail/u-boot/2014-October/191497.html

This seems a bit too early for me.

I'll try to find some time to move to the "CONFIG_SYS_I2C" framework...

I think this makes sense indeed and helps a lot. Thank you very much!

Best regards,
Marek Vasut