xref: /openbmc/u-boot/doc/README.generic-board (revision 0f605c1501f6e82553e9affc6e17876a85db408c)
1*0f605c15SSimon Glass#
2*0f605c15SSimon Glass# (C) Copyright 2014 Google, Inc
3*0f605c15SSimon Glass# Simon Glass <sjg@chromium.org>
4*0f605c15SSimon Glass#
5*0f605c15SSimon Glass# SPDX-License-Identifier:	GPL-2.0+
6*0f605c15SSimon Glass#
7*0f605c15SSimon Glass
8*0f605c15SSimon GlassDEPRECATION NOTICE FOR arch/<arch>/lib/board.c
9*0f605c15SSimon Glass
10*0f605c15SSimon GlassFor board maintainers: Please submit patches for boards you maintain before
11*0f605c15SSimon GlassJuly 2014, to make them use generic board.
12*0f605c15SSimon Glass
13*0f605c15SSimon GlassFor architecture maintainers: Please submit patches to remove your
14*0f605c15SSimon Glassarchitecture-specific board.c file before October 2014.
15*0f605c15SSimon Glass
16*0f605c15SSimon Glass
17*0f605c15SSimon GlassBackground
18*0f605c15SSimon Glass----------
19*0f605c15SSimon Glass
20*0f605c15SSimon GlassU-Boot has tranditionally had a board.c file for each architecture. This has
21*0f605c15SSimon Glassintroduced quite a lot of duplication, with each architecture tending to do
22*0f605c15SSimon Glassinitialisation slightly differently. To address this, a new 'generic board
23*0f605c15SSimon Glassinit' feature was introduced a year ago in March 2013 (further motivation is
24*0f605c15SSimon Glassprovided in the cover letter below).
25*0f605c15SSimon Glass
26*0f605c15SSimon Glass
27*0f605c15SSimon GlassWhat has changed?
28*0f605c15SSimon Glass-----------------
29*0f605c15SSimon Glass
30*0f605c15SSimon GlassThe main change is that the arch/<arch>/lib/board.c file is being removed in
31*0f605c15SSimon Glassfavour of common/board_f.c (for pre-relocation init) and common/board_r.c
32*0f605c15SSimon Glass(for post-relocation init).
33*0f605c15SSimon Glass
34*0f605c15SSimon GlassRelated to this, the global_data and bd_t structures now have a core set of
35*0f605c15SSimon Glassfields which are common to all architectures. Architecture-specific fields
36*0f605c15SSimon Glasshave been moved to separate structures.
37*0f605c15SSimon Glass
38*0f605c15SSimon Glass
39*0f605c15SSimon GlassSupported Arcthitectures
40*0f605c15SSimon Glass------------------------
41*0f605c15SSimon Glass
42*0f605c15SSimon GlassIf you are unlucky then your architecture may not support generic board.
43*0f605c15SSimon GlassThe following architectures are supported at the time of writing:
44*0f605c15SSimon Glass
45*0f605c15SSimon Glass   arc
46*0f605c15SSimon Glass   arm
47*0f605c15SSimon Glass   powerpc
48*0f605c15SSimon Glass   sandbox
49*0f605c15SSimon Glass   x86
50*0f605c15SSimon Glass
51*0f605c15SSimon GlassIf your architecture is not supported, you need to adjust your
52*0f605c15SSimon Glassarch/<arch>/config.mk file to include:
53*0f605c15SSimon Glass
54*0f605c15SSimon Glass   __HAVE_ARCH_GENERIC_BOARD := y
55*0f605c15SSimon Glass
56*0f605c15SSimon Glassand test it with a suitable board, as follows.
57*0f605c15SSimon Glass
58*0f605c15SSimon Glass
59*0f605c15SSimon GlassAdding Support for your Board
60*0f605c15SSimon Glass-----------------------------
61*0f605c15SSimon Glass
62*0f605c15SSimon GlassTo enable generic board for your board, define CONFIG_SYS_GENERIC_BOARD in
63*0f605c15SSimon Glassyour board config header file.
64*0f605c15SSimon Glass
65*0f605c15SSimon GlassTest that U-Boot still functions correctly on your board, and fix any
66*0f605c15SSimon Glassproblems you find. Don't be surprised if there are no problems - generic
67*0f605c15SSimon Glassboard has had a reasonable amount of testing with common boards.
68*0f605c15SSimon Glass
69*0f605c15SSimon Glass
70*0f605c15SSimon GlassDeadLine
71*0f605c15SSimon Glass--------
72*0f605c15SSimon Glass
73*0f605c15SSimon GlassPlease don't take this the wrong way - there is no intent to make your life
74*0f605c15SSimon Glassmiserable, and we have the greatest respect and admiration for U-Boot users.
75*0f605c15SSimon GlassHowever, with any migration there has to be a period where the old way is
76*0f605c15SSimon Glassdeprecated and removed. Every patch to the deprecated code introduces a
77*0f605c15SSimon Glasspotential breakage in the new unused code. Therefore:
78*0f605c15SSimon Glass
79*0f605c15SSimon GlassBoards or architectures not converted over to general board by the
80*0f605c15SSimon Glassend of 2014 may be forcibly changed over (potentially causing run-time
81*0f605c15SSimon Glassbreakage) or removed.
82*0f605c15SSimon Glass
83*0f605c15SSimon Glass
84*0f605c15SSimon Glass
85*0f605c15SSimon GlassFurther Background
86*0f605c15SSimon Glass------------------
87*0f605c15SSimon Glass
88*0f605c15SSimon GlassThe full text of the original generic board series is reproduced below.
89*0f605c15SSimon Glass
90*0f605c15SSimon Glass--8<-------------
91*0f605c15SSimon Glass
92*0f605c15SSimon GlassThis series creates a generic board.c implementation which contains
93*0f605c15SSimon Glassthe essential functions of the major arch/xxx/lib/board.c files.
94*0f605c15SSimon Glass
95*0f605c15SSimon GlassWhat is the motivation for this change?
96*0f605c15SSimon Glass
97*0f605c15SSimon Glass1. There is a lot of repeated code in the board.c files. Any change to
98*0f605c15SSimon Glassthings like setting up the baud rate requires a change in 10 separate
99*0f605c15SSimon Glassplaces.
100*0f605c15SSimon Glass
101*0f605c15SSimon Glass2. Since there are 10 separate files, adding a new feature which requires
102*0f605c15SSimon Glassinitialisation is painful since it must be independently added in 10
103*0f605c15SSimon Glassplaces.
104*0f605c15SSimon Glass
105*0f605c15SSimon Glass3. As time goes by the architectures naturely diverge since there is limited
106*0f605c15SSimon Glasspressure to compare features or even CONFIG options against simiilar things
107*0f605c15SSimon Glassin other board.c files.
108*0f605c15SSimon Glass
109*0f605c15SSimon Glass4. New architectures must implement all the features all over again, and
110*0f605c15SSimon Glasssometimes in subtley different ways. This places an unfair burden on getting
111*0f605c15SSimon Glassa new architecture fully functional and running with U-Boot.
112*0f605c15SSimon Glass
113*0f605c15SSimon Glass5. While it is a bit of a tricky change, I believe it is worthwhile and
114*0f605c15SSimon Glassachievable. There is no requirement that all code be common, only that
115*0f605c15SSimon Glassthe code that is common should be located in common/board.c rather than
116*0f605c15SSimon Glassarch/xxx/lib/board.c.
117*0f605c15SSimon Glass
118*0f605c15SSimon GlassAll the functions of board_init_f() and board_init_r() are broken into
119*0f605c15SSimon Glassseparate function calls so that they can easily be included or excluded
120*0f605c15SSimon Glassfor a particular architecture. It also makes it easier to adopt Graeme's
121*0f605c15SSimon Glassinitcall proposal when it is ready.
122*0f605c15SSimon Glass
123*0f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2012-January/114499.html
124*0f605c15SSimon Glass
125*0f605c15SSimon GlassThis series removes the dependency on generic relocation. So relocation
126*0f605c15SSimon Glasshappens as one big chunk and is still completely arch-specific. See the
127*0f605c15SSimon Glassrelocation series for a proposed solution to this for ARM:
128*0f605c15SSimon Glass
129*0f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2011-December/112928.html
130*0f605c15SSimon Glass
131*0f605c15SSimon Glassor Graeme's recent x86 series v2:
132*0f605c15SSimon Glass
133*0f605c15SSimon Glasshttp://lists.denx.de/pipermail/u-boot/2012-January/114467.html
134*0f605c15SSimon Glass
135*0f605c15SSimon GlassInstead of moving over a whole architecture, this series takes the approach
136*0f605c15SSimon Glassof simply enabling generic board support for an architecture. It is then up
137*0f605c15SSimon Glassto each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board
138*0f605c15SSimon Glassconfig file. If this is not done, then the code will be generated as
139*0f605c15SSimon Glassbefore. This allows both sets of code to co-exist until we are comfortable
140*0f605c15SSimon Glasswith the generic approach, and enough boards run.
141*0f605c15SSimon Glass
142*0f605c15SSimon GlassARM is a relatively large board.c file and one which I can test, therefore
143*0f605c15SSimon GlassI think it is a good target for this series. On the other hand, x86 is
144*0f605c15SSimon Glassrelatively small and simple, but different enough that it introduces a
145*0f605c15SSimon Glassfew issues to be solved. So I have chosen both ARM and x86 for this series.
146*0f605c15SSimon GlassAfter a suggestion from Wolfgang I have added PPC also. This is the
147*0f605c15SSimon Glasslargest and most feature-full board, so hopefully we have all bases
148*0f605c15SSimon Glasscovered in this RFC.
149*0f605c15SSimon Glass
150*0f605c15SSimon GlassA generic global_data structure is also required. This might upset a few
151*0f605c15SSimon Glasspeople. Here is my basic reasoning: most fields are the same, all
152*0f605c15SSimon Glassarchitectures include and need it, most global_data.h files already have
153*0f605c15SSimon Glass#ifdefs to select fields for a particular SOC, so it is hard to
154*0f605c15SSimon Glasssee why architecures are different in this area. We can perhaps add a
155*0f605c15SSimon Glassway to put architecture-specific fields into a separate header file, but
156*0f605c15SSimon Glassfor now I have judged that to be counter-productive.
157*0f605c15SSimon Glass
158*0f605c15SSimon GlassSimilarly we need a generic bd_info structure, since generic code will
159*0f605c15SSimon Glassbe accessing it. I have done this in the same way as global_data and the
160*0f605c15SSimon Glasssame comments apply.
161*0f605c15SSimon Glass
162*0f605c15SSimon GlassThere was dicussion on the list about passing gd_t around as a parameter
163*0f605c15SSimon Glassto pre-relocation init functions. I think this makes sense, but it can
164*0f605c15SSimon Glassbe done as a separate change, and this series does not require it.
165*0f605c15SSimon Glass
166*0f605c15SSimon GlassWhile this series needs to stand on its own (as with the link script
167*0f605c15SSimon Glasscleanup series and the generic relocation series) the goal is the
168*0f605c15SSimon Glassunification of the board init code. So I hope we can address issues with
169*0f605c15SSimon Glassthis in mind, rather than focusing too narrowly on particular ARM, x86 or
170*0f605c15SSimon GlassPPC issues.
171*0f605c15SSimon Glass
172*0f605c15SSimon GlassI have run-tested ARM on Tegra Seaboard only. To try it out, define
173*0f605c15SSimon GlassCONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on
174*0f605c15SSimon Glassx86 and PPC at least it will hang, but if you are lucky it will print
175*0f605c15SSimon Glasssomething first :-)
176*0f605c15SSimon Glass
177*0f605c15SSimon GlassI have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all
178*0f605c15SSimon GlassARM, PPC and x86 boards. There are a few failures due to errors in
179*0f605c15SSimon Glassthe board config, which I have sent patches for. The main issue is
180*0f605c15SSimon Glassjust the difference between __bss_end and __bss_end__.
181*0f605c15SSimon Glass
182*0f605c15SSimon GlassNote: the first group of commits are required for this series to build,
183*0f605c15SSimon Glassbut could be separated out if required. I have included them here for
184*0f605c15SSimon Glassconvenience.
185*0f605c15SSimon Glass
186*0f605c15SSimon Glass------------->8--
187*0f605c15SSimon Glass
188*0f605c15SSimon GlassSimon Glass, sjg@chromium.org
189*0f605c15SSimon GlassMarch 2014
190