[U-Boot] [PATCH] 2/12 Multiadapter/multibus I2C, common part 2

Signed-off-by: Sergey Kubushyn ksi@koi8.net --- diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c --- u-boot-i2c.orig/cpu/mpc8xx/video.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/cpu/mpc8xx/video.c 2009-02-12 10:46:00.000000000 -0800 @@ -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 */ diff -purN u-boot-i2c.orig/lib_arm/board.c u-boot-i2c/lib_arm/board.c --- u-boot-i2c.orig/lib_arm/board.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/lib_arm/board.c 2009-02-12 10:46:00.000000000 -0800 @@ -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(); diff -purN u-boot-i2c.orig/lib_blackfin/board.c u-boot-i2c/lib_blackfin/board.c --- u-boot-i2c.orig/lib_blackfin/board.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/lib_blackfin/board.c 2009-02-12 10:46:00.000000000 -0800 @@ -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"); diff -purN u-boot-i2c.orig/lib_m68k/board.c u-boot-i2c/lib_m68k/board.c --- u-boot-i2c.orig/lib_m68k/board.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/lib_m68k/board.c 2009-02-12 10:46:00.000000000 -0800 @@ -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 diff -purN u-boot-i2c.orig/lib_mips/board.c u-boot-i2c/lib_mips/board.c --- u-boot-i2c.orig/lib_mips/board.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/lib_mips/board.c 2009-02-12 10:46:00.000000000 -0800 @@ -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) { diff -purN u-boot-i2c.orig/lib_ppc/board.c u-boot-i2c/lib_ppc/board.c --- u-boot-i2c.orig/lib_ppc/board.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/lib_ppc/board.c 2009-02-12 10:46:00.000000000 -0800 @@ -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)

Dear ksi@koi8.net,
In message Pine.LNX.4.64ksi.0902121412060.21067@home-gw.koi8.net you wrote: ...
diff -purN u-boot-i2c.orig/lib_arm/board.c u-boot-i2c/lib_arm/board.c --- u-boot-i2c.orig/lib_arm/board.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/lib_arm/board.c 2009-02-12 10:46:00.000000000 -0800 @@ -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

On Mon, 16 Feb 2009, Wolfgang Denk wrote:
Dear ksi@koi8.net,
In message Pine.LNX.4.64ksi.0902121412060.21067@home-gw.koi8.net you wrote: ...
diff -purN u-boot-i2c.orig/lib_arm/board.c u-boot-i2c/lib_arm/board.c --- u-boot-i2c.orig/lib_arm/board.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/lib_arm/board.c 2009-02-12 10:46:00.000000000 -0800 @@ -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.
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@home KOI8 Net < > The impossible we do immediately. * * Las Vegas NV, USA < > Miracles require 24-hour notice. * ******************************************************************

Dear ksi@koi8.net,
In message Pine.LNX.4.64ksi.0902121412060.21067@home-gw.koi8.net you wrote:
Signed-off-by: Sergey Kubushyn ksi@koi8.net
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c --- u-boot-i2c.orig/cpu/mpc8xx/video.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/cpu/mpc8xx/video.c 2009-02-12 10:46:00.000000000 -0800 @@ -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

On Mon, 16 Feb 2009, Wolfgang Denk wrote:
Dear ksi@koi8.net,
In message Pine.LNX.4.64ksi.0902121412060.21067@home-gw.koi8.net you wrote:
Signed-off-by: Sergey Kubushyn ksi@koi8.net
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c --- u-boot-i2c.orig/cpu/mpc8xx/video.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/cpu/mpc8xx/video.c 2009-02-12 10:46:00.000000000 -0800 @@ -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.
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@home KOI8 Net < > The impossible we do immediately. * * Las Vegas NV, USA < > Miracles require 24-hour notice. * ******************************************************************

Dear ksi@koi8.net,
In message Pine.LNX.4.64ksi.0902121412060.21067@home-gw.koi8.net you wrote:
Signed-off-by: Sergey Kubushyn ksi@koi8.net
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c --- u-boot-i2c.orig/cpu/mpc8xx/video.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/cpu/mpc8xx/video.c 2009-02-12 10:46:00.000000000 -0800
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

On Mon, 16 Feb 2009, Wolfgang Denk wrote:
Dear ksi@koi8.net,
In message Pine.LNX.4.64ksi.0902121412060.21067@home-gw.koi8.net you wrote:
Signed-off-by: Sergey Kubushyn ksi@koi8.net
diff -purN u-boot-i2c.orig/cpu/mpc8xx/video.c u-boot-i2c/cpu/mpc8xx/video.c --- u-boot-i2c.orig/cpu/mpc8xx/video.c 2009-02-12 10:43:41.000000000 -0800 +++ u-boot-i2c/cpu/mpc8xx/video.c 2009-02-12 10:46:00.000000000 -0800
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.
I don't fully understand what is this but I will try to fix it when posting a next version.
--- ****************************************************************** * KSI@home KOI8 Net < > The impossible we do immediately. * * Las Vegas NV, USA < > Miracles require 24-hour notice. * ******************************************************************
participants (2)
-
ksi@koi8.net
-
Wolfgang Denk