[U-Boot] [RFC PATCH v2 0/28] Create generic board init for ARM, x86, PPC

Simon Glass sjg at chromium.org
Sat Jan 7 01:24:35 CET 2012


This series creates a generic board.c implementation which contains
the essential functions of the major arch/xxx/lib/board.c files.

What is the motivation for this change?

1. There is a lot of repeated code in the board.c files. Any change to
things like setting up the baud rate requires a change in 10 separate
places.

2. Since there are 10 separate files, adding a new feature which requires
initialisation is painful since it must be independently added in 10
places.

3. As time goes by the architectures naturely diverge since there is limited
pressure to compare features or even CONFIG options against simiilar things
in other board.c files.

4. New architectures must implement all the features all over again, and
sometimes in subtley different ways. This places an unfair burden on getting
a new architecture fully functional and running with U-Boot.

5. While it is a bit of a tricky change, I believe it is worthwhile and
achievable. There is no requirement that all code be common, only that
the code that is common should be located in common/board.c rather than
arch/xxx/lib/board.c.

All the functions of board_init_f() and board_init_r() are broken into
separate function calls so that they can easily be included or excluded
for a particular architecture. It also makes it easier to adopt Graeme's
initcall proposal when it is ready.

http://lists.denx.de/pipermail/u-boot/2012-January/114499.html

This series removes the dependency on generic relocation. So relocation
happens as one big chunk and is still completely arch-specific. See the
relocation series for a proposed solution to this for ARM:

http://lists.denx.de/pipermail/u-boot/2011-December/112928.html

or Graeme's recent x86 series v2:

http://lists.denx.de/pipermail/u-boot/2012-January/114467.html

Instead of moving over a whole architecture, this series takes the approach
of simply enabling generic board support for an architecture. It is then up
to each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board
config file. If this is not done, then the code will be generated as
before. This allows both sets of code to co-exist until we are comfortable
with the generic approach, and enough boards run.

ARM is a relatively large board.c file and one which I can test, therefore
I think it is a good target for this series. On the other hand, x86 is
relatively small and simple, but different enough that it introduces a
few issues to be solved. So I have chosen both ARM and x86 for this series.
After a suggestion from Wolfgang I have added PPC also. This is the
largest and most feature-full board, so hopefully we have all bases
covered in this RFC.

A generic global_data structure is also required. This might upset a few
people. Here is my basic reasoning: most fields are the same, all
architectures include and need it, most global_data.h files already have
 #ifdefs to select fields for a particular SOC, so it is hard to
see why architecures are different in this area. We can perhaps add a
way to put architecture-specific fields into a separate header file, but
for now I have judged that to be counter-productive.

Similarly we need a generic bd_info structure, since generic code will
be accessing it. I have done this in the same way as global_data and the
same comments apply.

There was dicussion on the list about passing gd_t around as a parameter
to pre-relocation init functions. I think this makes sense, but it can
be done as a separate change, and this series does not require it.

While this series needs to stand on its own (as with the link script
cleanup series and the generic relocation series) the goal is the
unification of the board init code. So I hope we can address issues with
this in mind, rather than focusing too narrowly on particular ARM, x86 or
PPC issues.

I have run-tested ARM on Tegra Seaboard only. To try it out, define
CONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on
x86 and PPC at least it will hang, but if you are lucky it will print
something first :-)

I have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all
ARM, PPC and x86 boards. There are a few failures, some due to errors in
the board config, some due to things that need fixing. I will address
these with the final series if required.

Note: the first group of commits are required for this series to build,
but could be separated out if required. I have included them here for
convenience.

Comments welcome.

Changes in v2:
- Change generic board to an opt-in system on a per-board basic
- Add CONFIG_SYS_GENERIC_BOARD to allow board to select generic board
- Add PowerPC support
- Rebase to master

Simon Glass (28):
  arm: Change board baud_rate to ulong
  x86: Change board baud_rate to ulong
  arm: Only display frame buffer info if there is LCD/video support
  x86: Remove compiler warning in sc520_timer.c
  x86: Remove dead code in eNET
  x86: Add initial memory barrier macros
  ppc: Add initial memory barrier macros
  Introduce generic global_data
  Introduce generic u-boot.h file
  Introduce generic link symbol file
  arm: Use sections header to obtain link symbols
  x86: Change stub example to use asm-generic/sections.h
  Introduce a basic initcall implementation
  Define CONFIG_SYS_LEGACY_BOARD everywhere
  Introduce generic pre-relocation board_f.c
  Introduce generic post-relocation board_r.c
  Add spl load feature
  arm: Enable generic board support
  Add CONFIG_SYS_SYM_OFFSETS to support offset symbols
  x86: Use sections header to obtain link symbols
  Add x86 fields to generic global_data
  x86: Enable generic board support
  Add ppc fields to generic global data
  Adjust board_f for ppc
  Adjust board_r.c for PowerPC
  ppc: Enable generic board board
  tegra: Mark board init files for ARMv4t
  tegra: Enable generic board for Seaboard.

 README                                 |   17 +
 arch/arm/cpu/armv7/tegra2/config.mk    |    2 +
 arch/arm/include/asm/global_data.h     |    7 +
 arch/arm/include/asm/u-boot-arm.h      |    4 -
 arch/arm/include/asm/u-boot.h          |   11 +-
 arch/arm/lib/Makefile                  |    4 +-
 arch/arm/lib/board.c                   |    1 +
 arch/avr32/config.mk                   |    3 +
 arch/blackfin/config.mk                |    3 +
 arch/m68k/config.mk                    |    3 +
 arch/microblaze/config.mk              |    3 +
 arch/mips/config.mk                    |    3 +
 arch/nds32/config.mk                   |    3 +
 arch/nios2/config.mk                   |    3 +
 arch/powerpc/include/asm/global_data.h |    7 +
 arch/powerpc/include/asm/io.h          |    8 +
 arch/powerpc/include/asm/u-boot.h      |    7 +
 arch/powerpc/lib/Makefile              |    4 +-
 arch/sandbox/config.mk                 |    3 +
 arch/sh/config.mk                      |    3 +
 arch/sparc/config.mk                   |    3 +
 arch/x86/cpu/sc520/sc520_timer.c       |    2 +-
 arch/x86/include/asm/global_data.h     |    7 +
 arch/x86/include/asm/io.h              |    8 +
 arch/x86/include/asm/u-boot-x86.h      |    8 -
 arch/x86/include/asm/u-boot.h          |   13 +-
 arch/x86/lib/Makefile                  |    4 +-
 arch/x86/lib/board.c                   |    1 +
 board/cm4008/flash.c                   |    1 +
 board/cm41xx/flash.c                   |    1 +
 board/eNET/eNET.c                      |    5 -
 common/Makefile                        |    4 +
 common/board_f.c                       |  888 ++++++++++++++++++++++++++++++++
 common/board_r.c                       |  863 +++++++++++++++++++++++++++++++
 common/cmd_bdinfo.c                    |    6 +-
 config.mk                              |    8 +
 examples/standalone/stubs.c            |    7 +-
 include/asm-generic/global_data.h      |  241 +++++++++
 include/asm-generic/sections.h         |  124 +++++
 include/asm-generic/u-boot.h           |  155 ++++++
 include/common.h                       |   16 +
 include/configs/seaboard.h             |    2 +
 include/initcall.h                     |   25 +
 lib/Makefile                           |    1 +
 lib/initcall.c                         |   41 ++
 45 files changed, 2504 insertions(+), 29 deletions(-)
 create mode 100644 common/board_f.c
 create mode 100644 common/board_r.c
 create mode 100644 include/asm-generic/global_data.h
 create mode 100644 include/asm-generic/sections.h
 create mode 100644 include/asm-generic/u-boot.h
 create mode 100644 include/initcall.h
 create mode 100644 lib/initcall.c

-- 
1.7.3.1



More information about the U-Boot mailing list