blob: 12550a140e055370df70a29e45a742d132c12d0e [file] [log] [blame]
Simon Glass4c8852b2024-08-21 10:19:26 -06001.. SPDX-License-Identifier: GPL-2.0+
2.. (C) Copyright 2014 Google, Inc
3.. sectionauthor:: Simon Glass <sjg@chromium.org>
Simon Glassf5b1c6d2014-03-22 17:14:51 -06004
Simon Glass4c8852b2024-08-21 10:19:26 -06005Generic board
6-------------
Simon Glassf5b1c6d2014-03-22 17:14:51 -06007
Simon Glass0f7dc592016-05-14 18:49:27 -06008U-Boot traditionally had a board.c file for each architecture. This introduced
9quite a lot of duplication, with each architecture tending to do
Simon Glassf5b1c6d2014-03-22 17:14:51 -060010initialisation slightly differently. To address this, a new 'generic board
Simon Glass0f7dc592016-05-14 18:49:27 -060011init' feature was introduced in March 2013 (further motivation is
Simon Glassf5b1c6d2014-03-22 17:14:51 -060012provided in the cover letter below).
13
Simon Glass0f7dc592016-05-14 18:49:27 -060014All boards and architectures have moved to this as of mid 2016.
15
Simon Glassf5b1c6d2014-03-22 17:14:51 -060016
17What has changed?
Simon Glass4c8852b2024-08-21 10:19:26 -060018~~~~~~~~~~~~~~~~~
Simon Glassf5b1c6d2014-03-22 17:14:51 -060019
Simon Glass0f7dc592016-05-14 18:49:27 -060020The main change is that the arch/<arch>/lib/board.c file is removed in
Simon Glassf5b1c6d2014-03-22 17:14:51 -060021favour of common/board_f.c (for pre-relocation init) and common/board_r.c
22(for post-relocation init).
23
Masahiro Yamada940a9222020-06-26 15:13:34 +090024Related to this, the global_data and bd_info structures now have a core set of
Simon Glassf5b1c6d2014-03-22 17:14:51 -060025fields which are common to all architectures. Architecture-specific fields
26have been moved to separate structures.
27
28
Simon Glassf5b1c6d2014-03-22 17:14:51 -060029Further Background
Simon Glass4c8852b2024-08-21 10:19:26 -060030~~~~~~~~~~~~~~~~~~
Simon Glassf5b1c6d2014-03-22 17:14:51 -060031
32The full text of the original generic board series is reproduced below.
33
34--8<-------------
35
36This series creates a generic board.c implementation which contains
37the essential functions of the major arch/xxx/lib/board.c files.
38
39What is the motivation for this change?
40
411. There is a lot of repeated code in the board.c files. Any change to
42things like setting up the baud rate requires a change in 10 separate
43places.
44
452. Since there are 10 separate files, adding a new feature which requires
46initialisation is painful since it must be independently added in 10
47places.
48
Ricardo Ribalda35ea0782015-05-12 16:20:28 +0200493. As time goes by the architectures naturally diverge since there is limited
50pressure to compare features or even CONFIG options against similar things
Simon Glassf5b1c6d2014-03-22 17:14:51 -060051in other board.c files.
52
534. New architectures must implement all the features all over again, and
Ricardo Ribalda35ea0782015-05-12 16:20:28 +020054sometimes in subtle different ways. This places an unfair burden on getting
Simon Glassf5b1c6d2014-03-22 17:14:51 -060055a new architecture fully functional and running with U-Boot.
56
575. While it is a bit of a tricky change, I believe it is worthwhile and
58achievable. There is no requirement that all code be common, only that
59the code that is common should be located in common/board.c rather than
60arch/xxx/lib/board.c.
61
62All the functions of board_init_f() and board_init_r() are broken into
63separate function calls so that they can easily be included or excluded
64for a particular architecture. It also makes it easier to adopt Graeme's
65initcall proposal when it is ready.
66
67http://lists.denx.de/pipermail/u-boot/2012-January/114499.html
68
69This series removes the dependency on generic relocation. So relocation
70happens as one big chunk and is still completely arch-specific. See the
71relocation series for a proposed solution to this for ARM:
72
73http://lists.denx.de/pipermail/u-boot/2011-December/112928.html
74
75or Graeme's recent x86 series v2:
76
77http://lists.denx.de/pipermail/u-boot/2012-January/114467.html
78
79Instead of moving over a whole architecture, this series takes the approach
80of simply enabling generic board support for an architecture. It is then up
81to each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board
82config file. If this is not done, then the code will be generated as
83before. This allows both sets of code to co-exist until we are comfortable
84with the generic approach, and enough boards run.
85
86ARM is a relatively large board.c file and one which I can test, therefore
87I think it is a good target for this series. On the other hand, x86 is
88relatively small and simple, but different enough that it introduces a
89few issues to be solved. So I have chosen both ARM and x86 for this series.
90After a suggestion from Wolfgang I have added PPC also. This is the
91largest and most feature-full board, so hopefully we have all bases
92covered in this RFC.
93
94A generic global_data structure is also required. This might upset a few
95people. Here is my basic reasoning: most fields are the same, all
96architectures include and need it, most global_data.h files already have
97#ifdefs to select fields for a particular SOC, so it is hard to
98see why architecures are different in this area. We can perhaps add a
99way to put architecture-specific fields into a separate header file, but
100for now I have judged that to be counter-productive.
101
102Similarly we need a generic bd_info structure, since generic code will
103be accessing it. I have done this in the same way as global_data and the
104same comments apply.
105
106There was dicussion on the list about passing gd_t around as a parameter
107to pre-relocation init functions. I think this makes sense, but it can
108be done as a separate change, and this series does not require it.
109
110While this series needs to stand on its own (as with the link script
111cleanup series and the generic relocation series) the goal is the
112unification of the board init code. So I hope we can address issues with
113this in mind, rather than focusing too narrowly on particular ARM, x86 or
114PPC issues.
115
116I have run-tested ARM on Tegra Seaboard only. To try it out, define
117CONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on
118x86 and PPC at least it will hang, but if you are lucky it will print
119something first :-)
120
121I have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all
122ARM, PPC and x86 boards. There are a few failures due to errors in
123the board config, which I have sent patches for. The main issue is
124just the difference between __bss_end and __bss_end__.
125
126Note: the first group of commits are required for this series to build,
127but could be separated out if required. I have included them here for
128convenience.
129
130------------->8--
131
132Simon Glass, sjg@chromium.org
133March 2014
Simon Glass4c8852b2024-08-21 10:19:26 -0600134
Simon Glass0f7dc592016-05-14 18:49:27 -0600135Updated after final removal, May 2016
Simon Glass4c8852b2024-08-21 10:19:26 -0600136