All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/3] Bring in new I2C framework
@ 2012-10-22 17:40 Heiko Schocher
  2012-10-22 17:40 ` [U-Boot] [PATCH 1/3] i2c: add i2c_core and prepare for new multibus support Heiko Schocher
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: Heiko Schocher @ 2012-10-22 17:40 UTC (permalink / raw)
  To: u-boot

rebased/reworked the I2C multibus patches from Simon Glass found
here:

http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html

It seems the timing is coming, to bring this in mainline and
move boards over to the new i2c framework. As an example I
converted the soft-i2c driver (and all boards using it) to
the new framework, so this patchseries has to be tested
intensively, as I can check compile only ...

Cc: Simon Glass <sjg@chromium.org>
Cc: Piotr Wilczek <p.wilczek@samsung.com>

Heiko Schocher (3):
  i2c: add i2c_core and prepare for new multibus support
  i2c: common changes for multibus/multiadapter support
  i2c, soft-i2c: switch to new multibus/multiadapter support

 README                                    |   89 +++++++-
 arch/arm/include/asm/global_data.h        |    3 +
 arch/arm/lib/board.c                      |   15 +-
 arch/avr32/include/asm/global_data.h      |    3 +
 arch/blackfin/include/asm/global_data.h   |    4 +-
 arch/blackfin/lib/board.c                 |    7 +
 arch/m68k/include/asm/global_data.h       |    3 +
 arch/m68k/lib/board.c                     |   15 +-
 arch/microblaze/include/asm/global_data.h |    3 +
 arch/mips/include/asm/global_data.h       |    3 +
 arch/mips/lib/board.c                     |    7 +
 arch/nds32/include/asm/global_data.h      |    3 +
 arch/nds32/lib/board.c                    |   10 +-
 arch/nios2/include/asm/global_data.h      |    3 +
 arch/powerpc/cpu/mpc8xx/video.c           |    4 +
 arch/powerpc/include/asm/global_data.h    |    3 +
 arch/powerpc/lib/board.c                  |   16 +-
 arch/sh/include/asm/global_data.h         |    3 +
 arch/sparc/include/asm/global_data.h      |    3 +
 arch/x86/include/asm/global_data.h        |    3 +
 board/BuS/eb_cpux9k2/cpux9k2.c            |    2 +-
 board/BuS/vl_ma2sc/vl_ma2sc.c             |    2 +-
 board/atc/atc.c                           |    2 +-
 board/bluewater/snapper9260/snapper9260.c |    2 +-
 board/cm5200/cm5200.c                     |    4 +-
 board/cpu86/cpu86.c                       |    2 +-
 board/cpu87/cpu87.c                       |    2 +-
 board/emk/top9000/top9000.c               |    8 +-
 board/eukrea/cpuat91/cpuat91.c            |    2 +-
 board/freescale/m52277evb/README          |    2 +-
 board/freescale/m53017evb/README          |    2 +-
 board/freescale/m5373evb/README           |    2 +-
 board/freescale/m54455evb/README          |    2 +-
 board/freescale/m547xevb/README           |    2 +-
 board/ids8247/ids8247.c                   |    2 +-
 board/keymile/common/common.c             |    3 +-
 board/keymile/common/ivm.c                |   15 +-
 board/keymile/km82xx/km82xx.c             |    2 +-
 board/keymile/km_arm/km_arm.c             |    8 +-
 board/lwmon/lwmon.c                       |    2 +-
 board/lwmon/pcmcia.c                      |    4 +-
 board/pm826/pm826.c                       |    2 +-
 board/pm828/pm828.c                       |    2 +-
 board/sacsng/ioconfig.h                   |    2 +-
 board/sandburst/karef/karef.c             |    1 -
 board/siemens/SCM/scm.c                   |    2 +-
 board/tqc/tqm8260/tqm8260.c               |    2 +-
 board/tqc/tqm8272/tqm8272.c               |    2 +-
 board/tqc/tqm8272/tqm8272.h               |    2 +-
 common/cmd_date.c                         |    9 +
 common/cmd_dtt.c                          |    9 +
 common/cmd_eeprom.c                       |    3 +-
 common/cmd_i2c.c                          |  118 ++++++---
 common/env_eeprom.c                       |   14 +
 common/stdio.c                            |   14 +-
 drivers/i2c/Makefile                      |    3 +-
 drivers/i2c/i2c_core.c                    |  367 +++++++++++++++++++++++++++++
 drivers/i2c/soft_i2c.c                    |  122 ++++++----
 include/configs/A3000.h                   |    4 +-
 include/configs/BSC9131RDB.h              |    1 -
 include/configs/CANBT.h                   |    4 +
 include/configs/CPU86.h                   |    9 +-
 include/configs/CPU87.h                   |    9 +-
 include/configs/DU440.h                   |    1 -
 include/configs/GEN860T.h                 |   36 ++--
 include/configs/HIDDEN_DRAGON.h           |   10 +-
 include/configs/IAD210.h                  |   12 +-
 include/configs/ICU862.h                  |   14 +-
 include/configs/IDS8247.h                 |   10 +-
 include/configs/IP860.h                   |   10 +-
 include/configs/IPHASE4539.h              |   12 +-
 include/configs/JSE.h                     |    1 -
 include/configs/KAREF.h                   |    1 -
 include/configs/KUP4K.h                   |   12 +-
 include/configs/KUP4X.h                   |   14 +-
 include/configs/M5208EVBE.h               |    1 -
 include/configs/M52277EVB.h               |    1 -
 include/configs/M5235EVB.h                |    1 -
 include/configs/M5271EVB.h                |    1 -
 include/configs/M5275EVB.h                |    1 -
 include/configs/M53017EVB.h               |    1 -
 include/configs/M5329EVB.h                |    1 -
 include/configs/M5373EVB.h                |    1 -
 include/configs/M54451EVB.h               |    1 -
 include/configs/M54455EVB.h               |    1 -
 include/configs/M5475EVB.h                |    1 -
 include/configs/M5485EVB.h                |    1 -
 include/configs/METROBOX.h                |    1 -
 include/configs/MHPC.h                    |    9 +-
 include/configs/MPC8323ERDB.h             |    1 -
 include/configs/MPC832XEMDS.h             |    1 -
 include/configs/MPC8349EMDS.h             |    1 -
 include/configs/MPC8349ITX.h              |    2 -
 include/configs/MPC8360EMDS.h             |    1 -
 include/configs/MPC8360ERDK.h             |    1 -
 include/configs/MPC837XEMDS.h             |    1 -
 include/configs/MPC837XERDB.h             |    1 -
 include/configs/MPC8536DS.h               |    1 -
 include/configs/MPC8540ADS.h              |    1 -
 include/configs/MPC8541CDS.h              |    1 -
 include/configs/MPC8544DS.h               |    1 -
 include/configs/MPC8548CDS.h              |    3 +-
 include/configs/MPC8555CDS.h              |    1 -
 include/configs/MPC8560ADS.h              |    1 -
 include/configs/MPC8568MDS.h              |    1 -
 include/configs/MPC8569MDS.h              |    1 -
 include/configs/MPC8572DS.h               |    1 -
 include/configs/MPC8610HPCD.h             |    1 -
 include/configs/MPC8641HPCN.h             |    1 -
 include/configs/P1010RDB.h                |    1 -
 include/configs/P1023RDS.h                |    1 -
 include/configs/P1_P2_RDB.h               |    1 -
 include/configs/P2020COME.h               |    1 -
 include/configs/PM826.h                   |    9 +-
 include/configs/PM828.h                   |    9 +-
 include/configs/PMC440.h                  |    1 -
 include/configs/R360MPI.h                 |    7 +-
 include/configs/RPXClassic.h              |   16 +-
 include/configs/RPXlite.h                 |   26 ++
 include/configs/RRvision.h                |   13 +-
 include/configs/SBC8540.h                 |    1 -
 include/configs/SCM.h                     |   11 +-
 include/configs/SXNI855T.h                |    8 +-
 include/configs/Sandpoint8240.h           |   10 +-
 include/configs/Sandpoint8245.h           |   14 +-
 include/configs/TASREG.h                  |   27 +-
 include/configs/TK885D.h                  |   13 +-
 include/configs/TOP5200.h                 |   15 +-
 include/configs/TOP860.h                  |   11 +-
 include/configs/TQM8260.h                 |    9 +-
 include/configs/TQM8272.h                 |   13 +-
 include/configs/TQM834x.h                 |    1 -
 include/configs/TQM855M.h                 |   13 +-
 include/configs/TQM866M.h                 |   13 +-
 include/configs/TQM885D.h                 |   13 +-
 include/configs/alpr.h                    |    1 -
 include/configs/aria.h                    |    1 -
 include/configs/astro_mcf5373l.h          |    1 -
 include/configs/bf533-ezkit.h             |   10 +-
 include/configs/bf533-stamp.h             |   47 ++++-
 include/configs/bf561-ezkit.h             |    9 +-
 include/configs/bfin_adi_common.h         |    2 +-
 include/configs/blackstamp.h              |    1 -
 include/configs/cpuat91.h                 |    1 -
 include/configs/debris.h                  |   10 +-
 include/configs/eXalion.h                 |    2 +-
 include/configs/eb_cpux9k2.h              |   14 +-
 include/configs/ep8260.h                  |   14 +-
 include/configs/ethernut5.h               |    9 +-
 include/configs/ibf-dsp561.h              |    5 +-
 include/configs/iocon.h                   |   11 +-
 include/configs/km/keymile-common.h       |    3 -
 include/configs/km/km83xx-common.h        |    3 +
 include/configs/km/km_arm.h               |   26 ++-
 include/configs/km82xx.h                  |   18 +-
 include/configs/km_kirkwood.h             |   14 +-
 include/configs/korat.h                   |    1 -
 include/configs/lwmon.h                   |   13 +-
 include/configs/lwmon5.h                  |    1 -
 include/configs/mecp5123.h                |    1 -
 include/configs/mpc5121ads.h              |    1 -
 include/configs/nhk8815.h                 |    8 +-
 include/configs/otc570.h                  |   18 +-
 include/configs/p1_p2_rdb_pc.h            |    1 -
 include/configs/p3p440.h                  |    1 -
 include/configs/pcs440ep.h                |    1 -
 include/configs/pdnb3.h                   |   11 +-
 include/configs/quad100hd.h               |    1 -
 include/configs/s5p_goni.h                |    7 +-
 include/configs/s5pc210_universal.h       |    7 +-
 include/configs/sacsng.h                  |   12 +-
 include/configs/sbc405.h                  |    1 -
 include/configs/sbc8349.h                 |    1 -
 include/configs/sbc8548.h                 |    1 -
 include/configs/sbc8560.h                 |    1 -
 include/configs/sbc8641d.h                |    1 -
 include/configs/sc3.h                     |    1 -
 include/configs/snapper9260.h             |    9 +-
 include/configs/socrates.h                |    1 -
 include/configs/spc1920.h                 |   13 +-
 include/configs/stxgp3.h                  |    1 -
 include/configs/stxssa.h                  |    1 -
 include/configs/top9000.h                 |   10 +-
 include/configs/trats.h                   |    7 +-
 include/configs/u8500_href.h              |    1 -
 include/configs/uc100.h                   |   13 +-
 include/configs/utx8245.h                 |    3 +-
 include/configs/vct.h                     |   12 +-
 include/configs/vl_ma2sc.h                |    7 +-
 include/configs/vme8349.h                 |    1 -
 include/configs/zeus.h                    |    1 -
 include/i2c.h                             |  196 +++++++++++++++-
 192 files changed, 1443 insertions(+), 533 deletions(-)
 create mode 100644 drivers/i2c/i2c_core.c

-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 1/3] i2c: add i2c_core and prepare for new multibus support
  2012-10-22 17:40 [U-Boot] [PATCH 0/3] Bring in new I2C framework Heiko Schocher
@ 2012-10-22 17:40 ` Heiko Schocher
  2012-10-22 17:40 ` [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support Heiko Schocher
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 25+ messages in thread
From: Heiko Schocher @ 2012-10-22 17:40 UTC (permalink / raw)
  To: u-boot

This Patch introduce the new i2c_core file, which holds
the I2C core functions, for the rework of the multibus/
multiadapter support.
Also adds changes in i2c.h for the new I2C multibus/multiadapter
support. This new support can be activated with the
CONFIG_SYS_I2C define.

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Cc: Mike Frysinger <vapier@gentoo.org>

---
- changes against Simons patches:
  - gd->cur_i2c_adap now used as "struct i2c_bus_hose *"
  - get rid of "i2c_cur_bus"
  add comments from Mike Frysinger:
  - renamed cur_adap to cur_i2c_adap
  - use uintx_t types
---
 arch/arm/include/asm/global_data.h        |    3 +
 arch/avr32/include/asm/global_data.h      |    3 +
 arch/blackfin/include/asm/global_data.h   |    4 +-
 arch/m68k/include/asm/global_data.h       |    3 +
 arch/microblaze/include/asm/global_data.h |    3 +
 arch/mips/include/asm/global_data.h       |    3 +
 arch/nds32/include/asm/global_data.h      |    3 +
 arch/nios2/include/asm/global_data.h      |    3 +
 arch/powerpc/include/asm/global_data.h    |    3 +
 arch/sh/include/asm/global_data.h         |    3 +
 arch/sparc/include/asm/global_data.h      |    3 +
 arch/x86/include/asm/global_data.h        |    3 +
 drivers/i2c/Makefile                      |    1 +
 drivers/i2c/i2c_core.c                    |  363 +++++++++++++++++++++++++++++
 include/i2c.h                             |  196 +++++++++++++++-
 15 files changed, 588 insertions(+), 9 deletions(-)
 create mode 100644 drivers/i2c/i2c_core.c

diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index f8088fe..bc97520 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -82,6 +82,9 @@ typedef	struct	global_data {
 	unsigned long	post_log_res; /* success of POST test */
 	unsigned long	post_init_f_time; /* When post_init_f started */
 #endif
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/avr32/include/asm/global_data.h b/arch/avr32/include/asm/global_data.h
index 7878bb1..e7da6e4 100644
--- a/arch/avr32/include/asm/global_data.h
+++ b/arch/avr32/include/asm/global_data.h
@@ -48,6 +48,9 @@ typedef	struct	global_data {
 #endif
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/blackfin/include/asm/global_data.h b/arch/blackfin/include/asm/global_data.h
index 290a9e7..f08f493 100644
--- a/arch/blackfin/include/asm/global_data.h
+++ b/arch/blackfin/include/asm/global_data.h
@@ -54,9 +54,11 @@ typedef struct global_data {
 	unsigned long post_log_res; 	/* success of POST test */
 	unsigned long post_init_f_time;	/* When post_init_f started */
 #endif
-
 	void	**jt;			/* jump table */
 	char	env_buf[32];		/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/m68k/include/asm/global_data.h b/arch/m68k/include/asm/global_data.h
index cd55b83..e976bbf 100644
--- a/arch/m68k/include/asm/global_data.h
+++ b/arch/m68k/include/asm/global_data.h
@@ -66,6 +66,9 @@ typedef	struct	global_data {
 #endif
 	void		**jt;		/* Standalone app jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/microblaze/include/asm/global_data.h b/arch/microblaze/include/asm/global_data.h
index de3b8db..eb5ded5 100644
--- a/arch/microblaze/include/asm/global_data.h
+++ b/arch/microblaze/include/asm/global_data.h
@@ -46,6 +46,9 @@ typedef	struct	global_data {
 	unsigned long	fb_base;	/* base address of frame buffer */
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
index 6e2cdc7..ad23587 100644
--- a/arch/mips/include/asm/global_data.h
+++ b/arch/mips/include/asm/global_data.h
@@ -59,6 +59,9 @@ typedef	struct	global_data {
 	unsigned long	env_valid;	/* Checksum of Environment valid? */
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/nds32/include/asm/global_data.h b/arch/nds32/include/asm/global_data.h
index 94bd4c2..bac218e 100644
--- a/arch/nds32/include/asm/global_data.h
+++ b/arch/nds32/include/asm/global_data.h
@@ -63,6 +63,9 @@ typedef	struct global_data {
 
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/nios2/include/asm/global_data.h b/arch/nios2/include/asm/global_data.h
index 3b0d9e6..e4c36dc 100644
--- a/arch/nios2/include/asm/global_data.h
+++ b/arch/nios2/include/asm/global_data.h
@@ -42,6 +42,9 @@ typedef	struct	global_data {
 #endif
 	void		**jt;		/* Standalone app jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/powerpc/include/asm/global_data.h b/arch/powerpc/include/asm/global_data.h
index 5a5877f..f063be9 100644
--- a/arch/powerpc/include/asm/global_data.h
+++ b/arch/powerpc/include/asm/global_data.h
@@ -182,6 +182,9 @@ typedef	struct	global_data {
 #endif
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/sh/include/asm/global_data.h b/arch/sh/include/asm/global_data.h
index 6e534ad..1929352 100644
--- a/arch/sh/include/asm/global_data.h
+++ b/arch/sh/include/asm/global_data.h
@@ -42,6 +42,9 @@ typedef	struct global_data
 	unsigned long	env_valid;	/* Checksum of Environment valid */
 	void		**jt;		/* Standalone app jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/sparc/include/asm/global_data.h b/arch/sparc/include/asm/global_data.h
index 93d3cc0..71432aa 100644
--- a/arch/sparc/include/asm/global_data.h
+++ b/arch/sparc/include/asm/global_data.h
@@ -74,6 +74,9 @@ typedef struct global_data {
 #endif
 	void	**jt;			/* jump table */
 	char	env_buf[32];		/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 #include <asm-generic/global_data_flags.h>
diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h
index 6d29c0b..88e9d6c 100644
--- a/arch/x86/include/asm/global_data.h
+++ b/arch/x86/include/asm/global_data.h
@@ -57,6 +57,9 @@ typedef	struct global_data {
 	unsigned long	reset_status;	/* reset status register at boot */
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	void		*cur_i2c_bus;	/* current used i2c bus */
+#endif
 } gd_t;
 
 static inline gd_t *get_fs_gd_ptr(void)
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 5dbdbe3..6373306 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -46,6 +46,7 @@ COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
 COBJS-$(CONFIG_U8500_I2C) += u8500_i2c.o
 COBJS-$(CONFIG_SH_I2C) += sh_i2c.o
 COBJS-$(CONFIG_SH_SH7734_I2C) += sh_sh7734_i2c.o
+COBJS-$(CONFIG_SYS_I2C) += i2c_core.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
new file mode 100644
index 0000000..cdb6a06
--- /dev/null
+++ b/drivers/i2c/i2c_core.c
@@ -0,0 +1,363 @@
+/*
+ * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
+ *
+ * Multibus/multiadapter I2C core functions (wrappers)
+ */
+#include <common.h>
+#include <i2c.h>
+
+struct i2c_adapter *i2c_adap[CONFIG_SYS_NUM_I2C_ADAPTERS] =
+			CONFIG_SYS_I2C_ADAPTERS;
+
+struct i2c_bus_hose i2c_bus[CONFIG_SYS_NUM_I2C_BUSSES] =
+			CONFIG_SYS_I2C_BUSSES;
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void i2c_reloc_fixup(void)
+{
+#if defined(CONFIG_NEEDS_MANUAL_RELOC)
+	int		i;
+	unsigned long	addr;
+
+	for (i = 0; i < CONFIG_SYS_NUM_I2C_ADAPTERS; i++) {
+		/* Adapter itself */
+		addr = (unsigned long)i2c_adap[i];
+		if (addr != 0)
+			addr += gd->reloc_off;
+
+		i2c_adap[i] = (struct i2c_adapter *)addr;
+		/* i2c_init() */
+		addr = (unsigned long)i2c_adap[i]->init;
+		if (addr != 0)
+			addr += gd->reloc_off;
+
+		i2c_adap[i]->init = (void (*)(int, int))addr;
+		/* i2c_probe() */
+		addr = (unsigned long)i2c_adap[i]->probe;
+		if (addr != 0)
+			addr += gd->reloc_off;
+
+		i2c_adap[i]->probe = (int (*)(uint8_t))addr;
+		/* i2c_read() */
+		addr = (unsigned long)i2c_adap[i]->read;
+		if (addr != 0)
+			addr += gd->reloc_off;
+
+		i2c_adap[i]->read = (int (*)(uint8_t, uint, int, uint8_t *,
+					int))addr;
+		/* i2c_write() */
+		addr = (unsigned long)i2c_adap[i]->write;
+		if (addr != 0)
+			addr += gd->reloc_off;
+
+		i2c_adap[i]->write = (int (*)(uint8_t, uint, int, uint8_t *,
+					int))addr;
+		/* i2c_set_bus_speed() */
+		addr = (unsigned long)i2c_adap[i]->set_bus_speed;
+		if (addr != 0)
+			addr += gd->reloc_off;
+
+		i2c_adap[i]->set_bus_speed = (uint (*)(uint))addr;
+		/* name */
+		addr = (unsigned long)i2c_adap[i]->name;
+		if (addr != 0)
+			addr += gd->reloc_off;
+
+		i2c_adap[i]->name = (char *)addr;
+	}
+	gd->cur_i2c_bus += gd->reloc_off;
+#else
+	/*
+	 * we need this here to set after relocation gd->cur_i2c_bus
+	 * to the new relocated value.
+	 */
+	gd->cur_i2c_bus = NULL;
+	i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
+#endif
+}
+
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+/*
+ * i2c_mux_set()
+ * -------------
+ *
+ * This turns on the given channel on I2C multiplexer chip connected to
+ * a given I2C adapter directly or via other multiplexers. In the latter
+ * case the entire multiplexer chain must be initialized first starting
+ * with the one connected directly to the adapter. When disabling a chain
+ * muxes must be programmed in reverse order, starting with the one
+ * farthest from the adapter.
+ *
+ * mux_id is the multiplexer chip type from defined in i2c.h. So far only
+ * NXP (Philips) PCA954x multiplexers are supported. Switches are NOT
+ * supported (anybody uses them?)
+ */
+
+static int i2c_mux_set(struct i2c_adapter *adap, int mux_id, int chip,
+			int channel)
+{
+	uint8_t	buf;
+
+	/* channel < 0 - turn off the mux */
+	if (channel < 0) {
+		buf = 0;
+		return adap->write(chip, 0, 0, &buf, 1);
+	}
+
+	switch (mux_id) {
+	case I2C_MUX_PCA9540_ID:
+	case I2C_MUX_PCA9542_ID:
+		if (channel > 1)
+			return -1;
+		buf = (uint8_t)((channel & 0x01) | (1 << 2));
+		break;
+	case I2C_MUX_PCA9544_ID:
+		if (channel > 3)
+			return -1;
+		buf = (uint8_t)((channel & 0x03) | (1 << 2));
+		break;
+	case I2C_MUX_PCA9547_ID:
+		if (channel > 7)
+			return -1;
+		buf = (uint8_t)((channel & 0x07) | (1 << 3));
+		break;
+	default:
+		return -1;
+	}
+
+	return adap->write(chip, 0, 0, &buf, 1);
+}
+#endif
+
+/*
+ * i2c_init_bus():
+ * ---------------
+ *
+ * Initializes one bus. Will initialize the parent adapter. No current bus
+ * changes, no mux (if any) setup.
+ */
+static void i2c_init_bus(unsigned int bus_no, int speed, int slaveaddr)
+{
+	if (bus_no >= CONFIG_SYS_NUM_I2C_BUSSES)
+		return;
+
+	I2C_ADAP->init(speed, slaveaddr);
+
+	if (gd->flags & GD_FLG_RELOC) {
+		I2C_ADAP->init_done = 1;
+		I2C_ADAP->speed = speed;
+		I2C_ADAP->slaveaddr = slaveaddr;
+	}
+}
+
+/*
+ * i2c_init_all():
+ *
+ * not longer needed, will deleted. Actual init the SPD_BUS
+ * for compatibility.
+ * i2c_adap[] must be initialized beforehead with function pointers and
+ * data, including speed and slaveaddr.
+ */
+void i2c_init_all(void)
+{
+	i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
+	return;
+}
+
+/*
+ * i2c_get_bus_num():
+ * ------------------
+ *
+ *  Returns index of currently active I2C bus.  Zero-based.
+ */
+unsigned int i2c_get_bus_num(void)
+{
+	int i = 0;
+
+	if (gd->cur_i2c_bus == NULL)
+		return CONFIG_SYS_SPD_BUS_NUM;
+
+	while (i < CONFIG_SYS_NUM_I2C_BUSSES) {
+		if (I2C_BUS == &i2c_bus[i])
+			return i;
+		i++;
+	}
+
+	return CONFIG_SYS_SPD_BUS_NUM;
+}
+
+/*
+ * i2c_set_bus_num():
+ * ------------------
+ *
+ *  Change the active I2C bus. Subsequent read/write calls will
+ *  go to this one. Sets all of the muxes in a proper condition
+ *  if that bus is behind muxes.
+ *  If previously selected bus is behind the muxes turns off all the
+ *  muxes along the path to that bus.
+ *
+ *	bus - bus index, zero based
+ *
+ *	Returns: 0 on success, not 0 on failure
+ */
+int i2c_set_bus_num(unsigned int bus)
+{
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+	int		i;
+	uint8_t	buf;
+#endif
+
+	if (bus >= CONFIG_SYS_NUM_I2C_BUSSES)
+		return -1;
+
+	if (gd->cur_i2c_bus == NULL)
+		gd->cur_i2c_bus = &i2c_bus[bus];
+	else if ((&i2c_bus[bus] == I2C_BUS) &&
+		(I2C_ADAP->init_done > 0))
+		return 0;
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+	else {
+		/* Disconnect current bus (turn off muxes if any) */
+		if ((I2C_BUS->next_hop[0].chip != 0) &&
+		    (I2C_ADAP->init_done != 0)) {
+			i = CONFIG_SYS_I2C_MAX_HOPS;
+			do {
+				uint8_t	chip;
+
+				chip = I2C_BUS->next_hop[--i].chip;
+				if (chip == 0)
+					continue;
+
+				I2C_ADAP->write(chip, 0, 0, &buf, 1);
+			} while (i > 0);
+		}
+	}
+#endif
+
+	gd->cur_i2c_bus = &i2c_bus[bus];
+	if (I2C_ADAP->init_done == 0)
+		i2c_init_bus(bus, I2C_ADAP->speed, I2C_ADAP->slaveaddr);
+
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+	/* Connect requested bus if behind muxes */
+	if (I2C_BUS->next_hop[0].chip != 0) {
+
+		/* Set all muxes along the path to that bus */
+		for (i = 0; i < CONFIG_SYS_I2C_MAX_HOPS; i++) {
+			int	ret;
+
+			if (I2C_BUS->next_hop[i].chip == 0)
+				break;
+
+			ret = i2c_mux_set(I2C_ADAP,
+					I2C_BUS->next_hop[i].mux.id,
+					I2C_BUS->next_hop[i].chip,
+					I2C_BUS->next_hop[i].channel);
+			if (ret != 0) {
+				printf("%s: could not set mux: id: %d "\
+					"chip: %x channel: %d\n", __func__,
+					I2C_BUS->next_hop[i].mux.id,
+					I2C_BUS->next_hop[i].chip,
+					I2C_BUS->next_hop[i].channel);
+			}
+		}
+	}
+#endif
+
+	return 0;
+}
+
+/*
+ * Probe the given I2C chip address.  Returns 0 if a chip responded,
+ * not 0 on failure.
+ */
+int i2c_probe(uint8_t chip)
+{
+	return I2C_ADAP->probe(chip);
+}
+
+/*
+ * Read/Write interface:
+ *   chip:    I2C chip address, range 0..127
+ *   addr:    Memory (register) address within the chip
+ *   alen:    Number of bytes to use for addr (typically 1, 2 for larger
+ *              memories, 0 for register type devices with only one
+ *              register)
+ *   buffer:  Where to read/write the data
+ *   len:     How many bytes to read/write
+ *
+ *   Returns: 0 on success, not 0 on failure
+ */
+int i2c_read(uint8_t chip, unsigned int addr, int alen,
+				uint8_t *buffer, int len)
+{
+	return I2C_ADAP->read(chip, addr, alen, buffer, len);
+}
+
+int i2c_write(uint8_t chip, unsigned int addr, int alen,
+				uint8_t *buffer, int len)
+{
+	return I2C_ADAP->write(chip, addr, alen, buffer, len);
+}
+
+unsigned int i2c_set_bus_speed(unsigned int speed)
+{
+	unsigned int ret;
+
+	if (I2C_ADAP->set_bus_speed == NULL)
+		return 0;
+	ret = I2C_ADAP->set_bus_speed(speed);
+	if (gd->flags & GD_FLG_RELOC)
+		I2C_ADAP->speed = ret;
+
+	return ret;
+}
+
+unsigned int i2c_get_bus_speed(void)
+{
+	struct i2c_adapter *cur = I2C_ADAP;
+	return cur->speed;
+}
+
+uint8_t i2c_reg_read(uint8_t addr, uint8_t reg)
+{
+	uint8_t buf;
+
+#ifdef CONFIG_8xx
+	/* MPC8xx needs this.  Maybe one day we can get rid of it. */
+	/* maybe it is now the time for it ... */
+	i2c_set_bus_num(i2c_get_bus_num());
+#endif
+	i2c_read(addr, reg, 1, &buf, 1);
+
+#ifdef DEBUG
+	printf("%s: bus=%d addr=0x%02x, reg=0x%02x, val=0x%02x\n",
+		 __func__, i2c_get_bus_num(), addr, reg, buf);
+#endif
+
+	return buf;
+}
+
+void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val)
+{
+#ifdef CONFIG_8xx
+	/* MPC8xx needs this.  Maybe one day we can get rid of it. */
+	/* maybe it is now the time for it ... */
+	i2c_set_bus_num(i2c_get_bus_num());
+#endif
+
+#ifdef DEBUG
+	printf("%s: bus=%d addr=0x%02x, reg=0x%02x, val=0x%02x\n",
+	       __func__, i2c_get_bus_num(), addr, reg, val);
+#endif
+
+	i2c_write(addr, reg, 1, &val, 1);
+}
+
+void __i2c_init(int speed, int slaveaddr)
+{
+	i2c_init_bus(i2c_get_bus_num(), speed, slaveaddr);
+}
+void i2c_init(int speed, int slaveaddr)
+	__attribute__((weak, alias("__i2c_init")));
diff --git a/include/i2c.h b/include/i2c.h
index 16f099d..44a05cd 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -1,4 +1,8 @@
 /*
+ * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
+ * Copyright (C) 2009 Heiko Schocher <hs@denx.de>
+ * Changes for multibus/multiadapter I2C support.
+ *
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com.
  *
@@ -46,16 +50,25 @@
  */
 #define I2C_RXTX_LEN	128	/* maximum tx/rx buffer length */
 
-#ifdef	CONFIG_I2C_MULTI_BUS
-#define	MAX_I2C_BUS			2
-#define	I2C_MULTI_BUS			1
-#else
-#define	MAX_I2C_BUS			1
-#define	I2C_MULTI_BUS			0
+#ifndef CONFIG_SYS_NUM_I2C_ADAPTERS
+#define CONFIG_SYS_NUM_I2C_ADAPTERS	1
 #endif
 
-#if !defined(CONFIG_SYS_MAX_I2C_BUS)
-#define CONFIG_SYS_MAX_I2C_BUS		MAX_I2C_BUS
+#if !defined(CONFIG_SYS_I2C_MAX_HOPS)
+#define CONFIG_SYS_I2C_DIRECT_BUS	1
+#define CONFIG_SYS_I2C_MAX_HOPS		1
+#if !defined(CONFIG_SYS_NUM_I2C_BUSSES)
+#define CONFIG_SYS_NUM_I2C_BUSSES	CONFIG_SYS_NUM_I2C_ADAPTERS
+#define CONFIG_SYS_I2C_BUSSES { {0, {I2C_NULL_HOP} } }
+#endif
+#else
+#undef CONFIG_SYS_I2C_DIRECT_BUS
+#ifndef CONFIG_SYS_NUM_I2C_BUSSES
+#define CONFIG_SYS_NUM_I2C_BUSSES	1
+#endif
+#ifndef CONFIG_SYS_I2C_BUSSES
+#define CONFIG_SYS_I2C_BUSSES { {0, {I2C_NULL_HOP} } }
+#endif
 #endif
 
 /* define the I2C bus number for RTC and DTT if not already done */
@@ -69,6 +82,59 @@
 #define CONFIG_SYS_SPD_BUS_NUM		0
 #endif
 
+struct i2c_adapter {
+	void		(*init)(int speed, int slaveaddr);
+	int		(*probe)(uint8_t chip);
+	int		(*read)(uint8_t chip, uint addr, int alen,
+				uint8_t *buffer, int len);
+	int		(*write)(uint8_t chip, uint addr, int alen,
+				uint8_t *buffer, int len);
+	uint		(*set_bus_speed)(uint speed);
+
+	int		speed;
+	int		slaveaddr;
+	int		init_done;
+	int		hwadapnr;
+	char		*name;
+};
+
+struct i2c_mux {
+	int	id;
+	char	name[16];
+};
+
+struct i2c_next_hop {
+	struct i2c_mux		mux;
+	uint8_t		chip;
+	uint8_t		channel;
+};
+
+struct i2c_bus_hose {
+	int	adapter;
+	struct i2c_next_hop	next_hop[CONFIG_SYS_I2C_MAX_HOPS];
+};
+
+#define I2C_NULL_HOP	{{-1, ""}, 0, 0}
+
+extern struct i2c_bus_hose	i2c_bus[];
+extern struct i2c_adapter	*i2c_adap[];
+
+#define	I2C_ADAP_NR(bus)	i2c_adap[i2c_bus[bus].adapter]
+#define	I2C_BUS			((struct i2c_bus_hose *)gd->cur_i2c_bus)
+#define	I2C_ADAP		i2c_adap[I2C_BUS->adapter]
+#define I2C_ADAP_HWNR		(I2C_ADAP->hwadapnr)
+
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+#define I2C_MUX_PCA9540_ID	1
+#define I2C_MUX_PCA9540		{I2C_MUX_PCA9540_ID, "PCA9540B"}
+#define I2C_MUX_PCA9542_ID	2
+#define I2C_MUX_PCA9542		{I2C_MUX_PCA9542_ID, "PCA9542A"}
+#define I2C_MUX_PCA9544_ID	3
+#define I2C_MUX_PCA9544		{I2C_MUX_PCA9544_ID, "PCA9544A"}
+#define I2C_MUX_PCA9547_ID	4
+#define I2C_MUX_PCA9547		{I2C_MUX_PCA9547_ID, "PCA9547A"}
+#endif
+
 #ifndef I2C_SOFT_DECLARATIONS
 # if defined(CONFIG_MPC8260)
 #  define I2C_SOFT_DECLARATIONS volatile ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT);
@@ -134,6 +200,104 @@ int i2x_mux_select_mux(int bus);
 int i2c_mux_ident_muxstring_f (uchar *buf);
 #endif
 
+#ifdef CONFIG_SYS_I2C
+/*
+ * Initialization, must be called once on start up, may be called
+ * repeatedly to change the speed and slave addresses.
+ */
+void i2c_init(unsigned int speed, int slaveaddr);
+#ifdef CONFIG_SYS_I2C_INIT_BOARD
+void i2c_init_board(void);
+#endif
+
+/*
+ * i2c_get_bus_num:
+ *
+ *  Returns index of currently active I2C bus.  Zero-based.
+ */
+unsigned int i2c_get_bus_num(void);
+
+/*
+ * i2c_set_bus_num:
+ *
+ *  Change the active I2C bus.  Subsequent read/write calls will
+ *  go to this one.
+ *
+ *	bus - bus index, zero based
+ *
+ *	Returns: 0 on success, not 0 on failure
+ *
+ */
+int i2c_set_bus_num(unsigned int bus);
+
+/*
+ * i2c_init_all():
+ *
+ * Initializes all I2C adapters in the system. All i2c_adap structures must
+ * be initialized beforehead with function pointers and data, including
+ * speed and slaveaddr. Returns 0 on success, non-0 on failure.
+ */
+void i2c_init_all(void);
+
+/*
+ * Probe the given I2C chip address.  Returns 0 if a chip responded,
+ * not 0 on failure.
+ */
+int i2c_probe(uint8_t chip);
+
+/*
+ * Read/Write interface:
+ *   chip:    I2C chip address, range 0..127
+ *   addr:    Memory (register) address within the chip
+ *   alen:    Number of bytes to use for addr (typically 1, 2 for larger
+ *              memories, 0 for register type devices with only one
+ *              register)
+ *   buffer:  Where to read/write the data
+ *   len:     How many bytes to read/write
+ *
+ *   Returns: 0 on success, not 0 on failure
+ */
+int i2c_read(uint8_t chip, unsigned int addr, int alen,
+				uint8_t *buffer, int len);
+
+int i2c_write(uint8_t chip, unsigned int addr, int alen,
+				uint8_t *buffer, int len);
+
+/*
+ * Utility routines to read/write registers.
+ */
+uint8_t i2c_reg_read(uint8_t addr, uint8_t reg);
+
+void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val);
+
+/*
+ * i2c_set_bus_speed:
+ *
+ *  Change the speed of the active I2C bus
+ *
+ *	speed - bus speed in Hz
+ *
+ *	Returns: new bus speed
+ *
+ */
+unsigned int i2c_set_bus_speed(unsigned int speed);
+
+/*
+ * i2c_get_bus_speed:
+ *
+ *  Returns speed of currently active I2C bus in Hz
+ */
+
+unsigned int i2c_get_bus_speed(void);
+
+/*
+ * i2c_reloc_fixup:
+ *
+ * Adjusts I2C pointers after U-Boot is relocated to DRAM
+ */
+void i2c_reloc_fixup(void);
+#else
+
 /*
  * Probe the given I2C chip address.  Returns 0 if a chip responded,
  * not 0 on failure.
@@ -235,6 +399,22 @@ int i2c_set_bus_speed(unsigned int);
  */
 
 unsigned int i2c_get_bus_speed(void);
+#endif /* CONFIG_SYS_I2C */
+
+/*
+ * only for backwardcompatibility, should go away if we switched
+ * completely to new multibus support.
+ */
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) || defined(CONFIG_I2C_MULTI_BUS)
+# if !defined(CONFIG_SYS_MAX_I2C_BUS)
+#  define CONFIG_SYS_MAX_I2C_BUS		2
+# endif
+# define I2C_MULTI_BUS				0
+#else
+# define CONFIG_SYS_MAX_I2C_BUS		1
+# define I2C_MULTI_BUS				0
+#endif
+
 
 /* NOTE: These two functions MUST be always_inline to avoid code growth! */
 static inline unsigned int I2C_GET_BUS(void) __attribute__((always_inline));
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support
  2012-10-22 17:40 [U-Boot] [PATCH 0/3] Bring in new I2C framework Heiko Schocher
  2012-10-22 17:40 ` [U-Boot] [PATCH 1/3] i2c: add i2c_core and prepare for new multibus support Heiko Schocher
@ 2012-10-22 17:40 ` Heiko Schocher
  2012-10-22 22:16   ` Henrik Nordström
  2012-10-22 17:40 ` [U-Boot] [PATCH 3/3] i2c, soft-i2c: switch to new " Heiko Schocher
  2012-10-25 21:37 ` [U-Boot] [PATCH 0/3] Bring in new I2C framework Simon Glass
  3 siblings, 1 reply; 25+ messages in thread
From: Heiko Schocher @ 2012-10-22 17:40 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
 README                          |   82 ++++++++++++++++++++++++++-
 arch/arm/lib/board.c            |   12 ++++-
 arch/blackfin/lib/board.c       |    7 ++
 arch/m68k/lib/board.c           |   18 +++++-
 arch/mips/lib/board.c           |    7 ++
 arch/nds32/lib/board.c          |   10 +++-
 arch/powerpc/cpu/mpc8xx/video.c |    4 +
 arch/powerpc/lib/board.c        |   18 +++++-
 common/cmd_date.c               |    9 +++
 common/cmd_dtt.c                |    9 +++
 common/cmd_i2c.c                |  118 ++++++++++++++++++++++++++-------------
 common/env_eeprom.c             |   14 +++++
 common/stdio.c                  |   13 ++++-
 include/i2c.h                   |    9 ---
 14 files changed, 269 insertions(+), 61 deletions(-)

diff --git a/README b/README
index df4aed1..634cff4 100644
--- a/README
+++ b/README
@@ -1757,9 +1757,85 @@ The following options need to be configured:
 		on those systems that support this (optional)
 		feature, like the TQM8xxL modules.
 
-- I2C Support:	CONFIG_HARD_I2C | CONFIG_SOFT_I2C
-
-		These enable I2C serial bus commands. Defining either of
+- I2C Support:	CONFIG_SYS_I2C
+
+		This enable the NEW i2c subsystem, and will allow you to use
+		i2c commands at the u-boot command line (as long as you set
+		CONFIG_CMD_I2C in CONFIG_COMMANDS) and communicate with i2c
+		based realtime clock chips or other i2c devices. See
+		common/cmd_i2c.c for a description of the command line
+		interface.
+
+		additional defines:
+
+		CONFIG_SYS_NUM_I2C_ADAPTERS
+		define how many i2c adapters you want to use on your
+		hardware. If you need only 1 i2c adapter, you can ommit
+		this define.
+
+		CONFIG_SYS_I2C_ADAPTERS
+		hold a list of adapters you want to use, for example:
+		{&soft_i2c_adap[0], &mpc5xxx_i2c_adap[0]}
+		with this configuration you have one soft_i2c adapter,
+		and one mpc5xxx i2c adapter.
+
+		No I2C adapters current suppor this new interface.
+
+		You need to define for each adapter a speed and a
+		slave address.
+
+		CONFIG_SYS_NUM_I2C_BUSSES
+		Hold the number of i2c busses you want to use. If you
+		don't use/have i2c muxes on your i2c bus, this
+		is equal to CONFIG_SYS_NUM_I2C_ADAPTERS, and you can
+		omit this define.
+
+		CONFIG_SYS_I2C_DIRECT_BUS
+		define this, if you don't use i2c muxes on your hardware.
+		if CONFIG_SYS_I2C_MAX_HOPS is not defined or == 0 you can
+		omit this define.
+
+		CONFIG_SYS_I2C_MAX_HOPS
+		define how many muxes are maximal consecutively connected
+		on one i2c bus.
+
+		CONFIG_SYS_I2C_BUSSES
+		hold a list of busses you want to use, only used if
+		CONFIG_SYS_I2C_DIRECT_BUS is not defined, for example
+		a board with CONFIG_SYS_I2C_MAX_HOPS = 1 and
+		CONFIG_SYS_NUM_I2C_BUSSES = 9:
+
+		 CONFIG_SYS_I2C_BUSSES	{{0, {I2C_NULL_HOP}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 1}}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 2}}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 3}}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 4}}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 5}}}, \
+					{1, {I2C_NULL_HOP}}, \
+					{1, {{I2C_MUX_PCA9544, 0x72, 1}}}, \
+					{1, {{I2C_MUX_PCA9544, 0x72, 2}}}, \
+					}
+
+		which defines
+			bus 0 on adapter 0 without a mux
+			bus 1 on adapter 0 without a PCA9547 on address 0x70 port 1
+			bus 2 on adapter 0 without a PCA9547 on address 0x70 port 2
+			bus 3 on adapter 0 without a PCA9547 on address 0x70 port 3
+			bus 4 on adapter 0 without a PCA9547 on address 0x70 port 4
+			bus 5 on adapter 0 without a PCA9547 on address 0x70 port 5
+			bus 6 on adapter 1 without a mux
+			bus 7 on adapter 1 without a PCA9544 on address 0x72 port 1
+			bus 8 on adapter 1 without a PCA9544 on address 0x72 port 2
+
+- Legacy I2C Support:	CONFIG_HARD_I2C | CONFIG_SOFT_I2C
+
+		NOTE: It is intended to move drivers to CONFIG_SYS_I2C which
+		provides the following compelling advantages:
+			1. Heiko to fill in
+
+		** Please consider updating your I2C driver now. **
+
+		These enable legacy I2C serial bus commands. Defining either of
 		(but not both of) CONFIG_HARD_I2C or CONFIG_SOFT_I2C will
 		include the appropriate I2C driver for the selected CPU.
 
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 0b47ab3..b5b53f4 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -74,7 +74,8 @@ extern void dataflash_print_info(void);
 #endif
 
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+	defined(CONFIG_SOFT_I2C) || \
+	defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
 
@@ -174,7 +175,11 @@ static int display_dram_config(void)
 static int init_func_i2c(void)
 {
 	puts("I2C:   ");
+#ifdef CONFIG_SYS_I2C
+	i2c_init_all();
+#else
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	puts("ready\n");
 	return (0);
 }
@@ -559,6 +564,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	dataflash_print_info();
 #endif
 
+#if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_ADAPTERS)
+	/* Adjust I2C subsystem pointers after relocation */
+	i2c_reloc_fixup();
+#endif
+
 	/* initialize environment */
 	env_relocate();
 
diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
index e47b606..999857c 100644
--- a/arch/blackfin/lib/board.c
+++ b/arch/blackfin/lib/board.c
@@ -37,6 +37,10 @@
 int post_flag;
 #endif
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+#include <i2c.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 __attribute__((always_inline))
@@ -364,6 +368,9 @@ void board_init_r(gd_t * id, ulong dest_addr)
 	mmc_initialize(bd);
 #endif
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+	i2c_reloc_fixup();
+#endif
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index 67c9a13..ba8c957 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/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
 
@@ -140,11 +141,16 @@ 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_SYS_I2C
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	puts ("ready\n");
 	return (0);
 }
@@ -176,7 +182,8 @@ 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)
@@ -501,6 +508,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	spi_init_r ();
 #endif
 
+#if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_ADAPTERS)
+	/* Adjust I2C subsystem pointers after relocation */
+	i2c_reloc_fixup();
+#endif
+
 	/* relocate environment function pointers etc. */
 	env_relocate ();
 
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index b14b33e..f274b0e 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -35,6 +35,9 @@
 #ifdef CONFIG_BITBANGMII
 #include <miiphy.h>
 #endif
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+#include <i2c.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -309,6 +312,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	onenand_init();
 #endif
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+	i2c_reloc_fixup();
+#endif
+
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
index 89900fe..e5d3870 100644
--- a/arch/nds32/lib/board.c
+++ b/arch/nds32/lib/board.c
@@ -39,6 +39,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_SYS_I2C)
+#include <i2c.h>
+#endif
+
 ulong monitor_flash_len;
 
 /*
@@ -172,7 +176,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_SYS_I2C)
 	init_func_i2c,
 #endif
 	dram_init,		/* configure available RAM banks */
@@ -358,6 +362,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	mmc_initialize(gd->bd);
 #endif
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+	i2c_reloc_fixup();
+#endif
+
 	/* initialize environment */
 	env_relocate();
 
diff --git a/arch/powerpc/cpu/mpc8xx/video.c b/arch/powerpc/cpu/mpc8xx/video.c
index 1bbf4cc..10e3e88 100644
--- a/arch/powerpc/cpu/mpc8xx/video.c
+++ b/arch/powerpc/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_SYS_I2C
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 
 #ifdef CONFIG_FADS
 	/* Reset ADV7176 chip */
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index b860141..0cd3408 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -99,7 +99,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>
@@ -214,11 +215,16 @@ 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_SYS_I2C
+	i2c_init_all();
+#else
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	puts("ready\n");
 	return 0;
 }
@@ -317,7 +323,8 @@ 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)
@@ -814,6 +821,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	mmc_initialize(bd);
 #endif
 
+#if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_ADAPTERS)
+	/* Adjust I2C subsystem pointers after relocation */
+	i2c_reloc_fixup();
+#endif
+
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 335bc05..d454974 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -50,8 +50,13 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	int old_bus;
 
 	/* switch to correct I2C bus */
+#ifdef CONFIG_SYS_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_RTC_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_RTC_BUS_NUM);
+#endif
 
 	switch (argc) {
 	case 2:			/* set date & time */
@@ -97,7 +102,11 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	/* switch back to original I2C bus */
+#ifdef CONFIG_SYS_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif
 
 	return rcode;
 }
diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
index cd94423..cb73614 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -69,8 +69,13 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	/* Force a compilation error, if there are more then 32 sensors */
 	BUILD_BUG_ON(sizeof(sensors) > 32);
 	/* switch to correct I2C bus */
+#ifdef CONFIG_SYS_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_DTT_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
+#endif
 
 	_initialize_dtt();
 
@@ -82,7 +87,11 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 		printf("DTT%d: %i C\n", i + 1, dtt_get_temp(sensors[i]));
 
 	/* switch back to original I2C bus */
+#ifdef CONFIG_SYS_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif
 
 	return 0;
 }	/* do_dtt() */
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 795814d..79145e9 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -1,4 +1,9 @@
 /*
+ * (C) Copyright 2009
+ * Sergey Kubushyn, himself, ksi at koi8.net
+ *
+ * Changes for unified multibus/multiadapter I2C support.
+ *
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com.
  *
@@ -83,6 +88,8 @@
 #include <malloc.h>
 #include <asm/byteorder.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Display values from last command.
  * Memory modify remembered values are different from display memory.
  */
@@ -101,7 +108,8 @@ static uint	i2c_mm_last_alen;
  * pairs.  The following macros take care of this */
 
 #if defined(CONFIG_SYS_I2C_NOPROBES)
-#if defined(CONFIG_I2C_MULTI_BUS)
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) || defined(CONFIG_I2C_MUX) || \
+	defined(CONFIG_I2C_MULTI_BUS)
 static struct
 {
 	uchar	bus;
@@ -117,7 +125,7 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
 #define COMPARE_BUS(b,i)	((b) == 0)	/* Make compiler happy */
 #define COMPARE_ADDR(a,i)	(i2c_no_probes[(i)] == (a))
 #define NO_PROBE_ADDR(i)	i2c_no_probes[(i)]
-#endif	/* CONFIG_MULTI_BUS */
+#endif	/* CONFIG_SYS_NUM_I2C_BUSSES > 1 */
 
 #define NUM_ELEMENTS_NOPROBE (sizeof(i2c_no_probes)/sizeof(i2c_no_probes[0]))
 #endif
@@ -125,9 +133,6 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
 #if defined(CONFIG_I2C_MUX)
 static I2C_MUX_DEVICE	*i2c_mux_devices = NULL;
 static	int	i2c_mux_busid = CONFIG_SYS_MAX_I2C_BUS;
-
-DECLARE_GLOBAL_DATA_PTR;
-
 #endif
 
 #define DISP_LINE_LEN	16
@@ -135,12 +140,15 @@ DECLARE_GLOBAL_DATA_PTR;
 /* implement possible board specific board init */
 void __def_i2c_init_board(void)
 {
-	return;
 }
 void i2c_init_board(void)
 	__attribute__((weak, alias("__def_i2c_init_board")));
 
-/* TODO: Implement architecture-specific get/set functions */
+#if !defined(CONFIG_SYS_I2C)
+/*
+ * TODO: Implement architecture-specific get/set functions
+ * Should go away, if we switched completely to new multibus support
+ */
 unsigned int __def_i2c_get_bus_speed(void)
 {
 	return CONFIG_SYS_I2C_SPEED;
@@ -157,6 +165,7 @@ int __def_i2c_set_bus_speed(unsigned int speed)
 }
 int i2c_set_bus_speed(unsigned int)
 	__attribute__((weak, alias("__def_i2c_set_bus_speed")));
+#endif
 
 /*
  * get_alen: small parser helper function to get address length
@@ -564,7 +573,7 @@ static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
 	int j;
 #if defined(CONFIG_SYS_I2C_NOPROBES)
 	int k, skip;
-	uchar bus = GET_BUS_NUM;
+	unsigned int bus = GET_BUS_NUM;
 #endif	/* NOPROBES */
 
 	puts ("Valid chip addresses:");
@@ -1186,53 +1195,78 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 }
 #endif
 
-#if defined(CONFIG_I2C_MUX)
-static int do_i2c_add_bus(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) && defined(CONFIG_SYS_I2C)
+int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	int ret=0;
+	int	i;
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+	int	j;
+#endif
 
 	if (argc == 1) {
 		/* show all busses */
-		I2C_MUX		*mux;
-		I2C_MUX_DEVICE	*device = i2c_mux_devices;
-
-		printf ("Busses reached over muxes:\n");
-		while (device != NULL) {
-			printf ("Bus ID: %x\n", device->busid);
-			printf ("  reached over Mux(es):\n");
-			mux = device->mux;
-			while (mux != NULL) {
-				printf ("    %s@%x ch: %x\n", mux->name, mux->chip, mux->channel);
-				mux = mux->next;
+		for (i = 0; i < CONFIG_SYS_NUM_I2C_BUSSES; i++) {
+			printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+			for (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {
+				if (i2c_bus[i].next_hop[j].chip == 0)
+					break;
+				printf("->%s at 0x%2x:%d",
+					i2c_bus[i].next_hop[j].mux.name,
+					i2c_bus[i].next_hop[j].chip,
+					i2c_bus[i].next_hop[j].channel);
 			}
-			device = device->next;
+#endif
+			printf("\n");
 		}
 	} else {
-		(void)i2c_mux_ident_muxstring ((uchar *)argv[1]);
-		ret = 0;
+		/* show specific bus */
+		i = simple_strtoul(argv[1], NULL, 10);
+		if (i >= CONFIG_SYS_NUM_I2C_BUSSES) {
+			printf("Invalid bus %d\n", i);
+			return -1;
+		}
+		printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+			for (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {
+				if (i2c_bus[i].next_hop[j].chip == 0)
+					break;
+				printf("->%s at 0x%2x:%d",
+					i2c_bus[i].next_hop[j].mux.name,
+					i2c_bus[i].next_hop[j].chip,
+					i2c_bus[i].next_hop[j].channel);
+			}
+#endif
+		printf("\n");
 	}
-	return ret;
+
+	return 0;
 }
-#endif  /* CONFIG_I2C_MUX */
+#endif
 
-#if defined(CONFIG_I2C_MULTI_BUS)
-static int do_i2c_bus_num(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+#if CONFIG_SYS_NUM_I2C_BUSSES > 1
+int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	int bus_idx, ret=0;
+	int		ret = 0;
+	unsigned int	bus_no;
 
 	if (argc == 1)
 		/* querying current setting */
 		printf("Current bus is %d\n", i2c_get_bus_num());
 	else {
-		bus_idx = simple_strtoul(argv[1], NULL, 10);
-		printf("Setting bus to %d\n", bus_idx);
-		ret = i2c_set_bus_num(bus_idx);
+		bus_no = simple_strtoul(argv[1], NULL, 10);
+		if (bus_no >= CONFIG_SYS_NUM_I2C_BUSSES) {
+			printf("Invalid bus %d\n", bus_no);
+			return -1;
+		}
+		printf("Setting bus to %d\n", bus_no);
+		ret = i2c_set_bus_num(bus_no);
 		if (ret)
 			printf("Failure changing bus number (%d)\n", ret);
 	}
 	return ret;
 }
-#endif  /* CONFIG_I2C_MULTI_BUS */
+#endif  /* CONFIG_SYS_NUM_I2C_BUSSES > 1 */
 
 static int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
@@ -1263,16 +1297,20 @@ static int do_i2c_nm(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 
 static int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
+#if defined(CONFIG_SYS_I2C)
+	i2c_init(I2C_ADAP->speed, I2C_ADAP->slaveaddr);
+#else
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	return 0;
 }
 
 static cmd_tbl_t cmd_i2c_sub[] = {
-#if defined(CONFIG_I2C_MUX)
-	U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_add_bus, "", ""),
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) && defined(CONFIG_SYS_I2C)
+	U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_show_bus, "", ""),
 #endif  /* CONFIG_I2C_MUX */
 	U_BOOT_CMD_MKENT(crc32, 3, 1, do_i2c_crc, "", ""),
-#if defined(CONFIG_I2C_MULTI_BUS)
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) && defined(CONFIG_SYS_I2C)
 	U_BOOT_CMD_MKENT(dev, 1, 1, do_i2c_bus_num, "", ""),
 #endif  /* CONFIG_I2C_MULTI_BUS */
 	U_BOOT_CMD_MKENT(loop, 3, 1, do_i2c_loop, "", ""),
@@ -1319,11 +1357,11 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 U_BOOT_CMD(
 	i2c, 6, 1, do_i2c,
 	"I2C sub-system",
-#if defined(CONFIG_I2C_MUX)
-	"bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\ni2c "
+#if CONFIG_SYS_NUM_I2C_BUSSES > 1
+	"bus [muxtype:muxaddr:muxchannel] - show I2C bus info\n"
 #endif  /* CONFIG_I2C_MUX */
 	"crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n"
-#if defined(CONFIG_I2C_MULTI_BUS)
+#if CONFIG_SYS_NUM_I2C_BUSSES > 1
 	"i2c dev [dev] - show or set current I2C bus\n"
 #endif  /* CONFIG_I2C_MULTI_BUS */
 	"i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device\n"
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index b66bba2..9a0b4c3 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -49,6 +49,10 @@ static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
 	int old_bus = i2c_get_bus_num();
 
+#if defined(CONFIG_SYS_I2C)
+	if (old_bus != CONFIG_I2C_ENV_EEPROM_BUS)
+		i2c_set_bus_num(CONFIG_I2C_ENV_EEPROM_BUS);
+#else
 	if (gd->flags & GD_FLG_RELOC) {
 		if (env_eeprom_bus == -1) {
 			I2C_MUX_DEVICE *dev = NULL;
@@ -68,11 +72,16 @@ static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
 				(uchar *)CONFIG_I2C_ENV_EEPROM_BUS);
 	}
 #endif
+#endif
 
 	rcode = eeprom_read(dev_addr, offset, buffer, cnt);
 
 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
+#if defined(CONFIG_SYS_I2C)
+	if (old_bus != CONFIG_I2C_ENV_EEPROM_BUS)
+#else
 	if (old_bus != env_eeprom_bus)
+#endif
 		i2c_set_bus_num(old_bus);
 #endif
 	return rcode;
@@ -85,8 +94,13 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned offset,
 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
 	int old_bus = i2c_get_bus_num();
 
+#if defined(CONFIG_SYS_I2C)
+	if (old_bus != CONFIG_I2C_ENV_EEPROM_BUS)
+		i2c_set_bus_num(CONFIG_I2C_ENV_EEPROM_BUS);
+#else
 	rcode = i2c_mux_ident_muxstring_f((uchar *)CONFIG_I2C_ENV_EEPROM_BUS);
 #endif
+#endif
 	rcode = eeprom_write(dev_addr, offset, buffer, cnt);
 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
 	i2c_set_bus_num(old_bus);
diff --git a/common/stdio.c b/common/stdio.c
index 605ff3f..9b2e6b2 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -1,4 +1,8 @@
 /*
+ * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
+ *
+ * Changes for multibus/multiadapter I2C support.
+ *
  * (C) Copyright 2000
  * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio at tin.it
  *
@@ -30,7 +34,8 @@
 #ifdef CONFIG_LOGBUFFER
 #include <logbuff.h>
 #endif
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) \
+		|| defined(CONFIG_SYS_I2C_ADAPTERS)
 #include <i2c.h>
 #endif
 
@@ -211,9 +216,15 @@ int stdio_init (void)
 #ifdef CONFIG_ARM_DCC_MULTI
 	drv_arm_dcc_init ();
 #endif
+#ifdef CONFIG_SYS_I2C
+#ifdef CONFIG_SYS_I2C_ADAPTERS
+	i2c_init_all();
+#endif
+#else
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
+#endif
 #ifdef CONFIG_LCD
 	drv_lcd_init ();
 #endif
diff --git a/include/i2c.h b/include/i2c.h
index 44a05cd..afb4409 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -202,15 +202,6 @@ int i2c_mux_ident_muxstring_f (uchar *buf);
 
 #ifdef CONFIG_SYS_I2C
 /*
- * Initialization, must be called once on start up, may be called
- * repeatedly to change the speed and slave addresses.
- */
-void i2c_init(unsigned int speed, int slaveaddr);
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-void i2c_init_board(void);
-#endif
-
-/*
  * i2c_get_bus_num:
  *
  *  Returns index of currently active I2C bus.  Zero-based.
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 3/3] i2c, soft-i2c: switch to new multibus/multiadapter support
  2012-10-22 17:40 [U-Boot] [PATCH 0/3] Bring in new I2C framework Heiko Schocher
  2012-10-22 17:40 ` [U-Boot] [PATCH 1/3] i2c: add i2c_core and prepare for new multibus support Heiko Schocher
  2012-10-22 17:40 ` [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support Heiko Schocher
@ 2012-10-22 17:40 ` Heiko Schocher
  2012-10-25 21:37 ` [U-Boot] [PATCH 0/3] Bring in new I2C framework Simon Glass
  3 siblings, 0 replies; 25+ messages in thread
From: Heiko Schocher @ 2012-10-22 17:40 UTC (permalink / raw)
  To: u-boot

- added to soft_i2c driver new multibus/multiadpater support
- adapted all config files, which uses this driver

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Simon Glass <sjg@chromium.org>
---
 README                                    |   25 ++++---
 arch/arm/lib/board.c                      |    5 +-
 arch/m68k/lib/board.c                     |    9 +--
 arch/powerpc/lib/board.c                  |   10 +--
 board/BuS/eb_cpux9k2/cpux9k2.c            |    2 +-
 board/BuS/vl_ma2sc/vl_ma2sc.c             |    2 +-
 board/atc/atc.c                           |    2 +-
 board/bluewater/snapper9260/snapper9260.c |    2 +-
 board/cm5200/cm5200.c                     |    4 +-
 board/cpu86/cpu86.c                       |    2 +-
 board/cpu87/cpu87.c                       |    2 +-
 board/emk/top9000/top9000.c               |    8 +-
 board/eukrea/cpuat91/cpuat91.c            |    2 +-
 board/freescale/m52277evb/README          |    2 +-
 board/freescale/m53017evb/README          |    2 +-
 board/freescale/m5373evb/README           |    2 +-
 board/freescale/m54455evb/README          |    2 +-
 board/freescale/m547xevb/README           |    2 +-
 board/ids8247/ids8247.c                   |    2 +-
 board/keymile/common/common.c             |    3 +-
 board/keymile/common/ivm.c                |   15 +++-
 board/keymile/km82xx/km82xx.c             |    2 +-
 board/keymile/km_arm/km_arm.c             |    8 +-
 board/lwmon/lwmon.c                       |    2 +-
 board/lwmon/pcmcia.c                      |    4 +-
 board/pm826/pm826.c                       |    2 +-
 board/pm828/pm828.c                       |    2 +-
 board/sacsng/ioconfig.h                   |    2 +-
 board/sandburst/karef/karef.c             |    1 -
 board/siemens/SCM/scm.c                   |    2 +-
 board/tqc/tqm8260/tqm8260.c               |    2 +-
 board/tqc/tqm8272/tqm8272.c               |    2 +-
 board/tqc/tqm8272/tqm8272.h               |    2 +-
 common/cmd_eeprom.c                       |    3 +-
 common/stdio.c                            |    5 +-
 drivers/i2c/Makefile                      |    2 +-
 drivers/i2c/i2c_core.c                    |    4 +
 drivers/i2c/soft_i2c.c                    |  122 +++++++++++++++++++----------
 include/configs/A3000.h                   |    4 +-
 include/configs/BSC9131RDB.h              |    1 -
 include/configs/CANBT.h                   |    4 +
 include/configs/CPU86.h                   |    9 +-
 include/configs/CPU87.h                   |    9 +-
 include/configs/DU440.h                   |    1 -
 include/configs/GEN860T.h                 |   36 +++++----
 include/configs/HIDDEN_DRAGON.h           |   10 ++-
 include/configs/IAD210.h                  |   12 ++-
 include/configs/ICU862.h                  |   14 ++--
 include/configs/IDS8247.h                 |   10 +-
 include/configs/IP860.h                   |   10 +-
 include/configs/IPHASE4539.h              |   12 +--
 include/configs/JSE.h                     |    1 -
 include/configs/KAREF.h                   |    1 -
 include/configs/KUP4K.h                   |   12 +--
 include/configs/KUP4X.h                   |   14 ++--
 include/configs/M5208EVBE.h               |    1 -
 include/configs/M52277EVB.h               |    1 -
 include/configs/M5235EVB.h                |    1 -
 include/configs/M5271EVB.h                |    1 -
 include/configs/M5275EVB.h                |    1 -
 include/configs/M53017EVB.h               |    1 -
 include/configs/M5329EVB.h                |    1 -
 include/configs/M5373EVB.h                |    1 -
 include/configs/M54451EVB.h               |    1 -
 include/configs/M54455EVB.h               |    1 -
 include/configs/M5475EVB.h                |    1 -
 include/configs/M5485EVB.h                |    1 -
 include/configs/METROBOX.h                |    1 -
 include/configs/MHPC.h                    |    9 +-
 include/configs/MPC8323ERDB.h             |    1 -
 include/configs/MPC832XEMDS.h             |    1 -
 include/configs/MPC8349EMDS.h             |    1 -
 include/configs/MPC8349ITX.h              |    2 -
 include/configs/MPC8360EMDS.h             |    1 -
 include/configs/MPC8360ERDK.h             |    1 -
 include/configs/MPC837XEMDS.h             |    1 -
 include/configs/MPC837XERDB.h             |    1 -
 include/configs/MPC8536DS.h               |    1 -
 include/configs/MPC8540ADS.h              |    1 -
 include/configs/MPC8541CDS.h              |    1 -
 include/configs/MPC8544DS.h               |    1 -
 include/configs/MPC8548CDS.h              |    3 +-
 include/configs/MPC8555CDS.h              |    1 -
 include/configs/MPC8560ADS.h              |    1 -
 include/configs/MPC8568MDS.h              |    1 -
 include/configs/MPC8569MDS.h              |    1 -
 include/configs/MPC8572DS.h               |    1 -
 include/configs/MPC8610HPCD.h             |    1 -
 include/configs/MPC8641HPCN.h             |    1 -
 include/configs/P1010RDB.h                |    1 -
 include/configs/P1023RDS.h                |    1 -
 include/configs/P1_P2_RDB.h               |    1 -
 include/configs/P2020COME.h               |    1 -
 include/configs/PM826.h                   |    9 +-
 include/configs/PM828.h                   |    9 +-
 include/configs/PMC440.h                  |    1 -
 include/configs/R360MPI.h                 |    7 ++-
 include/configs/RPXClassic.h              |   16 +++--
 include/configs/RPXlite.h                 |   26 ++++++
 include/configs/RRvision.h                |   13 +--
 include/configs/SBC8540.h                 |    1 -
 include/configs/SCM.h                     |   11 +--
 include/configs/SXNI855T.h                |    8 +-
 include/configs/Sandpoint8240.h           |   10 ++-
 include/configs/Sandpoint8245.h           |   14 ++-
 include/configs/TASREG.h                  |   27 ++++---
 include/configs/TK885D.h                  |   13 +--
 include/configs/TOP5200.h                 |   15 ++--
 include/configs/TOP860.h                  |   11 ++-
 include/configs/TQM8260.h                 |    9 +-
 include/configs/TQM8272.h                 |   13 ++--
 include/configs/TQM834x.h                 |    1 -
 include/configs/TQM855M.h                 |   13 +--
 include/configs/TQM866M.h                 |   13 +--
 include/configs/TQM885D.h                 |   13 +--
 include/configs/alpr.h                    |    1 -
 include/configs/aria.h                    |    1 -
 include/configs/astro_mcf5373l.h          |    1 -
 include/configs/bf533-ezkit.h             |   10 ++-
 include/configs/bf533-stamp.h             |   47 ++++++++++-
 include/configs/bf561-ezkit.h             |    9 ++-
 include/configs/bfin_adi_common.h         |    2 +-
 include/configs/blackstamp.h              |    1 -
 include/configs/cpuat91.h                 |    1 -
 include/configs/debris.h                  |   10 ++-
 include/configs/eXalion.h                 |    2 +-
 include/configs/eb_cpux9k2.h              |   14 ++--
 include/configs/ep8260.h                  |   14 ++-
 include/configs/ethernut5.h               |    9 ++-
 include/configs/ibf-dsp561.h              |    5 +-
 include/configs/iocon.h                   |   11 ++-
 include/configs/km/keymile-common.h       |    3 -
 include/configs/km/km83xx-common.h        |    3 +
 include/configs/km/km_arm.h               |   26 +++++-
 include/configs/km82xx.h                  |   18 +++-
 include/configs/km_kirkwood.h             |   14 ++--
 include/configs/korat.h                   |    1 -
 include/configs/lwmon.h                   |   13 +--
 include/configs/lwmon5.h                  |    1 -
 include/configs/mecp5123.h                |    1 -
 include/configs/mpc5121ads.h              |    1 -
 include/configs/nhk8815.h                 |    8 ++-
 include/configs/otc570.h                  |   18 ++--
 include/configs/p1_p2_rdb_pc.h            |    1 -
 include/configs/p3p440.h                  |    1 -
 include/configs/pcs440ep.h                |    1 -
 include/configs/pdnb3.h                   |   11 +--
 include/configs/quad100hd.h               |    1 -
 include/configs/s5p_goni.h                |    7 +-
 include/configs/s5pc210_universal.h       |    7 +-
 include/configs/sacsng.h                  |   12 +--
 include/configs/sbc405.h                  |    1 -
 include/configs/sbc8349.h                 |    1 -
 include/configs/sbc8548.h                 |    1 -
 include/configs/sbc8560.h                 |    1 -
 include/configs/sbc8641d.h                |    1 -
 include/configs/sc3.h                     |    1 -
 include/configs/snapper9260.h             |    9 +-
 include/configs/socrates.h                |    1 -
 include/configs/spc1920.h                 |   13 +--
 include/configs/stxgp3.h                  |    1 -
 include/configs/stxssa.h                  |    1 -
 include/configs/top9000.h                 |   10 ++-
 include/configs/trats.h                   |    7 +-
 include/configs/u8500_href.h              |    1 -
 include/configs/uc100.h                   |   13 +--
 include/configs/utx8245.h                 |    3 +-
 include/configs/vct.h                     |   12 ++--
 include/configs/vl_ma2sc.h                |    7 +-
 include/configs/vme8349.h                 |    1 -
 include/configs/zeus.h                    |    1 -
 include/i2c.h                             |    9 ++
 172 files changed, 619 insertions(+), 496 deletions(-)

diff --git a/README b/README
index 634cff4..ded3d86 100644
--- a/README
+++ b/README
@@ -1779,7 +1779,9 @@ The following options need to be configured:
 		with this configuration you have one soft_i2c adapter,
 		and one mpc5xxx i2c adapter.
 
-		No I2C adapters current suppor this new interface.
+		!! Only the soft i2c adapter currently supports this
+		new interface. Other i2c adapters should be converted
+		to it ...
 
 		You need to define for each adapter a speed and a
 		slave address.
@@ -1818,20 +1820,23 @@ The following options need to be configured:
 
 		which defines
 			bus 0 on adapter 0 without a mux
-			bus 1 on adapter 0 without a PCA9547 on address 0x70 port 1
-			bus 2 on adapter 0 without a PCA9547 on address 0x70 port 2
-			bus 3 on adapter 0 without a PCA9547 on address 0x70 port 3
-			bus 4 on adapter 0 without a PCA9547 on address 0x70 port 4
-			bus 5 on adapter 0 without a PCA9547 on address 0x70 port 5
+			bus 1 on adapter 0 with a PCA9547 on address 0x70 port 1
+			bus 2 on adapter 0 with a PCA9547 on address 0x70 port 2
+			bus 3 on adapter 0 with a PCA9547 on address 0x70 port 3
+			bus 4 on adapter 0 with a PCA9547 on address 0x70 port 4
+			bus 5 on adapter 0 with a PCA9547 on address 0x70 port 5
 			bus 6 on adapter 1 without a mux
-			bus 7 on adapter 1 without a PCA9544 on address 0x72 port 1
-			bus 8 on adapter 1 without a PCA9544 on address 0x72 port 2
+			bus 7 on adapter 1 with a PCA9544 on address 0x72 port 1
+			bus 8 on adapter 1 with a PCA9544 on address 0x72 port 2
 
 - Legacy I2C Support:	CONFIG_HARD_I2C | CONFIG_SOFT_I2C
 
 		NOTE: It is intended to move drivers to CONFIG_SYS_I2C which
 		provides the following compelling advantages:
-			1. Heiko to fill in
+
+		- more than one i2c adapter is usable
+		- approved multibus support
+		- better i2c mux support
 
 		** Please consider updating your I2C driver now. **
 
@@ -3222,7 +3227,7 @@ to save the current settings.
 	  I2C muxes, you can define here, how to reach this
 	  EEPROM. For example:
 
-	  #define CONFIG_I2C_ENV_EEPROM_BUS	  "pca9547:70:d\0"
+	  #define CONFIG_I2C_ENV_EEPROM_BUS	  1
 
 	  EEPROM which holds the environment, is reached over
 	  a pca9547 i2c mux with address 0x70, channel 3.
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index b5b53f4..96d7337 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -74,7 +74,6 @@ extern void dataflash_print_info(void);
 #endif
 
 #if defined(CONFIG_HARD_I2C) || \
-	defined(CONFIG_SOFT_I2C) || \
 	defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
@@ -171,7 +170,7 @@ static int display_dram_config(void)
 	return (0);
 }
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 static int init_func_i2c(void)
 {
 	puts("I2C:   ");
@@ -263,7 +262,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_SYS_I2C)
 	init_func_i2c,
 #endif
 	dram_init,		/* configure available RAM banks */
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index ba8c957..6554f74 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -55,8 +55,7 @@
 #include <version.h>
 
 #if defined(CONFIG_HARD_I2C) || \
-	defined(CONFIG_SOFT_I2C) || \
-	defined(CONFIG_SYS_I2C_ADAPTERS)
+	defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
 
@@ -141,8 +140,7 @@ static int init_func_ram (void)
 
 /***********************************************************************/
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) \
-		|| defined(CONFIG_SYS_I2C_ADAPTERS)
+#if defined(CONFIG_HARD_I2C) ||	defined(CONFIG_SYS_I2C)
 static int init_func_i2c (void)
 {
 	puts ("I2C:   ");
@@ -182,8 +180,7 @@ init_fnc_t *init_sequence[] = {
 	display_options,
 	checkcpu,
 	checkboard,
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) \
-		|| defined(CONFIG_SYS_I2C_ADAPTERS)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 	init_func_i2c,
 #endif
 #if defined(CONFIG_HARD_SPI)
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index 0cd3408..fa96975 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -98,9 +98,7 @@ extern void sc3_read_eeprom(void);
 #if defined(CONFIG_CMD_DOC)
 void doc_init(void);
 #endif
-#if defined(CONFIG_HARD_I2C) || \
-	defined(CONFIG_SOFT_I2C) || \
-	defined(CONFIG_SYS_I2C_ADAPTERS)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
 #include <spi.h>
@@ -215,8 +213,7 @@ static int init_func_ram(void)
 
 /***********************************************************************/
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) \
-		|| defined(CONFIG_SYS_I2C_ADAPTERS)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 static int init_func_i2c(void)
 {
 	puts("I2C:   ");
@@ -323,8 +320,7 @@ init_fnc_t *init_sequence[] = {
 	misc_init_f,
 #endif
 	INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) \
-		|| defined(CONFIG_SYS_I2C_ADAPTERS)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 	init_func_i2c,
 #endif
 #if defined(CONFIG_HARD_SPI)
diff --git a/board/BuS/eb_cpux9k2/cpux9k2.c b/board/BuS/eb_cpux9k2/cpux9k2.c
index e98244b..01b4382 100644
--- a/board/BuS/eb_cpux9k2/cpux9k2.c
+++ b/board/BuS/eb_cpux9k2/cpux9k2.c
@@ -288,7 +288,7 @@ int drv_video_init(void)
 }
 #endif
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 
 void i2c_init_board(void)
 {
diff --git a/board/BuS/vl_ma2sc/vl_ma2sc.c b/board/BuS/vl_ma2sc/vl_ma2sc.c
index 84b2060..7e086ee 100644
--- a/board/BuS/vl_ma2sc/vl_ma2sc.c
+++ b/board/BuS/vl_ma2sc/vl_ma2sc.c
@@ -323,7 +323,7 @@ int board_eth_init(bd_t *bis)
 	return rc;
 }
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 void i2c_init_board(void)
 {
 	u32 pin;
diff --git a/board/atc/atc.c b/board/atc/atc.c
index 936c031..c2b5a1f 100644
--- a/board/atc/atc.c
+++ b/board/atc/atc.c
@@ -170,7 +170,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD18 */ {   0,   0,   0,   0,   0,   0   }, /* PD18 */
 	/* PD17 */ {   0,   0,   0,   0,   0,   0   }, /* PD17 */
 	/* PD16 */ {   0,   0,   0,   0,   0,   0   }, /* PD16 */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SDA */
 	/* PD14 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SCL */
 #else
diff --git a/board/bluewater/snapper9260/snapper9260.c b/board/bluewater/snapper9260/snapper9260.c
index 60c55e9..b4378db 100644
--- a/board/bluewater/snapper9260/snapper9260.c
+++ b/board/bluewater/snapper9260/snapper9260.c
@@ -145,7 +145,7 @@ int board_init(void)
 
 	/* Initialise peripherals */
 	at91_seriald_hw_init();
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(0);
 	nand_hw_init();
 	macb_hw_init();
 
diff --git a/board/cm5200/cm5200.c b/board/cm5200/cm5200.c
index b25887b..55157d8 100644
--- a/board/cm5200/cm5200.c
+++ b/board/cm5200/cm5200.c
@@ -326,7 +326,7 @@ int board_early_init_r(void)
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
 	uchar buf[6];
 	char str[18];
 	char hostname[MODULE_NAME_MAXLEN];
@@ -349,7 +349,7 @@ int misc_init_r(void)
 			" device at address %02X:%04X\n", CONFIG_SYS_I2C_EEPROM,
 			CONFIG_MAC_OFFSET);
 	}
-#endif /* defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) */
+#endif /* defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT) */
 	if (!getenv("ethaddr"))
 		printf(LOG_PREFIX "MAC address not set, networking is not "
 					"operational\n");
diff --git a/board/cpu86/cpu86.c b/board/cpu86/cpu86.c
index bc7ebfe..1d4f90c 100644
--- a/board/cpu86/cpu86.c
+++ b/board/cpu86/cpu86.c
@@ -161,7 +161,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD18 */ {   0,   0,   0,   0,   0,   0   }, /* PD18 */
 	/* PD17 */ {   0,   0,   0,   0,   0,   0   }, /* PD17 */
 	/* PD16 */ {   0,   0,   0,   0,   0,   0   }, /* PD16 */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SDA */
 	/* PD14 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SCL */
 #else
diff --git a/board/cpu87/cpu87.c b/board/cpu87/cpu87.c
index 057a34c..7c591be 100644
--- a/board/cpu87/cpu87.c
+++ b/board/cpu87/cpu87.c
@@ -163,7 +163,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD18 */ {   0,   0,   0,   0,   0,   0   }, /* PD18 */
 	/* PD17 */ {   0,   0,   0,   0,   0,   0   }, /* PD17 */
 	/* PD16 */ {   0,   0,   0,   0,   0,   0   }, /* PD16 */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SDA */
 	/* PD14 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SCL */
 #else
diff --git a/board/emk/top9000/top9000.c b/board/emk/top9000/top9000.c
index 86a8d0b..c0609f0 100644
--- a/board/emk/top9000/top9000.c
+++ b/board/emk/top9000/top9000.c
@@ -245,7 +245,7 @@ int board_eth_init(bd_t *bis)
  * However i2c_get_bus_num() cannot be called before
  * relocation.
  */
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 void iic_init(void)
 {
 	/* ports are now initialized in board_early_init_f() */
@@ -253,7 +253,7 @@ void iic_init(void)
 
 int iic_read(void)
 {
-	switch ((gd->flags & GD_FLG_RELOC) ? i2c_get_bus_num() : 0) {
+	switch (I2C_ADAP_HWNR) {
 	case 0:
 		return at91_get_pio_value(I2C0_PORT, SDA0_PIN);
 	case 1:
@@ -264,7 +264,7 @@ int iic_read(void)
 
 void iic_sda(int bit)
 {
-	switch ((gd->flags & GD_FLG_RELOC) ? i2c_get_bus_num() : 0) {
+	switch (I2C_ADAP_HWNR) {
 	case 0:
 		at91_set_pio_value(I2C0_PORT, SDA0_PIN, bit);
 		break;
@@ -276,7 +276,7 @@ void iic_sda(int bit)
 
 void iic_scl(int bit)
 {
-	switch ((gd->flags & GD_FLG_RELOC) ? i2c_get_bus_num() : 0) {
+	switch (I2C_ADAP_HWNR) {
 	case 0:
 		at91_set_pio_value(I2C0_PORT, SCL0_PIN, bit);
 		break;
diff --git a/board/eukrea/cpuat91/cpuat91.c b/board/eukrea/cpuat91/cpuat91.c
index c74c3fc..5dde274 100644
--- a/board/eukrea/cpuat91/cpuat91.c
+++ b/board/eukrea/cpuat91/cpuat91.c
@@ -73,7 +73,7 @@ int board_eth_init(bd_t *bis)
 }
 #endif
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 void i2c_init_board(void)
 {
 	u32 pin;
diff --git a/board/freescale/m52277evb/README b/board/freescale/m52277evb/README
index b6e955b..d5e7b05 100644
--- a/board/freescale/m52277evb/README
+++ b/board/freescale/m52277evb/README
@@ -84,7 +84,7 @@ CONFIG_MCFPIT		-- define to use PIT timer
 
 CONFIG_FSL_I2C		-- define to use FSL common I2C driver
 CONFIG_HARD_I2C		-- define for I2C hardware support
-CONFIG_SOFT_I2C		-- define for I2C bit-banged
+CONFIG_SYS_I2C_SOFT	-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
 CONFIG_SYS_I2C_SLAVE		-- define for I2C slave address
 CONFIG_SYS_I2C_OFFSET		-- define for I2C base address offset
diff --git a/board/freescale/m53017evb/README b/board/freescale/m53017evb/README
index 64a3d42..855bbd1 100644
--- a/board/freescale/m53017evb/README
+++ b/board/freescale/m53017evb/README
@@ -92,7 +92,7 @@ CONFIG_MCFPIT			-- define to use PIT timer
 
 CONFIG_FSL_I2C			-- define to use FSL common I2C driver
 CONFIG_HARD_I2C			-- define for I2C hardware support
-CONFIG_SOFT_I2C			-- define for I2C bit-banged
+CONFIG_SYS_I2C_SOFT		-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
 CONFIG_SYS_I2C_SLAVE		-- define for I2C slave address
 CONFIG_SYS_I2C_OFFSET		-- define for I2C base address offset
diff --git a/board/freescale/m5373evb/README b/board/freescale/m5373evb/README
index 419d4d6..61e6d97 100644
--- a/board/freescale/m5373evb/README
+++ b/board/freescale/m5373evb/README
@@ -91,7 +91,7 @@ CONFIG_MCFPIT		-- define to use PIT timer
 
 CONFIG_FSL_I2C		-- define to use FSL common I2C driver
 CONFIG_HARD_I2C		-- define for I2C hardware support
-CONFIG_SOFT_I2C		-- define for I2C bit-banged
+CONFIG_SYS_I2C_SOFT	-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
 CONFIG_SYS_I2C_SLAVE		-- define for I2C slave address
 CONFIG_SYS_I2C_OFFSET		-- define for I2C base address offset
diff --git a/board/freescale/m54455evb/README b/board/freescale/m54455evb/README
index 2bc6ce4..2b25952 100644
--- a/board/freescale/m54455evb/README
+++ b/board/freescale/m54455evb/README
@@ -114,7 +114,7 @@ CONFIG_MCFPIT		-- define to use PIT timer
 
 CONFIG_FSL_I2C		-- define to use FSL common I2C driver
 CONFIG_HARD_I2C		-- define for I2C hardware support
-CONFIG_SOFT_I2C		-- define for I2C bit-banged
+CONFIG_SYS_I2C_SOFT	-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
 CONFIG_SYS_I2C_SLAVE		-- define for I2C slave address
 CONFIG_SYS_I2C_OFFSET		-- define for I2C base address offset
diff --git a/board/freescale/m547xevb/README b/board/freescale/m547xevb/README
index d3aec20..1a8cbce 100644
--- a/board/freescale/m547xevb/README
+++ b/board/freescale/m547xevb/README
@@ -99,7 +99,7 @@ CONFIG_SLTTMR		-- define to use SLT timer
 
 CONFIG_FSL_I2C		-- define to use FSL common I2C driver
 CONFIG_HARD_I2C		-- define for I2C hardware support
-CONFIG_SOFT_I2C		-- define for I2C bit-banged
+CONFIG_SYS_I2C_SOFT	-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
 CONFIG_SYS_I2C_SLAVE		-- define for I2C slave address
 CONFIG_SYS_I2C_OFFSET		-- define for I2C base address offset
diff --git a/board/ids8247/ids8247.c b/board/ids8247/ids8247.c
index 02db07f..541d7d6 100644
--- a/board/ids8247/ids8247.c
+++ b/board/ids8247/ids8247.c
@@ -51,7 +51,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PA27 */ {   1,   1,	 1,   0,   0,	0   }, /* FCC1 RXDV */
 	/* PA26 */ {   1,   1,	 1,   0,   0,	0   }, /* FCC1 RXER */
 	/* PA25 */ {   0,   0,	 0,   0,   1,	0   }, /* 8247_P0 */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PA24 */ {   1,   0,	 0,   0,   1,	1   }, /* I2C_SDA2 */
 	/* PA23 */ {   1,   0,	 0,   1,   1,	1   }, /* I2C_SCL2 */
 #else /* normal I/O port pins */
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index a90f112..4de2519 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -38,7 +38,8 @@
 #include "post.h"
 #endif
 #include "common.h"
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_ADAPTERS) || defined(CONFIG_HARD_I2C) || \
+	defined(CONFIG_SYS_I2C_SOFT)
 #include <i2c.h>
 #endif
 
diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index eaa924f..e6187a5 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -306,18 +306,22 @@ int ivm_read_eeprom(void)
 	I2C_MUX_DEVICE *dev = NULL;
 #endif
 	uchar i2c_buffer[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
-	uchar	*buf;
+	char	*buf;
 	unsigned long dev_addr = CONFIG_SYS_IVM_EEPROM_ADR;
 	int ret;
 
+#if defined(CONFIG_SYS_I2C)
+	buf = getenv("EEprom_ivm");
+	i2c_set_bus_num(buf ? (int)simple_strtol(buf, NULL, 10) : 0);
+#else
 #if defined(CONFIG_I2C_MUX)
 	/* First init the Bus, select the Bus */
 #if defined(CONFIG_SYS_I2C_IVM_BUS)
 	dev = i2c_mux_ident_muxstring((uchar *)CONFIG_SYS_I2C_IVM_BUS);
 #else
-	buf = (unsigned char *) getenv("EEprom_ivm");
+	buf = getenv("EEprom_ivm");
 	if (buf != NULL)
-		dev = i2c_mux_ident_muxstring(buf);
+		dev = i2c_mux_ident_muxstring((unsigned char *)buf);
 #endif
 	if (dev == NULL) {
 		printf("Error couldnt add Bus for IVM\n");
@@ -325,10 +329,11 @@ int ivm_read_eeprom(void)
 	}
 	i2c_set_bus_num(dev->busid);
 #endif
+#endif /* defined(CONFIG_SYS_I2C) */
 
-	buf = (unsigned char *) getenv("EEprom_ivm_addr");
+	buf = getenv("EEprom_ivm_addr");
 	if (buf != NULL) {
-		ret = strict_strtoul((char *)buf, 16, &dev_addr);
+		ret = strict_strtoul(buf, 16, &dev_addr);
 		if (ret != 0)
 			return -3;
 	}
diff --git a/board/keymile/km82xx/km82xx.c b/board/keymile/km82xx/km82xx.c
index 67b69f6..744d7fc 100644
--- a/board/keymile/km82xx/km82xx.c
+++ b/board/keymile/km82xx/km82xx.c
@@ -31,7 +31,7 @@
 #include <libfdt.h>
 #endif
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
 #include <i2c.h>
 #endif
 
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index 0c4dddc..9c820be 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -63,7 +63,7 @@ u32 kwmpp_config[] = {
 	MPP5_NF_IO7,
 	MPP6_SYSRST_OUTn,
 	MPP7_PEX_RST_OUTn,
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	MPP8_GPIO,		/* SDA */
 	MPP9_GPIO,		/* SCL */
 #endif
@@ -243,7 +243,7 @@ int misc_init_r(void)
 
 int board_early_init_f(void)
 {
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	u32 tmp;
 
 	/* set the 2 bitbang i2c pins as output gpios */
@@ -274,7 +274,7 @@ int board_init(void)
 	kw_gpio_set_valid(KM_FLASH_GPIO_PIN, 1);
 	kw_gpio_direction_output(KM_FLASH_GPIO_PIN, 1);
 
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/*
 	 * Reinit the GPIO for I2C Bitbang driver so that the now
 	 * available gpio framework is consistent. The calls to
@@ -454,7 +454,7 @@ int hush_init_var(void)
 }
 #endif
 
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 void set_sda(int state)
 {
 	I2C_ACTIVE;
diff --git a/board/lwmon/lwmon.c b/board/lwmon/lwmon.c
index b5e524b..3a27637 100644
--- a/board/lwmon/lwmon.c
+++ b/board/lwmon/lwmon.c
@@ -480,7 +480,7 @@ static void kbd_init (void)
 	uchar val, errcd;
 	int i;
 
-	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(0);
 
 	gd->kbd_status = 0;
 
diff --git a/board/lwmon/pcmcia.c b/board/lwmon/pcmcia.c
index acbb9d5..b9894cf 100644
--- a/board/lwmon/pcmcia.c
+++ b/board/lwmon/pcmcia.c
@@ -104,7 +104,7 @@ int pcmcia_hardware_enable(int slot)
 
 	/*  switch VCC on */
 	val |= MAX1604_OP_SUS | MAX1604_VCCBON;
-	i2c_init  (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(0);
 	i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR, 0, 0, &val, 1);
 
 	udelay(500000);
@@ -193,7 +193,7 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
 	 */
 	debug ("PCMCIA power OFF\n");
 	val  = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
-	i2c_init  (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(0);
 	i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR, 0, 0, &val, 1);
 
 	val = 0;
diff --git a/board/pm826/pm826.c b/board/pm826/pm826.c
index 19e7a00..17b4ac9 100644
--- a/board/pm826/pm826.c
+++ b/board/pm826/pm826.c
@@ -169,7 +169,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD18 */ {   0,   0,   0,   1,   0,   0   }, /* PD18 */
 	/* PD17 */ {   0,   1,   0,   0,   0,   0   }, /* PD17 */
 	/* PD16 */ {   0,   1,   0,   1,   0,   0   }, /* PD16 */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SDA */
 	/* PD14 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SCL */
 #else
diff --git a/board/pm828/pm828.c b/board/pm828/pm828.c
index 4a3b2fd..5e68d4d 100644
--- a/board/pm828/pm828.c
+++ b/board/pm828/pm828.c
@@ -169,7 +169,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD18 */ {   0,   0,   0,   1,   0,   0   }, /* PD18 */
 	/* PD17 */ {   0,   1,   0,   0,   0,   0   }, /* PD17 */
 	/* PD16 */ {   0,   1,   0,   1,   0,   0   }, /* PD16 */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SDA */
 	/* PD14 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SCL */
 #else
diff --git a/board/sacsng/ioconfig.h b/board/sacsng/ioconfig.h
index be1ce7c..ac8f152 100644
--- a/board/sacsng/ioconfig.h
+++ b/board/sacsng/ioconfig.h
@@ -187,7 +187,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD17 */ { CONF, SPEC,   1,  DOUT, ACTV,   0   }, /* SPI_MOSI       */
 	/* PD16 */ { CONF, SPEC,   1,  DIN,  ACTV,   0   }, /* SPI_MISO       */
 #endif
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ { CONF, GPIO,   0,  DOUT, OPEN,   1   }, /* I2C_SDA        */
 	/* PD14 */ { CONF, GPIO,   0,  DOUT, ACTV,   1   }, /* I2C_SCL        */
 #else
diff --git a/board/sandburst/karef/karef.c b/board/sandburst/karef/karef.c
index 6457f9b..186998d 100644
--- a/board/sandburst/karef/karef.c
+++ b/board/sandburst/karef/karef.c
@@ -32,7 +32,6 @@
 #include <spd_sdram.h>
 #include <i2c.h>
 #include "../common/sb_common.h"
-#include "../common/ppc440gx_i2c.h"
 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) || \
     defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
 #include <net.h>
diff --git a/board/siemens/SCM/scm.c b/board/siemens/SCM/scm.c
index 461b56e..3319d60 100644
--- a/board/siemens/SCM/scm.c
+++ b/board/siemens/SCM/scm.c
@@ -174,7 +174,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD18 */ {   1,   1,   1,   0,   0,   0   }, /* SPI SPICLK */
 	/* PD17 */ {   1,   1,   1,   0,   0,   0   }, /* SPI SPIMOSI */
 	/* PD16 */ {   1,   1,   1,   0,   0,   0   }, /* SPI SPIMOSO */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SDA */
 	/* PD14 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SCL */
 #else
diff --git a/board/tqc/tqm8260/tqm8260.c b/board/tqc/tqm8260/tqm8260.c
index 65a3174..867b969 100644
--- a/board/tqc/tqm8260/tqm8260.c
+++ b/board/tqc/tqm8260/tqm8260.c
@@ -160,7 +160,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD18 */ {   0,   0,   0,   1,   0,   0   }, /* PD19 */
 	/* PD17 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXPRTY */
 	/* PD16 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXPRTY */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SDA */
 	/* PD14 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SCL */
 #else
diff --git a/board/tqc/tqm8272/tqm8272.c b/board/tqc/tqm8272/tqm8272.c
index 5aca227..c874a7d 100644
--- a/board/tqc/tqm8272/tqm8272.c
+++ b/board/tqc/tqm8272/tqm8272.c
@@ -180,7 +180,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
 	/* PD18 */ {   0,   0,	 0,   1,   0,	0   }, /* PD19 */
 	/* PD17 */ {   0,   1,	 0,   0,   0,	0   }, /* FCC1 ATMRXPRTY */
 	/* PD16 */ {   0,   1,	 0,   1,   0,	0   }, /* FCC1 ATMTXPRTY */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
 	/* PD15 */ {   1,   0,	 0,   1,   1,	1   }, /* I2C SDA */
 	/* PD14 */ {   1,   0,	 0,   1,   1,	1   }, /* I2C SCL */
 #else
diff --git a/board/tqc/tqm8272/tqm8272.h b/board/tqc/tqm8272/tqm8272.h
index 6d558ec..91b86c9 100644
--- a/board/tqc/tqm8272/tqm8272.h
+++ b/board/tqc/tqm8272/tqm8272.h
@@ -50,4 +50,4 @@ typedef struct{
 
 static HWIB_INFO	hwinf = {0, 0, 1, 0, 1, 0, 0, 0, 0, 8272, 0 ,0,
 			 0, 0, 0, 0, 0, 0};
-#endif
+#endif	/* __CONFIG_H */
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 4a43116..511d8b6 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -406,8 +406,7 @@ void eeprom_init  (void)
 #if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 	spi_init_f ();
 #endif
-#if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
 }
diff --git a/common/stdio.c b/common/stdio.c
index 9b2e6b2..b083376 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -34,8 +34,7 @@
 #ifdef CONFIG_LOGBUFFER
 #include <logbuff.h>
 #endif
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) \
-		|| defined(CONFIG_SYS_I2C_ADAPTERS)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
 
@@ -221,7 +220,7 @@ int stdio_init (void)
 	i2c_init_all();
 #endif
 #else
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C)
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
 #endif
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 6373306..3e69270 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -40,13 +40,13 @@ COBJS-$(CONFIG_PCA9564_I2C) += pca9564_i2c.o
 COBJS-$(CONFIG_PPC4XX_I2C) += ppc4xx_i2c.o
 COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
 COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
-COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
 COBJS-$(CONFIG_TEGRA_I2C) += tegra_i2c.o
 COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
 COBJS-$(CONFIG_U8500_I2C) += u8500_i2c.o
 COBJS-$(CONFIG_SH_I2C) += sh_i2c.o
 COBJS-$(CONFIG_SH_SH7734_I2C) += sh_sh7734_i2c.o
 COBJS-$(CONFIG_SYS_I2C) += i2c_core.o
+COBJS-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
index cdb6a06..5a738d5 100644
--- a/drivers/i2c/i2c_core.c
+++ b/drivers/i2c/i2c_core.c
@@ -6,6 +6,10 @@
 #include <common.h>
 #include <i2c.h>
 
+#ifdef CONFIG_SYS_I2C_SOFT
+extern struct i2c_adapter soft_i2c_adap[];
+#endif
+
 struct i2c_adapter *i2c_adap[CONFIG_SYS_NUM_I2C_ADAPTERS] =
 			CONFIG_SYS_I2C_ADAPTERS;
 
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index 36c6114..a011e4c 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -1,4 +1,8 @@
 /*
+ * (C) Copyright 2009
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ * Changes for multibus/multiadapter I2C support.
+ *
  * (C) Copyright 2001, 2002
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
  *
@@ -103,14 +107,30 @@
 
 /* #define	DEBUG_I2C	*/
 
-#ifdef DEBUG_I2C
 DECLARE_GLOBAL_DATA_PTR;
+
+#ifndef	I2C_SOFT_DECLARATIONS
+# if defined(CONFIG_MPC8260)
+#  define I2C_SOFT_DECLARATIONS volatile ioport_t *iop = \
+		ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT);
+# elif defined(CONFIG_8xx)
+#  define I2C_SOFT_DECLARATIONS	volatile immap_t *immr = \
+		(immap_t *)CONFIG_SYS_IMMR;
+# else
+#  define I2C_SOFT_DECLARATIONS
+# endif
+#endif
+
+#if !defined(CONFIG_SYS_SOFT_I2C_SPEED)
+#define CONFIG_SYS_SOFT_I2C_SPEED CONFIG_SYS_I2C_SPEED
+#endif
+#if !defined(CONFIG_SYS_SOFT_I2C_SLAVE)
+#define CONFIG_SYS_SOFT_I2C_SLAVE CONFIG_SYS_I2C_SLAVE
 #endif
 
 /*-----------------------------------------------------------------------
  * Definitions
  */
-
 #define RETRIES		0
 
 #define I2C_ACK		0		/* PD_SDA level to ack a byte */
@@ -125,10 +145,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define PRINTD(fmt,args...)
 #endif
 
-#if defined(CONFIG_I2C_MULTI_BUS)
-static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
-#endif /* CONFIG_I2C_MULTI_BUS */
-
 /*-----------------------------------------------------------------------
  * Local functions
  */
@@ -267,39 +283,6 @@ static int write_byte(uchar data)
 	return(nack);	/* not a nack is an ack */
 }
 
-#if defined(CONFIG_I2C_MULTI_BUS)
-/*
- * Functions for multiple I2C bus handling
- */
-unsigned int i2c_get_bus_num(void)
-{
-	return i2c_bus_num;
-}
-
-int i2c_set_bus_num(unsigned int bus)
-{
-#if defined(CONFIG_I2C_MUX)
-	if (bus < CONFIG_SYS_MAX_I2C_BUS) {
-		i2c_bus_num = bus;
-	} else {
-		int	ret;
-
-		ret = i2x_mux_select_mux(bus);
-		i2c_init_board();
-		if (ret == 0)
-			i2c_bus_num = bus;
-		else
-			return ret;
-	}
-#else
-	if (bus >= CONFIG_SYS_MAX_I2C_BUS)
-		return -1;
-	i2c_bus_num = bus;
-#endif
-	return 0;
-}
-#endif
-
 /*-----------------------------------------------------------------------
  * if ack == I2C_ACK, ACK the byte so can continue reading, else
  * send I2C_NOACK to end the read.
@@ -337,7 +320,7 @@ static uchar read_byte(int ack)
 /*-----------------------------------------------------------------------
  * Initialization
  */
-void i2c_init (int speed, int slaveaddr)
+void soft_i2c_init(int speed, int slaveaddr)
 {
 #if defined(CONFIG_SYS_I2C_INIT_BOARD)
 	/* call board specific i2c bus reset routine before accessing the   */
@@ -360,7 +343,7 @@ void i2c_init (int speed, int slaveaddr)
  * completion of EEPROM writes since the chip stops responding until
  * the write completes (typically 10mSec).
  */
-int i2c_probe(uchar addr)
+int soft_i2c_probe(uint8_t addr)
 {
 	int rc;
 
@@ -378,7 +361,7 @@ int i2c_probe(uchar addr)
 /*-----------------------------------------------------------------------
  * Read bytes
  */
-int  i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
+int  soft_i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
 	int shift;
 	PRINTD("i2c_read: chip %02X addr %02X alen %d buffer %p len %d\n",
@@ -452,7 +435,7 @@ int  i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 /*-----------------------------------------------------------------------
  * Write bytes
  */
-int  i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
+int  soft_i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
 	int shift, failures = 0;
 
@@ -482,3 +465,56 @@ int  i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 	send_stop();
 	return(failures);
 }
+
+struct i2c_adapter soft_i2c_adap[] = {
+	{
+		.init		=	soft_i2c_init,
+		.probe		=	soft_i2c_probe,
+		.read		=	soft_i2c_read,
+		.write		=	soft_i2c_write,
+		.speed		=	CONFIG_SYS_I2C_SOFT_SPEED,
+		.slaveaddr	=	CONFIG_SYS_I2C_SOFT_SLAVE,
+		.init_done	=	0,
+		.hwadapnr	=	0,
+		.name		=	"soft-i2c"
+	},
+#if defined(I2C_SOFT_DECLARATIONS2)
+	{
+		.init		=	soft_i2c_init,
+		.probe		=	soft_i2c_probe,
+		.read		=	soft_i2c_read,
+		.write		=	soft_i2c_write,
+		.speed		=	CONFIG_SYS_I2C_SOFT_SPEED_2,
+		.slaveaddr	=	CONFIG_SYS_I2C_SOFT_SLAVE_2,
+		.init_done	=	0,
+		.hwadapnr	=	1,
+		.name		=	"soft-i2c#2"
+	},
+#endif
+#if defined(I2C_SOFT_DECLARATIONS3)
+	{
+		.init		=	soft_i2c_init,
+		.probe		=	soft_i2c_probe,
+		.read		=	soft_i2c_read,
+		.write		=	soft_i2c_write,
+		.speed		=	CONFIG_SYS_I2C_SOFT_SPEED_3,
+		.slaveaddr	=	CONFIG_SYS_I2C_SOFT_SLAVE_3,
+		.init_done	=	0,
+		.hwadapnr	=	2,
+		.name		=	"soft-i2c#3"
+	},
+#endif
+#if defined(I2C_SOFT_DECLARATIONS4)
+	{
+		.init		=	soft_i2c_init,
+		.probe		=	soft_i2c_probe,
+		.read		=	soft_i2c_read,
+		.write		=	soft_i2c_write,
+		.speed		=	CONFIG_SYS_I2C_SOFT_SPEED_4,
+		.slaveaddr	=	CONFIG_SYS_I2C_SOFT_SLAVE_4,
+		.init_done	=	0,
+		.hwadapnr	=	3,
+		.name		=	"soft-i2c#4"
+	},
+#endif
+};
diff --git a/include/configs/A3000.h b/include/configs/A3000.h
index b85244a..848a93d 100644
--- a/include/configs/A3000.h
+++ b/include/configs/A3000.h
@@ -86,8 +86,8 @@
  * PCI stuff
  *-----------------------------------------------------------------------
  */
-#define CONFIG_HARD_I2C		1		/* To enable I2C support	*/
-#undef	CONFIG_SOFT_I2C				/* I2C bit-banged		*/
+#define CONFIG_HARD_I2C		1		/* To enable I2C support */
+#undef	CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 
diff --git a/include/configs/BSC9131RDB.h b/include/configs/BSC9131RDB.h
index fd076e0..134cd7b 100644
--- a/include/configs/BSC9131RDB.h
+++ b/include/configs/BSC9131RDB.h
@@ -241,7 +241,6 @@ extern unsigned long get_sdram_size(void);
 
 #define CONFIG_FSL_I2C			/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C			/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_I2C_CMD_TREE
 #define CONFIG_SYS_I2C_SPEED		400000 /* I2C speed and slave address*/
diff --git a/include/configs/CANBT.h b/include/configs/CANBT.h
index be9238e..d36cc89 100644
--- a/include/configs/CANBT.h
+++ b/include/configs/CANBT.h
@@ -180,6 +180,10 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
+#if 0 /* Does not appear to be used?!  If it is used, needs to be fixed */
+#define CONFIG_SYS_I2C_SOFT		/* Software I2C support enabled */
+#endif
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
 #define CONFIG_HARD_I2C			/* I2C with hardware support */
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
diff --git a/include/configs/CPU86.h b/include/configs/CPU86.h
index 7ac182f..0a32523 100644
--- a/include/configs/CPU86.h
+++ b/include/configs/CPU86.h
@@ -129,10 +129,11 @@
 /*-----------------------------------------------------------------------
  * I2C/EEPROM/RTC configuration
  */
-#define	CONFIG_SOFT_I2C			/* Software I2C support enabled	*/
-
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/CPU87.h b/include/configs/CPU87.h
index aa5ce29..516529b 100644
--- a/include/configs/CPU87.h
+++ b/include/configs/CPU87.h
@@ -133,10 +133,11 @@
 /*-----------------------------------------------------------------------
  * I2C/EEPROM/RTC configuration
  */
-#define CONFIG_SOFT_I2C			/* Software I2C support enabled */
-
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/DU440.h b/include/configs/DU440.h
index bbe2713..09876f5 100644
--- a/include/configs/DU440.h
+++ b/include/configs/DU440.h
@@ -171,7 +171,6 @@
  * I2C
  */
 #define CONFIG_HARD_I2C		1	/* I2C with hardware support    */
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged	        */
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address  */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/GEN860T.h b/include/configs/GEN860T.h
index b98cacc..d281bad 100644
--- a/include/configs/GEN860T.h
+++ b/include/configs/GEN860T.h
@@ -163,26 +163,30 @@
 /*
  * Enable I2C and select the hardware/software driver
  */
-#define CONFIG_HARD_I2C		1				/* CPM based I2C			*/
-#undef	CONFIG_SOFT_I2C						/* Bit-banged I2C			*/
+#define CONFIG_HARD_I2C		1		/* CPM based I2C */
+#undef	CONFIG_SYS_I2C_SOFT			/* Bit-banged I2C */
 
 #ifdef CONFIG_HARD_I2C
-#define	CONFIG_SYS_I2C_SPEED		100000			/* clock speed in Hz		*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE			/* I2C slave address		*/
+#define	CONFIG_SYS_I2C_SPEED		100000	/* clock speed in Hz */
+#define CONFIG_SYS_I2C_SLAVE		0xFE	/* I2C slave address */
 #endif
 
-#ifdef CONFIG_SOFT_I2C
-#define PB_SCL				0x00000020		/* PB 26					*/
-#define PB_SDA				0x00000010		/* PB 27					*/
-#define I2C_INIT			(immr->im_cpm.cp_pbdir |=  PB_SCL)
-#define I2C_ACTIVE			(immr->im_cpm.cp_pbdir |=  PB_SDA)
-#define I2C_TRISTATE		(immr->im_cpm.cp_pbdir &= ~PB_SDA)
-#define I2C_READ			((immr->im_cpm.cp_pbdat & PB_SDA) != 0)
-#define I2C_SDA(bit)		if(bit) immr->im_cpm.cp_pbdat |=  PB_SDA; \
-								else    immr->im_cpm.cp_pbdat &= ~PB_SDA
-#define I2C_SCL(bit)		if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
-								else    immr->im_cpm.cp_pbdat &= ~PB_SCL
-#define I2C_DELAY			udelay(5)		/* 1/4 I2C clock duration	*/
+#ifdef CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+#define PB_SCL		0x00000020		/* PB 26 */
+#define PB_SDA		0x00000010		/* PB 27 */
+#define I2C_INIT	(immr->im_cpm.cp_pbdir |=  PB_SCL)
+#define I2C_ACTIVE	(immr->im_cpm.cp_pbdir |=  PB_SDA)
+#define I2C_TRISTATE	(immr->im_cpm.cp_pbdir &= ~PB_SDA)
+#define I2C_READ	((immr->im_cpm.cp_pbdat & PB_SDA) != 0)
+#define I2C_SDA(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SDA; \
+				else    immr->im_cpm.cp_pbdat &= ~PB_SDA
+#define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
+				else    immr->im_cpm.cp_pbdat &= ~PB_SCL
+#define I2C_DELAY	udelay(5) /* 1/4 I2C clock duration */
 #endif
 
 /*
diff --git a/include/configs/HIDDEN_DRAGON.h b/include/configs/HIDDEN_DRAGON.h
index a62ef63..3e13dce 100644
--- a/include/configs/HIDDEN_DRAGON.h
+++ b/include/configs/HIDDEN_DRAGON.h
@@ -168,12 +168,16 @@
  * configuration items that the driver uses to drive the port pins.
  */
 #define CONFIG_HARD_I2C		1		/* To enable I2C support	*/
-#undef	CONFIG_SOFT_I2C				/* I2C bit-banged		*/
+#undef	CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 #error "Soft I2C is not configured properly.  Please review!"
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define I2C_PORT		3		/* Port A=0, B=1, C=2, D=3 */
 #define I2C_ACTIVE		(iop->pdir |=  0x00010000)
 #define I2C_TRISTATE		(iop->pdir &= ~0x00010000)
@@ -183,7 +187,7 @@
 #define I2C_SCL(bit)		if(bit) iop->pdat |=  0x00020000; \
 				else	iop->pdat &= ~0x00020000
 #define I2C_DELAY		udelay(5)	/* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
+#endif /* CONFIG_SYS_I2C_SOFT */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57		/* EEPROM IS24C02		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1		/* Bytes of address		*/
diff --git a/include/configs/IAD210.h b/include/configs/IAD210.h
index 94b05dc..7e15c1c 100644
--- a/include/configs/IAD210.h
+++ b/include/configs/IAD210.h
@@ -111,11 +111,11 @@
 #define CONFIG_DOS_PARTITION
 
 /* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support    */
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged               */
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xDD
-# define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xDD
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -134,6 +134,8 @@
 
 #define	CONFIG_RTC_MPC8xx		/* use internal RTC of MPC8xx	*/
 
+#define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
+
 
 /*
  * Command line configuration.
diff --git a/include/configs/ICU862.h b/include/configs/ICU862.h
index 81f219c..2bbe559 100644
--- a/include/configs/ICU862.h
+++ b/include/configs/ICU862.h
@@ -106,12 +106,11 @@
 #define CONFIG_DOS_PARTITION
 
 /* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
-# define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
-# define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -133,6 +132,9 @@
 
 #define	CONFIG_RTC_MPC8xx		/* use internal RTC of MPC8xx	*/
 
+#define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address */
+
 
 /*
  * Command line configuration.
diff --git a/include/configs/IDS8247.h b/include/configs/IDS8247.h
index 6d0937f..71ee069 100644
--- a/include/configs/IDS8247.h
+++ b/include/configs/IDS8247.h
@@ -73,11 +73,11 @@
 #define CONFIG_MISC_INIT_R	1
 
 /* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/IP860.h b/include/configs/IP860.h
index 2379718..9bd9fbf 100644
--- a/include/configs/IP860.h
+++ b/include/configs/IP860.h
@@ -62,8 +62,11 @@
 
 
 /* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -80,9 +83,6 @@
 			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(5)	/* 1/4 I2C clock duration */
 
-
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
 # define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM X24C16		*/
 # define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* bytes of address		*/
 /* mask of address bits that overflow into the "EEPROM chip address"    */
diff --git a/include/configs/IPHASE4539.h b/include/configs/IPHASE4539.h
index 6dd9812..0f8c4d6 100644
--- a/include/configs/IPHASE4539.h
+++ b/include/configs/IPHASE4539.h
@@ -110,15 +110,14 @@
  * If the software driver is chosen, there are some additional
  * configuration items that the driver uses to drive the port pins.
  */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
-#ifdef CONFIG_SOFT_I2C
 #define I2C_PORT	3		/* Port A=0, B=1, C=2, D=3 */
 #define I2C_ACTIVE	(iop->pdir |=  0x00010000)
 #define I2C_TRISTATE	(iop->pdir &= ~0x00010000)
@@ -128,7 +127,6 @@
 #define I2C_SCL(bit)	if(bit) iop->pdat |=  0x00020000; \
 			else    iop->pdat &= ~0x00020000
 #define I2C_DELAY	udelay(5)	/* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
 
 
 /*
diff --git a/include/configs/JSE.h b/include/configs/JSE.h
index e0a0d8e..713dcca 100644
--- a/include/configs/JSE.h
+++ b/include/configs/JSE.h
@@ -211,7 +211,6 @@
 #define CONFIG_SYS_HZ		1000		/* decrementer freq: 1 ms ticks */
 
 #define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/KAREF.h b/include/configs/KAREF.h
index 546e28b..f8da14d 100644
--- a/include/configs/KAREF.h
+++ b/include/configs/KAREF.h
@@ -134,7 +134,6 @@
  * I2C
  *----------------------------------------------------------------------*/
 #define CONFIG_HARD_I2C	      1		     /* I2C hardware support	*/
-#undef	CONFIG_SOFT_I2C			     /* I2C !bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED	      400000	     /* I2C speed 400kHz	*/
 #define CONFIG_SYS_I2C_SLAVE	      0x7F	     /* I2C slave address	*/
diff --git a/include/configs/KUP4K.h b/include/configs/KUP4K.h
index c0035e6..0ac2789 100644
--- a/include/configs/KUP4K.h
+++ b/include/configs/KUP4K.h
@@ -106,13 +106,12 @@
 /*
  * enable I2C and select the hardware/software driver
  */
-#undef	CONFIG_HARD_I2C		/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C		/* I2C bit-banged		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 
-#define CONFIG_SYS_I2C_SPEED	93000	/* 93 kHz is supposed to work */
-#define CONFIG_SYS_I2C_SLAVE	0xFE
-
-#ifdef CONFIG_SOFT_I2C
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -128,7 +127,6 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(2)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
 
 /*-----------------------------------------------------------------------
  * I2C Configuration
diff --git a/include/configs/KUP4X.h b/include/configs/KUP4X.h
index 5084ccc..a0adf04 100644
--- a/include/configs/KUP4X.h
+++ b/include/configs/KUP4X.h
@@ -114,13 +114,13 @@
 /*
  * enable I2C and select the hardware/software driver
  */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C         1	/* I2C bit-banged		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
 
-#define CONFIG_SYS_I2C_SPEED		93000	/* 93 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -136,7 +136,7 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(2)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
+#endif	/* CONFIG_SYS_I2C_SOFT */
 
 
 /*-----------------------------------------------------------------------
diff --git a/include/configs/M5208EVBE.h b/include/configs/M5208EVBE.h
index a1eaeff..209c122 100644
--- a/include/configs/M5208EVBE.h
+++ b/include/configs/M5208EVBE.h
@@ -84,7 +84,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C			/* I2C with hw support */
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x58000
diff --git a/include/configs/M52277EVB.h b/include/configs/M52277EVB.h
index e4dea05..b1bdac2 100644
--- a/include/configs/M52277EVB.h
+++ b/include/configs/M52277EVB.h
@@ -147,7 +147,6 @@
 /* I2c */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged               */
 #define CONFIG_SYS_I2C_SPEED		80000	/* I2C speed and slave address  */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x58000
diff --git a/include/configs/M5235EVB.h b/include/configs/M5235EVB.h
index 733aece..dfc2ddf 100644
--- a/include/configs/M5235EVB.h
+++ b/include/configs/M5235EVB.h
@@ -101,7 +101,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hw support */
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x00000300
diff --git a/include/configs/M5271EVB.h b/include/configs/M5271EVB.h
index a5913df..e8a8998 100644
--- a/include/configs/M5271EVB.h
+++ b/include/configs/M5271EVB.h
@@ -111,7 +111,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hw support */
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x00000300
diff --git a/include/configs/M5275EVB.h b/include/configs/M5275EVB.h
index 9c2a3bb..fbf0c9d 100644
--- a/include/configs/M5275EVB.h
+++ b/include/configs/M5275EVB.h
@@ -111,7 +111,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hw support */
-#undef CONFIG_SOFT_I2C
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x00000300
diff --git a/include/configs/M53017EVB.h b/include/configs/M53017EVB.h
index 896d0d8..bedba2b 100644
--- a/include/configs/M53017EVB.h
+++ b/include/configs/M53017EVB.h
@@ -103,7 +103,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C			/* I2C with hw support */
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x58000
diff --git a/include/configs/M5329EVB.h b/include/configs/M5329EVB.h
index 64f8302..06fa57c 100644
--- a/include/configs/M5329EVB.h
+++ b/include/configs/M5329EVB.h
@@ -97,7 +97,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C			/* I2C with hw support */
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x58000
diff --git a/include/configs/M5373EVB.h b/include/configs/M5373EVB.h
index 4437bba..faa4f86 100644
--- a/include/configs/M5373EVB.h
+++ b/include/configs/M5373EVB.h
@@ -97,7 +97,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hw support */
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x58000
diff --git a/include/configs/M54451EVB.h b/include/configs/M54451EVB.h
index 6552f69..5dbe0b4 100644
--- a/include/configs/M54451EVB.h
+++ b/include/configs/M54451EVB.h
@@ -158,7 +158,6 @@
 /* I2c */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged               */
 #define CONFIG_SYS_I2C_SPEED		80000	/* I2C speed and slave address  */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x58000
diff --git a/include/configs/M54455EVB.h b/include/configs/M54455EVB.h
index 1bc2c5a..8eeda74 100644
--- a/include/configs/M54455EVB.h
+++ b/include/configs/M54455EVB.h
@@ -191,7 +191,6 @@
 /* I2c */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged               */
 #define CONFIG_SYS_I2C_SPEED		80000	/* I2C speed and slave address  */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x58000
diff --git a/include/configs/M5475EVB.h b/include/configs/M5475EVB.h
index 3bdb867..6e9cba0 100644
--- a/include/configs/M5475EVB.h
+++ b/include/configs/M5475EVB.h
@@ -122,7 +122,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hw support */
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x00008F00
diff --git a/include/configs/M5485EVB.h b/include/configs/M5485EVB.h
index 3487e49..24f28e0 100644
--- a/include/configs/M5485EVB.h
+++ b/include/configs/M5485EVB.h
@@ -119,7 +119,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C		/* I2C with hw support */
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x00008F00
diff --git a/include/configs/METROBOX.h b/include/configs/METROBOX.h
index 286f869..7556ad5 100644
--- a/include/configs/METROBOX.h
+++ b/include/configs/METROBOX.h
@@ -196,7 +196,6 @@
  * I2C
  *----------------------------------------------------------------------*/
 #define CONFIG_HARD_I2C	      1		     /* I2C hardware support	*/
-#undef	CONFIG_SOFT_I2C			     /* I2C !bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED	      400000	     /* I2C speed 400kHz	*/
 #define CONFIG_SYS_I2C_SLAVE	      0x7F	     /* I2C slave address	*/
diff --git a/include/configs/MHPC.h b/include/configs/MHPC.h
index 3ff36ad..d252b77 100644
--- a/include/configs/MHPC.h
+++ b/include/configs/MHPC.h
@@ -73,8 +73,11 @@
 #undef	CONFIG_UCODE_PATCH
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -91,8 +94,6 @@
 			else	immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(5)	/* 1/4 I2C clock duration */
 
-#define CONFIG_SYS_I2C_SPEED			50000
-#define CONFIG_SYS_I2C_SLAVE			0xFE
 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x50	/* EEPROM X24C04		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1	/* bytes of address		*/
 /* mask of address bits that overflow into the "EEPROM chip address"	*/
diff --git a/include/configs/MPC8323ERDB.h b/include/configs/MPC8323ERDB.h
index 8d5ed0f..0e7e5ad 100644
--- a/include/configs/MPC8323ERDB.h
+++ b/include/configs/MPC8323ERDB.h
@@ -234,7 +234,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE	0x7F
diff --git a/include/configs/MPC832XEMDS.h b/include/configs/MPC832XEMDS.h
index f592d3a..0b72a26 100644
--- a/include/configs/MPC832XEMDS.h
+++ b/include/configs/MPC832XEMDS.h
@@ -327,7 +327,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE	0x7F
diff --git a/include/configs/MPC8349EMDS.h b/include/configs/MPC8349EMDS.h
index e5529c7..5e0f54f 100644
--- a/include/configs/MPC8349EMDS.h
+++ b/include/configs/MPC8349EMDS.h
@@ -355,7 +355,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
diff --git a/include/configs/MPC8349ITX.h b/include/configs/MPC8349ITX.h
index 2c3f1f6..9a46fb0 100644
--- a/include/configs/MPC8349ITX.h
+++ b/include/configs/MPC8349ITX.h
@@ -131,8 +131,6 @@
 #define I2C_8574_PCI66		0x20	/* 0=33MHz PCI, 1=66MHz PCI */
 #define I2C_8574_FLASHSIDE	0x40	/* 0=Reset vector from U4, 1=from U7*/
 
-#undef CONFIG_SOFT_I2C
-
 #endif
 
 /* Compact Flash */
diff --git a/include/configs/MPC8360EMDS.h b/include/configs/MPC8360EMDS.h
index a1fbd5e..e2ae65a 100644
--- a/include/configs/MPC8360EMDS.h
+++ b/include/configs/MPC8360EMDS.h
@@ -424,7 +424,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE	0x7F
diff --git a/include/configs/MPC8360ERDK.h b/include/configs/MPC8360ERDK.h
index fc00952..971a3e0 100644
--- a/include/configs/MPC8360ERDK.h
+++ b/include/configs/MPC8360ERDK.h
@@ -288,7 +288,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
diff --git a/include/configs/MPC837XEMDS.h b/include/configs/MPC837XEMDS.h
index 8243661..95ea116 100644
--- a/include/configs/MPC837XEMDS.h
+++ b/include/configs/MPC837XEMDS.h
@@ -342,7 +342,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_SYS_I2C_SPEED	400000 /* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE	0x7F
diff --git a/include/configs/MPC837XERDB.h b/include/configs/MPC837XERDB.h
index 9ad7e3a..b9f437d 100644
--- a/include/configs/MPC837XERDB.h
+++ b/include/configs/MPC837XERDB.h
@@ -368,7 +368,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_SYS_I2C_SPEED	400000 /* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE	0x7F
diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h
index bcd77b6..c47281f 100644
--- a/include/configs/MPC8536DS.h
+++ b/include/configs/MPC8536DS.h
@@ -435,7 +435,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/MPC8540ADS.h b/include/configs/MPC8540ADS.h
index a0fe15e..aca41e6 100644
--- a/include/configs/MPC8540ADS.h
+++ b/include/configs/MPC8540ADS.h
@@ -261,7 +261,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES        {0x69}	/* Don't probe these addrs */
diff --git a/include/configs/MPC8541CDS.h b/include/configs/MPC8541CDS.h
index a6bea15..d2a4f78 100644
--- a/include/configs/MPC8541CDS.h
+++ b/include/configs/MPC8541CDS.h
@@ -284,7 +284,6 @@ extern unsigned long get_clock_freq(void);
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES        {0x69}	/* Don't probe these addrs */
diff --git a/include/configs/MPC8544DS.h b/include/configs/MPC8544DS.h
index 83b8668..57fefb3 100644
--- a/include/configs/MPC8544DS.h
+++ b/include/configs/MPC8544DS.h
@@ -233,7 +233,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 /* I2C */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h
index 0e22cc7..aa5c0c9 100644
--- a/include/configs/MPC8548CDS.h
+++ b/include/configs/MPC8548CDS.h
@@ -359,8 +359,7 @@ extern unsigned long get_clock_freq(void);
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C_SPEED		400000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES	{0x69}	/* Don't probe these addrs */
 #define CONFIG_SYS_I2C_OFFSET		0x3000
diff --git a/include/configs/MPC8555CDS.h b/include/configs/MPC8555CDS.h
index 266cb54..32a375f 100644
--- a/include/configs/MPC8555CDS.h
+++ b/include/configs/MPC8555CDS.h
@@ -282,7 +282,6 @@ extern unsigned long get_clock_freq(void);
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES        {0x69}	/* Don't probe these addrs */
diff --git a/include/configs/MPC8560ADS.h b/include/configs/MPC8560ADS.h
index 35d15f4..b8c657c 100644
--- a/include/configs/MPC8560ADS.h
+++ b/include/configs/MPC8560ADS.h
@@ -255,7 +255,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES        {0x69}	/* Don't probe these addrs */
diff --git a/include/configs/MPC8568MDS.h b/include/configs/MPC8568MDS.h
index 5d69fb6..31d83d3 100644
--- a/include/configs/MPC8568MDS.h
+++ b/include/configs/MPC8568MDS.h
@@ -267,7 +267,6 @@ extern unsigned long get_clock_freq(void);
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x52
diff --git a/include/configs/MPC8569MDS.h b/include/configs/MPC8569MDS.h
index acd3276..40c8dd9 100644
--- a/include/configs/MPC8569MDS.h
+++ b/include/configs/MPC8569MDS.h
@@ -303,7 +303,6 @@ extern unsigned long get_clock_freq(void);
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE	0x7F
diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h
index a62b7d5..fdf9f4b 100644
--- a/include/configs/MPC8572DS.h
+++ b/include/configs/MPC8572DS.h
@@ -432,7 +432,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57
diff --git a/include/configs/MPC8610HPCD.h b/include/configs/MPC8610HPCD.h
index c619827..27f825f 100644
--- a/include/configs/MPC8610HPCD.h
+++ b/include/configs/MPC8610HPCD.h
@@ -253,7 +253,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES	{0x69}	/* Don't probe these addrs */
diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h
index 2643097..3323c8d 100644
--- a/include/configs/MPC8641HPCN.h
+++ b/include/configs/MPC8641HPCN.h
@@ -300,7 +300,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES	{0x69}	/* Don't probe these addrs */
diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h
index 57aef21..ad2738b 100644
--- a/include/configs/P1010RDB.h
+++ b/include/configs/P1010RDB.h
@@ -477,7 +477,6 @@ extern unsigned long get_sdram_size(void);
 
 #define CONFIG_FSL_I2C			/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C			/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_I2C_CMD_TREE
 #define CONFIG_SYS_I2C_SPEED		400000 /* I2C speed and slave address*/
diff --git a/include/configs/P1023RDS.h b/include/configs/P1023RDS.h
index 800d666..b0348d1 100644
--- a/include/configs/P1023RDS.h
+++ b/include/configs/P1023RDS.h
@@ -314,7 +314,6 @@ extern unsigned long get_clock_freq(void);
 /* I2C */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x51
diff --git a/include/configs/P1_P2_RDB.h b/include/configs/P1_P2_RDB.h
index a57d9dd..6e92735 100644
--- a/include/configs/P1_P2_RDB.h
+++ b/include/configs/P1_P2_RDB.h
@@ -368,7 +368,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 /* I2C */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_I2C_CMD_TREE
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address*/
diff --git a/include/configs/P2020COME.h b/include/configs/P2020COME.h
index c75f86c..fc3f236 100644
--- a/include/configs/P2020COME.h
+++ b/include/configs/P2020COME.h
@@ -226,7 +226,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 /* I2C */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
-#undef  CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_I2C_CMD_TREE
 #define CONFIG_SYS_I2C_SPEED		400000  /* I2C speed and slave address*/
diff --git a/include/configs/PM826.h b/include/configs/PM826.h
index fbcf8e5..90f4047 100644
--- a/include/configs/PM826.h
+++ b/include/configs/PM826.h
@@ -57,10 +57,11 @@
 	"bootm"
 
 /* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/PM828.h b/include/configs/PM828.h
index c37aafd..a1184d2 100644
--- a/include/configs/PM828.h
+++ b/include/configs/PM828.h
@@ -57,10 +57,11 @@
 	"bootm"
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/PMC440.h b/include/configs/PMC440.h
index 3837b8f..2265d96 100644
--- a/include/configs/PMC440.h
+++ b/include/configs/PMC440.h
@@ -226,7 +226,6 @@
  * I2C
  *----------------------------------------------------------------------*/
 #define CONFIG_HARD_I2C		1	/* I2C with hardware support    */
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged               */
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address  */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/R360MPI.h b/include/configs/R360MPI.h
index 9befacb..fe7cf32 100644
--- a/include/configs/R360MPI.h
+++ b/include/configs/R360MPI.h
@@ -96,10 +96,14 @@
 #define	CONFIG_RTC_MPC8xx		/* use internal RTC of MPC8xx	*/
 
 #define CONFIG_HARD_I2C		1	/* To I2C with hardware support */
-#undef CONFIG_SORT_I2C			/* To I2C with software support */
+#undef CONFIG_SYS_I2C_SOFT		/* To I2C with software support */
 #define CONFIG_SYS_I2C_SPEED		4700	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 
+#if defined(CONFIG_SYS_I2C_SOFT)
+#define CONFIG_SYS_SYS_I2C_SOFT_SPEED	4700 /* I2C speed and slave address */
+#define CONFIG_SYS_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -115,6 +119,7 @@
 #define I2C_SCL(bit)		if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 				else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY		udelay(50)
+#endif /* #define(CONFIG_SYS_I2C_SOFT) */
 
 #define CONFIG_SYS_I2C_LCD_ADDR	0x8	/* LCD Control */
 #define CONFIG_SYS_I2C_KEY_ADDR	0x9	/* Keyboard coprocessor */
diff --git a/include/configs/RPXClassic.h b/include/configs/RPXClassic.h
index b215c2d..30d3d16 100644
--- a/include/configs/RPXClassic.h
+++ b/include/configs/RPXClassic.h
@@ -148,14 +148,16 @@
  * I2C Configuration
  *-----------------------------------------------------------------------------
  */
-#define CONFIG_I2C              1
-#define CONFIG_SYS_I2C_SPEED           50000
-#define CONFIG_SYS_I2C_SLAVE           0x34
+#define CONFIG_SYS_I2C_SPEED		50000
+#define CONFIG_SYS_I2C_SLAVE		0x34
 
 
 /* enable I2C and select the hardware/software driver */
 #define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#undef  CONFIG_SOFT_I2C			/* I2C bit-banged		*/
+#undef  CONFIG_SYS_I2C_SOFT		/* I2C bit-banged		*/
+
+#if defined(CONFIG_SYS_I2C_SOFT)
+#define CONFIG_SYS_I2C			1
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -170,8 +172,10 @@
 #define I2C_DELAY	udelay(5)	/* 1/4 I2C clock duration */
 
 
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0x34
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x34
+#endif
+
 # define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM X24C16		*/
 # define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* bytes of address		*/
 /* mask of address bits that overflow into the "EEPROM chip address"    */
diff --git a/include/configs/RPXlite.h b/include/configs/RPXlite.h
index 8ffb014..4fda185 100644
--- a/include/configs/RPXlite.h
+++ b/include/configs/RPXlite.h
@@ -62,6 +62,32 @@
 #undef	CONFIG_SYS_LOADS_BAUD_CHANGE		/* don't allow baudrate change	*/
 
 #define CONFIG_BZIP2		/* Include support for bzip2 compressed images  */
+
+/* enable I2C and select the hardware/software driver */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	40000	/* 40 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+/* Software (bit-bang) I2C driver configuration */
+#define PB_SCL		0x00000020	/* PB 26 */
+#define PB_SDA		0x00000010	/* PB 27 */
+
+#define I2C_INIT	(immr->im_cpm.cp_pbdir |=  PB_SCL)
+#define I2C_ACTIVE	(immr->im_cpm.cp_pbdir |=  PB_SDA)
+#define I2C_TRISTATE	(immr->im_cpm.cp_pbdir &= ~PB_SDA)
+#define I2C_READ	((immr->im_cpm.cp_pbdat & PB_SDA) != 0)
+#define I2C_SDA(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SDA; \
+			else    immr->im_cpm.cp_pbdat &= ~PB_SDA
+#define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
+			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
+#define I2C_DELAY	udelay(5)	/* 1/4 I2C clock duration */
+
+/* M41T11 Serial Access Timekeeper(R) SRAM */
+#define CONFIG_RTC_M41T11 1
+#define CONFIG_SYS_I2C_RTC_ADDR 0x68
+#define CONFIG_SYS_M41T11_BASE_YEAR 1900	/* play along with the linux driver */
+
 #undef	CONFIG_WATCHDOG			/* watchdog disabled		*/
 
 /*
diff --git a/include/configs/RRvision.h b/include/configs/RRvision.h
index 671d521..26de1a8 100644
--- a/include/configs/RRvision.h
+++ b/include/configs/RRvision.h
@@ -120,13 +120,11 @@
 #endif
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
-
-# define CONFIG_SYS_I2C_SPEED		50000	/* 50 kHz is supposed to work	*/
-# define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -142,7 +140,6 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(1)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
 
 
 /*
diff --git a/include/configs/SBC8540.h b/include/configs/SBC8540.h
index d448bf6..a7bdeeb 100644
--- a/include/configs/SBC8540.h
+++ b/include/configs/SBC8540.h
@@ -223,7 +223,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES	{0x69}	/* Don't probe these addrs */
diff --git a/include/configs/SCM.h b/include/configs/SCM.h
index 87d52ba..ea96696 100644
--- a/include/configs/SCM.h
+++ b/include/configs/SCM.h
@@ -75,15 +75,14 @@
 	"bootm"
 
 /* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
-
 #define I2C_PORT	3		/* Port A=0, B=1, C=2, D=3 */
 #define I2C_ACTIVE	(iop->pdir |=  0x00010000)
 #define I2C_TRISTATE	(iop->pdir &= ~0x00010000)
diff --git a/include/configs/SXNI855T.h b/include/configs/SXNI855T.h
index b7fbe5e..7bdcd62 100644
--- a/include/configs/SXNI855T.h
+++ b/include/configs/SXNI855T.h
@@ -121,7 +121,11 @@
 
 #define	CONFIG_RTC_DS1306		/* Dallas 1306 real time clock	*/
 
-#define	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -138,8 +142,6 @@
 			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(5)	/* 1/4 I2C clock duration */
 
-# define CONFIG_SYS_I2C_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
 # define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Atmel 24C64			*/
 # define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2	/* two byte address		*/
 
diff --git a/include/configs/Sandpoint8240.h b/include/configs/Sandpoint8240.h
index f54fcb3..6b0c56f 100644
--- a/include/configs/Sandpoint8240.h
+++ b/include/configs/Sandpoint8240.h
@@ -202,12 +202,16 @@
  * configuration items that the driver uses to drive the port pins.
  */
 #define CONFIG_HARD_I2C		1		/* To enable I2C support	*/
-#undef  CONFIG_SOFT_I2C				/* I2C bit-banged		*/
+#undef  CONFIG_SYS_I2C_SOFT			/* I2C bit-banged		*/
 #define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 #error "Soft I2C is not configured properly.  Please review!"
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define I2C_PORT		3               /* Port A=0, B=1, C=2, D=3 */
 #define I2C_ACTIVE		(iop->pdir |=  0x00010000)
 #define I2C_TRISTATE		(iop->pdir &= ~0x00010000)
@@ -217,7 +221,7 @@
 #define I2C_SCL(bit)		if(bit) iop->pdat |=  0x00020000; \
 				else    iop->pdat &= ~0x00020000
 #define I2C_DELAY		udelay(5)	/* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
+#endif /* CONFIG_SYS_I2C_SOFT */
 
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57		/* EEPROM IS24C02		*/
diff --git a/include/configs/Sandpoint8245.h b/include/configs/Sandpoint8245.h
index 84e4891..ad214f4 100644
--- a/include/configs/Sandpoint8245.h
+++ b/include/configs/Sandpoint8245.h
@@ -172,12 +172,16 @@
  * configuration items that the driver uses to drive the port pins.
  */
 #define CONFIG_HARD_I2C		1		/* To enable I2C support	*/
-#undef  CONFIG_SOFT_I2C				/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#undef  CONFIG_SYS_I2C_SOFT			/* I2C bit-banged		*/
+#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_SLAVE	0x7F
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 #error "Soft I2C is not configured properly.  Please review!"
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define I2C_PORT		3               /* Port A=0, B=1, C=2, D=3 */
 #define I2C_ACTIVE		(iop->pdir |=  0x00010000)
 #define I2C_TRISTATE		(iop->pdir &= ~0x00010000)
@@ -187,7 +191,7 @@
 #define I2C_SCL(bit)		if(bit) iop->pdat |=  0x00020000; \
 				else    iop->pdat &= ~0x00020000
 #define I2C_DELAY		udelay(5)	/* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
+#endif /* CONFIG_SYS_I2C_SOFT */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57		/* EEPROM IS24C02		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1		/* Bytes of address		*/
diff --git a/include/configs/TASREG.h b/include/configs/TASREG.h
index d95a226..1991f2f 100644
--- a/include/configs/TASREG.h
+++ b/include/configs/TASREG.h
@@ -136,19 +136,12 @@
 /*-----------------------------------------------------------------------
  * I2C
  */
-#define	CONFIG_SOFT_I2C
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC32		*/
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2	/* Bytes of address		*/
-/* mask of address bits that overflow into the "EEPROM chip address"	*/
-#define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW	0x01
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 5	/* The Catalyst CAT24WC32 has	*/
-					/* 32 byte page write mode using*/
-					/* last 5 bits of the address	*/
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10   /* and takes up to 10 msec */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	100000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 
-#if defined (CONFIG_SOFT_I2C)
 #if 0 /* push-pull */
 #define	SDA	        0x00800000
 #define	SCL	        0x00000008
@@ -182,7 +175,15 @@
 #define	I2C_ACTIVE	{DIR1|=SDA;}
 #define	I2C_TRISTATE    {DIR1&=~SDA;}
 #endif
-#endif
+
+#define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC32		*/
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2	/* Bytes of address		*/
+/* mask of address bits that overflow into the "EEPROM chip address"	*/
+#define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW	0x01
+#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 5	/* The Catalyst CAT24WC32 has	*/
+					/* 32 byte page write mode using*/
+					/* last 5 bits of the address	*/
+#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10   /* and takes up to 10 msec */
 
 /*-----------------------------------------------------------------------
  * Definitions for initial stack pointer and data area (in DPRAM)
diff --git a/include/configs/TK885D.h b/include/configs/TK885D.h
index 4176c7f..d723e25 100644
--- a/include/configs/TK885D.h
+++ b/include/configs/TK885D.h
@@ -104,13 +104,11 @@
 #undef	CONFIG_CAN_DRIVER		/* CAN Driver support disabled	*/
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-
-#define CONFIG_SYS_I2C_SPEED		93000	/* 93 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -126,7 +124,6 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else	immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(2)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50		/* EEPROM AT24C??	*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2		/* two byte address	*/
diff --git a/include/configs/TOP5200.h b/include/configs/TOP5200.h
index 2267d59..9ff6c6e 100644
--- a/include/configs/TOP5200.h
+++ b/include/configs/TOP5200.h
@@ -200,10 +200,14 @@
 #define CONFIG_ENV_OVERWRITE
 #define CONFIG_MISC_INIT_R
 
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support */
-#define	CONFIG_SOFT_I2C		1	/* I2C with softwate support */
-
-#if defined (CONFIG_SOFT_I2C)
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+
+#if defined(CONFIG_SYS_I2C_SOFT)
+#  define CONFIG_SYS_I2C
+#  define CONFIG_SYS_I2C_SOFT_SPEED	100000
+#  define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#  define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+/**/
 #  define SDA0			0x40
 #  define SCL0			0x80
 #  define GPIOE0		*((volatile uchar*)(CONFIG_SYS_MBAR+0x0c00))
@@ -218,8 +222,7 @@
 #  define I2C_DELAY		{udelay(5);}
 #  define I2C_ACTIVE	{DDR0|=SDA0;}
 #  define I2C_TRISTATE	{DDR0&=~SDA0;}
-#  define CONFIG_SYS_I2C_SPEED		100000
-#  define CONFIG_SYS_I2C_SLAVE		0x7F
+
 #define CONFIG_SYS_I2C_EEPROM_ADDR 0x57
 #define CONFIG_SYS_I2C_FACT_ADDR	0x57
 #endif
diff --git a/include/configs/TOP860.h b/include/configs/TOP860.h
index 36921ca..b29071b 100644
--- a/include/configs/TOP860.h
+++ b/include/configs/TOP860.h
@@ -159,7 +159,6 @@
  * Environment handler
  * only the first 6k in EEPROM are available for user. Of that we use 256b
  */
-#define	CONFIG_SOFT_I2C
 #define CONFIG_ENV_IS_IN_EEPROM	1	/* turn on EEPROM env feature */
 #define CONFIG_ENV_OFFSET		0x1000
 #define CONFIG_ENV_SIZE		0x0700
@@ -170,13 +169,16 @@
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 #define CONFIG_SYS_EEPROM_SIZE 0x2000
-#define	CONFIG_SYS_I2C_SPEED	100000
-#define	CONFIG_SYS_I2C_SLAVE	0xFE
 #define	CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 12
 #define CONFIG_ENV_OVERWRITE
 #define CONFIG_MISC_INIT_R
 
-#if defined (CONFIG_SOFT_I2C)
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	100000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+/**/
 #define	SDA	0x00010
 #define	SCL	0x00020
 #define __I2C_DIR	immr->im_cpm.cp_pbdir
@@ -193,7 +195,6 @@
 #define	I2C_DELAY	{ udelay(5); }
 #define	I2C_ACTIVE	{ __I2C_DIR |= SDA; }
 #define	I2C_TRISTATE	{ __I2C_DIR &= ~SDA; }
-#endif
 
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200, 230400 }
 
diff --git a/include/configs/TQM8260.h b/include/configs/TQM8260.h
index 7e24131..2367394 100644
--- a/include/configs/TQM8260.h
+++ b/include/configs/TQM8260.h
@@ -89,10 +89,11 @@
 #define CONFIG_BOOTCOMMAND	"run flash_self"
 
 /* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 
 /*
  * Software (bit-bang) I2C driver configuration
diff --git a/include/configs/TQM8272.h b/include/configs/TQM8272.h
index be977f1..68d7c46 100644
--- a/include/configs/TQM8272.h
+++ b/include/configs/TQM8272.h
@@ -97,11 +97,11 @@
 
 #if CONFIG_I2C
 /* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -135,8 +135,9 @@
 #define CONFIG_SYS_DTT_HYSTERESIS	3
 
 #else
+#undef CONFIG_SYS_I2C
 #undef CONFIG_HARD_I2C
-#undef CONFIG_SOFT_I2C
+#undef CONFIG_SYS_I2C_SOFT
 #endif
 
 /*
diff --git a/include/configs/TQM834x.h b/include/configs/TQM834x.h
index 0738423..133d7df 100644
--- a/include/configs/TQM834x.h
+++ b/include/configs/TQM834x.h
@@ -188,7 +188,6 @@
  * I2C
  */
 #define CONFIG_HARD_I2C			/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed: 400KHz */
 #define CONFIG_SYS_I2C_SLAVE		0x7F	/* slave address */
diff --git a/include/configs/TQM855M.h b/include/configs/TQM855M.h
index 95bc4d9..558fd82 100644
--- a/include/configs/TQM855M.h
+++ b/include/configs/TQM855M.h
@@ -93,13 +93,11 @@
 #undef	CONFIG_CAN_DRIVER		/* CAN Driver support disabled	*/
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C         1	/* I2C bit-banged		*/
-
-#define CONFIG_SYS_I2C_SPEED		93000	/* 93 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -115,7 +113,6 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(2)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50		/* EEPROM AT24C64	*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2		/* two byte address	*/
diff --git a/include/configs/TQM866M.h b/include/configs/TQM866M.h
index a13c16a..cc84fa4 100644
--- a/include/configs/TQM866M.h
+++ b/include/configs/TQM866M.h
@@ -107,13 +107,11 @@
 #undef	CONFIG_CAN_DRIVER		/* CAN Driver support disabled	*/
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-
-#define CONFIG_SYS_I2C_SPEED		93000	/* 93 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -129,7 +127,6 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else	immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(2)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50		/* EEPROM AT24C256	*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2		/* two byte address	*/
diff --git a/include/configs/TQM885D.h b/include/configs/TQM885D.h
index 7df76fb..122577e 100644
--- a/include/configs/TQM885D.h
+++ b/include/configs/TQM885D.h
@@ -101,13 +101,11 @@
 #undef	CONFIG_CAN_DRIVER		/* CAN Driver support disabled	*/
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-
-#define CONFIG_SYS_I2C_SPEED		93000	/* 93 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -123,7 +121,6 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else	immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(2)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50		/* EEPROM AT24C??	*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2		/* two byte address	*/
diff --git a/include/configs/alpr.h b/include/configs/alpr.h
index 0d53e51..a6add6b 100644
--- a/include/configs/alpr.h
+++ b/include/configs/alpr.h
@@ -122,7 +122,6 @@
  * I2C
  *----------------------------------------------------------------------*/
 #define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/aria.h b/include/configs/aria.h
index 0b31c50..fd98fb2 100644
--- a/include/configs/aria.h
+++ b/include/configs/aria.h
@@ -366,7 +366,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C			/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C			/* so disable bit-banged I2C */
 #define CONFIG_I2C_MULTI_BUS
 
 /* I2C speed and slave address */
diff --git a/include/configs/astro_mcf5373l.h b/include/configs/astro_mcf5373l.h
index a0ed8f1..6dabe57 100644
--- a/include/configs/astro_mcf5373l.h
+++ b/include/configs/astro_mcf5373l.h
@@ -118,7 +118,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C
 #define CONFIG_HARD_I2C			/* I2C with hw support */
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		80000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x58000
diff --git a/include/configs/bf533-ezkit.h b/include/configs/bf533-ezkit.h
index c1a5ecd..1598eb4 100644
--- a/include/configs/bf533-ezkit.h
+++ b/include/configs/bf533-ezkit.h
@@ -94,10 +94,16 @@
 /*
  * I2C Settings
  */
-#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C_SOFT
+#ifdef CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C
 #define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0
 #define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1
-
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0
+#define I2C_DELAY              udelay(5)       /* 1/4 I2C clock duration */
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+#endif
 
 /*
  * Misc Settings
diff --git a/include/configs/bf533-stamp.h b/include/configs/bf533-stamp.h
index e3344e9..cc5dbe79 100644
--- a/include/configs/bf533-stamp.h
+++ b/include/configs/bf533-stamp.h
@@ -14,7 +14,6 @@
 #define CONFIG_BFIN_CPU             bf533-0.3
 #define CONFIG_BFIN_BOOT_MODE       BFIN_BOOT_BYPASS
 
-
 /*
  * Clock Settings
  *	CCLK = (CLKIN * VCO_MULT) / CCLK_DIV
@@ -38,7 +37,6 @@
 /* Values can range from 1-15						*/
 #define CONFIG_SCLK_DIV			6 /* note: 1.2 boards can go faster */
 
-
 /*
  * Memory Settings
  */
@@ -74,6 +72,40 @@
 /* #define CONFIG_ETHADDR	02:80:ad:20:31:b8 */
 
 
+/* I2C */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+/*
+ * Software (bit-bang) I2C driver configuration
+ */
+#define PF_SCL			PF3
+#define PF_SDA			PF2
+#define I2C_INIT		(*pFIO_DIR |=  PF_SCL); asm("ssync;")
+#define I2C_ACTIVE		(*pFIO_DIR |=  PF_SDA); *pFIO_INEN &= ~PF_SDA; asm("ssync;")
+#define I2C_TRISTATE		(*pFIO_DIR &= ~PF_SDA); *pFIO_INEN |= PF_SDA; asm("ssync;")
+#define I2C_READ		((volatile)(*pFIO_FLAG_D & PF_SDA) != 0); asm("ssync;")
+#define I2C_SDA(bit)	if(bit) { \
+				*pFIO_FLAG_S = PF_SDA; \
+				asm("ssync;"); \
+				} \
+			else	{ \
+				*pFIO_FLAG_C = PF_SDA; \
+				asm("ssync;"); \
+				}
+#define I2C_SCL(bit)	if(bit) { \
+				*pFIO_FLAG_S = PF_SCL; \
+				asm("ssync;"); \
+				} \
+			else	{ \
+				*pFIO_FLAG_C = PF_SCL; \
+				asm("ssync;"); \
+				}
+#define I2C_DELAY		udelay(5)	/* 1/4 I2C clock duration */
+
+
 /*
  * Flash Settings
  */
@@ -84,7 +116,6 @@
 #define CONFIG_SYS_MAX_FLASH_BANKS	1
 #define CONFIG_SYS_MAX_FLASH_SECT	67
 
-
 /*
  * SPI Settings
  */
@@ -132,10 +163,16 @@
 /*
  * I2C Settings
  */
-#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C_SOFT
+#ifdef CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C
 #define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF3
 #define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF2
-
+#define I2C_DELAY		udelay(5)	/* 1/4 I2C clock duration */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+#endif
 
 /*
  * Compact Flash / IDE / ATA Settings
diff --git a/include/configs/bf561-ezkit.h b/include/configs/bf561-ezkit.h
index 1a9d27e..2cb93e5 100644
--- a/include/configs/bf561-ezkit.h
+++ b/include/configs/bf561-ezkit.h
@@ -88,10 +88,15 @@
 /*
  * I2C Settings
  */
-#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C_SOFT
+#ifdef CONFIG_SYS_I2C_SOFT
 #define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0
 #define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1
-
+#define I2C_DELAY		udelay(5)	/* 1/4 I2C clock duration */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+#endif
 
 /*
  * Misc Settings
diff --git a/include/configs/bfin_adi_common.h b/include/configs/bfin_adi_common.h
index ccdec0d..aa4de38 100644
--- a/include/configs/bfin_adi_common.h
+++ b/include/configs/bfin_adi_common.h
@@ -71,7 +71,7 @@
 # ifdef CONFIG_SPI_FLASH
 #  define CONFIG_CMD_SF
 # endif
-# if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+# if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
 #  define CONFIG_CMD_I2C
 #  define CONFIG_SOFT_I2C_READ_REPEATED_START
 # endif
diff --git a/include/configs/blackstamp.h b/include/configs/blackstamp.h
index 83ad659..59daf5a 100644
--- a/include/configs/blackstamp.h
+++ b/include/configs/blackstamp.h
@@ -40,7 +40,6 @@
 #define SHARED_RESOURCES	1
 
 /* Is I2C bit-banged? */
-#undef CONFIG_SOFT_I2
 
 /*
  * Clock Settings
diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
index 15d56c3..3f8e4a2 100644
--- a/include/configs/cpuat91.h
+++ b/include/configs/cpuat91.h
@@ -92,7 +92,6 @@
 #define CONFIG_USART_ID		0/* ignored in arm */
 
 #undef CONFIG_HARD_I2C
-#undef CONFIG_SOFT_I2C
 #define AT91_PIN_SDA			(1<<25)
 #define AT91_PIN_SCL			(1<<26)
 
diff --git a/include/configs/debris.h b/include/configs/debris.h
index 32aa4e5..a0c3e5a 100644
--- a/include/configs/debris.h
+++ b/include/configs/debris.h
@@ -272,12 +272,16 @@
  * configuration items that the driver uses to drive the port pins.
  */
 #define CONFIG_HARD_I2C		1		/* To enable I2C support	*/
-#undef  CONFIG_SOFT_I2C				/* I2C bit-banged		*/
+#undef  CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 #error "Soft I2C is not configured properly.  Please review!"
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define I2C_PORT		3               /* Port A=0, B=1, C=2, D=3 */
 #define I2C_ACTIVE		(iop->pdir |=  0x00010000)
 #define I2C_TRISTATE		(iop->pdir &= ~0x00010000)
@@ -287,7 +291,7 @@
 #define I2C_SCL(bit)		if(bit) iop->pdat |=  0x00020000; \
 				else    iop->pdat &= ~0x00020000
 #define I2C_DELAY		udelay(5)	/* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
+#endif /* CONFIG_SYS_I2C_SOFT */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57		/* EEPROM IS24C02		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1		/* Bytes of address		*/
diff --git a/include/configs/eXalion.h b/include/configs/eXalion.h
index 3238ac7..122e0b3 100644
--- a/include/configs/eXalion.h
+++ b/include/configs/eXalion.h
@@ -223,7 +223,7 @@
  * configuration items that the driver uses to drive the port pins.
  */
 #define CONFIG_HARD_I2C		1	/* To enable I2C support	*/
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged		*/
+#undef	CONFIG_SYS_I2C_SOFT		/* I2C bit-banged		*/
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 
diff --git a/include/configs/eb_cpux9k2.h b/include/configs/eb_cpux9k2.h
index 9371ec3..4d2d50f 100644
--- a/include/configs/eb_cpux9k2.h
+++ b/include/configs/eb_cpux9k2.h
@@ -220,11 +220,11 @@
  * I2C-Bus
  */
 
-#define CONFIG_SYS_I2C_SPEED		50000
-#define CONFIG_SYS_I2C_SLAVE		0 		/* not used */
-
-#ifndef CONFIG_HARD_I2C
-#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 
 /* Software  I2C driver configuration */
 
@@ -248,9 +248,7 @@
 	else							\
 		writel(ATMEL_PMX_AA_TWCK, &pio->pioa.codr);
 
-#define I2C_DELAY	udelay(2500000/CONFIG_SYS_I2C_SPEED)
-
-#endif	/* CONFIG_HARD_I2C */
+#define I2C_DELAY	udelay(2500000/CONFIG_SYS_I2C_SOFT_SPEED)
 
 /* I2C-RTC */
 
diff --git a/include/configs/ep8260.h b/include/configs/ep8260.h
index ccfe032..73ab177 100644
--- a/include/configs/ep8260.h
+++ b/include/configs/ep8260.h
@@ -227,15 +227,19 @@
  * If the software driver is chosen, there are some additional
  * configuration items that the driver uses to drive the port pins.
  */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C_SLAVE		0x7F	/* This is for HARD, must go */
 
 /*
  * Software (bit-bang) I2C driver configuration
  */
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define I2C_PORT	3		/* Port A=0, B=1, C=2, D=3 */
 #define I2C_ACTIVE	(iop->pdir |=  0x00010000)
 #define I2C_TRISTATE	(iop->pdir &= ~0x00010000)
@@ -245,7 +249,7 @@
 #define I2C_SCL(bit)	if(bit) iop->pdat |=  0x00020000; \
 			else    iop->pdat &= ~0x00020000
 #define I2C_DELAY	udelay(5)	/* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
+#endif /* CONFIG_SYS_I2C_SOFT */
 
 /* #define CONFIG_RTC_DS174x */
 
diff --git a/include/configs/ethernut5.h b/include/configs/ethernut5.h
index 14a0f02..47942b9 100644
--- a/include/configs/ethernut5.h
+++ b/include/configs/ethernut5.h
@@ -210,10 +210,13 @@
 
 /* I2C */
 #define CONFIG_SYS_MAX_I2C_BUS	1
-#define CONFIG_SYS_I2C_SLAVE	0
-#define CONFIG_SYS_I2C_SPEED	100000
 
-#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	100000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+
 #define I2C_SOFT_DECLARATIONS
 
 #define GPIO_I2C_SCL		AT91_PIO_PORTA, 24
diff --git a/include/configs/ibf-dsp561.h b/include/configs/ibf-dsp561.h
index 294af73..ce8c385 100644
--- a/include/configs/ibf-dsp561.h
+++ b/include/configs/ibf-dsp561.h
@@ -105,11 +105,12 @@
 /*
  * I2C Settings
  */
-#define CONFIG_SOFT_I2C		1
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0
 #define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1
 
-
 /*
  * Misc Settings
  */
diff --git a/include/configs/iocon.h b/include/configs/iocon.h
index 7f8825b..ed8afc2 100644
--- a/include/configs/iocon.h
+++ b/include/configs/iocon.h
@@ -110,11 +110,12 @@
 /*
  * I2C stuff
  */
-#define CONFIG_SYS_I2C_SPEED		400000
-
-/* enable I2C and select the hardware/software driver */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
+#undef CONFIG_HARD_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 
 /*
  * Software (bit-bang) I2C driver configuration
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h
index 05480d4..728c79e 100644
--- a/include/configs/km/keymile-common.h
+++ b/include/configs/km/keymile-common.h
@@ -82,10 +82,7 @@
 #define CONFIG_LOADS_ECHO
 #define CONFIG_SYS_LOADS_BAUD_CHANGE
 
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_MAX_I2C_BUS		1
 #define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_I2C_MUX
 
 /* Support the IVM EEprom */
 #define	CONFIG_SYS_IVM_EEPROM_ADR	0x50
diff --git a/include/configs/km/km83xx-common.h b/include/configs/km/km83xx-common.h
index 877d841..d9e935e 100644
--- a/include/configs/km/km83xx-common.h
+++ b/include/configs/km/km83xx-common.h
@@ -207,6 +207,9 @@
 #define CONFIG_SYS_I2C_SPEED	200000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE	0x7F
 #define CONFIG_SYS_I2C_OFFSET	0x3000
+#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_MAX_I2C_BUS		1
+#define CONFIG_I2C_MUX
 
 /* I2C SYSMON (LM75, AD7414 is almost compatible) */
 #define CONFIG_DTT_LM75		/* ON Semi's LM75 */
diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h
index 549278d..9d4534b 100644
--- a/include/configs/km/km_arm.h
+++ b/include/configs/km/km_arm.h
@@ -55,7 +55,6 @@
 
 #define CONFIG_CMD_NAND
 #define CONFIG_CMD_SF
-#define CONFIG_SOFT_I2C		/* I2C bit-banged	*/
 
 /* SPI NOR Flash default params, used by sf commands */
 #define CONFIG_SF_DEFAULT_SPEED		8100000
@@ -184,8 +183,25 @@
 /*
  * I2C related stuff
  */
+#undef CONFIG_I2C_MVTWSI
+#define CONFIG_SYS_I2C
+#define	CONFIG_SYS_I2C_SOFT	/* I2C bit-banged	*/
+
 #define	CONFIG_KIRKWOOD_GPIO		/* Enable GPIO Support */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
+
+#define CONFIG_SYS_NUM_I2C_ADAPTERS	1
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_BUSSES	6
+#define CONFIG_SYS_I2C_MAX_HOPS		1
+#define CONFIG_SYS_I2C_BUSSES	{	{0, {I2C_NULL_HOP} }, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 1} } }, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 2} } }, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 3} } }, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 4} } }, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 5} } }, \
+				}
+
 #ifndef __ASSEMBLY__
 #include <asm/arch-kirkwood/gpio.h>
 extern void __set_direction(unsigned pin, int high);
@@ -208,6 +224,8 @@ int get_scl(void);
 #define I2C_DELAY	udelay(1)
 #define I2C_SOFT_DECLARATIONS
 
+#define	CONFIG_SYS_I2C_SOFT_SLAVE	0x0
+#define	CONFIG_SYS_I2C_SOFT_SPEED	100000
 #endif
 
 /* EEprom support 24C128, 24C256 valid for environment eeprom */
@@ -237,7 +255,7 @@ int get_scl(void);
 #define CONFIG_SYS_EEPROM_WREN
 #define CONFIG_ENV_OFFSET		0x0 /* no bracets! */
 #define CONFIG_ENV_SIZE			(0x2000 - CONFIG_ENV_OFFSET)
-#define CONFIG_I2C_ENV_EEPROM_BUS	KM_ENV_BUS "\0"
+#define CONFIG_I2C_ENV_EEPROM_BUS	KM_ENV_BUS
 #define CONFIG_ENV_OFFSET_REDUND	0x2000 /* no bracets! */
 #define CONFIG_ENV_SIZE_REDUND		(CONFIG_ENV_SIZE)
 #endif
@@ -290,7 +308,7 @@ int get_scl(void);
 	CONFIG_KM_DEF_ENV						\
 	CONFIG_KM_NEW_ENV						\
 	"arch=arm\0"							\
-	"EEprom_ivm=" KM_IVM_BUS "\0"					\
+	"EEprom_ivm=" __stringify(KM_IVM_BUS) "\0"			\
 	""
 
 #if defined(CONFIG_SYS_NO_FLASH)
diff --git a/include/configs/km82xx.h b/include/configs/km82xx.h
index 3c2117f..6800071 100644
--- a/include/configs/km82xx.h
+++ b/include/configs/km82xx.h
@@ -212,7 +212,7 @@
 #define	CONFIG_EXTRA_ENV_SETTINGS					\
 	CONFIG_KM_BOARD_EXTRA_ENV					\
 	CONFIG_KM_DEF_ENV						\
-	"EEprom_ivm=pca9544a:70:4 \0"					\
+	"EEprom_ivm=0\0"						\
 	"unlock=yes\0"							\
 	"newenv="							\
 		"prot off 0xFE0C0000 +0x40000 && "			\
@@ -242,10 +242,18 @@
 #endif /* CONFIG_ENV_IS_IN_FLASH */
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		50000	/* I2C speed */
-#define CONFIG_SYS_I2C_SLAVE		0x7F	/* I2C slave address */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_NUM_I2C_ADAPTERS	1
+#define CONFIG_SYS_NUM_I2C_BUSSES	3
+#define CONFIG_SYS_I2C_MAX_HOPS		1
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SPEED		CONFIG_SYS_I2C_SOFT_SPEED
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+#define CONFIG_SYS_I2C_BUSSES	{{0, {I2C_NULL_HOP} }, \
+			{0, {{I2C_MUX_PCA9542, 0x70, 0} } }, \
+			{0, {{I2C_MUX_PCA9542, 0x70, 1} } } }
 
 /*
  * Software (bit-bang) I2C driver configuration
diff --git a/include/configs/km_kirkwood.h b/include/configs/km_kirkwood.h
index 762cc10..0d1eb58 100644
--- a/include/configs/km_kirkwood.h
+++ b/include/configs/km_kirkwood.h
@@ -42,18 +42,18 @@
 #define CONFIG_IDENT_STRING		"\nKeymile Kirkwood"
 #define CONFIG_HOSTNAME			km_kirkwood
 #define CONFIG_KM_DISABLE_PCIE
-#define KM_IVM_BUS			"pca9544a:70:9"	/* I2C2 (Mux-Port 1)*/
+#define KM_IVM_BUS			1	/* I2C2 (Mux-Port 1)*/
 
 /* KM_KIRKWOOD_PCI */
 #elif defined(CONFIG_KM_KIRKWOOD_PCI)
 #define CONFIG_IDENT_STRING		"\nKeymile Kirkwood PCI"
 #define CONFIG_HOSTNAME			km_kirkwood_pci
-#define KM_IVM_BUS			"pca9544a:70:9"	/* I2C2 (Mux-Port 1)*/
+#define KM_IVM_BUS			1	/* I2C2 (Mux-Port 1)*/
 #define CONFIG_KM_FPGA_CONFIG
 
 /* KM_NUSA */
 #elif defined(CONFIG_KM_NUSA)
-#define KM_IVM_BUS			"pca9547:70:9"	/* I2C2 (Mux-Port 1)*/
+#define KM_IVM_BUS			1	/* I2C2 (Mux-Port 1)*/
 #define CONFIG_IDENT_STRING		"\nKeymile NUSA"
 #define CONFIG_HOSTNAME			kmnusa
 #undef CONFIG_SYS_KWD_CONFIG
@@ -69,7 +69,7 @@
 #elif defined(CONFIG_KM_MGCOGE3UN)
 #define CONFIG_IDENT_STRING		"\nKeymile COGE3UN"
 #define CONFIG_HOSTNAME			mgcoge3un
-#define KM_IVM_BUS			"pca9547:70:9" /* I2C2 (Mux-Port 1)*/
+#define KM_IVM_BUS			1	/* I2C2 (Mux-Port 1)*/
 #undef CONFIG_SYS_KWD_CONFIG
 #define CONFIG_SYS_KWD_CONFIG \
 		$(SRCTREE)/$(CONFIG_BOARDDIR)/kwbimage-memphis.cfg
@@ -81,7 +81,7 @@
 /* KMCOGE5UN */
 #elif defined(CONFIG_KM_COGE5UN)
 #define CONFIG_IDENT_STRING		"\nKeymile COGE5UN"
-#define KM_IVM_BUS			"pca9547:70:9"	/* I2C2 (Mux-Port 1)*/
+#define KM_IVM_BUS			1	/* I2C2 (Mux-Port 1)*/
 #undef	CONFIG_SYS_KWD_CONFIG
 #define CONFIG_SYS_KWD_CONFIG \
 		$(SRCTREE)/$(CONFIG_BOARDDIR)/kwbimage_256M8_1.cfg
@@ -95,7 +95,7 @@
 #elif defined(CONFIG_KM_PORTL2)
 #define CONFIG_IDENT_STRING		"\nKeymile Port-L2"
 #define CONFIG_HOSTNAME			portl2
-#define KM_IVM_BUS			"pca9544a:70:9" /* I2C2 (Mux-Port 1)*/
+#define KM_IVM_BUS			1	/* I2C2 (Mux-Port 1)*/
 #define CONFIG_KM_PIGGY4_88E6061
 
 #else
@@ -106,7 +106,7 @@
 #include "km/km_arm.h"
 
 #ifndef CONFIG_KM_ENV_IS_IN_SPI_NOR
-#define KM_ENV_BUS	"pca9544a:70:d"	/* I2C2 (Mux-Port 5)*/
+#define KM_ENV_BUS	5	/* I2C2 (Mux-Port 5)*/
 #endif
 
 #if defined(CONFIG_KM_PIGGY4_88E6352)
diff --git a/include/configs/korat.h b/include/configs/korat.h
index b919aec..7d5fb15 100644
--- a/include/configs/korat.h
+++ b/include/configs/korat.h
@@ -156,7 +156,6 @@
  * I2C
  */
 #define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/lwmon.h b/include/configs/lwmon.h
index ab86053..a8aa013 100644
--- a/include/configs/lwmon.h
+++ b/include/configs/lwmon.h
@@ -145,13 +145,11 @@
 #undef	CONFIG_STATUS_LED		/* Status LED disabled		*/
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C         1	/* I2C bit-banged		*/
-
-#define CONFIG_SYS_I2C_SPEED		93000	/* 93 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -167,7 +165,6 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(2)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
 
 
 #define CONFIG_RTC_PCF8563		/* use Philips PCF8563 RTC	*/
diff --git a/include/configs/lwmon5.h b/include/configs/lwmon5.h
index 2d33ebc..d0c05f5 100644
--- a/include/configs/lwmon5.h
+++ b/include/configs/lwmon5.h
@@ -281,7 +281,6 @@
  * I2C
  */
 #define CONFIG_HARD_I2C				/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C				/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		100000		/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/mecp5123.h b/include/configs/mecp5123.h
index cafc273..46c0422 100644
--- a/include/configs/mecp5123.h
+++ b/include/configs/mecp5123.h
@@ -243,7 +243,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C			/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C			/* so disable bit-banged I2C */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed */
 #define CONFIG_SYS_I2C_SLAVE		0x7F	/* slave address */
diff --git a/include/configs/mpc5121ads.h b/include/configs/mpc5121ads.h
index 3f55d35..b2057f2 100644
--- a/include/configs/mpc5121ads.h
+++ b/include/configs/mpc5121ads.h
@@ -336,7 +336,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C			/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C			/* so disable bit-banged I2C */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/nhk8815.h b/include/configs/nhk8815.h
index d438efd..2759433 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -109,8 +109,12 @@
 #ifndef __ASSEMBLY__
 #include <asm/arch/gpio.h>
 #define CONFIG_CMD_I2C
-#define CONFIG_SOFT_I2C
-#define CONFIG_SYS_I2C_SPEED	400000
+#define CONFIG_SYS_I2C
+#define	CONFIG_SYS_I2C_SOFT	1	/* I2C bit-banged	*/
+#define I2C_SOFT_DEFS
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define __SDA			63
 #define __SCL			62
 #define I2C_SDA(x)		nmk_gpio_set(__SDA, x)
diff --git a/include/configs/otc570.h b/include/configs/otc570.h
index fe4f3c0..7ffbde8 100644
--- a/include/configs/otc570.h
+++ b/include/configs/otc570.h
@@ -115,14 +115,14 @@
 /* RTC and I2C stuff */
 #define CONFIG_RTC_DS1338
 #define CONFIG_SYS_I2C_RTC_ADDR		0x68
-#undef CONFIG_HARD_I2C
-#define CONFIG_SOFT_I2C
-#define CONFIG_SYS_I2C_SPEED		100000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-
-#ifdef CONFIG_SOFT_I2C
-# define CONFIG_I2C_CMD_TREE
-# define CONFIG_I2C_MULTI_BUS
+
+#define CONFIG_SYS_I2C
+#define	CONFIG_SYS_I2C_SOFT	/* I2C bit-banged	*/
+#ifdef CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C_SOFT_SPEED	100000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+
 /* Configure data and clock pins for pio */
 # define I2C_INIT { \
 	at91_set_pio_output(AT91_PIO_PORTB, 4, 0); \
@@ -140,7 +140,7 @@
 /* Set clock pin */
 # define I2C_SCL(bit)		at91_set_pio_value(AT91_PIO_PORTB, 5, bit)
 # define I2C_DELAY		udelay(2) /* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
+#endif /* CONFIG_SYS_I2C_SOFT */
 
 /*
  * BOOTP options
diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h
index 350150b..823239b 100644
--- a/include/configs/p1_p2_rdb_pc.h
+++ b/include/configs/p1_p2_rdb_pc.h
@@ -538,7 +538,6 @@
 /* I2C */
 #define CONFIG_FSL_I2C			/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C			/* I2C with hardware support */
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_I2C_CMD_TREE
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C spd and slave address */
diff --git a/include/configs/p3p440.h b/include/configs/p3p440.h
index d7b1ca2..ba10e88 100644
--- a/include/configs/p3p440.h
+++ b/include/configs/p3p440.h
@@ -98,7 +98,6 @@
  * I2C
  *----------------------------------------------------------------------*/
 #define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/pcs440ep.h b/include/configs/pcs440ep.h
index 351ff5a..8d46607 100644
--- a/include/configs/pcs440ep.h
+++ b/include/configs/pcs440ep.h
@@ -140,7 +140,6 @@
  * I2C
  *----------------------------------------------------------------------*/
 #define CONFIG_HARD_I2C		1	    /* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C			    /* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/pdnb3.h b/include/configs/pdnb3.h
index 1e07317..dcd2237 100644
--- a/include/configs/pdnb3.h
+++ b/include/configs/pdnb3.h
@@ -281,12 +281,11 @@
  */
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-
-#define CONFIG_SYS_I2C_SPEED		83000	/* 83 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	83000	/* 83 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/quad100hd.h b/include/configs/quad100hd.h
index 5f1bb58..30a8c55 100644
--- a/include/configs/quad100hd.h
+++ b/include/configs/quad100hd.h
@@ -153,7 +153,6 @@
  * I2C
  *----------------------------------------------------------------------*/
 #define CONFIG_HARD_I2C		1		/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C				/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 7e0b302..ba30c29 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -226,8 +226,11 @@
 #define CONFIG_SOFT_I2C_GPIO_SCL s5pc110_gpio_get_nr(j4, 3)
 #define CONFIG_SOFT_I2C_GPIO_SDA s5pc110_gpio_get_nr(j4, 0)
 
-#define CONFIG_SOFT_I2C	1
-#define CONFIG_SYS_I2C_SPEED	50000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS	7
 #define CONFIG_USB_GADGET
diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h
index 5fc6136..3c68141 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -247,9 +247,12 @@
 #define CONFIG_SOFT_I2C_GPIO_SCL exynos4_gpio_part1_get_nr(b, 7)
 #define CONFIG_SOFT_I2C_GPIO_SDA exynos4_gpio_part1_get_nr(b, 6)
 
-#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
-#define CONFIG_SYS_I2C_SPEED	50000
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS	7
 
diff --git a/include/configs/sacsng.h b/include/configs/sacsng.h
index 54d55a0..10ad52a 100644
--- a/include/configs/sacsng.h
+++ b/include/configs/sacsng.h
@@ -296,15 +296,14 @@
  * If the software driver is chosen, there are some additional
  * configuration items that the driver uses to drive the port pins.
  */
-#undef  CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SOFT_I2C		1	/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
-#ifdef CONFIG_SOFT_I2C
 #define I2C_PORT	3		/* Port A=0, B=1, C=2, D=3 */
 #define I2C_ACTIVE	(iop->pdir |=  0x00010000)
 #define I2C_TRISTATE	(iop->pdir &= ~0x00010000)
@@ -314,7 +313,6 @@
 #define I2C_SCL(bit)	if(bit) iop->pdat |=  0x00020000; \
 			else    iop->pdat &= ~0x00020000
 #define I2C_DELAY	udelay(20)	/* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
 
 /* Define this to reserve an entire FLASH sector for
  * environment variables. Otherwise, the environment will be
diff --git a/include/configs/sbc405.h b/include/configs/sbc405.h
index 5abcda3..9918638 100644
--- a/include/configs/sbc405.h
+++ b/include/configs/sbc405.h
@@ -169,7 +169,6 @@
 #define CONFIG_SYS_RX_ETH_BUFFER	16	/* use 16 rx buffer on 405 emac */
 
 #define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#undef  CONFIG_SOFT_I2C			/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/sbc8349.h b/include/configs/sbc8349.h
index 478d0d8..6d115c5 100644
--- a/include/configs/sbc8349.h
+++ b/include/configs/sbc8349.h
@@ -305,7 +305,6 @@
 
 /* I2C */
 #define CONFIG_HARD_I2C			/* I2C with hardware support*/
-#undef CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE	0x7F
diff --git a/include/configs/sbc8548.h b/include/configs/sbc8548.h
index 2209ddf..33197b4 100644
--- a/include/configs/sbc8548.h
+++ b/include/configs/sbc8548.h
@@ -445,7 +445,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/configs/sbc8560.h b/include/configs/sbc8560.h
index 46d6098..0e47f6c 100644
--- a/include/configs/sbc8560.h
+++ b/include/configs/sbc8560.h
@@ -215,7 +215,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES	{0x69}	/* Don't probe these addrs */
diff --git a/include/configs/sbc8641d.h b/include/configs/sbc8641d.h
index 9040ec6..8142205 100644
--- a/include/configs/sbc8641d.h
+++ b/include/configs/sbc8641d.h
@@ -290,7 +290,6 @@
  */
 #define	CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define	CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_NOPROBES        {0x69}	/* Don't probe these addrs */
diff --git a/include/configs/sc3.h b/include/configs/sc3.h
index fb74608..abca9e0 100644
--- a/include/configs/sc3.h
+++ b/include/configs/sc3.h
@@ -247,7 +247,6 @@
  *-----------------------------------------------------------------------
  */
 #define  CONFIG_HARD_I2C		/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 
 #define I2C_INIT
diff --git a/include/configs/snapper9260.h b/include/configs/snapper9260.h
index 218ca54..634db9a 100644
--- a/include/configs/snapper9260.h
+++ b/include/configs/snapper9260.h
@@ -106,11 +106,12 @@
 #define CONFIG_SYS_PROMPT		"Snapper> "
 
 /* I2C - Bit-bashed */
-#define CONFIG_SOFT_I2C
-#define CONFIG_SYS_I2C_SPEED		100000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	100000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
-#define CONFIG_I2C_MULTI_BUS
 #define I2C_INIT do {							\
 		at91_set_gpio_output(AT91_PIN_PA23, 1);			\
 		at91_set_gpio_output(AT91_PIN_PA24, 1);			\
diff --git a/include/configs/socrates.h b/include/configs/socrates.h
index 25f15f2..e42c8aa 100644
--- a/include/configs/socrates.h
+++ b/include/configs/socrates.h
@@ -236,7 +236,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
 #define CONFIG_SYS_I2C_SPEED		102124	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #define CONFIG_SYS_I2C_OFFSET		0x3000
diff --git a/include/configs/spc1920.h b/include/configs/spc1920.h
index 87878d5..3df551d 100644
--- a/include/configs/spc1920.h
+++ b/include/configs/spc1920.h
@@ -207,13 +207,11 @@
  */
 #if defined(CONFIG_CMD_I2C)
 /* enable I2C and select the hardware/software driver */
-#undef CONFIG_HARD_I2C                 /* I2C with hardware support    */
-#define CONFIG_SOFT_I2C                1       /* I2C bit-banged               */
-
-#define CONFIG_SYS_I2C_SPEED          93000   /* 93 kHz is supposed to work   */
-#define CONFIG_SYS_I2C_SLAVE          0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -229,7 +227,6 @@
 #define I2C_SCL(bit)   if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 		       else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY      udelay(2)       /* 1/4 I2C clock duration */
-#endif /* CONFIG_SOFT_I2C */
 #endif
 
 /*-----------------------------------------------------------------------
diff --git a/include/configs/stxgp3.h b/include/configs/stxgp3.h
index 939a964..b688b45 100644
--- a/include/configs/stxgp3.h
+++ b/include/configs/stxgp3.h
@@ -180,7 +180,6 @@
  */
 #define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #if 0
diff --git a/include/configs/stxssa.h b/include/configs/stxssa.h
index c1a90a7..5d8ff79 100644
--- a/include/configs/stxssa.h
+++ b/include/configs/stxssa.h
@@ -199,7 +199,6 @@
  */
 #define CONFIG_FSL_I2C			/* Use FSL common I2C driver */
 #define  CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #undef CONFIG_SYS_I2C_NOPROBES
diff --git a/include/configs/top9000.h b/include/configs/top9000.h
index 7cc6577..54edaae 100644
--- a/include/configs/top9000.h
+++ b/include/configs/top9000.h
@@ -201,11 +201,13 @@
 #define CONFIG_CMD_USB
 
 /* I2C support must always be enabled */
-#define CONFIG_SOFT_I2C
 #define CONFIG_CMD_I2C
-#define CONFIG_SYS_I2C_SPEED		400000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	400000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7F
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
+
 #define I2C0_PORT			AT91_PIO_PORTA
 #define SDA0_PIN			23
 #define SCL0_PIN			24
diff --git a/include/configs/trats.h b/include/configs/trats.h
index d7808aa..106fd37 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -212,10 +212,13 @@
 #define CONFIG_SYS_CACHELINE_SIZE       32
 
 
-#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	50000
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
 #define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_SYS_I2C_SPEED	50000
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SOFT_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS	15
diff --git a/include/configs/u8500_href.h b/include/configs/u8500_href.h
index 1bb6128..218feeb 100644
--- a/include/configs/u8500_href.h
+++ b/include/configs/u8500_href.h
@@ -166,7 +166,6 @@
  */
 #define CONFIG_U8500_I2C
 #undef	CONFIG_HARD_I2C			/* I2C with hardware support */
-#undef	CONFIG_SOFT_I2C			/* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_I2C_SPEED		100000
 #define CONFIG_SYS_I2C_SLAVE		0	/* slave addr of controller */
diff --git a/include/configs/uc100.h b/include/configs/uc100.h
index 8c8fb5a..d68c917 100644
--- a/include/configs/uc100.h
+++ b/include/configs/uc100.h
@@ -463,13 +463,11 @@
  */
 
 /* enable I2C and select the hardware/software driver */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C         1	/* I2C bit-banged		*/
-
-#define CONFIG_SYS_I2C_SPEED		93000	/* 93 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000 /* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -485,7 +483,6 @@
 #define I2C_SCL(bit)	if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
 			else    immr->im_cpm.cp_pbdat &= ~PB_SCL
 #define I2C_DELAY	udelay(2)	/* 1/4 I2C clock duration */
-#endif	/* CONFIG_SOFT_I2C */
 
 /*-----------------------------------------------------------------------
  * I2C EEPROM (24C164)
diff --git a/include/configs/utx8245.h b/include/configs/utx8245.h
index d203bb4..1df9ec7 100644
--- a/include/configs/utx8245.h
+++ b/include/configs/utx8245.h
@@ -235,8 +235,7 @@ protect on ${u-boot_startaddr} ${u-boot_endaddr}"
  *------------------------------------------------------------------*/
 #if 1
 #define CONFIG_HARD_I2C		1		/* To enable I2C support	*/
-#undef  CONFIG_SOFT_I2C				/* I2C bit-banged		*/
-#define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_SPEED		400000
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 #endif
 
diff --git a/include/configs/vct.h b/include/configs/vct.h
index b4b0949..c59a02e 100644
--- a/include/configs/vct.h
+++ b/include/configs/vct.h
@@ -246,11 +246,11 @@
 /*
  * I2C/EEPROM
  */
-#undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define	CONFIG_SOFT_I2C			/* I2C bit-banged		*/
-
-#define CONFIG_SYS_I2C_SPEED		83000	/* 83 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7f
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	83000	/* 83 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0x7f
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 
 /*
  * Software (bit-bang) I2C driver configuration
@@ -338,7 +338,7 @@ int vct_gpio_get(int pin);
 #undef CONFIG_CMD_USB
 
 #undef CONFIG_SMC911X
-#undef CONFIG_SOFT_I2C
+#undef CONFIG_SYS_I2C_SOFT
 #undef CONFIG_SOURCE
 #undef CONFIG_SYS_LONGHELP
 #undef CONFIG_TIMESTAMP
diff --git a/include/configs/vl_ma2sc.h b/include/configs/vl_ma2sc.h
index e2cf4f0..9c1d1c1 100644
--- a/include/configs/vl_ma2sc.h
+++ b/include/configs/vl_ma2sc.h
@@ -147,10 +147,13 @@
 #define CONFIG_SYS_I2C_SLAVE			0		/* not used */
 
 #ifndef CONFIG_HARD_I2C
-#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT			/* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED	CONFIG_SYS_I2C_SPEED
+#define CONFIG_SYS_I2C_SOFT_SLAVE	CONFIG_SYS_I2C_SLAVE
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 
 /* Software  I2C driver configuration */
-
 #define I2C_DELAY	udelay(2500000/CONFIG_SYS_I2C_SPEED)
 
 #define AT91_PIN_SDA	(1<<4)		/* AT91C_PIO_PB4 */
diff --git a/include/configs/vme8349.h b/include/configs/vme8349.h
index 61e02e6..eec7ee2 100644
--- a/include/configs/vme8349.h
+++ b/include/configs/vme8349.h
@@ -239,7 +239,6 @@
 /* I2C */
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#undef CONFIG_SOFT_I2C		/* I2C bit-banged */
 #define CONFIG_FSL_I2C
 #define CONFIG_I2C_CMD_TREE
 #define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
diff --git a/include/configs/zeus.h b/include/configs/zeus.h
index b0c3bd5..75195bc 100644
--- a/include/configs/zeus.h
+++ b/include/configs/zeus.h
@@ -169,7 +169,6 @@
  * I2C
  *----------------------------------------------------------------------*/
 #define CONFIG_HARD_I2C		1		/* I2C with hardware support	*/
-#undef	CONFIG_SOFT_I2C				/* I2C bit-banged		*/
 #define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
 #define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
 #define CONFIG_SYS_I2C_SLAVE		0x7F
diff --git a/include/i2c.h b/include/i2c.h
index afb4409..8aca0b8 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -287,6 +287,15 @@ unsigned int i2c_get_bus_speed(void);
  * Adjusts I2C pointers after U-Boot is relocated to DRAM
  */
 void i2c_reloc_fixup(void);
+#if defined(CONFIG_SYS_I2C_SOFT)
+void i2c_soft_init(void);
+void i2c_soft_active(void);
+void i2c_soft_tristate(void);
+int i2c_soft_read(void);
+void i2c_soft_sda(int bit);
+void i2c_soft_scl(int bit);
+void i2c_soft_delay(void);
+#endif
 #else
 
 /*
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support
  2012-10-22 17:40 ` [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support Heiko Schocher
@ 2012-10-22 22:16   ` Henrik Nordström
  2012-10-23  3:25     ` Heiko Schocher
  0 siblings, 1 reply; 25+ messages in thread
From: Henrik Nordström @ 2012-10-22 22:16 UTC (permalink / raw)
  To: u-boot

m?n 2012-10-22 klockan 19:40 +0200 skrev Heiko Schocher:
> +- Legacy I2C Support:	CONFIG_HARD_I2C | CONFIG_SOFT_I2C
> +
> +		NOTE: It is intended to move drivers to CONFIG_SYS_I2C which
> +		provides the following compelling advantages:
> +			1. Heiko to fill in

Something missing here?

Regards
Henrik

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support
  2012-10-22 22:16   ` Henrik Nordström
@ 2012-10-23  3:25     ` Heiko Schocher
  0 siblings, 0 replies; 25+ messages in thread
From: Heiko Schocher @ 2012-10-23  3:25 UTC (permalink / raw)
  To: u-boot

Hello Henrik Nordstr?m,

On 23.10.2012 00:16, Henrik Nordstr?m wrote:
> m?n 2012-10-22 klockan 19:40 +0200 skrev Heiko Schocher:
>> +- Legacy I2C Support:	CONFIG_HARD_I2C | CONFIG_SOFT_I2C
>> +
>> +		NOTE: It is intended to move drivers to CONFIG_SYS_I2C which
>> +		provides the following compelling advantages:
>> +			1. Heiko to fill in
>
> Something missing here?

Oh... this is removed in the 3/3 patch. Update this in the next
patchversion, thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-22 17:40 [U-Boot] [PATCH 0/3] Bring in new I2C framework Heiko Schocher
                   ` (2 preceding siblings ...)
  2012-10-22 17:40 ` [U-Boot] [PATCH 3/3] i2c, soft-i2c: switch to new " Heiko Schocher
@ 2012-10-25 21:37 ` Simon Glass
  2012-10-26  5:48   ` Heiko Schocher
  2012-10-26 18:44   ` Tom Rini
  3 siblings, 2 replies; 25+ messages in thread
From: Simon Glass @ 2012-10-25 21:37 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher <hs@denx.de> wrote:
> rebased/reworked the I2C multibus patches from Simon Glass found
> here:
>
> http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html
>
> It seems the timing is coming, to bring this in mainline and
> move boards over to the new i2c framework. As an example I
> converted the soft-i2c driver (and all boards using it) to
> the new framework, so this patchseries has to be tested
> intensively, as I can check compile only ...

I am very happy to see this, thank you.

I have brought this in and tried to get it running for Tegra. A few points:

1. The methods in struct i2c_adapter should IMO be passed a struct
i2c_adapter *, so they can determine which adapter is being accessed.
Otherwise I can't see how they would know.

2. The init is a bit odd, in that we can call init() repeatedly.
Perhaps that function should be renamed to reset, and the init should
be used for calling just once at the start?

3. Rather than each device having to call i2c_get_bus_num() to find
out what bus is referred to, why not just pass this information in? In
fact the adapter pointer can serve for this.

4. So perhaps the i2c read/write functions should change from:

int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)

to:

int i2c_read((struct i2c_adapter *adapter, uint addr, int alen, uchar
*buffer, int len)

Later, I wonder whether the concept of a 'current' i2c bus should be
maintained by the command line interpreter, rather than the i2c
system. Because to be honest, most of the drivers I see have to save
the current bus number, set the current bus, do the operation, then
set the bus back how they found it (to preserve whatever the user
things is the current bus).

Granted there is overhead with i2c muxes, but the i2c core can
remember the state of these muxes and doesn't have to switch things
until there has been a change since the last transaction.

This last suggestion can be dealt with later, but I thought I would bring it up.

Regards,
Simon

>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Piotr Wilczek <p.wilczek@samsung.com>
>
> Heiko Schocher (3):
>   i2c: add i2c_core and prepare for new multibus support
>   i2c: common changes for multibus/multiadapter support
>   i2c, soft-i2c: switch to new multibus/multiadapter support
>
>  README                                    |   89 +++++++-
>  arch/arm/include/asm/global_data.h        |    3 +
>  arch/arm/lib/board.c                      |   15 +-
>  arch/avr32/include/asm/global_data.h      |    3 +
>  arch/blackfin/include/asm/global_data.h   |    4 +-
>  arch/blackfin/lib/board.c                 |    7 +
>  arch/m68k/include/asm/global_data.h       |    3 +
>  arch/m68k/lib/board.c                     |   15 +-
>  arch/microblaze/include/asm/global_data.h |    3 +
>  arch/mips/include/asm/global_data.h       |    3 +
>  arch/mips/lib/board.c                     |    7 +
>  arch/nds32/include/asm/global_data.h      |    3 +
>  arch/nds32/lib/board.c                    |   10 +-
>  arch/nios2/include/asm/global_data.h      |    3 +
>  arch/powerpc/cpu/mpc8xx/video.c           |    4 +
>  arch/powerpc/include/asm/global_data.h    |    3 +
>  arch/powerpc/lib/board.c                  |   16 +-
>  arch/sh/include/asm/global_data.h         |    3 +
>  arch/sparc/include/asm/global_data.h      |    3 +
>  arch/x86/include/asm/global_data.h        |    3 +
>  board/BuS/eb_cpux9k2/cpux9k2.c            |    2 +-
>  board/BuS/vl_ma2sc/vl_ma2sc.c             |    2 +-
>  board/atc/atc.c                           |    2 +-
>  board/bluewater/snapper9260/snapper9260.c |    2 +-
>  board/cm5200/cm5200.c                     |    4 +-
>  board/cpu86/cpu86.c                       |    2 +-
>  board/cpu87/cpu87.c                       |    2 +-
>  board/emk/top9000/top9000.c               |    8 +-
>  board/eukrea/cpuat91/cpuat91.c            |    2 +-
>  board/freescale/m52277evb/README          |    2 +-
>  board/freescale/m53017evb/README          |    2 +-
>  board/freescale/m5373evb/README           |    2 +-
>  board/freescale/m54455evb/README          |    2 +-
>  board/freescale/m547xevb/README           |    2 +-
>  board/ids8247/ids8247.c                   |    2 +-
>  board/keymile/common/common.c             |    3 +-
>  board/keymile/common/ivm.c                |   15 +-
>  board/keymile/km82xx/km82xx.c             |    2 +-
>  board/keymile/km_arm/km_arm.c             |    8 +-
>  board/lwmon/lwmon.c                       |    2 +-
>  board/lwmon/pcmcia.c                      |    4 +-
>  board/pm826/pm826.c                       |    2 +-
>  board/pm828/pm828.c                       |    2 +-
>  board/sacsng/ioconfig.h                   |    2 +-
>  board/sandburst/karef/karef.c             |    1 -
>  board/siemens/SCM/scm.c                   |    2 +-
>  board/tqc/tqm8260/tqm8260.c               |    2 +-
>  board/tqc/tqm8272/tqm8272.c               |    2 +-
>  board/tqc/tqm8272/tqm8272.h               |    2 +-
>  common/cmd_date.c                         |    9 +
>  common/cmd_dtt.c                          |    9 +
>  common/cmd_eeprom.c                       |    3 +-
>  common/cmd_i2c.c                          |  118 ++++++---
>  common/env_eeprom.c                       |   14 +
>  common/stdio.c                            |   14 +-
>  drivers/i2c/Makefile                      |    3 +-
>  drivers/i2c/i2c_core.c                    |  367 +++++++++++++++++++++++++++++
>  drivers/i2c/soft_i2c.c                    |  122 ++++++----
>  include/configs/A3000.h                   |    4 +-
>  include/configs/BSC9131RDB.h              |    1 -
>  include/configs/CANBT.h                   |    4 +
>  include/configs/CPU86.h                   |    9 +-
>  include/configs/CPU87.h                   |    9 +-
>  include/configs/DU440.h                   |    1 -
>  include/configs/GEN860T.h                 |   36 ++--
>  include/configs/HIDDEN_DRAGON.h           |   10 +-
>  include/configs/IAD210.h                  |   12 +-
>  include/configs/ICU862.h                  |   14 +-
>  include/configs/IDS8247.h                 |   10 +-
>  include/configs/IP860.h                   |   10 +-
>  include/configs/IPHASE4539.h              |   12 +-
>  include/configs/JSE.h                     |    1 -
>  include/configs/KAREF.h                   |    1 -
>  include/configs/KUP4K.h                   |   12 +-
>  include/configs/KUP4X.h                   |   14 +-
>  include/configs/M5208EVBE.h               |    1 -
>  include/configs/M52277EVB.h               |    1 -
>  include/configs/M5235EVB.h                |    1 -
>  include/configs/M5271EVB.h                |    1 -
>  include/configs/M5275EVB.h                |    1 -
>  include/configs/M53017EVB.h               |    1 -
>  include/configs/M5329EVB.h                |    1 -
>  include/configs/M5373EVB.h                |    1 -
>  include/configs/M54451EVB.h               |    1 -
>  include/configs/M54455EVB.h               |    1 -
>  include/configs/M5475EVB.h                |    1 -
>  include/configs/M5485EVB.h                |    1 -
>  include/configs/METROBOX.h                |    1 -
>  include/configs/MHPC.h                    |    9 +-
>  include/configs/MPC8323ERDB.h             |    1 -
>  include/configs/MPC832XEMDS.h             |    1 -
>  include/configs/MPC8349EMDS.h             |    1 -
>  include/configs/MPC8349ITX.h              |    2 -
>  include/configs/MPC8360EMDS.h             |    1 -
>  include/configs/MPC8360ERDK.h             |    1 -
>  include/configs/MPC837XEMDS.h             |    1 -
>  include/configs/MPC837XERDB.h             |    1 -
>  include/configs/MPC8536DS.h               |    1 -
>  include/configs/MPC8540ADS.h              |    1 -
>  include/configs/MPC8541CDS.h              |    1 -
>  include/configs/MPC8544DS.h               |    1 -
>  include/configs/MPC8548CDS.h              |    3 +-
>  include/configs/MPC8555CDS.h              |    1 -
>  include/configs/MPC8560ADS.h              |    1 -
>  include/configs/MPC8568MDS.h              |    1 -
>  include/configs/MPC8569MDS.h              |    1 -
>  include/configs/MPC8572DS.h               |    1 -
>  include/configs/MPC8610HPCD.h             |    1 -
>  include/configs/MPC8641HPCN.h             |    1 -
>  include/configs/P1010RDB.h                |    1 -
>  include/configs/P1023RDS.h                |    1 -
>  include/configs/P1_P2_RDB.h               |    1 -
>  include/configs/P2020COME.h               |    1 -
>  include/configs/PM826.h                   |    9 +-
>  include/configs/PM828.h                   |    9 +-
>  include/configs/PMC440.h                  |    1 -
>  include/configs/R360MPI.h                 |    7 +-
>  include/configs/RPXClassic.h              |   16 +-
>  include/configs/RPXlite.h                 |   26 ++
>  include/configs/RRvision.h                |   13 +-
>  include/configs/SBC8540.h                 |    1 -
>  include/configs/SCM.h                     |   11 +-
>  include/configs/SXNI855T.h                |    8 +-
>  include/configs/Sandpoint8240.h           |   10 +-
>  include/configs/Sandpoint8245.h           |   14 +-
>  include/configs/TASREG.h                  |   27 +-
>  include/configs/TK885D.h                  |   13 +-
>  include/configs/TOP5200.h                 |   15 +-
>  include/configs/TOP860.h                  |   11 +-
>  include/configs/TQM8260.h                 |    9 +-
>  include/configs/TQM8272.h                 |   13 +-
>  include/configs/TQM834x.h                 |    1 -
>  include/configs/TQM855M.h                 |   13 +-
>  include/configs/TQM866M.h                 |   13 +-
>  include/configs/TQM885D.h                 |   13 +-
>  include/configs/alpr.h                    |    1 -
>  include/configs/aria.h                    |    1 -
>  include/configs/astro_mcf5373l.h          |    1 -
>  include/configs/bf533-ezkit.h             |   10 +-
>  include/configs/bf533-stamp.h             |   47 ++++-
>  include/configs/bf561-ezkit.h             |    9 +-
>  include/configs/bfin_adi_common.h         |    2 +-
>  include/configs/blackstamp.h              |    1 -
>  include/configs/cpuat91.h                 |    1 -
>  include/configs/debris.h                  |   10 +-
>  include/configs/eXalion.h                 |    2 +-
>  include/configs/eb_cpux9k2.h              |   14 +-
>  include/configs/ep8260.h                  |   14 +-
>  include/configs/ethernut5.h               |    9 +-
>  include/configs/ibf-dsp561.h              |    5 +-
>  include/configs/iocon.h                   |   11 +-
>  include/configs/km/keymile-common.h       |    3 -
>  include/configs/km/km83xx-common.h        |    3 +
>  include/configs/km/km_arm.h               |   26 ++-
>  include/configs/km82xx.h                  |   18 +-
>  include/configs/km_kirkwood.h             |   14 +-
>  include/configs/korat.h                   |    1 -
>  include/configs/lwmon.h                   |   13 +-
>  include/configs/lwmon5.h                  |    1 -
>  include/configs/mecp5123.h                |    1 -
>  include/configs/mpc5121ads.h              |    1 -
>  include/configs/nhk8815.h                 |    8 +-
>  include/configs/otc570.h                  |   18 +-
>  include/configs/p1_p2_rdb_pc.h            |    1 -
>  include/configs/p3p440.h                  |    1 -
>  include/configs/pcs440ep.h                |    1 -
>  include/configs/pdnb3.h                   |   11 +-
>  include/configs/quad100hd.h               |    1 -
>  include/configs/s5p_goni.h                |    7 +-
>  include/configs/s5pc210_universal.h       |    7 +-
>  include/configs/sacsng.h                  |   12 +-
>  include/configs/sbc405.h                  |    1 -
>  include/configs/sbc8349.h                 |    1 -
>  include/configs/sbc8548.h                 |    1 -
>  include/configs/sbc8560.h                 |    1 -
>  include/configs/sbc8641d.h                |    1 -
>  include/configs/sc3.h                     |    1 -
>  include/configs/snapper9260.h             |    9 +-
>  include/configs/socrates.h                |    1 -
>  include/configs/spc1920.h                 |   13 +-
>  include/configs/stxgp3.h                  |    1 -
>  include/configs/stxssa.h                  |    1 -
>  include/configs/top9000.h                 |   10 +-
>  include/configs/trats.h                   |    7 +-
>  include/configs/u8500_href.h              |    1 -
>  include/configs/uc100.h                   |   13 +-
>  include/configs/utx8245.h                 |    3 +-
>  include/configs/vct.h                     |   12 +-
>  include/configs/vl_ma2sc.h                |    7 +-
>  include/configs/vme8349.h                 |    1 -
>  include/configs/zeus.h                    |    1 -
>  include/i2c.h                             |  196 +++++++++++++++-
>  192 files changed, 1443 insertions(+), 533 deletions(-)
>  create mode 100644 drivers/i2c/i2c_core.c
>
> --
> 1.7.7.6
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-25 21:37 ` [U-Boot] [PATCH 0/3] Bring in new I2C framework Simon Glass
@ 2012-10-26  5:48   ` Heiko Schocher
  2012-10-26 16:07     ` Stephen Warren
  2012-10-26 16:08     ` Simon Glass
  2012-10-26 18:44   ` Tom Rini
  1 sibling, 2 replies; 25+ messages in thread
From: Heiko Schocher @ 2012-10-26  5:48 UTC (permalink / raw)
  To: u-boot

Hello Simon,

On 25.10.2012 23:37, Simon Glass wrote:
> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>  wrote:
>> rebased/reworked the I2C multibus patches from Simon Glass found
>> here:
>>
>> http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html
>>
>> It seems the timing is coming, to bring this in mainline and
>> move boards over to the new i2c framework. As an example I
>> converted the soft-i2c driver (and all boards using it) to
>> the new framework, so this patchseries has to be tested
>> intensively, as I can check compile only ...
>
> I am very happy to see this, thank you.

I am too ;-) and Sorry that I am only now ready ...

> I have brought this in and tried to get it running for Tegra. A few points:
>
> 1. The methods in struct i2c_adapter should IMO be passed a struct
> i2c_adapter *, so they can determine which adapter is being accessed.
> Otherwise I can't see how they would know.

They can get the current used adapter through the defines in
include/i2c.h:
[...]
#define I2C_ADAP_NR(bus)        i2c_adap[i2c_bus[bus].adapter]
#define I2C_BUS                 ((struct i2c_bus_hose *)gd->cur_i2c_bus)
#define I2C_ADAP                i2c_adap[I2C_BUS->adapter]
#define I2C_ADAP_HWNR           (I2C_ADAP->hwadapnr)

preparing just the fsl i2c driver and there I do for example:
drivers/i2c/fsl_i2c.c
[...]
static const struct fsl_i2c *i2c_dev[2] = {
         (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C_OFFSET),
#ifdef CONFIG_SYS_FSL_I2C2_OFFSET
         (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C2_OFFSET)
#endif
};
[...]
static int fsl_i2c_probe(uchar chip)
{
         struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[I2C_ADAP_HWNR];
[...]

but of course, we still can change the "struct i2c_adapter" if
needed ... but we have one more parameter ... Ok, not really a bad
problem.

> 2. The init is a bit odd, in that we can call init() repeatedly.
> Perhaps that function should be renamed to reset, and the init should
> be used for calling just once at the start?

What do you mean here exactly? I couldn?t parse this ...

> 3. Rather than each device having to call i2c_get_bus_num() to find
> out what bus is referred to, why not just pass this information in? In
> fact the adapter pointer can serve for this.

Not the "struct i2c_adapter" must passed, but the "struct
i2c_bus"!

And each device should know, which i2c bus it uses, or? So at
the end we should have something like i2c_read(struct i2c_bus *bus, ...)
calls ... and the i2c core can detect, if this bus is the
current, if so go on, if not switch to this bus. So at the
end i2c_set_bus_num would be go static ...

> 4. So perhaps the i2c read/write functions should change from:
>
> int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
>
> to:
>
> int i2c_read((struct i2c_adapter *adapter, uint addr, int alen, uchar
> *buffer, int len)

Yep, exactly, see comments to point 3 ...

That would be the best (and I think in previous discussions I defined
this as one goal ...), but this would be (another) big change,
because this is an *API* change, with maybe a lot of config file
changes ...

Let us bring in the new i2c framework with all i2c drivers converted,
and then do the next step ... maybe one step more, if mareks device
model is ready, we can switch easy to DM ... and maybe get this API
change for free ...

> Later, I wonder whether the concept of a 'current' i2c bus should be
> maintained by the command line interpreter, rather than the i2c
> system. Because to be honest, most of the drivers I see have to save
> the current bus number, set the current bus, do the operation, then
> set the bus back how they found it (to preserve whatever the user
> things is the current bus).

Yes, suboptimal ... but this is independent from the new i2c framework
patches!

It is possible (with old/new i2c bus framework) to introduce a
"current commandline i2c bus", and then, before calling i2c_read/write
from the commandline, call a i2c_set_bus_num() ... then we can get rid
of this store/restore current i2c bus ... waiting for patches ;-)

> Granted there is overhead with i2c muxes, but the i2c core can
> remember the state of these muxes and doesn't have to switch things
> until there has been a change since the last transaction.

This exactly do the i2c_set_bus_num() now!

> This last suggestion can be dealt with later, but I thought I would bring it up.

I am happy about every comment! :-)

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-26  5:48   ` Heiko Schocher
@ 2012-10-26 16:07     ` Stephen Warren
  2012-10-29  9:47       ` Heiko Schocher
  2012-10-26 16:08     ` Simon Glass
  1 sibling, 1 reply; 25+ messages in thread
From: Stephen Warren @ 2012-10-26 16:07 UTC (permalink / raw)
  To: u-boot

On 10/25/2012 11:48 PM, Heiko Schocher wrote:
> Hello Simon,
> 
> On 25.10.2012 23:37, Simon Glass wrote:
>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>  wrote:
>>> rebased/reworked the I2C multibus patches from Simon Glass found
>>> here:
>>>
>>> http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html
>>>
>>> It seems the timing is coming, to bring this in mainline and
>>> move boards over to the new i2c framework. As an example I
>>> converted the soft-i2c driver (and all boards using it) to
>>> the new framework, so this patchseries has to be tested
>>> intensively, as I can check compile only ...
>>
>> I am very happy to see this, thank you.
> 
> I am too ;-) and Sorry that I am only now ready ...
> 
>> I have brought this in and tried to get it running for Tegra. A few
>> points:
>>
>> 1. The methods in struct i2c_adapter should IMO be passed a struct
>> i2c_adapter *, so they can determine which adapter is being accessed.
>> Otherwise I can't see how they would know.
> 
> They can get the current used adapter through the defines in
> include/i2c.h:
> [...]
> #define I2C_ADAP_NR(bus)        i2c_adap[i2c_bus[bus].adapter]
> #define I2C_BUS                 ((struct i2c_bus_hose *)gd->cur_i2c_bus)
> #define I2C_ADAP                i2c_adap[I2C_BUS->adapter]
> #define I2C_ADAP_HWNR           (I2C_ADAP->hwadapnr)
> 
> preparing just the fsl i2c driver and there I do for example:
> drivers/i2c/fsl_i2c.c
> [...]
> static const struct fsl_i2c *i2c_dev[2] = {
>         (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C_OFFSET),
> #ifdef CONFIG_SYS_FSL_I2C2_OFFSET
>         (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C2_OFFSET)
> #endif
> };
> [...]
> static int fsl_i2c_probe(uchar chip)
> {
>         struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[I2C_ADAP_HWNR];
> [...]
> 
> but of course, we still can change the "struct i2c_adapter" if
> needed ... but we have one more parameter ... Ok, not really a bad
> problem.

That rather relies on their being a concept of a "current" I2C adapter.
It seems a little limiting to require that. What if the "current"
adapter is the user-selected adapter for commands to operate on, but
e.g. some power-management driver wants to use I2C to communicate with a
PMIC during the internals of some other command. Sure, you could save
and later restore the I2C core's idea of "current" adapter, but it'd
surely be cleaner to just pass around the I2C adapter ID or struct
pointer everywhere to avoid the need for save/restore.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-26  5:48   ` Heiko Schocher
  2012-10-26 16:07     ` Stephen Warren
@ 2012-10-26 16:08     ` Simon Glass
  2012-10-29  9:44       ` Heiko Schocher
  1 sibling, 1 reply; 25+ messages in thread
From: Simon Glass @ 2012-10-26 16:08 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Thu, Oct 25, 2012 at 10:48 PM, Heiko Schocher <hs@denx.de> wrote:
> Hello Simon,
>
>
> On 25.10.2012 23:37, Simon Glass wrote:
>>
>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>  wrote:
>>>
>>> rebased/reworked the I2C multibus patches from Simon Glass found
>>> here:
>>>
>>> http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html
>>>
>>> It seems the timing is coming, to bring this in mainline and
>>> move boards over to the new i2c framework. As an example I
>>> converted the soft-i2c driver (and all boards using it) to
>>> the new framework, so this patchseries has to be tested
>>> intensively, as I can check compile only ...
>>
>>
>> I am very happy to see this, thank you.
>
>
> I am too ;-) and Sorry that I am only now ready ...
>
>
>> I have brought this in and tried to get it running for Tegra. A few
>> points:
>>
>> 1. The methods in struct i2c_adapter should IMO be passed a struct
>> i2c_adapter *, so they can determine which adapter is being accessed.
>> Otherwise I can't see how they would know.
>
>
> They can get the current used adapter through the defines in
> include/i2c.h:
> [...]
> #define I2C_ADAP_NR(bus)        i2c_adap[i2c_bus[bus].adapter]
> #define I2C_BUS                 ((struct i2c_bus_hose *)gd->cur_i2c_bus)
> #define I2C_ADAP                i2c_adap[I2C_BUS->adapter]
> #define I2C_ADAP_HWNR           (I2C_ADAP->hwadapnr)
>
> preparing just the fsl i2c driver and there I do for example:
> drivers/i2c/fsl_i2c.c
> [...]
> static const struct fsl_i2c *i2c_dev[2] = {
>         (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C_OFFSET),
> #ifdef CONFIG_SYS_FSL_I2C2_OFFSET
>         (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C2_OFFSET)
> #endif
> };
> [...]
> static int fsl_i2c_probe(uchar chip)
> {
>         struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[I2C_ADAP_HWNR];
> [...]
>
> but of course, we still can change the "struct i2c_adapter" if
> needed ... but we have one more parameter ... Ok, not really a bad
> problem.
>
>
>> 2. The init is a bit odd, in that we can call init() repeatedly.
>> Perhaps that function should be renamed to reset, and the init should
>> be used for calling just once at the start?
>
>
> What do you mean here exactly? I couldn?t parse this ...

Well there is start-of-day setup, which I think should be called init.
This is done once on boot for each i2c adapter.

And then there is the i2c_init() which seems to be called whenever we
feel like it - e.g. to change speed. I suggest that we use init() to
mean start-of-day init and reset(), or similar, to mean any post-init.
I am not suggest that for this series, just as a future effort.

>
>
>> 3. Rather than each device having to call i2c_get_bus_num() to find
>> out what bus is referred to, why not just pass this information in? In
>> fact the adapter pointer can serve for this.
>
>
> Not the "struct i2c_adapter" must passed, but the "struct
> i2c_bus"!
>
> And each device should know, which i2c bus it uses, or? So at
> the end we should have something like i2c_read(struct i2c_bus *bus, ...)
> calls ... and the i2c core can detect, if this bus is the
> current, if so go on, if not switch to this bus. So at the
> end i2c_set_bus_num would be go static ...
>
>
>> 4. So perhaps the i2c read/write functions should change from:
>>
>> int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
>>
>> to:
>>
>> int i2c_read((struct i2c_adapter *adapter, uint addr, int alen, uchar
>> *buffer, int len)
>
>
> Yep, exactly, see comments to point 3 ...
>
> That would be the best (and I think in previous discussions I defined
> this as one goal ...), but this would be (another) big change,
> because this is an *API* change, with maybe a lot of config file
> changes ...
>
> Let us bring in the new i2c framework with all i2c drivers converted,
> and then do the next step ... maybe one step more, if mareks device
> model is ready, we can switch easy to DM ... and maybe get this API
> change for free ...

Yes. I certainly understand the need to fit in with what is already
there, and avoid a massive API change, which can be performed as a
follow-on patch anyway. With your info above I will adjust the tegra
driver to work with this and test it.

>
>
>> Later, I wonder whether the concept of a 'current' i2c bus should be
>> maintained by the command line interpreter, rather than the i2c
>> system. Because to be honest, most of the drivers I see have to save
>> the current bus number, set the current bus, do the operation, then
>> set the bus back how they found it (to preserve whatever the user
>> things is the current bus).
>
>
> Yes, suboptimal ... but this is independent from the new i2c framework
> patches!
>
> It is possible (with old/new i2c bus framework) to introduce a
> "current commandline i2c bus", and then, before calling i2c_read/write
> from the commandline, call a i2c_set_bus_num() ... then we can get rid
> of this store/restore current i2c bus ... waiting for patches ;-)

OK.

>
>
>> Granted there is overhead with i2c muxes, but the i2c core can
>> remember the state of these muxes and doesn't have to switch things
>> until there has been a change since the last transaction.
>
>
> This exactly do the i2c_set_bus_num() now!

Great.

>
>
>> This last suggestion can be dealt with later, but I thought I would bring
>> it up.
>
>
> I am happy about every comment! :-)

Thanks,
Simon

>
> bye,
> Heiko
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-25 21:37 ` [U-Boot] [PATCH 0/3] Bring in new I2C framework Simon Glass
  2012-10-26  5:48   ` Heiko Schocher
@ 2012-10-26 18:44   ` Tom Rini
  2012-10-29  9:53     ` Heiko Schocher
  1 sibling, 1 reply; 25+ messages in thread
From: Tom Rini @ 2012-10-26 18:44 UTC (permalink / raw)
  To: u-boot

On Thu, Oct 25, 2012 at 02:37:08PM -0700, Simon Glass wrote:

[snip]
> Later, I wonder whether the concept of a 'current' i2c bus should be
> maintained by the command line interpreter, rather than the i2c
> system. Because to be honest, most of the drivers I see have to save
> the current bus number, set the current bus, do the operation, then
> set the bus back how they found it (to preserve whatever the user
> things is the current bus).

I agree.  Lets move the notion of "current" to cmd_i2c and make
everything internally pass around the bus to operate on.  Or try going
down this path and find a fatal problem :)

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121026/f80ee320/attachment.pgp>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-26 16:08     ` Simon Glass
@ 2012-10-29  9:44       ` Heiko Schocher
  2012-10-29 13:48         ` Simon Glass
  0 siblings, 1 reply; 25+ messages in thread
From: Heiko Schocher @ 2012-10-29  9:44 UTC (permalink / raw)
  To: u-boot

Hello Simon,

On 26.10.2012 18:08, Simon Glass wrote:
> On Thu, Oct 25, 2012 at 10:48 PM, Heiko Schocher<hs@denx.de>  wrote:
>> Hello Simon,
>>
>>
>> On 25.10.2012 23:37, Simon Glass wrote:
>>>
>>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>   wrote:
[...]
>>> 2. The init is a bit odd, in that we can call init() repeatedly.
>>> Perhaps that function should be renamed to reset, and the init should
>>> be used for calling just once at the start?
>>
>>
>> What do you mean here exactly? I couldn?t parse this ...
>
> Well there is start-of-day setup, which I think should be called init.
> This is done once on boot for each i2c adapter.

Hmm... I am not sure if this is only done on boot, because we should
"close" or "deinit" an adapter if not used any more in U-Boot as the
U-Boot principle says:

http://www.denx.de/wiki/view/U-Boot/DesignPrinciples#2_Keep_it_Fast

So I want to add in future some "deinit" to every adapter, and
call it from i2c_set_bus() when switching to another i2c adapter ...

> And then there is the i2c_init() which seems to be called whenever we
> feel like it - e.g. to change speed. I suggest that we use init() to
> mean start-of-day init and reset(), or similar, to mean any post-init.
> I am not suggest that for this series, just as a future effort.

Yes, that should be changed. We do not need an init() in the i2c
API, as i2c_set_bus_num() do this for us (and later also the deinit())

We just need a set/get_speed() and a deblock()/reset() ?

Maybe a step in the API cleanup?

>>> 3. Rather than each device having to call i2c_get_bus_num() to find
>>> out what bus is referred to, why not just pass this information in? In
>>> fact the adapter pointer can serve for this.
>>
>>
>> Not the "struct i2c_adapter" must passed, but the "struct
>> i2c_bus"!
>>
>> And each device should know, which i2c bus it uses, or? So at
>> the end we should have something like i2c_read(struct i2c_bus *bus, ...)
>> calls ... and the i2c core can detect, if this bus is the
>> current, if so go on, if not switch to this bus. So at the
>> end i2c_set_bus_num would be go static ...
>>
>>
>>> 4. So perhaps the i2c read/write functions should change from:
>>>
>>> int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
>>>
>>> to:
>>>
>>> int i2c_read((struct i2c_adapter *adapter, uint addr, int alen, uchar
>>> *buffer, int len)
>>
>>
>> Yep, exactly, see comments to point 3 ...
>>
>> That would be the best (and I think in previous discussions I defined
>> this as one goal ...), but this would be (another) big change,
>> because this is an *API* change, with maybe a lot of config file
>> changes ...
>>
>> Let us bring in the new i2c framework with all i2c drivers converted,
>> and then do the next step ... maybe one step more, if mareks device
>> model is ready, we can switch easy to DM ... and maybe get this API
>> change for free ...
>
> Yes. I certainly understand the need to fit in with what is already
> there, and avoid a massive API change, which can be performed as a
> follow-on patch anyway. With your info above I will adjust the tegra
> driver to work with this and test it.

Ok, great! So I post v2 patches after you tested ...

And Yes, we should do this API change, but I tend to do this step after
the new i2c framework is stable and all i2c drivers are converted to it ...

>>> Later, I wonder whether the concept of a 'current' i2c bus should be
>>> maintained by the command line interpreter, rather than the i2c
>>> system. Because to be honest, most of the drivers I see have to save
>>> the current bus number, set the current bus, do the operation, then
>>> set the bus back how they found it (to preserve whatever the user
>>> things is the current bus).
>>
>>
>> Yes, suboptimal ... but this is independent from the new i2c framework
>> patches!
>>
>> It is possible (with old/new i2c bus framework) to introduce a
>> "current commandline i2c bus", and then, before calling i2c_read/write
>> from the commandline, call a i2c_set_bus_num() ... then we can get rid
>> of this store/restore current i2c bus ... waiting for patches ;-)
>
> OK.
>
>>
>>
>>> Granted there is overhead with i2c muxes, but the i2c core can
>>> remember the state of these muxes and doesn't have to switch things
>>> until there has been a change since the last transaction.
>>
>>
>> This exactly do the i2c_set_bus_num() now!
>
> Great.
>
>>
>>
>>> This last suggestion can be dealt with later, but I thought I would bring
>>> it up.
>>
>>
>> I am happy about every comment! :-)
>
> Thanks,
> Simon

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-26 16:07     ` Stephen Warren
@ 2012-10-29  9:47       ` Heiko Schocher
  2012-10-29 15:34         ` Stephen Warren
  0 siblings, 1 reply; 25+ messages in thread
From: Heiko Schocher @ 2012-10-29  9:47 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

On 26.10.2012 18:07, Stephen Warren wrote:
> On 10/25/2012 11:48 PM, Heiko Schocher wrote:
>> Hello Simon,
>>
>> On 25.10.2012 23:37, Simon Glass wrote:
>>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>   wrote:
>>>> rebased/reworked the I2C multibus patches from Simon Glass found
>>>> here:
>>>>
>>>> http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html
>>>>
>>>> It seems the timing is coming, to bring this in mainline and
>>>> move boards over to the new i2c framework. As an example I
>>>> converted the soft-i2c driver (and all boards using it) to
>>>> the new framework, so this patchseries has to be tested
>>>> intensively, as I can check compile only ...
>>>
>>> I am very happy to see this, thank you.
>>
>> I am too ;-) and Sorry that I am only now ready ...
>>
>>> I have brought this in and tried to get it running for Tegra. A few
>>> points:
>>>
>>> 1. The methods in struct i2c_adapter should IMO be passed a struct
>>> i2c_adapter *, so they can determine which adapter is being accessed.
>>> Otherwise I can't see how they would know.
>>
>> They can get the current used adapter through the defines in
>> include/i2c.h:
>> [...]
>> #define I2C_ADAP_NR(bus)        i2c_adap[i2c_bus[bus].adapter]
>> #define I2C_BUS                 ((struct i2c_bus_hose *)gd->cur_i2c_bus)
>> #define I2C_ADAP                i2c_adap[I2C_BUS->adapter]
>> #define I2C_ADAP_HWNR           (I2C_ADAP->hwadapnr)
>>
>> preparing just the fsl i2c driver and there I do for example:
>> drivers/i2c/fsl_i2c.c
>> [...]
>> static const struct fsl_i2c *i2c_dev[2] = {
>>          (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C_OFFSET),
>> #ifdef CONFIG_SYS_FSL_I2C2_OFFSET
>>          (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C2_OFFSET)
>> #endif
>> };
>> [...]
>> static int fsl_i2c_probe(uchar chip)
>> {
>>          struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[I2C_ADAP_HWNR];
>> [...]
>>
>> but of course, we still can change the "struct i2c_adapter" if
>> needed ... but we have one more parameter ... Ok, not really a bad
>> problem.
>
> That rather relies on their being a concept of a "current" I2C adapter.
> It seems a little limiting to require that. What if the "current"
> adapter is the user-selected adapter for commands to operate on, but
> e.g. some power-management driver wants to use I2C to communicate with a
> PMIC during the internals of some other command. Sure, you could save
> and later restore the I2C core's idea of "current" adapter, but it'd
> surely be cleaner to just pass around the I2C adapter ID or struct
> pointer everywhere to avoid the need for save/restore.

Yes, you are right, but just the same problem with current code!
You mixed here two things!

The idea behind the current i2c adapter was/is, that the i2c
core need to know, which bus is "current" because there is the
possibility that on one adapter are more i2c busses, because
of using i2c muxes ... and we must know, on which bus we are
currently, because if we want to switch to another bus, we must
first disable the old way (and maybe disable the i2c adapter too).
-> If we want this feature, we need a current adapter. If we say,
    Ok, we do not want this disabling... we can get rid of it, yes!

But I think it is safer to disable the i2c muxes, before
switching to another bus ... so this "current i2c adapter"
is an i2c core internal! We should of course change the i2c
API that we pass the bus to the i2c API, but, as I said this
to simon, this is another big change, and I want to have this
step after getting in the new i2c framework (and maybe hope,
that when we convert to mareks DM, we get this for free),
because we must also adapt for example all dtt, RTC, because
they need to know on which bus they resist, and we have to
config this ...

The problem from storing/restoring the "current cmdline i2c
bus", is another problem, which is an independent patch!
You can make with current code a patch, which holds the current
i2c cmdline bus in a variable, and then get rid of this store/
restore calls as for example found in cmd_date.c ...

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-26 18:44   ` Tom Rini
@ 2012-10-29  9:53     ` Heiko Schocher
  2012-10-30 22:38       ` Tom Rini
  0 siblings, 1 reply; 25+ messages in thread
From: Heiko Schocher @ 2012-10-29  9:53 UTC (permalink / raw)
  To: u-boot

Hello Tom,

On 26.10.2012 20:44, Tom Rini wrote:
> On Thu, Oct 25, 2012 at 02:37:08PM -0700, Simon Glass wrote:
>
> [snip]
>> Later, I wonder whether the concept of a 'current' i2c bus should be
>> maintained by the command line interpreter, rather than the i2c
>> system. Because to be honest, most of the drivers I see have to save
>> the current bus number, set the current bus, do the operation, then
>> set the bus back how they found it (to preserve whatever the user
>> things is the current bus).
>
> I agree.  Lets move the notion of "current" to cmd_i2c and make
> everything internally pass around the bus to operate on.  Or try going
> down this path and find a fatal problem :)

As I wrote to simon, stephen, this is an independent problem from the
new framework patches!

- There are two steps to do:
   - save the curent cmdline bus in a variable, and call i2c_set_bus_num()
     before you call i2c_* from the commandline, get rid of the store/restore
     calls ...

   - change the i2c API to pass the i2c bus in the i2c_* functions
     -> in the new i2c framework, i2c_set_bus() gets static and the
        gd->current_i2c_bus is used only in i2c_core.c

This two steps can be done in one step, but the second step is complicated
enough, so it is better to do it in two steps (I think)!

Waiting for patches ;-)

The i2c framework change is independent from this! The current_i2c_bus is
used i2c_core internally for storing the current active i2c bus, based
on the idea of having only one i2c bus active in U-Boot, see therefore
the U-Boot principle:

http://www.denx.de/wiki/view/U-Boot/DesignPrinciples#2_Keep_it_Fast
"Initialize devices only when they are needed within U-Boot, i.e. don't
initialize the Ethernet interface(s) unless U-Boot performs" [...]", etc.
(and don't forget to shut down these devices after using them -
otherwise nasty things may happen when you try to boot your OS). "

therefore the "current i2c bus" is needed! If we want to drop this
"U-Boot principle", we can get rid of current_i2c_bus ... (Ok, currently
U-Boot do not deactivate not used i2c adapters ...)

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-29  9:44       ` Heiko Schocher
@ 2012-10-29 13:48         ` Simon Glass
  2012-10-30  5:44           ` Heiko Schocher
  0 siblings, 1 reply; 25+ messages in thread
From: Simon Glass @ 2012-10-29 13:48 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Mon, Oct 29, 2012 at 2:44 AM, Heiko Schocher <hs@denx.de> wrote:
> Hello Simon,
>
>
> On 26.10.2012 18:08, Simon Glass wrote:
>>
>> On Thu, Oct 25, 2012 at 10:48 PM, Heiko Schocher<hs@denx.de>  wrote:
>>>
>>> Hello Simon,
>>>
>>>
>>> On 25.10.2012 23:37, Simon Glass wrote:
>>>>
>>>>
>>>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>   wrote:
>
> [...]
>
>>>> 2. The init is a bit odd, in that we can call init() repeatedly.
>>>> Perhaps that function should be renamed to reset, and the init should
>>>> be used for calling just once at the start?
>>>
>>>
>>>
>>> What do you mean here exactly? I couldn?t parse this ...
>>
>>
>> Well there is start-of-day setup, which I think should be called init.
>> This is done once on boot for each i2c adapter.
>
>
> Hmm... I am not sure if this is only done on boot, because we should
> "close" or "deinit" an adapter if not used any more in U-Boot as the
> U-Boot principle says:
>
> http://www.denx.de/wiki/view/U-Boot/DesignPrinciples#2_Keep_it_Fast
>
> So I want to add in future some "deinit" to every adapter, and
> call it from i2c_set_bus() when switching to another i2c adapter ...

Well deinit() should be probably be done before finishing U-Boot, not
after every transaction, since you don't know that the current
transaction will be the last.

When using FDT, you need to look up the available i2c ports in the
driver, and this should be done once at the start. If the i2c core can
call a suitable init function then this is easier, rather than us
having to keep track of whether the init is done or not.

>
>
>> And then there is the i2c_init() which seems to be called whenever we
>> feel like it - e.g. to change speed. I suggest that we use init() to
>> mean start-of-day init and reset(), or similar, to mean any post-init.
>> I am not suggest that for this series, just as a future effort.
>
>
> Yes, that should be changed. We do not need an init() in the i2c
> API, as i2c_set_bus_num() do this for us (and later also the deinit())
>
> We just need a set/get_speed() and a deblock()/reset() ?
>
> Maybe a step in the API cleanup?

Yes, a future step I think. I feel that i2c is one of the darker
corners of U-Boot and so am keen to get this tidied up.

>
>
>>>> 3. Rather than each device having to call i2c_get_bus_num() to find
>>>> out what bus is referred to, why not just pass this information in? In
>>>> fact the adapter pointer can serve for this.
>>>
>>>
>>>
>>> Not the "struct i2c_adapter" must passed, but the "struct
>>> i2c_bus"!
>>>
>>> And each device should know, which i2c bus it uses, or? So at
>>> the end we should have something like i2c_read(struct i2c_bus *bus, ...)
>>> calls ... and the i2c core can detect, if this bus is the
>>> current, if so go on, if not switch to this bus. So at the
>>> end i2c_set_bus_num would be go static ...
>>>
>>>
>>>> 4. So perhaps the i2c read/write functions should change from:
>>>>
>>>> int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
>>>>
>>>> to:
>>>>
>>>> int i2c_read((struct i2c_adapter *adapter, uint addr, int alen, uchar
>>>> *buffer, int len)
>>>
>>>
>>>
>>> Yep, exactly, see comments to point 3 ...
>>>
>>> That would be the best (and I think in previous discussions I defined
>>> this as one goal ...), but this would be (another) big change,
>>> because this is an *API* change, with maybe a lot of config file
>>> changes ...
>>>
>>> Let us bring in the new i2c framework with all i2c drivers converted,
>>> and then do the next step ... maybe one step more, if mareks device
>>> model is ready, we can switch easy to DM ... and maybe get this API
>>> change for free ...
>>
>>
>> Yes. I certainly understand the need to fit in with what is already
>> there, and avoid a massive API change, which can be performed as a
>> follow-on patch anyway. With your info above I will adjust the tegra
>> driver to work with this and test it.
>
>
> Ok, great! So I post v2 patches after you tested ...
>
> And Yes, we should do this API change, but I tend to do this step after
> the new i2c framework is stable and all i2c drivers are converted to it ...

[snip]

Regards,
Simon

> bye,
> Heiko
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-29  9:47       ` Heiko Schocher
@ 2012-10-29 15:34         ` Stephen Warren
  2012-10-29 15:56           ` Simon Glass
  2012-10-30  5:57           ` Heiko Schocher
  0 siblings, 2 replies; 25+ messages in thread
From: Stephen Warren @ 2012-10-29 15:34 UTC (permalink / raw)
  To: u-boot

On 10/29/2012 03:47 AM, Heiko Schocher wrote:
> Hello Stephen,
> 
> On 26.10.2012 18:07, Stephen Warren wrote:
>> On 10/25/2012 11:48 PM, Heiko Schocher wrote:
>>> Hello Simon,
>>>
>>> On 25.10.2012 23:37, Simon Glass wrote:
>>>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>   wrote:
>>>>> rebased/reworked the I2C multibus patches from Simon Glass found
>>>>> here:
>>>>>
>>>>> http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html
>>>>>
>>>>> It seems the timing is coming, to bring this in mainline and
>>>>> move boards over to the new i2c framework. As an example I
>>>>> converted the soft-i2c driver (and all boards using it) to
>>>>> the new framework, so this patchseries has to be tested
>>>>> intensively, as I can check compile only ...
>>>>
>>>> I am very happy to see this, thank you.
>>>
>>> I am too ;-) and Sorry that I am only now ready ...
>>>
>>>> I have brought this in and tried to get it running for Tegra. A few
>>>> points:
>>>>
>>>> 1. The methods in struct i2c_adapter should IMO be passed a struct
>>>> i2c_adapter *, so they can determine which adapter is being accessed.
>>>> Otherwise I can't see how they would know.
>>>
>>> They can get the current used adapter through the defines in
>>> include/i2c.h:
>>> [...]
>>> #define I2C_ADAP_NR(bus)        i2c_adap[i2c_bus[bus].adapter]
>>> #define I2C_BUS                 ((struct i2c_bus_hose *)gd->cur_i2c_bus)
>>> #define I2C_ADAP                i2c_adap[I2C_BUS->adapter]
>>> #define I2C_ADAP_HWNR           (I2C_ADAP->hwadapnr)
>>>
>>> preparing just the fsl i2c driver and there I do for example:
>>> drivers/i2c/fsl_i2c.c
>>> [...]
>>> static const struct fsl_i2c *i2c_dev[2] = {
>>>          (struct fsl_i2c *) (CONFIG_SYS_IMMR +
>>> CONFIG_SYS_FSL_I2C_OFFSET),
>>> #ifdef CONFIG_SYS_FSL_I2C2_OFFSET
>>>          (struct fsl_i2c *) (CONFIG_SYS_IMMR +
>>> CONFIG_SYS_FSL_I2C2_OFFSET)
>>> #endif
>>> };
>>> [...]
>>> static int fsl_i2c_probe(uchar chip)
>>> {
>>>          struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[I2C_ADAP_HWNR];
>>> [...]
>>>
>>> but of course, we still can change the "struct i2c_adapter" if
>>> needed ... but we have one more parameter ... Ok, not really a bad
>>> problem.
>>
>> That rather relies on their being a concept of a "current" I2C adapter.
>> It seems a little limiting to require that. What if the "current"
>> adapter is the user-selected adapter for commands to operate on, but
>> e.g. some power-management driver wants to use I2C to communicate with a
>> PMIC during the internals of some other command. Sure, you could save
>> and later restore the I2C core's idea of "current" adapter, but it'd
>> surely be cleaner to just pass around the I2C adapter ID or struct
>> pointer everywhere to avoid the need for save/restore.
> 
> Yes, you are right, but just the same problem with current code!
> You mixed here two things!

I think you're reading more into what I was saying than what I actually
said.

If there are e.g. 4 I2C controllers in an SoC, the driver needs to know
which one is in use. Passing that information directly to the driver
functions is much simple than requiring the SoC I2C driver to go grovel
in some I2C core global variables to find out the same information.

This is all unrelated to I2C bus muxes; they shouldn't be implemented as
part of an SoC I2C driver anyway, so the driver shouldn't know about bus
muxes before or after this patch - the I2C core should manage that.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-29 15:34         ` Stephen Warren
@ 2012-10-29 15:56           ` Simon Glass
  2012-10-30  5:57           ` Heiko Schocher
  1 sibling, 0 replies; 25+ messages in thread
From: Simon Glass @ 2012-10-29 15:56 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Mon, Oct 29, 2012 at 8:34 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 10/29/2012 03:47 AM, Heiko Schocher wrote:
>> Hello Stephen,
>>
>> On 26.10.2012 18:07, Stephen Warren wrote:
>>> On 10/25/2012 11:48 PM, Heiko Schocher wrote:
>>>> Hello Simon,
>>>>
>>>> On 25.10.2012 23:37, Simon Glass wrote:
>>>>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>   wrote:
>>>>>> rebased/reworked the I2C multibus patches from Simon Glass found
>>>>>> here:
>>>>>>
>>>>>> http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html
>>>>>>
>>>>>> It seems the timing is coming, to bring this in mainline and
>>>>>> move boards over to the new i2c framework. As an example I
>>>>>> converted the soft-i2c driver (and all boards using it) to
>>>>>> the new framework, so this patchseries has to be tested
>>>>>> intensively, as I can check compile only ...
>>>>>
>>>>> I am very happy to see this, thank you.
>>>>
>>>> I am too ;-) and Sorry that I am only now ready ...
>>>>
>>>>> I have brought this in and tried to get it running for Tegra. A few
>>>>> points:
>>>>>
>>>>> 1. The methods in struct i2c_adapter should IMO be passed a struct
>>>>> i2c_adapter *, so they can determine which adapter is being accessed.
>>>>> Otherwise I can't see how they would know.
>>>>
>>>> They can get the current used adapter through the defines in
>>>> include/i2c.h:
>>>> [...]
>>>> #define I2C_ADAP_NR(bus)        i2c_adap[i2c_bus[bus].adapter]
>>>> #define I2C_BUS                 ((struct i2c_bus_hose *)gd->cur_i2c_bus)
>>>> #define I2C_ADAP                i2c_adap[I2C_BUS->adapter]
>>>> #define I2C_ADAP_HWNR           (I2C_ADAP->hwadapnr)
>>>>
>>>> preparing just the fsl i2c driver and there I do for example:
>>>> drivers/i2c/fsl_i2c.c
>>>> [...]
>>>> static const struct fsl_i2c *i2c_dev[2] = {
>>>>          (struct fsl_i2c *) (CONFIG_SYS_IMMR +
>>>> CONFIG_SYS_FSL_I2C_OFFSET),
>>>> #ifdef CONFIG_SYS_FSL_I2C2_OFFSET
>>>>          (struct fsl_i2c *) (CONFIG_SYS_IMMR +
>>>> CONFIG_SYS_FSL_I2C2_OFFSET)
>>>> #endif
>>>> };
>>>> [...]
>>>> static int fsl_i2c_probe(uchar chip)
>>>> {
>>>>          struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[I2C_ADAP_HWNR];
>>>> [...]
>>>>
>>>> but of course, we still can change the "struct i2c_adapter" if
>>>> needed ... but we have one more parameter ... Ok, not really a bad
>>>> problem.
>>>
>>> That rather relies on their being a concept of a "current" I2C adapter.
>>> It seems a little limiting to require that. What if the "current"
>>> adapter is the user-selected adapter for commands to operate on, but
>>> e.g. some power-management driver wants to use I2C to communicate with a
>>> PMIC during the internals of some other command. Sure, you could save
>>> and later restore the I2C core's idea of "current" adapter, but it'd
>>> surely be cleaner to just pass around the I2C adapter ID or struct
>>> pointer everywhere to avoid the need for save/restore.
>>
>> Yes, you are right, but just the same problem with current code!
>> You mixed here two things!
>
> I think you're reading more into what I was saying than what I actually
> said.
>
> If there are e.g. 4 I2C controllers in an SoC, the driver needs to know
> which one is in use. Passing that information directly to the driver
> functions is much simple than requiring the SoC I2C driver to go grovel
> in some I2C core global variables to find out the same information.

I think Heiko agreed with this, just that he wants to take things a
step at a time.

>
> This is all unrelated to I2C bus muxes; they shouldn't be implemented as
> part of an SoC I2C driver anyway, so the driver shouldn't know about bus
> muxes before or after this patch - the I2C core should manage that.

Regards,
Simon

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-29 13:48         ` Simon Glass
@ 2012-10-30  5:44           ` Heiko Schocher
  0 siblings, 0 replies; 25+ messages in thread
From: Heiko Schocher @ 2012-10-30  5:44 UTC (permalink / raw)
  To: u-boot

Hello Simon,

On 29.10.2012 14:48, Simon Glass wrote:
> Hi Heiko,
>
> On Mon, Oct 29, 2012 at 2:44 AM, Heiko Schocher<hs@denx.de>  wrote:
>> Hello Simon,
>>
>>
>> On 26.10.2012 18:08, Simon Glass wrote:
>>>
>>> On Thu, Oct 25, 2012 at 10:48 PM, Heiko Schocher<hs@denx.de>   wrote:
>>>>
>>>> Hello Simon,
>>>>
>>>>
>>>> On 25.10.2012 23:37, Simon Glass wrote:
>>>>>
>>>>>
>>>>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>    wrote:
>>
>> [...]
>>
>>>>> 2. The init is a bit odd, in that we can call init() repeatedly.
>>>>> Perhaps that function should be renamed to reset, and the init should
>>>>> be used for calling just once at the start?
>>>>
>>>>
>>>>
>>>> What do you mean here exactly? I couldn?t parse this ...
>>>
>>>
>>> Well there is start-of-day setup, which I think should be called init.
>>> This is done once on boot for each i2c adapter.
>>
>>
>> Hmm... I am not sure if this is only done on boot, because we should
>> "close" or "deinit" an adapter if not used any more in U-Boot as the
>> U-Boot principle says:
>>
>> http://www.denx.de/wiki/view/U-Boot/DesignPrinciples#2_Keep_it_Fast
>>
>> So I want to add in future some "deinit" to every adapter, and
>> call it from i2c_set_bus() when switching to another i2c adapter ...
>
> Well deinit() should be probably be done before finishing U-Boot, not
> after every transaction, since you don't know that the current
> transaction will be the last.

Not after every transaction, only when switching to another adapter,
or before booting linux ...

> When using FDT, you need to look up the available i2c ports in the
> driver, and this should be done once at the start. If the i2c core can
> call a suitable init function then this is easier, rather than us
> having to keep track of whether the init is done or not.

Dummy question, why is this needed when using FDT?

>>> And then there is the i2c_init() which seems to be called whenever we
>>> feel like it - e.g. to change speed. I suggest that we use init() to
>>> mean start-of-day init and reset(), or similar, to mean any post-init.
>>> I am not suggest that for this series, just as a future effort.
>>
>>
>> Yes, that should be changed. We do not need an init() in the i2c
>> API, as i2c_set_bus_num() do this for us (and later also the deinit())
>>
>> We just need a set/get_speed() and a deblock()/reset() ?
>>
>> Maybe a step in the API cleanup?
>
> Yes, a future step I think. I feel that i2c is one of the darker
> corners of U-Boot and so am keen to get this tidied up.

Patches are welcome! Let us bring in the new framework, clean up
the i2c API / maybe DM integration, then we are on a good way I
think ...

[...]

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-29 15:34         ` Stephen Warren
  2012-10-29 15:56           ` Simon Glass
@ 2012-10-30  5:57           ` Heiko Schocher
  2012-10-30 16:50             ` Stephen Warren
  1 sibling, 1 reply; 25+ messages in thread
From: Heiko Schocher @ 2012-10-30  5:57 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

On 29.10.2012 16:34, Stephen Warren wrote:
> On 10/29/2012 03:47 AM, Heiko Schocher wrote:
>> Hello Stephen,
>>
>> On 26.10.2012 18:07, Stephen Warren wrote:
>>> On 10/25/2012 11:48 PM, Heiko Schocher wrote:
>>>> Hello Simon,
>>>>
>>>> On 25.10.2012 23:37, Simon Glass wrote:
>>>>> On Mon, Oct 22, 2012 at 10:40 AM, Heiko Schocher<hs@denx.de>    wrote:
[...]
>>> That rather relies on their being a concept of a "current" I2C adapter.
>>> It seems a little limiting to require that. What if the "current"
>>> adapter is the user-selected adapter for commands to operate on, but
>>> e.g. some power-management driver wants to use I2C to communicate with a
>>> PMIC during the internals of some other command. Sure, you could save
>>> and later restore the I2C core's idea of "current" adapter, but it'd
>>> surely be cleaner to just pass around the I2C adapter ID or struct
>>> pointer everywhere to avoid the need for save/restore.
>>
>> Yes, you are right, but just the same problem with current code!
>> You mixed here two things!
>
> I think you're reading more into what I was saying than what I actually
> said.

Sorry, maybe I misunderstood you ...

> If there are e.g. 4 I2C controllers in an SoC, the driver needs to know
> which one is in use. Passing that information directly to the driver
> functions is much simple than requiring the SoC I2C driver to go grovel
> in some I2C core global variables to find out the same information.

Ah, do you mean we should change the i2c adapter struct from:

struct i2c_adapter {
        void            (*init)(int speed, int slaveaddr);
        int             (*probe)(uint8_t chip);
        int             (*read)(uint8_t chip, uint addr, int alen,
                                uint8_t *buffer, int len);
        int             (*write)(uint8_t chip, uint addr, int alen,
                                uint8_t *buffer, int len);
        uint            (*set_bus_speed)(uint speed);
[...]

to

struct i2c_adapter {
        void            (*init)(struct i2c_adapter *adap, int speed, int slaveaddr);
        int             (*probe)(struct i2c_adapter *adap, uint8_t chip);
        int             (*read)(struct i2c_adapter *adap, uint8_t chip, uint addr, int alen,
                                uint8_t *buffer, int len);
        int             (*write)(struct i2c_adapter *adap, uint8_t chip, uint addr, int alen,
                                uint8_t *buffer, int len);
        uint            (*set_bus_speed)(struct i2c_adapter *adap, uint speed);
[...]
?

We can do this. Simon suggested this too ...

@Simon: Is this Ok with you?

Nevertheless, we need a "cur_i2c_bus" pointer, as the i2c core, needs
to know the current i2c bus for detecting if the bus, which whould be
accessed is the current or not and a switching to another bus is needed.

> This is all unrelated to I2C bus muxes; they shouldn't be implemented as
> part of an SoC I2C driver anyway, so the driver shouldn't know about bus
> muxes before or after this patch - the I2C core should manage that.

Exactly! And that do the new i2c framework in i2c_core.c!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-30  5:57           ` Heiko Schocher
@ 2012-10-30 16:50             ` Stephen Warren
  2012-10-30 17:22               ` Simon Glass
  0 siblings, 1 reply; 25+ messages in thread
From: Stephen Warren @ 2012-10-30 16:50 UTC (permalink / raw)
  To: u-boot

On 10/29/2012 11:57 PM, Heiko Schocher wrote:
> Hello Stephen,
> 
> On 29.10.2012 16:34, Stephen Warren wrote:
...
>> If there are e.g. 4 I2C controllers in an SoC, the driver needs to know
>> which one is in use. Passing that information directly to the driver
>> functions is much simple than requiring the SoC I2C driver to go grovel
>> in some I2C core global variables to find out the same information.
> 
> Ah, do you mean we should change the i2c adapter struct from:
> 
> struct i2c_adapter {
>        void            (*init)(int speed, int slaveaddr);
>        int             (*probe)(uint8_t chip);
>        int             (*read)(uint8_t chip, uint addr, int alen,
>                                uint8_t *buffer, int len);
>        int             (*write)(uint8_t chip, uint addr, int alen,
>                                uint8_t *buffer, int len);
>        uint            (*set_bus_speed)(uint speed);
> [...]
> 
> to
> 
> struct i2c_adapter {
>        void            (*init)(struct i2c_adapter *adap, int speed, int
> slaveaddr);
>        int             (*probe)(struct i2c_adapter *adap, uint8_t chip);
>        int             (*read)(struct i2c_adapter *adap, uint8_t chip,
> uint addr, int alen,
>                                uint8_t *buffer, int len);
>        int             (*write)(struct i2c_adapter *adap, uint8_t chip,
> uint addr, int alen,
>                                uint8_t *buffer, int len);
>        uint            (*set_bus_speed)(struct i2c_adapter *adap, uint
> speed);
> [...]
> ?
> 
> We can do this. Simon suggested this too ...

Yes, exactly. (the functions will need some way to get information out
of the struct i2c_adapter; I assume there's some kind of driver_private
field in there too).

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-30 16:50             ` Stephen Warren
@ 2012-10-30 17:22               ` Simon Glass
  2012-10-31  5:02                 ` Heiko Schocher
  2012-10-31  5:20                 ` Tom Rini
  0 siblings, 2 replies; 25+ messages in thread
From: Simon Glass @ 2012-10-30 17:22 UTC (permalink / raw)
  To: u-boot

Hi,

On Tue, Oct 30, 2012 at 9:50 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 10/29/2012 11:57 PM, Heiko Schocher wrote:
>> Hello Stephen,
>>
>> On 29.10.2012 16:34, Stephen Warren wrote:
> ...
>>> If there are e.g. 4 I2C controllers in an SoC, the driver needs to know
>>> which one is in use. Passing that information directly to the driver
>>> functions is much simple than requiring the SoC I2C driver to go grovel
>>> in some I2C core global variables to find out the same information.
>>
>> Ah, do you mean we should change the i2c adapter struct from:
>>
>> struct i2c_adapter {
>>        void            (*init)(int speed, int slaveaddr);
>>        int             (*probe)(uint8_t chip);
>>        int             (*read)(uint8_t chip, uint addr, int alen,
>>                                uint8_t *buffer, int len);
>>        int             (*write)(uint8_t chip, uint addr, int alen,
>>                                uint8_t *buffer, int len);
>>        uint            (*set_bus_speed)(uint speed);
>> [...]
>>
>> to
>>
>> struct i2c_adapter {
>>        void            (*init)(struct i2c_adapter *adap, int speed, int
>> slaveaddr);
>>        int             (*probe)(struct i2c_adapter *adap, uint8_t chip);
>>        int             (*read)(struct i2c_adapter *adap, uint8_t chip,
>> uint addr, int alen,
>>                                uint8_t *buffer, int len);
>>        int             (*write)(struct i2c_adapter *adap, uint8_t chip,
>> uint addr, int alen,
>>                                uint8_t *buffer, int len);
>>        uint            (*set_bus_speed)(struct i2c_adapter *adap, uint
>> speed);
>> [...]
>> ?
>>
>> We can do this. Simon suggested this too ...
>
> Yes, exactly. (the functions will need some way to get information out
> of the struct i2c_adapter; I assume there's some kind of driver_private
> field in there too).

Yes.

I will post a few patches to move Tegra over to the new framework as
it is, so that people can see the impact. Given that every driver has
to change, it would be my preference to set the i2c API once. But I
suppose within a short while everything will move to the device model,
so perhaps the job of this series is just to move things in the right
direction?

Regards,
Simon

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-29  9:53     ` Heiko Schocher
@ 2012-10-30 22:38       ` Tom Rini
  0 siblings, 0 replies; 25+ messages in thread
From: Tom Rini @ 2012-10-30 22:38 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 29, 2012 at 10:53:10AM +0100, Heiko Schocher wrote:
> Hello Tom,
> 
> On 26.10.2012 20:44, Tom Rini wrote:
> >On Thu, Oct 25, 2012 at 02:37:08PM -0700, Simon Glass wrote:
> >
> >[snip]
> >>Later, I wonder whether the concept of a 'current' i2c bus should be
> >>maintained by the command line interpreter, rather than the i2c
> >>system. Because to be honest, most of the drivers I see have to save
> >>the current bus number, set the current bus, do the operation, then
> >>set the bus back how they found it (to preserve whatever the user
> >>things is the current bus).
> >
> >I agree.  Lets move the notion of "current" to cmd_i2c and make
> >everything internally pass around the bus to operate on.  Or try going
> >down this path and find a fatal problem :)
> 
> As I wrote to simon, stephen, this is an independent problem from the
> new framework patches!

OK.  I was hoping we could just:
- Change init_func_i2c (for ARM/m68k/ppc/nds32, equiv elsewhere) to init
  all configured busses.
- Change the CLI part to track what bus it is operating on.

It sounds like it's more work than just this, really.  Since there is
agreement to push things further after this update, yes, OK, we can go
one step at a time here.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121030/30eda42a/attachment.pgp>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-30 17:22               ` Simon Glass
@ 2012-10-31  5:02                 ` Heiko Schocher
  2012-10-31  5:20                 ` Tom Rini
  1 sibling, 0 replies; 25+ messages in thread
From: Heiko Schocher @ 2012-10-31  5:02 UTC (permalink / raw)
  To: u-boot

Hello Simon,

On 30.10.2012 18:22, Simon Glass wrote:
> Hi,
>
> On Tue, Oct 30, 2012 at 9:50 AM, Stephen Warren<swarren@wwwdotorg.org>  wrote:
>> On 10/29/2012 11:57 PM, Heiko Schocher wrote:
>>> Hello Stephen,
>>>
>>> On 29.10.2012 16:34, Stephen Warren wrote:
>> ...
>>>> If there are e.g. 4 I2C controllers in an SoC, the driver needs to know
>>>> which one is in use. Passing that information directly to the driver
>>>> functions is much simple than requiring the SoC I2C driver to go grovel
>>>> in some I2C core global variables to find out the same information.
>>>
>>> Ah, do you mean we should change the i2c adapter struct from:
>>>
>>> struct i2c_adapter {
>>>         void            (*init)(int speed, int slaveaddr);
>>>         int             (*probe)(uint8_t chip);
>>>         int             (*read)(uint8_t chip, uint addr, int alen,
>>>                                 uint8_t *buffer, int len);
>>>         int             (*write)(uint8_t chip, uint addr, int alen,
>>>                                 uint8_t *buffer, int len);
>>>         uint            (*set_bus_speed)(uint speed);
>>> [...]
>>>
>>> to
>>>
>>> struct i2c_adapter {
>>>         void            (*init)(struct i2c_adapter *adap, int speed, int
>>> slaveaddr);
>>>         int             (*probe)(struct i2c_adapter *adap, uint8_t chip);
>>>         int             (*read)(struct i2c_adapter *adap, uint8_t chip,
>>> uint addr, int alen,
>>>                                 uint8_t *buffer, int len);
>>>         int             (*write)(struct i2c_adapter *adap, uint8_t chip,
>>> uint addr, int alen,
>>>                                 uint8_t *buffer, int len);
>>>         uint            (*set_bus_speed)(struct i2c_adapter *adap, uint
>>> speed);
>>> [...]
>>> ?
>>>
>>> We can do this. Simon suggested this too ...
>>
>> Yes, exactly. (the functions will need some way to get information out
>> of the struct i2c_adapter; I assume there's some kind of driver_private
>> field in there too).
>
> Yes.
>
> I will post a few patches to move Tegra over to the new framework as
> it is, so that people can see the impact. Given that every driver has
> to change, it would be my preference to set the i2c API once. But I
> suppose within a short while everything will move to the device model,
> so perhaps the job of this series is just to move things in the right
> direction?

Yes, but not only, I think the i2c framework needs an update.

bye,
heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 0/3] Bring in new I2C framework
  2012-10-30 17:22               ` Simon Glass
  2012-10-31  5:02                 ` Heiko Schocher
@ 2012-10-31  5:20                 ` Tom Rini
  1 sibling, 0 replies; 25+ messages in thread
From: Tom Rini @ 2012-10-31  5:20 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 30, 2012 at 10:22:54AM -0700, Simon Glass wrote:
> Hi,
> 
> On Tue, Oct 30, 2012 at 9:50 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> > On 10/29/2012 11:57 PM, Heiko Schocher wrote:
> >> Hello Stephen,
> >>
> >> On 29.10.2012 16:34, Stephen Warren wrote:
> > ...
> >>> If there are e.g. 4 I2C controllers in an SoC, the driver needs to know
> >>> which one is in use. Passing that information directly to the driver
> >>> functions is much simple than requiring the SoC I2C driver to go grovel
> >>> in some I2C core global variables to find out the same information.
> >>
> >> Ah, do you mean we should change the i2c adapter struct from:
> >>
> >> struct i2c_adapter {
> >>        void            (*init)(int speed, int slaveaddr);
> >>        int             (*probe)(uint8_t chip);
> >>        int             (*read)(uint8_t chip, uint addr, int alen,
> >>                                uint8_t *buffer, int len);
> >>        int             (*write)(uint8_t chip, uint addr, int alen,
> >>                                uint8_t *buffer, int len);
> >>        uint            (*set_bus_speed)(uint speed);
> >> [...]
> >>
> >> to
> >>
> >> struct i2c_adapter {
> >>        void            (*init)(struct i2c_adapter *adap, int speed, int
> >> slaveaddr);
> >>        int             (*probe)(struct i2c_adapter *adap, uint8_t chip);
> >>        int             (*read)(struct i2c_adapter *adap, uint8_t chip,
> >> uint addr, int alen,
> >>                                uint8_t *buffer, int len);
> >>        int             (*write)(struct i2c_adapter *adap, uint8_t chip,
> >> uint addr, int alen,
> >>                                uint8_t *buffer, int len);
> >>        uint            (*set_bus_speed)(struct i2c_adapter *adap, uint
> >> speed);
> >> [...]
> >> ?
> >>
> >> We can do this. Simon suggested this too ...
> >
> > Yes, exactly. (the functions will need some way to get information out
> > of the struct i2c_adapter; I assume there's some kind of driver_private
> > field in there too).
> 
> Yes.
> 
> I will post a few patches to move Tegra over to the new framework as
> it is, so that people can see the impact. Given that every driver has
> to change, it would be my preference to set the i2c API once. But I
> suppose within a short while everything will move to the device model,
> so perhaps the job of this series is just to move things in the right
> direction?

Funny enough I don't see a UDM-i2c.txt file, so I guess the community
gets to think about that one :)

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121030/48d42ea8/attachment.pgp>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support
  2012-01-17  7:12 Simon Glass
@ 2012-01-17  7:12 ` Simon Glass
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Glass @ 2012-01-17  7:12 UTC (permalink / raw)
  To: u-boot

From: Heiko Schocher <hs@denx.de>

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
 README                          |   82 ++++++++++++++++++++++++-
 arch/arm/lib/board.c            |    3 +-
 arch/blackfin/lib/board.c       |    7 ++
 arch/m68k/lib/board.c           |   18 +++++-
 arch/mips/lib/board.c           |    7 ++
 arch/powerpc/cpu/mpc8xx/video.c |    4 +
 arch/powerpc/lib/board.c        |   18 +++++-
 common/cmd_date.c               |    9 +++
 common/cmd_dtt.c                |    9 +++
 common/cmd_i2c.c                |  127 +++++++++++++++++++++++++-------------
 common/stdio.c                  |   13 ++++-
 include/i2c.h                   |    9 ---
 12 files changed, 242 insertions(+), 64 deletions(-)

diff --git a/README b/README
index 7adf7c7..fe1c0d9 100644
--- a/README
+++ b/README
@@ -1669,9 +1669,85 @@ The following options need to be configured:
 		on those systems that support this (optional)
 		feature, like the TQM8xxL modules.
 
-- I2C Support:	CONFIG_HARD_I2C | CONFIG_SOFT_I2C
-
-		These enable I2C serial bus commands. Defining either of
+- I2C Support:	CONFIG_SYS_I2C
+
+		This enable the NEW i2c subsystem, and will allow you to use
+		i2c commands at the u-boot command line (as long as you set
+		CONFIG_CMD_I2C in CONFIG_COMMANDS) and communicate with i2c
+		based realtime clock chips or other i2c devices. See
+		common/cmd_i2c.c for a description of the command line
+		interface.
+
+		additional defines:
+
+		CONFIG_SYS_NUM_I2C_ADAPTERS
+		define how many i2c adapters you want to use on your
+		hardware. If you need only 1 i2c adapter, you can ommit
+		this define.
+
+		CONFIG_SYS_I2C_ADAPTERS
+		hold a list of adapters you want to use, for example:
+		{&soft_i2c_adap[0], &mpc5xxx_i2c_adap[0]}
+		with this configuration you have one soft_i2c adapter,
+		and one mpc5xxx i2c adapter.
+
+		No I2C adapters current suppor this new interface.
+
+		You need to define for each adapter a speed and a
+		slave address.
+
+		CONFIG_SYS_NUM_I2C_BUSSES
+		Hold the number of i2c busses you want to use. If you
+		don't use/have i2c muxes on your i2c bus, this
+		is equal to CONFIG_SYS_NUM_I2C_ADAPTERS, and you can
+		omit this define.
+
+		CONFIG_SYS_I2C_DIRECT_BUS
+		define this, if you don't use i2c muxes on your hardware.
+		if CONFIG_SYS_I2C_MAX_HOPS is not defined or == 0 you can
+		omit this define.
+
+		CONFIG_SYS_I2C_MAX_HOPS
+		define how many muxes are maximal consecutively connected
+		on one i2c bus.
+
+		CONFIG_SYS_I2C_BUSSES
+		hold a list of busses you want to use, only used if
+		CONFIG_SYS_I2C_DIRECT_BUS is not defined, for example
+		a board with CONFIG_SYS_I2C_MAX_HOPS = 1 and
+		CONFIG_SYS_NUM_I2C_BUSSES = 9:
+
+		 CONFIG_SYS_I2C_BUSSES	{{0, {I2C_NULL_HOP}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 1}}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 2}}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 3}}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 4}}}, \
+					{0, {{I2C_MUX_PCA9547, 0x70, 5}}}, \
+					{1, {I2C_NULL_HOP}}, \
+					{1, {{I2C_MUX_PCA9544, 0x72, 1}}}, \
+					{1, {{I2C_MUX_PCA9544, 0x72, 2}}}, \
+					}
+
+		which defines
+			bus 0 on adapter 0 without a mux
+			bus 1 on adapter 0 without a PCA9547 on address 0x70 port 1
+			bus 2 on adapter 0 without a PCA9547 on address 0x70 port 2
+			bus 3 on adapter 0 without a PCA9547 on address 0x70 port 3
+			bus 4 on adapter 0 without a PCA9547 on address 0x70 port 4
+			bus 5 on adapter 0 without a PCA9547 on address 0x70 port 5
+			bus 6 on adapter 1 without a mux
+			bus 7 on adapter 1 without a PCA9544 on address 0x72 port 1
+			bus 8 on adapter 1 without a PCA9544 on address 0x72 port 2
+
+- Legacy I2C Support:	CONFIG_HARD_I2C | CONFIG_SOFT_I2C
+
+		NOTE: It is intended to move drivers to CONFIG_SYS_I2C which
+		provides the following compelling advantages:
+			1. Heiko to fill in
+
+		** Please consider updating your I2C driver now. **
+
+		These enable legacy I2C serial bus commands. Defining either of
 		(but not both of) CONFIG_HARD_I2C or CONFIG_SOFT_I2C will
 		include the appropriate I2C driver for the selected CPU.
 
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 81293c3..8b86a7d 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -74,7 +74,8 @@ extern void dataflash_print_info(void);
 #endif
 
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+	defined(CONFIG_SOFT_I2C) || \
+	defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
 
diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
index e3ee4cd..660fa57 100644
--- a/arch/blackfin/lib/board.c
+++ b/arch/blackfin/lib/board.c
@@ -37,6 +37,10 @@
 int post_flag;
 #endif
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+#include <i2c.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 __attribute__((always_inline))
@@ -353,6 +357,9 @@ void board_init_r(gd_t * id, ulong dest_addr)
 
 	/* Initialize stdio devices */
 	stdio_init();
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+	i2c_reloc_fixup();
+#endif
 	jumptable_init();
 
 	/* Initialize the console (after the relocation and devices init) */
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index 259b71c..17876d5 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/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
 
@@ -140,11 +141,16 @@ 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_SYS_I2C
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	puts ("ready\n");
 	return (0);
 }
@@ -176,7 +182,8 @@ 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)
@@ -507,6 +514,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	/* relocate environment function pointers etc. */
 	env_relocate ();
 
+#if defined(CONFIG_SYS_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 --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index d998f0e..8c6d35e 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -35,6 +35,9 @@
 #ifdef CONFIG_BITBANGMII
 #include <miiphy.h>
 #endif
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+#include <i2c.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -316,6 +319,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
+	i2c_reloc_fixup();
+#endif
+
 	/* IP Address */
 	bd->bi_ip_addr = getenv_IPaddr("ipaddr");
 
diff --git a/arch/powerpc/cpu/mpc8xx/video.c b/arch/powerpc/cpu/mpc8xx/video.c
index 1bbf4cc..10e3e88 100644
--- a/arch/powerpc/cpu/mpc8xx/video.c
+++ b/arch/powerpc/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_SYS_I2C
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 
 #ifdef CONFIG_FADS
 	/* Reset ADV7176 chip */
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index ff5888e..563da9a 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -99,7 +99,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>
@@ -214,11 +215,16 @@ 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_SYS_I2C
+	i2c_init_all();
+#else
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	puts("ready\n");
 	return 0;
 }
@@ -317,7 +323,8 @@ 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)
@@ -823,6 +830,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	 * the environment is in EEPROM.
 	 */
 
+#if defined(CONFIG_SYS_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)
diff --git a/common/cmd_date.c b/common/cmd_date.c
index f0fa02a..21e72b8 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -50,8 +50,13 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	int old_bus;
 
 	/* switch to correct I2C bus */
+#ifdef CONFIG_SYS_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_RTC_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_RTC_BUS_NUM);
+#endif
 
 	switch (argc) {
 	case 2:			/* set date & time */
@@ -98,7 +103,11 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	/* switch back to original I2C bus */
+#ifdef CONFIG_SYS_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif
 
 	return rcode;
 }
diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
index cd94423..cb73614 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -69,8 +69,13 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	/* Force a compilation error, if there are more then 32 sensors */
 	BUILD_BUG_ON(sizeof(sensors) > 32);
 	/* switch to correct I2C bus */
+#ifdef CONFIG_SYS_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_DTT_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
+#endif
 
 	_initialize_dtt();
 
@@ -82,7 +87,11 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 		printf("DTT%d: %i C\n", i + 1, dtt_get_temp(sensors[i]));
 
 	/* switch back to original I2C bus */
+#ifdef CONFIG_SYS_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif
 
 	return 0;
 }	/* do_dtt() */
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index e795139..50d006f 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -1,4 +1,9 @@
 /*
+ * (C) Copyright 2009
+ * Sergey Kubushyn, himself, ksi at koi8.net
+ *
+ * Changes for unified multibus/multiadapter I2C support.
+ *
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com.
  *
@@ -83,6 +88,8 @@
 #include <malloc.h>
 #include <asm/byteorder.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Display values from last command.
  * Memory modify remembered values are different from display memory.
  */
@@ -101,7 +108,8 @@ static uint	i2c_mm_last_alen;
  * pairs.  The following macros take care of this */
 
 #if defined(CONFIG_SYS_I2C_NOPROBES)
-#if defined(CONFIG_I2C_MULTI_BUS)
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) || defined(CONFIG_I2C_MUX) || \
+	defined(CONFIG_I2C_MULTI_BUS)
 static struct
 {
 	uchar	bus;
@@ -117,7 +125,7 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
 #define COMPARE_BUS(b,i)	((b) == 0)	/* Make compiler happy */
 #define COMPARE_ADDR(a,i)	(i2c_no_probes[(i)] == (a))
 #define NO_PROBE_ADDR(i)	i2c_no_probes[(i)]
-#endif	/* CONFIG_MULTI_BUS */
+#endif	/* CONFIG_SYS_NUM_I2C_BUSSES > 1 */
 
 #define NUM_ELEMENTS_NOPROBE (sizeof(i2c_no_probes)/sizeof(i2c_no_probes[0]))
 #endif
@@ -125,22 +133,23 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
 #if defined(CONFIG_I2C_MUX)
 static I2C_MUX_DEVICE	*i2c_mux_devices = NULL;
 static	int	i2c_mux_busid = CONFIG_SYS_MAX_I2C_BUS;
-
-DECLARE_GLOBAL_DATA_PTR;
-
 #endif
 
 #define DISP_LINE_LEN	16
 
 /* implement possible board specific board init */
-void __def_i2c_init_board(void)
+int __def_i2c_init_board(void)
 {
-	return;
+	return 0;
 }
-void i2c_init_board(void)
+int i2c_init_board(void)
 	__attribute__((weak, alias("__def_i2c_init_board")));
 
-/* TODO: Implement architecture-specific get/set functions */
+#if !defined(CONFIG_SYS_I2C)
+/*
+ * TODO: Implement architecture-specific get/set functions
+ * Should go away, if we switched completely to new multibus support
+ */
 unsigned int __def_i2c_get_bus_speed(void)
 {
 	return CONFIG_SYS_I2C_SPEED;
@@ -157,6 +166,7 @@ int __def_i2c_set_bus_speed(unsigned int speed)
 }
 int i2c_set_bus_speed(unsigned int)
 	__attribute__((weak, alias("__def_i2c_set_bus_speed")));
+#endif
 
 /*
  * get_alen: small parser helper function to get address length
@@ -564,7 +574,7 @@ static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
 	int j;
 #if defined(CONFIG_SYS_I2C_NOPROBES)
 	int k, skip;
-	uchar bus = GET_BUS_NUM;
+	unsigned int bus = GET_BUS_NUM;
 #endif	/* NOPROBES */
 
 	puts ("Valid chip addresses:");
@@ -1186,53 +1196,78 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 }
 #endif
 
-#if defined(CONFIG_I2C_MUX)
-static int do_i2c_add_bus(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) && defined(CONFIG_SYS_I2C)
+int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	int ret=0;
+	int	i;
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+	int	j;
+#endif
 
-	if (argc == 1) {
+	if (argc == 0) {
 		/* show all busses */
-		I2C_MUX		*mux;
-		I2C_MUX_DEVICE	*device = i2c_mux_devices;
-
-		printf ("Busses reached over muxes:\n");
-		while (device != NULL) {
-			printf ("Bus ID: %x\n", device->busid);
-			printf ("  reached over Mux(es):\n");
-			mux = device->mux;
-			while (mux != NULL) {
-				printf ("    %s@%x ch: %x\n", mux->name, mux->chip, mux->channel);
-				mux = mux->next;
+		for (i = 0; i < CONFIG_SYS_NUM_I2C_BUSSES; i++) {
+			printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+			for (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {
+				if (i2c_bus[i].next_hop[j].chip == 0)
+					break;
+				printf("->%s at 0x%2x:%d",
+					i2c_bus[i].next_hop[j].mux.name,
+					i2c_bus[i].next_hop[j].chip,
+					i2c_bus[i].next_hop[j].channel);
 			}
-			device = device->next;
+#endif
+			printf("\n");
 		}
 	} else {
-		(void)i2c_mux_ident_muxstring ((uchar *)argv[1]);
-		ret = 0;
+		/* show specific bus */
+		i = simple_strtoul(argv[1], NULL, 10);
+		if (i >= CONFIG_SYS_NUM_I2C_BUSSES) {
+			printf("Invalid bus %d\n", i);
+			return -1;
+		}
+		printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+			for (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {
+				if (i2c_bus[i].next_hop[j].chip == 0)
+					break;
+				printf("->%s at 0x%2x:%d",
+					i2c_bus[i].next_hop[j].mux.name,
+					i2c_bus[i].next_hop[j].chip,
+					i2c_bus[i].next_hop[j].channel);
+			}
+#endif
+		printf("\n");
 	}
-	return ret;
+
+	return 0 ;
 }
-#endif  /* CONFIG_I2C_MUX */
+#endif
 
-#if defined(CONFIG_I2C_MULTI_BUS)
-static int do_i2c_bus_num(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+#if CONFIG_SYS_NUM_I2C_BUSSES > 1
+int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	int bus_idx, ret=0;
+	int		ret = 0;
+	unsigned int	bus_no;
 
-	if (argc == 1)
+	if (argc == 0)
 		/* querying current setting */
 		printf("Current bus is %d\n", i2c_get_bus_num());
 	else {
-		bus_idx = simple_strtoul(argv[1], NULL, 10);
-		printf("Setting bus to %d\n", bus_idx);
-		ret = i2c_set_bus_num(bus_idx);
+		bus_no = simple_strtoul(argv[1], NULL, 10);
+		if (bus_no >= CONFIG_SYS_NUM_I2C_BUSSES) {
+			printf("Invalid bus %d\n", bus_no);
+			return -1;
+		}
+		printf("Setting bus to %d\n", bus_no);
+		ret = i2c_set_bus_num(bus_no);
 		if (ret)
 			printf("Failure changing bus number (%d)\n", ret);
 	}
 	return ret;
 }
-#endif  /* CONFIG_I2C_MULTI_BUS */
+#endif  /* CONFIG_SYS_NUM_I2C_BUSSES > 1 */
 
 static int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
@@ -1263,16 +1298,20 @@ static int do_i2c_nm(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 
 static int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
+#if defined(CONFIG_SYS_I2C)
+	i2c_init(I2C_ADAP->speed, I2C_ADAP->slaveaddr);
+#else
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	return 0;
 }
 
 static cmd_tbl_t cmd_i2c_sub[] = {
-#if defined(CONFIG_I2C_MUX)
-	U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_add_bus, "", ""),
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) && defined(CONFIG_SYS_I2C)
+	U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_show_bus, "", ""),
 #endif  /* CONFIG_I2C_MUX */
 	U_BOOT_CMD_MKENT(crc32, 3, 1, do_i2c_crc, "", ""),
-#if defined(CONFIG_I2C_MULTI_BUS)
+#if (CONFIG_SYS_NUM_I2C_BUSSES > 1) && defined(CONFIG_SYS_I2C)
 	U_BOOT_CMD_MKENT(dev, 1, 1, do_i2c_bus_num, "", ""),
 #endif  /* CONFIG_I2C_MULTI_BUS */
 	U_BOOT_CMD_MKENT(loop, 3, 1, do_i2c_loop, "", ""),
@@ -1319,11 +1358,11 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 U_BOOT_CMD(
 	i2c, 6, 1, do_i2c,
 	"I2C sub-system",
-#if defined(CONFIG_I2C_MUX)
-	"bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\ni2c "
+#if CONFIG_SYS_NUM_I2C_BUSSES > 1
+	"bus [muxtype:muxaddr:muxchannel] - show I2C bus info\n"
 #endif  /* CONFIG_I2C_MUX */
 	"crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n"
-#if defined(CONFIG_I2C_MULTI_BUS)
+#if CONFIG_SYS_NUM_I2C_BUSSES > 1
 	"i2c dev [dev] - show or set current I2C bus\n"
 #endif  /* CONFIG_I2C_MULTI_BUS */
 	"i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device\n"
diff --git a/common/stdio.c b/common/stdio.c
index 1bf9ba0..08337f9 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -1,4 +1,8 @@
 /*
+ * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
+ *
+ * Changes for multibus/multiadapter I2C support.
+ *
  * (C) Copyright 2000
  * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio at tin.it
  *
@@ -30,7 +34,8 @@
 #ifdef CONFIG_LOGBUFFER
 #include <logbuff.h>
 #endif
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) \
+		|| defined(CONFIG_SYS_I2C_ADAPTERS)
 #include <i2c.h>
 #endif
 
@@ -211,9 +216,15 @@ int stdio_init (void)
 #ifdef CONFIG_ARM_DCC_MULTI
 	drv_arm_dcc_init ();
 #endif
+#ifdef CONFIG_SYS_I2C
+#ifdef CONFIG_SYS_I2C_ADAPTERS
+	i2c_init_all();
+#endif
+#else
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
+#endif
 #ifdef CONFIG_LCD
 	drv_lcd_init ();
 #endif
diff --git a/include/i2c.h b/include/i2c.h
index 910552d..e482827 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -203,15 +203,6 @@ int i2c_mux_ident_muxstring_f (uchar *buf);
 
 #ifdef CONFIG_SYS_I2C
 /*
- * Initialization, must be called once on start up, may be called
- * repeatedly to change the speed and slave addresses.
- */
-void i2c_init(unsigned int speed, int slaveaddr);
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-void i2c_init_board(void);
-#endif
-
-/*
  * i2c_get_bus_num:
  *
  *  Returns index of currently active I2C bus.  Zero-based.
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2012-10-31  5:20 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-22 17:40 [U-Boot] [PATCH 0/3] Bring in new I2C framework Heiko Schocher
2012-10-22 17:40 ` [U-Boot] [PATCH 1/3] i2c: add i2c_core and prepare for new multibus support Heiko Schocher
2012-10-22 17:40 ` [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support Heiko Schocher
2012-10-22 22:16   ` Henrik Nordström
2012-10-23  3:25     ` Heiko Schocher
2012-10-22 17:40 ` [U-Boot] [PATCH 3/3] i2c, soft-i2c: switch to new " Heiko Schocher
2012-10-25 21:37 ` [U-Boot] [PATCH 0/3] Bring in new I2C framework Simon Glass
2012-10-26  5:48   ` Heiko Schocher
2012-10-26 16:07     ` Stephen Warren
2012-10-29  9:47       ` Heiko Schocher
2012-10-29 15:34         ` Stephen Warren
2012-10-29 15:56           ` Simon Glass
2012-10-30  5:57           ` Heiko Schocher
2012-10-30 16:50             ` Stephen Warren
2012-10-30 17:22               ` Simon Glass
2012-10-31  5:02                 ` Heiko Schocher
2012-10-31  5:20                 ` Tom Rini
2012-10-26 16:08     ` Simon Glass
2012-10-29  9:44       ` Heiko Schocher
2012-10-29 13:48         ` Simon Glass
2012-10-30  5:44           ` Heiko Schocher
2012-10-26 18:44   ` Tom Rini
2012-10-29  9:53     ` Heiko Schocher
2012-10-30 22:38       ` Tom Rini
  -- strict thread matches above, loose matches on Subject: below --
2012-01-17  7:12 Simon Glass
2012-01-17  7:12 ` [U-Boot] [PATCH 2/3] i2c: common changes for multibus/multiadapter support Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.