[RFC PATCH v1 0/2] Allow disabling driver model for I2C in SPL

Igor Opaniuk igor.opaniuk at foundries.io
Fri Feb 5 16:10:56 CET 2021


From: Igor Opaniuk <igor.opaniuk at foundries.io>

At present if U-Boot proper uses driver model for I2C, then SPL has to
also. While this is desirable, it places a significant barrier to moving
to driver model in some cases. For example, with a space-constrained SPL
it may be necessary to enable CONFIG_SPL_OF_PLATDATA which involves
adjusting some drivers.

This patch introduces a separate Kconfig symbols for enabling DM_I2C and
DM_I2C_GPIO support in SPL.

This will also help to get away from dirty workarounds to
achieve non-DM I2C support for SPL, which is currently used in some
board header files like:

ifdef CONFIG_SPL_BUILD
undef CONFIG_DM_I2C
endif

All occurences were replaced automatically using these bash cmds:
$ find . -type f -exec sed -i
     's/ifndef CONFIG_DM_I2C/if !CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/ifdef CONFIG_DM_I2C/if CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/defined(CONFIG_DM_I2C)/CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/ifndef CONFIG_DM_I2C_GPIO/if !CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +
$ find . -type f -exec sed -i
    's/ifdef CONFIG_DM_I2C_GPIO/if CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +
$ find . -type f -exec sed -i
    's/defined(CONFIG_DM_I2C_GPIO)/CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +

Testing:
$ make check
...
Name                                                    Stmts   Miss  Cover
---------------------------------------------------------------------------
tools/binman/cbfs_util.py                                 370      7    98%
tools/binman/cmdline.py                                    49      0   100%
tools/binman/control.py                                   291      0   100%
tools/binman/elf.py                                       123      0   100%
tools/binman/entry.py                                     340      0   100%
tools/binman/etype/atf_bl31.py                              5      0   100%
tools/binman/etype/blob.py                                 26      0   100%
tools/binman/etype/blob_dtb.py                             23      0   100%
tools/binman/etype/blob_ext.py                              9      0   100%
tools/binman/etype/blob_named_by_arg.py                     9      0   100%
tools/binman/etype/cbfs.py                                 90      0   100%
tools/binman/etype/cros_ec_rw.py                            5      0   100%
tools/binman/etype/fdtmap.py                               53      0   100%
tools/binman/etype/files.py                                32      0   100%
tools/binman/etype/fill.py                                 14      0   100%
tools/binman/etype/fit.py                                 109      0   100%
tools/binman/etype/fmap.py                                 29      0   100%
tools/binman/etype/gbb.py                                  33      0   100%
tools/binman/etype/image_header.py                         53      0   100%
tools/binman/etype/intel_cmc.py                             4      0   100%
tools/binman/etype/intel_descriptor.py                     39      0   100%
tools/binman/etype/intel_fit.py                            12      0   100%
tools/binman/etype/intel_fit_ptr.py                        17      0   100%
tools/binman/etype/intel_fsp.py                             4      0   100%
tools/binman/etype/intel_fsp_m.py                           4      0   100%
tools/binman/etype/intel_fsp_s.py                           4      0   100%
tools/binman/etype/intel_fsp_t.py                           4      0   100%
tools/binman/etype/intel_ifwi.py                           59      0   100%
tools/binman/etype/intel_me.py                              4      0   100%
tools/binman/etype/intel_mrc.py                             6      0   100%
tools/binman/etype/intel_refcode.py                         6      0   100%
tools/binman/etype/intel_vbt.py                             4      0   100%
tools/binman/etype/intel_vga.py                             4      0   100%
tools/binman/etype/mkimage.py                              28      0   100%
tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py       6      0   100%
tools/binman/etype/scp.py                                   5      0   100%
tools/binman/etype/section.py                             328      0   100%
tools/binman/etype/text.py                                 21      0   100%
tools/binman/etype/u_boot.py                                7      0   100%
tools/binman/etype/u_boot_dtb.py                            9      0   100%
tools/binman/etype/u_boot_dtb_with_ucode.py                50      0   100%
tools/binman/etype/u_boot_elf.py                           19      0   100%
tools/binman/etype/u_boot_env.py                           27      0   100%
tools/binman/etype/u_boot_img.py                            7      0   100%
tools/binman/etype/u_boot_nodtb.py                          7      0   100%
tools/binman/etype/u_boot_spl.py                           11      0   100%
tools/binman/etype/u_boot_spl_bss_pad.py                   14      0   100%
tools/binman/etype/u_boot_spl_dtb.py                        9      0   100%
tools/binman/etype/u_boot_spl_elf.py                        7      0   100%
tools/binman/etype/u_boot_spl_nodtb.py                      7      0   100%
tools/binman/etype/u_boot_spl_with_ucode_ptr.py             8      0   100%
tools/binman/etype/u_boot_tpl.py                           11      0   100%
tools/binman/etype/u_boot_tpl_dtb.py                        9      0   100%
tools/binman/etype/u_boot_tpl_dtb_with_ucode.py             8      0   100%
tools/binman/etype/u_boot_tpl_elf.py                        7      0   100%
tools/binman/etype/u_boot_tpl_with_ucode_ptr.py            12      0   100%
tools/binman/etype/u_boot_ucode.py                         33      0   100%
tools/binman/etype/u_boot_with_ucode_ptr.py                42      0   100%
tools/binman/etype/vblock.py                               36      0   100%
tools/binman/etype/x86_reset16.py                           7      0   100%
tools/binman/etype/x86_reset16_spl.py                       7      0   100%
tools/binman/etype/x86_reset16_tpl.py                       7      0   100%
tools/binman/etype/x86_start16.py                           7      0   100%
tools/binman/etype/x86_start16_spl.py                       7      0   100%
tools/binman/etype/x86_start16_tpl.py                       7      0   100%
tools/binman/fmap_util.py                                  48      0   100%
tools/binman/image.py                                     154      0   100%
tools/binman/state.py                                     154      0   100%
---------------------------------------------------------------------------
TOTAL                                                    2960      7    99%

Testing builds with buildman for some random set of boards:

Toradex:
buildman -l -W -v -m -o ../buildman-results/ toradex
   10    5    0 /15             0:00:07  : apalis_t30
Completed: 15 total built, duration 0:02:41, rate 0.09

----------------------------------

Xilinx:
buildman -l -W -v -m -o ../buildman-results/ xilinx
    3   14    1 /18             xilinx_zynq_virt
Completed: 18 total built, duration 0:02:29, rate 0.12

----------------------------------
ST:
buildman -l -W -v -m -o ../buildman-results/ st

   15    2    5 /22             0:00:03  : stm32f769-disco
Completed: 22 total built, duration 0:02:46, rate 0.13


Igor Opaniuk (2):
  dm: i2c: allow disabling driver model in SPL
  dm: i2c: use CONFIG_IS_ENABLED macro for DM_I2C and DM_I2C_GPIO

 .../include/asm/arch-fsl-layerscape/config.h  |  2 +-
 arch/arm/include/asm/arch-lpc32xx/i2c.h       |  2 +-
 arch/arm/include/asm/mach-imx/mxc_i2c.h       |  2 +-
 arch/arm/include/asm/omap_i2c.h               |  2 +-
 arch/arm/mach-imx/i2c-mxv7.c                  |  2 +-
 arch/arm/mach-keystone/ddr3_spd.c             |  2 +-
 arch/arm/mach-kirkwood/include/mach/config.h  |  2 +-
 arch/arm/mach-omap2/am33xx/board.c            |  2 +-
 arch/arm/mach-omap2/am33xx/clk_synthesizer.c  |  6 +-
 arch/arm/mach-omap2/boot-common.c             |  2 +-
 arch/arm/mach-omap2/clocks-common.c           |  2 +-
 arch/arm/mach-sunxi/board.c                   |  2 +-
 arch/powerpc/include/asm/fsl_i2c.h            |  2 +-
 board/freescale/common/dcu_sii9022a.c         |  2 +-
 board/freescale/common/diu_ch7301.c           |  2 +-
 board/freescale/common/emc2305.c              |  4 +-
 board/freescale/common/qixis.c                |  4 +-
 board/freescale/common/sys_eeprom.c           | 20 ++--
 board/freescale/common/vid.c                  | 24 ++---
 board/freescale/common/vsc3316_3308.c         | 10 +-
 board/freescale/ls1012aqds/ls1012aqds.c       |  2 +-
 board/freescale/ls1012ardb/eth.c              |  2 +-
 board/freescale/ls1012ardb/ls1012ardb.c       | 12 +--
 board/freescale/ls1021aqds/dcu.c              |  6 +-
 board/freescale/ls1021aqds/ls1021aqds.c       |  2 +-
 board/freescale/ls1021atwr/ls1021atwr.c       |  2 +-
 board/freescale/ls1028a/ls1028a.c             |  2 +-
 board/freescale/ls1043aqds/ls1043aqds.c       |  4 +-
 board/freescale/ls1046afrwy/ls1046afrwy.c     |  2 +-
 board/freescale/ls1046aqds/ls1046aqds.c       |  2 +-
 board/freescale/ls1088a/eth_ls1088aqds.c      | 16 +--
 board/freescale/ls1088a/ls1088a.c             | 60 ++++++------
 board/freescale/ls2080aqds/eth.c              | 14 +--
 board/freescale/ls2080aqds/ls2080aqds.c       |  4 +-
 board/freescale/ls2080ardb/ls2080ardb.c       |  2 +-
 board/freescale/lx2160a/lx2160a.c             |  2 +-
 board/freescale/p1010rdb/p1010rdb.c           |  8 +-
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c   |  2 +-
 board/freescale/t102xrdb/t102xrdb.c           |  2 +-
 board/freescale/t208xqds/t208xqds.c           |  2 +-
 board/friendlyarm/nanopi2/onewire.c           |  6 +-
 board/keymile/common/ivm.c                    |  2 +-
 board/samsung/common/misc.c                   |  2 +-
 board/samsung/trats/trats.c                   | 10 +-
 board/samsung/trats2/trats2.c                 | 10 +-
 board/sunxi/board.c                           |  2 +-
 board/ti/am335x/board.c                       |  8 +-
 board/ti/am335x/mux.c                         |  2 +-
 board/ti/am43xx/board.c                       | 12 +--
 board/ti/common/board_detect.c                |  4 +-
 board/ti/ks2_evm/board_k2g.c                  |  2 +-
 board/wandboard/wandboard.c                   |  4 +-
 cmd/eeprom.c                                  |  6 +-
 cmd/i2c.c                                     | 98 +++++++++----------
 doc/driver-model/i2c-howto.rst                |  2 +-
 drivers/ddr/fsl/main.c                        |  8 +-
 drivers/i2c/Kconfig                           | 21 ++++
 drivers/i2c/Makefile                          |  4 +-
 drivers/i2c/davinci_i2c.c                     |  4 +-
 drivers/i2c/designware_i2c.c                  |  4 +-
 drivers/i2c/fsl_i2c.c                         |  6 +-
 drivers/i2c/ihs_i2c.c                         | 42 ++++----
 drivers/i2c/lpc32xx_i2c.c                     |  4 +-
 drivers/i2c/mv_i2c.c                          |  2 +-
 drivers/i2c/mvtwsi.c                          | 16 +--
 drivers/i2c/mxc_i2c.c                         |  4 +-
 drivers/i2c/omap24xx_i2c.c                    |  2 +-
 drivers/misc/Makefile                         |  2 +-
 drivers/power/palmas.c                        |  2 +-
 drivers/power/pmic/pmic_tps62362.c            |  6 +-
 drivers/power/pmic/pmic_tps65217.c            | 14 +--
 drivers/power/pmic/pmic_tps65218.c            |  4 +-
 drivers/power/pmic/pmic_tps65910.c            |  6 +-
 drivers/power/twl4030.c                       |  2 +-
 drivers/power/twl6030.c                       |  2 +-
 drivers/tpm/tpm_atmel_twi.c                   |  6 +-
 drivers/usb/host/ohci-lpc32xx.c               |  8 +-
 include/_exports.h                            |  2 +-
 include/config_fallbacks.h                    |  2 +-
 include/configs/MPC8548CDS.h                  |  2 +-
 include/configs/P1010RDB.h                    |  2 +-
 include/configs/P2041RDB.h                    |  2 +-
 include/configs/T102xRDB.h                    |  2 +-
 include/configs/T104xRDB.h                    |  2 +-
 include/configs/T208xQDS.h                    |  2 +-
 include/configs/T208xRDB.h                    |  2 +-
 include/configs/T4240RDB.h                    |  2 +-
 include/configs/am43xx_evm.h                  |  2 +-
 include/configs/corenet_ds.h                  |  2 +-
 include/configs/ls1012a_common.h              |  2 +-
 include/configs/ls1021aiot.h                  |  2 +-
 include/configs/ls1021aqds.h                  |  2 +-
 include/configs/ls1021atsn.h                  |  2 +-
 include/configs/ls1021atwr.h                  |  2 +-
 include/configs/ls1028a_common.h              |  2 +-
 include/configs/ls1043a_common.h              |  2 +-
 include/configs/ls1046a_common.h              |  2 +-
 include/configs/ls1088a_common.h              |  2 +-
 include/configs/ls1088aqds.h                  |  2 +-
 include/configs/ls2080a_common.h              |  2 +-
 include/configs/ls2080aqds.h                  |  2 +-
 include/configs/ls2080ardb.h                  |  2 +-
 include/configs/p1_p2_rdb_pc.h                |  2 +-
 include/configs/sunxi-common.h                |  2 +-
 include/configs/ti_armv7_common.h             |  2 +-
 include/exports.h                             |  2 +-
 include/i2c.h                                 |  2 +-
 include/palmas.h                              |  2 +-
 include/twl4030.h                             |  2 +-
 include/twl6030.h                             |  2 +-
 110 files changed, 335 insertions(+), 314 deletions(-)

-- 
2.25.1



More information about the U-Boot mailing list