[U-Boot] [PATCH 00/16] RFC: Board init using driver model

Simon Glass sjg at chromium.org
Sun Mar 19 18:59:19 UTC 2017


At present we have a lot of ad-hoc init functions related to boards, for
example board_early_init_f(), board_misc_init_f() and dram_init().

There are used in different ways by different boards as useful hooks to
do the required init and sequence it correctly. Some functions are always
enabled but have a __weak default. Some are controlled by the existence
of a CONFIG.

There are two main init sequences: board_init_f() (f for running from
read-only flash) which runs before relocation and board_init_r() (r for
relocated) which runs afterwards.

One problem with the current sequence is that it has a lot of
arch-specific #ifdefs around various functions. There are also #ifdefs
for various features. There has been quite a bit of discussion about how
to tidy this up and at least one RFC series[1].

Now that we have driver model we can use this to deal with the init
sequences. This approach has several advantages:

- We have a path to remove the #ifdefs
- It is easy for multiple parts of the code to implement the same hook
- We can track what is called and what is not
- We don't need weak functions
- We can eventually adjust the sequence to improve naming or to add new
init phases
- It provides a model for how we might deal with ft_board_setup() and
friends

This series starts the process of replacing the pre-relocation init
sequence with a driver-model solution. It defines a uclass, adds tests
and converts sandbox and a few x86 boards over to use this new setup.

This series is not ready for use yet as the rest of the init sequence
hooks need to be converted. But there is enough here to show the idea.

Comments welcome.

[1] https://lists.denx.de/pipermail/u-boot/2011-August/098718.html


Simon Glass (16):
  x86: Drop leading spaces in cpu_x86_get_desc()
  x86: Display the SPL banner only once
  x86: config: Enable dhrystone command for link
  dm: board: Add a uclass for init functions
  dm: board: Add a command to view phase info
  dm: board: Adjust pre-relocation init hooks
  dm: board: Support printing CPU info using the uclass
  dm: sandbox: Convert to using driver-model baord init
  dm: board: Add tests for the board uclass
  dm: board: Add documentation
  dm: x86: board: Enable CONFIG_BOARD
  dm: x86: board: Add a BOARD_F_RESERVE_ARCH driver
  dm: x86: board: ivybridge: Add support for CONFIG_BOARD
  dm: x86: board: ivybridge: Switch to use CONFIG_BOARD
  dm: x86: board: ivybridge: Remove old board init code
  dm: board: Add information about the new board init to the README

 README                                            |   3 +
 arch/Kconfig                                      |   5 +
 arch/sandbox/dts/test.dts                         |  12 ++
 arch/sandbox/include/asm/state.h                  |   3 +
 arch/sandbox/include/asm/test.h                   |   9 ++
 arch/x86/cpu/coreboot/coreboot.c                  |   2 +
 arch/x86/cpu/cpu.c                                |  41 ++++-
 arch/x86/cpu/cpu_x86.c                            |   6 +-
 arch/x86/cpu/ivybridge/cpu.c                      |  57 +++++--
 arch/x86/cpu/ivybridge/sdram.c                    |   6 +-
 arch/x86/cpu/ivybridge/sdram_nop.c                |  36 ++++-
 arch/x86/cpu/x86_64/cpu.c                         |   2 +
 arch/x86/include/asm/arch-ivybridge/sandybridge.h |   7 +
 arch/x86/lib/spl.c                                |  11 +-
 board/google/chromebook_link/link.c               |   5 -
 board/google/chromebox_panther/panther.c          |   5 -
 board/sandbox/sandbox.c                           |  44 +++++-
 cmd/Kconfig                                       |   8 +
 cmd/Makefile                                      |   1 +
 cmd/board.c                                       |  58 +++++++
 common/Kconfig                                    |  31 ++++
 common/board_f.c                                  |  58 ++++++-
 common/init/Makefile                              |   1 +
 common/init/board-uclass.c                        | 108 +++++++++++++
 configs/chromebook_link64_defconfig               |   2 +
 configs/chromebook_link_defconfig                 |   2 +
 configs/chromebox_panther_defconfig               |   1 +
 doc/driver-model/board-info.txt                   | 181 ++++++++++++++++++++++
 drivers/cpu/cpu-uclass.c                          |  19 +++
 drivers/misc/Makefile                             |   1 +
 drivers/misc/board_sandbox.c                      |  44 ++++++
 include/asm-generic/global_data.h                 |   5 +
 include/board.h                                   | 170 ++++++++++++++++++++
 include/cpu.h                                     |   5 +
 include/dm/uclass-id.h                            |   1 +
 test/dm/Makefile                                  |   1 +
 test/dm/board.c                                   |  74 +++++++++
 37 files changed, 980 insertions(+), 45 deletions(-)
 create mode 100644 cmd/board.c
 create mode 100644 common/init/board-uclass.c
 create mode 100644 doc/driver-model/board-info.txt
 create mode 100644 drivers/misc/board_sandbox.c
 create mode 100644 include/board.h
 create mode 100644 test/dm/board.c

-- 
2.12.0.367.g23dc2f6d3c-goog



More information about the U-Boot mailing list