All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
@ 2013-05-04 12:01 Heiko Schocher
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 1/9] i2c: add i2c_core and prepare for new multibus support Heiko Schocher
                   ` (10 more replies)
  0 siblings, 11 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 UTC (permalink / raw)
  To: u-boot

It seems the timing is coming, to bring this finally in mainline
and move boards over to the new i2c framework.

Changes for v3 series:

- Compiler collects the used i2c adapters in _u_boot_list_i2c,
  so no need for defining the used i2c adpaters in the board config file.
  -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
- Some adaptions for the keymile boards, so we can drop CONFIG_I2C_MUX
  completely
- add ppc4xx_i2c driver, ported from Dirk Eibach

Serie compiles clean on arm and powerpc

Ported i2c drivers:
soft_i2c  : from me, tested on some arm and powerpc boards
fsl_i2c   : from me, only compile tested
tegra_i2c : ported from Simon Glass
ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
            tested on (which board?) with 4 soft_i2c drivers
            and one ppc4x_i2c driver.
 
Cc: Dirk Eibach <dirk.eibach@gdsys.cc>                                                                                                          
Cc: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Piotr Wilczek <p.wilczek@samsung.com>
Cc: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Stephen Warren <swarren@wwwdotorg.org>

Dirk Eibach (1):
  i2c, ppc4xx_i2c: switch to new multibus/multiadapter support

Heiko Schocher (6):
  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
  i2c, fsl_i2c: switch to new multibus/multiadapter support
  i2c, multibus: get rid of CONFIG_I2C_MUX
  i2c, multibus, keymile: get rid of EEprom_ivm envvariable

Simon Glass (2):
  tegra: i2c: Add function to know about current bus
  tegra: i2c: Enable new CONFIG_SYS_I2C framework

 README                                      | 175 ++++++----
 arch/arm/lib/board.c                        |  10 +-
 arch/blackfin/lib/board.c                   |   7 +
 arch/m68k/cpu/mcf5227x/cpu_init.c           |   2 +-
 arch/m68k/cpu/mcf5227x/speed.c              |   2 +-
 arch/m68k/cpu/mcf523x/cpu_init.c            |   2 +-
 arch/m68k/cpu/mcf523x/speed.c               |   2 +-
 arch/m68k/cpu/mcf52x2/cpu_init.c            |   4 +-
 arch/m68k/cpu/mcf52x2/speed.c               |   4 +-
 arch/m68k/cpu/mcf532x/cpu_init.c            |   4 +-
 arch/m68k/cpu/mcf532x/speed.c               |   2 +-
 arch/m68k/cpu/mcf5445x/speed.c              |   2 +-
 arch/m68k/cpu/mcf547x_8x/cpu_init.c         |   2 +-
 arch/m68k/cpu/mcf547x_8x/speed.c            |   2 +-
 arch/m68k/include/asm/global_data.h         |   2 +-
 arch/m68k/lib/board.c                       |  15 +-
 arch/mips/lib/board.c                       |   7 +
 arch/nds32/lib/board.c                      |  10 +-
 arch/powerpc/cpu/mpc8260/i2c.c              |  14 -
 arch/powerpc/cpu/mpc8xx/video.c             |   4 +
 arch/powerpc/cpu/ppc4xx/40x_spd_sdram.c     |   6 +-
 arch/powerpc/cpu/ppc4xx/44x_spd_ddr.c       |   6 +-
 arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c      |   3 +-
 arch/powerpc/cpu/ppc4xx/cmd_chip_config.c   |   2 +-
 arch/powerpc/cpu/ppc4xx/denali_spd_ddr2.c   |   3 +-
 arch/powerpc/include/asm/ppc4xx-i2c.h       |  18 -
 arch/powerpc/lib/board.c                    |  11 +-
 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/csb272/csb272.c                       |   2 +-
 board/emk/top9000/top9000.c                 |   8 +-
 board/esd/du440/du440.c                     |   2 -
 board/esd/vme8349/vme8349.c                 |   6 +-
 board/eukrea/cpuat91/cpuat91.c              |   2 +-
 board/freescale/m52277evb/README            |   4 +-
 board/freescale/m53017evb/README            |   4 +-
 board/freescale/m5373evb/README             |   4 +-
 board/freescale/m54455evb/README            |   4 +-
 board/freescale/m547xevb/README             |   4 +-
 board/freescale/mpc8349itx/mpc8349itx.c     |   3 +-
 board/freescale/mpc8349itx/pci.c            |   2 +-
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c |   2 +-
 board/ids8247/ids8247.c                     |   2 +-
 board/keymile/common/ivm.c                  |  19 +-
 board/keymile/km83xx/km83xx.c               |  15 -
 board/keymile/km_arm/km_arm.c               |   8 +-
 board/lwmon/lwmon.c                         |   2 +-
 board/lwmon/pcmcia.c                        |   4 +-
 board/lwmon5/kbd.c                          |   2 +-
 board/mpl/pip405/pip405.c                   |   2 +-
 board/pm826/pm826.c                         |   2 +-
 board/pm828/pm828.c                         |   2 +-
 board/sacsng/ioconfig.h                     |   2 +-
 board/sandburst/common/ppc440gx_i2c.c       | 510 ----------------------------
 board/sandburst/common/ppc440gx_i2c.h       |  60 ----
 board/sandburst/common/sb_common.c          | 103 +++---
 board/sandburst/common/sb_common.h          |   1 -
 board/sandburst/karef/Makefile              |   3 +-
 board/sandburst/karef/karef.c               |   6 -
 board/sandburst/metrobox/Makefile           |   3 +-
 board/sandburst/metrobox/metrobox.c         |   6 -
 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                            | 350 +++++--------------
 common/env_eeprom.c                         |  26 +-
 common/stdio.c                              |  13 +-
 drivers/i2c/Makefile                        |   9 +-
 drivers/i2c/fsl_i2c.c                       | 220 +++++-------
 drivers/i2c/i2c_core.c                      | 414 ++++++++++++++++++++++
 drivers/i2c/ppc4xx_i2c.c                    | 193 ++++++-----
 drivers/i2c/soft_i2c.c                      | 104 +++---
 drivers/i2c/tegra_i2c.c                     | 118 ++++---
 include/asm-generic/global_data.h           |   3 +
 include/configs/A3000.h                     |   4 +-
 include/configs/APC405.h                    |   9 +-
 include/configs/ASH405.h                    |   9 +-
 include/configs/B4860QDS.h                  |  16 +-
 include/configs/BSC9131RDB.h                |  12 +-
 include/configs/BSC9132QDS.h                |  17 +-
 include/configs/CANBT.h                     |  15 +-
 include/configs/CATcenter.h                 |   9 +-
 include/configs/CMS700.h                    |   9 +-
 include/configs/CPCI2DP.h                   |   9 +-
 include/configs/CPCI405.h                   |   9 +-
 include/configs/CPCI4052.h                  |   9 +-
 include/configs/CPCI405AB.h                 |   9 +-
 include/configs/CPCI405DT.h                 |   9 +-
 include/configs/CPCIISER4.h                 |   9 +-
 include/configs/CPU86.h                     |   7 +-
 include/configs/CPU87.h                     |   7 +-
 include/configs/CRAYL1.h                    |   9 +-
 include/configs/DP405.h                     |   9 +-
 include/configs/DU405.h                     |   9 +-
 include/configs/DU440.h                     |  19 +-
 include/configs/G2000.h                     |   9 +-
 include/configs/GEN860T.h                   |  39 ++-
 include/configs/HH405.h                     |  11 +-
 include/configs/HIDDEN_DRAGON.h             |   9 +-
 include/configs/HUB405.h                    |   9 +-
 include/configs/HWW1U1A.h                   |  18 +-
 include/configs/ICU862.h                    |  13 +-
 include/configs/IDS8247.h                   |   9 +-
 include/configs/IP860.h                     |   9 +-
 include/configs/IPHASE4539.h                |  11 +-
 include/configs/JSE.h                       |  10 +-
 include/configs/KAREF.h                     |  17 +-
 include/configs/KUP4K.h                     |  11 +-
 include/configs/KUP4X.h                     |  12 +-
 include/configs/M5208EVBE.h                 |  11 +-
 include/configs/M52277EVB.h                 |  11 +-
 include/configs/M5235EVB.h                  |  11 +-
 include/configs/M5253DEMO.h                 |  10 +-
 include/configs/M5271EVB.h                  |  11 +-
 include/configs/M5275EVB.h                  |  11 +-
 include/configs/M53017EVB.h                 |  11 +-
 include/configs/M5329EVB.h                  |  11 +-
 include/configs/M5373EVB.h                  |  11 +-
 include/configs/M54451EVB.h                 |  11 +-
 include/configs/M54455EVB.h                 |  11 +-
 include/configs/M5475EVB.h                  |  11 +-
 include/configs/M5485EVB.h                  |  11 +-
 include/configs/MERGERBOX.h                 |  15 +-
 include/configs/METROBOX.h                  |  17 +-
 include/configs/MHPC.h                      |   8 +-
 include/configs/MIP405.h                    |   9 +-
 include/configs/MPC8308RDB.h                |  17 +-
 include/configs/MPC8313ERDB.h               |  17 +-
 include/configs/MPC8315ERDB.h               |  13 +-
 include/configs/MPC8323ERDB.h               |  13 +-
 include/configs/MPC832XEMDS.h               |  13 +-
 include/configs/MPC8349EMDS.h               |  18 +-
 include/configs/MPC8349ITX.h                |  24 +-
 include/configs/MPC8360EMDS.h               |  14 +-
 include/configs/MPC8360ERDK.h               |  18 +-
 include/configs/MPC837XEMDS.h               |  14 +-
 include/configs/MPC837XERDB.h               |  14 +-
 include/configs/MPC8536DS.h                 |  18 +-
 include/configs/MPC8540ADS.h                |  13 +-
 include/configs/MPC8541CDS.h                |  13 +-
 include/configs/MPC8544DS.h                 |  13 +-
 include/configs/MPC8548CDS.h                |  13 +-
 include/configs/MPC8555CDS.h                |  13 +-
 include/configs/MPC8560ADS.h                |  13 +-
 include/configs/MPC8568MDS.h                |  18 +-
 include/configs/MPC8569MDS.h                |  18 +-
 include/configs/MPC8572DS.h                 |  18 +-
 include/configs/MPC8610HPCD.h               |  13 +-
 include/configs/MPC8641HPCN.h               |  13 +-
 include/configs/MVBLM7.h                    |  16 +-
 include/configs/OCRTC.h                     |   9 +-
 include/configs/ORSG.h                      |   9 +-
 include/configs/P1010RDB.h                  |  18 +-
 include/configs/P1022DS.h                   |  16 +-
 include/configs/P1023RDS.h                  |  16 +-
 include/configs/P1_P2_RDB.h                 |  19 +-
 include/configs/P2020COME.h                 |  17 +-
 include/configs/P2020DS.h                   |  17 +-
 include/configs/P2041RDB.h                  |  16 +-
 include/configs/PCI405.h                    |   9 +-
 include/configs/PIP405.h                    |   9 +-
 include/configs/PLU405.h                    |   9 +-
 include/configs/PM826.h                     |   8 +-
 include/configs/PM828.h                     |   8 +-
 include/configs/PMC405.h                    |   9 +-
 include/configs/PMC405DE.h                  |   9 +-
 include/configs/PMC440.h                    |  15 +-
 include/configs/PPChameleonEVB.h            |   9 +-
 include/configs/R360MPI.h                   |   6 +-
 include/configs/RPXClassic.h                |  16 +-
 include/configs/RPXlite.h                   |  30 ++
 include/configs/RRvision.h                  |  12 +-
 include/configs/SIMPC8313.h                 |  17 +-
 include/configs/SXNI855T.h                  |   7 +-
 include/configs/Sandpoint8240.h             |  15 +-
 include/configs/Sandpoint8245.h             |  15 +-
 include/configs/TASREG.h                    |  28 +-
 include/configs/TK885D.h                    |  12 +-
 include/configs/TOP5200.h                   |  12 +-
 include/configs/TOP860.h                    |  10 +-
 include/configs/TQM8260.h                   |   8 +-
 include/configs/TQM8272.h                   |  12 +-
 include/configs/TQM834x.h                   |  11 +-
 include/configs/TQM855M.h                   |  12 +-
 include/configs/TQM866M.h                   |  11 +-
 include/configs/TQM885D.h                   |  12 +-
 include/configs/VOH405.h                    |   9 +-
 include/configs/VOM405.h                    |   9 +-
 include/configs/W7OLMC.h                    |   9 +-
 include/configs/W7OLMG.h                    |   9 +-
 include/configs/WUH405.h                    |   9 +-
 include/configs/acadia.h                    |   2 +-
 include/configs/alpr.h                      |  12 +-
 include/configs/amcc-common.h               |   7 +-
 include/configs/aria.h                      |   1 -
 include/configs/astro_mcf5373l.h            |  11 +-
 include/configs/bamboo.h                    |   2 +-
 include/configs/beaver.h                    |   5 +-
 include/configs/bf533-ezkit.h               |   9 +-
 include/configs/bf533-stamp.h               |  48 ++-
 include/configs/bf561-ezkit.h               |   8 +-
 include/configs/bfin_adi_common.h           |   2 +-
 include/configs/blackstamp.h                |   3 +-
 include/configs/blackvme.h                  |   2 +-
 include/configs/bluestone.h                 |   2 +-
 include/configs/bubinga.h                   |   4 +-
 include/configs/canyonlands.h               |   2 +-
 include/configs/cardhu.h                    |   3 +-
 include/configs/corenet_ds.h                |  16 +-
 include/configs/cpuat91.h                   |   3 +-
 include/configs/csb272.h                    |   9 +-
 include/configs/csb472.h                    |   9 +-
 include/configs/dalmore.h                   |   3 +-
 include/configs/debris.h                    |   9 +-
 include/configs/dlvision-10g.h              |   2 +-
 include/configs/dlvision.h                  |   2 +-
 include/configs/eXalion.h                   |   2 +-
 include/configs/eb_cpux9k2.h                |  13 +-
 include/configs/ebony.h                     |   2 +-
 include/configs/ep8260.h                    |  13 +-
 include/configs/ethernut5.h                 |   8 +-
 include/configs/gdppc440etx.h               |   2 +-
 include/configs/ibf-dsp561.h                |   4 +-
 include/configs/icon.h                      |   3 +-
 include/configs/intip.h                     |   2 +-
 include/configs/io.h                        |   2 +-
 include/configs/io64.h                      |   2 +-
 include/configs/iocon.h                     |  10 +-
 include/configs/katmai.h                    |   3 +-
 include/configs/kilauea.h                   |   2 +-
 include/configs/km/keymile-common.h         |   3 -
 include/configs/km/km83xx-common.h          |  25 +-
 include/configs/km/km_arm.h                 |  23 +-
 include/configs/km82xx.h                    |  19 +-
 include/configs/km_kirkwood.h               |  16 +-
 include/configs/korat.h                     |  10 +-
 include/configs/luan.h                      |   2 +-
 include/configs/lwmon.h                     |  12 +-
 include/configs/lwmon5.h                    |  10 +-
 include/configs/makalu.h                    |   2 +-
 include/configs/mecp5123.h                  |   1 -
 include/configs/mpc5121ads.h                |   1 -
 include/configs/mpc8308_p1m.h               |  15 +-
 include/configs/mpq101.h                    |  16 +-
 include/configs/neo.h                       |   2 +-
 include/configs/nhk8815.h                   |   7 +-
 include/configs/ocotea.h                    |   2 +-
 include/configs/otc570.h                    |  17 +-
 include/configs/p1_p2_rdb_pc.h              |  19 +-
 include/configs/p3p440.h                    |  12 +-
 include/configs/pcs440ep.h                  |  10 +-
 include/configs/pdnb3.h                     |  10 +-
 include/configs/quad100hd.h                 |  10 +-
 include/configs/redwood.h                   |   4 +-
 include/configs/s5p_goni.h                  |   6 +-
 include/configs/s5pc210_universal.h         |   6 +-
 include/configs/sacsng.h                    |  11 +-
 include/configs/sbc405.h                    |  10 +-
 include/configs/sbc8349.h                   |  18 +-
 include/configs/sbc8548.h                   |  11 +-
 include/configs/sbc8641d.h                  |  13 +-
 include/configs/sc3.h                       |  10 +-
 include/configs/seaboard.h                  |   5 +-
 include/configs/sequoia.h                   |   2 +-
 include/configs/snapper9260.h               |   8 +-
 include/configs/socrates.h                  |  17 +-
 include/configs/spc1920.h                   |  12 +-
 include/configs/stxgp3.h                    |  12 +-
 include/configs/stxssa.h                    |  11 +-
 include/configs/t3corp.h                    |   2 +-
 include/configs/t4qds.h                     |  17 +-
 include/configs/taihu.h                     |   4 +-
 include/configs/taishan.h                   |   2 +-
 include/configs/top9000.h                   |   9 +-
 include/configs/trats.h                     |   6 +-
 include/configs/trimslice.h                 |   5 +-
 include/configs/u8500_href.h                |   1 -
 include/configs/uc100.h                     |  12 +-
 include/configs/utx8245.h                   |   3 +-
 include/configs/vct.h                       |  11 +-
 include/configs/vl_ma2sc.h                  |   6 +-
 include/configs/vme8349.h                   |  20 +-
 include/configs/walnut.h                    |   2 +-
 include/configs/whistler.h                  |   5 +-
 include/configs/xpedite1000.h               |  10 +-
 include/configs/xpedite517x.h               |  15 +-
 include/configs/xpedite520x.h               |  15 +-
 include/configs/xpedite537x.h               |  16 +-
 include/configs/xpedite550x.h               |  15 +-
 include/configs/yosemite.h                  |   2 +-
 include/configs/yucca.h                     |   4 +-
 include/configs/zeus.h                      |  10 +-
 include/i2c.h                               | 232 +++++++++++--
 301 Dateien ge?ndert, 2549 Zeilen hinzugef?gt(+), 2604 Zeilen entfernt(-)
 delete mode 100644 board/sandburst/common/ppc440gx_i2c.c
 delete mode 100644 board/sandburst/common/ppc440gx_i2c.h
 create mode 100644 drivers/i2c/i2c_core.c

-- 
1.7.11.7

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

* [U-Boot] [PATCH v3 1/9] i2c: add i2c_core and prepare for new multibus support
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support Heiko Schocher
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 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>
Cc: Stephen Warren <swarren@wwwdotorg.org>

---
- changes against Simons patches
  (see: http://www.mail-archive.com/u-boot at lists.denx.de/msg75530.html):
  - 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
- changes for v2:
  - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
  - pass i2c_adapter struct to i2c_core callbacks
    suggested by Stephen Warren and Simon Glass.
  - add i2c_init_board() to i2c_init_all() as Simon found
    in his tests.
  - need CONFIG_SYS_I2C_BUSES only, if i2c muxes used
    (Steven Warren suggested to get rid of this completely, now
     we need this defines in a first step only in the case, we have
     i2c muxes)
  - global data is now a int only
  - move i2c_init_board() to drivers/i2c/i2c_core.c
  - add correct license text to i2c_core.c
- changes for v3:
  - introduce U_BOOT_I2C_ADAP_COMPLETE for adding an i2c adapter.
    Compiler collects the used i2c adapters in _u_boot_list_i2c,
    so no need for defining the used i2c adpaters in the board config file.
    -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
---
 drivers/i2c/Makefile              |   1 +
 drivers/i2c/i2c_core.c            | 414 ++++++++++++++++++++++++++++++++++++++
 include/asm-generic/global_data.h |   3 +
 include/i2c.h                     | 215 +++++++++++++++++++-
 4 Dateien ge?ndert, 624 Zeilen hinzugef?gt(+), 9 Zeilen entfernt(-)
 create mode 100644 drivers/i2c/i2c_core.c

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..3c01893
--- /dev/null
+++ b/drivers/i2c/i2c_core.c
@@ -0,0 +1,414 @@
+/*
+ * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
+ *
+ * (C) Copyright 2012
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ * Multibus/multiadapter I2C core functions (wrappers)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <common.h>
+#include <i2c.h>
+
+struct i2c_adapter *i2c_get_adapter(int index)
+{
+	struct i2c_adapter *i2c_adap_p = ll_entry_start(struct i2c_adapter,
+						i2c);
+	int max = ll_entry_count(struct i2c_adapter, i2c);
+	int i;
+
+	if (index >= max) {
+		printf("Error, wrong i2c adapter %d max %d possible\n",
+		       index, max);
+		return i2c_adap_p;
+	}
+	if (index == 0)
+		return i2c_adap_p;
+
+	for (i = 0; i < index; i++)
+		i2c_adap_p++;
+
+	return i2c_adap_p;
+}
+
+#if !defined(CONFIG_SYS_I2C_DIRECT_BUS)
+struct i2c_bus_hose i2c_bus[CONFIG_SYS_NUM_I2C_BUSES] =
+			CONFIG_SYS_I2C_BUSES;
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void i2c_reloc_fixup(void)
+{
+#if defined(CONFIG_NEEDS_MANUAL_RELOC)
+	struct i2c_adapter *i2c_adap_p = ll_entry_start(struct i2c_adapter,
+						i2c);
+	struct i2c_adapter *tmp = i2c_adap_p;
+	int max = ll_entry_count(struct i2c_adapter, i2c);
+	int		i;
+	unsigned long	addr;
+
+	if (gd->reloc_off == 0)
+		return;
+
+	for (i = 0; i < max; i++) {
+		/* adapter itself */
+		addr = (unsigned long)i2c_adap_p;
+		addr += gd->reloc_off;
+		i2c_adap_p = (struct i2c_adapter *)addr;
+		/* i2c_init() */
+		addr = (unsigned long)i2c_adap_p->init;
+		addr += gd->reloc_off;
+		i2c_adap_p->init = (void (*)(int, int))addr;
+		/* i2c_probe() */
+		addr = (unsigned long)i2c_adap_p->probe;
+		addr += gd->reloc_off;
+		i2c_adap_p->probe = (int (*)(uint8_t))addr;
+		/* i2c_read() */
+		addr = (unsigned long)i2c_adap_p->read;
+		addr += gd->reloc_off;
+		i2c_adap_p->read = (int (*)(uint8_t, uint, int, uint8_t *,
+					int))addr;
+		/* i2c_write() */
+		addr = (unsigned long)i2c_adap_p->write;
+		addr += gd->reloc_off;
+		i2c_adap_p->write = (int (*)(uint8_t, uint, int, uint8_t *,
+					int))addr;
+		/* i2c_set_bus_speed() */
+		addr = (unsigned long)i2c_adap_p->set_bus_speed;
+		addr += gd->reloc_off;
+		i2c_adap_p->set_bus_speed = (uint (*)(uint))addr;
+		/* name */
+		addr = (unsigned long)i2c_adap_p->name;
+		addr += gd->reloc_off;
+		i2c_adap_p->name = (char *)addr;
+		tmp++;
+		i2c_adap_p = tmp;
+	}
+#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;
+	int ret;
+
+	/* channel < 0 - turn off the mux */
+	if (channel < 0) {
+		buf = 0;
+		ret = adap->write(adap, chip, 0, 0, &buf, 1);
+		if (ret)
+			printf("%s: Could not turn off the mux.\n", __func__);
+		return ret;
+	}
+
+	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:
+		printf("%s: wrong mux id: %d\n", __func__, mux_id);
+		return -1;
+	}
+
+	ret = adap->write(adap, chip, 0, 0, &buf, 1);
+	if (ret)
+		printf("%s: could not set mux: id: %d chip: %x channel: %d\n",
+		       __func__, mux_id, chip, channel);
+	return ret;
+}
+
+static int i2c_mux_set_all(void)
+{
+	struct i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS];
+	int i;
+
+	/* Connect requested bus if behind muxes */
+	if (i2c_bus_tmp->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_tmp->next_hop[i].chip == 0)
+				break;
+
+			ret = i2c_mux_set(I2C_ADAP,
+					i2c_bus_tmp->next_hop[i].mux.id,
+					i2c_bus_tmp->next_hop[i].chip,
+					i2c_bus_tmp->next_hop[i].channel);
+			if (ret != 0)
+				return ret;
+		}
+	}
+	return 0;
+}
+
+static int i2c_mux_disconnet_all(void)
+{
+	struct	i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS];
+	int	i;
+	uint8_t	buf;
+
+	if (I2C_ADAP->init_done == 0)
+		return 0;
+
+	/* Disconnect current bus (turn off muxes if any) */
+	if ((i2c_bus_tmp->next_hop[0].chip != 0) &&
+	    (I2C_ADAP->init_done != 0)) {
+		i = CONFIG_SYS_I2C_MAX_HOPS;
+		do {
+			uint8_t	chip;
+			int ret;
+
+			chip = i2c_bus_tmp->next_hop[--i].chip;
+			if (chip == 0)
+				continue;
+
+			ret = I2C_ADAP->write(I2C_ADAP, chip, 0, 0, &buf, 1);
+			if (ret != 0) {
+				printf("i2c: mux diconnect error\n");
+				return ret;
+			}
+		} while (i > 0);
+	}
+
+	return 0;
+}
+#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_BUSES)
+		return;
+
+	I2C_ADAP->init(I2C_ADAP, speed, slaveaddr);
+
+	if (gd->flags & GD_FLG_RELOC) {
+		I2C_ADAP->init_done = 1;
+		I2C_ADAP->speed = speed;
+		I2C_ADAP->slaveaddr = slaveaddr;
+	}
+}
+
+/* implement possible board specific board init */
+static void __def_i2c_init_board(void)
+{
+}
+void i2c_init_board(void)
+	__attribute__((weak, alias("__def_i2c_init_board")));
+
+/*
+ * 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_init_board();
+	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)
+{
+	return gd->cur_i2c_bus;
+}
+
+/*
+ * 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)
+{
+	int max = ll_entry_count(struct i2c_adapter, i2c);
+
+	if (I2C_ADAPTER(bus) >= max) {
+		printf("Error, wrong i2c adapter %d max %d possible\n",
+		       I2C_ADAPTER(bus), max);
+		return -2;
+	}
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+	if (bus >= CONFIG_SYS_NUM_I2C_BUSES)
+		return -1;
+#endif
+
+	if ((bus == I2C_BUS) && (I2C_ADAP->init_done > 0))
+		return 0;
+
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+	i2c_mux_disconnet_all();
+#endif
+
+	gd->cur_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
+	i2c_mux_set_all();
+#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(I2C_ADAP, 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(I2C_ADAP, 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(I2C_ADAP, 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(I2C_ADAP, 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/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 5416f46..c3919cc 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -85,6 +85,9 @@ typedef struct global_data {
 	unsigned long fdt_size;	/* Space reserved for relocated FDT */
 	void **jt;		/* jump table */
 	char env_buf[32];	/* buffer for getenv() before reloc. */
+#if defined(CONFIG_SYS_I2C)
+	int		cur_i2c_bus;	/* current used i2c bus */
+#endif
 	struct arch_global_data arch;	/* architecture-specific data */
 } gd_t;
 #endif
diff --git a/include/i2c.h b/include/i2c.h
index c60d075..457fd7d 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -1,4 +1,8 @@
 /*
+ * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
+ * Copyright (C) 2009 - 2013 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,14 @@
  */
 #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
+#if !defined(CONFIG_SYS_I2C_MAX_HOPS)
+/* no muxes used bus = i2c adapters */
+#define CONFIG_SYS_I2C_DIRECT_BUS	1
+#define CONFIG_SYS_I2C_MAX_HOPS		0
+#define CONFIG_SYS_NUM_I2C_BUSES	ll_entry_count(struct i2c_adapter, i2c)
 #else
-#define	MAX_I2C_BUS			1
-#define	I2C_MULTI_BUS			0
-#endif
-
-#if !defined(CONFIG_SYS_MAX_I2C_BUS)
-#define CONFIG_SYS_MAX_I2C_BUS		MAX_I2C_BUS
+/* we use i2c muxes */
+#undef CONFIG_SYS_I2C_DIRECT_BUS
 #endif
 
 /* define the I2C bus number for RTC and DTT if not already done */
@@ -69,6 +71,88 @@
 #define CONFIG_SYS_SPD_BUS_NUM		0
 #endif
 
+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);
+	int		speed;
+	int		slaveaddr;
+	int		init_done;
+	int		hwadapnr;
+	char		*name;
+};
+
+#define U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \
+		_set_speed, _speed, _slaveaddr, _hwadapnr, _name) \
+	{ \
+		.init		=	_init, \
+		.probe		=	_probe, \
+		.read		=	_read, \
+		.write		=	_write, \
+		.set_bus_speed	=	_set_speed, \
+		.speed		=	_speed, \
+		.slaveaddr	=	_slaveaddr, \
+		.init_done	=	0, \
+		.hwadapnr	=	_hwadapnr, \
+		.name		=	#_name \
+};
+
+#define U_BOOT_I2C_ADAP_COMPLETE(_name, _init, _probe, _read, _write, \
+			_set_speed, _speed, _slaveaddr, _hwadapnr) \
+	ll_entry_declare(struct i2c_adapter, _name, i2c) = \
+	U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \
+		 _set_speed, _speed, _slaveaddr, _hwadapnr, _name);
+
+struct i2c_adapter *i2c_get_adapter(int index);
+
+#ifndef CONFIG_SYS_I2C_DIRECT_BUS
+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[];
+
+#define I2C_ADAPTER(bus)	i2c_bus[bus].adapter
+#else
+#define I2C_ADAPTER(bus)	bus
+#endif
+#define	I2C_BUS			gd->cur_i2c_bus
+
+#define	I2C_ADAP_NR(bus)	i2c_get_adapter(I2C_ADAPTER(bus))
+#define	I2C_ADAP		I2C_ADAP_NR(gd->cur_i2c_bus)
+#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 +218,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 +417,21 @@ 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 defined(CONFIG_SYS_I2C) || 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.11.7

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

* [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 1/9] i2c: add i2c_core and prepare for new multibus support Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-06 16:39   ` Daniel Schwierzeck
                     ` (2 more replies)
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 3/9] i2c, soft-i2c: switch to new " Heiko Schocher
                   ` (8 subsequent siblings)
  10 siblings, 3 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Cc: Henrik Nordstr?m <henrik@henriknordstrom.net>

---
- changes for v2:
  add comment from Henrik Nordstr?m <henrik@henriknordstrom.net>
  remove wrong line in README
  - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
- changes for v3:
  - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
  - fix Codingstyle issues
  - adapt README
---
 README                          |  74 ++++++++++++++++++++++++-
 arch/arm/lib/board.c            |   7 ++-
 arch/blackfin/lib/board.c       |   7 +++
 arch/m68k/lib/board.c           |  17 +++++-
 arch/mips/lib/board.c           |   7 +++
 arch/nds32/lib/board.c          |  10 +++-
 arch/powerpc/cpu/mpc8xx/video.c |   4 ++
 arch/powerpc/lib/board.c        |  12 +++-
 common/cmd_date.c               |   9 +++
 common/cmd_dtt.c                |   9 +++
 common/cmd_i2c.c                | 120 ++++++++++++++++++++++++++--------------
 common/env_eeprom.c             |  14 +++++
 common/stdio.c                  |  13 ++++-
 include/i2c.h                   |   9 ---
 14 Dateien ge?ndert, 251 Zeilen hinzugef?gt(+), 61 Zeilen entfernt(-)

diff --git a/README b/README
index 862bb3e..3144d60 100644
--- a/README
+++ b/README
@@ -1884,9 +1884,77 @@ CBFS (Coreboot Filesystem) support
 		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.
+
+		ported i2c driver to the new framework:
+
+		additional defines:
+
+		CONFIG_SYS_NUM_I2C_BUSES
+		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. If you not use i2c muxes, omit this
+		define.
+
+		CONFIG_SYS_I2C_BUSES
+		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_BUSES = 9:
+
+		 CONFIG_SYS_I2C_BUSES	{{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
+
+		If you do not have i2c muxes on your board, omit this define.
+
+- 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:
+
+		- more than one i2c adapter is usable
+		- approved multibus support
+		- better i2c mux support
+
+		** 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 0521178..b473dcb 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -69,7 +69,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
 
@@ -169,7 +170,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);
 }
diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
index 75b6c46..309b927 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)
+#include <i2c.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 __attribute__((always_inline))
@@ -385,6 +389,9 @@ void board_init_r(gd_t * id, ulong dest_addr)
 	mmc_initialize(bd);
 #endif
 
+#if defined(CONFIG_SYS_I2C)
+	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 adaccfe..257fd47 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -56,7 +56,7 @@
 #include <version.h>
 
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+	defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
 #endif
 
@@ -142,11 +142,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)
 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);
 }
@@ -178,7 +183,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)
 	init_func_i2c,
 #endif
 #if defined(CONFIG_HARD_SPI)
@@ -501,6 +507,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	spi_init_r ();
 #endif
 
+#if defined(CONFIG_SYS_I2C)
+	/* 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 f19f198..fedac71 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -36,6 +36,9 @@
 #ifdef CONFIG_BITBANGMII
 #include <miiphy.h>
 #endif
+#if defined(CONFIG_SYS_I2C)
+#include <i2c.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -296,6 +299,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	onenand_init();
 #endif
 
+#if defined(CONFIG_SYS_I2C)
+	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 a7d27fc..8845d05 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 */
@@ -346,6 +350,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 422b4a3..23151ef 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -99,7 +99,7 @@ extern void sc3_read_eeprom(void);
 void doc_init(void);
 #endif
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+	defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
 #endif
 #include <spi.h>
@@ -214,11 +214,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)
 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;
 }
@@ -310,7 +315,8 @@ static 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)
 	init_func_i2c,
 #endif
 #if defined(CONFIG_HARD_SPI)
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 0ac032c..f7ae1da 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -50,8 +50,13 @@ static 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 @@ static 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 edbd4a8..c3f8982 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -73,8 +73,13 @@ int dtt_i2c(void)
 	/* 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();
 
@@ -86,8 +91,12 @@ int dtt_i2c(void)
 		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
+#endif
 
 	return 0;
 }
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 4380794..d59f10d 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.
  *
@@ -85,6 +90,8 @@
 #include <asm/byteorder.h>
 #include <linux/compiler.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Display values from last command.
  * Memory modify remembered values are different from display memory.
  */
@@ -103,7 +110,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 defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MUX) || \
+	defined(CONFIG_I2C_MULTI_BUS)
 static struct
 {
 	uchar	bus;
@@ -119,7 +127,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	/* defined(CONFIG_SYS_I2C) */
 
 #define NUM_ELEMENTS_NOPROBE (sizeof(i2c_no_probes)/sizeof(i2c_no_probes[0]))
 #endif
@@ -127,9 +135,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
@@ -144,7 +149,6 @@ DECLARE_GLOBAL_DATA_PTR;
 __weak
 void i2c_init_board(void)
 {
-	return;
 }
 
 /* TODO: Implement architecture-specific get/set functions */
@@ -161,6 +165,11 @@ void i2c_init_board(void)
  *
  * Returns I2C bus speed in Hz.
  */
+#if !defined(CONFIG_SYS_I2C)
+/*
+ * TODO: Implement architecture-specific get/set functions
+ * Should go away, if we switched completely to new multibus support
+ */
 __weak
 unsigned int i2c_get_bus_speed(void)
 {
@@ -188,6 +197,7 @@ int i2c_set_bus_speed(unsigned int speed)
 
 	return 0;
 }
+#endif
 
 /**
  * get_alen() - Small parser helper function to get address length
@@ -700,7 +710,7 @@ static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
 	int found = 0;
 #if defined(CONFIG_SYS_I2C_NOPROBES)
 	int k, skip;
-	uchar bus = GET_BUS_NUM;
+	unsigned int bus = GET_BUS_NUM;
 #endif	/* NOPROBES */
 
 	if (argc == 2)
@@ -1373,9 +1383,8 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 }
 #endif /* CONFIG_I2C_EDID */
 
-#if defined(CONFIG_I2C_MUX)
 /**
- * do_i2c_add_bus() - Handle the "i2c bus" command-line command
+ * do_i2c_show_bus() - Handle the "i2c bus" command-line command
  * @cmdtp:	Command data struct pointer
  * @flag:	Command flag
  * @argc:	Command-line argument count
@@ -1383,35 +1392,55 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
  *
  * Returns zero always.
  */
-static int do_i2c_add_bus(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+#if 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_BUSES; 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_BUSES) {
+			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)
 /**
  * do_i2c_bus_num() - Handle the "i2c dev" command-line command
  * @cmdtp:	Command data struct pointer
@@ -1422,23 +1451,29 @@ static int do_i2c_add_bus(cmd_tbl_t * cmdtp, int flag, int argc, char * const ar
  * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
  * on error.
  */
-static int do_i2c_bus_num(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+#if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS)
+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_BUSES) {
+			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  /* defined(CONFIG_SYS_I2C) */
 
 /**
  * do_i2c_bus_speed() - Handle the "i2c speed" command-line command
@@ -1508,16 +1543,21 @@ 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 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 defined(CONFIG_SYS_I2C) || \
+	defined(CONFIG_I2C_MULTI_BUS)
 	U_BOOT_CMD_MKENT(dev, 1, 1, do_i2c_bus_num, "", ""),
 #endif  /* CONFIG_I2C_MULTI_BUS */
 #if defined(CONFIG_I2C_EDID)
@@ -1576,11 +1616,11 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 /***************************************************/
 #ifdef CONFIG_SYS_LONGHELP
 static char i2c_help_text[] =
-#if defined(CONFIG_I2C_MUX)
-	"bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\ni2c "
+#if defined(CONFIG_SYS_I2C)
+	"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 defined(CONFIG_SYS_I2C)
 	"i2c dev [dev] - show or set current I2C bus\n"
 #endif  /* CONFIG_I2C_MULTI_BUS */
 #if defined(CONFIG_I2C_EDID)
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 45c935b..fbd459a 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 5d5117c..2011880 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
 
@@ -210,9 +215,15 @@ int stdio_init (void)
 #ifdef CONFIG_ARM_DCC
 	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 457fd7d..3e09af9 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -220,15 +220,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.11.7

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

* [U-Boot] [PATCH v3 3/9] i2c, soft-i2c: switch to new multibus/multiadapter support
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 1/9] i2c: add i2c_core and prepare for new multibus support Heiko Schocher
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 4/9] i2c, fsl_i2c: " Heiko Schocher
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 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>
Cc: Stephen Warren <swarren@wwwdotorg.org>

---
- changes for v2:
  - fix EEprom_ivm setting for km82xx boards
  - adapted README
  - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
  - pass i2c_adapter struct to i2c_core callbacks
    suggested by Stephen Warren and Simon Glass.
- changes for v3:
  - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
  - added README entry
  - patch has 2 different checkpatch warnings:
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
+#  define I2C_SOFT_DECLARATIONS volatile ioport_t *iop = \
WARNING: Avoid CamelCase: <pFIO_DIR>
+#define I2C_INIT		(*pFIO_DIR |=  PF_SCL); asm("ssync;")
    This should be fixed in a seperate step, as it affects a lot
    of boards...
---
 README                                    |  45 +++++++------
 arch/arm/lib/board.c                      |   5 +-
 arch/m68k/lib/board.c                     |   8 +--
 arch/powerpc/lib/board.c                  |   9 +--
 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/ivm.c                |   6 +-
 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/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                            |   8 +--
 drivers/i2c/Makefile                      |   2 +-
 drivers/i2c/soft_i2c.c                    | 104 ++++++++++++++++--------------
 include/configs/A3000.h                   |   4 +-
 include/configs/BSC9131RDB.h              |   1 -
 include/configs/CANBT.h                   |   1 +
 include/configs/CPU86.h                   |   7 +-
 include/configs/CPU87.h                   |   7 +-
 include/configs/DU440.h                   |   1 -
 include/configs/GEN860T.h                 |  39 ++++++-----
 include/configs/HIDDEN_DRAGON.h           |   9 ++-
 include/configs/ICU862.h                  |  13 ++--
 include/configs/IDS8247.h                 |   9 ++-
 include/configs/IP860.h                   |   9 ++-
 include/configs/IPHASE4539.h              |  11 ++--
 include/configs/JSE.h                     |   1 -
 include/configs/KAREF.h                   |   1 -
 include/configs/KUP4K.h                   |  11 ++--
 include/configs/KUP4X.h                   |  12 ++--
 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                    |   8 +--
 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                   |   8 +--
 include/configs/PM828.h                   |   8 +--
 include/configs/PMC440.h                  |   1 -
 include/configs/R360MPI.h                 |   6 +-
 include/configs/RPXClassic.h              |  16 +++--
 include/configs/RPXlite.h                 |  30 +++++++++
 include/configs/RRvision.h                |  12 ++--
 include/configs/SXNI855T.h                |   7 +-
 include/configs/Sandpoint8240.h           |  15 +++--
 include/configs/Sandpoint8245.h           |  15 +++--
 include/configs/TASREG.h                  |  28 ++++----
 include/configs/TK885D.h                  |  12 ++--
 include/configs/TOP5200.h                 |  12 ++--
 include/configs/TOP860.h                  |  10 +--
 include/configs/TQM8260.h                 |   8 +--
 include/configs/TQM8272.h                 |  12 ++--
 include/configs/TQM834x.h                 |   1 -
 include/configs/TQM855M.h                 |  12 ++--
 include/configs/TQM866M.h                 |  11 ++--
 include/configs/TQM885D.h                 |  12 ++--
 include/configs/alpr.h                    |   1 -
 include/configs/aria.h                    |   1 -
 include/configs/astro_mcf5373l.h          |   1 -
 include/configs/bf533-ezkit.h             |   9 ++-
 include/configs/bf533-stamp.h             |  48 ++++++++++++--
 include/configs/bf561-ezkit.h             |   8 ++-
 include/configs/bfin_adi_common.h         |   2 +-
 include/configs/blackstamp.h              |   3 +-
 include/configs/blackvme.h                |   2 +-
 include/configs/cpuat91.h                 |   3 +-
 include/configs/debris.h                  |   9 ++-
 include/configs/eXalion.h                 |   2 +-
 include/configs/eb_cpux9k2.h              |  13 ++--
 include/configs/ep8260.h                  |  13 ++--
 include/configs/ethernut5.h               |   8 ++-
 include/configs/ibf-dsp561.h              |   4 +-
 include/configs/iocon.h                   |  10 +--
 include/configs/km/keymile-common.h       |   3 -
 include/configs/km/km83xx-common.h        |   3 +
 include/configs/km/km_arm.h               |  24 +++++--
 include/configs/km82xx.h                  |  18 ++++--
 include/configs/km_kirkwood.h             |  16 ++---
 include/configs/korat.h                   |   1 -
 include/configs/lwmon.h                   |  12 ++--
 include/configs/lwmon5.h                  |   1 -
 include/configs/mecp5123.h                |   1 -
 include/configs/mpc5121ads.h              |   1 -
 include/configs/nhk8815.h                 |   7 +-
 include/configs/otc570.h                  |  17 +++--
 include/configs/p1_p2_rdb_pc.h            |   1 -
 include/configs/p3p440.h                  |   1 -
 include/configs/pcs440ep.h                |   1 -
 include/configs/pdnb3.h                   |  10 ++-
 include/configs/quad100hd.h               |   1 -
 include/configs/s5p_goni.h                |   6 +-
 include/configs/s5pc210_universal.h       |   6 +-
 include/configs/sacsng.h                  |  11 ++--
 include/configs/sbc405.h                  |   1 -
 include/configs/sbc8349.h                 |   1 -
 include/configs/sbc8548.h                 |   1 -
 include/configs/sbc8641d.h                |   1 -
 include/configs/sc3.h                     |   1 -
 include/configs/snapper9260.h             |   8 +--
 include/configs/socrates.h                |   1 -
 include/configs/spc1920.h                 |  12 ++--
 include/configs/stxgp3.h                  |   1 -
 include/configs/stxssa.h                  |   1 -
 include/configs/top9000.h                 |   9 +--
 include/configs/trats.h                   |   6 +-
 include/configs/u8500_href.h              |   1 -
 include/configs/uc100.h                   |  12 ++--
 include/configs/utx8245.h                 |   3 +-
 include/configs/vct.h                     |  11 ++--
 include/configs/vl_ma2sc.h                |   6 +-
 include/configs/vme8349.h                 |   1 -
 include/configs/zeus.h                    |   1 -
 include/i2c.h                             |   9 +++
 165 Dateien ge?ndert, 548 Zeilen hinzugef?gt(+), 492 Zeilen entfernt(-)

diff --git a/README b/README
index 3144d60..2568003 100644
--- a/README
+++ b/README
@@ -1894,6 +1894,19 @@ CBFS (Coreboot Filesystem) support
 		interface.
 
 		ported i2c driver to the new framework:
+		- drivers/i2c/soft_i2c.c:
+		  - activate first bus with CONFIG_SYS_I2C_SOFT define
+		    CONFIG_SYS_I2C_SOFT_SPEED and CONFIG_SYS_I2C_SOFT_SLAVE
+		    for defining speed and slave address
+		  - activate second bus with I2C_SOFT_DECLARATIONS2 define
+		    CONFIG_SYS_I2C_SOFT_SPEED_2 and CONFIG_SYS_I2C_SOFT_SLAVE_2
+		    for defining speed and slave address
+		  - activate third bus with I2C_SOFT_DECLARATIONS3 define
+		    CONFIG_SYS_I2C_SOFT_SPEED_3 and CONFIG_SYS_I2C_SOFT_SLAVE_3
+		    for defining speed and slave address
+		  - activate fourth bus with I2C_SOFT_DECLARATIONS4 define
+		    CONFIG_SYS_I2C_SOFT_SPEED_4 and CONFIG_SYS_I2C_SOFT_SLAVE_4
+		    for defining speed and slave address
 
 		additional defines:
 
@@ -1932,18 +1945,18 @@ CBFS (Coreboot Filesystem) support
 
 		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
 
 		If you do not have i2c muxes on your board, omit this define.
 
-- Legacy I2C Support:	CONFIG_HARD_I2C | CONFIG_SOFT_I2C
+- Legacy I2C Support:	CONFIG_HARD_I2C
 
 		NOTE: It is intended to move drivers to CONFIG_SYS_I2C which
 		provides the following compelling advantages:
@@ -1954,9 +1967,9 @@ CBFS (Coreboot Filesystem) support
 
 		** 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.
+		These enable legacy I2C serial bus commands. Defining
+		CONFIG_HARD_I2C will include the appropriate I2C driver
+		for the selected CPU.
 
 		This will allow you to use i2c commands at the u-boot
 		command line (as long as you set CONFIG_CMD_I2C in
@@ -1966,12 +1979,8 @@ CBFS (Coreboot Filesystem) support
 
 		CONFIG_HARD_I2C selects a hardware I2C controller.
 
-		CONFIG_SOFT_I2C configures u-boot to use a software (aka
-		bit-banging) driver instead of CPM or similar hardware
-		support for I2C.
-
 		There are several other quantities that must also be
-		defined when you define CONFIG_HARD_I2C or CONFIG_SOFT_I2C.
+		defined when you define CONFIG_HARD_I2C.
 
 		In both cases you will need to define CONFIG_SYS_I2C_SPEED
 		to be the frequency (in Hz) at which you wish your i2c bus
@@ -1993,7 +2002,7 @@ CBFS (Coreboot Filesystem) support
 
 		That's all that's required for CONFIG_HARD_I2C.
 
-		If you use the software i2c interface (CONFIG_SOFT_I2C)
+		If you use the software i2c interface (CONFIG_SYS_I2C_SOFT)
 		then the following macros need to be defined (examples are
 		from include/configs/lwmon.h):
 
@@ -3556,7 +3565,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 b473dcb..d580dd3 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -69,7 +69,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
@@ -166,7 +165,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:   ");
@@ -273,7 +272,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 257fd47..60a584b 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -56,7 +56,7 @@
 #include <version.h>
 
 #if defined(CONFIG_HARD_I2C) || \
-	defined(CONFIG_SOFT_I2C)
+	defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
 
@@ -142,8 +142,7 @@ static int init_func_ram (void)
 
 /***********************************************************************/
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || \
-		defined(CONFIG_SYS_I2C)
+#if defined(CONFIG_HARD_I2C) ||	defined(CONFIG_SYS_I2C)
 static int init_func_i2c (void)
 {
 	puts ("I2C:   ");
@@ -183,8 +182,7 @@ init_fnc_t *init_sequence[] = {
 	display_options,
 	checkcpu,
 	checkboard,
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || \
-		defined(CONFIG_SYS_I2C)
+#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 23151ef..93bb3f9 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -98,8 +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)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
 #include <spi.h>
@@ -214,8 +213,7 @@ static int init_func_ram(void)
 
 /***********************************************************************/
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || \
-		defined(CONFIG_SYS_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 static int init_func_i2c(void)
 {
 	puts("I2C:   ");
@@ -315,8 +313,7 @@ static 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)
+#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 c0ea1c6..ad50452 100644
--- a/board/cm5200/cm5200.c
+++ b/board/cm5200/cm5200.c
@@ -325,7 +325,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];
@@ -348,7 +348,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/ivm.c b/board/keymile/common/ivm.c
index 22d5256..918a6ab 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -318,10 +318,14 @@ 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 */
 	buf = (unsigned char *) getenv("EEprom_ivm");
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index eda9199..bd81938 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -63,7 +63,7 @@ static const 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
@@ -234,7 +234,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 */
@@ -260,7 +260,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
@@ -440,7 +440,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 34c6675..85e0995 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->arch.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/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 2011880..39eef5a 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -34,8 +34,8 @@
 #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
 
@@ -216,11 +216,9 @@ int stdio_init (void)
 	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)
+#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/soft_i2c.c b/drivers/i2c/soft_i2c.c
index ae3c573..1269304 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.
@@ -330,14 +313,10 @@ static uchar read_byte(int ack)
 	return(data);
 }
 
-/*=====================================================================*/
-/*                         Public Functions                            */
-/*=====================================================================*/
-
 /*-----------------------------------------------------------------------
  * Initialization
  */
-void i2c_init (int speed, int slaveaddr)
+static void soft_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
 {
 #if defined(CONFIG_SYS_I2C_INIT_BOARD)
 	/* call board specific i2c bus reset routine before accessing the   */
@@ -360,7 +339,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)
+static int soft_i2c_probe(struct i2c_adapter *adap, uint8_t addr)
 {
 	int rc;
 
@@ -378,7 +357,8 @@ int i2c_probe(uchar addr)
 /*-----------------------------------------------------------------------
  * Read bytes
  */
-int  i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
+static int  soft_i2c_read(struct i2c_adapter *adap, 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 +432,8 @@ 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)
+static int  soft_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
+			int alen, uchar *buffer, int len)
 {
 	int shift, failures = 0;
 
@@ -482,3 +463,32 @@ int  i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 	send_stop();
 	return(failures);
 }
+
+/*
+ * Register soft i2c adapters
+ */
+U_BOOT_I2C_ADAP_COMPLETE(soft0, soft_i2c_init, soft_i2c_probe,
+			 soft_i2c_read, soft_i2c_write, NULL,
+			 CONFIG_SYS_I2C_SOFT_SPEED, CONFIG_SYS_I2C_SOFT_SLAVE,
+			 0)
+#if defined(I2C_SOFT_DECLARATIONS2)
+U_BOOT_I2C_ADAP_COMPLETE(soft1, soft_i2c_init, soft_i2c_probe,
+			 soft_i2c_read, soft_i2c_write, NULL,
+			 CONFIG_SYS_I2C_SOFT_SPEED_2,
+			 CONFIG_SYS_I2C_SOFT_SLAVE_2,
+			 1)
+#endif
+#if defined(I2C_SOFT_DECLARATIONS3)
+U_BOOT_I2C_ADAP_COMPLETE(soft2, soft_i2c_init, soft_i2c_probe,
+			 soft_i2c_read, soft_i2c_write, NULL,
+			 CONFIG_SYS_I2C_SOFT_SPEED_3,
+			 CONFIG_SYS_I2C_SOFT_SLAVE_3,
+			 2)
+#endif
+#if defined(I2C_SOFT_DECLARATIONS4)
+U_BOOT_I2C_ADAP_COMPLETE(soft3, soft_i2c_init, soft_i2c_probe,
+			 soft_i2c_read, soft_i2c_write, NULL,
+			 CONFIG_SYS_I2C_SOFT_SPEED_4,
+			 CONFIG_SYS_I2C_SOFT_SLAVE_4,
+			 3)
+#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..fd3eff0 100644
--- a/include/configs/CANBT.h
+++ b/include/configs/CANBT.h
@@ -180,6 +180,7 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
+#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..43b07cf 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
+#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_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/CPU87.h b/include/configs/CPU87.h
index aa5ce29..c9ed376 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
+#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_SPEED		50000
-# define CONFIG_SYS_I2C_SLAVE		0xFE
 /*
  * 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 9a649ca..cc03d39 100644
--- a/include/configs/GEN860T.h
+++ b/include/configs/GEN860T.h
@@ -158,26 +158,33 @@
 /*
  * 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 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..354c44e 100644
--- a/include/configs/HIDDEN_DRAGON.h
+++ b/include/configs/HIDDEN_DRAGON.h
@@ -168,12 +168,15 @@
  * 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 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 +186,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/ICU862.h b/include/configs/ICU862.h
index b58b6f6..ca8138b 100644
--- a/include/configs/ICU862.h
+++ b/include/configs/ICU862.h
@@ -106,12 +106,10 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -133,6 +131,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..b5a8d37 100644
--- a/include/configs/IDS8247.h
+++ b/include/configs/IDS8247.h
@@ -73,11 +73,10 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/IP860.h b/include/configs/IP860.h
index 2379718..e5cc4e3 100644
--- a/include/configs/IP860.h
+++ b/include/configs/IP860.h
@@ -62,8 +62,10 @@
 
 
 /* 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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -80,9 +82,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..b1fec10 100644
--- a/include/configs/IPHASE4539.h
+++ b/include/configs/IPHASE4539.h
@@ -110,15 +110,13 @@
  * 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
 /*
  * 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 +126,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 dae9b8c..d6f3a62 100644
--- a/include/configs/KUP4K.h
+++ b/include/configs/KUP4K.h
@@ -106,13 +106,11 @@
 /*
  * 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_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 +126,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 cceee96..2473749 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_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C_SOFT_SPEED	93000	/* 93 kHz is supposed to work */
+#define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
 
-#ifdef CONFIG_SOFT_I2C
 /*
  * 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..fdd811d 100644
--- a/include/configs/MHPC.h
+++ b/include/configs/MHPC.h
@@ -73,8 +73,10 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -91,8 +93,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 d5f3c5f..c835cae 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 d233365..1a3ca11 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 437ee6e..cbdfaae 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 878bd5f..bb5329f 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..b2fa0fa 100644
--- a/include/configs/PM826.h
+++ b/include/configs/PM826.h
@@ -57,10 +57,10 @@
 	"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
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/PM828.h b/include/configs/PM828.h
index c37aafd..82179af 100644
--- a/include/configs/PM828.h
+++ b/include/configs/PM828.h
@@ -57,10 +57,10 @@
 	"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
 /*
  * 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 60cccff..df16598 100644
--- a/include/configs/R360MPI.h
+++ b/include/configs/R360MPI.h
@@ -97,10 +97,13 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -116,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 3595200..8130ee6 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 563abea..9a385a4 100644
--- a/include/configs/RPXlite.h
+++ b/include/configs/RPXlite.h
@@ -62,6 +62,36 @@
 #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
+/* 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
+/* play along with the linux driver */
+#define CONFIG_SYS_M41T11_BASE_YEAR 1900
+
 #undef	CONFIG_WATCHDOG			/* watchdog disabled		*/
 
 /*
diff --git a/include/configs/RRvision.h b/include/configs/RRvision.h
index e2ea016..b14136d 100644
--- a/include/configs/RRvision.h
+++ b/include/configs/RRvision.h
@@ -122,13 +122,10 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -144,7 +141,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/SXNI855T.h b/include/configs/SXNI855T.h
index b7fbe5e..f0ce282 100644
--- a/include/configs/SXNI855T.h
+++ b/include/configs/SXNI855T.h
@@ -121,7 +121,10 @@
 
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -138,8 +141,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..ea96238 100644
--- a/include/configs/Sandpoint8240.h
+++ b/include/configs/Sandpoint8240.h
@@ -201,13 +201,16 @@
  * If the software driver is chosen, there are some additional
  * 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
+#define CONFIG_HARD_I2C		1		/* To enable I2C support */
+#undef  CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C_SLAVE	0x7F
+#define CONFIG_SYS_I2C_SPEED	400000
 
-#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 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 +220,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..9a4863b 100644
--- a/include/configs/Sandpoint8245.h
+++ b/include/configs/Sandpoint8245.h
@@ -171,13 +171,16 @@
  * If the software driver is chosen, there are some additional
  * 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
+#define CONFIG_HARD_I2C		1		/* To enable I2C support */
+#undef  CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C_SPEED	400000
+#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 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 +190,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..059fb36 100644
--- a/include/configs/TASREG.h
+++ b/include/configs/TASREG.h
@@ -136,19 +136,11 @@
 /*-----------------------------------------------------------------------
  * 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
 
-#if defined (CONFIG_SOFT_I2C)
 #if 0 /* push-pull */
 #define	SDA	        0x00800000
 #define	SCL	        0x00000008
@@ -182,7 +174,17 @@
 #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
+/*
+ * The Catalyst CAT24WC32 has 32 byte page write mode using
+ * last 5 bits of the address
+ */
+#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 5
+#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 623cb66..af88773 100644
--- a/include/configs/TK885D.h
+++ b/include/configs/TK885D.h
@@ -104,13 +104,10 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -126,7 +123,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..e9dcefc 100644
--- a/include/configs/TOP5200.h
+++ b/include/configs/TOP5200.h
@@ -200,10 +200,13 @@
 #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 */
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
 
-#if defined (CONFIG_SOFT_I2C)
+#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 SDA0			0x40
 #  define SCL0			0x80
 #  define GPIOE0		*((volatile uchar*)(CONFIG_SYS_MBAR+0x0c00))
@@ -218,8 +221,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 4849f94..1f728e3 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,15 @@
 #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	SDA	0x00010
 #define	SCL	0x00020
 #define __I2C_DIR	immr->im_cpm.cp_pbdir
@@ -193,7 +194,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..5fbfd1c9 100644
--- a/include/configs/TQM8260.h
+++ b/include/configs/TQM8260.h
@@ -89,10 +89,10 @@
 #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
 
 /*
  * Software (bit-bang) I2C driver configuration
diff --git a/include/configs/TQM8272.h b/include/configs/TQM8272.h
index be977f1..a9c4610 100644
--- a/include/configs/TQM8272.h
+++ b/include/configs/TQM8272.h
@@ -97,11 +97,10 @@
 
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -135,8 +134,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 e7fd2db..1b558fc 100644
--- a/include/configs/TQM855M.h
+++ b/include/configs/TQM855M.h
@@ -93,13 +93,10 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -115,7 +112,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 7d0ae99..9104971 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
+#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_SPEED		93000	/* 93 kHz is supposed to work	*/
-#define CONFIG_SYS_I2C_SLAVE		0xFE
-
-#ifdef CONFIG_SOFT_I2C
 /*
  * 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 7941631..65d7c58 100644
--- a/include/configs/TQM885D.h
+++ b/include/configs/TQM885D.h
@@ -101,13 +101,10 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -123,7 +120,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 b425399..79163ee 100644
--- a/include/configs/aria.h
+++ b/include/configs/aria.h
@@ -370,7 +370,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..beab127 100644
--- a/include/configs/bf533-ezkit.h
+++ b/include/configs/bf533-ezkit.h
@@ -94,10 +94,15 @@
 /*
  * 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 */
+#endif
 
 /*
  * Misc Settings
diff --git a/include/configs/bf533-stamp.h b/include/configs/bf533-stamp.h
index e3344e9..7144c63 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,42 @@
 /* #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
+/*
+ * 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 +118,6 @@
 #define CONFIG_SYS_MAX_FLASH_BANKS	1
 #define CONFIG_SYS_MAX_FLASH_SECT	67
 
-
 /*
  * SPI Settings
  */
@@ -132,10 +165,15 @@
 /*
  * 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
+#endif
 
 /*
  * Compact Flash / IDE / ATA Settings
diff --git a/include/configs/bf561-ezkit.h b/include/configs/bf561-ezkit.h
index 1a9d27e..646c376 100644
--- a/include/configs/bf561-ezkit.h
+++ b/include/configs/bf561-ezkit.h
@@ -88,10 +88,14 @@
 /*
  * 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
+#endif
 
 /*
  * Misc Settings
diff --git a/include/configs/bfin_adi_common.h b/include/configs/bfin_adi_common.h
index d3ae3a7..8505efb 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..0b2b5cd 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
@@ -115,7 +114,7 @@
 # undef CONFIG_CMD_NET
 #endif
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 # define CONFIG_CMD_I2C
 #endif
 
diff --git a/include/configs/blackvme.h b/include/configs/blackvme.h
index 523c4e4..cd37f9a 100644
--- a/include/configs/blackvme.h
+++ b/include/configs/blackvme.h
@@ -224,7 +224,7 @@
  * Soft I2C settings (BF561 does not have hard I2C)
  * PF12,13 on SPI connector 0.
  */
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 # define CONFIG_CMD_I2C
 # define CONFIG_SOFT_I2C_GPIO_SCL	GPIO_PF12
 # define CONFIG_SOFT_I2C_GPIO_SDA	GPIO_PF13
diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
index 15d56c3..d9b006a 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)
 
@@ -139,7 +138,7 @@
 #undef CONFIG_CMD_NFS
 #undef CONFIG_CMD_DHCP
 
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_I2C
 #endif
diff --git a/include/configs/debris.h b/include/configs/debris.h
index 32aa4e5..8315c6e 100644
--- a/include/configs/debris.h
+++ b/include/configs/debris.h
@@ -272,12 +272,15 @@
  * 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 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 +290,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 3be4929..efb50e3 100644
--- a/include/configs/eb_cpux9k2.h
+++ b/include/configs/eb_cpux9k2.h
@@ -223,11 +223,10 @@
  * 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
 
 /* Software  I2C driver configuration */
 
@@ -251,9 +250,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 5a87cc5..2e675bc 100644
--- a/include/configs/ep8260.h
+++ b/include/configs/ep8260.h
@@ -227,15 +227,18 @@
  * 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 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 +248,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..5bf8c22 100644
--- a/include/configs/ethernut5.h
+++ b/include/configs/ethernut5.h
@@ -210,10 +210,12 @@
 
 /* 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 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..5291755 100644
--- a/include/configs/ibf-dsp561.h
+++ b/include/configs/ibf-dsp561.h
@@ -105,11 +105,11 @@
 /*
  * I2C Settings
  */
-#define CONFIG_SOFT_I2C		1
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
 #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..695aa5c 100644
--- a/include/configs/iocon.h
+++ b/include/configs/iocon.h
@@ -110,11 +110,11 @@
 /*
  * 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
 
 /*
  * Software (bit-bang) I2C driver configuration
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h
index 3b15c4e..6182e81 100644
--- a/include/configs/km/keymile-common.h
+++ b/include/configs/km/keymile-common.h
@@ -78,10 +78,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 eb0e5b6..5a430ed 100644
--- a/include/configs/km/km83xx-common.h
+++ b/include/configs/km/km83xx-common.h
@@ -209,6 +209,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 766d76e..c2c67c1 100644
--- a/include/configs/km/km_arm.h
+++ b/include/configs/km/km_arm.h
@@ -58,7 +58,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
@@ -187,8 +186,23 @@
 /*
  * 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_BUSES	6
+#define CONFIG_SYS_I2C_MAX_HOPS		1
+#define CONFIG_SYS_I2C_BUSES	{	{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);
@@ -211,6 +225,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 */
@@ -240,7 +256,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
@@ -293,7 +309,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..54041f3 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=1\0"						\
 	"unlock=yes\0"							\
 	"newenv="							\
 		"prot off 0xFE0C0000 +0x40000 && "			\
@@ -242,10 +242,16 @@
 #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_BUSES	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_BUSES	{{0, {I2C_NULL_HOP} }, \
+			{0, {{I2C_MUX_PCA9542, 0x70, 0} } }, \
+			{0, {{I2C_MUX_PCA9542, 0x70, 1} } } }
 
 /*
  * Software (bit-bang) I2C driver configuration
@@ -282,7 +288,7 @@ int get_scl(void);
 #define CONFIG_SYS_DTT_MAX_TEMP	70
 #define CONFIG_SYS_DTT_LOW_TEMP	-30
 #define CONFIG_SYS_DTT_HYSTERESIS	3
-#define CONFIG_SYS_DTT_BUS_NUM		(CONFIG_SYS_MAX_I2C_BUS)
+#define CONFIG_SYS_DTT_BUS_NUM		2
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1
 
diff --git a/include/configs/km_kirkwood.h b/include/configs/km_kirkwood.h
index 83bb7aa..a0ad47e 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,12 +95,12 @@
 #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
 
 /* KM_SUV31 */
 #elif defined(CONFIG_KM_SUV31)
-#define KM_IVM_BUS			"pca9547:70:9"	/* I2C2 (Mux-Port 1)*/
+#define CONFIG_KM_IVM_BUS		1	/* I2C2 (Mux-Port 1)*/
 #define CONFIG_IDENT_STRING		"\nKeymile SUV31"
 #define CONFIG_HOSTNAME			kmsuv31
 #define CONFIG_KM_ENV_IS_IN_SPI_NOR
@@ -114,7 +114,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 3c02b73..dc0bd33 100644
--- a/include/configs/lwmon.h
+++ b/include/configs/lwmon.h
@@ -146,13 +146,10 @@
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -168,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 ba613e3..4dcb25a 100644
--- a/include/configs/lwmon5.h
+++ b/include/configs/lwmon5.h
@@ -299,7 +299,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 af30257..a3be6e8 100644
--- a/include/configs/mecp5123.h
+++ b/include/configs/mecp5123.h
@@ -267,7 +267,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 6e6af62..fd87566 100644
--- a/include/configs/mpc5121ads.h
+++ b/include/configs/mpc5121ads.h
@@ -359,7 +359,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..09073e9 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -109,8 +109,11 @@
 #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 __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..010e1b9 100644
--- a/include/configs/otc570.h
+++ b/include/configs/otc570.h
@@ -115,14 +115,13 @@
 /* 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
+
 /* Configure data and clock pins for pio */
 # define I2C_INIT { \
 	at91_set_pio_output(AT91_PIO_PORTB, 4, 0); \
@@ -140,7 +139,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 7ed634b..bedf28f 100644
--- a/include/configs/p1_p2_rdb_pc.h
+++ b/include/configs/p1_p2_rdb_pc.h
@@ -535,7 +535,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..9aa112a 100644
--- a/include/configs/pdnb3.h
+++ b/include/configs/pdnb3.h
@@ -281,12 +281,10 @@
  */
 
 /* 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
 /*
  * 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 56e8347..89ae32b 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -226,8 +226,10 @@
 #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_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 eb13bb3..f7266aa 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -250,9 +250,11 @@
 #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_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..efbf6b6 100644
--- a/include/configs/sacsng.h
+++ b/include/configs/sacsng.h
@@ -296,15 +296,13 @@
  * 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
 /*
  * 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 +312,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/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..c683fab 100644
--- a/include/configs/snapper9260.h
+++ b/include/configs/snapper9260.h
@@ -106,11 +106,11 @@
 #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_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..2a9b00c 100644
--- a/include/configs/spc1920.h
+++ b/include/configs/spc1920.h
@@ -207,13 +207,10 @@
  */
 #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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -229,7 +226,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..884670d 100644
--- a/include/configs/top9000.h
+++ b/include/configs/top9000.h
@@ -201,11 +201,12 @@
 #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 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 fd58558..ccb5dc8 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -269,10 +269,12 @@
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
 #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_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 450c98b..ce122b4 100644
--- a/include/configs/uc100.h
+++ b/include/configs/uc100.h
@@ -464,13 +464,10 @@
  */
 
 /* 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
 /*
  * Software (bit-bang) I2C driver configuration
  */
@@ -486,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 66568c8..813e08a 100644
--- a/include/configs/utx8245.h
+++ b/include/configs/utx8245.h
@@ -234,8 +234,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 7aeb668..fbdb728 100644
--- a/include/configs/vct.h
+++ b/include/configs/vct.h
@@ -245,11 +245,10 @@
 /*
  * 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
 
 /*
  * Software (bit-bang) I2C driver configuration
@@ -337,7 +336,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..5c43c1b 100644
--- a/include/configs/vl_ma2sc.h
+++ b/include/configs/vl_ma2sc.h
@@ -147,10 +147,12 @@
 #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
 
 /* 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 3e09af9..f532a14 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -305,6 +305,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.11.7

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

* [U-Boot] [PATCH v3 4/9] i2c, fsl_i2c: switch to new multibus/multiadapter support
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
                   ` (2 preceding siblings ...)
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 3/9] i2c, soft-i2c: switch to new " Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 5/9] i2c, multibus: get rid of CONFIG_I2C_MUX Heiko Schocher
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 UTC (permalink / raw)
  To: u-boot

- added to fsl_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>
Cc: Stephen Warren <swarren@wwwdotorg.org>

---
- changes for v2:
  new in v2
- changes for v3:
  - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
  - adapt README
---
 README                                      |  17 ++-
 arch/m68k/cpu/mcf5227x/cpu_init.c           |   2 +-
 arch/m68k/cpu/mcf5227x/speed.c              |   2 +-
 arch/m68k/cpu/mcf523x/cpu_init.c            |   2 +-
 arch/m68k/cpu/mcf523x/speed.c               |   2 +-
 arch/m68k/cpu/mcf52x2/cpu_init.c            |   4 +-
 arch/m68k/cpu/mcf52x2/speed.c               |   4 +-
 arch/m68k/cpu/mcf532x/cpu_init.c            |   4 +-
 arch/m68k/cpu/mcf532x/speed.c               |   2 +-
 arch/m68k/cpu/mcf5445x/speed.c              |   2 +-
 arch/m68k/cpu/mcf547x_8x/cpu_init.c         |   2 +-
 arch/m68k/cpu/mcf547x_8x/speed.c            |   2 +-
 arch/m68k/include/asm/global_data.h         |   2 +-
 board/esd/vme8349/vme8349.c                 |   6 +-
 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/freescale/mpc8349itx/mpc8349itx.c     |   3 +-
 board/freescale/mpc8349itx/pci.c            |   2 +-
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c |   2 +-
 board/keymile/common/ivm.c                  |  16 --
 board/keymile/km83xx/km83xx.c               |  15 --
 drivers/i2c/Makefile                        |   2 +-
 drivers/i2c/fsl_i2c.c                       | 220 +++++++++++-----------------
 include/configs/B4860QDS.h                  |  16 +-
 include/configs/BSC9131RDB.h                |  11 +-
 include/configs/BSC9132QDS.h                |  17 +--
 include/configs/HWW1U1A.h                   |  18 +--
 include/configs/M5208EVBE.h                 |  10 +-
 include/configs/M52277EVB.h                 |  10 +-
 include/configs/M5235EVB.h                  |  10 +-
 include/configs/M5253DEMO.h                 |  10 +-
 include/configs/M5271EVB.h                  |  10 +-
 include/configs/M5275EVB.h                  |  10 +-
 include/configs/M53017EVB.h                 |  10 +-
 include/configs/M5329EVB.h                  |  10 +-
 include/configs/M5373EVB.h                  |  10 +-
 include/configs/M54451EVB.h                 |  10 +-
 include/configs/M54455EVB.h                 |  10 +-
 include/configs/M5475EVB.h                  |  10 +-
 include/configs/M5485EVB.h                  |  10 +-
 include/configs/MERGERBOX.h                 |  15 +-
 include/configs/MPC8308RDB.h                |  17 ++-
 include/configs/MPC8313ERDB.h               |  17 ++-
 include/configs/MPC8315ERDB.h               |  13 +-
 include/configs/MPC8323ERDB.h               |  12 +-
 include/configs/MPC832XEMDS.h               |  12 +-
 include/configs/MPC8349EMDS.h               |  17 ++-
 include/configs/MPC8349ITX.h                |  22 +--
 include/configs/MPC8360EMDS.h               |  13 +-
 include/configs/MPC8360ERDK.h               |  17 ++-
 include/configs/MPC837XEMDS.h               |  13 +-
 include/configs/MPC837XERDB.h               |  13 +-
 include/configs/MPC8536DS.h                 |  17 ++-
 include/configs/MPC8540ADS.h                |  12 +-
 include/configs/MPC8541CDS.h                |  12 +-
 include/configs/MPC8544DS.h                 |  12 +-
 include/configs/MPC8548CDS.h                |  12 +-
 include/configs/MPC8555CDS.h                |  12 +-
 include/configs/MPC8560ADS.h                |  12 +-
 include/configs/MPC8568MDS.h                |  17 ++-
 include/configs/MPC8569MDS.h                |  17 ++-
 include/configs/MPC8572DS.h                 |  17 ++-
 include/configs/MPC8610HPCD.h               |  12 +-
 include/configs/MPC8641HPCN.h               |  12 +-
 include/configs/MVBLM7.h                    |  16 +-
 include/configs/P1010RDB.h                  |  17 ++-
 include/configs/P1022DS.h                   |  16 +-
 include/configs/P1023RDS.h                  |  15 +-
 include/configs/P1_P2_RDB.h                 |  18 +--
 include/configs/P2020COME.h                 |  16 +-
 include/configs/P2020DS.h                   |  17 ++-
 include/configs/P2041RDB.h                  |  16 +-
 include/configs/SIMPC8313.h                 |  17 ++-
 include/configs/TQM834x.h                   |  10 +-
 include/configs/astro_mcf5373l.h            |  10 +-
 include/configs/corenet_ds.h                |  16 +-
 include/configs/km/km83xx-common.h          |  27 ++--
 include/configs/mpc8308_p1m.h               |  15 +-
 include/configs/mpq101.h                    |  16 +-
 include/configs/p1_p2_rdb_pc.h              |  18 +--
 include/configs/sbc8349.h                   |  17 ++-
 include/configs/sbc8548.h                   |  10 +-
 include/configs/sbc8641d.h                  |  12 +-
 include/configs/socrates.h                  |  16 +-
 include/configs/stxgp3.h                    |  11 +-
 include/configs/stxssa.h                    |  10 +-
 include/configs/t4qds.h                     |  17 ++-
 include/configs/vme8349.h                   |  19 ++-
 include/configs/xpedite517x.h               |  15 +-
 include/configs/xpedite520x.h               |  15 +-
 include/configs/xpedite537x.h               |  16 +-
 include/configs/xpedite550x.h               |  15 +-
 95 Dateien ge?ndert, 622 Zeilen hinzugef?gt(+), 671 Zeilen entfernt(-)

diff --git a/README b/README
index 2568003..5e0395e 100644
--- a/README
+++ b/README
@@ -1908,6 +1908,18 @@ CBFS (Coreboot Filesystem) support
 		    CONFIG_SYS_I2C_SOFT_SPEED_4 and CONFIG_SYS_I2C_SOFT_SLAVE_4
 		    for defining speed and slave address
 
+		- drivers/i2c/fsl_i2c.c:
+		  - activate i2c driver with CONFIG_SYS_I2C_FSL
+		    define CONFIG_SYS_FSL_I2C_OFFSET for setting the register
+		    offset CONFIG_SYS_FSL_I2C_SPEED for the i2c speed and
+		    CONFIG_SYS_FSL_I2C_SLAVE for the slave addr of the first
+		    bus.
+                  - If your board supports a second fsl i2c bus, define
+		    CONFIG_SYS_FSL_I2C2_OFFSET for the register offset
+		    CONFIG_SYS_FSL_I2C2_SPEED for the speed and
+		    CONFIG_SYS_FSL_I2C2_SLAVE for the slave address of the
+		    second bus.
+
 		additional defines:
 
 		CONFIG_SYS_NUM_I2C_BUSES
@@ -2153,11 +2165,6 @@ CBFS (Coreboot Filesystem) support
 		If not defined, then U-Boot uses predefined value for
 		specified DTT device.
 
-		CONFIG_FSL_I2C
-
-		Define this option if you want to use Freescale's I2C driver in
-		drivers/i2c/fsl_i2c.c.
-
 		CONFIG_I2C_MUX
 
 		Define this option if you have I2C devices reached over 1 .. n
diff --git a/arch/m68k/cpu/mcf5227x/cpu_init.c b/arch/m68k/cpu/mcf5227x/cpu_init.c
index 1928eb3..e9ac21a 100644
--- a/arch/m68k/cpu/mcf5227x/cpu_init.c
+++ b/arch/m68k/cpu/mcf5227x/cpu_init.c
@@ -105,7 +105,7 @@ void cpu_init_f(void)
 	out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
 #endif
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	out_8(&gpio->par_i2c, GPIO_PAR_I2C_SCL_SCL | GPIO_PAR_I2C_SDA_SDA);
 #endif
 
diff --git a/arch/m68k/cpu/mcf5227x/speed.c b/arch/m68k/cpu/mcf5227x/speed.c
index 98f554a..30d3207 100644
--- a/arch/m68k/cpu/mcf5227x/speed.c
+++ b/arch/m68k/cpu/mcf5227x/speed.c
@@ -134,7 +134,7 @@ int get_clocks(void)
 		gd->bus_clk = gd->arch.flb_clk;
 	}
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	gd->arch.i2c1_clk = gd->bus_clk;
 #endif
 
diff --git a/arch/m68k/cpu/mcf523x/cpu_init.c b/arch/m68k/cpu/mcf523x/cpu_init.c
index d1c0b40..1ad5d02 100644
--- a/arch/m68k/cpu/mcf523x/cpu_init.c
+++ b/arch/m68k/cpu/mcf523x/cpu_init.c
@@ -115,7 +115,7 @@ void cpu_init_f(void)
 	out_be32(&fbcs->csmr7, CONFIG_SYS_CS7_MASK);
 #endif
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
 	CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
 #endif
diff --git a/arch/m68k/cpu/mcf523x/speed.c b/arch/m68k/cpu/mcf523x/speed.c
index ae46257..7876ba8 100644
--- a/arch/m68k/cpu/mcf523x/speed.c
+++ b/arch/m68k/cpu/mcf523x/speed.c
@@ -47,7 +47,7 @@ int get_clocks(void)
 	gd->bus_clk = CONFIG_SYS_CLK;
 	gd->cpu_clk = (gd->bus_clk * 2);
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	gd->arch.i2c1_clk = gd->bus_clk;
 #endif
 
diff --git a/arch/m68k/cpu/mcf52x2/cpu_init.c b/arch/m68k/cpu/mcf52x2/cpu_init.c
index 5d0e9f0..5d01670 100644
--- a/arch/m68k/cpu/mcf52x2/cpu_init.c
+++ b/arch/m68k/cpu/mcf52x2/cpu_init.c
@@ -228,7 +228,7 @@ void cpu_init_f(void)
 	/* FlexBus Chipselect */
 	init_fbcs();
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	CONFIG_SYS_I2C_PINMUX_REG =
 	    CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR;
 	CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
@@ -498,7 +498,7 @@ void cpu_init_f(void)
 	init_fbcs();
 #endif				/* #ifndef CONFIG_MONITOR_IS_IN_RAM */
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
 	CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
 #endif
diff --git a/arch/m68k/cpu/mcf52x2/speed.c b/arch/m68k/cpu/mcf52x2/speed.c
index ba7dbaa..ad68692 100644
--- a/arch/m68k/cpu/mcf52x2/speed.c
+++ b/arch/m68k/cpu/mcf52x2/speed.c
@@ -90,9 +90,9 @@ int get_clocks (void)
 	gd->bus_clk = gd->cpu_clk;
 #endif
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	gd->arch.i2c1_clk = gd->bus_clk;
-#ifdef CONFIG_SYS_I2C2_OFFSET
+#ifdef CONFIG_SYS_I2C2_FSL_OFFSET
 	gd->arch.i2c2_clk = gd->bus_clk;
 #endif
 #endif
diff --git a/arch/m68k/cpu/mcf532x/cpu_init.c b/arch/m68k/cpu/mcf532x/cpu_init.c
index f571fad..bd7672d 100644
--- a/arch/m68k/cpu/mcf532x/cpu_init.c
+++ b/arch/m68k/cpu/mcf532x/cpu_init.c
@@ -98,7 +98,7 @@ void cpu_init_f(void)
 	out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
 #endif
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	out_8(&gpio->par_feci2c,
 		GPIO_PAR_FECI2C_SDA_SDA | GPIO_PAR_FECI2C_SCL_SCL);
 #endif
@@ -292,7 +292,7 @@ void cpu_init_f(void)
 	out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
 #endif
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	out_8(&gpio->par_feci2c,
 		GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
 #endif
diff --git a/arch/m68k/cpu/mcf532x/speed.c b/arch/m68k/cpu/mcf532x/speed.c
index 8efb451..6e1d6a5 100644
--- a/arch/m68k/cpu/mcf532x/speed.c
+++ b/arch/m68k/cpu/mcf532x/speed.c
@@ -270,7 +270,7 @@ int get_clocks(void)
 	gd->bus_clk = clock_pll(CONFIG_SYS_CLK / 1000, 0) * 1000;
 	gd->cpu_clk = (gd->bus_clk * 3);
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	gd->arch.i2c1_clk = gd->bus_clk;
 #endif
 
diff --git a/arch/m68k/cpu/mcf5445x/speed.c b/arch/m68k/cpu/mcf5445x/speed.c
index aa73e1f..f220c76 100644
--- a/arch/m68k/cpu/mcf5445x/speed.c
+++ b/arch/m68k/cpu/mcf5445x/speed.c
@@ -273,7 +273,7 @@ void setup_5445x_clocks(void)
 #endif
 	}
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	gd->arch.i2c1_clk = gd->bus_clk;
 #endif
 }
diff --git a/arch/m68k/cpu/mcf547x_8x/cpu_init.c b/arch/m68k/cpu/mcf547x_8x/cpu_init.c
index 4eb8a7c..4c529dc 100644
--- a/arch/m68k/cpu/mcf547x_8x/cpu_init.c
+++ b/arch/m68k/cpu/mcf547x_8x/cpu_init.c
@@ -95,7 +95,7 @@ void cpu_init_f(void)
 	out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
 #endif
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	out_be16(&gpio->par_feci2cirq,
 		GPIO_PAR_FECI2CIRQ_SCL | GPIO_PAR_FECI2CIRQ_SDA);
 #endif
diff --git a/arch/m68k/cpu/mcf547x_8x/speed.c b/arch/m68k/cpu/mcf547x_8x/speed.c
index 41aae9d..80e006b 100644
--- a/arch/m68k/cpu/mcf547x_8x/speed.c
+++ b/arch/m68k/cpu/mcf547x_8x/speed.c
@@ -40,7 +40,7 @@ int get_clocks(void)
 	gd->bus_clk = CONFIG_SYS_CLK;
 	gd->cpu_clk = (gd->bus_clk * 2);
 
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	gd->arch.i2c1_clk = gd->bus_clk;
 #endif
 
diff --git a/arch/m68k/include/asm/global_data.h b/arch/m68k/include/asm/global_data.h
index 3ec298f..58a481d 100644
--- a/arch/m68k/include/asm/global_data.h
+++ b/arch/m68k/include/asm/global_data.h
@@ -26,7 +26,7 @@
 
 /* Architecture-specific global data */
 struct arch_global_data {
-#ifdef CONFIG_FSL_I2C
+#ifdef CONFIG_SYS_I2C_FSL
 	unsigned long	i2c1_clk;
 	unsigned long	i2c2_clk;
 #endif
diff --git a/board/esd/vme8349/vme8349.c b/board/esd/vme8349/vme8349.c
index 96698e7..8c8b8ee 100644
--- a/board/esd/vme8349/vme8349.c
+++ b/board/esd/vme8349/vme8349.c
@@ -186,11 +186,11 @@ static spd_eeprom_t default_spd_eeprom = {
 
 int vme8349_read_spd(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
-	int old_bus = I2C_GET_BUS();
+	int old_bus = i2c_get_bus_num();
 	unsigned int l, sum;
 	int valid = 0;
 
-	I2C_SET_BUS(0);
+	i2c_set_bus_num(0);
 
 	if (i2c_read(chip, addr, alen, buffer, len) == 0)
 		if (memcmp(&buffer[64], &default_spd_eeprom.mid[0], 8) == 0) {
@@ -215,7 +215,7 @@ int vme8349_read_spd(uchar chip, uint addr, int alen, uchar *buffer, int len)
 		buffer[63] = sum;
 	}
 
-	I2C_SET_BUS(old_bus);
+	i2c_set_bus_num(old_bus);
 
 	return 0;
 }
diff --git a/board/freescale/m52277evb/README b/board/freescale/m52277evb/README
index d5e7b05..3178d49 100644
--- a/board/freescale/m52277evb/README
+++ b/board/freescale/m52277evb/README
@@ -82,7 +82,7 @@ CONFIG_CMD_DATE		-- enable to use date feature in u-boot
 CONFIG_MCFTMR		-- define to use DMA timer
 CONFIG_MCFPIT		-- define to use PIT timer
 
-CONFIG_FSL_I2C		-- define to use FSL common I2C driver
+CONFIG_SYS_I2C_FSL	-- define to use FSL common I2C driver
 CONFIG_HARD_I2C		-- define for I2C hardware support
 CONFIG_SYS_I2C_SOFT	-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
diff --git a/board/freescale/m53017evb/README b/board/freescale/m53017evb/README
index 855bbd1..84fc1ec 100644
--- a/board/freescale/m53017evb/README
+++ b/board/freescale/m53017evb/README
@@ -90,7 +90,7 @@ MCFFEC_TOUT_LOOP		-- set FEC timeout loop
 CONFIG_MCFTMR			-- define to use DMA timer
 CONFIG_MCFPIT			-- define to use PIT timer
 
-CONFIG_FSL_I2C			-- define to use FSL common I2C driver
+CONFIG_SYS_I2C_FSL		-- define to use FSL common I2C driver
 CONFIG_HARD_I2C			-- define for I2C hardware support
 CONFIG_SYS_I2C_SOFT		-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
diff --git a/board/freescale/m5373evb/README b/board/freescale/m5373evb/README
index 61e6d97..52eac7b 100644
--- a/board/freescale/m5373evb/README
+++ b/board/freescale/m5373evb/README
@@ -89,7 +89,7 @@ MCFFEC_TOUT_LOOP	-- set FEC timeout loop
 CONFIG_MCFTMR		-- define to use DMA timer
 CONFIG_MCFPIT		-- define to use PIT timer
 
-CONFIG_FSL_I2C		-- define to use FSL common I2C driver
+CONFIG_SYS_I2C_FSL	-- define to use FSL common I2C driver
 CONFIG_HARD_I2C		-- define for I2C hardware support
 CONFIG_SYS_I2C_SOFT	-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
diff --git a/board/freescale/m54455evb/README b/board/freescale/m54455evb/README
index 2b25952..c70c4c5 100644
--- a/board/freescale/m54455evb/README
+++ b/board/freescale/m54455evb/README
@@ -112,7 +112,7 @@ _IO_BASE		-- define for IO base address
 CONFIG_MCFTMR		-- define to use DMA timer
 CONFIG_MCFPIT		-- define to use PIT timer
 
-CONFIG_FSL_I2C		-- define to use FSL common I2C driver
+CONFIG_SYS_FSL_I2C	-- define to use FSL common I2C driver
 CONFIG_HARD_I2C		-- define for I2C hardware support
 CONFIG_SYS_I2C_SOFT	-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
diff --git a/board/freescale/m547xevb/README b/board/freescale/m547xevb/README
index 1a8cbce..ce497c0 100644
--- a/board/freescale/m547xevb/README
+++ b/board/freescale/m547xevb/README
@@ -97,7 +97,7 @@ CONFIG_DOS_PARTITION	-- enable DOS read/write
 
 CONFIG_SLTTMR		-- define to use SLT timer
 
-CONFIG_FSL_I2C		-- define to use FSL common I2C driver
+CONFIG_SYS_I2C_FSL	-- define to use FSL common I2C driver
 CONFIG_HARD_I2C		-- define for I2C hardware support
 CONFIG_SYS_I2C_SOFT	-- define for I2C bit-banged
 CONFIG_SYS_I2C_SPEED		-- define for I2C speed
diff --git a/board/freescale/mpc8349itx/mpc8349itx.c b/board/freescale/mpc8349itx/mpc8349itx.c
index 9cc808e..271768d 100644
--- a/board/freescale/mpc8349itx/mpc8349itx.c
+++ b/board/freescale/mpc8349itx/mpc8349itx.c
@@ -263,8 +263,7 @@ int misc_init_r(void)
 {
 	int rc = 0;
 
-#ifdef CONFIG_HARD_I2C
-
+#if defined(CONFIG_SYS_I2C)
 	unsigned int orig_bus = i2c_get_bus_num();
 	u8 i2c_data;
 
diff --git a/board/freescale/mpc8349itx/pci.c b/board/freescale/mpc8349itx/pci.c
index 7d30d9b..1ab4e0c 100644
--- a/board/freescale/mpc8349itx/pci.c
+++ b/board/freescale/mpc8349itx/pci.c
@@ -87,7 +87,7 @@ void pci_init_board(void)
 #endif
 	u8 reg8;
 
-#ifdef CONFIG_HARD_I2C
+#if defined(CONFIG_SYS_I2C)
 	i2c_set_bus_num(1);
 	/* Read the PCI_M66EN jumper setting */
 	if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
index 5b5b86c..2c84fe6 100644
--- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
+++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
@@ -231,7 +231,7 @@ int checkboard(void)
 		in_8(&cpld_data->pcba_rev) & 0x0F);
 
 	/* Initialize i2c early for rom_loc and flash bank information */
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
 
 	if (i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 0, 1, &in, 1) < 0 ||
 	    i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 1, 1, &out, 1) < 0 ||
diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index 918a6ab..a14496f 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -314,29 +314,13 @@ int ivm_analyze_eeprom(unsigned char *buf, int len)
 
 int ivm_read_eeprom(void)
 {
-#if defined(CONFIG_I2C_MUX)
-	I2C_MUX_DEVICE *dev = NULL;
-#endif
 	uchar i2c_buffer[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
 	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 */
-	buf = (unsigned char *) getenv("EEprom_ivm");
-	if (buf != NULL)
-		dev = i2c_mux_ident_muxstring(buf);
-	if (dev == NULL) {
-		printf("Error couldnt add Bus for IVM\n");
-		return -1;
-	}
-	i2c_set_bus_num(dev->busid);
-#endif
 	/* add deblocking here */
 	i2c_make_abort();
 
diff --git a/board/keymile/km83xx/km83xx.c b/board/keymile/km83xx/km83xx.c
index faaa39b..6d45809 100644
--- a/board/keymile/km83xx/km83xx.c
+++ b/board/keymile/km83xx/km83xx.c
@@ -95,19 +95,6 @@ const qe_iop_conf_t qe_iop_conf_tab[] = {
 	{0,  0, 0, 0, QE_IOP_TAB_END},
 };
 
-static int board_init_i2c_busses(void)
-{
-	I2C_MUX_DEVICE *dev = NULL;
-	uchar *dtt_bus = (uchar *)"pca9547:70:a";
-
-	/* Set up the Bus for the DTTs */
-	dev = i2c_mux_ident_muxstring(dtt_bus);
-	if (dev == NULL)
-		printf("Error couldn't add Bus for DTT\n");
-
-	return 0;
-}
-
 #if defined(CONFIG_SUVD3)
 const uint upma_table[] = {
 	0x1ffedc00, 0x0ffcdc80, 0x0ffcdc80, 0x0ffcdc04, /* Words 0 to 3 */
@@ -206,8 +193,6 @@ int board_early_init_r(void)
 
 int misc_init_r(void)
 {
-	/* add board specific i2c busses */
-	board_init_i2c_busses();
 	return 0;
 }
 
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 3e69270..2162173 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -28,7 +28,6 @@ LIB	:= $(obj)libi2c.o
 COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
 COBJS-$(CONFIG_DRIVER_DAVINCI_I2C) += davinci_i2c.o
 COBJS-$(CONFIG_DW_I2C) += designware_i2c.o
-COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
 COBJS-$(CONFIG_I2C_MVTWSI) += mvtwsi.o
 COBJS-$(CONFIG_I2C_MV) += mv_i2c.o
 COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
@@ -46,6 +45,7 @@ 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_FSL) += fsl_i2c.o
 COBJS-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o
 
 COBJS	:= $(COBJS-y)
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index 1c7265d..2e749f9 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -1,6 +1,9 @@
 /*
  * Copyright 2006,2009 Freescale Semiconductor, Inc.
  *
+ * 2012, Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ * Changes for multibus/multiadapter I2C support.
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * Version 2 as published by the Free Software Foundation.
@@ -17,12 +20,8 @@
  */
 
 #include <common.h>
-
-#ifdef CONFIG_HARD_I2C
-
 #include <command.h>
 #include <i2c.h>		/* Functional interface */
-
 #include <asm/io.h>
 #include <asm/fsl_i2c.h>	/* HW definitions */
 
@@ -47,25 +46,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/* Initialize the bus pointer to whatever one the SPD EEPROM is on.
- * Default is bus 0.  This is necessary because the DDR initialization
- * runs from ROM, and we can't switch buses because we can't modify
- * the global variables.
- */
-#ifndef CONFIG_SYS_SPD_BUS_NUM
-#define CONFIG_SYS_SPD_BUS_NUM 0
-#endif
-static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = CONFIG_SYS_SPD_BUS_NUM;
-#if defined(CONFIG_I2C_MUX)
-static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
-#endif
-
-static unsigned int i2c_bus_speed[2] = {CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SPEED};
-
 static const struct fsl_i2c *i2c_dev[2] = {
-	(struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET),
-#ifdef CONFIG_SYS_I2C2_OFFSET
-	(struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C2_OFFSET)
+	(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
 };
 
@@ -222,12 +206,9 @@ static unsigned int get_i2c_clock(int bus)
 		return gd->arch.i2c1_clk;	/* I2C1 clock */
 }
 
-void
-i2c_init(int speed, int slaveadd)
+static void fsl_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
 {
 	const struct fsl_i2c *dev;
-	unsigned int temp;
-	int bus_num, i;
 
 #ifdef CONFIG_SYS_I2C_INIT_BOARD
 	/* Call board specific i2c bus reset routine before accessing the
@@ -236,23 +217,14 @@ i2c_init(int speed, int slaveadd)
 	*/
 	i2c_init_board();
 #endif
-#ifdef CONFIG_SYS_I2C2_OFFSET
-	bus_num = 2;
-#else
-	bus_num = 1;
-#endif
-	for (i = 0; i < bus_num; i++) {
-		dev = i2c_dev[i];
-
-		writeb(0, &dev->cr);		/* stop I2C controller */
-		udelay(5);			/* let it shutdown in peace */
-		temp = set_i2c_bus_speed(dev, get_i2c_clock(i), speed);
-		if (gd->flags & GD_FLG_RELOC)
-			i2c_bus_speed[i] = temp;
-		writeb(slaveadd << 1, &dev->adr);/* write slave address */
-		writeb(0x0, &dev->sr);		/* clear status register */
-		writeb(I2C_CR_MEN, &dev->cr);	/* start I2C controller */
-	}
+	dev = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
+
+	writeb(0, &dev->cr);		/* stop I2C controller */
+	udelay(5);			/* let it shutdown in peace */
+	set_i2c_bus_speed(dev, get_i2c_clock(adap->hwadapnr), speed);
+	writeb(slaveadd << 1, &dev->adr);/* write slave address */
+	writeb(0x0, &dev->sr);		/* clear status register */
+	writeb(I2C_CR_MEN, &dev->cr);	/* start I2C controller */
 
 #ifdef CONFIG_SYS_I2C_BOARD_LATE_INIT
 	/* Call board specific i2c bus reset routine AFTER the bus has been
@@ -265,12 +237,13 @@ i2c_init(int speed, int slaveadd)
 }
 
 static int
-i2c_wait4bus(void)
+i2c_wait4bus(struct i2c_adapter *adap)
 {
+	struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
 	unsigned long long timeval = get_ticks();
 	const unsigned long long timeout = usec2ticks(CONFIG_I2C_MBB_TIMEOUT);
 
-	while (readb(&i2c_dev[i2c_bus_num]->sr) & I2C_SR_MBB) {
+	while (readb(&dev->sr) & I2C_SR_MBB) {
 		if ((get_ticks() - timeval) > timeout)
 			return -1;
 	}
@@ -279,20 +252,21 @@ i2c_wait4bus(void)
 }
 
 static __inline__ int
-i2c_wait(int write)
+i2c_wait(struct i2c_adapter *adap, int write)
 {
 	u32 csr;
 	unsigned long long timeval = get_ticks();
 	const unsigned long long timeout = usec2ticks(CONFIG_I2C_TIMEOUT);
+	struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
 
 	do {
-		csr = readb(&i2c_dev[i2c_bus_num]->sr);
+		csr = readb(&dev->sr);
 		if (!(csr & I2C_SR_MIF))
 			continue;
 		/* Read again to allow register to stabilise */
-		csr = readb(&i2c_dev[i2c_bus_num]->sr);
+		csr = readb(&dev->sr);
 
-		writeb(0x0, &i2c_dev[i2c_bus_num]->sr);
+		writeb(0x0, &dev->sr);
 
 		if (csr & I2C_SR_MAL) {
 			debug("i2c_wait: MAL\n");
@@ -317,29 +291,32 @@ i2c_wait(int write)
 }
 
 static __inline__ int
-i2c_write_addr (u8 dev, u8 dir, int rsta)
+i2c_write_addr(struct i2c_adapter *adap, u8 dev, u8 dir, int rsta)
 {
+	struct fsl_i2c *device = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
+
 	writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_MTX
 	       | (rsta ? I2C_CR_RSTA : 0),
-	       &i2c_dev[i2c_bus_num]->cr);
+	       &device->cr);
 
-	writeb((dev << 1) | dir, &i2c_dev[i2c_bus_num]->dr);
+	writeb((dev << 1) | dir, &device->dr);
 
-	if (i2c_wait(I2C_WRITE_BIT) < 0)
+	if (i2c_wait(adap, I2C_WRITE_BIT) < 0)
 		return 0;
 
 	return 1;
 }
 
 static __inline__ int
-__i2c_write(u8 *data, int length)
+__i2c_write(struct i2c_adapter *adap, u8 *data, int length)
 {
+	struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
 	int i;
 
 	for (i = 0; i < length; i++) {
-		writeb(data[i], &i2c_dev[i2c_bus_num]->dr);
+		writeb(data[i], &dev->dr);
 
-		if (i2c_wait(I2C_WRITE_BIT) < 0)
+		if (i2c_wait(adap, I2C_WRITE_BIT) < 0)
 			break;
 	}
 
@@ -347,54 +324,57 @@ __i2c_write(u8 *data, int length)
 }
 
 static __inline__ int
-__i2c_read(u8 *data, int length)
+__i2c_read(struct i2c_adapter *adap, u8 *data, int length)
 {
+	struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
 	int i;
 
 	writeb(I2C_CR_MEN | I2C_CR_MSTA | ((length == 1) ? I2C_CR_TXAK : 0),
-	       &i2c_dev[i2c_bus_num]->cr);
+	       &dev->cr);
 
 	/* dummy read */
-	readb(&i2c_dev[i2c_bus_num]->dr);
+	readb(&dev->dr);
 
 	for (i = 0; i < length; i++) {
-		if (i2c_wait(I2C_READ_BIT) < 0)
+		if (i2c_wait(adap, I2C_READ_BIT) < 0)
 			break;
 
 		/* Generate ack on last next to last byte */
 		if (i == length - 2)
 			writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_TXAK,
-			       &i2c_dev[i2c_bus_num]->cr);
+			       &dev->cr);
 
 		/* Do not generate stop on last byte */
 		if (i == length - 1)
 			writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_MTX,
-			       &i2c_dev[i2c_bus_num]->cr);
+			       &dev->cr);
 
-		data[i] = readb(&i2c_dev[i2c_bus_num]->dr);
+		data[i] = readb(&dev->dr);
 	}
 
 	return i;
 }
 
-int
-i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
+static int
+fsl_i2c_read(struct i2c_adapter *adap, u8 dev, uint addr, int alen, u8 *data,
+	     int length)
 {
+	struct fsl_i2c *device = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
 	int i = -1; /* signal error */
 	u8 *a = (u8*)&addr;
 
-	if (i2c_wait4bus() >= 0
-	    && i2c_write_addr(dev, I2C_WRITE_BIT, 0) != 0
-	    && __i2c_write(&a[4 - alen], alen) == alen)
+	if (i2c_wait4bus(adap) >= 0 &&
+	    i2c_write_addr(adap, dev, I2C_WRITE_BIT, 0) != 0 &&
+	    __i2c_write(adap, &a[4 - alen], alen) == alen)
 		i = 0; /* No error so far */
 
-	if (length
-	    && i2c_write_addr(dev, I2C_READ_BIT, 1) != 0)
-		i = __i2c_read(data, length);
+	if (length &&
+	    i2c_write_addr(adap, dev, I2C_READ_BIT, 1) != 0)
+		i = __i2c_read(adap, data, length);
 
-	writeb(I2C_CR_MEN, &i2c_dev[i2c_bus_num]->cr);
+	writeb(I2C_CR_MEN, &device->cr);
 
-	if (i2c_wait4bus()) /* Wait until STOP */
+	if (i2c_wait4bus(adap)) /* Wait until STOP */
 		debug("i2c_read: wait4bus timed out\n");
 
 	if (i == length)
@@ -403,20 +383,22 @@ i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
 	return -1;
 }
 
-int
-i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
+static int
+fsl_i2c_write(struct i2c_adapter *adap, u8 dev, uint addr, int alen,
+	      u8 *data, int length)
 {
+	struct fsl_i2c *device = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
 	int i = -1; /* signal error */
 	u8 *a = (u8*)&addr;
 
-	if (i2c_wait4bus() >= 0
-	    && i2c_write_addr(dev, I2C_WRITE_BIT, 0) != 0
-	    && __i2c_write(&a[4 - alen], alen) == alen) {
-		i = __i2c_write(data, length);
+	if (i2c_wait4bus(adap) >= 0 &&
+	    i2c_write_addr(adap, dev, I2C_WRITE_BIT, 0) != 0 &&
+	    __i2c_write(adap, &a[4 - alen], alen) == alen) {
+		i = __i2c_write(adap, data, length);
 	}
 
-	writeb(I2C_CR_MEN, &i2c_dev[i2c_bus_num]->cr);
-	if (i2c_wait4bus()) /* Wait until STOP */
+	writeb(I2C_CR_MEN, &device->cr);
+	if (i2c_wait4bus(adap)) /* Wait until STOP */
 		debug("i2c_write: wait4bus timed out\n");
 
 	if (i == length)
@@ -425,72 +407,42 @@ i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
 	return -1;
 }
 
-int
-i2c_probe(uchar chip)
+static int
+fsl_i2c_probe(struct i2c_adapter *adap, uchar chip)
 {
+	struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
 	/* For unknow reason the controller will ACK when
 	 * probing for a slave with the same address, so skip
 	 * it.
 	 */
-	if (chip == (readb(&i2c_dev[i2c_bus_num]->adr) >> 1))
-		return -1;
-
-	return i2c_read(chip, 0, 0, NULL, 0);
-}
-
-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);
-		if (ret)
-			return ret;
-		i2c_bus_num = 0;
-	}
-	i2c_bus_num_mux = bus;
-#else
-#ifdef CONFIG_SYS_I2C2_OFFSET
-	if (bus > 1) {
-#else
-	if (bus > 0) {
-#endif
+	if (chip == (readb(&dev->adr) >> 1))
 		return -1;
-	}
 
-	i2c_bus_num = bus;
-#endif
-	return 0;
+	return fsl_i2c_read(adap, chip, 0, 0, NULL, 0);
 }
 
-int i2c_set_bus_speed(unsigned int speed)
+static unsigned int fsl_i2c_set_bus_speed(struct i2c_adapter *adap,
+			unsigned int speed)
 {
-	unsigned int i2c_clk = (i2c_bus_num == 1)
-			? gd->arch.i2c2_clk : gd->arch.i2c1_clk;
+	struct fsl_i2c *dev = (struct fsl_i2c *)i2c_dev[adap->hwadapnr];
 
-	writeb(0, &i2c_dev[i2c_bus_num]->cr);		/* stop controller */
-	i2c_bus_speed[i2c_bus_num] =
-		set_i2c_bus_speed(i2c_dev[i2c_bus_num], i2c_clk, speed);
-	writeb(I2C_CR_MEN, &i2c_dev[i2c_bus_num]->cr);	/* start controller */
+	writeb(0, &dev->cr);		/* stop controller */
+	set_i2c_bus_speed(dev, get_i2c_clock(adap->hwadapnr), speed);
+	writeb(I2C_CR_MEN, &dev->cr);	/* start controller */
 
 	return 0;
 }
 
-unsigned int i2c_get_bus_num(void)
-{
-#if defined(CONFIG_I2C_MUX)
-	return i2c_bus_num_mux;
-#else
-	return i2c_bus_num;
+/*
+ * Register fsl i2c adapters
+ */
+U_BOOT_I2C_ADAP_COMPLETE(fsl_0, fsl_i2c_init, fsl_i2c_probe, fsl_i2c_read,
+			 fsl_i2c_write, fsl_i2c_set_bus_speed,
+			 CONFIG_SYS_FSL_I2C_SPEED, CONFIG_SYS_FSL_I2C_SLAVE,
+			 0)
+#ifdef CONFIG_SYS_FSL_I2C2_OFFSET
+U_BOOT_I2C_ADAP_COMPLETE(fsl_1, fsl_i2c_init, fsl_i2c_probe, fsl_i2c_read,
+			 fsl_i2c_write, fsl_i2c_set_bus_speed,
+			 CONFIG_SYS_FSL_I2C2_SPEED, CONFIG_SYS_FSL_I2C2_SLAVE,
+			 1)
 #endif
-}
-
-unsigned int i2c_get_bus_speed(void)
-{
-	return i2c_bus_speed[i2c_bus_num];
-}
-
-#endif /* CONFIG_HARD_I2C */
diff --git a/include/configs/B4860QDS.h b/include/configs/B4860QDS.h
index b09119a..f9a8613 100644
--- a/include/configs/B4860QDS.h
+++ b/include/configs/B4860QDS.h
@@ -447,14 +447,14 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed in Hz */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x118000
-#define CONFIG_SYS_I2C2_OFFSET		0x119000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL		/* Use FSL common I2C driver */
+#define CONFIG_SYS_FSL_I2C_SPEED	400000	/* I2C speed in Hz */
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000	/* I2C speed in Hz */
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x118000
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x119000
 
 /*
  * RTC configuration
diff --git a/include/configs/BSC9131RDB.h b/include/configs/BSC9131RDB.h
index 134cd7b..350da32 100644
--- a/include/configs/BSC9131RDB.h
+++ b/include/configs/BSC9131RDB.h
@@ -239,12 +239,11 @@ extern unsigned long get_sdram_size(void);
 #define CONFIG_FIT
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
-#define CONFIG_FSL_I2C			/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C			/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED		400000 /* I2C speed and slave address*/
-#define CONFIG_SYS_I2C_OFFSET		0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
 
 /* I2C EEPROM */
 #define CONFIG_CMD_EEPROM
diff --git a/include/configs/BSC9132QDS.h b/include/configs/BSC9132QDS.h
index 431c686..d90c7fa 100644
--- a/include/configs/BSC9132QDS.h
+++ b/include/configs/BSC9132QDS.h
@@ -402,15 +402,14 @@ combinations. this should be removed later
 #define CONFIG_FIT
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
-#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		400800 /* I2C speed and slave address*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400800 /* I2C speed and slave address*/
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_SPEED	400800 /* I2C speed and slave address*/
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /* I2C EEPROM */
 #define CONFIG_ID_EEPROM
diff --git a/include/configs/HWW1U1A.h b/include/configs/HWW1U1A.h
index 791763a..b6a5b72 100644
--- a/include/configs/HWW1U1A.h
+++ b/include/configs/HWW1U1A.h
@@ -217,16 +217,16 @@
 /* -------------------------------------------------------------------- */
 
 /* Generic FreeScale hardware I2C support */
-#define CONFIG_HARD_I2C
-#define CONFIG_FSL_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x29} }
 #define CONFIG_CMD_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_OFFSET  0x3000
-#define CONFIG_SYS_I2C2_OFFSET 0x3100
-
-/* I2C bus configuration */
-#define CONFIG_SYS_I2C_SPEED 400000
-#define CONFIG_SYS_I2C_SLAVE 0x7F
 
 /* DDR2 SO-RDIMM SPD EEPROM is at I2C0-0x51 */
 #define CONFIG_SYS_SPD_BUS_NUM 0
diff --git a/include/configs/M5208EVBE.h b/include/configs/M5208EVBE.h
index 209c122..8410d8b 100644
--- a/include/configs/M5208EVBE.h
+++ b/include/configs/M5208EVBE.h
@@ -82,11 +82,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C			/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x58000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x58000
 #define CONFIG_SYS_IMMR			CONFIG_SYS_MBAR
 
 #define CONFIG_BOOTDELAY		1	/* autoboot after 5 seconds */
diff --git a/include/configs/M52277EVB.h b/include/configs/M52277EVB.h
index b1bdac2..4275088 100644
--- a/include/configs/M52277EVB.h
+++ b/include/configs/M52277EVB.h
@@ -145,11 +145,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2c */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED		80000	/* I2C speed and slave address  */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x58000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x58000
 #define CONFIG_SYS_IMMR			CONFIG_SYS_MBAR
 
 /* DSPI and Serial Flash */
diff --git a/include/configs/M5235EVB.h b/include/configs/M5235EVB.h
index dfc2ddf..3ba4d14 100644
--- a/include/configs/M5235EVB.h
+++ b/include/configs/M5235EVB.h
@@ -99,11 +99,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x00000300
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_i2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x00000300
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 #define CONFIG_SYS_I2C_PINMUX_REG	(gpio->par_qspi)
 #define CONFIG_SYS_I2C_PINMUX_CLR	~(GPIO_PAR_FECI2C_SCL_MASK | GPIO_PAR_FECI2C_SDA_MASK)
diff --git a/include/configs/M5253DEMO.h b/include/configs/M5253DEMO.h
index fe1cca5..eb375f0 100644
--- a/include/configs/M5253DEMO.h
+++ b/include/configs/M5253DEMO.h
@@ -114,11 +114,11 @@
 #define CONFIG_HOSTNAME		M5253DEMO
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x00000280
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x00000280
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 #define CONFIG_SYS_I2C_PINMUX_REG	(*(u32 *) (CONFIG_SYS_MBAR+0x19C))
 #define CONFIG_SYS_I2C_PINMUX_CLR	(0xFFFFE7FF)
diff --git a/include/configs/M5271EVB.h b/include/configs/M5271EVB.h
index e8a8998..9ca850e 100644
--- a/include/configs/M5271EVB.h
+++ b/include/configs/M5271EVB.h
@@ -109,11 +109,11 @@
 #endif
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x00000300
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x00000300
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 
 #define CONFIG_BOOTDELAY	1	/* autoboot after 1 seconds */
diff --git a/include/configs/M5275EVB.h b/include/configs/M5275EVB.h
index fbf0c9d..9d2dfa0 100644
--- a/include/configs/M5275EVB.h
+++ b/include/configs/M5275EVB.h
@@ -109,11 +109,11 @@
 #endif
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x00000300
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x00000300
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 #define CONFIG_SYS_I2C_PINMUX_REG	(gpio_reg->par_feci2c)
 #define CONFIG_SYS_I2C_PINMUX_CLR	(0xFFF0)
diff --git a/include/configs/M53017EVB.h b/include/configs/M53017EVB.h
index bedba2b..4bb693a 100644
--- a/include/configs/M53017EVB.h
+++ b/include/configs/M53017EVB.h
@@ -101,11 +101,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C			/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x58000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x58000
 #define CONFIG_SYS_IMMR			CONFIG_SYS_MBAR
 
 #define CONFIG_BOOTDELAY		1	/* autoboot after 5 seconds */
diff --git a/include/configs/M5329EVB.h b/include/configs/M5329EVB.h
index 06fa57c..23ee61e 100644
--- a/include/configs/M5329EVB.h
+++ b/include/configs/M5329EVB.h
@@ -95,11 +95,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C			/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x58000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x58000
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 
 #define CONFIG_BOOTDELAY	1	/* autoboot after 5 seconds */
diff --git a/include/configs/M5373EVB.h b/include/configs/M5373EVB.h
index faa4f86..bbfef90 100644
--- a/include/configs/M5373EVB.h
+++ b/include/configs/M5373EVB.h
@@ -95,11 +95,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x58000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x58000
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 
 #define CONFIG_BOOTDELAY	1	/* autoboot after 5 seconds */
diff --git a/include/configs/M54451EVB.h b/include/configs/M54451EVB.h
index 5dbe0b4..85cd464 100644
--- a/include/configs/M54451EVB.h
+++ b/include/configs/M54451EVB.h
@@ -156,11 +156,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2c */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED		80000	/* I2C speed and slave address  */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x58000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x58000
 #define CONFIG_SYS_IMMR			CONFIG_SYS_MBAR
 
 /* DSPI and Serial Flash */
diff --git a/include/configs/M54455EVB.h b/include/configs/M54455EVB.h
index 8eeda74..fd53c0f 100644
--- a/include/configs/M54455EVB.h
+++ b/include/configs/M54455EVB.h
@@ -189,11 +189,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2c */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED		80000	/* I2C speed and slave address  */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x58000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSLI2C_OFFSET	0x58000
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 
 /* DSPI and Serial Flash */
diff --git a/include/configs/M5475EVB.h b/include/configs/M5475EVB.h
index 6e9cba0..5377a51 100644
--- a/include/configs/M5475EVB.h
+++ b/include/configs/M5475EVB.h
@@ -120,11 +120,11 @@
 #endif
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x00008F00
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x00008F00
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 
 /* PCI */
diff --git a/include/configs/M5485EVB.h b/include/configs/M5485EVB.h
index 24f28e0..316e07c 100644
--- a/include/configs/M5485EVB.h
+++ b/include/configs/M5485EVB.h
@@ -117,11 +117,11 @@
 #endif
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C		/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x00008F00
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x00008F00
 #define CONFIG_SYS_IMMR		CONFIG_SYS_MBAR
 
 /* PCI */
diff --git a/include/configs/MERGERBOX.h b/include/configs/MERGERBOX.h
index c296e3c..234158d 100644
--- a/include/configs/MERGERBOX.h
+++ b/include/configs/MERGERBOX.h
@@ -223,13 +223,14 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS 1
 
 /* I2C */
-#define CONFIG_HARD_I2C
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED		120000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /*
  * General PCI
diff --git a/include/configs/MPC8308RDB.h b/include/configs/MPC8308RDB.h
index 95a1885..620de8b 100644
--- a/include/configs/MPC8308RDB.h
+++ b/include/configs/MPC8308RDB.h
@@ -350,14 +350,15 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED	400000 /* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x51} } /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x51} }
 
 /*
  * SPI on header J8
diff --git a/include/configs/MPC8313ERDB.h b/include/configs/MPC8313ERDB.h
index c28dfe0..7c0a16c 100644
--- a/include/configs/MPC8313ERDB.h
+++ b/include/configs/MPC8313ERDB.h
@@ -402,14 +402,15 @@
 #define CONFIG_SYS_HUSH_PARSER
 
 /* I2C */
-#define CONFIG_HARD_I2C			/* I2C with hardware support*/
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x69} } /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /*
  * General PCI
diff --git a/include/configs/MPC8315ERDB.h b/include/configs/MPC8315ERDB.h
index 767b976..14b8b1c 100644
--- a/include/configs/MPC8315ERDB.h
+++ b/include/configs/MPC8315ERDB.h
@@ -347,13 +347,12 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_SYS_I2C_SPEED		400000 /* I2C speed and slave addr */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES		{0x51} /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x51} }
 
 /*
  * Board info - revision and where boot from
diff --git a/include/configs/MPC8323ERDB.h b/include/configs/MPC8323ERDB.h
index 0e7e5ad..c7cb1f5 100644
--- a/include/configs/MPC8323ERDB.h
+++ b/include/configs/MPC8323ERDB.h
@@ -233,12 +233,12 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{0x51}	/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x51} }
 
 /*
  * Config on-board EEPROM
diff --git a/include/configs/MPC832XEMDS.h b/include/configs/MPC832XEMDS.h
index 0b72a26..cabb503 100644
--- a/include/configs/MPC832XEMDS.h
+++ b/include/configs/MPC832XEMDS.h
@@ -326,12 +326,12 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{0x51}	/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x51} }
 
 /*
  * Config on-board RTC
diff --git a/include/configs/MPC8349EMDS.h b/include/configs/MPC8349EMDS.h
index 5e0f54f..baf61ad 100644
--- a/include/configs/MPC8349EMDS.h
+++ b/include/configs/MPC8349EMDS.h
@@ -354,14 +354,15 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x69} }	/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /* SPI */
 #define CONFIG_MPC8XXX_SPI
diff --git a/include/configs/MPC8349ITX.h b/include/configs/MPC8349ITX.h
index 9a46fb0..de7941d 100644
--- a/include/configs/MPC8349ITX.h
+++ b/include/configs/MPC8349ITX.h
@@ -90,7 +90,7 @@
 
 #define CONFIG_PCI
 #define CONFIG_RTC_DS1337
-#define CONFIG_HARD_I2C
+#define CONFIG_SYS_I2C
 #define CONFIG_TSEC_ENET		/* TSEC Ethernet support */
 
 /*
@@ -98,12 +98,15 @@
  */
 
 /* I2C */
-#ifdef CONFIG_HARD_I2C
+#ifdef CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
 #define CONFIG_SYS_SPD_BUS_NUM		1	/* The I2C bus for SPD */
 #define CONFIG_SYS_RTC_BUS_NUM		1	/* The I2C bus for RTC */
 
@@ -115,9 +118,6 @@
 #define CONFIG_SYS_I2C_RTC_ADDR		0x68	/* I2C1, DS1339 RTC*/
 #define SPD_EEPROM_ADDRESS		0x51	/* I2C1, DDR */
 
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-
 /* Don't probe these addresses: */
 #define CONFIG_SYS_I2C_NOPROBES	{ {1, CONFIG_SYS_I2C_8574_ADDR1}, \
 				 {1, CONFIG_SYS_I2C_8574_ADDR2}, \
@@ -197,7 +197,7 @@
 #define CONFIG_VERY_BIG_RAM
 #define CONFIG_MAX_MEM_MAPPED   ((phys_size_t)256 << 20)
 
-#ifdef CONFIG_HARD_I2C
+#ifdef CONFIG_SYS_I2C
 #define CONFIG_SPD_EEPROM		/* use SPD EEPROM for DDR setup*/
 #endif
 
@@ -542,7 +542,7 @@ boards, we say we have two, but don't display a message if we find only one. */
 	#define CONFIG_CMD_PCI
 #endif
 
-#ifdef CONFIG_HARD_I2C
+#ifdef CONFIG_SYS_I2C
 	#define CONFIG_CMD_I2C
 #endif
 
diff --git a/include/configs/MPC8360EMDS.h b/include/configs/MPC8360EMDS.h
index e2ae65a..647a55a 100644
--- a/include/configs/MPC8360EMDS.h
+++ b/include/configs/MPC8360EMDS.h
@@ -423,13 +423,12 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{0x52} /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET 0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x52} }
 
 /*
  * Config on-board RTC
diff --git a/include/configs/MPC8360ERDK.h b/include/configs/MPC8360ERDK.h
index 971a3e0..1ddfb40 100644
--- a/include/configs/MPC8360ERDK.h
+++ b/include/configs/MPC8360ERDK.h
@@ -287,14 +287,15 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x52} } /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x52} }
 
 /*
  * General PCI
diff --git a/include/configs/MPC837XEMDS.h b/include/configs/MPC837XEMDS.h
index 95ea116..bf17f71 100644
--- a/include/configs/MPC837XEMDS.h
+++ b/include/configs/MPC837XEMDS.h
@@ -341,13 +341,12 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_SYS_I2C_SPEED	400000 /* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{0x51} /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x51} }
 
 /*
  * Config on-board RTC
diff --git a/include/configs/MPC837XERDB.h b/include/configs/MPC837XERDB.h
index b9f437d..24bedae 100644
--- a/include/configs/MPC837XERDB.h
+++ b/include/configs/MPC837XERDB.h
@@ -367,13 +367,12 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS 1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_SYS_I2C_SPEED	400000 /* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{0x51} /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x51} }
 
 /*
  * Config on-board RTC
diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h
index c47281f..3356410 100644
--- a/include/configs/MPC8536DS.h
+++ b/include/configs/MPC8536DS.h
@@ -433,14 +433,15 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{{0, 0x29}}	/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x29} }
 
 /*
  * I2C2 EEPROM
diff --git a/include/configs/MPC8540ADS.h b/include/configs/MPC8540ADS.h
index aca41e6..4520e9b 100644
--- a/include/configs/MPC8540ADS.h
+++ b/include/configs/MPC8540ADS.h
@@ -259,12 +259,12 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#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 */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /* RapidIO MMU */
 #define CONFIG_SYS_RIO_MEM_VIRT	0xc0000000	/* base address */
diff --git a/include/configs/MPC8541CDS.h b/include/configs/MPC8541CDS.h
index d2a4f78..b897b73 100644
--- a/include/configs/MPC8541CDS.h
+++ b/include/configs/MPC8541CDS.h
@@ -282,12 +282,12 @@ 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*/
-#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 */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /* EEPROM */
 #define CONFIG_ID_EEPROM
diff --git a/include/configs/MPC8544DS.h b/include/configs/MPC8544DS.h
index c835cae..8730112 100644
--- a/include/configs/MPC8544DS.h
+++ b/include/configs/MPC8544DS.h
@@ -231,13 +231,13 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{0x69}	/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET		0x3100
 
 /*
  * General PCI
diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h
index aa5c0c9..facf3aa 100644
--- a/include/configs/MPC8548CDS.h
+++ b/include/configs/MPC8548CDS.h
@@ -357,12 +357,12 @@ 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*/
-#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
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /* EEPROM */
 #define CONFIG_ID_EEPROM
diff --git a/include/configs/MPC8555CDS.h b/include/configs/MPC8555CDS.h
index 32a375f..4c788fb 100644
--- a/include/configs/MPC8555CDS.h
+++ b/include/configs/MPC8555CDS.h
@@ -280,12 +280,12 @@ 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*/
-#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 */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /* EEPROM */
 #define CONFIG_ID_EEPROM
diff --git a/include/configs/MPC8560ADS.h b/include/configs/MPC8560ADS.h
index b8c657c..6585ad2 100644
--- a/include/configs/MPC8560ADS.h
+++ b/include/configs/MPC8560ADS.h
@@ -253,12 +253,12 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#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 */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /* RapidIO MMU */
 #define CONFIG_SYS_RIO_MEM_VIRT	0xc0000000	/* base address */
diff --git a/include/configs/MPC8568MDS.h b/include/configs/MPC8568MDS.h
index 31d83d3..97b2df7 100644
--- a/include/configs/MPC8568MDS.h
+++ b/include/configs/MPC8568MDS.h
@@ -265,15 +265,16 @@ 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*/
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x52
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES        {{0,0x69}}	/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
 
 /*
  * General PCI
diff --git a/include/configs/MPC8569MDS.h b/include/configs/MPC8569MDS.h
index 40c8dd9..b979a34 100644
--- a/include/configs/MPC8569MDS.h
+++ b/include/configs/MPC8569MDS.h
@@ -301,14 +301,15 @@ 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*/
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{{0,0x69}}	/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /*
  * I2C2 EEPROM
diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h
index 1a3ca11..f86cb21 100644
--- a/include/configs/MPC8572DS.h
+++ b/include/configs/MPC8572DS.h
@@ -430,15 +430,16 @@
 #define CONFIG_FIT_VERBOSE	1 /* enable fit_format_{error,warning}() */
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x29} }
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{{0,0x29}}/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
 
 /*
  * I2C2 EEPROM
diff --git a/include/configs/MPC8610HPCD.h b/include/configs/MPC8610HPCD.h
index 27f825f..67fd6d6 100644
--- a/include/configs/MPC8610HPCD.h
+++ b/include/configs/MPC8610HPCD.h
@@ -251,12 +251,12 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#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 */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /*
  * General PCI
diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h
index 3323c8d..02acd41 100644
--- a/include/configs/MPC8641HPCN.h
+++ b/include/configs/MPC8641HPCN.h
@@ -298,12 +298,12 @@ 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*/
-#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 */
-#define CONFIG_SYS_I2C_OFFSET		0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /*
  * RapidIO MMU
diff --git a/include/configs/MVBLM7.h b/include/configs/MVBLM7.h
index a99ad3c..fc6023f 100644
--- a/include/configs/MVBLM7.h
+++ b/include/configs/MVBLM7.h
@@ -43,7 +43,6 @@
 
 #define CONFIG_PCI
 #define CONFIG_PCI_SKIP_HOST_BRIDGE
-#define CONFIG_HARD_I2C
 #define CONFIG_TSEC_ENET
 #define CONFIG_MPC8XXX_SPI
 #define CONFIG_HARD_SPI
@@ -51,13 +50,14 @@
 #define CONFIG_MISC_INIT_R
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
-
-#define CONFIG_SYS_I2C_SPEED		100000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	100000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	100000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /*
  * DDR Setup
diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h
index cbdfaae..21451d2 100644
--- a/include/configs/P1010RDB.h
+++ b/include/configs/P1010RDB.h
@@ -475,14 +475,15 @@ extern unsigned long get_sdram_size(void);
 #define CONFIG_FIT
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
-#define CONFIG_FSL_I2C			/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C			/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED		400000 /* I2C speed and slave address*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
+/* I2C */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /* I2C EEPROM */
 #undef CONFIG_ID_EEPROM
diff --git a/include/configs/P1022DS.h b/include/configs/P1022DS.h
index 14d597a..d842266 100644
--- a/include/configs/P1022DS.h
+++ b/include/configs/P1022DS.h
@@ -257,15 +257,15 @@
 #define CONFIG_FIT_VERBOSE
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED		400000
-#define CONFIG_SYS_I2C_EEPROM_ADDR	0x57
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 #define CONFIG_SYS_I2C_NOPROBES		{{0, 0x29}}
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
 
 /*
  * I2C2 EEPROM
diff --git a/include/configs/P1023RDS.h b/include/configs/P1023RDS.h
index bb5329f..98dfa0c 100644
--- a/include/configs/P1023RDS.h
+++ b/include/configs/P1023RDS.h
@@ -312,14 +312,15 @@ extern unsigned long get_clock_freq(void);
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x51
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
 
 /*
  * I2C2 EEPROM
diff --git a/include/configs/P1_P2_RDB.h b/include/configs/P1_P2_RDB.h
index 6e92735..bbafe86 100644
--- a/include/configs/P1_P2_RDB.h
+++ b/include/configs/P1_P2_RDB.h
@@ -366,15 +366,15 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_FIT_VERBOSE	1 /* enable fit_format_{error,warning}() */
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{{0,0x29}}	/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x29} }
 
 /*
  * I2C2 EEPROM
diff --git a/include/configs/P2020COME.h b/include/configs/P2020COME.h
index fc3f236..356037f 100644
--- a/include/configs/P2020COME.h
+++ b/include/configs/P2020COME.h
@@ -224,15 +224,15 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_FIT_VERBOSE		1
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#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_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 #define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x29} }
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
 
 /*
  * I2C2 EEPROM
diff --git a/include/configs/P2020DS.h b/include/configs/P2020DS.h
index a975ee1..bac6d1e 100644
--- a/include/configs/P2020DS.h
+++ b/include/configs/P2020DS.h
@@ -386,15 +386,16 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x57
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{{0,0x29}}/* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x29} }
 
 /*
  * I2C2 EEPROM
diff --git a/include/configs/P2041RDB.h b/include/configs/P2041RDB.h
index bbc53ce..ee15973 100644
--- a/include/configs/P2041RDB.h
+++ b/include/configs/P2041RDB.h
@@ -366,14 +366,14 @@ unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED		400000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x118000
-#define CONFIG_SYS_I2C2_OFFSET		0x118100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /*
  * RapidIO
diff --git a/include/configs/SIMPC8313.h b/include/configs/SIMPC8313.h
index c0ffb33..d4bcf50 100644
--- a/include/configs/SIMPC8313.h
+++ b/include/configs/SIMPC8313.h
@@ -244,14 +244,15 @@
 #define CONFIG_SYS_HUSH_PARSER
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x69} } /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /*
  * General PCI
diff --git a/include/configs/TQM834x.h b/include/configs/TQM834x.h
index 133d7df..b326833 100644
--- a/include/configs/TQM834x.h
+++ b/include/configs/TQM834x.h
@@ -187,11 +187,11 @@
 /*
  * I2C
  */
-#define CONFIG_HARD_I2C			/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed: 400KHz */
-#define CONFIG_SYS_I2C_SLAVE		0x7F	/* slave address */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
 
 /* I2C EEPROM, configuration for onboard EEPROMs 24C256 and 24C32 */
 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x50	/* 1010000x */
diff --git a/include/configs/astro_mcf5373l.h b/include/configs/astro_mcf5373l.h
index 6dabe57..f641959 100644
--- a/include/configs/astro_mcf5373l.h
+++ b/include/configs/astro_mcf5373l.h
@@ -116,11 +116,11 @@
 #undef CONFIG_MCFPIT
 
 /* I2C */
-#define CONFIG_FSL_I2C
-#define CONFIG_HARD_I2C			/* I2C with hw support */
-#define CONFIG_SYS_I2C_SPEED		80000
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x58000
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	80000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x58000
 #define CONFIG_SYS_IMMR			CONFIG_SYS_MBAR
 
 /*
diff --git a/include/configs/corenet_ds.h b/include/configs/corenet_ds.h
index 3f42cd9..f8af27e 100644
--- a/include/configs/corenet_ds.h
+++ b/include/configs/corenet_ds.h
@@ -360,14 +360,14 @@
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x118000
-#define CONFIG_SYS_I2C2_OFFSET		0x118100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x118000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x118100
 
 /*
  * RapidIO
diff --git a/include/configs/km/km83xx-common.h b/include/configs/km/km83xx-common.h
index 5a430ed..a6f8ebd 100644
--- a/include/configs/km/km83xx-common.h
+++ b/include/configs/km/km83xx-common.h
@@ -204,14 +204,21 @@
 #endif /* CFG_SYS_RAMBOOT */
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#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
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_NUM_I2C_BUSES	4
+#define CONFIG_SYS_I2C_MAX_HOPS		1
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	200000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_I2C_OFFSET		0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	200000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_BUSES	{{0, {I2C_NULL_HOP} }, \
+		{0, {{I2C_MUX_PCA9547, 0x70, 2} } }, \
+		{0, {{I2C_MUX_PCA9547, 0x70, 1} } }, \
+		{1, {I2C_NULL_HOP} } }
 
 /* I2C SYSMON (LM75, AD7414 is almost compatible) */
 #define CONFIG_DTT_LM75		/* ON Semi's LM75 */
@@ -219,7 +226,7 @@
 #define CONFIG_SYS_DTT_MAX_TEMP	70
 #define CONFIG_SYS_DTT_LOW_TEMP	-30
 #define CONFIG_SYS_DTT_HYSTERESIS	3
-#define CONFIG_SYS_DTT_BUS_NUM		(CONFIG_SYS_MAX_I2C_BUS)
+#define CONFIG_SYS_DTT_BUS_NUM		1
 
 #if defined(CONFIG_CMD_NAND)
 #define CONFIG_NAND_KMETER1
@@ -315,7 +322,7 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	CONFIG_KM_DEF_ENV						\
 	CONFIG_KM_DEF_ARCH						\
-	"EEprom_ivm=pca9547:70:9\0"					\
+	"EEprom_ivm=2\0"						\
 	"newenv="							\
 		"prot off 0xF00C0000 +0x40000 && "			\
 		"era 0xF00C0000 +0x40000\0"				\
diff --git a/include/configs/mpc8308_p1m.h b/include/configs/mpc8308_p1m.h
index aa681f0..13c860f 100644
--- a/include/configs/mpc8308_p1m.h
+++ b/include/configs/mpc8308_p1m.h
@@ -327,13 +327,14 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED	400000 /* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /*
  * General PCI
diff --git a/include/configs/mpq101.h b/include/configs/mpq101.h
index 339c736..8ca3f76 100644
--- a/include/configs/mpq101.h
+++ b/include/configs/mpq101.h
@@ -221,13 +221,15 @@
 /*
  * I2C buses and peripherals
  */
-#define CONFIG_FSL_I2C         /* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C        /* I2C with hardware support*/
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_SPEED   400000 /* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE   0x7f
-#define CONFIG_SYS_I2C_OFFSET  0x3000
-#define CONFIG_SYS_I2C2_OFFSET 0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /* I2C RTC - M41T81 */
 #define CONFIG_RTC_M41T62
diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h
index bedf28f..494f9d8 100644
--- a/include/configs/p1_p2_rdb_pc.h
+++ b/include/configs/p1_p2_rdb_pc.h
@@ -533,16 +533,16 @@
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
 /* I2C */
-#define CONFIG_FSL_I2C			/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C			/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C spd and slave address */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x29} }
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x52
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES		{{0, 0x29}} /* Don't probe this addr */
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
 #define CONFIG_SYS_SPD_BUS_NUM		1 /* For rom_loc and flash bank */
 
 /*
diff --git a/include/configs/sbc8349.h b/include/configs/sbc8349.h
index 6d115c5..d35732b 100644
--- a/include/configs/sbc8349.h
+++ b/include/configs/sbc8349.h
@@ -304,14 +304,15 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
-#define CONFIG_HARD_I2C			/* I2C with hardware support*/
-#define CONFIG_FSL_I2C
-#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 */
-#define CONFIG_SYS_I2C1_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
-#define CONFIG_SYS_I2C_OFFSET	CONFIG_SYS_I2C2_OFFSET
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69}, {1, 0x69} }
 /* could also use CONFIG_I2C_MULTI_BUS and CONFIG_SYS_SPD_BUS_NUM... */
 
 /* TSEC */
diff --git a/include/configs/sbc8548.h b/include/configs/sbc8548.h
index 33197b4..2712725 100644
--- a/include/configs/sbc8548.h
+++ b/include/configs/sbc8548.h
@@ -443,12 +443,12 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
 
 /*
  * General PCI
diff --git a/include/configs/sbc8641d.h b/include/configs/sbc8641d.h
index 8142205..b739fa5 100644
--- a/include/configs/sbc8641d.h
+++ b/include/configs/sbc8641d.h
@@ -288,12 +288,12 @@
 /*
  * I2C
  */
-#define	CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define	CONFIG_HARD_I2C		/* I2C with hardware support*/
-#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 */
-#define CONFIG_SYS_I2C_OFFSET		0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /*
  * RapidIO MMU
diff --git a/include/configs/socrates.h b/include/configs/socrates.h
index e42c8aa..0c96c58 100644
--- a/include/configs/socrates.h
+++ b/include/configs/socrates.h
@@ -234,14 +234,14 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_SYS_I2C_SPEED		102124	/* 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_I2C2_OFFSET		0x3100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	102124
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	102124
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /* I2C RTC */
 #define CONFIG_RTC_RX8025		/* Use Epson rx8025 rtc via i2c	*/
diff --git a/include/configs/stxgp3.h b/include/configs/stxgp3.h
index b688b45..d7c0797 100644
--- a/include/configs/stxgp3.h
+++ b/include/configs/stxgp3.h
@@ -178,17 +178,18 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#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_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+
 #if 0
 #define CONFIG_SYS_I2C_NOPROBES        {0x00}  /* Don't probe these addrs */
 #else
 /* I did the 'if 0' so we could keep the syntax above if ever needed. */
 #undef CONFIG_SYS_I2C_NOPROBES
 #endif
-#define CONFIG_SYS_I2C_OFFSET		0x3000
 
 /* RapdIO Map configuration, mapped 1:1.
 */
diff --git a/include/configs/stxssa.h b/include/configs/stxssa.h
index 5d8ff79..8fd57ef 100644
--- a/include/configs/stxssa.h
+++ b/include/configs/stxssa.h
@@ -197,12 +197,12 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C			/* Use FSL common I2C driver */
-#define  CONFIG_HARD_I2C		/* I2C with hardware support*/
-#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_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
 #undef CONFIG_SYS_I2C_NOPROBES
-#define CONFIG_SYS_I2C_OFFSET		0x3000
 
 /* I2C RTC */
 #define CONFIG_RTC_DS1337		/* This is really a DS1339 RTC	*/
diff --git a/include/configs/t4qds.h b/include/configs/t4qds.h
index 2c665b8..5f0e2a8 100644
--- a/include/configs/t4qds.h
+++ b/include/configs/t4qds.h
@@ -433,14 +433,15 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_FIT_VERBOSE	/* enable fit_format_{error,warning}() */
 
 /* I2C */
-#define CONFIG_FSL_I2C		/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C		/* I2C with hardware support */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x118000
-#define CONFIG_SYS_I2C2_OFFSET		0x118100
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	100000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x118000
+#define CONFIG_SYS_FSL_I2C2_SPEED	100000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x118100
+
 #define I2C_MUX_PCA_ADDR_PRI		0x77 /* I2C bus multiplexer,primary */
 #define I2C_MUX_PCA_ADDR_SEC		0x76 /* I2C bus multiplexer,secondary */
 
diff --git a/include/configs/vme8349.h b/include/configs/vme8349.h
index eec7ee2..eeda46c 100644
--- a/include/configs/vme8349.h
+++ b/include/configs/vme8349.h
@@ -237,16 +237,15 @@
 #define CONFIG_OF_STDOUT_VIA_ALIAS
 
 /* I2C */
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_HARD_I2C		/* I2C with hardware support*/
-#define CONFIG_FSL_I2C
-#define CONFIG_I2C_CMD_TREE
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE	0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x69} } /* Don't probe these addrs */
-#define CONFIG_SYS_I2C1_OFFSET	0x3000
-#define CONFIG_SYS_I2C2_OFFSET	0x3100
-#define CONFIG_SYS_I2C_OFFSET	CONFIG_SYS_I2C1_OFFSET
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 /* could also use CONFIG_I2C_MULTI_BUS and CONFIG_SYS_SPD_BUS_NUM... */
 
 #define CONFIG_SYS_I2C_8574_ADDR2       0x20    /* I2C1, PCF8574 */
diff --git a/include/configs/xpedite517x.h b/include/configs/xpedite517x.h
index 1851a00..0199cf7 100644
--- a/include/configs/xpedite517x.h
+++ b/include/configs/xpedite517x.h
@@ -257,13 +257,14 @@ 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 */
-#define CONFIG_SYS_I2C_SPEED		100000	/* M41T00 only supports 100 KHz */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
-#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	100000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	100000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /* PEX8518 slave I2C interface */
 #define CONFIG_SYS_I2C_PEX8518_ADDR	0x70
diff --git a/include/configs/xpedite520x.h b/include/configs/xpedite520x.h
index ff99481..534aea9 100644
--- a/include/configs/xpedite520x.h
+++ b/include/configs/xpedite520x.h
@@ -219,13 +219,14 @@
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C				/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C				/* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
-#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /* I2C EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x50
diff --git a/include/configs/xpedite537x.h b/include/configs/xpedite537x.h
index 46f1c90..4a38546 100644
--- a/include/configs/xpedite537x.h
+++ b/include/configs/xpedite537x.h
@@ -257,13 +257,15 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C				/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C				/* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
-#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
+#define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
 /* PEX8518 slave I2C interface */
 #define CONFIG_SYS_I2C_PEX8518_ADDR	0x70
diff --git a/include/configs/xpedite550x.h b/include/configs/xpedite550x.h
index 2acf6c8..c0c375d 100644
--- a/include/configs/xpedite550x.h
+++ b/include/configs/xpedite550x.h
@@ -248,13 +248,14 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 /*
  * I2C
  */
-#define CONFIG_FSL_I2C				/* Use FSL common I2C driver */
-#define CONFIG_HARD_I2C				/* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_OFFSET		0x3000
-#define CONFIG_SYS_I2C2_OFFSET		0x3100
-#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_FSL
+#define CONFIG_SYS_FSL_I2C_SPEED	400000
+#define CONFIG_SYS_FSL_I2C_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C_OFFSET	0x3000
+#define CONFIG_SYS_FSL_I2C2_SPEED	400000
+#define CONFIG_SYS_FSL_I2C2_SLAVE	0x7F
+#define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 
 /* I2C DS7505 temperature sensor */
 #define CONFIG_DTT_LM75
-- 
1.7.11.7

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

* [U-Boot] [PATCH v3 5/9] i2c, multibus: get rid of CONFIG_I2C_MUX
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
                   ` (3 preceding siblings ...)
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 4/9] i2c, fsl_i2c: " Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-06 12:23   ` Holger Brunck
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 6/9] i2c, multibus, keymile: get rid of EEprom_ivm envvariable Heiko Schocher
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 UTC (permalink / raw)
  To: u-boot

CONFIG_I2C_MUX is replaced through the new i2c multibus/multiadapter
framework, configured through CONFIG_SYS_I2C. As CONFIG_I2C_MUX
is only used on the keymile boards, and they are now completely
moved to the new framework, remove CONFIG_I2C_MUX.

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Holger Brunck <holger.brunck@keymile.com>

---
- changes for v2:
  new in v2
---
 README                         |  47 ---------
 arch/powerpc/cpu/mpc8260/i2c.c |  14 ---
 common/cmd_i2c.c               | 234 +----------------------------------------
 common/env_eeprom.c            |  32 +-----
 include/i2c.h                  |  21 ----
 5 Dateien ge?ndert, 6 Zeilen hinzugef?gt(+), 342 Zeilen entfernt(-)

diff --git a/README b/README
index 5e0395e..e322f51 100644
--- a/README
+++ b/README
@@ -2165,53 +2165,6 @@ CBFS (Coreboot Filesystem) support
 		If not defined, then U-Boot uses predefined value for
 		specified DTT device.
 
-		CONFIG_I2C_MUX
-
-		Define this option if you have I2C devices reached over 1 .. n
-		I2C Muxes like the pca9544a. This option addes a new I2C
-		Command "i2c bus [muxtype:muxaddr:muxchannel]" which adds a
-		new I2C Bus to the existing I2C Busses. If you select the
-		new Bus with "i2c dev", u-bbot sends first the commandos for
-		the muxes to activate this new "bus".
-
-		CONFIG_I2C_MULTI_BUS must be also defined, to use this
-		feature!
-
-		Example:
-		Adding a new I2C Bus reached over 2 pca9544a muxes
-			The First mux with address 70 and channel 6
-			The Second mux with address 71 and channel 4
-
-		=> i2c bus pca9544a:70:6:pca9544a:71:4
-
-		Use the "i2c bus" command without parameter, to get a list
-		of I2C Busses with muxes:
-
-		=> i2c bus
-		Busses reached over muxes:
-		Bus ID: 2
-		  reached over Mux(es):
-		    pca9544a at 70 ch: 4
-		Bus ID: 3
-		  reached over Mux(es):
-		    pca9544a at 70 ch: 6
-		    pca9544a at 71 ch: 4
-		=>
-
-		If you now switch to the new I2C Bus 3 with "i2c dev 3"
-		u-boot first sends the command to the mux at 70 to enable
-		channel 6, and then the command to the mux at 71 to enable
-		the channel 4.
-
-		After that, you can use the "normal" i2c commands as
-		usual to communicate with your I2C devices behind
-		the 2 muxes.
-
-		This option is actually implemented for the bitbanging
-		algorithm in common/soft_i2c.c and for the Hardware I2C
-		Bus on the MPC8260. But it should be not so difficult
-		to add this option to other architectures.
-
 		CONFIG_SOFT_I2C_READ_REPEATED_START
 
 		defining this will force the i2c_read() function in
diff --git a/arch/powerpc/cpu/mpc8260/i2c.c b/arch/powerpc/cpu/mpc8260/i2c.c
index b720b1f..425a94a 100644
--- a/arch/powerpc/cpu/mpc8260/i2c.c
+++ b/arch/powerpc/cpu/mpc8260/i2c.c
@@ -746,23 +746,9 @@ unsigned int i2c_get_bus_num(void)
 
 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);
-		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;
 }
 
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index d59f10d..aedcc4d 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -110,8 +110,7 @@ static uint	i2c_mm_last_alen;
  * pairs.  The following macros take care of this */
 
 #if defined(CONFIG_SYS_I2C_NOPROBES)
-#if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MUX) || \
-	defined(CONFIG_I2C_MULTI_BUS)
+#if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS)
 static struct
 {
 	uchar	bus;
@@ -132,11 +131,6 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
 #define NUM_ELEMENTS_NOPROBE (sizeof(i2c_no_probes)/sizeof(i2c_no_probes[0]))
 #endif
 
-#if defined(CONFIG_I2C_MUX)
-static I2C_MUX_DEVICE	*i2c_mux_devices = NULL;
-static	int	i2c_mux_busid = CONFIG_SYS_MAX_I2C_BUS;
-#endif
-
 #define DISP_LINE_LEN	16
 
 /**
@@ -1554,7 +1548,7 @@ static int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv
 static cmd_tbl_t cmd_i2c_sub[] = {
 #if defined(CONFIG_SYS_I2C)
 	U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_show_bus, "", ""),
-#endif  /* CONFIG_I2C_MUX */
+#endif
 	U_BOOT_CMD_MKENT(crc32, 3, 1, do_i2c_crc, "", ""),
 #if defined(CONFIG_SYS_I2C) || \
 	defined(CONFIG_I2C_MULTI_BUS)
@@ -1618,7 +1612,7 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 static char i2c_help_text[] =
 #if defined(CONFIG_SYS_I2C)
 	"bus [muxtype:muxaddr:muxchannel] - show I2C bus info\n"
-#endif  /* CONFIG_I2C_MUX */
+#endif
 	"crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n"
 #if defined(CONFIG_SYS_I2C)
 	"i2c dev [dev] - show or set current I2C bus\n"
@@ -1646,225 +1640,3 @@ U_BOOT_CMD(
 	"I2C sub-system",
 	i2c_help_text
 );
-
-#if defined(CONFIG_I2C_MUX)
-static int i2c_mux_add_device(I2C_MUX_DEVICE *dev)
-{
-	I2C_MUX_DEVICE	*devtmp = i2c_mux_devices;
-
-	if (i2c_mux_devices == NULL) {
-		i2c_mux_devices = dev;
-		return 0;
-	}
-	while (devtmp->next != NULL)
-		devtmp = devtmp->next;
-
-	devtmp->next = dev;
-	return 0;
-}
-
-I2C_MUX_DEVICE	*i2c_mux_search_device(int id)
-{
-	I2C_MUX_DEVICE	*device = i2c_mux_devices;
-
-	while (device != NULL) {
-		if (device->busid == id)
-			return device;
-		device = device->next;
-	}
-	return NULL;
-}
-
-/* searches in the buf from *pos the next ':'.
- * returns:
- *     0 if found (with *pos = where)
- *   < 0 if an error occured
- *   > 0 if the end of buf is reached
- */
-static int i2c_mux_search_next (int *pos, uchar	*buf, int len)
-{
-	while ((buf[*pos] != ':') && (*pos < len)) {
-		*pos += 1;
-	}
-	if (*pos >= len)
-		return 1;
-	if (buf[*pos] != ':')
-		return -1;
-	return 0;
-}
-
-static int i2c_mux_get_busid (void)
-{
-	int	tmp = i2c_mux_busid;
-
-	i2c_mux_busid ++;
-	return tmp;
-}
-
-/* Analyses a Muxstring and immediately sends the
-   commands to the muxes. Runs from flash.
- */
-int i2c_mux_ident_muxstring_f (uchar *buf)
-{
-	int	pos = 0;
-	int	oldpos;
-	int	ret = 0;
-	int	len = strlen((char *)buf);
-	int	chip;
-	uchar	channel;
-	int	was = 0;
-
-	while (ret == 0) {
-		oldpos = pos;
-		/* search name */
-		ret = i2c_mux_search_next(&pos, buf, len);
-		if (ret != 0)
-			printf ("ERROR\n");
-		/* search address */
-		pos ++;
-		oldpos = pos;
-		ret = i2c_mux_search_next(&pos, buf, len);
-		if (ret != 0)
-			printf ("ERROR\n");
-		buf[pos] = 0;
-		chip = simple_strtoul((char *)&buf[oldpos], NULL, 16);
-		buf[pos] = ':';
-		/* search channel */
-		pos ++;
-		oldpos = pos;
-		ret = i2c_mux_search_next(&pos, buf, len);
-		if (ret < 0)
-			printf ("ERROR\n");
-		was = 0;
-		if (buf[pos] != 0) {
-			buf[pos] = 0;
-			was = 1;
-		}
-		channel = simple_strtoul((char *)&buf[oldpos], NULL, 16);
-		if (was)
-			buf[pos] = ':';
-		if (i2c_write(chip, 0, 0, &channel, 1) != 0) {
-			printf ("Error setting Mux: chip:%x channel: \
-				%x\n", chip, channel);
-			return -1;
-		}
-		pos ++;
-		oldpos = pos;
-
-	}
-	i2c_init_board();
-
-	return 0;
-}
-
-/* Analyses a Muxstring and if this String is correct
- * adds a new I2C Bus.
- */
-I2C_MUX_DEVICE *i2c_mux_ident_muxstring (uchar *buf)
-{
-	I2C_MUX_DEVICE	*device;
-	I2C_MUX		*mux;
-	int	pos = 0;
-	int	oldpos;
-	int	ret = 0;
-	int	len = strlen((char *)buf);
-	int	was = 0;
-
-	device = (I2C_MUX_DEVICE *)malloc (sizeof(I2C_MUX_DEVICE));
-	device->mux = NULL;
-	device->busid = i2c_mux_get_busid ();
-	device->next = NULL;
-	while (ret == 0) {
-		mux = (I2C_MUX *)malloc (sizeof(I2C_MUX));
-		mux->next = NULL;
-		/* search name of mux */
-		oldpos = pos;
-		ret = i2c_mux_search_next(&pos, buf, len);
-		if (ret != 0)
-			printf ("%s no name.\n", __FUNCTION__);
-		mux->name = (char *)malloc (pos - oldpos + 1);
-		memcpy (mux->name, &buf[oldpos], pos - oldpos);
-		mux->name[pos - oldpos] = 0;
-		/* search address */
-		pos ++;
-		oldpos = pos;
-		ret = i2c_mux_search_next(&pos, buf, len);
-		if (ret != 0)
-			printf ("%s no mux address.\n", __FUNCTION__);
-		buf[pos] = 0;
-		mux->chip = simple_strtoul((char *)&buf[oldpos], NULL, 16);
-		buf[pos] = ':';
-		/* search channel */
-		pos ++;
-		oldpos = pos;
-		ret = i2c_mux_search_next(&pos, buf, len);
-		if (ret < 0)
-			printf ("%s no mux channel.\n", __FUNCTION__);
-		was = 0;
-		if (buf[pos] != 0) {
-			buf[pos] = 0;
-			was = 1;
-		}
-		mux->channel = simple_strtoul((char *)&buf[oldpos], NULL, 16);
-		if (was)
-			buf[pos] = ':';
-		if (device->mux == NULL)
-			device->mux = mux;
-		else {
-			I2C_MUX		*muxtmp = device->mux;
-			while (muxtmp->next != NULL) {
-				muxtmp = muxtmp->next;
-			}
-			muxtmp->next = mux;
-		}
-		pos ++;
-		oldpos = pos;
-	}
-	if (ret > 0) {
-		/* Add Device */
-		i2c_mux_add_device (device);
-		return device;
-	}
-
-	return NULL;
-}
-
-int i2x_mux_select_mux(int bus)
-{
-	I2C_MUX_DEVICE  *dev;
-	I2C_MUX		*mux;
-
-	if ((gd->flags & GD_FLG_RELOC) != GD_FLG_RELOC) {
-		/* select Default Mux Bus */
-#if defined(CONFIG_SYS_I2C_IVM_BUS)
-		i2c_mux_ident_muxstring_f ((uchar *)CONFIG_SYS_I2C_IVM_BUS);
-#else
-		{
-		unsigned char *buf;
-		buf = (unsigned char *) getenv("EEprom_ivm");
-		if (buf != NULL)
-			i2c_mux_ident_muxstring_f (buf);
-		}
-#endif
-		return 0;
-	}
-	dev = i2c_mux_search_device(bus);
-	if (dev == NULL)
-		return -1;
-
-	mux = dev->mux;
-	while (mux != NULL) {
-		/* do deblocking on each level of mux, before mux config */
-		i2c_init_board();
-		if (i2c_write(mux->chip, 0, 0, &mux->channel, 1) != 0) {
-			printf ("Error setting Mux: chip:%x channel: \
-				%x\n", mux->chip, mux->channel);
-			return -1;
-		}
-		mux = mux->next;
-	}
-	/* do deblocking on each level of mux and after mux config */
-	i2c_init_board();
-	return 0;
-}
-#endif /* CONFIG_I2C_MUX */
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index fbd459a..21226bf 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -49,41 +49,17 @@ 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;
-			dev = i2c_mux_ident_muxstring(
-				(uchar *)CONFIG_I2C_ENV_EEPROM_BUS);
-			if (dev != NULL)
-				env_eeprom_bus = dev->busid;
-			else
-				printf("error adding env eeprom bus.\n");
-		}
-		if (old_bus != env_eeprom_bus) {
-			i2c_set_bus_num(env_eeprom_bus);
-			old_bus = env_eeprom_bus;
-		}
-	} else {
-		rcode = i2c_mux_ident_muxstring_f(
-				(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;
 }
 
@@ -94,14 +70,12 @@ 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);
 #endif
diff --git a/include/i2c.h b/include/i2c.h
index f532a14..a8074ac 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -197,27 +197,6 @@ void i2c_init_board(void);
 void i2c_board_late_init(void);
 #endif
 
-#if defined(CONFIG_I2C_MUX)
-
-typedef struct _mux {
-	uchar	chip;
-	uchar	channel;
-	char	*name;
-	struct _mux	*next;
-} I2C_MUX;
-
-typedef struct _mux_device {
-	int	busid;
-	I2C_MUX	*mux;	/* List of muxes, to reach the device */
-	struct _mux_device	*next;
-} I2C_MUX_DEVICE;
-
-I2C_MUX_DEVICE	*i2c_mux_search_device(int id);
-I2C_MUX_DEVICE *i2c_mux_ident_muxstring (uchar *buf);
-int i2x_mux_select_mux(int bus);
-int i2c_mux_ident_muxstring_f (uchar *buf);
-#endif
-
 #ifdef CONFIG_SYS_I2C
 /*
  * i2c_get_bus_num:
-- 
1.7.11.7

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

* [U-Boot] [PATCH v3 6/9] i2c, multibus, keymile: get rid of EEprom_ivm envvariable
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
                   ` (4 preceding siblings ...)
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 5/9] i2c, multibus: get rid of CONFIG_I2C_MUX Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-06 12:24   ` Holger Brunck
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 7/9] tegra: i2c: Add function to know about current bus Heiko Schocher
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 UTC (permalink / raw)
  To: u-boot

as the keymile boards use now the new i2c multibus/multiadapter
framework, remove the EEprom_ivm Environmentvar, as not longer
needed.

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Holger Brunck <holger.brunck@keymile.com>

---
- changes for v2:
  new in v2
---
 board/keymile/common/ivm.c         |  7 ++-----
 include/configs/km/km83xx-common.h |  3 ++-
 include/configs/km/km_arm.h        |  1 -
 include/configs/km82xx.h           |  3 ++-
 include/configs/km_kirkwood.h      | 12 ++++++------
 5 Dateien ge?ndert, 12 Zeilen hinzugef?gt(+), 14 Zeilen entfernt(-)

diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index a14496f..ac3cc9c 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -315,16 +315,13 @@ int ivm_analyze_eeprom(unsigned char *buf, int len)
 int ivm_read_eeprom(void)
 {
 	uchar i2c_buffer[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
-	char	*buf;
-	unsigned long dev_addr = CONFIG_SYS_IVM_EEPROM_ADR;
 	int ret;
 
-	buf = getenv("EEprom_ivm");
-	i2c_set_bus_num(buf ? (int)simple_strtol(buf, NULL, 10) : 0);
+	i2c_set_bus_num(CONFIG_KM_IVM_BUS);
 	/* add deblocking here */
 	i2c_make_abort();
 
-	ret = i2c_read(dev_addr, 0, 1, i2c_buffer,
+	ret = i2c_read(CONFIG_SYS_IVM_EEPROM_ADR, 0, 1, i2c_buffer,
 		CONFIG_SYS_IVM_EEPROM_MAX_LEN);
 	if (ret != 0) {
 		printf("Error reading EEprom\n");
diff --git a/include/configs/km/km83xx-common.h b/include/configs/km/km83xx-common.h
index a6f8ebd..8f97f67 100644
--- a/include/configs/km/km83xx-common.h
+++ b/include/configs/km/km83xx-common.h
@@ -220,6 +220,8 @@
 		{0, {{I2C_MUX_PCA9547, 0x70, 1} } }, \
 		{1, {I2C_NULL_HOP} } }
 
+#define CONFIG_KM_IVM_BUS		2	/* I2C2 (Mux-Port 1)*/
+
 /* I2C SYSMON (LM75, AD7414 is almost compatible) */
 #define CONFIG_DTT_LM75		/* ON Semi's LM75 */
 #define CONFIG_DTT_SENSORS	{0, 1, 2, 3}	/* Sensor addresses */
@@ -322,7 +324,6 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	CONFIG_KM_DEF_ENV						\
 	CONFIG_KM_DEF_ARCH						\
-	"EEprom_ivm=2\0"						\
 	"newenv="							\
 		"prot off 0xF00C0000 +0x40000 && "			\
 		"era 0xF00C0000 +0x40000\0"				\
diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h
index c2c67c1..ebbfa84 100644
--- a/include/configs/km/km_arm.h
+++ b/include/configs/km/km_arm.h
@@ -309,7 +309,6 @@ int get_scl(void);
 	CONFIG_KM_DEF_ENV						\
 	CONFIG_KM_NEW_ENV						\
 	"arch=arm\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 54041f3..4278be2 100644
--- a/include/configs/km82xx.h
+++ b/include/configs/km82xx.h
@@ -212,7 +212,6 @@
 #define	CONFIG_EXTRA_ENV_SETTINGS					\
 	CONFIG_KM_BOARD_EXTRA_ENV					\
 	CONFIG_KM_DEF_ENV						\
-	"EEprom_ivm=1\0"						\
 	"unlock=yes\0"							\
 	"newenv="							\
 		"prot off 0xFE0C0000 +0x40000 && "			\
@@ -253,6 +252,8 @@
 			{0, {{I2C_MUX_PCA9542, 0x70, 0} } }, \
 			{0, {{I2C_MUX_PCA9542, 0x70, 1} } } }
 
+#define CONFIG_KM_IVM_BUS		1	/* I2C2 (Mux-Port 1)*/
+
 /*
  * Software (bit-bang) I2C driver configuration
  */
diff --git a/include/configs/km_kirkwood.h b/include/configs/km_kirkwood.h
index a0ad47e..5f3e444 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			1	/* I2C2 (Mux-Port 1)*/
+#define CONFIG_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			1	/* I2C2 (Mux-Port 1)*/
+#define CONFIG_KM_IVM_BUS		1	/* I2C2 (Mux-Port 1)*/
 #define CONFIG_KM_FPGA_CONFIG
 
 /* KM_NUSA */
 #elif defined(CONFIG_KM_NUSA)
-#define KM_IVM_BUS			1	/* I2C2 (Mux-Port 1)*/
+#define CONFIG_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			1	/* I2C2 (Mux-Port 1)*/
+#define CONFIG_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			1	/* I2C2 (Mux-Port 1)*/
+#define CONFIG_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			1	/* I2C2 (Mux-Port 1)*/
+#define CONFIG_KM_IVM_BUS		1	/* I2C2 (Mux-Port 1)*/
 #define CONFIG_KM_PIGGY4_88E6061
 
 /* KM_SUV31 */
-- 
1.7.11.7

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

* [U-Boot] [PATCH v3 7/9] tegra: i2c: Add function to know about current bus
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
                   ` (5 preceding siblings ...)
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 6/9] i2c, multibus, keymile: get rid of EEprom_ivm envvariable Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework Heiko Schocher
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 UTC (permalink / raw)
  To: u-boot

From: Simon Glass <sjg@chromium.org>

Rather than using a variable in various places, add a single function,
tegra_i2c_get_bus(), which returns a pointer to information about a
bus.

This will make it easier to move to the new i2c framework.

Signed-off-by: Simon Glass <sjg@chromium.org>

---
- changes for v2:
  new in v2
  posted from Simon Glass here:
  http://patchwork.ozlabs.org/patch/195569/

  added to this patchserie, just rebased to current head
---
 drivers/i2c/tegra_i2c.c | 78 ++++++++++++++++++++++++++++++++++++++-----------
 1 Datei ge?ndert, 61 Zeilen hinzugef?gt(+), 17 Zeilen entfernt(-)

diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index ca71cd3..8fa1cda 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -284,7 +284,8 @@ exit:
 	return error;
 }
 
-static int tegra_i2c_write_data(u32 addr, u8 *data, u32 len)
+static int tegra_i2c_write_data(struct i2c_bus *bus, u32 addr, u8 *data,
+				u32 len)
 {
 	int error;
 	struct i2c_trans_info trans_info;
@@ -295,14 +296,15 @@ static int tegra_i2c_write_data(u32 addr, u8 *data, u32 len)
 	trans_info.num_bytes = len;
 	trans_info.is_10bit_address = 0;
 
-	error = send_recv_packets(&i2c_controllers[i2c_bus_num], &trans_info);
+	error = send_recv_packets(bus, &trans_info);
 	if (error)
 		debug("tegra_i2c_write_data: Error (%d) !!!\n", error);
 
 	return error;
 }
 
-static int tegra_i2c_read_data(u32 addr, u8 *data, u32 len)
+static int tegra_i2c_read_data(struct i2c_bus *bus, u32 addr, u8 *data,
+			       u32 len)
 {
 	int error;
 	struct i2c_trans_info trans_info;
@@ -313,7 +315,7 @@ static int tegra_i2c_read_data(u32 addr, u8 *data, u32 len)
 	trans_info.num_bytes = len;
 	trans_info.is_10bit_address = 0;
 
-	error = send_recv_packets(&i2c_controllers[i2c_bus_num], &trans_info);
+	error = send_recv_packets(bus, &trans_info);
 	if (error)
 		debug("tegra_i2c_read_data: Error (%d) !!!\n", error);
 
@@ -324,18 +326,48 @@ static int tegra_i2c_read_data(u32 addr, u8 *data, u32 len)
 #error "Please enable device tree support to use this driver"
 #endif
 
+/**
+ * Check that a bus number is valid and return a pointer to it
+ *
+ * @param bus_num	Bus number to check / return
+ * @return pointer to bus, if valid, else NULL
+ */
+static struct i2c_bus *tegra_i2c_get_bus(unsigned int bus_num)
+{
+	struct i2c_bus *bus;
+
+	if (bus_num >= TEGRA_I2C_NUM_CONTROLLERS) {
+		debug("%s: Invalid bus number %u\n", __func__, bus_num);
+		return NULL;
+	}
+	bus = &i2c_controllers[bus_num];
+	if (!bus->inited) {
+		debug("%s: Bus %u not available\n", __func__, bus_num);
+		return NULL;
+	}
+
+	return bus;
+}
+
 unsigned int i2c_get_bus_speed(void)
 {
-	return i2c_controllers[i2c_bus_num].speed;
+	struct i2c_bus *bus;
+
+	bus = tegra_i2c_get_bus(i2c_bus_num);
+	if (!bus)
+		return 0;
+	return bus->speed;
 }
 
 int i2c_set_bus_speed(unsigned int speed)
 {
-	struct i2c_bus *i2c_bus;
+	struct i2c_bus *bus;
 
-	i2c_bus = &i2c_controllers[i2c_bus_num];
-	i2c_bus->speed = speed;
-	i2c_init_controller(i2c_bus);
+	bus = tegra_i2c_get_bus(i2c_bus_num);
+	if (!bus)
+		return 0;
+	bus->speed = speed;
+	i2c_init_controller(bus);
 
 	return 0;
 }
@@ -458,7 +490,7 @@ void i2c_init(int speed, int slaveaddr)
 }
 
 /* i2c write version without the register address */
-int i2c_write_data(uchar chip, uchar *buffer, int len)
+int i2c_write_data(struct i2c_bus *bus, uchar chip, uchar *buffer, int len)
 {
 	int rc;
 
@@ -470,7 +502,7 @@ int i2c_write_data(uchar chip, uchar *buffer, int len)
 	debug("\n");
 
 	/* Shift 7-bit address over for lower-level i2c functions */
-	rc = tegra_i2c_write_data(chip << 1, buffer, len);
+	rc = tegra_i2c_write_data(bus, chip << 1, buffer, len);
 	if (rc)
 		debug("i2c_write_data(): rc=%d\n", rc);
 
@@ -478,13 +510,13 @@ int i2c_write_data(uchar chip, uchar *buffer, int len)
 }
 
 /* i2c read version without the register address */
-int i2c_read_data(uchar chip, uchar *buffer, int len)
+int i2c_read_data(struct i2c_bus *bus, uchar chip, uchar *buffer, int len)
 {
 	int rc;
 
 	debug("inside i2c_read_data():\n");
 	/* Shift 7-bit address over for lower-level i2c functions */
-	rc = tegra_i2c_read_data(chip << 1, buffer, len);
+	rc = tegra_i2c_read_data(bus, chip << 1, buffer, len);
 	if (rc) {
 		debug("i2c_read_data(): rc=%d\n", rc);
 		return rc;
@@ -502,12 +534,16 @@ int i2c_read_data(uchar chip, uchar *buffer, int len)
 /* Probe to see if a chip is present. */
 int i2c_probe(uchar chip)
 {
+	struct i2c_bus *bus;
 	int rc;
 	uchar reg;
 
 	debug("i2c_probe: addr=0x%x\n", chip);
+	bus = tegra_i2c_get_bus(i2c_get_bus_num());
+	if (!bus)
+		return 1;
 	reg = 0;
-	rc = i2c_write_data(chip, &reg, 1);
+	rc = i2c_write_data(bus, chip, &reg, 1);
 	if (rc) {
 		debug("Error probing 0x%x.\n", chip);
 		return 1;
@@ -524,11 +560,15 @@ static int i2c_addr_ok(const uint addr, const int alen)
 /* Read bytes */
 int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
+	struct i2c_bus *bus;
 	uint offset;
 	int i;
 
 	debug("i2c_read: chip=0x%x, addr=0x%x, len=0x%x\n",
 				chip, addr, len);
+	bus = tegra_i2c_get_bus(i2c_bus_num);
+	if (!bus)
+		return 1;
 	if (!i2c_addr_ok(addr, alen)) {
 		debug("i2c_read: Bad address %x.%d.\n", addr, alen);
 		return 1;
@@ -540,13 +580,13 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 				data[alen - i - 1] =
 					(addr + offset) >> (8 * i);
 			}
-			if (i2c_write_data(chip, data, alen)) {
+			if (i2c_write_data(bus, chip, data, alen)) {
 				debug("i2c_read: error sending (0x%x)\n",
 					addr);
 				return 1;
 			}
 		}
-		if (i2c_read_data(chip, buffer + offset, 1)) {
+		if (i2c_read_data(bus, chip, buffer + offset, 1)) {
 			debug("i2c_read: error reading (0x%x)\n", addr);
 			return 1;
 		}
@@ -558,11 +598,15 @@ 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)
 {
+	struct i2c_bus *bus;
 	uint offset;
 	int i;
 
 	debug("i2c_write: chip=0x%x, addr=0x%x, len=0x%x\n",
 				chip, addr, len);
+	bus = tegra_i2c_get_bus(i2c_bus_num);
+	if (!bus)
+		return 1;
 	if (!i2c_addr_ok(addr, alen)) {
 		debug("i2c_write: Bad address %x.%d.\n", addr, alen);
 		return 1;
@@ -572,7 +616,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 		for (i = 0; i < alen; i++)
 			data[alen - i - 1] = (addr + offset) >> (8 * i);
 		data[alen] = buffer[offset];
-		if (i2c_write_data(chip, data, alen + 1)) {
+		if (i2c_write_data(bus, chip, data, alen + 1)) {
 			debug("i2c_write: error sending (0x%x)\n", addr);
 			return 1;
 		}
-- 
1.7.11.7

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
                   ` (6 preceding siblings ...)
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 7/9] tegra: i2c: Add function to know about current bus Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-06 19:08   ` Stephen Warren
  2013-07-29 16:12   ` Stephen Warren
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 9/9] i2c, ppc4xx_i2c: switch to new multibus/multiadapter support Heiko Schocher
                   ` (2 subsequent siblings)
  10 siblings, 2 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 UTC (permalink / raw)
  To: u-boot

From: Simon Glass <sjg@chromium.org>

This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the Tegra
i2c driver to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heiko Schocher <hs@denx.de>
---
- changes for v2:
  new in v2
  posted from Simon Glass here:
  http://patchwork.ozlabs.org/patch/195568/

  added to this patchserie, changes:
  - rebased to current head
  - add "struct i2c_adapter *adap" to the i2c adapter functions.
  - rework tegra_i2c_get_bus()
  - add missing adapters in tegra_i2c_adap[]
  - replace CONFIG_SYS_MAX_I2C_BUS through TEGRA_I2C_NUM_CONTROLLERS
  - rename CONFIG_TEGRA_I2C to CONFIG_SYS_I2C_TEGRA

- changes for v3:
  - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
  - add changes for dalmore and cardhu boards
  - adapt README
  - adapt commit message
  - patch has 1 checkpatch warning:
WARNING: Avoid CamelCase: <get_OPB_freq>
#1274: FILE: drivers/i2c/ppc4xx_i2c.c:128:
+	divisor = (get_OPB_freq() - 1) / 10000000;
    This should be fixed in a seperate step, as it affects a lot
    of boards...
---
 README                      |  5 +++
 drivers/i2c/Makefile        |  2 +-
 drivers/i2c/tegra_i2c.c     | 80 ++++++++++++++++++---------------------------
 include/configs/beaver.h    |  5 ++-
 include/configs/cardhu.h    |  3 +-
 include/configs/dalmore.h   |  3 +-
 include/configs/seaboard.h  |  5 ++-
 include/configs/trimslice.h |  5 ++-
 include/configs/whistler.h  |  5 ++-
 9 Dateien ge?ndert, 50 Zeilen hinzugef?gt(+), 63 Zeilen entfernt(-)

diff --git a/README b/README
index e322f51..513d84f 100644
--- a/README
+++ b/README
@@ -1920,6 +1920,11 @@ CBFS (Coreboot Filesystem) support
 		    CONFIG_SYS_FSL_I2C2_SLAVE for the slave address of the
 		    second bus.
 
+		- drivers/i2c/tegra_i2c.c:
+		 - activate this driver with CONFIG_SYS_I2C_TEGRA
+		 - This driver adds 4 i2c buses with a fix speed from
+		   100000 and the slave addr 0!
+
 		additional defines:
 
 		CONFIG_SYS_NUM_I2C_BUSES
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 2162173..564d061 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -39,7 +39,6 @@ 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_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
@@ -47,6 +46,7 @@ COBJS-$(CONFIG_SH_SH7734_I2C) += sh_sh7734_i2c.o
 COBJS-$(CONFIG_SYS_I2C) += i2c_core.o
 COBJS-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
 COBJS-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o
+COBJS-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 8fa1cda..9bf71a6 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -35,8 +35,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static unsigned int i2c_bus_num;
-
 /* Information about i2c controller */
 struct i2c_bus {
 	int			id;
@@ -332,38 +330,25 @@ static int tegra_i2c_read_data(struct i2c_bus *bus, u32 addr, u8 *data,
  * @param bus_num	Bus number to check / return
  * @return pointer to bus, if valid, else NULL
  */
-static struct i2c_bus *tegra_i2c_get_bus(unsigned int bus_num)
+static struct i2c_bus *tegra_i2c_get_bus(struct i2c_adapter *adap)
 {
 	struct i2c_bus *bus;
 
-	if (bus_num >= TEGRA_I2C_NUM_CONTROLLERS) {
-		debug("%s: Invalid bus number %u\n", __func__, bus_num);
-		return NULL;
-	}
-	bus = &i2c_controllers[bus_num];
+	bus = &i2c_controllers[adap->hwadapnr];
 	if (!bus->inited) {
-		debug("%s: Bus %u not available\n", __func__, bus_num);
+		debug("%s: Bus %u not available\n", __func__, adap->hwadapnr);
 		return NULL;
 	}
 
 	return bus;
 }
 
-unsigned int i2c_get_bus_speed(void)
-{
-	struct i2c_bus *bus;
-
-	bus = tegra_i2c_get_bus(i2c_bus_num);
-	if (!bus)
-		return 0;
-	return bus->speed;
-}
-
-int i2c_set_bus_speed(unsigned int speed)
+static unsigned int tegra_i2c_set_bus_speed(struct i2c_adapter *adap,
+			unsigned int speed)
 {
 	struct i2c_bus *bus;
 
-	bus = tegra_i2c_get_bus(i2c_bus_num);
+	bus = tegra_i2c_get_bus(adap);
 	if (!bus)
 		return 0;
 	bus->speed = speed;
@@ -482,7 +467,7 @@ void i2c_init_board(void)
 		return;
 }
 
-void i2c_init(int speed, int slaveaddr)
+static void tegra_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
 {
 	/* This will override the speed selected in the fdt for that port */
 	debug("i2c_init(speed=%u, slaveaddr=0x%x)\n", speed, slaveaddr);
@@ -532,14 +517,14 @@ int i2c_read_data(struct i2c_bus *bus, uchar chip, uchar *buffer, int len)
 }
 
 /* Probe to see if a chip is present. */
-int i2c_probe(uchar chip)
+static int tegra_i2c_probe(struct i2c_adapter *adap, uchar chip)
 {
 	struct i2c_bus *bus;
 	int rc;
 	uchar reg;
 
 	debug("i2c_probe: addr=0x%x\n", chip);
-	bus = tegra_i2c_get_bus(i2c_get_bus_num());
+	bus = tegra_i2c_get_bus(adap);
 	if (!bus)
 		return 1;
 	reg = 0;
@@ -558,7 +543,8 @@ static int i2c_addr_ok(const uint addr, const int alen)
 }
 
 /* Read bytes */
-int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
+static int tegra_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
+			int alen, uchar *buffer, int len)
 {
 	struct i2c_bus *bus;
 	uint offset;
@@ -566,7 +552,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 
 	debug("i2c_read: chip=0x%x, addr=0x%x, len=0x%x\n",
 				chip, addr, len);
-	bus = tegra_i2c_get_bus(i2c_bus_num);
+	bus = tegra_i2c_get_bus(adap);
 	if (!bus)
 		return 1;
 	if (!i2c_addr_ok(addr, alen)) {
@@ -596,7 +582,8 @@ 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)
+static int tegra_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
+			int alen, uchar *buffer, int len)
 {
 	struct i2c_bus *bus;
 	uint offset;
@@ -604,7 +591,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 
 	debug("i2c_write: chip=0x%x, addr=0x%x, len=0x%x\n",
 				chip, addr, len);
-	bus = tegra_i2c_get_bus(i2c_bus_num);
+	bus = tegra_i2c_get_bus(adap);
 	if (!bus)
 		return 1;
 	if (!i2c_addr_ok(addr, alen)) {
@@ -625,30 +612,11 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 	return 0;
 }
 
-#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 (bus >= TEGRA_I2C_NUM_CONTROLLERS || !i2c_controllers[bus].inited)
-		return -1;
-	i2c_bus_num = bus;
-
-	return 0;
-}
-#endif
-
 int tegra_i2c_get_dvc_bus_num(void)
 {
 	int i;
 
-	for (i = 0; i < CONFIG_SYS_MAX_I2C_BUS; i++) {
+	for (i = 0; i < TEGRA_I2C_NUM_CONTROLLERS; i++) {
 		struct i2c_bus *bus = &i2c_controllers[i];
 
 		if (bus->inited && bus->is_dvc)
@@ -657,3 +625,19 @@ int tegra_i2c_get_dvc_bus_num(void)
 
 	return -1;
 }
+
+/*
+ * Register soft i2c adapters
+ */
+U_BOOT_I2C_ADAP_COMPLETE(tegra0, tegra_i2c_init, tegra_i2c_probe,
+			 tegra_i2c_read, tegra_i2c_write,
+			 tegra_i2c_set_bus_speed, 100000, 0, 0)
+U_BOOT_I2C_ADAP_COMPLETE(tegra1, tegra_i2c_init, tegra_i2c_probe,
+			 tegra_i2c_read, tegra_i2c_write,
+			 tegra_i2c_set_bus_speed, 100000, 0, 1)
+U_BOOT_I2C_ADAP_COMPLETE(tegra2, tegra_i2c_init, tegra_i2c_probe,
+			 tegra_i2c_read, tegra_i2c_write,
+			 tegra_i2c_set_bus_speed, 100000, 0, 2)
+U_BOOT_I2C_ADAP_COMPLETE(tegra3, tegra_i2c_init, tegra_i2c_probe,
+			 tegra_i2c_read, tegra_i2c_write,
+			 tegra_i2c_set_bus_speed, 100000, 0, 3)
diff --git a/include/configs/beaver.h b/include/configs/beaver.h
index 058da4f..dce08d5 100644
--- a/include/configs/beaver.h
+++ b/include/configs/beaver.h
@@ -41,12 +41,11 @@
 #define CONFIG_BOARD_EARLY_INIT_F
 
 /* I2C */
-#define CONFIG_TEGRA_I2C
+#define CONFIG_SYS_I2C_TEGRA
 #define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_MAX_I2C_BUS		TEGRA_I2C_NUM_CONTROLLERS
 #define CONFIG_SYS_I2C_SPEED		100000
 #define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
 
 /* SD/MMC */
 #define CONFIG_MMC
diff --git a/include/configs/cardhu.h b/include/configs/cardhu.h
index 6a99175..4c67446 100644
--- a/include/configs/cardhu.h
+++ b/include/configs/cardhu.h
@@ -40,12 +40,13 @@
 #define CONFIG_BOARD_EARLY_INIT_F
 
 /* I2C */
-#define CONFIG_TEGRA_I2C
+#define CONFIG_SYS_I2C_TEGRA
 #define CONFIG_SYS_I2C_INIT_BOARD
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS		TEGRA_I2C_NUM_CONTROLLERS
 #define CONFIG_SYS_I2C_SPEED		100000
 #define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
 
 /* SD/MMC */
 #define CONFIG_MMC
diff --git a/include/configs/dalmore.h b/include/configs/dalmore.h
index 7b68f7c..f76f93f 100644
--- a/include/configs/dalmore.h
+++ b/include/configs/dalmore.h
@@ -43,12 +43,13 @@
 #define CONFIG_BOARD_EARLY_INIT_F
 
 /* I2C */
-#define CONFIG_TEGRA_I2C
+#define CONFIG_SYS_I2C_TEGRA
 #define CONFIG_SYS_I2C_INIT_BOARD
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS		TEGRA_I2C_NUM_CONTROLLERS
 #define CONFIG_SYS_I2C_SPEED		100000
 #define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
 
 /* SD/MMC */
 #define CONFIG_MMC
diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h
index f66173e..58bf60a 100644
--- a/include/configs/seaboard.h
+++ b/include/configs/seaboard.h
@@ -57,12 +57,11 @@
 #define CONFIG_BOARD_LATE_INIT		/* Make sure LCD init is complete */
 
 /* I2C */
-#define CONFIG_TEGRA_I2C
+#define CONFIG_SYS_I2C_TEGRA
 #define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_MAX_I2C_BUS		4
 #define CONFIG_SYS_I2C_SPEED		100000
 #define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
 
 /* SD/MMC */
 #define CONFIG_MMC
diff --git a/include/configs/trimslice.h b/include/configs/trimslice.h
index b925314..209c60e 100644
--- a/include/configs/trimslice.h
+++ b/include/configs/trimslice.h
@@ -54,12 +54,11 @@
 #define CONFIG_CMD_SF
 
 /* I2C */
-#define CONFIG_TEGRA_I2C
+#define CONFIG_SYS_I2C_TEGRA
 #define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_MAX_I2C_BUS		4
 #define CONFIG_SYS_I2C_SPEED		100000
 #define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
 
 /* SD/MMC */
 #define CONFIG_MMC
diff --git a/include/configs/whistler.h b/include/configs/whistler.h
index 9542c7e..11a7904 100644
--- a/include/configs/whistler.h
+++ b/include/configs/whistler.h
@@ -46,12 +46,11 @@
 #define CONFIG_BOARD_EARLY_INIT_F
 
 /* I2C */
-#define CONFIG_TEGRA_I2C
+#define CONFIG_SYS_I2C_TEGRA
 #define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_MAX_I2C_BUS		4
 #define CONFIG_SYS_I2C_SPEED		100000
 #define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
 
 /* SD/MMC */
 #define CONFIG_MMC
-- 
1.7.11.7

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

* [U-Boot] [PATCH v3 9/9] i2c, ppc4xx_i2c: switch to new multibus/multiadapter support
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
                   ` (7 preceding siblings ...)
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework Heiko Schocher
@ 2013-05-04 12:01 ` Heiko Schocher
  2013-05-06  6:52   ` Stefan Roese
  2013-05-06  8:57 ` [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Dirk Eibach
  2013-05-17 13:17 ` Piotr Wilczek
  10 siblings, 1 reply; 104+ messages in thread
From: Heiko Schocher @ 2013-05-04 12:01 UTC (permalink / raw)
  To: u-boot

From: Dirk Eibach <dirk.eibach@gdsys.cc>

Signed-off-by: Dirk Eibach <dirk.eibach@gdsys.cc>
Cc: Heiko Schocher <hs@denx.de>
Cc: Stefan Roese <sr@denx.de>

---
- changes for v3:
  - new patch in this serie
  - changes against post from Dirk Eibach
    patchwork.ozlabs.org/patch/239502
    - adapt README
    - fix rebase issue in include/configs/CANBT.h
---
 README                                    |   5 +
 arch/powerpc/cpu/ppc4xx/40x_spd_sdram.c   |   6 +-
 arch/powerpc/cpu/ppc4xx/44x_spd_ddr.c     |   6 +-
 arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c    |   3 +-
 arch/powerpc/cpu/ppc4xx/cmd_chip_config.c |   2 +-
 arch/powerpc/cpu/ppc4xx/denali_spd_ddr2.c |   3 +-
 arch/powerpc/include/asm/ppc4xx-i2c.h     |  18 --
 board/csb272/csb272.c                     |   2 +-
 board/esd/du440/du440.c                   |   2 -
 board/lwmon5/kbd.c                        |   2 +-
 board/mpl/pip405/pip405.c                 |   2 +-
 board/sandburst/common/ppc440gx_i2c.c     | 510 ------------------------------
 board/sandburst/common/ppc440gx_i2c.h     |  60 ----
 board/sandburst/common/sb_common.c        | 103 +++---
 board/sandburst/common/sb_common.h        |   1 -
 board/sandburst/karef/Makefile            |   3 +-
 board/sandburst/karef/karef.c             |   5 -
 board/sandburst/metrobox/Makefile         |   3 +-
 board/sandburst/metrobox/metrobox.c       |   6 -
 drivers/i2c/Makefile                      |   2 +-
 drivers/i2c/ppc4xx_i2c.c                  | 193 ++++++-----
 include/configs/APC405.h                  |   9 +-
 include/configs/ASH405.h                  |   9 +-
 include/configs/CANBT.h                   |  16 +-
 include/configs/CATcenter.h               |   9 +-
 include/configs/CMS700.h                  |   9 +-
 include/configs/CPCI2DP.h                 |   9 +-
 include/configs/CPCI405.h                 |   9 +-
 include/configs/CPCI4052.h                |   9 +-
 include/configs/CPCI405AB.h               |   9 +-
 include/configs/CPCI405DT.h               |   9 +-
 include/configs/CPCIISER4.h               |   9 +-
 include/configs/CRAYL1.h                  |   9 +-
 include/configs/DP405.h                   |   9 +-
 include/configs/DU405.h                   |   9 +-
 include/configs/DU440.h                   |  18 +-
 include/configs/G2000.h                   |   9 +-
 include/configs/HH405.h                   |  11 +-
 include/configs/HUB405.h                  |   9 +-
 include/configs/JSE.h                     |   9 +-
 include/configs/KAREF.h                   |  16 +-
 include/configs/METROBOX.h                |  16 +-
 include/configs/MIP405.h                  |   9 +-
 include/configs/OCRTC.h                   |   9 +-
 include/configs/ORSG.h                    |   9 +-
 include/configs/PCI405.h                  |   9 +-
 include/configs/PIP405.h                  |   9 +-
 include/configs/PLU405.h                  |   9 +-
 include/configs/PMC405.h                  |   9 +-
 include/configs/PMC405DE.h                |   9 +-
 include/configs/PMC440.h                  |  14 +-
 include/configs/PPChameleonEVB.h          |   9 +-
 include/configs/VOH405.h                  |   9 +-
 include/configs/VOM405.h                  |   9 +-
 include/configs/W7OLMC.h                  |   9 +-
 include/configs/W7OLMG.h                  |   9 +-
 include/configs/WUH405.h                  |   9 +-
 include/configs/acadia.h                  |   2 +-
 include/configs/alpr.h                    |  11 +-
 include/configs/amcc-common.h             |   7 +-
 include/configs/bamboo.h                  |   2 +-
 include/configs/bluestone.h               |   2 +-
 include/configs/bubinga.h                 |   4 +-
 include/configs/canyonlands.h             |   2 +-
 include/configs/csb272.h                  |   9 +-
 include/configs/csb472.h                  |   9 +-
 include/configs/dlvision-10g.h            |   2 +-
 include/configs/dlvision.h                |   2 +-
 include/configs/ebony.h                   |   2 +-
 include/configs/gdppc440etx.h             |   2 +-
 include/configs/icon.h                    |   3 +-
 include/configs/intip.h                   |   2 +-
 include/configs/io.h                      |   2 +-
 include/configs/io64.h                    |   2 +-
 include/configs/iocon.h                   |   8 +-
 include/configs/katmai.h                  |   3 +-
 include/configs/kilauea.h                 |   2 +-
 include/configs/korat.h                   |   9 +-
 include/configs/luan.h                    |   2 +-
 include/configs/lwmon5.h                  |   9 +-
 include/configs/makalu.h                  |   2 +-
 include/configs/neo.h                     |   2 +-
 include/configs/ocotea.h                  |   2 +-
 include/configs/p3p440.h                  |  11 +-
 include/configs/pcs440ep.h                |   9 +-
 include/configs/quad100hd.h               |   9 +-
 include/configs/redwood.h                 |   4 +-
 include/configs/sbc405.h                  |   9 +-
 include/configs/sc3.h                     |   9 +-
 include/configs/sequoia.h                 |   2 +-
 include/configs/t3corp.h                  |   2 +-
 include/configs/taihu.h                   |   4 +-
 include/configs/taishan.h                 |   2 +-
 include/configs/walnut.h                  |   2 +-
 include/configs/xpedite1000.h             |  10 +-
 include/configs/yosemite.h                |   2 +-
 include/configs/yucca.h                   |   4 +-
 include/configs/zeus.h                    |   9 +-
 98 Dateien ge?ndert, 465 Zeilen hinzugef?gt(+), 1025 Zeilen entfernt(-)
 delete mode 100644 board/sandburst/common/ppc440gx_i2c.c
 delete mode 100644 board/sandburst/common/ppc440gx_i2c.h

diff --git a/README b/README
index 513d84f..ffbbac1 100644
--- a/README
+++ b/README
@@ -1925,6 +1925,11 @@ CBFS (Coreboot Filesystem) support
 		 - This driver adds 4 i2c buses with a fix speed from
 		   100000 and the slave addr 0!
 
+		- drivers/i2c/ppc4xx_i2c.c
+		  - activate this driver with CONFIG_SYS_I2C_PPC4XX
+		  - CONFIG_SYS_I2C_PPC4XX_CH0 activate hardware channel 0
+		  - CONFIG_SYS_I2C_PPC4XX_CH1 activate hardware channel 1
+
 		additional defines:
 
 		CONFIG_SYS_NUM_I2C_BUSES
diff --git a/arch/powerpc/cpu/ppc4xx/40x_spd_sdram.c b/arch/powerpc/cpu/ppc4xx/40x_spd_sdram.c
index 48aa753..fd458fd 100644
--- a/arch/powerpc/cpu/ppc4xx/40x_spd_sdram.c
+++ b/arch/powerpc/cpu/ppc4xx/40x_spd_sdram.c
@@ -52,10 +52,6 @@
 /*
  * Set default values
  */
-#ifndef CONFIG_SYS_I2C_SPEED
-#define CONFIG_SYS_I2C_SPEED	50000
-#endif
-
 #define ONE_BILLION	1000000000
 
 #define	 SDRAM0_CFG_DCE		0x80000000
@@ -158,7 +154,7 @@ long int spd_sdram(int(read_spd)(uint addr))
 		 * Make sure I2C controller is initialized
 		 * before continuing.
 		 */
-		i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+		i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
 	}
 
 	/* Make shure we are using SDRAM */
diff --git a/arch/powerpc/cpu/ppc4xx/44x_spd_ddr.c b/arch/powerpc/cpu/ppc4xx/44x_spd_ddr.c
index 161d274..9c566c1 100644
--- a/arch/powerpc/cpu/ppc4xx/44x_spd_ddr.c
+++ b/arch/powerpc/cpu/ppc4xx/44x_spd_ddr.c
@@ -62,10 +62,6 @@
 /*
  * Set default values
  */
-#ifndef CONFIG_SYS_I2C_SPEED
-#define CONFIG_SYS_I2C_SPEED	50000
-#endif
-
 #define ONE_BILLION	1000000000
 
 /*
@@ -168,7 +164,7 @@ long int spd_sdram(void) {
 	 * Make sure I2C controller is initialized
 	 * before continuing.
 	 */
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
 
 	/*
 	 * Read the SPD information using I2C interface. Check to see if the
diff --git a/arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c b/arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c
index def7ebf..a66973e 100644
--- a/arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c
+++ b/arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c
@@ -459,8 +459,7 @@ phys_size_t initdram(int board_type)
 	 */
 
 	/* switch to correct I2C bus */
-	I2C_SET_BUS(CONFIG_SYS_SPD_BUS_NUM);
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
 
 	/*------------------------------------------------------------------
 	 * Clear out the serial presence detect buffers.
diff --git a/arch/powerpc/cpu/ppc4xx/cmd_chip_config.c b/arch/powerpc/cpu/ppc4xx/cmd_chip_config.c
index 72c5aec..0eafe3e 100644
--- a/arch/powerpc/cpu/ppc4xx/cmd_chip_config.c
+++ b/arch/powerpc/cpu/ppc4xx/cmd_chip_config.c
@@ -56,7 +56,7 @@ static int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
 	 * First switch to correct I2C bus. This is I2C bus 0
 	 * for all currently available 4xx derivats.
 	 */
-	I2C_SET_BUS(0);
+	i2c_set_bus_num(0);
 
 #ifdef CONFIG_CMD_EEPROM
 	ret = eeprom_read(CONFIG_4xx_CONFIG_I2C_EEPROM_ADDR,
diff --git a/arch/powerpc/cpu/ppc4xx/denali_spd_ddr2.c b/arch/powerpc/cpu/ppc4xx/denali_spd_ddr2.c
index 3ceab32..df96375 100644
--- a/arch/powerpc/cpu/ppc4xx/denali_spd_ddr2.c
+++ b/arch/powerpc/cpu/ppc4xx/denali_spd_ddr2.c
@@ -1041,8 +1041,7 @@ phys_size_t initdram(int board_type)
 	 * before continuing.
 	 */
 	/* switch to correct I2C bus */
-	I2C_SET_BUS(CONFIG_SYS_SPD_BUS_NUM);
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
 
 	/*------------------------------------------------------------------
 	 * Clear out the serial presence detect buffers.
diff --git a/arch/powerpc/include/asm/ppc4xx-i2c.h b/arch/powerpc/include/asm/ppc4xx-i2c.h
index 0c6c926..89de508 100644
--- a/arch/powerpc/include/asm/ppc4xx-i2c.h
+++ b/arch/powerpc/include/asm/ppc4xx-i2c.h
@@ -34,24 +34,6 @@
 
 #define IIC_TIMEOUT	1		/* 1 second */
 
-#if defined(CONFIG_I2C_MULTI_BUS)
-#define I2C_BUS_OFFS	(i2c_bus_num * 0x100)
-#else
-#define I2C_BUS_OFFS	(0x000)
-#endif /* CONFIG_I2C_MULTI_BUS */
-
-#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
-    defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
-    defined(CONFIG_460EX) || defined(CONFIG_460GT)
-#define I2C_BASE_ADDR	(CONFIG_SYS_PERIPHERAL_BASE + 0x00000700 + I2C_BUS_OFFS)
-#elif defined(CONFIG_440) || defined(CONFIG_405EX)
-/* all remaining 440 variants */
-#define I2C_BASE_ADDR	(CONFIG_SYS_PERIPHERAL_BASE + 0x00000400 + I2C_BUS_OFFS)
-#else
-/* all 405 variants */
-#define I2C_BASE_ADDR	(0xEF600500 + I2C_BUS_OFFS)
-#endif
-
 struct ppc4xx_i2c {
 	u8 mdbuf;
 	u8 res1;
diff --git a/board/csb272/csb272.c b/board/csb272/csb272.c
index 8b36127..a53dac1 100644
--- a/board/csb272/csb272.c
+++ b/board/csb272/csb272.c
@@ -51,7 +51,7 @@ uchar pll_fs6377_regs[16] = {
  */
 int pll_init(void)
 {
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(0);
 
 	return  i2c_write(CONFIG_SYS_I2C_PLL_ADDR, 0, 1,
 		(uchar *) pll_fs6377_regs, sizeof(pll_fs6377_regs));
diff --git a/board/esd/du440/du440.c b/board/esd/du440/du440.c
index 1ada1bc..64d43c5 100644
--- a/board/esd/du440/du440.c
+++ b/board/esd/du440/du440.c
@@ -385,7 +385,6 @@ int last_stage_init(void)
 	return 0;
 }
 
-#if defined(CONFIG_I2C_MULTI_BUS)
 /*
  * read field strength from I2C ADC
  */
@@ -500,7 +499,6 @@ U_BOOT_CMD(
 	"Initialize USB hub",
 	""
 );
-#endif /* CONFIG_I2C_MULTI_BUS */
 
 #define CONFIG_SYS_BOOT_EEPROM_PAGE_WRITE_BITS 3
 int boot_eeprom_write (unsigned dev_addr,
diff --git a/board/lwmon5/kbd.c b/board/lwmon5/kbd.c
index b66f681..9834bfd 100644
--- a/board/lwmon5/kbd.c
+++ b/board/lwmon5/kbd.c
@@ -111,7 +111,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->arch.kbd_status = 0;
 
diff --git a/board/mpl/pip405/pip405.c b/board/mpl/pip405/pip405.c
index b203037..655e129 100644
--- a/board/mpl/pip405/pip405.c
+++ b/board/mpl/pip405/pip405.c
@@ -209,7 +209,7 @@ int board_early_init_f (void)
 #endif
 
 	/* Read Serial Presence Detect Information */
-	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(0);
 	for (i = 0; i < 128; i++)
 		datain[i] = 127;
 	i2c_read(SPD_EEPROM_ADDRESS,0,1,datain,128);
diff --git a/board/sandburst/common/ppc440gx_i2c.c b/board/sandburst/common/ppc440gx_i2c.c
deleted file mode 100644
index 85b63fc..0000000
--- a/board/sandburst/common/ppc440gx_i2c.c
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- *  Copyright (C) 2005 Sandburst Corporation
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-/*
- * Ported from arch/powerpc/cpu/ppc4xx/i2c.c by AS HARNOIS by
- * Travis B. Sawyer
- * Sandburst Corporation.
- */
-#include <common.h>
-#include <asm/ppc4xx.h>
-#include <asm/ppc4xx-i2c.h>
-#include <i2c.h>
-#include <command.h>
-#include "ppc440gx_i2c.h"
-#include <asm/io.h>
-
-#ifdef CONFIG_I2C_BUS1
-
-#define IIC_OK		0
-#define IIC_NOK		1
-#define IIC_NOK_LA	2		/* Lost arbitration */
-#define IIC_NOK_ICT	3		/* Incomplete transfer */
-#define IIC_NOK_XFRA	4		/* Transfer aborted */
-#define IIC_NOK_DATA	5		/* No data in buffer */
-#define IIC_NOK_TOUT	6		/* Transfer timeout */
-
-#define IIC_TIMEOUT 1			/* 1 second */
-#if defined(CONFIG_SYS_I2C_NOPROBES)
-static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
-#endif
-
-static struct ppc4xx_i2c *i2c = (struct ppc4xx_i2c *)I2C_REGISTERS_BUS1_BASE_ADDRESS;
-
-static void _i2c_bus1_reset (void)
-{
-	int i, status;
-
-	/* Reset status register */
-	/* write 1 in SCMP and IRQA to clear these fields */
-	out_8 (IIC_STS1, 0x0A);
-
-	/* write 1 in IRQP IRQD LA ICT XFRA to clear these fields */
-	out_8 (IIC_EXTSTS1, 0x8F);
-	__asm__ volatile ("eieio");
-
-	/*
-	 * Get current state, reset bus
-	 * only if no transfers are pending.
-	 */
-	i = 10;
-	do {
-		/* Get status */
-		status = in_8 (IIC_STS1);
-		udelay (500);			/* 500us */
-		i--;
-	} while ((status & IIC_STS_PT) && (i > 0));
-	/* Soft reset controller */
-	status = in_8 (IIC_XTCNTLSS1);
-	out_8 (IIC_XTCNTLSS1, (status | IIC_XTCNTLSS_SRST));
-	__asm__ volatile ("eieio");
-
-	/* make sure where in initial state, data hi, clock hi */
-	out_8 (IIC_DIRECTCNTL1, 0xC);
-	for (i = 0; i < 10; i++) {
-		if ((in_8 (IIC_DIRECTCNTL1) & 0x3) != 0x3) {
-			/* clock until we get to known state */
-			out_8 (IIC_DIRECTCNTL1, 0x8);	/* clock lo */
-			udelay (100);		/* 100us */
-			out_8 (IIC_DIRECTCNTL1, 0xC);	/* clock hi */
-			udelay (100);		/* 100us */
-		} else {
-			break;
-		}
-	}
-	/* send start condition */
-	out_8 (IIC_DIRECTCNTL1, 0x4);
-	udelay (1000);				/* 1ms */
-	/* send stop condition */
-	out_8 (IIC_DIRECTCNTL1, 0xC);
-	udelay (1000);				/* 1ms */
-	/* Unreset controller */
-	out_8 (IIC_XTCNTLSS1, (status & ~IIC_XTCNTLSS_SRST));
-	udelay (1000);				/* 1ms */
-}
-
-void i2c1_init (int speed, int slaveadd)
-{
-	sys_info_t sysInfo;
-	unsigned long freqOPB;
-	int val, divisor;
-
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-	/* call board specific i2c bus reset routine before accessing the   */
-	/* environment, which might be in a chip on that bus. For details   */
-	/* about this problem see doc/I2C_Edge_Conditions.                  */
-	i2c_init_board();
-#endif
-
-	/* Handle possible failed I2C state */
-	/* FIXME: put this into i2c_init_board()? */
-	_i2c_bus1_reset ();
-
-	/* clear lo master address */
-	out_8 (IIC_LMADR1, 0);
-
-	/* clear hi master address */
-	out_8 (IIC_HMADR1, 0);
-
-	/* clear lo slave address */
-	out_8 (IIC_LSADR1, 0);
-
-	/* clear hi slave address */
-	out_8 (IIC_HSADR1, 0);
-
-	/* Clock divide Register */
-	/* get OPB frequency */
-	get_sys_info (&sysInfo);
-	freqOPB = sysInfo.freqPLB / sysInfo.pllOpbDiv;
-	/* set divisor according to freqOPB */
-	divisor = (freqOPB - 1) / 10000000;
-	if (divisor == 0)
-		divisor = 1;
-	out_8 (IIC_CLKDIV1, divisor);
-
-	/* no interrupts */
-	out_8 (IIC_INTRMSK1, 0);
-
-	/* clear transfer count */
-	out_8 (IIC_XFRCNT1, 0);
-
-	/* clear extended control & stat */
-	/* write 1 in SRC SRS SWC SWS to clear these fields */
-	out_8 (IIC_XTCNTLSS1, 0xF0);
-
-	/* Mode Control Register
-	   Flush Slave/Master data buffer */
-	out_8 (IIC_MDCNTL1, IIC_MDCNTL_FSDB | IIC_MDCNTL_FMDB);
-	__asm__ volatile ("eieio");
-
-
-	val = in_8(IIC_MDCNTL1);
-	__asm__ volatile ("eieio");
-
-	/* Ignore General Call, slave transfers are ignored,
-	   disable interrupts, exit unknown bus state, enable hold
-	   SCL
-	   100kHz normaly or FastMode for 400kHz and above
-	*/
-
-	val |= IIC_MDCNTL_EUBS|IIC_MDCNTL_HSCL;
-	if( speed >= 400000 ){
-		val |= IIC_MDCNTL_FSM;
-	}
-	out_8 (IIC_MDCNTL1, val);
-
-	/* clear control reg */
-	out_8 (IIC_CNTL1, 0x00);
-	__asm__ volatile ("eieio");
-
-}
-
-/*
-  This code tries to use the features of the 405GP i2c
-  controller. It will transfer up to 4 bytes in one pass
-  on the loop. It only does out_8(lbz) to the buffer when it
-  is possible to do out16(lhz) transfers.
-
-  cmd_type is 0 for write 1 for read.
-
-  addr_len can take any value from 0-255, it is only limited
-  by the char, we could make it larger if needed. If it is
-  0 we skip the address write cycle.
-
-  Typical case is a Write of an addr followd by a Read. The
-  IBM FAQ does not cover this. On the last byte of the write
-  we don't set the creg CHT bit, and on the first bytes of the
-  read we set the RPST bit.
-
-  It does not support address only transfers, there must be
-  a data part. If you want to write the address yourself, put
-  it in the data pointer.
-
-  It does not support transfer to/from address 0.
-
-  It does not check XFRCNT.
-*/
-static
-int i2c_transfer1(unsigned char cmd_type,
-		  unsigned char chip,
-		  unsigned char addr[],
-		  unsigned char addr_len,
-		  unsigned char data[],
-		  unsigned short data_len )
-{
-	unsigned char* ptr;
-	int reading;
-	int tran,cnt;
-	int result;
-	int status;
-	int i;
-	uchar creg;
-
-	if( data == 0 || data_len == 0 ){
-		/*Don't support data transfer of no length or to address 0*/
-		printf( "i2c_transfer: bad call\n" );
-		return IIC_NOK;
-	}
-	if( addr && addr_len ){
-		ptr = addr;
-		cnt = addr_len;
-		reading = 0;
-	}else{
-		ptr = data;
-		cnt = data_len;
-		reading = cmd_type;
-	}
-
-	/*Clear Stop Complete Bit*/
-	out_8(IIC_STS1,IIC_STS_SCMP);
-	/* Check init */
-	i=10;
-	do {
-		/* Get status */
-		status = in_8(IIC_STS1);
-		__asm__ volatile("eieio");
-		i--;
-	} while ((status & IIC_STS_PT) && (i>0));
-
-	if (status & IIC_STS_PT) {
-		result = IIC_NOK_TOUT;
-		return(result);
-	}
-	/*flush the Master/Slave Databuffers*/
-	out_8(IIC_MDCNTL1, ((in_8(IIC_MDCNTL1))|IIC_MDCNTL_FMDB|IIC_MDCNTL_FSDB));
-	/*need to wait 4 OPB clocks? code below should take that long*/
-
-	/* 7-bit adressing */
-	out_8(IIC_HMADR1,0);
-	out_8(IIC_LMADR1, chip);
-	__asm__ volatile("eieio");
-
-	tran = 0;
-	result = IIC_OK;
-	creg = 0;
-
-	while ( tran != cnt && (result == IIC_OK)) {
-		int  bc,j;
-
-		/* Control register =
-		   Normal transfer, 7-bits adressing, Transfer up to bc bytes, Normal start,
-		   Transfer is a sequence of transfers
-		*/
-		creg |= IIC_CNTL_PT;
-
-		bc = (cnt - tran) > 4 ? 4 :
-			cnt - tran;
-		creg |= (bc-1)<<4;
-		/* if the real cmd type is write continue trans*/
-		if ( (!cmd_type && (ptr == addr)) || ((tran+bc) != cnt) )
-			creg |= IIC_CNTL_CHT;
-
-		if (reading)
-			creg |= IIC_CNTL_READ;
-		else {
-			for(j=0; j<bc; j++) {
-				/* Set buffer */
-				out_8(IIC_MDBUF1,ptr[tran+j]);
-				__asm__ volatile("eieio");
-			}
-		}
-		out_8(IIC_CNTL1, creg );
-		__asm__ volatile("eieio");
-
-		/* Transfer is in progress
-		   we have to wait for upto 5 bytes of data
-		   1 byte chip address+r/w bit then bc bytes
-		   of data.
-		   udelay(10) is 1 bit time@100khz
-		   Doubled for slop. 20 is too small.
-		*/
-		i=2*5*8;
-		do {
-			/* Get status */
-			status = in_8(IIC_STS1);
-			__asm__ volatile("eieio");
-			udelay (10);
-			i--;
-		} while ((status & IIC_STS_PT) && !(status & IIC_STS_ERR)
-			 && (i>0));
-
-		if (status & IIC_STS_ERR) {
-			result = IIC_NOK;
-			status = in_8 (IIC_EXTSTS1);
-			/* Lost arbitration? */
-			if (status & IIC_EXTSTS_LA)
-				result = IIC_NOK_LA;
-			/* Incomplete transfer? */
-			if (status & IIC_EXTSTS_ICT)
-				result = IIC_NOK_ICT;
-			/* Transfer aborted? */
-			if (status & IIC_EXTSTS_XFRA)
-				result = IIC_NOK_XFRA;
-		} else if ( status & IIC_STS_PT) {
-			result = IIC_NOK_TOUT;
-		}
-		/* Command is reading => get buffer */
-		if ((reading) && (result == IIC_OK)) {
-			/* Are there data in buffer */
-			if (status & IIC_STS_MDBS) {
-				/*
-				  even if we have data we have to wait 4OPB clocks
-				  for it to hit the front of the FIFO, after that
-				  we can just read. We should check XFCNT here and
-				  if the FIFO is full there is no need to wait.
-				*/
-				udelay (1);
-				for(j=0;j<bc;j++) {
-					ptr[tran+j] = in_8(IIC_MDBUF1);
-					__asm__ volatile("eieio");
-				}
-			} else
-				result = IIC_NOK_DATA;
-		}
-		creg = 0;
-		tran+=bc;
-		if( ptr == addr && tran == cnt ) {
-			ptr = data;
-			cnt = data_len;
-			tran = 0;
-			reading = cmd_type;
-			if( reading )
-				creg = IIC_CNTL_RPST;
-		}
-	}
-	return (result);
-}
-
-int i2c_probe1 (uchar chip)
-{
-	uchar buf[1];
-
-	buf[0] = 0;
-
-	/*
-	 * What is needed is to send the chip address and verify that the
-	 * address was <ACK>ed (i.e. there was a chip at that address which
-	 * drove the data line low).
-	 */
-	return(i2c_transfer1 (1, chip << 1, 0,0, buf, 1) != 0);
-}
-
-
-int i2c_read1 (uchar chip, uint addr, int alen, uchar * buffer, int len)
-{
-	uchar xaddr[4];
-	int ret;
-
-	if ( alen > 4 ) {
-		printf ("I2C read: addr len %d not supported\n", alen);
-		return 1;
-	}
-
-	if ( alen > 0 ) {
-		xaddr[0] = (addr >> 24) & 0xFF;
-		xaddr[1] = (addr >> 16) & 0xFF;
-		xaddr[2] = (addr >> 8) & 0xFF;
-		xaddr[3] = addr & 0xFF;
-	}
-
-
-#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW
-	/*
-	 * EEPROM chips that implement "address overflow" are ones
-	 * like Catalyst 24WC04/08/16 which has 9/10/11 bits of
-	 * address and the extra bits end up in the "chip address"
-	 * bit slots. This makes a 24WC08 (1Kbyte) chip look like
-	 * four 256 byte chips.
-	 *
-	 * Note that we consider the length of the address field to
-	 * still be one byte because the extra address bits are
-	 * hidden in the chip address.
-	 */
-	if( alen > 0 )
-		chip |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
-#endif
-	if( (ret = i2c_transfer1( 1, chip<<1, &xaddr[4-alen], alen, buffer, len )) != 0) {
-		printf( "I2c read: failed %d\n", ret);
-		return 1;
-	}
-	return 0;
-}
-
-int i2c_write1 (uchar chip, uint addr, int alen, uchar * buffer, int len)
-{
-	uchar xaddr[4];
-
-	if ( alen > 4 ) {
-		printf ("I2C write: addr len %d not supported\n", alen);
-		return 1;
-
-	}
-	if ( alen > 0 ) {
-		xaddr[0] = (addr >> 24) & 0xFF;
-		xaddr[1] = (addr >> 16) & 0xFF;
-		xaddr[2] = (addr >> 8) & 0xFF;
-		xaddr[3] = addr & 0xFF;
-	}
-
-#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW
-	/*
-	 * EEPROM chips that implement "address overflow" are ones
-	 * like Catalyst 24WC04/08/16 which has 9/10/11 bits of
-	 * address and the extra bits end up in the "chip address"
-	 * bit slots. This makes a 24WC08 (1Kbyte) chip look like
-	 * four 256 byte chips.
-	 *
-	 * Note that we consider the length of the address field to
-	 * still be one byte because the extra address bits are
-	 * hidden in the chip address.
-	 */
-	if( alen > 0 )
-		chip |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
-#endif
-
-	return (i2c_transfer1( 0, chip<<1, &xaddr[4-alen], alen, buffer, len ) != 0);
-}
-
-/*-----------------------------------------------------------------------
- * Read a register
- */
-uchar i2c_reg_read1(uchar i2c_addr, uchar reg)
-{
-	uchar buf;
-
-	i2c_read1(i2c_addr, reg, 1, &buf, (uchar)1);
-
-	return(buf);
-}
-
-/*-----------------------------------------------------------------------
- * Write a register
- */
-void i2c_reg_write1(uchar i2c_addr, uchar reg, uchar val)
-{
-	i2c_write1(i2c_addr, reg, 1, &val, 1);
-}
-
-
-int do_i2c1_probe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	int j;
-#if defined(CONFIG_SYS_I2C_NOPROBES)
-	int k, skip;
-#endif
-
-	puts ("Valid chip addresses:");
-	for(j = 0; j < 128; j++) {
-#if defined(CONFIG_SYS_I2C_NOPROBES)
-		skip = 0;
-		for (k = 0; k < sizeof(i2c_no_probes); k++){
-			if (j == i2c_no_probes[k]){
-				skip = 1;
-				break;
-			}
-		}
-		if (skip)
-			continue;
-#endif
-		if(i2c_probe1(j) == 0) {
-			printf(" %02X", j);
-		}
-	}
-	putc ('\n');
-
-#if defined(CONFIG_SYS_I2C_NOPROBES)
-	puts ("Excluded chip addresses:");
-	for( k = 0; k < sizeof(i2c_no_probes); k++ )
-		printf(" %02X", i2c_no_probes[k] );
-	putc ('\n');
-#endif
-
-	return 0;
-}
-
-U_BOOT_CMD(
-	iprobe1,	1,	1,	do_i2c1_probe,
-	"probe to discover valid I2C chip addresses",
-	""
-);
-
-#endif	/* CONFIG_I2C_BUS1 */
diff --git a/board/sandburst/common/ppc440gx_i2c.h b/board/sandburst/common/ppc440gx_i2c.h
deleted file mode 100644
index 7496db4..0000000
--- a/board/sandburst/common/ppc440gx_i2c.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  Copyright (C) 2005 Sandburst Corporation
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-/*
- * Ported from i2c driver for ppc4xx by AS HARNOIS by
- * Travis B. Sawyer
- * Sandburst Corporation
- */
-#include <common.h>
-#include <asm/ppc4xx.h>
-#include <asm/ppc4xx-i2c.h>
-#include <i2c.h>
-
-#ifdef CONFIG_HARD_I2C
-
-#define I2C_BUS1_BASE_ADDR (CONFIG_SYS_PERIPHERAL_BASE + 0x00000500)
-#define	   I2C_REGISTERS_BUS1_BASE_ADDRESS I2C_BUS1_BASE_ADDR
-#define    IIC_MDBUF1	(&i2c->mdbuf)
-#define    IIC_SDBUF1	(&i2c->sdbuf)
-#define    IIC_LMADR1	(&i2c->lmadr)
-#define    IIC_HMADR1	(&i2c->hmadr)
-#define    IIC_CNTL1	(&i2c->cntl)
-#define    IIC_MDCNTL1	(&i2c->mdcntl)
-#define    IIC_STS1	(&i2c->sts)
-#define    IIC_EXTSTS1	(&i2c->extsts)
-#define    IIC_LSADR1	(&i2c->lsadr)
-#define    IIC_HSADR1	(&i2c->hsadr)
-#define    IIC_CLKDIV1	(&i2c->clkdiv)
-#define    IIC_INTRMSK1	(&i2c->intrmsk)
-#define    IIC_XFRCNT1	(&i2c->xfrcnt)
-#define    IIC_XTCNTLSS1	(&i2c->xtcntlss)
-#define    IIC_DIRECTCNTL1 (&i2c->directcntl)
-
-void i2c1_init (int speed, int slaveadd);
-int i2c_probe1 (uchar chip);
-int i2c_read1 (uchar chip, uint addr, int alen, uchar * buffer, int len);
-int i2c_write1 (uchar chip, uint addr, int alen, uchar * buffer, int len);
-uchar i2c_reg_read1(uchar i2c_addr, uchar reg);
-void i2c_reg_write1(uchar i2c_addr, uchar reg, uchar val);
-
-#endif	/* CONFIG_HARD_I2C */
diff --git a/board/sandburst/common/sb_common.c b/board/sandburst/common/sb_common.c
index 6b91074..305e110 100644
--- a/board/sandburst/common/sb_common.c
+++ b/board/sandburst/common/sb_common.c
@@ -26,7 +26,6 @@
 #include <asm/io.h>
 #include <spd_sdram.h>
 #include <i2c.h>
-#include "ppc440gx_i2c.h"
 #include "sb_common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -84,7 +83,7 @@ unsigned short sbcommon_get_serial_number(void)
 
 	/* Get the board serial number from eeprom */
 	/* Initialize I2C */
-	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(0);
 
 	/* Read 256 bytes in EEPROM */
 	i2c_read (0x50, 0, 1, buff, 0x100);
@@ -110,85 +109,87 @@ void sbcommon_fans(void)
 	 * Attempt to turn on 2 of the fans...
 	 * Need to go through the bridge
 	 */
+	i2c_set_bus_num(1);
 	puts ("FANS:  ");
 
 	/* select fan4 through the bridge */
-	i2c_reg_write1(0x73, /* addr */
-		       0x00, /* reg */
-		       0x08); /* val = bus 4 */
+	i2c_reg_write(0x73, /* addr */
+		      0x00, /* reg */
+		      0x08); /* val = bus 4 */
 
 	/* Turn on FAN 4 */
-	i2c_reg_write1(0x2e,
-		       1,
-		       0x80);
+	i2c_reg_write(0x2e,
+		      1,
+		      0x80);
 
-	i2c_reg_write1(0x2e,
-		       0,
-		       0x19);
+	i2c_reg_write(0x2e,
+		      0,
+		      0x19);
 
 	/* Deselect bus 4 on the bridge */
-	i2c_reg_write1(0x73,
-		       0x00,
-		       0x00);
+	i2c_reg_write(0x73,
+		      0x00,
+		      0x00);
 
 	/* select fan3 through the bridge */
-	i2c_reg_write1(0x73, /* addr */
-		       0x00, /* reg */
-		       0x04); /* val = bus 3 */
+	i2c_reg_write(0x73, /* addr */
+		      0x00, /* reg */
+		      0x04); /* val = bus 3 */
 
 	/* Turn on FAN 3 */
-	i2c_reg_write1(0x2e,
-		       1,
-		       0x80);
+	i2c_reg_write(0x2e,
+		      1,
+		      0x80);
 
-	i2c_reg_write1(0x2e,
-		       0,
-		       0x19);
+	i2c_reg_write(0x2e,
+		      0,
+		      0x19);
 
 	/* Deselect bus 3 on the bridge */
-	i2c_reg_write1(0x73,
-		       0x00,
-		       0x00);
+	i2c_reg_write(0x73,
+		      0x00,
+		      0x00);
 
 	/* select fan2 through the bridge */
-	i2c_reg_write1(0x73, /* addr */
-		       0x00, /* reg */
-		       0x02); /* val = bus 4 */
+	i2c_reg_write(0x73, /* addr */
+		      0x00, /* reg */
+		      0x02); /* val = bus 4 */
 
 	/* Turn on FAN 2 */
-	i2c_reg_write1(0x2e,
-		       1,
-		       0x80);
+	i2c_reg_write(0x2e,
+		      1,
+		      0x80);
 
-	i2c_reg_write1(0x2e,
-		       0,
-		       0x19);
+	i2c_reg_write(0x2e,
+		      0,
+		      0x19);
 
 	/* Deselect bus 2 on the bridge */
-	i2c_reg_write1(0x73,
-		       0x00,
-		       0x00);
+	i2c_reg_write(0x73,
+		      0x00,
+		      0x00);
 
 	/* select fan1 through the bridge */
-	i2c_reg_write1(0x73, /* addr */
-		       0x00, /* reg */
-		       0x01); /* val = bus 0 */
+	i2c_reg_write(0x73, /* addr */
+		      0x00, /* reg */
+		      0x01); /* val = bus 0 */
 
 	/* Turn on FAN 1 */
-	i2c_reg_write1(0x2e,
-		       1,
-		       0x80);
+	i2c_reg_write(0x2e,
+		      1,
+		      0x80);
 
-	i2c_reg_write1(0x2e,
-		       0,
-		       0x19);
+	i2c_reg_write(0x2e,
+		      0,
+		      0x19);
 
 	/* Deselect bus 1 on the bridge */
-	i2c_reg_write1(0x73,
-		       0x00,
-		       0x00);
+	i2c_reg_write(0x73,
+		      0x00,
+		      0x00);
 
 	puts ("on\n");
+	i2c_set_bus_num(0);
 
 	return;
 
@@ -319,7 +320,7 @@ void board_get_enetaddr(int macaddr_idx, uchar *enet)
 	if (0 == macaddr_idx) {
 
 		/* Initialize I2C */
-		i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+		i2c_set_bus_num(0);
 
 		/* Read 256 bytes in EEPROM */
 		i2c_read (0x50, 0, 1, buff, 0x100);
diff --git a/board/sandburst/common/sb_common.h b/board/sandburst/common/sb_common.h
index e652ba8..5b28244 100644
--- a/board/sandburst/common/sb_common.h
+++ b/board/sandburst/common/sb_common.h
@@ -28,7 +28,6 @@
 #include <asm/io.h>
 #include <spd_sdram.h>
 #include <i2c.h>
-#include "ppc440gx_i2c.h"
 
 /*
  * GPIO Settings
diff --git a/board/sandburst/karef/Makefile b/board/sandburst/karef/Makefile
index fe9b514..d9b3170 100644
--- a/board/sandburst/karef/Makefile
+++ b/board/sandburst/karef/Makefile
@@ -40,8 +40,7 @@ CFLAGS += -DBUILDUSER='"$(BUILDUSER)"'
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	= $(BOARD).o ../common/flash.o ../common/ppc440gx_i2c.o \
-	../common/sb_common.o
+COBJS	= $(BOARD).o ../common/flash.o ../common/sb_common.o
 
 SOBJS	= init.o
 
diff --git a/board/sandburst/karef/karef.c b/board/sandburst/karef/karef.c
index 186998d..d156844 100644
--- a/board/sandburst/karef/karef.c
+++ b/board/sandburst/karef/karef.c
@@ -337,11 +337,6 @@ int checkboard (void)
  ************************************************************************/
 int misc_init_f (void)
 {
-	/* Turn on i2c bus 1 */
-	puts ("I2C1:  ");
-	i2c1_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-	puts ("ready\n");
-
 	/* Turn on fans 3 & 4 */
 	sbcommon_fans();
 
diff --git a/board/sandburst/metrobox/Makefile b/board/sandburst/metrobox/Makefile
index 6019d59..3f19bf2 100644
--- a/board/sandburst/metrobox/Makefile
+++ b/board/sandburst/metrobox/Makefile
@@ -39,8 +39,7 @@ CFLAGS += -DBUILDUSER='"$(BUILDUSER)"'
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	= $(BOARD).o ../common/flash.o ../common/ppc440gx_i2c.o \
-	../common/sb_common.o
+COBJS	= $(BOARD).o ../common/flash.o ../common/sb_common.o
 SOBJS	= init.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/board/sandburst/metrobox/metrobox.c b/board/sandburst/metrobox/metrobox.c
index 76d8293..ce4a029 100644
--- a/board/sandburst/metrobox/metrobox.c
+++ b/board/sandburst/metrobox/metrobox.c
@@ -30,7 +30,6 @@
 #include <asm/io.h>
 #include <spd_sdram.h>
 #include <i2c.h>
-#include "../common/ppc440gx_i2c.h"
 #include "../common/sb_common.h"
 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) || \
     defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
@@ -305,11 +304,6 @@ int checkboard (void)
  ************************************************************************/
 int misc_init_f (void)
 {
-	/* Turn on i2c bus 1 */
-	puts ("I2C1:  ");
-	i2c1_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-	puts ("ready\n");
-
 	/* Turn on fans */
 	sbcommon_fans();
 
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 564d061..0298e3e 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -36,7 +36,6 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o
 COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
 COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
 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_TSI108_I2C) += tsi108_i2c.o
@@ -45,6 +44,7 @@ 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_FSL) += fsl_i2c.o
+COBJS-$(CONFIG_SYS_I2C_PPC4XX) += ppc4xx_i2c.o
 COBJS-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o
 COBJS-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o
 
diff --git a/drivers/i2c/ppc4xx_i2c.c b/drivers/i2c/ppc4xx_i2c.c
index 53fedd5..c924874 100644
--- a/drivers/i2c/ppc4xx_i2c.c
+++ b/drivers/i2c/ppc4xx_i2c.c
@@ -32,27 +32,29 @@
 #include <i2c.h>
 #include <asm/io.h>
 
-#ifdef CONFIG_HARD_I2C
-
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_I2C_MULTI_BUS)
-/*
- * Initialize the bus pointer to whatever one the SPD EEPROM is on.
- * Default is bus 0.  This is necessary because the DDR initialization
- * runs from ROM, and we can't switch buses because we can't modify
- * the global variables.
- */
-#ifndef CONFIG_SYS_SPD_BUS_NUM
-#define CONFIG_SYS_SPD_BUS_NUM	0
+static inline struct ppc4xx_i2c *ppc4xx_get_i2c(int hwadapnr)
+{
+	unsigned long base;
+
+#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
+	defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
+	defined(CONFIG_460EX) || defined(CONFIG_460GT)
+	base = CONFIG_SYS_PERIPHERAL_BASE + 0x00000700 + (hwadapnr * 0x100);
+#elif defined(CONFIG_440) || defined(CONFIG_405EX)
+/* all remaining 440 variants */
+	base = CONFIG_SYS_PERIPHERAL_BASE + 0x00000400 + (hwadapnr * 0x100);
+#else
+/* all 405 variants */
+	base = 0xEF600500 + (hwadapnr * 0x100);
 #endif
-static unsigned int i2c_bus_num __attribute__ ((section (".data"))) =
-	CONFIG_SYS_SPD_BUS_NUM;
-#endif /* CONFIG_I2C_MULTI_BUS */
+	return (struct ppc4xx_i2c *)base;
+}
 
-static void _i2c_bus_reset(void)
+static void _i2c_bus_reset(struct i2c_adapter *adap)
 {
-	struct ppc4xx_i2c *i2c = (struct ppc4xx_i2c *)I2C_BASE_ADDR;
+	struct ppc4xx_i2c *i2c = ppc4xx_get_i2c(adap->hwadapnr);
 	int i;
 	u8 dc;
 
@@ -91,11 +93,10 @@ static void _i2c_bus_reset(void)
 	out_8(&i2c->xtcntlss, 0);
 }
 
-void i2c_init(int speed, int slaveaddr)
+static void ppc4xx_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
 {
-	struct ppc4xx_i2c *i2c;
+	struct ppc4xx_i2c *i2c = ppc4xx_get_i2c(adap->hwadapnr);
 	int val, divisor;
-	int bus;
 
 #ifdef CONFIG_SYS_I2C_INIT_BOARD
 	/*
@@ -106,67 +107,57 @@ void i2c_init(int speed, int slaveaddr)
 	i2c_init_board();
 #endif
 
-	for (bus = 0; bus < CONFIG_SYS_MAX_I2C_BUS; bus++) {
-		I2C_SET_BUS(bus);
-
-		/* Set i2c pointer after calling I2C_SET_BUS() */
-		i2c = (struct ppc4xx_i2c *)I2C_BASE_ADDR;
-
-		/* Handle possible failed I2C state */
-		/* FIXME: put this into i2c_init_board()? */
-		_i2c_bus_reset();
+	/* Handle possible failed I2C state */
+	/* FIXME: put this into i2c_init_board()? */
+	_i2c_bus_reset(adap);
 
-		/* clear lo master address */
-		out_8(&i2c->lmadr, 0);
+	/* clear lo master address */
+	out_8(&i2c->lmadr, 0);
 
-		/* clear hi master address */
-		out_8(&i2c->hmadr, 0);
-
-		/* clear lo slave address */
-		out_8(&i2c->lsadr, 0);
+	/* clear hi master address */
+	out_8(&i2c->hmadr, 0);
 
-		/* clear hi slave address */
-		out_8(&i2c->hsadr, 0);
+	/* clear lo slave address */
+	out_8(&i2c->lsadr, 0);
 
-		/* Clock divide Register */
-		/* set divisor according to freq_opb */
-		divisor = (get_OPB_freq() - 1) / 10000000;
-		if (divisor == 0)
-			divisor = 1;
-		out_8(&i2c->clkdiv, divisor);
+	/* clear hi slave address */
+	out_8(&i2c->hsadr, 0);
 
-		/* no interrupts */
-		out_8(&i2c->intrmsk, 0);
+	/* Clock divide Register */
+	/* set divisor according to freq_opb */
+	divisor = (get_OPB_freq() - 1) / 10000000;
+	if (divisor == 0)
+		divisor = 1;
+	out_8(&i2c->clkdiv, divisor);
 
-		/* clear transfer count */
-		out_8(&i2c->xfrcnt, 0);
+	/* no interrupts */
+	out_8(&i2c->intrmsk, 0);
 
-		/* clear extended control & stat */
-		/* write 1 in SRC SRS SWC SWS to clear these fields */
-		out_8(&i2c->xtcntlss, 0xF0);
+	/* clear transfer count */
+	out_8(&i2c->xfrcnt, 0);
 
-		/* Mode Control Register
-		   Flush Slave/Master data buffer */
-		out_8(&i2c->mdcntl, IIC_MDCNTL_FSDB | IIC_MDCNTL_FMDB);
+	/* clear extended control & stat */
+	/* write 1 in SRC SRS SWC SWS to clear these fields */
+	out_8(&i2c->xtcntlss, 0xF0);
 
-		val = in_8(&i2c->mdcntl);
+	/* Mode Control Register
+	   Flush Slave/Master data buffer */
+	out_8(&i2c->mdcntl, IIC_MDCNTL_FSDB | IIC_MDCNTL_FMDB);
 
-		/* Ignore General Call, slave transfers are ignored,
-		 * disable interrupts, exit unknown bus state, enable hold
-		 * SCL 100kHz normaly or FastMode for 400kHz and above
-		 */
+	val = in_8(&i2c->mdcntl);
 
-		val |= IIC_MDCNTL_EUBS | IIC_MDCNTL_HSCL;
-		if (speed >= 400000)
-			val |= IIC_MDCNTL_FSM;
-		out_8(&i2c->mdcntl, val);
+	/* Ignore General Call, slave transfers are ignored,
+	 * disable interrupts, exit unknown bus state, enable hold
+	 * SCL 100kHz normaly or FastMode for 400kHz and above
+	 */
 
-		/* clear control reg */
-		out_8(&i2c->cntl, 0x00);
-	}
+	val |= IIC_MDCNTL_EUBS | IIC_MDCNTL_HSCL;
+	if (speed >= 400000)
+		val |= IIC_MDCNTL_FSM;
+	out_8(&i2c->mdcntl, val);
 
-	/* set to SPD bus as default bus upon powerup */
-	I2C_SET_BUS(CONFIG_SYS_SPD_BUS_NUM);
+	/* clear control reg */
+	out_8(&i2c->cntl, 0x00);
 }
 
 /*
@@ -194,14 +185,15 @@ void i2c_init(int speed, int slaveaddr)
  *
  * It does not check XFRCNT.
  */
-static int i2c_transfer(unsigned char cmd_type,
+static int _i2c_transfer(struct i2c_adapter *adap,
+			unsigned char cmd_type,
 			unsigned char chip,
 			unsigned char addr[],
 			unsigned char addr_len,
 			unsigned char data[],
 			unsigned short data_len)
 {
-	struct ppc4xx_i2c *i2c = (struct ppc4xx_i2c *)I2C_BASE_ADDR;
+	struct ppc4xx_i2c *i2c = ppc4xx_get_i2c(adap->hwadapnr);
 	u8 *ptr;
 	int reading;
 	int tran, cnt;
@@ -345,7 +337,7 @@ static int i2c_transfer(unsigned char cmd_type,
 	return result;
 }
 
-int i2c_probe(uchar chip)
+static int ppc4xx_i2c_probe(struct i2c_adapter *adap, uchar chip)
 {
 	uchar buf[1];
 
@@ -356,11 +348,11 @@ int i2c_probe(uchar chip)
 	 * address was <ACK>ed (i.e. there was a chip at that address which
 	 * drove the data line low).
 	 */
-	return (i2c_transfer(1, chip << 1, 0, 0, buf, 1) != 0);
+	return (_i2c_transfer(adap, 1, chip << 1, 0, 0, buf, 1) != 0);
 }
 
-static int ppc4xx_i2c_transfer(uchar chip, uint addr, int alen, uchar *buffer,
-			       int len, int read)
+static int ppc4xx_i2c_transfer(struct i2c_adapter *adap, uchar chip, uint addr,
+			       int alen, uchar *buffer, int len, int read)
 {
 	uchar xaddr[4];
 	int ret;
@@ -394,43 +386,50 @@ static int ppc4xx_i2c_transfer(uchar chip, uint addr, int alen, uchar *buffer,
 		chip |= ((addr >> (alen * 8)) &
 			 CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
-	if ((ret = i2c_transfer(read, chip << 1, &xaddr[4 - alen], alen,
-				buffer, len)) != 0) {
+	ret = _i2c_transfer(adap, read, chip << 1, &xaddr[4 - alen], alen,
+			    buffer, len);
+	if (ret) {
 		printf("I2C %s: failed %d\n", read ? "read" : "write", ret);
-
 		return 1;
 	}
 
 	return 0;
 }
 
-int i2c_read(uchar chip, uint addr, int alen, uchar * buffer, int len)
+static int ppc4xx_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
+			   int alen, uchar *buffer, int len)
 {
-	return ppc4xx_i2c_transfer(chip, addr, alen, buffer, len, 1);
+	return ppc4xx_i2c_transfer(adap, chip, addr, alen, buffer, len, 1);
 }
 
-int i2c_write(uchar chip, uint addr, int alen, uchar * buffer, int len)
+static int ppc4xx_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
+			    int alen, uchar *buffer, int len)
 {
-	return ppc4xx_i2c_transfer(chip, addr, alen, buffer, len, 0);
+	return ppc4xx_i2c_transfer(adap, chip, addr, alen, buffer, len, 0);
 }
 
-#if defined(CONFIG_I2C_MULTI_BUS)
-/*
- * Functions for multiple I2C bus handling
- */
-unsigned int i2c_get_bus_num(void)
+static unsigned int ppc4xx_i2c_set_bus_speed(struct i2c_adapter *adap,
+					     unsigned int speed)
 {
-	return i2c_bus_num;
-}
-
-int i2c_set_bus_num(unsigned int bus)
-{
-	if (bus >= CONFIG_SYS_MAX_I2C_BUS)
+	if (speed != adap->speed)
 		return -1;
-
-	i2c_bus_num = bus;
-
-	return 0;
+	return speed;
 }
-#endif	/* CONFIG_I2C_MULTI_BUS */
-#endif	/* CONFIG_HARD_I2C */
+
+/*
+ * Register ppc4xx i2c adapters
+ */
+#ifdef CONFIG_SYS_I2C_PPC4XX_CH0
+U_BOOT_I2C_ADAP_COMPLETE(ppc4xx_0, ppc4xx_i2c_init, ppc4xx_i2c_probe,
+			 ppc4xx_i2c_read, ppc4xx_i2c_write,
+			 ppc4xx_i2c_set_bus_speed,
+			 CONFIG_SYS_I2C_PPC4XX_SPEED_0,
+			 CONFIG_SYS_I2C_PPC4XX_SLAVE_0, 0)
+#endif
+#ifdef CONFIG_SYS_I2C_PPC4XX_CH1
+U_BOOT_I2C_ADAP_COMPLETE(ppc4xx_1, ppc4xx_i2c_init, ppc4xx_i2c_probe,
+			 ppc4xx_i2c_read, ppc4xx_i2c_write,
+			 ppc4xx_i2c_set_bus_speed,
+			 CONFIG_SYS_I2C_PPC4XX_SPEED_1,
+			 CONFIG_SYS_I2C_PPC4XX_SLAVE_1, 1)
+#endif
diff --git a/include/configs/APC405.h b/include/configs/APC405.h
index 9a65cbc..6720445 100644
--- a/include/configs/APC405.h
+++ b/include/configs/APC405.h
@@ -305,10 +305,11 @@
 /*
  * I2C EEPROM (CAT24WC16) for environment
  */
-#define CONFIG_HARD_I2C			/* I2c with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08 */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1	/* Bytes of address */
diff --git a/include/configs/ASH405.h b/include/configs/ASH405.h
index 09aa763..a6545c1 100644
--- a/include/configs/ASH405.h
+++ b/include/configs/ASH405.h
@@ -246,10 +246,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/CANBT.h b/include/configs/CANBT.h
index fd3eff0..b805fbd 100644
--- a/include/configs/CANBT.h
+++ b/include/configs/CANBT.h
@@ -180,14 +180,14 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-
-#define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* bytes of address		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
+
+#define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08	*/
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* bytes of address	*/
 /* mask of address bits that overflow into the "EEPROM chip address"	*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW	0x07
 
diff --git a/include/configs/CATcenter.h b/include/configs/CATcenter.h
index 1e3a564..d17adf8 100644
--- a/include/configs/CATcenter.h
+++ b/include/configs/CATcenter.h
@@ -401,10 +401,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/CMS700.h b/include/configs/CMS700.h
index 686d158..ca258e6 100644
--- a/include/configs/CMS700.h
+++ b/include/configs/CMS700.h
@@ -226,10 +226,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#define CONFIG_HARD_I2C			/* I2c with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/CPCI2DP.h b/include/configs/CPCI2DP.h
index 11cf58b..8a3eb54 100644
--- a/include/configs/CPCI2DP.h
+++ b/include/configs/CPCI2DP.h
@@ -210,10 +210,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/CPCI405.h b/include/configs/CPCI405.h
index e3e5ebc..4751b8f 100644
--- a/include/configs/CPCI405.h
+++ b/include/configs/CPCI405.h
@@ -259,10 +259,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/CPCI4052.h b/include/configs/CPCI4052.h
index c4fff48..6cbee62 100644
--- a/include/configs/CPCI4052.h
+++ b/include/configs/CPCI4052.h
@@ -286,10 +286,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/CPCI405AB.h b/include/configs/CPCI405AB.h
index 9122cbd..5a014c4 100644
--- a/include/configs/CPCI405AB.h
+++ b/include/configs/CPCI405AB.h
@@ -262,10 +262,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC32) for environment
  */
-#define CONFIG_HARD_I2C			/* I2c with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC32		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2	/* Bytes of address		*/
diff --git a/include/configs/CPCI405DT.h b/include/configs/CPCI405DT.h
index f778af7..7572f57 100644
--- a/include/configs/CPCI405DT.h
+++ b/include/configs/CPCI405DT.h
@@ -281,10 +281,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/CPCIISER4.h b/include/configs/CPCIISER4.h
index 35daed0..854847b 100644
--- a/include/configs/CPCIISER4.h
+++ b/include/configs/CPCIISER4.h
@@ -195,10 +195,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/CRAYL1.h b/include/configs/CRAYL1.h
index 6bceccb..37139ed 100644
--- a/include/configs/CRAYL1.h
+++ b/include/configs/CRAYL1.h
@@ -76,11 +76,12 @@
  #define CONFIG_SERVERIP         10.0.0.1
  #define CONFIG_ETHADDR          00:40:a6:80:14:5
  */
-#define CONFIG_HARD_I2C         1		/* hardware support for i2c */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
 #define CONFIG_SDRAM_BANK0		1
-#define CONFIG_SYS_I2C_SPEED		    400000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		    0x7F
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		    400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		    0x7F
 #define CONFIG_SYS_I2C_EEPROM_ADDR     0x57
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_IDENT_STRING     "Cray L1"
diff --git a/include/configs/DP405.h b/include/configs/DP405.h
index 6d67d6e..fa09797 100644
--- a/include/configs/DP405.h
+++ b/include/configs/DP405.h
@@ -178,10 +178,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/DU405.h b/include/configs/DU405.h
index 24df85a..26162d1 100644
--- a/include/configs/DU405.h
+++ b/include/configs/DU405.h
@@ -197,10 +197,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/DU440.h b/include/configs/DU440.h
index 09876f5..2de4443 100644
--- a/include/configs/DU440.h
+++ b/include/configs/DU440.h
@@ -170,18 +170,20 @@
 /*
  * I2C
  */
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support    */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address  */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_I2C_MULTI_BUS    1
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
+#define CONFIG_SYS_I2C_PPC4XX_CH1
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_1		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_1		0x7F
 
 #define CONFIG_SYS_SPD_BUS_NUM         0
 #define IIC1_MCP3021_ADDR	0x4d
 #define IIC1_USB2507_ADDR	0x2c
-#ifdef CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_I2C_NOPROBES        {{1, IIC1_USB2507_ADDR}}
-#endif
+#define CONFIG_SYS_I2C_NOPROBES		{ {1, IIC1_USB2507_ADDR} }
+
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x54
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
diff --git a/include/configs/G2000.h b/include/configs/G2000.h
index 08ba840..5d8eb77 100644
--- a/include/configs/G2000.h
+++ b/include/configs/G2000.h
@@ -297,10 +297,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT24WC08		*/
 /* CAT24WC08/16... */
diff --git a/include/configs/HH405.h b/include/configs/HH405.h
index 444413d..1435f03 100644
--- a/include/configs/HH405.h
+++ b/include/configs/HH405.h
@@ -333,14 +333,15 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#define CONFIG_HARD_I2C			/* I2c with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
 #if 0 /* test-only */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 #else
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
 #endif
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT24WC08		*/
 #define CONFIG_SYS_EEPROM_WREN         1
diff --git a/include/configs/HUB405.h b/include/configs/HUB405.h
index e90782f..ecfc4aa 100644
--- a/include/configs/HUB405.h
+++ b/include/configs/HUB405.h
@@ -246,10 +246,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/JSE.h b/include/configs/JSE.h
index 713dcca..0ab6864 100644
--- a/include/configs/JSE.h
+++ b/include/configs/JSE.h
@@ -210,10 +210,11 @@
 
 #define CONFIG_SYS_HZ		1000		/* decrementer freq: 1 ms ticks */
 
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#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_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 
 /*-----------------------------------------------------------------------
diff --git a/include/configs/KAREF.h b/include/configs/KAREF.h
index f8da14d..4a60436 100644
--- a/include/configs/KAREF.h
+++ b/include/configs/KAREF.h
@@ -133,13 +133,15 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_HARD_I2C	      1		     /* I2C hardware support	*/
-#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	*/
-#define CONFIG_SYS_I2C_NOPROBES      {0x69}	     /* Don't probe these addrs */
-#define CONFIG_I2C_BUS1	      1		     /* Include i2c bus 1 supp	*/
-
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0 400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0 0x7F
+#define CONFIG_SYS_I2C_PPC4XX_CH1
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_1 400000 /* I2C speed 400kHz */
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_1 0x7F
+#define CONFIG_SYS_I2C_NOPROBES { { 0, 0x69} } /* Don't probe these addrs */
 
 /*-----------------------------------------------------------------------
  * Environment
diff --git a/include/configs/METROBOX.h b/include/configs/METROBOX.h
index 7556ad5..96f3015 100644
--- a/include/configs/METROBOX.h
+++ b/include/configs/METROBOX.h
@@ -195,13 +195,15 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_HARD_I2C	      1		     /* I2C hardware support	*/
-#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	*/
-#define CONFIG_SYS_I2C_NOPROBES      {0x69}	     /* Don't probe these addrs */
-#define CONFIG_I2C_BUS1	      1		     /* Include i2c bus 1 supp	*/
-
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0 400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0 0x7F
+#define CONFIG_SYS_I2C_PPC4XX_CH1
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_1 400000 /* I2C speed 400kHz */
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_1 0x7F
+#define CONFIG_SYS_I2C_NOPROBES { { 0, 0x69} } /* Don't probe these addrs */
 
 /*-----------------------------------------------------------------------
  * Environment
diff --git a/include/configs/MIP405.h b/include/configs/MIP405.h
index 979495a..831f5c9 100644
--- a/include/configs/MIP405.h
+++ b/include/configs/MIP405.h
@@ -98,10 +98,11 @@
  * The Atmel EEPROM uses 16Bit addressing.
  ***************************************************************/
 
-#define CONFIG_HARD_I2C			/* I2c with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		50000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		50000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x53	/* EEPROM 24C128/256		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2	/* Bytes of address		*/
diff --git a/include/configs/OCRTC.h b/include/configs/OCRTC.h
index 47110af..9b8b701 100644
--- a/include/configs/OCRTC.h
+++ b/include/configs/OCRTC.h
@@ -216,10 +216,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/ORSG.h b/include/configs/ORSG.h
index 9f754c2..8f221f9 100644
--- a/include/configs/ORSG.h
+++ b/include/configs/ORSG.h
@@ -212,10 +212,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/PCI405.h b/include/configs/PCI405.h
index 119819e..687340d 100644
--- a/include/configs/PCI405.h
+++ b/include/configs/PCI405.h
@@ -208,10 +208,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/PIP405.h b/include/configs/PIP405.h
index 713ea12..b881609 100644
--- a/include/configs/PIP405.h
+++ b/include/configs/PIP405.h
@@ -87,10 +87,11 @@
  * EEPROM of the SDRAM
  * The Atmel EEPROM uses 16Bit addressing.
  ***************************************************************/
-#define CONFIG_HARD_I2C			/* I2c with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		50000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		50000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x53
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
diff --git a/include/configs/PLU405.h b/include/configs/PLU405.h
index 1ee0c48..7240d00 100644
--- a/include/configs/PLU405.h
+++ b/include/configs/PLU405.h
@@ -280,10 +280,11 @@
 /*
  * I2C EEPROM (24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM 24WC16 */
 #define CONFIG_SYS_EEPROM_WREN         1
diff --git a/include/configs/PMC405.h b/include/configs/PMC405.h
index 8235b85..6cc8917 100644
--- a/include/configs/PMC405.h
+++ b/include/configs/PMC405.h
@@ -238,10 +238,11 @@
 /*
  * I2C EEPROM (CAT24WC16) for environment
  */
-#define CONFIG_HARD_I2C			/* I2c with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000 /* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT24W16 */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address */
diff --git a/include/configs/PMC405DE.h b/include/configs/PMC405DE.h
index 992443a..6ee3a8d 100644
--- a/include/configs/PMC405DE.h
+++ b/include/configs/PMC405DE.h
@@ -216,10 +216,11 @@
 /*
  * I2C EEPROM (24W16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM 24W16	*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address */
diff --git a/include/configs/PMC440.h b/include/configs/PMC440.h
index 2265d96..470ee69 100644
--- a/include/configs/PMC440.h
+++ b/include/configs/PMC440.h
@@ -225,12 +225,14 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support    */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address  */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-
-#define CONFIG_I2C_MULTI_BUS	1
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
+#define CONFIG_SYS_I2C_PPC4XX_CH1
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_1		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_1		0x7F
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 
diff --git a/include/configs/PPChameleonEVB.h b/include/configs/PPChameleonEVB.h
index 27a12b3..82739fe 100644
--- a/include/configs/PPChameleonEVB.h
+++ b/include/configs/PPChameleonEVB.h
@@ -418,10 +418,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/VOH405.h b/include/configs/VOH405.h
index f1032f0..46e1674 100644
--- a/include/configs/VOH405.h
+++ b/include/configs/VOH405.h
@@ -279,10 +279,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#define CONFIG_HARD_I2C			/* I2c with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT24WC08		*/
 #define CONFIG_SYS_EEPROM_WREN         1
diff --git a/include/configs/VOM405.h b/include/configs/VOM405.h
index 43d6bb3..85722e4 100644
--- a/include/configs/VOM405.h
+++ b/include/configs/VOM405.h
@@ -205,10 +205,11 @@
 /*
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/W7OLMC.h b/include/configs/W7OLMC.h
index 462b155..40cd8f8 100644
--- a/include/configs/W7OLMC.h
+++ b/include/configs/W7OLMC.h
@@ -278,10 +278,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC08) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1	/* Bytes of address		*/
diff --git a/include/configs/W7OLMG.h b/include/configs/W7OLMG.h
index f28f3e4..f419d7e 100644
--- a/include/configs/W7OLMG.h
+++ b/include/configs/W7OLMG.h
@@ -285,10 +285,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (ATMEL 24C04N)
  */
-#define CONFIG_HARD_I2C		1		/* Hardware assisted I2C	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#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_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50		/* EEPROM ATMEL 24C04N		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1		/* Bytes of address		*/
diff --git a/include/configs/WUH405.h b/include/configs/WUH405.h
index 5def36a..97983a6 100644
--- a/include/configs/WUH405.h
+++ b/include/configs/WUH405.h
@@ -243,10 +243,11 @@
 /*-----------------------------------------------------------------------
  * I2C EEPROM (CAT24WC16) for environment
  */
-#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 */
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* EEPROM CAT28WC08		*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1	/* Bytes of address		*/
diff --git a/include/configs/acadia.h b/include/configs/acadia.h
index 8c447ca..52a64bf 100644
--- a/include/configs/acadia.h
+++ b/include/configs/acadia.h
@@ -206,7 +206,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000		/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/alpr.h b/include/configs/alpr.h
index a6add6b..99b1290 100644
--- a/include/configs/alpr.h
+++ b/include/configs/alpr.h
@@ -121,11 +121,12 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{0x69}	/* Don't probe these addrs	*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
+#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x69} }	/* Don't probe these addrs */
 
 /*-----------------------------------------------------------------------
  * I2C EEPROM (PCF8594C)
diff --git a/include/configs/amcc-common.h b/include/configs/amcc-common.h
index f2f522d..d5dd67c 100644
--- a/include/configs/amcc-common.h
+++ b/include/configs/amcc-common.h
@@ -42,9 +42,10 @@
 /*
  * I2C
  */
-#define CONFIG_HARD_I2C			/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 /*
  * Ethernet/EMAC/PHY
diff --git a/include/configs/bamboo.h b/include/configs/bamboo.h
index 506a558..910b626 100644
--- a/include/configs/bamboo.h
+++ b/include/configs/bamboo.h
@@ -222,7 +222,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/bluestone.h b/include/configs/bluestone.h
index 3e691fd..934da81 100644
--- a/include/configs/bluestone.h
+++ b/include/configs/bluestone.h
@@ -122,7 +122,7 @@
 /*
  * I2C
  */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed            */
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x54
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
diff --git a/include/configs/bubinga.h b/include/configs/bubinga.h
index da67ae3..e429ed2 100644
--- a/include/configs/bubinga.h
+++ b/include/configs/bubinga.h
@@ -134,9 +134,9 @@
  * I2C stuff
  *-----------------------------------------------------------------------
  */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_NOPROBES	{ 0x69 }	/* avoid i2c probe hangup (why?) */
+#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x69} }	/* avoid i2c probe hangup (?) */
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	6	/* 24C02 requires 5ms delay */
 
 #if defined(CONFIG_CMD_EEPROM)
diff --git a/include/configs/canyonlands.h b/include/configs/canyonlands.h
index acb127c..61dbda6 100644
--- a/include/configs/canyonlands.h
+++ b/include/configs/canyonlands.h
@@ -329,7 +329,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed			*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
diff --git a/include/configs/csb272.h b/include/configs/csb272.h
index f21fa64..d1a1d2a 100644
--- a/include/configs/csb272.h
+++ b/include/configs/csb272.h
@@ -175,10 +175,11 @@
  * I2C configuration
  *
  */
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed			*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F	/* I2C slave address		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F	/* I2C slave address */
 
 /*
  * MII PHY configuration
diff --git a/include/configs/csb472.h b/include/configs/csb472.h
index aed5fa6..4cd0057 100644
--- a/include/configs/csb472.h
+++ b/include/configs/csb472.h
@@ -174,10 +174,11 @@
  * I2C configuration
  *
  */
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed			*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F	/* I2C slave address		*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F	/* I2C slave address */
 
 /*
  * MII PHY configuration
diff --git a/include/configs/dlvision-10g.h b/include/configs/dlvision-10g.h
index 2cd2027..5d6308f 100644
--- a/include/configs/dlvision-10g.h
+++ b/include/configs/dlvision-10g.h
@@ -114,7 +114,7 @@
 /*
  * I2C stuff
  */
-#define CONFIG_SYS_I2C_SPEED		100000
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
 
 /* Temp sensor/hwmon/dtt */
 #define CONFIG_DTT_LM63		1	/* National LM63	*/
diff --git a/include/configs/dlvision.h b/include/configs/dlvision.h
index c490ff6..24c9fa4 100644
--- a/include/configs/dlvision.h
+++ b/include/configs/dlvision.h
@@ -107,7 +107,7 @@
 /*
  * I2C stuff
  */
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
 
 /*
  * FLASH organization
diff --git a/include/configs/ebony.h b/include/configs/ebony.h
index d6b6551..bb56d0f 100644
--- a/include/configs/ebony.h
+++ b/include/configs/ebony.h
@@ -138,7 +138,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/gdppc440etx.h b/include/configs/gdppc440etx.h
index 9efbb8e..ab35901 100644
--- a/include/configs/gdppc440etx.h
+++ b/include/configs/gdppc440etx.h
@@ -145,7 +145,7 @@
 /*
  * I2C
  */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed+slave address*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 /*
  * Default environment variables
diff --git a/include/configs/icon.h b/include/configs/icon.h
index 2fac0ef..a55a851 100644
--- a/include/configs/icon.h
+++ b/include/configs/icon.h
@@ -120,9 +120,8 @@
 /*
  * I2C
  */
-#define CONFIG_SYS_I2C_SPEED	100000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0	100000
 
-#define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_SPD_BUS_NUM	0	/* The I2C bus for SPD		*/
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
diff --git a/include/configs/intip.h b/include/configs/intip.h
index 33364a8..04451b3 100644
--- a/include/configs/intip.h
+++ b/include/configs/intip.h
@@ -228,7 +228,7 @@
 /*
  * I2C
  */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed */
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
diff --git a/include/configs/io.h b/include/configs/io.h
index 03661cc..4950ad7 100644
--- a/include/configs/io.h
+++ b/include/configs/io.h
@@ -114,7 +114,7 @@
 /*
  * I2C stuff
  */
-#define CONFIG_SYS_I2C_SPEED		100000
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
 
 /* Temp sensor/hwmon/dtt */
 #define CONFIG_DTT_LM63		1	/* National LM63	*/
diff --git a/include/configs/io64.h b/include/configs/io64.h
index 887aaef..bb29bed 100644
--- a/include/configs/io64.h
+++ b/include/configs/io64.h
@@ -340,7 +340,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED	400000	/* I2C speed and slave address */
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0	400000
 
 #define CONFIG_PCA9698		1	/* NXP PCA9698 */
 
diff --git a/include/configs/iocon.h b/include/configs/iocon.h
index 695aa5c..5972711 100644
--- a/include/configs/iocon.h
+++ b/include/configs/iocon.h
@@ -110,11 +110,11 @@
 /*
  * I2C stuff
  */
-#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_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 /*
  * Software (bit-bang) I2C driver configuration
diff --git a/include/configs/katmai.h b/include/configs/katmai.h
index 3ed8dc7..5b3ad74 100644
--- a/include/configs/katmai.h
+++ b/include/configs/katmai.h
@@ -119,9 +119,8 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
 
-#define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_SPD_BUS_NUM		0	/* The I2C bus for SPD		*/
 
 #define IIC0_BOOTPROM_ADDR	0x50
diff --git a/include/configs/kilauea.h b/include/configs/kilauea.h
index d505a41..4af908d 100644
--- a/include/configs/kilauea.h
+++ b/include/configs/kilauea.h
@@ -385,7 +385,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x52	/* I2C boot EEPROM (24C02BN)	*/
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1	/* Bytes of address		*/
diff --git a/include/configs/korat.h b/include/configs/korat.h
index 7d5fb15..5744db3 100644
--- a/include/configs/korat.h
+++ b/include/configs/korat.h
@@ -155,10 +155,11 @@
 /*
  * I2C
  */
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#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_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/luan.h b/include/configs/luan.h
index 3b4761b..ed275a1 100644
--- a/include/configs/luan.h
+++ b/include/configs/luan.h
@@ -134,7 +134,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/lwmon5.h b/include/configs/lwmon5.h
index 4dcb25a..7d9378e 100644
--- a/include/configs/lwmon5.h
+++ b/include/configs/lwmon5.h
@@ -298,10 +298,11 @@
 /*
  * I2C
  */
-#define CONFIG_HARD_I2C				/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000		/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_RTC_ADDR	0x51	/* RTC				*/
 #define CONFIG_SYS_I2C_EEPROM_CPU_ADDR	0x52	/* EEPROM          (CPU Modul)	*/
diff --git a/include/configs/makalu.h b/include/configs/makalu.h
index 6c1b136..5baba18 100644
--- a/include/configs/makalu.h
+++ b/include/configs/makalu.h
@@ -201,7 +201,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	6	/* 24C02 requires 5ms delay */
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x52	/* I2C boot EEPROM (24C02BN)	*/
diff --git a/include/configs/neo.h b/include/configs/neo.h
index 38b5bec..be1c9ff 100644
--- a/include/configs/neo.h
+++ b/include/configs/neo.h
@@ -117,7 +117,7 @@
 /*
  * I2C stuff
  */
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
 
 /* RTC */
 #define CONFIG_RTC_DS1337
diff --git a/include/configs/ocotea.h b/include/configs/ocotea.h
index d0fe9da..de021e3 100644
--- a/include/configs/ocotea.h
+++ b/include/configs/ocotea.h
@@ -151,7 +151,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/p3p440.h b/include/configs/p3p440.h
index ba10e88..4c9fb6f 100644
--- a/include/configs/p3p440.h
+++ b/include/configs/p3p440.h
@@ -97,11 +97,12 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
-#define CONFIG_SYS_I2C_NOPROBES	{0x69}	/* Don't probe these addrs	*/
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
+#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x69} }	/* Don't probe these addrs */
 
 /*-----------------------------------------------------------------------
  * I2C RTC
diff --git a/include/configs/pcs440ep.h b/include/configs/pcs440ep.h
index 8d46607..51e26be 100644
--- a/include/configs/pcs440ep.h
+++ b/include/configs/pcs440ep.h
@@ -139,10 +139,11 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_HARD_I2C		1	    /* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed and slave address	*/
-#define CONFIG_SYS_I2C_SLAVE		0x7F
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa4>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
diff --git a/include/configs/quad100hd.h b/include/configs/quad100hd.h
index 30a8c55..809d764 100644
--- a/include/configs/quad100hd.h
+++ b/include/configs/quad100hd.h
@@ -152,10 +152,11 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_HARD_I2C		1		/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#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_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50		/* base address */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2		/* bytes of address */
diff --git a/include/configs/redwood.h b/include/configs/redwood.h
index f75ab67..355c330 100644
--- a/include/configs/redwood.h
+++ b/include/configs/redwood.h
@@ -110,13 +110,13 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed			*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define IIC0_BOOTPROM_ADDR	0x50
 #define IIC0_ALT_BOOTPROM_ADDR	0x54
 
 /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_NOPROBES	{0x50, 0x52, 0x53, 0x54}
+#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x50}, {0, 0x52}, {0, 0x53}, {0, 0x54} }
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2	/* Bytes of address		*/
 
diff --git a/include/configs/sbc405.h b/include/configs/sbc405.h
index 9918638..2342d7c 100644
--- a/include/configs/sbc405.h
+++ b/include/configs/sbc405.h
@@ -168,10 +168,11 @@
 
 #define CONFIG_SYS_RX_ETH_BUFFER	16	/* use 16 rx buffer on 405 emac */
 
-#define CONFIG_HARD_I2C		1	/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#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_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 /*-----------------------------------------------------------------------
  * PCI stuff
diff --git a/include/configs/sc3.h b/include/configs/sc3.h
index abca9e0..cabe45e 100644
--- a/include/configs/sc3.h
+++ b/include/configs/sc3.h
@@ -246,15 +246,16 @@
  * IIC stuff
  *-----------------------------------------------------------------------
  */
-#define  CONFIG_HARD_I2C		/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
+#define  CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
 
 #define I2C_INIT
 #define I2C_ACTIVE 0
 #define I2C_TRISTATE 0
 
-#define CONFIG_SYS_I2C_SPEED		100000	/* use the standard 100kHz speed */
-#define CONFIG_SYS_I2C_SLAVE		0x7F		/* mask valid bits */
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		100000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F	/* mask valid bits */
 
 #define CONFIG_RTC_DS1337
 #define CONFIG_SYS_I2C_RTC_ADDR 0x68
diff --git a/include/configs/sequoia.h b/include/configs/sequoia.h
index dd5d7cd..3b8a0c6 100644
--- a/include/configs/sequoia.h
+++ b/include/configs/sequoia.h
@@ -232,7 +232,7 @@
 /*
  * I2C
  */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/t3corp.h b/include/configs/t3corp.h
index 2a731a6..a129013 100644
--- a/include/configs/t3corp.h
+++ b/include/configs/t3corp.h
@@ -319,7 +319,7 @@
 /*
  * I2C
  */
-#define CONFIG_SYS_I2C_SPEED			400000	/* I2C speed */
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0			400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
diff --git a/include/configs/taihu.h b/include/configs/taihu.h
index a3738b7..9bc247d 100644
--- a/include/configs/taihu.h
+++ b/include/configs/taihu.h
@@ -138,9 +138,9 @@
  * I2C stuff
  *-----------------------------------------------------------------------
  */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_NOPROBES	{ 0x69 } /* avoid i2c probe hangup (why?) */
+#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x69} } /* avoid i2c probe hangup (?) */
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	6 /* 24C02 requires 5ms delay */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* I2C boot EEPROM (24C02W)	*/
diff --git a/include/configs/taishan.h b/include/configs/taishan.h
index 3046081..a80eccc 100644
--- a/include/configs/taishan.h
+++ b/include/configs/taishan.h
@@ -133,7 +133,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #undef CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
diff --git a/include/configs/walnut.h b/include/configs/walnut.h
index d10f748..7b97f13 100644
--- a/include/configs/walnut.h
+++ b/include/configs/walnut.h
@@ -95,7 +95,7 @@
  * I2C stuff
  *-----------------------------------------------------------------------
  */
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/xpedite1000.h b/include/configs/xpedite1000.h
index 506d646..8077e39 100644
--- a/include/configs/xpedite1000.h
+++ b/include/configs/xpedite1000.h
@@ -145,11 +145,11 @@ extern void out32(unsigned int, unsigned long);
 /*
  * I2C
  */
-#define CONFIG_HARD_I2C			1	/* I2C with hardware support */
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address */
-#define CONFIG_SYS_I2C_SLAVE		0x7f
-#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7f
 
 /* I2C EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x50
diff --git a/include/configs/yosemite.h b/include/configs/yosemite.h
index 0cbef6f..c0b0177 100644
--- a/include/configs/yosemite.h
+++ b/include/configs/yosemite.h
@@ -137,7 +137,7 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
diff --git a/include/configs/yucca.h b/include/configs/yucca.h
index fb684b5..7311c2d 100644
--- a/include/configs/yucca.h
+++ b/include/configs/yucca.h
@@ -120,13 +120,13 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_SYS_I2C_SPEED		400000	/* I2C speed and slave address	*/
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
 #define IIC0_BOOTPROM_ADDR	0x50
 #define IIC0_ALT_BOOTPROM_ADDR	0x54
 
 /* Don't probe these addrs */
-#define CONFIG_SYS_I2C_NOPROBES	{0x50, 0x52, 0x53, 0x54}
+#define CONFIG_SYS_I2C_NOPROBES	{ {0, 0x50}, {0, 0x52}, {0, 0x53}, {0, 0x54} }
 
 /* #if defined(CONFIG_CMD_EEPROM) */
 /* #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50 */	/* I2C boot EEPROM		*/
diff --git a/include/configs/zeus.h b/include/configs/zeus.h
index 75195bc..b653993 100644
--- a/include/configs/zeus.h
+++ b/include/configs/zeus.h
@@ -168,10 +168,11 @@
 /*-----------------------------------------------------------------------
  * I2C
  *----------------------------------------------------------------------*/
-#define CONFIG_HARD_I2C		1		/* I2C with hardware support	*/
-#define CONFIG_PPC4XX_I2C		/* use PPC4xx driver		*/
-#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_PPC4XX
+#define CONFIG_SYS_I2C_PPC4XX_CH0
+#define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
+#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0		0x7F
 
 /* these are for the ST M24C02 2kbit serial i2c eeprom */
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50		/* base address */
-- 
1.7.11.7

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

* [U-Boot] [PATCH v3 9/9] i2c, ppc4xx_i2c: switch to new multibus/multiadapter support
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 9/9] i2c, ppc4xx_i2c: switch to new multibus/multiadapter support Heiko Schocher
@ 2013-05-06  6:52   ` Stefan Roese
  0 siblings, 0 replies; 104+ messages in thread
From: Stefan Roese @ 2013-05-06  6:52 UTC (permalink / raw)
  To: u-boot

On 05/04/2013 02:01 PM, Heiko Schocher wrote:
> From: Dirk Eibach <dirk.eibach@gdsys.cc>
> 
> Signed-off-by: Dirk Eibach <dirk.eibach@gdsys.cc>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Stefan Roese <sr@denx.de>

Heiko & Dirk, thanks for this work.

I tested this patch-set on sequoia and canyonlands. No problems
detected. So:

Tested-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
                   ` (8 preceding siblings ...)
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 9/9] i2c, ppc4xx_i2c: switch to new multibus/multiadapter support Heiko Schocher
@ 2013-05-06  8:57 ` Dirk Eibach
  2013-05-06 14:11   ` Heiko Schocher
  2013-05-17 13:17 ` Piotr Wilczek
  10 siblings, 1 reply; 104+ messages in thread
From: Dirk Eibach @ 2013-05-06  8:57 UTC (permalink / raw)
  To: u-boot

Hello Heiko,

Am 04.05.2013 14:01, schrieb Heiko Schocher:
> It seems the timing is coming, to bring this finally in mainline
> and move boards over to the new i2c framework.
> 
> Changes for v3 series:
> 
> - Compiler collects the used i2c adapters in _u_boot_list_i2c,
>   so no need for defining the used i2c adpaters in the board config 
> file.
>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
> - Some adaptions for the keymile boards, so we can drop CONFIG_I2C_MUX
>   completely
> - add ppc4xx_i2c driver, ported from Dirk Eibach
> 
> Serie compiles clean on arm and powerpc
> 
> Ported i2c drivers:
> soft_i2c  : from me, tested on some arm and powerpc boards
> fsl_i2c   : from me, only compile tested
> tegra_i2c : ported from Simon Glass
> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
>             tested on (which board?) with 4 soft_i2c drivers
>             and one ppc4x_i2c driver.

great to see you finally made it.
Testing was done on our iocon platform (which was the reason I started 
the ppc4xx adaption). I will rebase on your patchset and post our ppc4xx 
series again.

Cheers
Dirk

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

* [U-Boot] [PATCH v3 5/9] i2c, multibus: get rid of CONFIG_I2C_MUX
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 5/9] i2c, multibus: get rid of CONFIG_I2C_MUX Heiko Schocher
@ 2013-05-06 12:23   ` Holger Brunck
  2013-05-06 13:57     ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Holger Brunck @ 2013-05-06 12:23 UTC (permalink / raw)
  To: u-boot

On 05/04/2013 02:01 PM, Heiko Schocher wrote:
> CONFIG_I2C_MUX is replaced through the new i2c multibus/multiadapter
> framework, configured through CONFIG_SYS_I2C. As CONFIG_I2C_MUX
> is only used on the keymile boards, and they are now completely
> moved to the new framework, remove CONFIG_I2C_MUX.
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Cc: Holger Brunck <holger.brunck@keymile.com>
> 
> ---
> - changes for v2:
>   new in v2

Tested on mgcoge (MPC8247) and km_kirkwood (Kirkwood), feel free to add my:

Tested-By: Holger Brunck <holger.brunck@keymile.com>

Regards
Holger

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

* [U-Boot] [PATCH v3 6/9] i2c, multibus, keymile: get rid of EEprom_ivm envvariable
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 6/9] i2c, multibus, keymile: get rid of EEprom_ivm envvariable Heiko Schocher
@ 2013-05-06 12:24   ` Holger Brunck
  2013-05-06 13:58     ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Holger Brunck @ 2013-05-06 12:24 UTC (permalink / raw)
  To: u-boot

On 05/04/2013 02:01 PM, Heiko Schocher wrote:
> as the keymile boards use now the new i2c multibus/multiadapter
> framework, remove the EEprom_ivm Environmentvar, as not longer
> needed.
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Cc: Holger Brunck <holger.brunck@keymile.com>
> 


Tested on mgcoge (MPC8247) and km_kirkwood (Kirkwood), feel free to add my:

Tested-By: Holger Brunck <holger.brunck@keymile.com>

Regards
Holger

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

* [U-Boot] [PATCH v3 5/9] i2c, multibus: get rid of CONFIG_I2C_MUX
  2013-05-06 12:23   ` Holger Brunck
@ 2013-05-06 13:57     ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-06 13:57 UTC (permalink / raw)
  To: u-boot

Hello Holger,

Am 06.05.2013 14:23, schrieb Holger Brunck:
> On 05/04/2013 02:01 PM, Heiko Schocher wrote:
>> CONFIG_I2C_MUX is replaced through the new i2c multibus/multiadapter
>> framework, configured through CONFIG_SYS_I2C. As CONFIG_I2C_MUX
>> is only used on the keymile boards, and they are now completely
>> moved to the new framework, remove CONFIG_I2C_MUX.
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> Cc: Holger Brunck <holger.brunck@keymile.com>
>>
>> ---
>> - changes for v2:
>>   new in v2
> 
> Tested on mgcoge (MPC8247) and km_kirkwood (Kirkwood), feel free to add my:
> 
> Tested-By: Holger Brunck <holger.brunck@keymile.com>

Thanks for testing!

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] 104+ messages in thread

* [U-Boot] [PATCH v3 6/9] i2c, multibus, keymile: get rid of EEprom_ivm envvariable
  2013-05-06 12:24   ` Holger Brunck
@ 2013-05-06 13:58     ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-06 13:58 UTC (permalink / raw)
  To: u-boot

Hello Holger,

Am 06.05.2013 14:24, schrieb Holger Brunck:
> On 05/04/2013 02:01 PM, Heiko Schocher wrote:
>> as the keymile boards use now the new i2c multibus/multiadapter
>> framework, remove the EEprom_ivm Environmentvar, as not longer
>> needed.
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> Cc: Holger Brunck <holger.brunck@keymile.com>
>>
> 
> 
> Tested on mgcoge (MPC8247) and km_kirkwood (Kirkwood), feel free to add my:
> 
> Tested-By: Holger Brunck <holger.brunck@keymile.com>

Thanks for testing!

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] 104+ messages in thread

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-05-06  8:57 ` [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Dirk Eibach
@ 2013-05-06 14:11   ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-06 14:11 UTC (permalink / raw)
  To: u-boot

Hello Dirk,

Am 06.05.2013 10:57, schrieb Dirk Eibach:
> Hello Heiko,
> 
> Am 04.05.2013 14:01, schrieb Heiko Schocher:
>> It seems the timing is coming, to bring this finally in mainline
>> and move boards over to the new i2c framework.
>>
>> Changes for v3 series:
>>
>> - Compiler collects the used i2c adapters in _u_boot_list_i2c,
>>   so no need for defining the used i2c adpaters in the board config 
>> file.
>>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
>> - Some adaptions for the keymile boards, so we can drop CONFIG_I2C_MUX
>>   completely
>> - add ppc4xx_i2c driver, ported from Dirk Eibach
>>
>> Serie compiles clean on arm and powerpc
>>
>> Ported i2c drivers:
>> soft_i2c  : from me, tested on some arm and powerpc boards
>> fsl_i2c   : from me, only compile tested
>> tegra_i2c : ported from Simon Glass
>> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
>>             tested on (which board?) with 4 soft_i2c drivers
>>             and one ppc4x_i2c driver.
> 
> great to see you finally made it.
> Testing was done on our iocon platform (which was the reason I started 
> the ppc4xx adaption). I will rebase on your patchset and post our ppc4xx 
> series again.

Thanks for your work!

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] 104+ messages in thread

* [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support Heiko Schocher
@ 2013-05-06 16:39   ` Daniel Schwierzeck
  2013-05-07 13:05     ` Heiko Schocher
  2013-05-11 21:17   ` Simon Glass
  2013-05-11 21:33   ` Simon Glass
  2 siblings, 1 reply; 104+ messages in thread
From: Daniel Schwierzeck @ 2013-05-06 16:39 UTC (permalink / raw)
  To: u-boot

2013/5/4 Heiko Schocher <hs@denx.de>
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Cc: Henrik Nordstr?m <henrik@henriknordstrom.net>
>
> ---
> - changes for v2:
>   add comment from Henrik Nordstr?m <henrik@henriknordstrom.net>
>   remove wrong line in README
>   - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
> - changes for v3:
>   - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
>   - fix Codingstyle issues
>   - adapt README
> ---
>  README                          |  74 ++++++++++++++++++++++++-
>  arch/arm/lib/board.c            |   7 ++-
>  arch/blackfin/lib/board.c       |   7 +++
>  arch/m68k/lib/board.c           |  17 +++++-
>  arch/mips/lib/board.c           |   7 +++
>  arch/nds32/lib/board.c          |  10 +++-
>  arch/powerpc/cpu/mpc8xx/video.c |   4 ++
>  arch/powerpc/lib/board.c        |  12 +++-
>  common/cmd_date.c               |   9 +++
>  common/cmd_dtt.c                |   9 +++
>  common/cmd_i2c.c                | 120 ++++++++++++++++++++++++++--------------
>  common/env_eeprom.c             |  14 +++++
>  common/stdio.c                  |  13 ++++-
>  include/i2c.h                   |   9 ---
>  14 Dateien ge?ndert, 251 Zeilen hinzugef?gt(+), 61 Zeilen entfernt(-)
>
...
>
>
> diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
> index f19f198..fedac71 100644
> --- a/arch/mips/lib/board.c
> +++ b/arch/mips/lib/board.c
> @@ -36,6 +36,9 @@
>  #ifdef CONFIG_BITBANGMII
>  #include <miiphy.h>
>  #endif
> +#if defined(CONFIG_SYS_I2C)
> +#include <i2c.h>
> +#endif
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -296,6 +299,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
>         onenand_init();
>  #endif
>
> +#if defined(CONFIG_SYS_I2C)
> +       i2c_reloc_fixup();
> +#endif
> +
>

MIPS doesn't need manual relocation fixups anymore. So you could use
i2c_init_all() here too.

--
Best regards,
Daniel

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework Heiko Schocher
@ 2013-05-06 19:08   ` Stephen Warren
  2013-05-07  8:01     ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2Cframework Marc Dietrich
                       ` (2 more replies)
  2013-07-29 16:12   ` Stephen Warren
  1 sibling, 3 replies; 104+ messages in thread
From: Stephen Warren @ 2013-05-06 19:08 UTC (permalink / raw)
  To: u-boot

On 05/04/2013 06:01 AM, Heiko Schocher wrote:
> From: Simon Glass <sjg@chromium.org>
> 
> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the Tegra
> i2c driver to support this.

>  include/configs/beaver.h    |  5 ++-
>  include/configs/cardhu.h    |  3 +-
>  include/configs/dalmore.h   |  3 +-
>  include/configs/seaboard.h  |  5 ++-
>  include/configs/trimslice.h |  5 ++-
>  include/configs/whistler.h  |  5 ++-

There are a lot more Tegra boards than just those. Shouldn't they all be
updated? You also didn't Cc the Tegra maintainer - I have done on this mail.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2Cframework
  2013-05-06 19:08   ` Stephen Warren
@ 2013-05-07  8:01     ` Marc Dietrich
  2013-05-07 14:55       ` Stephen Warren
  2013-05-07 13:07     ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework Heiko Schocher
       [not found]     ` <5FBF8E85CA34454794F0F7ECBA79798F37ACAFEF3F@HQMAIL04.nvidia.com>
  2 siblings, 1 reply; 104+ messages in thread
From: Marc Dietrich @ 2013-05-07  8:01 UTC (permalink / raw)
  To: u-boot

Hi,

Am Montag, 6. Mai 2013, 13:08:31 schrieb Stephen Warren:
> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
> > From: Simon Glass <sjg@chromium.org>
> > 
> > This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the
> > Tegra i2c driver to support this.
> > 
> >  include/configs/beaver.h    |  5 ++-
> >  include/configs/cardhu.h    |  3 +-
> >  include/configs/dalmore.h   |  3 +-
> >  include/configs/seaboard.h  |  5 ++-
> >  include/configs/trimslice.h |  5 ++-
> >  include/configs/whistler.h  |  5 ++-
> 
> There are a lot more Tegra boards than just those. Shouldn't they all be
> updated? You also didn't Cc the Tegra maintainer - I have done on this mail.

not all boards use I2C up to now, to the patch seems to change only the boards 
which do. So this is ok for now. The question is if CONFIG_SYS_I2C could be 
moved to tegra_common or so because the device-tree disables I2C be default.

Marc

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

* [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support
  2013-05-06 16:39   ` Daniel Schwierzeck
@ 2013-05-07 13:05     ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-07 13:05 UTC (permalink / raw)
  To: u-boot

Hello Daniel,

Am 06.05.2013 18:39, schrieb Daniel Schwierzeck:
> 2013/5/4 Heiko Schocher <hs@denx.de>
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> Cc: Henrik Nordstr?m <henrik@henriknordstrom.net>
>>
>> ---
>> - changes for v2:
>>   add comment from Henrik Nordstr?m <henrik@henriknordstrom.net>
>>   remove wrong line in README
>>   - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
>> - changes for v3:
>>   - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
>>   - fix Codingstyle issues
>>   - adapt README
>> ---
>>  README                          |  74 ++++++++++++++++++++++++-
>>  arch/arm/lib/board.c            |   7 ++-
>>  arch/blackfin/lib/board.c       |   7 +++
>>  arch/m68k/lib/board.c           |  17 +++++-
>>  arch/mips/lib/board.c           |   7 +++
>>  arch/nds32/lib/board.c          |  10 +++-
>>  arch/powerpc/cpu/mpc8xx/video.c |   4 ++
>>  arch/powerpc/lib/board.c        |  12 +++-
>>  common/cmd_date.c               |   9 +++
>>  common/cmd_dtt.c                |   9 +++
>>  common/cmd_i2c.c                | 120 ++++++++++++++++++++++++++--------------
>>  common/env_eeprom.c             |  14 +++++
>>  common/stdio.c                  |  13 ++++-
>>  include/i2c.h                   |   9 ---
>>  14 Dateien ge?ndert, 251 Zeilen hinzugef?gt(+), 61 Zeilen entfernt(-)
>>
> ...
>>
>>
>> diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
>> index f19f198..fedac71 100644
>> --- a/arch/mips/lib/board.c
>> +++ b/arch/mips/lib/board.c
>> @@ -36,6 +36,9 @@
>>  #ifdef CONFIG_BITBANGMII
>>  #include <miiphy.h>
>>  #endif
>> +#if defined(CONFIG_SYS_I2C)
>> +#include <i2c.h>
>> +#endif
>>
>>  DECLARE_GLOBAL_DATA_PTR;
>>
>> @@ -296,6 +299,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
>>         onenand_init();
>>  #endif
>>
>> +#if defined(CONFIG_SYS_I2C)
>> +       i2c_reloc_fixup();
>> +#endif
>> +
>>
> 
> MIPS doesn't need manual relocation fixups anymore. So you could use
> i2c_init_all() here too.

Ok, removed this ... Hmm.. can you test this changes on a
mips board?

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-05-06 19:08   ` Stephen Warren
  2013-05-07  8:01     ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2Cframework Marc Dietrich
@ 2013-05-07 13:07     ` Heiko Schocher
       [not found]     ` <5FBF8E85CA34454794F0F7ECBA79798F37ACAFEF3F@HQMAIL04.nvidia.com>
  2 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-07 13:07 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 06.05.2013 21:08, schrieb Stephen Warren:
> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>> From: Simon Glass <sjg@chromium.org>
>>
>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the Tegra
>> i2c driver to support this.
> 
>>  include/configs/beaver.h    |  5 ++-
>>  include/configs/cardhu.h    |  3 +-
>>  include/configs/dalmore.h   |  3 +-
>>  include/configs/seaboard.h  |  5 ++-
>>  include/configs/trimslice.h |  5 ++-
>>  include/configs/whistler.h  |  5 ++-
> 
> There are a lot more Tegra boards than just those. Shouldn't they all be
> updated? You also didn't Cc the Tegra maintainer - I have done on this mail.

I got no compiler warnings ... Hmm.. maybe Simon Glass can help here
more (added to cc), as he did this patch ... 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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
       [not found]     ` <5FBF8E85CA34454794F0F7ECBA79798F37ACAFEF3F@HQMAIL04.nvidia.com>
@ 2013-05-07 13:12       ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-07 13:12 UTC (permalink / raw)
  To: u-boot

Hello Tom,

Am 06.05.2013 21:39, schrieb Tom Warren:
> Thanks, Stephen. Adding Yen, who wrote the original Tegra I2C driver.
> 
>> -----Original Message-----
>> From: Stephen Warren [mailto:swarren at wwwdotorg.org]
>> Sent: Monday, May 06, 2013 12:09 PM
>> To: Heiko Schocher
>> Cc: u-boot at lists.denx.de; Tom Warren
>> Subject: Re: [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C
>> framework
>>
>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>> From: Simon Glass <sjg@chromium.org>
>>>
>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the
>>> Tegra i2c driver to support this.
>>
>>>  include/configs/beaver.h    |  5 ++-
>>>  include/configs/cardhu.h    |  3 +-
>>>  include/configs/dalmore.h   |  3 +-
>>>  include/configs/seaboard.h  |  5 ++-
>>>  include/configs/trimslice.h |  5 ++-
>>>  include/configs/whistler.h  |  5 ++-
>>
>> There are a lot more Tegra boards than just those. Shouldn't they all be
>> updated? You also didn't Cc the Tegra maintainer - I have done on this mail.
> 
> Heiko - please explain what the new CONFIG_SYS_I2C_TEGRA switch does, what it adds to/improves upon for the extant Tegra I2C driver, and what testing you did.

It just convert the existing i2c driver to the new i2c multibus/
multiadapter framework, see the description in the README for
this new define. I add Simon Glass to this, as he did this
patch for the tegra i2c driver. I did only compile tests ...
IIRC Simon did some tests on real HW.

> The boards listed are the only ones w/CONFIG_TEGRA_I2C currently enabled, so I don't think any others need it, until such time as their maintainers need to add I2C support.

Yes, I think so too, as I get no compilerwarning/error when doing
a "MAKEALL arm" ...

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2Cframework
  2013-05-07  8:01     ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2Cframework Marc Dietrich
@ 2013-05-07 14:55       ` Stephen Warren
  2013-05-07 16:17         ` Simon Glass
  2013-05-08  4:11         ` Heiko Schocher
  0 siblings, 2 replies; 104+ messages in thread
From: Stephen Warren @ 2013-05-07 14:55 UTC (permalink / raw)
  To: u-boot

On 05/07/2013 02:01 AM, Marc Dietrich wrote:
> Hi,
> 
> Am Montag, 6. Mai 2013, 13:08:31 schrieb Stephen Warren:
>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>> From: Simon Glass <sjg@chromium.org>
>>>
>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the
>>> Tegra i2c driver to support this.
>>>
>>>  include/configs/beaver.h    |  5 ++-
>>>  include/configs/cardhu.h    |  3 +-
>>>  include/configs/dalmore.h   |  3 +-
>>>  include/configs/seaboard.h  |  5 ++-
>>>  include/configs/trimslice.h |  5 ++-
>>>  include/configs/whistler.h  |  5 ++-
>>
>> There are a lot more Tegra boards than just those. Shouldn't they all be
>> updated? You also didn't Cc the Tegra maintainer - I have done on this mail.
> 
> not all boards use I2C up to now, to the patch seems to change only the boards 
> which do. So this is ok for now. The question is if CONFIG_SYS_I2C could be 
> moved to tegra_common or so because the device-tree disables I2C be default.

Yes, we should do that for all the devices that are now
instantiated/configured using device tree. But, we can do that as a
separate patch series after this.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2Cframework
  2013-05-07 14:55       ` Stephen Warren
@ 2013-05-07 16:17         ` Simon Glass
  2013-05-08  4:11         ` Heiko Schocher
  1 sibling, 0 replies; 104+ messages in thread
From: Simon Glass @ 2013-05-07 16:17 UTC (permalink / raw)
  To: u-boot

Hi,

On Tue, May 7, 2013 at 8:55 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 05/07/2013 02:01 AM, Marc Dietrich wrote:
>> Hi,
>>
>> Am Montag, 6. Mai 2013, 13:08:31 schrieb Stephen Warren:
>>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>>> From: Simon Glass <sjg@chromium.org>
>>>>
>>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the
>>>> Tegra i2c driver to support this.
>>>>
>>>>  include/configs/beaver.h    |  5 ++-
>>>>  include/configs/cardhu.h    |  3 +-
>>>>  include/configs/dalmore.h   |  3 +-
>>>>  include/configs/seaboard.h  |  5 ++-
>>>>  include/configs/trimslice.h |  5 ++-
>>>>  include/configs/whistler.h  |  5 ++-
>>>
>>> There are a lot more Tegra boards than just those. Shouldn't they all be
>>> updated? You also didn't Cc the Tegra maintainer - I have done on this mail.
>>
>> not all boards use I2C up to now, to the patch seems to change only the boards
>> which do. So this is ok for now. The question is if CONFIG_SYS_I2C could be
>> moved to tegra_common or so because the device-tree disables I2C be default.
>
> Yes, we should do that for all the devices that are now
> instantiated/configured using device tree. But, we can do that as a
> separate patch series after this.

I don't have anything to add to this - I did the Tegra patch a long
time ago when this was last posted, and it was tested on Seaboard at
the time.

I'll make time to review and test the series at least on snow.

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2Cframework
  2013-05-07 14:55       ` Stephen Warren
  2013-05-07 16:17         ` Simon Glass
@ 2013-05-08  4:11         ` Heiko Schocher
  1 sibling, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-08  4:11 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 07.05.2013 16:55, schrieb Stephen Warren:
> On 05/07/2013 02:01 AM, Marc Dietrich wrote:
>> Hi,
>>
>> Am Montag, 6. Mai 2013, 13:08:31 schrieb Stephen Warren:
>>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>>> From: Simon Glass <sjg@chromium.org>
>>>>
>>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the
>>>> Tegra i2c driver to support this.
>>>>
>>>>  include/configs/beaver.h    |  5 ++-
>>>>  include/configs/cardhu.h    |  3 +-
>>>>  include/configs/dalmore.h   |  3 +-
>>>>  include/configs/seaboard.h  |  5 ++-
>>>>  include/configs/trimslice.h |  5 ++-
>>>>  include/configs/whistler.h  |  5 ++-
>>>
>>> There are a lot more Tegra boards than just those. Shouldn't they all be
>>> updated? You also didn't Cc the Tegra maintainer - I have done on this mail.
>>
>> not all boards use I2C up to now, to the patch seems to change only the boards 
>> which do. So this is ok for now. The question is if CONFIG_SYS_I2C could be 
>> moved to tegra_common or so because the device-tree disables I2C be default.
> 
> Yes, we should do that for all the devices that are now
> instantiated/configured using device tree. But, we can do that as a
> separate patch series after this.

Yes, that makes sense.

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] 104+ messages in thread

* [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support Heiko Schocher
  2013-05-06 16:39   ` Daniel Schwierzeck
@ 2013-05-11 21:17   ` Simon Glass
  2013-05-13  4:47     ` Heiko Schocher
  2013-05-11 21:33   ` Simon Glass
  2 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-05-11 21:17 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Sat, May 4, 2013 at 6:01 AM, Heiko Schocher <hs@denx.de> wrote:
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Cc: Henrik Nordstr?m <henrik@henriknordstrom.net>
>
> ---
> - changes for v2:
>   add comment from Henrik Nordstr?m <henrik@henriknordstrom.net>
>   remove wrong line in README
>   - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
> - changes for v3:
>   - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
>   - fix Codingstyle issues
>   - adapt README
> ---
>  README                          |  74 ++++++++++++++++++++++++-
>  arch/arm/lib/board.c            |   7 ++-
>  arch/blackfin/lib/board.c       |   7 +++
>  arch/m68k/lib/board.c           |  17 +++++-
>  arch/mips/lib/board.c           |   7 +++
>  arch/nds32/lib/board.c          |  10 +++-
>  arch/powerpc/cpu/mpc8xx/video.c |   4 ++
>  arch/powerpc/lib/board.c        |  12 +++-
>  common/cmd_date.c               |   9 +++
>  common/cmd_dtt.c                |   9 +++
>  common/cmd_i2c.c                | 120 ++++++++++++++++++++++++++--------------
>  common/env_eeprom.c             |  14 +++++
>  common/stdio.c                  |  13 ++++-
>  include/i2c.h                   |   9 ---
>  14 Dateien ge?ndert, 251 Zeilen hinzugef?gt(+), 61 Zeilen entfernt(-)

Very happy to see this again.

Do you also need to change common/board_f.c or common/board_r.c?

Regards,
Simon

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

* [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support Heiko Schocher
  2013-05-06 16:39   ` Daniel Schwierzeck
  2013-05-11 21:17   ` Simon Glass
@ 2013-05-11 21:33   ` Simon Glass
  2013-05-13  5:41     ` Heiko Schocher
  2 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-05-11 21:33 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Sat, May 4, 2013 at 6:01 AM, Heiko Schocher <hs@denx.de> wrote:
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Cc: Henrik Nordstr?m <henrik@henriknordstrom.net>
>
> ---
> - changes for v2:
>   add comment from Henrik Nordstr?m <henrik@henriknordstrom.net>
>   remove wrong line in README
>   - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
> - changes for v3:
>   - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
>   - fix Codingstyle issues
>   - adapt README
> ---
>  README                          |  74 ++++++++++++++++++++++++-
>  arch/arm/lib/board.c            |   7 ++-
>  arch/blackfin/lib/board.c       |   7 +++
>  arch/m68k/lib/board.c           |  17 +++++-
>  arch/mips/lib/board.c           |   7 +++
>  arch/nds32/lib/board.c          |  10 +++-
>  arch/powerpc/cpu/mpc8xx/video.c |   4 ++
>  arch/powerpc/lib/board.c        |  12 +++-
>  common/cmd_date.c               |   9 +++
>  common/cmd_dtt.c                |   9 +++
>  common/cmd_i2c.c                | 120 ++++++++++++++++++++++++++--------------
>  common/env_eeprom.c             |  14 +++++
>  common/stdio.c                  |  13 ++++-
>  include/i2c.h                   |   9 ---
>  14 Dateien ge?ndert, 251 Zeilen hinzugef?gt(+), 61 Zeilen entfernt(-)
>

...
> diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
> index 4380794..d59f10d 100644

> @@ -1508,16 +1543,21 @@ 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 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 defined(CONFIG_SYS_I2C) || \
> +       defined(CONFIG_I2C_MULTI_BUS)
>         U_BOOT_CMD_MKENT(dev, 1, 1, do_i2c_bus_num, "", ""),

If you are changing the condition here you should change the condition
on the help also.

>  #endif  /* CONFIG_I2C_MULTI_BUS */
>  #if defined(CONFIG_I2C_EDID)
> @@ -1576,11 +1616,11 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
>  /***************************************************/
>  #ifdef CONFIG_SYS_LONGHELP
>  static char i2c_help_text[] =
> -#if defined(CONFIG_I2C_MUX)
> -       "bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\ni2c "
> +#if defined(CONFIG_SYS_I2C)
> +       "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 defined(CONFIG_SYS_I2C)
>         "i2c dev [dev] - show or set current I2C bus\n"
>  #endif  /* CONFIG_I2C_MULTI_BUS */
>  #if defined(CONFIG_I2C_EDID)
> diff --git a/common/env_eeprom.c b/common/env_eeprom.c
> index 45c935b..fbd459a 100644

I tested this on snow and it seems to disable every bus except bus 0.
I will see if I can take a look.

Hopefully one of the Nvidia guys can test on seaboard as I don't have
mind with me right now.

SMDK5250 # i2c dev 4
Invalid bus 4

Regards,
Simon

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

* [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support
  2013-05-11 21:17   ` Simon Glass
@ 2013-05-13  4:47     ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-13  4:47 UTC (permalink / raw)
  To: u-boot

Hello Simon,

Am 11.05.2013 23:17, schrieb Simon Glass:
> Hi Heiko,
> 
> On Sat, May 4, 2013 at 6:01 AM, Heiko Schocher <hs@denx.de> wrote:
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> Cc: Henrik Nordstr?m <henrik@henriknordstrom.net>
>>
>> ---
>> - changes for v2:
>>   add comment from Henrik Nordstr?m <henrik@henriknordstrom.net>
>>   remove wrong line in README
>>   - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
>> - changes for v3:
>>   - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
>>   - fix Codingstyle issues
>>   - adapt README
>> ---
>>  README                          |  74 ++++++++++++++++++++++++-
>>  arch/arm/lib/board.c            |   7 ++-
>>  arch/blackfin/lib/board.c       |   7 +++
>>  arch/m68k/lib/board.c           |  17 +++++-
>>  arch/mips/lib/board.c           |   7 +++
>>  arch/nds32/lib/board.c          |  10 +++-
>>  arch/powerpc/cpu/mpc8xx/video.c |   4 ++
>>  arch/powerpc/lib/board.c        |  12 +++-
>>  common/cmd_date.c               |   9 +++
>>  common/cmd_dtt.c                |   9 +++
>>  common/cmd_i2c.c                | 120 ++++++++++++++++++++++++++--------------
>>  common/env_eeprom.c             |  14 +++++
>>  common/stdio.c                  |  13 ++++-
>>  include/i2c.h                   |   9 ---
>>  14 Dateien ge?ndert, 251 Zeilen hinzugef?gt(+), 61 Zeilen entfernt(-)
> 
> Very happy to see this again.
> 
> Do you also need to change common/board_f.c or common/board_r.c?

Uh.. yes, you are right, fix this!

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] 104+ messages in thread

* [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support
  2013-05-11 21:33   ` Simon Glass
@ 2013-05-13  5:41     ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-05-13  5:41 UTC (permalink / raw)
  To: u-boot

Hello Simon,

Am 11.05.2013 23:33, schrieb Simon Glass:
> Hi Heiko,
> 
> On Sat, May 4, 2013 at 6:01 AM, Heiko Schocher <hs@denx.de> wrote:
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> Cc: Henrik Nordstr?m <henrik@henriknordstrom.net>
>>
>> ---
>> - changes for v2:
>>   add comment from Henrik Nordstr?m <henrik@henriknordstrom.net>
>>   remove wrong line in README
>>   - rebase against current mainline 178d0cc1a4c73c3341afbeb2a93b172de8c96bd1
>> - changes for v3:
>>   - adapt to the new introduced U_BOOT_I2C_ADAP_COMPLETE define
>>   - fix Codingstyle issues
>>   - adapt README
>> ---
>>  README                          |  74 ++++++++++++++++++++++++-
>>  arch/arm/lib/board.c            |   7 ++-
>>  arch/blackfin/lib/board.c       |   7 +++
>>  arch/m68k/lib/board.c           |  17 +++++-
>>  arch/mips/lib/board.c           |   7 +++
>>  arch/nds32/lib/board.c          |  10 +++-
>>  arch/powerpc/cpu/mpc8xx/video.c |   4 ++
>>  arch/powerpc/lib/board.c        |  12 +++-
>>  common/cmd_date.c               |   9 +++
>>  common/cmd_dtt.c                |   9 +++
>>  common/cmd_i2c.c                | 120 ++++++++++++++++++++++++++--------------
>>  common/env_eeprom.c             |  14 +++++
>>  common/stdio.c                  |  13 ++++-
>>  include/i2c.h                   |   9 ---
>>  14 Dateien ge?ndert, 251 Zeilen hinzugef?gt(+), 61 Zeilen entfernt(-)
>>
> 
> ...
>> diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
>> index 4380794..d59f10d 100644
> 
>> @@ -1508,16 +1543,21 @@ 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 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 defined(CONFIG_SYS_I2C) || \
>> +       defined(CONFIG_I2C_MULTI_BUS)
>>         U_BOOT_CMD_MKENT(dev, 1, 1, do_i2c_bus_num, "", ""),
> 
> If you are changing the condition here you should change the condition
> on the help also.

Fixed.

>>  #endif  /* CONFIG_I2C_MULTI_BUS */
>>  #if defined(CONFIG_I2C_EDID)
>> @@ -1576,11 +1616,11 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
>>  /***************************************************/
>>  #ifdef CONFIG_SYS_LONGHELP
>>  static char i2c_help_text[] =
>> -#if defined(CONFIG_I2C_MUX)
>> -       "bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\ni2c "
>> +#if defined(CONFIG_SYS_I2C)
>> +       "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 defined(CONFIG_SYS_I2C)
>>         "i2c dev [dev] - show or set current I2C bus\n"
>>  #endif  /* CONFIG_I2C_MULTI_BUS */
>>  #if defined(CONFIG_I2C_EDID)
>> diff --git a/common/env_eeprom.c b/common/env_eeprom.c
>> index 45c935b..fbd459a 100644
> 
> I tested this on snow and it seems to disable every bus except bus 0.
> I will see if I can take a look.

Bad news ... did you tried it with debug traces enabled?

> Hopefully one of the Nvidia guys can test on seaboard as I don't have
> mind with me right now.
> 
> SMDK5250 # i2c dev 4
> Invalid bus 4

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] 104+ messages in thread

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
                   ` (9 preceding siblings ...)
  2013-05-06  8:57 ` [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Dirk Eibach
@ 2013-05-17 13:17 ` Piotr Wilczek
  2013-05-18 17:41   ` Simon Glass
  10 siblings, 1 reply; 104+ messages in thread
From: Piotr Wilczek @ 2013-05-17 13:17 UTC (permalink / raw)
  To: u-boot

Dear Heiko,

> -----Original Message-----
> From: Heiko Schocher [mailto:hs at denx.de]
> Sent: Saturday, May 04, 2013 2:02 PM
> To: u-boot at lists.denx.de
> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass; Piotr
> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
> Subject: [PATCH v3 0/9] Bring in new I2C framework
> 
> It seems the timing is coming, to bring this finally in mainline and
> move boards over to the new i2c framework.
> 
> Changes for v3 series:
> 
> - Compiler collects the used i2c adapters in _u_boot_list_i2c,
>   so no need for defining the used i2c adpaters in the board config
> file.
>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
> - Some adaptions for the keymile boards, so we can drop CONFIG_I2C_MUX
>   completely
> - add ppc4xx_i2c driver, ported from Dirk Eibach
> 
> Serie compiles clean on arm and powerpc
> 
> Ported i2c drivers:
> soft_i2c  : from me, tested on some arm and powerpc boards
> fsl_i2c   : from me, only compile tested
> tegra_i2c : ported from Simon Glass
> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
>             tested on (which board?) with 4 soft_i2c drivers
>             and one ppc4x_i2c driver.
> 
> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Piotr Wilczek <p.wilczek@samsung.com>
> Cc: Holger Brunck <holger.brunck@keymile.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
> Cc: Stephen Warren <swarren@wwwdotorg.org>
> 

I ported s3c24x0_i2c driver and tested this framework on Samsung tree on Trats2 board.

Best regards,
Piotr Wilczek

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-05-17 13:17 ` Piotr Wilczek
@ 2013-05-18 17:41   ` Simon Glass
  2013-05-20  6:13     ` Piotr Wilczek
  0 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-05-18 17:41 UTC (permalink / raw)
  To: u-boot

Hi Piotr,

On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek <p.wilczek@samsung.com> wrote:
> Dear Heiko,
>
>> -----Original Message-----
>> From: Heiko Schocher [mailto:hs at denx.de]
>> Sent: Saturday, May 04, 2013 2:02 PM
>> To: u-boot at lists.denx.de
>> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass; Piotr
>> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
>> Subject: [PATCH v3 0/9] Bring in new I2C framework
>>
>> It seems the timing is coming, to bring this finally in mainline and
>> move boards over to the new i2c framework.
>>
>> Changes for v3 series:
>>
>> - Compiler collects the used i2c adapters in _u_boot_list_i2c,
>>   so no need for defining the used i2c adpaters in the board config
>> file.
>>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
>> - Some adaptions for the keymile boards, so we can drop CONFIG_I2C_MUX
>>   completely
>> - add ppc4xx_i2c driver, ported from Dirk Eibach
>>
>> Serie compiles clean on arm and powerpc
>>
>> Ported i2c drivers:
>> soft_i2c  : from me, tested on some arm and powerpc boards
>> fsl_i2c   : from me, only compile tested
>> tegra_i2c : ported from Simon Glass
>> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
>>             tested on (which board?) with 4 soft_i2c drivers
>>             and one ppc4x_i2c driver.
>>
>> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
>> Cc: Stefan Roese <sr@denx.de>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: Piotr Wilczek <p.wilczek@samsung.com>
>> Cc: Holger Brunck <holger.brunck@keymile.com>
>> Cc: Mike Frysinger <vapier@gentoo.org>
>> Cc: Stephen Warren <swarren@wwwdotorg.org>
>>
>
> I ported s3c24x0_i2c driver and tested this framework on Samsung tree on Trats2 board.

Please can you send a patch for this port?

>
> Best regards,
> Piotr Wilczek
>
>
>

Regards,
Simon

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-05-18 17:41   ` Simon Glass
@ 2013-05-20  6:13     ` Piotr Wilczek
  2013-06-19 22:07       ` Simon Glass
  0 siblings, 1 reply; 104+ messages in thread
From: Piotr Wilczek @ 2013-05-20  6:13 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
> Sent: Saturday, May 18, 2013 7:41 PM
> To: Piotr Wilczek
> Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan Roese;
> Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
> Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> 
> Hi Piotr,
> 
> On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek <p.wilczek@samsung.com>
> wrote:
> > Dear Heiko,
> >
> >> -----Original Message-----
> >> From: Heiko Schocher [mailto:hs at denx.de]
> >> Sent: Saturday, May 04, 2013 2:02 PM
> >> To: u-boot at lists.denx.de
> >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass; Piotr
> >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
> >> Subject: [PATCH v3 0/9] Bring in new I2C framework
> >>
> >> It seems the timing is coming, to bring this finally in mainline and
> >> move boards over to the new i2c framework.
> >>
> >> Changes for v3 series:
> >>
> >> - Compiler collects the used i2c adapters in _u_boot_list_i2c,
> >>   so no need for defining the used i2c adpaters in the board config
> >> file.
> >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
> >> - Some adaptions for the keymile boards, so we can drop
> CONFIG_I2C_MUX
> >>   completely
> >> - add ppc4xx_i2c driver, ported from Dirk Eibach
> >>
> >> Serie compiles clean on arm and powerpc
> >>
> >> Ported i2c drivers:
> >> soft_i2c  : from me, tested on some arm and powerpc boards
> >> fsl_i2c   : from me, only compile tested
> >> tegra_i2c : ported from Simon Glass
> >> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
> >>             tested on (which board?) with 4 soft_i2c drivers
> >>             and one ppc4x_i2c driver.
> >>
> >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
> >> Cc: Stefan Roese <sr@denx.de>
> >> Cc: Simon Glass <sjg@chromium.org>
> >> Cc: Piotr Wilczek <p.wilczek@samsung.com>
> >> Cc: Holger Brunck <holger.brunck@keymile.com>
> >> Cc: Mike Frysinger <vapier@gentoo.org>
> >> Cc: Stephen Warren <swarren@wwwdotorg.org>
> >>
> >
> > I ported s3c24x0_i2c driver and tested this framework on Samsung tree
> on Trats2 board.
> 
> Please can you send a patch for this port?

I posted that patch and some others with series introducing Trsts2, where I
want to use this framework.
I'm sorry I didn't mention it in my first mail.
http://patchwork.ozlabs.org/patch/244645/
http://patchwork.ozlabs.org/patch/244644/
.
http://patchwork.ozlabs.org/patch/244638/
http://patchwork.ozlabs.org/patch/244637/
http://patchwork.ozlabs.org/patch/244640/
http://patchwork.ozlabs.org/patch/244636/

> 
> >
> > Best regards,
> > Piotr Wilczek
> >
> >
> >
> 
> Regards,
> Simon

Best regards,
Piotr

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-05-20  6:13     ` Piotr Wilczek
@ 2013-06-19 22:07       ` Simon Glass
  2013-06-20  3:38         ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-06-19 22:07 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Sun, May 19, 2013 at 11:13 PM, Piotr Wilczek <p.wilczek@samsung.com>wrote:

> Hi Simon,
>
> > -----Original Message-----
> > From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
> > Sent: Saturday, May 18, 2013 7:41 PM
> > To: Piotr Wilczek
> > Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan Roese;
> > Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
> > Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> >
> > Hi Piotr,
> >
> > On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek <p.wilczek@samsung.com>
> > wrote:
> > > Dear Heiko,
> > >
> > >> -----Original Message-----
> > >> From: Heiko Schocher [mailto:hs at denx.de]
> > >> Sent: Saturday, May 04, 2013 2:02 PM
> > >> To: u-boot at lists.denx.de
> > >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass; Piotr
> > >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
> > >> Subject: [PATCH v3 0/9] Bring in new I2C framework
> > >>
> > >> It seems the timing is coming, to bring this finally in mainline and
> > >> move boards over to the new i2c framework.
> > >>
> > >> Changes for v3 series:
> > >>
> > >> - Compiler collects the used i2c adapters in _u_boot_list_i2c,
> > >>   so no need for defining the used i2c adpaters in the board config
> > >> file.
> > >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
> > >> - Some adaptions for the keymile boards, so we can drop
> > CONFIG_I2C_MUX
> > >>   completely
> > >> - add ppc4xx_i2c driver, ported from Dirk Eibach
> > >>
> > >> Serie compiles clean on arm and powerpc
> > >>
> > >> Ported i2c drivers:
> > >> soft_i2c  : from me, tested on some arm and powerpc boards
> > >> fsl_i2c   : from me, only compile tested
> > >> tegra_i2c : ported from Simon Glass
> > >> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
> > >>             tested on (which board?) with 4 soft_i2c drivers
> > >>             and one ppc4x_i2c driver.
> > >>
> > >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
> > >> Cc: Stefan Roese <sr@denx.de>
> > >> Cc: Simon Glass <sjg@chromium.org>
> > >> Cc: Piotr Wilczek <p.wilczek@samsung.com>
> > >> Cc: Holger Brunck <holger.brunck@keymile.com>
> > >> Cc: Mike Frysinger <vapier@gentoo.org>
> > >> Cc: Stephen Warren <swarren@wwwdotorg.org>
> > >>
> > >
> > > I ported s3c24x0_i2c driver and tested this framework on Samsung tree
> > on Trats2 board.
> >
> > Please can you send a patch for this port?
>
> I posted that patch and some others with series introducing Trsts2, where I
> want to use this framework.
> I'm sorry I didn't mention it in my first mail.
> http://patchwork.ozlabs.org/patch/244645/
> http://patchwork.ozlabs.org/patch/244644/
> .
> http://patchwork.ozlabs.org/patch/244638/
> http://patchwork.ozlabs.org/patch/244637/
> http://patchwork.ozlabs.org/patch/244640/
> http://patchwork.ozlabs.org/patch/244636/
>
>
What is the status of this series now please?

Regards,
Simon

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-19 22:07       ` Simon Glass
@ 2013-06-20  3:38         ` Heiko Schocher
  2013-06-20  5:50           ` Minkyu Kang
                             ` (2 more replies)
  0 siblings, 3 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-06-20  3:38 UTC (permalink / raw)
  To: u-boot

Hello Simon,

Am 20.06.2013 00:07, schrieb Simon Glass:
> Hi Heiko,
> 
> On Sun, May 19, 2013 at 11:13 PM, Piotr Wilczek <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>> wrote:
> 
>     Hi Simon,
> 
>     > -----Original Message-----
>     > From: sjg at google.com <mailto:sjg@google.com> [mailto:sjg at google.com <mailto:sjg@google.com>] On Behalf Of Simon Glass
>     > Sent: Saturday, May 18, 2013 7:41 PM
>     > To: Piotr Wilczek
>     > Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan Roese;
>     > Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
>     > Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
>     >
>     > Hi Piotr,
>     >
>     > On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
>     > wrote:
>     > > Dear Heiko,
>     > >
>     > >> -----Original Message-----
>     > >> From: Heiko Schocher [mailto:hs at denx.de <mailto:hs@denx.de>]
>     > >> Sent: Saturday, May 04, 2013 2:02 PM
>     > >> To: u-boot at lists.denx.de <mailto:u-boot@lists.denx.de>
>     > >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass; Piotr
>     > >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
>     > >> Subject: [PATCH v3 0/9] Bring in new I2C framework
>     > >>
>     > >> It seems the timing is coming, to bring this finally in mainline and
>     > >> move boards over to the new i2c framework.
>     > >>
>     > >> Changes for v3 series:
>     > >>
>     > >> - Compiler collects the used i2c adapters in _u_boot_list_i2c,
>     > >>   so no need for defining the used i2c adpaters in the board config
>     > >> file.
>     > >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
>     > >> - Some adaptions for the keymile boards, so we can drop
>     > CONFIG_I2C_MUX
>     > >>   completely
>     > >> - add ppc4xx_i2c driver, ported from Dirk Eibach
>     > >>
>     > >> Serie compiles clean on arm and powerpc
>     > >>
>     > >> Ported i2c drivers:
>     > >> soft_i2c  : from me, tested on some arm and powerpc boards
>     > >> fsl_i2c   : from me, only compile tested
>     > >> tegra_i2c : ported from Simon Glass
>     > >> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
>     > >>             tested on (which board?) with 4 soft_i2c drivers
>     > >>             and one ppc4x_i2c driver.
>     > >>
>     > >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
>     > >> Cc: Stefan Roese <sr at denx.de <mailto:sr@denx.de>>
>     > >> Cc: Simon Glass <sjg at chromium.org <mailto:sjg@chromium.org>>
>     > >> Cc: Piotr Wilczek <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
>     > >> Cc: Holger Brunck <holger.brunck at keymile.com <mailto:holger.brunck@keymile.com>>
>     > >> Cc: Mike Frysinger <vapier at gentoo.org <mailto:vapier@gentoo.org>>
>     > >> Cc: Stephen Warren <swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>>
>     > >>
>     > >
>     > > I ported s3c24x0_i2c driver and tested this framework on Samsung tree
>     > on Trats2 board.
>     >
>     > Please can you send a patch for this port?
> 
>     I posted that patch and some others with series introducing Trsts2, where I
>     want to use this framework.
>     I'm sorry I didn't mention it in my first mail.
>     http://patchwork.ozlabs.org/patch/244645/
>     http://patchwork.ozlabs.org/patch/244644/
>     .
>     http://patchwork.ozlabs.org/patch/244638/
>     http://patchwork.ozlabs.org/patch/244637/
>     http://patchwork.ozlabs.org/patch/244640/
>     http://patchwork.ozlabs.org/patch/244636/

Hups, missed this patches ...

> What is the status of this series now please?

I heared nothing negatives for the new i2c multibus framework,
so I plan to merge it into mainline, if the next merge widow is
open.

So, the best for above patches would be, If I delegate them
to me, and apply them, when merging the new i2c multibus
support ...

@Minkyu: Is this OK for you?

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] 104+ messages in thread

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  3:38         ` Heiko Schocher
@ 2013-06-20  5:50           ` Minkyu Kang
  2013-06-20  6:41             ` Piotr Wilczek
  2013-06-20  5:52           ` Piotr Wilczek
  2013-06-20  6:52           ` Dirk Eibach
  2 siblings, 1 reply; 104+ messages in thread
From: Minkyu Kang @ 2013-06-20  5:50 UTC (permalink / raw)
  To: u-boot

Dear Heiko,

On 20/06/13 12:38, Heiko Schocher wrote:
> Hello Simon,
> 
> Am 20.06.2013 00:07, schrieb Simon Glass:
>> Hi Heiko,
>>
>> On Sun, May 19, 2013 at 11:13 PM, Piotr Wilczek <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>> wrote:
>>
>>     Hi Simon,
>>
>>     > -----Original Message-----
>>     > From: sjg at google.com <mailto:sjg@google.com> [mailto:sjg at google.com <mailto:sjg@google.com>] On Behalf Of Simon Glass
>>     > Sent: Saturday, May 18, 2013 7:41 PM
>>     > To: Piotr Wilczek
>>     > Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan Roese;
>>     > Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
>>     > Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
>>     >
>>     > Hi Piotr,
>>     >
>>     > On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
>>     > wrote:
>>     > > Dear Heiko,
>>     > >
>>     > >> -----Original Message-----
>>     > >> From: Heiko Schocher [mailto:hs at denx.de <mailto:hs@denx.de>]
>>     > >> Sent: Saturday, May 04, 2013 2:02 PM
>>     > >> To: u-boot at lists.denx.de <mailto:u-boot@lists.denx.de>
>>     > >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass; Piotr
>>     > >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
>>     > >> Subject: [PATCH v3 0/9] Bring in new I2C framework
>>     > >>
>>     > >> It seems the timing is coming, to bring this finally in mainline and
>>     > >> move boards over to the new i2c framework.
>>     > >>
>>     > >> Changes for v3 series:
>>     > >>
>>     > >> - Compiler collects the used i2c adapters in _u_boot_list_i2c,
>>     > >>   so no need for defining the used i2c adpaters in the board config
>>     > >> file.
>>     > >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and CONFIG_SYS_I2C_ADAPTERS
>>     > >> - Some adaptions for the keymile boards, so we can drop
>>     > CONFIG_I2C_MUX
>>     > >>   completely
>>     > >> - add ppc4xx_i2c driver, ported from Dirk Eibach
>>     > >>
>>     > >> Serie compiles clean on arm and powerpc
>>     > >>
>>     > >> Ported i2c drivers:
>>     > >> soft_i2c  : from me, tested on some arm and powerpc boards
>>     > >> fsl_i2c   : from me, only compile tested
>>     > >> tegra_i2c : ported from Simon Glass
>>     > >> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
>>     > >>             tested on (which board?) with 4 soft_i2c drivers
>>     > >>             and one ppc4x_i2c driver.
>>     > >>
>>     > >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
>>     > >> Cc: Stefan Roese <sr at denx.de <mailto:sr@denx.de>>
>>     > >> Cc: Simon Glass <sjg at chromium.org <mailto:sjg@chromium.org>>
>>     > >> Cc: Piotr Wilczek <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
>>     > >> Cc: Holger Brunck <holger.brunck at keymile.com <mailto:holger.brunck@keymile.com>>
>>     > >> Cc: Mike Frysinger <vapier at gentoo.org <mailto:vapier@gentoo.org>>
>>     > >> Cc: Stephen Warren <swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>>
>>     > >>
>>     > >
>>     > > I ported s3c24x0_i2c driver and tested this framework on Samsung tree
>>     > on Trats2 board.
>>     >
>>     > Please can you send a patch for this port?
>>
>>     I posted that patch and some others with series introducing Trsts2, where I
>>     want to use this framework.
>>     I'm sorry I didn't mention it in my first mail.
>>     http://patchwork.ozlabs.org/patch/244645/
>>     http://patchwork.ozlabs.org/patch/244644/
>>     .
>>     http://patchwork.ozlabs.org/patch/244638/
>>     http://patchwork.ozlabs.org/patch/244637/
>>     http://patchwork.ozlabs.org/patch/244640/
>>     http://patchwork.ozlabs.org/patch/244636/
> 
> Hups, missed this patches ...
> 
>> What is the status of this series now please?
> 
> I heared nothing negatives for the new i2c multibus framework,
> so I plan to merge it into mainline, if the next merge widow is
> open.
> 
> So, the best for above patches would be, If I delegate them
> to me, and apply them, when merging the new i2c multibus
> support ...
> 
> @Minkyu: Is this OK for you?

OK..
please pick patches.

> 
> bye,
> Heiko
> 

Thanks,
Minkyu Kang.

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  3:38         ` Heiko Schocher
  2013-06-20  5:50           ` Minkyu Kang
@ 2013-06-20  5:52           ` Piotr Wilczek
  2013-06-20  6:52           ` Dirk Eibach
  2 siblings, 0 replies; 104+ messages in thread
From: Piotr Wilczek @ 2013-06-20  5:52 UTC (permalink / raw)
  To: u-boot

Dear All,

> -----Original Message-----
> From: Heiko Schocher [mailto:hs at denx.de]
> Sent: Thursday, June 20, 2013 5:38 AM
> To: Simon Glass
> Cc: Piotr Wilczek; U-Boot Mailing List; Dirk Eibach; Stefan Roese;
> Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
> Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> 
> Hello Simon,
> 
> Am 20.06.2013 00:07, schrieb Simon Glass:
> > Hi Heiko,
> >
> > On Sun, May 19, 2013 at 11:13 PM, Piotr Wilczek
> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>> wrote:
> >
> >     Hi Simon,
> >
> >     > -----Original Message-----
> >     > From: sjg at google.com <mailto:sjg@google.com>
> [mailto:sjg at google.com <mailto:sjg@google.com>] On Behalf Of Simon
> Glass
> >     > Sent: Saturday, May 18, 2013 7:41 PM
> >     > To: Piotr Wilczek
> >     > Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan
> Roese;
> >     > Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
> >     > Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> >     >
> >     > Hi Piotr,
> >     >
> >     > On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek
> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
> >     > wrote:
> >     > > Dear Heiko,
> >     > >
> >     > >> -----Original Message-----
> >     > >> From: Heiko Schocher [mailto:hs at denx.de <mailto:hs@denx.de>]
> >     > >> Sent: Saturday, May 04, 2013 2:02 PM
> >     > >> To: u-boot at lists.denx.de <mailto:u-boot@lists.denx.de>
> >     > >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass;
> Piotr
> >     > >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
> >     > >> Subject: [PATCH v3 0/9] Bring in new I2C framework
> >     > >>
> >     > >> It seems the timing is coming, to bring this finally in
> mainline and
> >     > >> move boards over to the new i2c framework.
> >     > >>
> >     > >> Changes for v3 series:
> >     > >>
> >     > >> - Compiler collects the used i2c adapters in
> _u_boot_list_i2c,
> >     > >>   so no need for defining the used i2c adpaters in the board
> config
> >     > >> file.
> >     > >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and
> CONFIG_SYS_I2C_ADAPTERS
> >     > >> - Some adaptions for the keymile boards, so we can drop
> >     > CONFIG_I2C_MUX
> >     > >>   completely
> >     > >> - add ppc4xx_i2c driver, ported from Dirk Eibach
> >     > >>
> >     > >> Serie compiles clean on arm and powerpc
> >     > >>
> >     > >> Ported i2c drivers:
> >     > >> soft_i2c  : from me, tested on some arm and powerpc boards
> >     > >> fsl_i2c   : from me, only compile tested
> >     > >> tegra_i2c : ported from Simon Glass
> >     > >> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
> >     > >>             tested on (which board?) with 4 soft_i2c drivers
> >     > >>             and one ppc4x_i2c driver.
> >     > >>
> >     > >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
> >     > >> Cc: Stefan Roese <sr at denx.de <mailto:sr@denx.de>>
> >     > >> Cc: Simon Glass <sjg at chromium.org <mailto:sjg@chromium.org>>
> >     > >> Cc: Piotr Wilczek <p.wilczek@samsung.com
> <mailto:p.wilczek@samsung.com>>
> >     > >> Cc: Holger Brunck <holger.brunck@keymile.com
> <mailto:holger.brunck@keymile.com>>
> >     > >> Cc: Mike Frysinger <vapier@gentoo.org
> <mailto:vapier@gentoo.org>>
> >     > >> Cc: Stephen Warren <swarren@wwwdotorg.org
> <mailto:swarren@wwwdotorg.org>>
> >     > >>
> >     > >
> >     > > I ported s3c24x0_i2c driver and tested this framework on
> Samsung tree
> >     > on Trats2 board.
> >     >
> >     > Please can you send a patch for this port?
> >
> >     I posted that patch and some others with series introducing
> Trsts2, where I
> >     want to use this framework.
> >     I'm sorry I didn't mention it in my first mail.
> >     http://patchwork.ozlabs.org/patch/244645/
> >     http://patchwork.ozlabs.org/patch/244644/
> >     .
> >     http://patchwork.ozlabs.org/patch/244638/
> >     http://patchwork.ozlabs.org/patch/244637/
> >     http://patchwork.ozlabs.org/patch/244640/
> >     http://patchwork.ozlabs.org/patch/244636/
> 
> Hups, missed this patches ...
> 
> > What is the status of this series now please?
> 
> I heared nothing negatives for the new i2c multibus framework, so I
> plan to merge it into mainline, if the next merge widow is open.
> 
> So, the best for above patches would be, If I delegate them to me, and
> apply them, when merging the new i2c multibus support ...
> 

In this patch set I wanted to introduce new board and use the new i2c
framework at the same time.
Because both go through two different tress, I finally decided to use only
software i2c on the new board and switch to the new i2c framework when it is
finally in the mainline. I'm sorry for confusion.

> @Minkyu: Is this OK for you?
> 
> bye,
> Heiko
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Best regards,
Piotr Wilczek

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  5:50           ` Minkyu Kang
@ 2013-06-20  6:41             ` Piotr Wilczek
  2013-06-20  7:14               ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Piotr Wilczek @ 2013-06-20  6:41 UTC (permalink / raw)
  To: u-boot

Dear Heiko,

> -----Original Message-----
> From: Minkyu Kang [mailto:mk7.kang at samsung.com]
> Sent: Thursday, June 20, 2013 7:51 AM
> To: Heiko Schocher
> Cc: Simon Glass; Piotr Wilczek; U-Boot Mailing List; Dirk Eibach;
> Stefan Roese; Holger Brunck; Mike Frysinger; Stephen Warren
> Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> 
> Dear Heiko,
> 
> On 20/06/13 12:38, Heiko Schocher wrote:
> > Hello Simon,
> >
> > Am 20.06.2013 00:07, schrieb Simon Glass:
> >> Hi Heiko,
> >>
> >> On Sun, May 19, 2013 at 11:13 PM, Piotr Wilczek
> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>> wrote:
> >>
> >>     Hi Simon,
> >>
> >>     > -----Original Message-----
> >>     > From: sjg at google.com <mailto:sjg@google.com>
> [mailto:sjg at google.com <mailto:sjg@google.com>] On Behalf Of Simon
> Glass
> >>     > Sent: Saturday, May 18, 2013 7:41 PM
> >>     > To: Piotr Wilczek
> >>     > Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan
> Roese;
> >>     > Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
> >>     > Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> >>     >
> >>     > Hi Piotr,
> >>     >
> >>     > On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek
> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
> >>     > wrote:
> >>     > > Dear Heiko,
> >>     > >
> >>     > >> -----Original Message-----
> >>     > >> From: Heiko Schocher [mailto:hs at denx.de
> <mailto:hs@denx.de>]
> >>     > >> Sent: Saturday, May 04, 2013 2:02 PM
> >>     > >> To: u-boot at lists.denx.de <mailto:u-boot@lists.denx.de>
> >>     > >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass;
> Piotr
> >>     > >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
> >>     > >> Subject: [PATCH v3 0/9] Bring in new I2C framework
> >>     > >>
> >>     > >> It seems the timing is coming, to bring this finally in
> mainline and
> >>     > >> move boards over to the new i2c framework.
> >>     > >>
> >>     > >> Changes for v3 series:
> >>     > >>
> >>     > >> - Compiler collects the used i2c adapters in
> _u_boot_list_i2c,
> >>     > >>   so no need for defining the used i2c adpaters in the
> board config
> >>     > >> file.
> >>     > >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and
> CONFIG_SYS_I2C_ADAPTERS
> >>     > >> - Some adaptions for the keymile boards, so we can drop
> >>     > CONFIG_I2C_MUX
> >>     > >>   completely
> >>     > >> - add ppc4xx_i2c driver, ported from Dirk Eibach
> >>     > >>
> >>     > >> Serie compiles clean on arm and powerpc
> >>     > >>
> >>     > >> Ported i2c drivers:
> >>     > >> soft_i2c  : from me, tested on some arm and powerpc boards
> >>     > >> fsl_i2c   : from me, only compile tested
> >>     > >> tegra_i2c : ported from Simon Glass
> >>     > >> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
> >>     > >>             tested on (which board?) with 4 soft_i2c
> drivers
> >>     > >>             and one ppc4x_i2c driver.
> >>     > >>
> >>     > >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
> >>     > >> Cc: Stefan Roese <sr at denx.de <mailto:sr@denx.de>>
> >>     > >> Cc: Simon Glass <sjg@chromium.org
> <mailto:sjg@chromium.org>>
> >>     > >> Cc: Piotr Wilczek <p.wilczek@samsung.com
> <mailto:p.wilczek@samsung.com>>
> >>     > >> Cc: Holger Brunck <holger.brunck@keymile.com
> <mailto:holger.brunck@keymile.com>>
> >>     > >> Cc: Mike Frysinger <vapier@gentoo.org
> <mailto:vapier@gentoo.org>>
> >>     > >> Cc: Stephen Warren <swarren@wwwdotorg.org
> <mailto:swarren@wwwdotorg.org>>
> >>     > >>
> >>     > >
> >>     > > I ported s3c24x0_i2c driver and tested this framework on
> Samsung tree
> >>     > on Trats2 board.
> >>     >
> >>     > Please can you send a patch for this port?
> >>
> >>     I posted that patch and some others with series introducing
> Trsts2, where I
> >>     want to use this framework.
> >>     I'm sorry I didn't mention it in my first mail.
> >>     http://patchwork.ozlabs.org/patch/244645/
> >>     http://patchwork.ozlabs.org/patch/244644/
> >>     .
> >>     http://patchwork.ozlabs.org/patch/244638/
> >>     http://patchwork.ozlabs.org/patch/244637/
> >>     http://patchwork.ozlabs.org/patch/244640/
> >>     http://patchwork.ozlabs.org/patch/244636/
> >
> > Hups, missed this patches ...
> >
> >> What is the status of this series now please?
> >

If you take this series, please replace the following patch:
http://patchwork.ozlabs.org/patch/244642/

with the following one:
http://patchwork.ozlabs.org/patch/248927/

> > I heared nothing negatives for the new i2c multibus framework, so I
> > plan to merge it into mainline, if the next merge widow is open.
> >
> > So, the best for above patches would be, If I delegate them to me,
> and
> > apply them, when merging the new i2c multibus support ...
> >
> > @Minkyu: Is this OK for you?
> 
> OK..
> please pick patches.
> 
> >
> > bye,
> > Heiko
> >
> 
> Thanks,
> Minkyu Kang.

Best regards,
Piotr Wilczek

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  3:38         ` Heiko Schocher
  2013-06-20  5:50           ` Minkyu Kang
  2013-06-20  5:52           ` Piotr Wilczek
@ 2013-06-20  6:52           ` Dirk Eibach
  2013-06-20  7:59             ` Heiko Schocher
  2 siblings, 1 reply; 104+ messages in thread
From: Dirk Eibach @ 2013-06-20  6:52 UTC (permalink / raw)
  To: u-boot

Hello Heiko,

>> What is the status of this series now please?
>
> I heared nothing negatives for the new i2c multibus framework,
> so I plan to merge it into mainline, if the next merge widow is
> open.

actually I thought it would go into the current release :( What's the
reason for the delay?

I rebased my series on this, so it would not get in either.

Cheers
Dirk

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  6:41             ` Piotr Wilczek
@ 2013-06-20  7:14               ` Heiko Schocher
  2013-06-20  8:34                 ` Piotr Wilczek
  0 siblings, 1 reply; 104+ messages in thread
From: Heiko Schocher @ 2013-06-20  7:14 UTC (permalink / raw)
  To: u-boot

Hello Piotr,

Am 20.06.2013 08:41, schrieb Piotr Wilczek:
> Dear Heiko,
> 
>> -----Original Message-----
>> From: Minkyu Kang [mailto:mk7.kang at samsung.com]
>> Sent: Thursday, June 20, 2013 7:51 AM
>> To: Heiko Schocher
>> Cc: Simon Glass; Piotr Wilczek; U-Boot Mailing List; Dirk Eibach;
>> Stefan Roese; Holger Brunck; Mike Frysinger; Stephen Warren
>> Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
>>
>> Dear Heiko,
>>
>> On 20/06/13 12:38, Heiko Schocher wrote:
>>> Hello Simon,
>>>
>>> Am 20.06.2013 00:07, schrieb Simon Glass:
>>>> Hi Heiko,
>>>>
>>>> On Sun, May 19, 2013 at 11:13 PM, Piotr Wilczek
>> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>> wrote:
>>>>
>>>>     Hi Simon,
>>>>
>>>>     > -----Original Message-----
>>>>     > From: sjg at google.com <mailto:sjg@google.com>
>> [mailto:sjg at google.com <mailto:sjg@google.com>] On Behalf Of Simon
>> Glass
>>>>     > Sent: Saturday, May 18, 2013 7:41 PM
>>>>     > To: Piotr Wilczek
>>>>     > Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan
>> Roese;
>>>>     > Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
>>>>     > Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
>>>>     >
>>>>     > Hi Piotr,
>>>>     >
>>>>     > On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek
>> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
>>>>     > wrote:
>>>>     > > Dear Heiko,
>>>>     > >
>>>>     > >> -----Original Message-----
>>>>     > >> From: Heiko Schocher [mailto:hs at denx.de
>> <mailto:hs@denx.de>]
>>>>     > >> Sent: Saturday, May 04, 2013 2:02 PM
>>>>     > >> To: u-boot at lists.denx.de <mailto:u-boot@lists.denx.de>
>>>>     > >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon Glass;
>> Piotr
>>>>     > >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
>>>>     > >> Subject: [PATCH v3 0/9] Bring in new I2C framework
>>>>     > >>
>>>>     > >> It seems the timing is coming, to bring this finally in
>> mainline and
>>>>     > >> move boards over to the new i2c framework.
>>>>     > >>
>>>>     > >> Changes for v3 series:
>>>>     > >>
>>>>     > >> - Compiler collects the used i2c adapters in
>> _u_boot_list_i2c,
>>>>     > >>   so no need for defining the used i2c adpaters in the
>> board config
>>>>     > >> file.
>>>>     > >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and
>> CONFIG_SYS_I2C_ADAPTERS
>>>>     > >> - Some adaptions for the keymile boards, so we can drop
>>>>     > CONFIG_I2C_MUX
>>>>     > >>   completely
>>>>     > >> - add ppc4xx_i2c driver, ported from Dirk Eibach
>>>>     > >>
>>>>     > >> Serie compiles clean on arm and powerpc
>>>>     > >>
>>>>     > >> Ported i2c drivers:
>>>>     > >> soft_i2c  : from me, tested on some arm and powerpc boards
>>>>     > >> fsl_i2c   : from me, only compile tested
>>>>     > >> tegra_i2c : ported from Simon Glass
>>>>     > >> ppc4xx_i2c: adapted from Dirk Eibach <dirk.eibach@gdsys.cc>
>>>>     > >>             tested on (which board?) with 4 soft_i2c
>> drivers
>>>>     > >>             and one ppc4x_i2c driver.
>>>>     > >>
>>>>     > >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
>>>>     > >> Cc: Stefan Roese <sr at denx.de <mailto:sr@denx.de>>
>>>>     > >> Cc: Simon Glass <sjg@chromium.org
>> <mailto:sjg@chromium.org>>
>>>>     > >> Cc: Piotr Wilczek <p.wilczek@samsung.com
>> <mailto:p.wilczek@samsung.com>>
>>>>     > >> Cc: Holger Brunck <holger.brunck@keymile.com
>> <mailto:holger.brunck@keymile.com>>
>>>>     > >> Cc: Mike Frysinger <vapier@gentoo.org
>> <mailto:vapier@gentoo.org>>
>>>>     > >> Cc: Stephen Warren <swarren@wwwdotorg.org
>> <mailto:swarren@wwwdotorg.org>>
>>>>     > >>
>>>>     > >
>>>>     > > I ported s3c24x0_i2c driver and tested this framework on
>> Samsung tree
>>>>     > on Trats2 board.
>>>>     >
>>>>     > Please can you send a patch for this port?
>>>>
>>>>     I posted that patch and some others with series introducing
>> Trsts2, where I
>>>>     want to use this framework.
>>>>     I'm sorry I didn't mention it in my first mail.
>>>>     http://patchwork.ozlabs.org/patch/244645/
>>>>     http://patchwork.ozlabs.org/patch/244644/
>>>>     .
>>>>     http://patchwork.ozlabs.org/patch/244638/
>>>>     http://patchwork.ozlabs.org/patch/244637/
>>>>     http://patchwork.ozlabs.org/patch/244640/
>>>>     http://patchwork.ozlabs.org/patch/244636/
>>>
>>> Hups, missed this patches ...
>>>
>>>> What is the status of this series now please?
>>>
> 
> If you take this series, please replace the following patch:
> http://patchwork.ozlabs.org/patch/244642/
> 
> with the following one:
> http://patchwork.ozlabs.org/patch/248927/

I am little confused now ... can you send a complete list
which patches have to be picked up... thanks!

>>> I heared nothing negatives for the new i2c multibus framework, so I
>>> plan to merge it into mainline, if the next merge widow is open.
>>>
>>> So, the best for above patches would be, If I delegate them to me,
>> and
>>> apply them, when merging the new i2c multibus support ...
>>>
>>> @Minkyu: Is this OK for you?
>>
>> OK..
>> please pick patches.

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] 104+ messages in thread

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  6:52           ` Dirk Eibach
@ 2013-06-20  7:59             ` Heiko Schocher
  2013-06-20  8:20               ` Dirk Eibach
  0 siblings, 1 reply; 104+ messages in thread
From: Heiko Schocher @ 2013-06-20  7:59 UTC (permalink / raw)
  To: u-boot

Hello Dirk,

Am 20.06.2013 08:52, schrieb Dirk Eibach:
> Hello Heiko,
> 
>>> What is the status of this series now please?
>>
>> I heared nothing negatives for the new i2c multibus framework,
>> so I plan to merge it into mainline, if the next merge widow is
>> open.
> 
> actually I thought it would go into the current release :( What's the
> reason for the delay?

No real reason (just not found time for it), and we are near to the
release date, and this is a big change, which impacts a lot of boards,
different architetures...

Ok, since my last version from 18.05.2013 I got no more comments,
so ... just currently rebased against current head and it compiles
clean for arm ... but I have to try it on some plattforms, also
look at the powerpc side ... and I am afraid that I have no chance
to do this in the next two weeks ... also I am nearly one week
on vacation ... so there is not much time till the next release,
for reviewing bugfixes ...

> I rebased my series on this, so it would not get in either.

Sorry for the delay ... I vote for pushing this to mainline when
the next merge window opens, so more time for testing/fixing errors
remains ...

You found my current multibus branch here:
http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/20130620_multibus_v2

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] 104+ messages in thread

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  7:59             ` Heiko Schocher
@ 2013-06-20  8:20               ` Dirk Eibach
  2013-06-20  9:11                 ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Dirk Eibach @ 2013-06-20  8:20 UTC (permalink / raw)
  To: u-boot

Hello Heiko,

2013/6/20 Heiko Schocher <hs@denx.de>:
> Hello Dirk,
>
> Am 20.06.2013 08:52, schrieb Dirk Eibach:
>> Hello Heiko,
>>
>>>> What is the status of this series now please?
>>>
>>> I heared nothing negatives for the new i2c multibus framework,
>>> so I plan to merge it into mainline, if the next merge widow is
>>> open.
>>
>> actually I thought it would go into the current release :( What's the
>> reason for the delay?
>
> No real reason (just not found time for it), and we are near to the
> release date, and this is a big change, which impacts a lot of boards,
> different architetures...
>
> Ok, since my last version from 18.05.2013 I got no more comments,
> so ... just currently rebased against current head and it compiles
> clean for arm ... but I have to try it on some plattforms, also
> look at the powerpc side ... and I am afraid that I have no chance
> to do this in the next two weeks ... also I am nearly one week
> on vacation ... so there is not much time till the next release,
> for reviewing bugfixes ...
>
>> I rebased my series on this, so it would not get in either.
>
> Sorry for the delay ... I vote for pushing this to mainline when
> the next merge window opens, so more time for testing/fixing errors
> remains ...

OK, so with a strong emphasis on "when the next merge window *opens*"

> You found my current multibus branch here:
> http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/20130620_multibus_v2

As I am just doing a v4 of my series I will rebase it onto this.

Cheers
Dirk

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  7:14               ` Heiko Schocher
@ 2013-06-20  8:34                 ` Piotr Wilczek
  2013-06-20  9:19                   ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Piotr Wilczek @ 2013-06-20  8:34 UTC (permalink / raw)
  To: u-boot

Dear Minkyu and Heiko,

> -----Original Message-----
> From: Heiko Schocher [mailto:hs at denx.de]
> Sent: Thursday, June 20, 2013 9:14 AM
> To: Piotr Wilczek
> Cc: 'Minkyu Kang'; 'Simon Glass'; 'U-Boot Mailing List'; 'Dirk Eibach';
> 'Stefan Roese'; 'Holger Brunck'; 'Mike Frysinger'; 'Stephen Warren'
> Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> 
> Hello Piotr,
> 
> Am 20.06.2013 08:41, schrieb Piotr Wilczek:
> > Dear Heiko,
> >
> >> -----Original Message-----
> >> From: Minkyu Kang [mailto:mk7.kang at samsung.com]
> >> Sent: Thursday, June 20, 2013 7:51 AM
> >> To: Heiko Schocher
> >> Cc: Simon Glass; Piotr Wilczek; U-Boot Mailing List; Dirk Eibach;
> >> Stefan Roese; Holger Brunck; Mike Frysinger; Stephen Warren
> >> Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> >>
> >> Dear Heiko,
> >>
> >> On 20/06/13 12:38, Heiko Schocher wrote:
> >>> Hello Simon,
> >>>
> >>> Am 20.06.2013 00:07, schrieb Simon Glass:
> >>>> Hi Heiko,
> >>>>
> >>>> On Sun, May 19, 2013 at 11:13 PM, Piotr Wilczek
> >> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>> wrote:
> >>>>
> >>>>     Hi Simon,
> >>>>
> >>>>     > -----Original Message-----
> >>>>     > From: sjg at google.com <mailto:sjg@google.com>
> >> [mailto:sjg at google.com <mailto:sjg@google.com>] On Behalf Of Simon
> >> Glass
> >>>>     > Sent: Saturday, May 18, 2013 7:41 PM
> >>>>     > To: Piotr Wilczek
> >>>>     > Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan
> >> Roese;
> >>>>     > Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
> >>>>     > Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
> >>>>     >
> >>>>     > Hi Piotr,
> >>>>     >
> >>>>     > On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek
> >> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
> >>>>     > wrote:
> >>>>     > > Dear Heiko,
> >>>>     > >
> >>>>     > >> -----Original Message-----
> >>>>     > >> From: Heiko Schocher [mailto:hs at denx.de
> >> <mailto:hs@denx.de>]
> >>>>     > >> Sent: Saturday, May 04, 2013 2:02 PM
> >>>>     > >> To: u-boot at lists.denx.de <mailto:u-boot@lists.denx.de>
> >>>>     > >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon
> >>>> Glass;
> >> Piotr
> >>>>     > >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
> >>>>     > >> Subject: [PATCH v3 0/9] Bring in new I2C framework
> >>>>     > >>
> >>>>     > >> It seems the timing is coming, to bring this finally in
> >> mainline and
> >>>>     > >> move boards over to the new i2c framework.
> >>>>     > >>
> >>>>     > >> Changes for v3 series:
> >>>>     > >>
> >>>>     > >> - Compiler collects the used i2c adapters in
> >> _u_boot_list_i2c,
> >>>>     > >>   so no need for defining the used i2c adpaters in the
> >> board config
> >>>>     > >> file.
> >>>>     > >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and
> >> CONFIG_SYS_I2C_ADAPTERS
> >>>>     > >> - Some adaptions for the keymile boards, so we can drop
> >>>>     > CONFIG_I2C_MUX
> >>>>     > >>   completely
> >>>>     > >> - add ppc4xx_i2c driver, ported from Dirk Eibach
> >>>>     > >>
> >>>>     > >> Serie compiles clean on arm and powerpc
> >>>>     > >>
> >>>>     > >> Ported i2c drivers:
> >>>>     > >> soft_i2c  : from me, tested on some arm and powerpc
> boards
> >>>>     > >> fsl_i2c   : from me, only compile tested
> >>>>     > >> tegra_i2c : ported from Simon Glass
> >>>>     > >> ppc4xx_i2c: adapted from Dirk Eibach
> <dirk.eibach@gdsys.cc>
> >>>>     > >>             tested on (which board?) with 4 soft_i2c
> >> drivers
> >>>>     > >>             and one ppc4x_i2c driver.
> >>>>     > >>
> >>>>     > >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
> >>>>     > >> Cc: Stefan Roese <sr at denx.de <mailto:sr@denx.de>>
> >>>>     > >> Cc: Simon Glass <sjg@chromium.org
> >> <mailto:sjg@chromium.org>>
> >>>>     > >> Cc: Piotr Wilczek <p.wilczek@samsung.com
> >> <mailto:p.wilczek@samsung.com>>
> >>>>     > >> Cc: Holger Brunck <holger.brunck@keymile.com
> >> <mailto:holger.brunck@keymile.com>>
> >>>>     > >> Cc: Mike Frysinger <vapier@gentoo.org
> >> <mailto:vapier@gentoo.org>>
> >>>>     > >> Cc: Stephen Warren <swarren@wwwdotorg.org
> >> <mailto:swarren@wwwdotorg.org>>
> >>>>     > >>
> >>>>     > >
> >>>>     > > I ported s3c24x0_i2c driver and tested this framework on
> >> Samsung tree
> >>>>     > on Trats2 board.
> >>>>     >
> >>>>     > Please can you send a patch for this port?
> >>>>
> >>>>     I posted that patch and some others with series introducing
> >> Trsts2, where I
> >>>>     want to use this framework.
> >>>>     I'm sorry I didn't mention it in my first mail.
> >>>>     http://patchwork.ozlabs.org/patch/244645/
> >>>>     http://patchwork.ozlabs.org/patch/244644/
> >>>>     .
> >>>>     http://patchwork.ozlabs.org/patch/244638/
> >>>>     http://patchwork.ozlabs.org/patch/244637/
> >>>>     http://patchwork.ozlabs.org/patch/244640/
> >>>>     http://patchwork.ozlabs.org/patch/244636/
> >>>
> >>> Hups, missed this patches ...
> >>>
> >>>> What is the status of this series now please?
> >>>
> >
> > If you take this series, please replace the following patch:
> > http://patchwork.ozlabs.org/patch/244642/
> >
> > with the following one:
> > http://patchwork.ozlabs.org/patch/248927/
> 
> I am little confused now ... can you send a complete list which patches
> have to be picked up... thanks!
> 

This series does not apply cleanly any more on u-boot-i2c. I would have to
post an updated version.

In my opinion, It would be better that this series to be disregarded and the
new board Trats2 goes through the Samsung tree (it's been already tested).
Then later I should post new patches to adapt s3c24x0 i2c driver.

> >>> I heared nothing negatives for the new i2c multibus framework, so I
> >>> plan to merge it into mainline, if the next merge widow is open.
> >>>
> >>> So, the best for above patches would be, If I delegate them to me,
> >> and
> >>> apply them, when merging the new i2c multibus support ...
> >>>
> >>> @Minkyu: Is this OK for you?
> >>
> >> OK..
> >> please pick patches.
> 
> bye,
> Heiko
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Best regards,
Piotr Wilczek

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

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  8:20               ` Dirk Eibach
@ 2013-06-20  9:11                 ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-06-20  9:11 UTC (permalink / raw)
  To: u-boot

Hello Dirk,

Am 20.06.2013 10:20, schrieb Dirk Eibach:
> Hello Heiko,
> 
> 2013/6/20 Heiko Schocher <hs@denx.de>:
>> Hello Dirk,
>>
>> Am 20.06.2013 08:52, schrieb Dirk Eibach:
>>> Hello Heiko,
>>>
>>>>> What is the status of this series now please?
>>>>
>>>> I heared nothing negatives for the new i2c multibus framework,
>>>> so I plan to merge it into mainline, if the next merge widow is
>>>> open.
>>>
>>> actually I thought it would go into the current release :( What's the
>>> reason for the delay?
>>
>> No real reason (just not found time for it), and we are near to the
>> release date, and this is a big change, which impacts a lot of boards,
>> different architetures...
>>
>> Ok, since my last version from 18.05.2013 I got no more comments,
>> so ... just currently rebased against current head and it compiles
>> clean for arm ... but I have to try it on some plattforms, also
>> look at the powerpc side ... and I am afraid that I have no chance
>> to do this in the next two weeks ... also I am nearly one week
>> on vacation ... so there is not much time till the next release,
>> for reviewing bugfixes ...
>>
>>> I rebased my series on this, so it would not get in either.
>>
>> Sorry for the delay ... I vote for pushing this to mainline when
>> the next merge window opens, so more time for testing/fixing errors
>> remains ...
> 
> OK, so with a strong emphasis on "when the next merge window *opens*"

Yes!

>> You found my current multibus branch here:
>> http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/20130620_multibus_v2
> 
> As I am just doing a v4 of my series I will rebase it onto this.

Ok, 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] 104+ messages in thread

* [U-Boot] [PATCH v3 0/9] Bring in new I2C framework
  2013-06-20  8:34                 ` Piotr Wilczek
@ 2013-06-20  9:19                   ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-06-20  9:19 UTC (permalink / raw)
  To: u-boot

Hello Piotr,

Am 20.06.2013 10:34, schrieb Piotr Wilczek:
> Dear Minkyu and Heiko,
> 
>> -----Original Message-----
>> From: Heiko Schocher [mailto:hs at denx.de]
>> Sent: Thursday, June 20, 2013 9:14 AM
>> To: Piotr Wilczek
>> Cc: 'Minkyu Kang'; 'Simon Glass'; 'U-Boot Mailing List'; 'Dirk Eibach';
>> 'Stefan Roese'; 'Holger Brunck'; 'Mike Frysinger'; 'Stephen Warren'
>> Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
>>
>> Hello Piotr,
>>
>> Am 20.06.2013 08:41, schrieb Piotr Wilczek:
>>> Dear Heiko,
>>>
>>>> -----Original Message-----
>>>> From: Minkyu Kang [mailto:mk7.kang at samsung.com]
>>>> Sent: Thursday, June 20, 2013 7:51 AM
>>>> To: Heiko Schocher
>>>> Cc: Simon Glass; Piotr Wilczek; U-Boot Mailing List; Dirk Eibach;
>>>> Stefan Roese; Holger Brunck; Mike Frysinger; Stephen Warren
>>>> Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
>>>>
>>>> Dear Heiko,
>>>>
>>>> On 20/06/13 12:38, Heiko Schocher wrote:
>>>>> Hello Simon,
>>>>>
>>>>> Am 20.06.2013 00:07, schrieb Simon Glass:
>>>>>> Hi Heiko,
>>>>>>
>>>>>> On Sun, May 19, 2013 at 11:13 PM, Piotr Wilczek
>>>> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>> wrote:
>>>>>>
>>>>>>     Hi Simon,
>>>>>>
>>>>>>     > -----Original Message-----
>>>>>>     > From: sjg at google.com <mailto:sjg@google.com>
>>>> [mailto:sjg at google.com <mailto:sjg@google.com>] On Behalf Of Simon
>>>> Glass
>>>>>>     > Sent: Saturday, May 18, 2013 7:41 PM
>>>>>>     > To: Piotr Wilczek
>>>>>>     > Cc: Heiko Schocher; U-Boot Mailing List; Dirk Eibach; Stefan
>>>> Roese;
>>>>>>     > Holger Brunck; Mike Frysinger; Stephen Warren; Minkyu Kang
>>>>>>     > Subject: Re: [PATCH v3 0/9] Bring in new I2C framework
>>>>>>     >
>>>>>>     > Hi Piotr,
>>>>>>     >
>>>>>>     > On Fri, May 17, 2013 at 6:17 AM, Piotr Wilczek
>>>> <p.wilczek at samsung.com <mailto:p.wilczek@samsung.com>>
>>>>>>     > wrote:
>>>>>>     > > Dear Heiko,
>>>>>>     > >
>>>>>>     > >> -----Original Message-----
>>>>>>     > >> From: Heiko Schocher [mailto:hs at denx.de
>>>> <mailto:hs@denx.de>]
>>>>>>     > >> Sent: Saturday, May 04, 2013 2:02 PM
>>>>>>     > >> To: u-boot at lists.denx.de <mailto:u-boot@lists.denx.de>
>>>>>>     > >> Cc: Heiko Schocher; Dirk Eibach; Stefan Roese; Simon
>>>>>> Glass;
>>>> Piotr
>>>>>>     > >> Wilczek; Holger Brunck; Mike Frysinger; Stephen Warren
>>>>>>     > >> Subject: [PATCH v3 0/9] Bring in new I2C framework
>>>>>>     > >>
>>>>>>     > >> It seems the timing is coming, to bring this finally in
>>>> mainline and
>>>>>>     > >> move boards over to the new i2c framework.
>>>>>>     > >>
>>>>>>     > >> Changes for v3 series:
>>>>>>     > >>
>>>>>>     > >> - Compiler collects the used i2c adapters in
>>>> _u_boot_list_i2c,
>>>>>>     > >>   so no need for defining the used i2c adpaters in the
>>>> board config
>>>>>>     > >> file.
>>>>>>     > >>   -> drop CONFIG_SYS_NUM_I2C_ADAPTERS and
>>>> CONFIG_SYS_I2C_ADAPTERS
>>>>>>     > >> - Some adaptions for the keymile boards, so we can drop
>>>>>>     > CONFIG_I2C_MUX
>>>>>>     > >>   completely
>>>>>>     > >> - add ppc4xx_i2c driver, ported from Dirk Eibach
>>>>>>     > >>
>>>>>>     > >> Serie compiles clean on arm and powerpc
>>>>>>     > >>
>>>>>>     > >> Ported i2c drivers:
>>>>>>     > >> soft_i2c  : from me, tested on some arm and powerpc
>> boards
>>>>>>     > >> fsl_i2c   : from me, only compile tested
>>>>>>     > >> tegra_i2c : ported from Simon Glass
>>>>>>     > >> ppc4xx_i2c: adapted from Dirk Eibach
>> <dirk.eibach@gdsys.cc>
>>>>>>     > >>             tested on (which board?) with 4 soft_i2c
>>>> drivers
>>>>>>     > >>             and one ppc4x_i2c driver.
>>>>>>     > >>
>>>>>>     > >> Cc: Dirk Eibach <dirk.eibach@gdsys.cc>
>>>>>>     > >> Cc: Stefan Roese <sr at denx.de <mailto:sr@denx.de>>
>>>>>>     > >> Cc: Simon Glass <sjg@chromium.org
>>>> <mailto:sjg@chromium.org>>
>>>>>>     > >> Cc: Piotr Wilczek <p.wilczek@samsung.com
>>>> <mailto:p.wilczek@samsung.com>>
>>>>>>     > >> Cc: Holger Brunck <holger.brunck@keymile.com
>>>> <mailto:holger.brunck@keymile.com>>
>>>>>>     > >> Cc: Mike Frysinger <vapier@gentoo.org
>>>> <mailto:vapier@gentoo.org>>
>>>>>>     > >> Cc: Stephen Warren <swarren@wwwdotorg.org
>>>> <mailto:swarren@wwwdotorg.org>>
>>>>>>     > >>
>>>>>>     > >
>>>>>>     > > I ported s3c24x0_i2c driver and tested this framework on
>>>> Samsung tree
>>>>>>     > on Trats2 board.
>>>>>>     >
>>>>>>     > Please can you send a patch for this port?
>>>>>>
>>>>>>     I posted that patch and some others with series introducing
>>>> Trsts2, where I
>>>>>>     want to use this framework.
>>>>>>     I'm sorry I didn't mention it in my first mail.
>>>>>>     http://patchwork.ozlabs.org/patch/244645/
>>>>>>     http://patchwork.ozlabs.org/patch/244644/
>>>>>>     .
>>>>>>     http://patchwork.ozlabs.org/patch/244638/
>>>>>>     http://patchwork.ozlabs.org/patch/244637/
>>>>>>     http://patchwork.ozlabs.org/patch/244640/
>>>>>>     http://patchwork.ozlabs.org/patch/244636/
>>>>>
>>>>> Hups, missed this patches ...
>>>>>
>>>>>> What is the status of this series now please?
>>>>>
>>>
>>> If you take this series, please replace the following patch:
>>> http://patchwork.ozlabs.org/patch/244642/
>>>
>>> with the following one:
>>> http://patchwork.ozlabs.org/patch/248927/
>>
>> I am little confused now ... can you send a complete list which patches
>> have to be picked up... thanks!
>>
> 
> This series does not apply cleanly any more on u-boot-i2c. I would have to
> post an updated version.
> 
> In my opinion, It would be better that this series to be disregarded and the
> new board Trats2 goes through the Samsung tree (it's been already tested).
> Then later I should post new patches to adapt s3c24x0 i2c driver.

Ok from my side ...

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-05-04 12:01 ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework Heiko Schocher
  2013-05-06 19:08   ` Stephen Warren
@ 2013-07-29 16:12   ` Stephen Warren
  2013-07-30  4:28     ` Heiko Schocher
  1 sibling, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-07-29 16:12 UTC (permalink / raw)
  To: u-boot

On 05/04/2013 06:01 AM, Heiko Schocher wrote:
> From: Simon Glass <sjg@chromium.org>
> 
> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the Tegra
> i2c driver to support this.

Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
bisect" points at this patch. Olof reported the issue to me.

Can you take a look at the code and see what might be wrong? Thanks.

I suspect some kind of initialization ordering issue, since the boot
messages are:

-----
U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)

TEGRA30
Board: NVIDIA Beaver
I2C:   Caller requested bad clock: periph=-49, parent=2
-----

... and that "bad clock" message implies to me that the I2C driver is
initializing before it has parsed the correct clock ID out of device tree.

Some later commit causes the hang to happen right after printing "I2C:",
without printing the "bad clock" message. I didn't investigate that,
since I'm assuming the root-cause is the same. Most likely some later
commit causes the uninitialized data to be a valid clock, yet not the
actual I2C clock, so the I2C clock still isn't turned on, and touching
HW (i.e. reading/writing the I2C registers) without a running clock on
Tegra caused hard hangs.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-29 16:12   ` Stephen Warren
@ 2013-07-30  4:28     ` Heiko Schocher
  2013-07-30  4:34       ` Simon Glass
                         ` (2 more replies)
  0 siblings, 3 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-07-30  4:28 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 29.07.2013 18:12, schrieb Stephen Warren:
> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>> From: Simon Glass<sjg@chromium.org>
>>
>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the Tegra
>> i2c driver to support this.
>
> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git

:-(

Could you enable debug printf?

> bisect" points at this patch. Olof reported the issue to me.

Thanks!

> Can you take a look at the code and see what might be wrong? Thanks.

Yep.

> I suspect some kind of initialization ordering issue, since the boot
> messages are:
>
> -----
> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>
> TEGRA30
> Board: NVIDIA Beaver
> I2C:   Caller requested bad clock: periph=-49, parent=2
> -----
>
> ... and that "bad clock" message implies to me that the I2C driver is
> initializing before it has parsed the correct clock ID out of device tree.

Hmm... looking in the patch ... I can see nothing which changes
some initializing order ...

@Simon: Do you have an idea?

just found some wrong settings for tegra30:

In include/configs/tegra30-common.h:
/* Total I2C ports on Tegra30 */
#define TEGRA_I2C_NUM_CONTROLLERS       5

README says:
                - drivers/i2c/tegra_i2c.c:
                 - activate this driver with CONFIG_SYS_I2C_TEGRA
                 - This driver adds 4 i2c buses with a fix speed from
                   100000 and the slave addr 0!

end yes, in the i2c driver are only 4 ports activated ... this
should be changed ... but I think, this has nothing to do with
your problem ... but try to add in the i2c driver one more i2c adapter
for the case TEGRA_I2C_NUM_CONTROLLERS > 4

> Some later commit causes the hang to happen right after printing "I2C:",
> without printing the "bad clock" message. I didn't investigate that,
> since I'm assuming the root-cause is the same. Most likely some later
> commit causes the uninitialized data to be a valid clock, yet not the
> actual I2C clock, so the I2C clock still isn't turned on, and touching
> HW (i.e. reading/writing the I2C registers) without a running clock on
> Tegra caused hard hangs.

digging deeper, the above "bad clock" message

is a result from calling this function from the i2c driver:
./drivers/i2c/tegra_i2c.c:
static void i2c_init_controller(struct i2c_bus *i2c_bus)
{
         /*
          * Use PLLP - DP-04508-001_v06 datasheet indicates a divisor of 8
          * here, in section 23.3.1, but in fact we seem to need a factor of
          * 16 to get the right frequency.
          */
         clock_start_periph_pll(i2c_bus->periph_id, CLOCK_ID_PERIPH,
                 i2c_bus->speed * 2 * 8);

Please enable debug printfs and look from where i2c_init_controller()
is called. You should see the following debug printf if it go the right
way (Just reading code, I have no HW ...)

process_nodes():
                 debug("%s: controller bus %d at %p, periph_id %d, speed %d: ",
                       is_dvc ? "dvc" : "i2c", i, i2c_bus->regs,
                       i2c_bus->periph_id, i2c_bus->speed);

called from i2c_init_board in this driver.

This should be called from drivers/i2c/i2c_core.c i2c_init_all()
called from arch/arm/lib/board.c init_func_i2c()

I think i2c_bus->periph_id ("periph=-49") is not setup right ... do
you have the correct dt?

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30  4:28     ` Heiko Schocher
@ 2013-07-30  4:34       ` Simon Glass
  2013-07-30 18:56       ` Stephen Warren
  2013-07-30 19:22       ` Stephen Warren
  2 siblings, 0 replies; 104+ messages in thread
From: Simon Glass @ 2013-07-30  4:34 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Mon, Jul 29, 2013 at 10:28 PM, Heiko Schocher <hs@denx.de> wrote:

> Hello Stephen,
>
> Am 29.07.2013 18:12, schrieb Stephen Warren:
>
>  On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>
>>> From: Simon Glass<sjg@chromium.org>
>>>
>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and the
>>> Tegra
>>> i2c driver to support this.
>>>
>>
>> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
>>
>
> :-(
>
> Could you enable debug printf?
>
>
>  bisect" points at this patch. Olof reported the issue to me.
>>
>
> Thanks!
>
>
>  Can you take a look at the code and see what might be wrong? Thanks.
>>
>
> Yep.
>
>
>  I suspect some kind of initialization ordering issue, since the boot
>> messages are:
>>
>> -----
>> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>
>> TEGRA30
>> Board: NVIDIA Beaver
>> I2C:   Caller requested bad clock: periph=-49, parent=2
>> -----
>>
>> ... and that "bad clock" message implies to me that the I2C driver is
>> initializing before it has parsed the correct clock ID out of device tree.
>>
>
> Hmm... looking in the patch ... I can see nothing which changes
> some initializing order ...
>
> @Simon: Do you have an idea?
>
> just found some wrong settings for tegra30:
>
> In include/configs/tegra30-**common.h:
> /* Total I2C ports on Tegra30 */
> #define TEGRA_I2C_NUM_CONTROLLERS       5
>
> README says:
>                - drivers/i2c/tegra_i2c.c:
>
>                 - activate this driver with CONFIG_SYS_I2C_TEGRA
>                 - This driver adds 4 i2c buses with a fix speed from
>                   100000 and the slave addr 0!
>
> end yes, in the i2c driver are only 4 ports activated ... this
> should be changed ... but I think, this has nothing to do with
> your problem ... but try to add in the i2c driver one more i2c adapter
> for the case TEGRA_I2C_NUM_CONTROLLERS > 4
>
>
>  Some later commit causes the hang to happen right after printing "I2C:",
>> without printing the "bad clock" message. I didn't investigate that,
>> since I'm assuming the root-cause is the same. Most likely some later
>> commit causes the uninitialized data to be a valid clock, yet not the
>> actual I2C clock, so the I2C clock still isn't turned on, and touching
>> HW (i.e. reading/writing the I2C registers) without a running clock on
>> Tegra caused hard hangs.
>>
>
> digging deeper, the above "bad clock" message
>
> is a result from calling this function from the i2c driver:
> ./drivers/i2c/tegra_i2c.c:
> static void i2c_init_controller(struct i2c_bus *i2c_bus)
> {
>         /*
>          * Use PLLP - DP-04508-001_v06 datasheet indicates a divisor of 8
>          * here, in section 23.3.1, but in fact we seem to need a factor of
>          * 16 to get the right frequency.
>          */
>         clock_start_periph_pll(i2c_**bus->periph_id, CLOCK_ID_PERIPH,
>                 i2c_bus->speed * 2 * 8);
>
> Please enable debug printfs and look from where i2c_init_controller()
> is called. You should see the following debug printf if it go the right
> way (Just reading code, I have no HW ...)
>
> process_nodes():
>                 debug("%s: controller bus %d at %p, periph_id %d, speed
> %d: ",
>                       is_dvc ? "dvc" : "i2c", i, i2c_bus->regs,
>                       i2c_bus->periph_id, i2c_bus->speed);
>
> called from i2c_init_board in this driver.
>
> This should be called from drivers/i2c/i2c_core.c i2c_init_all()
> called from arch/arm/lib/board.c init_func_i2c()
>
> I think i2c_bus->periph_id ("periph=-49") is not setup right ... do
> you have the correct dt?


I am not sure what is wrong here - Stephen if you have a board and can
debug please do, otherwise I might be able to dig one out.

49 looks to be PERIPH_ID_TVO.

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30  4:28     ` Heiko Schocher
  2013-07-30  4:34       ` Simon Glass
@ 2013-07-30 18:56       ` Stephen Warren
  2013-07-31  4:29         ` Heiko Schocher
  2013-07-30 19:22       ` Stephen Warren
  2 siblings, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-07-30 18:56 UTC (permalink / raw)
  To: u-boot

On 07/29/2013 10:28 PM, Heiko Schocher wrote:
> Hello Stephen,
> 
> Am 29.07.2013 18:12, schrieb Stephen Warren:
>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>> From: Simon Glass<sjg@chromium.org>
>>>
>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and
>>> the Tegra
>>> i2c driver to support this.
>>
>> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
> 
> :-(
> 
> Could you enable debug printf?
> 
>> bisect" points at this patch. Olof reported the issue to me.
> 
> Thanks!
> 
>> Can you take a look at the code and see what might be wrong? Thanks.
> 
> Yep.
> 
>> I suspect some kind of initialization ordering issue, since the boot
>> messages are:
>>
>> -----
>> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>
>> TEGRA30
>> Board: NVIDIA Beaver
>> I2C:   Caller requested bad clock: periph=-49, parent=2
>> -----
>>
>> ... and that "bad clock" message implies to me that the I2C driver is
>> initializing before it has parsed the correct clock ID out of device
>> tree.
> 
> Hmm... looking in the patch ... I can see nothing which changes
> some initializing order ...
> 
> @Simon: Do you have an idea?
> 
> just found some wrong settings for tegra30:
> 
> In include/configs/tegra30-common.h:
> /* Total I2C ports on Tegra30 */
> #define TEGRA_I2C_NUM_CONTROLLERS       5
> 
> README says:
>                - drivers/i2c/tegra_i2c.c:
>                 - activate this driver with CONFIG_SYS_I2C_TEGRA
>                 - This driver adds 4 i2c buses with a fix speed from
>                   100000 and the slave addr 0!

I think that's just stale documentation; Tegra20 had just 4 I2C
controllers, and the docs probably weren't updated for Tegra30 which has 5.

> end yes, in the i2c driver are only 4 ports activated ... this

I don't see any limit in the driver; everything seems to use
TEGRA_I2C_NUM_CONTROLLERS.

> should be changed ... but I think, this has nothing to do with
> your problem ... but try to add in the i2c driver one more i2c adapter
> for the case TEGRA_I2C_NUM_CONTROLLERS > 4

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30  4:28     ` Heiko Schocher
  2013-07-30  4:34       ` Simon Glass
  2013-07-30 18:56       ` Stephen Warren
@ 2013-07-30 19:22       ` Stephen Warren
  2013-07-30 20:00         ` Stephen Warren
                           ` (2 more replies)
  2 siblings, 3 replies; 104+ messages in thread
From: Stephen Warren @ 2013-07-30 19:22 UTC (permalink / raw)
  To: u-boot

On 07/29/2013 10:28 PM, Heiko Schocher wrote:
> Hello Stephen,
> 
> Am 29.07.2013 18:12, schrieb Stephen Warren:
>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>> From: Simon Glass<sjg@chromium.org>
>>>
>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and
>>> the Tegra
>>> i2c driver to support this.
>>
>> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
>> bisect" points at this patch. Olof reported the issue to me.
>> Can you take a look at the code and see what might be wrong? Thanks.
>>
>> I suspect some kind of initialization ordering issue, since the boot
>> messages are:
>>
>> -----
>> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>
>> TEGRA30
>> Board: NVIDIA Beaver
>> I2C:   Caller requested bad clock: periph=-49, parent=2
>> -----
>>
>> ... and that "bad clock" message implies to me that the I2C driver is
>> initializing before it has parsed the correct clock ID out of device
>> tree.
> 
> Hmm... looking in the patch ... I can see nothing which changes
> some initializing order ...

Yes, there's some initialization order issue; before this patch, I see
the I2C controller initialization, followed by some usage of it:

----------
U-Boot SPL 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
U-Boot 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)

TEGRA30
Board: NVIDIA Beaver
DRAM:  2 GiB
i2c: controller bus 0 at 7000d000, periph_id 47, speed 100000: ok
i2c: controller bus 1 at 7000c000, periph_id 12, speed 100000: ok
i2c: controller bus 2 at 7000c400, periph_id 54, speed 100000: ok
i2c: controller bus 3 at 7000c500, periph_id 67, speed 100000: ok
i2c: controller bus 4 at 7000c700, periph_id 103, speed 100000: ok
MMC:   i2c_write: chip=0x2d, addr=0x32, len=0x1
----------

However with this patch applied, something starts using the controller
immediately, without it having been "probed" from device-tree:

----------
U-Boot SPL 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
U-Boot 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)

TEGRA30
Board: NVIDIA Beaver
I2C:   i2c_init(speed=100000, slaveaddr=0xfe)
----------

i2c_init touches HW, but since process_nodes() hasn't run, none of the
parameters like register address or clock ID are yet known.

I think this call comes from init_sequence_f[] -> init_func_i2c() ->
i2c_init() -> i2c_init() == __i2c_init() -> i2c_init_bus() ->
I2C_ADAP->init(), although I didn't validate that in the running code,
just by code inspection.

The issue here is that the I2C core and/or Tegra driver seems to be
statically registering the I2C device objects, even though they should
be dynamically registered from device tree.

Should Tegra move its call of i2c_init_board() out of board_init() to
board_init_f(), and/or override __i2c_init() to call i2c_init_board()?

I think when init_sequence_f[] is running, there may be no serial
console to report errors. If so, moving the I2C initialization to that
early point sounds like a really bad idea.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 19:22       ` Stephen Warren
@ 2013-07-30 20:00         ` Stephen Warren
  2013-07-30 21:21           ` Simon Glass
                             ` (2 more replies)
  2013-07-30 21:19         ` Simon Glass
  2013-07-31  5:01         ` Heiko Schocher
  2 siblings, 3 replies; 104+ messages in thread
From: Stephen Warren @ 2013-07-30 20:00 UTC (permalink / raw)
  To: u-boot

On 07/30/2013 01:22 PM, Stephen Warren wrote:
> On 07/29/2013 10:28 PM, Heiko Schocher wrote:
>> Hello Stephen,
>>
>> Am 29.07.2013 18:12, schrieb Stephen Warren:
>>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>>> From: Simon Glass<sjg@chromium.org>
>>>>
>>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and
>>>> the Tegra
>>>> i2c driver to support this.
>>>
>>> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
>>> bisect" points at this patch. Olof reported the issue to me.
>>> Can you take a look at the code and see what might be wrong? Thanks.
>>>
>>> I suspect some kind of initialization ordering issue, since the boot
>>> messages are:
>>>
>>> -----
>>> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>>
>>> TEGRA30
>>> Board: NVIDIA Beaver
>>> I2C:   Caller requested bad clock: periph=-49, parent=2
>>> -----
>>>
>>> ... and that "bad clock" message implies to me that the I2C driver is
>>> initializing before it has parsed the correct clock ID out of device
>>> tree.
>>
>> Hmm... looking in the patch ... I can see nothing which changes
>> some initializing order ...
> 
> Yes, there's some initialization order issue; before this patch, I see
> the I2C controller initialization, followed by some usage of it:
> 
> ----------
> U-Boot SPL 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
> U-Boot 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
> 
> TEGRA30
> Board: NVIDIA Beaver
> DRAM:  2 GiB
> i2c: controller bus 0 at 7000d000, periph_id 47, speed 100000: ok
> i2c: controller bus 1 at 7000c000, periph_id 12, speed 100000: ok
> i2c: controller bus 2 at 7000c400, periph_id 54, speed 100000: ok
> i2c: controller bus 3 at 7000c500, periph_id 67, speed 100000: ok
> i2c: controller bus 4 at 7000c700, periph_id 103, speed 100000: ok
> MMC:   i2c_write: chip=0x2d, addr=0x32, len=0x1
> ----------
> 
> However with this patch applied, something starts using the controller
> immediately, without it having been "probed" from device-tree:
> 
> ----------
> U-Boot SPL 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
> U-Boot 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
> 
> TEGRA30
> Board: NVIDIA Beaver
> I2C:   i2c_init(speed=100000, slaveaddr=0xfe)
> ----------
> 
> i2c_init touches HW, but since process_nodes() hasn't run, none of the
> parameters like register address or clock ID are yet known.
> 
> I think this call comes from init_sequence_f[] -> init_func_i2c() ->
> i2c_init() -> i2c_init() == __i2c_init() -> i2c_init_bus() ->
> I2C_ADAP->init(), although I didn't validate that in the running code,
> just by code inspection.

Oh, with the options Tegra has enabled, perhaps the call sequence is:

board_init_f() (which uses init_sequence_f[]) -> init_func_i2c() ->
i2c_init_all(), which then calls:

* i2c_init_board(), which is supposed to parse DT
* i2c_set_bus_num(), which will call I2C_ADAP->init

However, according to the comments near the top of arch/arm/lib/crt0.S,
board_init_f() is called in an environment where variable data (.data,
.bss) is not available, hence i2c_init_board() cannot possibly operate
correctly since its whole purpose is to fill in variable data structures
from DT.

I think the only way to solve this is not to use DT to instantiate
devices, or to move the I2C initialization after relocation etc.,
although the latter won't work on boards that need I2C up in order to
initialize DRAM.

It seems like much of U-Boot's initialization architecture simply wasn't
designed to accommodate dynamically initializing devices from DT.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 19:22       ` Stephen Warren
  2013-07-30 20:00         ` Stephen Warren
@ 2013-07-30 21:19         ` Simon Glass
  2013-07-30 21:21           ` Stephen Warren
  2013-07-31  5:01         ` Heiko Schocher
  2 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-07-30 21:19 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Tue, Jul 30, 2013 at 1:22 PM, Stephen Warren <swarren@wwwdotorg.org>wrote:

> On 07/29/2013 10:28 PM, Heiko Schocher wrote:
> > Hello Stephen,
> >
> > Am 29.07.2013 18:12, schrieb Stephen Warren:
> >> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
> >>> From: Simon Glass<sjg@chromium.org>
> >>>
> >>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and
> >>> the Tegra
> >>> i2c driver to support this.
> >>
> >> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
> >> bisect" points at this patch. Olof reported the issue to me.
> >> Can you take a look at the code and see what might be wrong? Thanks.
> >>
> >> I suspect some kind of initialization ordering issue, since the boot
> >> messages are:
> >>
> >> -----
> >> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
> >> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
> >>
> >> TEGRA30
> >> Board: NVIDIA Beaver
> >> I2C:   Caller requested bad clock: periph=-49, parent=2
> >> -----
> >>
> >> ... and that "bad clock" message implies to me that the I2C driver is
> >> initializing before it has parsed the correct clock ID out of device
> >> tree.
> >
> > Hmm... looking in the patch ... I can see nothing which changes
> > some initializing order ...
>
> Yes, there's some initialization order issue; before this patch, I see
> the I2C controller initialization, followed by some usage of it:
>
> ----------
> U-Boot SPL 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
> U-Boot 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
>
> TEGRA30
> Board: NVIDIA Beaver
> DRAM:  2 GiB
> i2c: controller bus 0 at 7000d000, periph_id 47, speed 100000: ok
> i2c: controller bus 1 at 7000c000, periph_id 12, speed 100000: ok
> i2c: controller bus 2 at 7000c400, periph_id 54, speed 100000: ok
> i2c: controller bus 3 at 7000c500, periph_id 67, speed 100000: ok
> i2c: controller bus 4 at 7000c700, periph_id 103, speed 100000: ok
> MMC:   i2c_write: chip=0x2d, addr=0x32, len=0x1
> ----------
>
> However with this patch applied, something starts using the controller
> immediately, without it having been "probed" from device-tree:
>
> ----------
> U-Boot SPL 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
> U-Boot 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
>
> TEGRA30
> Board: NVIDIA Beaver
> I2C:   i2c_init(speed=100000, slaveaddr=0xfe)
> ----------
>
> i2c_init touches HW, but since process_nodes() hasn't run, none of the
> parameters like register address or clock ID are yet known.
>
> I think this call comes from init_sequence_f[] -> init_func_i2c() ->
> i2c_init() -> i2c_init() == __i2c_init() -> i2c_init_bus() ->
> I2C_ADAP->init(), although I didn't validate that in the running code,
> just by code inspection.
>
> The issue here is that the I2C core and/or Tegra driver seems to be
> statically registering the I2C device objects, even though they should
> be dynamically registered from device tree.
>
> Should Tegra move its call of i2c_init_board() out of board_init() to
> board_init_f(), and/or override __i2c_init() to call i2c_init_board()?


Something like that. We need i2c_init_board() to be called earlier, now
that the init sequence is doing i2c on ARM.


>
> I think when init_sequence_f[] is running, there may be no serial
> console to report errors. If so, moving the I2C initialization to that
> early point sounds like a really bad idea.
>

Not really - when you see the U-Boot banner the console is working, and we
clearly see the U-Boot banner before i2c init happens.

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 21:19         ` Simon Glass
@ 2013-07-30 21:21           ` Stephen Warren
  2013-07-30 21:45             ` Simon Glass
  0 siblings, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-07-30 21:21 UTC (permalink / raw)
  To: u-boot

On 07/30/2013 03:19 PM, Simon Glass wrote:
> Hi Stephen,
> 
> On Tue, Jul 30, 2013 at 1:22 PM, Stephen Warren <swarren@wwwdotorg.org
> <mailto:swarren@wwwdotorg.org>> wrote:
...
>     I think when init_sequence_f[] is running, there may be no serial
>     console to report errors. If so, moving the I2C initialization to that
>     early point sounds like a really bad idea.
> 
> 
> Not really - when you see the U-Boot banner the console is working, and
> we clearly see the U-Boot banner before i2c init happens.

I thought it got buffered up and only actually sent to the UART much
later, and not in the case when something failed since U-Boot wouldn't
get that far? Or, did that proposal get shot down?

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 20:00         ` Stephen Warren
@ 2013-07-30 21:21           ` Simon Glass
  2013-07-30 21:32             ` Stephen Warren
  2013-07-31  5:03           ` Heiko Schocher
  2013-08-05 19:21           ` Stephen Warren
  2 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-07-30 21:21 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren <swarren@wwwdotorg.org>wrote:

> On 07/30/2013 01:22 PM, Stephen Warren wrote:
> > On 07/29/2013 10:28 PM, Heiko Schocher wrote:
> >> Hello Stephen,
> >>
> >> Am 29.07.2013 18:12, schrieb Stephen Warren:
> >>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
> >>>> From: Simon Glass<sjg@chromium.org>
> >>>>
> >>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and
> >>>> the Tegra
> >>>> i2c driver to support this.
> >>>
> >>> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
> >>> bisect" points at this patch. Olof reported the issue to me.
> >>> Can you take a look at the code and see what might be wrong? Thanks.
> >>>
> >>> I suspect some kind of initialization ordering issue, since the boot
> >>> messages are:
> >>>
> >>> -----
> >>> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
> >>> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
> >>>
> >>> TEGRA30
> >>> Board: NVIDIA Beaver
> >>> I2C:   Caller requested bad clock: periph=-49, parent=2
> >>> -----
> >>>
> >>> ... and that "bad clock" message implies to me that the I2C driver is
> >>> initializing before it has parsed the correct clock ID out of device
> >>> tree.
> >>
> >> Hmm... looking in the patch ... I can see nothing which changes
> >> some initializing order ...
> >
> > Yes, there's some initialization order issue; before this patch, I see
> > the I2C controller initialization, followed by some usage of it:
> >
> > ----------
> > U-Boot SPL 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
> > U-Boot 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
> >
> > TEGRA30
> > Board: NVIDIA Beaver
> > DRAM:  2 GiB
> > i2c: controller bus 0 at 7000d000, periph_id 47, speed 100000: ok
> > i2c: controller bus 1 at 7000c000, periph_id 12, speed 100000: ok
> > i2c: controller bus 2 at 7000c400, periph_id 54, speed 100000: ok
> > i2c: controller bus 3 at 7000c500, periph_id 67, speed 100000: ok
> > i2c: controller bus 4 at 7000c700, periph_id 103, speed 100000: ok
> > MMC:   i2c_write: chip=0x2d, addr=0x32, len=0x1
> > ----------
> >
> > However with this patch applied, something starts using the controller
> > immediately, without it having been "probed" from device-tree:
> >
> > ----------
> > U-Boot SPL 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
> > U-Boot 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
> >
> > TEGRA30
> > Board: NVIDIA Beaver
> > I2C:   i2c_init(speed=100000, slaveaddr=0xfe)
> > ----------
> >
> > i2c_init touches HW, but since process_nodes() hasn't run, none of the
> > parameters like register address or clock ID are yet known.
> >
> > I think this call comes from init_sequence_f[] -> init_func_i2c() ->
> > i2c_init() -> i2c_init() == __i2c_init() -> i2c_init_bus() ->
> > I2C_ADAP->init(), although I didn't validate that in the running code,
> > just by code inspection.
>
> Oh, with the options Tegra has enabled, perhaps the call sequence is:
>
> board_init_f() (which uses init_sequence_f[]) -> init_func_i2c() ->
> i2c_init_all(), which then calls:
>
> * i2c_init_board(), which is supposed to parse DT
> * i2c_set_bus_num(), which will call I2C_ADAP->init
>
> However, according to the comments near the top of arch/arm/lib/crt0.S,
> board_init_f() is called in an environment where variable data (.data,
> .bss) is not available, hence i2c_init_board() cannot possibly operate
> correctly since its whole purpose is to fill in variable data structures
> from DT.
>

I suppose you could mark i2c_controllers so that it is in the data section
with __attribute__((section(".data"))). That's what eynos does, for
example. It is valid since SPL or BCT has set up the SDRAM.


>
> I think the only way to solve this is not to use DT to instantiate
> devices, or to move the I2C initialization after relocation etc.,
> although the latter won't work on boards that need I2C up in order to
> initialize DRAM.
>
> It seems like much of U-Boot's initialization architecture simply wasn't
> designed to accommodate dynamically initializing devices from DT.
>

True, although remember that very little init happens before relocation.
Here, I2C has moved to pre-reloc. But the vast majority of it happens after
reloc, so the actual impact of this problem is small, and there is a
workaround (above).

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 21:21           ` Simon Glass
@ 2013-07-30 21:32             ` Stephen Warren
  2013-07-30 21:46               ` Simon Glass
  0 siblings, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-07-30 21:32 UTC (permalink / raw)
  To: u-boot

On 07/30/2013 03:21 PM, Simon Glass wrote:
> On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren <swarren@wwwdotorg.org
> <mailto:swarren@wwwdotorg.org>> wrote:
...
>     Oh, with the options Tegra has enabled, perhaps the call sequence is:
> 
>     board_init_f() (which uses init_sequence_f[]) -> init_func_i2c() ->
>     i2c_init_all(), which then calls:
> 
>     * i2c_init_board(), which is supposed to parse DT
>     * i2c_set_bus_num(), which will call I2C_ADAP->init
> 
>     However, according to the comments near the top of arch/arm/lib/crt0.S,
>     board_init_f() is called in an environment where variable data (.data,
>     .bss) is not available, hence i2c_init_board() cannot possibly operate
>     correctly since its whole purpose is to fill in variable data structures
>     from DT.
> 
> 
> I suppose you could mark i2c_controllers so that it is in the data
> section with __attribute__((section(".data"))). That's what eynos does,
> for example. It is valid since SPL or BCT has set up the SDRAM.

Neither .data nor .bss is available. Only .rodata and .text are.

In practice, perhaps we can assume that it will work on Tegra because we
know the DRAM is already set up, but then that makes Tegra work in some
strange special-case way, and completely violates the constraints
described in crt0.S. We should be striving to unify how all the
different chips work, rather than adding yet more strange special-cases
to the initialization sequence to hack around systemic problems.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 21:21           ` Stephen Warren
@ 2013-07-30 21:45             ` Simon Glass
  0 siblings, 0 replies; 104+ messages in thread
From: Simon Glass @ 2013-07-30 21:45 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 30, 2013 at 3:21 PM, Stephen Warren <swarren@wwwdotorg.org>wrote:

> On 07/30/2013 03:19 PM, Simon Glass wrote:
> > Hi Stephen,
> >
> > On Tue, Jul 30, 2013 at 1:22 PM, Stephen Warren <swarren@wwwdotorg.org
> > <mailto:swarren@wwwdotorg.org>> wrote:
> ...
> >     I think when init_sequence_f[] is running, there may be no serial
> >     console to report errors. If so, moving the I2C initialization to
> that
> >     early point sounds like a really bad idea.
> >
> >
> > Not really - when you see the U-Boot banner the console is working, and
> > we clearly see the U-Boot banner before i2c init happens.
>
> I thought it got buffered up and only actually sent to the UART much
> later, and not in the case when something failed since U-Boot wouldn't
> get that far? Or, did that proposal get shot down?
>

There is an option to buffer output until console_init_f() is called, but
that is called very early...

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 21:32             ` Stephen Warren
@ 2013-07-30 21:46               ` Simon Glass
  2013-07-30 21:51                 ` Stephen Warren
  0 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-07-30 21:46 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 30, 2013 at 3:32 PM, Stephen Warren <swarren@wwwdotorg.org>wrote:

> On 07/30/2013 03:21 PM, Simon Glass wrote:
> > On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren <swarren@wwwdotorg.org
> > <mailto:swarren@wwwdotorg.org>> wrote:
> ...
> >     Oh, with the options Tegra has enabled, perhaps the call sequence is:
> >
> >     board_init_f() (which uses init_sequence_f[]) -> init_func_i2c() ->
> >     i2c_init_all(), which then calls:
> >
> >     * i2c_init_board(), which is supposed to parse DT
> >     * i2c_set_bus_num(), which will call I2C_ADAP->init
> >
> >     However, according to the comments near the top of
> arch/arm/lib/crt0.S,
> >     board_init_f() is called in an environment where variable data
> (.data,
> >     .bss) is not available, hence i2c_init_board() cannot possibly
> operate
> >     correctly since its whole purpose is to fill in variable data
> structures
> >     from DT.
> >
> >
> > I suppose you could mark i2c_controllers so that it is in the data
> > section with __attribute__((section(".data"))). That's what eynos does,
> > for example. It is valid since SPL or BCT has set up the SDRAM.
>
> Neither .data nor .bss is available. Only .rodata and .text are.
>

.data is available, honest. We rely on it. During relocation it gets copied.


>
> In practice, perhaps we can assume that it will work on Tegra because we
> know the DRAM is already set up, but then that makes Tegra work in some
> strange special-case way, and completely violates the constraints
> described in crt0.S. We should be striving to unify how all the
> different chips work, rather than adding yet more strange special-cases
> to the initialization sequence to hack around systemic problems.
>

Sure, this is up to you. I was just suggesting something that works and
requires little effort. It isn't pure, agreed.

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 21:46               ` Simon Glass
@ 2013-07-30 21:51                 ` Stephen Warren
  2013-07-30 22:05                   ` Simon Glass
  2013-07-30 22:09                   ` Albert ARIBAUD
  0 siblings, 2 replies; 104+ messages in thread
From: Stephen Warren @ 2013-07-30 21:51 UTC (permalink / raw)
  To: u-boot

On 07/30/2013 03:46 PM, Simon Glass wrote:
> On Tue, Jul 30, 2013 at 3:32 PM, Stephen Warren <swarren@wwwdotorg.org
> <mailto:swarren@wwwdotorg.org>> wrote:
> 
>     On 07/30/2013 03:21 PM, Simon Glass wrote:
>     > On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren
>     <swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>
>     > <mailto:swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>>> wrote:
>     ...
>     >     Oh, with the options Tegra has enabled, perhaps the call
>     sequence is:
>     >
>     >     board_init_f() (which uses init_sequence_f[]) ->
>     init_func_i2c() ->
>     >     i2c_init_all(), which then calls:
>     >
>     >     * i2c_init_board(), which is supposed to parse DT
>     >     * i2c_set_bus_num(), which will call I2C_ADAP->init
>     >
>     >     However, according to the comments near the top of
>     arch/arm/lib/crt0.S,
>     >     board_init_f() is called in an environment where variable data
>     (.data,
>     >     .bss) is not available, hence i2c_init_board() cannot possibly
>     operate
>     >     correctly since its whole purpose is to fill in variable data
>     structures
>     >     from DT.
>     >
>     >
>     > I suppose you could mark i2c_controllers so that it is in the data
>     > section with __attribute__((section(".data"))). That's what eynos
>     does,
>     > for example. It is valid since SPL or BCT has set up the SDRAM.
> 
>     Neither .data nor .bss is available. Only .rodata and .text are.
> 
> 
> .data is available, honest. We rely on it. During relocation it gets copied.

It gets copied so that it ends up in RAM. It is assumed that before
relocation, all .text/.rodata/.data is in ROM and can't be modified, and
.bss in inaccessible. Technically that means we could read .data before
relocation, but certainly not write to it.

Now in practice yes, it does work to write to .data before relocation on
platforms where the U-Boot binary isn't actually in flash, but is
already in ROM. However as I mention, code cannot rely on that.

If any of this isn't true, then the documentation in crt0.S is wrong.
I'm CC'ing Albert to see if that's the case.

>     In practice, perhaps we can assume that it will work on Tegra because we
>     know the DRAM is already set up, but then that makes Tegra work in some
>     strange special-case way, and completely violates the constraints
>     described in crt0.S. We should be striving to unify how all the
>     different chips work, rather than adding yet more strange special-cases
>     to the initialization sequence to hack around systemic problems.
> 
> 
> Sure, this is up to you. I was just suggesting something that works and
> requires little effort. It isn't pure, agreed.

The simplest approach is probably to revert the patch in question, since
it clearly violates how U-Boot is supposed to work.

It's not really up to me; I think someone like Albert should make the
decision since he controls the ARM U-Boot architecture, or Tom as Tegra
maintainer, or perhaps you as your patch broke the code.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 21:51                 ` Stephen Warren
@ 2013-07-30 22:05                   ` Simon Glass
  2013-07-31  5:46                     ` Heiko Schocher
  2013-07-30 22:09                   ` Albert ARIBAUD
  1 sibling, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-07-30 22:05 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Tue, Jul 30, 2013 at 3:51 PM, Stephen Warren <swarren@wwwdotorg.org>wrote:

> On 07/30/2013 03:46 PM, Simon Glass wrote:
> > On Tue, Jul 30, 2013 at 3:32 PM, Stephen Warren <swarren@wwwdotorg.org
> > <mailto:swarren@wwwdotorg.org>> wrote:
> >
> >     On 07/30/2013 03:21 PM, Simon Glass wrote:
> >     > On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren
> >     <swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>
> >     > <mailto:swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>>>
> wrote:
> >     ...
> >     >     Oh, with the options Tegra has enabled, perhaps the call
> >     sequence is:
> >     >
> >     >     board_init_f() (which uses init_sequence_f[]) ->
> >     init_func_i2c() ->
> >     >     i2c_init_all(), which then calls:
> >     >
> >     >     * i2c_init_board(), which is supposed to parse DT
> >     >     * i2c_set_bus_num(), which will call I2C_ADAP->init
> >     >
> >     >     However, according to the comments near the top of
> >     arch/arm/lib/crt0.S,
> >     >     board_init_f() is called in an environment where variable data
> >     (.data,
> >     >     .bss) is not available, hence i2c_init_board() cannot possibly
> >     operate
> >     >     correctly since its whole purpose is to fill in variable data
> >     structures
> >     >     from DT.
> >     >
> >     >
> >     > I suppose you could mark i2c_controllers so that it is in the data
> >     > section with __attribute__((section(".data"))). That's what eynos
> >     does,
> >     > for example. It is valid since SPL or BCT has set up the SDRAM.
> >
> >     Neither .data nor .bss is available. Only .rodata and .text are.
> >
> >
> > .data is available, honest. We rely on it. During relocation it gets
> copied.
>
> It gets copied so that it ends up in RAM. It is assumed that before
> relocation, all .text/.rodata/.data is in ROM and can't be modified, and
> .bss in inaccessible. Technically that means we could read .data before
> relocation, but certainly not write to it.
>
> Now in practice yes, it does work to write to .data before relocation on
> platforms where the U-Boot binary isn't actually in flash, but is
> already in ROM. However as I mention, code cannot rely on that.
>
> If any of this isn't true, then the documentation in crt0.S is wrong.
> I'm CC'ing Albert to see if that's the case.
>

In practice in the SPL case (which tegra sort-of uses) there is earlier
step before U-Boot which sets up SDRAM, so it is (I think) always true that
U-Boot is running from RAM. I guess the longer term plan is to allow some
sort of pre-reloc malloc(), which would work for any machine, but I'm not
sure if anyone is working on it.


>
> >     In practice, perhaps we can assume that it will work on Tegra
> because we
> >     know the DRAM is already set up, but then that makes Tegra work in
> some
> >     strange special-case way, and completely violates the constraints
> >     described in crt0.S. We should be striving to unify how all the
> >     different chips work, rather than adding yet more strange
> special-cases
> >     to the initialization sequence to hack around systemic problems.
> >
> >
> > Sure, this is up to you. I was just suggesting something that works and
> > requires little effort. It isn't pure, agreed.
>
> The simplest approach is probably to revert the patch in question, since
> it clearly violates how U-Boot is supposed to work.
>
> It's not really up to me; I think someone like Albert should make the
> decision since he controls the ARM U-Boot architecture, or Tom as Tegra
> maintainer, or perhaps you as your patch broke the code.
>

My '(just for illustration, please don't merge)' patch from last October?
:-)

I did offer to look at this for seaboard if it helps, once we agree on a
solution, but if you have a solution in mind, please go ahead.

Regards,
SImon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 21:51                 ` Stephen Warren
  2013-07-30 22:05                   ` Simon Glass
@ 2013-07-30 22:09                   ` Albert ARIBAUD
  2013-07-30 22:11                     ` Simon Glass
                                       ` (2 more replies)
  1 sibling, 3 replies; 104+ messages in thread
From: Albert ARIBAUD @ 2013-07-30 22:09 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Tue, 30 Jul 2013 15:51:44 -0600, Stephen Warren
<swarren@wwwdotorg.org> wrote:

> On 07/30/2013 03:46 PM, Simon Glass wrote:
> > On Tue, Jul 30, 2013 at 3:32 PM, Stephen Warren <swarren@wwwdotorg.org
> > <mailto:swarren@wwwdotorg.org>> wrote:
> > 
> >     On 07/30/2013 03:21 PM, Simon Glass wrote:
> >     > On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren
> >     <swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>
> >     > <mailto:swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>>> wrote:
> >     ...
> >     >     Oh, with the options Tegra has enabled, perhaps the call
> >     sequence is:
> >     >
> >     >     board_init_f() (which uses init_sequence_f[]) ->
> >     init_func_i2c() ->
> >     >     i2c_init_all(), which then calls:
> >     >
> >     >     * i2c_init_board(), which is supposed to parse DT
> >     >     * i2c_set_bus_num(), which will call I2C_ADAP->init
> >     >
> >     >     However, according to the comments near the top of
> >     arch/arm/lib/crt0.S,
> >     >     board_init_f() is called in an environment where variable data
> >     (.data,
> >     >     .bss) is not available, hence i2c_init_board() cannot possibly
> >     operate
> >     >     correctly since its whole purpose is to fill in variable data
> >     structures
> >     >     from DT.
> >     >
> >     >
> >     > I suppose you could mark i2c_controllers so that it is in the data
> >     > section with __attribute__((section(".data"))). That's what eynos
> >     does,
> >     > for example. It is valid since SPL or BCT has set up the SDRAM.
> > 
> >     Neither .data nor .bss is available. Only .rodata and .text are.
> > 
> > 
> > .data is available, honest. We rely on it. During relocation it gets copied.
> 
> It gets copied so that it ends up in RAM. It is assumed that before
> relocation, all .text/.rodata/.data is in ROM and can't be modified, and
> .bss in inaccessible. Technically that means we could read .data before
> relocation, but certainly not write to it.

Indeed, initialized data happens to be readable before relocation, but
writing to data, on the other hand, is strictly forbidden. Before
relocation, that is, while within board_init_f() the only writable area
is GD.

> Now in practice yes, it does work to write to .data before relocation on
> platforms where the U-Boot binary isn't actually in flash, but is
> already in ROM. However as I mention, code cannot rely on that.

Already in RAM, not ROM -- and indeed, one should not rely on this.

> If any of this isn't true, then the documentation in crt0.S is wrong.
> I'm CC'ing Albert to see if that's the case.
> 
> >     In practice, perhaps we can assume that it will work on Tegra because we
> >     know the DRAM is already set up, but then that makes Tegra work in some
> >     strange special-case way, and completely violates the constraints
> >     described in crt0.S. We should be striving to unify how all the
> >     different chips work, rather than adding yet more strange special-cases
> >     to the initialization sequence to hack around systemic problems.
> > 
> > 
> > Sure, this is up to you. I was just suggesting something that works and
> > requires little effort. It isn't pure, agreed.
> 
> The simplest approach is probably to revert the patch in question, since
> it clearly violates how U-Boot is supposed to work.
> 
> It's not really up to me; I think someone like Albert should make the
> decision since he controls the ARM U-Boot architecture, or Tom as Tegra
> maintainer, or perhaps you as your patch broke the code.

board_init_f() is supposed to initialize just enough of the system to
allow relocation. Is initializing i2c necessary in this context?

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 22:09                   ` Albert ARIBAUD
@ 2013-07-30 22:11                     ` Simon Glass
  2013-07-31  5:18                     ` Wolfgang Denk
  2013-07-31  5:52                     ` Heiko Schocher
  2 siblings, 0 replies; 104+ messages in thread
From: Simon Glass @ 2013-07-30 22:11 UTC (permalink / raw)
  To: u-boot

Hi Albert,

On Tue, Jul 30, 2013 at 4:09 PM, Albert ARIBAUD
<albert.u.boot@aribaud.net>wrote:

> Hi Stephen,
>
> On Tue, 30 Jul 2013 15:51:44 -0600, Stephen Warren
> <swarren@wwwdotorg.org> wrote:
>
> > On 07/30/2013 03:46 PM, Simon Glass wrote:
> > > On Tue, Jul 30, 2013 at 3:32 PM, Stephen Warren <swarren@wwwdotorg.org
> > > <mailto:swarren@wwwdotorg.org>> wrote:
> > >
> > >     On 07/30/2013 03:21 PM, Simon Glass wrote:
> > >     > On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren
> > >     <swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>
> > >     > <mailto:swarren at wwwdotorg.org <mailto:swarren@wwwdotorg.org>>>
> wrote:
> > >     ...
> > >     >     Oh, with the options Tegra has enabled, perhaps the call
> > >     sequence is:
> > >     >
> > >     >     board_init_f() (which uses init_sequence_f[]) ->
> > >     init_func_i2c() ->
> > >     >     i2c_init_all(), which then calls:
> > >     >
> > >     >     * i2c_init_board(), which is supposed to parse DT
> > >     >     * i2c_set_bus_num(), which will call I2C_ADAP->init
> > >     >
> > >     >     However, according to the comments near the top of
> > >     arch/arm/lib/crt0.S,
> > >     >     board_init_f() is called in an environment where variable
> data
> > >     (.data,
> > >     >     .bss) is not available, hence i2c_init_board() cannot
> possibly
> > >     operate
> > >     >     correctly since its whole purpose is to fill in variable data
> > >     structures
> > >     >     from DT.
> > >     >
> > >     >
> > >     > I suppose you could mark i2c_controllers so that it is in the
> data
> > >     > section with __attribute__((section(".data"))). That's what eynos
> > >     does,
> > >     > for example. It is valid since SPL or BCT has set up the SDRAM.
> > >
> > >     Neither .data nor .bss is available. Only .rodata and .text are.
> > >
> > >
> > > .data is available, honest. We rely on it. During relocation it gets
> copied.
> >
> > It gets copied so that it ends up in RAM. It is assumed that before
> > relocation, all .text/.rodata/.data is in ROM and can't be modified, and
> > .bss in inaccessible. Technically that means we could read .data before
> > relocation, but certainly not write to it.
>
> Indeed, initialized data happens to be readable before relocation, but
> writing to data, on the other hand, is strictly forbidden. Before
> relocation, that is, while within board_init_f() the only writable area
> is GD.
>
> > Now in practice yes, it does work to write to .data before relocation on
> > platforms where the U-Boot binary isn't actually in flash, but is
> > already in ROM. However as I mention, code cannot rely on that.
>
> Already in RAM, not ROM -- and indeed, one should not rely on this.
>
> > If any of this isn't true, then the documentation in crt0.S is wrong.
> > I'm CC'ing Albert to see if that's the case.
> >
> > >     In practice, perhaps we can assume that it will work on Tegra
> because we
> > >     know the DRAM is already set up, but then that makes Tegra work in
> some
> > >     strange special-case way, and completely violates the constraints
> > >     described in crt0.S. We should be striving to unify how all the
> > >     different chips work, rather than adding yet more strange
> special-cases
> > >     to the initialization sequence to hack around systemic problems.
> > >
> > >
> > > Sure, this is up to you. I was just suggesting something that works and
> > > requires little effort. It isn't pure, agreed.
> >
> > The simplest approach is probably to revert the patch in question, since
> > it clearly violates how U-Boot is supposed to work.
> >
> > It's not really up to me; I think someone like Albert should make the
> > decision since he controls the ARM U-Boot architecture, or Tom as Tegra
> > maintainer, or perhaps you as your patch broke the code.
>
> board_init_f() is supposed to initialize just enough of the system to
> allow relocation. Is initializing i2c necessary in this context?
>

I'm not sure. There must be some reason for those i2c_init calls in
board_init_f() - or are they purely historical?

>
> Amicalement,
> --
> Albert.
>

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 18:56       ` Stephen Warren
@ 2013-07-31  4:29         ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31  4:29 UTC (permalink / raw)
  To: u-boot

Hello Stephen

Am 30.07.2013 20:56, schrieb Stephen Warren:
> On 07/29/2013 10:28 PM, Heiko Schocher wrote:
>> Hello Stephen,
>>
>> Am 29.07.2013 18:12, schrieb Stephen Warren:
>>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>>> From: Simon Glass<sjg@chromium.org>
>>>>
>>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and
>>>> the Tegra
>>>> i2c driver to support this.
>>>
>>> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
>>
>> :-(
>>
>> Could you enable debug printf?
>>
>>> bisect" points at this patch. Olof reported the issue to me.
>>
>> Thanks!
>>
>>> Can you take a look at the code and see what might be wrong? Thanks.
>>
>> Yep.
>>
>>> I suspect some kind of initialization ordering issue, since the boot
>>> messages are:
>>>
>>> -----
>>> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>>
>>> TEGRA30
>>> Board: NVIDIA Beaver
>>> I2C:   Caller requested bad clock: periph=-49, parent=2
>>> -----
>>>
>>> ... and that "bad clock" message implies to me that the I2C driver is
>>> initializing before it has parsed the correct clock ID out of device
>>> tree.
>>
>> Hmm... looking in the patch ... I can see nothing which changes
>> some initializing order ...
>>
>> @Simon: Do you have an idea?
>>
>> just found some wrong settings for tegra30:
>>
>> In include/configs/tegra30-common.h:
>> /* Total I2C ports on Tegra30 */
>> #define TEGRA_I2C_NUM_CONTROLLERS       5
>>
>> README says:
>>                 - drivers/i2c/tegra_i2c.c:
>>                  - activate this driver with CONFIG_SYS_I2C_TEGRA
>>                  - This driver adds 4 i2c buses with a fix speed from
>>                    100000 and the slave addr 0!
>
> I think that's just stale documentation; Tegra20 had just 4 I2C
> controllers, and the docs probably weren't updated for Tegra30 which has 5.
>
>> end yes, in the i2c driver are only 4 ports activated ... this
>
> I don't see any limit in the driver; everything seems to use
> TEGRA_I2C_NUM_CONTROLLERS.
>
>> should be changed ... but I think, this has nothing to do with
>> your problem ... but try to add in the i2c driver one more i2c adapter
>> for the case TEGRA_I2C_NUM_CONTROLLERS>  4

As I wrote here, add (at the end of the file):

#if TEGRA_I2C_NUM_CONTROLLERS > 4
U_BOOT_I2C_ADAP_COMPLETE(tegra4, tegra_i2c_init, tegra_i2c_probe,
                          tegra_i2c_read, tegra_i2c_write,
                          tegra_i2c_set_bus_speed, 100000, 0, 4)
#endif

bye,
Heiko

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 19:22       ` Stephen Warren
  2013-07-30 20:00         ` Stephen Warren
  2013-07-30 21:19         ` Simon Glass
@ 2013-07-31  5:01         ` Heiko Schocher
  2 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31  5:01 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 30.07.2013 21:22, schrieb Stephen Warren:
> On 07/29/2013 10:28 PM, Heiko Schocher wrote:
>> Hello Stephen,
>>
>> Am 29.07.2013 18:12, schrieb Stephen Warren:
>>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>>> From: Simon Glass<sjg@chromium.org>
>>>>
>>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and
>>>> the Tegra
>>>> i2c driver to support this.
>>>
>>> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
>>> bisect" points at this patch. Olof reported the issue to me.
>>> Can you take a look at the code and see what might be wrong? Thanks.
>>>
>>> I suspect some kind of initialization ordering issue, since the boot
>>> messages are:
>>>
>>> -----
>>> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>>
>>> TEGRA30
>>> Board: NVIDIA Beaver
>>> I2C:   Caller requested bad clock: periph=-49, parent=2
>>> -----
>>>
>>> ... and that "bad clock" message implies to me that the I2C driver is
>>> initializing before it has parsed the correct clock ID out of device
>>> tree.
>>
>> Hmm... looking in the patch ... I can see nothing which changes
>> some initializing order ...
>
> Yes, there's some initialization order issue; before this patch, I see
> the I2C controller initialization, followed by some usage of it:

Ok, great!

> ----------
> U-Boot SPL 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
> U-Boot 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
>
> TEGRA30
> Board: NVIDIA Beaver
> DRAM:  2 GiB
> i2c: controller bus 0 at 7000d000, periph_id 47, speed 100000: ok
> i2c: controller bus 1 at 7000c000, periph_id 12, speed 100000: ok
> i2c: controller bus 2 at 7000c400, periph_id 54, speed 100000: ok
> i2c: controller bus 3 at 7000c500, periph_id 67, speed 100000: ok
> i2c: controller bus 4 at 7000c700, periph_id 103, speed 100000: ok
> MMC:   i2c_write: chip=0x2d, addr=0x32, len=0x1
> ----------
>
> However with this patch applied, something starts using the controller
> immediately, without it having been "probed" from device-tree:

Hmm... do you have a debugger?

> ----------
> U-Boot SPL 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
> U-Boot 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
>
> TEGRA30
> Board: NVIDIA Beaver
> I2C:   i2c_init(speed=100000, slaveaddr=0xfe)
> ----------
>
> i2c_init touches HW, but since process_nodes() hasn't run, none of the
> parameters like register address or clock ID are yet known.
>
i> I think this call comes from init_sequence_f[] ->  init_func_i2c() ->
> i2c_init() ->  i2c_init() == __i2c_init() ->  i2c_init_bus() ->

No, we have now defined CONFIG_SYS_I2C and this calls

i2c_init_all() -> i2c_init_board()

and I think, on nvidia board i2c_init_board is defined. Yes, in the
i2c driver there it is ... calling process_nodes() ... so, the i2c
busses should be setup ...

> I2C_ADAP->init(), although I didn't validate that in the running code,
> just by code inspection.
>
> The issue here is that the I2C core and/or Tegra driver seems to be
> statically registering the I2C device objects, even though they should
> be dynamically registered from device tree.

Feel free to post patches.

> Should Tegra move its call of i2c_init_board() out of board_init() to
> board_init_f(), and/or override __i2c_init() to call i2c_init_board()?

No, i2c_init_board gets called here very early:
init_func_i2c() -> i2c_init_all():

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);
}

and we have CONFIG_SYS_I2C defined (or, did you have it?)

and in drivers/i2c/i2c_core.c:
void i2c_init_all(void)
{
         i2c_init_board();
         i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
         return;
}

Ah, I see, it is also called in board_init ...

> I think when init_sequence_f[] is running, there may be no serial
> console to report errors. If so, moving the I2C initialization to that
> early point sounds like a really bad idea.

No, we need i2c before relocation for example to read SPD data
from eeprom, but this is on powerpc.
puts() is working, as your log shows.

I added in the comment from i2c_init_all:
/*
  * 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.
  */

So the question raises, do we need this on arm?

bye,
Heiko

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 20:00         ` Stephen Warren
  2013-07-30 21:21           ` Simon Glass
@ 2013-07-31  5:03           ` Heiko Schocher
  2013-08-05 19:21           ` Stephen Warren
  2 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31  5:03 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 30.07.2013 22:00, schrieb Stephen Warren:
> On 07/30/2013 01:22 PM, Stephen Warren wrote:
>> On 07/29/2013 10:28 PM, Heiko Schocher wrote:
>>> Hello Stephen,
>>>
>>> Am 29.07.2013 18:12, schrieb Stephen Warren:
>>>> On 05/04/2013 06:01 AM, Heiko Schocher wrote:
>>>>> From: Simon Glass<sjg@chromium.org>
>>>>>
>>>>> This enables CONFIG_SYS_I2C on Tegra, updating existing boards and
>>>>> the Tegra
>>>>> i2c driver to support this.
>>>>
>>>> Heiko, the latest U-Boot tree hangs during boot on Tegra, and "git
>>>> bisect" points at this patch. Olof reported the issue to me.
>>>> Can you take a look at the code and see what might be wrong? Thanks.
>>>>
>>>> I suspect some kind of initialization ordering issue, since the boot
>>>> messages are:
>>>>
>>>> -----
>>>> U-Boot SPL 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>>> U-Boot 2013.07-rc3-00038-g880540d (Jul 29 2013 - 10:04:37)
>>>>
>>>> TEGRA30
>>>> Board: NVIDIA Beaver
>>>> I2C:   Caller requested bad clock: periph=-49, parent=2
>>>> -----
>>>>
>>>> ... and that "bad clock" message implies to me that the I2C driver is
>>>> initializing before it has parsed the correct clock ID out of device
>>>> tree.
>>>
>>> Hmm... looking in the patch ... I can see nothing which changes
>>> some initializing order ...
>>
>> Yes, there's some initialization order issue; before this patch, I see
>> the I2C controller initialization, followed by some usage of it:
>>
>> ----------
>> U-Boot SPL 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
>> U-Boot 2013.07-rc3-00036-gd84eb85-dirty (Jul 30 2013 - 13:04:47)
>>
>> TEGRA30
>> Board: NVIDIA Beaver
>> DRAM:  2 GiB
>> i2c: controller bus 0 at 7000d000, periph_id 47, speed 100000: ok
>> i2c: controller bus 1 at 7000c000, periph_id 12, speed 100000: ok
>> i2c: controller bus 2 at 7000c400, periph_id 54, speed 100000: ok
>> i2c: controller bus 3 at 7000c500, periph_id 67, speed 100000: ok
>> i2c: controller bus 4 at 7000c700, periph_id 103, speed 100000: ok
>> MMC:   i2c_write: chip=0x2d, addr=0x32, len=0x1
>> ----------
>>
>> However with this patch applied, something starts using the controller
>> immediately, without it having been "probed" from device-tree:
>>
>> ----------
>> U-Boot SPL 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
>> U-Boot 2013.07-rc3-00037-g1f2ba72-dirty (Jul 30 2013 - 13:08:28)
>>
>> TEGRA30
>> Board: NVIDIA Beaver
>> I2C:   i2c_init(speed=100000, slaveaddr=0xfe)
>> ----------
>>
>> i2c_init touches HW, but since process_nodes() hasn't run, none of the
>> parameters like register address or clock ID are yet known.
>>
>> I think this call comes from init_sequence_f[] ->  init_func_i2c() ->
>> i2c_init() ->  i2c_init() == __i2c_init() ->  i2c_init_bus() ->
>> I2C_ADAP->init(), although I didn't validate that in the running code,
>> just by code inspection.
>
> Oh, with the options Tegra has enabled, perhaps the call sequence is:
>
> board_init_f() (which uses init_sequence_f[]) ->  init_func_i2c() ->
> i2c_init_all(), which then calls:
>
> * i2c_init_board(), which is supposed to parse DT
> * i2c_set_bus_num(), which will call I2C_ADAP->init
>
> However, according to the comments near the top of arch/arm/lib/crt0.S,
> board_init_f() is called in an environment where variable data (.data,
> .bss) is not available, hence i2c_init_board() cannot possibly operate
> correctly since its whole purpose is to fill in variable data structures
> from DT.

Yes, you are right, this would not work on tegra.

> I think the only way to solve this is not to use DT to instantiate
> devices, or to move the I2C initialization after relocation etc.,
> although the latter won't work on boards that need I2C up in order to
> initialize DRAM.

Yes.

> It seems like much of U-Boot's initialization architecture simply wasn't
> designed to accommodate dynamically initializing devices from DT.

Yes.

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 22:09                   ` Albert ARIBAUD
  2013-07-30 22:11                     ` Simon Glass
@ 2013-07-31  5:18                     ` Wolfgang Denk
  2013-07-31  5:55                       ` Heiko Schocher
  2013-07-31  7:06                       ` Albert ARIBAUD
  2013-07-31  5:52                     ` Heiko Schocher
  2 siblings, 2 replies; 104+ messages in thread
From: Wolfgang Denk @ 2013-07-31  5:18 UTC (permalink / raw)
  To: u-boot

Dear Albert ARIBAUD,

In message <20130731000921.724f5c71@lilith> you wrote:
> 
> board_init_f() is supposed to initialize just enough of the system to
> allow relocation. Is initializing i2c necessary in this context?

On some boards, yes.  For example, if they store the environment in an
I2C attached EEPROM. Then you need I2C support early, before console,
to read for example the baudrate setting.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Every time history repeats itself the price goes up.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 22:05                   ` Simon Glass
@ 2013-07-31  5:46                     ` Heiko Schocher
  2013-07-31 19:31                       ` Stephen Warren
  0 siblings, 1 reply; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31  5:46 UTC (permalink / raw)
  To: u-boot

Hello Simon,

Am 31.07.2013 00:05, schrieb Simon Glass:
> Hi Stephen,
>
> On Tue, Jul 30, 2013 at 3:51 PM, Stephen Warren<swarren@wwwdotorg.org>wrote:
>
>> On 07/30/2013 03:46 PM, Simon Glass wrote:
>>> On Tue, Jul 30, 2013 at 3:32 PM, Stephen Warren<swarren@wwwdotorg.org
>>> <mailto:swarren@wwwdotorg.org>>  wrote:
>>>
>>>      On 07/30/2013 03:21 PM, Simon Glass wrote:
>>>      >  On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren
>>>      <swarren at wwwdotorg.org<mailto:swarren@wwwdotorg.org>
>>>      >  <mailto:swarren at wwwdotorg.org<mailto:swarren@wwwdotorg.org>>>
>> wrote:
[...]
>>>      In practice, perhaps we can assume that it will work on Tegra
>> because we
>>>      know the DRAM is already set up, but then that makes Tegra work in
>> some
>>>      strange special-case way, and completely violates the constraints
>>>      described in crt0.S. We should be striving to unify how all the
>>>      different chips work, rather than adding yet more strange
>> special-cases
>>>      to the initialization sequence to hack around systemic problems.
>>>
>>>
>>> Sure, this is up to you. I was just suggesting something that works and
>>> requires little effort. It isn't pure, agreed.
>>
>> The simplest approach is probably to revert the patch in question, since
>> it clearly violates how U-Boot is supposed to work.
>>
>> It's not really up to me; I think someone like Albert should make the
>> decision since he controls the ARM U-Boot architecture, or Tom as Tegra
>> maintainer, or perhaps you as your patch broke the code.
>>
>
> My '(just for illustration, please don't merge)' patch from last October?
> :-)

:-(

I thought you are testing the tegra plattforms with this patchset,
as you triggered a few times, when this will go to mainline ...

> I did offer to look at this for seaboard if it helps, once we agree on a
> solution, but if you have a solution in mind, please go ahead.

Yes, lets go ahead.

A goal of the i2c rework is to get rid of all i2c_init* calls
around the code, and only use i2c_set_bus_num() before accessing
the i2c subsystem (which looks if it needs to switch to this bus,
is it initialized, muxes setup, ... ) ... maybe add the "bus"
parameter as a second step to the i2c api, and i2c_set_bus_num()
is no longer needed, just internal in the i2c subsystem ...

Maybe we can make i2c_init_func() weak (in the CONFIG_SYS_I2C case),
and define it only on such boards, which need i2c so early?
(Or remove it for the CONFIG_SYS_I2C completely, so boards which
  need early i2c access and switch to the new framework would add
  a i2c_set_bus_num() where they need it ...)

Hmm.. each i2c adapter has its own init function ... why the tegra
driver do not use it? And do the necessary inits in it? So we
initialize an adapater only if we use it, which is also a rule
for u-boot ...

I have no hw, but it should be possible to add to process_nodes()
a parameter "controller_number" and call
process_nodes(controller_number, ...) from the i2c drivers init
function ...

So I see two steps:
- make i2c_init_func weak, and define this function only on boards
   which need i2c so early, or remove it completely ... and see
   which boards fail.
- change i2c tegra driver as described above

Maybe this is a way to go?

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 22:09                   ` Albert ARIBAUD
  2013-07-30 22:11                     ` Simon Glass
  2013-07-31  5:18                     ` Wolfgang Denk
@ 2013-07-31  5:52                     ` Heiko Schocher
  2 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31  5:52 UTC (permalink / raw)
  To: u-boot

Hello Albert,

Am 31.07.2013 00:09, schrieb Albert ARIBAUD:
> Hi Stephen,
>
> On Tue, 30 Jul 2013 15:51:44 -0600, Stephen Warren
> <swarren@wwwdotorg.org>  wrote:
>
>> On 07/30/2013 03:46 PM, Simon Glass wrote:
>>> On Tue, Jul 30, 2013 at 3:32 PM, Stephen Warren<swarren@wwwdotorg.org
>>> <mailto:swarren@wwwdotorg.org>>  wrote:
>>>
>>>      On 07/30/2013 03:21 PM, Simon Glass wrote:
>>>      >  On Tue, Jul 30, 2013 at 2:00 PM, Stephen Warren
>>>      <swarren at wwwdotorg.org<mailto:swarren@wwwdotorg.org>
>>>      >  <mailto:swarren at wwwdotorg.org<mailto:swarren@wwwdotorg.org>>>  wrote:
>>>      ...
>>>      >      Oh, with the options Tegra has enabled, perhaps the call
>>>      sequence is:
>>>      >
>>>      >      board_init_f() (which uses init_sequence_f[]) ->
>>>      init_func_i2c() ->
>>>      >      i2c_init_all(), which then calls:
>>>      >
>>>      >      * i2c_init_board(), which is supposed to parse DT
>>>      >      * i2c_set_bus_num(), which will call I2C_ADAP->init
>>>      >
>>>      >      However, according to the comments near the top of
>>>      arch/arm/lib/crt0.S,
>>>      >      board_init_f() is called in an environment where variable data
>>>      (.data,
>>>      >      .bss) is not available, hence i2c_init_board() cannot possibly
>>>      operate
>>>      >      correctly since its whole purpose is to fill in variable data
>>>      structures
>>>      >      from DT.
>>>      >
>>>      >
>>>      >  I suppose you could mark i2c_controllers so that it is in the data
>>>      >  section with __attribute__((section(".data"))). That's what eynos
>>>      does,
>>>      >  for example. It is valid since SPL or BCT has set up the SDRAM.
>>>
>>>      Neither .data nor .bss is available. Only .rodata and .text are.
>>>
>>>
>>> .data is available, honest. We rely on it. During relocation it gets copied.
>>
>> It gets copied so that it ends up in RAM. It is assumed that before
>> relocation, all .text/.rodata/.data is in ROM and can't be modified, and
>> .bss in inaccessible. Technically that means we could read .data before
>> relocation, but certainly not write to it.
>
> Indeed, initialized data happens to be readable before relocation, but
> writing to data, on the other hand, is strictly forbidden. Before
> relocation, that is, while within board_init_f() the only writable area
> is GD.

Yes.

>> Now in practice yes, it does work to write to .data before relocation on
>> platforms where the U-Boot binary isn't actually in flash, but is
>> already in ROM. However as I mention, code cannot rely on that.
>
> Already in RAM, not ROM -- and indeed, one should not rely on this.
>
>> If any of this isn't true, then the documentation in crt0.S is wrong.
>> I'm CC'ing Albert to see if that's the case.
>>
>>>      In practice, perhaps we can assume that it will work on Tegra because we
>>>      know the DRAM is already set up, but then that makes Tegra work in some
>>>      strange special-case way, and completely violates the constraints
>>>      described in crt0.S. We should be striving to unify how all the
>>>      different chips work, rather than adding yet more strange special-cases
>>>      to the initialization sequence to hack around systemic problems.
>>>
>>>
>>> Sure, this is up to you. I was just suggesting something that works and
>>> requires little effort. It isn't pure, agreed.
>>
>> The simplest approach is probably to revert the patch in question, since
>> it clearly violates how U-Boot is supposed to work.
>>
>> It's not really up to me; I think someone like Albert should make the
>> decision since he controls the ARM U-Boot architecture, or Tom as Tegra
>> maintainer, or perhaps you as your patch broke the code.
>
> board_init_f() is supposed to initialize just enough of the system to
> allow relocation. Is initializing i2c necessary in this context?

Not on tegra I think. It is needed for example for reading ram setup
data from an eeprom ...

maybe we should do here:

- remove init_func_i2c() completly from board_init_f, as a goal
   from the new i2c framework is, to get rid of i2c_init* calls
   all over the code. If boards fail, they should add i2c_set_bus_num()
   where they need it
   - or at least make init_func_i2c() weak, and define it only
   on boards, which need it.
- adapt i2c tegra driver:
   each i2c adapter has its own init function. Do the necessary
   inits there for the i2c tegra driver.

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  5:18                     ` Wolfgang Denk
@ 2013-07-31  5:55                       ` Heiko Schocher
  2013-07-31  7:06                       ` Albert ARIBAUD
  1 sibling, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31  5:55 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang,

Am 31.07.2013 07:18, schrieb Wolfgang Denk:
> Dear Albert ARIBAUD,
>
> In message<20130731000921.724f5c71@lilith>  you wrote:
>>
>> board_init_f() is supposed to initialize just enough of the system to
>> allow relocation. Is initializing i2c necessary in this context?
>
> On some boards, yes.  For example, if they store the environment in an
> I2C attached EEPROM. Then you need I2C support early, before console,
> to read for example the baudrate setting.

Ah, yes. Hmm.. how did in such a case the puts() call in init_func_i2c()
work?

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  5:18                     ` Wolfgang Denk
  2013-07-31  5:55                       ` Heiko Schocher
@ 2013-07-31  7:06                       ` Albert ARIBAUD
  2013-07-31  7:36                         ` Heiko Schocher
  2013-07-31 19:39                         ` Wolfgang Denk
  1 sibling, 2 replies; 104+ messages in thread
From: Albert ARIBAUD @ 2013-07-31  7:06 UTC (permalink / raw)
  To: u-boot

Hi Wolfgang,

On Wed, 31 Jul 2013 07:18:21 +0200, Wolfgang Denk <wd@denx.de> wrote:

> Dear Albert ARIBAUD,
> 
> In message <20130731000921.724f5c71@lilith> you wrote:
> > 
> > board_init_f() is supposed to initialize just enough of the system to
> > allow relocation. Is initializing i2c necessary in this context?
> 
> On some boards, yes.  For example, if they store the environment in an
> I2C attached EEPROM. Then you need I2C support early, before console,
> to read for example the baudrate setting.

Thanks, so some I2C reads are needed. Next question: on these boards,
do these I2C reads require DT reads? Maybe a few hard-coded low level
I2C reads are enough. I guess DT writes are completely unneeded at
that point. Also, why exactly do I2C and, as the case may be, DT, need
to write to .data?

More generally, while I think the board_init_f() part of U-Boot should
be as short and compact as possible, I understand and admit that it
might have to read from just about any (local) storage resource, be it
environment or DT or any stored information it needs.

On the other hand, it may be hard to immediately know what functions
throughout U-boot are safe to call from within board_init_f(); maybe we
should start thinking about checking and marking these, the simplest
way being to suffix them with "_f" once we have made sure they are safe
to call from within board_init_f().

But we should strictly limit the scope of board_init_f() or we'll find
the board_init_f()/board_init_r() pair following a patch similar to the
SPL/U-Boot pair, where SPL started out as a tiny helper piece of code
and ending up a resizeable (and, I dare to say, sizeable as well) kind
of U-boot. If we let too many features slip in board_init_f(), it'll
blur into a board_init_r() like and before we know it, it'll *require*
DDR, and write access to it too...

So, board_init_() should *strictly* be limited to setting up a console
(for information purposes) and giving access to DDR while in the same
time never writing to it itself. Bonus points if it can limit itself to
*enabling* and postpone any *optimizing*(I am thinking of DDR settings
here and no, I don't have specific existing cases in mind; just sayin').

In the present instance, I'd rather we either:

- removed dependency on DT etc. by using "hard-coded" low level I2C
  reads for those boards that need it (I assume that for each of these
  boards the I2C slave, offset, and length to read are constant) in _f
  phase, or

- parsed the _f phase looking for offending functions or calls which
  write to .data or .bss and fix them, suffixing them with _f; in
  essence, that amounts to starting the implementation of my suggestion
  above alongside fixing the issue at hand.

The first approach is rather "let's bring the thing back up first", so
it does not have my preference, but I would understand the need to
quickly fix things.

The second approach seems to be going in the same direction as Heiko's
proposal of 07:52 +0200, which I thus second provided it is applicable
to all the boards Wolfgang had in mind.

> Best regards,
> 
> Wolfgang Denk

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  7:06                       ` Albert ARIBAUD
@ 2013-07-31  7:36                         ` Heiko Schocher
  2013-07-31  8:16                           ` Albert ARIBAUD
  2013-07-31 19:39                         ` Wolfgang Denk
  1 sibling, 1 reply; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31  7:36 UTC (permalink / raw)
  To: u-boot

Hello Albert,

Am 31.07.2013 09:06, schrieb Albert ARIBAUD:
> Hi Wolfgang,
>
> On Wed, 31 Jul 2013 07:18:21 +0200, Wolfgang Denk<wd@denx.de>  wrote:
>
>> Dear Albert ARIBAUD,
>>
>> In message<20130731000921.724f5c71@lilith>  you wrote:
>>>
>>> board_init_f() is supposed to initialize just enough of the system to
>>> allow relocation. Is initializing i2c necessary in this context?
>>
>> On some boards, yes.  For example, if they store the environment in an
>> I2C attached EEPROM. Then you need I2C support early, before console,
>> to read for example the baudrate setting.
>
> Thanks, so some I2C reads are needed. Next question: on these boards,
> do these I2C reads require DT reads? Maybe a few hard-coded low level

If I understand the tegra driver, dt reads are needed for init
the i2c driver ... but this should be done in the i2c driver
init function ... and this should be possible without writes

> I2C reads are enough. I guess DT writes are completely unneeded at
> that point. Also, why exactly do I2C and, as the case may be, DT, need
> to write to .data?

I2c do not write before relocation (I hope so), see:
drivers/i2c/i2c_core.c

All writes to internal i2c structs are (should be) protected by a:

if (gd->flags & GD_FLG_RELOC) {

but using i2c write/reads are possible.

> More generally, while I think the board_init_f() part of U-Boot should
> be as short and compact as possible, I understand and admit that it
> might have to read from just about any (local) storage resource, be it
> environment or DT or any stored information it needs.
>
> On the other hand, it may be hard to immediately know what functions
> throughout U-boot are safe to call from within board_init_f(); maybe we
> should start thinking about checking and marking these, the simplest
> way being to suffix them with "_f" once we have made sure they are safe
> to call from within board_init_f().

Hmmm... Maybe instead we should think (also in thinking common bring
up for all boards) about:

getting rid of board_init_f in u-boot code, instead use for all
boards spl code to init needed things and copy and relocate u-boot
to ram in spl code ... so we have in u-boot no longer such
restictions ... but thats just an idea which whirs in my head ...
without thinking to deep in it.

But this approach would have some advantages ...

> But we should strictly limit the scope of board_init_f() or we'll find
> the board_init_f()/board_init_r() pair following a patch similar to the
> SPL/U-Boot pair, where SPL started out as a tiny helper piece of code
> and ending up a resizeable (and, I dare to say, sizeable as well) kind
> of U-boot. If we let too many features slip in board_init_f(), it'll
> blur into a board_init_r() like and before we know it, it'll *require*
> DDR, and write access to it too...
>
> So, board_init_() should *strictly* be limited to setting up a console
> (for information purposes) and giving access to DDR while in the same
> time never writing to it itself. Bonus points if it can limit itself to
> *enabling* and postpone any *optimizing*(I am thinking of DDR settings
> here and no, I don't have specific existing cases in mind; just sayin').
>
> In the present instance, I'd rather we either:
>
> - removed dependency on DT etc. by using "hard-coded" low level I2C
>    reads for those boards that need it (I assume that for each of these
>    boards the I2C slave, offset, and length to read are constant) in _f
>    phase, or

But DT is used for initializing the i2c driver in tegra ...

> - parsed the _f phase looking for offending functions or calls which
>    write to .data or .bss and fix them, suffixing them with _f; in
>    essence, that amounts to starting the implementation of my suggestion
>    above alongside fixing the issue at hand.
>
> The first approach is rather "let's bring the thing back up first", so
> it does not have my preference, but I would understand the need to
> quickly fix things.

Yes.

> The second approach seems to be going in the same direction as Heiko's
> proposal of 07:52 +0200, which I thus second provided it is applicable
> to all the boards Wolfgang had in mind.

Lets do us this step as fixup ;-)

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  7:36                         ` Heiko Schocher
@ 2013-07-31  8:16                           ` Albert ARIBAUD
  2013-07-31  8:31                             ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Albert ARIBAUD @ 2013-07-31  8:16 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Wed, 31 Jul 2013 09:36:19 +0200, Heiko Schocher <hs@denx.de> wrote:

> > On the other hand, it may be hard to immediately know what functions
> > throughout U-boot are safe to call from within board_init_f(); maybe we
> > should start thinking about checking and marking these, the simplest
> > way being to suffix them with "_f" once we have made sure they are safe
> > to call from within board_init_f().
> 
> Hmmm... Maybe instead we should think (also in thinking common bring
> up for all boards) about:
> 
> getting rid of board_init_f in u-boot code, instead use for all
> boards spl code to init needed things and copy and relocate u-boot
> to ram in spl code ... so we have in u-boot no longer such
> restictions ... but thats just an idea which whirs in my head ...
> without thinking to deep in it.
> 
> But this approach would have some advantages ...

Well, the original SPL was basically board_init_f() plus some code to
copy U-Boot from wherever it was to DDR, so it was tightly linked to
board_init_f(). But... first, SPL has evolved into a "U-Boot lite"
where much can happen beyond board_init_f() -- think Falcon mode, for
instance -- and second, there are boards which do not have SPL at all,
and their board_init_f() can thus not be "moved to SPL".

So no, I don't think we can move U-Boot's design from "_f/_r" to
"SPL/U-Boot".

> > But we should strictly limit the scope of board_init_f() or we'll find
> > the board_init_f()/board_init_r() pair following a patch similar to the
> > SPL/U-Boot pair, where SPL started out as a tiny helper piece of code
> > and ending up a resizeable (and, I dare to say, sizeable as well) kind
> > of U-boot. If we let too many features slip in board_init_f(), it'll
> > blur into a board_init_r() like and before we know it, it'll *require*
> > DDR, and write access to it too...
> >
> > So, board_init_() should *strictly* be limited to setting up a console
> > (for information purposes) and giving access to DDR while in the same
> > time never writing to it itself. Bonus points if it can limit itself to
> > *enabling* and postpone any *optimizing*(I am thinking of DDR settings
> > here and no, I don't have specific existing cases in mind; just sayin').
> >
> > In the present instance, I'd rather we either:
> >
> > - removed dependency on DT etc. by using "hard-coded" low level I2C
> >    reads for those boards that need it (I assume that for each of these
> >    boards the I2C slave, offset, and length to read are constant) in _f
> >    phase, or
> 
> But DT is used for initializing the i2c driver in tegra ...

Alright, out goes this proposal. Anyway, I didn't like it best. :)

> > - parsed the _f phase looking for offending functions or calls which
> >    write to .data or .bss and fix them, suffixing them with _f; in
> >    essence, that amounts to starting the implementation of my suggestion
> >    above alongside fixing the issue at hand.
> >
> > The first approach is rather "let's bring the thing back up first", so
> > it does not have my preference, but I would understand the need to
> > quickly fix things.
> 
> Yes.
> 
> > The second approach seems to be going in the same direction as Heiko's
> > proposal of 07:52 +0200, which I thus second provided it is applicable
> > to all the boards Wolfgang had in mind.
> 
> Lets do us this step as fixup ;-)

Alright too. :)

> bye,
> Heiko

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  8:16                           ` Albert ARIBAUD
@ 2013-07-31  8:31                             ` Heiko Schocher
  2013-07-31  9:38                               ` Albert ARIBAUD
  2013-07-31 19:41                               ` Stephen Warren
  0 siblings, 2 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31  8:31 UTC (permalink / raw)
  To: u-boot

Hello Albert,

Am 31.07.2013 10:16, schrieb Albert ARIBAUD:
> Hi Heiko,
>
> On Wed, 31 Jul 2013 09:36:19 +0200, Heiko Schocher<hs@denx.de>  wrote:
>
>>> On the other hand, it may be hard to immediately know what functions
>>> throughout U-boot are safe to call from within board_init_f(); maybe we
>>> should start thinking about checking and marking these, the simplest
>>> way being to suffix them with "_f" once we have made sure they are safe
>>> to call from within board_init_f().
>>
>> Hmmm... Maybe instead we should think (also in thinking common bring
>> up for all boards) about:
>>
>> getting rid of board_init_f in u-boot code, instead use for all
>> boards spl code to init needed things and copy and relocate u-boot
>> to ram in spl code ... so we have in u-boot no longer such
>> restictions ... but thats just an idea which whirs in my head ...
>> without thinking to deep in it.
>>
>> But this approach would have some advantages ...
>
> Well, the original SPL was basically board_init_f() plus some code to
> copy U-Boot from wherever it was to DDR, so it was tightly linked to
> board_init_f(). But... first, SPL has evolved into a "U-Boot lite"
> where much can happen beyond board_init_f() -- think Falcon mode, for
> instance -- and second, there are boards which do not have SPL at all,
> and their board_init_f() can thus not be "moved to SPL".

Hmm... all boards use board_init_f ... and spl do pieces from board_init_f
So why should it not be possible to do all init things in spl code?
Code beyond board_init_f is optional ...

And yes, there are a lot of boards, which have no spl, but they
can execute spl code (thinking of the lof of powerpc boards which
booting from nor flash ... spl code can also run from nor ... and
copy the u-boot piece of the image to ram, relocate it ...)

And yes, a side effect could be, that all boards can use Falcon boot mode.

;-)

> So no, I don't think we can move U-Boot's design from "_f/_r" to
> "SPL/U-Boot".

I am not sure ...

>>> But we should strictly limit the scope of board_init_f() or we'll find
>>> the board_init_f()/board_init_r() pair following a patch similar to the
>>> SPL/U-Boot pair, where SPL started out as a tiny helper piece of code
>>> and ending up a resizeable (and, I dare to say, sizeable as well) kind
>>> of U-boot. If we let too many features slip in board_init_f(), it'll
>>> blur into a board_init_r() like and before we know it, it'll *require*
>>> DDR, and write access to it too...
>>>
>>> So, board_init_() should *strictly* be limited to setting up a console
>>> (for information purposes) and giving access to DDR while in the same
>>> time never writing to it itself. Bonus points if it can limit itself to
>>> *enabling* and postpone any *optimizing*(I am thinking of DDR settings
>>> here and no, I don't have specific existing cases in mind; just sayin').
>>>
>>> In the present instance, I'd rather we either:
>>>
>>> - removed dependency on DT etc. by using "hard-coded" low level I2C
>>>     reads for those boards that need it (I assume that for each of these
>>>     boards the I2C slave, offset, and length to read are constant) in _f
>>>     phase, or
>>
>> But DT is used for initializing the i2c driver in tegra ...
>
> Alright, out goes this proposal. Anyway, I didn't like it best. :)

Yes.

>>> - parsed the _f phase looking for offending functions or calls which
>>>     write to .data or .bss and fix them, suffixing them with _f; in
>>>     essence, that amounts to starting the implementation of my suggestion
>>>     above alongside fixing the issue at hand.
>>>
>>> The first approach is rather "let's bring the thing back up first", so
>>> it does not have my preference, but I would understand the need to
>>> quickly fix things.
>>
>> Yes.
>>
>>> The second approach seems to be going in the same direction as Heiko's
>>> proposal of 07:52 +0200, which I thus second provided it is applicable
>>> to all the boards Wolfgang had in mind.
>>
>> Lets do us this step as fixup ;-)
>
> Alright too. :)

Ok.

@Stephen, Simon: Could anyone from you do this 2 steps?

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  8:31                             ` Heiko Schocher
@ 2013-07-31  9:38                               ` Albert ARIBAUD
  2013-07-31 12:30                                 ` Simon Glass
  2013-07-31 19:41                               ` Stephen Warren
  1 sibling, 1 reply; 104+ messages in thread
From: Albert ARIBAUD @ 2013-07-31  9:38 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Wed, 31 Jul 2013 10:31:12 +0200, Heiko Schocher <hs@denx.de> wrote:

> Hello Albert,
> 
> Am 31.07.2013 10:16, schrieb Albert ARIBAUD:
> > Hi Heiko,
> >
> > On Wed, 31 Jul 2013 09:36:19 +0200, Heiko Schocher<hs@denx.de>  wrote:
> >
> >>> On the other hand, it may be hard to immediately know what functions
> >>> throughout U-boot are safe to call from within board_init_f(); maybe we
> >>> should start thinking about checking and marking these, the simplest
> >>> way being to suffix them with "_f" once we have made sure they are safe
> >>> to call from within board_init_f().
> >>
> >> Hmmm... Maybe instead we should think (also in thinking common bring
> >> up for all boards) about:
> >>
> >> getting rid of board_init_f in u-boot code, instead use for all
> >> boards spl code to init needed things and copy and relocate u-boot
> >> to ram in spl code ... so we have in u-boot no longer such
> >> restictions ... but thats just an idea which whirs in my head ...
> >> without thinking to deep in it.
> >>
> >> But this approach would have some advantages ...
> >
> > Well, the original SPL was basically board_init_f() plus some code to
> > copy U-Boot from wherever it was to DDR, so it was tightly linked to
> > board_init_f(). But... first, SPL has evolved into a "U-Boot lite"
> > where much can happen beyond board_init_f() -- think Falcon mode, for
> > instance -- and second, there are boards which do not have SPL at all,
> > and their board_init_f() can thus not be "moved to SPL".
> 
> Hmm... all boards use board_init_f ... and spl do pieces from board_init_f
> So why should it not be possible to do all init things in spl code?
> Code beyond board_init_f is optional ...

It is, in the original "SPL is just board_init_f plus some copying"
view. In the current "SPL is U-boot only not full-featured", it becomes
false.

> And yes, there are a lot of boards, which have no spl, but they
> can execute spl code (thinking of the lof of powerpc boards which
> booting from nor flash ... spl code can also run from nor ... and
> copy the u-boot piece of the image to ram, relocate it ...)
> 
> And yes, a side effect could be, that all boards can use Falcon boot mode.
> 
> ;-)
> 
> > So no, I don't think we can move U-Boot's design from "_f/_r" to
> > "SPL/U-Boot".
> 
> I am not sure ...

I see this approach of likening SPL to _f and U-boot to _r as forcing a
dual-binary model onto all boards whereas not all boards require it. I
prefer a model where _f can exist, _r can exist, and for each target,
the maintainer decides which binaries are built and for each one,
whether _f and/or _r is present and what _r does.

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  9:38                               ` Albert ARIBAUD
@ 2013-07-31 12:30                                 ` Simon Glass
  2013-07-31 13:03                                   ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-07-31 12:30 UTC (permalink / raw)
  To: u-boot

Hi,

On Wed, Jul 31, 2013 at 3:38 AM, Albert ARIBAUD
<albert.u.boot@aribaud.net>wrote:

> Hi Heiko,
>
> On Wed, 31 Jul 2013 10:31:12 +0200, Heiko Schocher <hs@denx.de> wrote:
>
> > Hello Albert,
> >
> > Am 31.07.2013 10:16, schrieb Albert ARIBAUD:
> > > Hi Heiko,
> > >
> > > On Wed, 31 Jul 2013 09:36:19 +0200, Heiko Schocher<hs@denx.de>  wrote:
> > >
> > >>> On the other hand, it may be hard to immediately know what functions
> > >>> throughout U-boot are safe to call from within board_init_f(); maybe
> we
> > >>> should start thinking about checking and marking these, the simplest
> > >>> way being to suffix them with "_f" once we have made sure they are
> safe
> > >>> to call from within board_init_f().
> > >>
> > >> Hmmm... Maybe instead we should think (also in thinking common bring
> > >> up for all boards) about:
> > >>
> > >> getting rid of board_init_f in u-boot code, instead use for all
> > >> boards spl code to init needed things and copy and relocate u-boot
> > >> to ram in spl code ... so we have in u-boot no longer such
> > >> restictions ... but thats just an idea which whirs in my head ...
> > >> without thinking to deep in it.
> > >>
> > >> But this approach would have some advantages ...
> > >
> > > Well, the original SPL was basically board_init_f() plus some code to
> > > copy U-Boot from wherever it was to DDR, so it was tightly linked to
> > > board_init_f(). But... first, SPL has evolved into a "U-Boot lite"
> > > where much can happen beyond board_init_f() -- think Falcon mode, for
> > > instance -- and second, there are boards which do not have SPL at all,
> > > and their board_init_f() can thus not be "moved to SPL".
> >
> > Hmm... all boards use board_init_f ... and spl do pieces from
> board_init_f
> > So why should it not be possible to do all init things in spl code?
> > Code beyond board_init_f is optional ...
>
> It is, in the original "SPL is just board_init_f plus some copying"
> view. In the current "SPL is U-boot only not full-featured", it becomes
> false.
>
> > And yes, there are a lot of boards, which have no spl, but they
> > can execute spl code (thinking of the lof of powerpc boards which
> > booting from nor flash ... spl code can also run from nor ... and
> > copy the u-boot piece of the image to ram, relocate it ...)
> >
> > And yes, a side effect could be, that all boards can use Falcon boot
> mode.
> >
> > ;-)
> >
> > > So no, I don't think we can move U-Boot's design from "_f/_r" to
> > > "SPL/U-Boot".
> >
> > I am not sure ...
>
> I see this approach of likening SPL to _f and U-boot to _r as forcing a
> dual-binary model onto all boards whereas not all boards require it. I
> prefer a model where _f can exist, _r can exist, and for each target,
> the maintainer decides which binaries are built and for each one,
> whether _f and/or _r is present and what _r does.
>

I am not really any clearer as to what should be done here.

Previously on ARM i2c init generally happened in board_init_r(). This has
changed now, and so boards which need to do some init (e.g. reading and
storing DT information) to make i2c work are going to have problems if they
cannot access any memory (yes we could put it in global_data I suppose).

It sounds like the need for early i2c is rare, so we could perhaps create
an option like CONFIG_SYS_EARLY_I2C to enable this?

While I agree that minimising code in board_init_f() is a great idea, if we
have one case that needs it, then we need to deal with the problem.

Although did I mention that it does seem silly to me to solve what is an
entirely hypothetical problem on Tegra and (I think) any other modern ARM
SOC that uses SPL? After all, SDRAM is fully available on these SOCs and in
fact setting that up and getting U-Boot loaded into RAM is the purpose of
the SPL stage! To my mind, SPL has taken over this responsibility of
board_init_f(). Thoughts? Maybe a minor rethink of
SPL/board_init_f()/board_init_r() is in order?

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31 12:30                                 ` Simon Glass
@ 2013-07-31 13:03                                   ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-07-31 13:03 UTC (permalink / raw)
  To: u-boot

Hello Simon,

Am 31.07.2013 14:30, schrieb Simon Glass:
> Hi,
>
> On Wed, Jul 31, 2013 at 3:38 AM, Albert ARIBAUD
> <albert.u.boot@aribaud.net>wrote:
>
>> Hi Heiko,
>>
>> On Wed, 31 Jul 2013 10:31:12 +0200, Heiko Schocher<hs@denx.de>  wrote:
>>
>>> Hello Albert,
>>>
>>> Am 31.07.2013 10:16, schrieb Albert ARIBAUD:
>>>> Hi Heiko,
>>>>
>>>> On Wed, 31 Jul 2013 09:36:19 +0200, Heiko Schocher<hs@denx.de>   wrote:
>>>>
>>>>>> On the other hand, it may be hard to immediately know what functions
>>>>>> throughout U-boot are safe to call from within board_init_f(); maybe
>> we
>>>>>> should start thinking about checking and marking these, the simplest
>>>>>> way being to suffix them with "_f" once we have made sure they are
>> safe
>>>>>> to call from within board_init_f().
>>>>>
>>>>> Hmmm... Maybe instead we should think (also in thinking common bring
>>>>> up for all boards) about:
>>>>>
>>>>> getting rid of board_init_f in u-boot code, instead use for all
>>>>> boards spl code to init needed things and copy and relocate u-boot
>>>>> to ram in spl code ... so we have in u-boot no longer such
>>>>> restictions ... but thats just an idea which whirs in my head ...
>>>>> without thinking to deep in it.
>>>>>
>>>>> But this approach would have some advantages ...
>>>>
>>>> Well, the original SPL was basically board_init_f() plus some code to
>>>> copy U-Boot from wherever it was to DDR, so it was tightly linked to
>>>> board_init_f(). But... first, SPL has evolved into a "U-Boot lite"
>>>> where much can happen beyond board_init_f() -- think Falcon mode, for
>>>> instance -- and second, there are boards which do not have SPL at all,
>>>> and their board_init_f() can thus not be "moved to SPL".
>>>
>>> Hmm... all boards use board_init_f ... and spl do pieces from
>> board_init_f
>>> So why should it not be possible to do all init things in spl code?
>>> Code beyond board_init_f is optional ...
>>
>> It is, in the original "SPL is just board_init_f plus some copying"
>> view. In the current "SPL is U-boot only not full-featured", it becomes
>> false.
>>
>>> And yes, there are a lot of boards, which have no spl, but they
>>> can execute spl code (thinking of the lof of powerpc boards which
>>> booting from nor flash ... spl code can also run from nor ... and
>>> copy the u-boot piece of the image to ram, relocate it ...)
>>>
>>> And yes, a side effect could be, that all boards can use Falcon boot
>> mode.
>>>
>>> ;-)
>>>
>>>> So no, I don't think we can move U-Boot's design from "_f/_r" to
>>>> "SPL/U-Boot".
>>>
>>> I am not sure ...
>>
>> I see this approach of likening SPL to _f and U-boot to _r as forcing a
>> dual-binary model onto all boards whereas not all boards require it. I
>> prefer a model where _f can exist, _r can exist, and for each target,
>> the maintainer decides which binaries are built and for each one,
>> whether _f and/or _r is present and what _r does.
>>
>
> I am not really any clearer as to what should be done here.
>
> Previously on ARM i2c init generally happened in board_init_r(). This has

really? The init_func_i2c() call is not introduced through the
i2c multibus approach ...

> changed now, and so boards which need to do some init (e.g. reading and
> storing DT information) to make i2c work are going to have problems if they
> cannot access any memory (yes we could put it in global_data I suppose).
>
> It sounds like the need for early i2c is rare, so we could perhaps create
> an option like CONFIG_SYS_EARLY_I2C to enable this?
>
> While I agree that minimising code in board_init_f() is a great idea, if we
> have one case that needs it, then we need to deal with the problem.

 From my side, yes. But this different to powerpc!

> Although did I mention that it does seem silly to me to solve what is an
> entirely hypothetical problem on Tegra and (I think) any other modern ARM
> SOC that uses SPL? After all, SDRAM is fully available on these SOCs and in
> fact setting that up and getting U-Boot loaded into RAM is the purpose of
> the SPL stage! To my mind, SPL has taken over this responsibility of
> board_init_f(). Thoughts? Maybe a minor rethink of
> SPL/board_init_f()/board_init_r() is in order?

Yes, but board_init_f is used in spl code, or? And it is not only
ram settings, maybe read baudrate setting in an i2c epprom ...

We can make init_func_i2c() weak, and in the first step a
dummy function and see, which boards really need it.

Nevertheless, why the tegra i2c driver do not call process_node()
from the i2c_init function? This must be fixed I think, as it
is not good to do some setup needed for i2c in board_init()
and other in i2c_init to have a working i2c adapter ...

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  5:46                     ` Heiko Schocher
@ 2013-07-31 19:31                       ` Stephen Warren
  2013-08-01  4:32                         ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-07-31 19:31 UTC (permalink / raw)
  To: u-boot

On 07/30/2013 11:46 PM, Heiko Schocher wrote:
...
> Hmm.. each i2c adapter has its own init function ... why the tegra
> driver do not use it? And do the necessary inits in it? So we
> initialize an adapater only if we use it, which is also a rule
> for u-boot ...
> 
> I have no hw, but it should be possible to add to process_nodes()
> a parameter "controller_number" and call
> process_nodes(controller_number, ...) from the i2c drivers init
> function ...

There are two steps to initializing I2C on a Tegra system:

1) Parsing the DT to determine which/how-many I2C adapters exist in the
SoC. This will yield information such as the register address of the I2C
adapters, which clock/reset signal they rely on, perhaps the max bus
clock rate, etc.

This is a single global operation that needs to happen one single time
before anything else.

This stage initializes the i2c_controllers[] array, since that's what
stores all the data parsed from DT.

2) Actually initializing or using the I2C HW. That could certainly be
part of the per-I2C-controller init() function you mention.


Now, I think the big disconnect here is that historically, the U-Boot
binary has hard-coded all the details that step (1) above parses out of
DT, so that step (1) did not need to exist.

However, Simon has been pushing Tegra towards not hard-coding any of
this information, but instead having a single binary that can work on
arbitrary Tegra boards and even across different Tegra SoCs which have a
different number of I2C controllers at different register addresses.
This is quite fundamentally different to how U-Boot has worked in the
past, and evidently has some problems fitting into the typical U-Boot
initialization sequence.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  7:06                       ` Albert ARIBAUD
  2013-07-31  7:36                         ` Heiko Schocher
@ 2013-07-31 19:39                         ` Wolfgang Denk
  1 sibling, 0 replies; 104+ messages in thread
From: Wolfgang Denk @ 2013-07-31 19:39 UTC (permalink / raw)
  To: u-boot

Dear Albert,

In message <20130731090644.2b4ce215@lilith> you wrote:
> 
> > On some boards, yes.  For example, if they store the environment in an
> > I2C attached EEPROM. Then you need I2C support early, before console,
> > to read for example the baudrate setting.
> 
> Thanks, so some I2C reads are needed. Next question: on these boards,
> do these I2C reads require DT reads? Maybe a few hard-coded low level
> I2C reads are enough. I guess DT writes are completely unneeded at
> that point. Also, why exactly do I2C and, as the case may be, DT, need
> to write to .data?

A quick check shows that it's actually more than 50 boards that store
the env in EEPROM (I'm surprised myself about this large number, given
the disadvantages of such an approach), but AFAICT none of these needs
to access the DT that early.

> More generally, while I think the board_init_f() part of U-Boot should
> be as short and compact as possible, I understand and admit that it
> might have to read from just about any (local) storage resource, be it
> environment or DT or any stored information it needs.

Agreed - actually we're entering an area hear that smells pretty
strong like device model reorganization ;-)

> So, board_init_() should *strictly* be limited to setting up a console
> (for information purposes) and giving access to DDR while in the same
> time never writing to it itself. Bonus points if it can limit itself to
> *enabling* and postpone any *optimizing*(I am thinking of DDR settings
> here and no, I don't have specific existing cases in mind; just sayin').

Agreed!


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A good marriage would be between a blind wife and deaf husband.
                                               -- Michel de Montaigne

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31  8:31                             ` Heiko Schocher
  2013-07-31  9:38                               ` Albert ARIBAUD
@ 2013-07-31 19:41                               ` Stephen Warren
  2013-08-01  4:32                                 ` Heiko Schocher
  1 sibling, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-07-31 19:41 UTC (permalink / raw)
  To: u-boot

On 07/31/2013 02:31 AM, Heiko Schocher wrote:
> Am 31.07.2013 10:16, schrieb Albert ARIBAUD:
>> On Wed, 31 Jul 2013 09:36:19 +0200, Heiko Schocher<hs@denx.de>  wrote:
...
>>>> In the present instance, I'd rather we either:
>>>>
>>>> - removed dependency on DT etc. by using "hard-coded" low level I2C
>>>>     reads for those boards that need it (I assume that for each of
>>>> these
>>>>     boards the I2C slave, offset, and length to read are constant)
>>>> in _f
>>>>     phase, or
>>>
>>> But DT is used for initializing the i2c driver in tegra ...
>>
>> Alright, out goes this proposal. Anyway, I didn't like it best. :)
> 
> Yes.
> 
>>>> - parsed the _f phase looking for offending functions or calls which
>>>>     write to .data or .bss and fix them, suffixing them with _f; in
>>>>     essence, that amounts to starting the implementation of my
>>>> suggestion
>>>>     above alongside fixing the issue at hand.
>>>>
>>>> The first approach is rather "let's bring the thing back up first", so
>>>> it does not have my preference, but I would understand the need to
>>>> quickly fix things.
>>>
>>> Yes.
>>>
>>>> The second approach seems to be going in the same direction as Heiko's
>>>> proposal of 07:52 +0200, which I thus second provided it is applicable
>>>> to all the boards Wolfgang had in mind.
>>>
>>> Lets do us this step as fixup ;-)
>>
>> Alright too. :)
> 
> Ok.
> 
> @Stephen, Simon: Could anyone from you do this 2 steps?

Sorry, I really can't tell which 2 steps you mean? I don't see any email
in any timezone with minutes==:52...

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31 19:31                       ` Stephen Warren
@ 2013-08-01  4:32                         ` Heiko Schocher
  2013-08-01  5:39                           ` Stephen Warren
  0 siblings, 1 reply; 104+ messages in thread
From: Heiko Schocher @ 2013-08-01  4:32 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 31.07.2013 21:31, schrieb Stephen Warren:
> On 07/30/2013 11:46 PM, Heiko Schocher wrote:
> ...
>> Hmm.. each i2c adapter has its own init function ... why the tegra
>> driver do not use it? And do the necessary inits in it? So we
>> initialize an adapater only if we use it, which is also a rule
>> for u-boot ...
>>
>> I have no hw, but it should be possible to add to process_nodes()
>> a parameter "controller_number" and call
>> process_nodes(controller_number, ...) from the i2c drivers init
>> function ...
>
> There are two steps to initializing I2C on a Tegra system:
>
> 1) Parsing the DT to determine which/how-many I2C adapters exist in the
> SoC. This will yield information such as the register address of the I2C
> adapters, which clock/reset signal they rely on, perhaps the max bus
> clock rate, etc.
>
> This is a single global operation that needs to happen one single time
> before anything else.

Why?

> This stage initializes the i2c_controllers[] array, since that's what
> stores all the data parsed from DT.
>
> 2) Actually initializing or using the I2C HW. That could certainly be
> part of the per-I2C-controller init() function you mention.

For that purpose is the i2c_init function.

And why we could not do step 1 when we do step 2? Why doing step 1
for hw we later do not use?

saying something like this (just as an example, should be tested):

diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 9ac3969..7bbd3c7 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -378,81 +378,91 @@ static int i2c_get_config(const void *blob, int node, struct i2c_bus *i2c_bus)
   * @param is_scs       1 if this HW uses a single clock source (T114+)
   * @return 0 if ok, -1 on error
   */
-static int process_nodes(const void *blob, int node_list[], int count,
+static int process_nodes(const void *blob, int node_list[],
+                        struct i2c_adapter *adap, int count,
                          int is_dvc, int is_scs)
  {
         struct i2c_bus *i2c_bus;
-       int i;
-
-       /* build the i2c_controllers[] for each controller */
-       for (i = 0; i < count; i++) {
-               int node = node_list[i];
+       int node = node_list[i];

-               if (node <= 0)
-                       continue;
+       bus = &i2c_controllers[adap->hwadapnr];
+       i2c_bus->id = adap->hwadapnr;

-               i2c_bus = &i2c_controllers[i];
-               i2c_bus->id = i;
+       if (node <= 0)
+               continue;

-               if (i2c_get_config(blob, node, i2c_bus)) {
-                       printf("i2c_init_board: failed to decode bus %d\n", i);
-                       return -1;
-               }
+       if (i2c_get_config(blob, node, i2c_bus)) {
+               printf("i2c_init_board: failed to decode bus %d\n", i);
+               return -1;
+       }

-               i2c_bus->is_scs = is_scs;
+       i2c_bus->is_scs = is_scs;

-               i2c_bus->is_dvc = is_dvc;
-               if (is_dvc) {
-                       i2c_bus->control =
-                               &((struct dvc_ctlr *)i2c_bus->regs)->control;
-               } else {
-                       i2c_bus->control = &i2c_bus->regs->control;
-               }
-               debug("%s: controller bus %d at %p, periph_id %d, speed %d: ",
-                     is_dvc ? "dvc" : "i2c", i, i2c_bus->regs,
-                     i2c_bus->periph_id, i2c_bus->speed);
-               i2c_init_controller(i2c_bus);
-               debug("ok\n");
-               i2c_bus->inited = 1;
-
-               /* Mark position as used */
-               node_list[i] = -1;
+       i2c_bus->is_dvc = is_dvc;
+       if (is_dvc) {
+               i2c_bus->control =
+                       &((struct dvc_ctlr *)i2c_bus->regs)->control;
+       } else {
+               i2c_bus->control = &i2c_bus->regs->control;
         }
+       debug("%s: controller bus %d at %p, periph_id %d, speed %d: ",
+             is_dvc ? "dvc" : "i2c", i, i2c_bus->regs,
+             i2c_bus->periph_id, i2c_bus->speed);
+       i2c_init_controller(i2c_bus);
+       debug("ok\n");
+       i2c_bus->inited = 1;
+
+       /* Mark position as used */
+       node_list[i] = -1;

         return 0;
  }

  /* Sadly there is no error return from this function */
-void i2c_init_board(void)
+static int tegra_i2c_init_board(struct i2c_adapter *adap)
  {
+       struct i2c_bus *i2c_bus;
         int node_list[TEGRA_I2C_NUM_CONTROLLERS];
         const void *blob = gd->fdt_blob;
         int count;

+       bus = tegra_i2c_get_bus(adap);
+        if (bus)
+                return 0;
+
         /* First check for newer (T114+) I2C ports */
         count = fdtdec_find_aliases_for_id(blob, "i2c",
                         COMPAT_NVIDIA_TEGRA114_I2C, node_list,
                         TEGRA_I2C_NUM_CONTROLLERS);
-       if (process_nodes(blob, node_list, count, 0, 1))
-               return;
+       if (process_nodes(blob, node_list, adap, count, 0, 1))
+               return -1;

         /* Now get the older (T20/T30) normal I2C ports */
         count = fdtdec_find_aliases_for_id(blob, "i2c",
                         COMPAT_NVIDIA_TEGRA20_I2C, node_list,
                         TEGRA_I2C_NUM_CONTROLLERS);
-       if (process_nodes(blob, node_list, count, 0, 0))
-               return;
+       if (process_nodes(blob, node_list, adap, count, 0, 0))
+               return -1;

         /* Now look for dvc ports */
         count = fdtdec_add_aliases_for_id(blob, "i2c",
                         COMPAT_NVIDIA_TEGRA20_DVC, node_list,
                         TEGRA_I2C_NUM_CONTROLLERS);
-       if (process_nodes(blob, node_list, count, 1, 0))
-               return;
+       if (process_nodes(blob, node_list, adap, count, 1, 0))
+               return -1;
+
+       return 0;
  }

  static void tegra_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
  {
+       int ret;
+
+       ret = tegra_i2c_init_board(adap);
+       if (ret) {
+               printf("Could not decode bus: %d\n", adap->hwadapnr);
+               return;
+       }
         /* This will override the speed selected in the fdt for that port */
         debug("i2c_init(speed=%u, slaveaddr=0x%x)\n", speed, slaveaddr);
         i2c_set_bus_speed(speed);

Which will call process_nodes() from the i2c_init function, which only
is called, when i2c bus get used ...

> Now, I think the big disconnect here is that historically, the U-Boot
> binary has hard-coded all the details that step (1) above parses out of
> DT, so that step (1) did not need to exist.
>
> However, Simon has been pushing Tegra towards not hard-coding any of
> this information, but instead having a single binary that can work on
> arbitrary Tegra boards and even across different Tegra SoCs which have a
> different number of I2C controllers at different register addresses.
> This is quite fundamentally different to how U-Boot has worked in the
> past, and evidently has some problems fitting into the typical U-Boot
> initialization sequence.

Yes ... but again, if we parse the DT in the moment we need to init
a hw, it would fit again (at least for the dt case). But we have a
problem, if we need to write (like the i2c_controllers[] array) before
relocation. So I2C and DT usage is not possible before relocation.
(And not only i2c in conjunction with dt 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 related	[flat|nested] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-31 19:41                               ` Stephen Warren
@ 2013-08-01  4:32                                 ` Heiko Schocher
  0 siblings, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-08-01  4:32 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 31.07.2013 21:41, schrieb Stephen Warren:
> On 07/31/2013 02:31 AM, Heiko Schocher wrote:
>> Am 31.07.2013 10:16, schrieb Albert ARIBAUD:
>>> On Wed, 31 Jul 2013 09:36:19 +0200, Heiko Schocher<hs@denx.de>   wrote:
> ...
>>>>> In the present instance, I'd rather we either:
>>>>>
>>>>> - removed dependency on DT etc. by using "hard-coded" low level I2C
>>>>>      reads for those boards that need it (I assume that for each of
>>>>> these
>>>>>      boards the I2C slave, offset, and length to read are constant)
>>>>> in _f
>>>>>      phase, or
>>>>
>>>> But DT is used for initializing the i2c driver in tegra ...
>>>
>>> Alright, out goes this proposal. Anyway, I didn't like it best. :)
>>
>> Yes.
>>
>>>>> - parsed the _f phase looking for offending functions or calls which
>>>>>      write to .data or .bss and fix them, suffixing them with _f; in
>>>>>      essence, that amounts to starting the implementation of my
>>>>> suggestion
>>>>>      above alongside fixing the issue at hand.
>>>>>
>>>>> The first approach is rather "let's bring the thing back up first", so
>>>>> it does not have my preference, but I would understand the need to
>>>>> quickly fix things.
>>>>
>>>> Yes.
>>>>
>>>>> The second approach seems to be going in the same direction as Heiko's
>>>>> proposal of 07:52 +0200, which I thus second provided it is applicable
>>>>> to all the boards Wolfgang had in mind.
>>>>
>>>> Lets do us this step as fixup ;-)
>>>
>>> Alright too. :)
>>
>> Ok.
>>
>> @Stephen, Simon: Could anyone from you do this 2 steps?
>
> Sorry, I really can't tell which 2 steps you mean? I don't see any email
> in any timezone with minutes==:52...

http://lists.denx.de/pipermail/u-boot/2013-July/159853.html
(you were also on Cc ...)

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01  4:32                         ` Heiko Schocher
@ 2013-08-01  5:39                           ` Stephen Warren
  2013-08-01  6:02                             ` Heiko Schocher
  0 siblings, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-08-01  5:39 UTC (permalink / raw)
  To: u-boot

On 07/31/2013 10:32 PM, Heiko Schocher wrote:
> Hello Stephen,
> 
> Am 31.07.2013 21:31, schrieb Stephen Warren:
>> On 07/30/2013 11:46 PM, Heiko Schocher wrote:
>> ...
>>> Hmm.. each i2c adapter has its own init function ... why the tegra
>>> driver do not use it? And do the necessary inits in it? So we
>>> initialize an adapater only if we use it, which is also a rule
>>> for u-boot ...
>>>
>>> I have no hw, but it should be possible to add to process_nodes()
>>> a parameter "controller_number" and call
>>> process_nodes(controller_number, ...) from the i2c drivers init
>>> function ...
>>
>> There are two steps to initializing I2C on a Tegra system:
>>
>> 1) Parsing the DT to determine which/how-many I2C adapters exist in the
>> SoC. This will yield information such as the register address of the I2C
>> adapters, which clock/reset signal they rely on, perhaps the max bus
>> clock rate, etc.
>>
>> This is a single global operation that needs to happen one single time
>> before anything else.
> 
> Why?

That's simply the way the code is written.

>> This stage initializes the i2c_controllers[] array, since that's what
>> stores all the data parsed from DT.
>>
>> 2) Actually initializing or using the I2C HW. That could certainly be
>> part of the per-I2C-controller init() function you mention.
> 
> For that purpose is the i2c_init function.
> 
> And why we could not do step 1 when we do step 2? Why doing step 1
> for hw we later do not use?

I suppose you could. It seems conceptually /far/ simpler to just scan
the DT once up-front rather than having to defer all this stuff until
you actually use an I2C bus. If you do that, how can you know how many
I2C buses exist without trying to use every possible one and seeing
which fail? Also, the mapping from I2C bus number to register address is
only created by actually scanning the whole DT; there's no need to every
I2C DT node to have a /aliases entry that dictates its U-Boot device ID,
so you really do have to scan everything completely up-front before you
can determine which registers to use.

> saying something like this (just as an example, should be tested):
> 
> diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
> index 9ac3969..7bbd3c7 100644
> --- a/drivers/i2c/tegra_i2c.c
> +++ b/drivers/i2c/tegra_i2c.c
> @@ -378,81 +378,91 @@ static int i2c_get_config(const void *blob, int
> node, struct i2c_bus *i2c_bus)
>   * @param is_scs       1 if this HW uses a single clock source (T114+)
>   * @return 0 if ok, -1 on error
>   */
> -static int process_nodes(const void *blob, int node_list[], int count,
> +static int process_nodes(const void *blob, int node_list[],
> +                        struct i2c_adapter *adap, int count,
>                          int is_dvc, int is_scs)
>  {
>         struct i2c_bus *i2c_bus;
> -       int i;
> -
> -       /* build the i2c_controllers[] for each controller */
> -       for (i = 0; i < count; i++) {
> -               int node = node_list[i];
> +       int node = node_list[i];

How do you determine i here? There's no guarantee that all I2C DT nodes
end up being processed in a single call to process_nodes(); there might
be some "Tegra20 I2C", some "Tegra20 I2C DVC", some "Tegra30 I2C"
modules in the same SoC.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01  5:39                           ` Stephen Warren
@ 2013-08-01  6:02                             ` Heiko Schocher
  2013-08-01  6:53                               ` Albert ARIBAUD
  2013-08-01 20:32                               ` Stephen Warren
  0 siblings, 2 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-08-01  6:02 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 01.08.2013 07:39, schrieb Stephen Warren:
> On 07/31/2013 10:32 PM, Heiko Schocher wrote:
>> Hello Stephen,
>>
>> Am 31.07.2013 21:31, schrieb Stephen Warren:
>>> On 07/30/2013 11:46 PM, Heiko Schocher wrote:
>>> ...
>>>> Hmm.. each i2c adapter has its own init function ... why the tegra
>>>> driver do not use it? And do the necessary inits in it? So we
>>>> initialize an adapater only if we use it, which is also a rule
>>>> for u-boot ...
>>>>
>>>> I have no hw, but it should be possible to add to process_nodes()
>>>> a parameter "controller_number" and call
>>>> process_nodes(controller_number, ...) from the i2c drivers init
>>>> function ...
>>>
>>> There are two steps to initializing I2C on a Tegra system:
>>>
>>> 1) Parsing the DT to determine which/how-many I2C adapters exist in the
>>> SoC. This will yield information such as the register address of the I2C
>>> adapters, which clock/reset signal they rely on, perhaps the max bus
>>> clock rate, etc.
>>>
>>> This is a single global operation that needs to happen one single time
>>> before anything else.
>>
>> Why?
>
> That's simply the way the code is written.

Ok.

>>> This stage initializes the i2c_controllers[] array, since that's what
>>> stores all the data parsed from DT.
>>>
>>> 2) Actually initializing or using the I2C HW. That could certainly be
>>> part of the per-I2C-controller init() function you mention.
>>
>> For that purpose is the i2c_init function.
>>
>> And why we could not do step 1 when we do step 2? Why doing step 1
>> for hw we later do not use?
>
> I suppose you could. It seems conceptually /far/ simpler to just scan
> the DT once up-front rather than having to defer all this stuff until

on the other hand we ring for every ms boot time ... and here we want
to scan a complete dt with maybe a lot of nodes, we do not want to
use?

> you actually use an I2C bus. If you do that, how can you know how many
> I2C buses exist without trying to use every possible one and seeing

Do I really need to know that?

> which fail? Also, the mapping from I2C bus number to register address is

Hmm.. there are max TEGRA_I2C_NUM_CONTROLLERS. If one gets used,
it scans the dt ... if only 1 adapter is used, only one is activated
through i2c_init ...

> only created by actually scanning the whole DT; there's no need to every
> I2C DT node to have a /aliases entry that dictates its U-Boot device ID,
> so you really do have to scan everything completely up-front before you
> can determine which registers to use.

But the i2c bus number is coded static all over the u-boot code (Should
be changed) in the code. Saying a board has an i2c eeprom on bus "2",
it calls i2c_set_bus_number(2) ... this "2" must be somewhere in the dt
or?

If this "2" is used on different boards with the same u-boot code only
different in dt, bus 2 maybe not exist ...
or if you change the order of i2c nodes in the dt "2" is no longer
"2" ... or?

>> saying something like this (just as an example, should be tested):
>>
>> diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
>> index 9ac3969..7bbd3c7 100644
>> --- a/drivers/i2c/tegra_i2c.c
>> +++ b/drivers/i2c/tegra_i2c.c
>> @@ -378,81 +378,91 @@ static int i2c_get_config(const void *blob, int
>> node, struct i2c_bus *i2c_bus)
>>    * @param is_scs       1 if this HW uses a single clock source (T114+)
>>    * @return 0 if ok, -1 on error
>>    */
>> -static int process_nodes(const void *blob, int node_list[], int count,
>> +static int process_nodes(const void *blob, int node_list[],
>> +                        struct i2c_adapter *adap, int count,
>>                           int is_dvc, int is_scs)
>>   {
>>          struct i2c_bus *i2c_bus;
>> -       int i;
>> -
>> -       /* build the i2c_controllers[] for each controller */
>> -       for (i = 0; i<  count; i++) {
>> -               int node = node_list[i];
>> +       int node = node_list[i];
>
> How do you determine i here? There's no guarantee that all I2C DT nodes

adap->hwadapnr

as in drivers/i2c/tegra_i2c.c:

static struct i2c_bus *tegra_i2c_get_bus(struct i2c_adapter *adap)
{
         struct i2c_bus *bus;

         bus = &i2c_controllers[adap->hwadapnr];
[...]

> end up being processed in a single call to process_nodes(); there might
> be some "Tegra20 I2C", some "Tegra20 I2C DVC", some "Tegra30 I2C"
> modules in the same SoC.

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01  6:02                             ` Heiko Schocher
@ 2013-08-01  6:53                               ` Albert ARIBAUD
  2013-08-01  8:38                                 ` Heiko Schocher
  2013-08-01 20:34                                 ` Stephen Warren
  2013-08-01 20:32                               ` Stephen Warren
  1 sibling, 2 replies; 104+ messages in thread
From: Albert ARIBAUD @ 2013-08-01  6:53 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Thu, 01 Aug 2013 08:02:42 +0200, Heiko Schocher <hs@denx.de> wrote:

> > I suppose you could. It seems conceptually /far/ simpler to just scan
> > the DT once up-front rather than having to defer all this stuff until
> 
> on the other hand we ring for every ms boot time ... and here we want
> to scan a complete dt with maybe a lot of nodes, we do not want to
> use?

Scanning all of DT seems to imply it has no strict or standard
ordering. Could we mandate, suggest, of make it so that all entries in
the DT needed at _f time are put first, and even maybe place an "end of
_f" custom marker in DT to delimit them? (I assume that, for the sake of
Postel-ism, anything in DT which is not understandable is skipped, so
other users of the DT than us would not even be annoyed by such a
marker)

This way, we'd avoid wasting time scanning most of the DT in this case.

Note: I confess I don't even know at the moment how DT is structured, so
I may have talked complete nonsense above. If so, please forgive me and
point me to some DT 101 course for me to avoid shame (at least on this
topic) in the future.

> bye,
> Heiko

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01  6:53                               ` Albert ARIBAUD
@ 2013-08-01  8:38                                 ` Heiko Schocher
  2013-08-01 14:22                                   ` Simon Glass
  2013-08-01 20:14                                   ` Albert ARIBAUD
  2013-08-01 20:34                                 ` Stephen Warren
  1 sibling, 2 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-08-01  8:38 UTC (permalink / raw)
  To: u-boot

Hello Albert,

Am 01.08.2013 08:53, schrieb Albert ARIBAUD:
> Hi Heiko,
>
> On Thu, 01 Aug 2013 08:02:42 +0200, Heiko Schocher<hs@denx.de>  wrote:
>
>>> I suppose you could. It seems conceptually /far/ simpler to just scan
>>> the DT once up-front rather than having to defer all this stuff until
>>
>> on the other hand we ring for every ms boot time ... and here we want
>> to scan a complete dt with maybe a lot of nodes, we do not want to
>> use?
>
> Scanning all of DT seems to imply it has no strict or standard
> ordering. Could we mandate, suggest, of make it so that all entries in
> the DT needed at _f time are put first, and even maybe place an "end of
> _f" custom marker in DT to delimit them? (I assume that, for the sake of

I do not know, if this is possible, as I think the DT used in U-Boot
should be the same as used in linux ... or?

> Postel-ism, anything in DT which is not understandable is skipped, so
> other users of the DT than us would not even be annoyed by such a
> marker)
>
> This way, we'd avoid wasting time scanning most of the DT in this case.

Hmm.. why should we introduce such things, instead of scanning the
node only if we need it?

We have "only" the problem, that we could not write to data at this
moment ... but this problem should be solved in a seperate topic.
I2C is usable before relocation, the problem is in conjunction with
dt, that we can not save for example the base address of the controller,
which we get from the DT ... If I understand it correct!

So we need an option when using dt, that we have (small ram) in which
we can write some parameters parsed from dt ...

I think this problem have all subsystems used before relocation.
(for example: environment on a spi flash?)

As Wolfgang said:
"Agreed - actually we're entering an area hear that smells pretty
strong like device model reorganization :-)"

BTW: How is this problem solved with the device model approach?

> Note: I confess I don't even know at the moment how DT is structured, so
> I may have talked complete nonsense above. If so, please forgive me and
> point me to some DT 101 course for me to avoid shame (at least on this
> topic) in the future.

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01  8:38                                 ` Heiko Schocher
@ 2013-08-01 14:22                                   ` Simon Glass
  2013-08-01 15:06                                     ` Heiko Schocher
  2013-08-01 20:16                                     ` Albert ARIBAUD
  2013-08-01 20:14                                   ` Albert ARIBAUD
  1 sibling, 2 replies; 104+ messages in thread
From: Simon Glass @ 2013-08-01 14:22 UTC (permalink / raw)
  To: u-boot

Hi,

On Thu, Aug 1, 2013 at 2:38 AM, Heiko Schocher <hs@denx.de> wrote:

> Hello Albert,
>
> Am 01.08.2013 08:53, schrieb Albert ARIBAUD:
>
>  Hi Heiko,
>>
>> On Thu, 01 Aug 2013 08:02:42 +0200, Heiko Schocher<hs@denx.de>  wrote:
>>
>>  I suppose you could. It seems conceptually /far/ simpler to just scan
>>>> the DT once up-front rather than having to defer all this stuff until
>>>>
>>>
>>> on the other hand we ring for every ms boot time ... and here we want
>>> to scan a complete dt with maybe a lot of nodes, we do not want to
>>> use?
>>>
>>
>> Scanning all of DT seems to imply it has no strict or standard
>> ordering. Could we mandate, suggest, of make it so that all entries in
>> the DT needed at _f time are put first, and even maybe place an "end of
>> _f" custom marker in DT to delimit them? (I assume that, for the sake of
>>
>
> I do not know, if this is possible, as I think the DT used in U-Boot
> should be the same as used in linux ... or?
>
>
>  Postel-ism, anything in DT which is not understandable is skipped, so
>> other users of the DT than us would not even be annoyed by such a
>> marker)
>>
>> This way, we'd avoid wasting time scanning most of the DT in this case.
>>
>
> Hmm.. why should we introduce such things, instead of scanning the
> node only if we need it?
>
> We have "only" the problem, that we could not write to data at this
> moment ... but this problem should be solved in a seperate topic.
> I2C is usable before relocation, the problem is in conjunction with
> dt, that we can not save for example the base address of the controller,
> which we get from the DT ... If I understand it correct!
>
> So we need an option when using dt, that we have (small ram) in which
> we can write some parameters parsed from dt ...
>
> I think this problem have all subsystems used before relocation.
> (for example: environment on a spi flash?)
>
>
I think using a small RAM is a good approach. At least it is better than
pretending there is no RAM at all. We currently have no facility to
allocate RAM before relocation, other than to use the .data section. We can
use global_data but that won't scale well for many drivers adding their own
stuff in there. Samsung's driver uses .data, I don't think it is a big deal.

One option I should mention is to decode the I2C FDT nodes each time it is
needed prior to relocation (i.e. to the stack), use it for the transaction,
and throw it away. This is quite painful IMO this it involves putting calls
in the driver to check if we are pre-reloc and have a stack space used
every time. On tegra20 this would be 130 bytes or so. I mention it because
console working this way for a while (decoding the console again on every
byte).

Options as I see it:

- just fudge it for now and use .data (deal with it later with driver model)
- change the meaning of board_init_f() such that memory may be available
(e.g. if run from SPL)
- decode the FDT nodes every time we need them (ick)
- adjust the ordering so that I2C normally happens post reloc except for
specific platforms with a CONFIG defined (Heiko, the difference as I
understand it is that with your patch CONFIG_HARD_I2C or CONFIG_SOFT_I2C
are now defined, and so I2C happens prior to reloc now)


>
> As Wolfgang said:
> "Agreed - actually we're entering an area hear that smells pretty
> strong like device model reorganization :-)"
>
> BTW: How is this problem solved with the device model approach?


More that we need to solve it, probably with a limited malloc() pre-reloc.

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01 14:22                                   ` Simon Glass
@ 2013-08-01 15:06                                     ` Heiko Schocher
  2013-08-01 20:16                                     ` Albert ARIBAUD
  1 sibling, 0 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-08-01 15:06 UTC (permalink / raw)
  To: u-boot

Hello Simon,

Am 01.08.2013 16:22, schrieb Simon Glass:
> Hi,
>
> On Thu, Aug 1, 2013 at 2:38 AM, Heiko Schocher<hs@denx.de>  wrote:
>
>> Hello Albert,
>>
>> Am 01.08.2013 08:53, schrieb Albert ARIBAUD:
>>
>>   Hi Heiko,
>>>
>>> On Thu, 01 Aug 2013 08:02:42 +0200, Heiko Schocher<hs@denx.de>   wrote:
>>>
>>>   I suppose you could. It seems conceptually /far/ simpler to just scan
>>>>> the DT once up-front rather than having to defer all this stuff until
>>>>>
>>>>
>>>> on the other hand we ring for every ms boot time ... and here we want
>>>> to scan a complete dt with maybe a lot of nodes, we do not want to
>>>> use?
>>>>
>>>
>>> Scanning all of DT seems to imply it has no strict or standard
>>> ordering. Could we mandate, suggest, of make it so that all entries in
>>> the DT needed at _f time are put first, and even maybe place an "end of
>>> _f" custom marker in DT to delimit them? (I assume that, for the sake of
>>>
>>
>> I do not know, if this is possible, as I think the DT used in U-Boot
>> should be the same as used in linux ... or?
>>
>>
>>   Postel-ism, anything in DT which is not understandable is skipped, so
>>> other users of the DT than us would not even be annoyed by such a
>>> marker)
>>>
>>> This way, we'd avoid wasting time scanning most of the DT in this case.
>>>
>>
>> Hmm.. why should we introduce such things, instead of scanning the
>> node only if we need it?
>>
>> We have "only" the problem, that we could not write to data at this
>> moment ... but this problem should be solved in a seperate topic.
>> I2C is usable before relocation, the problem is in conjunction with
>> dt, that we can not save for example the base address of the controller,
>> which we get from the DT ... If I understand it correct!
>>
>> So we need an option when using dt, that we have (small ram) in which
>> we can write some parameters parsed from dt ...
>>
>> I think this problem have all subsystems used before relocation.
>> (for example: environment on a spi flash?)
>>
>>
> I think using a small RAM is a good approach. At least it is better than
> pretending there is no RAM at all. We currently have no facility to
> allocate RAM before relocation, other than to use the .data section. We can
> use global_data but that won't scale well for many drivers adding their own
> stuff in there. Samsung's driver uses .data, I don't think it is a big deal.
>
> One option I should mention is to decode the I2C FDT nodes each time it is
> needed prior to relocation (i.e. to the stack), use it for the transaction,
> and throw it away. This is quite painful IMO this it involves putting calls
> in the driver to check if we are pre-reloc and have a stack space used
> every time. On tegra20 this would be 130 bytes or so. I mention it because
> console working this way for a while (decoding the console again on every
> byte).
>
> Options as I see it:
>
> - just fudge it for now and use .data (deal with it later with driver model)
> - change the meaning of board_init_f() such that memory may be available
> (e.g. if run from SPL)
> - decode the FDT nodes every time we need them (ick)

Why? after relocation it is needed exactly once.
You can do something like that in the i2c_init function:

+       bus = tegra_i2c_get_bus(adap);
+        if (bus)
+                return 0;

If you get a bus with tegra_i2c_get_bus(adap), it is "fdt initialized"

If you not get a bus ... init it ... only once

The problem before relocation could be solved with .data or later
with the driver model ...

> - adjust the ordering so that I2C normally happens post reloc except for
> specific platforms with a CONFIG defined (Heiko, the difference as I
> understand it is that with your patch CONFIG_HARD_I2C or CONFIG_SOFT_I2C
> are now defined, and so I2C happens prior to reloc now)

Hmm.. BTW: CONFIG_SOFT_I2C is no longer in the code :-)

And there are a lot of boards that use i2c before relocation, that is
not a new feature.

The problem pop up, because in arch/arm/lib/board.c at init_func_i2c()
the new code calls i2c_init_all() instead i2c_init() ...
This i2c_init_all() was introduced to init fix the SPD EEPROM bus
and call i2c_init_board() before it...

So we can call here again i2c_init() I think ... but, i2c_init()
also calls i2c_init_bus() and this i2c_init from the tegra driver,
which sets speed and return 0 ... what is not really clean, it
just works, because tegra_i2c_set_bus_speed() checks if the
bus is valid, if not only returns ...

but i2c_init_board is not called so early, which is the cause
for our problem with the tegra driver and the new framework,
as i2c_init_board() hysterically was introduced to unblock
blocked i2c busses (Correct me, if I am wrong)

My prefered way is still:
- replace i2c_init_all() through i2c_init() in
   arch/arm/lib/board.c at init_func_i2c()
   to get tegra again working
   In the long term when all i2c drivers use the new framework
   init_func_i2c() will no longer necessary :-)
   As the goal is to change the i2c api, so all i2c functions
   pass "bus" as a parameter, and i2c_set_bus_num() get
   a static function in drivers/i2c/i2c_core.c
   no need longer for storing the old bus, setting the new bus,
   doing i2c work, set the old bus, as this sequence is spread
   over the hole u-boot code.
- decoding fdt node in tegra_i2c_init, as I think
   it is the right place for it. optional more or less, but
   to prevent in future again such "order" problems ...

>> As Wolfgang said:
>> "Agreed - actually we're entering an area hear that smells pretty
>> strong like device model reorganization :-)"
>>
>> BTW: How is this problem solved with the device model approach?
>
>
> More that we need to solve it, probably with a limited malloc() pre-reloc.

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01  8:38                                 ` Heiko Schocher
  2013-08-01 14:22                                   ` Simon Glass
@ 2013-08-01 20:14                                   ` Albert ARIBAUD
  1 sibling, 0 replies; 104+ messages in thread
From: Albert ARIBAUD @ 2013-08-01 20:14 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Thu, 01 Aug 2013 10:38:15 +0200, Heiko Schocher <hs@denx.de> wrote:

> Hello Albert,
> 
> Am 01.08.2013 08:53, schrieb Albert ARIBAUD:
> > Hi Heiko,
> >
> > On Thu, 01 Aug 2013 08:02:42 +0200, Heiko Schocher<hs@denx.de>  wrote:
> >
> >>> I suppose you could. It seems conceptually /far/ simpler to just scan
> >>> the DT once up-front rather than having to defer all this stuff until
> >>
> >> on the other hand we ring for every ms boot time ... and here we want
> >> to scan a complete dt with maybe a lot of nodes, we do not want to
> >> use?
> >
> > Scanning all of DT seems to imply it has no strict or standard
> > ordering. Could we mandate, suggest, of make it so that all entries in
> > the DT needed at _f time are put first, and even maybe place an "end of
> > _f" custom marker in DT to delimit them? (I assume that, for the sake of
> 
> I do not know, if this is possible, as I think the DT used in U-Boot
> should be the same as used in linux ... or?
> 
> > Postel-ism, anything in DT which is not understandable is skipped, so
> > other users of the DT than us would not even be annoyed by such a
> > marker)
> >
> > This way, we'd avoid wasting time scanning most of the DT in this case.
> 
> Hmm.. why should we introduce such things, instead of scanning the
> node only if we need it?

From the "we want to scan a complete dt with maybe a lot of nodes, we
do not want to use?" above, I inferred that one problem here was having
to waste time going through the whole DT looking only for info needed
at _f stage. This is why I made the suggestion above for that problem.
Sorry if I did not understand this properly.

> We have "only" the problem, that we could not write to data at this
> moment ... but this problem should be solved in a seperate topic.
> I2C is usable before relocation, the problem is in conjunction with
> dt, that we can not save for example the base address of the controller,
> which we get from the DT ... If I understand it correct!
> 
> So we need an option when using dt, that we have (small ram) in which
> we can write some parameters parsed from dt ...
> 
> I think this problem have all subsystems used before relocation.
> (for example: environment on a spi flash?)
> 
> As Wolfgang said:
> "Agreed - actually we're entering an area hear that smells pretty
> strong like device model reorganization :-)"
> 
> BTW: How is this problem solved with the device model approach?
> 
> > Note: I confess I don't even know at the moment how DT is structured, so
> > I may have talked complete nonsense above. If so, please forgive me and
> > point me to some DT 101 course for me to avoid shame (at least on this
> > topic) in the future.
> 
> bye,
> Heiko


Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01 14:22                                   ` Simon Glass
  2013-08-01 15:06                                     ` Heiko Schocher
@ 2013-08-01 20:16                                     ` Albert ARIBAUD
  2013-08-02 19:32                                       ` Simon Glass
  1 sibling, 1 reply; 104+ messages in thread
From: Albert ARIBAUD @ 2013-08-01 20:16 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Thu, 1 Aug 2013 08:22:55 -0600, Simon Glass <sjg@chromium.org> wrote:

> Hi,
> 
> On Thu, Aug 1, 2013 at 2:38 AM, Heiko Schocher <hs@denx.de> wrote:
> 
> > Hello Albert,
> >
> > Am 01.08.2013 08:53, schrieb Albert ARIBAUD:
> >
> >  Hi Heiko,
> >>
> >> On Thu, 01 Aug 2013 08:02:42 +0200, Heiko Schocher<hs@denx.de>  wrote:
> >>
> >>  I suppose you could. It seems conceptually /far/ simpler to just scan
> >>>> the DT once up-front rather than having to defer all this stuff until
> >>>>
> >>>
> >>> on the other hand we ring for every ms boot time ... and here we want
> >>> to scan a complete dt with maybe a lot of nodes, we do not want to
> >>> use?
> >>>
> >>
> >> Scanning all of DT seems to imply it has no strict or standard
> >> ordering. Could we mandate, suggest, of make it so that all entries in
> >> the DT needed at _f time are put first, and even maybe place an "end of
> >> _f" custom marker in DT to delimit them? (I assume that, for the sake of
> >>
> >
> > I do not know, if this is possible, as I think the DT used in U-Boot
> > should be the same as used in linux ... or?
> >
> >
> >  Postel-ism, anything in DT which is not understandable is skipped, so
> >> other users of the DT than us would not even be annoyed by such a
> >> marker)
> >>
> >> This way, we'd avoid wasting time scanning most of the DT in this case.
> >>
> >
> > Hmm.. why should we introduce such things, instead of scanning the
> > node only if we need it?
> >
> > We have "only" the problem, that we could not write to data at this
> > moment ... but this problem should be solved in a seperate topic.
> > I2C is usable before relocation, the problem is in conjunction with
> > dt, that we can not save for example the base address of the controller,
> > which we get from the DT ... If I understand it correct!
> >
> > So we need an option when using dt, that we have (small ram) in which
> > we can write some parameters parsed from dt ...
> >
> > I think this problem have all subsystems used before relocation.
> > (for example: environment on a spi flash?)
> >
> >
> I think using a small RAM is a good approach. At least it is better than
> pretending there is no RAM at all. We currently have no facility to
> allocate RAM before relocation, other than to use the .data section. We can
> use global_data but that won't scale well for many drivers adding their own
> stuff in there. Samsung's driver uses .data, I don't think it is a big deal.

What about targets which do not have such a small RAM available?

> One option I should mention is to decode the I2C FDT nodes each time it is
> needed prior to relocation (i.e. to the stack), use it for the transaction,
> and throw it away. This is quite painful IMO this it involves putting calls
> in the driver to check if we are pre-reloc and have a stack space used
> every time. On tegra20 this would be 130 bytes or so. I mention it because
> console working this way for a while (decoding the console again on every
> byte).
> 
> Options as I see it:
> 
> - just fudge it for now and use .data (deal with it later with driver model)
> - change the meaning of board_init_f() such that memory may be available
> (e.g. if run from SPL)
> - decode the FDT nodes every time we need them (ick)
> - adjust the ordering so that I2C normally happens post reloc except for
> specific platforms with a CONFIG defined (Heiko, the difference as I
> understand it is that with your patch CONFIG_HARD_I2C or CONFIG_SOFT_I2C
> are now defined, and so I2C happens prior to reloc now)
> 
> 
> >
> > As Wolfgang said:
> > "Agreed - actually we're entering an area hear that smells pretty
> > strong like device model reorganization :-)"
> >
> > BTW: How is this problem solved with the device model approach?
> 
> 
> More that we need to solve it, probably with a limited malloc() pre-reloc.
> 
> Regards,
> Simon


Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01  6:02                             ` Heiko Schocher
  2013-08-01  6:53                               ` Albert ARIBAUD
@ 2013-08-01 20:32                               ` Stephen Warren
  2013-08-02  4:40                                 ` Heiko Schocher
  1 sibling, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-08-01 20:32 UTC (permalink / raw)
  To: u-boot

On 08/01/2013 12:02 AM, Heiko Schocher wrote:
> Am 01.08.2013 07:39, schrieb Stephen Warren:
>> On 07/31/2013 10:32 PM, Heiko Schocher wrote:
>>> Am 31.07.2013 21:31, schrieb Stephen Warren:
>>>> On 07/30/2013 11:46 PM, Heiko Schocher wrote:
...
>>>> 2) Actually initializing or using the I2C HW. That could certainly be
>>>> part of the per-I2C-controller init() function you mention.
>>>
>>> For that purpose is the i2c_init function.
>>>
>>> And why we could not do step 1 when we do step 2? Why doing step 1
>>> for hw we later do not use?
>>
>> I suppose you could. It seems conceptually /far/ simpler to just scan
>> the DT once up-front rather than having to defer all this stuff until
> 
> on the other hand we ring for every ms boot time ... and here we want
> to scan a complete dt with maybe a lot of nodes, we do not want to
> use?
> 
>> you actually use an I2C bus. If you do that, how can you know how many
>> I2C buses exist without trying to use every possible one and seeing
> 
> Do I really need to know that?

Well, with the recent patches, U-Boot prints out a list of valid I2C
adapters at boot. So, I suppose someone must have thought it a good idea!

Perhaps the most relevant reason: why on earth wouldn't a user want to
run e.g. "i2c list" or "i2c dev" and get back a list of valid I2C
adapters, as opposed to poking around in the dark to see which exist?

>> which fail? Also, the mapping from I2C bus number to register address is
> 
> Hmm.. there are max TEGRA_I2C_NUM_CONTROLLERS. If one gets used,
> it scans the dt ... if only 1 adapter is used, only one is activated
> through i2c_init ...
> 
>> only created by actually scanning the whole DT; there's no need to every
>> I2C DT node to have a /aliases entry that dictates its U-Boot device ID,
>> so you really do have to scan everything completely up-front before you
>> can determine which registers to use.
> 
> But the i2c bus number is coded static all over the u-boot code (Should
> be changed) in the code. Saying a board has an i2c eeprom on bus "2",
> it calls i2c_set_bus_number(2) ... this "2" must be somewhere in the dt
> or?

Yes, the "2" must come from DT, or DT is pointless. We simply have to
get rid of all the hard-coding. If we can't do that, then I'd strongly
prefer to revert all the DT mess, and put the list of HW modules back
into the source code. DT isn't adding anything at all unless we can
actually use it exclusively.

Given how long this discussion is going on, can we please just revert
the commit so that the code works for everyone who's trying to use it,
then fix the problem later?

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01  6:53                               ` Albert ARIBAUD
  2013-08-01  8:38                                 ` Heiko Schocher
@ 2013-08-01 20:34                                 ` Stephen Warren
  1 sibling, 0 replies; 104+ messages in thread
From: Stephen Warren @ 2013-08-01 20:34 UTC (permalink / raw)
  To: u-boot

On 08/01/2013 12:53 AM, Albert ARIBAUD wrote:
> Hi Heiko,
> 
> On Thu, 01 Aug 2013 08:02:42 +0200, Heiko Schocher <hs@denx.de> wrote:
> 
>>> I suppose you could. It seems conceptually /far/ simpler to just scan
>>> the DT once up-front rather than having to defer all this stuff until
>>
>> on the other hand we ring for every ms boot time ... and here we want
>> to scan a complete dt with maybe a lot of nodes, we do not want to
>> use?
> 
> Scanning all of DT seems to imply it has no strict or standard
> ordering. Could we mandate, suggest, of make it so that all entries in
> the DT needed at _f time are put first, and even maybe place an "end of
> _f" custom marker in DT to delimit them? (I assume that, for the sake of
> Postel-ism, anything in DT which is not understandable is skipped, so
> other users of the DT than us would not even be annoyed by such a
> marker)

DT nodes are explicitly unordered, and there is and should be no
guaranteed correlation between the order of entries in DT and when
drivers that handle them are probed.

In particular, for the Tegra DTs, nodes are supposed to be sorted by
register address to keep things neat.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01 20:32                               ` Stephen Warren
@ 2013-08-02  4:40                                 ` Heiko Schocher
  2013-08-02 19:35                                   ` Simon Glass
  2013-08-02 21:43                                   ` Stephen Warren
  0 siblings, 2 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-08-02  4:40 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 01.08.2013 22:32, schrieb Stephen Warren:
> On 08/01/2013 12:02 AM, Heiko Schocher wrote:
>> Am 01.08.2013 07:39, schrieb Stephen Warren:
>>> On 07/31/2013 10:32 PM, Heiko Schocher wrote:
>>>> Am 31.07.2013 21:31, schrieb Stephen Warren:
>>>>> On 07/30/2013 11:46 PM, Heiko Schocher wrote:
> ...
>>>>> 2) Actually initializing or using the I2C HW. That could certainly be
>>>>> part of the per-I2C-controller init() function you mention.
>>>>
>>>> For that purpose is the i2c_init function.
>>>>
>>>> And why we could not do step 1 when we do step 2? Why doing step 1
>>>> for hw we later do not use?
>>>
>>> I suppose you could. It seems conceptually /far/ simpler to just scan
>>> the DT once up-front rather than having to defer all this stuff until
>>
>> on the other hand we ring for every ms boot time ... and here we want
>> to scan a complete dt with maybe a lot of nodes, we do not want to
>> use?
>>
>>> you actually use an I2C bus. If you do that, how can you know how many
>>> I2C buses exist without trying to use every possible one and seeing
>>
>> Do I really need to know that?
>
> Well, with the recent patches, U-Boot prints out a list of valid I2C

which patches? I am trying current U-Boot on some boards, I do
not see such a list ... you mean on tegra based boards?

> adapters at boot. So, I suppose someone must have thought it a good idea!

Ok, but then, printing this "list" should done after relocation.
And the me known "I2C:   ready" print on U-Boot boot, comes from
init_func_i2c() ... which is ancient code from powerpc times ...

> Perhaps the most relevant reason: why on earth wouldn't a user want to
> run e.g. "i2c list" or "i2c dev" and get back a list of valid I2C
> adapters, as opposed to poking around in the dark to see which exist?

Didn't you need also a list of devices on each i2c bus, if you use
this argument?

But for this reason we have in the new framework the "i2c bus"
command, which shows all busses. This could be adapted in the DT case,
to look, which buses really exist and print them. No need to do this
at boottime!

Also, in an old version of the multibus/multiadapter approach
I made a option to add dynamically new i2c buses for example
from the environment or from the "i2c bus" command ... maybe
it is worth to think about such an option in the DT case?

see here:
http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=commit;h=ccb680c8cf9002232bc459e4003e3b47db5e1bf4

Patches welcome ;-)

>>> which fail? Also, the mapping from I2C bus number to register address is
>>
>> Hmm.. there are max TEGRA_I2C_NUM_CONTROLLERS. If one gets used,
>> it scans the dt ... if only 1 adapter is used, only one is activated
>> through i2c_init ...
>>
>>> only created by actually scanning the whole DT; there's no need to every
>>> I2C DT node to have a /aliases entry that dictates its U-Boot device ID,
>>> so you really do have to scan everything completely up-front before you
>>> can determine which registers to use.
>>
>> But the i2c bus number is coded static all over the u-boot code (Should
>> be changed) in the code. Saying a board has an i2c eeprom on bus "2",
>> it calls i2c_set_bus_number(2) ... this "2" must be somewhere in the dt
>> or?
>
> Yes, the "2" must come from DT, or DT is pointless. We simply have to

Ok, puuh...

> get rid of all the hard-coding. If we can't do that, then I'd strongly
> prefer to revert all the DT mess, and put the list of HW modules back
> into the source code. DT isn't adding anything at all unless we can
> actually use it exclusively.
>
> Given how long this discussion is going on, can we please just revert
> the commit so that the code works for everyone who's trying to use it,
> then fix the problem later?

Yes, but not reverting the hole commit, please just remove the
i2c_init_board() call in i2c_init_all() and test it, and send a
new patch, thanks!

diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
index d1072e8..5f10eb3 100644
--- a/drivers/i2c/i2c_core.c
+++ b/drivers/i2c/i2c_core.c
@@ -246,7 +246,6 @@ void i2c_init_board(void)
   */
  void i2c_init_all(void)
  {
-       i2c_init_board();
         i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
         return;
  }

Or we make the "init_func_i2c()" function weak, and as the
first step it is a dummy function, and boards which really need
it, currently fail and must code it in board code? I would prefer
this way, as it is anyway the goal to get rid of this function
if all boards are using the new framework ...)

Can you or Simon try this?

@Simon:
Hmm... just looking in an older version of the new framework...
i2c_init_board() was from the beginning in i2c_init_all()... why
didn't this poped up when you tested the tegra patches? Are there
some changes in the DT/tegra code in the meantime?

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

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-01 20:16                                     ` Albert ARIBAUD
@ 2013-08-02 19:32                                       ` Simon Glass
  0 siblings, 0 replies; 104+ messages in thread
From: Simon Glass @ 2013-08-02 19:32 UTC (permalink / raw)
  To: u-boot

Hi Albert,

On Thu, Aug 1, 2013 at 2:16 PM, Albert ARIBAUD <albert.u.boot@aribaud.net>wrote:

> Hi Simon,
>
> On Thu, 1 Aug 2013 08:22:55 -0600, Simon Glass <sjg@chromium.org> wrote:
>
> > Hi,
> >
> > On Thu, Aug 1, 2013 at 2:38 AM, Heiko Schocher <hs@denx.de> wrote:
> >
> > > Hello Albert,
> > >
> > > Am 01.08.2013 08:53, schrieb Albert ARIBAUD:
> > >
> > >  Hi Heiko,
> > >>
> > >> On Thu, 01 Aug 2013 08:02:42 +0200, Heiko Schocher<hs@denx.de>
>  wrote:
> > >>
> > >>  I suppose you could. It seems conceptually /far/ simpler to just scan
> > >>>> the DT once up-front rather than having to defer all this stuff
> until
> > >>>>
> > >>>
> > >>> on the other hand we ring for every ms boot time ... and here we want
> > >>> to scan a complete dt with maybe a lot of nodes, we do not want to
> > >>> use?
> > >>>
> > >>
> > >> Scanning all of DT seems to imply it has no strict or standard
> > >> ordering. Could we mandate, suggest, of make it so that all entries in
> > >> the DT needed at _f time are put first, and even maybe place an "end
> of
> > >> _f" custom marker in DT to delimit them? (I assume that, for the sake
> of
> > >>
> > >
> > > I do not know, if this is possible, as I think the DT used in U-Boot
> > > should be the same as used in linux ... or?
> > >
> > >
> > >  Postel-ism, anything in DT which is not understandable is skipped, so
> > >> other users of the DT than us would not even be annoyed by such a
> > >> marker)
> > >>
> > >> This way, we'd avoid wasting time scanning most of the DT in this
> case.
> > >>
> > >
> > > Hmm.. why should we introduce such things, instead of scanning the
> > > node only if we need it?
> > >
> > > We have "only" the problem, that we could not write to data at this
> > > moment ... but this problem should be solved in a seperate topic.
> > > I2C is usable before relocation, the problem is in conjunction with
> > > dt, that we can not save for example the base address of the
> controller,
> > > which we get from the DT ... If I understand it correct!
> > >
> > > So we need an option when using dt, that we have (small ram) in which
> > > we can write some parameters parsed from dt ...
> > >
> > > I think this problem have all subsystems used before relocation.
> > > (for example: environment on a spi flash?)
> > >
> > >
> > I think using a small RAM is a good approach. At least it is better than
> > pretending there is no RAM at all. We currently have no facility to
> > allocate RAM before relocation, other than to use the .data section. We
> can
> > use global_data but that won't scale well for many drivers adding their
> own
> > stuff in there. Samsung's driver uses .data, I don't think it is a big
> deal.
>
> What about targets which do not have such a small RAM available?
>

Presumably such targets do not use SPL, and perhaps don't use FDT at
present?


>
> > One option I should mention is to decode the I2C FDT nodes each time it
> is
> > needed prior to relocation (i.e. to the stack), use it for the
> transaction,
> > and throw it away. This is quite painful IMO this it involves putting
> calls
> > in the driver to check if we are pre-reloc and have a stack space used
> > every time. On tegra20 this would be 130 bytes or so. I mention it
> because
> > console working this way for a while (decoding the console again on every
> > byte).
> >
> > Options as I see it:
> >
> > - just fudge it for now and use .data (deal with it later with driver
> model)
> > - change the meaning of board_init_f() such that memory may be available
> > (e.g. if run from SPL)
> > - decode the FDT nodes every time we need them (ick)
> > - adjust the ordering so that I2C normally happens post reloc except for
> > specific platforms with a CONFIG defined (Heiko, the difference as I
> > understand it is that with your patch CONFIG_HARD_I2C or CONFIG_SOFT_I2C
> > are now defined, and so I2C happens prior to reloc now)
> >
> >
> > >
> > > As Wolfgang said:
> > > "Agreed - actually we're entering an area hear that smells pretty
> > > strong like device model reorganization :-)"
> > >
> > > BTW: How is this problem solved with the device model approach?
> >
> >
> > More that we need to solve it, probably with a limited malloc()
> pre-reloc.
>
>
Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-02  4:40                                 ` Heiko Schocher
@ 2013-08-02 19:35                                   ` Simon Glass
  2013-08-02 21:43                                   ` Stephen Warren
  1 sibling, 0 replies; 104+ messages in thread
From: Simon Glass @ 2013-08-02 19:35 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Thu, Aug 1, 2013 at 10:40 PM, Heiko Schocher <hs@denx.de> wrote:

> Hello Stephen,
>
> Am 01.08.2013 22:32, schrieb Stephen Warren:
>
>  On 08/01/2013 12:02 AM, Heiko Schocher wrote:
>>
>>> Am 01.08.2013 07:39, schrieb Stephen Warren:
>>>
>>>> On 07/31/2013 10:32 PM, Heiko Schocher wrote:
>>>>
>>>>> Am 31.07.2013 21:31, schrieb Stephen Warren:
>>>>>
>>>>>> On 07/30/2013 11:46 PM, Heiko Schocher wrote:
>>>>>>
>>>>> ...
>>
>>> 2) Actually initializing or using the I2C HW. That could certainly be
>>>>>> part of the per-I2C-controller init() function you mention.
>>>>>>
>>>>>
>>>>> For that purpose is the i2c_init function.
>>>>>
>>>>> And why we could not do step 1 when we do step 2? Why doing step 1
>>>>> for hw we later do not use?
>>>>>
>>>>
>>>> I suppose you could. It seems conceptually /far/ simpler to just scan
>>>> the DT once up-front rather than having to defer all this stuff until
>>>>
>>>
>>> on the other hand we ring for every ms boot time ... and here we want
>>> to scan a complete dt with maybe a lot of nodes, we do not want to
>>> use?
>>>
>>>  you actually use an I2C bus. If you do that, how can you know how many
>>>> I2C buses exist without trying to use every possible one and seeing
>>>>
>>>
>>> Do I really need to know that?
>>>
>>
>> Well, with the recent patches, U-Boot prints out a list of valid I2C
>>
>
> which patches? I am trying current U-Boot on some boards, I do
> not see such a list ... you mean on tegra based boards?
>
>
>  adapters at boot. So, I suppose someone must have thought it a good idea!
>>
>
> Ok, but then, printing this "list" should done after relocation.
> And the me known "I2C:   ready" print on U-Boot boot, comes from
> init_func_i2c() ... which is ancient code from powerpc times ...
>
>
>  Perhaps the most relevant reason: why on earth wouldn't a user want to
>> run e.g. "i2c list" or "i2c dev" and get back a list of valid I2C
>> adapters, as opposed to poking around in the dark to see which exist?
>>
>
> Didn't you need also a list of devices on each i2c bus, if you use
> this argument?
>
> But for this reason we have in the new framework the "i2c bus"
> command, which shows all busses. This could be adapted in the DT case,
> to look, which buses really exist and print them. No need to do this
> at boottime!
>
> Also, in an old version of the multibus/multiadapter approach
> I made a option to add dynamically new i2c buses for example
> from the environment or from the "i2c bus" command ... maybe
> it is worth to think about such an option in the DT case?
>
> see here:
> http://git.denx.de/?p=u-boot/**u-boot-i2c.git;a=commit;h=**
> ccb680c8cf9002232bc459e4003e3b**47db5e1bf4<http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=commit;h=ccb680c8cf9002232bc459e4003e3b47db5e1bf4>
>
> Patches welcome ;-)
>
>
>  which fail? Also, the mapping from I2C bus number to register address is
>>>>
>>>
>>> Hmm.. there are max TEGRA_I2C_NUM_CONTROLLERS. If one gets used,
>>> it scans the dt ... if only 1 adapter is used, only one is activated
>>> through i2c_init ...
>>>
>>>  only created by actually scanning the whole DT; there's no need to every
>>>> I2C DT node to have a /aliases entry that dictates its U-Boot device ID,
>>>> so you really do have to scan everything completely up-front before you
>>>> can determine which registers to use.
>>>>
>>>
>>> But the i2c bus number is coded static all over the u-boot code (Should
>>> be changed) in the code. Saying a board has an i2c eeprom on bus "2",
>>> it calls i2c_set_bus_number(2) ... this "2" must be somewhere in the dt
>>> or?
>>>
>>
>> Yes, the "2" must come from DT, or DT is pointless. We simply have to
>>
>
> Ok, puuh...
>
>
>  get rid of all the hard-coding. If we can't do that, then I'd strongly
>> prefer to revert all the DT mess, and put the list of HW modules back
>> into the source code. DT isn't adding anything at all unless we can
>> actually use it exclusively.
>>
>> Given how long this discussion is going on, can we please just revert
>> the commit so that the code works for everyone who's trying to use it,
>> then fix the problem later?
>>
>
> Yes, but not reverting the hole commit, please just remove the
> i2c_init_board() call in i2c_init_all() and test it, and send a
> new patch, thanks!
>
> diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
> index d1072e8..5f10eb3 100644
> --- a/drivers/i2c/i2c_core.c
> +++ b/drivers/i2c/i2c_core.c
> @@ -246,7 +246,6 @@ void i2c_init_board(void)
>   */
>  void i2c_init_all(void)
>  {
> -       i2c_init_board();
>         i2c_set_bus_num(CONFIG_SYS_**SPD_BUS_NUM);
>         return;
>  }
>
> Or we make the "init_func_i2c()" function weak, and as the
> first step it is a dummy function, and boards which really need
> it, currently fail and must code it in board code? I would prefer
> this way, as it is anyway the goal to get rid of this function
> if all boards are using the new framework ...)
>
> Can you or Simon try this?
>
> @Simon:
> Hmm... just looking in an older version of the new framework...
> i2c_init_board() was from the beginning in i2c_init_all()... why
> didn't this poped up when you tested the tegra patches? Are there
> some changes in the DT/tegra code in the meantime?


I don't remember it listing all the devices. It was a very long time ago,
but when I sent my patch everything seemed to work find on Seaboard. Time
is not my friend at the moment but I will see if I can make time this
weekend to try this out and come up with a patch.

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-02  4:40                                 ` Heiko Schocher
  2013-08-02 19:35                                   ` Simon Glass
@ 2013-08-02 21:43                                   ` Stephen Warren
  2013-08-03  3:55                                     ` Heiko Schocher
  1 sibling, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-08-02 21:43 UTC (permalink / raw)
  To: u-boot

On 08/01/2013 10:40 PM, Heiko Schocher wrote:
> Am 01.08.2013 22:32, schrieb Stephen Warren:
...
>> Given how long this discussion is going on, can we please just revert
>> the commit so that the code works for everyone who's trying to use it,
>> then fix the problem later?
> 
> Yes, but not reverting the hole commit, please just remove the
> i2c_init_board() call in i2c_init_all() and test it, and send a
> new patch, thanks!
> 
> diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
> index d1072e8..5f10eb3 100644
> --- a/drivers/i2c/i2c_core.c
> +++ b/drivers/i2c/i2c_core.c
> @@ -246,7 +246,6 @@ void i2c_init_board(void)
>   */
>  void i2c_init_all(void)
>  {
> -       i2c_init_board();
>         i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
>         return;
>  }

That change doesn't work. Instead of hanging immediately after printing
"I2C:", it hangs after printing:

I2C:   Caller requested bad clock: periph=-49, parent=2

I guess now various data is simply uninitialized since DT parsing hasn't
been run at all?

This is exactly why I suggest a full revert of the problematic patch. If
we do that, it should immediately allow all Tegra boards to actually
work again. Right now, nobody can use or test u-boot.git/master is
completely blocked by this issue. This is dangerous, since it could
easily allow all manner of other problems to appear in other areas
without anyone being able to notice. It's my opinion we should
immediately unblock them by a revert, and then later work out how to
resolve the issues.

For the record, "git revert 1f2ba722ac06393d6abe6d4734824d3b98ea9108"
has one simple conflict in README, and certainly allows at least Beaver
to work without issue.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-02 21:43                                   ` Stephen Warren
@ 2013-08-03  3:55                                     ` Heiko Schocher
  2013-08-05 15:40                                       ` Simon Glass
  2013-08-05 17:59                                       ` Stephen Warren
  0 siblings, 2 replies; 104+ messages in thread
From: Heiko Schocher @ 2013-08-03  3:55 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

Am 02.08.2013 23:43, schrieb Stephen Warren:
> On 08/01/2013 10:40 PM, Heiko Schocher wrote:
>> Am 01.08.2013 22:32, schrieb Stephen Warren:
> ...
>>> Given how long this discussion is going on, can we please just revert
>>> the commit so that the code works for everyone who's trying to use it,
>>> then fix the problem later?
>>
>> Yes, but not reverting the hole commit, please just remove the
>> i2c_init_board() call in i2c_init_all() and test it, and send a
>> new patch, thanks!
>>
>> diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
>> index d1072e8..5f10eb3 100644
>> --- a/drivers/i2c/i2c_core.c
>> +++ b/drivers/i2c/i2c_core.c
>> @@ -246,7 +246,6 @@ void i2c_init_board(void)
>>    */
>>   void i2c_init_all(void)
>>   {
>> -       i2c_init_board();
>>          i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
>>          return;
>>   }
>
> That change doesn't work. Instead of hanging immediately after printing
> "I2C:", it hangs after printing:
>
> I2C:   Caller requested bad clock: periph=-49, parent=2
>
> I guess now various data is simply uninitialized since DT parsing hasn't
> been run at all?

I do not know this ... and what happen if you make init_func_i2c()
weak and default just dummy?

> This is exactly why I suggest a full revert of the problematic patch. If
> we do that, it should immediately allow all Tegra boards to actually
> work again. Right now, nobody can use or test u-boot.git/master is

nobody = only tegra boards ... I am working fine with current mainline
on other arm targets ...

> completely blocked by this issue. This is dangerous, since it could
> easily allow all manner of other problems to appear in other areas
> without anyone being able to notice. It's my opinion we should
> immediately unblock them by a revert, and then later work out how to
> resolve the issues.
>
> For the record, "git revert 1f2ba722ac06393d6abe6d4734824d3b98ea9108"
> has one simple conflict in README, and certainly allows at least Beaver
> to work without issue.

Ah, you mean only the switch from the tegra i2c driver to the new
framework ... Hmm.. Ok, but I would prefer the way fixing the
current problem ... as I think, nobody want to do this work again ...

But it is alberts descicion on the end, and if nobody has currently
time for searching the real reason, the best way.

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] 104+ messages in thread

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-03  3:55                                     ` Heiko Schocher
@ 2013-08-05 15:40                                       ` Simon Glass
  2013-08-05 17:28                                         ` Stephen Warren
  2013-08-05 17:59                                       ` Stephen Warren
  1 sibling, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-08-05 15:40 UTC (permalink / raw)
  To: u-boot

Hi,

On Fri, Aug 2, 2013 at 9:55 PM, Heiko Schocher <hs@denx.de> wrote:

> Hello Stephen,
>
> Am 02.08.2013 23:43, schrieb Stephen Warren:
>
>  On 08/01/2013 10:40 PM, Heiko Schocher wrote:
>>
>>> Am 01.08.2013 22:32, schrieb Stephen Warren:
>>>
>> ...
>>
>>> Given how long this discussion is going on, can we please just revert
>>>> the commit so that the code works for everyone who's trying to use it,
>>>> then fix the problem later?
>>>>
>>>
>>> Yes, but not reverting the hole commit, please just remove the
>>> i2c_init_board() call in i2c_init_all() and test it, and send a
>>> new patch, thanks!
>>>
>>> diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
>>> index d1072e8..5f10eb3 100644
>>> --- a/drivers/i2c/i2c_core.c
>>> +++ b/drivers/i2c/i2c_core.c
>>> @@ -246,7 +246,6 @@ void i2c_init_board(void)
>>>    */
>>>   void i2c_init_all(void)
>>>   {
>>> -       i2c_init_board();
>>>          i2c_set_bus_num(CONFIG_SYS_**SPD_BUS_NUM);
>>>          return;
>>>   }
>>>
>>
>> That change doesn't work. Instead of hanging immediately after printing
>> "I2C:", it hangs after printing:
>>
>> I2C:   Caller requested bad clock: periph=-49, parent=2
>>
>> I guess now various data is simply uninitialized since DT parsing hasn't
>> been run at all?
>>
>
> I do not know this ... and what happen if you make init_func_i2c()
> weak and default just dummy?
>
>
>  This is exactly why I suggest a full revert of the problematic patch. If
>> we do that, it should immediately allow all Tegra boards to actually
>> work again. Right now, nobody can use or test u-boot.git/master is
>>
>
> nobody = only tegra boards ... I am working fine with current mainline
> on other arm targets ...
>
>
>  completely blocked by this issue. This is dangerous, since it could
>> easily allow all manner of other problems to appear in other areas
>> without anyone being able to notice. It's my opinion we should
>> immediately unblock them by a revert, and then later work out how to
>> resolve the issues.
>>
>> For the record, "git revert 1f2ba722ac06393d6abe6d4734824d**3b98ea9108"
>> has one simple conflict in README, and certainly allows at least Beaver
>> to work without issue.
>>
>
> Ah, you mean only the switch from the tegra i2c driver to the new
> framework ... Hmm.. Ok, but I would prefer the way fixing the
> current problem ... as I think, nobody want to do this work again ...
>
> But it is alberts descicion on the end, and if nobody has currently
> time for searching the real reason, the best way.


Yes I think we should fix the problem properly rather than just revert. I
will take a look.

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-05 15:40                                       ` Simon Glass
@ 2013-08-05 17:28                                         ` Stephen Warren
  2013-08-05 20:12                                           ` Simon Glass
  0 siblings, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-08-05 17:28 UTC (permalink / raw)
  To: u-boot

On 08/05/2013 09:40 AM, Simon Glass wrote:
...
> Yes I think we should fix the problem properly rather than just revert.
> I will take a look.

How long will fixing it properly take?

I've already received at least a couple reports from people outside
NVIDIA and a couple from people inside NVIDIA who have been hit by this
bug. Surely a revert-first-so-people-can-do-other-work approach is
better so as to reduce the impact of this bug, unless you're planning on
providing the fix in the same time-scale as a revert would take? (and
the window on doing that has *long* gone). This is certainly the
approach we use internally at NVIDIA for serious regressions like this.
Reverting the revert once the real fix is available is trivial with git.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-03  3:55                                     ` Heiko Schocher
  2013-08-05 15:40                                       ` Simon Glass
@ 2013-08-05 17:59                                       ` Stephen Warren
  1 sibling, 0 replies; 104+ messages in thread
From: Stephen Warren @ 2013-08-05 17:59 UTC (permalink / raw)
  To: u-boot

On 08/02/2013 09:55 PM, Heiko Schocher wrote:
> Hello Stephen,
> 
> Am 02.08.2013 23:43, schrieb Stephen Warren:
>> On 08/01/2013 10:40 PM, Heiko Schocher wrote:
>>> Am 01.08.2013 22:32, schrieb Stephen Warren:
>> ...
>>>> Given how long this discussion is going on, can we please just revert
>>>> the commit so that the code works for everyone who's trying to use it,
>>>> then fix the problem later?
>>>
>>> Yes, but not reverting the hole commit, please just remove the
>>> i2c_init_board() call in i2c_init_all() and test it, and send a
>>> new patch, thanks!
>>>
>>> diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
>>> index d1072e8..5f10eb3 100644
>>> --- a/drivers/i2c/i2c_core.c
>>> +++ b/drivers/i2c/i2c_core.c
>>> @@ -246,7 +246,6 @@ void i2c_init_board(void)
>>>    */
>>>   void i2c_init_all(void)
>>>   {
>>> -       i2c_init_board();
>>>          i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
>>>          return;
>>>   }
>>
>> That change doesn't work. Instead of hanging immediately after printing
>> "I2C:", it hangs after printing:
>>
>> I2C:   Caller requested bad clock: periph=-49, parent=2
>>
>> I guess now various data is simply uninitialized since DT parsing hasn't
>> been run at all?
> 
> I do not know this ... and what happen if you make init_func_i2c()
> weak and default just dummy?
> 
>> This is exactly why I suggest a full revert of the problematic patch. If
>> we do that, it should immediately allow all Tegra boards to actually
>> work again. Right now, nobody can use or test u-boot.git/master is
> 
> nobody = only tegra boards ... I am working fine with current mainline
> on other arm targets ...

Sure, that is a valid distinction.

However, just because the problem doesn't affect all boards, that surely
doesn't make it any more acceptable?

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-07-30 20:00         ` Stephen Warren
  2013-07-30 21:21           ` Simon Glass
  2013-07-31  5:03           ` Heiko Schocher
@ 2013-08-05 19:21           ` Stephen Warren
  2013-08-05 20:08             ` Tom Rini
  2 siblings, 1 reply; 104+ messages in thread
From: Stephen Warren @ 2013-08-05 19:21 UTC (permalink / raw)
  To: u-boot

On 07/30/2013 02:00 PM, Stephen Warren wrote:
...
(discussion of instantiating/initializing I2C devices from device tree,
and the fact U-Boot attempts to do that before .data or malloc can be
touched/used, which doesn't work)
...
> It seems like much of U-Boot's initialization architecture simply wasn't
> designed to accommodate dynamically initializing devices from DT.

I thought about this a little over the weekend. I think the solution
here may be to break up U-Boot initialization steps more explicitly,
even into more separate binaries.

There are at least the following separate things going on right now
(admittedly some of these are slightly loosely defined, and some are
currently lumped into the main image's _f _r steps/tables):

* Basic CPU initialization.

* Initializing SDRAM controller (not required on Tegra; boot ROM already
does this). This is what the SPL is typically used for.

* Tegra-specific: Run code on the AVP (boot) CPU which starts the main
CPU complex running. On Tegra, we've hijacked the SPL to do this
separate step.

* Copying U-Boot to SDRAM now it's available and/or performing
initialization steps that require SDRAM.

* Sizing SDRAM, perhaps by

* Relocating the U-Boot binary to top of RAM (at least if relocation is
enabled).

* The main U-Boot binary.

Some more steps I've probably forgotten while I write this email!

Now, obviously some of those steps run in a very restricted environment.

For example, on systems where the boot ROM doesn't exist or doesn't
enable SDRAM, then steps before U-Boot initializes it can't touch
.data/malloc etc.

It's probably not a good idea to make the code that initializes and
probes SDRAM have to retrieve information about the SPD I2C controller
(if one exists) from DT; it'd probably be better to hard-code the I2C
controller information into that part of U-Boot, and defer any complex
dynamic stuff to later. This is at least partially fallout from the
previous point.

The order of some of those bullet points above might even vary a little
depending on the SoC.

For example, on Tegra, we have to do basic CPU initialization on two
different CPUs; once on the AVP when we first start running any code at
all, and separately on the main CPU complex after it has been booted.
Those two CPUs are different ARM architectures too. And on Tegra we
don't have to initialize SDRAM at all; the boot ROM does it.

So, I wonder if it wouldn't be worth splitting U-Boot up into more
separate binaries for these steps, so that any restrictions on the steps
can be much better defined and segregated. Then, the final U-Boot binary
can be constructed not just by:

cat spl.bin u-boot.bin

But perhaps more like:

cat sdram-init.bin relocater.bin u-boot.bin

or something like that?

Everything in sdram-init.bin would use no .data (the linker script could
enforce this) and hard-coded devices. Everything in u-boot.bin could
immediately assume that SDRAM and .data was available, and use DT for
everything, and not need any pointer relocation fixup phase, since there
would be nothing in .data to fix up.

Each board or SoC could define a list of the steps they need, their
order, and the restrictions on their execution (e.g. no .data, ROMable
code, hard-coded vs. dynamic devices possibly from DT, etc.)

Another thing that made me think of this: I briefly experimented with
getting Tegra's U-Boot SPL to jump directly to a Linux zImage. A few
things were missing, since Tegra's SPL runs on the AVP CPU not the main
CPU, and hence never initializes anything on the main CPU, leaving that
responsibility to the main U-Boot binary). Hence, some main-CPU cache
setup was missing from Tegra's SPL. Solving this issue requires 3
separate binaries:

1) AVP boot code, to start the main CPU complex
2) Main CPU low-level initialization
3) Main U-Boot binary

To boot U-Boot, all 3 steps would be used.

To directly boot a zImage, only steps (1) and (2) would be needed.

Right now, we need to hack up a separate binary for (2) for the
boot-a-zImage-directly case, and hence concatenate SPL, CPU init,
zImage. It'd be nice if the "CPU init" part of that set of binaries was
something we could easily pull out of the U-Boot build process, rather
than something custom.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-05 19:21           ` Stephen Warren
@ 2013-08-05 20:08             ` Tom Rini
  2013-08-05 21:06               ` Stephen Warren
  2013-08-05 23:18               ` Stephen Warren
  0 siblings, 2 replies; 104+ messages in thread
From: Tom Rini @ 2013-08-05 20:08 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 05, 2013 at 01:21:50PM -0600, Stephen Warren wrote:
> On 07/30/2013 02:00 PM, Stephen Warren wrote:
> ...
> (discussion of instantiating/initializing I2C devices from device tree,
> and the fact U-Boot attempts to do that before .data or malloc can be
> touched/used, which doesn't work)
> ...
> > It seems like much of U-Boot's initialization architecture simply wasn't
> > designed to accommodate dynamically initializing devices from DT.
> 
> I thought about this a little over the weekend. I think the solution
> here may be to break up U-Boot initialization steps more explicitly,
> even into more separate binaries.

Have you seen the 'TPL' code Freescale has been posting?  That might be
a handy concept, but I'm concerned we're going to be heading towards N
separate little programs, and that's possibly a big complex (and thus
fragile) web.

[snip]
> Another thing that made me think of this: I briefly experimented with
> getting Tegra's U-Boot SPL to jump directly to a Linux zImage. A few
> things were missing, since Tegra's SPL runs on the AVP CPU not the main
> CPU, and hence never initializes anything on the main CPU, leaving that
> responsibility to the main U-Boot binary). Hence, some main-CPU cache
> setup was missing from Tegra's SPL. Solving this issue requires 3
> separate binaries:
> 
> 1) AVP boot code, to start the main CPU complex
> 2) Main CPU low-level initialization
> 3) Main U-Boot binary
> 
> To boot U-Boot, all 3 steps would be used.
> 
> To directly boot a zImage, only steps (1) and (2) would be needed.
> 
> Right now, we need to hack up a separate binary for (2) for the
> boot-a-zImage-directly case, and hence concatenate SPL, CPU init,
> zImage. It'd be nice if the "CPU init" part of that set of binaries was
> something we could easily pull out of the U-Boot build process, rather
> than something custom.

So I guess you're trying to do something that's not quite falcon mode
here?

-- 
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/20130805/f9e55fec/attachment.pgp>

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-05 17:28                                         ` Stephen Warren
@ 2013-08-05 20:12                                           ` Simon Glass
  2013-08-05 20:15                                             ` Stephen Warren
  0 siblings, 1 reply; 104+ messages in thread
From: Simon Glass @ 2013-08-05 20:12 UTC (permalink / raw)
  To: u-boot

Hi Stephen,


On Mon, Aug 5, 2013 at 11:28 AM, Stephen Warren <swarren@wwwdotorg.org>wrote:

> On 08/05/2013 09:40 AM, Simon Glass wrote:
> ...
> > Yes I think we should fix the problem properly rather than just revert.
> > I will take a look.
>
> How long will fixing it properly take?
>

I expect to have a patch tomorrow.


>
> I've already received at least a couple reports from people outside
> NVIDIA and a couple from people inside NVIDIA who have been hit by this
> bug. Surely a revert-first-so-people-can-do-other-work approach is
> better so as to reduce the impact of this bug, unless you're planning on
> providing the fix in the same time-scale as a revert would take? (and
> the window on doing that has *long* gone). This is certainly the
> approach we use internally at NVIDIA for serious regressions like this.
> Reverting the revert once the real fix is available is trivial with git.
>

Fair enough. My concern is that the I2C refactor has been a long time
coming and it would be nice if it could stick :-)

How about a revert tomorrow if I don't come up with some sort of patch?

Regards,
Simon

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-05 20:12                                           ` Simon Glass
@ 2013-08-05 20:15                                             ` Stephen Warren
  0 siblings, 0 replies; 104+ messages in thread
From: Stephen Warren @ 2013-08-05 20:15 UTC (permalink / raw)
  To: u-boot

On 08/05/2013 02:12 PM, Simon Glass wrote:
> Hi Stephen,
> 
> 
> On Mon, Aug 5, 2013 at 11:28 AM, Stephen Warren <swarren@wwwdotorg.org
> <mailto:swarren@wwwdotorg.org>> wrote:
> 
>     On 08/05/2013 09:40 AM, Simon Glass wrote:
>     ...
>     > Yes I think we should fix the problem properly rather than just
>     revert.
>     > I will take a look.
> 
>     How long will fixing it properly take?
> 
> 
> I expect to have a patch tomorrow.

OK, that sounds fine.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-05 20:08             ` Tom Rini
@ 2013-08-05 21:06               ` Stephen Warren
  2013-08-05 23:18               ` Stephen Warren
  1 sibling, 0 replies; 104+ messages in thread
From: Stephen Warren @ 2013-08-05 21:06 UTC (permalink / raw)
  To: u-boot

On 08/05/2013 02:08 PM, Tom Rini wrote:
> On Mon, Aug 05, 2013 at 01:21:50PM -0600, Stephen Warren wrote:
>> On 07/30/2013 02:00 PM, Stephen Warren wrote: ... (discussion of
>> instantiating/initializing I2C devices from device tree, and the
>> fact U-Boot attempts to do that before .data or malloc can be 
>> touched/used, which doesn't work) ...
>>> It seems like much of U-Boot's initialization architecture
>>> simply wasn't designed to accommodate dynamically initializing
>>> devices from DT.
>> 
>> I thought about this a little over the weekend. I think the
>> solution here may be to break up U-Boot initialization steps more
>> explicitly, even into more separate binaries.
> 
> Have you seen the 'TPL' code Freescale has been posting?  That
> might be a handy concept, but I'm concerned we're going to be
> heading towards N separate little programs, and that's possibly a
> big complex (and thus fragile) web.

No, I'll go try and find it and take a look.

> [snip]
>> Another thing that made me think of this: I briefly experimented
>> with getting Tegra's U-Boot SPL to jump directly to a Linux
>> zImage. A few things were missing, since Tegra's SPL runs on the
>> AVP CPU not the main CPU, and hence never initializes anything on
>> the main CPU, leaving that responsibility to the main U-Boot
>> binary). Hence, some main-CPU cache setup was missing from
>> Tegra's SPL. Solving this issue requires 3 separate binaries:
>> 
>> 1) AVP boot code, to start the main CPU complex 2) Main CPU
>> low-level initialization 3) Main U-Boot binary
>> 
>> To boot U-Boot, all 3 steps would be used.
>> 
>> To directly boot a zImage, only steps (1) and (2) would be
>> needed.
>> 
>> Right now, we need to hack up a separate binary for (2) for the 
>> boot-a-zImage-directly case, and hence concatenate SPL, CPU
>> init, zImage. It'd be nice if the "CPU init" part of that set of
>> binaries was something we could easily pull out of the U-Boot
>> build process, rather than something custom.
> 
> So I guess you're trying to do something that's not quite falcon
> mode here?

I thought it was very similar to falcon mode, but reading
doc/README.falcon, it's actually pretty different.

My use-case is that as a kernel developer, I want to repeatedly boot
new kernels. I can do the following now:

* Copy new kernel to SD card, put it in the target system, reboot it
* Copy new kernel to TFTP server, reboot target

Either of these are slower than I'd like either due to swapping SD
cards about, or slow TFTP transfers. Tegra at least has another boot
option: When the system boots, it can immediately go into special mode
whereby a USB-hosted protocol can be used download arbitrary code to
SDRAM and execute it. I want to make that downloaded code be the
zImage, perhaps with some stuff concatenated on the front to do a
little basic initialization first, e.g. setting up caches, setting r2
to point at a DTB, etc.

Now, I was hoping to re-use some code from U-Boot as the stuff I
concatenate with the zImage, so I wouldn't have to maintain it
separately. The bits I need area almost just the SPL, although since
our SPL and main U-Boot run on different CPUs, I also need a bit extra
CPU initialization, so for now I hacked up a very simple stub to do this.

Finally, I was then hoping to be able to burn that concatenated image
into flash and have the system always boot it. This is the part that's
most similar to falcon mode, I think.

My use case here is for that flashed kernel/initrd be able to choose a
boot target (SD, TFTP, ...), get a kernel from there, and kexec it.
That would make the kernel+initrd replace the main U-Boot binary. Then
I can write bash/... scripts and use kernel features for my boot menu,
rather than U-Boot scripts.

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

* [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework
  2013-08-05 20:08             ` Tom Rini
  2013-08-05 21:06               ` Stephen Warren
@ 2013-08-05 23:18               ` Stephen Warren
  1 sibling, 0 replies; 104+ messages in thread
From: Stephen Warren @ 2013-08-05 23:18 UTC (permalink / raw)
  To: u-boot

On 08/05/2013 02:08 PM, Tom Rini wrote:
> On Mon, Aug 05, 2013 at 01:21:50PM -0600, Stephen Warren wrote:
>> On 07/30/2013 02:00 PM, Stephen Warren wrote: ... (discussion of
>> instantiating/initializing I2C devices from device tree, and the
>> fact U-Boot attempts to do that before .data or malloc can be 
>> touched/used, which doesn't work) ...
>>> It seems like much of U-Boot's initialization architecture
>>> simply wasn't designed to accommodate dynamically initializing
>>> devices from DT.
>> 
>> I thought about this a little over the weekend. I think the
>> solution here may be to break up U-Boot initialization steps more
>> explicitly, even into more separate binaries.
> 
> Have you seen the 'TPL' code Freescale has been posting?  That
> might be a handy concept, but I'm concerned we're going to be
> heading towards N separate little programs, and that's possibly a
> big complex (and thus fragile) web.

TPL is certainly similar, but the implementation is pretty different.

On Tegra, the boot ROM initializes SDRAM, so there aren't any max size
requirements on SPL/U-Boot; they're concatenated together in flash and
both placed into SDRAM by the boot ROM in all cases. SPL+U-Boot is
just one big binary as far as our boot ROM is concerned, but just
happens to be made out of a few chunks that are concatenated together
as far as the U-Boot build process is concerned.

So, my proposal to further split up the U-Boot binary was more to allow:

a) A more obvious boundary for various restrictions, such as lack of
.data access, to applied or lifted.

b) Re-using some of the component parts of U-Boot to build other things.

Freescale's TPL patches are all about limitations on the size of the
various components. Hence, each of SPL, TPL is a separate entity in
flash too, and each contains a flash driver to read the next component
in the chain.

I suppose the two concepts could be unified by simply having SPL/TPL
on Tegra not contain any flash drivers, and both use the "jump to
hard-coded address" method of dispatching to the next binary just as
we do today for the SPL->u-boot.bin handoff. However, I'd still rather
explicitly call out what each component binary is for with a
per-board/soc list, rather than re-using the names SPL/TPL to do
different things on different systems.

Not that I likely have any time to actually implement any of this:-(

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

end of thread, other threads:[~2013-08-05 23:18 UTC | newest]

Thread overview: 104+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-04 12:01 [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 1/9] i2c: add i2c_core and prepare for new multibus support Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 2/9] i2c: common changes for multibus/multiadapter support Heiko Schocher
2013-05-06 16:39   ` Daniel Schwierzeck
2013-05-07 13:05     ` Heiko Schocher
2013-05-11 21:17   ` Simon Glass
2013-05-13  4:47     ` Heiko Schocher
2013-05-11 21:33   ` Simon Glass
2013-05-13  5:41     ` Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 3/9] i2c, soft-i2c: switch to new " Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 4/9] i2c, fsl_i2c: " Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 5/9] i2c, multibus: get rid of CONFIG_I2C_MUX Heiko Schocher
2013-05-06 12:23   ` Holger Brunck
2013-05-06 13:57     ` Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 6/9] i2c, multibus, keymile: get rid of EEprom_ivm envvariable Heiko Schocher
2013-05-06 12:24   ` Holger Brunck
2013-05-06 13:58     ` Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 7/9] tegra: i2c: Add function to know about current bus Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework Heiko Schocher
2013-05-06 19:08   ` Stephen Warren
2013-05-07  8:01     ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2Cframework Marc Dietrich
2013-05-07 14:55       ` Stephen Warren
2013-05-07 16:17         ` Simon Glass
2013-05-08  4:11         ` Heiko Schocher
2013-05-07 13:07     ` [U-Boot] [PATCH v3 8/9] tegra: i2c: Enable new CONFIG_SYS_I2C framework Heiko Schocher
     [not found]     ` <5FBF8E85CA34454794F0F7ECBA79798F37ACAFEF3F@HQMAIL04.nvidia.com>
2013-05-07 13:12       ` Heiko Schocher
2013-07-29 16:12   ` Stephen Warren
2013-07-30  4:28     ` Heiko Schocher
2013-07-30  4:34       ` Simon Glass
2013-07-30 18:56       ` Stephen Warren
2013-07-31  4:29         ` Heiko Schocher
2013-07-30 19:22       ` Stephen Warren
2013-07-30 20:00         ` Stephen Warren
2013-07-30 21:21           ` Simon Glass
2013-07-30 21:32             ` Stephen Warren
2013-07-30 21:46               ` Simon Glass
2013-07-30 21:51                 ` Stephen Warren
2013-07-30 22:05                   ` Simon Glass
2013-07-31  5:46                     ` Heiko Schocher
2013-07-31 19:31                       ` Stephen Warren
2013-08-01  4:32                         ` Heiko Schocher
2013-08-01  5:39                           ` Stephen Warren
2013-08-01  6:02                             ` Heiko Schocher
2013-08-01  6:53                               ` Albert ARIBAUD
2013-08-01  8:38                                 ` Heiko Schocher
2013-08-01 14:22                                   ` Simon Glass
2013-08-01 15:06                                     ` Heiko Schocher
2013-08-01 20:16                                     ` Albert ARIBAUD
2013-08-02 19:32                                       ` Simon Glass
2013-08-01 20:14                                   ` Albert ARIBAUD
2013-08-01 20:34                                 ` Stephen Warren
2013-08-01 20:32                               ` Stephen Warren
2013-08-02  4:40                                 ` Heiko Schocher
2013-08-02 19:35                                   ` Simon Glass
2013-08-02 21:43                                   ` Stephen Warren
2013-08-03  3:55                                     ` Heiko Schocher
2013-08-05 15:40                                       ` Simon Glass
2013-08-05 17:28                                         ` Stephen Warren
2013-08-05 20:12                                           ` Simon Glass
2013-08-05 20:15                                             ` Stephen Warren
2013-08-05 17:59                                       ` Stephen Warren
2013-07-30 22:09                   ` Albert ARIBAUD
2013-07-30 22:11                     ` Simon Glass
2013-07-31  5:18                     ` Wolfgang Denk
2013-07-31  5:55                       ` Heiko Schocher
2013-07-31  7:06                       ` Albert ARIBAUD
2013-07-31  7:36                         ` Heiko Schocher
2013-07-31  8:16                           ` Albert ARIBAUD
2013-07-31  8:31                             ` Heiko Schocher
2013-07-31  9:38                               ` Albert ARIBAUD
2013-07-31 12:30                                 ` Simon Glass
2013-07-31 13:03                                   ` Heiko Schocher
2013-07-31 19:41                               ` Stephen Warren
2013-08-01  4:32                                 ` Heiko Schocher
2013-07-31 19:39                         ` Wolfgang Denk
2013-07-31  5:52                     ` Heiko Schocher
2013-07-31  5:03           ` Heiko Schocher
2013-08-05 19:21           ` Stephen Warren
2013-08-05 20:08             ` Tom Rini
2013-08-05 21:06               ` Stephen Warren
2013-08-05 23:18               ` Stephen Warren
2013-07-30 21:19         ` Simon Glass
2013-07-30 21:21           ` Stephen Warren
2013-07-30 21:45             ` Simon Glass
2013-07-31  5:01         ` Heiko Schocher
2013-05-04 12:01 ` [U-Boot] [PATCH v3 9/9] i2c, ppc4xx_i2c: switch to new multibus/multiadapter support Heiko Schocher
2013-05-06  6:52   ` Stefan Roese
2013-05-06  8:57 ` [U-Boot] [PATCH v3 0/9] Bring in new I2C framework Dirk Eibach
2013-05-06 14:11   ` Heiko Schocher
2013-05-17 13:17 ` Piotr Wilczek
2013-05-18 17:41   ` Simon Glass
2013-05-20  6:13     ` Piotr Wilczek
2013-06-19 22:07       ` Simon Glass
2013-06-20  3:38         ` Heiko Schocher
2013-06-20  5:50           ` Minkyu Kang
2013-06-20  6:41             ` Piotr Wilczek
2013-06-20  7:14               ` Heiko Schocher
2013-06-20  8:34                 ` Piotr Wilczek
2013-06-20  9:19                   ` Heiko Schocher
2013-06-20  5:52           ` Piotr Wilczek
2013-06-20  6:52           ` Dirk Eibach
2013-06-20  7:59             ` Heiko Schocher
2013-06-20  8:20               ` Dirk Eibach
2013-06-20  9:11                 ` Heiko Schocher

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.