[U-Boot] [PATCH 0/3] Bring in new I2C framework

Simon Glass sjg at chromium.org
Thu Oct 25 23:37:08 CEST 2012


Hi Heiko,

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

I am very happy to see this, thank you.

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

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

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

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

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

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

to:

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

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

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

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

Regards,
Simon

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


More information about the U-Boot mailing list