xref: /openbmc/u-boot/doc/README.generic-board (revision a560ad7083736fa147137eda2b04fd98b159c63f)
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
2096ee97a1SFabio 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
39*a560ad70SRicardo RibaldaSupported Architectures
400f605c15SSimon Glass------------------------
410f605c15SSimon Glass
420f605c15SSimon GlassIf you are unlucky then your architecture may not support generic board.
4315a77375SMasahiro YamadaThe following architectures are supported now:
440f605c15SSimon Glass
450f605c15SSimon Glass   arc
460f605c15SSimon Glass   arm
470a12e687SMasahiro Yamada   avr32
480a12e687SMasahiro Yamada   blackfin
490a12e687SMasahiro Yamada   m68k
500a12e687SMasahiro Yamada   microblaze
5115a77375SMasahiro Yamada   mips
520a12e687SMasahiro Yamada   nios2
530f605c15SSimon Glass   powerpc
540f605c15SSimon Glass   sandbox
550f605c15SSimon Glass   x86
560f605c15SSimon Glass
570a12e687SMasahiro YamadaIf your architecture is not supported, you need to select
580a12e687SMasahiro YamadaHAVE_GENERIC_BOARD in arch/Kconfig
590f605c15SSimon Glassand test it with a suitable board, as follows.
600f605c15SSimon Glass
610f605c15SSimon Glass
620f605c15SSimon GlassAdding Support for your Board
630f605c15SSimon Glass-----------------------------
640f605c15SSimon Glass
650f605c15SSimon GlassTo enable generic board for your board, define CONFIG_SYS_GENERIC_BOARD in
660f605c15SSimon Glassyour board config header file.
670f605c15SSimon Glass
680f605c15SSimon GlassTest that U-Boot still functions correctly on your board, and fix any
690f605c15SSimon Glassproblems you find. Don't be surprised if there are no problems - generic
700f605c15SSimon Glassboard has had a reasonable amount of testing with common boards.
710f605c15SSimon Glass
720f605c15SSimon Glass
730f605c15SSimon GlassDeadLine
740f605c15SSimon Glass--------
750f605c15SSimon Glass
760f605c15SSimon GlassPlease don't take this the wrong way - there is no intent to make your life
770f605c15SSimon Glassmiserable, and we have the greatest respect and admiration for U-Boot users.
780f605c15SSimon GlassHowever, with any migration there has to be a period where the old way is
790f605c15SSimon Glassdeprecated and removed. Every patch to the deprecated code introduces a
800f605c15SSimon Glasspotential breakage in the new unused code. Therefore:
810f605c15SSimon Glass
820f605c15SSimon GlassBoards or architectures not converted over to general board by the
830f605c15SSimon Glassend of 2014 may be forcibly changed over (potentially causing run-time
840f605c15SSimon Glassbreakage) or removed.
850f605c15SSimon Glass
860f605c15SSimon Glass
870f605c15SSimon Glass
880f605c15SSimon GlassFurther Background
890f605c15SSimon Glass------------------
900f605c15SSimon Glass
910f605c15SSimon GlassThe full text of the original generic board series is reproduced below.
920f605c15SSimon Glass
930f605c15SSimon Glass--8<-------------
940f605c15SSimon Glass
950f605c15SSimon GlassThis series creates a generic board.c implementation which contains
960f605c15SSimon Glassthe essential functions of the major arch/xxx/lib/board.c files.
970f605c15SSimon Glass
980f605c15SSimon GlassWhat is the motivation for this change?
990f605c15SSimon Glass
1000f605c15SSimon Glass1. There is a lot of repeated code in the board.c files. Any change to
1010f605c15SSimon Glassthings like setting up the baud rate requires a change in 10 separate
1020f605c15SSimon Glassplaces.
1030f605c15SSimon Glass
1040f605c15SSimon Glass2. Since there are 10 separate files, adding a new feature which requires
1050f605c15SSimon Glassinitialisation is painful since it must be independently added in 10
1060f605c15SSimon Glassplaces.
1070f605c15SSimon Glass
108*a560ad70SRicardo Ribalda3. As time goes by the architectures naturally diverge since there is limited
109*a560ad70SRicardo Ribaldapressure to compare features or even CONFIG options against similar things
1100f605c15SSimon Glassin other board.c files.
1110f605c15SSimon Glass
1120f605c15SSimon Glass4. New architectures must implement all the features all over again, and
113*a560ad70SRicardo Ribaldasometimes in subtle different ways. This places an unfair burden on getting
1140f605c15SSimon Glassa new architecture fully functional and running with U-Boot.
1150f605c15SSimon Glass
1160f605c15SSimon Glass5. While it is a bit of a tricky change, I believe it is worthwhile and
1170f605c15SSimon Glassachievable. There is no requirement that all code be common, only that
1180f605c15SSimon Glassthe code that is common should be located in common/board.c rather than
1190f605c15SSimon Glassarch/xxx/lib/board.c.
1200f605c15SSimon Glass
1210f605c15SSimon GlassAll the functions of board_init_f() and board_init_r() are broken into
1220f605c15SSimon Glassseparate function calls so that they can easily be included or excluded
1230f605c15SSimon Glassfor a particular architecture. It also makes it easier to adopt Graeme's
1240f605c15SSimon Glassinitcall proposal when it is ready.
1250f605c15SSimon Glass
1260f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2012-January/114499.html
1270f605c15SSimon Glass
1280f605c15SSimon GlassThis series removes the dependency on generic relocation. So relocation
1290f605c15SSimon Glasshappens as one big chunk and is still completely arch-specific. See the
1300f605c15SSimon Glassrelocation series for a proposed solution to this for ARM:
1310f605c15SSimon Glass
1320f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2011-December/112928.html
1330f605c15SSimon Glass
1340f605c15SSimon Glassor Graeme's recent x86 series v2:
1350f605c15SSimon Glass
1360f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2012-January/114467.html
1370f605c15SSimon Glass
1380f605c15SSimon GlassInstead of moving over a whole architecture, this series takes the approach
1390f605c15SSimon Glassof simply enabling generic board support for an architecture. It is then up
1400f605c15SSimon Glassto each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board
1410f605c15SSimon Glassconfig file. If this is not done, then the code will be generated as
1420f605c15SSimon Glassbefore. This allows both sets of code to co-exist until we are comfortable
1430f605c15SSimon Glasswith the generic approach, and enough boards run.
1440f605c15SSimon Glass
1450f605c15SSimon GlassARM is a relatively large board.c file and one which I can test, therefore
1460f605c15SSimon GlassI think it is a good target for this series. On the other hand, x86 is
1470f605c15SSimon Glassrelatively small and simple, but different enough that it introduces a
1480f605c15SSimon Glassfew issues to be solved. So I have chosen both ARM and x86 for this series.
1490f605c15SSimon GlassAfter a suggestion from Wolfgang I have added PPC also. This is the
1500f605c15SSimon Glasslargest and most feature-full board, so hopefully we have all bases
1510f605c15SSimon Glasscovered in this RFC.
1520f605c15SSimon Glass
1530f605c15SSimon GlassA generic global_data structure is also required. This might upset a few
1540f605c15SSimon Glasspeople. Here is my basic reasoning: most fields are the same, all
1550f605c15SSimon Glassarchitectures include and need it, most global_data.h files already have
1560f605c15SSimon Glass#ifdefs to select fields for a particular SOC, so it is hard to
1570f605c15SSimon Glasssee why architecures are different in this area. We can perhaps add a
1580f605c15SSimon Glassway to put architecture-specific fields into a separate header file, but
1590f605c15SSimon Glassfor now I have judged that to be counter-productive.
1600f605c15SSimon Glass
1610f605c15SSimon GlassSimilarly we need a generic bd_info structure, since generic code will
1620f605c15SSimon Glassbe accessing it. I have done this in the same way as global_data and the
1630f605c15SSimon Glasssame comments apply.
1640f605c15SSimon Glass
1650f605c15SSimon GlassThere was dicussion on the list about passing gd_t around as a parameter
1660f605c15SSimon Glassto pre-relocation init functions. I think this makes sense, but it can
1670f605c15SSimon Glassbe done as a separate change, and this series does not require it.
1680f605c15SSimon Glass
1690f605c15SSimon GlassWhile this series needs to stand on its own (as with the link script
1700f605c15SSimon Glasscleanup series and the generic relocation series) the goal is the
1710f605c15SSimon Glassunification of the board init code. So I hope we can address issues with
1720f605c15SSimon Glassthis in mind, rather than focusing too narrowly on particular ARM, x86 or
1730f605c15SSimon GlassPPC issues.
1740f605c15SSimon Glass
1750f605c15SSimon GlassI have run-tested ARM on Tegra Seaboard only. To try it out, define
1760f605c15SSimon GlassCONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on
1770f605c15SSimon Glassx86 and PPC at least it will hang, but if you are lucky it will print
1780f605c15SSimon Glasssomething first :-)
1790f605c15SSimon Glass
1800f605c15SSimon GlassI have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all
1810f605c15SSimon GlassARM, PPC and x86 boards. There are a few failures due to errors in
1820f605c15SSimon Glassthe board config, which I have sent patches for. The main issue is
1830f605c15SSimon Glassjust the difference between __bss_end and __bss_end__.
1840f605c15SSimon Glass
1850f605c15SSimon GlassNote: the first group of commits are required for this series to build,
1860f605c15SSimon Glassbut could be separated out if required. I have included them here for
1870f605c15SSimon Glassconvenience.
1880f605c15SSimon Glass
1890f605c15SSimon Glass------------->8--
1900f605c15SSimon Glass
1910f605c15SSimon GlassSimon Glass, sjg@chromium.org
1920f605c15SSimon GlassMarch 2014
193