Skip to contentSkip to conversation

2/12 Multiadapter/multibus I2C, common part 2

PATCH New ksi at koi8.net 2 participants 7 messages Feb 12, 2009 – Feb 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2/12 Multiadapter/multibus I2C, common part 2

---

cpu/mpc8xx/video.c +4 -0
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c
@@ -809,7 +809,11 @@ static void video_encoder_init (void)
 
 	/* Initialize the I2C */
 	debug ("[VIDEO ENCODER] Initializing I2C bus...\n");
+#ifdef CONFIG_NEW_I2C
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 
 #ifdef CONFIG_FADS
 	/* Reset ADV7176 chip */
lib_arm/board.c +12 -3
diff -purN u-boot-i2c.orig/lib_arm/board.c u-boot-i2c/lib_arm/board.c
@@ -81,7 +81,8 @@ extern void rtl8019_get_enetaddr (uchar 
 #endif
 
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+    defined(CONFIG_SOFT_I2C) || \
+    defined(CONFIG_SYS_I2C_ADAPTERS)
 #include <i2c.h>
 #endif
 
@@ -211,11 +212,15 @@ static void display_flash_config (ulong 
 }
 #endif /* CONFIG_SYS_NO_FLASH */
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || defined(CONFIG_SYS_I2C_ADAPTERS)
 static int init_func_i2c (void)
 {
 	puts ("I2C:   ");
+#ifdef CONFIG_NEW_I2C
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	puts ("ready\n");
 	return (0);
 }
@@ -272,7 +277,7 @@ init_fnc_t *init_sequence[] = {
 #if defined(CONFIG_DISPLAY_BOARDINFO)
 	checkboard,		/* display board info */
 #endif
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || defined(CONFIG_SYS_I2C_ADAPTERS)
 	init_func_i2c,
 #endif
 	dram_init,		/* configure available RAM banks */
@@ -368,6 +373,10 @@ void start_armboot (void)
 	/* initialize environment */
 	env_relocate ();
 
+#if defined(CONFIG_NEW_I2C) && defined(CONFIG_SYS_I2C_ADAPTERS)
+	i2c_reloc_fixup();
+#endif
+
 #ifdef CONFIG_VFD
 	/* must do this after the framebuffer is allocated */
 	drv_vfd_init();
lib_blackfin/board.c +8 -0
diff -purN u-boot-i2c.orig/lib_blackfin/board.c u-boot-i2c/lib_blackfin/board.c
@@ -31,6 +31,10 @@
 int post_flag;
 #endif
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+#include <i2c.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 const char version_string[] = U_BOOT_VERSION " ("U_BOOT_DATE" - "U_BOOT_TIME")";
@@ -338,6 +342,10 @@ void board_init_r(gd_t * id, ulong dest_
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+	i2c_reloc_fixup();
+#endif
+
 #ifdef CONFIG_CMD_NET
 	/* board MAC address */
 	s = getenv("ethaddr");
lib_m68k/board.c +13 -3
diff -purN u-boot-i2c.orig/lib_m68k/board.c u-boot-i2c/lib_m68k/board.c
@@ -55,7 +55,8 @@
 #include <version.h>
 
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+    defined(CONFIG_SOFT_I2C) || \
+    defined(CONFIG_SYS_I2C_ADAPTERS)
 #include <i2c.h>
 #endif
 
@@ -191,11 +192,15 @@ static int init_func_ram (void)
 
 /***********************************************************************/
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || defined(CONFIG_SYS_I2C_ADAPTERS)
 static int init_func_i2c (void)
 {
 	puts ("I2C:   ");
+#ifdef CONFIG_NEW_I2C
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	puts ("ready\n");
 	return (0);
 }
@@ -227,7 +232,7 @@ init_fnc_t *init_sequence[] = {
 	display_options,
 	checkcpu,
 	checkboard,
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || defined(CONFIG_SYS_I2C_ADAPTERS)
 	init_func_i2c,
 #endif
 #if defined(CONFIG_HARD_SPI)
@@ -577,6 +582,11 @@ void board_init_r (gd_t *id, ulong dest_
 	/* relocate environment function pointers etc. */
 	env_relocate ();
 
+#if defined(CONFIG_NEW_I2C) && defined(CONFIG_SYS_I2C_ADAPTERS)
+	/* Adjust I2C subsystem pointers after relocation */
+	i2c_reloc_fixup();
+#endif
+
 	/*
 	 * Fill in missing fields of bd_info.
 	 * We do this here, where we have "normal" access to the
lib_mips/board.c +8 -0
diff -purN u-boot-i2c.orig/lib_mips/board.c u-boot-i2c/lib_mips/board.c
@@ -33,6 +33,10 @@
 #include <onenand_uboot.h>
 #include <spi.h>
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+#include <i2c.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #if ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
@@ -401,6 +405,10 @@ void board_init_r (gd_t *id, ulong dest_
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+	i2c_reloc_fixup();
+#endif
+
 	/* board MAC address */
 	s = getenv ("ethaddr");
 	for (i = 0; i < 6; ++i) {
lib_ppc/board.c +13 -3
diff -purN u-boot-i2c.orig/lib_ppc/board.c u-boot-i2c/lib_ppc/board.c
@@ -88,7 +88,8 @@ extern void sc3_read_eeprom(void);
 void doc_init (void);
 #endif
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+    defined(CONFIG_SOFT_I2C) || \
+    defined(CONFIG_SYS_I2C_ADAPTERS)
 #include <i2c.h>
 #endif
 #include <spi.h>
@@ -231,11 +232,15 @@ static int init_func_ram (void)
 
 /***********************************************************************/
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || defined(CONFIG_SYS_I2C_ADAPTERS)
 static int init_func_i2c (void)
 {
 	puts ("I2C:   ");
+#ifdef CONFIG_NEW_I2C
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	puts ("ready\n");
 	return (0);
 }
@@ -330,7 +335,7 @@ init_fnc_t *init_sequence[] = {
 	misc_init_f,
 #endif
 	INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || defined(CONFIG_SYS_I2C_ADAPTERS)
 	init_func_i2c,
 #endif
 #if defined(CONFIG_HARD_SPI)
@@ -847,6 +852,11 @@ void board_init_r (gd_t *id, ulong dest_
 	 * the environment is in EEPROM.
 	 */
 
+#if defined(CONFIG_NEW_I2C) && defined(CONFIG_SYS_I2C_ADAPTERS)
+	/* Adjust I2C subsystem pointers after relocation */
+	i2c_reloc_fixup();
+#endif
+
 #if defined(CONFIG_SYS_EXTBDINFO)
 #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
 #if defined(CONFIG_I2CFAST)
#1 lore raw

PATCH 1/1 2/12 Multiadapter/multibus I2C, common part 2

Dear ksi at koi8.net,

In message <[email protected]> you wrote:
...

lib_arm/board.c extern void rtl8019_get_enetaddr (uchar · line 85

Quoted 10 lines

diff -purN u-boot-i2c.orig/lib_arm/board.c u-boot-i2c/lib_arm/board.c

lib_arm/board.c +2 -1
@@ -81,7 +81,8 @@ extern void rtl8019_get_enetaddr (uchar 
 #endif
 
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+    defined(CONFIG_SOFT_I2C) || \
+    defined(CONFIG_SYS_I2C_ADAPTERS)

It seems you define a set of new CONFIG_SYS_ options, but I did not see any respective updates to the README file. PLease add.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"UNIX was not designed to stop you from doing stupid things,  because
that would also stop you from doing clever things."       - Doug Gwyn
#2 lore raw

PATCH 1/1 2/12 Multiadapter/multibus I2C, common part 2

Quoted 10 lines · Wolfgang Denk

Dear ksi at koi8.net,

In message <[email protected]> you wrote:
...

Quoted 6 lines

diff -purN u-boot-i2c.orig/lib_arm/board.c u-boot-i2c/lib_arm/board.c

lib_arm/board.c +0 -0
@@ -81,7 +81,8 @@ extern void rtl8019_get_enetaddr (uchar 
 #endif
 
Quoted 7 lines

lib_arm/board.c extern void rtl8019_get_enetaddr (uchar · line 85

Quoted 4 lines
lib_arm/board.c +2 -1
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+    defined(CONFIG_SOFT_I2C) || \
+    defined(CONFIG_SYS_I2C_ADAPTERS)

It seems you define a set of new CONFIG_SYS_ options, but I did not see any respective updates to the README file. PLease add.

I will definitely make a new README file. But it takes time and not everything can be done at once. This thing is big and I'm not gonna spend all my time making huge patches that are not going to make it in the main tree. Let's eat an elephant in chunks. When the core is accepted I can make the rest. It is just waste of time otherwise.

---
******************************************************************
* KSI at home KOI8 Net < > The impossible we do immediately. *
* Las Vegas NV, USA < > Miracles require 24-hour notice. *
******************************************************************

#3 lore raw

PATCH 1/1 2/12 Multiadapter/multibus I2C, common part 2

In reply to ksi at koi8.net

Dear ksi at koi8.net,

cpu/mpc8xx/video.c static void video_encoder_init (void) · line 813

Quoted 11 lines · In message <[email protected]> you wrote:

---
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c

cpu/mpc8xx/video.c +2 -0
@@ -809,7 +809,11 @@ static void video_encoder_init (void)
 
 	/* Initialize the I2C */
 	debug ("[VIDEO ENCODER] Initializing I2C bus...\n");
+#ifdef CONFIG_NEW_I2C
+	i2c_init_all();

As mentioned before, I think this is a design problem.

You must not gloablly initialize all I2C busses / adapters.

You are only permitted to initialize those devices that are actually needed by U-Boot itself to perform certain operations, and you are supposed to deactivate these after use.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
How can you tell when sour cream goes bad?
#4 lore raw

PATCH 1/1 2/12 Multiadapter/multibus I2C, common part 2

Quoted 17 lines · Wolfgang Denk

Dear ksi at koi8.net,

cpu/mpc8xx/video.c static void video_encoder_init (void) · line 813

Quoted 11 lines · In message <[email protected]> you wrote:

---
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c

cpu/mpc8xx/video.c +2 -0
@@ -809,7 +809,11 @@ static void video_encoder_init (void)
 
 	/* Initialize the I2C */
 	debug ("[VIDEO ENCODER] Initializing I2C bus...\n");
+#ifdef CONFIG_NEW_I2C
+	i2c_init_all();

As mentioned before, I think this is a design problem.

Quoted 5 lines

You must not gloablly initialize all I2C busses / adapters.

You are only permitted to initialize those devices that are actually needed by U-Boot itself to perform certain operations, and you are supposed to deactivate these after use.

What is wrong with activating ALL i2c adapters? Is there any viable reason for this?

Then, please point me to a single board that deactivates an I2C adapter. And please tell me what function one can use to do that. I haven't seen anything like i2c_deinit() or i2c_disable().

---
******************************************************************
* KSI at home KOI8 Net < > The impossible we do immediately. *
* Las Vegas NV, USA < > Miracles require 24-hour notice. *
******************************************************************

#5 lore raw

PATCH 1/1 2/12 Multiadapter/multibus I2C, common part 2

In reply to ksi at koi8.net

Dear ksi at koi8.net,

cpu/mpc8xx/video.c

Quoted 5 lines · In message <[email protected]> you wrote:

---
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c

cpu/mpc8xx/video.c +0 -0

Looking close at this "common part 2" patch I think your patches are not split orthogonally - to me it seems as if "common part 1" and "common part 2" cannot be separated without causing bisect problems.

Please fix - and check the rmaining patches for other, similar issues.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Niklaus Wirth has lamented that, whereas Europeans pronounce his name
correctly (Ni-klows Virt), Americans invariably mangle it into (Nick-
les Worth). Which is to say that Europeans  call  him  by  name,  but
Americans call him by value.
#6 lore raw

PATCH 1/1 2/12 Multiadapter/multibus I2C, common part 2

Quoted 13 lines · Wolfgang Denk

Dear ksi at koi8.net,

cpu/mpc8xx/video.c

Quoted 5 lines · In message <[email protected]> you wrote:

---
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c

cpu/mpc8xx/video.c +0 -0

Looking close at this "common part 2" patch I think your patches are not split orthogonally - to me it seems as if "common part 1" and "common part 2" cannot be separated without causing bisect problems.

Quoted 1 line

Please fix - and check the rmaining patches for other, similar issues.

I don't fully understand what is this but I will try to fix it when posting a next version.

---
******************************************************************
* KSI at home KOI8 Net < > The impossible we do immediately. *
* Las Vegas NV, USA < > Miracles require 24-hour notice. *
******************************************************************