xref: /openbmc/u-boot/doc/README.generic-board (revision 96ee97a17b0d093e8af067acce76de3622ddf3a0)
10f605c15SSimon Glass#
20f605c15SSimon Glass# (C) Copyright 2014 Google, Inc
30f605c15SSimon Glass# Simon Glass <sjg@chromium.org>
40f605c15SSimon Glass#
50f605c15SSimon Glass# SPDX-License-Identifier:	GPL-2.0+
60f605c15SSimon Glass#
70f605c15SSimon Glass
80f605c15SSimon GlassDEPRECATION NOTICE FOR arch/<arch>/lib/board.c
90f605c15SSimon Glass
100f605c15SSimon GlassFor board maintainers: Please submit patches for boards you maintain before
110f605c15SSimon GlassJuly 2014, to make them use generic board.
120f605c15SSimon Glass
130f605c15SSimon GlassFor architecture maintainers: Please submit patches to remove your
140f605c15SSimon Glassarchitecture-specific board.c file before October 2014.
150f605c15SSimon Glass
160f605c15SSimon Glass
170f605c15SSimon GlassBackground
180f605c15SSimon Glass----------
190f605c15SSimon Glass
20*96ee97a1SFabio EstevamU-Boot has traditionally had a board.c file for each architecture. This has
210f605c15SSimon Glassintroduced quite a lot of duplication, with each architecture tending to do
220f605c15SSimon Glassinitialisation slightly differently. To address this, a new 'generic board
230f605c15SSimon Glassinit' feature was introduced a year ago in March 2013 (further motivation is
240f605c15SSimon Glassprovided in the cover letter below).
250f605c15SSimon Glass
260f605c15SSimon Glass
270f605c15SSimon GlassWhat has changed?
280f605c15SSimon Glass-----------------
290f605c15SSimon Glass
300f605c15SSimon GlassThe main change is that the arch/<arch>/lib/board.c file is being removed in
310f605c15SSimon Glassfavour of common/board_f.c (for pre-relocation init) and common/board_r.c
320f605c15SSimon Glass(for post-relocation init).
330f605c15SSimon Glass
340f605c15SSimon GlassRelated to this, the global_data and bd_t structures now have a core set of
350f605c15SSimon Glassfields which are common to all architectures. Architecture-specific fields
360f605c15SSimon Glasshave been moved to separate structures.
370f605c15SSimon Glass
380f605c15SSimon Glass
390f605c15SSimon GlassSupported Arcthitectures
400f605c15SSimon Glass------------------------
410f605c15SSimon Glass
420f605c15SSimon GlassIf you are unlucky then your architecture may not support generic board.
430f605c15SSimon GlassThe following architectures are supported at the time of writing:
440f605c15SSimon Glass
450f605c15SSimon Glass   arc
460f605c15SSimon Glass   arm
470f605c15SSimon Glass   powerpc
480f605c15SSimon Glass   sandbox
490f605c15SSimon Glass   x86
500f605c15SSimon Glass
510f605c15SSimon GlassIf your architecture is not supported, you need to adjust your
520f605c15SSimon Glassarch/<arch>/config.mk file to include:
530f605c15SSimon Glass
540f605c15SSimon Glass   __HAVE_ARCH_GENERIC_BOARD := y
550f605c15SSimon Glass
560f605c15SSimon Glassand test it with a suitable board, as follows.
570f605c15SSimon Glass
580f605c15SSimon Glass
590f605c15SSimon GlassAdding Support for your Board
600f605c15SSimon Glass-----------------------------
610f605c15SSimon Glass
620f605c15SSimon GlassTo enable generic board for your board, define CONFIG_SYS_GENERIC_BOARD in
630f605c15SSimon Glassyour board config header file.
640f605c15SSimon Glass
650f605c15SSimon GlassTest that U-Boot still functions correctly on your board, and fix any
660f605c15SSimon Glassproblems you find. Don't be surprised if there are no problems - generic
670f605c15SSimon Glassboard has had a reasonable amount of testing with common boards.
680f605c15SSimon Glass
690f605c15SSimon Glass
700f605c15SSimon GlassDeadLine
710f605c15SSimon Glass--------
720f605c15SSimon Glass
730f605c15SSimon GlassPlease don't take this the wrong way - there is no intent to make your life
740f605c15SSimon Glassmiserable, and we have the greatest respect and admiration for U-Boot users.
750f605c15SSimon GlassHowever, with any migration there has to be a period where the old way is
760f605c15SSimon Glassdeprecated and removed. Every patch to the deprecated code introduces a
770f605c15SSimon Glasspotential breakage in the new unused code. Therefore:
780f605c15SSimon Glass
790f605c15SSimon GlassBoards or architectures not converted over to general board by the
800f605c15SSimon Glassend of 2014 may be forcibly changed over (potentially causing run-time
810f605c15SSimon Glassbreakage) or removed.
820f605c15SSimon Glass
830f605c15SSimon Glass
840f605c15SSimon Glass
850f605c15SSimon GlassFurther Background
860f605c15SSimon Glass------------------
870f605c15SSimon Glass
880f605c15SSimon GlassThe full text of the original generic board series is reproduced below.
890f605c15SSimon Glass
900f605c15SSimon Glass--8<-------------
910f605c15SSimon Glass
920f605c15SSimon GlassThis series creates a generic board.c implementation which contains
930f605c15SSimon Glassthe essential functions of the major arch/xxx/lib/board.c files.
940f605c15SSimon Glass
950f605c15SSimon GlassWhat is the motivation for this change?
960f605c15SSimon Glass
970f605c15SSimon Glass1. There is a lot of repeated code in the board.c files. Any change to
980f605c15SSimon Glassthings like setting up the baud rate requires a change in 10 separate
990f605c15SSimon Glassplaces.
1000f605c15SSimon Glass
1010f605c15SSimon Glass2. Since there are 10 separate files, adding a new feature which requires
1020f605c15SSimon Glassinitialisation is painful since it must be independently added in 10
1030f605c15SSimon Glassplaces.
1040f605c15SSimon Glass
1050f605c15SSimon Glass3. As time goes by the architectures naturely diverge since there is limited
1060f605c15SSimon Glasspressure to compare features or even CONFIG options against simiilar things
1070f605c15SSimon Glassin other board.c files.
1080f605c15SSimon Glass
1090f605c15SSimon Glass4. New architectures must implement all the features all over again, and
1100f605c15SSimon Glasssometimes in subtley different ways. This places an unfair burden on getting
1110f605c15SSimon Glassa new architecture fully functional and running with U-Boot.
1120f605c15SSimon Glass
1130f605c15SSimon Glass5. While it is a bit of a tricky change, I believe it is worthwhile and
1140f605c15SSimon Glassachievable. There is no requirement that all code be common, only that
1150f605c15SSimon Glassthe code that is common should be located in common/board.c rather than
1160f605c15SSimon Glassarch/xxx/lib/board.c.
1170f605c15SSimon Glass
1180f605c15SSimon GlassAll the functions of board_init_f() and board_init_r() are broken into
1190f605c15SSimon Glassseparate function calls so that they can easily be included or excluded
1200f605c15SSimon Glassfor a particular architecture. It also makes it easier to adopt Graeme's
1210f605c15SSimon Glassinitcall proposal when it is ready.
1220f605c15SSimon Glass
1230f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2012-January/114499.html
1240f605c15SSimon Glass
1250f605c15SSimon GlassThis series removes the dependency on generic relocation. So relocation
1260f605c15SSimon Glasshappens as one big chunk and is still completely arch-specific. See the
1270f605c15SSimon Glassrelocation series for a proposed solution to this for ARM:
1280f605c15SSimon Glass
1290f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2011-December/112928.html
1300f605c15SSimon Glass
1310f605c15SSimon Glassor Graeme's recent x86 series v2:
1320f605c15SSimon Glass
1330f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2012-January/114467.html
1340f605c15SSimon Glass
1350f605c15SSimon GlassInstead of moving over a whole architecture, this series takes the approach
1360f605c15SSimon Glassof simply enabling generic board support for an architecture. It is then up
1370f605c15SSimon Glassto each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board
1380f605c15SSimon Glassconfig file. If this is not done, then the code will be generated as
1390f605c15SSimon Glassbefore. This allows both sets of code to co-exist until we are comfortable
1400f605c15SSimon Glasswith the generic approach, and enough boards run.
1410f605c15SSimon Glass
1420f605c15SSimon GlassARM is a relatively large board.c file and one which I can test, therefore
1430f605c15SSimon GlassI think it is a good target for this series. On the other hand, x86 is
1440f605c15SSimon Glassrelatively small and simple, but different enough that it introduces a
1450f605c15SSimon Glassfew issues to be solved. So I have chosen both ARM and x86 for this series.
1460f605c15SSimon GlassAfter a suggestion from Wolfgang I have added PPC also. This is the
1470f605c15SSimon Glasslargest and most feature-full board, so hopefully we have all bases
1480f605c15SSimon Glasscovered in this RFC.
1490f605c15SSimon Glass
1500f605c15SSimon GlassA generic global_data structure is also required. This might upset a few
1510f605c15SSimon Glasspeople. Here is my basic reasoning: most fields are the same, all
1520f605c15SSimon Glassarchitectures include and need it, most global_data.h files already have
1530f605c15SSimon Glass#ifdefs to select fields for a particular SOC, so it is hard to
1540f605c15SSimon Glasssee why architecures are different in this area. We can perhaps add a
1550f605c15SSimon Glassway to put architecture-specific fields into a separate header file, but
1560f605c15SSimon Glassfor now I have judged that to be counter-productive.
1570f605c15SSimon Glass
1580f605c15SSimon GlassSimilarly we need a generic bd_info structure, since generic code will
1590f605c15SSimon Glassbe accessing it. I have done this in the same way as global_data and the
1600f605c15SSimon Glasssame comments apply.
1610f605c15SSimon Glass
1620f605c15SSimon GlassThere was dicussion on the list about passing gd_t around as a parameter
1630f605c15SSimon Glassto pre-relocation init functions. I think this makes sense, but it can
1640f605c15SSimon Glassbe done as a separate change, and this series does not require it.
1650f605c15SSimon Glass
1660f605c15SSimon GlassWhile this series needs to stand on its own (as with the link script
1670f605c15SSimon Glasscleanup series and the generic relocation series) the goal is the
1680f605c15SSimon Glassunification of the board init code. So I hope we can address issues with
1690f605c15SSimon Glassthis in mind, rather than focusing too narrowly on particular ARM, x86 or
1700f605c15SSimon GlassPPC issues.
1710f605c15SSimon Glass
1720f605c15SSimon GlassI have run-tested ARM on Tegra Seaboard only. To try it out, define
1730f605c15SSimon GlassCONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on
1740f605c15SSimon Glassx86 and PPC at least it will hang, but if you are lucky it will print
1750f605c15SSimon Glasssomething first :-)
1760f605c15SSimon Glass
1770f605c15SSimon GlassI have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all
1780f605c15SSimon GlassARM, PPC and x86 boards. There are a few failures due to errors in
1790f605c15SSimon Glassthe board config, which I have sent patches for. The main issue is
1800f605c15SSimon Glassjust the difference between __bss_end and __bss_end__.
1810f605c15SSimon Glass
1820f605c15SSimon GlassNote: the first group of commits are required for this series to build,
1830f605c15SSimon Glassbut could be separated out if required. I have included them here for
1840f605c15SSimon Glassconvenience.
1850f605c15SSimon Glass
1860f605c15SSimon Glass------------->8--
1870f605c15SSimon Glass
1880f605c15SSimon GlassSimon Glass, sjg@chromium.org
1890f605c15SSimon GlassMarch 2014
190