Commit c68a05feeb88de9fcf158e67ff6423c4cc988f88
Committed by
Wolfgang Denk
1 parent
41410eee47
Exists in
master
and in
54 other branches
Adds two more ethernet interface to 83xx
Added as a convenience for other platforms that uses MPC8360 (has 8 UCC). Six eth interface is chosen because the platform I am using combines UCC1&2 and UCC3&4 as 1000 Eth and the other four UCCs as 10/100 Eth. Signed-off-by: Richard Retanubun <RichardRetanubun@RugggedCom.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Showing 10 changed files with 126 additions and 2 deletions Inline Diff
README
1 | # | 1 | # |
2 | # (C) Copyright 2000 - 2008 | 2 | # (C) Copyright 2000 - 2008 |
3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | # | 4 | # |
5 | # See file CREDITS for list of people who contributed to this | 5 | # See file CREDITS for list of people who contributed to this |
6 | # project. | 6 | # project. |
7 | # | 7 | # |
8 | # This program is free software; you can redistribute it and/or | 8 | # This program is free software; you can redistribute it and/or |
9 | # modify it under the terms of the GNU General Public License as | 9 | # modify it under the terms of the GNU General Public License as |
10 | # published by the Free Software Foundation; either version 2 of | 10 | # published by the Free Software Foundation; either version 2 of |
11 | # the License, or (at your option) any later version. | 11 | # the License, or (at your option) any later version. |
12 | # | 12 | # |
13 | # This program is distributed in the hope that it will be useful, | 13 | # This program is distributed in the hope that it will be useful, |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | # GNU General Public License for more details. | 16 | # GNU General Public License for more details. |
17 | # | 17 | # |
18 | # You should have received a copy of the GNU General Public License | 18 | # You should have received a copy of the GNU General Public License |
19 | # along with this program; if not, write to the Free Software | 19 | # along with this program; if not, write to the Free Software |
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | # MA 02111-1307 USA | 21 | # MA 02111-1307 USA |
22 | # | 22 | # |
23 | 23 | ||
24 | Summary: | 24 | Summary: |
25 | ======== | 25 | ======== |
26 | 26 | ||
27 | This directory contains the source code for U-Boot, a boot loader for | 27 | This directory contains the source code for U-Boot, a boot loader for |
28 | Embedded boards based on PowerPC, ARM, MIPS and several other | 28 | Embedded boards based on PowerPC, ARM, MIPS and several other |
29 | processors, which can be installed in a boot ROM and used to | 29 | processors, which can be installed in a boot ROM and used to |
30 | initialize and test the hardware or to download and run application | 30 | initialize and test the hardware or to download and run application |
31 | code. | 31 | code. |
32 | 32 | ||
33 | The development of U-Boot is closely related to Linux: some parts of | 33 | The development of U-Boot is closely related to Linux: some parts of |
34 | the source code originate in the Linux source tree, we have some | 34 | the source code originate in the Linux source tree, we have some |
35 | header files in common, and special provision has been made to | 35 | header files in common, and special provision has been made to |
36 | support booting of Linux images. | 36 | support booting of Linux images. |
37 | 37 | ||
38 | Some attention has been paid to make this software easily | 38 | Some attention has been paid to make this software easily |
39 | configurable and extendable. For instance, all monitor commands are | 39 | configurable and extendable. For instance, all monitor commands are |
40 | implemented with the same call interface, so that it's very easy to | 40 | implemented with the same call interface, so that it's very easy to |
41 | add new commands. Also, instead of permanently adding rarely used | 41 | add new commands. Also, instead of permanently adding rarely used |
42 | code (for instance hardware test utilities) to the monitor, you can | 42 | code (for instance hardware test utilities) to the monitor, you can |
43 | load and run it dynamically. | 43 | load and run it dynamically. |
44 | 44 | ||
45 | 45 | ||
46 | Status: | 46 | Status: |
47 | ======= | 47 | ======= |
48 | 48 | ||
49 | In general, all boards for which a configuration option exists in the | 49 | In general, all boards for which a configuration option exists in the |
50 | Makefile have been tested to some extent and can be considered | 50 | Makefile have been tested to some extent and can be considered |
51 | "working". In fact, many of them are used in production systems. | 51 | "working". In fact, many of them are used in production systems. |
52 | 52 | ||
53 | In case of problems see the CHANGELOG and CREDITS files to find out | 53 | In case of problems see the CHANGELOG and CREDITS files to find out |
54 | who contributed the specific port. The MAINTAINERS file lists board | 54 | who contributed the specific port. The MAINTAINERS file lists board |
55 | maintainers. | 55 | maintainers. |
56 | 56 | ||
57 | 57 | ||
58 | Where to get help: | 58 | Where to get help: |
59 | ================== | 59 | ================== |
60 | 60 | ||
61 | In case you have questions about, problems with or contributions for | 61 | In case you have questions about, problems with or contributions for |
62 | U-Boot you should send a message to the U-Boot mailing list at | 62 | U-Boot you should send a message to the U-Boot mailing list at |
63 | <u-boot@lists.denx.de>. There is also an archive of previous traffic | 63 | <u-boot@lists.denx.de>. There is also an archive of previous traffic |
64 | on the mailing list - please search the archive before asking FAQ's. | 64 | on the mailing list - please search the archive before asking FAQ's. |
65 | Please see http://lists.denx.de/pipermail/u-boot and | 65 | Please see http://lists.denx.de/pipermail/u-boot and |
66 | http://dir.gmane.org/gmane.comp.boot-loaders.u-boot | 66 | http://dir.gmane.org/gmane.comp.boot-loaders.u-boot |
67 | 67 | ||
68 | 68 | ||
69 | Where to get source code: | 69 | Where to get source code: |
70 | ========================= | 70 | ========================= |
71 | 71 | ||
72 | The U-Boot source code is maintained in the git repository at | 72 | The U-Boot source code is maintained in the git repository at |
73 | git://www.denx.de/git/u-boot.git ; you can browse it online at | 73 | git://www.denx.de/git/u-boot.git ; you can browse it online at |
74 | http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=summary | 74 | http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=summary |
75 | 75 | ||
76 | The "snapshot" links on this page allow you to download tarballs of | 76 | The "snapshot" links on this page allow you to download tarballs of |
77 | any version you might be interested in. Official releases are also | 77 | any version you might be interested in. Official releases are also |
78 | available for FTP download from the ftp://ftp.denx.de/pub/u-boot/ | 78 | available for FTP download from the ftp://ftp.denx.de/pub/u-boot/ |
79 | directory. | 79 | directory. |
80 | 80 | ||
81 | Pre-built (and tested) images are available from | 81 | Pre-built (and tested) images are available from |
82 | ftp://ftp.denx.de/pub/u-boot/images/ | 82 | ftp://ftp.denx.de/pub/u-boot/images/ |
83 | 83 | ||
84 | 84 | ||
85 | Where we come from: | 85 | Where we come from: |
86 | =================== | 86 | =================== |
87 | 87 | ||
88 | - start from 8xxrom sources | 88 | - start from 8xxrom sources |
89 | - create PPCBoot project (http://sourceforge.net/projects/ppcboot) | 89 | - create PPCBoot project (http://sourceforge.net/projects/ppcboot) |
90 | - clean up code | 90 | - clean up code |
91 | - make it easier to add custom boards | 91 | - make it easier to add custom boards |
92 | - make it possible to add other [PowerPC] CPUs | 92 | - make it possible to add other [PowerPC] CPUs |
93 | - extend functions, especially: | 93 | - extend functions, especially: |
94 | * Provide extended interface to Linux boot loader | 94 | * Provide extended interface to Linux boot loader |
95 | * S-Record download | 95 | * S-Record download |
96 | * network boot | 96 | * network boot |
97 | * PCMCIA / CompactFlash / ATA disk / SCSI ... boot | 97 | * PCMCIA / CompactFlash / ATA disk / SCSI ... boot |
98 | - create ARMBoot project (http://sourceforge.net/projects/armboot) | 98 | - create ARMBoot project (http://sourceforge.net/projects/armboot) |
99 | - add other CPU families (starting with ARM) | 99 | - add other CPU families (starting with ARM) |
100 | - create U-Boot project (http://sourceforge.net/projects/u-boot) | 100 | - create U-Boot project (http://sourceforge.net/projects/u-boot) |
101 | - current project page: see http://www.denx.de/wiki/U-Boot | 101 | - current project page: see http://www.denx.de/wiki/U-Boot |
102 | 102 | ||
103 | 103 | ||
104 | Names and Spelling: | 104 | Names and Spelling: |
105 | =================== | 105 | =================== |
106 | 106 | ||
107 | The "official" name of this project is "Das U-Boot". The spelling | 107 | The "official" name of this project is "Das U-Boot". The spelling |
108 | "U-Boot" shall be used in all written text (documentation, comments | 108 | "U-Boot" shall be used in all written text (documentation, comments |
109 | in source files etc.). Example: | 109 | in source files etc.). Example: |
110 | 110 | ||
111 | This is the README file for the U-Boot project. | 111 | This is the README file for the U-Boot project. |
112 | 112 | ||
113 | File names etc. shall be based on the string "u-boot". Examples: | 113 | File names etc. shall be based on the string "u-boot". Examples: |
114 | 114 | ||
115 | include/asm-ppc/u-boot.h | 115 | include/asm-ppc/u-boot.h |
116 | 116 | ||
117 | #include <asm/u-boot.h> | 117 | #include <asm/u-boot.h> |
118 | 118 | ||
119 | Variable names, preprocessor constants etc. shall be either based on | 119 | Variable names, preprocessor constants etc. shall be either based on |
120 | the string "u_boot" or on "U_BOOT". Example: | 120 | the string "u_boot" or on "U_BOOT". Example: |
121 | 121 | ||
122 | U_BOOT_VERSION u_boot_logo | 122 | U_BOOT_VERSION u_boot_logo |
123 | IH_OS_U_BOOT u_boot_hush_start | 123 | IH_OS_U_BOOT u_boot_hush_start |
124 | 124 | ||
125 | 125 | ||
126 | Versioning: | 126 | Versioning: |
127 | =========== | 127 | =========== |
128 | 128 | ||
129 | U-Boot uses a 3 level version number containing a version, a | 129 | U-Boot uses a 3 level version number containing a version, a |
130 | sub-version, and a patchlevel: "U-Boot-2.34.5" means version "2", | 130 | sub-version, and a patchlevel: "U-Boot-2.34.5" means version "2", |
131 | sub-version "34", and patchlevel "4". | 131 | sub-version "34", and patchlevel "4". |
132 | 132 | ||
133 | The patchlevel is used to indicate certain stages of development | 133 | The patchlevel is used to indicate certain stages of development |
134 | between released versions, i. e. officially released versions of | 134 | between released versions, i. e. officially released versions of |
135 | U-Boot will always have a patchlevel of "0". | 135 | U-Boot will always have a patchlevel of "0". |
136 | 136 | ||
137 | 137 | ||
138 | Directory Hierarchy: | 138 | Directory Hierarchy: |
139 | ==================== | 139 | ==================== |
140 | 140 | ||
141 | - board Board dependent files | 141 | - board Board dependent files |
142 | - common Misc architecture independent functions | 142 | - common Misc architecture independent functions |
143 | - cpu CPU specific files | 143 | - cpu CPU specific files |
144 | - 74xx_7xx Files specific to Freescale MPC74xx and 7xx CPUs | 144 | - 74xx_7xx Files specific to Freescale MPC74xx and 7xx CPUs |
145 | - arm720t Files specific to ARM 720 CPUs | 145 | - arm720t Files specific to ARM 720 CPUs |
146 | - arm920t Files specific to ARM 920 CPUs | 146 | - arm920t Files specific to ARM 920 CPUs |
147 | - at91rm9200 Files specific to Atmel AT91RM9200 CPU | 147 | - at91rm9200 Files specific to Atmel AT91RM9200 CPU |
148 | - imx Files specific to Freescale MC9328 i.MX CPUs | 148 | - imx Files specific to Freescale MC9328 i.MX CPUs |
149 | - s3c24x0 Files specific to Samsung S3C24X0 CPUs | 149 | - s3c24x0 Files specific to Samsung S3C24X0 CPUs |
150 | - arm925t Files specific to ARM 925 CPUs | 150 | - arm925t Files specific to ARM 925 CPUs |
151 | - arm926ejs Files specific to ARM 926 CPUs | 151 | - arm926ejs Files specific to ARM 926 CPUs |
152 | - arm1136 Files specific to ARM 1136 CPUs | 152 | - arm1136 Files specific to ARM 1136 CPUs |
153 | - at32ap Files specific to Atmel AVR32 AP CPUs | 153 | - at32ap Files specific to Atmel AVR32 AP CPUs |
154 | - i386 Files specific to i386 CPUs | 154 | - i386 Files specific to i386 CPUs |
155 | - ixp Files specific to Intel XScale IXP CPUs | 155 | - ixp Files specific to Intel XScale IXP CPUs |
156 | - leon2 Files specific to Gaisler LEON2 SPARC CPU | 156 | - leon2 Files specific to Gaisler LEON2 SPARC CPU |
157 | - leon3 Files specific to Gaisler LEON3 SPARC CPU | 157 | - leon3 Files specific to Gaisler LEON3 SPARC CPU |
158 | - mcf52x2 Files specific to Freescale ColdFire MCF52x2 CPUs | 158 | - mcf52x2 Files specific to Freescale ColdFire MCF52x2 CPUs |
159 | - mcf5227x Files specific to Freescale ColdFire MCF5227x CPUs | 159 | - mcf5227x Files specific to Freescale ColdFire MCF5227x CPUs |
160 | - mcf532x Files specific to Freescale ColdFire MCF5329 CPUs | 160 | - mcf532x Files specific to Freescale ColdFire MCF5329 CPUs |
161 | - mcf5445x Files specific to Freescale ColdFire MCF5445x CPUs | 161 | - mcf5445x Files specific to Freescale ColdFire MCF5445x CPUs |
162 | - mcf547x_8x Files specific to Freescale ColdFire MCF547x_8x CPUs | 162 | - mcf547x_8x Files specific to Freescale ColdFire MCF547x_8x CPUs |
163 | - mips Files specific to MIPS CPUs | 163 | - mips Files specific to MIPS CPUs |
164 | - mpc5xx Files specific to Freescale MPC5xx CPUs | 164 | - mpc5xx Files specific to Freescale MPC5xx CPUs |
165 | - mpc5xxx Files specific to Freescale MPC5xxx CPUs | 165 | - mpc5xxx Files specific to Freescale MPC5xxx CPUs |
166 | - mpc8xx Files specific to Freescale MPC8xx CPUs | 166 | - mpc8xx Files specific to Freescale MPC8xx CPUs |
167 | - mpc8220 Files specific to Freescale MPC8220 CPUs | 167 | - mpc8220 Files specific to Freescale MPC8220 CPUs |
168 | - mpc824x Files specific to Freescale MPC824x CPUs | 168 | - mpc824x Files specific to Freescale MPC824x CPUs |
169 | - mpc8260 Files specific to Freescale MPC8260 CPUs | 169 | - mpc8260 Files specific to Freescale MPC8260 CPUs |
170 | - mpc85xx Files specific to Freescale MPC85xx CPUs | 170 | - mpc85xx Files specific to Freescale MPC85xx CPUs |
171 | - nios Files specific to Altera NIOS CPUs | 171 | - nios Files specific to Altera NIOS CPUs |
172 | - nios2 Files specific to Altera Nios-II CPUs | 172 | - nios2 Files specific to Altera Nios-II CPUs |
173 | - ppc4xx Files specific to AMCC PowerPC 4xx CPUs | 173 | - ppc4xx Files specific to AMCC PowerPC 4xx CPUs |
174 | - pxa Files specific to Intel XScale PXA CPUs | 174 | - pxa Files specific to Intel XScale PXA CPUs |
175 | - s3c44b0 Files specific to Samsung S3C44B0 CPUs | 175 | - s3c44b0 Files specific to Samsung S3C44B0 CPUs |
176 | - sa1100 Files specific to Intel StrongARM SA1100 CPUs | 176 | - sa1100 Files specific to Intel StrongARM SA1100 CPUs |
177 | - disk Code for disk drive partition handling | 177 | - disk Code for disk drive partition handling |
178 | - doc Documentation (don't expect too much) | 178 | - doc Documentation (don't expect too much) |
179 | - drivers Commonly used device drivers | 179 | - drivers Commonly used device drivers |
180 | - dtt Digital Thermometer and Thermostat drivers | 180 | - dtt Digital Thermometer and Thermostat drivers |
181 | - examples Example code for standalone applications, etc. | 181 | - examples Example code for standalone applications, etc. |
182 | - include Header Files | 182 | - include Header Files |
183 | - lib_arm Files generic to ARM architecture | 183 | - lib_arm Files generic to ARM architecture |
184 | - lib_avr32 Files generic to AVR32 architecture | 184 | - lib_avr32 Files generic to AVR32 architecture |
185 | - lib_generic Files generic to all architectures | 185 | - lib_generic Files generic to all architectures |
186 | - lib_i386 Files generic to i386 architecture | 186 | - lib_i386 Files generic to i386 architecture |
187 | - lib_m68k Files generic to m68k architecture | 187 | - lib_m68k Files generic to m68k architecture |
188 | - lib_mips Files generic to MIPS architecture | 188 | - lib_mips Files generic to MIPS architecture |
189 | - lib_nios Files generic to NIOS architecture | 189 | - lib_nios Files generic to NIOS architecture |
190 | - lib_ppc Files generic to PowerPC architecture | 190 | - lib_ppc Files generic to PowerPC architecture |
191 | - lib_sparc Files generic to SPARC architecture | 191 | - lib_sparc Files generic to SPARC architecture |
192 | - libfdt Library files to support flattened device trees | 192 | - libfdt Library files to support flattened device trees |
193 | - net Networking code | 193 | - net Networking code |
194 | - post Power On Self Test | 194 | - post Power On Self Test |
195 | - rtc Real Time Clock drivers | 195 | - rtc Real Time Clock drivers |
196 | - tools Tools to build S-Record or U-Boot images, etc. | 196 | - tools Tools to build S-Record or U-Boot images, etc. |
197 | 197 | ||
198 | Software Configuration: | 198 | Software Configuration: |
199 | ======================= | 199 | ======================= |
200 | 200 | ||
201 | Configuration is usually done using C preprocessor defines; the | 201 | Configuration is usually done using C preprocessor defines; the |
202 | rationale behind that is to avoid dead code whenever possible. | 202 | rationale behind that is to avoid dead code whenever possible. |
203 | 203 | ||
204 | There are two classes of configuration variables: | 204 | There are two classes of configuration variables: |
205 | 205 | ||
206 | * Configuration _OPTIONS_: | 206 | * Configuration _OPTIONS_: |
207 | These are selectable by the user and have names beginning with | 207 | These are selectable by the user and have names beginning with |
208 | "CONFIG_". | 208 | "CONFIG_". |
209 | 209 | ||
210 | * Configuration _SETTINGS_: | 210 | * Configuration _SETTINGS_: |
211 | These depend on the hardware etc. and should not be meddled with if | 211 | These depend on the hardware etc. and should not be meddled with if |
212 | you don't know what you're doing; they have names beginning with | 212 | you don't know what you're doing; they have names beginning with |
213 | "CFG_". | 213 | "CFG_". |
214 | 214 | ||
215 | Later we will add a configuration tool - probably similar to or even | 215 | Later we will add a configuration tool - probably similar to or even |
216 | identical to what's used for the Linux kernel. Right now, we have to | 216 | identical to what's used for the Linux kernel. Right now, we have to |
217 | do the configuration by hand, which means creating some symbolic | 217 | do the configuration by hand, which means creating some symbolic |
218 | links and editing some configuration files. We use the TQM8xxL boards | 218 | links and editing some configuration files. We use the TQM8xxL boards |
219 | as an example here. | 219 | as an example here. |
220 | 220 | ||
221 | 221 | ||
222 | Selection of Processor Architecture and Board Type: | 222 | Selection of Processor Architecture and Board Type: |
223 | --------------------------------------------------- | 223 | --------------------------------------------------- |
224 | 224 | ||
225 | For all supported boards there are ready-to-use default | 225 | For all supported boards there are ready-to-use default |
226 | configurations available; just type "make <board_name>_config". | 226 | configurations available; just type "make <board_name>_config". |
227 | 227 | ||
228 | Example: For a TQM823L module type: | 228 | Example: For a TQM823L module type: |
229 | 229 | ||
230 | cd u-boot | 230 | cd u-boot |
231 | make TQM823L_config | 231 | make TQM823L_config |
232 | 232 | ||
233 | For the Cogent platform, you need to specify the CPU type as well; | 233 | For the Cogent platform, you need to specify the CPU type as well; |
234 | e.g. "make cogent_mpc8xx_config". And also configure the cogent | 234 | e.g. "make cogent_mpc8xx_config". And also configure the cogent |
235 | directory according to the instructions in cogent/README. | 235 | directory according to the instructions in cogent/README. |
236 | 236 | ||
237 | 237 | ||
238 | Configuration Options: | 238 | Configuration Options: |
239 | ---------------------- | 239 | ---------------------- |
240 | 240 | ||
241 | Configuration depends on the combination of board and CPU type; all | 241 | Configuration depends on the combination of board and CPU type; all |
242 | such information is kept in a configuration file | 242 | such information is kept in a configuration file |
243 | "include/configs/<board_name>.h". | 243 | "include/configs/<board_name>.h". |
244 | 244 | ||
245 | Example: For a TQM823L module, all configuration settings are in | 245 | Example: For a TQM823L module, all configuration settings are in |
246 | "include/configs/TQM823L.h". | 246 | "include/configs/TQM823L.h". |
247 | 247 | ||
248 | 248 | ||
249 | Many of the options are named exactly as the corresponding Linux | 249 | Many of the options are named exactly as the corresponding Linux |
250 | kernel configuration options. The intention is to make it easier to | 250 | kernel configuration options. The intention is to make it easier to |
251 | build a config tool - later. | 251 | build a config tool - later. |
252 | 252 | ||
253 | 253 | ||
254 | The following options need to be configured: | 254 | The following options need to be configured: |
255 | 255 | ||
256 | - CPU Type: Define exactly one, e.g. CONFIG_MPC85XX. | 256 | - CPU Type: Define exactly one, e.g. CONFIG_MPC85XX. |
257 | 257 | ||
258 | - Board Type: Define exactly one, e.g. CONFIG_MPC8540ADS. | 258 | - Board Type: Define exactly one, e.g. CONFIG_MPC8540ADS. |
259 | 259 | ||
260 | - CPU Daughterboard Type: (if CONFIG_ATSTK1000 is defined) | 260 | - CPU Daughterboard Type: (if CONFIG_ATSTK1000 is defined) |
261 | Define exactly one, e.g. CONFIG_ATSTK1002 | 261 | Define exactly one, e.g. CONFIG_ATSTK1002 |
262 | 262 | ||
263 | - CPU Module Type: (if CONFIG_COGENT is defined) | 263 | - CPU Module Type: (if CONFIG_COGENT is defined) |
264 | Define exactly one of | 264 | Define exactly one of |
265 | CONFIG_CMA286_60_OLD | 265 | CONFIG_CMA286_60_OLD |
266 | --- FIXME --- not tested yet: | 266 | --- FIXME --- not tested yet: |
267 | CONFIG_CMA286_60, CONFIG_CMA286_21, CONFIG_CMA286_60P, | 267 | CONFIG_CMA286_60, CONFIG_CMA286_21, CONFIG_CMA286_60P, |
268 | CONFIG_CMA287_23, CONFIG_CMA287_50 | 268 | CONFIG_CMA287_23, CONFIG_CMA287_50 |
269 | 269 | ||
270 | - Motherboard Type: (if CONFIG_COGENT is defined) | 270 | - Motherboard Type: (if CONFIG_COGENT is defined) |
271 | Define exactly one of | 271 | Define exactly one of |
272 | CONFIG_CMA101, CONFIG_CMA102 | 272 | CONFIG_CMA101, CONFIG_CMA102 |
273 | 273 | ||
274 | - Motherboard I/O Modules: (if CONFIG_COGENT is defined) | 274 | - Motherboard I/O Modules: (if CONFIG_COGENT is defined) |
275 | Define one or more of | 275 | Define one or more of |
276 | CONFIG_CMA302 | 276 | CONFIG_CMA302 |
277 | 277 | ||
278 | - Motherboard Options: (if CONFIG_CMA101 or CONFIG_CMA102 are defined) | 278 | - Motherboard Options: (if CONFIG_CMA101 or CONFIG_CMA102 are defined) |
279 | Define one or more of | 279 | Define one or more of |
280 | CONFIG_LCD_HEARTBEAT - update a character position on | 280 | CONFIG_LCD_HEARTBEAT - update a character position on |
281 | the LCD display every second with | 281 | the LCD display every second with |
282 | a "rotator" |\-/|\-/ | 282 | a "rotator" |\-/|\-/ |
283 | 283 | ||
284 | - Board flavour: (if CONFIG_MPC8260ADS is defined) | 284 | - Board flavour: (if CONFIG_MPC8260ADS is defined) |
285 | CONFIG_ADSTYPE | 285 | CONFIG_ADSTYPE |
286 | Possible values are: | 286 | Possible values are: |
287 | CFG_8260ADS - original MPC8260ADS | 287 | CFG_8260ADS - original MPC8260ADS |
288 | CFG_8266ADS - MPC8266ADS | 288 | CFG_8266ADS - MPC8266ADS |
289 | CFG_PQ2FADS - PQ2FADS-ZU or PQ2FADS-VR | 289 | CFG_PQ2FADS - PQ2FADS-ZU or PQ2FADS-VR |
290 | CFG_8272ADS - MPC8272ADS | 290 | CFG_8272ADS - MPC8272ADS |
291 | 291 | ||
292 | - MPC824X Family Member (if CONFIG_MPC824X is defined) | 292 | - MPC824X Family Member (if CONFIG_MPC824X is defined) |
293 | Define exactly one of | 293 | Define exactly one of |
294 | CONFIG_MPC8240, CONFIG_MPC8245 | 294 | CONFIG_MPC8240, CONFIG_MPC8245 |
295 | 295 | ||
296 | - 8xx CPU Options: (if using an MPC8xx CPU) | 296 | - 8xx CPU Options: (if using an MPC8xx CPU) |
297 | CONFIG_8xx_GCLK_FREQ - deprecated: CPU clock if | 297 | CONFIG_8xx_GCLK_FREQ - deprecated: CPU clock if |
298 | get_gclk_freq() cannot work | 298 | get_gclk_freq() cannot work |
299 | e.g. if there is no 32KHz | 299 | e.g. if there is no 32KHz |
300 | reference PIT/RTC clock | 300 | reference PIT/RTC clock |
301 | CONFIG_8xx_OSCLK - PLL input clock (either EXTCLK | 301 | CONFIG_8xx_OSCLK - PLL input clock (either EXTCLK |
302 | or XTAL/EXTAL) | 302 | or XTAL/EXTAL) |
303 | 303 | ||
304 | - 859/866/885 CPU options: (if using a MPC859 or MPC866 or MPC885 CPU): | 304 | - 859/866/885 CPU options: (if using a MPC859 or MPC866 or MPC885 CPU): |
305 | CFG_8xx_CPUCLK_MIN | 305 | CFG_8xx_CPUCLK_MIN |
306 | CFG_8xx_CPUCLK_MAX | 306 | CFG_8xx_CPUCLK_MAX |
307 | CONFIG_8xx_CPUCLK_DEFAULT | 307 | CONFIG_8xx_CPUCLK_DEFAULT |
308 | See doc/README.MPC866 | 308 | See doc/README.MPC866 |
309 | 309 | ||
310 | CFG_MEASURE_CPUCLK | 310 | CFG_MEASURE_CPUCLK |
311 | 311 | ||
312 | Define this to measure the actual CPU clock instead | 312 | Define this to measure the actual CPU clock instead |
313 | of relying on the correctness of the configured | 313 | of relying on the correctness of the configured |
314 | values. Mostly useful for board bringup to make sure | 314 | values. Mostly useful for board bringup to make sure |
315 | the PLL is locked at the intended frequency. Note | 315 | the PLL is locked at the intended frequency. Note |
316 | that this requires a (stable) reference clock (32 kHz | 316 | that this requires a (stable) reference clock (32 kHz |
317 | RTC clock or CFG_8XX_XIN) | 317 | RTC clock or CFG_8XX_XIN) |
318 | 318 | ||
319 | - Intel Monahans options: | 319 | - Intel Monahans options: |
320 | CFG_MONAHANS_RUN_MODE_OSC_RATIO | 320 | CFG_MONAHANS_RUN_MODE_OSC_RATIO |
321 | 321 | ||
322 | Defines the Monahans run mode to oscillator | 322 | Defines the Monahans run mode to oscillator |
323 | ratio. Valid values are 8, 16, 24, 31. The core | 323 | ratio. Valid values are 8, 16, 24, 31. The core |
324 | frequency is this value multiplied by 13 MHz. | 324 | frequency is this value multiplied by 13 MHz. |
325 | 325 | ||
326 | CFG_MONAHANS_TURBO_RUN_MODE_RATIO | 326 | CFG_MONAHANS_TURBO_RUN_MODE_RATIO |
327 | 327 | ||
328 | Defines the Monahans turbo mode to oscillator | 328 | Defines the Monahans turbo mode to oscillator |
329 | ratio. Valid values are 1 (default if undefined) and | 329 | ratio. Valid values are 1 (default if undefined) and |
330 | 2. The core frequency as calculated above is multiplied | 330 | 2. The core frequency as calculated above is multiplied |
331 | by this value. | 331 | by this value. |
332 | 332 | ||
333 | - Linux Kernel Interface: | 333 | - Linux Kernel Interface: |
334 | CONFIG_CLOCKS_IN_MHZ | 334 | CONFIG_CLOCKS_IN_MHZ |
335 | 335 | ||
336 | U-Boot stores all clock information in Hz | 336 | U-Boot stores all clock information in Hz |
337 | internally. For binary compatibility with older Linux | 337 | internally. For binary compatibility with older Linux |
338 | kernels (which expect the clocks passed in the | 338 | kernels (which expect the clocks passed in the |
339 | bd_info data to be in MHz) the environment variable | 339 | bd_info data to be in MHz) the environment variable |
340 | "clocks_in_mhz" can be defined so that U-Boot | 340 | "clocks_in_mhz" can be defined so that U-Boot |
341 | converts clock data to MHZ before passing it to the | 341 | converts clock data to MHZ before passing it to the |
342 | Linux kernel. | 342 | Linux kernel. |
343 | When CONFIG_CLOCKS_IN_MHZ is defined, a definition of | 343 | When CONFIG_CLOCKS_IN_MHZ is defined, a definition of |
344 | "clocks_in_mhz=1" is automatically included in the | 344 | "clocks_in_mhz=1" is automatically included in the |
345 | default environment. | 345 | default environment. |
346 | 346 | ||
347 | CONFIG_MEMSIZE_IN_BYTES [relevant for MIPS only] | 347 | CONFIG_MEMSIZE_IN_BYTES [relevant for MIPS only] |
348 | 348 | ||
349 | When transferring memsize parameter to linux, some versions | 349 | When transferring memsize parameter to linux, some versions |
350 | expect it to be in bytes, others in MB. | 350 | expect it to be in bytes, others in MB. |
351 | Define CONFIG_MEMSIZE_IN_BYTES to make it in bytes. | 351 | Define CONFIG_MEMSIZE_IN_BYTES to make it in bytes. |
352 | 352 | ||
353 | CONFIG_OF_LIBFDT | 353 | CONFIG_OF_LIBFDT |
354 | 354 | ||
355 | New kernel versions are expecting firmware settings to be | 355 | New kernel versions are expecting firmware settings to be |
356 | passed using flattened device trees (based on open firmware | 356 | passed using flattened device trees (based on open firmware |
357 | concepts). | 357 | concepts). |
358 | 358 | ||
359 | CONFIG_OF_LIBFDT | 359 | CONFIG_OF_LIBFDT |
360 | * New libfdt-based support | 360 | * New libfdt-based support |
361 | * Adds the "fdt" command | 361 | * Adds the "fdt" command |
362 | * The bootm command automatically updates the fdt | 362 | * The bootm command automatically updates the fdt |
363 | 363 | ||
364 | OF_CPU - The proper name of the cpus node. | 364 | OF_CPU - The proper name of the cpus node. |
365 | OF_SOC - The proper name of the soc node. | 365 | OF_SOC - The proper name of the soc node. |
366 | OF_TBCLK - The timebase frequency. | 366 | OF_TBCLK - The timebase frequency. |
367 | OF_STDOUT_PATH - The path to the console device | 367 | OF_STDOUT_PATH - The path to the console device |
368 | 368 | ||
369 | boards with QUICC Engines require OF_QE to set UCC MAC | 369 | boards with QUICC Engines require OF_QE to set UCC MAC |
370 | addresses | 370 | addresses |
371 | 371 | ||
372 | CONFIG_OF_BOARD_SETUP | 372 | CONFIG_OF_BOARD_SETUP |
373 | 373 | ||
374 | Board code has addition modification that it wants to make | 374 | Board code has addition modification that it wants to make |
375 | to the flat device tree before handing it off to the kernel | 375 | to the flat device tree before handing it off to the kernel |
376 | 376 | ||
377 | CONFIG_OF_BOOT_CPU | 377 | CONFIG_OF_BOOT_CPU |
378 | 378 | ||
379 | This define fills in the correct boot CPU in the boot | 379 | This define fills in the correct boot CPU in the boot |
380 | param header, the default value is zero if undefined. | 380 | param header, the default value is zero if undefined. |
381 | 381 | ||
382 | - Serial Ports: | 382 | - Serial Ports: |
383 | CONFIG_PL010_SERIAL | 383 | CONFIG_PL010_SERIAL |
384 | 384 | ||
385 | Define this if you want support for Amba PrimeCell PL010 UARTs. | 385 | Define this if you want support for Amba PrimeCell PL010 UARTs. |
386 | 386 | ||
387 | CONFIG_PL011_SERIAL | 387 | CONFIG_PL011_SERIAL |
388 | 388 | ||
389 | Define this if you want support for Amba PrimeCell PL011 UARTs. | 389 | Define this if you want support for Amba PrimeCell PL011 UARTs. |
390 | 390 | ||
391 | CONFIG_PL011_CLOCK | 391 | CONFIG_PL011_CLOCK |
392 | 392 | ||
393 | If you have Amba PrimeCell PL011 UARTs, set this variable to | 393 | If you have Amba PrimeCell PL011 UARTs, set this variable to |
394 | the clock speed of the UARTs. | 394 | the clock speed of the UARTs. |
395 | 395 | ||
396 | CONFIG_PL01x_PORTS | 396 | CONFIG_PL01x_PORTS |
397 | 397 | ||
398 | If you have Amba PrimeCell PL010 or PL011 UARTs on your board, | 398 | If you have Amba PrimeCell PL010 or PL011 UARTs on your board, |
399 | define this to a list of base addresses for each (supported) | 399 | define this to a list of base addresses for each (supported) |
400 | port. See e.g. include/configs/versatile.h | 400 | port. See e.g. include/configs/versatile.h |
401 | 401 | ||
402 | 402 | ||
403 | - Console Interface: | 403 | - Console Interface: |
404 | Depending on board, define exactly one serial port | 404 | Depending on board, define exactly one serial port |
405 | (like CONFIG_8xx_CONS_SMC1, CONFIG_8xx_CONS_SMC2, | 405 | (like CONFIG_8xx_CONS_SMC1, CONFIG_8xx_CONS_SMC2, |
406 | CONFIG_8xx_CONS_SCC1, ...), or switch off the serial | 406 | CONFIG_8xx_CONS_SCC1, ...), or switch off the serial |
407 | console by defining CONFIG_8xx_CONS_NONE | 407 | console by defining CONFIG_8xx_CONS_NONE |
408 | 408 | ||
409 | Note: if CONFIG_8xx_CONS_NONE is defined, the serial | 409 | Note: if CONFIG_8xx_CONS_NONE is defined, the serial |
410 | port routines must be defined elsewhere | 410 | port routines must be defined elsewhere |
411 | (i.e. serial_init(), serial_getc(), ...) | 411 | (i.e. serial_init(), serial_getc(), ...) |
412 | 412 | ||
413 | CONFIG_CFB_CONSOLE | 413 | CONFIG_CFB_CONSOLE |
414 | Enables console device for a color framebuffer. Needs following | 414 | Enables console device for a color framebuffer. Needs following |
415 | defines (cf. smiLynxEM, i8042, board/eltec/bab7xx) | 415 | defines (cf. smiLynxEM, i8042, board/eltec/bab7xx) |
416 | VIDEO_FB_LITTLE_ENDIAN graphic memory organisation | 416 | VIDEO_FB_LITTLE_ENDIAN graphic memory organisation |
417 | (default big endian) | 417 | (default big endian) |
418 | VIDEO_HW_RECTFILL graphic chip supports | 418 | VIDEO_HW_RECTFILL graphic chip supports |
419 | rectangle fill | 419 | rectangle fill |
420 | (cf. smiLynxEM) | 420 | (cf. smiLynxEM) |
421 | VIDEO_HW_BITBLT graphic chip supports | 421 | VIDEO_HW_BITBLT graphic chip supports |
422 | bit-blit (cf. smiLynxEM) | 422 | bit-blit (cf. smiLynxEM) |
423 | VIDEO_VISIBLE_COLS visible pixel columns | 423 | VIDEO_VISIBLE_COLS visible pixel columns |
424 | (cols=pitch) | 424 | (cols=pitch) |
425 | VIDEO_VISIBLE_ROWS visible pixel rows | 425 | VIDEO_VISIBLE_ROWS visible pixel rows |
426 | VIDEO_PIXEL_SIZE bytes per pixel | 426 | VIDEO_PIXEL_SIZE bytes per pixel |
427 | VIDEO_DATA_FORMAT graphic data format | 427 | VIDEO_DATA_FORMAT graphic data format |
428 | (0-5, cf. cfb_console.c) | 428 | (0-5, cf. cfb_console.c) |
429 | VIDEO_FB_ADRS framebuffer address | 429 | VIDEO_FB_ADRS framebuffer address |
430 | VIDEO_KBD_INIT_FCT keyboard int fct | 430 | VIDEO_KBD_INIT_FCT keyboard int fct |
431 | (i.e. i8042_kbd_init()) | 431 | (i.e. i8042_kbd_init()) |
432 | VIDEO_TSTC_FCT test char fct | 432 | VIDEO_TSTC_FCT test char fct |
433 | (i.e. i8042_tstc) | 433 | (i.e. i8042_tstc) |
434 | VIDEO_GETC_FCT get char fct | 434 | VIDEO_GETC_FCT get char fct |
435 | (i.e. i8042_getc) | 435 | (i.e. i8042_getc) |
436 | CONFIG_CONSOLE_CURSOR cursor drawing on/off | 436 | CONFIG_CONSOLE_CURSOR cursor drawing on/off |
437 | (requires blink timer | 437 | (requires blink timer |
438 | cf. i8042.c) | 438 | cf. i8042.c) |
439 | CFG_CONSOLE_BLINK_COUNT blink interval (cf. i8042.c) | 439 | CFG_CONSOLE_BLINK_COUNT blink interval (cf. i8042.c) |
440 | CONFIG_CONSOLE_TIME display time/date info in | 440 | CONFIG_CONSOLE_TIME display time/date info in |
441 | upper right corner | 441 | upper right corner |
442 | (requires CONFIG_CMD_DATE) | 442 | (requires CONFIG_CMD_DATE) |
443 | CONFIG_VIDEO_LOGO display Linux logo in | 443 | CONFIG_VIDEO_LOGO display Linux logo in |
444 | upper left corner | 444 | upper left corner |
445 | CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead of | 445 | CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead of |
446 | linux_logo.h for logo. | 446 | linux_logo.h for logo. |
447 | Requires CONFIG_VIDEO_LOGO | 447 | Requires CONFIG_VIDEO_LOGO |
448 | CONFIG_CONSOLE_EXTRA_INFO | 448 | CONFIG_CONSOLE_EXTRA_INFO |
449 | additional board info beside | 449 | additional board info beside |
450 | the logo | 450 | the logo |
451 | 451 | ||
452 | When CONFIG_CFB_CONSOLE is defined, video console is | 452 | When CONFIG_CFB_CONSOLE is defined, video console is |
453 | default i/o. Serial console can be forced with | 453 | default i/o. Serial console can be forced with |
454 | environment 'console=serial'. | 454 | environment 'console=serial'. |
455 | 455 | ||
456 | When CONFIG_SILENT_CONSOLE is defined, all console | 456 | When CONFIG_SILENT_CONSOLE is defined, all console |
457 | messages (by U-Boot and Linux!) can be silenced with | 457 | messages (by U-Boot and Linux!) can be silenced with |
458 | the "silent" environment variable. See | 458 | the "silent" environment variable. See |
459 | doc/README.silent for more information. | 459 | doc/README.silent for more information. |
460 | 460 | ||
461 | - Console Baudrate: | 461 | - Console Baudrate: |
462 | CONFIG_BAUDRATE - in bps | 462 | CONFIG_BAUDRATE - in bps |
463 | Select one of the baudrates listed in | 463 | Select one of the baudrates listed in |
464 | CFG_BAUDRATE_TABLE, see below. | 464 | CFG_BAUDRATE_TABLE, see below. |
465 | CFG_BRGCLK_PRESCALE, baudrate prescale | 465 | CFG_BRGCLK_PRESCALE, baudrate prescale |
466 | 466 | ||
467 | - Interrupt driven serial port input: | 467 | - Interrupt driven serial port input: |
468 | CONFIG_SERIAL_SOFTWARE_FIFO | 468 | CONFIG_SERIAL_SOFTWARE_FIFO |
469 | 469 | ||
470 | PPC405GP only. | 470 | PPC405GP only. |
471 | Use an interrupt handler for receiving data on the | 471 | Use an interrupt handler for receiving data on the |
472 | serial port. It also enables using hardware handshake | 472 | serial port. It also enables using hardware handshake |
473 | (RTS/CTS) and UART's built-in FIFO. Set the number of | 473 | (RTS/CTS) and UART's built-in FIFO. Set the number of |
474 | bytes the interrupt driven input buffer should have. | 474 | bytes the interrupt driven input buffer should have. |
475 | 475 | ||
476 | Leave undefined to disable this feature, including | 476 | Leave undefined to disable this feature, including |
477 | disable the buffer and hardware handshake. | 477 | disable the buffer and hardware handshake. |
478 | 478 | ||
479 | - Console UART Number: | 479 | - Console UART Number: |
480 | CONFIG_UART1_CONSOLE | 480 | CONFIG_UART1_CONSOLE |
481 | 481 | ||
482 | AMCC PPC4xx only. | 482 | AMCC PPC4xx only. |
483 | If defined internal UART1 (and not UART0) is used | 483 | If defined internal UART1 (and not UART0) is used |
484 | as default U-Boot console. | 484 | as default U-Boot console. |
485 | 485 | ||
486 | - Boot Delay: CONFIG_BOOTDELAY - in seconds | 486 | - Boot Delay: CONFIG_BOOTDELAY - in seconds |
487 | Delay before automatically booting the default image; | 487 | Delay before automatically booting the default image; |
488 | set to -1 to disable autoboot. | 488 | set to -1 to disable autoboot. |
489 | 489 | ||
490 | See doc/README.autoboot for these options that | 490 | See doc/README.autoboot for these options that |
491 | work with CONFIG_BOOTDELAY. None are required. | 491 | work with CONFIG_BOOTDELAY. None are required. |
492 | CONFIG_BOOT_RETRY_TIME | 492 | CONFIG_BOOT_RETRY_TIME |
493 | CONFIG_BOOT_RETRY_MIN | 493 | CONFIG_BOOT_RETRY_MIN |
494 | CONFIG_AUTOBOOT_KEYED | 494 | CONFIG_AUTOBOOT_KEYED |
495 | CONFIG_AUTOBOOT_PROMPT | 495 | CONFIG_AUTOBOOT_PROMPT |
496 | CONFIG_AUTOBOOT_DELAY_STR | 496 | CONFIG_AUTOBOOT_DELAY_STR |
497 | CONFIG_AUTOBOOT_STOP_STR | 497 | CONFIG_AUTOBOOT_STOP_STR |
498 | CONFIG_AUTOBOOT_DELAY_STR2 | 498 | CONFIG_AUTOBOOT_DELAY_STR2 |
499 | CONFIG_AUTOBOOT_STOP_STR2 | 499 | CONFIG_AUTOBOOT_STOP_STR2 |
500 | CONFIG_ZERO_BOOTDELAY_CHECK | 500 | CONFIG_ZERO_BOOTDELAY_CHECK |
501 | CONFIG_RESET_TO_RETRY | 501 | CONFIG_RESET_TO_RETRY |
502 | 502 | ||
503 | - Autoboot Command: | 503 | - Autoboot Command: |
504 | CONFIG_BOOTCOMMAND | 504 | CONFIG_BOOTCOMMAND |
505 | Only needed when CONFIG_BOOTDELAY is enabled; | 505 | Only needed when CONFIG_BOOTDELAY is enabled; |
506 | define a command string that is automatically executed | 506 | define a command string that is automatically executed |
507 | when no character is read on the console interface | 507 | when no character is read on the console interface |
508 | within "Boot Delay" after reset. | 508 | within "Boot Delay" after reset. |
509 | 509 | ||
510 | CONFIG_BOOTARGS | 510 | CONFIG_BOOTARGS |
511 | This can be used to pass arguments to the bootm | 511 | This can be used to pass arguments to the bootm |
512 | command. The value of CONFIG_BOOTARGS goes into the | 512 | command. The value of CONFIG_BOOTARGS goes into the |
513 | environment value "bootargs". | 513 | environment value "bootargs". |
514 | 514 | ||
515 | CONFIG_RAMBOOT and CONFIG_NFSBOOT | 515 | CONFIG_RAMBOOT and CONFIG_NFSBOOT |
516 | The value of these goes into the environment as | 516 | The value of these goes into the environment as |
517 | "ramboot" and "nfsboot" respectively, and can be used | 517 | "ramboot" and "nfsboot" respectively, and can be used |
518 | as a convenience, when switching between booting from | 518 | as a convenience, when switching between booting from |
519 | RAM and NFS. | 519 | RAM and NFS. |
520 | 520 | ||
521 | - Pre-Boot Commands: | 521 | - Pre-Boot Commands: |
522 | CONFIG_PREBOOT | 522 | CONFIG_PREBOOT |
523 | 523 | ||
524 | When this option is #defined, the existence of the | 524 | When this option is #defined, the existence of the |
525 | environment variable "preboot" will be checked | 525 | environment variable "preboot" will be checked |
526 | immediately before starting the CONFIG_BOOTDELAY | 526 | immediately before starting the CONFIG_BOOTDELAY |
527 | countdown and/or running the auto-boot command resp. | 527 | countdown and/or running the auto-boot command resp. |
528 | entering interactive mode. | 528 | entering interactive mode. |
529 | 529 | ||
530 | This feature is especially useful when "preboot" is | 530 | This feature is especially useful when "preboot" is |
531 | automatically generated or modified. For an example | 531 | automatically generated or modified. For an example |
532 | see the LWMON board specific code: here "preboot" is | 532 | see the LWMON board specific code: here "preboot" is |
533 | modified when the user holds down a certain | 533 | modified when the user holds down a certain |
534 | combination of keys on the (special) keyboard when | 534 | combination of keys on the (special) keyboard when |
535 | booting the systems | 535 | booting the systems |
536 | 536 | ||
537 | - Serial Download Echo Mode: | 537 | - Serial Download Echo Mode: |
538 | CONFIG_LOADS_ECHO | 538 | CONFIG_LOADS_ECHO |
539 | If defined to 1, all characters received during a | 539 | If defined to 1, all characters received during a |
540 | serial download (using the "loads" command) are | 540 | serial download (using the "loads" command) are |
541 | echoed back. This might be needed by some terminal | 541 | echoed back. This might be needed by some terminal |
542 | emulations (like "cu"), but may as well just take | 542 | emulations (like "cu"), but may as well just take |
543 | time on others. This setting #define's the initial | 543 | time on others. This setting #define's the initial |
544 | value of the "loads_echo" environment variable. | 544 | value of the "loads_echo" environment variable. |
545 | 545 | ||
546 | - Kgdb Serial Baudrate: (if CONFIG_CMD_KGDB is defined) | 546 | - Kgdb Serial Baudrate: (if CONFIG_CMD_KGDB is defined) |
547 | CONFIG_KGDB_BAUDRATE | 547 | CONFIG_KGDB_BAUDRATE |
548 | Select one of the baudrates listed in | 548 | Select one of the baudrates listed in |
549 | CFG_BAUDRATE_TABLE, see below. | 549 | CFG_BAUDRATE_TABLE, see below. |
550 | 550 | ||
551 | - Monitor Functions: | 551 | - Monitor Functions: |
552 | Monitor commands can be included or excluded | 552 | Monitor commands can be included or excluded |
553 | from the build by using the #include files | 553 | from the build by using the #include files |
554 | "config_cmd_all.h" and #undef'ing unwanted | 554 | "config_cmd_all.h" and #undef'ing unwanted |
555 | commands, or using "config_cmd_default.h" | 555 | commands, or using "config_cmd_default.h" |
556 | and augmenting with additional #define's | 556 | and augmenting with additional #define's |
557 | for wanted commands. | 557 | for wanted commands. |
558 | 558 | ||
559 | The default command configuration includes all commands | 559 | The default command configuration includes all commands |
560 | except those marked below with a "*". | 560 | except those marked below with a "*". |
561 | 561 | ||
562 | CONFIG_CMD_ASKENV * ask for env variable | 562 | CONFIG_CMD_ASKENV * ask for env variable |
563 | CONFIG_CMD_AUTOSCRIPT Autoscript Support | 563 | CONFIG_CMD_AUTOSCRIPT Autoscript Support |
564 | CONFIG_CMD_BDI bdinfo | 564 | CONFIG_CMD_BDI bdinfo |
565 | CONFIG_CMD_BEDBUG * Include BedBug Debugger | 565 | CONFIG_CMD_BEDBUG * Include BedBug Debugger |
566 | CONFIG_CMD_BMP * BMP support | 566 | CONFIG_CMD_BMP * BMP support |
567 | CONFIG_CMD_BSP * Board specific commands | 567 | CONFIG_CMD_BSP * Board specific commands |
568 | CONFIG_CMD_BOOTD bootd | 568 | CONFIG_CMD_BOOTD bootd |
569 | CONFIG_CMD_CACHE * icache, dcache | 569 | CONFIG_CMD_CACHE * icache, dcache |
570 | CONFIG_CMD_CONSOLE coninfo | 570 | CONFIG_CMD_CONSOLE coninfo |
571 | CONFIG_CMD_DATE * support for RTC, date/time... | 571 | CONFIG_CMD_DATE * support for RTC, date/time... |
572 | CONFIG_CMD_DHCP * DHCP support | 572 | CONFIG_CMD_DHCP * DHCP support |
573 | CONFIG_CMD_DIAG * Diagnostics | 573 | CONFIG_CMD_DIAG * Diagnostics |
574 | CONFIG_CMD_DOC * Disk-On-Chip Support | 574 | CONFIG_CMD_DOC * Disk-On-Chip Support |
575 | CONFIG_CMD_DTT * Digital Therm and Thermostat | 575 | CONFIG_CMD_DTT * Digital Therm and Thermostat |
576 | CONFIG_CMD_ECHO echo arguments | 576 | CONFIG_CMD_ECHO echo arguments |
577 | CONFIG_CMD_EEPROM * EEPROM read/write support | 577 | CONFIG_CMD_EEPROM * EEPROM read/write support |
578 | CONFIG_CMD_ELF * bootelf, bootvx | 578 | CONFIG_CMD_ELF * bootelf, bootvx |
579 | CONFIG_CMD_ENV saveenv | 579 | CONFIG_CMD_ENV saveenv |
580 | CONFIG_CMD_FDC * Floppy Disk Support | 580 | CONFIG_CMD_FDC * Floppy Disk Support |
581 | CONFIG_CMD_FAT * FAT partition support | 581 | CONFIG_CMD_FAT * FAT partition support |
582 | CONFIG_CMD_FDOS * Dos diskette Support | 582 | CONFIG_CMD_FDOS * Dos diskette Support |
583 | CONFIG_CMD_FLASH flinfo, erase, protect | 583 | CONFIG_CMD_FLASH flinfo, erase, protect |
584 | CONFIG_CMD_FPGA FPGA device initialization support | 584 | CONFIG_CMD_FPGA FPGA device initialization support |
585 | CONFIG_CMD_HWFLOW * RTS/CTS hw flow control | 585 | CONFIG_CMD_HWFLOW * RTS/CTS hw flow control |
586 | CONFIG_CMD_I2C * I2C serial bus support | 586 | CONFIG_CMD_I2C * I2C serial bus support |
587 | CONFIG_CMD_IDE * IDE harddisk support | 587 | CONFIG_CMD_IDE * IDE harddisk support |
588 | CONFIG_CMD_IMI iminfo | 588 | CONFIG_CMD_IMI iminfo |
589 | CONFIG_CMD_IMLS List all found images | 589 | CONFIG_CMD_IMLS List all found images |
590 | CONFIG_CMD_IMMAP * IMMR dump support | 590 | CONFIG_CMD_IMMAP * IMMR dump support |
591 | CONFIG_CMD_IRQ * irqinfo | 591 | CONFIG_CMD_IRQ * irqinfo |
592 | CONFIG_CMD_ITEST Integer/string test of 2 values | 592 | CONFIG_CMD_ITEST Integer/string test of 2 values |
593 | CONFIG_CMD_JFFS2 * JFFS2 Support | 593 | CONFIG_CMD_JFFS2 * JFFS2 Support |
594 | CONFIG_CMD_KGDB * kgdb | 594 | CONFIG_CMD_KGDB * kgdb |
595 | CONFIG_CMD_LOADB loadb | 595 | CONFIG_CMD_LOADB loadb |
596 | CONFIG_CMD_LOADS loads | 596 | CONFIG_CMD_LOADS loads |
597 | CONFIG_CMD_MEMORY md, mm, nm, mw, cp, cmp, crc, base, | 597 | CONFIG_CMD_MEMORY md, mm, nm, mw, cp, cmp, crc, base, |
598 | loop, loopw, mtest | 598 | loop, loopw, mtest |
599 | CONFIG_CMD_MISC Misc functions like sleep etc | 599 | CONFIG_CMD_MISC Misc functions like sleep etc |
600 | CONFIG_CMD_MMC * MMC memory mapped support | 600 | CONFIG_CMD_MMC * MMC memory mapped support |
601 | CONFIG_CMD_MII * MII utility commands | 601 | CONFIG_CMD_MII * MII utility commands |
602 | CONFIG_CMD_NAND * NAND support | 602 | CONFIG_CMD_NAND * NAND support |
603 | CONFIG_CMD_NET bootp, tftpboot, rarpboot | 603 | CONFIG_CMD_NET bootp, tftpboot, rarpboot |
604 | CONFIG_CMD_PCI * pciinfo | 604 | CONFIG_CMD_PCI * pciinfo |
605 | CONFIG_CMD_PCMCIA * PCMCIA support | 605 | CONFIG_CMD_PCMCIA * PCMCIA support |
606 | CONFIG_CMD_PING * send ICMP ECHO_REQUEST to network | 606 | CONFIG_CMD_PING * send ICMP ECHO_REQUEST to network |
607 | host | 607 | host |
608 | CONFIG_CMD_PORTIO * Port I/O | 608 | CONFIG_CMD_PORTIO * Port I/O |
609 | CONFIG_CMD_REGINFO * Register dump | 609 | CONFIG_CMD_REGINFO * Register dump |
610 | CONFIG_CMD_RUN run command in env variable | 610 | CONFIG_CMD_RUN run command in env variable |
611 | CONFIG_CMD_SAVES * save S record dump | 611 | CONFIG_CMD_SAVES * save S record dump |
612 | CONFIG_CMD_SCSI * SCSI Support | 612 | CONFIG_CMD_SCSI * SCSI Support |
613 | CONFIG_CMD_SDRAM * print SDRAM configuration information | 613 | CONFIG_CMD_SDRAM * print SDRAM configuration information |
614 | (requires CONFIG_CMD_I2C) | 614 | (requires CONFIG_CMD_I2C) |
615 | CONFIG_CMD_SETGETDCR Support for DCR Register access | 615 | CONFIG_CMD_SETGETDCR Support for DCR Register access |
616 | (4xx only) | 616 | (4xx only) |
617 | CONFIG_CMD_SPI * SPI serial bus support | 617 | CONFIG_CMD_SPI * SPI serial bus support |
618 | CONFIG_CMD_USB * USB support | 618 | CONFIG_CMD_USB * USB support |
619 | CONFIG_CMD_VFD * VFD support (TRAB) | 619 | CONFIG_CMD_VFD * VFD support (TRAB) |
620 | CONFIG_CMD_CDP * Cisco Discover Protocol support | 620 | CONFIG_CMD_CDP * Cisco Discover Protocol support |
621 | CONFIG_CMD_FSL * Microblaze FSL support | 621 | CONFIG_CMD_FSL * Microblaze FSL support |
622 | 622 | ||
623 | 623 | ||
624 | EXAMPLE: If you want all functions except of network | 624 | EXAMPLE: If you want all functions except of network |
625 | support you can write: | 625 | support you can write: |
626 | 626 | ||
627 | #include "config_cmd_all.h" | 627 | #include "config_cmd_all.h" |
628 | #undef CONFIG_CMD_NET | 628 | #undef CONFIG_CMD_NET |
629 | 629 | ||
630 | Other Commands: | 630 | Other Commands: |
631 | fdt (flattened device tree) command: CONFIG_OF_LIBFDT | 631 | fdt (flattened device tree) command: CONFIG_OF_LIBFDT |
632 | 632 | ||
633 | Note: Don't enable the "icache" and "dcache" commands | 633 | Note: Don't enable the "icache" and "dcache" commands |
634 | (configuration option CONFIG_CMD_CACHE) unless you know | 634 | (configuration option CONFIG_CMD_CACHE) unless you know |
635 | what you (and your U-Boot users) are doing. Data | 635 | what you (and your U-Boot users) are doing. Data |
636 | cache cannot be enabled on systems like the 8xx or | 636 | cache cannot be enabled on systems like the 8xx or |
637 | 8260 (where accesses to the IMMR region must be | 637 | 8260 (where accesses to the IMMR region must be |
638 | uncached), and it cannot be disabled on all other | 638 | uncached), and it cannot be disabled on all other |
639 | systems where we (mis-) use the data cache to hold an | 639 | systems where we (mis-) use the data cache to hold an |
640 | initial stack and some data. | 640 | initial stack and some data. |
641 | 641 | ||
642 | 642 | ||
643 | XXX - this list needs to get updated! | 643 | XXX - this list needs to get updated! |
644 | 644 | ||
645 | - Watchdog: | 645 | - Watchdog: |
646 | CONFIG_WATCHDOG | 646 | CONFIG_WATCHDOG |
647 | If this variable is defined, it enables watchdog | 647 | If this variable is defined, it enables watchdog |
648 | support. There must be support in the platform specific | 648 | support. There must be support in the platform specific |
649 | code for a watchdog. For the 8xx and 8260 CPUs, the | 649 | code for a watchdog. For the 8xx and 8260 CPUs, the |
650 | SIU Watchdog feature is enabled in the SYPCR | 650 | SIU Watchdog feature is enabled in the SYPCR |
651 | register. | 651 | register. |
652 | 652 | ||
653 | - U-Boot Version: | 653 | - U-Boot Version: |
654 | CONFIG_VERSION_VARIABLE | 654 | CONFIG_VERSION_VARIABLE |
655 | If this variable is defined, an environment variable | 655 | If this variable is defined, an environment variable |
656 | named "ver" is created by U-Boot showing the U-Boot | 656 | named "ver" is created by U-Boot showing the U-Boot |
657 | version as printed by the "version" command. | 657 | version as printed by the "version" command. |
658 | This variable is readonly. | 658 | This variable is readonly. |
659 | 659 | ||
660 | - Real-Time Clock: | 660 | - Real-Time Clock: |
661 | 661 | ||
662 | When CONFIG_CMD_DATE is selected, the type of the RTC | 662 | When CONFIG_CMD_DATE is selected, the type of the RTC |
663 | has to be selected, too. Define exactly one of the | 663 | has to be selected, too. Define exactly one of the |
664 | following options: | 664 | following options: |
665 | 665 | ||
666 | CONFIG_RTC_MPC8xx - use internal RTC of MPC8xx | 666 | CONFIG_RTC_MPC8xx - use internal RTC of MPC8xx |
667 | CONFIG_RTC_PCF8563 - use Philips PCF8563 RTC | 667 | CONFIG_RTC_PCF8563 - use Philips PCF8563 RTC |
668 | CONFIG_RTC_MC13783 - use MC13783 RTC | 668 | CONFIG_RTC_MC13783 - use MC13783 RTC |
669 | CONFIG_RTC_MC146818 - use MC146818 RTC | 669 | CONFIG_RTC_MC146818 - use MC146818 RTC |
670 | CONFIG_RTC_DS1307 - use Maxim, Inc. DS1307 RTC | 670 | CONFIG_RTC_DS1307 - use Maxim, Inc. DS1307 RTC |
671 | CONFIG_RTC_DS1337 - use Maxim, Inc. DS1337 RTC | 671 | CONFIG_RTC_DS1337 - use Maxim, Inc. DS1337 RTC |
672 | CONFIG_RTC_DS1338 - use Maxim, Inc. DS1338 RTC | 672 | CONFIG_RTC_DS1338 - use Maxim, Inc. DS1338 RTC |
673 | CONFIG_RTC_DS164x - use Dallas DS164x RTC | 673 | CONFIG_RTC_DS164x - use Dallas DS164x RTC |
674 | CONFIG_RTC_ISL1208 - use Intersil ISL1208 RTC | 674 | CONFIG_RTC_ISL1208 - use Intersil ISL1208 RTC |
675 | CONFIG_RTC_MAX6900 - use Maxim, Inc. MAX6900 RTC | 675 | CONFIG_RTC_MAX6900 - use Maxim, Inc. MAX6900 RTC |
676 | CFG_RTC_DS1337_NOOSC - Turn off the OSC output for DS1337 | 676 | CFG_RTC_DS1337_NOOSC - Turn off the OSC output for DS1337 |
677 | 677 | ||
678 | Note that if the RTC uses I2C, then the I2C interface | 678 | Note that if the RTC uses I2C, then the I2C interface |
679 | must also be configured. See I2C Support, below. | 679 | must also be configured. See I2C Support, below. |
680 | 680 | ||
681 | - Timestamp Support: | 681 | - Timestamp Support: |
682 | 682 | ||
683 | When CONFIG_TIMESTAMP is selected, the timestamp | 683 | When CONFIG_TIMESTAMP is selected, the timestamp |
684 | (date and time) of an image is printed by image | 684 | (date and time) of an image is printed by image |
685 | commands like bootm or iminfo. This option is | 685 | commands like bootm or iminfo. This option is |
686 | automatically enabled when you select CONFIG_CMD_DATE . | 686 | automatically enabled when you select CONFIG_CMD_DATE . |
687 | 687 | ||
688 | - Partition Support: | 688 | - Partition Support: |
689 | CONFIG_MAC_PARTITION and/or CONFIG_DOS_PARTITION | 689 | CONFIG_MAC_PARTITION and/or CONFIG_DOS_PARTITION |
690 | and/or CONFIG_ISO_PARTITION | 690 | and/or CONFIG_ISO_PARTITION |
691 | 691 | ||
692 | If IDE or SCSI support is enabled (CONFIG_CMD_IDE or | 692 | If IDE or SCSI support is enabled (CONFIG_CMD_IDE or |
693 | CONFIG_CMD_SCSI) you must configure support for at | 693 | CONFIG_CMD_SCSI) you must configure support for at |
694 | least one partition type as well. | 694 | least one partition type as well. |
695 | 695 | ||
696 | - IDE Reset method: | 696 | - IDE Reset method: |
697 | CONFIG_IDE_RESET_ROUTINE - this is defined in several | 697 | CONFIG_IDE_RESET_ROUTINE - this is defined in several |
698 | board configurations files but used nowhere! | 698 | board configurations files but used nowhere! |
699 | 699 | ||
700 | CONFIG_IDE_RESET - is this is defined, IDE Reset will | 700 | CONFIG_IDE_RESET - is this is defined, IDE Reset will |
701 | be performed by calling the function | 701 | be performed by calling the function |
702 | ide_set_reset(int reset) | 702 | ide_set_reset(int reset) |
703 | which has to be defined in a board specific file | 703 | which has to be defined in a board specific file |
704 | 704 | ||
705 | - ATAPI Support: | 705 | - ATAPI Support: |
706 | CONFIG_ATAPI | 706 | CONFIG_ATAPI |
707 | 707 | ||
708 | Set this to enable ATAPI support. | 708 | Set this to enable ATAPI support. |
709 | 709 | ||
710 | - LBA48 Support | 710 | - LBA48 Support |
711 | CONFIG_LBA48 | 711 | CONFIG_LBA48 |
712 | 712 | ||
713 | Set this to enable support for disks larger than 137GB | 713 | Set this to enable support for disks larger than 137GB |
714 | Also look at CFG_64BIT_LBA ,CFG_64BIT_VSPRINTF and CFG_64BIT_STRTOUL | 714 | Also look at CFG_64BIT_LBA ,CFG_64BIT_VSPRINTF and CFG_64BIT_STRTOUL |
715 | Whithout these , LBA48 support uses 32bit variables and will 'only' | 715 | Whithout these , LBA48 support uses 32bit variables and will 'only' |
716 | support disks up to 2.1TB. | 716 | support disks up to 2.1TB. |
717 | 717 | ||
718 | CFG_64BIT_LBA: | 718 | CFG_64BIT_LBA: |
719 | When enabled, makes the IDE subsystem use 64bit sector addresses. | 719 | When enabled, makes the IDE subsystem use 64bit sector addresses. |
720 | Default is 32bit. | 720 | Default is 32bit. |
721 | 721 | ||
722 | - SCSI Support: | 722 | - SCSI Support: |
723 | At the moment only there is only support for the | 723 | At the moment only there is only support for the |
724 | SYM53C8XX SCSI controller; define | 724 | SYM53C8XX SCSI controller; define |
725 | CONFIG_SCSI_SYM53C8XX to enable it. | 725 | CONFIG_SCSI_SYM53C8XX to enable it. |
726 | 726 | ||
727 | CFG_SCSI_MAX_LUN [8], CFG_SCSI_MAX_SCSI_ID [7] and | 727 | CFG_SCSI_MAX_LUN [8], CFG_SCSI_MAX_SCSI_ID [7] and |
728 | CFG_SCSI_MAX_DEVICE [CFG_SCSI_MAX_SCSI_ID * | 728 | CFG_SCSI_MAX_DEVICE [CFG_SCSI_MAX_SCSI_ID * |
729 | CFG_SCSI_MAX_LUN] can be adjusted to define the | 729 | CFG_SCSI_MAX_LUN] can be adjusted to define the |
730 | maximum numbers of LUNs, SCSI ID's and target | 730 | maximum numbers of LUNs, SCSI ID's and target |
731 | devices. | 731 | devices. |
732 | CFG_SCSI_SYM53C8XX_CCF to fix clock timing (80Mhz) | 732 | CFG_SCSI_SYM53C8XX_CCF to fix clock timing (80Mhz) |
733 | 733 | ||
734 | - NETWORK Support (PCI): | 734 | - NETWORK Support (PCI): |
735 | CONFIG_E1000 | 735 | CONFIG_E1000 |
736 | Support for Intel 8254x gigabit chips. | 736 | Support for Intel 8254x gigabit chips. |
737 | 737 | ||
738 | CONFIG_E1000_FALLBACK_MAC | 738 | CONFIG_E1000_FALLBACK_MAC |
739 | default MAC for empty EEPROM after production. | 739 | default MAC for empty EEPROM after production. |
740 | 740 | ||
741 | CONFIG_EEPRO100 | 741 | CONFIG_EEPRO100 |
742 | Support for Intel 82557/82559/82559ER chips. | 742 | Support for Intel 82557/82559/82559ER chips. |
743 | Optional CONFIG_EEPRO100_SROM_WRITE enables EEPROM | 743 | Optional CONFIG_EEPRO100_SROM_WRITE enables EEPROM |
744 | write routine for first time initialisation. | 744 | write routine for first time initialisation. |
745 | 745 | ||
746 | CONFIG_TULIP | 746 | CONFIG_TULIP |
747 | Support for Digital 2114x chips. | 747 | Support for Digital 2114x chips. |
748 | Optional CONFIG_TULIP_SELECT_MEDIA for board specific | 748 | Optional CONFIG_TULIP_SELECT_MEDIA for board specific |
749 | modem chip initialisation (KS8761/QS6611). | 749 | modem chip initialisation (KS8761/QS6611). |
750 | 750 | ||
751 | CONFIG_NATSEMI | 751 | CONFIG_NATSEMI |
752 | Support for National dp83815 chips. | 752 | Support for National dp83815 chips. |
753 | 753 | ||
754 | CONFIG_NS8382X | 754 | CONFIG_NS8382X |
755 | Support for National dp8382[01] gigabit chips. | 755 | Support for National dp8382[01] gigabit chips. |
756 | 756 | ||
757 | - NETWORK Support (other): | 757 | - NETWORK Support (other): |
758 | 758 | ||
759 | CONFIG_DRIVER_LAN91C96 | 759 | CONFIG_DRIVER_LAN91C96 |
760 | Support for SMSC's LAN91C96 chips. | 760 | Support for SMSC's LAN91C96 chips. |
761 | 761 | ||
762 | CONFIG_LAN91C96_BASE | 762 | CONFIG_LAN91C96_BASE |
763 | Define this to hold the physical address | 763 | Define this to hold the physical address |
764 | of the LAN91C96's I/O space | 764 | of the LAN91C96's I/O space |
765 | 765 | ||
766 | CONFIG_LAN91C96_USE_32_BIT | 766 | CONFIG_LAN91C96_USE_32_BIT |
767 | Define this to enable 32 bit addressing | 767 | Define this to enable 32 bit addressing |
768 | 768 | ||
769 | CONFIG_DRIVER_SMC91111 | 769 | CONFIG_DRIVER_SMC91111 |
770 | Support for SMSC's LAN91C111 chip | 770 | Support for SMSC's LAN91C111 chip |
771 | 771 | ||
772 | CONFIG_SMC91111_BASE | 772 | CONFIG_SMC91111_BASE |
773 | Define this to hold the physical address | 773 | Define this to hold the physical address |
774 | of the device (I/O space) | 774 | of the device (I/O space) |
775 | 775 | ||
776 | CONFIG_SMC_USE_32_BIT | 776 | CONFIG_SMC_USE_32_BIT |
777 | Define this if data bus is 32 bits | 777 | Define this if data bus is 32 bits |
778 | 778 | ||
779 | CONFIG_SMC_USE_IOFUNCS | 779 | CONFIG_SMC_USE_IOFUNCS |
780 | Define this to use i/o functions instead of macros | 780 | Define this to use i/o functions instead of macros |
781 | (some hardware wont work with macros) | 781 | (some hardware wont work with macros) |
782 | 782 | ||
783 | CONFIG_DRIVER_SMC911X | 783 | CONFIG_DRIVER_SMC911X |
784 | Support for SMSC's LAN911x and LAN921x chips | 784 | Support for SMSC's LAN911x and LAN921x chips |
785 | 785 | ||
786 | CONFIG_DRIVER_SMC911X_BASE | 786 | CONFIG_DRIVER_SMC911X_BASE |
787 | Define this to hold the physical address | 787 | Define this to hold the physical address |
788 | of the device (I/O space) | 788 | of the device (I/O space) |
789 | 789 | ||
790 | CONFIG_DRIVER_SMC911X_32_BIT | 790 | CONFIG_DRIVER_SMC911X_32_BIT |
791 | Define this if data bus is 32 bits | 791 | Define this if data bus is 32 bits |
792 | 792 | ||
793 | CONFIG_DRIVER_SMC911X_16_BIT | 793 | CONFIG_DRIVER_SMC911X_16_BIT |
794 | Define this if data bus is 16 bits. If your processor | 794 | Define this if data bus is 16 bits. If your processor |
795 | automatically converts one 32 bit word to two 16 bit | 795 | automatically converts one 32 bit word to two 16 bit |
796 | words you may also try CONFIG_DRIVER_SMC911X_32_BIT. | 796 | words you may also try CONFIG_DRIVER_SMC911X_32_BIT. |
797 | 797 | ||
798 | - USB Support: | 798 | - USB Support: |
799 | At the moment only the UHCI host controller is | 799 | At the moment only the UHCI host controller is |
800 | supported (PIP405, MIP405, MPC5200); define | 800 | supported (PIP405, MIP405, MPC5200); define |
801 | CONFIG_USB_UHCI to enable it. | 801 | CONFIG_USB_UHCI to enable it. |
802 | define CONFIG_USB_KEYBOARD to enable the USB Keyboard | 802 | define CONFIG_USB_KEYBOARD to enable the USB Keyboard |
803 | and define CONFIG_USB_STORAGE to enable the USB | 803 | and define CONFIG_USB_STORAGE to enable the USB |
804 | storage devices. | 804 | storage devices. |
805 | Note: | 805 | Note: |
806 | Supported are USB Keyboards and USB Floppy drives | 806 | Supported are USB Keyboards and USB Floppy drives |
807 | (TEAC FD-05PUB). | 807 | (TEAC FD-05PUB). |
808 | MPC5200 USB requires additional defines: | 808 | MPC5200 USB requires additional defines: |
809 | CONFIG_USB_CLOCK | 809 | CONFIG_USB_CLOCK |
810 | for 528 MHz Clock: 0x0001bbbb | 810 | for 528 MHz Clock: 0x0001bbbb |
811 | CONFIG_USB_CONFIG | 811 | CONFIG_USB_CONFIG |
812 | for differential drivers: 0x00001000 | 812 | for differential drivers: 0x00001000 |
813 | for single ended drivers: 0x00005000 | 813 | for single ended drivers: 0x00005000 |
814 | CFG_USB_EVENT_POLL | 814 | CFG_USB_EVENT_POLL |
815 | May be defined to allow interrupt polling | 815 | May be defined to allow interrupt polling |
816 | instead of using asynchronous interrupts | 816 | instead of using asynchronous interrupts |
817 | 817 | ||
818 | - USB Device: | 818 | - USB Device: |
819 | Define the below if you wish to use the USB console. | 819 | Define the below if you wish to use the USB console. |
820 | Once firmware is rebuilt from a serial console issue the | 820 | Once firmware is rebuilt from a serial console issue the |
821 | command "setenv stdin usbtty; setenv stdout usbtty" and | 821 | command "setenv stdin usbtty; setenv stdout usbtty" and |
822 | attach your USB cable. The Unix command "dmesg" should print | 822 | attach your USB cable. The Unix command "dmesg" should print |
823 | it has found a new device. The environment variable usbtty | 823 | it has found a new device. The environment variable usbtty |
824 | can be set to gserial or cdc_acm to enable your device to | 824 | can be set to gserial or cdc_acm to enable your device to |
825 | appear to a USB host as a Linux gserial device or a | 825 | appear to a USB host as a Linux gserial device or a |
826 | Common Device Class Abstract Control Model serial device. | 826 | Common Device Class Abstract Control Model serial device. |
827 | If you select usbtty = gserial you should be able to enumerate | 827 | If you select usbtty = gserial you should be able to enumerate |
828 | a Linux host by | 828 | a Linux host by |
829 | # modprobe usbserial vendor=0xVendorID product=0xProductID | 829 | # modprobe usbserial vendor=0xVendorID product=0xProductID |
830 | else if using cdc_acm, simply setting the environment | 830 | else if using cdc_acm, simply setting the environment |
831 | variable usbtty to be cdc_acm should suffice. The following | 831 | variable usbtty to be cdc_acm should suffice. The following |
832 | might be defined in YourBoardName.h | 832 | might be defined in YourBoardName.h |
833 | 833 | ||
834 | CONFIG_USB_DEVICE | 834 | CONFIG_USB_DEVICE |
835 | Define this to build a UDC device | 835 | Define this to build a UDC device |
836 | 836 | ||
837 | CONFIG_USB_TTY | 837 | CONFIG_USB_TTY |
838 | Define this to have a tty type of device available to | 838 | Define this to have a tty type of device available to |
839 | talk to the UDC device | 839 | talk to the UDC device |
840 | 840 | ||
841 | CFG_CONSOLE_IS_IN_ENV | 841 | CFG_CONSOLE_IS_IN_ENV |
842 | Define this if you want stdin, stdout &/or stderr to | 842 | Define this if you want stdin, stdout &/or stderr to |
843 | be set to usbtty. | 843 | be set to usbtty. |
844 | 844 | ||
845 | mpc8xx: | 845 | mpc8xx: |
846 | CFG_USB_EXTC_CLK 0xBLAH | 846 | CFG_USB_EXTC_CLK 0xBLAH |
847 | Derive USB clock from external clock "blah" | 847 | Derive USB clock from external clock "blah" |
848 | - CFG_USB_EXTC_CLK 0x02 | 848 | - CFG_USB_EXTC_CLK 0x02 |
849 | 849 | ||
850 | CFG_USB_BRG_CLK 0xBLAH | 850 | CFG_USB_BRG_CLK 0xBLAH |
851 | Derive USB clock from brgclk | 851 | Derive USB clock from brgclk |
852 | - CFG_USB_BRG_CLK 0x04 | 852 | - CFG_USB_BRG_CLK 0x04 |
853 | 853 | ||
854 | If you have a USB-IF assigned VendorID then you may wish to | 854 | If you have a USB-IF assigned VendorID then you may wish to |
855 | define your own vendor specific values either in BoardName.h | 855 | define your own vendor specific values either in BoardName.h |
856 | or directly in usbd_vendor_info.h. If you don't define | 856 | or directly in usbd_vendor_info.h. If you don't define |
857 | CONFIG_USBD_MANUFACTURER, CONFIG_USBD_PRODUCT_NAME, | 857 | CONFIG_USBD_MANUFACTURER, CONFIG_USBD_PRODUCT_NAME, |
858 | CONFIG_USBD_VENDORID and CONFIG_USBD_PRODUCTID, then U-Boot | 858 | CONFIG_USBD_VENDORID and CONFIG_USBD_PRODUCTID, then U-Boot |
859 | should pretend to be a Linux device to it's target host. | 859 | should pretend to be a Linux device to it's target host. |
860 | 860 | ||
861 | CONFIG_USBD_MANUFACTURER | 861 | CONFIG_USBD_MANUFACTURER |
862 | Define this string as the name of your company for | 862 | Define this string as the name of your company for |
863 | - CONFIG_USBD_MANUFACTURER "my company" | 863 | - CONFIG_USBD_MANUFACTURER "my company" |
864 | 864 | ||
865 | CONFIG_USBD_PRODUCT_NAME | 865 | CONFIG_USBD_PRODUCT_NAME |
866 | Define this string as the name of your product | 866 | Define this string as the name of your product |
867 | - CONFIG_USBD_PRODUCT_NAME "acme usb device" | 867 | - CONFIG_USBD_PRODUCT_NAME "acme usb device" |
868 | 868 | ||
869 | CONFIG_USBD_VENDORID | 869 | CONFIG_USBD_VENDORID |
870 | Define this as your assigned Vendor ID from the USB | 870 | Define this as your assigned Vendor ID from the USB |
871 | Implementors Forum. This *must* be a genuine Vendor ID | 871 | Implementors Forum. This *must* be a genuine Vendor ID |
872 | to avoid polluting the USB namespace. | 872 | to avoid polluting the USB namespace. |
873 | - CONFIG_USBD_VENDORID 0xFFFF | 873 | - CONFIG_USBD_VENDORID 0xFFFF |
874 | 874 | ||
875 | CONFIG_USBD_PRODUCTID | 875 | CONFIG_USBD_PRODUCTID |
876 | Define this as the unique Product ID | 876 | Define this as the unique Product ID |
877 | for your device | 877 | for your device |
878 | - CONFIG_USBD_PRODUCTID 0xFFFF | 878 | - CONFIG_USBD_PRODUCTID 0xFFFF |
879 | 879 | ||
880 | 880 | ||
881 | - MMC Support: | 881 | - MMC Support: |
882 | The MMC controller on the Intel PXA is supported. To | 882 | The MMC controller on the Intel PXA is supported. To |
883 | enable this define CONFIG_MMC. The MMC can be | 883 | enable this define CONFIG_MMC. The MMC can be |
884 | accessed from the boot prompt by mapping the device | 884 | accessed from the boot prompt by mapping the device |
885 | to physical memory similar to flash. Command line is | 885 | to physical memory similar to flash. Command line is |
886 | enabled with CONFIG_CMD_MMC. The MMC driver also works with | 886 | enabled with CONFIG_CMD_MMC. The MMC driver also works with |
887 | the FAT fs. This is enabled with CONFIG_CMD_FAT. | 887 | the FAT fs. This is enabled with CONFIG_CMD_FAT. |
888 | 888 | ||
889 | - Journaling Flash filesystem support: | 889 | - Journaling Flash filesystem support: |
890 | CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, | 890 | CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, |
891 | CONFIG_JFFS2_NAND_DEV | 891 | CONFIG_JFFS2_NAND_DEV |
892 | Define these for a default partition on a NAND device | 892 | Define these for a default partition on a NAND device |
893 | 893 | ||
894 | CFG_JFFS2_FIRST_SECTOR, | 894 | CFG_JFFS2_FIRST_SECTOR, |
895 | CFG_JFFS2_FIRST_BANK, CFG_JFFS2_NUM_BANKS | 895 | CFG_JFFS2_FIRST_BANK, CFG_JFFS2_NUM_BANKS |
896 | Define these for a default partition on a NOR device | 896 | Define these for a default partition on a NOR device |
897 | 897 | ||
898 | CFG_JFFS_CUSTOM_PART | 898 | CFG_JFFS_CUSTOM_PART |
899 | Define this to create an own partition. You have to provide a | 899 | Define this to create an own partition. You have to provide a |
900 | function struct part_info* jffs2_part_info(int part_num) | 900 | function struct part_info* jffs2_part_info(int part_num) |
901 | 901 | ||
902 | If you define only one JFFS2 partition you may also want to | 902 | If you define only one JFFS2 partition you may also want to |
903 | #define CFG_JFFS_SINGLE_PART 1 | 903 | #define CFG_JFFS_SINGLE_PART 1 |
904 | to disable the command chpart. This is the default when you | 904 | to disable the command chpart. This is the default when you |
905 | have not defined a custom partition | 905 | have not defined a custom partition |
906 | 906 | ||
907 | - Keyboard Support: | 907 | - Keyboard Support: |
908 | CONFIG_ISA_KEYBOARD | 908 | CONFIG_ISA_KEYBOARD |
909 | 909 | ||
910 | Define this to enable standard (PC-Style) keyboard | 910 | Define this to enable standard (PC-Style) keyboard |
911 | support | 911 | support |
912 | 912 | ||
913 | CONFIG_I8042_KBD | 913 | CONFIG_I8042_KBD |
914 | Standard PC keyboard driver with US (is default) and | 914 | Standard PC keyboard driver with US (is default) and |
915 | GERMAN key layout (switch via environment 'keymap=de') support. | 915 | GERMAN key layout (switch via environment 'keymap=de') support. |
916 | Export function i8042_kbd_init, i8042_tstc and i8042_getc | 916 | Export function i8042_kbd_init, i8042_tstc and i8042_getc |
917 | for cfb_console. Supports cursor blinking. | 917 | for cfb_console. Supports cursor blinking. |
918 | 918 | ||
919 | - Video support: | 919 | - Video support: |
920 | CONFIG_VIDEO | 920 | CONFIG_VIDEO |
921 | 921 | ||
922 | Define this to enable video support (for output to | 922 | Define this to enable video support (for output to |
923 | video). | 923 | video). |
924 | 924 | ||
925 | CONFIG_VIDEO_CT69000 | 925 | CONFIG_VIDEO_CT69000 |
926 | 926 | ||
927 | Enable Chips & Technologies 69000 Video chip | 927 | Enable Chips & Technologies 69000 Video chip |
928 | 928 | ||
929 | CONFIG_VIDEO_SMI_LYNXEM | 929 | CONFIG_VIDEO_SMI_LYNXEM |
930 | Enable Silicon Motion SMI 712/710/810 Video chip. The | 930 | Enable Silicon Motion SMI 712/710/810 Video chip. The |
931 | video output is selected via environment 'videoout' | 931 | video output is selected via environment 'videoout' |
932 | (1 = LCD and 2 = CRT). If videoout is undefined, CRT is | 932 | (1 = LCD and 2 = CRT). If videoout is undefined, CRT is |
933 | assumed. | 933 | assumed. |
934 | 934 | ||
935 | For the CT69000 and SMI_LYNXEM drivers, videomode is | 935 | For the CT69000 and SMI_LYNXEM drivers, videomode is |
936 | selected via environment 'videomode'. Two different ways | 936 | selected via environment 'videomode'. Two different ways |
937 | are possible: | 937 | are possible: |
938 | - "videomode=num" 'num' is a standard LiLo mode numbers. | 938 | - "videomode=num" 'num' is a standard LiLo mode numbers. |
939 | Following standard modes are supported (* is default): | 939 | Following standard modes are supported (* is default): |
940 | 940 | ||
941 | Colors 640x480 800x600 1024x768 1152x864 1280x1024 | 941 | Colors 640x480 800x600 1024x768 1152x864 1280x1024 |
942 | -------------+--------------------------------------------- | 942 | -------------+--------------------------------------------- |
943 | 8 bits | 0x301* 0x303 0x305 0x161 0x307 | 943 | 8 bits | 0x301* 0x303 0x305 0x161 0x307 |
944 | 15 bits | 0x310 0x313 0x316 0x162 0x319 | 944 | 15 bits | 0x310 0x313 0x316 0x162 0x319 |
945 | 16 bits | 0x311 0x314 0x317 0x163 0x31A | 945 | 16 bits | 0x311 0x314 0x317 0x163 0x31A |
946 | 24 bits | 0x312 0x315 0x318 ? 0x31B | 946 | 24 bits | 0x312 0x315 0x318 ? 0x31B |
947 | -------------+--------------------------------------------- | 947 | -------------+--------------------------------------------- |
948 | (i.e. setenv videomode 317; saveenv; reset;) | 948 | (i.e. setenv videomode 317; saveenv; reset;) |
949 | 949 | ||
950 | - "videomode=bootargs" all the video parameters are parsed | 950 | - "videomode=bootargs" all the video parameters are parsed |
951 | from the bootargs. (See drivers/video/videomodes.c) | 951 | from the bootargs. (See drivers/video/videomodes.c) |
952 | 952 | ||
953 | 953 | ||
954 | CONFIG_VIDEO_SED13806 | 954 | CONFIG_VIDEO_SED13806 |
955 | Enable Epson SED13806 driver. This driver supports 8bpp | 955 | Enable Epson SED13806 driver. This driver supports 8bpp |
956 | and 16bpp modes defined by CONFIG_VIDEO_SED13806_8BPP | 956 | and 16bpp modes defined by CONFIG_VIDEO_SED13806_8BPP |
957 | or CONFIG_VIDEO_SED13806_16BPP | 957 | or CONFIG_VIDEO_SED13806_16BPP |
958 | 958 | ||
959 | - Keyboard Support: | 959 | - Keyboard Support: |
960 | CONFIG_KEYBOARD | 960 | CONFIG_KEYBOARD |
961 | 961 | ||
962 | Define this to enable a custom keyboard support. | 962 | Define this to enable a custom keyboard support. |
963 | This simply calls drv_keyboard_init() which must be | 963 | This simply calls drv_keyboard_init() which must be |
964 | defined in your board-specific files. | 964 | defined in your board-specific files. |
965 | The only board using this so far is RBC823. | 965 | The only board using this so far is RBC823. |
966 | 966 | ||
967 | - LCD Support: CONFIG_LCD | 967 | - LCD Support: CONFIG_LCD |
968 | 968 | ||
969 | Define this to enable LCD support (for output to LCD | 969 | Define this to enable LCD support (for output to LCD |
970 | display); also select one of the supported displays | 970 | display); also select one of the supported displays |
971 | by defining one of these: | 971 | by defining one of these: |
972 | 972 | ||
973 | CONFIG_ATMEL_LCD: | 973 | CONFIG_ATMEL_LCD: |
974 | 974 | ||
975 | HITACHI TX09D70VM1CCA, 3.5", 240x320. | 975 | HITACHI TX09D70VM1CCA, 3.5", 240x320. |
976 | 976 | ||
977 | CONFIG_NEC_NL6448AC33: | 977 | CONFIG_NEC_NL6448AC33: |
978 | 978 | ||
979 | NEC NL6448AC33-18. Active, color, single scan. | 979 | NEC NL6448AC33-18. Active, color, single scan. |
980 | 980 | ||
981 | CONFIG_NEC_NL6448BC20 | 981 | CONFIG_NEC_NL6448BC20 |
982 | 982 | ||
983 | NEC NL6448BC20-08. 6.5", 640x480. | 983 | NEC NL6448BC20-08. 6.5", 640x480. |
984 | Active, color, single scan. | 984 | Active, color, single scan. |
985 | 985 | ||
986 | CONFIG_NEC_NL6448BC33_54 | 986 | CONFIG_NEC_NL6448BC33_54 |
987 | 987 | ||
988 | NEC NL6448BC33-54. 10.4", 640x480. | 988 | NEC NL6448BC33-54. 10.4", 640x480. |
989 | Active, color, single scan. | 989 | Active, color, single scan. |
990 | 990 | ||
991 | CONFIG_SHARP_16x9 | 991 | CONFIG_SHARP_16x9 |
992 | 992 | ||
993 | Sharp 320x240. Active, color, single scan. | 993 | Sharp 320x240. Active, color, single scan. |
994 | It isn't 16x9, and I am not sure what it is. | 994 | It isn't 16x9, and I am not sure what it is. |
995 | 995 | ||
996 | CONFIG_SHARP_LQ64D341 | 996 | CONFIG_SHARP_LQ64D341 |
997 | 997 | ||
998 | Sharp LQ64D341 display, 640x480. | 998 | Sharp LQ64D341 display, 640x480. |
999 | Active, color, single scan. | 999 | Active, color, single scan. |
1000 | 1000 | ||
1001 | CONFIG_HLD1045 | 1001 | CONFIG_HLD1045 |
1002 | 1002 | ||
1003 | HLD1045 display, 640x480. | 1003 | HLD1045 display, 640x480. |
1004 | Active, color, single scan. | 1004 | Active, color, single scan. |
1005 | 1005 | ||
1006 | CONFIG_OPTREX_BW | 1006 | CONFIG_OPTREX_BW |
1007 | 1007 | ||
1008 | Optrex CBL50840-2 NF-FW 99 22 M5 | 1008 | Optrex CBL50840-2 NF-FW 99 22 M5 |
1009 | or | 1009 | or |
1010 | Hitachi LMG6912RPFC-00T | 1010 | Hitachi LMG6912RPFC-00T |
1011 | or | 1011 | or |
1012 | Hitachi SP14Q002 | 1012 | Hitachi SP14Q002 |
1013 | 1013 | ||
1014 | 320x240. Black & white. | 1014 | 320x240. Black & white. |
1015 | 1015 | ||
1016 | Normally display is black on white background; define | 1016 | Normally display is black on white background; define |
1017 | CFG_WHITE_ON_BLACK to get it inverted. | 1017 | CFG_WHITE_ON_BLACK to get it inverted. |
1018 | 1018 | ||
1019 | - Splash Screen Support: CONFIG_SPLASH_SCREEN | 1019 | - Splash Screen Support: CONFIG_SPLASH_SCREEN |
1020 | 1020 | ||
1021 | If this option is set, the environment is checked for | 1021 | If this option is set, the environment is checked for |
1022 | a variable "splashimage". If found, the usual display | 1022 | a variable "splashimage". If found, the usual display |
1023 | of logo, copyright and system information on the LCD | 1023 | of logo, copyright and system information on the LCD |
1024 | is suppressed and the BMP image at the address | 1024 | is suppressed and the BMP image at the address |
1025 | specified in "splashimage" is loaded instead. The | 1025 | specified in "splashimage" is loaded instead. The |
1026 | console is redirected to the "nulldev", too. This | 1026 | console is redirected to the "nulldev", too. This |
1027 | allows for a "silent" boot where a splash screen is | 1027 | allows for a "silent" boot where a splash screen is |
1028 | loaded very quickly after power-on. | 1028 | loaded very quickly after power-on. |
1029 | 1029 | ||
1030 | - Gzip compressed BMP image support: CONFIG_VIDEO_BMP_GZIP | 1030 | - Gzip compressed BMP image support: CONFIG_VIDEO_BMP_GZIP |
1031 | 1031 | ||
1032 | If this option is set, additionally to standard BMP | 1032 | If this option is set, additionally to standard BMP |
1033 | images, gzipped BMP images can be displayed via the | 1033 | images, gzipped BMP images can be displayed via the |
1034 | splashscreen support or the bmp command. | 1034 | splashscreen support or the bmp command. |
1035 | 1035 | ||
1036 | - Compression support: | 1036 | - Compression support: |
1037 | CONFIG_BZIP2 | 1037 | CONFIG_BZIP2 |
1038 | 1038 | ||
1039 | If this option is set, support for bzip2 compressed | 1039 | If this option is set, support for bzip2 compressed |
1040 | images is included. If not, only uncompressed and gzip | 1040 | images is included. If not, only uncompressed and gzip |
1041 | compressed images are supported. | 1041 | compressed images are supported. |
1042 | 1042 | ||
1043 | NOTE: the bzip2 algorithm requires a lot of RAM, so | 1043 | NOTE: the bzip2 algorithm requires a lot of RAM, so |
1044 | the malloc area (as defined by CFG_MALLOC_LEN) should | 1044 | the malloc area (as defined by CFG_MALLOC_LEN) should |
1045 | be at least 4MB. | 1045 | be at least 4MB. |
1046 | 1046 | ||
1047 | CONFIG_LZMA | 1047 | CONFIG_LZMA |
1048 | 1048 | ||
1049 | If this option is set, support for lzma compressed | 1049 | If this option is set, support for lzma compressed |
1050 | images is included. | 1050 | images is included. |
1051 | 1051 | ||
1052 | Note: The LZMA algorithm adds between 2 and 4KB of code and it | 1052 | Note: The LZMA algorithm adds between 2 and 4KB of code and it |
1053 | requires an amount of dynamic memory that is given by the | 1053 | requires an amount of dynamic memory that is given by the |
1054 | formula: | 1054 | formula: |
1055 | 1055 | ||
1056 | (1846 + 768 << (lc + lp)) * sizeof(uint16) | 1056 | (1846 + 768 << (lc + lp)) * sizeof(uint16) |
1057 | 1057 | ||
1058 | Where lc and lp stand for, respectively, Literal context bits | 1058 | Where lc and lp stand for, respectively, Literal context bits |
1059 | and Literal pos bits. | 1059 | and Literal pos bits. |
1060 | 1060 | ||
1061 | This value is upper-bounded by 14MB in the worst case. Anyway, | 1061 | This value is upper-bounded by 14MB in the worst case. Anyway, |
1062 | for a ~4MB large kernel image, we have lc=3 and lp=0 for a | 1062 | for a ~4MB large kernel image, we have lc=3 and lp=0 for a |
1063 | total amount of (1846 + 768 << (3 + 0)) * 2 = ~41KB... that is | 1063 | total amount of (1846 + 768 << (3 + 0)) * 2 = ~41KB... that is |
1064 | a very small buffer. | 1064 | a very small buffer. |
1065 | 1065 | ||
1066 | Use the lzmainfo tool to determinate the lc and lp values and | 1066 | Use the lzmainfo tool to determinate the lc and lp values and |
1067 | then calculate the amount of needed dynamic memory (ensuring | 1067 | then calculate the amount of needed dynamic memory (ensuring |
1068 | the appropriate CFG_MALLOC_LEN value). | 1068 | the appropriate CFG_MALLOC_LEN value). |
1069 | 1069 | ||
1070 | - MII/PHY support: | 1070 | - MII/PHY support: |
1071 | CONFIG_PHY_ADDR | 1071 | CONFIG_PHY_ADDR |
1072 | 1072 | ||
1073 | The address of PHY on MII bus. | 1073 | The address of PHY on MII bus. |
1074 | 1074 | ||
1075 | CONFIG_PHY_CLOCK_FREQ (ppc4xx) | 1075 | CONFIG_PHY_CLOCK_FREQ (ppc4xx) |
1076 | 1076 | ||
1077 | The clock frequency of the MII bus | 1077 | The clock frequency of the MII bus |
1078 | 1078 | ||
1079 | CONFIG_PHY_GIGE | 1079 | CONFIG_PHY_GIGE |
1080 | 1080 | ||
1081 | If this option is set, support for speed/duplex | 1081 | If this option is set, support for speed/duplex |
1082 | detection of gigabit PHY is included. | 1082 | detection of gigabit PHY is included. |
1083 | 1083 | ||
1084 | CONFIG_PHY_RESET_DELAY | 1084 | CONFIG_PHY_RESET_DELAY |
1085 | 1085 | ||
1086 | Some PHY like Intel LXT971A need extra delay after | 1086 | Some PHY like Intel LXT971A need extra delay after |
1087 | reset before any MII register access is possible. | 1087 | reset before any MII register access is possible. |
1088 | For such PHY, set this option to the usec delay | 1088 | For such PHY, set this option to the usec delay |
1089 | required. (minimum 300usec for LXT971A) | 1089 | required. (minimum 300usec for LXT971A) |
1090 | 1090 | ||
1091 | CONFIG_PHY_CMD_DELAY (ppc4xx) | 1091 | CONFIG_PHY_CMD_DELAY (ppc4xx) |
1092 | 1092 | ||
1093 | Some PHY like Intel LXT971A need extra delay after | 1093 | Some PHY like Intel LXT971A need extra delay after |
1094 | command issued before MII status register can be read | 1094 | command issued before MII status register can be read |
1095 | 1095 | ||
1096 | - Ethernet address: | 1096 | - Ethernet address: |
1097 | CONFIG_ETHADDR | 1097 | CONFIG_ETHADDR |
1098 | CONFIG_ETH1ADDR | ||
1098 | CONFIG_ETH2ADDR | 1099 | CONFIG_ETH2ADDR |
1099 | CONFIG_ETH3ADDR | 1100 | CONFIG_ETH3ADDR |
1101 | CONFIG_ETH4ADDR | ||
1102 | CONFIG_ETH5ADDR | ||
1100 | 1103 | ||
1101 | Define a default value for Ethernet address to use | 1104 | Define a default value for Ethernet address to use |
1102 | for the respective Ethernet interface, in case this | 1105 | for the respective Ethernet interface, in case this |
1103 | is not determined automatically. | 1106 | is not determined automatically. |
1104 | 1107 | ||
1105 | - IP address: | 1108 | - IP address: |
1106 | CONFIG_IPADDR | 1109 | CONFIG_IPADDR |
1107 | 1110 | ||
1108 | Define a default value for the IP address to use for | 1111 | Define a default value for the IP address to use for |
1109 | the default Ethernet interface, in case this is not | 1112 | the default Ethernet interface, in case this is not |
1110 | determined through e.g. bootp. | 1113 | determined through e.g. bootp. |
1111 | 1114 | ||
1112 | - Server IP address: | 1115 | - Server IP address: |
1113 | CONFIG_SERVERIP | 1116 | CONFIG_SERVERIP |
1114 | 1117 | ||
1115 | Defines a default value for the IP address of a TFTP | 1118 | Defines a default value for the IP address of a TFTP |
1116 | server to contact when using the "tftboot" command. | 1119 | server to contact when using the "tftboot" command. |
1117 | 1120 | ||
1118 | - Multicast TFTP Mode: | 1121 | - Multicast TFTP Mode: |
1119 | CONFIG_MCAST_TFTP | 1122 | CONFIG_MCAST_TFTP |
1120 | 1123 | ||
1121 | Defines whether you want to support multicast TFTP as per | 1124 | Defines whether you want to support multicast TFTP as per |
1122 | rfc-2090; for example to work with atftp. Lets lots of targets | 1125 | rfc-2090; for example to work with atftp. Lets lots of targets |
1123 | tftp down the same boot image concurrently. Note: the Ethernet | 1126 | tftp down the same boot image concurrently. Note: the Ethernet |
1124 | driver in use must provide a function: mcast() to join/leave a | 1127 | driver in use must provide a function: mcast() to join/leave a |
1125 | multicast group. | 1128 | multicast group. |
1126 | 1129 | ||
1127 | CONFIG_BOOTP_RANDOM_DELAY | 1130 | CONFIG_BOOTP_RANDOM_DELAY |
1128 | - BOOTP Recovery Mode: | 1131 | - BOOTP Recovery Mode: |
1129 | CONFIG_BOOTP_RANDOM_DELAY | 1132 | CONFIG_BOOTP_RANDOM_DELAY |
1130 | 1133 | ||
1131 | If you have many targets in a network that try to | 1134 | If you have many targets in a network that try to |
1132 | boot using BOOTP, you may want to avoid that all | 1135 | boot using BOOTP, you may want to avoid that all |
1133 | systems send out BOOTP requests at precisely the same | 1136 | systems send out BOOTP requests at precisely the same |
1134 | moment (which would happen for instance at recovery | 1137 | moment (which would happen for instance at recovery |
1135 | from a power failure, when all systems will try to | 1138 | from a power failure, when all systems will try to |
1136 | boot, thus flooding the BOOTP server. Defining | 1139 | boot, thus flooding the BOOTP server. Defining |
1137 | CONFIG_BOOTP_RANDOM_DELAY causes a random delay to be | 1140 | CONFIG_BOOTP_RANDOM_DELAY causes a random delay to be |
1138 | inserted before sending out BOOTP requests. The | 1141 | inserted before sending out BOOTP requests. The |
1139 | following delays are inserted then: | 1142 | following delays are inserted then: |
1140 | 1143 | ||
1141 | 1st BOOTP request: delay 0 ... 1 sec | 1144 | 1st BOOTP request: delay 0 ... 1 sec |
1142 | 2nd BOOTP request: delay 0 ... 2 sec | 1145 | 2nd BOOTP request: delay 0 ... 2 sec |
1143 | 3rd BOOTP request: delay 0 ... 4 sec | 1146 | 3rd BOOTP request: delay 0 ... 4 sec |
1144 | 4th and following | 1147 | 4th and following |
1145 | BOOTP requests: delay 0 ... 8 sec | 1148 | BOOTP requests: delay 0 ... 8 sec |
1146 | 1149 | ||
1147 | - DHCP Advanced Options: | 1150 | - DHCP Advanced Options: |
1148 | You can fine tune the DHCP functionality by defining | 1151 | You can fine tune the DHCP functionality by defining |
1149 | CONFIG_BOOTP_* symbols: | 1152 | CONFIG_BOOTP_* symbols: |
1150 | 1153 | ||
1151 | CONFIG_BOOTP_SUBNETMASK | 1154 | CONFIG_BOOTP_SUBNETMASK |
1152 | CONFIG_BOOTP_GATEWAY | 1155 | CONFIG_BOOTP_GATEWAY |
1153 | CONFIG_BOOTP_HOSTNAME | 1156 | CONFIG_BOOTP_HOSTNAME |
1154 | CONFIG_BOOTP_NISDOMAIN | 1157 | CONFIG_BOOTP_NISDOMAIN |
1155 | CONFIG_BOOTP_BOOTPATH | 1158 | CONFIG_BOOTP_BOOTPATH |
1156 | CONFIG_BOOTP_BOOTFILESIZE | 1159 | CONFIG_BOOTP_BOOTFILESIZE |
1157 | CONFIG_BOOTP_DNS | 1160 | CONFIG_BOOTP_DNS |
1158 | CONFIG_BOOTP_DNS2 | 1161 | CONFIG_BOOTP_DNS2 |
1159 | CONFIG_BOOTP_SEND_HOSTNAME | 1162 | CONFIG_BOOTP_SEND_HOSTNAME |
1160 | CONFIG_BOOTP_NTPSERVER | 1163 | CONFIG_BOOTP_NTPSERVER |
1161 | CONFIG_BOOTP_TIMEOFFSET | 1164 | CONFIG_BOOTP_TIMEOFFSET |
1162 | CONFIG_BOOTP_VENDOREX | 1165 | CONFIG_BOOTP_VENDOREX |
1163 | 1166 | ||
1164 | CONFIG_BOOTP_SERVERIP - TFTP server will be the serverip | 1167 | CONFIG_BOOTP_SERVERIP - TFTP server will be the serverip |
1165 | environment variable, not the BOOTP server. | 1168 | environment variable, not the BOOTP server. |
1166 | 1169 | ||
1167 | CONFIG_BOOTP_DNS2 - If a DHCP client requests the DNS | 1170 | CONFIG_BOOTP_DNS2 - If a DHCP client requests the DNS |
1168 | serverip from a DHCP server, it is possible that more | 1171 | serverip from a DHCP server, it is possible that more |
1169 | than one DNS serverip is offered to the client. | 1172 | than one DNS serverip is offered to the client. |
1170 | If CONFIG_BOOTP_DNS2 is enabled, the secondary DNS | 1173 | If CONFIG_BOOTP_DNS2 is enabled, the secondary DNS |
1171 | serverip will be stored in the additional environment | 1174 | serverip will be stored in the additional environment |
1172 | variable "dnsip2". The first DNS serverip is always | 1175 | variable "dnsip2". The first DNS serverip is always |
1173 | stored in the variable "dnsip", when CONFIG_BOOTP_DNS | 1176 | stored in the variable "dnsip", when CONFIG_BOOTP_DNS |
1174 | is defined. | 1177 | is defined. |
1175 | 1178 | ||
1176 | CONFIG_BOOTP_SEND_HOSTNAME - Some DHCP servers are capable | 1179 | CONFIG_BOOTP_SEND_HOSTNAME - Some DHCP servers are capable |
1177 | to do a dynamic update of a DNS server. To do this, they | 1180 | to do a dynamic update of a DNS server. To do this, they |
1178 | need the hostname of the DHCP requester. | 1181 | need the hostname of the DHCP requester. |
1179 | If CONFIG_BOOTP_SEND_HOSTNAME is defined, the content | 1182 | If CONFIG_BOOTP_SEND_HOSTNAME is defined, the content |
1180 | of the "hostname" environment variable is passed as | 1183 | of the "hostname" environment variable is passed as |
1181 | option 12 to the DHCP server. | 1184 | option 12 to the DHCP server. |
1182 | 1185 | ||
1183 | CONFIG_BOOTP_DHCP_REQUEST_DELAY | 1186 | CONFIG_BOOTP_DHCP_REQUEST_DELAY |
1184 | 1187 | ||
1185 | A 32bit value in microseconds for a delay between | 1188 | A 32bit value in microseconds for a delay between |
1186 | receiving a "DHCP Offer" and sending the "DHCP Request". | 1189 | receiving a "DHCP Offer" and sending the "DHCP Request". |
1187 | This fixes a problem with certain DHCP servers that don't | 1190 | This fixes a problem with certain DHCP servers that don't |
1188 | respond 100% of the time to a "DHCP request". E.g. On an | 1191 | respond 100% of the time to a "DHCP request". E.g. On an |
1189 | AT91RM9200 processor running at 180MHz, this delay needed | 1192 | AT91RM9200 processor running at 180MHz, this delay needed |
1190 | to be *at least* 15,000 usec before a Windows Server 2003 | 1193 | to be *at least* 15,000 usec before a Windows Server 2003 |
1191 | DHCP server would reply 100% of the time. I recommend at | 1194 | DHCP server would reply 100% of the time. I recommend at |
1192 | least 50,000 usec to be safe. The alternative is to hope | 1195 | least 50,000 usec to be safe. The alternative is to hope |
1193 | that one of the retries will be successful but note that | 1196 | that one of the retries will be successful but note that |
1194 | the DHCP timeout and retry process takes a longer than | 1197 | the DHCP timeout and retry process takes a longer than |
1195 | this delay. | 1198 | this delay. |
1196 | 1199 | ||
1197 | - CDP Options: | 1200 | - CDP Options: |
1198 | CONFIG_CDP_DEVICE_ID | 1201 | CONFIG_CDP_DEVICE_ID |
1199 | 1202 | ||
1200 | The device id used in CDP trigger frames. | 1203 | The device id used in CDP trigger frames. |
1201 | 1204 | ||
1202 | CONFIG_CDP_DEVICE_ID_PREFIX | 1205 | CONFIG_CDP_DEVICE_ID_PREFIX |
1203 | 1206 | ||
1204 | A two character string which is prefixed to the MAC address | 1207 | A two character string which is prefixed to the MAC address |
1205 | of the device. | 1208 | of the device. |
1206 | 1209 | ||
1207 | CONFIG_CDP_PORT_ID | 1210 | CONFIG_CDP_PORT_ID |
1208 | 1211 | ||
1209 | A printf format string which contains the ascii name of | 1212 | A printf format string which contains the ascii name of |
1210 | the port. Normally is set to "eth%d" which sets | 1213 | the port. Normally is set to "eth%d" which sets |
1211 | eth0 for the first Ethernet, eth1 for the second etc. | 1214 | eth0 for the first Ethernet, eth1 for the second etc. |
1212 | 1215 | ||
1213 | CONFIG_CDP_CAPABILITIES | 1216 | CONFIG_CDP_CAPABILITIES |
1214 | 1217 | ||
1215 | A 32bit integer which indicates the device capabilities; | 1218 | A 32bit integer which indicates the device capabilities; |
1216 | 0x00000010 for a normal host which does not forwards. | 1219 | 0x00000010 for a normal host which does not forwards. |
1217 | 1220 | ||
1218 | CONFIG_CDP_VERSION | 1221 | CONFIG_CDP_VERSION |
1219 | 1222 | ||
1220 | An ascii string containing the version of the software. | 1223 | An ascii string containing the version of the software. |
1221 | 1224 | ||
1222 | CONFIG_CDP_PLATFORM | 1225 | CONFIG_CDP_PLATFORM |
1223 | 1226 | ||
1224 | An ascii string containing the name of the platform. | 1227 | An ascii string containing the name of the platform. |
1225 | 1228 | ||
1226 | CONFIG_CDP_TRIGGER | 1229 | CONFIG_CDP_TRIGGER |
1227 | 1230 | ||
1228 | A 32bit integer sent on the trigger. | 1231 | A 32bit integer sent on the trigger. |
1229 | 1232 | ||
1230 | CONFIG_CDP_POWER_CONSUMPTION | 1233 | CONFIG_CDP_POWER_CONSUMPTION |
1231 | 1234 | ||
1232 | A 16bit integer containing the power consumption of the | 1235 | A 16bit integer containing the power consumption of the |
1233 | device in .1 of milliwatts. | 1236 | device in .1 of milliwatts. |
1234 | 1237 | ||
1235 | CONFIG_CDP_APPLIANCE_VLAN_TYPE | 1238 | CONFIG_CDP_APPLIANCE_VLAN_TYPE |
1236 | 1239 | ||
1237 | A byte containing the id of the VLAN. | 1240 | A byte containing the id of the VLAN. |
1238 | 1241 | ||
1239 | - Status LED: CONFIG_STATUS_LED | 1242 | - Status LED: CONFIG_STATUS_LED |
1240 | 1243 | ||
1241 | Several configurations allow to display the current | 1244 | Several configurations allow to display the current |
1242 | status using a LED. For instance, the LED will blink | 1245 | status using a LED. For instance, the LED will blink |
1243 | fast while running U-Boot code, stop blinking as | 1246 | fast while running U-Boot code, stop blinking as |
1244 | soon as a reply to a BOOTP request was received, and | 1247 | soon as a reply to a BOOTP request was received, and |
1245 | start blinking slow once the Linux kernel is running | 1248 | start blinking slow once the Linux kernel is running |
1246 | (supported by a status LED driver in the Linux | 1249 | (supported by a status LED driver in the Linux |
1247 | kernel). Defining CONFIG_STATUS_LED enables this | 1250 | kernel). Defining CONFIG_STATUS_LED enables this |
1248 | feature in U-Boot. | 1251 | feature in U-Boot. |
1249 | 1252 | ||
1250 | - CAN Support: CONFIG_CAN_DRIVER | 1253 | - CAN Support: CONFIG_CAN_DRIVER |
1251 | 1254 | ||
1252 | Defining CONFIG_CAN_DRIVER enables CAN driver support | 1255 | Defining CONFIG_CAN_DRIVER enables CAN driver support |
1253 | on those systems that support this (optional) | 1256 | on those systems that support this (optional) |
1254 | feature, like the TQM8xxL modules. | 1257 | feature, like the TQM8xxL modules. |
1255 | 1258 | ||
1256 | - I2C Support: CONFIG_HARD_I2C | CONFIG_SOFT_I2C | 1259 | - I2C Support: CONFIG_HARD_I2C | CONFIG_SOFT_I2C |
1257 | 1260 | ||
1258 | These enable I2C serial bus commands. Defining either of | 1261 | These enable I2C serial bus commands. Defining either of |
1259 | (but not both of) CONFIG_HARD_I2C or CONFIG_SOFT_I2C will | 1262 | (but not both of) CONFIG_HARD_I2C or CONFIG_SOFT_I2C will |
1260 | include the appropriate I2C driver for the selected CPU. | 1263 | include the appropriate I2C driver for the selected CPU. |
1261 | 1264 | ||
1262 | This will allow you to use i2c commands at the u-boot | 1265 | This will allow you to use i2c commands at the u-boot |
1263 | command line (as long as you set CONFIG_CMD_I2C in | 1266 | command line (as long as you set CONFIG_CMD_I2C in |
1264 | CONFIG_COMMANDS) and communicate with i2c based realtime | 1267 | CONFIG_COMMANDS) and communicate with i2c based realtime |
1265 | clock chips. See common/cmd_i2c.c for a description of the | 1268 | clock chips. See common/cmd_i2c.c for a description of the |
1266 | command line interface. | 1269 | command line interface. |
1267 | 1270 | ||
1268 | CONFIG_I2C_CMD_TREE is a recommended option that places | 1271 | CONFIG_I2C_CMD_TREE is a recommended option that places |
1269 | all I2C commands under a single 'i2c' root command. The | 1272 | all I2C commands under a single 'i2c' root command. The |
1270 | older 'imm', 'imd', 'iprobe' etc. commands are considered | 1273 | older 'imm', 'imd', 'iprobe' etc. commands are considered |
1271 | deprecated and may disappear in the future. | 1274 | deprecated and may disappear in the future. |
1272 | 1275 | ||
1273 | CONFIG_HARD_I2C selects a hardware I2C controller. | 1276 | CONFIG_HARD_I2C selects a hardware I2C controller. |
1274 | 1277 | ||
1275 | CONFIG_SOFT_I2C configures u-boot to use a software (aka | 1278 | CONFIG_SOFT_I2C configures u-boot to use a software (aka |
1276 | bit-banging) driver instead of CPM or similar hardware | 1279 | bit-banging) driver instead of CPM or similar hardware |
1277 | support for I2C. | 1280 | support for I2C. |
1278 | 1281 | ||
1279 | There are several other quantities that must also be | 1282 | There are several other quantities that must also be |
1280 | defined when you define CONFIG_HARD_I2C or CONFIG_SOFT_I2C. | 1283 | defined when you define CONFIG_HARD_I2C or CONFIG_SOFT_I2C. |
1281 | 1284 | ||
1282 | In both cases you will need to define CFG_I2C_SPEED | 1285 | In both cases you will need to define CFG_I2C_SPEED |
1283 | to be the frequency (in Hz) at which you wish your i2c bus | 1286 | to be the frequency (in Hz) at which you wish your i2c bus |
1284 | to run and CFG_I2C_SLAVE to be the address of this node (ie | 1287 | to run and CFG_I2C_SLAVE to be the address of this node (ie |
1285 | the CPU's i2c node address). | 1288 | the CPU's i2c node address). |
1286 | 1289 | ||
1287 | Now, the u-boot i2c code for the mpc8xx (cpu/mpc8xx/i2c.c) | 1290 | Now, the u-boot i2c code for the mpc8xx (cpu/mpc8xx/i2c.c) |
1288 | sets the CPU up as a master node and so its address should | 1291 | sets the CPU up as a master node and so its address should |
1289 | therefore be cleared to 0 (See, eg, MPC823e User's Manual | 1292 | therefore be cleared to 0 (See, eg, MPC823e User's Manual |
1290 | p.16-473). So, set CFG_I2C_SLAVE to 0. | 1293 | p.16-473). So, set CFG_I2C_SLAVE to 0. |
1291 | 1294 | ||
1292 | That's all that's required for CONFIG_HARD_I2C. | 1295 | That's all that's required for CONFIG_HARD_I2C. |
1293 | 1296 | ||
1294 | If you use the software i2c interface (CONFIG_SOFT_I2C) | 1297 | If you use the software i2c interface (CONFIG_SOFT_I2C) |
1295 | then the following macros need to be defined (examples are | 1298 | then the following macros need to be defined (examples are |
1296 | from include/configs/lwmon.h): | 1299 | from include/configs/lwmon.h): |
1297 | 1300 | ||
1298 | I2C_INIT | 1301 | I2C_INIT |
1299 | 1302 | ||
1300 | (Optional). Any commands necessary to enable the I2C | 1303 | (Optional). Any commands necessary to enable the I2C |
1301 | controller or configure ports. | 1304 | controller or configure ports. |
1302 | 1305 | ||
1303 | eg: #define I2C_INIT (immr->im_cpm.cp_pbdir |= PB_SCL) | 1306 | eg: #define I2C_INIT (immr->im_cpm.cp_pbdir |= PB_SCL) |
1304 | 1307 | ||
1305 | I2C_PORT | 1308 | I2C_PORT |
1306 | 1309 | ||
1307 | (Only for MPC8260 CPU). The I/O port to use (the code | 1310 | (Only for MPC8260 CPU). The I/O port to use (the code |
1308 | assumes both bits are on the same port). Valid values | 1311 | assumes both bits are on the same port). Valid values |
1309 | are 0..3 for ports A..D. | 1312 | are 0..3 for ports A..D. |
1310 | 1313 | ||
1311 | I2C_ACTIVE | 1314 | I2C_ACTIVE |
1312 | 1315 | ||
1313 | The code necessary to make the I2C data line active | 1316 | The code necessary to make the I2C data line active |
1314 | (driven). If the data line is open collector, this | 1317 | (driven). If the data line is open collector, this |
1315 | define can be null. | 1318 | define can be null. |
1316 | 1319 | ||
1317 | eg: #define I2C_ACTIVE (immr->im_cpm.cp_pbdir |= PB_SDA) | 1320 | eg: #define I2C_ACTIVE (immr->im_cpm.cp_pbdir |= PB_SDA) |
1318 | 1321 | ||
1319 | I2C_TRISTATE | 1322 | I2C_TRISTATE |
1320 | 1323 | ||
1321 | The code necessary to make the I2C data line tri-stated | 1324 | The code necessary to make the I2C data line tri-stated |
1322 | (inactive). If the data line is open collector, this | 1325 | (inactive). If the data line is open collector, this |
1323 | define can be null. | 1326 | define can be null. |
1324 | 1327 | ||
1325 | eg: #define I2C_TRISTATE (immr->im_cpm.cp_pbdir &= ~PB_SDA) | 1328 | eg: #define I2C_TRISTATE (immr->im_cpm.cp_pbdir &= ~PB_SDA) |
1326 | 1329 | ||
1327 | I2C_READ | 1330 | I2C_READ |
1328 | 1331 | ||
1329 | Code that returns TRUE if the I2C data line is high, | 1332 | Code that returns TRUE if the I2C data line is high, |
1330 | FALSE if it is low. | 1333 | FALSE if it is low. |
1331 | 1334 | ||
1332 | eg: #define I2C_READ ((immr->im_cpm.cp_pbdat & PB_SDA) != 0) | 1335 | eg: #define I2C_READ ((immr->im_cpm.cp_pbdat & PB_SDA) != 0) |
1333 | 1336 | ||
1334 | I2C_SDA(bit) | 1337 | I2C_SDA(bit) |
1335 | 1338 | ||
1336 | If <bit> is TRUE, sets the I2C data line high. If it | 1339 | If <bit> is TRUE, sets the I2C data line high. If it |
1337 | is FALSE, it clears it (low). | 1340 | is FALSE, it clears it (low). |
1338 | 1341 | ||
1339 | eg: #define I2C_SDA(bit) \ | 1342 | eg: #define I2C_SDA(bit) \ |
1340 | if(bit) immr->im_cpm.cp_pbdat |= PB_SDA; \ | 1343 | if(bit) immr->im_cpm.cp_pbdat |= PB_SDA; \ |
1341 | else immr->im_cpm.cp_pbdat &= ~PB_SDA | 1344 | else immr->im_cpm.cp_pbdat &= ~PB_SDA |
1342 | 1345 | ||
1343 | I2C_SCL(bit) | 1346 | I2C_SCL(bit) |
1344 | 1347 | ||
1345 | If <bit> is TRUE, sets the I2C clock line high. If it | 1348 | If <bit> is TRUE, sets the I2C clock line high. If it |
1346 | is FALSE, it clears it (low). | 1349 | is FALSE, it clears it (low). |
1347 | 1350 | ||
1348 | eg: #define I2C_SCL(bit) \ | 1351 | eg: #define I2C_SCL(bit) \ |
1349 | if(bit) immr->im_cpm.cp_pbdat |= PB_SCL; \ | 1352 | if(bit) immr->im_cpm.cp_pbdat |= PB_SCL; \ |
1350 | else immr->im_cpm.cp_pbdat &= ~PB_SCL | 1353 | else immr->im_cpm.cp_pbdat &= ~PB_SCL |
1351 | 1354 | ||
1352 | I2C_DELAY | 1355 | I2C_DELAY |
1353 | 1356 | ||
1354 | This delay is invoked four times per clock cycle so this | 1357 | This delay is invoked four times per clock cycle so this |
1355 | controls the rate of data transfer. The data rate thus | 1358 | controls the rate of data transfer. The data rate thus |
1356 | is 1 / (I2C_DELAY * 4). Often defined to be something | 1359 | is 1 / (I2C_DELAY * 4). Often defined to be something |
1357 | like: | 1360 | like: |
1358 | 1361 | ||
1359 | #define I2C_DELAY udelay(2) | 1362 | #define I2C_DELAY udelay(2) |
1360 | 1363 | ||
1361 | CFG_I2C_INIT_BOARD | 1364 | CFG_I2C_INIT_BOARD |
1362 | 1365 | ||
1363 | When a board is reset during an i2c bus transfer | 1366 | When a board is reset during an i2c bus transfer |
1364 | chips might think that the current transfer is still | 1367 | chips might think that the current transfer is still |
1365 | in progress. On some boards it is possible to access | 1368 | in progress. On some boards it is possible to access |
1366 | the i2c SCLK line directly, either by using the | 1369 | the i2c SCLK line directly, either by using the |
1367 | processor pin as a GPIO or by having a second pin | 1370 | processor pin as a GPIO or by having a second pin |
1368 | connected to the bus. If this option is defined a | 1371 | connected to the bus. If this option is defined a |
1369 | custom i2c_init_board() routine in boards/xxx/board.c | 1372 | custom i2c_init_board() routine in boards/xxx/board.c |
1370 | is run early in the boot sequence. | 1373 | is run early in the boot sequence. |
1371 | 1374 | ||
1372 | CONFIG_I2CFAST (PPC405GP|PPC405EP only) | 1375 | CONFIG_I2CFAST (PPC405GP|PPC405EP only) |
1373 | 1376 | ||
1374 | This option enables configuration of bi_iic_fast[] flags | 1377 | This option enables configuration of bi_iic_fast[] flags |
1375 | in u-boot bd_info structure based on u-boot environment | 1378 | in u-boot bd_info structure based on u-boot environment |
1376 | variable "i2cfast". (see also i2cfast) | 1379 | variable "i2cfast". (see also i2cfast) |
1377 | 1380 | ||
1378 | CONFIG_I2C_MULTI_BUS | 1381 | CONFIG_I2C_MULTI_BUS |
1379 | 1382 | ||
1380 | This option allows the use of multiple I2C buses, each of which | 1383 | This option allows the use of multiple I2C buses, each of which |
1381 | must have a controller. At any point in time, only one bus is | 1384 | must have a controller. At any point in time, only one bus is |
1382 | active. To switch to a different bus, use the 'i2c dev' command. | 1385 | active. To switch to a different bus, use the 'i2c dev' command. |
1383 | Note that bus numbering is zero-based. | 1386 | Note that bus numbering is zero-based. |
1384 | 1387 | ||
1385 | CFG_I2C_NOPROBES | 1388 | CFG_I2C_NOPROBES |
1386 | 1389 | ||
1387 | This option specifies a list of I2C devices that will be skipped | 1390 | This option specifies a list of I2C devices that will be skipped |
1388 | when the 'i2c probe' command is issued (or 'iprobe' using the legacy | 1391 | when the 'i2c probe' command is issued (or 'iprobe' using the legacy |
1389 | command). If CONFIG_I2C_MULTI_BUS is set, specify a list of bus-device | 1392 | command). If CONFIG_I2C_MULTI_BUS is set, specify a list of bus-device |
1390 | pairs. Otherwise, specify a 1D array of device addresses | 1393 | pairs. Otherwise, specify a 1D array of device addresses |
1391 | 1394 | ||
1392 | e.g. | 1395 | e.g. |
1393 | #undef CONFIG_I2C_MULTI_BUS | 1396 | #undef CONFIG_I2C_MULTI_BUS |
1394 | #define CFG_I2C_NOPROBES {0x50,0x68} | 1397 | #define CFG_I2C_NOPROBES {0x50,0x68} |
1395 | 1398 | ||
1396 | will skip addresses 0x50 and 0x68 on a board with one I2C bus | 1399 | will skip addresses 0x50 and 0x68 on a board with one I2C bus |
1397 | 1400 | ||
1398 | #define CONFIG_I2C_MULTI_BUS | 1401 | #define CONFIG_I2C_MULTI_BUS |
1399 | #define CFG_I2C_MULTI_NOPROBES {{0,0x50},{0,0x68},{1,0x54}} | 1402 | #define CFG_I2C_MULTI_NOPROBES {{0,0x50},{0,0x68},{1,0x54}} |
1400 | 1403 | ||
1401 | will skip addresses 0x50 and 0x68 on bus 0 and address 0x54 on bus 1 | 1404 | will skip addresses 0x50 and 0x68 on bus 0 and address 0x54 on bus 1 |
1402 | 1405 | ||
1403 | CFG_SPD_BUS_NUM | 1406 | CFG_SPD_BUS_NUM |
1404 | 1407 | ||
1405 | If defined, then this indicates the I2C bus number for DDR SPD. | 1408 | If defined, then this indicates the I2C bus number for DDR SPD. |
1406 | If not defined, then U-Boot assumes that SPD is on I2C bus 0. | 1409 | If not defined, then U-Boot assumes that SPD is on I2C bus 0. |
1407 | 1410 | ||
1408 | CFG_RTC_BUS_NUM | 1411 | CFG_RTC_BUS_NUM |
1409 | 1412 | ||
1410 | If defined, then this indicates the I2C bus number for the RTC. | 1413 | If defined, then this indicates the I2C bus number for the RTC. |
1411 | If not defined, then U-Boot assumes that RTC is on I2C bus 0. | 1414 | If not defined, then U-Boot assumes that RTC is on I2C bus 0. |
1412 | 1415 | ||
1413 | CFG_DTT_BUS_NUM | 1416 | CFG_DTT_BUS_NUM |
1414 | 1417 | ||
1415 | If defined, then this indicates the I2C bus number for the DTT. | 1418 | If defined, then this indicates the I2C bus number for the DTT. |
1416 | If not defined, then U-Boot assumes that DTT is on I2C bus 0. | 1419 | If not defined, then U-Boot assumes that DTT is on I2C bus 0. |
1417 | 1420 | ||
1418 | CFG_I2C_DTT_ADDR: | 1421 | CFG_I2C_DTT_ADDR: |
1419 | 1422 | ||
1420 | If defined, specifies the I2C address of the DTT device. | 1423 | If defined, specifies the I2C address of the DTT device. |
1421 | If not defined, then U-Boot uses predefined value for | 1424 | If not defined, then U-Boot uses predefined value for |
1422 | specified DTT device. | 1425 | specified DTT device. |
1423 | 1426 | ||
1424 | CONFIG_FSL_I2C | 1427 | CONFIG_FSL_I2C |
1425 | 1428 | ||
1426 | Define this option if you want to use Freescale's I2C driver in | 1429 | Define this option if you want to use Freescale's I2C driver in |
1427 | drivers/i2c/fsl_i2c.c. | 1430 | drivers/i2c/fsl_i2c.c. |
1428 | 1431 | ||
1429 | 1432 | ||
1430 | - SPI Support: CONFIG_SPI | 1433 | - SPI Support: CONFIG_SPI |
1431 | 1434 | ||
1432 | Enables SPI driver (so far only tested with | 1435 | Enables SPI driver (so far only tested with |
1433 | SPI EEPROM, also an instance works with Crystal A/D and | 1436 | SPI EEPROM, also an instance works with Crystal A/D and |
1434 | D/As on the SACSng board) | 1437 | D/As on the SACSng board) |
1435 | 1438 | ||
1436 | CONFIG_SPI_X | 1439 | CONFIG_SPI_X |
1437 | 1440 | ||
1438 | Enables extended (16-bit) SPI EEPROM addressing. | 1441 | Enables extended (16-bit) SPI EEPROM addressing. |
1439 | (symmetrical to CONFIG_I2C_X) | 1442 | (symmetrical to CONFIG_I2C_X) |
1440 | 1443 | ||
1441 | CONFIG_SOFT_SPI | 1444 | CONFIG_SOFT_SPI |
1442 | 1445 | ||
1443 | Enables a software (bit-bang) SPI driver rather than | 1446 | Enables a software (bit-bang) SPI driver rather than |
1444 | using hardware support. This is a general purpose | 1447 | using hardware support. This is a general purpose |
1445 | driver that only requires three general I/O port pins | 1448 | driver that only requires three general I/O port pins |
1446 | (two outputs, one input) to function. If this is | 1449 | (two outputs, one input) to function. If this is |
1447 | defined, the board configuration must define several | 1450 | defined, the board configuration must define several |
1448 | SPI configuration items (port pins to use, etc). For | 1451 | SPI configuration items (port pins to use, etc). For |
1449 | an example, see include/configs/sacsng.h. | 1452 | an example, see include/configs/sacsng.h. |
1450 | 1453 | ||
1451 | CONFIG_HARD_SPI | 1454 | CONFIG_HARD_SPI |
1452 | 1455 | ||
1453 | Enables a hardware SPI driver for general-purpose reads | 1456 | Enables a hardware SPI driver for general-purpose reads |
1454 | and writes. As with CONFIG_SOFT_SPI, the board configuration | 1457 | and writes. As with CONFIG_SOFT_SPI, the board configuration |
1455 | must define a list of chip-select function pointers. | 1458 | must define a list of chip-select function pointers. |
1456 | Currently supported on some MPC8xxx processors. For an | 1459 | Currently supported on some MPC8xxx processors. For an |
1457 | example, see include/configs/mpc8349emds.h. | 1460 | example, see include/configs/mpc8349emds.h. |
1458 | 1461 | ||
1459 | CONFIG_MXC_SPI | 1462 | CONFIG_MXC_SPI |
1460 | 1463 | ||
1461 | Enables the driver for the SPI controllers on i.MX and MXC | 1464 | Enables the driver for the SPI controllers on i.MX and MXC |
1462 | SoCs. Currently only i.MX31 is supported. | 1465 | SoCs. Currently only i.MX31 is supported. |
1463 | 1466 | ||
1464 | - FPGA Support: CONFIG_FPGA | 1467 | - FPGA Support: CONFIG_FPGA |
1465 | 1468 | ||
1466 | Enables FPGA subsystem. | 1469 | Enables FPGA subsystem. |
1467 | 1470 | ||
1468 | CONFIG_FPGA_<vendor> | 1471 | CONFIG_FPGA_<vendor> |
1469 | 1472 | ||
1470 | Enables support for specific chip vendors. | 1473 | Enables support for specific chip vendors. |
1471 | (ALTERA, XILINX) | 1474 | (ALTERA, XILINX) |
1472 | 1475 | ||
1473 | CONFIG_FPGA_<family> | 1476 | CONFIG_FPGA_<family> |
1474 | 1477 | ||
1475 | Enables support for FPGA family. | 1478 | Enables support for FPGA family. |
1476 | (SPARTAN2, SPARTAN3, VIRTEX2, CYCLONE2, ACEX1K, ACEX) | 1479 | (SPARTAN2, SPARTAN3, VIRTEX2, CYCLONE2, ACEX1K, ACEX) |
1477 | 1480 | ||
1478 | CONFIG_FPGA_COUNT | 1481 | CONFIG_FPGA_COUNT |
1479 | 1482 | ||
1480 | Specify the number of FPGA devices to support. | 1483 | Specify the number of FPGA devices to support. |
1481 | 1484 | ||
1482 | CFG_FPGA_PROG_FEEDBACK | 1485 | CFG_FPGA_PROG_FEEDBACK |
1483 | 1486 | ||
1484 | Enable printing of hash marks during FPGA configuration. | 1487 | Enable printing of hash marks during FPGA configuration. |
1485 | 1488 | ||
1486 | CFG_FPGA_CHECK_BUSY | 1489 | CFG_FPGA_CHECK_BUSY |
1487 | 1490 | ||
1488 | Enable checks on FPGA configuration interface busy | 1491 | Enable checks on FPGA configuration interface busy |
1489 | status by the configuration function. This option | 1492 | status by the configuration function. This option |
1490 | will require a board or device specific function to | 1493 | will require a board or device specific function to |
1491 | be written. | 1494 | be written. |
1492 | 1495 | ||
1493 | CONFIG_FPGA_DELAY | 1496 | CONFIG_FPGA_DELAY |
1494 | 1497 | ||
1495 | If defined, a function that provides delays in the FPGA | 1498 | If defined, a function that provides delays in the FPGA |
1496 | configuration driver. | 1499 | configuration driver. |
1497 | 1500 | ||
1498 | CFG_FPGA_CHECK_CTRLC | 1501 | CFG_FPGA_CHECK_CTRLC |
1499 | Allow Control-C to interrupt FPGA configuration | 1502 | Allow Control-C to interrupt FPGA configuration |
1500 | 1503 | ||
1501 | CFG_FPGA_CHECK_ERROR | 1504 | CFG_FPGA_CHECK_ERROR |
1502 | 1505 | ||
1503 | Check for configuration errors during FPGA bitfile | 1506 | Check for configuration errors during FPGA bitfile |
1504 | loading. For example, abort during Virtex II | 1507 | loading. For example, abort during Virtex II |
1505 | configuration if the INIT_B line goes low (which | 1508 | configuration if the INIT_B line goes low (which |
1506 | indicated a CRC error). | 1509 | indicated a CRC error). |
1507 | 1510 | ||
1508 | CFG_FPGA_WAIT_INIT | 1511 | CFG_FPGA_WAIT_INIT |
1509 | 1512 | ||
1510 | Maximum time to wait for the INIT_B line to deassert | 1513 | Maximum time to wait for the INIT_B line to deassert |
1511 | after PROB_B has been deasserted during a Virtex II | 1514 | after PROB_B has been deasserted during a Virtex II |
1512 | FPGA configuration sequence. The default time is 500 | 1515 | FPGA configuration sequence. The default time is 500 |
1513 | ms. | 1516 | ms. |
1514 | 1517 | ||
1515 | CFG_FPGA_WAIT_BUSY | 1518 | CFG_FPGA_WAIT_BUSY |
1516 | 1519 | ||
1517 | Maximum time to wait for BUSY to deassert during | 1520 | Maximum time to wait for BUSY to deassert during |
1518 | Virtex II FPGA configuration. The default is 5 ms. | 1521 | Virtex II FPGA configuration. The default is 5 ms. |
1519 | 1522 | ||
1520 | CFG_FPGA_WAIT_CONFIG | 1523 | CFG_FPGA_WAIT_CONFIG |
1521 | 1524 | ||
1522 | Time to wait after FPGA configuration. The default is | 1525 | Time to wait after FPGA configuration. The default is |
1523 | 200 ms. | 1526 | 200 ms. |
1524 | 1527 | ||
1525 | - Configuration Management: | 1528 | - Configuration Management: |
1526 | CONFIG_IDENT_STRING | 1529 | CONFIG_IDENT_STRING |
1527 | 1530 | ||
1528 | If defined, this string will be added to the U-Boot | 1531 | If defined, this string will be added to the U-Boot |
1529 | version information (U_BOOT_VERSION) | 1532 | version information (U_BOOT_VERSION) |
1530 | 1533 | ||
1531 | - Vendor Parameter Protection: | 1534 | - Vendor Parameter Protection: |
1532 | 1535 | ||
1533 | U-Boot considers the values of the environment | 1536 | U-Boot considers the values of the environment |
1534 | variables "serial#" (Board Serial Number) and | 1537 | variables "serial#" (Board Serial Number) and |
1535 | "ethaddr" (Ethernet Address) to be parameters that | 1538 | "ethaddr" (Ethernet Address) to be parameters that |
1536 | are set once by the board vendor / manufacturer, and | 1539 | are set once by the board vendor / manufacturer, and |
1537 | protects these variables from casual modification by | 1540 | protects these variables from casual modification by |
1538 | the user. Once set, these variables are read-only, | 1541 | the user. Once set, these variables are read-only, |
1539 | and write or delete attempts are rejected. You can | 1542 | and write or delete attempts are rejected. You can |
1540 | change this behaviour: | 1543 | change this behaviour: |
1541 | 1544 | ||
1542 | If CONFIG_ENV_OVERWRITE is #defined in your config | 1545 | If CONFIG_ENV_OVERWRITE is #defined in your config |
1543 | file, the write protection for vendor parameters is | 1546 | file, the write protection for vendor parameters is |
1544 | completely disabled. Anybody can change or delete | 1547 | completely disabled. Anybody can change or delete |
1545 | these parameters. | 1548 | these parameters. |
1546 | 1549 | ||
1547 | Alternatively, if you #define _both_ CONFIG_ETHADDR | 1550 | Alternatively, if you #define _both_ CONFIG_ETHADDR |
1548 | _and_ CONFIG_OVERWRITE_ETHADDR_ONCE, a default | 1551 | _and_ CONFIG_OVERWRITE_ETHADDR_ONCE, a default |
1549 | Ethernet address is installed in the environment, | 1552 | Ethernet address is installed in the environment, |
1550 | which can be changed exactly ONCE by the user. [The | 1553 | which can be changed exactly ONCE by the user. [The |
1551 | serial# is unaffected by this, i. e. it remains | 1554 | serial# is unaffected by this, i. e. it remains |
1552 | read-only.] | 1555 | read-only.] |
1553 | 1556 | ||
1554 | - Protected RAM: | 1557 | - Protected RAM: |
1555 | CONFIG_PRAM | 1558 | CONFIG_PRAM |
1556 | 1559 | ||
1557 | Define this variable to enable the reservation of | 1560 | Define this variable to enable the reservation of |
1558 | "protected RAM", i. e. RAM which is not overwritten | 1561 | "protected RAM", i. e. RAM which is not overwritten |
1559 | by U-Boot. Define CONFIG_PRAM to hold the number of | 1562 | by U-Boot. Define CONFIG_PRAM to hold the number of |
1560 | kB you want to reserve for pRAM. You can overwrite | 1563 | kB you want to reserve for pRAM. You can overwrite |
1561 | this default value by defining an environment | 1564 | this default value by defining an environment |
1562 | variable "pram" to the number of kB you want to | 1565 | variable "pram" to the number of kB you want to |
1563 | reserve. Note that the board info structure will | 1566 | reserve. Note that the board info structure will |
1564 | still show the full amount of RAM. If pRAM is | 1567 | still show the full amount of RAM. If pRAM is |
1565 | reserved, a new environment variable "mem" will | 1568 | reserved, a new environment variable "mem" will |
1566 | automatically be defined to hold the amount of | 1569 | automatically be defined to hold the amount of |
1567 | remaining RAM in a form that can be passed as boot | 1570 | remaining RAM in a form that can be passed as boot |
1568 | argument to Linux, for instance like that: | 1571 | argument to Linux, for instance like that: |
1569 | 1572 | ||
1570 | setenv bootargs ... mem=\${mem} | 1573 | setenv bootargs ... mem=\${mem} |
1571 | saveenv | 1574 | saveenv |
1572 | 1575 | ||
1573 | This way you can tell Linux not to use this memory, | 1576 | This way you can tell Linux not to use this memory, |
1574 | either, which results in a memory region that will | 1577 | either, which results in a memory region that will |
1575 | not be affected by reboots. | 1578 | not be affected by reboots. |
1576 | 1579 | ||
1577 | *WARNING* If your board configuration uses automatic | 1580 | *WARNING* If your board configuration uses automatic |
1578 | detection of the RAM size, you must make sure that | 1581 | detection of the RAM size, you must make sure that |
1579 | this memory test is non-destructive. So far, the | 1582 | this memory test is non-destructive. So far, the |
1580 | following board configurations are known to be | 1583 | following board configurations are known to be |
1581 | "pRAM-clean": | 1584 | "pRAM-clean": |
1582 | 1585 | ||
1583 | ETX094, IVMS8, IVML24, SPD8xx, TQM8xxL, | 1586 | ETX094, IVMS8, IVML24, SPD8xx, TQM8xxL, |
1584 | HERMES, IP860, RPXlite, LWMON, LANTEC, | 1587 | HERMES, IP860, RPXlite, LWMON, LANTEC, |
1585 | PCU_E, FLAGADM, TQM8260 | 1588 | PCU_E, FLAGADM, TQM8260 |
1586 | 1589 | ||
1587 | - Error Recovery: | 1590 | - Error Recovery: |
1588 | CONFIG_PANIC_HANG | 1591 | CONFIG_PANIC_HANG |
1589 | 1592 | ||
1590 | Define this variable to stop the system in case of a | 1593 | Define this variable to stop the system in case of a |
1591 | fatal error, so that you have to reset it manually. | 1594 | fatal error, so that you have to reset it manually. |
1592 | This is probably NOT a good idea for an embedded | 1595 | This is probably NOT a good idea for an embedded |
1593 | system where you want the system to reboot | 1596 | system where you want the system to reboot |
1594 | automatically as fast as possible, but it may be | 1597 | automatically as fast as possible, but it may be |
1595 | useful during development since you can try to debug | 1598 | useful during development since you can try to debug |
1596 | the conditions that lead to the situation. | 1599 | the conditions that lead to the situation. |
1597 | 1600 | ||
1598 | CONFIG_NET_RETRY_COUNT | 1601 | CONFIG_NET_RETRY_COUNT |
1599 | 1602 | ||
1600 | This variable defines the number of retries for | 1603 | This variable defines the number of retries for |
1601 | network operations like ARP, RARP, TFTP, or BOOTP | 1604 | network operations like ARP, RARP, TFTP, or BOOTP |
1602 | before giving up the operation. If not defined, a | 1605 | before giving up the operation. If not defined, a |
1603 | default value of 5 is used. | 1606 | default value of 5 is used. |
1604 | 1607 | ||
1605 | CONFIG_ARP_TIMEOUT | 1608 | CONFIG_ARP_TIMEOUT |
1606 | 1609 | ||
1607 | Timeout waiting for an ARP reply in milliseconds. | 1610 | Timeout waiting for an ARP reply in milliseconds. |
1608 | 1611 | ||
1609 | - Command Interpreter: | 1612 | - Command Interpreter: |
1610 | CONFIG_AUTO_COMPLETE | 1613 | CONFIG_AUTO_COMPLETE |
1611 | 1614 | ||
1612 | Enable auto completion of commands using TAB. | 1615 | Enable auto completion of commands using TAB. |
1613 | 1616 | ||
1614 | Note that this feature has NOT been implemented yet | 1617 | Note that this feature has NOT been implemented yet |
1615 | for the "hush" shell. | 1618 | for the "hush" shell. |
1616 | 1619 | ||
1617 | 1620 | ||
1618 | CFG_HUSH_PARSER | 1621 | CFG_HUSH_PARSER |
1619 | 1622 | ||
1620 | Define this variable to enable the "hush" shell (from | 1623 | Define this variable to enable the "hush" shell (from |
1621 | Busybox) as command line interpreter, thus enabling | 1624 | Busybox) as command line interpreter, thus enabling |
1622 | powerful command line syntax like | 1625 | powerful command line syntax like |
1623 | if...then...else...fi conditionals or `&&' and '||' | 1626 | if...then...else...fi conditionals or `&&' and '||' |
1624 | constructs ("shell scripts"). | 1627 | constructs ("shell scripts"). |
1625 | 1628 | ||
1626 | If undefined, you get the old, much simpler behaviour | 1629 | If undefined, you get the old, much simpler behaviour |
1627 | with a somewhat smaller memory footprint. | 1630 | with a somewhat smaller memory footprint. |
1628 | 1631 | ||
1629 | 1632 | ||
1630 | CFG_PROMPT_HUSH_PS2 | 1633 | CFG_PROMPT_HUSH_PS2 |
1631 | 1634 | ||
1632 | This defines the secondary prompt string, which is | 1635 | This defines the secondary prompt string, which is |
1633 | printed when the command interpreter needs more input | 1636 | printed when the command interpreter needs more input |
1634 | to complete a command. Usually "> ". | 1637 | to complete a command. Usually "> ". |
1635 | 1638 | ||
1636 | Note: | 1639 | Note: |
1637 | 1640 | ||
1638 | In the current implementation, the local variables | 1641 | In the current implementation, the local variables |
1639 | space and global environment variables space are | 1642 | space and global environment variables space are |
1640 | separated. Local variables are those you define by | 1643 | separated. Local variables are those you define by |
1641 | simply typing `name=value'. To access a local | 1644 | simply typing `name=value'. To access a local |
1642 | variable later on, you have write `$name' or | 1645 | variable later on, you have write `$name' or |
1643 | `${name}'; to execute the contents of a variable | 1646 | `${name}'; to execute the contents of a variable |
1644 | directly type `$name' at the command prompt. | 1647 | directly type `$name' at the command prompt. |
1645 | 1648 | ||
1646 | Global environment variables are those you use | 1649 | Global environment variables are those you use |
1647 | setenv/printenv to work with. To run a command stored | 1650 | setenv/printenv to work with. To run a command stored |
1648 | in such a variable, you need to use the run command, | 1651 | in such a variable, you need to use the run command, |
1649 | and you must not use the '$' sign to access them. | 1652 | and you must not use the '$' sign to access them. |
1650 | 1653 | ||
1651 | To store commands and special characters in a | 1654 | To store commands and special characters in a |
1652 | variable, please use double quotation marks | 1655 | variable, please use double quotation marks |
1653 | surrounding the whole text of the variable, instead | 1656 | surrounding the whole text of the variable, instead |
1654 | of the backslashes before semicolons and special | 1657 | of the backslashes before semicolons and special |
1655 | symbols. | 1658 | symbols. |
1656 | 1659 | ||
1657 | - Commandline Editing and History: | 1660 | - Commandline Editing and History: |
1658 | CONFIG_CMDLINE_EDITING | 1661 | CONFIG_CMDLINE_EDITING |
1659 | 1662 | ||
1660 | Enable editing and History functions for interactive | 1663 | Enable editing and History functions for interactive |
1661 | commandline input operations | 1664 | commandline input operations |
1662 | 1665 | ||
1663 | - Default Environment: | 1666 | - Default Environment: |
1664 | CONFIG_EXTRA_ENV_SETTINGS | 1667 | CONFIG_EXTRA_ENV_SETTINGS |
1665 | 1668 | ||
1666 | Define this to contain any number of null terminated | 1669 | Define this to contain any number of null terminated |
1667 | strings (variable = value pairs) that will be part of | 1670 | strings (variable = value pairs) that will be part of |
1668 | the default environment compiled into the boot image. | 1671 | the default environment compiled into the boot image. |
1669 | 1672 | ||
1670 | For example, place something like this in your | 1673 | For example, place something like this in your |
1671 | board's config file: | 1674 | board's config file: |
1672 | 1675 | ||
1673 | #define CONFIG_EXTRA_ENV_SETTINGS \ | 1676 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
1674 | "myvar1=value1\0" \ | 1677 | "myvar1=value1\0" \ |
1675 | "myvar2=value2\0" | 1678 | "myvar2=value2\0" |
1676 | 1679 | ||
1677 | Warning: This method is based on knowledge about the | 1680 | Warning: This method is based on knowledge about the |
1678 | internal format how the environment is stored by the | 1681 | internal format how the environment is stored by the |
1679 | U-Boot code. This is NOT an official, exported | 1682 | U-Boot code. This is NOT an official, exported |
1680 | interface! Although it is unlikely that this format | 1683 | interface! Although it is unlikely that this format |
1681 | will change soon, there is no guarantee either. | 1684 | will change soon, there is no guarantee either. |
1682 | You better know what you are doing here. | 1685 | You better know what you are doing here. |
1683 | 1686 | ||
1684 | Note: overly (ab)use of the default environment is | 1687 | Note: overly (ab)use of the default environment is |
1685 | discouraged. Make sure to check other ways to preset | 1688 | discouraged. Make sure to check other ways to preset |
1686 | the environment like the autoscript function or the | 1689 | the environment like the autoscript function or the |
1687 | boot command first. | 1690 | boot command first. |
1688 | 1691 | ||
1689 | - DataFlash Support: | 1692 | - DataFlash Support: |
1690 | CONFIG_HAS_DATAFLASH | 1693 | CONFIG_HAS_DATAFLASH |
1691 | 1694 | ||
1692 | Defining this option enables DataFlash features and | 1695 | Defining this option enables DataFlash features and |
1693 | allows to read/write in Dataflash via the standard | 1696 | allows to read/write in Dataflash via the standard |
1694 | commands cp, md... | 1697 | commands cp, md... |
1695 | 1698 | ||
1696 | - SystemACE Support: | 1699 | - SystemACE Support: |
1697 | CONFIG_SYSTEMACE | 1700 | CONFIG_SYSTEMACE |
1698 | 1701 | ||
1699 | Adding this option adds support for Xilinx SystemACE | 1702 | Adding this option adds support for Xilinx SystemACE |
1700 | chips attached via some sort of local bus. The address | 1703 | chips attached via some sort of local bus. The address |
1701 | of the chip must also be defined in the | 1704 | of the chip must also be defined in the |
1702 | CFG_SYSTEMACE_BASE macro. For example: | 1705 | CFG_SYSTEMACE_BASE macro. For example: |
1703 | 1706 | ||
1704 | #define CONFIG_SYSTEMACE | 1707 | #define CONFIG_SYSTEMACE |
1705 | #define CFG_SYSTEMACE_BASE 0xf0000000 | 1708 | #define CFG_SYSTEMACE_BASE 0xf0000000 |
1706 | 1709 | ||
1707 | When SystemACE support is added, the "ace" device type | 1710 | When SystemACE support is added, the "ace" device type |
1708 | becomes available to the fat commands, i.e. fatls. | 1711 | becomes available to the fat commands, i.e. fatls. |
1709 | 1712 | ||
1710 | - TFTP Fixed UDP Port: | 1713 | - TFTP Fixed UDP Port: |
1711 | CONFIG_TFTP_PORT | 1714 | CONFIG_TFTP_PORT |
1712 | 1715 | ||
1713 | If this is defined, the environment variable tftpsrcp | 1716 | If this is defined, the environment variable tftpsrcp |
1714 | is used to supply the TFTP UDP source port value. | 1717 | is used to supply the TFTP UDP source port value. |
1715 | If tftpsrcp isn't defined, the normal pseudo-random port | 1718 | If tftpsrcp isn't defined, the normal pseudo-random port |
1716 | number generator is used. | 1719 | number generator is used. |
1717 | 1720 | ||
1718 | Also, the environment variable tftpdstp is used to supply | 1721 | Also, the environment variable tftpdstp is used to supply |
1719 | the TFTP UDP destination port value. If tftpdstp isn't | 1722 | the TFTP UDP destination port value. If tftpdstp isn't |
1720 | defined, the normal port 69 is used. | 1723 | defined, the normal port 69 is used. |
1721 | 1724 | ||
1722 | The purpose for tftpsrcp is to allow a TFTP server to | 1725 | The purpose for tftpsrcp is to allow a TFTP server to |
1723 | blindly start the TFTP transfer using the pre-configured | 1726 | blindly start the TFTP transfer using the pre-configured |
1724 | target IP address and UDP port. This has the effect of | 1727 | target IP address and UDP port. This has the effect of |
1725 | "punching through" the (Windows XP) firewall, allowing | 1728 | "punching through" the (Windows XP) firewall, allowing |
1726 | the remainder of the TFTP transfer to proceed normally. | 1729 | the remainder of the TFTP transfer to proceed normally. |
1727 | A better solution is to properly configure the firewall, | 1730 | A better solution is to properly configure the firewall, |
1728 | but sometimes that is not allowed. | 1731 | but sometimes that is not allowed. |
1729 | 1732 | ||
1730 | - Show boot progress: | 1733 | - Show boot progress: |
1731 | CONFIG_SHOW_BOOT_PROGRESS | 1734 | CONFIG_SHOW_BOOT_PROGRESS |
1732 | 1735 | ||
1733 | Defining this option allows to add some board- | 1736 | Defining this option allows to add some board- |
1734 | specific code (calling a user-provided function | 1737 | specific code (calling a user-provided function |
1735 | "show_boot_progress(int)") that enables you to show | 1738 | "show_boot_progress(int)") that enables you to show |
1736 | the system's boot progress on some display (for | 1739 | the system's boot progress on some display (for |
1737 | example, some LED's) on your board. At the moment, | 1740 | example, some LED's) on your board. At the moment, |
1738 | the following checkpoints are implemented: | 1741 | the following checkpoints are implemented: |
1739 | 1742 | ||
1740 | Legacy uImage format: | 1743 | Legacy uImage format: |
1741 | 1744 | ||
1742 | Arg Where When | 1745 | Arg Where When |
1743 | 1 common/cmd_bootm.c before attempting to boot an image | 1746 | 1 common/cmd_bootm.c before attempting to boot an image |
1744 | -1 common/cmd_bootm.c Image header has bad magic number | 1747 | -1 common/cmd_bootm.c Image header has bad magic number |
1745 | 2 common/cmd_bootm.c Image header has correct magic number | 1748 | 2 common/cmd_bootm.c Image header has correct magic number |
1746 | -2 common/cmd_bootm.c Image header has bad checksum | 1749 | -2 common/cmd_bootm.c Image header has bad checksum |
1747 | 3 common/cmd_bootm.c Image header has correct checksum | 1750 | 3 common/cmd_bootm.c Image header has correct checksum |
1748 | -3 common/cmd_bootm.c Image data has bad checksum | 1751 | -3 common/cmd_bootm.c Image data has bad checksum |
1749 | 4 common/cmd_bootm.c Image data has correct checksum | 1752 | 4 common/cmd_bootm.c Image data has correct checksum |
1750 | -4 common/cmd_bootm.c Image is for unsupported architecture | 1753 | -4 common/cmd_bootm.c Image is for unsupported architecture |
1751 | 5 common/cmd_bootm.c Architecture check OK | 1754 | 5 common/cmd_bootm.c Architecture check OK |
1752 | -5 common/cmd_bootm.c Wrong Image Type (not kernel, multi) | 1755 | -5 common/cmd_bootm.c Wrong Image Type (not kernel, multi) |
1753 | 6 common/cmd_bootm.c Image Type check OK | 1756 | 6 common/cmd_bootm.c Image Type check OK |
1754 | -6 common/cmd_bootm.c gunzip uncompression error | 1757 | -6 common/cmd_bootm.c gunzip uncompression error |
1755 | -7 common/cmd_bootm.c Unimplemented compression type | 1758 | -7 common/cmd_bootm.c Unimplemented compression type |
1756 | 7 common/cmd_bootm.c Uncompression OK | 1759 | 7 common/cmd_bootm.c Uncompression OK |
1757 | 8 common/cmd_bootm.c No uncompress/copy overwrite error | 1760 | 8 common/cmd_bootm.c No uncompress/copy overwrite error |
1758 | -9 common/cmd_bootm.c Unsupported OS (not Linux, BSD, VxWorks, QNX) | 1761 | -9 common/cmd_bootm.c Unsupported OS (not Linux, BSD, VxWorks, QNX) |
1759 | 1762 | ||
1760 | 9 common/image.c Start initial ramdisk verification | 1763 | 9 common/image.c Start initial ramdisk verification |
1761 | -10 common/image.c Ramdisk header has bad magic number | 1764 | -10 common/image.c Ramdisk header has bad magic number |
1762 | -11 common/image.c Ramdisk header has bad checksum | 1765 | -11 common/image.c Ramdisk header has bad checksum |
1763 | 10 common/image.c Ramdisk header is OK | 1766 | 10 common/image.c Ramdisk header is OK |
1764 | -12 common/image.c Ramdisk data has bad checksum | 1767 | -12 common/image.c Ramdisk data has bad checksum |
1765 | 11 common/image.c Ramdisk data has correct checksum | 1768 | 11 common/image.c Ramdisk data has correct checksum |
1766 | 12 common/image.c Ramdisk verification complete, start loading | 1769 | 12 common/image.c Ramdisk verification complete, start loading |
1767 | -13 common/image.c Wrong Image Type (not PPC Linux ramdisk) | 1770 | -13 common/image.c Wrong Image Type (not PPC Linux ramdisk) |
1768 | 13 common/image.c Start multifile image verification | 1771 | 13 common/image.c Start multifile image verification |
1769 | 14 common/image.c No initial ramdisk, no multifile, continue. | 1772 | 14 common/image.c No initial ramdisk, no multifile, continue. |
1770 | 1773 | ||
1771 | 15 lib_<arch>/bootm.c All preparation done, transferring control to OS | 1774 | 15 lib_<arch>/bootm.c All preparation done, transferring control to OS |
1772 | 1775 | ||
1773 | -30 lib_ppc/board.c Fatal error, hang the system | 1776 | -30 lib_ppc/board.c Fatal error, hang the system |
1774 | -31 post/post.c POST test failed, detected by post_output_backlog() | 1777 | -31 post/post.c POST test failed, detected by post_output_backlog() |
1775 | -32 post/post.c POST test failed, detected by post_run_single() | 1778 | -32 post/post.c POST test failed, detected by post_run_single() |
1776 | 1779 | ||
1777 | 34 common/cmd_doc.c before loading a Image from a DOC device | 1780 | 34 common/cmd_doc.c before loading a Image from a DOC device |
1778 | -35 common/cmd_doc.c Bad usage of "doc" command | 1781 | -35 common/cmd_doc.c Bad usage of "doc" command |
1779 | 35 common/cmd_doc.c correct usage of "doc" command | 1782 | 35 common/cmd_doc.c correct usage of "doc" command |
1780 | -36 common/cmd_doc.c No boot device | 1783 | -36 common/cmd_doc.c No boot device |
1781 | 36 common/cmd_doc.c correct boot device | 1784 | 36 common/cmd_doc.c correct boot device |
1782 | -37 common/cmd_doc.c Unknown Chip ID on boot device | 1785 | -37 common/cmd_doc.c Unknown Chip ID on boot device |
1783 | 37 common/cmd_doc.c correct chip ID found, device available | 1786 | 37 common/cmd_doc.c correct chip ID found, device available |
1784 | -38 common/cmd_doc.c Read Error on boot device | 1787 | -38 common/cmd_doc.c Read Error on boot device |
1785 | 38 common/cmd_doc.c reading Image header from DOC device OK | 1788 | 38 common/cmd_doc.c reading Image header from DOC device OK |
1786 | -39 common/cmd_doc.c Image header has bad magic number | 1789 | -39 common/cmd_doc.c Image header has bad magic number |
1787 | 39 common/cmd_doc.c Image header has correct magic number | 1790 | 39 common/cmd_doc.c Image header has correct magic number |
1788 | -40 common/cmd_doc.c Error reading Image from DOC device | 1791 | -40 common/cmd_doc.c Error reading Image from DOC device |
1789 | 40 common/cmd_doc.c Image header has correct magic number | 1792 | 40 common/cmd_doc.c Image header has correct magic number |
1790 | 41 common/cmd_ide.c before loading a Image from a IDE device | 1793 | 41 common/cmd_ide.c before loading a Image from a IDE device |
1791 | -42 common/cmd_ide.c Bad usage of "ide" command | 1794 | -42 common/cmd_ide.c Bad usage of "ide" command |
1792 | 42 common/cmd_ide.c correct usage of "ide" command | 1795 | 42 common/cmd_ide.c correct usage of "ide" command |
1793 | -43 common/cmd_ide.c No boot device | 1796 | -43 common/cmd_ide.c No boot device |
1794 | 43 common/cmd_ide.c boot device found | 1797 | 43 common/cmd_ide.c boot device found |
1795 | -44 common/cmd_ide.c Device not available | 1798 | -44 common/cmd_ide.c Device not available |
1796 | 44 common/cmd_ide.c Device available | 1799 | 44 common/cmd_ide.c Device available |
1797 | -45 common/cmd_ide.c wrong partition selected | 1800 | -45 common/cmd_ide.c wrong partition selected |
1798 | 45 common/cmd_ide.c partition selected | 1801 | 45 common/cmd_ide.c partition selected |
1799 | -46 common/cmd_ide.c Unknown partition table | 1802 | -46 common/cmd_ide.c Unknown partition table |
1800 | 46 common/cmd_ide.c valid partition table found | 1803 | 46 common/cmd_ide.c valid partition table found |
1801 | -47 common/cmd_ide.c Invalid partition type | 1804 | -47 common/cmd_ide.c Invalid partition type |
1802 | 47 common/cmd_ide.c correct partition type | 1805 | 47 common/cmd_ide.c correct partition type |
1803 | -48 common/cmd_ide.c Error reading Image Header on boot device | 1806 | -48 common/cmd_ide.c Error reading Image Header on boot device |
1804 | 48 common/cmd_ide.c reading Image Header from IDE device OK | 1807 | 48 common/cmd_ide.c reading Image Header from IDE device OK |
1805 | -49 common/cmd_ide.c Image header has bad magic number | 1808 | -49 common/cmd_ide.c Image header has bad magic number |
1806 | 49 common/cmd_ide.c Image header has correct magic number | 1809 | 49 common/cmd_ide.c Image header has correct magic number |
1807 | -50 common/cmd_ide.c Image header has bad checksum | 1810 | -50 common/cmd_ide.c Image header has bad checksum |
1808 | 50 common/cmd_ide.c Image header has correct checksum | 1811 | 50 common/cmd_ide.c Image header has correct checksum |
1809 | -51 common/cmd_ide.c Error reading Image from IDE device | 1812 | -51 common/cmd_ide.c Error reading Image from IDE device |
1810 | 51 common/cmd_ide.c reading Image from IDE device OK | 1813 | 51 common/cmd_ide.c reading Image from IDE device OK |
1811 | 52 common/cmd_nand.c before loading a Image from a NAND device | 1814 | 52 common/cmd_nand.c before loading a Image from a NAND device |
1812 | -53 common/cmd_nand.c Bad usage of "nand" command | 1815 | -53 common/cmd_nand.c Bad usage of "nand" command |
1813 | 53 common/cmd_nand.c correct usage of "nand" command | 1816 | 53 common/cmd_nand.c correct usage of "nand" command |
1814 | -54 common/cmd_nand.c No boot device | 1817 | -54 common/cmd_nand.c No boot device |
1815 | 54 common/cmd_nand.c boot device found | 1818 | 54 common/cmd_nand.c boot device found |
1816 | -55 common/cmd_nand.c Unknown Chip ID on boot device | 1819 | -55 common/cmd_nand.c Unknown Chip ID on boot device |
1817 | 55 common/cmd_nand.c correct chip ID found, device available | 1820 | 55 common/cmd_nand.c correct chip ID found, device available |
1818 | -56 common/cmd_nand.c Error reading Image Header on boot device | 1821 | -56 common/cmd_nand.c Error reading Image Header on boot device |
1819 | 56 common/cmd_nand.c reading Image Header from NAND device OK | 1822 | 56 common/cmd_nand.c reading Image Header from NAND device OK |
1820 | -57 common/cmd_nand.c Image header has bad magic number | 1823 | -57 common/cmd_nand.c Image header has bad magic number |
1821 | 57 common/cmd_nand.c Image header has correct magic number | 1824 | 57 common/cmd_nand.c Image header has correct magic number |
1822 | -58 common/cmd_nand.c Error reading Image from NAND device | 1825 | -58 common/cmd_nand.c Error reading Image from NAND device |
1823 | 58 common/cmd_nand.c reading Image from NAND device OK | 1826 | 58 common/cmd_nand.c reading Image from NAND device OK |
1824 | 1827 | ||
1825 | -60 common/env_common.c Environment has a bad CRC, using default | 1828 | -60 common/env_common.c Environment has a bad CRC, using default |
1826 | 1829 | ||
1827 | 64 net/eth.c starting with Ethernet configuration. | 1830 | 64 net/eth.c starting with Ethernet configuration. |
1828 | -64 net/eth.c no Ethernet found. | 1831 | -64 net/eth.c no Ethernet found. |
1829 | 65 net/eth.c Ethernet found. | 1832 | 65 net/eth.c Ethernet found. |
1830 | 1833 | ||
1831 | -80 common/cmd_net.c usage wrong | 1834 | -80 common/cmd_net.c usage wrong |
1832 | 80 common/cmd_net.c before calling NetLoop() | 1835 | 80 common/cmd_net.c before calling NetLoop() |
1833 | -81 common/cmd_net.c some error in NetLoop() occurred | 1836 | -81 common/cmd_net.c some error in NetLoop() occurred |
1834 | 81 common/cmd_net.c NetLoop() back without error | 1837 | 81 common/cmd_net.c NetLoop() back without error |
1835 | -82 common/cmd_net.c size == 0 (File with size 0 loaded) | 1838 | -82 common/cmd_net.c size == 0 (File with size 0 loaded) |
1836 | 82 common/cmd_net.c trying automatic boot | 1839 | 82 common/cmd_net.c trying automatic boot |
1837 | 83 common/cmd_net.c running autoscript | 1840 | 83 common/cmd_net.c running autoscript |
1838 | -83 common/cmd_net.c some error in automatic boot or autoscript | 1841 | -83 common/cmd_net.c some error in automatic boot or autoscript |
1839 | 84 common/cmd_net.c end without errors | 1842 | 84 common/cmd_net.c end without errors |
1840 | 1843 | ||
1841 | FIT uImage format: | 1844 | FIT uImage format: |
1842 | 1845 | ||
1843 | Arg Where When | 1846 | Arg Where When |
1844 | 100 common/cmd_bootm.c Kernel FIT Image has correct format | 1847 | 100 common/cmd_bootm.c Kernel FIT Image has correct format |
1845 | -100 common/cmd_bootm.c Kernel FIT Image has incorrect format | 1848 | -100 common/cmd_bootm.c Kernel FIT Image has incorrect format |
1846 | 101 common/cmd_bootm.c No Kernel subimage unit name, using configuration | 1849 | 101 common/cmd_bootm.c No Kernel subimage unit name, using configuration |
1847 | -101 common/cmd_bootm.c Can't get configuration for kernel subimage | 1850 | -101 common/cmd_bootm.c Can't get configuration for kernel subimage |
1848 | 102 common/cmd_bootm.c Kernel unit name specified | 1851 | 102 common/cmd_bootm.c Kernel unit name specified |
1849 | -103 common/cmd_bootm.c Can't get kernel subimage node offset | 1852 | -103 common/cmd_bootm.c Can't get kernel subimage node offset |
1850 | 103 common/cmd_bootm.c Found configuration node | 1853 | 103 common/cmd_bootm.c Found configuration node |
1851 | 104 common/cmd_bootm.c Got kernel subimage node offset | 1854 | 104 common/cmd_bootm.c Got kernel subimage node offset |
1852 | -104 common/cmd_bootm.c Kernel subimage hash verification failed | 1855 | -104 common/cmd_bootm.c Kernel subimage hash verification failed |
1853 | 105 common/cmd_bootm.c Kernel subimage hash verification OK | 1856 | 105 common/cmd_bootm.c Kernel subimage hash verification OK |
1854 | -105 common/cmd_bootm.c Kernel subimage is for unsupported architecture | 1857 | -105 common/cmd_bootm.c Kernel subimage is for unsupported architecture |
1855 | 106 common/cmd_bootm.c Architecture check OK | 1858 | 106 common/cmd_bootm.c Architecture check OK |
1856 | -106 common/cmd_bootm.c Kernel subimage has wrong type | 1859 | -106 common/cmd_bootm.c Kernel subimage has wrong type |
1857 | 107 common/cmd_bootm.c Kernel subimage type OK | 1860 | 107 common/cmd_bootm.c Kernel subimage type OK |
1858 | -107 common/cmd_bootm.c Can't get kernel subimage data/size | 1861 | -107 common/cmd_bootm.c Can't get kernel subimage data/size |
1859 | 108 common/cmd_bootm.c Got kernel subimage data/size | 1862 | 108 common/cmd_bootm.c Got kernel subimage data/size |
1860 | -108 common/cmd_bootm.c Wrong image type (not legacy, FIT) | 1863 | -108 common/cmd_bootm.c Wrong image type (not legacy, FIT) |
1861 | -109 common/cmd_bootm.c Can't get kernel subimage type | 1864 | -109 common/cmd_bootm.c Can't get kernel subimage type |
1862 | -110 common/cmd_bootm.c Can't get kernel subimage comp | 1865 | -110 common/cmd_bootm.c Can't get kernel subimage comp |
1863 | -111 common/cmd_bootm.c Can't get kernel subimage os | 1866 | -111 common/cmd_bootm.c Can't get kernel subimage os |
1864 | -112 common/cmd_bootm.c Can't get kernel subimage load address | 1867 | -112 common/cmd_bootm.c Can't get kernel subimage load address |
1865 | -113 common/cmd_bootm.c Image uncompress/copy overwrite error | 1868 | -113 common/cmd_bootm.c Image uncompress/copy overwrite error |
1866 | 1869 | ||
1867 | 120 common/image.c Start initial ramdisk verification | 1870 | 120 common/image.c Start initial ramdisk verification |
1868 | -120 common/image.c Ramdisk FIT image has incorrect format | 1871 | -120 common/image.c Ramdisk FIT image has incorrect format |
1869 | 121 common/image.c Ramdisk FIT image has correct format | 1872 | 121 common/image.c Ramdisk FIT image has correct format |
1870 | 122 common/image.c No ramdisk subimage unit name, using configuration | 1873 | 122 common/image.c No ramdisk subimage unit name, using configuration |
1871 | -122 common/image.c Can't get configuration for ramdisk subimage | 1874 | -122 common/image.c Can't get configuration for ramdisk subimage |
1872 | 123 common/image.c Ramdisk unit name specified | 1875 | 123 common/image.c Ramdisk unit name specified |
1873 | -124 common/image.c Can't get ramdisk subimage node offset | 1876 | -124 common/image.c Can't get ramdisk subimage node offset |
1874 | 125 common/image.c Got ramdisk subimage node offset | 1877 | 125 common/image.c Got ramdisk subimage node offset |
1875 | -125 common/image.c Ramdisk subimage hash verification failed | 1878 | -125 common/image.c Ramdisk subimage hash verification failed |
1876 | 126 common/image.c Ramdisk subimage hash verification OK | 1879 | 126 common/image.c Ramdisk subimage hash verification OK |
1877 | -126 common/image.c Ramdisk subimage for unsupported architecture | 1880 | -126 common/image.c Ramdisk subimage for unsupported architecture |
1878 | 127 common/image.c Architecture check OK | 1881 | 127 common/image.c Architecture check OK |
1879 | -127 common/image.c Can't get ramdisk subimage data/size | 1882 | -127 common/image.c Can't get ramdisk subimage data/size |
1880 | 128 common/image.c Got ramdisk subimage data/size | 1883 | 128 common/image.c Got ramdisk subimage data/size |
1881 | 129 common/image.c Can't get ramdisk load address | 1884 | 129 common/image.c Can't get ramdisk load address |
1882 | -129 common/image.c Got ramdisk load address | 1885 | -129 common/image.c Got ramdisk load address |
1883 | 1886 | ||
1884 | -130 common/cmd_doc.c Incorrect FIT image format | 1887 | -130 common/cmd_doc.c Incorrect FIT image format |
1885 | 131 common/cmd_doc.c FIT image format OK | 1888 | 131 common/cmd_doc.c FIT image format OK |
1886 | 1889 | ||
1887 | -140 common/cmd_ide.c Incorrect FIT image format | 1890 | -140 common/cmd_ide.c Incorrect FIT image format |
1888 | 141 common/cmd_ide.c FIT image format OK | 1891 | 141 common/cmd_ide.c FIT image format OK |
1889 | 1892 | ||
1890 | -150 common/cmd_nand.c Incorrect FIT image format | 1893 | -150 common/cmd_nand.c Incorrect FIT image format |
1891 | 151 common/cmd_nand.c FIT image format OK | 1894 | 151 common/cmd_nand.c FIT image format OK |
1892 | 1895 | ||
1893 | 1896 | ||
1894 | Modem Support: | 1897 | Modem Support: |
1895 | -------------- | 1898 | -------------- |
1896 | 1899 | ||
1897 | [so far only for SMDK2400 and TRAB boards] | 1900 | [so far only for SMDK2400 and TRAB boards] |
1898 | 1901 | ||
1899 | - Modem support enable: | 1902 | - Modem support enable: |
1900 | CONFIG_MODEM_SUPPORT | 1903 | CONFIG_MODEM_SUPPORT |
1901 | 1904 | ||
1902 | - RTS/CTS Flow control enable: | 1905 | - RTS/CTS Flow control enable: |
1903 | CONFIG_HWFLOW | 1906 | CONFIG_HWFLOW |
1904 | 1907 | ||
1905 | - Modem debug support: | 1908 | - Modem debug support: |
1906 | CONFIG_MODEM_SUPPORT_DEBUG | 1909 | CONFIG_MODEM_SUPPORT_DEBUG |
1907 | 1910 | ||
1908 | Enables debugging stuff (char screen[1024], dbg()) | 1911 | Enables debugging stuff (char screen[1024], dbg()) |
1909 | for modem support. Useful only with BDI2000. | 1912 | for modem support. Useful only with BDI2000. |
1910 | 1913 | ||
1911 | - Interrupt support (PPC): | 1914 | - Interrupt support (PPC): |
1912 | 1915 | ||
1913 | There are common interrupt_init() and timer_interrupt() | 1916 | There are common interrupt_init() and timer_interrupt() |
1914 | for all PPC archs. interrupt_init() calls interrupt_init_cpu() | 1917 | for all PPC archs. interrupt_init() calls interrupt_init_cpu() |
1915 | for CPU specific initialization. interrupt_init_cpu() | 1918 | for CPU specific initialization. interrupt_init_cpu() |
1916 | should set decrementer_count to appropriate value. If | 1919 | should set decrementer_count to appropriate value. If |
1917 | CPU resets decrementer automatically after interrupt | 1920 | CPU resets decrementer automatically after interrupt |
1918 | (ppc4xx) it should set decrementer_count to zero. | 1921 | (ppc4xx) it should set decrementer_count to zero. |
1919 | timer_interrupt() calls timer_interrupt_cpu() for CPU | 1922 | timer_interrupt() calls timer_interrupt_cpu() for CPU |
1920 | specific handling. If board has watchdog / status_led | 1923 | specific handling. If board has watchdog / status_led |
1921 | / other_activity_monitor it works automatically from | 1924 | / other_activity_monitor it works automatically from |
1922 | general timer_interrupt(). | 1925 | general timer_interrupt(). |
1923 | 1926 | ||
1924 | - General: | 1927 | - General: |
1925 | 1928 | ||
1926 | In the target system modem support is enabled when a | 1929 | In the target system modem support is enabled when a |
1927 | specific key (key combination) is pressed during | 1930 | specific key (key combination) is pressed during |
1928 | power-on. Otherwise U-Boot will boot normally | 1931 | power-on. Otherwise U-Boot will boot normally |
1929 | (autoboot). The key_pressed() function is called from | 1932 | (autoboot). The key_pressed() function is called from |
1930 | board_init(). Currently key_pressed() is a dummy | 1933 | board_init(). Currently key_pressed() is a dummy |
1931 | function, returning 1 and thus enabling modem | 1934 | function, returning 1 and thus enabling modem |
1932 | initialization. | 1935 | initialization. |
1933 | 1936 | ||
1934 | If there are no modem init strings in the | 1937 | If there are no modem init strings in the |
1935 | environment, U-Boot proceed to autoboot; the | 1938 | environment, U-Boot proceed to autoboot; the |
1936 | previous output (banner, info printfs) will be | 1939 | previous output (banner, info printfs) will be |
1937 | suppressed, though. | 1940 | suppressed, though. |
1938 | 1941 | ||
1939 | See also: doc/README.Modem | 1942 | See also: doc/README.Modem |
1940 | 1943 | ||
1941 | 1944 | ||
1942 | Configuration Settings: | 1945 | Configuration Settings: |
1943 | ----------------------- | 1946 | ----------------------- |
1944 | 1947 | ||
1945 | - CFG_LONGHELP: Defined when you want long help messages included; | 1948 | - CFG_LONGHELP: Defined when you want long help messages included; |
1946 | undefine this when you're short of memory. | 1949 | undefine this when you're short of memory. |
1947 | 1950 | ||
1948 | - CFG_PROMPT: This is what U-Boot prints on the console to | 1951 | - CFG_PROMPT: This is what U-Boot prints on the console to |
1949 | prompt for user input. | 1952 | prompt for user input. |
1950 | 1953 | ||
1951 | - CFG_CBSIZE: Buffer size for input from the Console | 1954 | - CFG_CBSIZE: Buffer size for input from the Console |
1952 | 1955 | ||
1953 | - CFG_PBSIZE: Buffer size for Console output | 1956 | - CFG_PBSIZE: Buffer size for Console output |
1954 | 1957 | ||
1955 | - CFG_MAXARGS: max. Number of arguments accepted for monitor commands | 1958 | - CFG_MAXARGS: max. Number of arguments accepted for monitor commands |
1956 | 1959 | ||
1957 | - CFG_BARGSIZE: Buffer size for Boot Arguments which are passed to | 1960 | - CFG_BARGSIZE: Buffer size for Boot Arguments which are passed to |
1958 | the application (usually a Linux kernel) when it is | 1961 | the application (usually a Linux kernel) when it is |
1959 | booted | 1962 | booted |
1960 | 1963 | ||
1961 | - CFG_BAUDRATE_TABLE: | 1964 | - CFG_BAUDRATE_TABLE: |
1962 | List of legal baudrate settings for this board. | 1965 | List of legal baudrate settings for this board. |
1963 | 1966 | ||
1964 | - CFG_CONSOLE_INFO_QUIET | 1967 | - CFG_CONSOLE_INFO_QUIET |
1965 | Suppress display of console information at boot. | 1968 | Suppress display of console information at boot. |
1966 | 1969 | ||
1967 | - CFG_CONSOLE_IS_IN_ENV | 1970 | - CFG_CONSOLE_IS_IN_ENV |
1968 | If the board specific function | 1971 | If the board specific function |
1969 | extern int overwrite_console (void); | 1972 | extern int overwrite_console (void); |
1970 | returns 1, the stdin, stderr and stdout are switched to the | 1973 | returns 1, the stdin, stderr and stdout are switched to the |
1971 | serial port, else the settings in the environment are used. | 1974 | serial port, else the settings in the environment are used. |
1972 | 1975 | ||
1973 | - CFG_CONSOLE_OVERWRITE_ROUTINE | 1976 | - CFG_CONSOLE_OVERWRITE_ROUTINE |
1974 | Enable the call to overwrite_console(). | 1977 | Enable the call to overwrite_console(). |
1975 | 1978 | ||
1976 | - CFG_CONSOLE_ENV_OVERWRITE | 1979 | - CFG_CONSOLE_ENV_OVERWRITE |
1977 | Enable overwrite of previous console environment settings. | 1980 | Enable overwrite of previous console environment settings. |
1978 | 1981 | ||
1979 | - CFG_MEMTEST_START, CFG_MEMTEST_END: | 1982 | - CFG_MEMTEST_START, CFG_MEMTEST_END: |
1980 | Begin and End addresses of the area used by the | 1983 | Begin and End addresses of the area used by the |
1981 | simple memory test. | 1984 | simple memory test. |
1982 | 1985 | ||
1983 | - CFG_ALT_MEMTEST: | 1986 | - CFG_ALT_MEMTEST: |
1984 | Enable an alternate, more extensive memory test. | 1987 | Enable an alternate, more extensive memory test. |
1985 | 1988 | ||
1986 | - CFG_MEMTEST_SCRATCH: | 1989 | - CFG_MEMTEST_SCRATCH: |
1987 | Scratch address used by the alternate memory test | 1990 | Scratch address used by the alternate memory test |
1988 | You only need to set this if address zero isn't writeable | 1991 | You only need to set this if address zero isn't writeable |
1989 | 1992 | ||
1990 | - CFG_MEM_TOP_HIDE (PPC only): | 1993 | - CFG_MEM_TOP_HIDE (PPC only): |
1991 | If CFG_MEM_TOP_HIDE is defined in the board config header, | 1994 | If CFG_MEM_TOP_HIDE is defined in the board config header, |
1992 | this specified memory area will get subtracted from the top | 1995 | this specified memory area will get subtracted from the top |
1993 | (end) of RAM and won't get "touched" at all by U-Boot. By | 1996 | (end) of RAM and won't get "touched" at all by U-Boot. By |
1994 | fixing up gd->ram_size the Linux kernel should gets passed | 1997 | fixing up gd->ram_size the Linux kernel should gets passed |
1995 | the now "corrected" memory size and won't touch it either. | 1998 | the now "corrected" memory size and won't touch it either. |
1996 | This should work for arch/ppc and arch/powerpc. Only Linux | 1999 | This should work for arch/ppc and arch/powerpc. Only Linux |
1997 | board ports in arch/powerpc with bootwrapper support that | 2000 | board ports in arch/powerpc with bootwrapper support that |
1998 | recalculate the memory size from the SDRAM controller setup | 2001 | recalculate the memory size from the SDRAM controller setup |
1999 | will have to get fixed in Linux additionally. | 2002 | will have to get fixed in Linux additionally. |
2000 | 2003 | ||
2001 | This option can be used as a workaround for the 440EPx/GRx | 2004 | This option can be used as a workaround for the 440EPx/GRx |
2002 | CHIP 11 errata where the last 256 bytes in SDRAM shouldn't | 2005 | CHIP 11 errata where the last 256 bytes in SDRAM shouldn't |
2003 | be touched. | 2006 | be touched. |
2004 | 2007 | ||
2005 | WARNING: Please make sure that this value is a multiple of | 2008 | WARNING: Please make sure that this value is a multiple of |
2006 | the Linux page size (normally 4k). If this is not the case, | 2009 | the Linux page size (normally 4k). If this is not the case, |
2007 | then the end address of the Linux memory will be located at a | 2010 | then the end address of the Linux memory will be located at a |
2008 | non page size aligned address and this could cause major | 2011 | non page size aligned address and this could cause major |
2009 | problems. | 2012 | problems. |
2010 | 2013 | ||
2011 | - CFG_TFTP_LOADADDR: | 2014 | - CFG_TFTP_LOADADDR: |
2012 | Default load address for network file downloads | 2015 | Default load address for network file downloads |
2013 | 2016 | ||
2014 | - CFG_LOADS_BAUD_CHANGE: | 2017 | - CFG_LOADS_BAUD_CHANGE: |
2015 | Enable temporary baudrate change while serial download | 2018 | Enable temporary baudrate change while serial download |
2016 | 2019 | ||
2017 | - CFG_SDRAM_BASE: | 2020 | - CFG_SDRAM_BASE: |
2018 | Physical start address of SDRAM. _Must_ be 0 here. | 2021 | Physical start address of SDRAM. _Must_ be 0 here. |
2019 | 2022 | ||
2020 | - CFG_MBIO_BASE: | 2023 | - CFG_MBIO_BASE: |
2021 | Physical start address of Motherboard I/O (if using a | 2024 | Physical start address of Motherboard I/O (if using a |
2022 | Cogent motherboard) | 2025 | Cogent motherboard) |
2023 | 2026 | ||
2024 | - CFG_FLASH_BASE: | 2027 | - CFG_FLASH_BASE: |
2025 | Physical start address of Flash memory. | 2028 | Physical start address of Flash memory. |
2026 | 2029 | ||
2027 | - CFG_MONITOR_BASE: | 2030 | - CFG_MONITOR_BASE: |
2028 | Physical start address of boot monitor code (set by | 2031 | Physical start address of boot monitor code (set by |
2029 | make config files to be same as the text base address | 2032 | make config files to be same as the text base address |
2030 | (TEXT_BASE) used when linking) - same as | 2033 | (TEXT_BASE) used when linking) - same as |
2031 | CFG_FLASH_BASE when booting from flash. | 2034 | CFG_FLASH_BASE when booting from flash. |
2032 | 2035 | ||
2033 | - CFG_MONITOR_LEN: | 2036 | - CFG_MONITOR_LEN: |
2034 | Size of memory reserved for monitor code, used to | 2037 | Size of memory reserved for monitor code, used to |
2035 | determine _at_compile_time_ (!) if the environment is | 2038 | determine _at_compile_time_ (!) if the environment is |
2036 | embedded within the U-Boot image, or in a separate | 2039 | embedded within the U-Boot image, or in a separate |
2037 | flash sector. | 2040 | flash sector. |
2038 | 2041 | ||
2039 | - CFG_MALLOC_LEN: | 2042 | - CFG_MALLOC_LEN: |
2040 | Size of DRAM reserved for malloc() use. | 2043 | Size of DRAM reserved for malloc() use. |
2041 | 2044 | ||
2042 | - CFG_BOOTM_LEN: | 2045 | - CFG_BOOTM_LEN: |
2043 | Normally compressed uImages are limited to an | 2046 | Normally compressed uImages are limited to an |
2044 | uncompressed size of 8 MBytes. If this is not enough, | 2047 | uncompressed size of 8 MBytes. If this is not enough, |
2045 | you can define CFG_BOOTM_LEN in your board config file | 2048 | you can define CFG_BOOTM_LEN in your board config file |
2046 | to adjust this setting to your needs. | 2049 | to adjust this setting to your needs. |
2047 | 2050 | ||
2048 | - CFG_BOOTMAPSZ: | 2051 | - CFG_BOOTMAPSZ: |
2049 | Maximum size of memory mapped by the startup code of | 2052 | Maximum size of memory mapped by the startup code of |
2050 | the Linux kernel; all data that must be processed by | 2053 | the Linux kernel; all data that must be processed by |
2051 | the Linux kernel (bd_info, boot arguments, FDT blob if | 2054 | the Linux kernel (bd_info, boot arguments, FDT blob if |
2052 | used) must be put below this limit, unless "bootm_low" | 2055 | used) must be put below this limit, unless "bootm_low" |
2053 | enviroment variable is defined and non-zero. In such case | 2056 | enviroment variable is defined and non-zero. In such case |
2054 | all data for the Linux kernel must be between "bootm_low" | 2057 | all data for the Linux kernel must be between "bootm_low" |
2055 | and "bootm_low" + CFG_BOOTMAPSZ. | 2058 | and "bootm_low" + CFG_BOOTMAPSZ. |
2056 | 2059 | ||
2057 | - CFG_MAX_FLASH_BANKS: | 2060 | - CFG_MAX_FLASH_BANKS: |
2058 | Max number of Flash memory banks | 2061 | Max number of Flash memory banks |
2059 | 2062 | ||
2060 | - CFG_MAX_FLASH_SECT: | 2063 | - CFG_MAX_FLASH_SECT: |
2061 | Max number of sectors on a Flash chip | 2064 | Max number of sectors on a Flash chip |
2062 | 2065 | ||
2063 | - CFG_FLASH_ERASE_TOUT: | 2066 | - CFG_FLASH_ERASE_TOUT: |
2064 | Timeout for Flash erase operations (in ms) | 2067 | Timeout for Flash erase operations (in ms) |
2065 | 2068 | ||
2066 | - CFG_FLASH_WRITE_TOUT: | 2069 | - CFG_FLASH_WRITE_TOUT: |
2067 | Timeout for Flash write operations (in ms) | 2070 | Timeout for Flash write operations (in ms) |
2068 | 2071 | ||
2069 | - CFG_FLASH_LOCK_TOUT | 2072 | - CFG_FLASH_LOCK_TOUT |
2070 | Timeout for Flash set sector lock bit operation (in ms) | 2073 | Timeout for Flash set sector lock bit operation (in ms) |
2071 | 2074 | ||
2072 | - CFG_FLASH_UNLOCK_TOUT | 2075 | - CFG_FLASH_UNLOCK_TOUT |
2073 | Timeout for Flash clear lock bits operation (in ms) | 2076 | Timeout for Flash clear lock bits operation (in ms) |
2074 | 2077 | ||
2075 | - CFG_FLASH_PROTECTION | 2078 | - CFG_FLASH_PROTECTION |
2076 | If defined, hardware flash sectors protection is used | 2079 | If defined, hardware flash sectors protection is used |
2077 | instead of U-Boot software protection. | 2080 | instead of U-Boot software protection. |
2078 | 2081 | ||
2079 | - CFG_DIRECT_FLASH_TFTP: | 2082 | - CFG_DIRECT_FLASH_TFTP: |
2080 | 2083 | ||
2081 | Enable TFTP transfers directly to flash memory; | 2084 | Enable TFTP transfers directly to flash memory; |
2082 | without this option such a download has to be | 2085 | without this option such a download has to be |
2083 | performed in two steps: (1) download to RAM, and (2) | 2086 | performed in two steps: (1) download to RAM, and (2) |
2084 | copy from RAM to flash. | 2087 | copy from RAM to flash. |
2085 | 2088 | ||
2086 | The two-step approach is usually more reliable, since | 2089 | The two-step approach is usually more reliable, since |
2087 | you can check if the download worked before you erase | 2090 | you can check if the download worked before you erase |
2088 | the flash, but in some situations (when system RAM is | 2091 | the flash, but in some situations (when system RAM is |
2089 | too limited to allow for a temporary copy of the | 2092 | too limited to allow for a temporary copy of the |
2090 | downloaded image) this option may be very useful. | 2093 | downloaded image) this option may be very useful. |
2091 | 2094 | ||
2092 | - CFG_FLASH_CFI: | 2095 | - CFG_FLASH_CFI: |
2093 | Define if the flash driver uses extra elements in the | 2096 | Define if the flash driver uses extra elements in the |
2094 | common flash structure for storing flash geometry. | 2097 | common flash structure for storing flash geometry. |
2095 | 2098 | ||
2096 | - CONFIG_FLASH_CFI_DRIVER | 2099 | - CONFIG_FLASH_CFI_DRIVER |
2097 | This option also enables the building of the cfi_flash driver | 2100 | This option also enables the building of the cfi_flash driver |
2098 | in the drivers directory | 2101 | in the drivers directory |
2099 | 2102 | ||
2100 | - CFG_FLASH_USE_BUFFER_WRITE | 2103 | - CFG_FLASH_USE_BUFFER_WRITE |
2101 | Use buffered writes to flash. | 2104 | Use buffered writes to flash. |
2102 | 2105 | ||
2103 | - CONFIG_FLASH_SPANSION_S29WS_N | 2106 | - CONFIG_FLASH_SPANSION_S29WS_N |
2104 | s29ws-n MirrorBit flash has non-standard addresses for buffered | 2107 | s29ws-n MirrorBit flash has non-standard addresses for buffered |
2105 | write commands. | 2108 | write commands. |
2106 | 2109 | ||
2107 | - CFG_FLASH_QUIET_TEST | 2110 | - CFG_FLASH_QUIET_TEST |
2108 | If this option is defined, the common CFI flash doesn't | 2111 | If this option is defined, the common CFI flash doesn't |
2109 | print it's warning upon not recognized FLASH banks. This | 2112 | print it's warning upon not recognized FLASH banks. This |
2110 | is useful, if some of the configured banks are only | 2113 | is useful, if some of the configured banks are only |
2111 | optionally available. | 2114 | optionally available. |
2112 | 2115 | ||
2113 | - CONFIG_FLASH_SHOW_PROGRESS | 2116 | - CONFIG_FLASH_SHOW_PROGRESS |
2114 | If defined (must be an integer), print out countdown | 2117 | If defined (must be an integer), print out countdown |
2115 | digits and dots. Recommended value: 45 (9..1) for 80 | 2118 | digits and dots. Recommended value: 45 (9..1) for 80 |
2116 | column displays, 15 (3..1) for 40 column displays. | 2119 | column displays, 15 (3..1) for 40 column displays. |
2117 | 2120 | ||
2118 | - CFG_RX_ETH_BUFFER: | 2121 | - CFG_RX_ETH_BUFFER: |
2119 | Defines the number of Ethernet receive buffers. On some | 2122 | Defines the number of Ethernet receive buffers. On some |
2120 | Ethernet controllers it is recommended to set this value | 2123 | Ethernet controllers it is recommended to set this value |
2121 | to 8 or even higher (EEPRO100 or 405 EMAC), since all | 2124 | to 8 or even higher (EEPRO100 or 405 EMAC), since all |
2122 | buffers can be full shortly after enabling the interface | 2125 | buffers can be full shortly after enabling the interface |
2123 | on high Ethernet traffic. | 2126 | on high Ethernet traffic. |
2124 | Defaults to 4 if not defined. | 2127 | Defaults to 4 if not defined. |
2125 | 2128 | ||
2126 | The following definitions that deal with the placement and management | 2129 | The following definitions that deal with the placement and management |
2127 | of environment data (variable area); in general, we support the | 2130 | of environment data (variable area); in general, we support the |
2128 | following configurations: | 2131 | following configurations: |
2129 | 2132 | ||
2130 | - CONFIG_ENV_IS_IN_FLASH: | 2133 | - CONFIG_ENV_IS_IN_FLASH: |
2131 | 2134 | ||
2132 | Define this if the environment is in flash memory. | 2135 | Define this if the environment is in flash memory. |
2133 | 2136 | ||
2134 | a) The environment occupies one whole flash sector, which is | 2137 | a) The environment occupies one whole flash sector, which is |
2135 | "embedded" in the text segment with the U-Boot code. This | 2138 | "embedded" in the text segment with the U-Boot code. This |
2136 | happens usually with "bottom boot sector" or "top boot | 2139 | happens usually with "bottom boot sector" or "top boot |
2137 | sector" type flash chips, which have several smaller | 2140 | sector" type flash chips, which have several smaller |
2138 | sectors at the start or the end. For instance, such a | 2141 | sectors at the start or the end. For instance, such a |
2139 | layout can have sector sizes of 8, 2x4, 16, Nx32 kB. In | 2142 | layout can have sector sizes of 8, 2x4, 16, Nx32 kB. In |
2140 | such a case you would place the environment in one of the | 2143 | such a case you would place the environment in one of the |
2141 | 4 kB sectors - with U-Boot code before and after it. With | 2144 | 4 kB sectors - with U-Boot code before and after it. With |
2142 | "top boot sector" type flash chips, you would put the | 2145 | "top boot sector" type flash chips, you would put the |
2143 | environment in one of the last sectors, leaving a gap | 2146 | environment in one of the last sectors, leaving a gap |
2144 | between U-Boot and the environment. | 2147 | between U-Boot and the environment. |
2145 | 2148 | ||
2146 | - CONFIG_ENV_OFFSET: | 2149 | - CONFIG_ENV_OFFSET: |
2147 | 2150 | ||
2148 | Offset of environment data (variable area) to the | 2151 | Offset of environment data (variable area) to the |
2149 | beginning of flash memory; for instance, with bottom boot | 2152 | beginning of flash memory; for instance, with bottom boot |
2150 | type flash chips the second sector can be used: the offset | 2153 | type flash chips the second sector can be used: the offset |
2151 | for this sector is given here. | 2154 | for this sector is given here. |
2152 | 2155 | ||
2153 | CONFIG_ENV_OFFSET is used relative to CFG_FLASH_BASE. | 2156 | CONFIG_ENV_OFFSET is used relative to CFG_FLASH_BASE. |
2154 | 2157 | ||
2155 | - CONFIG_ENV_ADDR: | 2158 | - CONFIG_ENV_ADDR: |
2156 | 2159 | ||
2157 | This is just another way to specify the start address of | 2160 | This is just another way to specify the start address of |
2158 | the flash sector containing the environment (instead of | 2161 | the flash sector containing the environment (instead of |
2159 | CONFIG_ENV_OFFSET). | 2162 | CONFIG_ENV_OFFSET). |
2160 | 2163 | ||
2161 | - CONFIG_ENV_SECT_SIZE: | 2164 | - CONFIG_ENV_SECT_SIZE: |
2162 | 2165 | ||
2163 | Size of the sector containing the environment. | 2166 | Size of the sector containing the environment. |
2164 | 2167 | ||
2165 | 2168 | ||
2166 | b) Sometimes flash chips have few, equal sized, BIG sectors. | 2169 | b) Sometimes flash chips have few, equal sized, BIG sectors. |
2167 | In such a case you don't want to spend a whole sector for | 2170 | In such a case you don't want to spend a whole sector for |
2168 | the environment. | 2171 | the environment. |
2169 | 2172 | ||
2170 | - CONFIG_ENV_SIZE: | 2173 | - CONFIG_ENV_SIZE: |
2171 | 2174 | ||
2172 | If you use this in combination with CONFIG_ENV_IS_IN_FLASH | 2175 | If you use this in combination with CONFIG_ENV_IS_IN_FLASH |
2173 | and CONFIG_ENV_SECT_SIZE, you can specify to use only a part | 2176 | and CONFIG_ENV_SECT_SIZE, you can specify to use only a part |
2174 | of this flash sector for the environment. This saves | 2177 | of this flash sector for the environment. This saves |
2175 | memory for the RAM copy of the environment. | 2178 | memory for the RAM copy of the environment. |
2176 | 2179 | ||
2177 | It may also save flash memory if you decide to use this | 2180 | It may also save flash memory if you decide to use this |
2178 | when your environment is "embedded" within U-Boot code, | 2181 | when your environment is "embedded" within U-Boot code, |
2179 | since then the remainder of the flash sector could be used | 2182 | since then the remainder of the flash sector could be used |
2180 | for U-Boot code. It should be pointed out that this is | 2183 | for U-Boot code. It should be pointed out that this is |
2181 | STRONGLY DISCOURAGED from a robustness point of view: | 2184 | STRONGLY DISCOURAGED from a robustness point of view: |
2182 | updating the environment in flash makes it always | 2185 | updating the environment in flash makes it always |
2183 | necessary to erase the WHOLE sector. If something goes | 2186 | necessary to erase the WHOLE sector. If something goes |
2184 | wrong before the contents has been restored from a copy in | 2187 | wrong before the contents has been restored from a copy in |
2185 | RAM, your target system will be dead. | 2188 | RAM, your target system will be dead. |
2186 | 2189 | ||
2187 | - CONFIG_ENV_ADDR_REDUND | 2190 | - CONFIG_ENV_ADDR_REDUND |
2188 | CONFIG_ENV_SIZE_REDUND | 2191 | CONFIG_ENV_SIZE_REDUND |
2189 | 2192 | ||
2190 | These settings describe a second storage area used to hold | 2193 | These settings describe a second storage area used to hold |
2191 | a redundant copy of the environment data, so that there is | 2194 | a redundant copy of the environment data, so that there is |
2192 | a valid backup copy in case there is a power failure during | 2195 | a valid backup copy in case there is a power failure during |
2193 | a "saveenv" operation. | 2196 | a "saveenv" operation. |
2194 | 2197 | ||
2195 | BE CAREFUL! Any changes to the flash layout, and some changes to the | 2198 | BE CAREFUL! Any changes to the flash layout, and some changes to the |
2196 | source code will make it necessary to adapt <board>/u-boot.lds* | 2199 | source code will make it necessary to adapt <board>/u-boot.lds* |
2197 | accordingly! | 2200 | accordingly! |
2198 | 2201 | ||
2199 | 2202 | ||
2200 | - CONFIG_ENV_IS_IN_NVRAM: | 2203 | - CONFIG_ENV_IS_IN_NVRAM: |
2201 | 2204 | ||
2202 | Define this if you have some non-volatile memory device | 2205 | Define this if you have some non-volatile memory device |
2203 | (NVRAM, battery buffered SRAM) which you want to use for the | 2206 | (NVRAM, battery buffered SRAM) which you want to use for the |
2204 | environment. | 2207 | environment. |
2205 | 2208 | ||
2206 | - CONFIG_ENV_ADDR: | 2209 | - CONFIG_ENV_ADDR: |
2207 | - CONFIG_ENV_SIZE: | 2210 | - CONFIG_ENV_SIZE: |
2208 | 2211 | ||
2209 | These two #defines are used to determine the memory area you | 2212 | These two #defines are used to determine the memory area you |
2210 | want to use for environment. It is assumed that this memory | 2213 | want to use for environment. It is assumed that this memory |
2211 | can just be read and written to, without any special | 2214 | can just be read and written to, without any special |
2212 | provision. | 2215 | provision. |
2213 | 2216 | ||
2214 | BE CAREFUL! The first access to the environment happens quite early | 2217 | BE CAREFUL! The first access to the environment happens quite early |
2215 | in U-Boot initalization (when we try to get the setting of for the | 2218 | in U-Boot initalization (when we try to get the setting of for the |
2216 | console baudrate). You *MUST* have mapped your NVRAM area then, or | 2219 | console baudrate). You *MUST* have mapped your NVRAM area then, or |
2217 | U-Boot will hang. | 2220 | U-Boot will hang. |
2218 | 2221 | ||
2219 | Please note that even with NVRAM we still use a copy of the | 2222 | Please note that even with NVRAM we still use a copy of the |
2220 | environment in RAM: we could work on NVRAM directly, but we want to | 2223 | environment in RAM: we could work on NVRAM directly, but we want to |
2221 | keep settings there always unmodified except somebody uses "saveenv" | 2224 | keep settings there always unmodified except somebody uses "saveenv" |
2222 | to save the current settings. | 2225 | to save the current settings. |
2223 | 2226 | ||
2224 | 2227 | ||
2225 | - CONFIG_ENV_IS_IN_EEPROM: | 2228 | - CONFIG_ENV_IS_IN_EEPROM: |
2226 | 2229 | ||
2227 | Use this if you have an EEPROM or similar serial access | 2230 | Use this if you have an EEPROM or similar serial access |
2228 | device and a driver for it. | 2231 | device and a driver for it. |
2229 | 2232 | ||
2230 | - CONFIG_ENV_OFFSET: | 2233 | - CONFIG_ENV_OFFSET: |
2231 | - CONFIG_ENV_SIZE: | 2234 | - CONFIG_ENV_SIZE: |
2232 | 2235 | ||
2233 | These two #defines specify the offset and size of the | 2236 | These two #defines specify the offset and size of the |
2234 | environment area within the total memory of your EEPROM. | 2237 | environment area within the total memory of your EEPROM. |
2235 | 2238 | ||
2236 | - CFG_I2C_EEPROM_ADDR: | 2239 | - CFG_I2C_EEPROM_ADDR: |
2237 | If defined, specified the chip address of the EEPROM device. | 2240 | If defined, specified the chip address of the EEPROM device. |
2238 | The default address is zero. | 2241 | The default address is zero. |
2239 | 2242 | ||
2240 | - CFG_EEPROM_PAGE_WRITE_BITS: | 2243 | - CFG_EEPROM_PAGE_WRITE_BITS: |
2241 | If defined, the number of bits used to address bytes in a | 2244 | If defined, the number of bits used to address bytes in a |
2242 | single page in the EEPROM device. A 64 byte page, for example | 2245 | single page in the EEPROM device. A 64 byte page, for example |
2243 | would require six bits. | 2246 | would require six bits. |
2244 | 2247 | ||
2245 | - CFG_EEPROM_PAGE_WRITE_DELAY_MS: | 2248 | - CFG_EEPROM_PAGE_WRITE_DELAY_MS: |
2246 | If defined, the number of milliseconds to delay between | 2249 | If defined, the number of milliseconds to delay between |
2247 | page writes. The default is zero milliseconds. | 2250 | page writes. The default is zero milliseconds. |
2248 | 2251 | ||
2249 | - CFG_I2C_EEPROM_ADDR_LEN: | 2252 | - CFG_I2C_EEPROM_ADDR_LEN: |
2250 | The length in bytes of the EEPROM memory array address. Note | 2253 | The length in bytes of the EEPROM memory array address. Note |
2251 | that this is NOT the chip address length! | 2254 | that this is NOT the chip address length! |
2252 | 2255 | ||
2253 | - CFG_I2C_EEPROM_ADDR_OVERFLOW: | 2256 | - CFG_I2C_EEPROM_ADDR_OVERFLOW: |
2254 | EEPROM chips that implement "address overflow" are ones | 2257 | EEPROM chips that implement "address overflow" are ones |
2255 | like Catalyst 24WC04/08/16 which has 9/10/11 bits of | 2258 | like Catalyst 24WC04/08/16 which has 9/10/11 bits of |
2256 | address and the extra bits end up in the "chip address" bit | 2259 | address and the extra bits end up in the "chip address" bit |
2257 | slots. This makes a 24WC08 (1Kbyte) chip look like four 256 | 2260 | slots. This makes a 24WC08 (1Kbyte) chip look like four 256 |
2258 | byte chips. | 2261 | byte chips. |
2259 | 2262 | ||
2260 | Note that we consider the length of the address field to | 2263 | Note that we consider the length of the address field to |
2261 | still be one byte because the extra address bits are hidden | 2264 | still be one byte because the extra address bits are hidden |
2262 | in the chip address. | 2265 | in the chip address. |
2263 | 2266 | ||
2264 | - CFG_EEPROM_SIZE: | 2267 | - CFG_EEPROM_SIZE: |
2265 | The size in bytes of the EEPROM device. | 2268 | The size in bytes of the EEPROM device. |
2266 | 2269 | ||
2267 | 2270 | ||
2268 | - CONFIG_ENV_IS_IN_DATAFLASH: | 2271 | - CONFIG_ENV_IS_IN_DATAFLASH: |
2269 | 2272 | ||
2270 | Define this if you have a DataFlash memory device which you | 2273 | Define this if you have a DataFlash memory device which you |
2271 | want to use for the environment. | 2274 | want to use for the environment. |
2272 | 2275 | ||
2273 | - CONFIG_ENV_OFFSET: | 2276 | - CONFIG_ENV_OFFSET: |
2274 | - CONFIG_ENV_ADDR: | 2277 | - CONFIG_ENV_ADDR: |
2275 | - CONFIG_ENV_SIZE: | 2278 | - CONFIG_ENV_SIZE: |
2276 | 2279 | ||
2277 | These three #defines specify the offset and size of the | 2280 | These three #defines specify the offset and size of the |
2278 | environment area within the total memory of your DataFlash placed | 2281 | environment area within the total memory of your DataFlash placed |
2279 | at the specified address. | 2282 | at the specified address. |
2280 | 2283 | ||
2281 | - CONFIG_ENV_IS_IN_NAND: | 2284 | - CONFIG_ENV_IS_IN_NAND: |
2282 | 2285 | ||
2283 | Define this if you have a NAND device which you want to use | 2286 | Define this if you have a NAND device which you want to use |
2284 | for the environment. | 2287 | for the environment. |
2285 | 2288 | ||
2286 | - CONFIG_ENV_OFFSET: | 2289 | - CONFIG_ENV_OFFSET: |
2287 | - CONFIG_ENV_SIZE: | 2290 | - CONFIG_ENV_SIZE: |
2288 | 2291 | ||
2289 | These two #defines specify the offset and size of the environment | 2292 | These two #defines specify the offset and size of the environment |
2290 | area within the first NAND device. | 2293 | area within the first NAND device. |
2291 | 2294 | ||
2292 | - CONFIG_ENV_OFFSET_REDUND | 2295 | - CONFIG_ENV_OFFSET_REDUND |
2293 | 2296 | ||
2294 | This setting describes a second storage area of CONFIG_ENV_SIZE | 2297 | This setting describes a second storage area of CONFIG_ENV_SIZE |
2295 | size used to hold a redundant copy of the environment data, | 2298 | size used to hold a redundant copy of the environment data, |
2296 | so that there is a valid backup copy in case there is a | 2299 | so that there is a valid backup copy in case there is a |
2297 | power failure during a "saveenv" operation. | 2300 | power failure during a "saveenv" operation. |
2298 | 2301 | ||
2299 | Note: CONFIG_ENV_OFFSET and CONFIG_ENV_OFFSET_REDUND must be aligned | 2302 | Note: CONFIG_ENV_OFFSET and CONFIG_ENV_OFFSET_REDUND must be aligned |
2300 | to a block boundary, and CONFIG_ENV_SIZE must be a multiple of | 2303 | to a block boundary, and CONFIG_ENV_SIZE must be a multiple of |
2301 | the NAND devices block size. | 2304 | the NAND devices block size. |
2302 | 2305 | ||
2303 | - CFG_SPI_INIT_OFFSET | 2306 | - CFG_SPI_INIT_OFFSET |
2304 | 2307 | ||
2305 | Defines offset to the initial SPI buffer area in DPRAM. The | 2308 | Defines offset to the initial SPI buffer area in DPRAM. The |
2306 | area is used at an early stage (ROM part) if the environment | 2309 | area is used at an early stage (ROM part) if the environment |
2307 | is configured to reside in the SPI EEPROM: We need a 520 byte | 2310 | is configured to reside in the SPI EEPROM: We need a 520 byte |
2308 | scratch DPRAM area. It is used between the two initialization | 2311 | scratch DPRAM area. It is used between the two initialization |
2309 | calls (spi_init_f() and spi_init_r()). A value of 0xB00 seems | 2312 | calls (spi_init_f() and spi_init_r()). A value of 0xB00 seems |
2310 | to be a good choice since it makes it far enough from the | 2313 | to be a good choice since it makes it far enough from the |
2311 | start of the data area as well as from the stack pointer. | 2314 | start of the data area as well as from the stack pointer. |
2312 | 2315 | ||
2313 | Please note that the environment is read-only until the monitor | 2316 | Please note that the environment is read-only until the monitor |
2314 | has been relocated to RAM and a RAM copy of the environment has been | 2317 | has been relocated to RAM and a RAM copy of the environment has been |
2315 | created; also, when using EEPROM you will have to use getenv_r() | 2318 | created; also, when using EEPROM you will have to use getenv_r() |
2316 | until then to read environment variables. | 2319 | until then to read environment variables. |
2317 | 2320 | ||
2318 | The environment is protected by a CRC32 checksum. Before the monitor | 2321 | The environment is protected by a CRC32 checksum. Before the monitor |
2319 | is relocated into RAM, as a result of a bad CRC you will be working | 2322 | is relocated into RAM, as a result of a bad CRC you will be working |
2320 | with the compiled-in default environment - *silently*!!! [This is | 2323 | with the compiled-in default environment - *silently*!!! [This is |
2321 | necessary, because the first environment variable we need is the | 2324 | necessary, because the first environment variable we need is the |
2322 | "baudrate" setting for the console - if we have a bad CRC, we don't | 2325 | "baudrate" setting for the console - if we have a bad CRC, we don't |
2323 | have any device yet where we could complain.] | 2326 | have any device yet where we could complain.] |
2324 | 2327 | ||
2325 | Note: once the monitor has been relocated, then it will complain if | 2328 | Note: once the monitor has been relocated, then it will complain if |
2326 | the default environment is used; a new CRC is computed as soon as you | 2329 | the default environment is used; a new CRC is computed as soon as you |
2327 | use the "saveenv" command to store a valid environment. | 2330 | use the "saveenv" command to store a valid environment. |
2328 | 2331 | ||
2329 | - CFG_FAULT_ECHO_LINK_DOWN: | 2332 | - CFG_FAULT_ECHO_LINK_DOWN: |
2330 | Echo the inverted Ethernet link state to the fault LED. | 2333 | Echo the inverted Ethernet link state to the fault LED. |
2331 | 2334 | ||
2332 | Note: If this option is active, then CFG_FAULT_MII_ADDR | 2335 | Note: If this option is active, then CFG_FAULT_MII_ADDR |
2333 | also needs to be defined. | 2336 | also needs to be defined. |
2334 | 2337 | ||
2335 | - CFG_FAULT_MII_ADDR: | 2338 | - CFG_FAULT_MII_ADDR: |
2336 | MII address of the PHY to check for the Ethernet link state. | 2339 | MII address of the PHY to check for the Ethernet link state. |
2337 | 2340 | ||
2338 | - CFG_64BIT_VSPRINTF: | 2341 | - CFG_64BIT_VSPRINTF: |
2339 | Makes vsprintf (and all *printf functions) support printing | 2342 | Makes vsprintf (and all *printf functions) support printing |
2340 | of 64bit values by using the L quantifier | 2343 | of 64bit values by using the L quantifier |
2341 | 2344 | ||
2342 | - CFG_64BIT_STRTOUL: | 2345 | - CFG_64BIT_STRTOUL: |
2343 | Adds simple_strtoull that returns a 64bit value | 2346 | Adds simple_strtoull that returns a 64bit value |
2344 | 2347 | ||
2345 | Low Level (hardware related) configuration options: | 2348 | Low Level (hardware related) configuration options: |
2346 | --------------------------------------------------- | 2349 | --------------------------------------------------- |
2347 | 2350 | ||
2348 | - CFG_CACHELINE_SIZE: | 2351 | - CFG_CACHELINE_SIZE: |
2349 | Cache Line Size of the CPU. | 2352 | Cache Line Size of the CPU. |
2350 | 2353 | ||
2351 | - CFG_DEFAULT_IMMR: | 2354 | - CFG_DEFAULT_IMMR: |
2352 | Default address of the IMMR after system reset. | 2355 | Default address of the IMMR after system reset. |
2353 | 2356 | ||
2354 | Needed on some 8260 systems (MPC8260ADS, PQ2FADS-ZU, | 2357 | Needed on some 8260 systems (MPC8260ADS, PQ2FADS-ZU, |
2355 | and RPXsuper) to be able to adjust the position of | 2358 | and RPXsuper) to be able to adjust the position of |
2356 | the IMMR register after a reset. | 2359 | the IMMR register after a reset. |
2357 | 2360 | ||
2358 | - Floppy Disk Support: | 2361 | - Floppy Disk Support: |
2359 | CFG_FDC_DRIVE_NUMBER | 2362 | CFG_FDC_DRIVE_NUMBER |
2360 | 2363 | ||
2361 | the default drive number (default value 0) | 2364 | the default drive number (default value 0) |
2362 | 2365 | ||
2363 | CFG_ISA_IO_STRIDE | 2366 | CFG_ISA_IO_STRIDE |
2364 | 2367 | ||
2365 | defines the spacing between FDC chipset registers | 2368 | defines the spacing between FDC chipset registers |
2366 | (default value 1) | 2369 | (default value 1) |
2367 | 2370 | ||
2368 | CFG_ISA_IO_OFFSET | 2371 | CFG_ISA_IO_OFFSET |
2369 | 2372 | ||
2370 | defines the offset of register from address. It | 2373 | defines the offset of register from address. It |
2371 | depends on which part of the data bus is connected to | 2374 | depends on which part of the data bus is connected to |
2372 | the FDC chipset. (default value 0) | 2375 | the FDC chipset. (default value 0) |
2373 | 2376 | ||
2374 | If CFG_ISA_IO_STRIDE CFG_ISA_IO_OFFSET and | 2377 | If CFG_ISA_IO_STRIDE CFG_ISA_IO_OFFSET and |
2375 | CFG_FDC_DRIVE_NUMBER are undefined, they take their | 2378 | CFG_FDC_DRIVE_NUMBER are undefined, they take their |
2376 | default value. | 2379 | default value. |
2377 | 2380 | ||
2378 | if CFG_FDC_HW_INIT is defined, then the function | 2381 | if CFG_FDC_HW_INIT is defined, then the function |
2379 | fdc_hw_init() is called at the beginning of the FDC | 2382 | fdc_hw_init() is called at the beginning of the FDC |
2380 | setup. fdc_hw_init() must be provided by the board | 2383 | setup. fdc_hw_init() must be provided by the board |
2381 | source code. It is used to make hardware dependant | 2384 | source code. It is used to make hardware dependant |
2382 | initializations. | 2385 | initializations. |
2383 | 2386 | ||
2384 | - CFG_IMMR: Physical address of the Internal Memory. | 2387 | - CFG_IMMR: Physical address of the Internal Memory. |
2385 | DO NOT CHANGE unless you know exactly what you're | 2388 | DO NOT CHANGE unless you know exactly what you're |
2386 | doing! (11-4) [MPC8xx/82xx systems only] | 2389 | doing! (11-4) [MPC8xx/82xx systems only] |
2387 | 2390 | ||
2388 | - CFG_INIT_RAM_ADDR: | 2391 | - CFG_INIT_RAM_ADDR: |
2389 | 2392 | ||
2390 | Start address of memory area that can be used for | 2393 | Start address of memory area that can be used for |
2391 | initial data and stack; please note that this must be | 2394 | initial data and stack; please note that this must be |
2392 | writable memory that is working WITHOUT special | 2395 | writable memory that is working WITHOUT special |
2393 | initialization, i. e. you CANNOT use normal RAM which | 2396 | initialization, i. e. you CANNOT use normal RAM which |
2394 | will become available only after programming the | 2397 | will become available only after programming the |
2395 | memory controller and running certain initialization | 2398 | memory controller and running certain initialization |
2396 | sequences. | 2399 | sequences. |
2397 | 2400 | ||
2398 | U-Boot uses the following memory types: | 2401 | U-Boot uses the following memory types: |
2399 | - MPC8xx and MPC8260: IMMR (internal memory of the CPU) | 2402 | - MPC8xx and MPC8260: IMMR (internal memory of the CPU) |
2400 | - MPC824X: data cache | 2403 | - MPC824X: data cache |
2401 | - PPC4xx: data cache | 2404 | - PPC4xx: data cache |
2402 | 2405 | ||
2403 | - CFG_GBL_DATA_OFFSET: | 2406 | - CFG_GBL_DATA_OFFSET: |
2404 | 2407 | ||
2405 | Offset of the initial data structure in the memory | 2408 | Offset of the initial data structure in the memory |
2406 | area defined by CFG_INIT_RAM_ADDR. Usually | 2409 | area defined by CFG_INIT_RAM_ADDR. Usually |
2407 | CFG_GBL_DATA_OFFSET is chosen such that the initial | 2410 | CFG_GBL_DATA_OFFSET is chosen such that the initial |
2408 | data is located at the end of the available space | 2411 | data is located at the end of the available space |
2409 | (sometimes written as (CFG_INIT_RAM_END - | 2412 | (sometimes written as (CFG_INIT_RAM_END - |
2410 | CFG_INIT_DATA_SIZE), and the initial stack is just | 2413 | CFG_INIT_DATA_SIZE), and the initial stack is just |
2411 | below that area (growing from (CFG_INIT_RAM_ADDR + | 2414 | below that area (growing from (CFG_INIT_RAM_ADDR + |
2412 | CFG_GBL_DATA_OFFSET) downward. | 2415 | CFG_GBL_DATA_OFFSET) downward. |
2413 | 2416 | ||
2414 | Note: | 2417 | Note: |
2415 | On the MPC824X (or other systems that use the data | 2418 | On the MPC824X (or other systems that use the data |
2416 | cache for initial memory) the address chosen for | 2419 | cache for initial memory) the address chosen for |
2417 | CFG_INIT_RAM_ADDR is basically arbitrary - it must | 2420 | CFG_INIT_RAM_ADDR is basically arbitrary - it must |
2418 | point to an otherwise UNUSED address space between | 2421 | point to an otherwise UNUSED address space between |
2419 | the top of RAM and the start of the PCI space. | 2422 | the top of RAM and the start of the PCI space. |
2420 | 2423 | ||
2421 | - CFG_SIUMCR: SIU Module Configuration (11-6) | 2424 | - CFG_SIUMCR: SIU Module Configuration (11-6) |
2422 | 2425 | ||
2423 | - CFG_SYPCR: System Protection Control (11-9) | 2426 | - CFG_SYPCR: System Protection Control (11-9) |
2424 | 2427 | ||
2425 | - CFG_TBSCR: Time Base Status and Control (11-26) | 2428 | - CFG_TBSCR: Time Base Status and Control (11-26) |
2426 | 2429 | ||
2427 | - CFG_PISCR: Periodic Interrupt Status and Control (11-31) | 2430 | - CFG_PISCR: Periodic Interrupt Status and Control (11-31) |
2428 | 2431 | ||
2429 | - CFG_PLPRCR: PLL, Low-Power, and Reset Control Register (15-30) | 2432 | - CFG_PLPRCR: PLL, Low-Power, and Reset Control Register (15-30) |
2430 | 2433 | ||
2431 | - CFG_SCCR: System Clock and reset Control Register (15-27) | 2434 | - CFG_SCCR: System Clock and reset Control Register (15-27) |
2432 | 2435 | ||
2433 | - CFG_OR_TIMING_SDRAM: | 2436 | - CFG_OR_TIMING_SDRAM: |
2434 | SDRAM timing | 2437 | SDRAM timing |
2435 | 2438 | ||
2436 | - CFG_MAMR_PTA: | 2439 | - CFG_MAMR_PTA: |
2437 | periodic timer for refresh | 2440 | periodic timer for refresh |
2438 | 2441 | ||
2439 | - CFG_DER: Debug Event Register (37-47) | 2442 | - CFG_DER: Debug Event Register (37-47) |
2440 | 2443 | ||
2441 | - FLASH_BASE0_PRELIM, FLASH_BASE1_PRELIM, CFG_REMAP_OR_AM, | 2444 | - FLASH_BASE0_PRELIM, FLASH_BASE1_PRELIM, CFG_REMAP_OR_AM, |
2442 | CFG_PRELIM_OR_AM, CFG_OR_TIMING_FLASH, CFG_OR0_REMAP, | 2445 | CFG_PRELIM_OR_AM, CFG_OR_TIMING_FLASH, CFG_OR0_REMAP, |
2443 | CFG_OR0_PRELIM, CFG_BR0_PRELIM, CFG_OR1_REMAP, CFG_OR1_PRELIM, | 2446 | CFG_OR0_PRELIM, CFG_BR0_PRELIM, CFG_OR1_REMAP, CFG_OR1_PRELIM, |
2444 | CFG_BR1_PRELIM: | 2447 | CFG_BR1_PRELIM: |
2445 | Memory Controller Definitions: BR0/1 and OR0/1 (FLASH) | 2448 | Memory Controller Definitions: BR0/1 and OR0/1 (FLASH) |
2446 | 2449 | ||
2447 | - SDRAM_BASE2_PRELIM, SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE, | 2450 | - SDRAM_BASE2_PRELIM, SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE, |
2448 | CFG_OR_TIMING_SDRAM, CFG_OR2_PRELIM, CFG_BR2_PRELIM, | 2451 | CFG_OR_TIMING_SDRAM, CFG_OR2_PRELIM, CFG_BR2_PRELIM, |
2449 | CFG_OR3_PRELIM, CFG_BR3_PRELIM: | 2452 | CFG_OR3_PRELIM, CFG_BR3_PRELIM: |
2450 | Memory Controller Definitions: BR2/3 and OR2/3 (SDRAM) | 2453 | Memory Controller Definitions: BR2/3 and OR2/3 (SDRAM) |
2451 | 2454 | ||
2452 | - CFG_MAMR_PTA, CFG_MPTPR_2BK_4K, CFG_MPTPR_1BK_4K, CFG_MPTPR_2BK_8K, | 2455 | - CFG_MAMR_PTA, CFG_MPTPR_2BK_4K, CFG_MPTPR_1BK_4K, CFG_MPTPR_2BK_8K, |
2453 | CFG_MPTPR_1BK_8K, CFG_MAMR_8COL, CFG_MAMR_9COL: | 2456 | CFG_MPTPR_1BK_8K, CFG_MAMR_8COL, CFG_MAMR_9COL: |
2454 | Machine Mode Register and Memory Periodic Timer | 2457 | Machine Mode Register and Memory Periodic Timer |
2455 | Prescaler definitions (SDRAM timing) | 2458 | Prescaler definitions (SDRAM timing) |
2456 | 2459 | ||
2457 | - CFG_I2C_UCODE_PATCH, CFG_I2C_DPMEM_OFFSET [0x1FC0]: | 2460 | - CFG_I2C_UCODE_PATCH, CFG_I2C_DPMEM_OFFSET [0x1FC0]: |
2458 | enable I2C microcode relocation patch (MPC8xx); | 2461 | enable I2C microcode relocation patch (MPC8xx); |
2459 | define relocation offset in DPRAM [DSP2] | 2462 | define relocation offset in DPRAM [DSP2] |
2460 | 2463 | ||
2461 | - CFG_SMC_UCODE_PATCH, CFG_SMC_DPMEM_OFFSET [0x1FC0]: | 2464 | - CFG_SMC_UCODE_PATCH, CFG_SMC_DPMEM_OFFSET [0x1FC0]: |
2462 | enable SMC microcode relocation patch (MPC8xx); | 2465 | enable SMC microcode relocation patch (MPC8xx); |
2463 | define relocation offset in DPRAM [SMC1] | 2466 | define relocation offset in DPRAM [SMC1] |
2464 | 2467 | ||
2465 | - CFG_SPI_UCODE_PATCH, CFG_SPI_DPMEM_OFFSET [0x1FC0]: | 2468 | - CFG_SPI_UCODE_PATCH, CFG_SPI_DPMEM_OFFSET [0x1FC0]: |
2466 | enable SPI microcode relocation patch (MPC8xx); | 2469 | enable SPI microcode relocation patch (MPC8xx); |
2467 | define relocation offset in DPRAM [SCC4] | 2470 | define relocation offset in DPRAM [SCC4] |
2468 | 2471 | ||
2469 | - CFG_USE_OSCCLK: | 2472 | - CFG_USE_OSCCLK: |
2470 | Use OSCM clock mode on MBX8xx board. Be careful, | 2473 | Use OSCM clock mode on MBX8xx board. Be careful, |
2471 | wrong setting might damage your board. Read | 2474 | wrong setting might damage your board. Read |
2472 | doc/README.MBX before setting this variable! | 2475 | doc/README.MBX before setting this variable! |
2473 | 2476 | ||
2474 | - CFG_CPM_POST_WORD_ADDR: (MPC8xx, MPC8260 only) | 2477 | - CFG_CPM_POST_WORD_ADDR: (MPC8xx, MPC8260 only) |
2475 | Offset of the bootmode word in DPRAM used by post | 2478 | Offset of the bootmode word in DPRAM used by post |
2476 | (Power On Self Tests). This definition overrides | 2479 | (Power On Self Tests). This definition overrides |
2477 | #define'd default value in commproc.h resp. | 2480 | #define'd default value in commproc.h resp. |
2478 | cpm_8260.h. | 2481 | cpm_8260.h. |
2479 | 2482 | ||
2480 | - CFG_PCI_SLV_MEM_LOCAL, CFG_PCI_SLV_MEM_BUS, CFG_PICMR0_MASK_ATTRIB, | 2483 | - CFG_PCI_SLV_MEM_LOCAL, CFG_PCI_SLV_MEM_BUS, CFG_PICMR0_MASK_ATTRIB, |
2481 | CFG_PCI_MSTR0_LOCAL, CFG_PCIMSK0_MASK, CFG_PCI_MSTR1_LOCAL, | 2484 | CFG_PCI_MSTR0_LOCAL, CFG_PCIMSK0_MASK, CFG_PCI_MSTR1_LOCAL, |
2482 | CFG_PCIMSK1_MASK, CFG_PCI_MSTR_MEM_LOCAL, CFG_PCI_MSTR_MEM_BUS, | 2485 | CFG_PCIMSK1_MASK, CFG_PCI_MSTR_MEM_LOCAL, CFG_PCI_MSTR_MEM_BUS, |
2483 | CFG_CPU_PCI_MEM_START, CFG_PCI_MSTR_MEM_SIZE, CFG_POCMR0_MASK_ATTRIB, | 2486 | CFG_CPU_PCI_MEM_START, CFG_PCI_MSTR_MEM_SIZE, CFG_POCMR0_MASK_ATTRIB, |
2484 | CFG_PCI_MSTR_MEMIO_LOCAL, CFG_PCI_MSTR_MEMIO_BUS, CPU_PCI_MEMIO_START, | 2487 | CFG_PCI_MSTR_MEMIO_LOCAL, CFG_PCI_MSTR_MEMIO_BUS, CPU_PCI_MEMIO_START, |
2485 | CFG_PCI_MSTR_MEMIO_SIZE, CFG_POCMR1_MASK_ATTRIB, CFG_PCI_MSTR_IO_LOCAL, | 2488 | CFG_PCI_MSTR_MEMIO_SIZE, CFG_POCMR1_MASK_ATTRIB, CFG_PCI_MSTR_IO_LOCAL, |
2486 | CFG_PCI_MSTR_IO_BUS, CFG_CPU_PCI_IO_START, CFG_PCI_MSTR_IO_SIZE, | 2489 | CFG_PCI_MSTR_IO_BUS, CFG_CPU_PCI_IO_START, CFG_PCI_MSTR_IO_SIZE, |
2487 | CFG_POCMR2_MASK_ATTRIB: (MPC826x only) | 2490 | CFG_POCMR2_MASK_ATTRIB: (MPC826x only) |
2488 | Overrides the default PCI memory map in cpu/mpc8260/pci.c if set. | 2491 | Overrides the default PCI memory map in cpu/mpc8260/pci.c if set. |
2489 | 2492 | ||
2490 | - CONFIG_SPD_EEPROM | 2493 | - CONFIG_SPD_EEPROM |
2491 | Get DDR timing information from an I2C EEPROM. Common | 2494 | Get DDR timing information from an I2C EEPROM. Common |
2492 | with pluggable memory modules such as SODIMMs | 2495 | with pluggable memory modules such as SODIMMs |
2493 | 2496 | ||
2494 | SPD_EEPROM_ADDRESS | 2497 | SPD_EEPROM_ADDRESS |
2495 | I2C address of the SPD EEPROM | 2498 | I2C address of the SPD EEPROM |
2496 | 2499 | ||
2497 | - CFG_SPD_BUS_NUM | 2500 | - CFG_SPD_BUS_NUM |
2498 | If SPD EEPROM is on an I2C bus other than the first | 2501 | If SPD EEPROM is on an I2C bus other than the first |
2499 | one, specify here. Note that the value must resolve | 2502 | one, specify here. Note that the value must resolve |
2500 | to something your driver can deal with. | 2503 | to something your driver can deal with. |
2501 | 2504 | ||
2502 | - CFG_83XX_DDR_USES_CS0 | 2505 | - CFG_83XX_DDR_USES_CS0 |
2503 | Only for 83xx systems. If specified, then DDR should | 2506 | Only for 83xx systems. If specified, then DDR should |
2504 | be configured using CS0 and CS1 instead of CS2 and CS3. | 2507 | be configured using CS0 and CS1 instead of CS2 and CS3. |
2505 | 2508 | ||
2506 | - CFG_83XX_DDR_USES_CS0 | 2509 | - CFG_83XX_DDR_USES_CS0 |
2507 | Only for 83xx systems. If specified, then DDR should | 2510 | Only for 83xx systems. If specified, then DDR should |
2508 | be configured using CS0 and CS1 instead of CS2 and CS3. | 2511 | be configured using CS0 and CS1 instead of CS2 and CS3. |
2509 | 2512 | ||
2510 | - CONFIG_ETHER_ON_FEC[12] | 2513 | - CONFIG_ETHER_ON_FEC[12] |
2511 | Define to enable FEC[12] on a 8xx series processor. | 2514 | Define to enable FEC[12] on a 8xx series processor. |
2512 | 2515 | ||
2513 | - CONFIG_FEC[12]_PHY | 2516 | - CONFIG_FEC[12]_PHY |
2514 | Define to the hardcoded PHY address which corresponds | 2517 | Define to the hardcoded PHY address which corresponds |
2515 | to the given FEC; i. e. | 2518 | to the given FEC; i. e. |
2516 | #define CONFIG_FEC1_PHY 4 | 2519 | #define CONFIG_FEC1_PHY 4 |
2517 | means that the PHY with address 4 is connected to FEC1 | 2520 | means that the PHY with address 4 is connected to FEC1 |
2518 | 2521 | ||
2519 | When set to -1, means to probe for first available. | 2522 | When set to -1, means to probe for first available. |
2520 | 2523 | ||
2521 | - CONFIG_FEC[12]_PHY_NORXERR | 2524 | - CONFIG_FEC[12]_PHY_NORXERR |
2522 | The PHY does not have a RXERR line (RMII only). | 2525 | The PHY does not have a RXERR line (RMII only). |
2523 | (so program the FEC to ignore it). | 2526 | (so program the FEC to ignore it). |
2524 | 2527 | ||
2525 | - CONFIG_RMII | 2528 | - CONFIG_RMII |
2526 | Enable RMII mode for all FECs. | 2529 | Enable RMII mode for all FECs. |
2527 | Note that this is a global option, we can't | 2530 | Note that this is a global option, we can't |
2528 | have one FEC in standard MII mode and another in RMII mode. | 2531 | have one FEC in standard MII mode and another in RMII mode. |
2529 | 2532 | ||
2530 | - CONFIG_CRC32_VERIFY | 2533 | - CONFIG_CRC32_VERIFY |
2531 | Add a verify option to the crc32 command. | 2534 | Add a verify option to the crc32 command. |
2532 | The syntax is: | 2535 | The syntax is: |
2533 | 2536 | ||
2534 | => crc32 -v <address> <count> <crc32> | 2537 | => crc32 -v <address> <count> <crc32> |
2535 | 2538 | ||
2536 | Where address/count indicate a memory area | 2539 | Where address/count indicate a memory area |
2537 | and crc32 is the correct crc32 which the | 2540 | and crc32 is the correct crc32 which the |
2538 | area should have. | 2541 | area should have. |
2539 | 2542 | ||
2540 | - CONFIG_LOOPW | 2543 | - CONFIG_LOOPW |
2541 | Add the "loopw" memory command. This only takes effect if | 2544 | Add the "loopw" memory command. This only takes effect if |
2542 | the memory commands are activated globally (CONFIG_CMD_MEM). | 2545 | the memory commands are activated globally (CONFIG_CMD_MEM). |
2543 | 2546 | ||
2544 | - CONFIG_MX_CYCLIC | 2547 | - CONFIG_MX_CYCLIC |
2545 | Add the "mdc" and "mwc" memory commands. These are cyclic | 2548 | Add the "mdc" and "mwc" memory commands. These are cyclic |
2546 | "md/mw" commands. | 2549 | "md/mw" commands. |
2547 | Examples: | 2550 | Examples: |
2548 | 2551 | ||
2549 | => mdc.b 10 4 500 | 2552 | => mdc.b 10 4 500 |
2550 | This command will print 4 bytes (10,11,12,13) each 500 ms. | 2553 | This command will print 4 bytes (10,11,12,13) each 500 ms. |
2551 | 2554 | ||
2552 | => mwc.l 100 12345678 10 | 2555 | => mwc.l 100 12345678 10 |
2553 | This command will write 12345678 to address 100 all 10 ms. | 2556 | This command will write 12345678 to address 100 all 10 ms. |
2554 | 2557 | ||
2555 | This only takes effect if the memory commands are activated | 2558 | This only takes effect if the memory commands are activated |
2556 | globally (CONFIG_CMD_MEM). | 2559 | globally (CONFIG_CMD_MEM). |
2557 | 2560 | ||
2558 | - CONFIG_SKIP_LOWLEVEL_INIT | 2561 | - CONFIG_SKIP_LOWLEVEL_INIT |
2559 | - CONFIG_SKIP_RELOCATE_UBOOT | 2562 | - CONFIG_SKIP_RELOCATE_UBOOT |
2560 | 2563 | ||
2561 | [ARM only] If these variables are defined, then | 2564 | [ARM only] If these variables are defined, then |
2562 | certain low level initializations (like setting up | 2565 | certain low level initializations (like setting up |
2563 | the memory controller) are omitted and/or U-Boot does | 2566 | the memory controller) are omitted and/or U-Boot does |
2564 | not relocate itself into RAM. | 2567 | not relocate itself into RAM. |
2565 | Normally these variables MUST NOT be defined. The | 2568 | Normally these variables MUST NOT be defined. The |
2566 | only exception is when U-Boot is loaded (to RAM) by | 2569 | only exception is when U-Boot is loaded (to RAM) by |
2567 | some other boot loader or by a debugger which | 2570 | some other boot loader or by a debugger which |
2568 | performs these initializations itself. | 2571 | performs these initializations itself. |
2569 | 2572 | ||
2570 | 2573 | ||
2571 | Building the Software: | 2574 | Building the Software: |
2572 | ====================== | 2575 | ====================== |
2573 | 2576 | ||
2574 | Building U-Boot has been tested in several native build environments | 2577 | Building U-Boot has been tested in several native build environments |
2575 | and in many different cross environments. Of course we cannot support | 2578 | and in many different cross environments. Of course we cannot support |
2576 | all possibly existing versions of cross development tools in all | 2579 | all possibly existing versions of cross development tools in all |
2577 | (potentially obsolete) versions. In case of tool chain problems we | 2580 | (potentially obsolete) versions. In case of tool chain problems we |
2578 | recommend to use the ELDK (see http://www.denx.de/wiki/DULG/ELDK) | 2581 | recommend to use the ELDK (see http://www.denx.de/wiki/DULG/ELDK) |
2579 | which is extensively used to build and test U-Boot. | 2582 | which is extensively used to build and test U-Boot. |
2580 | 2583 | ||
2581 | If you are not using a native environment, it is assumed that you | 2584 | If you are not using a native environment, it is assumed that you |
2582 | have GNU cross compiling tools available in your path. In this case, | 2585 | have GNU cross compiling tools available in your path. In this case, |
2583 | you must set the environment variable CROSS_COMPILE in your shell. | 2586 | you must set the environment variable CROSS_COMPILE in your shell. |
2584 | Note that no changes to the Makefile or any other source files are | 2587 | Note that no changes to the Makefile or any other source files are |
2585 | necessary. For example using the ELDK on a 4xx CPU, please enter: | 2588 | necessary. For example using the ELDK on a 4xx CPU, please enter: |
2586 | 2589 | ||
2587 | $ CROSS_COMPILE=ppc_4xx- | 2590 | $ CROSS_COMPILE=ppc_4xx- |
2588 | $ export CROSS_COMPILE | 2591 | $ export CROSS_COMPILE |
2589 | 2592 | ||
2590 | U-Boot is intended to be simple to build. After installing the | 2593 | U-Boot is intended to be simple to build. After installing the |
2591 | sources you must configure U-Boot for one specific board type. This | 2594 | sources you must configure U-Boot for one specific board type. This |
2592 | is done by typing: | 2595 | is done by typing: |
2593 | 2596 | ||
2594 | make NAME_config | 2597 | make NAME_config |
2595 | 2598 | ||
2596 | where "NAME_config" is the name of one of the existing configu- | 2599 | where "NAME_config" is the name of one of the existing configu- |
2597 | rations; see the main Makefile for supported names. | 2600 | rations; see the main Makefile for supported names. |
2598 | 2601 | ||
2599 | Note: for some board special configuration names may exist; check if | 2602 | Note: for some board special configuration names may exist; check if |
2600 | additional information is available from the board vendor; for | 2603 | additional information is available from the board vendor; for |
2601 | instance, the TQM823L systems are available without (standard) | 2604 | instance, the TQM823L systems are available without (standard) |
2602 | or with LCD support. You can select such additional "features" | 2605 | or with LCD support. You can select such additional "features" |
2603 | when choosing the configuration, i. e. | 2606 | when choosing the configuration, i. e. |
2604 | 2607 | ||
2605 | make TQM823L_config | 2608 | make TQM823L_config |
2606 | - will configure for a plain TQM823L, i. e. no LCD support | 2609 | - will configure for a plain TQM823L, i. e. no LCD support |
2607 | 2610 | ||
2608 | make TQM823L_LCD_config | 2611 | make TQM823L_LCD_config |
2609 | - will configure for a TQM823L with U-Boot console on LCD | 2612 | - will configure for a TQM823L with U-Boot console on LCD |
2610 | 2613 | ||
2611 | etc. | 2614 | etc. |
2612 | 2615 | ||
2613 | 2616 | ||
2614 | Finally, type "make all", and you should get some working U-Boot | 2617 | Finally, type "make all", and you should get some working U-Boot |
2615 | images ready for download to / installation on your system: | 2618 | images ready for download to / installation on your system: |
2616 | 2619 | ||
2617 | - "u-boot.bin" is a raw binary image | 2620 | - "u-boot.bin" is a raw binary image |
2618 | - "u-boot" is an image in ELF binary format | 2621 | - "u-boot" is an image in ELF binary format |
2619 | - "u-boot.srec" is in Motorola S-Record format | 2622 | - "u-boot.srec" is in Motorola S-Record format |
2620 | 2623 | ||
2621 | By default the build is performed locally and the objects are saved | 2624 | By default the build is performed locally and the objects are saved |
2622 | in the source directory. One of the two methods can be used to change | 2625 | in the source directory. One of the two methods can be used to change |
2623 | this behavior and build U-Boot to some external directory: | 2626 | this behavior and build U-Boot to some external directory: |
2624 | 2627 | ||
2625 | 1. Add O= to the make command line invocations: | 2628 | 1. Add O= to the make command line invocations: |
2626 | 2629 | ||
2627 | make O=/tmp/build distclean | 2630 | make O=/tmp/build distclean |
2628 | make O=/tmp/build NAME_config | 2631 | make O=/tmp/build NAME_config |
2629 | make O=/tmp/build all | 2632 | make O=/tmp/build all |
2630 | 2633 | ||
2631 | 2. Set environment variable BUILD_DIR to point to the desired location: | 2634 | 2. Set environment variable BUILD_DIR to point to the desired location: |
2632 | 2635 | ||
2633 | export BUILD_DIR=/tmp/build | 2636 | export BUILD_DIR=/tmp/build |
2634 | make distclean | 2637 | make distclean |
2635 | make NAME_config | 2638 | make NAME_config |
2636 | make all | 2639 | make all |
2637 | 2640 | ||
2638 | Note that the command line "O=" setting overrides the BUILD_DIR environment | 2641 | Note that the command line "O=" setting overrides the BUILD_DIR environment |
2639 | variable. | 2642 | variable. |
2640 | 2643 | ||
2641 | 2644 | ||
2642 | Please be aware that the Makefiles assume you are using GNU make, so | 2645 | Please be aware that the Makefiles assume you are using GNU make, so |
2643 | for instance on NetBSD you might need to use "gmake" instead of | 2646 | for instance on NetBSD you might need to use "gmake" instead of |
2644 | native "make". | 2647 | native "make". |
2645 | 2648 | ||
2646 | 2649 | ||
2647 | If the system board that you have is not listed, then you will need | 2650 | If the system board that you have is not listed, then you will need |
2648 | to port U-Boot to your hardware platform. To do this, follow these | 2651 | to port U-Boot to your hardware platform. To do this, follow these |
2649 | steps: | 2652 | steps: |
2650 | 2653 | ||
2651 | 1. Add a new configuration option for your board to the toplevel | 2654 | 1. Add a new configuration option for your board to the toplevel |
2652 | "Makefile" and to the "MAKEALL" script, using the existing | 2655 | "Makefile" and to the "MAKEALL" script, using the existing |
2653 | entries as examples. Note that here and at many other places | 2656 | entries as examples. Note that here and at many other places |
2654 | boards and other names are listed in alphabetical sort order. Please | 2657 | boards and other names are listed in alphabetical sort order. Please |
2655 | keep this order. | 2658 | keep this order. |
2656 | 2. Create a new directory to hold your board specific code. Add any | 2659 | 2. Create a new directory to hold your board specific code. Add any |
2657 | files you need. In your board directory, you will need at least | 2660 | files you need. In your board directory, you will need at least |
2658 | the "Makefile", a "<board>.c", "flash.c" and "u-boot.lds". | 2661 | the "Makefile", a "<board>.c", "flash.c" and "u-boot.lds". |
2659 | 3. Create a new configuration file "include/configs/<board>.h" for | 2662 | 3. Create a new configuration file "include/configs/<board>.h" for |
2660 | your board | 2663 | your board |
2661 | 3. If you're porting U-Boot to a new CPU, then also create a new | 2664 | 3. If you're porting U-Boot to a new CPU, then also create a new |
2662 | directory to hold your CPU specific code. Add any files you need. | 2665 | directory to hold your CPU specific code. Add any files you need. |
2663 | 4. Run "make <board>_config" with your new name. | 2666 | 4. Run "make <board>_config" with your new name. |
2664 | 5. Type "make", and you should get a working "u-boot.srec" file | 2667 | 5. Type "make", and you should get a working "u-boot.srec" file |
2665 | to be installed on your target system. | 2668 | to be installed on your target system. |
2666 | 6. Debug and solve any problems that might arise. | 2669 | 6. Debug and solve any problems that might arise. |
2667 | [Of course, this last step is much harder than it sounds.] | 2670 | [Of course, this last step is much harder than it sounds.] |
2668 | 2671 | ||
2669 | 2672 | ||
2670 | Testing of U-Boot Modifications, Ports to New Hardware, etc.: | 2673 | Testing of U-Boot Modifications, Ports to New Hardware, etc.: |
2671 | ============================================================== | 2674 | ============================================================== |
2672 | 2675 | ||
2673 | If you have modified U-Boot sources (for instance added a new board | 2676 | If you have modified U-Boot sources (for instance added a new board |
2674 | or support for new devices, a new CPU, etc.) you are expected to | 2677 | or support for new devices, a new CPU, etc.) you are expected to |
2675 | provide feedback to the other developers. The feedback normally takes | 2678 | provide feedback to the other developers. The feedback normally takes |
2676 | the form of a "patch", i. e. a context diff against a certain (latest | 2679 | the form of a "patch", i. e. a context diff against a certain (latest |
2677 | official or latest in the git repository) version of U-Boot sources. | 2680 | official or latest in the git repository) version of U-Boot sources. |
2678 | 2681 | ||
2679 | But before you submit such a patch, please verify that your modifi- | 2682 | But before you submit such a patch, please verify that your modifi- |
2680 | cation did not break existing code. At least make sure that *ALL* of | 2683 | cation did not break existing code. At least make sure that *ALL* of |
2681 | the supported boards compile WITHOUT ANY compiler warnings. To do so, | 2684 | the supported boards compile WITHOUT ANY compiler warnings. To do so, |
2682 | just run the "MAKEALL" script, which will configure and build U-Boot | 2685 | just run the "MAKEALL" script, which will configure and build U-Boot |
2683 | for ALL supported system. Be warned, this will take a while. You can | 2686 | for ALL supported system. Be warned, this will take a while. You can |
2684 | select which (cross) compiler to use by passing a `CROSS_COMPILE' | 2687 | select which (cross) compiler to use by passing a `CROSS_COMPILE' |
2685 | environment variable to the script, i. e. to use the ELDK cross tools | 2688 | environment variable to the script, i. e. to use the ELDK cross tools |
2686 | you can type | 2689 | you can type |
2687 | 2690 | ||
2688 | CROSS_COMPILE=ppc_8xx- MAKEALL | 2691 | CROSS_COMPILE=ppc_8xx- MAKEALL |
2689 | 2692 | ||
2690 | or to build on a native PowerPC system you can type | 2693 | or to build on a native PowerPC system you can type |
2691 | 2694 | ||
2692 | CROSS_COMPILE=' ' MAKEALL | 2695 | CROSS_COMPILE=' ' MAKEALL |
2693 | 2696 | ||
2694 | When using the MAKEALL script, the default behaviour is to build | 2697 | When using the MAKEALL script, the default behaviour is to build |
2695 | U-Boot in the source directory. This location can be changed by | 2698 | U-Boot in the source directory. This location can be changed by |
2696 | setting the BUILD_DIR environment variable. Also, for each target | 2699 | setting the BUILD_DIR environment variable. Also, for each target |
2697 | built, the MAKEALL script saves two log files (<target>.ERR and | 2700 | built, the MAKEALL script saves two log files (<target>.ERR and |
2698 | <target>.MAKEALL) in the <source dir>/LOG directory. This default | 2701 | <target>.MAKEALL) in the <source dir>/LOG directory. This default |
2699 | location can be changed by setting the MAKEALL_LOGDIR environment | 2702 | location can be changed by setting the MAKEALL_LOGDIR environment |
2700 | variable. For example: | 2703 | variable. For example: |
2701 | 2704 | ||
2702 | export BUILD_DIR=/tmp/build | 2705 | export BUILD_DIR=/tmp/build |
2703 | export MAKEALL_LOGDIR=/tmp/log | 2706 | export MAKEALL_LOGDIR=/tmp/log |
2704 | CROSS_COMPILE=ppc_8xx- MAKEALL | 2707 | CROSS_COMPILE=ppc_8xx- MAKEALL |
2705 | 2708 | ||
2706 | With the above settings build objects are saved in the /tmp/build, | 2709 | With the above settings build objects are saved in the /tmp/build, |
2707 | log files are saved in the /tmp/log and the source tree remains clean | 2710 | log files are saved in the /tmp/log and the source tree remains clean |
2708 | during the whole build process. | 2711 | during the whole build process. |
2709 | 2712 | ||
2710 | 2713 | ||
2711 | See also "U-Boot Porting Guide" below. | 2714 | See also "U-Boot Porting Guide" below. |
2712 | 2715 | ||
2713 | 2716 | ||
2714 | Monitor Commands - Overview: | 2717 | Monitor Commands - Overview: |
2715 | ============================ | 2718 | ============================ |
2716 | 2719 | ||
2717 | go - start application at address 'addr' | 2720 | go - start application at address 'addr' |
2718 | run - run commands in an environment variable | 2721 | run - run commands in an environment variable |
2719 | bootm - boot application image from memory | 2722 | bootm - boot application image from memory |
2720 | bootp - boot image via network using BootP/TFTP protocol | 2723 | bootp - boot image via network using BootP/TFTP protocol |
2721 | tftpboot- boot image via network using TFTP protocol | 2724 | tftpboot- boot image via network using TFTP protocol |
2722 | and env variables "ipaddr" and "serverip" | 2725 | and env variables "ipaddr" and "serverip" |
2723 | (and eventually "gatewayip") | 2726 | (and eventually "gatewayip") |
2724 | rarpboot- boot image via network using RARP/TFTP protocol | 2727 | rarpboot- boot image via network using RARP/TFTP protocol |
2725 | diskboot- boot from IDE devicebootd - boot default, i.e., run 'bootcmd' | 2728 | diskboot- boot from IDE devicebootd - boot default, i.e., run 'bootcmd' |
2726 | loads - load S-Record file over serial line | 2729 | loads - load S-Record file over serial line |
2727 | loadb - load binary file over serial line (kermit mode) | 2730 | loadb - load binary file over serial line (kermit mode) |
2728 | md - memory display | 2731 | md - memory display |
2729 | mm - memory modify (auto-incrementing) | 2732 | mm - memory modify (auto-incrementing) |
2730 | nm - memory modify (constant address) | 2733 | nm - memory modify (constant address) |
2731 | mw - memory write (fill) | 2734 | mw - memory write (fill) |
2732 | cp - memory copy | 2735 | cp - memory copy |
2733 | cmp - memory compare | 2736 | cmp - memory compare |
2734 | crc32 - checksum calculation | 2737 | crc32 - checksum calculation |
2735 | imd - i2c memory display | 2738 | imd - i2c memory display |
2736 | imm - i2c memory modify (auto-incrementing) | 2739 | imm - i2c memory modify (auto-incrementing) |
2737 | inm - i2c memory modify (constant address) | 2740 | inm - i2c memory modify (constant address) |
2738 | imw - i2c memory write (fill) | 2741 | imw - i2c memory write (fill) |
2739 | icrc32 - i2c checksum calculation | 2742 | icrc32 - i2c checksum calculation |
2740 | iprobe - probe to discover valid I2C chip addresses | 2743 | iprobe - probe to discover valid I2C chip addresses |
2741 | iloop - infinite loop on address range | 2744 | iloop - infinite loop on address range |
2742 | isdram - print SDRAM configuration information | 2745 | isdram - print SDRAM configuration information |
2743 | sspi - SPI utility commands | 2746 | sspi - SPI utility commands |
2744 | base - print or set address offset | 2747 | base - print or set address offset |
2745 | printenv- print environment variables | 2748 | printenv- print environment variables |
2746 | setenv - set environment variables | 2749 | setenv - set environment variables |
2747 | saveenv - save environment variables to persistent storage | 2750 | saveenv - save environment variables to persistent storage |
2748 | protect - enable or disable FLASH write protection | 2751 | protect - enable or disable FLASH write protection |
2749 | erase - erase FLASH memory | 2752 | erase - erase FLASH memory |
2750 | flinfo - print FLASH memory information | 2753 | flinfo - print FLASH memory information |
2751 | bdinfo - print Board Info structure | 2754 | bdinfo - print Board Info structure |
2752 | iminfo - print header information for application image | 2755 | iminfo - print header information for application image |
2753 | coninfo - print console devices and informations | 2756 | coninfo - print console devices and informations |
2754 | ide - IDE sub-system | 2757 | ide - IDE sub-system |
2755 | loop - infinite loop on address range | 2758 | loop - infinite loop on address range |
2756 | loopw - infinite write loop on address range | 2759 | loopw - infinite write loop on address range |
2757 | mtest - simple RAM test | 2760 | mtest - simple RAM test |
2758 | icache - enable or disable instruction cache | 2761 | icache - enable or disable instruction cache |
2759 | dcache - enable or disable data cache | 2762 | dcache - enable or disable data cache |
2760 | reset - Perform RESET of the CPU | 2763 | reset - Perform RESET of the CPU |
2761 | echo - echo args to console | 2764 | echo - echo args to console |
2762 | version - print monitor version | 2765 | version - print monitor version |
2763 | help - print online help | 2766 | help - print online help |
2764 | ? - alias for 'help' | 2767 | ? - alias for 'help' |
2765 | 2768 | ||
2766 | 2769 | ||
2767 | Monitor Commands - Detailed Description: | 2770 | Monitor Commands - Detailed Description: |
2768 | ======================================== | 2771 | ======================================== |
2769 | 2772 | ||
2770 | TODO. | 2773 | TODO. |
2771 | 2774 | ||
2772 | For now: just type "help <command>". | 2775 | For now: just type "help <command>". |
2773 | 2776 | ||
2774 | 2777 | ||
2775 | Environment Variables: | 2778 | Environment Variables: |
2776 | ====================== | 2779 | ====================== |
2777 | 2780 | ||
2778 | U-Boot supports user configuration using Environment Variables which | 2781 | U-Boot supports user configuration using Environment Variables which |
2779 | can be made persistent by saving to Flash memory. | 2782 | can be made persistent by saving to Flash memory. |
2780 | 2783 | ||
2781 | Environment Variables are set using "setenv", printed using | 2784 | Environment Variables are set using "setenv", printed using |
2782 | "printenv", and saved to Flash using "saveenv". Using "setenv" | 2785 | "printenv", and saved to Flash using "saveenv". Using "setenv" |
2783 | without a value can be used to delete a variable from the | 2786 | without a value can be used to delete a variable from the |
2784 | environment. As long as you don't save the environment you are | 2787 | environment. As long as you don't save the environment you are |
2785 | working with an in-memory copy. In case the Flash area containing the | 2788 | working with an in-memory copy. In case the Flash area containing the |
2786 | environment is erased by accident, a default environment is provided. | 2789 | environment is erased by accident, a default environment is provided. |
2787 | 2790 | ||
2788 | Some configuration options can be set using Environment Variables: | 2791 | Some configuration options can be set using Environment Variables: |
2789 | 2792 | ||
2790 | baudrate - see CONFIG_BAUDRATE | 2793 | baudrate - see CONFIG_BAUDRATE |
2791 | 2794 | ||
2792 | bootdelay - see CONFIG_BOOTDELAY | 2795 | bootdelay - see CONFIG_BOOTDELAY |
2793 | 2796 | ||
2794 | bootcmd - see CONFIG_BOOTCOMMAND | 2797 | bootcmd - see CONFIG_BOOTCOMMAND |
2795 | 2798 | ||
2796 | bootargs - Boot arguments when booting an RTOS image | 2799 | bootargs - Boot arguments when booting an RTOS image |
2797 | 2800 | ||
2798 | bootfile - Name of the image to load with TFTP | 2801 | bootfile - Name of the image to load with TFTP |
2799 | 2802 | ||
2800 | bootm_low - Memory range available for image processing in the bootm | 2803 | bootm_low - Memory range available for image processing in the bootm |
2801 | command can be restricted. This variable is given as | 2804 | command can be restricted. This variable is given as |
2802 | a hexadecimal number and defines lowest address allowed | 2805 | a hexadecimal number and defines lowest address allowed |
2803 | for use by the bootm command. See also "bootm_size" | 2806 | for use by the bootm command. See also "bootm_size" |
2804 | environment variable. Address defined by "bootm_low" is | 2807 | environment variable. Address defined by "bootm_low" is |
2805 | also the base of the initial memory mapping for the Linux | 2808 | also the base of the initial memory mapping for the Linux |
2806 | kernel -- see the description of CFG_BOOTMAPSZ. | 2809 | kernel -- see the description of CFG_BOOTMAPSZ. |
2807 | 2810 | ||
2808 | bootm_size - Memory range available for image processing in the bootm | 2811 | bootm_size - Memory range available for image processing in the bootm |
2809 | command can be restricted. This variable is given as | 2812 | command can be restricted. This variable is given as |
2810 | a hexadecimal number and defines the size of the region | 2813 | a hexadecimal number and defines the size of the region |
2811 | allowed for use by the bootm command. See also "bootm_low" | 2814 | allowed for use by the bootm command. See also "bootm_low" |
2812 | environment variable. | 2815 | environment variable. |
2813 | 2816 | ||
2814 | autoload - if set to "no" (any string beginning with 'n'), | 2817 | autoload - if set to "no" (any string beginning with 'n'), |
2815 | "bootp" will just load perform a lookup of the | 2818 | "bootp" will just load perform a lookup of the |
2816 | configuration from the BOOTP server, but not try to | 2819 | configuration from the BOOTP server, but not try to |
2817 | load any image using TFTP | 2820 | load any image using TFTP |
2818 | 2821 | ||
2819 | autoscript - if set to "yes" commands like "loadb", "loady", | 2822 | autoscript - if set to "yes" commands like "loadb", "loady", |
2820 | "bootp", "tftpb", "rarpboot" and "nfs" will attempt | 2823 | "bootp", "tftpb", "rarpboot" and "nfs" will attempt |
2821 | to automatically run script images (by internally | 2824 | to automatically run script images (by internally |
2822 | calling "autoscript"). | 2825 | calling "autoscript"). |
2823 | 2826 | ||
2824 | autoscript_uname - if script image is in a format (FIT) this | 2827 | autoscript_uname - if script image is in a format (FIT) this |
2825 | variable is used to get script subimage unit name. | 2828 | variable is used to get script subimage unit name. |
2826 | 2829 | ||
2827 | autostart - if set to "yes", an image loaded using the "bootp", | 2830 | autostart - if set to "yes", an image loaded using the "bootp", |
2828 | "rarpboot", "tftpboot" or "diskboot" commands will | 2831 | "rarpboot", "tftpboot" or "diskboot" commands will |
2829 | be automatically started (by internally calling | 2832 | be automatically started (by internally calling |
2830 | "bootm") | 2833 | "bootm") |
2831 | 2834 | ||
2832 | If set to "no", a standalone image passed to the | 2835 | If set to "no", a standalone image passed to the |
2833 | "bootm" command will be copied to the load address | 2836 | "bootm" command will be copied to the load address |
2834 | (and eventually uncompressed), but NOT be started. | 2837 | (and eventually uncompressed), but NOT be started. |
2835 | This can be used to load and uncompress arbitrary | 2838 | This can be used to load and uncompress arbitrary |
2836 | data. | 2839 | data. |
2837 | 2840 | ||
2838 | i2cfast - (PPC405GP|PPC405EP only) | 2841 | i2cfast - (PPC405GP|PPC405EP only) |
2839 | if set to 'y' configures Linux I2C driver for fast | 2842 | if set to 'y' configures Linux I2C driver for fast |
2840 | mode (400kHZ). This environment variable is used in | 2843 | mode (400kHZ). This environment variable is used in |
2841 | initialization code. So, for changes to be effective | 2844 | initialization code. So, for changes to be effective |
2842 | it must be saved and board must be reset. | 2845 | it must be saved and board must be reset. |
2843 | 2846 | ||
2844 | initrd_high - restrict positioning of initrd images: | 2847 | initrd_high - restrict positioning of initrd images: |
2845 | If this variable is not set, initrd images will be | 2848 | If this variable is not set, initrd images will be |
2846 | copied to the highest possible address in RAM; this | 2849 | copied to the highest possible address in RAM; this |
2847 | is usually what you want since it allows for | 2850 | is usually what you want since it allows for |
2848 | maximum initrd size. If for some reason you want to | 2851 | maximum initrd size. If for some reason you want to |
2849 | make sure that the initrd image is loaded below the | 2852 | make sure that the initrd image is loaded below the |
2850 | CFG_BOOTMAPSZ limit, you can set this environment | 2853 | CFG_BOOTMAPSZ limit, you can set this environment |
2851 | variable to a value of "no" or "off" or "0". | 2854 | variable to a value of "no" or "off" or "0". |
2852 | Alternatively, you can set it to a maximum upper | 2855 | Alternatively, you can set it to a maximum upper |
2853 | address to use (U-Boot will still check that it | 2856 | address to use (U-Boot will still check that it |
2854 | does not overwrite the U-Boot stack and data). | 2857 | does not overwrite the U-Boot stack and data). |
2855 | 2858 | ||
2856 | For instance, when you have a system with 16 MB | 2859 | For instance, when you have a system with 16 MB |
2857 | RAM, and want to reserve 4 MB from use by Linux, | 2860 | RAM, and want to reserve 4 MB from use by Linux, |
2858 | you can do this by adding "mem=12M" to the value of | 2861 | you can do this by adding "mem=12M" to the value of |
2859 | the "bootargs" variable. However, now you must make | 2862 | the "bootargs" variable. However, now you must make |
2860 | sure that the initrd image is placed in the first | 2863 | sure that the initrd image is placed in the first |
2861 | 12 MB as well - this can be done with | 2864 | 12 MB as well - this can be done with |
2862 | 2865 | ||
2863 | setenv initrd_high 00c00000 | 2866 | setenv initrd_high 00c00000 |
2864 | 2867 | ||
2865 | If you set initrd_high to 0xFFFFFFFF, this is an | 2868 | If you set initrd_high to 0xFFFFFFFF, this is an |
2866 | indication to U-Boot that all addresses are legal | 2869 | indication to U-Boot that all addresses are legal |
2867 | for the Linux kernel, including addresses in flash | 2870 | for the Linux kernel, including addresses in flash |
2868 | memory. In this case U-Boot will NOT COPY the | 2871 | memory. In this case U-Boot will NOT COPY the |
2869 | ramdisk at all. This may be useful to reduce the | 2872 | ramdisk at all. This may be useful to reduce the |
2870 | boot time on your system, but requires that this | 2873 | boot time on your system, but requires that this |
2871 | feature is supported by your Linux kernel. | 2874 | feature is supported by your Linux kernel. |
2872 | 2875 | ||
2873 | ipaddr - IP address; needed for tftpboot command | 2876 | ipaddr - IP address; needed for tftpboot command |
2874 | 2877 | ||
2875 | loadaddr - Default load address for commands like "bootp", | 2878 | loadaddr - Default load address for commands like "bootp", |
2876 | "rarpboot", "tftpboot", "loadb" or "diskboot" | 2879 | "rarpboot", "tftpboot", "loadb" or "diskboot" |
2877 | 2880 | ||
2878 | loads_echo - see CONFIG_LOADS_ECHO | 2881 | loads_echo - see CONFIG_LOADS_ECHO |
2879 | 2882 | ||
2880 | serverip - TFTP server IP address; needed for tftpboot command | 2883 | serverip - TFTP server IP address; needed for tftpboot command |
2881 | 2884 | ||
2882 | bootretry - see CONFIG_BOOT_RETRY_TIME | 2885 | bootretry - see CONFIG_BOOT_RETRY_TIME |
2883 | 2886 | ||
2884 | bootdelaykey - see CONFIG_AUTOBOOT_DELAY_STR | 2887 | bootdelaykey - see CONFIG_AUTOBOOT_DELAY_STR |
2885 | 2888 | ||
2886 | bootstopkey - see CONFIG_AUTOBOOT_STOP_STR | 2889 | bootstopkey - see CONFIG_AUTOBOOT_STOP_STR |
2887 | 2890 | ||
2888 | ethprime - When CONFIG_NET_MULTI is enabled controls which | 2891 | ethprime - When CONFIG_NET_MULTI is enabled controls which |
2889 | interface is used first. | 2892 | interface is used first. |
2890 | 2893 | ||
2891 | ethact - When CONFIG_NET_MULTI is enabled controls which | 2894 | ethact - When CONFIG_NET_MULTI is enabled controls which |
2892 | interface is currently active. For example you | 2895 | interface is currently active. For example you |
2893 | can do the following | 2896 | can do the following |
2894 | 2897 | ||
2895 | => setenv ethact FEC ETHERNET | 2898 | => setenv ethact FEC ETHERNET |
2896 | => ping 192.168.0.1 # traffic sent on FEC ETHERNET | 2899 | => ping 192.168.0.1 # traffic sent on FEC ETHERNET |
2897 | => setenv ethact SCC ETHERNET | 2900 | => setenv ethact SCC ETHERNET |
2898 | => ping 10.0.0.1 # traffic sent on SCC ETHERNET | 2901 | => ping 10.0.0.1 # traffic sent on SCC ETHERNET |
2899 | 2902 | ||
2900 | ethrotate - When set to "no" U-Boot does not go through all | 2903 | ethrotate - When set to "no" U-Boot does not go through all |
2901 | available network interfaces. | 2904 | available network interfaces. |
2902 | It just stays at the currently selected interface. | 2905 | It just stays at the currently selected interface. |
2903 | 2906 | ||
2904 | netretry - When set to "no" each network operation will | 2907 | netretry - When set to "no" each network operation will |
2905 | either succeed or fail without retrying. | 2908 | either succeed or fail without retrying. |
2906 | When set to "once" the network operation will | 2909 | When set to "once" the network operation will |
2907 | fail when all the available network interfaces | 2910 | fail when all the available network interfaces |
2908 | are tried once without success. | 2911 | are tried once without success. |
2909 | Useful on scripts which control the retry operation | 2912 | Useful on scripts which control the retry operation |
2910 | themselves. | 2913 | themselves. |
2911 | 2914 | ||
2912 | npe_ucode - see CONFIG_IXP4XX_NPE_EXT_UCOD | 2915 | npe_ucode - see CONFIG_IXP4XX_NPE_EXT_UCOD |
2913 | if set load address for the NPE microcode | 2916 | if set load address for the NPE microcode |
2914 | 2917 | ||
2915 | tftpsrcport - If this is set, the value is used for TFTP's | 2918 | tftpsrcport - If this is set, the value is used for TFTP's |
2916 | UDP source port. | 2919 | UDP source port. |
2917 | 2920 | ||
2918 | tftpdstport - If this is set, the value is used for TFTP's UDP | 2921 | tftpdstport - If this is set, the value is used for TFTP's UDP |
2919 | destination port instead of the Well Know Port 69. | 2922 | destination port instead of the Well Know Port 69. |
2920 | 2923 | ||
2921 | vlan - When set to a value < 4095 the traffic over | 2924 | vlan - When set to a value < 4095 the traffic over |
2922 | Ethernet is encapsulated/received over 802.1q | 2925 | Ethernet is encapsulated/received over 802.1q |
2923 | VLAN tagged frames. | 2926 | VLAN tagged frames. |
2924 | 2927 | ||
2925 | The following environment variables may be used and automatically | 2928 | The following environment variables may be used and automatically |
2926 | updated by the network boot commands ("bootp" and "rarpboot"), | 2929 | updated by the network boot commands ("bootp" and "rarpboot"), |
2927 | depending the information provided by your boot server: | 2930 | depending the information provided by your boot server: |
2928 | 2931 | ||
2929 | bootfile - see above | 2932 | bootfile - see above |
2930 | dnsip - IP address of your Domain Name Server | 2933 | dnsip - IP address of your Domain Name Server |
2931 | dnsip2 - IP address of your secondary Domain Name Server | 2934 | dnsip2 - IP address of your secondary Domain Name Server |
2932 | gatewayip - IP address of the Gateway (Router) to use | 2935 | gatewayip - IP address of the Gateway (Router) to use |
2933 | hostname - Target hostname | 2936 | hostname - Target hostname |
2934 | ipaddr - see above | 2937 | ipaddr - see above |
2935 | netmask - Subnet Mask | 2938 | netmask - Subnet Mask |
2936 | rootpath - Pathname of the root filesystem on the NFS server | 2939 | rootpath - Pathname of the root filesystem on the NFS server |
2937 | serverip - see above | 2940 | serverip - see above |
2938 | 2941 | ||
2939 | 2942 | ||
2940 | There are two special Environment Variables: | 2943 | There are two special Environment Variables: |
2941 | 2944 | ||
2942 | serial# - contains hardware identification information such | 2945 | serial# - contains hardware identification information such |
2943 | as type string and/or serial number | 2946 | as type string and/or serial number |
2944 | ethaddr - Ethernet address | 2947 | ethaddr - Ethernet address |
2945 | 2948 | ||
2946 | These variables can be set only once (usually during manufacturing of | 2949 | These variables can be set only once (usually during manufacturing of |
2947 | the board). U-Boot refuses to delete or overwrite these variables | 2950 | the board). U-Boot refuses to delete or overwrite these variables |
2948 | once they have been set once. | 2951 | once they have been set once. |
2949 | 2952 | ||
2950 | 2953 | ||
2951 | Further special Environment Variables: | 2954 | Further special Environment Variables: |
2952 | 2955 | ||
2953 | ver - Contains the U-Boot version string as printed | 2956 | ver - Contains the U-Boot version string as printed |
2954 | with the "version" command. This variable is | 2957 | with the "version" command. This variable is |
2955 | readonly (see CONFIG_VERSION_VARIABLE). | 2958 | readonly (see CONFIG_VERSION_VARIABLE). |
2956 | 2959 | ||
2957 | 2960 | ||
2958 | Please note that changes to some configuration parameters may take | 2961 | Please note that changes to some configuration parameters may take |
2959 | only effect after the next boot (yes, that's just like Windoze :-). | 2962 | only effect after the next boot (yes, that's just like Windoze :-). |
2960 | 2963 | ||
2961 | 2964 | ||
2962 | Command Line Parsing: | 2965 | Command Line Parsing: |
2963 | ===================== | 2966 | ===================== |
2964 | 2967 | ||
2965 | There are two different command line parsers available with U-Boot: | 2968 | There are two different command line parsers available with U-Boot: |
2966 | the old "simple" one, and the much more powerful "hush" shell: | 2969 | the old "simple" one, and the much more powerful "hush" shell: |
2967 | 2970 | ||
2968 | Old, simple command line parser: | 2971 | Old, simple command line parser: |
2969 | -------------------------------- | 2972 | -------------------------------- |
2970 | 2973 | ||
2971 | - supports environment variables (through setenv / saveenv commands) | 2974 | - supports environment variables (through setenv / saveenv commands) |
2972 | - several commands on one line, separated by ';' | 2975 | - several commands on one line, separated by ';' |
2973 | - variable substitution using "... ${name} ..." syntax | 2976 | - variable substitution using "... ${name} ..." syntax |
2974 | - special characters ('$', ';') can be escaped by prefixing with '\', | 2977 | - special characters ('$', ';') can be escaped by prefixing with '\', |
2975 | for example: | 2978 | for example: |
2976 | setenv bootcmd bootm \${address} | 2979 | setenv bootcmd bootm \${address} |
2977 | - You can also escape text by enclosing in single apostrophes, for example: | 2980 | - You can also escape text by enclosing in single apostrophes, for example: |
2978 | setenv addip 'setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname::off' | 2981 | setenv addip 'setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname::off' |
2979 | 2982 | ||
2980 | Hush shell: | 2983 | Hush shell: |
2981 | ----------- | 2984 | ----------- |
2982 | 2985 | ||
2983 | - similar to Bourne shell, with control structures like | 2986 | - similar to Bourne shell, with control structures like |
2984 | if...then...else...fi, for...do...done; while...do...done, | 2987 | if...then...else...fi, for...do...done; while...do...done, |
2985 | until...do...done, ... | 2988 | until...do...done, ... |
2986 | - supports environment ("global") variables (through setenv / saveenv | 2989 | - supports environment ("global") variables (through setenv / saveenv |
2987 | commands) and local shell variables (through standard shell syntax | 2990 | commands) and local shell variables (through standard shell syntax |
2988 | "name=value"); only environment variables can be used with "run" | 2991 | "name=value"); only environment variables can be used with "run" |
2989 | command | 2992 | command |
2990 | 2993 | ||
2991 | General rules: | 2994 | General rules: |
2992 | -------------- | 2995 | -------------- |
2993 | 2996 | ||
2994 | (1) If a command line (or an environment variable executed by a "run" | 2997 | (1) If a command line (or an environment variable executed by a "run" |
2995 | command) contains several commands separated by semicolon, and | 2998 | command) contains several commands separated by semicolon, and |
2996 | one of these commands fails, then the remaining commands will be | 2999 | one of these commands fails, then the remaining commands will be |
2997 | executed anyway. | 3000 | executed anyway. |
2998 | 3001 | ||
2999 | (2) If you execute several variables with one call to run (i. e. | 3002 | (2) If you execute several variables with one call to run (i. e. |
3000 | calling run with a list of variables as arguments), any failing | 3003 | calling run with a list of variables as arguments), any failing |
3001 | command will cause "run" to terminate, i. e. the remaining | 3004 | command will cause "run" to terminate, i. e. the remaining |
3002 | variables are not executed. | 3005 | variables are not executed. |
3003 | 3006 | ||
3004 | Note for Redundant Ethernet Interfaces: | 3007 | Note for Redundant Ethernet Interfaces: |
3005 | ======================================= | 3008 | ======================================= |
3006 | 3009 | ||
3007 | Some boards come with redundant Ethernet interfaces; U-Boot supports | 3010 | Some boards come with redundant Ethernet interfaces; U-Boot supports |
3008 | such configurations and is capable of automatic selection of a | 3011 | such configurations and is capable of automatic selection of a |
3009 | "working" interface when needed. MAC assignment works as follows: | 3012 | "working" interface when needed. MAC assignment works as follows: |
3010 | 3013 | ||
3011 | Network interfaces are numbered eth0, eth1, eth2, ... Corresponding | 3014 | Network interfaces are numbered eth0, eth1, eth2, ... Corresponding |
3012 | MAC addresses can be stored in the environment as "ethaddr" (=>eth0), | 3015 | MAC addresses can be stored in the environment as "ethaddr" (=>eth0), |
3013 | "eth1addr" (=>eth1), "eth2addr", ... | 3016 | "eth1addr" (=>eth1), "eth2addr", ... |
3014 | 3017 | ||
3015 | If the network interface stores some valid MAC address (for instance | 3018 | If the network interface stores some valid MAC address (for instance |
3016 | in SROM), this is used as default address if there is NO correspon- | 3019 | in SROM), this is used as default address if there is NO correspon- |
3017 | ding setting in the environment; if the corresponding environment | 3020 | ding setting in the environment; if the corresponding environment |
3018 | variable is set, this overrides the settings in the card; that means: | 3021 | variable is set, this overrides the settings in the card; that means: |
3019 | 3022 | ||
3020 | o If the SROM has a valid MAC address, and there is no address in the | 3023 | o If the SROM has a valid MAC address, and there is no address in the |
3021 | environment, the SROM's address is used. | 3024 | environment, the SROM's address is used. |
3022 | 3025 | ||
3023 | o If there is no valid address in the SROM, and a definition in the | 3026 | o If there is no valid address in the SROM, and a definition in the |
3024 | environment exists, then the value from the environment variable is | 3027 | environment exists, then the value from the environment variable is |
3025 | used. | 3028 | used. |
3026 | 3029 | ||
3027 | o If both the SROM and the environment contain a MAC address, and | 3030 | o If both the SROM and the environment contain a MAC address, and |
3028 | both addresses are the same, this MAC address is used. | 3031 | both addresses are the same, this MAC address is used. |
3029 | 3032 | ||
3030 | o If both the SROM and the environment contain a MAC address, and the | 3033 | o If both the SROM and the environment contain a MAC address, and the |
3031 | addresses differ, the value from the environment is used and a | 3034 | addresses differ, the value from the environment is used and a |
3032 | warning is printed. | 3035 | warning is printed. |
3033 | 3036 | ||
3034 | o If neither SROM nor the environment contain a MAC address, an error | 3037 | o If neither SROM nor the environment contain a MAC address, an error |
3035 | is raised. | 3038 | is raised. |
3036 | 3039 | ||
3037 | 3040 | ||
3038 | Image Formats: | 3041 | Image Formats: |
3039 | ============== | 3042 | ============== |
3040 | 3043 | ||
3041 | U-Boot is capable of booting (and performing other auxiliary operations on) | 3044 | U-Boot is capable of booting (and performing other auxiliary operations on) |
3042 | images in two formats: | 3045 | images in two formats: |
3043 | 3046 | ||
3044 | New uImage format (FIT) | 3047 | New uImage format (FIT) |
3045 | ----------------------- | 3048 | ----------------------- |
3046 | 3049 | ||
3047 | Flexible and powerful format based on Flattened Image Tree -- FIT (similar | 3050 | Flexible and powerful format based on Flattened Image Tree -- FIT (similar |
3048 | to Flattened Device Tree). It allows the use of images with multiple | 3051 | to Flattened Device Tree). It allows the use of images with multiple |
3049 | components (several kernels, ramdisks, etc.), with contents protected by | 3052 | components (several kernels, ramdisks, etc.), with contents protected by |
3050 | SHA1, MD5 or CRC32. More details are found in the doc/uImage.FIT directory. | 3053 | SHA1, MD5 or CRC32. More details are found in the doc/uImage.FIT directory. |
3051 | 3054 | ||
3052 | 3055 | ||
3053 | Old uImage format | 3056 | Old uImage format |
3054 | ----------------- | 3057 | ----------------- |
3055 | 3058 | ||
3056 | Old image format is based on binary files which can be basically anything, | 3059 | Old image format is based on binary files which can be basically anything, |
3057 | preceded by a special header; see the definitions in include/image.h for | 3060 | preceded by a special header; see the definitions in include/image.h for |
3058 | details; basically, the header defines the following image properties: | 3061 | details; basically, the header defines the following image properties: |
3059 | 3062 | ||
3060 | * Target Operating System (Provisions for OpenBSD, NetBSD, FreeBSD, | 3063 | * Target Operating System (Provisions for OpenBSD, NetBSD, FreeBSD, |
3061 | 4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO, Dell, NCR, VxWorks, | 3064 | 4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO, Dell, NCR, VxWorks, |
3062 | LynxOS, pSOS, QNX, RTEMS, INTEGRITY; | 3065 | LynxOS, pSOS, QNX, RTEMS, INTEGRITY; |
3063 | Currently supported: Linux, NetBSD, VxWorks, QNX, RTEMS, LynxOS, | 3066 | Currently supported: Linux, NetBSD, VxWorks, QNX, RTEMS, LynxOS, |
3064 | INTEGRITY). | 3067 | INTEGRITY). |
3065 | * Target CPU Architecture (Provisions for Alpha, ARM, AVR32, Intel x86, | 3068 | * Target CPU Architecture (Provisions for Alpha, ARM, AVR32, Intel x86, |
3066 | IA64, MIPS, NIOS, PowerPC, IBM S390, SuperH, Sparc, Sparc 64 Bit; | 3069 | IA64, MIPS, NIOS, PowerPC, IBM S390, SuperH, Sparc, Sparc 64 Bit; |
3067 | Currently supported: ARM, AVR32, Intel x86, MIPS, NIOS, PowerPC). | 3070 | Currently supported: ARM, AVR32, Intel x86, MIPS, NIOS, PowerPC). |
3068 | * Compression Type (uncompressed, gzip, bzip2) | 3071 | * Compression Type (uncompressed, gzip, bzip2) |
3069 | * Load Address | 3072 | * Load Address |
3070 | * Entry Point | 3073 | * Entry Point |
3071 | * Image Name | 3074 | * Image Name |
3072 | * Image Timestamp | 3075 | * Image Timestamp |
3073 | 3076 | ||
3074 | The header is marked by a special Magic Number, and both the header | 3077 | The header is marked by a special Magic Number, and both the header |
3075 | and the data portions of the image are secured against corruption by | 3078 | and the data portions of the image are secured against corruption by |
3076 | CRC32 checksums. | 3079 | CRC32 checksums. |
3077 | 3080 | ||
3078 | 3081 | ||
3079 | Linux Support: | 3082 | Linux Support: |
3080 | ============== | 3083 | ============== |
3081 | 3084 | ||
3082 | Although U-Boot should support any OS or standalone application | 3085 | Although U-Boot should support any OS or standalone application |
3083 | easily, the main focus has always been on Linux during the design of | 3086 | easily, the main focus has always been on Linux during the design of |
3084 | U-Boot. | 3087 | U-Boot. |
3085 | 3088 | ||
3086 | U-Boot includes many features that so far have been part of some | 3089 | U-Boot includes many features that so far have been part of some |
3087 | special "boot loader" code within the Linux kernel. Also, any | 3090 | special "boot loader" code within the Linux kernel. Also, any |
3088 | "initrd" images to be used are no longer part of one big Linux image; | 3091 | "initrd" images to be used are no longer part of one big Linux image; |
3089 | instead, kernel and "initrd" are separate images. This implementation | 3092 | instead, kernel and "initrd" are separate images. This implementation |
3090 | serves several purposes: | 3093 | serves several purposes: |
3091 | 3094 | ||
3092 | - the same features can be used for other OS or standalone | 3095 | - the same features can be used for other OS or standalone |
3093 | applications (for instance: using compressed images to reduce the | 3096 | applications (for instance: using compressed images to reduce the |
3094 | Flash memory footprint) | 3097 | Flash memory footprint) |
3095 | 3098 | ||
3096 | - it becomes much easier to port new Linux kernel versions because | 3099 | - it becomes much easier to port new Linux kernel versions because |
3097 | lots of low-level, hardware dependent stuff are done by U-Boot | 3100 | lots of low-level, hardware dependent stuff are done by U-Boot |
3098 | 3101 | ||
3099 | - the same Linux kernel image can now be used with different "initrd" | 3102 | - the same Linux kernel image can now be used with different "initrd" |
3100 | images; of course this also means that different kernel images can | 3103 | images; of course this also means that different kernel images can |
3101 | be run with the same "initrd". This makes testing easier (you don't | 3104 | be run with the same "initrd". This makes testing easier (you don't |
3102 | have to build a new "zImage.initrd" Linux image when you just | 3105 | have to build a new "zImage.initrd" Linux image when you just |
3103 | change a file in your "initrd"). Also, a field-upgrade of the | 3106 | change a file in your "initrd"). Also, a field-upgrade of the |
3104 | software is easier now. | 3107 | software is easier now. |
3105 | 3108 | ||
3106 | 3109 | ||
3107 | Linux HOWTO: | 3110 | Linux HOWTO: |
3108 | ============ | 3111 | ============ |
3109 | 3112 | ||
3110 | Porting Linux to U-Boot based systems: | 3113 | Porting Linux to U-Boot based systems: |
3111 | --------------------------------------- | 3114 | --------------------------------------- |
3112 | 3115 | ||
3113 | U-Boot cannot save you from doing all the necessary modifications to | 3116 | U-Boot cannot save you from doing all the necessary modifications to |
3114 | configure the Linux device drivers for use with your target hardware | 3117 | configure the Linux device drivers for use with your target hardware |
3115 | (no, we don't intend to provide a full virtual machine interface to | 3118 | (no, we don't intend to provide a full virtual machine interface to |
3116 | Linux :-). | 3119 | Linux :-). |
3117 | 3120 | ||
3118 | But now you can ignore ALL boot loader code (in arch/ppc/mbxboot). | 3121 | But now you can ignore ALL boot loader code (in arch/ppc/mbxboot). |
3119 | 3122 | ||
3120 | Just make sure your machine specific header file (for instance | 3123 | Just make sure your machine specific header file (for instance |
3121 | include/asm-ppc/tqm8xx.h) includes the same definition of the Board | 3124 | include/asm-ppc/tqm8xx.h) includes the same definition of the Board |
3122 | Information structure as we define in include/asm-<arch>/u-boot.h, | 3125 | Information structure as we define in include/asm-<arch>/u-boot.h, |
3123 | and make sure that your definition of IMAP_ADDR uses the same value | 3126 | and make sure that your definition of IMAP_ADDR uses the same value |
3124 | as your U-Boot configuration in CFG_IMMR. | 3127 | as your U-Boot configuration in CFG_IMMR. |
3125 | 3128 | ||
3126 | 3129 | ||
3127 | Configuring the Linux kernel: | 3130 | Configuring the Linux kernel: |
3128 | ----------------------------- | 3131 | ----------------------------- |
3129 | 3132 | ||
3130 | No specific requirements for U-Boot. Make sure you have some root | 3133 | No specific requirements for U-Boot. Make sure you have some root |
3131 | device (initial ramdisk, NFS) for your target system. | 3134 | device (initial ramdisk, NFS) for your target system. |
3132 | 3135 | ||
3133 | 3136 | ||
3134 | Building a Linux Image: | 3137 | Building a Linux Image: |
3135 | ----------------------- | 3138 | ----------------------- |
3136 | 3139 | ||
3137 | With U-Boot, "normal" build targets like "zImage" or "bzImage" are | 3140 | With U-Boot, "normal" build targets like "zImage" or "bzImage" are |
3138 | not used. If you use recent kernel source, a new build target | 3141 | not used. If you use recent kernel source, a new build target |
3139 | "uImage" will exist which automatically builds an image usable by | 3142 | "uImage" will exist which automatically builds an image usable by |
3140 | U-Boot. Most older kernels also have support for a "pImage" target, | 3143 | U-Boot. Most older kernels also have support for a "pImage" target, |
3141 | which was introduced for our predecessor project PPCBoot and uses a | 3144 | which was introduced for our predecessor project PPCBoot and uses a |
3142 | 100% compatible format. | 3145 | 100% compatible format. |
3143 | 3146 | ||
3144 | Example: | 3147 | Example: |
3145 | 3148 | ||
3146 | make TQM850L_config | 3149 | make TQM850L_config |
3147 | make oldconfig | 3150 | make oldconfig |
3148 | make dep | 3151 | make dep |
3149 | make uImage | 3152 | make uImage |
3150 | 3153 | ||
3151 | The "uImage" build target uses a special tool (in 'tools/mkimage') to | 3154 | The "uImage" build target uses a special tool (in 'tools/mkimage') to |
3152 | encapsulate a compressed Linux kernel image with header information, | 3155 | encapsulate a compressed Linux kernel image with header information, |
3153 | CRC32 checksum etc. for use with U-Boot. This is what we are doing: | 3156 | CRC32 checksum etc. for use with U-Boot. This is what we are doing: |
3154 | 3157 | ||
3155 | * build a standard "vmlinux" kernel image (in ELF binary format): | 3158 | * build a standard "vmlinux" kernel image (in ELF binary format): |
3156 | 3159 | ||
3157 | * convert the kernel into a raw binary image: | 3160 | * convert the kernel into a raw binary image: |
3158 | 3161 | ||
3159 | ${CROSS_COMPILE}-objcopy -O binary \ | 3162 | ${CROSS_COMPILE}-objcopy -O binary \ |
3160 | -R .note -R .comment \ | 3163 | -R .note -R .comment \ |
3161 | -S vmlinux linux.bin | 3164 | -S vmlinux linux.bin |
3162 | 3165 | ||
3163 | * compress the binary image: | 3166 | * compress the binary image: |
3164 | 3167 | ||
3165 | gzip -9 linux.bin | 3168 | gzip -9 linux.bin |
3166 | 3169 | ||
3167 | * package compressed binary image for U-Boot: | 3170 | * package compressed binary image for U-Boot: |
3168 | 3171 | ||
3169 | mkimage -A ppc -O linux -T kernel -C gzip \ | 3172 | mkimage -A ppc -O linux -T kernel -C gzip \ |
3170 | -a 0 -e 0 -n "Linux Kernel Image" \ | 3173 | -a 0 -e 0 -n "Linux Kernel Image" \ |
3171 | -d linux.bin.gz uImage | 3174 | -d linux.bin.gz uImage |
3172 | 3175 | ||
3173 | 3176 | ||
3174 | The "mkimage" tool can also be used to create ramdisk images for use | 3177 | The "mkimage" tool can also be used to create ramdisk images for use |
3175 | with U-Boot, either separated from the Linux kernel image, or | 3178 | with U-Boot, either separated from the Linux kernel image, or |
3176 | combined into one file. "mkimage" encapsulates the images with a 64 | 3179 | combined into one file. "mkimage" encapsulates the images with a 64 |
3177 | byte header containing information about target architecture, | 3180 | byte header containing information about target architecture, |
3178 | operating system, image type, compression method, entry points, time | 3181 | operating system, image type, compression method, entry points, time |
3179 | stamp, CRC32 checksums, etc. | 3182 | stamp, CRC32 checksums, etc. |
3180 | 3183 | ||
3181 | "mkimage" can be called in two ways: to verify existing images and | 3184 | "mkimage" can be called in two ways: to verify existing images and |
3182 | print the header information, or to build new images. | 3185 | print the header information, or to build new images. |
3183 | 3186 | ||
3184 | In the first form (with "-l" option) mkimage lists the information | 3187 | In the first form (with "-l" option) mkimage lists the information |
3185 | contained in the header of an existing U-Boot image; this includes | 3188 | contained in the header of an existing U-Boot image; this includes |
3186 | checksum verification: | 3189 | checksum verification: |
3187 | 3190 | ||
3188 | tools/mkimage -l image | 3191 | tools/mkimage -l image |
3189 | -l ==> list image header information | 3192 | -l ==> list image header information |
3190 | 3193 | ||
3191 | The second form (with "-d" option) is used to build a U-Boot image | 3194 | The second form (with "-d" option) is used to build a U-Boot image |
3192 | from a "data file" which is used as image payload: | 3195 | from a "data file" which is used as image payload: |
3193 | 3196 | ||
3194 | tools/mkimage -A arch -O os -T type -C comp -a addr -e ep \ | 3197 | tools/mkimage -A arch -O os -T type -C comp -a addr -e ep \ |
3195 | -n name -d data_file image | 3198 | -n name -d data_file image |
3196 | -A ==> set architecture to 'arch' | 3199 | -A ==> set architecture to 'arch' |
3197 | -O ==> set operating system to 'os' | 3200 | -O ==> set operating system to 'os' |
3198 | -T ==> set image type to 'type' | 3201 | -T ==> set image type to 'type' |
3199 | -C ==> set compression type 'comp' | 3202 | -C ==> set compression type 'comp' |
3200 | -a ==> set load address to 'addr' (hex) | 3203 | -a ==> set load address to 'addr' (hex) |
3201 | -e ==> set entry point to 'ep' (hex) | 3204 | -e ==> set entry point to 'ep' (hex) |
3202 | -n ==> set image name to 'name' | 3205 | -n ==> set image name to 'name' |
3203 | -d ==> use image data from 'datafile' | 3206 | -d ==> use image data from 'datafile' |
3204 | 3207 | ||
3205 | Right now, all Linux kernels for PowerPC systems use the same load | 3208 | Right now, all Linux kernels for PowerPC systems use the same load |
3206 | address (0x00000000), but the entry point address depends on the | 3209 | address (0x00000000), but the entry point address depends on the |
3207 | kernel version: | 3210 | kernel version: |
3208 | 3211 | ||
3209 | - 2.2.x kernels have the entry point at 0x0000000C, | 3212 | - 2.2.x kernels have the entry point at 0x0000000C, |
3210 | - 2.3.x and later kernels have the entry point at 0x00000000. | 3213 | - 2.3.x and later kernels have the entry point at 0x00000000. |
3211 | 3214 | ||
3212 | So a typical call to build a U-Boot image would read: | 3215 | So a typical call to build a U-Boot image would read: |
3213 | 3216 | ||
3214 | -> tools/mkimage -n '2.4.4 kernel for TQM850L' \ | 3217 | -> tools/mkimage -n '2.4.4 kernel for TQM850L' \ |
3215 | > -A ppc -O linux -T kernel -C gzip -a 0 -e 0 \ | 3218 | > -A ppc -O linux -T kernel -C gzip -a 0 -e 0 \ |
3216 | > -d /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux.gz \ | 3219 | > -d /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux.gz \ |
3217 | > examples/uImage.TQM850L | 3220 | > examples/uImage.TQM850L |
3218 | Image Name: 2.4.4 kernel for TQM850L | 3221 | Image Name: 2.4.4 kernel for TQM850L |
3219 | Created: Wed Jul 19 02:34:59 2000 | 3222 | Created: Wed Jul 19 02:34:59 2000 |
3220 | Image Type: PowerPC Linux Kernel Image (gzip compressed) | 3223 | Image Type: PowerPC Linux Kernel Image (gzip compressed) |
3221 | Data Size: 335725 Bytes = 327.86 kB = 0.32 MB | 3224 | Data Size: 335725 Bytes = 327.86 kB = 0.32 MB |
3222 | Load Address: 0x00000000 | 3225 | Load Address: 0x00000000 |
3223 | Entry Point: 0x00000000 | 3226 | Entry Point: 0x00000000 |
3224 | 3227 | ||
3225 | To verify the contents of the image (or check for corruption): | 3228 | To verify the contents of the image (or check for corruption): |
3226 | 3229 | ||
3227 | -> tools/mkimage -l examples/uImage.TQM850L | 3230 | -> tools/mkimage -l examples/uImage.TQM850L |
3228 | Image Name: 2.4.4 kernel for TQM850L | 3231 | Image Name: 2.4.4 kernel for TQM850L |
3229 | Created: Wed Jul 19 02:34:59 2000 | 3232 | Created: Wed Jul 19 02:34:59 2000 |
3230 | Image Type: PowerPC Linux Kernel Image (gzip compressed) | 3233 | Image Type: PowerPC Linux Kernel Image (gzip compressed) |
3231 | Data Size: 335725 Bytes = 327.86 kB = 0.32 MB | 3234 | Data Size: 335725 Bytes = 327.86 kB = 0.32 MB |
3232 | Load Address: 0x00000000 | 3235 | Load Address: 0x00000000 |
3233 | Entry Point: 0x00000000 | 3236 | Entry Point: 0x00000000 |
3234 | 3237 | ||
3235 | NOTE: for embedded systems where boot time is critical you can trade | 3238 | NOTE: for embedded systems where boot time is critical you can trade |
3236 | speed for memory and install an UNCOMPRESSED image instead: this | 3239 | speed for memory and install an UNCOMPRESSED image instead: this |
3237 | needs more space in Flash, but boots much faster since it does not | 3240 | needs more space in Flash, but boots much faster since it does not |
3238 | need to be uncompressed: | 3241 | need to be uncompressed: |
3239 | 3242 | ||
3240 | -> gunzip /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux.gz | 3243 | -> gunzip /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux.gz |
3241 | -> tools/mkimage -n '2.4.4 kernel for TQM850L' \ | 3244 | -> tools/mkimage -n '2.4.4 kernel for TQM850L' \ |
3242 | > -A ppc -O linux -T kernel -C none -a 0 -e 0 \ | 3245 | > -A ppc -O linux -T kernel -C none -a 0 -e 0 \ |
3243 | > -d /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux \ | 3246 | > -d /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux \ |
3244 | > examples/uImage.TQM850L-uncompressed | 3247 | > examples/uImage.TQM850L-uncompressed |
3245 | Image Name: 2.4.4 kernel for TQM850L | 3248 | Image Name: 2.4.4 kernel for TQM850L |
3246 | Created: Wed Jul 19 02:34:59 2000 | 3249 | Created: Wed Jul 19 02:34:59 2000 |
3247 | Image Type: PowerPC Linux Kernel Image (uncompressed) | 3250 | Image Type: PowerPC Linux Kernel Image (uncompressed) |
3248 | Data Size: 792160 Bytes = 773.59 kB = 0.76 MB | 3251 | Data Size: 792160 Bytes = 773.59 kB = 0.76 MB |
3249 | Load Address: 0x00000000 | 3252 | Load Address: 0x00000000 |
3250 | Entry Point: 0x00000000 | 3253 | Entry Point: 0x00000000 |
3251 | 3254 | ||
3252 | 3255 | ||
3253 | Similar you can build U-Boot images from a 'ramdisk.image.gz' file | 3256 | Similar you can build U-Boot images from a 'ramdisk.image.gz' file |
3254 | when your kernel is intended to use an initial ramdisk: | 3257 | when your kernel is intended to use an initial ramdisk: |
3255 | 3258 | ||
3256 | -> tools/mkimage -n 'Simple Ramdisk Image' \ | 3259 | -> tools/mkimage -n 'Simple Ramdisk Image' \ |
3257 | > -A ppc -O linux -T ramdisk -C gzip \ | 3260 | > -A ppc -O linux -T ramdisk -C gzip \ |
3258 | > -d /LinuxPPC/images/SIMPLE-ramdisk.image.gz examples/simple-initrd | 3261 | > -d /LinuxPPC/images/SIMPLE-ramdisk.image.gz examples/simple-initrd |
3259 | Image Name: Simple Ramdisk Image | 3262 | Image Name: Simple Ramdisk Image |
3260 | Created: Wed Jan 12 14:01:50 2000 | 3263 | Created: Wed Jan 12 14:01:50 2000 |
3261 | Image Type: PowerPC Linux RAMDisk Image (gzip compressed) | 3264 | Image Type: PowerPC Linux RAMDisk Image (gzip compressed) |
3262 | Data Size: 566530 Bytes = 553.25 kB = 0.54 MB | 3265 | Data Size: 566530 Bytes = 553.25 kB = 0.54 MB |
3263 | Load Address: 0x00000000 | 3266 | Load Address: 0x00000000 |
3264 | Entry Point: 0x00000000 | 3267 | Entry Point: 0x00000000 |
3265 | 3268 | ||
3266 | 3269 | ||
3267 | Installing a Linux Image: | 3270 | Installing a Linux Image: |
3268 | ------------------------- | 3271 | ------------------------- |
3269 | 3272 | ||
3270 | To downloading a U-Boot image over the serial (console) interface, | 3273 | To downloading a U-Boot image over the serial (console) interface, |
3271 | you must convert the image to S-Record format: | 3274 | you must convert the image to S-Record format: |
3272 | 3275 | ||
3273 | objcopy -I binary -O srec examples/image examples/image.srec | 3276 | objcopy -I binary -O srec examples/image examples/image.srec |
3274 | 3277 | ||
3275 | The 'objcopy' does not understand the information in the U-Boot | 3278 | The 'objcopy' does not understand the information in the U-Boot |
3276 | image header, so the resulting S-Record file will be relative to | 3279 | image header, so the resulting S-Record file will be relative to |
3277 | address 0x00000000. To load it to a given address, you need to | 3280 | address 0x00000000. To load it to a given address, you need to |
3278 | specify the target address as 'offset' parameter with the 'loads' | 3281 | specify the target address as 'offset' parameter with the 'loads' |
3279 | command. | 3282 | command. |
3280 | 3283 | ||
3281 | Example: install the image to address 0x40100000 (which on the | 3284 | Example: install the image to address 0x40100000 (which on the |
3282 | TQM8xxL is in the first Flash bank): | 3285 | TQM8xxL is in the first Flash bank): |
3283 | 3286 | ||
3284 | => erase 40100000 401FFFFF | 3287 | => erase 40100000 401FFFFF |
3285 | 3288 | ||
3286 | .......... done | 3289 | .......... done |
3287 | Erased 8 sectors | 3290 | Erased 8 sectors |
3288 | 3291 | ||
3289 | => loads 40100000 | 3292 | => loads 40100000 |
3290 | ## Ready for S-Record download ... | 3293 | ## Ready for S-Record download ... |
3291 | ~>examples/image.srec | 3294 | ~>examples/image.srec |
3292 | 1 2 3 4 5 6 7 8 9 10 11 12 13 ... | 3295 | 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
3293 | ... | 3296 | ... |
3294 | 15989 15990 15991 15992 | 3297 | 15989 15990 15991 15992 |
3295 | [file transfer complete] | 3298 | [file transfer complete] |
3296 | [connected] | 3299 | [connected] |
3297 | ## Start Addr = 0x00000000 | 3300 | ## Start Addr = 0x00000000 |
3298 | 3301 | ||
3299 | 3302 | ||
3300 | You can check the success of the download using the 'iminfo' command; | 3303 | You can check the success of the download using the 'iminfo' command; |
3301 | this includes a checksum verification so you can be sure no data | 3304 | this includes a checksum verification so you can be sure no data |
3302 | corruption happened: | 3305 | corruption happened: |
3303 | 3306 | ||
3304 | => imi 40100000 | 3307 | => imi 40100000 |
3305 | 3308 | ||
3306 | ## Checking Image at 40100000 ... | 3309 | ## Checking Image at 40100000 ... |
3307 | Image Name: 2.2.13 for initrd on TQM850L | 3310 | Image Name: 2.2.13 for initrd on TQM850L |
3308 | Image Type: PowerPC Linux Kernel Image (gzip compressed) | 3311 | Image Type: PowerPC Linux Kernel Image (gzip compressed) |
3309 | Data Size: 335725 Bytes = 327 kB = 0 MB | 3312 | Data Size: 335725 Bytes = 327 kB = 0 MB |
3310 | Load Address: 00000000 | 3313 | Load Address: 00000000 |
3311 | Entry Point: 0000000c | 3314 | Entry Point: 0000000c |
3312 | Verifying Checksum ... OK | 3315 | Verifying Checksum ... OK |
3313 | 3316 | ||
3314 | 3317 | ||
3315 | Boot Linux: | 3318 | Boot Linux: |
3316 | ----------- | 3319 | ----------- |
3317 | 3320 | ||
3318 | The "bootm" command is used to boot an application that is stored in | 3321 | The "bootm" command is used to boot an application that is stored in |
3319 | memory (RAM or Flash). In case of a Linux kernel image, the contents | 3322 | memory (RAM or Flash). In case of a Linux kernel image, the contents |
3320 | of the "bootargs" environment variable is passed to the kernel as | 3323 | of the "bootargs" environment variable is passed to the kernel as |
3321 | parameters. You can check and modify this variable using the | 3324 | parameters. You can check and modify this variable using the |
3322 | "printenv" and "setenv" commands: | 3325 | "printenv" and "setenv" commands: |
3323 | 3326 | ||
3324 | 3327 | ||
3325 | => printenv bootargs | 3328 | => printenv bootargs |
3326 | bootargs=root=/dev/ram | 3329 | bootargs=root=/dev/ram |
3327 | 3330 | ||
3328 | => setenv bootargs root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2 | 3331 | => setenv bootargs root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2 |
3329 | 3332 | ||
3330 | => printenv bootargs | 3333 | => printenv bootargs |
3331 | bootargs=root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2 | 3334 | bootargs=root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2 |
3332 | 3335 | ||
3333 | => bootm 40020000 | 3336 | => bootm 40020000 |
3334 | ## Booting Linux kernel at 40020000 ... | 3337 | ## Booting Linux kernel at 40020000 ... |
3335 | Image Name: 2.2.13 for NFS on TQM850L | 3338 | Image Name: 2.2.13 for NFS on TQM850L |
3336 | Image Type: PowerPC Linux Kernel Image (gzip compressed) | 3339 | Image Type: PowerPC Linux Kernel Image (gzip compressed) |
3337 | Data Size: 381681 Bytes = 372 kB = 0 MB | 3340 | Data Size: 381681 Bytes = 372 kB = 0 MB |
3338 | Load Address: 00000000 | 3341 | Load Address: 00000000 |
3339 | Entry Point: 0000000c | 3342 | Entry Point: 0000000c |
3340 | Verifying Checksum ... OK | 3343 | Verifying Checksum ... OK |
3341 | Uncompressing Kernel Image ... OK | 3344 | Uncompressing Kernel Image ... OK |
3342 | Linux version 2.2.13 (wd@denx.local.net) (gcc version 2.95.2 19991024 (release)) #1 Wed Jul 19 02:35:17 MEST 2000 | 3345 | Linux version 2.2.13 (wd@denx.local.net) (gcc version 2.95.2 19991024 (release)) #1 Wed Jul 19 02:35:17 MEST 2000 |
3343 | Boot arguments: root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2 | 3346 | Boot arguments: root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2 |
3344 | time_init: decrementer frequency = 187500000/60 | 3347 | time_init: decrementer frequency = 187500000/60 |
3345 | Calibrating delay loop... 49.77 BogoMIPS | 3348 | Calibrating delay loop... 49.77 BogoMIPS |
3346 | Memory: 15208k available (700k kernel code, 444k data, 32k init) [c0000000,c1000000] | 3349 | Memory: 15208k available (700k kernel code, 444k data, 32k init) [c0000000,c1000000] |
3347 | ... | 3350 | ... |
3348 | 3351 | ||
3349 | If you want to boot a Linux kernel with initial RAM disk, you pass | 3352 | If you want to boot a Linux kernel with initial RAM disk, you pass |
3350 | the memory addresses of both the kernel and the initrd image (PPBCOOT | 3353 | the memory addresses of both the kernel and the initrd image (PPBCOOT |
3351 | format!) to the "bootm" command: | 3354 | format!) to the "bootm" command: |
3352 | 3355 | ||
3353 | => imi 40100000 40200000 | 3356 | => imi 40100000 40200000 |
3354 | 3357 | ||
3355 | ## Checking Image at 40100000 ... | 3358 | ## Checking Image at 40100000 ... |
3356 | Image Name: 2.2.13 for initrd on TQM850L | 3359 | Image Name: 2.2.13 for initrd on TQM850L |
3357 | Image Type: PowerPC Linux Kernel Image (gzip compressed) | 3360 | Image Type: PowerPC Linux Kernel Image (gzip compressed) |
3358 | Data Size: 335725 Bytes = 327 kB = 0 MB | 3361 | Data Size: 335725 Bytes = 327 kB = 0 MB |
3359 | Load Address: 00000000 | 3362 | Load Address: 00000000 |
3360 | Entry Point: 0000000c | 3363 | Entry Point: 0000000c |
3361 | Verifying Checksum ... OK | 3364 | Verifying Checksum ... OK |
3362 | 3365 | ||
3363 | ## Checking Image at 40200000 ... | 3366 | ## Checking Image at 40200000 ... |
3364 | Image Name: Simple Ramdisk Image | 3367 | Image Name: Simple Ramdisk Image |
3365 | Image Type: PowerPC Linux RAMDisk Image (gzip compressed) | 3368 | Image Type: PowerPC Linux RAMDisk Image (gzip compressed) |
3366 | Data Size: 566530 Bytes = 553 kB = 0 MB | 3369 | Data Size: 566530 Bytes = 553 kB = 0 MB |
3367 | Load Address: 00000000 | 3370 | Load Address: 00000000 |
3368 | Entry Point: 00000000 | 3371 | Entry Point: 00000000 |
3369 | Verifying Checksum ... OK | 3372 | Verifying Checksum ... OK |
3370 | 3373 | ||
3371 | => bootm 40100000 40200000 | 3374 | => bootm 40100000 40200000 |
3372 | ## Booting Linux kernel at 40100000 ... | 3375 | ## Booting Linux kernel at 40100000 ... |
3373 | Image Name: 2.2.13 for initrd on TQM850L | 3376 | Image Name: 2.2.13 for initrd on TQM850L |
3374 | Image Type: PowerPC Linux Kernel Image (gzip compressed) | 3377 | Image Type: PowerPC Linux Kernel Image (gzip compressed) |
3375 | Data Size: 335725 Bytes = 327 kB = 0 MB | 3378 | Data Size: 335725 Bytes = 327 kB = 0 MB |
3376 | Load Address: 00000000 | 3379 | Load Address: 00000000 |
3377 | Entry Point: 0000000c | 3380 | Entry Point: 0000000c |
3378 | Verifying Checksum ... OK | 3381 | Verifying Checksum ... OK |
3379 | Uncompressing Kernel Image ... OK | 3382 | Uncompressing Kernel Image ... OK |
3380 | ## Loading RAMDisk Image at 40200000 ... | 3383 | ## Loading RAMDisk Image at 40200000 ... |
3381 | Image Name: Simple Ramdisk Image | 3384 | Image Name: Simple Ramdisk Image |
3382 | Image Type: PowerPC Linux RAMDisk Image (gzip compressed) | 3385 | Image Type: PowerPC Linux RAMDisk Image (gzip compressed) |
3383 | Data Size: 566530 Bytes = 553 kB = 0 MB | 3386 | Data Size: 566530 Bytes = 553 kB = 0 MB |
3384 | Load Address: 00000000 | 3387 | Load Address: 00000000 |
3385 | Entry Point: 00000000 | 3388 | Entry Point: 00000000 |
3386 | Verifying Checksum ... OK | 3389 | Verifying Checksum ... OK |
3387 | Loading Ramdisk ... OK | 3390 | Loading Ramdisk ... OK |
3388 | Linux version 2.2.13 (wd@denx.local.net) (gcc version 2.95.2 19991024 (release)) #1 Wed Jul 19 02:32:08 MEST 2000 | 3391 | Linux version 2.2.13 (wd@denx.local.net) (gcc version 2.95.2 19991024 (release)) #1 Wed Jul 19 02:32:08 MEST 2000 |
3389 | Boot arguments: root=/dev/ram | 3392 | Boot arguments: root=/dev/ram |
3390 | time_init: decrementer frequency = 187500000/60 | 3393 | time_init: decrementer frequency = 187500000/60 |
3391 | Calibrating delay loop... 49.77 BogoMIPS | 3394 | Calibrating delay loop... 49.77 BogoMIPS |
3392 | ... | 3395 | ... |
3393 | RAMDISK: Compressed image found at block 0 | 3396 | RAMDISK: Compressed image found at block 0 |
3394 | VFS: Mounted root (ext2 filesystem). | 3397 | VFS: Mounted root (ext2 filesystem). |
3395 | 3398 | ||
3396 | bash# | 3399 | bash# |
3397 | 3400 | ||
3398 | Boot Linux and pass a flat device tree: | 3401 | Boot Linux and pass a flat device tree: |
3399 | ----------- | 3402 | ----------- |
3400 | 3403 | ||
3401 | First, U-Boot must be compiled with the appropriate defines. See the section | 3404 | First, U-Boot must be compiled with the appropriate defines. See the section |
3402 | titled "Linux Kernel Interface" above for a more in depth explanation. The | 3405 | titled "Linux Kernel Interface" above for a more in depth explanation. The |
3403 | following is an example of how to start a kernel and pass an updated | 3406 | following is an example of how to start a kernel and pass an updated |
3404 | flat device tree: | 3407 | flat device tree: |
3405 | 3408 | ||
3406 | => print oftaddr | 3409 | => print oftaddr |
3407 | oftaddr=0x300000 | 3410 | oftaddr=0x300000 |
3408 | => print oft | 3411 | => print oft |
3409 | oft=oftrees/mpc8540ads.dtb | 3412 | oft=oftrees/mpc8540ads.dtb |
3410 | => tftp $oftaddr $oft | 3413 | => tftp $oftaddr $oft |
3411 | Speed: 1000, full duplex | 3414 | Speed: 1000, full duplex |
3412 | Using TSEC0 device | 3415 | Using TSEC0 device |
3413 | TFTP from server 192.168.1.1; our IP address is 192.168.1.101 | 3416 | TFTP from server 192.168.1.1; our IP address is 192.168.1.101 |
3414 | Filename 'oftrees/mpc8540ads.dtb'. | 3417 | Filename 'oftrees/mpc8540ads.dtb'. |
3415 | Load address: 0x300000 | 3418 | Load address: 0x300000 |
3416 | Loading: # | 3419 | Loading: # |
3417 | done | 3420 | done |
3418 | Bytes transferred = 4106 (100a hex) | 3421 | Bytes transferred = 4106 (100a hex) |
3419 | => tftp $loadaddr $bootfile | 3422 | => tftp $loadaddr $bootfile |
3420 | Speed: 1000, full duplex | 3423 | Speed: 1000, full duplex |
3421 | Using TSEC0 device | 3424 | Using TSEC0 device |
3422 | TFTP from server 192.168.1.1; our IP address is 192.168.1.2 | 3425 | TFTP from server 192.168.1.1; our IP address is 192.168.1.2 |
3423 | Filename 'uImage'. | 3426 | Filename 'uImage'. |
3424 | Load address: 0x200000 | 3427 | Load address: 0x200000 |
3425 | Loading:############ | 3428 | Loading:############ |
3426 | done | 3429 | done |
3427 | Bytes transferred = 1029407 (fb51f hex) | 3430 | Bytes transferred = 1029407 (fb51f hex) |
3428 | => print loadaddr | 3431 | => print loadaddr |
3429 | loadaddr=200000 | 3432 | loadaddr=200000 |
3430 | => print oftaddr | 3433 | => print oftaddr |
3431 | oftaddr=0x300000 | 3434 | oftaddr=0x300000 |
3432 | => bootm $loadaddr - $oftaddr | 3435 | => bootm $loadaddr - $oftaddr |
3433 | ## Booting image at 00200000 ... | 3436 | ## Booting image at 00200000 ... |
3434 | Image Name: Linux-2.6.17-dirty | 3437 | Image Name: Linux-2.6.17-dirty |
3435 | Image Type: PowerPC Linux Kernel Image (gzip compressed) | 3438 | Image Type: PowerPC Linux Kernel Image (gzip compressed) |
3436 | Data Size: 1029343 Bytes = 1005.2 kB | 3439 | Data Size: 1029343 Bytes = 1005.2 kB |
3437 | Load Address: 00000000 | 3440 | Load Address: 00000000 |
3438 | Entry Point: 00000000 | 3441 | Entry Point: 00000000 |
3439 | Verifying Checksum ... OK | 3442 | Verifying Checksum ... OK |
3440 | Uncompressing Kernel Image ... OK | 3443 | Uncompressing Kernel Image ... OK |
3441 | Booting using flat device tree at 0x300000 | 3444 | Booting using flat device tree at 0x300000 |
3442 | Using MPC85xx ADS machine description | 3445 | Using MPC85xx ADS machine description |
3443 | Memory CAM mapping: CAM0=256Mb, CAM1=256Mb, CAM2=0Mb residual: 0Mb | 3446 | Memory CAM mapping: CAM0=256Mb, CAM1=256Mb, CAM2=0Mb residual: 0Mb |
3444 | [snip] | 3447 | [snip] |
3445 | 3448 | ||
3446 | 3449 | ||
3447 | More About U-Boot Image Types: | 3450 | More About U-Boot Image Types: |
3448 | ------------------------------ | 3451 | ------------------------------ |
3449 | 3452 | ||
3450 | U-Boot supports the following image types: | 3453 | U-Boot supports the following image types: |
3451 | 3454 | ||
3452 | "Standalone Programs" are directly runnable in the environment | 3455 | "Standalone Programs" are directly runnable in the environment |
3453 | provided by U-Boot; it is expected that (if they behave | 3456 | provided by U-Boot; it is expected that (if they behave |
3454 | well) you can continue to work in U-Boot after return from | 3457 | well) you can continue to work in U-Boot after return from |
3455 | the Standalone Program. | 3458 | the Standalone Program. |
3456 | "OS Kernel Images" are usually images of some Embedded OS which | 3459 | "OS Kernel Images" are usually images of some Embedded OS which |
3457 | will take over control completely. Usually these programs | 3460 | will take over control completely. Usually these programs |
3458 | will install their own set of exception handlers, device | 3461 | will install their own set of exception handlers, device |
3459 | drivers, set up the MMU, etc. - this means, that you cannot | 3462 | drivers, set up the MMU, etc. - this means, that you cannot |
3460 | expect to re-enter U-Boot except by resetting the CPU. | 3463 | expect to re-enter U-Boot except by resetting the CPU. |
3461 | "RAMDisk Images" are more or less just data blocks, and their | 3464 | "RAMDisk Images" are more or less just data blocks, and their |
3462 | parameters (address, size) are passed to an OS kernel that is | 3465 | parameters (address, size) are passed to an OS kernel that is |
3463 | being started. | 3466 | being started. |
3464 | "Multi-File Images" contain several images, typically an OS | 3467 | "Multi-File Images" contain several images, typically an OS |
3465 | (Linux) kernel image and one or more data images like | 3468 | (Linux) kernel image and one or more data images like |
3466 | RAMDisks. This construct is useful for instance when you want | 3469 | RAMDisks. This construct is useful for instance when you want |
3467 | to boot over the network using BOOTP etc., where the boot | 3470 | to boot over the network using BOOTP etc., where the boot |
3468 | server provides just a single image file, but you want to get | 3471 | server provides just a single image file, but you want to get |
3469 | for instance an OS kernel and a RAMDisk image. | 3472 | for instance an OS kernel and a RAMDisk image. |
3470 | 3473 | ||
3471 | "Multi-File Images" start with a list of image sizes, each | 3474 | "Multi-File Images" start with a list of image sizes, each |
3472 | image size (in bytes) specified by an "uint32_t" in network | 3475 | image size (in bytes) specified by an "uint32_t" in network |
3473 | byte order. This list is terminated by an "(uint32_t)0". | 3476 | byte order. This list is terminated by an "(uint32_t)0". |
3474 | Immediately after the terminating 0 follow the images, one by | 3477 | Immediately after the terminating 0 follow the images, one by |
3475 | one, all aligned on "uint32_t" boundaries (size rounded up to | 3478 | one, all aligned on "uint32_t" boundaries (size rounded up to |
3476 | a multiple of 4 bytes). | 3479 | a multiple of 4 bytes). |
3477 | 3480 | ||
3478 | "Firmware Images" are binary images containing firmware (like | 3481 | "Firmware Images" are binary images containing firmware (like |
3479 | U-Boot or FPGA images) which usually will be programmed to | 3482 | U-Boot or FPGA images) which usually will be programmed to |
3480 | flash memory. | 3483 | flash memory. |
3481 | 3484 | ||
3482 | "Script files" are command sequences that will be executed by | 3485 | "Script files" are command sequences that will be executed by |
3483 | U-Boot's command interpreter; this feature is especially | 3486 | U-Boot's command interpreter; this feature is especially |
3484 | useful when you configure U-Boot to use a real shell (hush) | 3487 | useful when you configure U-Boot to use a real shell (hush) |
3485 | as command interpreter. | 3488 | as command interpreter. |
3486 | 3489 | ||
3487 | 3490 | ||
3488 | Standalone HOWTO: | 3491 | Standalone HOWTO: |
3489 | ================= | 3492 | ================= |
3490 | 3493 | ||
3491 | One of the features of U-Boot is that you can dynamically load and | 3494 | One of the features of U-Boot is that you can dynamically load and |
3492 | run "standalone" applications, which can use some resources of | 3495 | run "standalone" applications, which can use some resources of |
3493 | U-Boot like console I/O functions or interrupt services. | 3496 | U-Boot like console I/O functions or interrupt services. |
3494 | 3497 | ||
3495 | Two simple examples are included with the sources: | 3498 | Two simple examples are included with the sources: |
3496 | 3499 | ||
3497 | "Hello World" Demo: | 3500 | "Hello World" Demo: |
3498 | ------------------- | 3501 | ------------------- |
3499 | 3502 | ||
3500 | 'examples/hello_world.c' contains a small "Hello World" Demo | 3503 | 'examples/hello_world.c' contains a small "Hello World" Demo |
3501 | application; it is automatically compiled when you build U-Boot. | 3504 | application; it is automatically compiled when you build U-Boot. |
3502 | It's configured to run at address 0x00040004, so you can play with it | 3505 | It's configured to run at address 0x00040004, so you can play with it |
3503 | like that: | 3506 | like that: |
3504 | 3507 | ||
3505 | => loads | 3508 | => loads |
3506 | ## Ready for S-Record download ... | 3509 | ## Ready for S-Record download ... |
3507 | ~>examples/hello_world.srec | 3510 | ~>examples/hello_world.srec |
3508 | 1 2 3 4 5 6 7 8 9 10 11 ... | 3511 | 1 2 3 4 5 6 7 8 9 10 11 ... |
3509 | [file transfer complete] | 3512 | [file transfer complete] |
3510 | [connected] | 3513 | [connected] |
3511 | ## Start Addr = 0x00040004 | 3514 | ## Start Addr = 0x00040004 |
3512 | 3515 | ||
3513 | => go 40004 Hello World! This is a test. | 3516 | => go 40004 Hello World! This is a test. |
3514 | ## Starting application at 0x00040004 ... | 3517 | ## Starting application at 0x00040004 ... |
3515 | Hello World | 3518 | Hello World |
3516 | argc = 7 | 3519 | argc = 7 |
3517 | argv[0] = "40004" | 3520 | argv[0] = "40004" |
3518 | argv[1] = "Hello" | 3521 | argv[1] = "Hello" |
3519 | argv[2] = "World!" | 3522 | argv[2] = "World!" |
3520 | argv[3] = "This" | 3523 | argv[3] = "This" |
3521 | argv[4] = "is" | 3524 | argv[4] = "is" |
3522 | argv[5] = "a" | 3525 | argv[5] = "a" |
3523 | argv[6] = "test." | 3526 | argv[6] = "test." |
3524 | argv[7] = "<NULL>" | 3527 | argv[7] = "<NULL>" |
3525 | Hit any key to exit ... | 3528 | Hit any key to exit ... |
3526 | 3529 | ||
3527 | ## Application terminated, rc = 0x0 | 3530 | ## Application terminated, rc = 0x0 |
3528 | 3531 | ||
3529 | Another example, which demonstrates how to register a CPM interrupt | 3532 | Another example, which demonstrates how to register a CPM interrupt |
3530 | handler with the U-Boot code, can be found in 'examples/timer.c'. | 3533 | handler with the U-Boot code, can be found in 'examples/timer.c'. |
3531 | Here, a CPM timer is set up to generate an interrupt every second. | 3534 | Here, a CPM timer is set up to generate an interrupt every second. |
3532 | The interrupt service routine is trivial, just printing a '.' | 3535 | The interrupt service routine is trivial, just printing a '.' |
3533 | character, but this is just a demo program. The application can be | 3536 | character, but this is just a demo program. The application can be |
3534 | controlled by the following keys: | 3537 | controlled by the following keys: |
3535 | 3538 | ||
3536 | ? - print current values og the CPM Timer registers | 3539 | ? - print current values og the CPM Timer registers |
3537 | b - enable interrupts and start timer | 3540 | b - enable interrupts and start timer |
3538 | e - stop timer and disable interrupts | 3541 | e - stop timer and disable interrupts |
3539 | q - quit application | 3542 | q - quit application |
3540 | 3543 | ||
3541 | => loads | 3544 | => loads |
3542 | ## Ready for S-Record download ... | 3545 | ## Ready for S-Record download ... |
3543 | ~>examples/timer.srec | 3546 | ~>examples/timer.srec |
3544 | 1 2 3 4 5 6 7 8 9 10 11 ... | 3547 | 1 2 3 4 5 6 7 8 9 10 11 ... |
3545 | [file transfer complete] | 3548 | [file transfer complete] |
3546 | [connected] | 3549 | [connected] |
3547 | ## Start Addr = 0x00040004 | 3550 | ## Start Addr = 0x00040004 |
3548 | 3551 | ||
3549 | => go 40004 | 3552 | => go 40004 |
3550 | ## Starting application at 0x00040004 ... | 3553 | ## Starting application at 0x00040004 ... |
3551 | TIMERS=0xfff00980 | 3554 | TIMERS=0xfff00980 |
3552 | Using timer 1 | 3555 | Using timer 1 |
3553 | tgcr @ 0xfff00980, tmr @ 0xfff00990, trr @ 0xfff00994, tcr @ 0xfff00998, tcn @ 0xfff0099c, ter @ 0xfff009b0 | 3556 | tgcr @ 0xfff00980, tmr @ 0xfff00990, trr @ 0xfff00994, tcr @ 0xfff00998, tcn @ 0xfff0099c, ter @ 0xfff009b0 |
3554 | 3557 | ||
3555 | Hit 'b': | 3558 | Hit 'b': |
3556 | [q, b, e, ?] Set interval 1000000 us | 3559 | [q, b, e, ?] Set interval 1000000 us |
3557 | Enabling timer | 3560 | Enabling timer |
3558 | Hit '?': | 3561 | Hit '?': |
3559 | [q, b, e, ?] ........ | 3562 | [q, b, e, ?] ........ |
3560 | tgcr=0x1, tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0xef6, ter=0x0 | 3563 | tgcr=0x1, tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0xef6, ter=0x0 |
3561 | Hit '?': | 3564 | Hit '?': |
3562 | [q, b, e, ?] . | 3565 | [q, b, e, ?] . |
3563 | tgcr=0x1, tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x2ad4, ter=0x0 | 3566 | tgcr=0x1, tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x2ad4, ter=0x0 |
3564 | Hit '?': | 3567 | Hit '?': |
3565 | [q, b, e, ?] . | 3568 | [q, b, e, ?] . |
3566 | tgcr=0x1, tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x1efc, ter=0x0 | 3569 | tgcr=0x1, tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x1efc, ter=0x0 |
3567 | Hit '?': | 3570 | Hit '?': |
3568 | [q, b, e, ?] . | 3571 | [q, b, e, ?] . |
3569 | tgcr=0x1, tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x169d, ter=0x0 | 3572 | tgcr=0x1, tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x169d, ter=0x0 |
3570 | Hit 'e': | 3573 | Hit 'e': |
3571 | [q, b, e, ?] ...Stopping timer | 3574 | [q, b, e, ?] ...Stopping timer |
3572 | Hit 'q': | 3575 | Hit 'q': |
3573 | [q, b, e, ?] ## Application terminated, rc = 0x0 | 3576 | [q, b, e, ?] ## Application terminated, rc = 0x0 |
3574 | 3577 | ||
3575 | 3578 | ||
3576 | Minicom warning: | 3579 | Minicom warning: |
3577 | ================ | 3580 | ================ |
3578 | 3581 | ||
3579 | Over time, many people have reported problems when trying to use the | 3582 | Over time, many people have reported problems when trying to use the |
3580 | "minicom" terminal emulation program for serial download. I (wd) | 3583 | "minicom" terminal emulation program for serial download. I (wd) |
3581 | consider minicom to be broken, and recommend not to use it. Under | 3584 | consider minicom to be broken, and recommend not to use it. Under |
3582 | Unix, I recommend to use C-Kermit for general purpose use (and | 3585 | Unix, I recommend to use C-Kermit for general purpose use (and |
3583 | especially for kermit binary protocol download ("loadb" command), and | 3586 | especially for kermit binary protocol download ("loadb" command), and |
3584 | use "cu" for S-Record download ("loads" command). | 3587 | use "cu" for S-Record download ("loads" command). |
3585 | 3588 | ||
3586 | Nevertheless, if you absolutely want to use it try adding this | 3589 | Nevertheless, if you absolutely want to use it try adding this |
3587 | configuration to your "File transfer protocols" section: | 3590 | configuration to your "File transfer protocols" section: |
3588 | 3591 | ||
3589 | Name Program Name U/D FullScr IO-Red. Multi | 3592 | Name Program Name U/D FullScr IO-Red. Multi |
3590 | X kermit /usr/bin/kermit -i -l %l -s Y U Y N N | 3593 | X kermit /usr/bin/kermit -i -l %l -s Y U Y N N |
3591 | Y kermit /usr/bin/kermit -i -l %l -r N D Y N N | 3594 | Y kermit /usr/bin/kermit -i -l %l -r N D Y N N |
3592 | 3595 | ||
3593 | 3596 | ||
3594 | NetBSD Notes: | 3597 | NetBSD Notes: |
3595 | ============= | 3598 | ============= |
3596 | 3599 | ||
3597 | Starting at version 0.9.2, U-Boot supports NetBSD both as host | 3600 | Starting at version 0.9.2, U-Boot supports NetBSD both as host |
3598 | (build U-Boot) and target system (boots NetBSD/mpc8xx). | 3601 | (build U-Boot) and target system (boots NetBSD/mpc8xx). |
3599 | 3602 | ||
3600 | Building requires a cross environment; it is known to work on | 3603 | Building requires a cross environment; it is known to work on |
3601 | NetBSD/i386 with the cross-powerpc-netbsd-1.3 package (you will also | 3604 | NetBSD/i386 with the cross-powerpc-netbsd-1.3 package (you will also |
3602 | need gmake since the Makefiles are not compatible with BSD make). | 3605 | need gmake since the Makefiles are not compatible with BSD make). |
3603 | Note that the cross-powerpc package does not install include files; | 3606 | Note that the cross-powerpc package does not install include files; |
3604 | attempting to build U-Boot will fail because <machine/ansi.h> is | 3607 | attempting to build U-Boot will fail because <machine/ansi.h> is |
3605 | missing. This file has to be installed and patched manually: | 3608 | missing. This file has to be installed and patched manually: |
3606 | 3609 | ||
3607 | # cd /usr/pkg/cross/powerpc-netbsd/include | 3610 | # cd /usr/pkg/cross/powerpc-netbsd/include |
3608 | # mkdir powerpc | 3611 | # mkdir powerpc |
3609 | # ln -s powerpc machine | 3612 | # ln -s powerpc machine |
3610 | # cp /usr/src/sys/arch/powerpc/include/ansi.h powerpc/ansi.h | 3613 | # cp /usr/src/sys/arch/powerpc/include/ansi.h powerpc/ansi.h |
3611 | # ${EDIT} powerpc/ansi.h ## must remove __va_list, _BSD_VA_LIST | 3614 | # ${EDIT} powerpc/ansi.h ## must remove __va_list, _BSD_VA_LIST |
3612 | 3615 | ||
3613 | Native builds *don't* work due to incompatibilities between native | 3616 | Native builds *don't* work due to incompatibilities between native |
3614 | and U-Boot include files. | 3617 | and U-Boot include files. |
3615 | 3618 | ||
3616 | Booting assumes that (the first part of) the image booted is a | 3619 | Booting assumes that (the first part of) the image booted is a |
3617 | stage-2 loader which in turn loads and then invokes the kernel | 3620 | stage-2 loader which in turn loads and then invokes the kernel |
3618 | proper. Loader sources will eventually appear in the NetBSD source | 3621 | proper. Loader sources will eventually appear in the NetBSD source |
3619 | tree (probably in sys/arc/mpc8xx/stand/u-boot_stage2/); in the | 3622 | tree (probably in sys/arc/mpc8xx/stand/u-boot_stage2/); in the |
3620 | meantime, see ftp://ftp.denx.de/pub/u-boot/ppcboot_stage2.tar.gz | 3623 | meantime, see ftp://ftp.denx.de/pub/u-boot/ppcboot_stage2.tar.gz |
3621 | 3624 | ||
3622 | 3625 | ||
3623 | Implementation Internals: | 3626 | Implementation Internals: |
3624 | ========================= | 3627 | ========================= |
3625 | 3628 | ||
3626 | The following is not intended to be a complete description of every | 3629 | The following is not intended to be a complete description of every |
3627 | implementation detail. However, it should help to understand the | 3630 | implementation detail. However, it should help to understand the |
3628 | inner workings of U-Boot and make it easier to port it to custom | 3631 | inner workings of U-Boot and make it easier to port it to custom |
3629 | hardware. | 3632 | hardware. |
3630 | 3633 | ||
3631 | 3634 | ||
3632 | Initial Stack, Global Data: | 3635 | Initial Stack, Global Data: |
3633 | --------------------------- | 3636 | --------------------------- |
3634 | 3637 | ||
3635 | The implementation of U-Boot is complicated by the fact that U-Boot | 3638 | The implementation of U-Boot is complicated by the fact that U-Boot |
3636 | starts running out of ROM (flash memory), usually without access to | 3639 | starts running out of ROM (flash memory), usually without access to |
3637 | system RAM (because the memory controller is not initialized yet). | 3640 | system RAM (because the memory controller is not initialized yet). |
3638 | This means that we don't have writable Data or BSS segments, and BSS | 3641 | This means that we don't have writable Data or BSS segments, and BSS |
3639 | is not initialized as zero. To be able to get a C environment working | 3642 | is not initialized as zero. To be able to get a C environment working |
3640 | at all, we have to allocate at least a minimal stack. Implementation | 3643 | at all, we have to allocate at least a minimal stack. Implementation |
3641 | options for this are defined and restricted by the CPU used: Some CPU | 3644 | options for this are defined and restricted by the CPU used: Some CPU |
3642 | models provide on-chip memory (like the IMMR area on MPC8xx and | 3645 | models provide on-chip memory (like the IMMR area on MPC8xx and |
3643 | MPC826x processors), on others (parts of) the data cache can be | 3646 | MPC826x processors), on others (parts of) the data cache can be |
3644 | locked as (mis-) used as memory, etc. | 3647 | locked as (mis-) used as memory, etc. |
3645 | 3648 | ||
3646 | Chris Hallinan posted a good summary of these issues to the | 3649 | Chris Hallinan posted a good summary of these issues to the |
3647 | u-boot-users mailing list: | 3650 | u-boot-users mailing list: |
3648 | 3651 | ||
3649 | Subject: RE: [U-Boot-Users] RE: More On Memory Bank x (nothingness)? | 3652 | Subject: RE: [U-Boot-Users] RE: More On Memory Bank x (nothingness)? |
3650 | From: "Chris Hallinan" <clh@net1plus.com> | 3653 | From: "Chris Hallinan" <clh@net1plus.com> |
3651 | Date: Mon, 10 Feb 2003 16:43:46 -0500 (22:43 MET) | 3654 | Date: Mon, 10 Feb 2003 16:43:46 -0500 (22:43 MET) |
3652 | ... | 3655 | ... |
3653 | 3656 | ||
3654 | Correct me if I'm wrong, folks, but the way I understand it | 3657 | Correct me if I'm wrong, folks, but the way I understand it |
3655 | is this: Using DCACHE as initial RAM for Stack, etc, does not | 3658 | is this: Using DCACHE as initial RAM for Stack, etc, does not |
3656 | require any physical RAM backing up the cache. The cleverness | 3659 | require any physical RAM backing up the cache. The cleverness |
3657 | is that the cache is being used as a temporary supply of | 3660 | is that the cache is being used as a temporary supply of |
3658 | necessary storage before the SDRAM controller is setup. It's | 3661 | necessary storage before the SDRAM controller is setup. It's |
3659 | beyond the scope of this list to explain the details, but you | 3662 | beyond the scope of this list to explain the details, but you |
3660 | can see how this works by studying the cache architecture and | 3663 | can see how this works by studying the cache architecture and |
3661 | operation in the architecture and processor-specific manuals. | 3664 | operation in the architecture and processor-specific manuals. |
3662 | 3665 | ||
3663 | OCM is On Chip Memory, which I believe the 405GP has 4K. It | 3666 | OCM is On Chip Memory, which I believe the 405GP has 4K. It |
3664 | is another option for the system designer to use as an | 3667 | is another option for the system designer to use as an |
3665 | initial stack/RAM area prior to SDRAM being available. Either | 3668 | initial stack/RAM area prior to SDRAM being available. Either |
3666 | option should work for you. Using CS 4 should be fine if your | 3669 | option should work for you. Using CS 4 should be fine if your |
3667 | board designers haven't used it for something that would | 3670 | board designers haven't used it for something that would |
3668 | cause you grief during the initial boot! It is frequently not | 3671 | cause you grief during the initial boot! It is frequently not |
3669 | used. | 3672 | used. |
3670 | 3673 | ||
3671 | CFG_INIT_RAM_ADDR should be somewhere that won't interfere | 3674 | CFG_INIT_RAM_ADDR should be somewhere that won't interfere |
3672 | with your processor/board/system design. The default value | 3675 | with your processor/board/system design. The default value |
3673 | you will find in any recent u-boot distribution in | 3676 | you will find in any recent u-boot distribution in |
3674 | walnut.h should work for you. I'd set it to a value larger | 3677 | walnut.h should work for you. I'd set it to a value larger |
3675 | than your SDRAM module. If you have a 64MB SDRAM module, set | 3678 | than your SDRAM module. If you have a 64MB SDRAM module, set |
3676 | it above 400_0000. Just make sure your board has no resources | 3679 | it above 400_0000. Just make sure your board has no resources |
3677 | that are supposed to respond to that address! That code in | 3680 | that are supposed to respond to that address! That code in |
3678 | start.S has been around a while and should work as is when | 3681 | start.S has been around a while and should work as is when |
3679 | you get the config right. | 3682 | you get the config right. |
3680 | 3683 | ||
3681 | -Chris Hallinan | 3684 | -Chris Hallinan |
3682 | DS4.COM, Inc. | 3685 | DS4.COM, Inc. |
3683 | 3686 | ||
3684 | It is essential to remember this, since it has some impact on the C | 3687 | It is essential to remember this, since it has some impact on the C |
3685 | code for the initialization procedures: | 3688 | code for the initialization procedures: |
3686 | 3689 | ||
3687 | * Initialized global data (data segment) is read-only. Do not attempt | 3690 | * Initialized global data (data segment) is read-only. Do not attempt |
3688 | to write it. | 3691 | to write it. |
3689 | 3692 | ||
3690 | * Do not use any uninitialized global data (or implicitely initialized | 3693 | * Do not use any uninitialized global data (or implicitely initialized |
3691 | as zero data - BSS segment) at all - this is undefined, initiali- | 3694 | as zero data - BSS segment) at all - this is undefined, initiali- |
3692 | zation is performed later (when relocating to RAM). | 3695 | zation is performed later (when relocating to RAM). |
3693 | 3696 | ||
3694 | * Stack space is very limited. Avoid big data buffers or things like | 3697 | * Stack space is very limited. Avoid big data buffers or things like |
3695 | that. | 3698 | that. |
3696 | 3699 | ||
3697 | Having only the stack as writable memory limits means we cannot use | 3700 | Having only the stack as writable memory limits means we cannot use |
3698 | normal global data to share information beween the code. But it | 3701 | normal global data to share information beween the code. But it |
3699 | turned out that the implementation of U-Boot can be greatly | 3702 | turned out that the implementation of U-Boot can be greatly |
3700 | simplified by making a global data structure (gd_t) available to all | 3703 | simplified by making a global data structure (gd_t) available to all |
3701 | functions. We could pass a pointer to this data as argument to _all_ | 3704 | functions. We could pass a pointer to this data as argument to _all_ |
3702 | functions, but this would bloat the code. Instead we use a feature of | 3705 | functions, but this would bloat the code. Instead we use a feature of |
3703 | the GCC compiler (Global Register Variables) to share the data: we | 3706 | the GCC compiler (Global Register Variables) to share the data: we |
3704 | place a pointer (gd) to the global data into a register which we | 3707 | place a pointer (gd) to the global data into a register which we |
3705 | reserve for this purpose. | 3708 | reserve for this purpose. |
3706 | 3709 | ||
3707 | When choosing a register for such a purpose we are restricted by the | 3710 | When choosing a register for such a purpose we are restricted by the |
3708 | relevant (E)ABI specifications for the current architecture, and by | 3711 | relevant (E)ABI specifications for the current architecture, and by |
3709 | GCC's implementation. | 3712 | GCC's implementation. |
3710 | 3713 | ||
3711 | For PowerPC, the following registers have specific use: | 3714 | For PowerPC, the following registers have specific use: |
3712 | R1: stack pointer | 3715 | R1: stack pointer |
3713 | R2: reserved for system use | 3716 | R2: reserved for system use |
3714 | R3-R4: parameter passing and return values | 3717 | R3-R4: parameter passing and return values |
3715 | R5-R10: parameter passing | 3718 | R5-R10: parameter passing |
3716 | R13: small data area pointer | 3719 | R13: small data area pointer |
3717 | R30: GOT pointer | 3720 | R30: GOT pointer |
3718 | R31: frame pointer | 3721 | R31: frame pointer |
3719 | 3722 | ||
3720 | (U-Boot also uses R14 as internal GOT pointer.) | 3723 | (U-Boot also uses R14 as internal GOT pointer.) |
3721 | 3724 | ||
3722 | ==> U-Boot will use R2 to hold a pointer to the global data | 3725 | ==> U-Boot will use R2 to hold a pointer to the global data |
3723 | 3726 | ||
3724 | Note: on PPC, we could use a static initializer (since the | 3727 | Note: on PPC, we could use a static initializer (since the |
3725 | address of the global data structure is known at compile time), | 3728 | address of the global data structure is known at compile time), |
3726 | but it turned out that reserving a register results in somewhat | 3729 | but it turned out that reserving a register results in somewhat |
3727 | smaller code - although the code savings are not that big (on | 3730 | smaller code - although the code savings are not that big (on |
3728 | average for all boards 752 bytes for the whole U-Boot image, | 3731 | average for all boards 752 bytes for the whole U-Boot image, |
3729 | 624 text + 127 data). | 3732 | 624 text + 127 data). |
3730 | 3733 | ||
3731 | On Blackfin, the normal C ABI (except for P5) is followed as documented here: | 3734 | On Blackfin, the normal C ABI (except for P5) is followed as documented here: |
3732 | http://docs.blackfin.uclinux.org/doku.php?id=application_binary_interface | 3735 | http://docs.blackfin.uclinux.org/doku.php?id=application_binary_interface |
3733 | 3736 | ||
3734 | ==> U-Boot will use P5 to hold a pointer to the global data | 3737 | ==> U-Boot will use P5 to hold a pointer to the global data |
3735 | 3738 | ||
3736 | On ARM, the following registers are used: | 3739 | On ARM, the following registers are used: |
3737 | 3740 | ||
3738 | R0: function argument word/integer result | 3741 | R0: function argument word/integer result |
3739 | R1-R3: function argument word | 3742 | R1-R3: function argument word |
3740 | R9: GOT pointer | 3743 | R9: GOT pointer |
3741 | R10: stack limit (used only if stack checking if enabled) | 3744 | R10: stack limit (used only if stack checking if enabled) |
3742 | R11: argument (frame) pointer | 3745 | R11: argument (frame) pointer |
3743 | R12: temporary workspace | 3746 | R12: temporary workspace |
3744 | R13: stack pointer | 3747 | R13: stack pointer |
3745 | R14: link register | 3748 | R14: link register |
3746 | R15: program counter | 3749 | R15: program counter |
3747 | 3750 | ||
3748 | ==> U-Boot will use R8 to hold a pointer to the global data | 3751 | ==> U-Boot will use R8 to hold a pointer to the global data |
3749 | 3752 | ||
3750 | NOTE: DECLARE_GLOBAL_DATA_PTR must be used with file-global scope, | 3753 | NOTE: DECLARE_GLOBAL_DATA_PTR must be used with file-global scope, |
3751 | or current versions of GCC may "optimize" the code too much. | 3754 | or current versions of GCC may "optimize" the code too much. |
3752 | 3755 | ||
3753 | Memory Management: | 3756 | Memory Management: |
3754 | ------------------ | 3757 | ------------------ |
3755 | 3758 | ||
3756 | U-Boot runs in system state and uses physical addresses, i.e. the | 3759 | U-Boot runs in system state and uses physical addresses, i.e. the |
3757 | MMU is not used either for address mapping nor for memory protection. | 3760 | MMU is not used either for address mapping nor for memory protection. |
3758 | 3761 | ||
3759 | The available memory is mapped to fixed addresses using the memory | 3762 | The available memory is mapped to fixed addresses using the memory |
3760 | controller. In this process, a contiguous block is formed for each | 3763 | controller. In this process, a contiguous block is formed for each |
3761 | memory type (Flash, SDRAM, SRAM), even when it consists of several | 3764 | memory type (Flash, SDRAM, SRAM), even when it consists of several |
3762 | physical memory banks. | 3765 | physical memory banks. |
3763 | 3766 | ||
3764 | U-Boot is installed in the first 128 kB of the first Flash bank (on | 3767 | U-Boot is installed in the first 128 kB of the first Flash bank (on |
3765 | TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After | 3768 | TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After |
3766 | booting and sizing and initializing DRAM, the code relocates itself | 3769 | booting and sizing and initializing DRAM, the code relocates itself |
3767 | to the upper end of DRAM. Immediately below the U-Boot code some | 3770 | to the upper end of DRAM. Immediately below the U-Boot code some |
3768 | memory is reserved for use by malloc() [see CFG_MALLOC_LEN | 3771 | memory is reserved for use by malloc() [see CFG_MALLOC_LEN |
3769 | configuration setting]. Below that, a structure with global Board | 3772 | configuration setting]. Below that, a structure with global Board |
3770 | Info data is placed, followed by the stack (growing downward). | 3773 | Info data is placed, followed by the stack (growing downward). |
3771 | 3774 | ||
3772 | Additionally, some exception handler code is copied to the low 8 kB | 3775 | Additionally, some exception handler code is copied to the low 8 kB |
3773 | of DRAM (0x00000000 ... 0x00001FFF). | 3776 | of DRAM (0x00000000 ... 0x00001FFF). |
3774 | 3777 | ||
3775 | So a typical memory configuration with 16 MB of DRAM could look like | 3778 | So a typical memory configuration with 16 MB of DRAM could look like |
3776 | this: | 3779 | this: |
3777 | 3780 | ||
3778 | 0x0000 0000 Exception Vector code | 3781 | 0x0000 0000 Exception Vector code |
3779 | : | 3782 | : |
3780 | 0x0000 1FFF | 3783 | 0x0000 1FFF |
3781 | 0x0000 2000 Free for Application Use | 3784 | 0x0000 2000 Free for Application Use |
3782 | : | 3785 | : |
3783 | : | 3786 | : |
3784 | 3787 | ||
3785 | : | 3788 | : |
3786 | : | 3789 | : |
3787 | 0x00FB FF20 Monitor Stack (Growing downward) | 3790 | 0x00FB FF20 Monitor Stack (Growing downward) |
3788 | 0x00FB FFAC Board Info Data and permanent copy of global data | 3791 | 0x00FB FFAC Board Info Data and permanent copy of global data |
3789 | 0x00FC 0000 Malloc Arena | 3792 | 0x00FC 0000 Malloc Arena |
3790 | : | 3793 | : |
3791 | 0x00FD FFFF | 3794 | 0x00FD FFFF |
3792 | 0x00FE 0000 RAM Copy of Monitor Code | 3795 | 0x00FE 0000 RAM Copy of Monitor Code |
3793 | ... eventually: LCD or video framebuffer | 3796 | ... eventually: LCD or video framebuffer |
3794 | ... eventually: pRAM (Protected RAM - unchanged by reset) | 3797 | ... eventually: pRAM (Protected RAM - unchanged by reset) |
3795 | 0x00FF FFFF [End of RAM] | 3798 | 0x00FF FFFF [End of RAM] |
3796 | 3799 | ||
3797 | 3800 | ||
3798 | System Initialization: | 3801 | System Initialization: |
3799 | ---------------------- | 3802 | ---------------------- |
3800 | 3803 | ||
3801 | In the reset configuration, U-Boot starts at the reset entry point | 3804 | In the reset configuration, U-Boot starts at the reset entry point |
3802 | (on most PowerPC systems at address 0x00000100). Because of the reset | 3805 | (on most PowerPC systems at address 0x00000100). Because of the reset |
3803 | configuration for CS0# this is a mirror of the onboard Flash memory. | 3806 | configuration for CS0# this is a mirror of the onboard Flash memory. |
3804 | To be able to re-map memory U-Boot then jumps to its link address. | 3807 | To be able to re-map memory U-Boot then jumps to its link address. |
3805 | To be able to implement the initialization code in C, a (small!) | 3808 | To be able to implement the initialization code in C, a (small!) |
3806 | initial stack is set up in the internal Dual Ported RAM (in case CPUs | 3809 | initial stack is set up in the internal Dual Ported RAM (in case CPUs |
3807 | which provide such a feature like MPC8xx or MPC8260), or in a locked | 3810 | which provide such a feature like MPC8xx or MPC8260), or in a locked |
3808 | part of the data cache. After that, U-Boot initializes the CPU core, | 3811 | part of the data cache. After that, U-Boot initializes the CPU core, |
3809 | the caches and the SIU. | 3812 | the caches and the SIU. |
3810 | 3813 | ||
3811 | Next, all (potentially) available memory banks are mapped using a | 3814 | Next, all (potentially) available memory banks are mapped using a |
3812 | preliminary mapping. For example, we put them on 512 MB boundaries | 3815 | preliminary mapping. For example, we put them on 512 MB boundaries |
3813 | (multiples of 0x20000000: SDRAM on 0x00000000 and 0x20000000, Flash | 3816 | (multiples of 0x20000000: SDRAM on 0x00000000 and 0x20000000, Flash |
3814 | on 0x40000000 and 0x60000000, SRAM on 0x80000000). Then UPM A is | 3817 | on 0x40000000 and 0x60000000, SRAM on 0x80000000). Then UPM A is |
3815 | programmed for SDRAM access. Using the temporary configuration, a | 3818 | programmed for SDRAM access. Using the temporary configuration, a |
3816 | simple memory test is run that determines the size of the SDRAM | 3819 | simple memory test is run that determines the size of the SDRAM |
3817 | banks. | 3820 | banks. |
3818 | 3821 | ||
3819 | When there is more than one SDRAM bank, and the banks are of | 3822 | When there is more than one SDRAM bank, and the banks are of |
3820 | different size, the largest is mapped first. For equal size, the first | 3823 | different size, the largest is mapped first. For equal size, the first |
3821 | bank (CS2#) is mapped first. The first mapping is always for address | 3824 | bank (CS2#) is mapped first. The first mapping is always for address |
3822 | 0x00000000, with any additional banks following immediately to create | 3825 | 0x00000000, with any additional banks following immediately to create |
3823 | contiguous memory starting from 0. | 3826 | contiguous memory starting from 0. |
3824 | 3827 | ||
3825 | Then, the monitor installs itself at the upper end of the SDRAM area | 3828 | Then, the monitor installs itself at the upper end of the SDRAM area |
3826 | and allocates memory for use by malloc() and for the global Board | 3829 | and allocates memory for use by malloc() and for the global Board |
3827 | Info data; also, the exception vector code is copied to the low RAM | 3830 | Info data; also, the exception vector code is copied to the low RAM |
3828 | pages, and the final stack is set up. | 3831 | pages, and the final stack is set up. |
3829 | 3832 | ||
3830 | Only after this relocation will you have a "normal" C environment; | 3833 | Only after this relocation will you have a "normal" C environment; |
3831 | until that you are restricted in several ways, mostly because you are | 3834 | until that you are restricted in several ways, mostly because you are |
3832 | running from ROM, and because the code will have to be relocated to a | 3835 | running from ROM, and because the code will have to be relocated to a |
3833 | new address in RAM. | 3836 | new address in RAM. |
3834 | 3837 | ||
3835 | 3838 | ||
3836 | U-Boot Porting Guide: | 3839 | U-Boot Porting Guide: |
3837 | ---------------------- | 3840 | ---------------------- |
3838 | 3841 | ||
3839 | [Based on messages by Jerry Van Baren in the U-Boot-Users mailing | 3842 | [Based on messages by Jerry Van Baren in the U-Boot-Users mailing |
3840 | list, October 2002] | 3843 | list, October 2002] |
3841 | 3844 | ||
3842 | 3845 | ||
3843 | int main (int argc, char *argv[]) | 3846 | int main (int argc, char *argv[]) |
3844 | { | 3847 | { |
3845 | sighandler_t no_more_time; | 3848 | sighandler_t no_more_time; |
3846 | 3849 | ||
3847 | signal (SIGALRM, no_more_time); | 3850 | signal (SIGALRM, no_more_time); |
3848 | alarm (PROJECT_DEADLINE - toSec (3 * WEEK)); | 3851 | alarm (PROJECT_DEADLINE - toSec (3 * WEEK)); |
3849 | 3852 | ||
3850 | if (available_money > available_manpower) { | 3853 | if (available_money > available_manpower) { |
3851 | pay consultant to port U-Boot; | 3854 | pay consultant to port U-Boot; |
3852 | return 0; | 3855 | return 0; |
3853 | } | 3856 | } |
3854 | 3857 | ||
3855 | Download latest U-Boot source; | 3858 | Download latest U-Boot source; |
3856 | 3859 | ||
3857 | Subscribe to u-boot-users mailing list; | 3860 | Subscribe to u-boot-users mailing list; |
3858 | 3861 | ||
3859 | if (clueless) { | 3862 | if (clueless) { |
3860 | email ("Hi, I am new to U-Boot, how do I get started?"); | 3863 | email ("Hi, I am new to U-Boot, how do I get started?"); |
3861 | } | 3864 | } |
3862 | 3865 | ||
3863 | while (learning) { | 3866 | while (learning) { |
3864 | Read the README file in the top level directory; | 3867 | Read the README file in the top level directory; |
3865 | Read http://www.denx.de/twiki/bin/view/DULG/Manual ; | 3868 | Read http://www.denx.de/twiki/bin/view/DULG/Manual ; |
3866 | Read the source, Luke; | 3869 | Read the source, Luke; |
3867 | } | 3870 | } |
3868 | 3871 | ||
3869 | if (available_money > toLocalCurrency ($2500)) { | 3872 | if (available_money > toLocalCurrency ($2500)) { |
3870 | Buy a BDI2000; | 3873 | Buy a BDI2000; |
3871 | } else { | 3874 | } else { |
3872 | Add a lot of aggravation and time; | 3875 | Add a lot of aggravation and time; |
3873 | } | 3876 | } |
3874 | 3877 | ||
3875 | Create your own board support subdirectory; | 3878 | Create your own board support subdirectory; |
3876 | 3879 | ||
3877 | Create your own board config file; | 3880 | Create your own board config file; |
3878 | 3881 | ||
3879 | while (!running) { | 3882 | while (!running) { |
3880 | do { | 3883 | do { |
3881 | Add / modify source code; | 3884 | Add / modify source code; |
3882 | } until (compiles); | 3885 | } until (compiles); |
3883 | Debug; | 3886 | Debug; |
3884 | if (clueless) | 3887 | if (clueless) |
3885 | email ("Hi, I am having problems..."); | 3888 | email ("Hi, I am having problems..."); |
3886 | } | 3889 | } |
3887 | Send patch file to Wolfgang; | 3890 | Send patch file to Wolfgang; |
3888 | 3891 | ||
3889 | return 0; | 3892 | return 0; |
3890 | } | 3893 | } |
3891 | 3894 | ||
3892 | void no_more_time (int sig) | 3895 | void no_more_time (int sig) |
3893 | { | 3896 | { |
3894 | hire_a_guru(); | 3897 | hire_a_guru(); |
3895 | } | 3898 | } |
3896 | 3899 | ||
3897 | 3900 | ||
3898 | Coding Standards: | 3901 | Coding Standards: |
3899 | ----------------- | 3902 | ----------------- |
3900 | 3903 | ||
3901 | All contributions to U-Boot should conform to the Linux kernel | 3904 | All contributions to U-Boot should conform to the Linux kernel |
3902 | coding style; see the file "Documentation/CodingStyle" and the script | 3905 | coding style; see the file "Documentation/CodingStyle" and the script |
3903 | "scripts/Lindent" in your Linux kernel source directory. In sources | 3906 | "scripts/Lindent" in your Linux kernel source directory. In sources |
3904 | originating from U-Boot a style corresponding to "Lindent -pcs" (adding | 3907 | originating from U-Boot a style corresponding to "Lindent -pcs" (adding |
3905 | spaces before parameters to function calls) is actually used. | 3908 | spaces before parameters to function calls) is actually used. |
3906 | 3909 | ||
3907 | Source files originating from a different project (for example the | 3910 | Source files originating from a different project (for example the |
3908 | MTD subsystem) are generally exempt from these guidelines and are not | 3911 | MTD subsystem) are generally exempt from these guidelines and are not |
3909 | reformated to ease subsequent migration to newer versions of those | 3912 | reformated to ease subsequent migration to newer versions of those |
3910 | sources. | 3913 | sources. |
3911 | 3914 | ||
3912 | Please note that U-Boot is implemented in C (and to some small parts in | 3915 | Please note that U-Boot is implemented in C (and to some small parts in |
3913 | Assembler); no C++ is used, so please do not use C++ style comments (//) | 3916 | Assembler); no C++ is used, so please do not use C++ style comments (//) |
3914 | in your code. | 3917 | in your code. |
3915 | 3918 | ||
3916 | Please also stick to the following formatting rules: | 3919 | Please also stick to the following formatting rules: |
3917 | - remove any trailing white space | 3920 | - remove any trailing white space |
3918 | - use TAB characters for indentation, not spaces | 3921 | - use TAB characters for indentation, not spaces |
3919 | - make sure NOT to use DOS '\r\n' line feeds | 3922 | - make sure NOT to use DOS '\r\n' line feeds |
3920 | - do not add more than 2 empty lines to source files | 3923 | - do not add more than 2 empty lines to source files |
3921 | - do not add trailing empty lines to source files | 3924 | - do not add trailing empty lines to source files |
3922 | 3925 | ||
3923 | Submissions which do not conform to the standards may be returned | 3926 | Submissions which do not conform to the standards may be returned |
3924 | with a request to reformat the changes. | 3927 | with a request to reformat the changes. |
3925 | 3928 | ||
3926 | 3929 | ||
3927 | Submitting Patches: | 3930 | Submitting Patches: |
3928 | ------------------- | 3931 | ------------------- |
3929 | 3932 | ||
3930 | Since the number of patches for U-Boot is growing, we need to | 3933 | Since the number of patches for U-Boot is growing, we need to |
3931 | establish some rules. Submissions which do not conform to these rules | 3934 | establish some rules. Submissions which do not conform to these rules |
3932 | may be rejected, even when they contain important and valuable stuff. | 3935 | may be rejected, even when they contain important and valuable stuff. |
3933 | 3936 | ||
3934 | Patches shall be sent to the u-boot-users mailing list. | 3937 | Patches shall be sent to the u-boot-users mailing list. |
3935 | 3938 | ||
3936 | Please see http://www.denx.de/wiki/U-Boot/Patches for details. | 3939 | Please see http://www.denx.de/wiki/U-Boot/Patches for details. |
3937 | 3940 | ||
3938 | When you send a patch, please include the following information with | 3941 | When you send a patch, please include the following information with |
3939 | it: | 3942 | it: |
3940 | 3943 | ||
3941 | * For bug fixes: a description of the bug and how your patch fixes | 3944 | * For bug fixes: a description of the bug and how your patch fixes |
3942 | this bug. Please try to include a way of demonstrating that the | 3945 | this bug. Please try to include a way of demonstrating that the |
3943 | patch actually fixes something. | 3946 | patch actually fixes something. |
3944 | 3947 | ||
3945 | * For new features: a description of the feature and your | 3948 | * For new features: a description of the feature and your |
3946 | implementation. | 3949 | implementation. |
3947 | 3950 | ||
3948 | * A CHANGELOG entry as plaintext (separate from the patch) | 3951 | * A CHANGELOG entry as plaintext (separate from the patch) |
3949 | 3952 | ||
3950 | * For major contributions, your entry to the CREDITS file | 3953 | * For major contributions, your entry to the CREDITS file |
3951 | 3954 | ||
3952 | * When you add support for a new board, don't forget to add this | 3955 | * When you add support for a new board, don't forget to add this |
3953 | board to the MAKEALL script, too. | 3956 | board to the MAKEALL script, too. |
3954 | 3957 | ||
3955 | * If your patch adds new configuration options, don't forget to | 3958 | * If your patch adds new configuration options, don't forget to |
3956 | document these in the README file. | 3959 | document these in the README file. |
3957 | 3960 | ||
3958 | * The patch itself. If you are using git (which is *strongly* | 3961 | * The patch itself. If you are using git (which is *strongly* |
3959 | recommended) you can easily generate the patch using the | 3962 | recommended) you can easily generate the patch using the |
3960 | "git-format-patch". If you then use "git-send-email" to send it to | 3963 | "git-format-patch". If you then use "git-send-email" to send it to |
3961 | the U-Boot mailing list, you will avoid most of the common problems | 3964 | the U-Boot mailing list, you will avoid most of the common problems |
3962 | with some other mail clients. | 3965 | with some other mail clients. |
3963 | 3966 | ||
3964 | If you cannot use git, use "diff -purN OLD NEW". If your version of | 3967 | If you cannot use git, use "diff -purN OLD NEW". If your version of |
3965 | diff does not support these options, then get the latest version of | 3968 | diff does not support these options, then get the latest version of |
3966 | GNU diff. | 3969 | GNU diff. |
3967 | 3970 | ||
3968 | The current directory when running this command shall be the parent | 3971 | The current directory when running this command shall be the parent |
3969 | directory of the U-Boot source tree (i. e. please make sure that | 3972 | directory of the U-Boot source tree (i. e. please make sure that |
3970 | your patch includes sufficient directory information for the | 3973 | your patch includes sufficient directory information for the |
3971 | affected files). | 3974 | affected files). |
3972 | 3975 | ||
3973 | We prefer patches as plain text. MIME attachments are discouraged, | 3976 | We prefer patches as plain text. MIME attachments are discouraged, |
3974 | and compressed attachments must not be used. | 3977 | and compressed attachments must not be used. |
3975 | 3978 | ||
3976 | * If one logical set of modifications affects or creates several | 3979 | * If one logical set of modifications affects or creates several |
3977 | files, all these changes shall be submitted in a SINGLE patch file. | 3980 | files, all these changes shall be submitted in a SINGLE patch file. |
3978 | 3981 | ||
3979 | * Changesets that contain different, unrelated modifications shall be | 3982 | * Changesets that contain different, unrelated modifications shall be |
3980 | submitted as SEPARATE patches, one patch per changeset. | 3983 | submitted as SEPARATE patches, one patch per changeset. |
3981 | 3984 | ||
3982 | 3985 | ||
3983 | Notes: | 3986 | Notes: |
3984 | 3987 | ||
3985 | * Before sending the patch, run the MAKEALL script on your patched | 3988 | * Before sending the patch, run the MAKEALL script on your patched |
3986 | source tree and make sure that no errors or warnings are reported | 3989 | source tree and make sure that no errors or warnings are reported |
3987 | for any of the boards. | 3990 | for any of the boards. |
3988 | 3991 | ||
3989 | * Keep your modifications to the necessary minimum: A patch | 3992 | * Keep your modifications to the necessary minimum: A patch |
3990 | containing several unrelated changes or arbitrary reformats will be | 3993 | containing several unrelated changes or arbitrary reformats will be |
3991 | returned with a request to re-formatting / split it. | 3994 | returned with a request to re-formatting / split it. |
3992 | 3995 | ||
3993 | * If you modify existing code, make sure that your new code does not | 3996 | * If you modify existing code, make sure that your new code does not |
3994 | add to the memory footprint of the code ;-) Small is beautiful! | 3997 | add to the memory footprint of the code ;-) Small is beautiful! |
3995 | When adding new features, these should compile conditionally only | 3998 | When adding new features, these should compile conditionally only |
3996 | (using #ifdef), and the resulting code with the new feature | 3999 | (using #ifdef), and the resulting code with the new feature |
3997 | disabled must not need more memory than the old code without your | 4000 | disabled must not need more memory than the old code without your |
3998 | modification. | 4001 | modification. |
3999 | 4002 | ||
4000 | * Remember that there is a size limit of 40 kB per message on the | 4003 | * Remember that there is a size limit of 40 kB per message on the |
4001 | u-boot-users mailing list. Bigger patches will be moderated. If | 4004 | u-boot-users mailing list. Bigger patches will be moderated. If |
4002 | they are reasonable and not bigger than 100 kB, they will be | 4005 | they are reasonable and not bigger than 100 kB, they will be |
4003 | acknowledged. Even bigger patches should be avoided. | 4006 | acknowledged. Even bigger patches should be avoided. |
4004 | 4007 |
common/cmd_bdinfo.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2003 | 2 | * (C) Copyright 2003 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * See file CREDITS for list of people who contributed to this | 5 | * See file CREDITS for list of people who contributed to this |
6 | * project. | 6 | * project. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of | 10 | * published by the Free Software Foundation; either version 2 of |
11 | * the License, or (at your option) any later version. | 11 | * the License, or (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | * MA 02111-1307 USA | 21 | * MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * Boot support | 25 | * Boot support |
26 | */ | 26 | */ |
27 | #include <common.h> | 27 | #include <common.h> |
28 | #include <command.h> | 28 | #include <command.h> |
29 | #include <net.h> /* for print_IPaddr */ | 29 | #include <net.h> /* for print_IPaddr */ |
30 | 30 | ||
31 | DECLARE_GLOBAL_DATA_PTR; | 31 | DECLARE_GLOBAL_DATA_PTR; |
32 | 32 | ||
33 | static void print_num(const char *, ulong); | 33 | static void print_num(const char *, ulong); |
34 | 34 | ||
35 | #ifndef CONFIG_ARM /* PowerPC and other */ | 35 | #ifndef CONFIG_ARM /* PowerPC and other */ |
36 | static void print_lnum(const char *, u64); | 36 | static void print_lnum(const char *, u64); |
37 | 37 | ||
38 | #ifdef CONFIG_PPC | 38 | #ifdef CONFIG_PPC |
39 | static void print_str(const char *, const char *); | 39 | static void print_str(const char *, const char *); |
40 | 40 | ||
41 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | 41 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
42 | { | 42 | { |
43 | int i; | 43 | int i; |
44 | bd_t *bd = gd->bd; | 44 | bd_t *bd = gd->bd; |
45 | char buf[32]; | 45 | char buf[32]; |
46 | 46 | ||
47 | #ifdef DEBUG | 47 | #ifdef DEBUG |
48 | print_num ("bd address", (ulong)bd ); | 48 | print_num ("bd address", (ulong)bd ); |
49 | #endif | 49 | #endif |
50 | print_num ("memstart", bd->bi_memstart ); | 50 | print_num ("memstart", bd->bi_memstart ); |
51 | print_lnum ("memsize", bd->bi_memsize ); | 51 | print_lnum ("memsize", bd->bi_memsize ); |
52 | print_num ("flashstart", bd->bi_flashstart ); | 52 | print_num ("flashstart", bd->bi_flashstart ); |
53 | print_num ("flashsize", bd->bi_flashsize ); | 53 | print_num ("flashsize", bd->bi_flashsize ); |
54 | print_num ("flashoffset", bd->bi_flashoffset ); | 54 | print_num ("flashoffset", bd->bi_flashoffset ); |
55 | print_num ("sramstart", bd->bi_sramstart ); | 55 | print_num ("sramstart", bd->bi_sramstart ); |
56 | print_num ("sramsize", bd->bi_sramsize ); | 56 | print_num ("sramsize", bd->bi_sramsize ); |
57 | #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \ | 57 | #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \ |
58 | defined(CONFIG_8260) || defined(CONFIG_E500) | 58 | defined(CONFIG_8260) || defined(CONFIG_E500) |
59 | print_num ("immr_base", bd->bi_immr_base ); | 59 | print_num ("immr_base", bd->bi_immr_base ); |
60 | #endif | 60 | #endif |
61 | print_num ("bootflags", bd->bi_bootflags ); | 61 | print_num ("bootflags", bd->bi_bootflags ); |
62 | #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \ | 62 | #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \ |
63 | defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \ | 63 | defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \ |
64 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ | 64 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ |
65 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \ | 65 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \ |
66 | defined(CONFIG_440SP) || defined(CONFIG_440SPE) | 66 | defined(CONFIG_440SP) || defined(CONFIG_440SPE) |
67 | print_str ("procfreq", strmhz(buf, bd->bi_procfreq)); | 67 | print_str ("procfreq", strmhz(buf, bd->bi_procfreq)); |
68 | print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq)); | 68 | print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq)); |
69 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \ | 69 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \ |
70 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_440SPE) || \ | 70 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_440SPE) || \ |
71 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) | 71 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) |
72 | print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq)); | 72 | print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq)); |
73 | #endif | 73 | #endif |
74 | #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */ | 74 | #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */ |
75 | #if defined(CONFIG_CPM2) | 75 | #if defined(CONFIG_CPM2) |
76 | print_str ("vco", strmhz(buf, bd->bi_vco)); | 76 | print_str ("vco", strmhz(buf, bd->bi_vco)); |
77 | print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq)); | 77 | print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq)); |
78 | print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq)); | 78 | print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq)); |
79 | #endif | 79 | #endif |
80 | print_str ("intfreq", strmhz(buf, bd->bi_intfreq)); | 80 | print_str ("intfreq", strmhz(buf, bd->bi_intfreq)); |
81 | #if defined(CONFIG_CPM2) | 81 | #if defined(CONFIG_CPM2) |
82 | print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq)); | 82 | print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq)); |
83 | #endif | 83 | #endif |
84 | print_str ("busfreq", strmhz(buf, bd->bi_busfreq)); | 84 | print_str ("busfreq", strmhz(buf, bd->bi_busfreq)); |
85 | #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */ | 85 | #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */ |
86 | #if defined(CONFIG_MPC8220) | 86 | #if defined(CONFIG_MPC8220) |
87 | print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq)); | 87 | print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq)); |
88 | print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq)); | 88 | print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq)); |
89 | print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq)); | 89 | print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq)); |
90 | print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq)); | 90 | print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq)); |
91 | print_str ("pevfreq", strmhz(buf, bd->bi_pevfreq)); | 91 | print_str ("pevfreq", strmhz(buf, bd->bi_pevfreq)); |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | puts ("ethaddr ="); | 94 | puts ("ethaddr ="); |
95 | for (i=0; i<6; ++i) { | 95 | for (i=0; i<6; ++i) { |
96 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 96 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
97 | } | 97 | } |
98 | 98 | ||
99 | #if defined(CONFIG_HAS_ETH1) | 99 | #if defined(CONFIG_HAS_ETH1) |
100 | puts ("\neth1addr ="); | 100 | puts ("\neth1addr ="); |
101 | for (i=0; i<6; ++i) { | 101 | for (i=0; i<6; ++i) { |
102 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]); | 102 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]); |
103 | } | 103 | } |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | #if defined(CONFIG_HAS_ETH2) | 106 | #if defined(CONFIG_HAS_ETH2) |
107 | puts ("\neth2addr ="); | 107 | puts ("\neth2addr ="); |
108 | for (i=0; i<6; ++i) { | 108 | for (i=0; i<6; ++i) { |
109 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]); | 109 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]); |
110 | } | 110 | } |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #if defined(CONFIG_HAS_ETH3) | 113 | #if defined(CONFIG_HAS_ETH3) |
114 | puts ("\neth3addr ="); | 114 | puts ("\neth3addr ="); |
115 | for (i=0; i<6; ++i) { | 115 | for (i=0; i<6; ++i) { |
116 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]); | 116 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]); |
117 | } | 117 | } |
118 | #endif | 118 | #endif |
119 | 119 | ||
120 | #if defined(CONFIG_HAS_ETH4) | ||
121 | puts ("\neth4addr ="); | ||
122 | for (i=0; i<6; ++i) { | ||
123 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet4addr[i]); | ||
124 | } | ||
125 | #endif | ||
126 | |||
127 | #if defined(CONFIG_HAS_ETH5) | ||
128 | puts ("\neth5addr ="); | ||
129 | for (i=0; i<6; ++i) { | ||
130 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet5addr[i]); | ||
131 | } | ||
132 | #endif | ||
133 | |||
120 | #ifdef CONFIG_HERMES | 134 | #ifdef CONFIG_HERMES |
121 | print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed)); | 135 | print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed)); |
122 | #endif | 136 | #endif |
123 | puts ("\nIP addr = "); print_IPaddr (bd->bi_ip_addr); | 137 | puts ("\nIP addr = "); print_IPaddr (bd->bi_ip_addr); |
124 | printf ("\nbaudrate = %6ld bps\n", bd->bi_baudrate ); | 138 | printf ("\nbaudrate = %6ld bps\n", bd->bi_baudrate ); |
125 | return 0; | 139 | return 0; |
126 | } | 140 | } |
127 | 141 | ||
128 | #elif defined(CONFIG_NIOS) /* NIOS*/ | 142 | #elif defined(CONFIG_NIOS) /* NIOS*/ |
129 | 143 | ||
130 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | 144 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
131 | { | 145 | { |
132 | int i; | 146 | int i; |
133 | bd_t *bd = gd->bd; | 147 | bd_t *bd = gd->bd; |
134 | 148 | ||
135 | print_num ("memstart", (ulong)bd->bi_memstart); | 149 | print_num ("memstart", (ulong)bd->bi_memstart); |
136 | print_lnum ("memsize", (u64)bd->bi_memsize); | 150 | print_lnum ("memsize", (u64)bd->bi_memsize); |
137 | print_num ("flashstart", (ulong)bd->bi_flashstart); | 151 | print_num ("flashstart", (ulong)bd->bi_flashstart); |
138 | print_num ("flashsize", (ulong)bd->bi_flashsize); | 152 | print_num ("flashsize", (ulong)bd->bi_flashsize); |
139 | print_num ("flashoffset", (ulong)bd->bi_flashoffset); | 153 | print_num ("flashoffset", (ulong)bd->bi_flashoffset); |
140 | 154 | ||
141 | puts ("ethaddr ="); | 155 | puts ("ethaddr ="); |
142 | for (i=0; i<6; ++i) { | 156 | for (i=0; i<6; ++i) { |
143 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 157 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
144 | } | 158 | } |
145 | puts ("\nip_addr = "); | 159 | puts ("\nip_addr = "); |
146 | print_IPaddr (bd->bi_ip_addr); | 160 | print_IPaddr (bd->bi_ip_addr); |
147 | printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate); | 161 | printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate); |
148 | 162 | ||
149 | return 0; | 163 | return 0; |
150 | } | 164 | } |
151 | 165 | ||
152 | #elif defined(CONFIG_NIOS2) /* Nios-II */ | 166 | #elif defined(CONFIG_NIOS2) /* Nios-II */ |
153 | 167 | ||
154 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | 168 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
155 | { | 169 | { |
156 | #if defined(CONFIG_CMD_NET) | 170 | #if defined(CONFIG_CMD_NET) |
157 | int i; | 171 | int i; |
158 | #endif | 172 | #endif |
159 | bd_t *bd = gd->bd; | 173 | bd_t *bd = gd->bd; |
160 | 174 | ||
161 | print_num ("mem start", (ulong)bd->bi_memstart); | 175 | print_num ("mem start", (ulong)bd->bi_memstart); |
162 | print_lnum ("mem size", (u64)bd->bi_memsize); | 176 | print_lnum ("mem size", (u64)bd->bi_memsize); |
163 | print_num ("flash start", (ulong)bd->bi_flashstart); | 177 | print_num ("flash start", (ulong)bd->bi_flashstart); |
164 | print_num ("flash size", (ulong)bd->bi_flashsize); | 178 | print_num ("flash size", (ulong)bd->bi_flashsize); |
165 | print_num ("flash offset", (ulong)bd->bi_flashoffset); | 179 | print_num ("flash offset", (ulong)bd->bi_flashoffset); |
166 | 180 | ||
167 | #if defined(CFG_SRAM_BASE) | 181 | #if defined(CFG_SRAM_BASE) |
168 | print_num ("sram start", (ulong)bd->bi_sramstart); | 182 | print_num ("sram start", (ulong)bd->bi_sramstart); |
169 | print_num ("sram size", (ulong)bd->bi_sramsize); | 183 | print_num ("sram size", (ulong)bd->bi_sramsize); |
170 | #endif | 184 | #endif |
171 | 185 | ||
172 | #if defined(CONFIG_CMD_NET) | 186 | #if defined(CONFIG_CMD_NET) |
173 | puts ("ethaddr ="); | 187 | puts ("ethaddr ="); |
174 | for (i=0; i<6; ++i) { | 188 | for (i=0; i<6; ++i) { |
175 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 189 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
176 | } | 190 | } |
177 | puts ("\nip_addr = "); | 191 | puts ("\nip_addr = "); |
178 | print_IPaddr (bd->bi_ip_addr); | 192 | print_IPaddr (bd->bi_ip_addr); |
179 | #endif | 193 | #endif |
180 | 194 | ||
181 | printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate); | 195 | printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate); |
182 | 196 | ||
183 | return 0; | 197 | return 0; |
184 | } | 198 | } |
185 | #elif defined(CONFIG_MICROBLAZE) /* ! PPC, which leaves Microblaze */ | 199 | #elif defined(CONFIG_MICROBLAZE) /* ! PPC, which leaves Microblaze */ |
186 | 200 | ||
187 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | 201 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
188 | { | 202 | { |
189 | int i; | 203 | int i; |
190 | bd_t *bd = gd->bd; | 204 | bd_t *bd = gd->bd; |
191 | print_num ("mem start ", (ulong)bd->bi_memstart); | 205 | print_num ("mem start ", (ulong)bd->bi_memstart); |
192 | print_lnum ("mem size ", (u64)bd->bi_memsize); | 206 | print_lnum ("mem size ", (u64)bd->bi_memsize); |
193 | print_num ("flash start ", (ulong)bd->bi_flashstart); | 207 | print_num ("flash start ", (ulong)bd->bi_flashstart); |
194 | print_num ("flash size ", (ulong)bd->bi_flashsize); | 208 | print_num ("flash size ", (ulong)bd->bi_flashsize); |
195 | print_num ("flash offset ", (ulong)bd->bi_flashoffset); | 209 | print_num ("flash offset ", (ulong)bd->bi_flashoffset); |
196 | #if defined(CFG_SRAM_BASE) | 210 | #if defined(CFG_SRAM_BASE) |
197 | print_num ("sram start ", (ulong)bd->bi_sramstart); | 211 | print_num ("sram start ", (ulong)bd->bi_sramstart); |
198 | print_num ("sram size ", (ulong)bd->bi_sramsize); | 212 | print_num ("sram size ", (ulong)bd->bi_sramsize); |
199 | #endif | 213 | #endif |
200 | #if defined(CONFIG_CMD_NET) | 214 | #if defined(CONFIG_CMD_NET) |
201 | puts ("ethaddr ="); | 215 | puts ("ethaddr ="); |
202 | for (i=0; i<6; ++i) { | 216 | for (i=0; i<6; ++i) { |
203 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 217 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
204 | } | 218 | } |
205 | puts ("\nip_addr = "); | 219 | puts ("\nip_addr = "); |
206 | print_IPaddr (bd->bi_ip_addr); | 220 | print_IPaddr (bd->bi_ip_addr); |
207 | #endif | 221 | #endif |
208 | printf ("\nbaudrate = %ld bps\n", (ulong)bd->bi_baudrate); | 222 | printf ("\nbaudrate = %ld bps\n", (ulong)bd->bi_baudrate); |
209 | return 0; | 223 | return 0; |
210 | } | 224 | } |
211 | 225 | ||
212 | #elif defined(CONFIG_SPARC) /* SPARC */ | 226 | #elif defined(CONFIG_SPARC) /* SPARC */ |
213 | int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) | 227 | int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
214 | { | 228 | { |
215 | bd_t *bd = gd->bd; | 229 | bd_t *bd = gd->bd; |
216 | #if defined(CONFIG_CMD_NET) | 230 | #if defined(CONFIG_CMD_NET) |
217 | int i; | 231 | int i; |
218 | #endif | 232 | #endif |
219 | 233 | ||
220 | #ifdef DEBUG | 234 | #ifdef DEBUG |
221 | print_num("bd address ", (ulong) bd); | 235 | print_num("bd address ", (ulong) bd); |
222 | #endif | 236 | #endif |
223 | print_num("memstart ", bd->bi_memstart); | 237 | print_num("memstart ", bd->bi_memstart); |
224 | print_lnum("memsize ", bd->bi_memsize); | 238 | print_lnum("memsize ", bd->bi_memsize); |
225 | print_num("flashstart ", bd->bi_flashstart); | 239 | print_num("flashstart ", bd->bi_flashstart); |
226 | print_num("CFG_MONITOR_BASE ", CFG_MONITOR_BASE); | 240 | print_num("CFG_MONITOR_BASE ", CFG_MONITOR_BASE); |
227 | print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR); | 241 | print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR); |
228 | printf("CFG_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CFG_RELOC_MONITOR_BASE, | 242 | printf("CFG_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CFG_RELOC_MONITOR_BASE, |
229 | CFG_MONITOR_LEN); | 243 | CFG_MONITOR_LEN); |
230 | printf("CFG_MALLOC_BASE = 0x%lx (%d)\n", CFG_MALLOC_BASE, | 244 | printf("CFG_MALLOC_BASE = 0x%lx (%d)\n", CFG_MALLOC_BASE, |
231 | CFG_MALLOC_LEN); | 245 | CFG_MALLOC_LEN); |
232 | printf("CFG_INIT_SP_OFFSET = 0x%lx (%d)\n", CFG_INIT_SP_OFFSET, | 246 | printf("CFG_INIT_SP_OFFSET = 0x%lx (%d)\n", CFG_INIT_SP_OFFSET, |
233 | CFG_STACK_SIZE); | 247 | CFG_STACK_SIZE); |
234 | printf("CFG_PROM_OFFSET = 0x%lx (%d)\n", CFG_PROM_OFFSET, | 248 | printf("CFG_PROM_OFFSET = 0x%lx (%d)\n", CFG_PROM_OFFSET, |
235 | CFG_PROM_SIZE); | 249 | CFG_PROM_SIZE); |
236 | printf("CFG_GBL_DATA_OFFSET = 0x%lx (%d)\n", CFG_GBL_DATA_OFFSET, | 250 | printf("CFG_GBL_DATA_OFFSET = 0x%lx (%d)\n", CFG_GBL_DATA_OFFSET, |
237 | CFG_GBL_DATA_SIZE); | 251 | CFG_GBL_DATA_SIZE); |
238 | 252 | ||
239 | #if defined(CONFIG_CMD_NET) | 253 | #if defined(CONFIG_CMD_NET) |
240 | puts("ethaddr ="); | 254 | puts("ethaddr ="); |
241 | for (i = 0; i < 6; ++i) { | 255 | for (i = 0; i < 6; ++i) { |
242 | printf("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 256 | printf("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
243 | } | 257 | } |
244 | puts("\nIP addr = "); | 258 | puts("\nIP addr = "); |
245 | print_IPaddr(bd->bi_ip_addr); | 259 | print_IPaddr(bd->bi_ip_addr); |
246 | #endif | 260 | #endif |
247 | printf("\nbaudrate = %6ld bps\n", bd->bi_baudrate); | 261 | printf("\nbaudrate = %6ld bps\n", bd->bi_baudrate); |
248 | return 0; | 262 | return 0; |
249 | } | 263 | } |
250 | 264 | ||
251 | #elif defined(CONFIG_M68K) /* M68K */ | 265 | #elif defined(CONFIG_M68K) /* M68K */ |
252 | static void print_str(const char *, const char *); | 266 | static void print_str(const char *, const char *); |
253 | 267 | ||
254 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | 268 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
255 | { | 269 | { |
256 | int i; | 270 | int i; |
257 | bd_t *bd = gd->bd; | 271 | bd_t *bd = gd->bd; |
258 | char buf[32]; | 272 | char buf[32]; |
259 | 273 | ||
260 | print_num ("memstart", (ulong)bd->bi_memstart); | 274 | print_num ("memstart", (ulong)bd->bi_memstart); |
261 | print_lnum ("memsize", (u64)bd->bi_memsize); | 275 | print_lnum ("memsize", (u64)bd->bi_memsize); |
262 | print_num ("flashstart", (ulong)bd->bi_flashstart); | 276 | print_num ("flashstart", (ulong)bd->bi_flashstart); |
263 | print_num ("flashsize", (ulong)bd->bi_flashsize); | 277 | print_num ("flashsize", (ulong)bd->bi_flashsize); |
264 | print_num ("flashoffset", (ulong)bd->bi_flashoffset); | 278 | print_num ("flashoffset", (ulong)bd->bi_flashoffset); |
265 | #if defined(CFG_INIT_RAM_ADDR) | 279 | #if defined(CFG_INIT_RAM_ADDR) |
266 | print_num ("sramstart", (ulong)bd->bi_sramstart); | 280 | print_num ("sramstart", (ulong)bd->bi_sramstart); |
267 | print_num ("sramsize", (ulong)bd->bi_sramsize); | 281 | print_num ("sramsize", (ulong)bd->bi_sramsize); |
268 | #endif | 282 | #endif |
269 | #if defined(CFG_MBAR) | 283 | #if defined(CFG_MBAR) |
270 | print_num ("mbar", bd->bi_mbar_base); | 284 | print_num ("mbar", bd->bi_mbar_base); |
271 | #endif | 285 | #endif |
272 | print_str ("busfreq", strmhz(buf, bd->bi_busfreq)); | 286 | print_str ("busfreq", strmhz(buf, bd->bi_busfreq)); |
273 | #ifdef CONFIG_PCI | 287 | #ifdef CONFIG_PCI |
274 | print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq)); | 288 | print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq)); |
275 | #endif | 289 | #endif |
276 | #ifdef CONFIG_EXTRA_CLOCK | 290 | #ifdef CONFIG_EXTRA_CLOCK |
277 | print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq)); | 291 | print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq)); |
278 | print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq)); | 292 | print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq)); |
279 | print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq)); | 293 | print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq)); |
280 | #endif | 294 | #endif |
281 | #if defined(CONFIG_CMD_NET) | 295 | #if defined(CONFIG_CMD_NET) |
282 | puts ("ethaddr ="); | 296 | puts ("ethaddr ="); |
283 | for (i=0; i<6; ++i) { | 297 | for (i=0; i<6; ++i) { |
284 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 298 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
285 | } | 299 | } |
286 | 300 | ||
287 | #if defined(CONFIG_HAS_ETH1) | 301 | #if defined(CONFIG_HAS_ETH1) |
288 | puts ("\neth1addr ="); | 302 | puts ("\neth1addr ="); |
289 | for (i=0; i<6; ++i) { | 303 | for (i=0; i<6; ++i) { |
290 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]); | 304 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]); |
291 | } | 305 | } |
292 | #endif | 306 | #endif |
293 | 307 | ||
294 | #if defined(CONFIG_HAS_ETH2) | 308 | #if defined(CONFIG_HAS_ETH2) |
295 | puts ("\neth2addr ="); | 309 | puts ("\neth2addr ="); |
296 | for (i=0; i<6; ++i) { | 310 | for (i=0; i<6; ++i) { |
297 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]); | 311 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]); |
298 | } | 312 | } |
299 | #endif | 313 | #endif |
300 | 314 | ||
301 | #if defined(CONFIG_HAS_ETH3) | 315 | #if defined(CONFIG_HAS_ETH3) |
302 | puts ("\neth3addr ="); | 316 | puts ("\neth3addr ="); |
303 | for (i=0; i<6; ++i) { | 317 | for (i=0; i<6; ++i) { |
304 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]); | 318 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]); |
305 | } | 319 | } |
306 | #endif | 320 | #endif |
307 | 321 | ||
308 | puts ("\nip_addr = "); | 322 | puts ("\nip_addr = "); |
309 | print_IPaddr (bd->bi_ip_addr); | 323 | print_IPaddr (bd->bi_ip_addr); |
310 | #endif | 324 | #endif |
311 | printf ("\nbaudrate = %d bps\n", bd->bi_baudrate); | 325 | printf ("\nbaudrate = %d bps\n", bd->bi_baudrate); |
312 | 326 | ||
313 | return 0; | 327 | return 0; |
314 | } | 328 | } |
315 | 329 | ||
316 | #elif defined(CONFIG_BLACKFIN) | 330 | #elif defined(CONFIG_BLACKFIN) |
317 | 331 | ||
318 | int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | 332 | int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
319 | { | 333 | { |
320 | int i; | 334 | int i; |
321 | bd_t *bd = gd->bd; | 335 | bd_t *bd = gd->bd; |
322 | 336 | ||
323 | printf("U-Boot = %s\n", bd->bi_r_version); | 337 | printf("U-Boot = %s\n", bd->bi_r_version); |
324 | printf("CPU = %s\n", bd->bi_cpu); | 338 | printf("CPU = %s\n", bd->bi_cpu); |
325 | printf("Board = %s\n", bd->bi_board_name); | 339 | printf("Board = %s\n", bd->bi_board_name); |
326 | printf("VCO = %lu MHz\n", bd->bi_vco / 1000000); | 340 | printf("VCO = %lu MHz\n", bd->bi_vco / 1000000); |
327 | printf("CCLK = %lu MHz\n", bd->bi_cclk / 1000000); | 341 | printf("CCLK = %lu MHz\n", bd->bi_cclk / 1000000); |
328 | printf("SCLK = %lu MHz\n", bd->bi_sclk / 1000000); | 342 | printf("SCLK = %lu MHz\n", bd->bi_sclk / 1000000); |
329 | 343 | ||
330 | print_num("boot_params", (ulong)bd->bi_boot_params); | 344 | print_num("boot_params", (ulong)bd->bi_boot_params); |
331 | print_num("memstart", (ulong)bd->bi_memstart); | 345 | print_num("memstart", (ulong)bd->bi_memstart); |
332 | print_lnum("memsize", (u64)bd->bi_memsize); | 346 | print_lnum("memsize", (u64)bd->bi_memsize); |
333 | print_num("flashstart", (ulong)bd->bi_flashstart); | 347 | print_num("flashstart", (ulong)bd->bi_flashstart); |
334 | print_num("flashsize", (ulong)bd->bi_flashsize); | 348 | print_num("flashsize", (ulong)bd->bi_flashsize); |
335 | print_num("flashoffset", (ulong)bd->bi_flashoffset); | 349 | print_num("flashoffset", (ulong)bd->bi_flashoffset); |
336 | 350 | ||
337 | puts("ethaddr ="); | 351 | puts("ethaddr ="); |
338 | for (i = 0; i < 6; ++i) | 352 | for (i = 0; i < 6; ++i) |
339 | printf("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 353 | printf("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
340 | puts("\nip_addr = "); | 354 | puts("\nip_addr = "); |
341 | print_IPaddr(bd->bi_ip_addr); | 355 | print_IPaddr(bd->bi_ip_addr); |
342 | printf("\nbaudrate = %d bps\n", bd->bi_baudrate); | 356 | printf("\nbaudrate = %d bps\n", bd->bi_baudrate); |
343 | 357 | ||
344 | return 0; | 358 | return 0; |
345 | } | 359 | } |
346 | 360 | ||
347 | #else /* ! PPC, which leaves MIPS */ | 361 | #else /* ! PPC, which leaves MIPS */ |
348 | 362 | ||
349 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | 363 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
350 | { | 364 | { |
351 | int i; | 365 | int i; |
352 | bd_t *bd = gd->bd; | 366 | bd_t *bd = gd->bd; |
353 | 367 | ||
354 | print_num ("boot_params", (ulong)bd->bi_boot_params); | 368 | print_num ("boot_params", (ulong)bd->bi_boot_params); |
355 | print_num ("memstart", (ulong)bd->bi_memstart); | 369 | print_num ("memstart", (ulong)bd->bi_memstart); |
356 | print_lnum ("memsize", (u64)bd->bi_memsize); | 370 | print_lnum ("memsize", (u64)bd->bi_memsize); |
357 | print_num ("flashstart", (ulong)bd->bi_flashstart); | 371 | print_num ("flashstart", (ulong)bd->bi_flashstart); |
358 | print_num ("flashsize", (ulong)bd->bi_flashsize); | 372 | print_num ("flashsize", (ulong)bd->bi_flashsize); |
359 | print_num ("flashoffset", (ulong)bd->bi_flashoffset); | 373 | print_num ("flashoffset", (ulong)bd->bi_flashoffset); |
360 | 374 | ||
361 | puts ("ethaddr ="); | 375 | puts ("ethaddr ="); |
362 | for (i=0; i<6; ++i) { | 376 | for (i=0; i<6; ++i) { |
363 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 377 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
364 | } | 378 | } |
365 | puts ("\nip_addr = "); | 379 | puts ("\nip_addr = "); |
366 | print_IPaddr (bd->bi_ip_addr); | 380 | print_IPaddr (bd->bi_ip_addr); |
367 | printf ("\nbaudrate = %d bps\n", bd->bi_baudrate); | 381 | printf ("\nbaudrate = %d bps\n", bd->bi_baudrate); |
368 | 382 | ||
369 | return 0; | 383 | return 0; |
370 | } | 384 | } |
371 | #endif /* MIPS */ | 385 | #endif /* MIPS */ |
372 | 386 | ||
373 | #else /* ARM */ | 387 | #else /* ARM */ |
374 | 388 | ||
375 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | 389 | int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
376 | { | 390 | { |
377 | int i; | 391 | int i; |
378 | bd_t *bd = gd->bd; | 392 | bd_t *bd = gd->bd; |
379 | 393 | ||
380 | print_num ("arch_number", bd->bi_arch_number); | 394 | print_num ("arch_number", bd->bi_arch_number); |
381 | print_num ("env_t", (ulong)bd->bi_env); | 395 | print_num ("env_t", (ulong)bd->bi_env); |
382 | print_num ("boot_params", (ulong)bd->bi_boot_params); | 396 | print_num ("boot_params", (ulong)bd->bi_boot_params); |
383 | 397 | ||
384 | for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) { | 398 | for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) { |
385 | print_num("DRAM bank", i); | 399 | print_num("DRAM bank", i); |
386 | print_num("-> start", bd->bi_dram[i].start); | 400 | print_num("-> start", bd->bi_dram[i].start); |
387 | print_num("-> size", bd->bi_dram[i].size); | 401 | print_num("-> size", bd->bi_dram[i].size); |
388 | } | 402 | } |
389 | 403 | ||
390 | #if defined(CONFIG_CMD_NET) | 404 | #if defined(CONFIG_CMD_NET) |
391 | puts ("ethaddr ="); | 405 | puts ("ethaddr ="); |
392 | for (i=0; i<6; ++i) { | 406 | for (i=0; i<6; ++i) { |
393 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); | 407 | printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); |
394 | } | 408 | } |
395 | puts ( "\n" | 409 | puts ( "\n" |
396 | "ip_addr = "); | 410 | "ip_addr = "); |
397 | print_IPaddr (bd->bi_ip_addr); | 411 | print_IPaddr (bd->bi_ip_addr); |
398 | #endif | 412 | #endif |
399 | printf ("\n" | 413 | printf ("\n" |
400 | "baudrate = %d bps\n", bd->bi_baudrate); | 414 | "baudrate = %d bps\n", bd->bi_baudrate); |
401 | 415 | ||
402 | return 0; | 416 | return 0; |
403 | } | 417 | } |
404 | 418 | ||
405 | #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ | 419 | #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ |
406 | 420 | ||
407 | static void print_num(const char *name, ulong value) | 421 | static void print_num(const char *name, ulong value) |
408 | { | 422 | { |
409 | printf ("%-12s= 0x%08lX\n", name, value); | 423 | printf ("%-12s= 0x%08lX\n", name, value); |
410 | } | 424 | } |
411 | 425 | ||
412 | #ifndef CONFIG_ARM | 426 | #ifndef CONFIG_ARM |
413 | static void print_lnum(const char *name, u64 value) | 427 | static void print_lnum(const char *name, u64 value) |
414 | { | 428 | { |
415 | printf ("%-12s= 0x%.8llX\n", name, value); | 429 | printf ("%-12s= 0x%.8llX\n", name, value); |
416 | } | 430 | } |
417 | #endif | 431 | #endif |
418 | 432 | ||
419 | #if defined(CONFIG_PPC) || defined(CONFIG_M68K) | 433 | #if defined(CONFIG_PPC) || defined(CONFIG_M68K) |
420 | static void print_str(const char *name, const char *str) | 434 | static void print_str(const char *name, const char *str) |
421 | { | 435 | { |
422 | printf ("%-12s= %6s MHz\n", name, str); | 436 | printf ("%-12s= %6s MHz\n", name, str); |
423 | } | 437 | } |
424 | #endif /* CONFIG_PPC */ | 438 | #endif /* CONFIG_PPC */ |
425 | 439 | ||
426 | 440 | ||
427 | /* -------------------------------------------------------------------- */ | 441 | /* -------------------------------------------------------------------- */ |
428 | 442 | ||
429 | U_BOOT_CMD( | 443 | U_BOOT_CMD( |
430 | bdinfo, 1, 1, do_bdinfo, | 444 | bdinfo, 1, 1, do_bdinfo, |
431 | "bdinfo - print Board Info structure\n", | 445 | "bdinfo - print Board Info structure\n", |
432 | NULL | 446 | NULL |
433 | ); | 447 | ); |
434 | 448 |
common/env_common.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2000-2002 | 2 | * (C) Copyright 2000-2002 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> | 5 | * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
6 | * Andreas Heppel <aheppel@sysgo.de> | 6 | * Andreas Heppel <aheppel@sysgo.de> |
7 | 7 | ||
8 | * See file CREDITS for list of people who contributed to this | 8 | * See file CREDITS for list of people who contributed to this |
9 | * project. | 9 | * project. |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License as | 12 | * modify it under the terms of the GNU General Public License as |
13 | * published by the Free Software Foundation; either version 2 of | 13 | * published by the Free Software Foundation; either version 2 of |
14 | * the License, or (at your option) any later version. | 14 | * the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. | 19 | * GNU General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software | 22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
24 | * MA 02111-1307 USA | 24 | * MA 02111-1307 USA |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <common.h> | 27 | #include <common.h> |
28 | #include <command.h> | 28 | #include <command.h> |
29 | #include <environment.h> | 29 | #include <environment.h> |
30 | #include <linux/stddef.h> | 30 | #include <linux/stddef.h> |
31 | #include <malloc.h> | 31 | #include <malloc.h> |
32 | 32 | ||
33 | DECLARE_GLOBAL_DATA_PTR; | 33 | DECLARE_GLOBAL_DATA_PTR; |
34 | 34 | ||
35 | #ifdef CONFIG_AMIGAONEG3SE | 35 | #ifdef CONFIG_AMIGAONEG3SE |
36 | extern void enable_nvram(void); | 36 | extern void enable_nvram(void); |
37 | extern void disable_nvram(void); | 37 | extern void disable_nvram(void); |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #undef DEBUG_ENV | 40 | #undef DEBUG_ENV |
41 | #ifdef DEBUG_ENV | 41 | #ifdef DEBUG_ENV |
42 | #define DEBUGF(fmt,args...) printf(fmt ,##args) | 42 | #define DEBUGF(fmt,args...) printf(fmt ,##args) |
43 | #else | 43 | #else |
44 | #define DEBUGF(fmt,args...) | 44 | #define DEBUGF(fmt,args...) |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | extern env_t *env_ptr; | 47 | extern env_t *env_ptr; |
48 | 48 | ||
49 | extern void env_relocate_spec (void); | 49 | extern void env_relocate_spec (void); |
50 | extern uchar env_get_char_spec(int); | 50 | extern uchar env_get_char_spec(int); |
51 | 51 | ||
52 | static uchar env_get_char_init (int index); | 52 | static uchar env_get_char_init (int index); |
53 | 53 | ||
54 | /************************************************************************ | 54 | /************************************************************************ |
55 | * Default settings to be used when no valid environment is found | 55 | * Default settings to be used when no valid environment is found |
56 | */ | 56 | */ |
57 | #define XMK_STR(x) #x | 57 | #define XMK_STR(x) #x |
58 | #define MK_STR(x) XMK_STR(x) | 58 | #define MK_STR(x) XMK_STR(x) |
59 | 59 | ||
60 | uchar default_environment[] = { | 60 | uchar default_environment[] = { |
61 | #ifdef CONFIG_BOOTARGS | 61 | #ifdef CONFIG_BOOTARGS |
62 | "bootargs=" CONFIG_BOOTARGS "\0" | 62 | "bootargs=" CONFIG_BOOTARGS "\0" |
63 | #endif | 63 | #endif |
64 | #ifdef CONFIG_BOOTCOMMAND | 64 | #ifdef CONFIG_BOOTCOMMAND |
65 | "bootcmd=" CONFIG_BOOTCOMMAND "\0" | 65 | "bootcmd=" CONFIG_BOOTCOMMAND "\0" |
66 | #endif | 66 | #endif |
67 | #ifdef CONFIG_RAMBOOTCOMMAND | 67 | #ifdef CONFIG_RAMBOOTCOMMAND |
68 | "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" | 68 | "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" |
69 | #endif | 69 | #endif |
70 | #ifdef CONFIG_NFSBOOTCOMMAND | 70 | #ifdef CONFIG_NFSBOOTCOMMAND |
71 | "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" | 71 | "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" |
72 | #endif | 72 | #endif |
73 | #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) | 73 | #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) |
74 | "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0" | 74 | "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0" |
75 | #endif | 75 | #endif |
76 | #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) | 76 | #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) |
77 | "baudrate=" MK_STR(CONFIG_BAUDRATE) "\0" | 77 | "baudrate=" MK_STR(CONFIG_BAUDRATE) "\0" |
78 | #endif | 78 | #endif |
79 | #ifdef CONFIG_LOADS_ECHO | 79 | #ifdef CONFIG_LOADS_ECHO |
80 | "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) "\0" | 80 | "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) "\0" |
81 | #endif | 81 | #endif |
82 | #ifdef CONFIG_ETHADDR | 82 | #ifdef CONFIG_ETHADDR |
83 | "ethaddr=" MK_STR(CONFIG_ETHADDR) "\0" | 83 | "ethaddr=" MK_STR(CONFIG_ETHADDR) "\0" |
84 | #endif | 84 | #endif |
85 | #ifdef CONFIG_ETH1ADDR | 85 | #ifdef CONFIG_ETH1ADDR |
86 | "eth1addr=" MK_STR(CONFIG_ETH1ADDR) "\0" | 86 | "eth1addr=" MK_STR(CONFIG_ETH1ADDR) "\0" |
87 | #endif | 87 | #endif |
88 | #ifdef CONFIG_ETH2ADDR | 88 | #ifdef CONFIG_ETH2ADDR |
89 | "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0" | 89 | "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0" |
90 | #endif | 90 | #endif |
91 | #ifdef CONFIG_ETH3ADDR | 91 | #ifdef CONFIG_ETH3ADDR |
92 | "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" | 92 | "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" |
93 | #endif | 93 | #endif |
94 | #ifdef CONFIG_ETH4ADDR | ||
95 | "eth4addr=" MK_STR(CONFIG_ETH4ADDR) "\0" | ||
96 | #endif | ||
97 | #ifdef CONFIG_ETH5ADDR | ||
98 | "eth5addr=" MK_STR(CONFIG_ETH5ADDR) "\0" | ||
99 | #endif | ||
94 | #ifdef CONFIG_IPADDR | 100 | #ifdef CONFIG_IPADDR |
95 | "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" | 101 | "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" |
96 | #endif | 102 | #endif |
97 | #ifdef CONFIG_SERVERIP | 103 | #ifdef CONFIG_SERVERIP |
98 | "serverip=" MK_STR(CONFIG_SERVERIP) "\0" | 104 | "serverip=" MK_STR(CONFIG_SERVERIP) "\0" |
99 | #endif | 105 | #endif |
100 | #ifdef CFG_AUTOLOAD | 106 | #ifdef CFG_AUTOLOAD |
101 | "autoload=" CFG_AUTOLOAD "\0" | 107 | "autoload=" CFG_AUTOLOAD "\0" |
102 | #endif | 108 | #endif |
103 | #ifdef CONFIG_PREBOOT | 109 | #ifdef CONFIG_PREBOOT |
104 | "preboot=" CONFIG_PREBOOT "\0" | 110 | "preboot=" CONFIG_PREBOOT "\0" |
105 | #endif | 111 | #endif |
106 | #ifdef CONFIG_ROOTPATH | 112 | #ifdef CONFIG_ROOTPATH |
107 | "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0" | 113 | "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0" |
108 | #endif | 114 | #endif |
109 | #ifdef CONFIG_GATEWAYIP | 115 | #ifdef CONFIG_GATEWAYIP |
110 | "gatewayip=" MK_STR(CONFIG_GATEWAYIP) "\0" | 116 | "gatewayip=" MK_STR(CONFIG_GATEWAYIP) "\0" |
111 | #endif | 117 | #endif |
112 | #ifdef CONFIG_NETMASK | 118 | #ifdef CONFIG_NETMASK |
113 | "netmask=" MK_STR(CONFIG_NETMASK) "\0" | 119 | "netmask=" MK_STR(CONFIG_NETMASK) "\0" |
114 | #endif | 120 | #endif |
115 | #ifdef CONFIG_HOSTNAME | 121 | #ifdef CONFIG_HOSTNAME |
116 | "hostname=" MK_STR(CONFIG_HOSTNAME) "\0" | 122 | "hostname=" MK_STR(CONFIG_HOSTNAME) "\0" |
117 | #endif | 123 | #endif |
118 | #ifdef CONFIG_BOOTFILE | 124 | #ifdef CONFIG_BOOTFILE |
119 | "bootfile=" MK_STR(CONFIG_BOOTFILE) "\0" | 125 | "bootfile=" MK_STR(CONFIG_BOOTFILE) "\0" |
120 | #endif | 126 | #endif |
121 | #ifdef CONFIG_LOADADDR | 127 | #ifdef CONFIG_LOADADDR |
122 | "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0" | 128 | "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0" |
123 | #endif | 129 | #endif |
124 | #ifdef CONFIG_CLOCKS_IN_MHZ | 130 | #ifdef CONFIG_CLOCKS_IN_MHZ |
125 | "clocks_in_mhz=1\0" | 131 | "clocks_in_mhz=1\0" |
126 | #endif | 132 | #endif |
127 | #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) | 133 | #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) |
128 | "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0" | 134 | "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0" |
129 | #endif | 135 | #endif |
130 | #ifdef CONFIG_EXTRA_ENV_SETTINGS | 136 | #ifdef CONFIG_EXTRA_ENV_SETTINGS |
131 | CONFIG_EXTRA_ENV_SETTINGS | 137 | CONFIG_EXTRA_ENV_SETTINGS |
132 | #endif | 138 | #endif |
133 | "\0" | 139 | "\0" |
134 | }; | 140 | }; |
135 | 141 | ||
136 | #if defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ \ | 142 | #if defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in Nand Flash */ \ |
137 | || defined(CONFIG_ENV_IS_IN_SPI_FLASH) | 143 | || defined(CONFIG_ENV_IS_IN_SPI_FLASH) |
138 | int default_environment_size = sizeof(default_environment); | 144 | int default_environment_size = sizeof(default_environment); |
139 | #endif | 145 | #endif |
140 | 146 | ||
141 | void env_crc_update (void) | 147 | void env_crc_update (void) |
142 | { | 148 | { |
143 | env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE); | 149 | env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE); |
144 | } | 150 | } |
145 | 151 | ||
146 | static uchar env_get_char_init (int index) | 152 | static uchar env_get_char_init (int index) |
147 | { | 153 | { |
148 | uchar c; | 154 | uchar c; |
149 | 155 | ||
150 | /* if crc was bad, use the default environment */ | 156 | /* if crc was bad, use the default environment */ |
151 | if (gd->env_valid) | 157 | if (gd->env_valid) |
152 | { | 158 | { |
153 | c = env_get_char_spec(index); | 159 | c = env_get_char_spec(index); |
154 | } else { | 160 | } else { |
155 | c = default_environment[index]; | 161 | c = default_environment[index]; |
156 | } | 162 | } |
157 | 163 | ||
158 | return (c); | 164 | return (c); |
159 | } | 165 | } |
160 | 166 | ||
161 | #ifdef CONFIG_AMIGAONEG3SE | 167 | #ifdef CONFIG_AMIGAONEG3SE |
162 | uchar env_get_char_memory (int index) | 168 | uchar env_get_char_memory (int index) |
163 | { | 169 | { |
164 | uchar retval; | 170 | uchar retval; |
165 | enable_nvram(); | 171 | enable_nvram(); |
166 | if (gd->env_valid) { | 172 | if (gd->env_valid) { |
167 | retval = ( *((uchar *)(gd->env_addr + index)) ); | 173 | retval = ( *((uchar *)(gd->env_addr + index)) ); |
168 | } else { | 174 | } else { |
169 | retval = ( default_environment[index] ); | 175 | retval = ( default_environment[index] ); |
170 | } | 176 | } |
171 | disable_nvram(); | 177 | disable_nvram(); |
172 | return retval; | 178 | return retval; |
173 | } | 179 | } |
174 | #else | 180 | #else |
175 | uchar env_get_char_memory (int index) | 181 | uchar env_get_char_memory (int index) |
176 | { | 182 | { |
177 | if (gd->env_valid) { | 183 | if (gd->env_valid) { |
178 | return ( *((uchar *)(gd->env_addr + index)) ); | 184 | return ( *((uchar *)(gd->env_addr + index)) ); |
179 | } else { | 185 | } else { |
180 | return ( default_environment[index] ); | 186 | return ( default_environment[index] ); |
181 | } | 187 | } |
182 | } | 188 | } |
183 | #endif | 189 | #endif |
184 | 190 | ||
185 | uchar env_get_char (int index) | 191 | uchar env_get_char (int index) |
186 | { | 192 | { |
187 | uchar c; | 193 | uchar c; |
188 | 194 | ||
189 | /* if relocated to RAM */ | 195 | /* if relocated to RAM */ |
190 | if (gd->flags & GD_FLG_RELOC) | 196 | if (gd->flags & GD_FLG_RELOC) |
191 | c = env_get_char_memory(index); | 197 | c = env_get_char_memory(index); |
192 | else | 198 | else |
193 | c = env_get_char_init(index); | 199 | c = env_get_char_init(index); |
194 | 200 | ||
195 | return (c); | 201 | return (c); |
196 | } | 202 | } |
197 | 203 | ||
198 | uchar *env_get_addr (int index) | 204 | uchar *env_get_addr (int index) |
199 | { | 205 | { |
200 | if (gd->env_valid) { | 206 | if (gd->env_valid) { |
201 | return ( ((uchar *)(gd->env_addr + index)) ); | 207 | return ( ((uchar *)(gd->env_addr + index)) ); |
202 | } else { | 208 | } else { |
203 | return (&default_environment[index]); | 209 | return (&default_environment[index]); |
204 | } | 210 | } |
205 | } | 211 | } |
206 | 212 | ||
207 | void set_default_env(void) | 213 | void set_default_env(void) |
208 | { | 214 | { |
209 | if (sizeof(default_environment) > ENV_SIZE) { | 215 | if (sizeof(default_environment) > ENV_SIZE) { |
210 | puts ("*** Error - default environment is too large\n\n"); | 216 | puts ("*** Error - default environment is too large\n\n"); |
211 | return; | 217 | return; |
212 | } | 218 | } |
213 | 219 | ||
214 | memset(env_ptr, 0, sizeof(env_t)); | 220 | memset(env_ptr, 0, sizeof(env_t)); |
215 | memcpy(env_ptr->data, default_environment, | 221 | memcpy(env_ptr->data, default_environment, |
216 | sizeof(default_environment)); | 222 | sizeof(default_environment)); |
217 | #ifdef CFG_REDUNDAND_ENVIRONMENT | 223 | #ifdef CFG_REDUNDAND_ENVIRONMENT |
218 | env_ptr->flags = 0xFF; | 224 | env_ptr->flags = 0xFF; |
219 | #endif | 225 | #endif |
220 | env_crc_update (); | 226 | env_crc_update (); |
221 | gd->env_valid = 1; | 227 | gd->env_valid = 1; |
222 | } | 228 | } |
223 | 229 | ||
224 | void env_relocate (void) | 230 | void env_relocate (void) |
225 | { | 231 | { |
226 | DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__, | 232 | DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__, |
227 | gd->reloc_off); | 233 | gd->reloc_off); |
228 | 234 | ||
229 | #ifdef CONFIG_AMIGAONEG3SE | 235 | #ifdef CONFIG_AMIGAONEG3SE |
230 | enable_nvram(); | 236 | enable_nvram(); |
231 | #endif | 237 | #endif |
232 | 238 | ||
233 | #ifdef ENV_IS_EMBEDDED | 239 | #ifdef ENV_IS_EMBEDDED |
234 | /* | 240 | /* |
235 | * The environment buffer is embedded with the text segment, | 241 | * The environment buffer is embedded with the text segment, |
236 | * just relocate the environment pointer | 242 | * just relocate the environment pointer |
237 | */ | 243 | */ |
238 | env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off); | 244 | env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off); |
239 | DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); | 245 | DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); |
240 | #else | 246 | #else |
241 | /* | 247 | /* |
242 | * We must allocate a buffer for the environment | 248 | * We must allocate a buffer for the environment |
243 | */ | 249 | */ |
244 | env_ptr = (env_t *)malloc (CONFIG_ENV_SIZE); | 250 | env_ptr = (env_t *)malloc (CONFIG_ENV_SIZE); |
245 | DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); | 251 | DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); |
246 | #endif | 252 | #endif |
247 | 253 | ||
248 | if (gd->env_valid == 0) { | 254 | if (gd->env_valid == 0) { |
249 | #if defined(CONFIG_GTH) || defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */ | 255 | #if defined(CONFIG_GTH) || defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */ |
250 | puts ("Using default environment\n\n"); | 256 | puts ("Using default environment\n\n"); |
251 | #else | 257 | #else |
252 | puts ("*** Warning - bad CRC, using default environment\n\n"); | 258 | puts ("*** Warning - bad CRC, using default environment\n\n"); |
253 | show_boot_progress (-60); | 259 | show_boot_progress (-60); |
254 | #endif | 260 | #endif |
255 | set_default_env(); | 261 | set_default_env(); |
256 | } | 262 | } |
257 | else { | 263 | else { |
258 | env_relocate_spec (); | 264 | env_relocate_spec (); |
259 | } | 265 | } |
260 | gd->env_addr = (ulong)&(env_ptr->data); | 266 | gd->env_addr = (ulong)&(env_ptr->data); |
261 | 267 | ||
262 | #ifdef CONFIG_AMIGAONEG3SE | 268 | #ifdef CONFIG_AMIGAONEG3SE |
263 | disable_nvram(); | 269 | disable_nvram(); |
264 | #endif | 270 | #endif |
265 | } | 271 | } |
266 | 272 | ||
267 | #ifdef CONFIG_AUTO_COMPLETE | 273 | #ifdef CONFIG_AUTO_COMPLETE |
268 | int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf) | 274 | int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf) |
269 | { | 275 | { |
270 | int i, nxt, len, vallen, found; | 276 | int i, nxt, len, vallen, found; |
271 | const char *lval, *rval; | 277 | const char *lval, *rval; |
272 | 278 | ||
273 | found = 0; | 279 | found = 0; |
274 | cmdv[0] = NULL; | 280 | cmdv[0] = NULL; |
275 | 281 | ||
276 | len = strlen(var); | 282 | len = strlen(var); |
277 | /* now iterate over the variables and select those that match */ | 283 | /* now iterate over the variables and select those that match */ |
278 | for (i=0; env_get_char(i) != '\0'; i=nxt+1) { | 284 | for (i=0; env_get_char(i) != '\0'; i=nxt+1) { |
279 | 285 | ||
280 | for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) | 286 | for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) |
281 | ; | 287 | ; |
282 | 288 | ||
283 | lval = (char *)env_get_addr(i); | 289 | lval = (char *)env_get_addr(i); |
284 | rval = strchr(lval, '='); | 290 | rval = strchr(lval, '='); |
285 | if (rval != NULL) { | 291 | if (rval != NULL) { |
286 | vallen = rval - lval; | 292 | vallen = rval - lval; |
287 | rval++; | 293 | rval++; |
288 | } else | 294 | } else |
289 | vallen = strlen(lval); | 295 | vallen = strlen(lval); |
290 | 296 | ||
291 | if (len > 0 && (vallen < len || memcmp(lval, var, len) != 0)) | 297 | if (len > 0 && (vallen < len || memcmp(lval, var, len) != 0)) |
292 | continue; | 298 | continue; |
293 | 299 | ||
294 | if (found >= maxv - 2 || bufsz < vallen + 1) { | 300 | if (found >= maxv - 2 || bufsz < vallen + 1) { |
295 | cmdv[found++] = "..."; | 301 | cmdv[found++] = "..."; |
296 | break; | 302 | break; |
297 | } | 303 | } |
298 | cmdv[found++] = buf; | 304 | cmdv[found++] = buf; |
299 | memcpy(buf, lval, vallen); buf += vallen; bufsz -= vallen; | 305 | memcpy(buf, lval, vallen); buf += vallen; bufsz -= vallen; |
300 | *buf++ = '\0'; bufsz--; | 306 | *buf++ = '\0'; bufsz--; |
301 | } | 307 | } |
302 | 308 | ||
303 | cmdv[found] = NULL; | 309 | cmdv[found] = NULL; |
304 | return found; | 310 | return found; |
305 | } | 311 | } |
306 | #endif | 312 | #endif |
307 | 313 |
common/env_embedded.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2001 | 2 | * (C) Copyright 2001 |
3 | * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. | 3 | * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. |
4 | * | 4 | * |
5 | * See file CREDITS for list of people who contributed to this | 5 | * See file CREDITS for list of people who contributed to this |
6 | * project. | 6 | * project. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of | 10 | * published by the Free Software Foundation; either version 2 of |
11 | * the License, or (at your option) any later version. | 11 | * the License, or (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | * MA 02111-1307 USA | 21 | * MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef __ASSEMBLY__ | 24 | #ifndef __ASSEMBLY__ |
25 | #define __ASSEMBLY__ /* Dirty trick to get only #defines */ | 25 | #define __ASSEMBLY__ /* Dirty trick to get only #defines */ |
26 | #endif | 26 | #endif |
27 | #define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */ | 27 | #define __ASM_STUB_PROCESSOR_H__ /* don't include asm/processor. */ |
28 | #include <config.h> | 28 | #include <config.h> |
29 | #undef __ASSEMBLY__ | 29 | #undef __ASSEMBLY__ |
30 | #include <environment.h> | 30 | #include <environment.h> |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * Handle HOSTS that have prepended | 33 | * Handle HOSTS that have prepended |
34 | * crap on symbol names, not TARGETS. | 34 | * crap on symbol names, not TARGETS. |
35 | */ | 35 | */ |
36 | #if defined(__APPLE__) | 36 | #if defined(__APPLE__) |
37 | /* Leading underscore on symbols */ | 37 | /* Leading underscore on symbols */ |
38 | # define SYM_CHAR "_" | 38 | # define SYM_CHAR "_" |
39 | #else /* No leading character on symbols */ | 39 | #else /* No leading character on symbols */ |
40 | # define SYM_CHAR | 40 | # define SYM_CHAR |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * Generate embedded environment table | 44 | * Generate embedded environment table |
45 | * inside U-Boot image, if needed. | 45 | * inside U-Boot image, if needed. |
46 | */ | 46 | */ |
47 | #if defined(ENV_IS_EMBEDDED) | 47 | #if defined(ENV_IS_EMBEDDED) |
48 | /* | 48 | /* |
49 | * Only put the environment in it's own section when we are building | 49 | * Only put the environment in it's own section when we are building |
50 | * U-Boot proper. The host based program "tools/envcrc" does not need | 50 | * U-Boot proper. The host based program "tools/envcrc" does not need |
51 | * a seperate section. Note that ENV_CRC is only defined when building | 51 | * a seperate section. Note that ENV_CRC is only defined when building |
52 | * U-Boot itself. | 52 | * U-Boot itself. |
53 | */ | 53 | */ |
54 | #if (defined(CFG_USE_PPCENV) || defined(CONFIG_NAND_U_BOOT)) && \ | 54 | #if (defined(CFG_USE_PPCENV) || defined(CONFIG_NAND_U_BOOT)) && \ |
55 | defined(ENV_CRC) /* Environment embedded in U-Boot .ppcenv section */ | 55 | defined(ENV_CRC) /* Environment embedded in U-Boot .ppcenv section */ |
56 | /* XXX - This only works with GNU C */ | 56 | /* XXX - This only works with GNU C */ |
57 | # define __PPCENV__ __attribute__ ((section(".ppcenv"))) | 57 | # define __PPCENV__ __attribute__ ((section(".ppcenv"))) |
58 | # define __PPCTEXT__ __attribute__ ((section(".text"))) | 58 | # define __PPCTEXT__ __attribute__ ((section(".text"))) |
59 | 59 | ||
60 | #elif defined(USE_HOSTCC) /* Native for 'tools/envcrc' */ | 60 | #elif defined(USE_HOSTCC) /* Native for 'tools/envcrc' */ |
61 | # define __PPCENV__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ | 61 | # define __PPCENV__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ |
62 | # define __PPCTEXT__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ | 62 | # define __PPCTEXT__ /*XXX DO_NOT_DEL_THIS_COMMENT*/ |
63 | 63 | ||
64 | #else /* Environment is embedded in U-Boot's .text section */ | 64 | #else /* Environment is embedded in U-Boot's .text section */ |
65 | /* XXX - This only works with GNU C */ | 65 | /* XXX - This only works with GNU C */ |
66 | # define __PPCENV__ __attribute__ ((section(".text"))) | 66 | # define __PPCENV__ __attribute__ ((section(".text"))) |
67 | # define __PPCTEXT__ __attribute__ ((section(".text"))) | 67 | # define __PPCTEXT__ __attribute__ ((section(".text"))) |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | /* | 70 | /* |
71 | * Macros to generate global absolutes. | 71 | * Macros to generate global absolutes. |
72 | */ | 72 | */ |
73 | #if defined(__bfin__) | 73 | #if defined(__bfin__) |
74 | # define GEN_SET_VALUE(name, value) asm (".set " GEN_SYMNAME(name) ", " GEN_VALUE(value)) | 74 | # define GEN_SET_VALUE(name, value) asm (".set " GEN_SYMNAME(name) ", " GEN_VALUE(value)) |
75 | #else | 75 | #else |
76 | # define GEN_SET_VALUE(name, value) asm (GEN_SYMNAME(name) " = " GEN_VALUE(value)) | 76 | # define GEN_SET_VALUE(name, value) asm (GEN_SYMNAME(name) " = " GEN_VALUE(value)) |
77 | #endif | 77 | #endif |
78 | #define GEN_SYMNAME(str) SYM_CHAR #str | 78 | #define GEN_SYMNAME(str) SYM_CHAR #str |
79 | #define GEN_VALUE(str) #str | 79 | #define GEN_VALUE(str) #str |
80 | #define GEN_ABS(name, value) \ | 80 | #define GEN_ABS(name, value) \ |
81 | asm (".globl " GEN_SYMNAME(name)); \ | 81 | asm (".globl " GEN_SYMNAME(name)); \ |
82 | GEN_SET_VALUE(name, value) | 82 | GEN_SET_VALUE(name, value) |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * Macros to transform values | 85 | * Macros to transform values |
86 | * into environment strings. | 86 | * into environment strings. |
87 | */ | 87 | */ |
88 | #define XMK_STR(x) #x | 88 | #define XMK_STR(x) #x |
89 | #define MK_STR(x) XMK_STR(x) | 89 | #define MK_STR(x) XMK_STR(x) |
90 | 90 | ||
91 | /* | 91 | /* |
92 | * Check to see if we are building with a | 92 | * Check to see if we are building with a |
93 | * computed CRC. Otherwise define it as ~0. | 93 | * computed CRC. Otherwise define it as ~0. |
94 | */ | 94 | */ |
95 | #if !defined(ENV_CRC) | 95 | #if !defined(ENV_CRC) |
96 | # define ENV_CRC ~0 | 96 | # define ENV_CRC ~0 |
97 | #endif | 97 | #endif |
98 | 98 | ||
99 | env_t environment __PPCENV__ = { | 99 | env_t environment __PPCENV__ = { |
100 | ENV_CRC, /* CRC Sum */ | 100 | ENV_CRC, /* CRC Sum */ |
101 | #ifdef CFG_REDUNDAND_ENVIRONMENT | 101 | #ifdef CFG_REDUNDAND_ENVIRONMENT |
102 | 1, /* Flags: valid */ | 102 | 1, /* Flags: valid */ |
103 | #endif | 103 | #endif |
104 | { | 104 | { |
105 | #if defined(CONFIG_BOOTARGS) | 105 | #if defined(CONFIG_BOOTARGS) |
106 | "bootargs=" CONFIG_BOOTARGS "\0" | 106 | "bootargs=" CONFIG_BOOTARGS "\0" |
107 | #endif | 107 | #endif |
108 | #if defined(CONFIG_BOOTCOMMAND) | 108 | #if defined(CONFIG_BOOTCOMMAND) |
109 | "bootcmd=" CONFIG_BOOTCOMMAND "\0" | 109 | "bootcmd=" CONFIG_BOOTCOMMAND "\0" |
110 | #endif | 110 | #endif |
111 | #if defined(CONFIG_RAMBOOTCOMMAND) | 111 | #if defined(CONFIG_RAMBOOTCOMMAND) |
112 | "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" | 112 | "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" |
113 | #endif | 113 | #endif |
114 | #if defined(CONFIG_NFSBOOTCOMMAND) | 114 | #if defined(CONFIG_NFSBOOTCOMMAND) |
115 | "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" | 115 | "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" |
116 | #endif | 116 | #endif |
117 | #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) | 117 | #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) |
118 | "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0" | 118 | "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0" |
119 | #endif | 119 | #endif |
120 | #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) | 120 | #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) |
121 | "baudrate=" MK_STR(CONFIG_BAUDRATE) "\0" | 121 | "baudrate=" MK_STR(CONFIG_BAUDRATE) "\0" |
122 | #endif | 122 | #endif |
123 | #ifdef CONFIG_LOADS_ECHO | 123 | #ifdef CONFIG_LOADS_ECHO |
124 | "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) "\0" | 124 | "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) "\0" |
125 | #endif | 125 | #endif |
126 | #ifdef CONFIG_ETHADDR | 126 | #ifdef CONFIG_ETHADDR |
127 | "ethaddr=" MK_STR(CONFIG_ETHADDR) "\0" | 127 | "ethaddr=" MK_STR(CONFIG_ETHADDR) "\0" |
128 | #endif | 128 | #endif |
129 | #ifdef CONFIG_ETH1ADDR | 129 | #ifdef CONFIG_ETH1ADDR |
130 | "eth1addr=" MK_STR(CONFIG_ETH1ADDR) "\0" | 130 | "eth1addr=" MK_STR(CONFIG_ETH1ADDR) "\0" |
131 | #endif | 131 | #endif |
132 | #ifdef CONFIG_ETH2ADDR | 132 | #ifdef CONFIG_ETH2ADDR |
133 | "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0" | 133 | "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0" |
134 | #endif | 134 | #endif |
135 | #ifdef CONFIG_ETH3ADDR | 135 | #ifdef CONFIG_ETH3ADDR |
136 | "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" | 136 | "eth3addr=" MK_STR(CONFIG_ETH3ADDR) "\0" |
137 | #endif | 137 | #endif |
138 | #ifdef CONFIG_ETH4ADDR | ||
139 | "eth4addr=" MK_STR(CONFIG_ETH4ADDR) "\0" | ||
140 | #endif | ||
141 | #ifdef CONFIG_ETH5ADDR | ||
142 | "eth5addr=" MK_STR(CONFIG_ETH5ADDR) "\0" | ||
143 | #endif | ||
138 | #ifdef CONFIG_ETHPRIME | 144 | #ifdef CONFIG_ETHPRIME |
139 | "ethprime=" CONFIG_ETHPRIME "\0" | 145 | "ethprime=" CONFIG_ETHPRIME "\0" |
140 | #endif | 146 | #endif |
141 | #ifdef CONFIG_IPADDR | 147 | #ifdef CONFIG_IPADDR |
142 | "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" | 148 | "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" |
143 | #endif | 149 | #endif |
144 | #ifdef CONFIG_SERVERIP | 150 | #ifdef CONFIG_SERVERIP |
145 | "serverip=" MK_STR(CONFIG_SERVERIP) "\0" | 151 | "serverip=" MK_STR(CONFIG_SERVERIP) "\0" |
146 | #endif | 152 | #endif |
147 | #ifdef CFG_AUTOLOAD | 153 | #ifdef CFG_AUTOLOAD |
148 | "autoload=" CFG_AUTOLOAD "\0" | 154 | "autoload=" CFG_AUTOLOAD "\0" |
149 | #endif | 155 | #endif |
150 | #ifdef CONFIG_ROOTPATH | 156 | #ifdef CONFIG_ROOTPATH |
151 | "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0" | 157 | "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0" |
152 | #endif | 158 | #endif |
153 | #ifdef CONFIG_GATEWAYIP | 159 | #ifdef CONFIG_GATEWAYIP |
154 | "gatewayip=" MK_STR(CONFIG_GATEWAYIP) "\0" | 160 | "gatewayip=" MK_STR(CONFIG_GATEWAYIP) "\0" |
155 | #endif | 161 | #endif |
156 | #ifdef CONFIG_NETMASK | 162 | #ifdef CONFIG_NETMASK |
157 | "netmask=" MK_STR(CONFIG_NETMASK) "\0" | 163 | "netmask=" MK_STR(CONFIG_NETMASK) "\0" |
158 | #endif | 164 | #endif |
159 | #ifdef CONFIG_HOSTNAME | 165 | #ifdef CONFIG_HOSTNAME |
160 | "hostname=" MK_STR(CONFIG_HOSTNAME) "\0" | 166 | "hostname=" MK_STR(CONFIG_HOSTNAME) "\0" |
161 | #endif | 167 | #endif |
162 | #ifdef CONFIG_BOOTFILE | 168 | #ifdef CONFIG_BOOTFILE |
163 | "bootfile=" MK_STR(CONFIG_BOOTFILE) "\0" | 169 | "bootfile=" MK_STR(CONFIG_BOOTFILE) "\0" |
164 | #endif | 170 | #endif |
165 | #ifdef CONFIG_LOADADDR | 171 | #ifdef CONFIG_LOADADDR |
166 | "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0" | 172 | "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0" |
167 | #endif | 173 | #endif |
168 | #ifdef CONFIG_PREBOOT | 174 | #ifdef CONFIG_PREBOOT |
169 | "preboot=" CONFIG_PREBOOT "\0" | 175 | "preboot=" CONFIG_PREBOOT "\0" |
170 | #endif | 176 | #endif |
171 | #ifdef CONFIG_CLOCKS_IN_MHZ | 177 | #ifdef CONFIG_CLOCKS_IN_MHZ |
172 | "clocks_in_mhz=" "1" "\0" | 178 | "clocks_in_mhz=" "1" "\0" |
173 | #endif | 179 | #endif |
174 | #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) | 180 | #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) |
175 | "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0" | 181 | "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0" |
176 | #endif | 182 | #endif |
177 | #ifdef CONFIG_EXTRA_ENV_SETTINGS | 183 | #ifdef CONFIG_EXTRA_ENV_SETTINGS |
178 | CONFIG_EXTRA_ENV_SETTINGS | 184 | CONFIG_EXTRA_ENV_SETTINGS |
179 | #endif | 185 | #endif |
180 | "\0" /* Term. env_t.data with 2 NULs */ | 186 | "\0" /* Term. env_t.data with 2 NULs */ |
181 | } | 187 | } |
182 | }; | 188 | }; |
183 | #ifdef CONFIG_ENV_ADDR_REDUND | 189 | #ifdef CONFIG_ENV_ADDR_REDUND |
184 | env_t redundand_environment __PPCENV__ = { | 190 | env_t redundand_environment __PPCENV__ = { |
185 | 0, /* CRC Sum: invalid */ | 191 | 0, /* CRC Sum: invalid */ |
186 | 0, /* Flags: invalid */ | 192 | 0, /* Flags: invalid */ |
187 | { | 193 | { |
188 | "\0" | 194 | "\0" |
189 | } | 195 | } |
190 | }; | 196 | }; |
191 | #endif /* CONFIG_ENV_ADDR_REDUND */ | 197 | #endif /* CONFIG_ENV_ADDR_REDUND */ |
192 | 198 | ||
193 | /* | 199 | /* |
194 | * These will end up in the .text section | 200 | * These will end up in the .text section |
195 | * if the environment strings are embedded | 201 | * if the environment strings are embedded |
196 | * in the image. When this is used for | 202 | * in the image. When this is used for |
197 | * tools/envcrc, they are placed in the | 203 | * tools/envcrc, they are placed in the |
198 | * .data/.sdata section. | 204 | * .data/.sdata section. |
199 | * | 205 | * |
200 | */ | 206 | */ |
201 | unsigned long env_size __PPCTEXT__ = sizeof(env_t); | 207 | unsigned long env_size __PPCTEXT__ = sizeof(env_t); |
202 | 208 | ||
203 | /* | 209 | /* |
204 | * Add in absolutes. | 210 | * Add in absolutes. |
205 | */ | 211 | */ |
206 | GEN_ABS(env_offset, CONFIG_ENV_OFFSET); | 212 | GEN_ABS(env_offset, CONFIG_ENV_OFFSET); |
207 | 213 | ||
208 | #endif /* ENV_IS_EMBEDDED */ | 214 | #endif /* ENV_IS_EMBEDDED */ |
209 | 215 |
cpu/mpc83xx/fdt.c
1 | /* | 1 | /* |
2 | * Copyright 2007 Freescale Semiconductor, Inc. | 2 | * Copyright 2007 Freescale Semiconductor, Inc. |
3 | * | 3 | * |
4 | * (C) Copyright 2000 | 4 | * (C) Copyright 2000 |
5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
6 | * | 6 | * |
7 | * See file CREDITS for list of people who contributed to this | 7 | * See file CREDITS for list of people who contributed to this |
8 | * project. | 8 | * project. |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU General Public License as | 11 | * modify it under the terms of the GNU General Public License as |
12 | * published by the Free Software Foundation; either version 2 of | 12 | * published by the Free Software Foundation; either version 2 of |
13 | * the License, or (at your option) any later version. | 13 | * the License, or (at your option) any later version. |
14 | * | 14 | * |
15 | * This program is distributed in the hope that it will be useful, | 15 | * This program is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
19 | * | 19 | * |
20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
21 | * along with this program; if not, write to the Free Software | 21 | * along with this program; if not, write to the Free Software |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
23 | * MA 02111-1307 USA | 23 | * MA 02111-1307 USA |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <common.h> | 26 | #include <common.h> |
27 | #include <libfdt.h> | 27 | #include <libfdt.h> |
28 | #include <fdt_support.h> | 28 | #include <fdt_support.h> |
29 | #include <asm/processor.h> | 29 | #include <asm/processor.h> |
30 | 30 | ||
31 | extern void ft_qe_setup(void *blob); | 31 | extern void ft_qe_setup(void *blob); |
32 | 32 | ||
33 | DECLARE_GLOBAL_DATA_PTR; | 33 | DECLARE_GLOBAL_DATA_PTR; |
34 | 34 | ||
35 | void ft_cpu_setup(void *blob, bd_t *bd) | 35 | void ft_cpu_setup(void *blob, bd_t *bd) |
36 | { | 36 | { |
37 | immap_t *immr = (immap_t *)CFG_IMMR; | 37 | immap_t *immr = (immap_t *)CFG_IMMR; |
38 | int spridr = immr->sysconf.spridr; | 38 | int spridr = immr->sysconf.spridr; |
39 | 39 | ||
40 | /* | 40 | /* |
41 | * delete crypto node if not on an E-processor | 41 | * delete crypto node if not on an E-processor |
42 | * initial revisions of the MPC834xE/6xE have the original SEC 2.0. | 42 | * initial revisions of the MPC834xE/6xE have the original SEC 2.0. |
43 | * EA revisions got the SEC uprevved to 2.4 but since the default device | 43 | * EA revisions got the SEC uprevved to 2.4 but since the default device |
44 | * tree contains SEC 2.0 properties we uprev them here. | 44 | * tree contains SEC 2.0 properties we uprev them here. |
45 | */ | 45 | */ |
46 | if (!IS_E_PROCESSOR(spridr)) | 46 | if (!IS_E_PROCESSOR(spridr)) |
47 | fdt_fixup_crypto_node(blob, 0); | 47 | fdt_fixup_crypto_node(blob, 0); |
48 | else if (IS_E_PROCESSOR(spridr) && | 48 | else if (IS_E_PROCESSOR(spridr) && |
49 | (SPR_FAMILY(spridr) == SPR_834X_FAMILY || | 49 | (SPR_FAMILY(spridr) == SPR_834X_FAMILY || |
50 | SPR_FAMILY(spridr) == SPR_836X_FAMILY) && | 50 | SPR_FAMILY(spridr) == SPR_836X_FAMILY) && |
51 | REVID_MAJOR(spridr) >= 2) | 51 | REVID_MAJOR(spridr) >= 2) |
52 | fdt_fixup_crypto_node(blob, 0x0204); | 52 | fdt_fixup_crypto_node(blob, 0x0204); |
53 | 53 | ||
54 | #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\ | 54 | #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\ |
55 | defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3) | 55 | defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3) ||\ |
56 | defined(CONFIG_HAS_ETH4) || defined(CONFIG_HAS_ETH5) | ||
56 | fdt_fixup_ethernet(blob); | 57 | fdt_fixup_ethernet(blob); |
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, | 60 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, |
60 | "timebase-frequency", (bd->bi_busfreq / 4), 1); | 61 | "timebase-frequency", (bd->bi_busfreq / 4), 1); |
61 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, | 62 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, |
62 | "bus-frequency", bd->bi_busfreq, 1); | 63 | "bus-frequency", bd->bi_busfreq, 1); |
63 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, | 64 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, |
64 | "clock-frequency", gd->core_clk, 1); | 65 | "clock-frequency", gd->core_clk, 1); |
65 | do_fixup_by_prop_u32(blob, "device_type", "soc", 4, | 66 | do_fixup_by_prop_u32(blob, "device_type", "soc", 4, |
66 | "bus-frequency", bd->bi_busfreq, 1); | 67 | "bus-frequency", bd->bi_busfreq, 1); |
67 | do_fixup_by_compat_u32(blob, "fsl,soc", | 68 | do_fixup_by_compat_u32(blob, "fsl,soc", |
68 | "bus-frequency", bd->bi_busfreq, 1); | 69 | "bus-frequency", bd->bi_busfreq, 1); |
69 | do_fixup_by_compat_u32(blob, "fsl,soc", | 70 | do_fixup_by_compat_u32(blob, "fsl,soc", |
70 | "clock-frequency", bd->bi_busfreq, 1); | 71 | "clock-frequency", bd->bi_busfreq, 1); |
71 | do_fixup_by_compat_u32(blob, "fsl,immr", | 72 | do_fixup_by_compat_u32(blob, "fsl,immr", |
72 | "bus-frequency", bd->bi_busfreq, 1); | 73 | "bus-frequency", bd->bi_busfreq, 1); |
73 | do_fixup_by_compat_u32(blob, "fsl,immr", | 74 | do_fixup_by_compat_u32(blob, "fsl,immr", |
74 | "clock-frequency", bd->bi_busfreq, 1); | 75 | "clock-frequency", bd->bi_busfreq, 1); |
75 | #ifdef CONFIG_QE | 76 | #ifdef CONFIG_QE |
76 | ft_qe_setup(blob); | 77 | ft_qe_setup(blob); |
77 | #endif | 78 | #endif |
78 | 79 | ||
79 | #ifdef CFG_NS16550 | 80 | #ifdef CFG_NS16550 |
80 | do_fixup_by_compat_u32(blob, "ns16550", | 81 | do_fixup_by_compat_u32(blob, "ns16550", |
81 | "clock-frequency", CFG_NS16550_CLK, 1); | 82 | "clock-frequency", CFG_NS16550_CLK, 1); |
82 | #endif | 83 | #endif |
83 | 84 | ||
84 | fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize); | 85 | fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize); |
85 | } | 86 | } |
86 | 87 |
drivers/qe/uec.c
1 | /* | 1 | /* |
2 | * Copyright (C) 2006 Freescale Semiconductor, Inc. | 2 | * Copyright (C) 2006 Freescale Semiconductor, Inc. |
3 | * | 3 | * |
4 | * Dave Liu <daveliu@freescale.com> | 4 | * Dave Liu <daveliu@freescale.com> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License as | 7 | * modify it under the terms of the GNU General Public License as |
8 | * published by the Free Software Foundation; either version 2 of | 8 | * published by the Free Software Foundation; either version 2 of |
9 | * the License, or (at your option) any later version. | 9 | * the License, or (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
19 | * MA 02111-1307 USA | 19 | * MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "common.h" | 22 | #include "common.h" |
23 | #include "net.h" | 23 | #include "net.h" |
24 | #include "malloc.h" | 24 | #include "malloc.h" |
25 | #include "asm/errno.h" | 25 | #include "asm/errno.h" |
26 | #include "asm/io.h" | 26 | #include "asm/io.h" |
27 | #include "asm/immap_qe.h" | 27 | #include "asm/immap_qe.h" |
28 | #include "qe.h" | 28 | #include "qe.h" |
29 | #include "uccf.h" | 29 | #include "uccf.h" |
30 | #include "uec.h" | 30 | #include "uec.h" |
31 | #include "uec_phy.h" | 31 | #include "uec_phy.h" |
32 | #include "miiphy.h" | 32 | #include "miiphy.h" |
33 | 33 | ||
34 | #ifdef CONFIG_UEC_ETH1 | 34 | #ifdef CONFIG_UEC_ETH1 |
35 | static uec_info_t eth1_uec_info = { | 35 | static uec_info_t eth1_uec_info = { |
36 | .uf_info = { | 36 | .uf_info = { |
37 | .ucc_num = CFG_UEC1_UCC_NUM, | 37 | .ucc_num = CFG_UEC1_UCC_NUM, |
38 | .rx_clock = CFG_UEC1_RX_CLK, | 38 | .rx_clock = CFG_UEC1_RX_CLK, |
39 | .tx_clock = CFG_UEC1_TX_CLK, | 39 | .tx_clock = CFG_UEC1_TX_CLK, |
40 | .eth_type = CFG_UEC1_ETH_TYPE, | 40 | .eth_type = CFG_UEC1_ETH_TYPE, |
41 | }, | 41 | }, |
42 | #if (CFG_UEC1_ETH_TYPE == FAST_ETH) | 42 | #if (CFG_UEC1_ETH_TYPE == FAST_ETH) |
43 | .num_threads_tx = UEC_NUM_OF_THREADS_1, | 43 | .num_threads_tx = UEC_NUM_OF_THREADS_1, |
44 | .num_threads_rx = UEC_NUM_OF_THREADS_1, | 44 | .num_threads_rx = UEC_NUM_OF_THREADS_1, |
45 | #else | 45 | #else |
46 | .num_threads_tx = UEC_NUM_OF_THREADS_4, | 46 | .num_threads_tx = UEC_NUM_OF_THREADS_4, |
47 | .num_threads_rx = UEC_NUM_OF_THREADS_4, | 47 | .num_threads_rx = UEC_NUM_OF_THREADS_4, |
48 | #endif | 48 | #endif |
49 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | 49 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, |
50 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | 50 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, |
51 | .tx_bd_ring_len = 16, | 51 | .tx_bd_ring_len = 16, |
52 | .rx_bd_ring_len = 16, | 52 | .rx_bd_ring_len = 16, |
53 | .phy_address = CFG_UEC1_PHY_ADDR, | 53 | .phy_address = CFG_UEC1_PHY_ADDR, |
54 | .enet_interface = CFG_UEC1_INTERFACE_MODE, | 54 | .enet_interface = CFG_UEC1_INTERFACE_MODE, |
55 | }; | 55 | }; |
56 | #endif | 56 | #endif |
57 | #ifdef CONFIG_UEC_ETH2 | 57 | #ifdef CONFIG_UEC_ETH2 |
58 | static uec_info_t eth2_uec_info = { | 58 | static uec_info_t eth2_uec_info = { |
59 | .uf_info = { | 59 | .uf_info = { |
60 | .ucc_num = CFG_UEC2_UCC_NUM, | 60 | .ucc_num = CFG_UEC2_UCC_NUM, |
61 | .rx_clock = CFG_UEC2_RX_CLK, | 61 | .rx_clock = CFG_UEC2_RX_CLK, |
62 | .tx_clock = CFG_UEC2_TX_CLK, | 62 | .tx_clock = CFG_UEC2_TX_CLK, |
63 | .eth_type = CFG_UEC2_ETH_TYPE, | 63 | .eth_type = CFG_UEC2_ETH_TYPE, |
64 | }, | 64 | }, |
65 | #if (CFG_UEC2_ETH_TYPE == FAST_ETH) | 65 | #if (CFG_UEC2_ETH_TYPE == FAST_ETH) |
66 | .num_threads_tx = UEC_NUM_OF_THREADS_1, | 66 | .num_threads_tx = UEC_NUM_OF_THREADS_1, |
67 | .num_threads_rx = UEC_NUM_OF_THREADS_1, | 67 | .num_threads_rx = UEC_NUM_OF_THREADS_1, |
68 | #else | 68 | #else |
69 | .num_threads_tx = UEC_NUM_OF_THREADS_4, | 69 | .num_threads_tx = UEC_NUM_OF_THREADS_4, |
70 | .num_threads_rx = UEC_NUM_OF_THREADS_4, | 70 | .num_threads_rx = UEC_NUM_OF_THREADS_4, |
71 | #endif | 71 | #endif |
72 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | 72 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, |
73 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | 73 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, |
74 | .tx_bd_ring_len = 16, | 74 | .tx_bd_ring_len = 16, |
75 | .rx_bd_ring_len = 16, | 75 | .rx_bd_ring_len = 16, |
76 | .phy_address = CFG_UEC2_PHY_ADDR, | 76 | .phy_address = CFG_UEC2_PHY_ADDR, |
77 | .enet_interface = CFG_UEC2_INTERFACE_MODE, | 77 | .enet_interface = CFG_UEC2_INTERFACE_MODE, |
78 | }; | 78 | }; |
79 | #endif | 79 | #endif |
80 | #ifdef CONFIG_UEC_ETH3 | 80 | #ifdef CONFIG_UEC_ETH3 |
81 | static uec_info_t eth3_uec_info = { | 81 | static uec_info_t eth3_uec_info = { |
82 | .uf_info = { | 82 | .uf_info = { |
83 | .ucc_num = CFG_UEC3_UCC_NUM, | 83 | .ucc_num = CFG_UEC3_UCC_NUM, |
84 | .rx_clock = CFG_UEC3_RX_CLK, | 84 | .rx_clock = CFG_UEC3_RX_CLK, |
85 | .tx_clock = CFG_UEC3_TX_CLK, | 85 | .tx_clock = CFG_UEC3_TX_CLK, |
86 | .eth_type = CFG_UEC3_ETH_TYPE, | 86 | .eth_type = CFG_UEC3_ETH_TYPE, |
87 | }, | 87 | }, |
88 | #if (CFG_UEC3_ETH_TYPE == FAST_ETH) | 88 | #if (CFG_UEC3_ETH_TYPE == FAST_ETH) |
89 | .num_threads_tx = UEC_NUM_OF_THREADS_1, | 89 | .num_threads_tx = UEC_NUM_OF_THREADS_1, |
90 | .num_threads_rx = UEC_NUM_OF_THREADS_1, | 90 | .num_threads_rx = UEC_NUM_OF_THREADS_1, |
91 | #else | 91 | #else |
92 | .num_threads_tx = UEC_NUM_OF_THREADS_4, | 92 | .num_threads_tx = UEC_NUM_OF_THREADS_4, |
93 | .num_threads_rx = UEC_NUM_OF_THREADS_4, | 93 | .num_threads_rx = UEC_NUM_OF_THREADS_4, |
94 | #endif | 94 | #endif |
95 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | 95 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, |
96 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | 96 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, |
97 | .tx_bd_ring_len = 16, | 97 | .tx_bd_ring_len = 16, |
98 | .rx_bd_ring_len = 16, | 98 | .rx_bd_ring_len = 16, |
99 | .phy_address = CFG_UEC3_PHY_ADDR, | 99 | .phy_address = CFG_UEC3_PHY_ADDR, |
100 | .enet_interface = CFG_UEC3_INTERFACE_MODE, | 100 | .enet_interface = CFG_UEC3_INTERFACE_MODE, |
101 | }; | 101 | }; |
102 | #endif | 102 | #endif |
103 | #ifdef CONFIG_UEC_ETH4 | 103 | #ifdef CONFIG_UEC_ETH4 |
104 | static uec_info_t eth4_uec_info = { | 104 | static uec_info_t eth4_uec_info = { |
105 | .uf_info = { | 105 | .uf_info = { |
106 | .ucc_num = CFG_UEC4_UCC_NUM, | 106 | .ucc_num = CFG_UEC4_UCC_NUM, |
107 | .rx_clock = CFG_UEC4_RX_CLK, | 107 | .rx_clock = CFG_UEC4_RX_CLK, |
108 | .tx_clock = CFG_UEC4_TX_CLK, | 108 | .tx_clock = CFG_UEC4_TX_CLK, |
109 | .eth_type = CFG_UEC4_ETH_TYPE, | 109 | .eth_type = CFG_UEC4_ETH_TYPE, |
110 | }, | 110 | }, |
111 | #if (CFG_UEC4_ETH_TYPE == FAST_ETH) | 111 | #if (CFG_UEC4_ETH_TYPE == FAST_ETH) |
112 | .num_threads_tx = UEC_NUM_OF_THREADS_1, | 112 | .num_threads_tx = UEC_NUM_OF_THREADS_1, |
113 | .num_threads_rx = UEC_NUM_OF_THREADS_1, | 113 | .num_threads_rx = UEC_NUM_OF_THREADS_1, |
114 | #else | 114 | #else |
115 | .num_threads_tx = UEC_NUM_OF_THREADS_4, | 115 | .num_threads_tx = UEC_NUM_OF_THREADS_4, |
116 | .num_threads_rx = UEC_NUM_OF_THREADS_4, | 116 | .num_threads_rx = UEC_NUM_OF_THREADS_4, |
117 | #endif | 117 | #endif |
118 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | 118 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, |
119 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | 119 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, |
120 | .tx_bd_ring_len = 16, | 120 | .tx_bd_ring_len = 16, |
121 | .rx_bd_ring_len = 16, | 121 | .rx_bd_ring_len = 16, |
122 | .phy_address = CFG_UEC4_PHY_ADDR, | 122 | .phy_address = CFG_UEC4_PHY_ADDR, |
123 | .enet_interface = CFG_UEC4_INTERFACE_MODE, | 123 | .enet_interface = CFG_UEC4_INTERFACE_MODE, |
124 | }; | 124 | }; |
125 | #endif | 125 | #endif |
126 | #ifdef CONFIG_UEC_ETH5 | ||
127 | static uec_info_t eth5_uec_info = { | ||
128 | .uf_info = { | ||
129 | .ucc_num = CFG_UEC5_UCC_NUM, | ||
130 | .rx_clock = CFG_UEC5_RX_CLK, | ||
131 | .tx_clock = CFG_UEC5_TX_CLK, | ||
132 | .eth_type = CFG_UEC5_ETH_TYPE, | ||
133 | }, | ||
134 | #if (CFG_UEC5_ETH_TYPE == FAST_ETH) | ||
135 | .num_threads_tx = UEC_NUM_OF_THREADS_1, | ||
136 | .num_threads_rx = UEC_NUM_OF_THREADS_1, | ||
137 | #else | ||
138 | .num_threads_tx = UEC_NUM_OF_THREADS_4, | ||
139 | .num_threads_rx = UEC_NUM_OF_THREADS_4, | ||
140 | #endif | ||
141 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | ||
142 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | ||
143 | .tx_bd_ring_len = 16, | ||
144 | .rx_bd_ring_len = 16, | ||
145 | .phy_address = CFG_UEC5_PHY_ADDR, | ||
146 | .enet_interface = CFG_UEC5_INTERFACE_MODE, | ||
147 | }; | ||
148 | #endif | ||
149 | #ifdef CONFIG_UEC_ETH6 | ||
150 | static uec_info_t eth6_uec_info = { | ||
151 | .uf_info = { | ||
152 | .ucc_num = CFG_UEC6_UCC_NUM, | ||
153 | .rx_clock = CFG_UEC6_RX_CLK, | ||
154 | .tx_clock = CFG_UEC6_TX_CLK, | ||
155 | .eth_type = CFG_UEC6_ETH_TYPE, | ||
156 | }, | ||
157 | #if (CFG_UEC6_ETH_TYPE == FAST_ETH) | ||
158 | .num_threads_tx = UEC_NUM_OF_THREADS_1, | ||
159 | .num_threads_rx = UEC_NUM_OF_THREADS_1, | ||
160 | #else | ||
161 | .num_threads_tx = UEC_NUM_OF_THREADS_4, | ||
162 | .num_threads_rx = UEC_NUM_OF_THREADS_4, | ||
163 | #endif | ||
164 | .riscTx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | ||
165 | .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, | ||
166 | .tx_bd_ring_len = 16, | ||
167 | .rx_bd_ring_len = 16, | ||
168 | .phy_address = CFG_UEC6_PHY_ADDR, | ||
169 | .enet_interface = CFG_UEC6_INTERFACE_MODE, | ||
170 | }; | ||
171 | #endif | ||
126 | 172 | ||
127 | #define MAXCONTROLLERS (4) | 173 | #define MAXCONTROLLERS (6) |
128 | 174 | ||
129 | static struct eth_device *devlist[MAXCONTROLLERS]; | 175 | static struct eth_device *devlist[MAXCONTROLLERS]; |
130 | 176 | ||
131 | u16 phy_read (struct uec_mii_info *mii_info, u16 regnum); | 177 | u16 phy_read (struct uec_mii_info *mii_info, u16 regnum); |
132 | void phy_write (struct uec_mii_info *mii_info, u16 regnum, u16 val); | 178 | void phy_write (struct uec_mii_info *mii_info, u16 regnum, u16 val); |
133 | 179 | ||
134 | static int uec_mac_enable(uec_private_t *uec, comm_dir_e mode) | 180 | static int uec_mac_enable(uec_private_t *uec, comm_dir_e mode) |
135 | { | 181 | { |
136 | uec_t *uec_regs; | 182 | uec_t *uec_regs; |
137 | u32 maccfg1; | 183 | u32 maccfg1; |
138 | 184 | ||
139 | if (!uec) { | 185 | if (!uec) { |
140 | printf("%s: uec not initial\n", __FUNCTION__); | 186 | printf("%s: uec not initial\n", __FUNCTION__); |
141 | return -EINVAL; | 187 | return -EINVAL; |
142 | } | 188 | } |
143 | uec_regs = uec->uec_regs; | 189 | uec_regs = uec->uec_regs; |
144 | 190 | ||
145 | maccfg1 = in_be32(&uec_regs->maccfg1); | 191 | maccfg1 = in_be32(&uec_regs->maccfg1); |
146 | 192 | ||
147 | if (mode & COMM_DIR_TX) { | 193 | if (mode & COMM_DIR_TX) { |
148 | maccfg1 |= MACCFG1_ENABLE_TX; | 194 | maccfg1 |= MACCFG1_ENABLE_TX; |
149 | out_be32(&uec_regs->maccfg1, maccfg1); | 195 | out_be32(&uec_regs->maccfg1, maccfg1); |
150 | uec->mac_tx_enabled = 1; | 196 | uec->mac_tx_enabled = 1; |
151 | } | 197 | } |
152 | 198 | ||
153 | if (mode & COMM_DIR_RX) { | 199 | if (mode & COMM_DIR_RX) { |
154 | maccfg1 |= MACCFG1_ENABLE_RX; | 200 | maccfg1 |= MACCFG1_ENABLE_RX; |
155 | out_be32(&uec_regs->maccfg1, maccfg1); | 201 | out_be32(&uec_regs->maccfg1, maccfg1); |
156 | uec->mac_rx_enabled = 1; | 202 | uec->mac_rx_enabled = 1; |
157 | } | 203 | } |
158 | 204 | ||
159 | return 0; | 205 | return 0; |
160 | } | 206 | } |
161 | 207 | ||
162 | static int uec_mac_disable(uec_private_t *uec, comm_dir_e mode) | 208 | static int uec_mac_disable(uec_private_t *uec, comm_dir_e mode) |
163 | { | 209 | { |
164 | uec_t *uec_regs; | 210 | uec_t *uec_regs; |
165 | u32 maccfg1; | 211 | u32 maccfg1; |
166 | 212 | ||
167 | if (!uec) { | 213 | if (!uec) { |
168 | printf("%s: uec not initial\n", __FUNCTION__); | 214 | printf("%s: uec not initial\n", __FUNCTION__); |
169 | return -EINVAL; | 215 | return -EINVAL; |
170 | } | 216 | } |
171 | uec_regs = uec->uec_regs; | 217 | uec_regs = uec->uec_regs; |
172 | 218 | ||
173 | maccfg1 = in_be32(&uec_regs->maccfg1); | 219 | maccfg1 = in_be32(&uec_regs->maccfg1); |
174 | 220 | ||
175 | if (mode & COMM_DIR_TX) { | 221 | if (mode & COMM_DIR_TX) { |
176 | maccfg1 &= ~MACCFG1_ENABLE_TX; | 222 | maccfg1 &= ~MACCFG1_ENABLE_TX; |
177 | out_be32(&uec_regs->maccfg1, maccfg1); | 223 | out_be32(&uec_regs->maccfg1, maccfg1); |
178 | uec->mac_tx_enabled = 0; | 224 | uec->mac_tx_enabled = 0; |
179 | } | 225 | } |
180 | 226 | ||
181 | if (mode & COMM_DIR_RX) { | 227 | if (mode & COMM_DIR_RX) { |
182 | maccfg1 &= ~MACCFG1_ENABLE_RX; | 228 | maccfg1 &= ~MACCFG1_ENABLE_RX; |
183 | out_be32(&uec_regs->maccfg1, maccfg1); | 229 | out_be32(&uec_regs->maccfg1, maccfg1); |
184 | uec->mac_rx_enabled = 0; | 230 | uec->mac_rx_enabled = 0; |
185 | } | 231 | } |
186 | 232 | ||
187 | return 0; | 233 | return 0; |
188 | } | 234 | } |
189 | 235 | ||
190 | static int uec_graceful_stop_tx(uec_private_t *uec) | 236 | static int uec_graceful_stop_tx(uec_private_t *uec) |
191 | { | 237 | { |
192 | ucc_fast_t *uf_regs; | 238 | ucc_fast_t *uf_regs; |
193 | u32 cecr_subblock; | 239 | u32 cecr_subblock; |
194 | u32 ucce; | 240 | u32 ucce; |
195 | 241 | ||
196 | if (!uec || !uec->uccf) { | 242 | if (!uec || !uec->uccf) { |
197 | printf("%s: No handle passed.\n", __FUNCTION__); | 243 | printf("%s: No handle passed.\n", __FUNCTION__); |
198 | return -EINVAL; | 244 | return -EINVAL; |
199 | } | 245 | } |
200 | 246 | ||
201 | uf_regs = uec->uccf->uf_regs; | 247 | uf_regs = uec->uccf->uf_regs; |
202 | 248 | ||
203 | /* Clear the grace stop event */ | 249 | /* Clear the grace stop event */ |
204 | out_be32(&uf_regs->ucce, UCCE_GRA); | 250 | out_be32(&uf_regs->ucce, UCCE_GRA); |
205 | 251 | ||
206 | /* Issue host command */ | 252 | /* Issue host command */ |
207 | cecr_subblock = | 253 | cecr_subblock = |
208 | ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); | 254 | ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); |
209 | qe_issue_cmd(QE_GRACEFUL_STOP_TX, cecr_subblock, | 255 | qe_issue_cmd(QE_GRACEFUL_STOP_TX, cecr_subblock, |
210 | (u8)QE_CR_PROTOCOL_ETHERNET, 0); | 256 | (u8)QE_CR_PROTOCOL_ETHERNET, 0); |
211 | 257 | ||
212 | /* Wait for command to complete */ | 258 | /* Wait for command to complete */ |
213 | do { | 259 | do { |
214 | ucce = in_be32(&uf_regs->ucce); | 260 | ucce = in_be32(&uf_regs->ucce); |
215 | } while (! (ucce & UCCE_GRA)); | 261 | } while (! (ucce & UCCE_GRA)); |
216 | 262 | ||
217 | uec->grace_stopped_tx = 1; | 263 | uec->grace_stopped_tx = 1; |
218 | 264 | ||
219 | return 0; | 265 | return 0; |
220 | } | 266 | } |
221 | 267 | ||
222 | static int uec_graceful_stop_rx(uec_private_t *uec) | 268 | static int uec_graceful_stop_rx(uec_private_t *uec) |
223 | { | 269 | { |
224 | u32 cecr_subblock; | 270 | u32 cecr_subblock; |
225 | u8 ack; | 271 | u8 ack; |
226 | 272 | ||
227 | if (!uec) { | 273 | if (!uec) { |
228 | printf("%s: No handle passed.\n", __FUNCTION__); | 274 | printf("%s: No handle passed.\n", __FUNCTION__); |
229 | return -EINVAL; | 275 | return -EINVAL; |
230 | } | 276 | } |
231 | 277 | ||
232 | if (!uec->p_rx_glbl_pram) { | 278 | if (!uec->p_rx_glbl_pram) { |
233 | printf("%s: No init rx global parameter\n", __FUNCTION__); | 279 | printf("%s: No init rx global parameter\n", __FUNCTION__); |
234 | return -EINVAL; | 280 | return -EINVAL; |
235 | } | 281 | } |
236 | 282 | ||
237 | /* Clear acknowledge bit */ | 283 | /* Clear acknowledge bit */ |
238 | ack = uec->p_rx_glbl_pram->rxgstpack; | 284 | ack = uec->p_rx_glbl_pram->rxgstpack; |
239 | ack &= ~GRACEFUL_STOP_ACKNOWLEDGE_RX; | 285 | ack &= ~GRACEFUL_STOP_ACKNOWLEDGE_RX; |
240 | uec->p_rx_glbl_pram->rxgstpack = ack; | 286 | uec->p_rx_glbl_pram->rxgstpack = ack; |
241 | 287 | ||
242 | /* Keep issuing cmd and checking ack bit until it is asserted */ | 288 | /* Keep issuing cmd and checking ack bit until it is asserted */ |
243 | do { | 289 | do { |
244 | /* Issue host command */ | 290 | /* Issue host command */ |
245 | cecr_subblock = | 291 | cecr_subblock = |
246 | ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); | 292 | ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); |
247 | qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock, | 293 | qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock, |
248 | (u8)QE_CR_PROTOCOL_ETHERNET, 0); | 294 | (u8)QE_CR_PROTOCOL_ETHERNET, 0); |
249 | ack = uec->p_rx_glbl_pram->rxgstpack; | 295 | ack = uec->p_rx_glbl_pram->rxgstpack; |
250 | } while (! (ack & GRACEFUL_STOP_ACKNOWLEDGE_RX )); | 296 | } while (! (ack & GRACEFUL_STOP_ACKNOWLEDGE_RX )); |
251 | 297 | ||
252 | uec->grace_stopped_rx = 1; | 298 | uec->grace_stopped_rx = 1; |
253 | 299 | ||
254 | return 0; | 300 | return 0; |
255 | } | 301 | } |
256 | 302 | ||
257 | static int uec_restart_tx(uec_private_t *uec) | 303 | static int uec_restart_tx(uec_private_t *uec) |
258 | { | 304 | { |
259 | u32 cecr_subblock; | 305 | u32 cecr_subblock; |
260 | 306 | ||
261 | if (!uec || !uec->uec_info) { | 307 | if (!uec || !uec->uec_info) { |
262 | printf("%s: No handle passed.\n", __FUNCTION__); | 308 | printf("%s: No handle passed.\n", __FUNCTION__); |
263 | return -EINVAL; | 309 | return -EINVAL; |
264 | } | 310 | } |
265 | 311 | ||
266 | cecr_subblock = | 312 | cecr_subblock = |
267 | ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); | 313 | ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); |
268 | qe_issue_cmd(QE_RESTART_TX, cecr_subblock, | 314 | qe_issue_cmd(QE_RESTART_TX, cecr_subblock, |
269 | (u8)QE_CR_PROTOCOL_ETHERNET, 0); | 315 | (u8)QE_CR_PROTOCOL_ETHERNET, 0); |
270 | 316 | ||
271 | uec->grace_stopped_tx = 0; | 317 | uec->grace_stopped_tx = 0; |
272 | 318 | ||
273 | return 0; | 319 | return 0; |
274 | } | 320 | } |
275 | 321 | ||
276 | static int uec_restart_rx(uec_private_t *uec) | 322 | static int uec_restart_rx(uec_private_t *uec) |
277 | { | 323 | { |
278 | u32 cecr_subblock; | 324 | u32 cecr_subblock; |
279 | 325 | ||
280 | if (!uec || !uec->uec_info) { | 326 | if (!uec || !uec->uec_info) { |
281 | printf("%s: No handle passed.\n", __FUNCTION__); | 327 | printf("%s: No handle passed.\n", __FUNCTION__); |
282 | return -EINVAL; | 328 | return -EINVAL; |
283 | } | 329 | } |
284 | 330 | ||
285 | cecr_subblock = | 331 | cecr_subblock = |
286 | ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); | 332 | ucc_fast_get_qe_cr_subblock(uec->uec_info->uf_info.ucc_num); |
287 | qe_issue_cmd(QE_RESTART_RX, cecr_subblock, | 333 | qe_issue_cmd(QE_RESTART_RX, cecr_subblock, |
288 | (u8)QE_CR_PROTOCOL_ETHERNET, 0); | 334 | (u8)QE_CR_PROTOCOL_ETHERNET, 0); |
289 | 335 | ||
290 | uec->grace_stopped_rx = 0; | 336 | uec->grace_stopped_rx = 0; |
291 | 337 | ||
292 | return 0; | 338 | return 0; |
293 | } | 339 | } |
294 | 340 | ||
295 | static int uec_open(uec_private_t *uec, comm_dir_e mode) | 341 | static int uec_open(uec_private_t *uec, comm_dir_e mode) |
296 | { | 342 | { |
297 | ucc_fast_private_t *uccf; | 343 | ucc_fast_private_t *uccf; |
298 | 344 | ||
299 | if (!uec || !uec->uccf) { | 345 | if (!uec || !uec->uccf) { |
300 | printf("%s: No handle passed.\n", __FUNCTION__); | 346 | printf("%s: No handle passed.\n", __FUNCTION__); |
301 | return -EINVAL; | 347 | return -EINVAL; |
302 | } | 348 | } |
303 | uccf = uec->uccf; | 349 | uccf = uec->uccf; |
304 | 350 | ||
305 | /* check if the UCC number is in range. */ | 351 | /* check if the UCC number is in range. */ |
306 | if (uec->uec_info->uf_info.ucc_num >= UCC_MAX_NUM) { | 352 | if (uec->uec_info->uf_info.ucc_num >= UCC_MAX_NUM) { |
307 | printf("%s: ucc_num out of range.\n", __FUNCTION__); | 353 | printf("%s: ucc_num out of range.\n", __FUNCTION__); |
308 | return -EINVAL; | 354 | return -EINVAL; |
309 | } | 355 | } |
310 | 356 | ||
311 | /* Enable MAC */ | 357 | /* Enable MAC */ |
312 | uec_mac_enable(uec, mode); | 358 | uec_mac_enable(uec, mode); |
313 | 359 | ||
314 | /* Enable UCC fast */ | 360 | /* Enable UCC fast */ |
315 | ucc_fast_enable(uccf, mode); | 361 | ucc_fast_enable(uccf, mode); |
316 | 362 | ||
317 | /* RISC microcode start */ | 363 | /* RISC microcode start */ |
318 | if ((mode & COMM_DIR_TX) && uec->grace_stopped_tx) { | 364 | if ((mode & COMM_DIR_TX) && uec->grace_stopped_tx) { |
319 | uec_restart_tx(uec); | 365 | uec_restart_tx(uec); |
320 | } | 366 | } |
321 | if ((mode & COMM_DIR_RX) && uec->grace_stopped_rx) { | 367 | if ((mode & COMM_DIR_RX) && uec->grace_stopped_rx) { |
322 | uec_restart_rx(uec); | 368 | uec_restart_rx(uec); |
323 | } | 369 | } |
324 | 370 | ||
325 | return 0; | 371 | return 0; |
326 | } | 372 | } |
327 | 373 | ||
328 | static int uec_stop(uec_private_t *uec, comm_dir_e mode) | 374 | static int uec_stop(uec_private_t *uec, comm_dir_e mode) |
329 | { | 375 | { |
330 | ucc_fast_private_t *uccf; | 376 | ucc_fast_private_t *uccf; |
331 | 377 | ||
332 | if (!uec || !uec->uccf) { | 378 | if (!uec || !uec->uccf) { |
333 | printf("%s: No handle passed.\n", __FUNCTION__); | 379 | printf("%s: No handle passed.\n", __FUNCTION__); |
334 | return -EINVAL; | 380 | return -EINVAL; |
335 | } | 381 | } |
336 | uccf = uec->uccf; | 382 | uccf = uec->uccf; |
337 | 383 | ||
338 | /* check if the UCC number is in range. */ | 384 | /* check if the UCC number is in range. */ |
339 | if (uec->uec_info->uf_info.ucc_num >= UCC_MAX_NUM) { | 385 | if (uec->uec_info->uf_info.ucc_num >= UCC_MAX_NUM) { |
340 | printf("%s: ucc_num out of range.\n", __FUNCTION__); | 386 | printf("%s: ucc_num out of range.\n", __FUNCTION__); |
341 | return -EINVAL; | 387 | return -EINVAL; |
342 | } | 388 | } |
343 | /* Stop any transmissions */ | 389 | /* Stop any transmissions */ |
344 | if ((mode & COMM_DIR_TX) && !uec->grace_stopped_tx) { | 390 | if ((mode & COMM_DIR_TX) && !uec->grace_stopped_tx) { |
345 | uec_graceful_stop_tx(uec); | 391 | uec_graceful_stop_tx(uec); |
346 | } | 392 | } |
347 | /* Stop any receptions */ | 393 | /* Stop any receptions */ |
348 | if ((mode & COMM_DIR_RX) && !uec->grace_stopped_rx) { | 394 | if ((mode & COMM_DIR_RX) && !uec->grace_stopped_rx) { |
349 | uec_graceful_stop_rx(uec); | 395 | uec_graceful_stop_rx(uec); |
350 | } | 396 | } |
351 | 397 | ||
352 | /* Disable the UCC fast */ | 398 | /* Disable the UCC fast */ |
353 | ucc_fast_disable(uec->uccf, mode); | 399 | ucc_fast_disable(uec->uccf, mode); |
354 | 400 | ||
355 | /* Disable the MAC */ | 401 | /* Disable the MAC */ |
356 | uec_mac_disable(uec, mode); | 402 | uec_mac_disable(uec, mode); |
357 | 403 | ||
358 | return 0; | 404 | return 0; |
359 | } | 405 | } |
360 | 406 | ||
361 | static int uec_set_mac_duplex(uec_private_t *uec, int duplex) | 407 | static int uec_set_mac_duplex(uec_private_t *uec, int duplex) |
362 | { | 408 | { |
363 | uec_t *uec_regs; | 409 | uec_t *uec_regs; |
364 | u32 maccfg2; | 410 | u32 maccfg2; |
365 | 411 | ||
366 | if (!uec) { | 412 | if (!uec) { |
367 | printf("%s: uec not initial\n", __FUNCTION__); | 413 | printf("%s: uec not initial\n", __FUNCTION__); |
368 | return -EINVAL; | 414 | return -EINVAL; |
369 | } | 415 | } |
370 | uec_regs = uec->uec_regs; | 416 | uec_regs = uec->uec_regs; |
371 | 417 | ||
372 | if (duplex == DUPLEX_HALF) { | 418 | if (duplex == DUPLEX_HALF) { |
373 | maccfg2 = in_be32(&uec_regs->maccfg2); | 419 | maccfg2 = in_be32(&uec_regs->maccfg2); |
374 | maccfg2 &= ~MACCFG2_FDX; | 420 | maccfg2 &= ~MACCFG2_FDX; |
375 | out_be32(&uec_regs->maccfg2, maccfg2); | 421 | out_be32(&uec_regs->maccfg2, maccfg2); |
376 | } | 422 | } |
377 | 423 | ||
378 | if (duplex == DUPLEX_FULL) { | 424 | if (duplex == DUPLEX_FULL) { |
379 | maccfg2 = in_be32(&uec_regs->maccfg2); | 425 | maccfg2 = in_be32(&uec_regs->maccfg2); |
380 | maccfg2 |= MACCFG2_FDX; | 426 | maccfg2 |= MACCFG2_FDX; |
381 | out_be32(&uec_regs->maccfg2, maccfg2); | 427 | out_be32(&uec_regs->maccfg2, maccfg2); |
382 | } | 428 | } |
383 | 429 | ||
384 | return 0; | 430 | return 0; |
385 | } | 431 | } |
386 | 432 | ||
387 | static int uec_set_mac_if_mode(uec_private_t *uec, enet_interface_e if_mode) | 433 | static int uec_set_mac_if_mode(uec_private_t *uec, enet_interface_e if_mode) |
388 | { | 434 | { |
389 | enet_interface_e enet_if_mode; | 435 | enet_interface_e enet_if_mode; |
390 | uec_info_t *uec_info; | 436 | uec_info_t *uec_info; |
391 | uec_t *uec_regs; | 437 | uec_t *uec_regs; |
392 | u32 upsmr; | 438 | u32 upsmr; |
393 | u32 maccfg2; | 439 | u32 maccfg2; |
394 | 440 | ||
395 | if (!uec) { | 441 | if (!uec) { |
396 | printf("%s: uec not initial\n", __FUNCTION__); | 442 | printf("%s: uec not initial\n", __FUNCTION__); |
397 | return -EINVAL; | 443 | return -EINVAL; |
398 | } | 444 | } |
399 | 445 | ||
400 | uec_info = uec->uec_info; | 446 | uec_info = uec->uec_info; |
401 | uec_regs = uec->uec_regs; | 447 | uec_regs = uec->uec_regs; |
402 | enet_if_mode = if_mode; | 448 | enet_if_mode = if_mode; |
403 | 449 | ||
404 | maccfg2 = in_be32(&uec_regs->maccfg2); | 450 | maccfg2 = in_be32(&uec_regs->maccfg2); |
405 | maccfg2 &= ~MACCFG2_INTERFACE_MODE_MASK; | 451 | maccfg2 &= ~MACCFG2_INTERFACE_MODE_MASK; |
406 | 452 | ||
407 | upsmr = in_be32(&uec->uccf->uf_regs->upsmr); | 453 | upsmr = in_be32(&uec->uccf->uf_regs->upsmr); |
408 | upsmr &= ~(UPSMR_RPM | UPSMR_TBIM | UPSMR_R10M | UPSMR_RMM); | 454 | upsmr &= ~(UPSMR_RPM | UPSMR_TBIM | UPSMR_R10M | UPSMR_RMM); |
409 | 455 | ||
410 | switch (enet_if_mode) { | 456 | switch (enet_if_mode) { |
411 | case ENET_100_MII: | 457 | case ENET_100_MII: |
412 | case ENET_10_MII: | 458 | case ENET_10_MII: |
413 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; | 459 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; |
414 | break; | 460 | break; |
415 | case ENET_1000_GMII: | 461 | case ENET_1000_GMII: |
416 | maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE; | 462 | maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE; |
417 | break; | 463 | break; |
418 | case ENET_1000_TBI: | 464 | case ENET_1000_TBI: |
419 | maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE; | 465 | maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE; |
420 | upsmr |= UPSMR_TBIM; | 466 | upsmr |= UPSMR_TBIM; |
421 | break; | 467 | break; |
422 | case ENET_1000_RTBI: | 468 | case ENET_1000_RTBI: |
423 | maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE; | 469 | maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE; |
424 | upsmr |= (UPSMR_RPM | UPSMR_TBIM); | 470 | upsmr |= (UPSMR_RPM | UPSMR_TBIM); |
425 | break; | 471 | break; |
426 | case ENET_1000_RGMII_RXID: | 472 | case ENET_1000_RGMII_RXID: |
427 | case ENET_1000_RGMII_ID: | 473 | case ENET_1000_RGMII_ID: |
428 | case ENET_1000_RGMII: | 474 | case ENET_1000_RGMII: |
429 | maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE; | 475 | maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE; |
430 | upsmr |= UPSMR_RPM; | 476 | upsmr |= UPSMR_RPM; |
431 | break; | 477 | break; |
432 | case ENET_100_RGMII: | 478 | case ENET_100_RGMII: |
433 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; | 479 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; |
434 | upsmr |= UPSMR_RPM; | 480 | upsmr |= UPSMR_RPM; |
435 | break; | 481 | break; |
436 | case ENET_10_RGMII: | 482 | case ENET_10_RGMII: |
437 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; | 483 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; |
438 | upsmr |= (UPSMR_RPM | UPSMR_R10M); | 484 | upsmr |= (UPSMR_RPM | UPSMR_R10M); |
439 | break; | 485 | break; |
440 | case ENET_100_RMII: | 486 | case ENET_100_RMII: |
441 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; | 487 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; |
442 | upsmr |= UPSMR_RMM; | 488 | upsmr |= UPSMR_RMM; |
443 | break; | 489 | break; |
444 | case ENET_10_RMII: | 490 | case ENET_10_RMII: |
445 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; | 491 | maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE; |
446 | upsmr |= (UPSMR_R10M | UPSMR_RMM); | 492 | upsmr |= (UPSMR_R10M | UPSMR_RMM); |
447 | break; | 493 | break; |
448 | default: | 494 | default: |
449 | return -EINVAL; | 495 | return -EINVAL; |
450 | break; | 496 | break; |
451 | } | 497 | } |
452 | out_be32(&uec_regs->maccfg2, maccfg2); | 498 | out_be32(&uec_regs->maccfg2, maccfg2); |
453 | out_be32(&uec->uccf->uf_regs->upsmr, upsmr); | 499 | out_be32(&uec->uccf->uf_regs->upsmr, upsmr); |
454 | 500 | ||
455 | return 0; | 501 | return 0; |
456 | } | 502 | } |
457 | 503 | ||
458 | static int init_mii_management_configuration(uec_mii_t *uec_mii_regs) | 504 | static int init_mii_management_configuration(uec_mii_t *uec_mii_regs) |
459 | { | 505 | { |
460 | uint timeout = 0x1000; | 506 | uint timeout = 0x1000; |
461 | u32 miimcfg = 0; | 507 | u32 miimcfg = 0; |
462 | 508 | ||
463 | miimcfg = in_be32(&uec_mii_regs->miimcfg); | 509 | miimcfg = in_be32(&uec_mii_regs->miimcfg); |
464 | miimcfg |= MIIMCFG_MNGMNT_CLC_DIV_INIT_VALUE; | 510 | miimcfg |= MIIMCFG_MNGMNT_CLC_DIV_INIT_VALUE; |
465 | out_be32(&uec_mii_regs->miimcfg, miimcfg); | 511 | out_be32(&uec_mii_regs->miimcfg, miimcfg); |
466 | 512 | ||
467 | /* Wait until the bus is free */ | 513 | /* Wait until the bus is free */ |
468 | while ((in_be32(&uec_mii_regs->miimcfg) & MIIMIND_BUSY) && timeout--); | 514 | while ((in_be32(&uec_mii_regs->miimcfg) & MIIMIND_BUSY) && timeout--); |
469 | if (timeout <= 0) { | 515 | if (timeout <= 0) { |
470 | printf("%s: The MII Bus is stuck!", __FUNCTION__); | 516 | printf("%s: The MII Bus is stuck!", __FUNCTION__); |
471 | return -ETIMEDOUT; | 517 | return -ETIMEDOUT; |
472 | } | 518 | } |
473 | 519 | ||
474 | return 0; | 520 | return 0; |
475 | } | 521 | } |
476 | 522 | ||
477 | static int init_phy(struct eth_device *dev) | 523 | static int init_phy(struct eth_device *dev) |
478 | { | 524 | { |
479 | uec_private_t *uec; | 525 | uec_private_t *uec; |
480 | uec_mii_t *umii_regs; | 526 | uec_mii_t *umii_regs; |
481 | struct uec_mii_info *mii_info; | 527 | struct uec_mii_info *mii_info; |
482 | struct phy_info *curphy; | 528 | struct phy_info *curphy; |
483 | int err; | 529 | int err; |
484 | 530 | ||
485 | uec = (uec_private_t *)dev->priv; | 531 | uec = (uec_private_t *)dev->priv; |
486 | umii_regs = uec->uec_mii_regs; | 532 | umii_regs = uec->uec_mii_regs; |
487 | 533 | ||
488 | uec->oldlink = 0; | 534 | uec->oldlink = 0; |
489 | uec->oldspeed = 0; | 535 | uec->oldspeed = 0; |
490 | uec->oldduplex = -1; | 536 | uec->oldduplex = -1; |
491 | 537 | ||
492 | mii_info = malloc(sizeof(*mii_info)); | 538 | mii_info = malloc(sizeof(*mii_info)); |
493 | if (!mii_info) { | 539 | if (!mii_info) { |
494 | printf("%s: Could not allocate mii_info", dev->name); | 540 | printf("%s: Could not allocate mii_info", dev->name); |
495 | return -ENOMEM; | 541 | return -ENOMEM; |
496 | } | 542 | } |
497 | memset(mii_info, 0, sizeof(*mii_info)); | 543 | memset(mii_info, 0, sizeof(*mii_info)); |
498 | 544 | ||
499 | if (uec->uec_info->uf_info.eth_type == GIGA_ETH) { | 545 | if (uec->uec_info->uf_info.eth_type == GIGA_ETH) { |
500 | mii_info->speed = SPEED_1000; | 546 | mii_info->speed = SPEED_1000; |
501 | } else { | 547 | } else { |
502 | mii_info->speed = SPEED_100; | 548 | mii_info->speed = SPEED_100; |
503 | } | 549 | } |
504 | 550 | ||
505 | mii_info->duplex = DUPLEX_FULL; | 551 | mii_info->duplex = DUPLEX_FULL; |
506 | mii_info->pause = 0; | 552 | mii_info->pause = 0; |
507 | mii_info->link = 1; | 553 | mii_info->link = 1; |
508 | 554 | ||
509 | mii_info->advertising = (ADVERTISED_10baseT_Half | | 555 | mii_info->advertising = (ADVERTISED_10baseT_Half | |
510 | ADVERTISED_10baseT_Full | | 556 | ADVERTISED_10baseT_Full | |
511 | ADVERTISED_100baseT_Half | | 557 | ADVERTISED_100baseT_Half | |
512 | ADVERTISED_100baseT_Full | | 558 | ADVERTISED_100baseT_Full | |
513 | ADVERTISED_1000baseT_Full); | 559 | ADVERTISED_1000baseT_Full); |
514 | mii_info->autoneg = 1; | 560 | mii_info->autoneg = 1; |
515 | mii_info->mii_id = uec->uec_info->phy_address; | 561 | mii_info->mii_id = uec->uec_info->phy_address; |
516 | mii_info->dev = dev; | 562 | mii_info->dev = dev; |
517 | 563 | ||
518 | mii_info->mdio_read = &uec_read_phy_reg; | 564 | mii_info->mdio_read = &uec_read_phy_reg; |
519 | mii_info->mdio_write = &uec_write_phy_reg; | 565 | mii_info->mdio_write = &uec_write_phy_reg; |
520 | 566 | ||
521 | uec->mii_info = mii_info; | 567 | uec->mii_info = mii_info; |
522 | 568 | ||
523 | qe_set_mii_clk_src(uec->uec_info->uf_info.ucc_num); | 569 | qe_set_mii_clk_src(uec->uec_info->uf_info.ucc_num); |
524 | 570 | ||
525 | if (init_mii_management_configuration(umii_regs)) { | 571 | if (init_mii_management_configuration(umii_regs)) { |
526 | printf("%s: The MII Bus is stuck!", dev->name); | 572 | printf("%s: The MII Bus is stuck!", dev->name); |
527 | err = -1; | 573 | err = -1; |
528 | goto bus_fail; | 574 | goto bus_fail; |
529 | } | 575 | } |
530 | 576 | ||
531 | /* get info for this PHY */ | 577 | /* get info for this PHY */ |
532 | curphy = uec_get_phy_info(uec->mii_info); | 578 | curphy = uec_get_phy_info(uec->mii_info); |
533 | if (!curphy) { | 579 | if (!curphy) { |
534 | printf("%s: No PHY found", dev->name); | 580 | printf("%s: No PHY found", dev->name); |
535 | err = -1; | 581 | err = -1; |
536 | goto no_phy; | 582 | goto no_phy; |
537 | } | 583 | } |
538 | 584 | ||
539 | mii_info->phyinfo = curphy; | 585 | mii_info->phyinfo = curphy; |
540 | 586 | ||
541 | /* Run the commands which initialize the PHY */ | 587 | /* Run the commands which initialize the PHY */ |
542 | if (curphy->init) { | 588 | if (curphy->init) { |
543 | err = curphy->init(uec->mii_info); | 589 | err = curphy->init(uec->mii_info); |
544 | if (err) | 590 | if (err) |
545 | goto phy_init_fail; | 591 | goto phy_init_fail; |
546 | } | 592 | } |
547 | 593 | ||
548 | return 0; | 594 | return 0; |
549 | 595 | ||
550 | phy_init_fail: | 596 | phy_init_fail: |
551 | no_phy: | 597 | no_phy: |
552 | bus_fail: | 598 | bus_fail: |
553 | free(mii_info); | 599 | free(mii_info); |
554 | return err; | 600 | return err; |
555 | } | 601 | } |
556 | 602 | ||
557 | static void adjust_link(struct eth_device *dev) | 603 | static void adjust_link(struct eth_device *dev) |
558 | { | 604 | { |
559 | uec_private_t *uec = (uec_private_t *)dev->priv; | 605 | uec_private_t *uec = (uec_private_t *)dev->priv; |
560 | uec_t *uec_regs; | 606 | uec_t *uec_regs; |
561 | struct uec_mii_info *mii_info = uec->mii_info; | 607 | struct uec_mii_info *mii_info = uec->mii_info; |
562 | 608 | ||
563 | extern void change_phy_interface_mode(struct eth_device *dev, | 609 | extern void change_phy_interface_mode(struct eth_device *dev, |
564 | enet_interface_e mode); | 610 | enet_interface_e mode); |
565 | uec_regs = uec->uec_regs; | 611 | uec_regs = uec->uec_regs; |
566 | 612 | ||
567 | if (mii_info->link) { | 613 | if (mii_info->link) { |
568 | /* Now we make sure that we can be in full duplex mode. | 614 | /* Now we make sure that we can be in full duplex mode. |
569 | * If not, we operate in half-duplex mode. */ | 615 | * If not, we operate in half-duplex mode. */ |
570 | if (mii_info->duplex != uec->oldduplex) { | 616 | if (mii_info->duplex != uec->oldduplex) { |
571 | if (!(mii_info->duplex)) { | 617 | if (!(mii_info->duplex)) { |
572 | uec_set_mac_duplex(uec, DUPLEX_HALF); | 618 | uec_set_mac_duplex(uec, DUPLEX_HALF); |
573 | printf("%s: Half Duplex\n", dev->name); | 619 | printf("%s: Half Duplex\n", dev->name); |
574 | } else { | 620 | } else { |
575 | uec_set_mac_duplex(uec, DUPLEX_FULL); | 621 | uec_set_mac_duplex(uec, DUPLEX_FULL); |
576 | printf("%s: Full Duplex\n", dev->name); | 622 | printf("%s: Full Duplex\n", dev->name); |
577 | } | 623 | } |
578 | uec->oldduplex = mii_info->duplex; | 624 | uec->oldduplex = mii_info->duplex; |
579 | } | 625 | } |
580 | 626 | ||
581 | if (mii_info->speed != uec->oldspeed) { | 627 | if (mii_info->speed != uec->oldspeed) { |
582 | if (uec->uec_info->uf_info.eth_type == GIGA_ETH) { | 628 | if (uec->uec_info->uf_info.eth_type == GIGA_ETH) { |
583 | switch (mii_info->speed) { | 629 | switch (mii_info->speed) { |
584 | case 1000: | 630 | case 1000: |
585 | break; | 631 | break; |
586 | case 100: | 632 | case 100: |
587 | printf ("switching to rgmii 100\n"); | 633 | printf ("switching to rgmii 100\n"); |
588 | /* change phy to rgmii 100 */ | 634 | /* change phy to rgmii 100 */ |
589 | change_phy_interface_mode(dev, | 635 | change_phy_interface_mode(dev, |
590 | ENET_100_RGMII); | 636 | ENET_100_RGMII); |
591 | /* change the MAC interface mode */ | 637 | /* change the MAC interface mode */ |
592 | uec_set_mac_if_mode(uec,ENET_100_RGMII); | 638 | uec_set_mac_if_mode(uec,ENET_100_RGMII); |
593 | break; | 639 | break; |
594 | case 10: | 640 | case 10: |
595 | printf ("switching to rgmii 10\n"); | 641 | printf ("switching to rgmii 10\n"); |
596 | /* change phy to rgmii 10 */ | 642 | /* change phy to rgmii 10 */ |
597 | change_phy_interface_mode(dev, | 643 | change_phy_interface_mode(dev, |
598 | ENET_10_RGMII); | 644 | ENET_10_RGMII); |
599 | /* change the MAC interface mode */ | 645 | /* change the MAC interface mode */ |
600 | uec_set_mac_if_mode(uec,ENET_10_RGMII); | 646 | uec_set_mac_if_mode(uec,ENET_10_RGMII); |
601 | break; | 647 | break; |
602 | default: | 648 | default: |
603 | printf("%s: Ack,Speed(%d)is illegal\n", | 649 | printf("%s: Ack,Speed(%d)is illegal\n", |
604 | dev->name, mii_info->speed); | 650 | dev->name, mii_info->speed); |
605 | break; | 651 | break; |
606 | } | 652 | } |
607 | } | 653 | } |
608 | 654 | ||
609 | printf("%s: Speed %dBT\n", dev->name, mii_info->speed); | 655 | printf("%s: Speed %dBT\n", dev->name, mii_info->speed); |
610 | uec->oldspeed = mii_info->speed; | 656 | uec->oldspeed = mii_info->speed; |
611 | } | 657 | } |
612 | 658 | ||
613 | if (!uec->oldlink) { | 659 | if (!uec->oldlink) { |
614 | printf("%s: Link is up\n", dev->name); | 660 | printf("%s: Link is up\n", dev->name); |
615 | uec->oldlink = 1; | 661 | uec->oldlink = 1; |
616 | } | 662 | } |
617 | 663 | ||
618 | } else { /* if (mii_info->link) */ | 664 | } else { /* if (mii_info->link) */ |
619 | if (uec->oldlink) { | 665 | if (uec->oldlink) { |
620 | printf("%s: Link is down\n", dev->name); | 666 | printf("%s: Link is down\n", dev->name); |
621 | uec->oldlink = 0; | 667 | uec->oldlink = 0; |
622 | uec->oldspeed = 0; | 668 | uec->oldspeed = 0; |
623 | uec->oldduplex = -1; | 669 | uec->oldduplex = -1; |
624 | } | 670 | } |
625 | } | 671 | } |
626 | } | 672 | } |
627 | 673 | ||
628 | static void phy_change(struct eth_device *dev) | 674 | static void phy_change(struct eth_device *dev) |
629 | { | 675 | { |
630 | uec_private_t *uec = (uec_private_t *)dev->priv; | 676 | uec_private_t *uec = (uec_private_t *)dev->priv; |
631 | 677 | ||
632 | /* Update the link, speed, duplex */ | 678 | /* Update the link, speed, duplex */ |
633 | uec->mii_info->phyinfo->read_status(uec->mii_info); | 679 | uec->mii_info->phyinfo->read_status(uec->mii_info); |
634 | 680 | ||
635 | /* Adjust the interface according to speed */ | 681 | /* Adjust the interface according to speed */ |
636 | adjust_link(dev); | 682 | adjust_link(dev); |
637 | } | 683 | } |
638 | 684 | ||
639 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \ | 685 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \ |
640 | && !defined(BITBANGMII) | 686 | && !defined(BITBANGMII) |
641 | 687 | ||
642 | /* | 688 | /* |
643 | * Read a MII PHY register. | 689 | * Read a MII PHY register. |
644 | * | 690 | * |
645 | * Returns: | 691 | * Returns: |
646 | * 0 on success | 692 | * 0 on success |
647 | */ | 693 | */ |
648 | static int uec_miiphy_read(char *devname, unsigned char addr, | 694 | static int uec_miiphy_read(char *devname, unsigned char addr, |
649 | unsigned char reg, unsigned short *value) | 695 | unsigned char reg, unsigned short *value) |
650 | { | 696 | { |
651 | *value = uec_read_phy_reg(devlist[0], addr, reg); | 697 | *value = uec_read_phy_reg(devlist[0], addr, reg); |
652 | 698 | ||
653 | return 0; | 699 | return 0; |
654 | } | 700 | } |
655 | 701 | ||
656 | /* | 702 | /* |
657 | * Write a MII PHY register. | 703 | * Write a MII PHY register. |
658 | * | 704 | * |
659 | * Returns: | 705 | * Returns: |
660 | * 0 on success | 706 | * 0 on success |
661 | */ | 707 | */ |
662 | static int uec_miiphy_write(char *devname, unsigned char addr, | 708 | static int uec_miiphy_write(char *devname, unsigned char addr, |
663 | unsigned char reg, unsigned short value) | 709 | unsigned char reg, unsigned short value) |
664 | { | 710 | { |
665 | uec_write_phy_reg(devlist[0], addr, reg, value); | 711 | uec_write_phy_reg(devlist[0], addr, reg, value); |
666 | 712 | ||
667 | return 0; | 713 | return 0; |
668 | } | 714 | } |
669 | 715 | ||
670 | #endif | 716 | #endif |
671 | 717 | ||
672 | static int uec_set_mac_address(uec_private_t *uec, u8 *mac_addr) | 718 | static int uec_set_mac_address(uec_private_t *uec, u8 *mac_addr) |
673 | { | 719 | { |
674 | uec_t *uec_regs; | 720 | uec_t *uec_regs; |
675 | u32 mac_addr1; | 721 | u32 mac_addr1; |
676 | u32 mac_addr2; | 722 | u32 mac_addr2; |
677 | 723 | ||
678 | if (!uec) { | 724 | if (!uec) { |
679 | printf("%s: uec not initial\n", __FUNCTION__); | 725 | printf("%s: uec not initial\n", __FUNCTION__); |
680 | return -EINVAL; | 726 | return -EINVAL; |
681 | } | 727 | } |
682 | 728 | ||
683 | uec_regs = uec->uec_regs; | 729 | uec_regs = uec->uec_regs; |
684 | 730 | ||
685 | /* if a station address of 0x12345678ABCD, perform a write to | 731 | /* if a station address of 0x12345678ABCD, perform a write to |
686 | MACSTNADDR1 of 0xCDAB7856, | 732 | MACSTNADDR1 of 0xCDAB7856, |
687 | MACSTNADDR2 of 0x34120000 */ | 733 | MACSTNADDR2 of 0x34120000 */ |
688 | 734 | ||
689 | mac_addr1 = (mac_addr[5] << 24) | (mac_addr[4] << 16) | \ | 735 | mac_addr1 = (mac_addr[5] << 24) | (mac_addr[4] << 16) | \ |
690 | (mac_addr[3] << 8) | (mac_addr[2]); | 736 | (mac_addr[3] << 8) | (mac_addr[2]); |
691 | out_be32(&uec_regs->macstnaddr1, mac_addr1); | 737 | out_be32(&uec_regs->macstnaddr1, mac_addr1); |
692 | 738 | ||
693 | mac_addr2 = ((mac_addr[1] << 24) | (mac_addr[0] << 16)) & 0xffff0000; | 739 | mac_addr2 = ((mac_addr[1] << 24) | (mac_addr[0] << 16)) & 0xffff0000; |
694 | out_be32(&uec_regs->macstnaddr2, mac_addr2); | 740 | out_be32(&uec_regs->macstnaddr2, mac_addr2); |
695 | 741 | ||
696 | return 0; | 742 | return 0; |
697 | } | 743 | } |
698 | 744 | ||
699 | static int uec_convert_threads_num(uec_num_of_threads_e threads_num, | 745 | static int uec_convert_threads_num(uec_num_of_threads_e threads_num, |
700 | int *threads_num_ret) | 746 | int *threads_num_ret) |
701 | { | 747 | { |
702 | int num_threads_numerica; | 748 | int num_threads_numerica; |
703 | 749 | ||
704 | switch (threads_num) { | 750 | switch (threads_num) { |
705 | case UEC_NUM_OF_THREADS_1: | 751 | case UEC_NUM_OF_THREADS_1: |
706 | num_threads_numerica = 1; | 752 | num_threads_numerica = 1; |
707 | break; | 753 | break; |
708 | case UEC_NUM_OF_THREADS_2: | 754 | case UEC_NUM_OF_THREADS_2: |
709 | num_threads_numerica = 2; | 755 | num_threads_numerica = 2; |
710 | break; | 756 | break; |
711 | case UEC_NUM_OF_THREADS_4: | 757 | case UEC_NUM_OF_THREADS_4: |
712 | num_threads_numerica = 4; | 758 | num_threads_numerica = 4; |
713 | break; | 759 | break; |
714 | case UEC_NUM_OF_THREADS_6: | 760 | case UEC_NUM_OF_THREADS_6: |
715 | num_threads_numerica = 6; | 761 | num_threads_numerica = 6; |
716 | break; | 762 | break; |
717 | case UEC_NUM_OF_THREADS_8: | 763 | case UEC_NUM_OF_THREADS_8: |
718 | num_threads_numerica = 8; | 764 | num_threads_numerica = 8; |
719 | break; | 765 | break; |
720 | default: | 766 | default: |
721 | printf("%s: Bad number of threads value.", | 767 | printf("%s: Bad number of threads value.", |
722 | __FUNCTION__); | 768 | __FUNCTION__); |
723 | return -EINVAL; | 769 | return -EINVAL; |
724 | } | 770 | } |
725 | 771 | ||
726 | *threads_num_ret = num_threads_numerica; | 772 | *threads_num_ret = num_threads_numerica; |
727 | 773 | ||
728 | return 0; | 774 | return 0; |
729 | } | 775 | } |
730 | 776 | ||
731 | static void uec_init_tx_parameter(uec_private_t *uec, int num_threads_tx) | 777 | static void uec_init_tx_parameter(uec_private_t *uec, int num_threads_tx) |
732 | { | 778 | { |
733 | uec_info_t *uec_info; | 779 | uec_info_t *uec_info; |
734 | u32 end_bd; | 780 | u32 end_bd; |
735 | u8 bmrx = 0; | 781 | u8 bmrx = 0; |
736 | int i; | 782 | int i; |
737 | 783 | ||
738 | uec_info = uec->uec_info; | 784 | uec_info = uec->uec_info; |
739 | 785 | ||
740 | /* Alloc global Tx parameter RAM page */ | 786 | /* Alloc global Tx parameter RAM page */ |
741 | uec->tx_glbl_pram_offset = qe_muram_alloc( | 787 | uec->tx_glbl_pram_offset = qe_muram_alloc( |
742 | sizeof(uec_tx_global_pram_t), | 788 | sizeof(uec_tx_global_pram_t), |
743 | UEC_TX_GLOBAL_PRAM_ALIGNMENT); | 789 | UEC_TX_GLOBAL_PRAM_ALIGNMENT); |
744 | uec->p_tx_glbl_pram = (uec_tx_global_pram_t *) | 790 | uec->p_tx_glbl_pram = (uec_tx_global_pram_t *) |
745 | qe_muram_addr(uec->tx_glbl_pram_offset); | 791 | qe_muram_addr(uec->tx_glbl_pram_offset); |
746 | 792 | ||
747 | /* Zero the global Tx prameter RAM */ | 793 | /* Zero the global Tx prameter RAM */ |
748 | memset(uec->p_tx_glbl_pram, 0, sizeof(uec_tx_global_pram_t)); | 794 | memset(uec->p_tx_glbl_pram, 0, sizeof(uec_tx_global_pram_t)); |
749 | 795 | ||
750 | /* Init global Tx parameter RAM */ | 796 | /* Init global Tx parameter RAM */ |
751 | 797 | ||
752 | /* TEMODER, RMON statistics disable, one Tx queue */ | 798 | /* TEMODER, RMON statistics disable, one Tx queue */ |
753 | out_be16(&uec->p_tx_glbl_pram->temoder, TEMODER_INIT_VALUE); | 799 | out_be16(&uec->p_tx_glbl_pram->temoder, TEMODER_INIT_VALUE); |
754 | 800 | ||
755 | /* SQPTR */ | 801 | /* SQPTR */ |
756 | uec->send_q_mem_reg_offset = qe_muram_alloc( | 802 | uec->send_q_mem_reg_offset = qe_muram_alloc( |
757 | sizeof(uec_send_queue_qd_t), | 803 | sizeof(uec_send_queue_qd_t), |
758 | UEC_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT); | 804 | UEC_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT); |
759 | uec->p_send_q_mem_reg = (uec_send_queue_mem_region_t *) | 805 | uec->p_send_q_mem_reg = (uec_send_queue_mem_region_t *) |
760 | qe_muram_addr(uec->send_q_mem_reg_offset); | 806 | qe_muram_addr(uec->send_q_mem_reg_offset); |
761 | out_be32(&uec->p_tx_glbl_pram->sqptr, uec->send_q_mem_reg_offset); | 807 | out_be32(&uec->p_tx_glbl_pram->sqptr, uec->send_q_mem_reg_offset); |
762 | 808 | ||
763 | /* Setup the table with TxBDs ring */ | 809 | /* Setup the table with TxBDs ring */ |
764 | end_bd = (u32)uec->p_tx_bd_ring + (uec_info->tx_bd_ring_len - 1) | 810 | end_bd = (u32)uec->p_tx_bd_ring + (uec_info->tx_bd_ring_len - 1) |
765 | * SIZEOFBD; | 811 | * SIZEOFBD; |
766 | out_be32(&uec->p_send_q_mem_reg->sqqd[0].bd_ring_base, | 812 | out_be32(&uec->p_send_q_mem_reg->sqqd[0].bd_ring_base, |
767 | (u32)(uec->p_tx_bd_ring)); | 813 | (u32)(uec->p_tx_bd_ring)); |
768 | out_be32(&uec->p_send_q_mem_reg->sqqd[0].last_bd_completed_address, | 814 | out_be32(&uec->p_send_q_mem_reg->sqqd[0].last_bd_completed_address, |
769 | end_bd); | 815 | end_bd); |
770 | 816 | ||
771 | /* Scheduler Base Pointer, we have only one Tx queue, no need it */ | 817 | /* Scheduler Base Pointer, we have only one Tx queue, no need it */ |
772 | out_be32(&uec->p_tx_glbl_pram->schedulerbasepointer, 0); | 818 | out_be32(&uec->p_tx_glbl_pram->schedulerbasepointer, 0); |
773 | 819 | ||
774 | /* TxRMON Base Pointer, TxRMON disable, we don't need it */ | 820 | /* TxRMON Base Pointer, TxRMON disable, we don't need it */ |
775 | out_be32(&uec->p_tx_glbl_pram->txrmonbaseptr, 0); | 821 | out_be32(&uec->p_tx_glbl_pram->txrmonbaseptr, 0); |
776 | 822 | ||
777 | /* TSTATE, global snooping, big endian, the CSB bus selected */ | 823 | /* TSTATE, global snooping, big endian, the CSB bus selected */ |
778 | bmrx = BMR_INIT_VALUE; | 824 | bmrx = BMR_INIT_VALUE; |
779 | out_be32(&uec->p_tx_glbl_pram->tstate, ((u32)(bmrx) << BMR_SHIFT)); | 825 | out_be32(&uec->p_tx_glbl_pram->tstate, ((u32)(bmrx) << BMR_SHIFT)); |
780 | 826 | ||
781 | /* IPH_Offset */ | 827 | /* IPH_Offset */ |
782 | for (i = 0; i < MAX_IPH_OFFSET_ENTRY; i++) { | 828 | for (i = 0; i < MAX_IPH_OFFSET_ENTRY; i++) { |
783 | out_8(&uec->p_tx_glbl_pram->iphoffset[i], 0); | 829 | out_8(&uec->p_tx_glbl_pram->iphoffset[i], 0); |
784 | } | 830 | } |
785 | 831 | ||
786 | /* VTAG table */ | 832 | /* VTAG table */ |
787 | for (i = 0; i < UEC_TX_VTAG_TABLE_ENTRY_MAX; i++) { | 833 | for (i = 0; i < UEC_TX_VTAG_TABLE_ENTRY_MAX; i++) { |
788 | out_be32(&uec->p_tx_glbl_pram->vtagtable[i], 0); | 834 | out_be32(&uec->p_tx_glbl_pram->vtagtable[i], 0); |
789 | } | 835 | } |
790 | 836 | ||
791 | /* TQPTR */ | 837 | /* TQPTR */ |
792 | uec->thread_dat_tx_offset = qe_muram_alloc( | 838 | uec->thread_dat_tx_offset = qe_muram_alloc( |
793 | num_threads_tx * sizeof(uec_thread_data_tx_t) + | 839 | num_threads_tx * sizeof(uec_thread_data_tx_t) + |
794 | 32 *(num_threads_tx == 1), UEC_THREAD_DATA_ALIGNMENT); | 840 | 32 *(num_threads_tx == 1), UEC_THREAD_DATA_ALIGNMENT); |
795 | 841 | ||
796 | uec->p_thread_data_tx = (uec_thread_data_tx_t *) | 842 | uec->p_thread_data_tx = (uec_thread_data_tx_t *) |
797 | qe_muram_addr(uec->thread_dat_tx_offset); | 843 | qe_muram_addr(uec->thread_dat_tx_offset); |
798 | out_be32(&uec->p_tx_glbl_pram->tqptr, uec->thread_dat_tx_offset); | 844 | out_be32(&uec->p_tx_glbl_pram->tqptr, uec->thread_dat_tx_offset); |
799 | } | 845 | } |
800 | 846 | ||
801 | static void uec_init_rx_parameter(uec_private_t *uec, int num_threads_rx) | 847 | static void uec_init_rx_parameter(uec_private_t *uec, int num_threads_rx) |
802 | { | 848 | { |
803 | u8 bmrx = 0; | 849 | u8 bmrx = 0; |
804 | int i; | 850 | int i; |
805 | uec_82xx_address_filtering_pram_t *p_af_pram; | 851 | uec_82xx_address_filtering_pram_t *p_af_pram; |
806 | 852 | ||
807 | /* Allocate global Rx parameter RAM page */ | 853 | /* Allocate global Rx parameter RAM page */ |
808 | uec->rx_glbl_pram_offset = qe_muram_alloc( | 854 | uec->rx_glbl_pram_offset = qe_muram_alloc( |
809 | sizeof(uec_rx_global_pram_t), UEC_RX_GLOBAL_PRAM_ALIGNMENT); | 855 | sizeof(uec_rx_global_pram_t), UEC_RX_GLOBAL_PRAM_ALIGNMENT); |
810 | uec->p_rx_glbl_pram = (uec_rx_global_pram_t *) | 856 | uec->p_rx_glbl_pram = (uec_rx_global_pram_t *) |
811 | qe_muram_addr(uec->rx_glbl_pram_offset); | 857 | qe_muram_addr(uec->rx_glbl_pram_offset); |
812 | 858 | ||
813 | /* Zero Global Rx parameter RAM */ | 859 | /* Zero Global Rx parameter RAM */ |
814 | memset(uec->p_rx_glbl_pram, 0, sizeof(uec_rx_global_pram_t)); | 860 | memset(uec->p_rx_glbl_pram, 0, sizeof(uec_rx_global_pram_t)); |
815 | 861 | ||
816 | /* Init global Rx parameter RAM */ | 862 | /* Init global Rx parameter RAM */ |
817 | /* REMODER, Extended feature mode disable, VLAN disable, | 863 | /* REMODER, Extended feature mode disable, VLAN disable, |
818 | LossLess flow control disable, Receive firmware statisic disable, | 864 | LossLess flow control disable, Receive firmware statisic disable, |
819 | Extended address parsing mode disable, One Rx queues, | 865 | Extended address parsing mode disable, One Rx queues, |
820 | Dynamic maximum/minimum frame length disable, IP checksum check | 866 | Dynamic maximum/minimum frame length disable, IP checksum check |
821 | disable, IP address alignment disable | 867 | disable, IP address alignment disable |
822 | */ | 868 | */ |
823 | out_be32(&uec->p_rx_glbl_pram->remoder, REMODER_INIT_VALUE); | 869 | out_be32(&uec->p_rx_glbl_pram->remoder, REMODER_INIT_VALUE); |
824 | 870 | ||
825 | /* RQPTR */ | 871 | /* RQPTR */ |
826 | uec->thread_dat_rx_offset = qe_muram_alloc( | 872 | uec->thread_dat_rx_offset = qe_muram_alloc( |
827 | num_threads_rx * sizeof(uec_thread_data_rx_t), | 873 | num_threads_rx * sizeof(uec_thread_data_rx_t), |
828 | UEC_THREAD_DATA_ALIGNMENT); | 874 | UEC_THREAD_DATA_ALIGNMENT); |
829 | uec->p_thread_data_rx = (uec_thread_data_rx_t *) | 875 | uec->p_thread_data_rx = (uec_thread_data_rx_t *) |
830 | qe_muram_addr(uec->thread_dat_rx_offset); | 876 | qe_muram_addr(uec->thread_dat_rx_offset); |
831 | out_be32(&uec->p_rx_glbl_pram->rqptr, uec->thread_dat_rx_offset); | 877 | out_be32(&uec->p_rx_glbl_pram->rqptr, uec->thread_dat_rx_offset); |
832 | 878 | ||
833 | /* Type_or_Len */ | 879 | /* Type_or_Len */ |
834 | out_be16(&uec->p_rx_glbl_pram->typeorlen, 3072); | 880 | out_be16(&uec->p_rx_glbl_pram->typeorlen, 3072); |
835 | 881 | ||
836 | /* RxRMON base pointer, we don't need it */ | 882 | /* RxRMON base pointer, we don't need it */ |
837 | out_be32(&uec->p_rx_glbl_pram->rxrmonbaseptr, 0); | 883 | out_be32(&uec->p_rx_glbl_pram->rxrmonbaseptr, 0); |
838 | 884 | ||
839 | /* IntCoalescingPTR, we don't need it, no interrupt */ | 885 | /* IntCoalescingPTR, we don't need it, no interrupt */ |
840 | out_be32(&uec->p_rx_glbl_pram->intcoalescingptr, 0); | 886 | out_be32(&uec->p_rx_glbl_pram->intcoalescingptr, 0); |
841 | 887 | ||
842 | /* RSTATE, global snooping, big endian, the CSB bus selected */ | 888 | /* RSTATE, global snooping, big endian, the CSB bus selected */ |
843 | bmrx = BMR_INIT_VALUE; | 889 | bmrx = BMR_INIT_VALUE; |
844 | out_8(&uec->p_rx_glbl_pram->rstate, bmrx); | 890 | out_8(&uec->p_rx_glbl_pram->rstate, bmrx); |
845 | 891 | ||
846 | /* MRBLR */ | 892 | /* MRBLR */ |
847 | out_be16(&uec->p_rx_glbl_pram->mrblr, MAX_RXBUF_LEN); | 893 | out_be16(&uec->p_rx_glbl_pram->mrblr, MAX_RXBUF_LEN); |
848 | 894 | ||
849 | /* RBDQPTR */ | 895 | /* RBDQPTR */ |
850 | uec->rx_bd_qs_tbl_offset = qe_muram_alloc( | 896 | uec->rx_bd_qs_tbl_offset = qe_muram_alloc( |
851 | sizeof(uec_rx_bd_queues_entry_t) + \ | 897 | sizeof(uec_rx_bd_queues_entry_t) + \ |
852 | sizeof(uec_rx_prefetched_bds_t), | 898 | sizeof(uec_rx_prefetched_bds_t), |
853 | UEC_RX_BD_QUEUES_ALIGNMENT); | 899 | UEC_RX_BD_QUEUES_ALIGNMENT); |
854 | uec->p_rx_bd_qs_tbl = (uec_rx_bd_queues_entry_t *) | 900 | uec->p_rx_bd_qs_tbl = (uec_rx_bd_queues_entry_t *) |
855 | qe_muram_addr(uec->rx_bd_qs_tbl_offset); | 901 | qe_muram_addr(uec->rx_bd_qs_tbl_offset); |
856 | 902 | ||
857 | /* Zero it */ | 903 | /* Zero it */ |
858 | memset(uec->p_rx_bd_qs_tbl, 0, sizeof(uec_rx_bd_queues_entry_t) + \ | 904 | memset(uec->p_rx_bd_qs_tbl, 0, sizeof(uec_rx_bd_queues_entry_t) + \ |
859 | sizeof(uec_rx_prefetched_bds_t)); | 905 | sizeof(uec_rx_prefetched_bds_t)); |
860 | out_be32(&uec->p_rx_glbl_pram->rbdqptr, uec->rx_bd_qs_tbl_offset); | 906 | out_be32(&uec->p_rx_glbl_pram->rbdqptr, uec->rx_bd_qs_tbl_offset); |
861 | out_be32(&uec->p_rx_bd_qs_tbl->externalbdbaseptr, | 907 | out_be32(&uec->p_rx_bd_qs_tbl->externalbdbaseptr, |
862 | (u32)uec->p_rx_bd_ring); | 908 | (u32)uec->p_rx_bd_ring); |
863 | 909 | ||
864 | /* MFLR */ | 910 | /* MFLR */ |
865 | out_be16(&uec->p_rx_glbl_pram->mflr, MAX_FRAME_LEN); | 911 | out_be16(&uec->p_rx_glbl_pram->mflr, MAX_FRAME_LEN); |
866 | /* MINFLR */ | 912 | /* MINFLR */ |
867 | out_be16(&uec->p_rx_glbl_pram->minflr, MIN_FRAME_LEN); | 913 | out_be16(&uec->p_rx_glbl_pram->minflr, MIN_FRAME_LEN); |
868 | /* MAXD1 */ | 914 | /* MAXD1 */ |
869 | out_be16(&uec->p_rx_glbl_pram->maxd1, MAX_DMA1_LEN); | 915 | out_be16(&uec->p_rx_glbl_pram->maxd1, MAX_DMA1_LEN); |
870 | /* MAXD2 */ | 916 | /* MAXD2 */ |
871 | out_be16(&uec->p_rx_glbl_pram->maxd2, MAX_DMA2_LEN); | 917 | out_be16(&uec->p_rx_glbl_pram->maxd2, MAX_DMA2_LEN); |
872 | /* ECAM_PTR */ | 918 | /* ECAM_PTR */ |
873 | out_be32(&uec->p_rx_glbl_pram->ecamptr, 0); | 919 | out_be32(&uec->p_rx_glbl_pram->ecamptr, 0); |
874 | /* L2QT */ | 920 | /* L2QT */ |
875 | out_be32(&uec->p_rx_glbl_pram->l2qt, 0); | 921 | out_be32(&uec->p_rx_glbl_pram->l2qt, 0); |
876 | /* L3QT */ | 922 | /* L3QT */ |
877 | for (i = 0; i < 8; i++) { | 923 | for (i = 0; i < 8; i++) { |
878 | out_be32(&uec->p_rx_glbl_pram->l3qt[i], 0); | 924 | out_be32(&uec->p_rx_glbl_pram->l3qt[i], 0); |
879 | } | 925 | } |
880 | 926 | ||
881 | /* VLAN_TYPE */ | 927 | /* VLAN_TYPE */ |
882 | out_be16(&uec->p_rx_glbl_pram->vlantype, 0x8100); | 928 | out_be16(&uec->p_rx_glbl_pram->vlantype, 0x8100); |
883 | /* TCI */ | 929 | /* TCI */ |
884 | out_be16(&uec->p_rx_glbl_pram->vlantci, 0); | 930 | out_be16(&uec->p_rx_glbl_pram->vlantci, 0); |
885 | 931 | ||
886 | /* Clear PQ2 style address filtering hash table */ | 932 | /* Clear PQ2 style address filtering hash table */ |
887 | p_af_pram = (uec_82xx_address_filtering_pram_t *) \ | 933 | p_af_pram = (uec_82xx_address_filtering_pram_t *) \ |
888 | uec->p_rx_glbl_pram->addressfiltering; | 934 | uec->p_rx_glbl_pram->addressfiltering; |
889 | 935 | ||
890 | p_af_pram->iaddr_h = 0; | 936 | p_af_pram->iaddr_h = 0; |
891 | p_af_pram->iaddr_l = 0; | 937 | p_af_pram->iaddr_l = 0; |
892 | p_af_pram->gaddr_h = 0; | 938 | p_af_pram->gaddr_h = 0; |
893 | p_af_pram->gaddr_l = 0; | 939 | p_af_pram->gaddr_l = 0; |
894 | } | 940 | } |
895 | 941 | ||
896 | static int uec_issue_init_enet_rxtx_cmd(uec_private_t *uec, | 942 | static int uec_issue_init_enet_rxtx_cmd(uec_private_t *uec, |
897 | int thread_tx, int thread_rx) | 943 | int thread_tx, int thread_rx) |
898 | { | 944 | { |
899 | uec_init_cmd_pram_t *p_init_enet_param; | 945 | uec_init_cmd_pram_t *p_init_enet_param; |
900 | u32 init_enet_param_offset; | 946 | u32 init_enet_param_offset; |
901 | uec_info_t *uec_info; | 947 | uec_info_t *uec_info; |
902 | int i; | 948 | int i; |
903 | int snum; | 949 | int snum; |
904 | u32 init_enet_offset; | 950 | u32 init_enet_offset; |
905 | u32 entry_val; | 951 | u32 entry_val; |
906 | u32 command; | 952 | u32 command; |
907 | u32 cecr_subblock; | 953 | u32 cecr_subblock; |
908 | 954 | ||
909 | uec_info = uec->uec_info; | 955 | uec_info = uec->uec_info; |
910 | 956 | ||
911 | /* Allocate init enet command parameter */ | 957 | /* Allocate init enet command parameter */ |
912 | uec->init_enet_param_offset = qe_muram_alloc( | 958 | uec->init_enet_param_offset = qe_muram_alloc( |
913 | sizeof(uec_init_cmd_pram_t), 4); | 959 | sizeof(uec_init_cmd_pram_t), 4); |
914 | init_enet_param_offset = uec->init_enet_param_offset; | 960 | init_enet_param_offset = uec->init_enet_param_offset; |
915 | uec->p_init_enet_param = (uec_init_cmd_pram_t *) | 961 | uec->p_init_enet_param = (uec_init_cmd_pram_t *) |
916 | qe_muram_addr(uec->init_enet_param_offset); | 962 | qe_muram_addr(uec->init_enet_param_offset); |
917 | 963 | ||
918 | /* Zero init enet command struct */ | 964 | /* Zero init enet command struct */ |
919 | memset((void *)uec->p_init_enet_param, 0, sizeof(uec_init_cmd_pram_t)); | 965 | memset((void *)uec->p_init_enet_param, 0, sizeof(uec_init_cmd_pram_t)); |
920 | 966 | ||
921 | /* Init the command struct */ | 967 | /* Init the command struct */ |
922 | p_init_enet_param = uec->p_init_enet_param; | 968 | p_init_enet_param = uec->p_init_enet_param; |
923 | p_init_enet_param->resinit0 = ENET_INIT_PARAM_MAGIC_RES_INIT0; | 969 | p_init_enet_param->resinit0 = ENET_INIT_PARAM_MAGIC_RES_INIT0; |
924 | p_init_enet_param->resinit1 = ENET_INIT_PARAM_MAGIC_RES_INIT1; | 970 | p_init_enet_param->resinit1 = ENET_INIT_PARAM_MAGIC_RES_INIT1; |
925 | p_init_enet_param->resinit2 = ENET_INIT_PARAM_MAGIC_RES_INIT2; | 971 | p_init_enet_param->resinit2 = ENET_INIT_PARAM_MAGIC_RES_INIT2; |
926 | p_init_enet_param->resinit3 = ENET_INIT_PARAM_MAGIC_RES_INIT3; | 972 | p_init_enet_param->resinit3 = ENET_INIT_PARAM_MAGIC_RES_INIT3; |
927 | p_init_enet_param->resinit4 = ENET_INIT_PARAM_MAGIC_RES_INIT4; | 973 | p_init_enet_param->resinit4 = ENET_INIT_PARAM_MAGIC_RES_INIT4; |
928 | p_init_enet_param->largestexternallookupkeysize = 0; | 974 | p_init_enet_param->largestexternallookupkeysize = 0; |
929 | 975 | ||
930 | p_init_enet_param->rgftgfrxglobal |= ((u32)uec_info->num_threads_rx) | 976 | p_init_enet_param->rgftgfrxglobal |= ((u32)uec_info->num_threads_rx) |
931 | << ENET_INIT_PARAM_RGF_SHIFT; | 977 | << ENET_INIT_PARAM_RGF_SHIFT; |
932 | p_init_enet_param->rgftgfrxglobal |= ((u32)uec_info->num_threads_tx) | 978 | p_init_enet_param->rgftgfrxglobal |= ((u32)uec_info->num_threads_tx) |
933 | << ENET_INIT_PARAM_TGF_SHIFT; | 979 | << ENET_INIT_PARAM_TGF_SHIFT; |
934 | 980 | ||
935 | /* Init Rx global parameter pointer */ | 981 | /* Init Rx global parameter pointer */ |
936 | p_init_enet_param->rgftgfrxglobal |= uec->rx_glbl_pram_offset | | 982 | p_init_enet_param->rgftgfrxglobal |= uec->rx_glbl_pram_offset | |
937 | (u32)uec_info->riscRx; | 983 | (u32)uec_info->riscRx; |
938 | 984 | ||
939 | /* Init Rx threads */ | 985 | /* Init Rx threads */ |
940 | for (i = 0; i < (thread_rx + 1); i++) { | 986 | for (i = 0; i < (thread_rx + 1); i++) { |
941 | if ((snum = qe_get_snum()) < 0) { | 987 | if ((snum = qe_get_snum()) < 0) { |
942 | printf("%s can not get snum\n", __FUNCTION__); | 988 | printf("%s can not get snum\n", __FUNCTION__); |
943 | return -ENOMEM; | 989 | return -ENOMEM; |
944 | } | 990 | } |
945 | 991 | ||
946 | if (i==0) { | 992 | if (i==0) { |
947 | init_enet_offset = 0; | 993 | init_enet_offset = 0; |
948 | } else { | 994 | } else { |
949 | init_enet_offset = qe_muram_alloc( | 995 | init_enet_offset = qe_muram_alloc( |
950 | sizeof(uec_thread_rx_pram_t), | 996 | sizeof(uec_thread_rx_pram_t), |
951 | UEC_THREAD_RX_PRAM_ALIGNMENT); | 997 | UEC_THREAD_RX_PRAM_ALIGNMENT); |
952 | } | 998 | } |
953 | 999 | ||
954 | entry_val = ((u32)snum << ENET_INIT_PARAM_SNUM_SHIFT) | | 1000 | entry_val = ((u32)snum << ENET_INIT_PARAM_SNUM_SHIFT) | |
955 | init_enet_offset | (u32)uec_info->riscRx; | 1001 | init_enet_offset | (u32)uec_info->riscRx; |
956 | p_init_enet_param->rxthread[i] = entry_val; | 1002 | p_init_enet_param->rxthread[i] = entry_val; |
957 | } | 1003 | } |
958 | 1004 | ||
959 | /* Init Tx global parameter pointer */ | 1005 | /* Init Tx global parameter pointer */ |
960 | p_init_enet_param->txglobal = uec->tx_glbl_pram_offset | | 1006 | p_init_enet_param->txglobal = uec->tx_glbl_pram_offset | |
961 | (u32)uec_info->riscTx; | 1007 | (u32)uec_info->riscTx; |
962 | 1008 | ||
963 | /* Init Tx threads */ | 1009 | /* Init Tx threads */ |
964 | for (i = 0; i < thread_tx; i++) { | 1010 | for (i = 0; i < thread_tx; i++) { |
965 | if ((snum = qe_get_snum()) < 0) { | 1011 | if ((snum = qe_get_snum()) < 0) { |
966 | printf("%s can not get snum\n", __FUNCTION__); | 1012 | printf("%s can not get snum\n", __FUNCTION__); |
967 | return -ENOMEM; | 1013 | return -ENOMEM; |
968 | } | 1014 | } |
969 | 1015 | ||
970 | init_enet_offset = qe_muram_alloc(sizeof(uec_thread_tx_pram_t), | 1016 | init_enet_offset = qe_muram_alloc(sizeof(uec_thread_tx_pram_t), |
971 | UEC_THREAD_TX_PRAM_ALIGNMENT); | 1017 | UEC_THREAD_TX_PRAM_ALIGNMENT); |
972 | 1018 | ||
973 | entry_val = ((u32)snum << ENET_INIT_PARAM_SNUM_SHIFT) | | 1019 | entry_val = ((u32)snum << ENET_INIT_PARAM_SNUM_SHIFT) | |
974 | init_enet_offset | (u32)uec_info->riscTx; | 1020 | init_enet_offset | (u32)uec_info->riscTx; |
975 | p_init_enet_param->txthread[i] = entry_val; | 1021 | p_init_enet_param->txthread[i] = entry_val; |
976 | } | 1022 | } |
977 | 1023 | ||
978 | __asm__ __volatile__("sync"); | 1024 | __asm__ __volatile__("sync"); |
979 | 1025 | ||
980 | /* Issue QE command */ | 1026 | /* Issue QE command */ |
981 | command = QE_INIT_TX_RX; | 1027 | command = QE_INIT_TX_RX; |
982 | cecr_subblock = ucc_fast_get_qe_cr_subblock( | 1028 | cecr_subblock = ucc_fast_get_qe_cr_subblock( |
983 | uec->uec_info->uf_info.ucc_num); | 1029 | uec->uec_info->uf_info.ucc_num); |
984 | qe_issue_cmd(command, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, | 1030 | qe_issue_cmd(command, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, |
985 | init_enet_param_offset); | 1031 | init_enet_param_offset); |
986 | 1032 | ||
987 | return 0; | 1033 | return 0; |
988 | } | 1034 | } |
989 | 1035 | ||
990 | static int uec_startup(uec_private_t *uec) | 1036 | static int uec_startup(uec_private_t *uec) |
991 | { | 1037 | { |
992 | uec_info_t *uec_info; | 1038 | uec_info_t *uec_info; |
993 | ucc_fast_info_t *uf_info; | 1039 | ucc_fast_info_t *uf_info; |
994 | ucc_fast_private_t *uccf; | 1040 | ucc_fast_private_t *uccf; |
995 | ucc_fast_t *uf_regs; | 1041 | ucc_fast_t *uf_regs; |
996 | uec_t *uec_regs; | 1042 | uec_t *uec_regs; |
997 | int num_threads_tx; | 1043 | int num_threads_tx; |
998 | int num_threads_rx; | 1044 | int num_threads_rx; |
999 | u32 utbipar; | 1045 | u32 utbipar; |
1000 | enet_interface_e enet_interface; | 1046 | enet_interface_e enet_interface; |
1001 | u32 length; | 1047 | u32 length; |
1002 | u32 align; | 1048 | u32 align; |
1003 | qe_bd_t *bd; | 1049 | qe_bd_t *bd; |
1004 | u8 *buf; | 1050 | u8 *buf; |
1005 | int i; | 1051 | int i; |
1006 | 1052 | ||
1007 | if (!uec || !uec->uec_info) { | 1053 | if (!uec || !uec->uec_info) { |
1008 | printf("%s: uec or uec_info not initial\n", __FUNCTION__); | 1054 | printf("%s: uec or uec_info not initial\n", __FUNCTION__); |
1009 | return -EINVAL; | 1055 | return -EINVAL; |
1010 | } | 1056 | } |
1011 | 1057 | ||
1012 | uec_info = uec->uec_info; | 1058 | uec_info = uec->uec_info; |
1013 | uf_info = &(uec_info->uf_info); | 1059 | uf_info = &(uec_info->uf_info); |
1014 | 1060 | ||
1015 | /* Check if Rx BD ring len is illegal */ | 1061 | /* Check if Rx BD ring len is illegal */ |
1016 | if ((uec_info->rx_bd_ring_len < UEC_RX_BD_RING_SIZE_MIN) || \ | 1062 | if ((uec_info->rx_bd_ring_len < UEC_RX_BD_RING_SIZE_MIN) || \ |
1017 | (uec_info->rx_bd_ring_len % UEC_RX_BD_RING_SIZE_ALIGNMENT)) { | 1063 | (uec_info->rx_bd_ring_len % UEC_RX_BD_RING_SIZE_ALIGNMENT)) { |
1018 | printf("%s: Rx BD ring len must be multiple of 4, and > 8.\n", | 1064 | printf("%s: Rx BD ring len must be multiple of 4, and > 8.\n", |
1019 | __FUNCTION__); | 1065 | __FUNCTION__); |
1020 | return -EINVAL; | 1066 | return -EINVAL; |
1021 | } | 1067 | } |
1022 | 1068 | ||
1023 | /* Check if Tx BD ring len is illegal */ | 1069 | /* Check if Tx BD ring len is illegal */ |
1024 | if (uec_info->tx_bd_ring_len < UEC_TX_BD_RING_SIZE_MIN) { | 1070 | if (uec_info->tx_bd_ring_len < UEC_TX_BD_RING_SIZE_MIN) { |
1025 | printf("%s: Tx BD ring length must not be smaller than 2.\n", | 1071 | printf("%s: Tx BD ring length must not be smaller than 2.\n", |
1026 | __FUNCTION__); | 1072 | __FUNCTION__); |
1027 | return -EINVAL; | 1073 | return -EINVAL; |
1028 | } | 1074 | } |
1029 | 1075 | ||
1030 | /* Check if MRBLR is illegal */ | 1076 | /* Check if MRBLR is illegal */ |
1031 | if ((MAX_RXBUF_LEN == 0) || (MAX_RXBUF_LEN % UEC_MRBLR_ALIGNMENT)) { | 1077 | if ((MAX_RXBUF_LEN == 0) || (MAX_RXBUF_LEN % UEC_MRBLR_ALIGNMENT)) { |
1032 | printf("%s: max rx buffer length must be mutliple of 128.\n", | 1078 | printf("%s: max rx buffer length must be mutliple of 128.\n", |
1033 | __FUNCTION__); | 1079 | __FUNCTION__); |
1034 | return -EINVAL; | 1080 | return -EINVAL; |
1035 | } | 1081 | } |
1036 | 1082 | ||
1037 | /* Both Rx and Tx are stopped */ | 1083 | /* Both Rx and Tx are stopped */ |
1038 | uec->grace_stopped_rx = 1; | 1084 | uec->grace_stopped_rx = 1; |
1039 | uec->grace_stopped_tx = 1; | 1085 | uec->grace_stopped_tx = 1; |
1040 | 1086 | ||
1041 | /* Init UCC fast */ | 1087 | /* Init UCC fast */ |
1042 | if (ucc_fast_init(uf_info, &uccf)) { | 1088 | if (ucc_fast_init(uf_info, &uccf)) { |
1043 | printf("%s: failed to init ucc fast\n", __FUNCTION__); | 1089 | printf("%s: failed to init ucc fast\n", __FUNCTION__); |
1044 | return -ENOMEM; | 1090 | return -ENOMEM; |
1045 | } | 1091 | } |
1046 | 1092 | ||
1047 | /* Save uccf */ | 1093 | /* Save uccf */ |
1048 | uec->uccf = uccf; | 1094 | uec->uccf = uccf; |
1049 | 1095 | ||
1050 | /* Convert the Tx threads number */ | 1096 | /* Convert the Tx threads number */ |
1051 | if (uec_convert_threads_num(uec_info->num_threads_tx, | 1097 | if (uec_convert_threads_num(uec_info->num_threads_tx, |
1052 | &num_threads_tx)) { | 1098 | &num_threads_tx)) { |
1053 | return -EINVAL; | 1099 | return -EINVAL; |
1054 | } | 1100 | } |
1055 | 1101 | ||
1056 | /* Convert the Rx threads number */ | 1102 | /* Convert the Rx threads number */ |
1057 | if (uec_convert_threads_num(uec_info->num_threads_rx, | 1103 | if (uec_convert_threads_num(uec_info->num_threads_rx, |
1058 | &num_threads_rx)) { | 1104 | &num_threads_rx)) { |
1059 | return -EINVAL; | 1105 | return -EINVAL; |
1060 | } | 1106 | } |
1061 | 1107 | ||
1062 | uf_regs = uccf->uf_regs; | 1108 | uf_regs = uccf->uf_regs; |
1063 | 1109 | ||
1064 | /* UEC register is following UCC fast registers */ | 1110 | /* UEC register is following UCC fast registers */ |
1065 | uec_regs = (uec_t *)(&uf_regs->ucc_eth); | 1111 | uec_regs = (uec_t *)(&uf_regs->ucc_eth); |
1066 | 1112 | ||
1067 | /* Save the UEC register pointer to UEC private struct */ | 1113 | /* Save the UEC register pointer to UEC private struct */ |
1068 | uec->uec_regs = uec_regs; | 1114 | uec->uec_regs = uec_regs; |
1069 | 1115 | ||
1070 | /* Init UPSMR, enable hardware statistics (UCC) */ | 1116 | /* Init UPSMR, enable hardware statistics (UCC) */ |
1071 | out_be32(&uec->uccf->uf_regs->upsmr, UPSMR_INIT_VALUE); | 1117 | out_be32(&uec->uccf->uf_regs->upsmr, UPSMR_INIT_VALUE); |
1072 | 1118 | ||
1073 | /* Init MACCFG1, flow control disable, disable Tx and Rx */ | 1119 | /* Init MACCFG1, flow control disable, disable Tx and Rx */ |
1074 | out_be32(&uec_regs->maccfg1, MACCFG1_INIT_VALUE); | 1120 | out_be32(&uec_regs->maccfg1, MACCFG1_INIT_VALUE); |
1075 | 1121 | ||
1076 | /* Init MACCFG2, length check, MAC PAD and CRC enable */ | 1122 | /* Init MACCFG2, length check, MAC PAD and CRC enable */ |
1077 | out_be32(&uec_regs->maccfg2, MACCFG2_INIT_VALUE); | 1123 | out_be32(&uec_regs->maccfg2, MACCFG2_INIT_VALUE); |
1078 | 1124 | ||
1079 | /* Setup MAC interface mode */ | 1125 | /* Setup MAC interface mode */ |
1080 | uec_set_mac_if_mode(uec, uec_info->enet_interface); | 1126 | uec_set_mac_if_mode(uec, uec_info->enet_interface); |
1081 | 1127 | ||
1082 | /* Setup MII management base */ | 1128 | /* Setup MII management base */ |
1083 | #ifndef CONFIG_eTSEC_MDIO_BUS | 1129 | #ifndef CONFIG_eTSEC_MDIO_BUS |
1084 | uec->uec_mii_regs = (uec_mii_t *)(&uec_regs->miimcfg); | 1130 | uec->uec_mii_regs = (uec_mii_t *)(&uec_regs->miimcfg); |
1085 | #else | 1131 | #else |
1086 | uec->uec_mii_regs = (uec_mii_t *) CONFIG_MIIM_ADDRESS; | 1132 | uec->uec_mii_regs = (uec_mii_t *) CONFIG_MIIM_ADDRESS; |
1087 | #endif | 1133 | #endif |
1088 | 1134 | ||
1089 | /* Setup MII master clock source */ | 1135 | /* Setup MII master clock source */ |
1090 | qe_set_mii_clk_src(uec_info->uf_info.ucc_num); | 1136 | qe_set_mii_clk_src(uec_info->uf_info.ucc_num); |
1091 | 1137 | ||
1092 | /* Setup UTBIPAR */ | 1138 | /* Setup UTBIPAR */ |
1093 | utbipar = in_be32(&uec_regs->utbipar); | 1139 | utbipar = in_be32(&uec_regs->utbipar); |
1094 | utbipar &= ~UTBIPAR_PHY_ADDRESS_MASK; | 1140 | utbipar &= ~UTBIPAR_PHY_ADDRESS_MASK; |
1095 | enet_interface = uec->uec_info->enet_interface; | 1141 | enet_interface = uec->uec_info->enet_interface; |
1096 | if (enet_interface == ENET_1000_TBI || | 1142 | if (enet_interface == ENET_1000_TBI || |
1097 | enet_interface == ENET_1000_RTBI) { | 1143 | enet_interface == ENET_1000_RTBI) { |
1098 | utbipar |= (uec_info->phy_address + uec_info->uf_info.ucc_num) | 1144 | utbipar |= (uec_info->phy_address + uec_info->uf_info.ucc_num) |
1099 | << UTBIPAR_PHY_ADDRESS_SHIFT; | 1145 | << UTBIPAR_PHY_ADDRESS_SHIFT; |
1100 | } else { | 1146 | } else { |
1101 | utbipar |= (0x10 + uec_info->uf_info.ucc_num) | 1147 | utbipar |= (0x10 + uec_info->uf_info.ucc_num) |
1102 | << UTBIPAR_PHY_ADDRESS_SHIFT; | 1148 | << UTBIPAR_PHY_ADDRESS_SHIFT; |
1103 | } | 1149 | } |
1104 | 1150 | ||
1105 | out_be32(&uec_regs->utbipar, utbipar); | 1151 | out_be32(&uec_regs->utbipar, utbipar); |
1106 | 1152 | ||
1107 | /* Allocate Tx BDs */ | 1153 | /* Allocate Tx BDs */ |
1108 | length = ((uec_info->tx_bd_ring_len * SIZEOFBD) / | 1154 | length = ((uec_info->tx_bd_ring_len * SIZEOFBD) / |
1109 | UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) * | 1155 | UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) * |
1110 | UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; | 1156 | UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; |
1111 | if ((uec_info->tx_bd_ring_len * SIZEOFBD) % | 1157 | if ((uec_info->tx_bd_ring_len * SIZEOFBD) % |
1112 | UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) { | 1158 | UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) { |
1113 | length += UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; | 1159 | length += UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; |
1114 | } | 1160 | } |
1115 | 1161 | ||
1116 | align = UEC_TX_BD_RING_ALIGNMENT; | 1162 | align = UEC_TX_BD_RING_ALIGNMENT; |
1117 | uec->tx_bd_ring_offset = (u32)malloc((u32)(length + align)); | 1163 | uec->tx_bd_ring_offset = (u32)malloc((u32)(length + align)); |
1118 | if (uec->tx_bd_ring_offset != 0) { | 1164 | if (uec->tx_bd_ring_offset != 0) { |
1119 | uec->p_tx_bd_ring = (u8 *)((uec->tx_bd_ring_offset + align) | 1165 | uec->p_tx_bd_ring = (u8 *)((uec->tx_bd_ring_offset + align) |
1120 | & ~(align - 1)); | 1166 | & ~(align - 1)); |
1121 | } | 1167 | } |
1122 | 1168 | ||
1123 | /* Zero all of Tx BDs */ | 1169 | /* Zero all of Tx BDs */ |
1124 | memset((void *)(uec->tx_bd_ring_offset), 0, length + align); | 1170 | memset((void *)(uec->tx_bd_ring_offset), 0, length + align); |
1125 | 1171 | ||
1126 | /* Allocate Rx BDs */ | 1172 | /* Allocate Rx BDs */ |
1127 | length = uec_info->rx_bd_ring_len * SIZEOFBD; | 1173 | length = uec_info->rx_bd_ring_len * SIZEOFBD; |
1128 | align = UEC_RX_BD_RING_ALIGNMENT; | 1174 | align = UEC_RX_BD_RING_ALIGNMENT; |
1129 | uec->rx_bd_ring_offset = (u32)(malloc((u32)(length + align))); | 1175 | uec->rx_bd_ring_offset = (u32)(malloc((u32)(length + align))); |
1130 | if (uec->rx_bd_ring_offset != 0) { | 1176 | if (uec->rx_bd_ring_offset != 0) { |
1131 | uec->p_rx_bd_ring = (u8 *)((uec->rx_bd_ring_offset + align) | 1177 | uec->p_rx_bd_ring = (u8 *)((uec->rx_bd_ring_offset + align) |
1132 | & ~(align - 1)); | 1178 | & ~(align - 1)); |
1133 | } | 1179 | } |
1134 | 1180 | ||
1135 | /* Zero all of Rx BDs */ | 1181 | /* Zero all of Rx BDs */ |
1136 | memset((void *)(uec->rx_bd_ring_offset), 0, length + align); | 1182 | memset((void *)(uec->rx_bd_ring_offset), 0, length + align); |
1137 | 1183 | ||
1138 | /* Allocate Rx buffer */ | 1184 | /* Allocate Rx buffer */ |
1139 | length = uec_info->rx_bd_ring_len * MAX_RXBUF_LEN; | 1185 | length = uec_info->rx_bd_ring_len * MAX_RXBUF_LEN; |
1140 | align = UEC_RX_DATA_BUF_ALIGNMENT; | 1186 | align = UEC_RX_DATA_BUF_ALIGNMENT; |
1141 | uec->rx_buf_offset = (u32)malloc(length + align); | 1187 | uec->rx_buf_offset = (u32)malloc(length + align); |
1142 | if (uec->rx_buf_offset != 0) { | 1188 | if (uec->rx_buf_offset != 0) { |
1143 | uec->p_rx_buf = (u8 *)((uec->rx_buf_offset + align) | 1189 | uec->p_rx_buf = (u8 *)((uec->rx_buf_offset + align) |
1144 | & ~(align - 1)); | 1190 | & ~(align - 1)); |
1145 | } | 1191 | } |
1146 | 1192 | ||
1147 | /* Zero all of the Rx buffer */ | 1193 | /* Zero all of the Rx buffer */ |
1148 | memset((void *)(uec->rx_buf_offset), 0, length + align); | 1194 | memset((void *)(uec->rx_buf_offset), 0, length + align); |
1149 | 1195 | ||
1150 | /* Init TxBD ring */ | 1196 | /* Init TxBD ring */ |
1151 | bd = (qe_bd_t *)uec->p_tx_bd_ring; | 1197 | bd = (qe_bd_t *)uec->p_tx_bd_ring; |
1152 | uec->txBd = bd; | 1198 | uec->txBd = bd; |
1153 | 1199 | ||
1154 | for (i = 0; i < uec_info->tx_bd_ring_len; i++) { | 1200 | for (i = 0; i < uec_info->tx_bd_ring_len; i++) { |
1155 | BD_DATA_CLEAR(bd); | 1201 | BD_DATA_CLEAR(bd); |
1156 | BD_STATUS_SET(bd, 0); | 1202 | BD_STATUS_SET(bd, 0); |
1157 | BD_LENGTH_SET(bd, 0); | 1203 | BD_LENGTH_SET(bd, 0); |
1158 | bd ++; | 1204 | bd ++; |
1159 | } | 1205 | } |
1160 | BD_STATUS_SET((--bd), TxBD_WRAP); | 1206 | BD_STATUS_SET((--bd), TxBD_WRAP); |
1161 | 1207 | ||
1162 | /* Init RxBD ring */ | 1208 | /* Init RxBD ring */ |
1163 | bd = (qe_bd_t *)uec->p_rx_bd_ring; | 1209 | bd = (qe_bd_t *)uec->p_rx_bd_ring; |
1164 | uec->rxBd = bd; | 1210 | uec->rxBd = bd; |
1165 | buf = uec->p_rx_buf; | 1211 | buf = uec->p_rx_buf; |
1166 | for (i = 0; i < uec_info->rx_bd_ring_len; i++) { | 1212 | for (i = 0; i < uec_info->rx_bd_ring_len; i++) { |
1167 | BD_DATA_SET(bd, buf); | 1213 | BD_DATA_SET(bd, buf); |
1168 | BD_LENGTH_SET(bd, 0); | 1214 | BD_LENGTH_SET(bd, 0); |
1169 | BD_STATUS_SET(bd, RxBD_EMPTY); | 1215 | BD_STATUS_SET(bd, RxBD_EMPTY); |
1170 | buf += MAX_RXBUF_LEN; | 1216 | buf += MAX_RXBUF_LEN; |
1171 | bd ++; | 1217 | bd ++; |
1172 | } | 1218 | } |
1173 | BD_STATUS_SET((--bd), RxBD_WRAP | RxBD_EMPTY); | 1219 | BD_STATUS_SET((--bd), RxBD_WRAP | RxBD_EMPTY); |
1174 | 1220 | ||
1175 | /* Init global Tx parameter RAM */ | 1221 | /* Init global Tx parameter RAM */ |
1176 | uec_init_tx_parameter(uec, num_threads_tx); | 1222 | uec_init_tx_parameter(uec, num_threads_tx); |
1177 | 1223 | ||
1178 | /* Init global Rx parameter RAM */ | 1224 | /* Init global Rx parameter RAM */ |
1179 | uec_init_rx_parameter(uec, num_threads_rx); | 1225 | uec_init_rx_parameter(uec, num_threads_rx); |
1180 | 1226 | ||
1181 | /* Init ethernet Tx and Rx parameter command */ | 1227 | /* Init ethernet Tx and Rx parameter command */ |
1182 | if (uec_issue_init_enet_rxtx_cmd(uec, num_threads_tx, | 1228 | if (uec_issue_init_enet_rxtx_cmd(uec, num_threads_tx, |
1183 | num_threads_rx)) { | 1229 | num_threads_rx)) { |
1184 | printf("%s issue init enet cmd failed\n", __FUNCTION__); | 1230 | printf("%s issue init enet cmd failed\n", __FUNCTION__); |
1185 | return -ENOMEM; | 1231 | return -ENOMEM; |
1186 | } | 1232 | } |
1187 | 1233 | ||
1188 | return 0; | 1234 | return 0; |
1189 | } | 1235 | } |
1190 | 1236 | ||
1191 | static int uec_init(struct eth_device* dev, bd_t *bd) | 1237 | static int uec_init(struct eth_device* dev, bd_t *bd) |
1192 | { | 1238 | { |
1193 | uec_private_t *uec; | 1239 | uec_private_t *uec; |
1194 | int err, i; | 1240 | int err, i; |
1195 | struct phy_info *curphy; | 1241 | struct phy_info *curphy; |
1196 | 1242 | ||
1197 | uec = (uec_private_t *)dev->priv; | 1243 | uec = (uec_private_t *)dev->priv; |
1198 | 1244 | ||
1199 | if (uec->the_first_run == 0) { | 1245 | if (uec->the_first_run == 0) { |
1200 | err = init_phy(dev); | 1246 | err = init_phy(dev); |
1201 | if (err) { | 1247 | if (err) { |
1202 | printf("%s: Cannot initialize PHY, aborting.\n", | 1248 | printf("%s: Cannot initialize PHY, aborting.\n", |
1203 | dev->name); | 1249 | dev->name); |
1204 | return err; | 1250 | return err; |
1205 | } | 1251 | } |
1206 | 1252 | ||
1207 | curphy = uec->mii_info->phyinfo; | 1253 | curphy = uec->mii_info->phyinfo; |
1208 | 1254 | ||
1209 | if (curphy->config_aneg) { | 1255 | if (curphy->config_aneg) { |
1210 | err = curphy->config_aneg(uec->mii_info); | 1256 | err = curphy->config_aneg(uec->mii_info); |
1211 | if (err) { | 1257 | if (err) { |
1212 | printf("%s: Can't negotiate PHY\n", dev->name); | 1258 | printf("%s: Can't negotiate PHY\n", dev->name); |
1213 | return err; | 1259 | return err; |
1214 | } | 1260 | } |
1215 | } | 1261 | } |
1216 | 1262 | ||
1217 | /* Give PHYs up to 5 sec to report a link */ | 1263 | /* Give PHYs up to 5 sec to report a link */ |
1218 | i = 50; | 1264 | i = 50; |
1219 | do { | 1265 | do { |
1220 | err = curphy->read_status(uec->mii_info); | 1266 | err = curphy->read_status(uec->mii_info); |
1221 | udelay(100000); | 1267 | udelay(100000); |
1222 | } while (((i-- > 0) && !uec->mii_info->link) || err); | 1268 | } while (((i-- > 0) && !uec->mii_info->link) || err); |
1223 | 1269 | ||
1224 | if (err || i <= 0) | 1270 | if (err || i <= 0) |
1225 | printf("warning: %s: timeout on PHY link\n", dev->name); | 1271 | printf("warning: %s: timeout on PHY link\n", dev->name); |
1226 | 1272 | ||
1227 | uec->the_first_run = 1; | 1273 | uec->the_first_run = 1; |
1228 | } | 1274 | } |
1229 | 1275 | ||
1230 | /* Set up the MAC address */ | 1276 | /* Set up the MAC address */ |
1231 | if (dev->enetaddr[0] & 0x01) { | 1277 | if (dev->enetaddr[0] & 0x01) { |
1232 | printf("%s: MacAddress is multcast address\n", | 1278 | printf("%s: MacAddress is multcast address\n", |
1233 | __FUNCTION__); | 1279 | __FUNCTION__); |
1234 | return -1; | 1280 | return -1; |
1235 | } | 1281 | } |
1236 | uec_set_mac_address(uec, dev->enetaddr); | 1282 | uec_set_mac_address(uec, dev->enetaddr); |
1237 | 1283 | ||
1238 | 1284 | ||
1239 | err = uec_open(uec, COMM_DIR_RX_AND_TX); | 1285 | err = uec_open(uec, COMM_DIR_RX_AND_TX); |
1240 | if (err) { | 1286 | if (err) { |
1241 | printf("%s: cannot enable UEC device\n", dev->name); | 1287 | printf("%s: cannot enable UEC device\n", dev->name); |
1242 | return -1; | 1288 | return -1; |
1243 | } | 1289 | } |
1244 | 1290 | ||
1245 | phy_change(dev); | 1291 | phy_change(dev); |
1246 | 1292 | ||
1247 | return (uec->mii_info->link ? 0 : -1); | 1293 | return (uec->mii_info->link ? 0 : -1); |
1248 | } | 1294 | } |
1249 | 1295 | ||
1250 | static void uec_halt(struct eth_device* dev) | 1296 | static void uec_halt(struct eth_device* dev) |
1251 | { | 1297 | { |
1252 | uec_private_t *uec = (uec_private_t *)dev->priv; | 1298 | uec_private_t *uec = (uec_private_t *)dev->priv; |
1253 | uec_stop(uec, COMM_DIR_RX_AND_TX); | 1299 | uec_stop(uec, COMM_DIR_RX_AND_TX); |
1254 | } | 1300 | } |
1255 | 1301 | ||
1256 | static int uec_send(struct eth_device* dev, volatile void *buf, int len) | 1302 | static int uec_send(struct eth_device* dev, volatile void *buf, int len) |
1257 | { | 1303 | { |
1258 | uec_private_t *uec; | 1304 | uec_private_t *uec; |
1259 | ucc_fast_private_t *uccf; | 1305 | ucc_fast_private_t *uccf; |
1260 | volatile qe_bd_t *bd; | 1306 | volatile qe_bd_t *bd; |
1261 | u16 status; | 1307 | u16 status; |
1262 | int i; | 1308 | int i; |
1263 | int result = 0; | 1309 | int result = 0; |
1264 | 1310 | ||
1265 | uec = (uec_private_t *)dev->priv; | 1311 | uec = (uec_private_t *)dev->priv; |
1266 | uccf = uec->uccf; | 1312 | uccf = uec->uccf; |
1267 | bd = uec->txBd; | 1313 | bd = uec->txBd; |
1268 | 1314 | ||
1269 | /* Find an empty TxBD */ | 1315 | /* Find an empty TxBD */ |
1270 | for (i = 0; bd->status & TxBD_READY; i++) { | 1316 | for (i = 0; bd->status & TxBD_READY; i++) { |
1271 | if (i > 0x100000) { | 1317 | if (i > 0x100000) { |
1272 | printf("%s: tx buffer not ready\n", dev->name); | 1318 | printf("%s: tx buffer not ready\n", dev->name); |
1273 | return result; | 1319 | return result; |
1274 | } | 1320 | } |
1275 | } | 1321 | } |
1276 | 1322 | ||
1277 | /* Init TxBD */ | 1323 | /* Init TxBD */ |
1278 | BD_DATA_SET(bd, buf); | 1324 | BD_DATA_SET(bd, buf); |
1279 | BD_LENGTH_SET(bd, len); | 1325 | BD_LENGTH_SET(bd, len); |
1280 | status = bd->status; | 1326 | status = bd->status; |
1281 | status &= BD_WRAP; | 1327 | status &= BD_WRAP; |
1282 | status |= (TxBD_READY | TxBD_LAST); | 1328 | status |= (TxBD_READY | TxBD_LAST); |
1283 | BD_STATUS_SET(bd, status); | 1329 | BD_STATUS_SET(bd, status); |
1284 | 1330 | ||
1285 | /* Tell UCC to transmit the buffer */ | 1331 | /* Tell UCC to transmit the buffer */ |
1286 | ucc_fast_transmit_on_demand(uccf); | 1332 | ucc_fast_transmit_on_demand(uccf); |
1287 | 1333 | ||
1288 | /* Wait for buffer to be transmitted */ | 1334 | /* Wait for buffer to be transmitted */ |
1289 | for (i = 0; bd->status & TxBD_READY; i++) { | 1335 | for (i = 0; bd->status & TxBD_READY; i++) { |
1290 | if (i > 0x100000) { | 1336 | if (i > 0x100000) { |
1291 | printf("%s: tx error\n", dev->name); | 1337 | printf("%s: tx error\n", dev->name); |
1292 | return result; | 1338 | return result; |
1293 | } | 1339 | } |
1294 | } | 1340 | } |
1295 | 1341 | ||
1296 | /* Ok, the buffer be transimitted */ | 1342 | /* Ok, the buffer be transimitted */ |
1297 | BD_ADVANCE(bd, status, uec->p_tx_bd_ring); | 1343 | BD_ADVANCE(bd, status, uec->p_tx_bd_ring); |
1298 | uec->txBd = bd; | 1344 | uec->txBd = bd; |
1299 | result = 1; | 1345 | result = 1; |
1300 | 1346 | ||
1301 | return result; | 1347 | return result; |
1302 | } | 1348 | } |
1303 | 1349 | ||
1304 | static int uec_recv(struct eth_device* dev) | 1350 | static int uec_recv(struct eth_device* dev) |
1305 | { | 1351 | { |
1306 | uec_private_t *uec = dev->priv; | 1352 | uec_private_t *uec = dev->priv; |
1307 | volatile qe_bd_t *bd; | 1353 | volatile qe_bd_t *bd; |
1308 | u16 status; | 1354 | u16 status; |
1309 | u16 len; | 1355 | u16 len; |
1310 | u8 *data; | 1356 | u8 *data; |
1311 | 1357 | ||
1312 | bd = uec->rxBd; | 1358 | bd = uec->rxBd; |
1313 | status = bd->status; | 1359 | status = bd->status; |
1314 | 1360 | ||
1315 | while (!(status & RxBD_EMPTY)) { | 1361 | while (!(status & RxBD_EMPTY)) { |
1316 | if (!(status & RxBD_ERROR)) { | 1362 | if (!(status & RxBD_ERROR)) { |
1317 | data = BD_DATA(bd); | 1363 | data = BD_DATA(bd); |
1318 | len = BD_LENGTH(bd); | 1364 | len = BD_LENGTH(bd); |
1319 | NetReceive(data, len); | 1365 | NetReceive(data, len); |
1320 | } else { | 1366 | } else { |
1321 | printf("%s: Rx error\n", dev->name); | 1367 | printf("%s: Rx error\n", dev->name); |
1322 | } | 1368 | } |
1323 | status &= BD_CLEAN; | 1369 | status &= BD_CLEAN; |
1324 | BD_LENGTH_SET(bd, 0); | 1370 | BD_LENGTH_SET(bd, 0); |
1325 | BD_STATUS_SET(bd, status | RxBD_EMPTY); | 1371 | BD_STATUS_SET(bd, status | RxBD_EMPTY); |
1326 | BD_ADVANCE(bd, status, uec->p_rx_bd_ring); | 1372 | BD_ADVANCE(bd, status, uec->p_rx_bd_ring); |
1327 | status = bd->status; | 1373 | status = bd->status; |
1328 | } | 1374 | } |
1329 | uec->rxBd = bd; | 1375 | uec->rxBd = bd; |
1330 | 1376 | ||
1331 | return 1; | 1377 | return 1; |
1332 | } | 1378 | } |
1333 | 1379 | ||
1334 | int uec_initialize(int index) | 1380 | int uec_initialize(int index) |
1335 | { | 1381 | { |
1336 | struct eth_device *dev; | 1382 | struct eth_device *dev; |
1337 | int i; | 1383 | int i; |
1338 | uec_private_t *uec; | 1384 | uec_private_t *uec; |
1339 | uec_info_t *uec_info; | 1385 | uec_info_t *uec_info; |
1340 | int err; | 1386 | int err; |
1341 | 1387 | ||
1342 | dev = (struct eth_device *)malloc(sizeof(struct eth_device)); | 1388 | dev = (struct eth_device *)malloc(sizeof(struct eth_device)); |
1343 | if (!dev) | 1389 | if (!dev) |
1344 | return 0; | 1390 | return 0; |
1345 | memset(dev, 0, sizeof(struct eth_device)); | 1391 | memset(dev, 0, sizeof(struct eth_device)); |
1346 | 1392 | ||
1347 | /* Allocate the UEC private struct */ | 1393 | /* Allocate the UEC private struct */ |
1348 | uec = (uec_private_t *)malloc(sizeof(uec_private_t)); | 1394 | uec = (uec_private_t *)malloc(sizeof(uec_private_t)); |
1349 | if (!uec) { | 1395 | if (!uec) { |
1350 | return -ENOMEM; | 1396 | return -ENOMEM; |
1351 | } | 1397 | } |
1352 | memset(uec, 0, sizeof(uec_private_t)); | 1398 | memset(uec, 0, sizeof(uec_private_t)); |
1353 | 1399 | ||
1354 | /* Init UEC private struct, they come from board.h */ | 1400 | /* Init UEC private struct, they come from board.h */ |
1355 | uec_info = NULL; | 1401 | uec_info = NULL; |
1356 | if (index == 0) { | 1402 | if (index == 0) { |
1357 | #ifdef CONFIG_UEC_ETH1 | 1403 | #ifdef CONFIG_UEC_ETH1 |
1358 | uec_info = ð1_uec_info; | 1404 | uec_info = ð1_uec_info; |
1359 | #endif | 1405 | #endif |
1360 | } else if (index == 1) { | 1406 | } else if (index == 1) { |
1361 | #ifdef CONFIG_UEC_ETH2 | 1407 | #ifdef CONFIG_UEC_ETH2 |
1362 | uec_info = ð2_uec_info; | 1408 | uec_info = ð2_uec_info; |
1363 | #endif | 1409 | #endif |
1364 | } else if (index == 2) { | 1410 | } else if (index == 2) { |
1365 | #ifdef CONFIG_UEC_ETH3 | 1411 | #ifdef CONFIG_UEC_ETH3 |
1366 | uec_info = ð3_uec_info; | 1412 | uec_info = ð3_uec_info; |
1367 | #endif | 1413 | #endif |
1368 | } else if (index == 3) { | 1414 | } else if (index == 3) { |
1369 | #ifdef CONFIG_UEC_ETH4 | 1415 | #ifdef CONFIG_UEC_ETH4 |
1370 | uec_info = ð4_uec_info; | 1416 | uec_info = ð4_uec_info; |
1371 | #endif | 1417 | #endif |
1372 | } else { | 1418 | } else { |
1373 | printf("%s: index is illegal.\n", __FUNCTION__); | 1419 | printf("%s: index is illegal.\n", __FUNCTION__); |
1374 | return -EINVAL; | 1420 | return -EINVAL; |
1375 | } | 1421 | } |
1376 | 1422 | ||
1377 | devlist[index] = dev; | 1423 | devlist[index] = dev; |
1378 | 1424 | ||
1379 | uec->uec_info = uec_info; | 1425 | uec->uec_info = uec_info; |
1380 | 1426 | ||
1381 | sprintf(dev->name, "FSL UEC%d", index); | 1427 | sprintf(dev->name, "FSL UEC%d", index); |
1382 | dev->iobase = 0; | 1428 | dev->iobase = 0; |
1383 | dev->priv = (void *)uec; | 1429 | dev->priv = (void *)uec; |
1384 | dev->init = uec_init; | 1430 | dev->init = uec_init; |
1385 | dev->halt = uec_halt; | 1431 | dev->halt = uec_halt; |
1386 | dev->send = uec_send; | 1432 | dev->send = uec_send; |
1387 | dev->recv = uec_recv; | 1433 | dev->recv = uec_recv; |
1388 | 1434 | ||
1389 | /* Clear the ethnet address */ | 1435 | /* Clear the ethnet address */ |
1390 | for (i = 0; i < 6; i++) | 1436 | for (i = 0; i < 6; i++) |
1391 | dev->enetaddr[i] = 0; | 1437 | dev->enetaddr[i] = 0; |
1392 | 1438 | ||
1393 | eth_register(dev); | 1439 | eth_register(dev); |
1394 | 1440 | ||
1395 | err = uec_startup(uec); | 1441 | err = uec_startup(uec); |
1396 | if (err) { | 1442 | if (err) { |
1397 | printf("%s: Cannot configure net device, aborting.",dev->name); | 1443 | printf("%s: Cannot configure net device, aborting.",dev->name); |
1398 | return err; | 1444 | return err; |
1399 | } | 1445 | } |
1400 | 1446 | ||
1401 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \ | 1447 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \ |
1402 | && !defined(BITBANGMII) | 1448 | && !defined(BITBANGMII) |
1403 | miiphy_register(dev->name, uec_miiphy_read, uec_miiphy_write); | 1449 | miiphy_register(dev->name, uec_miiphy_read, uec_miiphy_write); |
1404 | #endif | 1450 | #endif |
1405 | 1451 | ||
1406 | return 1; | 1452 | return 1; |
1407 | } | 1453 | } |
1408 | 1454 |
include/asm-ppc/u-boot.h
1 | /* | 1 | /* |
2 | * (C) Copyright 2000 - 2002 | 2 | * (C) Copyright 2000 - 2002 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
7 | * published by the Free Software Foundation; either version 2 of | 7 | * published by the Free Software Foundation; either version 2 of |
8 | * the License, or (at your option) any later version. | 8 | * the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
18 | * MA 02111-1307 USA | 18 | * MA 02111-1307 USA |
19 | * | 19 | * |
20 | ******************************************************************** | 20 | ******************************************************************** |
21 | * NOTE: This header file defines an interface to U-Boot. Including | 21 | * NOTE: This header file defines an interface to U-Boot. Including |
22 | * this (unmodified) header file in another file is considered normal | 22 | * this (unmodified) header file in another file is considered normal |
23 | * use of U-Boot, and does *not* fall under the heading of "derived | 23 | * use of U-Boot, and does *not* fall under the heading of "derived |
24 | * work". | 24 | * work". |
25 | ******************************************************************** | 25 | ******************************************************************** |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef __U_BOOT_H__ | 28 | #ifndef __U_BOOT_H__ |
29 | #define __U_BOOT_H__ | 29 | #define __U_BOOT_H__ |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * Board information passed to Linux kernel from U-Boot | 32 | * Board information passed to Linux kernel from U-Boot |
33 | * | 33 | * |
34 | * include/asm-ppc/u-boot.h | 34 | * include/asm-ppc/u-boot.h |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #ifndef __ASSEMBLY__ | 37 | #ifndef __ASSEMBLY__ |
38 | 38 | ||
39 | typedef struct bd_info { | 39 | typedef struct bd_info { |
40 | unsigned long bi_memstart; /* start of DRAM memory */ | 40 | unsigned long bi_memstart; /* start of DRAM memory */ |
41 | phys_size_t bi_memsize; /* size of DRAM memory in bytes */ | 41 | phys_size_t bi_memsize; /* size of DRAM memory in bytes */ |
42 | unsigned long bi_flashstart; /* start of FLASH memory */ | 42 | unsigned long bi_flashstart; /* start of FLASH memory */ |
43 | unsigned long bi_flashsize; /* size of FLASH memory */ | 43 | unsigned long bi_flashsize; /* size of FLASH memory */ |
44 | unsigned long bi_flashoffset; /* reserved area for startup monitor */ | 44 | unsigned long bi_flashoffset; /* reserved area for startup monitor */ |
45 | unsigned long bi_sramstart; /* start of SRAM memory */ | 45 | unsigned long bi_sramstart; /* start of SRAM memory */ |
46 | unsigned long bi_sramsize; /* size of SRAM memory */ | 46 | unsigned long bi_sramsize; /* size of SRAM memory */ |
47 | #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || defined(CONFIG_8260) \ | 47 | #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || defined(CONFIG_8260) \ |
48 | || defined(CONFIG_E500) || defined(CONFIG_MPC86xx) | 48 | || defined(CONFIG_E500) || defined(CONFIG_MPC86xx) |
49 | unsigned long bi_immr_base; /* base of IMMR register */ | 49 | unsigned long bi_immr_base; /* base of IMMR register */ |
50 | #endif | 50 | #endif |
51 | #if defined(CONFIG_MPC5xxx) | 51 | #if defined(CONFIG_MPC5xxx) |
52 | unsigned long bi_mbar_base; /* base of internal registers */ | 52 | unsigned long bi_mbar_base; /* base of internal registers */ |
53 | #endif | 53 | #endif |
54 | #if defined(CONFIG_MPC83XX) | 54 | #if defined(CONFIG_MPC83XX) |
55 | unsigned long bi_immrbar; | 55 | unsigned long bi_immrbar; |
56 | #endif | 56 | #endif |
57 | #if defined(CONFIG_MPC8220) | 57 | #if defined(CONFIG_MPC8220) |
58 | unsigned long bi_mbar_base; /* base of internal registers */ | 58 | unsigned long bi_mbar_base; /* base of internal registers */ |
59 | unsigned long bi_inpfreq; /* Input Freq, In MHz */ | 59 | unsigned long bi_inpfreq; /* Input Freq, In MHz */ |
60 | unsigned long bi_pcifreq; /* PCI Freq, in MHz */ | 60 | unsigned long bi_pcifreq; /* PCI Freq, in MHz */ |
61 | unsigned long bi_pevfreq; /* PEV Freq, in MHz */ | 61 | unsigned long bi_pevfreq; /* PEV Freq, in MHz */ |
62 | unsigned long bi_flbfreq; /* Flexbus Freq, in MHz */ | 62 | unsigned long bi_flbfreq; /* Flexbus Freq, in MHz */ |
63 | unsigned long bi_vcofreq; /* VCO Freq, in MHz */ | 63 | unsigned long bi_vcofreq; /* VCO Freq, in MHz */ |
64 | #endif | 64 | #endif |
65 | unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */ | 65 | unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */ |
66 | unsigned long bi_ip_addr; /* IP Address */ | 66 | unsigned long bi_ip_addr; /* IP Address */ |
67 | unsigned char bi_enetaddr[6]; /* Ethernet adress */ | 67 | unsigned char bi_enetaddr[6]; /* Ethernet adress */ |
68 | unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ | 68 | unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ |
69 | unsigned long bi_intfreq; /* Internal Freq, in MHz */ | 69 | unsigned long bi_intfreq; /* Internal Freq, in MHz */ |
70 | unsigned long bi_busfreq; /* Bus Freq, in MHz */ | 70 | unsigned long bi_busfreq; /* Bus Freq, in MHz */ |
71 | #if defined(CONFIG_CPM2) | 71 | #if defined(CONFIG_CPM2) |
72 | unsigned long bi_cpmfreq; /* CPM_CLK Freq, in MHz */ | 72 | unsigned long bi_cpmfreq; /* CPM_CLK Freq, in MHz */ |
73 | unsigned long bi_brgfreq; /* BRG_CLK Freq, in MHz */ | 73 | unsigned long bi_brgfreq; /* BRG_CLK Freq, in MHz */ |
74 | unsigned long bi_sccfreq; /* SCC_CLK Freq, in MHz */ | 74 | unsigned long bi_sccfreq; /* SCC_CLK Freq, in MHz */ |
75 | unsigned long bi_vco; /* VCO Out from PLL, in MHz */ | 75 | unsigned long bi_vco; /* VCO Out from PLL, in MHz */ |
76 | #endif | 76 | #endif |
77 | #if defined(CONFIG_MPC512X) | 77 | #if defined(CONFIG_MPC512X) |
78 | unsigned long bi_ipsfreq; /* IPS Bus Freq, in MHz */ | 78 | unsigned long bi_ipsfreq; /* IPS Bus Freq, in MHz */ |
79 | #endif /* CONFIG_MPC512X */ | 79 | #endif /* CONFIG_MPC512X */ |
80 | #if defined(CONFIG_MPC5xxx) | 80 | #if defined(CONFIG_MPC5xxx) |
81 | unsigned long bi_ipbfreq; /* IPB Bus Freq, in MHz */ | 81 | unsigned long bi_ipbfreq; /* IPB Bus Freq, in MHz */ |
82 | unsigned long bi_pcifreq; /* PCI Bus Freq, in MHz */ | 82 | unsigned long bi_pcifreq; /* PCI Bus Freq, in MHz */ |
83 | #endif | 83 | #endif |
84 | unsigned long bi_baudrate; /* Console Baudrate */ | 84 | unsigned long bi_baudrate; /* Console Baudrate */ |
85 | #if defined(CONFIG_405) || \ | 85 | #if defined(CONFIG_405) || \ |
86 | defined(CONFIG_405GP) || \ | 86 | defined(CONFIG_405GP) || \ |
87 | defined(CONFIG_405CR) || \ | 87 | defined(CONFIG_405CR) || \ |
88 | defined(CONFIG_405EP) || \ | 88 | defined(CONFIG_405EP) || \ |
89 | defined(CONFIG_405EZ) || \ | 89 | defined(CONFIG_405EZ) || \ |
90 | defined(CONFIG_405EX) || \ | 90 | defined(CONFIG_405EX) || \ |
91 | defined(CONFIG_440) | 91 | defined(CONFIG_440) |
92 | unsigned char bi_s_version[4]; /* Version of this structure */ | 92 | unsigned char bi_s_version[4]; /* Version of this structure */ |
93 | unsigned char bi_r_version[32]; /* Version of the ROM (AMCC) */ | 93 | unsigned char bi_r_version[32]; /* Version of the ROM (AMCC) */ |
94 | unsigned int bi_procfreq; /* CPU (Internal) Freq, in Hz */ | 94 | unsigned int bi_procfreq; /* CPU (Internal) Freq, in Hz */ |
95 | unsigned int bi_plb_busfreq; /* PLB Bus speed, in Hz */ | 95 | unsigned int bi_plb_busfreq; /* PLB Bus speed, in Hz */ |
96 | unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */ | 96 | unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */ |
97 | unsigned char bi_pci_enetaddr[6]; /* PCI Ethernet MAC address */ | 97 | unsigned char bi_pci_enetaddr[6]; /* PCI Ethernet MAC address */ |
98 | #endif | 98 | #endif |
99 | #if defined(CONFIG_HYMOD) | 99 | #if defined(CONFIG_HYMOD) |
100 | hymod_conf_t bi_hymod_conf; /* hymod configuration information */ | 100 | hymod_conf_t bi_hymod_conf; /* hymod configuration information */ |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | #ifdef CONFIG_HAS_ETH1 | 103 | #ifdef CONFIG_HAS_ETH1 |
104 | /* second onboard ethernet port */ | 104 | /* second onboard ethernet port */ |
105 | unsigned char bi_enet1addr[6]; | 105 | unsigned char bi_enet1addr[6]; |
106 | #endif | 106 | #endif |
107 | #ifdef CONFIG_HAS_ETH2 | 107 | #ifdef CONFIG_HAS_ETH2 |
108 | /* third onboard ethernet port */ | 108 | /* third onboard ethernet port */ |
109 | unsigned char bi_enet2addr[6]; | 109 | unsigned char bi_enet2addr[6]; |
110 | #endif | 110 | #endif |
111 | #ifdef CONFIG_HAS_ETH3 | 111 | #ifdef CONFIG_HAS_ETH3 |
112 | unsigned char bi_enet3addr[6]; | 112 | unsigned char bi_enet3addr[6]; |
113 | #endif | 113 | #endif |
114 | #ifdef CONFIG_HAS_ETH4 | ||
115 | unsigned char bi_enet4addr[6]; | ||
116 | #endif | ||
117 | #ifdef CONFIG_HAS_ETH5 | ||
118 | unsigned char bi_enet5addr[6]; | ||
119 | #endif | ||
114 | 120 | ||
115 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ | 121 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ |
116 | defined(CONFIG_405EZ) || defined(CONFIG_440GX) || \ | 122 | defined(CONFIG_405EZ) || defined(CONFIG_440GX) || \ |
117 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ | 123 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ |
118 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \ | 124 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \ |
119 | defined(CONFIG_460EX) || defined(CONFIG_460GT) | 125 | defined(CONFIG_460EX) || defined(CONFIG_460GT) |
120 | unsigned int bi_opbfreq; /* OPB clock in Hz */ | 126 | unsigned int bi_opbfreq; /* OPB clock in Hz */ |
121 | int bi_iic_fast[2]; /* Use fast i2c mode */ | 127 | int bi_iic_fast[2]; /* Use fast i2c mode */ |
122 | #endif | 128 | #endif |
123 | #if defined(CONFIG_NX823) | 129 | #if defined(CONFIG_NX823) |
124 | unsigned char bi_sernum[8]; | 130 | unsigned char bi_sernum[8]; |
125 | #endif | 131 | #endif |
126 | #if defined(CONFIG_4xx) | 132 | #if defined(CONFIG_4xx) |
127 | #if defined(CONFIG_440GX) || \ | 133 | #if defined(CONFIG_440GX) || \ |
128 | defined(CONFIG_460EX) || defined(CONFIG_460GT) | 134 | defined(CONFIG_460EX) || defined(CONFIG_460GT) |
129 | int bi_phynum[4]; /* Determines phy mapping */ | 135 | int bi_phynum[4]; /* Determines phy mapping */ |
130 | int bi_phymode[4]; /* Determines phy mode */ | 136 | int bi_phymode[4]; /* Determines phy mode */ |
131 | #elif defined(CONFIG_405EP) || defined(CONFIG_440) | 137 | #elif defined(CONFIG_405EP) || defined(CONFIG_440) |
132 | int bi_phynum[2]; /* Determines phy mapping */ | 138 | int bi_phynum[2]; /* Determines phy mapping */ |
133 | int bi_phymode[2]; /* Determines phy mode */ | 139 | int bi_phymode[2]; /* Determines phy mode */ |
134 | #else | 140 | #else |
135 | int bi_phynum[1]; /* Determines phy mapping */ | 141 | int bi_phynum[1]; /* Determines phy mapping */ |
136 | int bi_phymode[1]; /* Determines phy mode */ | 142 | int bi_phymode[1]; /* Determines phy mode */ |
137 | #endif | 143 | #endif |
138 | #endif /* defined(CONFIG_4xx) */ | 144 | #endif /* defined(CONFIG_4xx) */ |
139 | } bd_t; | 145 | } bd_t; |
140 | 146 | ||
141 | #endif /* __ASSEMBLY__ */ | 147 | #endif /* __ASSEMBLY__ */ |
142 | #endif /* __U_BOOT_H__ */ | 148 | #endif /* __U_BOOT_H__ */ |
143 | 149 |
lib_ppc/board.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2000-2006 | 2 | * (C) Copyright 2000-2006 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * See file CREDITS for list of people who contributed to this | 5 | * See file CREDITS for list of people who contributed to this |
6 | * project. | 6 | * project. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of | 10 | * published by the Free Software Foundation; either version 2 of |
11 | * the License, or (at your option) any later version. | 11 | * the License, or (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | * MA 02111-1307 USA | 21 | * MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <common.h> | 24 | #include <common.h> |
25 | #include <watchdog.h> | 25 | #include <watchdog.h> |
26 | #include <command.h> | 26 | #include <command.h> |
27 | #include <malloc.h> | 27 | #include <malloc.h> |
28 | #include <devices.h> | 28 | #include <devices.h> |
29 | #ifdef CONFIG_8xx | 29 | #ifdef CONFIG_8xx |
30 | #include <mpc8xx.h> | 30 | #include <mpc8xx.h> |
31 | #endif | 31 | #endif |
32 | #ifdef CONFIG_5xx | 32 | #ifdef CONFIG_5xx |
33 | #include <mpc5xx.h> | 33 | #include <mpc5xx.h> |
34 | #endif | 34 | #endif |
35 | #ifdef CONFIG_MPC5xxx | 35 | #ifdef CONFIG_MPC5xxx |
36 | #include <mpc5xxx.h> | 36 | #include <mpc5xxx.h> |
37 | #endif | 37 | #endif |
38 | #if defined(CONFIG_CMD_IDE) | 38 | #if defined(CONFIG_CMD_IDE) |
39 | #include <ide.h> | 39 | #include <ide.h> |
40 | #endif | 40 | #endif |
41 | #if defined(CONFIG_CMD_SATA) | 41 | #if defined(CONFIG_CMD_SATA) |
42 | #include <sata.h> | 42 | #include <sata.h> |
43 | #endif | 43 | #endif |
44 | #if defined(CONFIG_CMD_SCSI) | 44 | #if defined(CONFIG_CMD_SCSI) |
45 | #include <scsi.h> | 45 | #include <scsi.h> |
46 | #endif | 46 | #endif |
47 | #if defined(CONFIG_CMD_KGDB) | 47 | #if defined(CONFIG_CMD_KGDB) |
48 | #include <kgdb.h> | 48 | #include <kgdb.h> |
49 | #endif | 49 | #endif |
50 | #ifdef CONFIG_STATUS_LED | 50 | #ifdef CONFIG_STATUS_LED |
51 | #include <status_led.h> | 51 | #include <status_led.h> |
52 | #endif | 52 | #endif |
53 | #include <net.h> | 53 | #include <net.h> |
54 | #include <serial.h> | 54 | #include <serial.h> |
55 | #ifdef CFG_ALLOC_DPRAM | 55 | #ifdef CFG_ALLOC_DPRAM |
56 | #if !defined(CONFIG_CPM2) | 56 | #if !defined(CONFIG_CPM2) |
57 | #include <commproc.h> | 57 | #include <commproc.h> |
58 | #endif | 58 | #endif |
59 | #endif | 59 | #endif |
60 | #include <version.h> | 60 | #include <version.h> |
61 | #if defined(CONFIG_BAB7xx) | 61 | #if defined(CONFIG_BAB7xx) |
62 | #include <w83c553f.h> | 62 | #include <w83c553f.h> |
63 | #endif | 63 | #endif |
64 | #include <dtt.h> | 64 | #include <dtt.h> |
65 | #if defined(CONFIG_POST) | 65 | #if defined(CONFIG_POST) |
66 | #include <post.h> | 66 | #include <post.h> |
67 | #endif | 67 | #endif |
68 | #if defined(CONFIG_LOGBUFFER) | 68 | #if defined(CONFIG_LOGBUFFER) |
69 | #include <logbuff.h> | 69 | #include <logbuff.h> |
70 | #endif | 70 | #endif |
71 | #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500) | 71 | #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500) |
72 | #include <asm/cache.h> | 72 | #include <asm/cache.h> |
73 | #endif | 73 | #endif |
74 | #ifdef CONFIG_PS2KBD | 74 | #ifdef CONFIG_PS2KBD |
75 | #include <keyboard.h> | 75 | #include <keyboard.h> |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #ifdef CFG_UPDATE_FLASH_SIZE | 78 | #ifdef CFG_UPDATE_FLASH_SIZE |
79 | extern int update_flash_size (int flash_size); | 79 | extern int update_flash_size (int flash_size); |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | #if defined(CONFIG_SC3) | 82 | #if defined(CONFIG_SC3) |
83 | extern void sc3_read_eeprom(void); | 83 | extern void sc3_read_eeprom(void); |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | #if defined(CONFIG_CMD_DOC) | 86 | #if defined(CONFIG_CMD_DOC) |
87 | void doc_init (void); | 87 | void doc_init (void); |
88 | #endif | 88 | #endif |
89 | #if defined(CONFIG_HARD_I2C) || \ | 89 | #if defined(CONFIG_HARD_I2C) || \ |
90 | defined(CONFIG_SOFT_I2C) | 90 | defined(CONFIG_SOFT_I2C) |
91 | #include <i2c.h> | 91 | #include <i2c.h> |
92 | #endif | 92 | #endif |
93 | #include <spi.h> | 93 | #include <spi.h> |
94 | #include <nand.h> | 94 | #include <nand.h> |
95 | 95 | ||
96 | static char *failed = "*** failed ***\n"; | 96 | static char *failed = "*** failed ***\n"; |
97 | 97 | ||
98 | #if defined(CONFIG_OXC) || defined(CONFIG_PCU_E) || defined(CONFIG_RMU) | 98 | #if defined(CONFIG_OXC) || defined(CONFIG_PCU_E) || defined(CONFIG_RMU) |
99 | extern flash_info_t flash_info[]; | 99 | extern flash_info_t flash_info[]; |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #if defined(CONFIG_START_IDE) | 102 | #if defined(CONFIG_START_IDE) |
103 | extern int board_start_ide(void); | 103 | extern int board_start_ide(void); |
104 | #endif | 104 | #endif |
105 | #include <environment.h> | 105 | #include <environment.h> |
106 | 106 | ||
107 | DECLARE_GLOBAL_DATA_PTR; | 107 | DECLARE_GLOBAL_DATA_PTR; |
108 | 108 | ||
109 | #if defined(CONFIG_ENV_IS_EMBEDDED) | 109 | #if defined(CONFIG_ENV_IS_EMBEDDED) |
110 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN | 110 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN |
111 | #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CFG_MONITOR_BASE) || \ | 111 | #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CFG_MONITOR_BASE) || \ |
112 | (CONFIG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ | 112 | (CONFIG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ |
113 | defined(CONFIG_ENV_IS_IN_NVRAM) | 113 | defined(CONFIG_ENV_IS_IN_NVRAM) |
114 | #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CONFIG_ENV_SIZE) | 114 | #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CONFIG_ENV_SIZE) |
115 | #else | 115 | #else |
116 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN | 116 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | #if !defined(CFG_MEM_TOP_HIDE) | 119 | #if !defined(CFG_MEM_TOP_HIDE) |
120 | #define CFG_MEM_TOP_HIDE 0 | 120 | #define CFG_MEM_TOP_HIDE 0 |
121 | #endif | 121 | #endif |
122 | 122 | ||
123 | extern ulong __init_end; | 123 | extern ulong __init_end; |
124 | extern ulong _end; | 124 | extern ulong _end; |
125 | ulong monitor_flash_len; | 125 | ulong monitor_flash_len; |
126 | 126 | ||
127 | #if defined(CONFIG_CMD_BEDBUG) | 127 | #if defined(CONFIG_CMD_BEDBUG) |
128 | #include <bedbug/type.h> | 128 | #include <bedbug/type.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | /* | 131 | /* |
132 | * Begin and End of memory area for malloc(), and current "brk" | 132 | * Begin and End of memory area for malloc(), and current "brk" |
133 | */ | 133 | */ |
134 | static ulong mem_malloc_start = 0; | 134 | static ulong mem_malloc_start = 0; |
135 | static ulong mem_malloc_end = 0; | 135 | static ulong mem_malloc_end = 0; |
136 | static ulong mem_malloc_brk = 0; | 136 | static ulong mem_malloc_brk = 0; |
137 | 137 | ||
138 | /************************************************************************ | 138 | /************************************************************************ |
139 | * Utilities * | 139 | * Utilities * |
140 | ************************************************************************ | 140 | ************************************************************************ |
141 | */ | 141 | */ |
142 | 142 | ||
143 | /* | 143 | /* |
144 | * The Malloc area is immediately below the monitor copy in DRAM | 144 | * The Malloc area is immediately below the monitor copy in DRAM |
145 | */ | 145 | */ |
146 | static void mem_malloc_init (void) | 146 | static void mem_malloc_init (void) |
147 | { | 147 | { |
148 | #if !defined(CONFIG_RELOC_FIXUP_WORKS) | 148 | #if !defined(CONFIG_RELOC_FIXUP_WORKS) |
149 | mem_malloc_end = CFG_MONITOR_BASE + gd->reloc_off; | 149 | mem_malloc_end = CFG_MONITOR_BASE + gd->reloc_off; |
150 | #endif | 150 | #endif |
151 | mem_malloc_start = mem_malloc_end - TOTAL_MALLOC_LEN; | 151 | mem_malloc_start = mem_malloc_end - TOTAL_MALLOC_LEN; |
152 | mem_malloc_brk = mem_malloc_start; | 152 | mem_malloc_brk = mem_malloc_start; |
153 | 153 | ||
154 | memset ((void *) mem_malloc_start, | 154 | memset ((void *) mem_malloc_start, |
155 | 0, | 155 | 0, |
156 | mem_malloc_end - mem_malloc_start); | 156 | mem_malloc_end - mem_malloc_start); |
157 | } | 157 | } |
158 | 158 | ||
159 | void *sbrk (ptrdiff_t increment) | 159 | void *sbrk (ptrdiff_t increment) |
160 | { | 160 | { |
161 | ulong old = mem_malloc_brk; | 161 | ulong old = mem_malloc_brk; |
162 | ulong new = old + increment; | 162 | ulong new = old + increment; |
163 | 163 | ||
164 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { | 164 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { |
165 | return (NULL); | 165 | return (NULL); |
166 | } | 166 | } |
167 | mem_malloc_brk = new; | 167 | mem_malloc_brk = new; |
168 | return ((void *) old); | 168 | return ((void *) old); |
169 | } | 169 | } |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * All attempts to come up with a "common" initialization sequence | 172 | * All attempts to come up with a "common" initialization sequence |
173 | * that works for all boards and architectures failed: some of the | 173 | * that works for all boards and architectures failed: some of the |
174 | * requirements are just _too_ different. To get rid of the resulting | 174 | * requirements are just _too_ different. To get rid of the resulting |
175 | * mess of board dependend #ifdef'ed code we now make the whole | 175 | * mess of board dependend #ifdef'ed code we now make the whole |
176 | * initialization sequence configurable to the user. | 176 | * initialization sequence configurable to the user. |
177 | * | 177 | * |
178 | * The requirements for any new initalization function is simple: it | 178 | * The requirements for any new initalization function is simple: it |
179 | * receives a pointer to the "global data" structure as it's only | 179 | * receives a pointer to the "global data" structure as it's only |
180 | * argument, and returns an integer return code, where 0 means | 180 | * argument, and returns an integer return code, where 0 means |
181 | * "continue" and != 0 means "fatal error, hang the system". | 181 | * "continue" and != 0 means "fatal error, hang the system". |
182 | */ | 182 | */ |
183 | typedef int (init_fnc_t) (void); | 183 | typedef int (init_fnc_t) (void); |
184 | 184 | ||
185 | /************************************************************************ | 185 | /************************************************************************ |
186 | * Init Utilities * | 186 | * Init Utilities * |
187 | ************************************************************************ | 187 | ************************************************************************ |
188 | * Some of this code should be moved into the core functions, | 188 | * Some of this code should be moved into the core functions, |
189 | * but let's get it working (again) first... | 189 | * but let's get it working (again) first... |
190 | */ | 190 | */ |
191 | 191 | ||
192 | static int init_baudrate (void) | 192 | static int init_baudrate (void) |
193 | { | 193 | { |
194 | char tmp[64]; /* long enough for environment variables */ | 194 | char tmp[64]; /* long enough for environment variables */ |
195 | int i = getenv_r ("baudrate", tmp, sizeof (tmp)); | 195 | int i = getenv_r ("baudrate", tmp, sizeof (tmp)); |
196 | 196 | ||
197 | gd->baudrate = (i > 0) | 197 | gd->baudrate = (i > 0) |
198 | ? (int) simple_strtoul (tmp, NULL, 10) | 198 | ? (int) simple_strtoul (tmp, NULL, 10) |
199 | : CONFIG_BAUDRATE; | 199 | : CONFIG_BAUDRATE; |
200 | return (0); | 200 | return (0); |
201 | } | 201 | } |
202 | 202 | ||
203 | /***********************************************************************/ | 203 | /***********************************************************************/ |
204 | 204 | ||
205 | void __board_add_ram_info(int use_default) | 205 | void __board_add_ram_info(int use_default) |
206 | { | 206 | { |
207 | /* please define platform specific board_add_ram_info() */ | 207 | /* please define platform specific board_add_ram_info() */ |
208 | } | 208 | } |
209 | void board_add_ram_info(int) __attribute__((weak, alias("__board_add_ram_info"))); | 209 | void board_add_ram_info(int) __attribute__((weak, alias("__board_add_ram_info"))); |
210 | 210 | ||
211 | 211 | ||
212 | static int init_func_ram (void) | 212 | static int init_func_ram (void) |
213 | { | 213 | { |
214 | #ifdef CONFIG_BOARD_TYPES | 214 | #ifdef CONFIG_BOARD_TYPES |
215 | int board_type = gd->board_type; | 215 | int board_type = gd->board_type; |
216 | #else | 216 | #else |
217 | int board_type = 0; /* use dummy arg */ | 217 | int board_type = 0; /* use dummy arg */ |
218 | #endif | 218 | #endif |
219 | puts ("DRAM: "); | 219 | puts ("DRAM: "); |
220 | 220 | ||
221 | if ((gd->ram_size = initdram (board_type)) > 0) { | 221 | if ((gd->ram_size = initdram (board_type)) > 0) { |
222 | print_size (gd->ram_size, ""); | 222 | print_size (gd->ram_size, ""); |
223 | board_add_ram_info(0); | 223 | board_add_ram_info(0); |
224 | putc('\n'); | 224 | putc('\n'); |
225 | return (0); | 225 | return (0); |
226 | } | 226 | } |
227 | puts (failed); | 227 | puts (failed); |
228 | return (1); | 228 | return (1); |
229 | } | 229 | } |
230 | 230 | ||
231 | /***********************************************************************/ | 231 | /***********************************************************************/ |
232 | 232 | ||
233 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) | 233 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) |
234 | static int init_func_i2c (void) | 234 | static int init_func_i2c (void) |
235 | { | 235 | { |
236 | puts ("I2C: "); | 236 | puts ("I2C: "); |
237 | i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); | 237 | i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); |
238 | puts ("ready\n"); | 238 | puts ("ready\n"); |
239 | return (0); | 239 | return (0); |
240 | } | 240 | } |
241 | #endif | 241 | #endif |
242 | 242 | ||
243 | #if defined(CONFIG_HARD_SPI) | 243 | #if defined(CONFIG_HARD_SPI) |
244 | static int init_func_spi (void) | 244 | static int init_func_spi (void) |
245 | { | 245 | { |
246 | puts ("SPI: "); | 246 | puts ("SPI: "); |
247 | spi_init (); | 247 | spi_init (); |
248 | puts ("ready\n"); | 248 | puts ("ready\n"); |
249 | return (0); | 249 | return (0); |
250 | } | 250 | } |
251 | #endif | 251 | #endif |
252 | 252 | ||
253 | /***********************************************************************/ | 253 | /***********************************************************************/ |
254 | 254 | ||
255 | #if defined(CONFIG_WATCHDOG) | 255 | #if defined(CONFIG_WATCHDOG) |
256 | static int init_func_watchdog_init (void) | 256 | static int init_func_watchdog_init (void) |
257 | { | 257 | { |
258 | puts (" Watchdog enabled\n"); | 258 | puts (" Watchdog enabled\n"); |
259 | WATCHDOG_RESET (); | 259 | WATCHDOG_RESET (); |
260 | return (0); | 260 | return (0); |
261 | } | 261 | } |
262 | # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init, | 262 | # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init, |
263 | 263 | ||
264 | static int init_func_watchdog_reset (void) | 264 | static int init_func_watchdog_reset (void) |
265 | { | 265 | { |
266 | WATCHDOG_RESET (); | 266 | WATCHDOG_RESET (); |
267 | return (0); | 267 | return (0); |
268 | } | 268 | } |
269 | # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset, | 269 | # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset, |
270 | #else | 270 | #else |
271 | # define INIT_FUNC_WATCHDOG_INIT /* undef */ | 271 | # define INIT_FUNC_WATCHDOG_INIT /* undef */ |
272 | # define INIT_FUNC_WATCHDOG_RESET /* undef */ | 272 | # define INIT_FUNC_WATCHDOG_RESET /* undef */ |
273 | #endif /* CONFIG_WATCHDOG */ | 273 | #endif /* CONFIG_WATCHDOG */ |
274 | 274 | ||
275 | /************************************************************************ | 275 | /************************************************************************ |
276 | * Initialization sequence * | 276 | * Initialization sequence * |
277 | ************************************************************************ | 277 | ************************************************************************ |
278 | */ | 278 | */ |
279 | 279 | ||
280 | init_fnc_t *init_sequence[] = { | 280 | init_fnc_t *init_sequence[] = { |
281 | 281 | ||
282 | #if defined(CONFIG_BOARD_EARLY_INIT_F) | 282 | #if defined(CONFIG_BOARD_EARLY_INIT_F) |
283 | board_early_init_f, | 283 | board_early_init_f, |
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | #if !defined(CONFIG_8xx_CPUCLK_DEFAULT) | 286 | #if !defined(CONFIG_8xx_CPUCLK_DEFAULT) |
287 | get_clocks, /* get CPU and bus clocks (etc.) */ | 287 | get_clocks, /* get CPU and bus clocks (etc.) */ |
288 | #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \ | 288 | #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \ |
289 | && !defined(CONFIG_TQM885D) | 289 | && !defined(CONFIG_TQM885D) |
290 | adjust_sdram_tbs_8xx, | 290 | adjust_sdram_tbs_8xx, |
291 | #endif | 291 | #endif |
292 | init_timebase, | 292 | init_timebase, |
293 | #endif | 293 | #endif |
294 | #ifdef CFG_ALLOC_DPRAM | 294 | #ifdef CFG_ALLOC_DPRAM |
295 | #if !defined(CONFIG_CPM2) | 295 | #if !defined(CONFIG_CPM2) |
296 | dpram_init, | 296 | dpram_init, |
297 | #endif | 297 | #endif |
298 | #endif | 298 | #endif |
299 | #if defined(CONFIG_BOARD_POSTCLK_INIT) | 299 | #if defined(CONFIG_BOARD_POSTCLK_INIT) |
300 | board_postclk_init, | 300 | board_postclk_init, |
301 | #endif | 301 | #endif |
302 | env_init, | 302 | env_init, |
303 | #if defined(CONFIG_8xx_CPUCLK_DEFAULT) | 303 | #if defined(CONFIG_8xx_CPUCLK_DEFAULT) |
304 | get_clocks_866, /* get CPU and bus clocks according to the environment variable */ | 304 | get_clocks_866, /* get CPU and bus clocks according to the environment variable */ |
305 | sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */ | 305 | sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */ |
306 | init_timebase, | 306 | init_timebase, |
307 | #endif | 307 | #endif |
308 | init_baudrate, | 308 | init_baudrate, |
309 | serial_init, | 309 | serial_init, |
310 | console_init_f, | 310 | console_init_f, |
311 | display_options, | 311 | display_options, |
312 | #if defined(CONFIG_8260) | 312 | #if defined(CONFIG_8260) |
313 | prt_8260_rsr, | 313 | prt_8260_rsr, |
314 | prt_8260_clks, | 314 | prt_8260_clks, |
315 | #endif /* CONFIG_8260 */ | 315 | #endif /* CONFIG_8260 */ |
316 | #if defined(CONFIG_MPC83XX) | 316 | #if defined(CONFIG_MPC83XX) |
317 | prt_83xx_rsr, | 317 | prt_83xx_rsr, |
318 | #endif | 318 | #endif |
319 | checkcpu, | 319 | checkcpu, |
320 | #if defined(CONFIG_MPC5xxx) | 320 | #if defined(CONFIG_MPC5xxx) |
321 | prt_mpc5xxx_clks, | 321 | prt_mpc5xxx_clks, |
322 | #endif /* CONFIG_MPC5xxx */ | 322 | #endif /* CONFIG_MPC5xxx */ |
323 | #if defined(CONFIG_MPC8220) | 323 | #if defined(CONFIG_MPC8220) |
324 | prt_mpc8220_clks, | 324 | prt_mpc8220_clks, |
325 | #endif | 325 | #endif |
326 | checkboard, | 326 | checkboard, |
327 | INIT_FUNC_WATCHDOG_INIT | 327 | INIT_FUNC_WATCHDOG_INIT |
328 | #if defined(CONFIG_MISC_INIT_F) | 328 | #if defined(CONFIG_MISC_INIT_F) |
329 | misc_init_f, | 329 | misc_init_f, |
330 | #endif | 330 | #endif |
331 | INIT_FUNC_WATCHDOG_RESET | 331 | INIT_FUNC_WATCHDOG_RESET |
332 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) | 332 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) |
333 | init_func_i2c, | 333 | init_func_i2c, |
334 | #endif | 334 | #endif |
335 | #if defined(CONFIG_HARD_SPI) | 335 | #if defined(CONFIG_HARD_SPI) |
336 | init_func_spi, | 336 | init_func_spi, |
337 | #endif | 337 | #endif |
338 | #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */ | 338 | #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */ |
339 | dtt_init, | 339 | dtt_init, |
340 | #endif | 340 | #endif |
341 | #ifdef CONFIG_POST | 341 | #ifdef CONFIG_POST |
342 | post_init_f, | 342 | post_init_f, |
343 | #endif | 343 | #endif |
344 | INIT_FUNC_WATCHDOG_RESET | 344 | INIT_FUNC_WATCHDOG_RESET |
345 | init_func_ram, | 345 | init_func_ram, |
346 | #if defined(CFG_DRAM_TEST) | 346 | #if defined(CFG_DRAM_TEST) |
347 | testdram, | 347 | testdram, |
348 | #endif /* CFG_DRAM_TEST */ | 348 | #endif /* CFG_DRAM_TEST */ |
349 | INIT_FUNC_WATCHDOG_RESET | 349 | INIT_FUNC_WATCHDOG_RESET |
350 | 350 | ||
351 | NULL, /* Terminate this list */ | 351 | NULL, /* Terminate this list */ |
352 | }; | 352 | }; |
353 | 353 | ||
354 | #ifndef CONFIG_MAX_MEM_MAPPED | 354 | #ifndef CONFIG_MAX_MEM_MAPPED |
355 | #define CONFIG_MAX_MEM_MAPPED (256 << 20) | 355 | #define CONFIG_MAX_MEM_MAPPED (256 << 20) |
356 | #endif | 356 | #endif |
357 | ulong get_effective_memsize(void) | 357 | ulong get_effective_memsize(void) |
358 | { | 358 | { |
359 | #ifndef CONFIG_VERY_BIG_RAM | 359 | #ifndef CONFIG_VERY_BIG_RAM |
360 | return gd->ram_size; | 360 | return gd->ram_size; |
361 | #else | 361 | #else |
362 | /* limit stack to what we can reasonable map */ | 362 | /* limit stack to what we can reasonable map */ |
363 | return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ? | 363 | return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ? |
364 | CONFIG_MAX_MEM_MAPPED : gd->ram_size); | 364 | CONFIG_MAX_MEM_MAPPED : gd->ram_size); |
365 | #endif | 365 | #endif |
366 | } | 366 | } |
367 | 367 | ||
368 | /************************************************************************ | 368 | /************************************************************************ |
369 | * | 369 | * |
370 | * This is the first part of the initialization sequence that is | 370 | * This is the first part of the initialization sequence that is |
371 | * implemented in C, but still running from ROM. | 371 | * implemented in C, but still running from ROM. |
372 | * | 372 | * |
373 | * The main purpose is to provide a (serial) console interface as | 373 | * The main purpose is to provide a (serial) console interface as |
374 | * soon as possible (so we can see any error messages), and to | 374 | * soon as possible (so we can see any error messages), and to |
375 | * initialize the RAM so that we can relocate the monitor code to | 375 | * initialize the RAM so that we can relocate the monitor code to |
376 | * RAM. | 376 | * RAM. |
377 | * | 377 | * |
378 | * Be aware of the restrictions: global data is read-only, BSS is not | 378 | * Be aware of the restrictions: global data is read-only, BSS is not |
379 | * initialized, and stack space is limited to a few kB. | 379 | * initialized, and stack space is limited to a few kB. |
380 | * | 380 | * |
381 | ************************************************************************ | 381 | ************************************************************************ |
382 | */ | 382 | */ |
383 | 383 | ||
384 | #ifdef CONFIG_LOGBUFFER | 384 | #ifdef CONFIG_LOGBUFFER |
385 | unsigned long logbuffer_base(void) | 385 | unsigned long logbuffer_base(void) |
386 | { | 386 | { |
387 | return CFG_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN; | 387 | return CFG_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN; |
388 | } | 388 | } |
389 | #endif | 389 | #endif |
390 | 390 | ||
391 | void board_init_f (ulong bootflag) | 391 | void board_init_f (ulong bootflag) |
392 | { | 392 | { |
393 | bd_t *bd; | 393 | bd_t *bd; |
394 | ulong len, addr, addr_sp; | 394 | ulong len, addr, addr_sp; |
395 | ulong *s; | 395 | ulong *s; |
396 | gd_t *id; | 396 | gd_t *id; |
397 | init_fnc_t **init_fnc_ptr; | 397 | init_fnc_t **init_fnc_ptr; |
398 | #ifdef CONFIG_PRAM | 398 | #ifdef CONFIG_PRAM |
399 | int i; | 399 | int i; |
400 | ulong reg; | 400 | ulong reg; |
401 | uchar tmp[64]; /* long enough for environment variables */ | 401 | uchar tmp[64]; /* long enough for environment variables */ |
402 | #endif | 402 | #endif |
403 | 403 | ||
404 | /* Pointer is writable since we allocated a register for it */ | 404 | /* Pointer is writable since we allocated a register for it */ |
405 | gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); | 405 | gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); |
406 | /* compiler optimization barrier needed for GCC >= 3.4 */ | 406 | /* compiler optimization barrier needed for GCC >= 3.4 */ |
407 | __asm__ __volatile__("": : :"memory"); | 407 | __asm__ __volatile__("": : :"memory"); |
408 | 408 | ||
409 | #if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX) && \ | 409 | #if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX) && \ |
410 | !defined(CONFIG_MPC85xx) && !defined(CONFIG_MPC86xx) | 410 | !defined(CONFIG_MPC85xx) && !defined(CONFIG_MPC86xx) |
411 | /* Clear initial global data */ | 411 | /* Clear initial global data */ |
412 | memset ((void *) gd, 0, sizeof (gd_t)); | 412 | memset ((void *) gd, 0, sizeof (gd_t)); |
413 | #endif | 413 | #endif |
414 | 414 | ||
415 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { | 415 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { |
416 | if ((*init_fnc_ptr) () != 0) { | 416 | if ((*init_fnc_ptr) () != 0) { |
417 | hang (); | 417 | hang (); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | 420 | ||
421 | /* | 421 | /* |
422 | * Now that we have DRAM mapped and working, we can | 422 | * Now that we have DRAM mapped and working, we can |
423 | * relocate the code and continue running from DRAM. | 423 | * relocate the code and continue running from DRAM. |
424 | * | 424 | * |
425 | * Reserve memory at end of RAM for (top down in that order): | 425 | * Reserve memory at end of RAM for (top down in that order): |
426 | * - area that won't get touched by U-Boot and Linux (optional) | 426 | * - area that won't get touched by U-Boot and Linux (optional) |
427 | * - kernel log buffer | 427 | * - kernel log buffer |
428 | * - protected RAM | 428 | * - protected RAM |
429 | * - LCD framebuffer | 429 | * - LCD framebuffer |
430 | * - monitor code | 430 | * - monitor code |
431 | * - board info struct | 431 | * - board info struct |
432 | */ | 432 | */ |
433 | len = (ulong)&_end - CFG_MONITOR_BASE; | 433 | len = (ulong)&_end - CFG_MONITOR_BASE; |
434 | 434 | ||
435 | /* | 435 | /* |
436 | * Subtract specified amount of memory to hide so that it won't | 436 | * Subtract specified amount of memory to hide so that it won't |
437 | * get "touched" at all by U-Boot. By fixing up gd->ram_size | 437 | * get "touched" at all by U-Boot. By fixing up gd->ram_size |
438 | * the Linux kernel should now get passed the now "corrected" | 438 | * the Linux kernel should now get passed the now "corrected" |
439 | * memory size and won't touch it either. This should work | 439 | * memory size and won't touch it either. This should work |
440 | * for arch/ppc and arch/powerpc. Only Linux board ports in | 440 | * for arch/ppc and arch/powerpc. Only Linux board ports in |
441 | * arch/powerpc with bootwrapper support, that recalculate the | 441 | * arch/powerpc with bootwrapper support, that recalculate the |
442 | * memory size from the SDRAM controller setup will have to | 442 | * memory size from the SDRAM controller setup will have to |
443 | * get fixed. | 443 | * get fixed. |
444 | */ | 444 | */ |
445 | gd->ram_size -= CFG_MEM_TOP_HIDE; | 445 | gd->ram_size -= CFG_MEM_TOP_HIDE; |
446 | 446 | ||
447 | addr = CFG_SDRAM_BASE + get_effective_memsize(); | 447 | addr = CFG_SDRAM_BASE + get_effective_memsize(); |
448 | 448 | ||
449 | #ifdef CONFIG_LOGBUFFER | 449 | #ifdef CONFIG_LOGBUFFER |
450 | #ifndef CONFIG_ALT_LB_ADDR | 450 | #ifndef CONFIG_ALT_LB_ADDR |
451 | /* reserve kernel log buffer */ | 451 | /* reserve kernel log buffer */ |
452 | addr -= (LOGBUFF_RESERVE); | 452 | addr -= (LOGBUFF_RESERVE); |
453 | debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); | 453 | debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); |
454 | #endif | 454 | #endif |
455 | #endif | 455 | #endif |
456 | 456 | ||
457 | #ifdef CONFIG_PRAM | 457 | #ifdef CONFIG_PRAM |
458 | /* | 458 | /* |
459 | * reserve protected RAM | 459 | * reserve protected RAM |
460 | */ | 460 | */ |
461 | i = getenv_r ("pram", (char *)tmp, sizeof (tmp)); | 461 | i = getenv_r ("pram", (char *)tmp, sizeof (tmp)); |
462 | reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM; | 462 | reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM; |
463 | addr -= (reg << 10); /* size is in kB */ | 463 | addr -= (reg << 10); /* size is in kB */ |
464 | debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); | 464 | debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); |
465 | #endif /* CONFIG_PRAM */ | 465 | #endif /* CONFIG_PRAM */ |
466 | 466 | ||
467 | /* round down to next 4 kB limit */ | 467 | /* round down to next 4 kB limit */ |
468 | addr &= ~(4096 - 1); | 468 | addr &= ~(4096 - 1); |
469 | debug ("Top of RAM usable for U-Boot at: %08lx\n", addr); | 469 | debug ("Top of RAM usable for U-Boot at: %08lx\n", addr); |
470 | 470 | ||
471 | #ifdef CONFIG_LCD | 471 | #ifdef CONFIG_LCD |
472 | /* reserve memory for LCD display (always full pages) */ | 472 | /* reserve memory for LCD display (always full pages) */ |
473 | addr = lcd_setmem (addr); | 473 | addr = lcd_setmem (addr); |
474 | gd->fb_base = addr; | 474 | gd->fb_base = addr; |
475 | #endif /* CONFIG_LCD */ | 475 | #endif /* CONFIG_LCD */ |
476 | 476 | ||
477 | #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx) | 477 | #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx) |
478 | /* reserve memory for video display (always full pages) */ | 478 | /* reserve memory for video display (always full pages) */ |
479 | addr = video_setmem (addr); | 479 | addr = video_setmem (addr); |
480 | gd->fb_base = addr; | 480 | gd->fb_base = addr; |
481 | #endif /* CONFIG_VIDEO */ | 481 | #endif /* CONFIG_VIDEO */ |
482 | 482 | ||
483 | /* | 483 | /* |
484 | * reserve memory for U-Boot code, data & bss | 484 | * reserve memory for U-Boot code, data & bss |
485 | * round down to next 4 kB limit | 485 | * round down to next 4 kB limit |
486 | */ | 486 | */ |
487 | addr -= len; | 487 | addr -= len; |
488 | addr &= ~(4096 - 1); | 488 | addr &= ~(4096 - 1); |
489 | #ifdef CONFIG_E500 | 489 | #ifdef CONFIG_E500 |
490 | /* round down to next 64 kB limit so that IVPR stays aligned */ | 490 | /* round down to next 64 kB limit so that IVPR stays aligned */ |
491 | addr &= ~(65536 - 1); | 491 | addr &= ~(65536 - 1); |
492 | #endif | 492 | #endif |
493 | 493 | ||
494 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); | 494 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); |
495 | 495 | ||
496 | #ifdef CONFIG_AMIGAONEG3SE | 496 | #ifdef CONFIG_AMIGAONEG3SE |
497 | gd->relocaddr = addr; | 497 | gd->relocaddr = addr; |
498 | #endif | 498 | #endif |
499 | 499 | ||
500 | /* | 500 | /* |
501 | * reserve memory for malloc() arena | 501 | * reserve memory for malloc() arena |
502 | */ | 502 | */ |
503 | addr_sp = addr - TOTAL_MALLOC_LEN; | 503 | addr_sp = addr - TOTAL_MALLOC_LEN; |
504 | debug ("Reserving %dk for malloc() at: %08lx\n", | 504 | debug ("Reserving %dk for malloc() at: %08lx\n", |
505 | TOTAL_MALLOC_LEN >> 10, addr_sp); | 505 | TOTAL_MALLOC_LEN >> 10, addr_sp); |
506 | 506 | ||
507 | /* | 507 | /* |
508 | * (permanently) allocate a Board Info struct | 508 | * (permanently) allocate a Board Info struct |
509 | * and a permanent copy of the "global" data | 509 | * and a permanent copy of the "global" data |
510 | */ | 510 | */ |
511 | addr_sp -= sizeof (bd_t); | 511 | addr_sp -= sizeof (bd_t); |
512 | bd = (bd_t *) addr_sp; | 512 | bd = (bd_t *) addr_sp; |
513 | gd->bd = bd; | 513 | gd->bd = bd; |
514 | debug ("Reserving %zu Bytes for Board Info at: %08lx\n", | 514 | debug ("Reserving %zu Bytes for Board Info at: %08lx\n", |
515 | sizeof (bd_t), addr_sp); | 515 | sizeof (bd_t), addr_sp); |
516 | addr_sp -= sizeof (gd_t); | 516 | addr_sp -= sizeof (gd_t); |
517 | id = (gd_t *) addr_sp; | 517 | id = (gd_t *) addr_sp; |
518 | debug ("Reserving %zu Bytes for Global Data at: %08lx\n", | 518 | debug ("Reserving %zu Bytes for Global Data at: %08lx\n", |
519 | sizeof (gd_t), addr_sp); | 519 | sizeof (gd_t), addr_sp); |
520 | 520 | ||
521 | /* | 521 | /* |
522 | * Finally, we set up a new (bigger) stack. | 522 | * Finally, we set up a new (bigger) stack. |
523 | * | 523 | * |
524 | * Leave some safety gap for SP, force alignment on 16 byte boundary | 524 | * Leave some safety gap for SP, force alignment on 16 byte boundary |
525 | * Clear initial stack frame | 525 | * Clear initial stack frame |
526 | */ | 526 | */ |
527 | addr_sp -= 16; | 527 | addr_sp -= 16; |
528 | addr_sp &= ~0xF; | 528 | addr_sp &= ~0xF; |
529 | s = (ulong *)addr_sp; | 529 | s = (ulong *)addr_sp; |
530 | *s-- = 0; | 530 | *s-- = 0; |
531 | *s-- = 0; | 531 | *s-- = 0; |
532 | addr_sp = (ulong)s; | 532 | addr_sp = (ulong)s; |
533 | debug ("Stack Pointer at: %08lx\n", addr_sp); | 533 | debug ("Stack Pointer at: %08lx\n", addr_sp); |
534 | 534 | ||
535 | /* | 535 | /* |
536 | * Save local variables to board info struct | 536 | * Save local variables to board info struct |
537 | */ | 537 | */ |
538 | 538 | ||
539 | bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ | 539 | bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ |
540 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ | 540 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ |
541 | 541 | ||
542 | #ifdef CONFIG_IP860 | 542 | #ifdef CONFIG_IP860 |
543 | bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */ | 543 | bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */ |
544 | bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */ | 544 | bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */ |
545 | #elif defined CONFIG_MPC8220 | 545 | #elif defined CONFIG_MPC8220 |
546 | bd->bi_sramstart = CFG_SRAM_BASE; /* start of SRAM memory */ | 546 | bd->bi_sramstart = CFG_SRAM_BASE; /* start of SRAM memory */ |
547 | bd->bi_sramsize = CFG_SRAM_SIZE; /* size of SRAM memory */ | 547 | bd->bi_sramsize = CFG_SRAM_SIZE; /* size of SRAM memory */ |
548 | #else | 548 | #else |
549 | bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */ | 549 | bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */ |
550 | bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */ | 550 | bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */ |
551 | #endif | 551 | #endif |
552 | 552 | ||
553 | #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \ | 553 | #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \ |
554 | defined(CONFIG_E500) || defined(CONFIG_MPC86xx) | 554 | defined(CONFIG_E500) || defined(CONFIG_MPC86xx) |
555 | bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */ | 555 | bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */ |
556 | #endif | 556 | #endif |
557 | #if defined(CONFIG_MPC5xxx) | 557 | #if defined(CONFIG_MPC5xxx) |
558 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ | 558 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ |
559 | #endif | 559 | #endif |
560 | #if defined(CONFIG_MPC83XX) | 560 | #if defined(CONFIG_MPC83XX) |
561 | bd->bi_immrbar = CFG_IMMR; | 561 | bd->bi_immrbar = CFG_IMMR; |
562 | #endif | 562 | #endif |
563 | #if defined(CONFIG_MPC8220) | 563 | #if defined(CONFIG_MPC8220) |
564 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ | 564 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ |
565 | bd->bi_inpfreq = gd->inp_clk; | 565 | bd->bi_inpfreq = gd->inp_clk; |
566 | bd->bi_pcifreq = gd->pci_clk; | 566 | bd->bi_pcifreq = gd->pci_clk; |
567 | bd->bi_vcofreq = gd->vco_clk; | 567 | bd->bi_vcofreq = gd->vco_clk; |
568 | bd->bi_pevfreq = gd->pev_clk; | 568 | bd->bi_pevfreq = gd->pev_clk; |
569 | bd->bi_flbfreq = gd->flb_clk; | 569 | bd->bi_flbfreq = gd->flb_clk; |
570 | 570 | ||
571 | /* store bootparam to sram (backward compatible), here? */ | 571 | /* store bootparam to sram (backward compatible), here? */ |
572 | { | 572 | { |
573 | u32 *sram = (u32 *)CFG_SRAM_BASE; | 573 | u32 *sram = (u32 *)CFG_SRAM_BASE; |
574 | *sram++ = gd->ram_size; | 574 | *sram++ = gd->ram_size; |
575 | *sram++ = gd->bus_clk; | 575 | *sram++ = gd->bus_clk; |
576 | *sram++ = gd->inp_clk; | 576 | *sram++ = gd->inp_clk; |
577 | *sram++ = gd->cpu_clk; | 577 | *sram++ = gd->cpu_clk; |
578 | *sram++ = gd->vco_clk; | 578 | *sram++ = gd->vco_clk; |
579 | *sram++ = gd->flb_clk; | 579 | *sram++ = gd->flb_clk; |
580 | *sram++ = 0xb8c3ba11; /* boot signature */ | 580 | *sram++ = 0xb8c3ba11; /* boot signature */ |
581 | } | 581 | } |
582 | #endif | 582 | #endif |
583 | 583 | ||
584 | bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ | 584 | bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ |
585 | 585 | ||
586 | WATCHDOG_RESET (); | 586 | WATCHDOG_RESET (); |
587 | bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ | 587 | bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ |
588 | bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ | 588 | bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ |
589 | #if defined(CONFIG_CPM2) | 589 | #if defined(CONFIG_CPM2) |
590 | bd->bi_cpmfreq = gd->cpm_clk; | 590 | bd->bi_cpmfreq = gd->cpm_clk; |
591 | bd->bi_brgfreq = gd->brg_clk; | 591 | bd->bi_brgfreq = gd->brg_clk; |
592 | bd->bi_sccfreq = gd->scc_clk; | 592 | bd->bi_sccfreq = gd->scc_clk; |
593 | bd->bi_vco = gd->vco_out; | 593 | bd->bi_vco = gd->vco_out; |
594 | #endif /* CONFIG_CPM2 */ | 594 | #endif /* CONFIG_CPM2 */ |
595 | #if defined(CONFIG_MPC512X) | 595 | #if defined(CONFIG_MPC512X) |
596 | bd->bi_ipsfreq = gd->ips_clk; | 596 | bd->bi_ipsfreq = gd->ips_clk; |
597 | #endif /* CONFIG_MPC512X */ | 597 | #endif /* CONFIG_MPC512X */ |
598 | #if defined(CONFIG_MPC5xxx) | 598 | #if defined(CONFIG_MPC5xxx) |
599 | bd->bi_ipbfreq = gd->ipb_clk; | 599 | bd->bi_ipbfreq = gd->ipb_clk; |
600 | bd->bi_pcifreq = gd->pci_clk; | 600 | bd->bi_pcifreq = gd->pci_clk; |
601 | #endif /* CONFIG_MPC5xxx */ | 601 | #endif /* CONFIG_MPC5xxx */ |
602 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ | 602 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ |
603 | 603 | ||
604 | #ifdef CFG_EXTBDINFO | 604 | #ifdef CFG_EXTBDINFO |
605 | strncpy ((char *)bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); | 605 | strncpy ((char *)bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); |
606 | strncpy ((char *)bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); | 606 | strncpy ((char *)bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); |
607 | 607 | ||
608 | bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */ | 608 | bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */ |
609 | bd->bi_plb_busfreq = gd->bus_clk; | 609 | bd->bi_plb_busfreq = gd->bus_clk; |
610 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ | 610 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ |
611 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ | 611 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ |
612 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) | 612 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) |
613 | bd->bi_pci_busfreq = get_PCI_freq (); | 613 | bd->bi_pci_busfreq = get_PCI_freq (); |
614 | bd->bi_opbfreq = get_OPB_freq (); | 614 | bd->bi_opbfreq = get_OPB_freq (); |
615 | #elif defined(CONFIG_XILINX_405) | 615 | #elif defined(CONFIG_XILINX_405) |
616 | bd->bi_pci_busfreq = get_PCI_freq (); | 616 | bd->bi_pci_busfreq = get_PCI_freq (); |
617 | #endif | 617 | #endif |
618 | #endif | 618 | #endif |
619 | 619 | ||
620 | debug ("New Stack Pointer is: %08lx\n", addr_sp); | 620 | debug ("New Stack Pointer is: %08lx\n", addr_sp); |
621 | 621 | ||
622 | WATCHDOG_RESET (); | 622 | WATCHDOG_RESET (); |
623 | 623 | ||
624 | #ifdef CONFIG_POST | 624 | #ifdef CONFIG_POST |
625 | post_bootmode_init(); | 625 | post_bootmode_init(); |
626 | post_run (NULL, POST_ROM | post_bootmode_get(0)); | 626 | post_run (NULL, POST_ROM | post_bootmode_get(0)); |
627 | #endif | 627 | #endif |
628 | 628 | ||
629 | WATCHDOG_RESET(); | 629 | WATCHDOG_RESET(); |
630 | 630 | ||
631 | memcpy (id, (void *)gd, sizeof (gd_t)); | 631 | memcpy (id, (void *)gd, sizeof (gd_t)); |
632 | 632 | ||
633 | relocate_code (addr_sp, id, addr); | 633 | relocate_code (addr_sp, id, addr); |
634 | 634 | ||
635 | /* NOTREACHED - relocate_code() does not return */ | 635 | /* NOTREACHED - relocate_code() does not return */ |
636 | } | 636 | } |
637 | 637 | ||
638 | int __is_sata_supported(void) | 638 | int __is_sata_supported(void) |
639 | { | 639 | { |
640 | /* For some boards, when sata disabled by the switch, and the | 640 | /* For some boards, when sata disabled by the switch, and the |
641 | * driver still access the sata registers, the cpu will hangup. | 641 | * driver still access the sata registers, the cpu will hangup. |
642 | * please define platform specific is_sata_supported() if your | 642 | * please define platform specific is_sata_supported() if your |
643 | * board have such issue.*/ | 643 | * board have such issue.*/ |
644 | return 1; | 644 | return 1; |
645 | } | 645 | } |
646 | int is_sata_supported(void) __attribute__((weak, alias("__is_sata_supported"))); | 646 | int is_sata_supported(void) __attribute__((weak, alias("__is_sata_supported"))); |
647 | 647 | ||
648 | /************************************************************************ | 648 | /************************************************************************ |
649 | * | 649 | * |
650 | * This is the next part if the initialization sequence: we are now | 650 | * This is the next part if the initialization sequence: we are now |
651 | * running from RAM and have a "normal" C environment, i. e. global | 651 | * running from RAM and have a "normal" C environment, i. e. global |
652 | * data can be written, BSS has been cleared, the stack size in not | 652 | * data can be written, BSS has been cleared, the stack size in not |
653 | * that critical any more, etc. | 653 | * that critical any more, etc. |
654 | * | 654 | * |
655 | ************************************************************************ | 655 | ************************************************************************ |
656 | */ | 656 | */ |
657 | void board_init_r (gd_t *id, ulong dest_addr) | 657 | void board_init_r (gd_t *id, ulong dest_addr) |
658 | { | 658 | { |
659 | cmd_tbl_t *cmdtp; | 659 | cmd_tbl_t *cmdtp; |
660 | char *s, *e; | 660 | char *s, *e; |
661 | bd_t *bd; | 661 | bd_t *bd; |
662 | int i; | 662 | int i; |
663 | extern void malloc_bin_reloc (void); | 663 | extern void malloc_bin_reloc (void); |
664 | #ifndef CONFIG_ENV_IS_NOWHERE | 664 | #ifndef CONFIG_ENV_IS_NOWHERE |
665 | extern char * env_name_spec; | 665 | extern char * env_name_spec; |
666 | #endif | 666 | #endif |
667 | 667 | ||
668 | #ifndef CFG_NO_FLASH | 668 | #ifndef CFG_NO_FLASH |
669 | ulong flash_size; | 669 | ulong flash_size; |
670 | #endif | 670 | #endif |
671 | 671 | ||
672 | gd = id; /* initialize RAM version of global data */ | 672 | gd = id; /* initialize RAM version of global data */ |
673 | bd = gd->bd; | 673 | bd = gd->bd; |
674 | 674 | ||
675 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ | 675 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
676 | 676 | ||
677 | #if defined(CONFIG_RELOC_FIXUP_WORKS) | 677 | #if defined(CONFIG_RELOC_FIXUP_WORKS) |
678 | gd->reloc_off = 0; | 678 | gd->reloc_off = 0; |
679 | mem_malloc_end = dest_addr; | 679 | mem_malloc_end = dest_addr; |
680 | #else | 680 | #else |
681 | gd->reloc_off = dest_addr - CFG_MONITOR_BASE; | 681 | gd->reloc_off = dest_addr - CFG_MONITOR_BASE; |
682 | #endif | 682 | #endif |
683 | 683 | ||
684 | #ifdef CONFIG_SERIAL_MULTI | 684 | #ifdef CONFIG_SERIAL_MULTI |
685 | serial_initialize(); | 685 | serial_initialize(); |
686 | #endif | 686 | #endif |
687 | 687 | ||
688 | debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); | 688 | debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); |
689 | 689 | ||
690 | WATCHDOG_RESET (); | 690 | WATCHDOG_RESET (); |
691 | 691 | ||
692 | #if defined(CONFIG_BOARD_EARLY_INIT_R) | 692 | #if defined(CONFIG_BOARD_EARLY_INIT_R) |
693 | board_early_init_r (); | 693 | board_early_init_r (); |
694 | #endif | 694 | #endif |
695 | 695 | ||
696 | monitor_flash_len = (ulong)&__init_end - dest_addr; | 696 | monitor_flash_len = (ulong)&__init_end - dest_addr; |
697 | 697 | ||
698 | /* | 698 | /* |
699 | * We have to relocate the command table manually | 699 | * We have to relocate the command table manually |
700 | */ | 700 | */ |
701 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { | 701 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { |
702 | ulong addr; | 702 | ulong addr; |
703 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; | 703 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; |
704 | #if 0 | 704 | #if 0 |
705 | printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", | 705 | printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", |
706 | cmdtp->name, (ulong) (cmdtp->cmd), addr); | 706 | cmdtp->name, (ulong) (cmdtp->cmd), addr); |
707 | #endif | 707 | #endif |
708 | cmdtp->cmd = | 708 | cmdtp->cmd = |
709 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; | 709 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; |
710 | 710 | ||
711 | addr = (ulong)(cmdtp->name) + gd->reloc_off; | 711 | addr = (ulong)(cmdtp->name) + gd->reloc_off; |
712 | cmdtp->name = (char *)addr; | 712 | cmdtp->name = (char *)addr; |
713 | 713 | ||
714 | if (cmdtp->usage) { | 714 | if (cmdtp->usage) { |
715 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; | 715 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; |
716 | cmdtp->usage = (char *)addr; | 716 | cmdtp->usage = (char *)addr; |
717 | } | 717 | } |
718 | #ifdef CFG_LONGHELP | 718 | #ifdef CFG_LONGHELP |
719 | if (cmdtp->help) { | 719 | if (cmdtp->help) { |
720 | addr = (ulong)(cmdtp->help) + gd->reloc_off; | 720 | addr = (ulong)(cmdtp->help) + gd->reloc_off; |
721 | cmdtp->help = (char *)addr; | 721 | cmdtp->help = (char *)addr; |
722 | } | 722 | } |
723 | #endif | 723 | #endif |
724 | } | 724 | } |
725 | /* there are some other pointer constants we must deal with */ | 725 | /* there are some other pointer constants we must deal with */ |
726 | #ifndef CONFIG_ENV_IS_NOWHERE | 726 | #ifndef CONFIG_ENV_IS_NOWHERE |
727 | env_name_spec += gd->reloc_off; | 727 | env_name_spec += gd->reloc_off; |
728 | #endif | 728 | #endif |
729 | 729 | ||
730 | WATCHDOG_RESET (); | 730 | WATCHDOG_RESET (); |
731 | 731 | ||
732 | #ifdef CONFIG_LOGBUFFER | 732 | #ifdef CONFIG_LOGBUFFER |
733 | logbuff_init_ptrs (); | 733 | logbuff_init_ptrs (); |
734 | #endif | 734 | #endif |
735 | #ifdef CONFIG_POST | 735 | #ifdef CONFIG_POST |
736 | post_output_backlog (); | 736 | post_output_backlog (); |
737 | post_reloc (); | 737 | post_reloc (); |
738 | #endif | 738 | #endif |
739 | 739 | ||
740 | WATCHDOG_RESET(); | 740 | WATCHDOG_RESET(); |
741 | 741 | ||
742 | #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || \ | 742 | #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || \ |
743 | defined (CONFIG_FLAGADM) || defined(CONFIG_MPC83XX) | 743 | defined (CONFIG_FLAGADM) || defined(CONFIG_MPC83XX) |
744 | icache_enable (); /* it's time to enable the instruction cache */ | 744 | icache_enable (); /* it's time to enable the instruction cache */ |
745 | #endif | 745 | #endif |
746 | 746 | ||
747 | #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500) | 747 | #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500) |
748 | unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */ | 748 | unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */ |
749 | #endif | 749 | #endif |
750 | 750 | ||
751 | #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45) | 751 | #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45) |
752 | /* | 752 | /* |
753 | * Do PCI configuration on BAB7xx and CPC45 _before_ the flash | 753 | * Do PCI configuration on BAB7xx and CPC45 _before_ the flash |
754 | * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus | 754 | * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus |
755 | * bridge there. | 755 | * bridge there. |
756 | */ | 756 | */ |
757 | pci_init (); | 757 | pci_init (); |
758 | #endif | 758 | #endif |
759 | #if defined(CONFIG_BAB7xx) | 759 | #if defined(CONFIG_BAB7xx) |
760 | /* | 760 | /* |
761 | * Initialise the ISA bridge | 761 | * Initialise the ISA bridge |
762 | */ | 762 | */ |
763 | initialise_w83c553f (); | 763 | initialise_w83c553f (); |
764 | #endif | 764 | #endif |
765 | 765 | ||
766 | asm ("sync ; isync"); | 766 | asm ("sync ; isync"); |
767 | 767 | ||
768 | /* | 768 | /* |
769 | * Setup trap handlers | 769 | * Setup trap handlers |
770 | */ | 770 | */ |
771 | trap_init (dest_addr); | 771 | trap_init (dest_addr); |
772 | 772 | ||
773 | #if !defined(CFG_NO_FLASH) | 773 | #if !defined(CFG_NO_FLASH) |
774 | puts ("FLASH: "); | 774 | puts ("FLASH: "); |
775 | 775 | ||
776 | if ((flash_size = flash_init ()) > 0) { | 776 | if ((flash_size = flash_init ()) > 0) { |
777 | # ifdef CFG_FLASH_CHECKSUM | 777 | # ifdef CFG_FLASH_CHECKSUM |
778 | print_size (flash_size, ""); | 778 | print_size (flash_size, ""); |
779 | /* | 779 | /* |
780 | * Compute and print flash CRC if flashchecksum is set to 'y' | 780 | * Compute and print flash CRC if flashchecksum is set to 'y' |
781 | * | 781 | * |
782 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX | 782 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX |
783 | */ | 783 | */ |
784 | s = getenv ("flashchecksum"); | 784 | s = getenv ("flashchecksum"); |
785 | if (s && (*s == 'y')) { | 785 | if (s && (*s == 'y')) { |
786 | printf (" CRC: %08X", | 786 | printf (" CRC: %08X", |
787 | crc32 (0, (const unsigned char *) CFG_FLASH_BASE, flash_size) | 787 | crc32 (0, (const unsigned char *) CFG_FLASH_BASE, flash_size) |
788 | ); | 788 | ); |
789 | } | 789 | } |
790 | putc ('\n'); | 790 | putc ('\n'); |
791 | # else /* !CFG_FLASH_CHECKSUM */ | 791 | # else /* !CFG_FLASH_CHECKSUM */ |
792 | print_size (flash_size, "\n"); | 792 | print_size (flash_size, "\n"); |
793 | # endif /* CFG_FLASH_CHECKSUM */ | 793 | # endif /* CFG_FLASH_CHECKSUM */ |
794 | } else { | 794 | } else { |
795 | puts (failed); | 795 | puts (failed); |
796 | hang (); | 796 | hang (); |
797 | } | 797 | } |
798 | 798 | ||
799 | bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */ | 799 | bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */ |
800 | bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ | 800 | bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ |
801 | 801 | ||
802 | #if defined(CFG_UPDATE_FLASH_SIZE) | 802 | #if defined(CFG_UPDATE_FLASH_SIZE) |
803 | /* Make a update of the Memctrl. */ | 803 | /* Make a update of the Memctrl. */ |
804 | update_flash_size (flash_size); | 804 | update_flash_size (flash_size); |
805 | #endif | 805 | #endif |
806 | 806 | ||
807 | 807 | ||
808 | # if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) || defined(CONFIG_RMU) | 808 | # if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) || defined(CONFIG_RMU) |
809 | /* flash mapped at end of memory map */ | 809 | /* flash mapped at end of memory map */ |
810 | bd->bi_flashoffset = TEXT_BASE + flash_size; | 810 | bd->bi_flashoffset = TEXT_BASE + flash_size; |
811 | # elif CFG_MONITOR_BASE == CFG_FLASH_BASE | 811 | # elif CFG_MONITOR_BASE == CFG_FLASH_BASE |
812 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */ | 812 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */ |
813 | # else | 813 | # else |
814 | bd->bi_flashoffset = 0; | 814 | bd->bi_flashoffset = 0; |
815 | # endif | 815 | # endif |
816 | #else /* CFG_NO_FLASH */ | 816 | #else /* CFG_NO_FLASH */ |
817 | 817 | ||
818 | bd->bi_flashsize = 0; | 818 | bd->bi_flashsize = 0; |
819 | bd->bi_flashstart = 0; | 819 | bd->bi_flashstart = 0; |
820 | bd->bi_flashoffset = 0; | 820 | bd->bi_flashoffset = 0; |
821 | #endif /* !CFG_NO_FLASH */ | 821 | #endif /* !CFG_NO_FLASH */ |
822 | 822 | ||
823 | WATCHDOG_RESET (); | 823 | WATCHDOG_RESET (); |
824 | 824 | ||
825 | /* initialize higher level parts of CPU like time base and timers */ | 825 | /* initialize higher level parts of CPU like time base and timers */ |
826 | cpu_init_r (); | 826 | cpu_init_r (); |
827 | 827 | ||
828 | WATCHDOG_RESET (); | 828 | WATCHDOG_RESET (); |
829 | 829 | ||
830 | /* initialize malloc() area */ | 830 | /* initialize malloc() area */ |
831 | mem_malloc_init (); | 831 | mem_malloc_init (); |
832 | malloc_bin_reloc (); | 832 | malloc_bin_reloc (); |
833 | 833 | ||
834 | #ifdef CONFIG_SPI | 834 | #ifdef CONFIG_SPI |
835 | # if !defined(CONFIG_ENV_IS_IN_EEPROM) | 835 | # if !defined(CONFIG_ENV_IS_IN_EEPROM) |
836 | spi_init_f (); | 836 | spi_init_f (); |
837 | # endif | 837 | # endif |
838 | spi_init_r (); | 838 | spi_init_r (); |
839 | #endif | 839 | #endif |
840 | 840 | ||
841 | #if defined(CONFIG_CMD_NAND) | 841 | #if defined(CONFIG_CMD_NAND) |
842 | WATCHDOG_RESET (); | 842 | WATCHDOG_RESET (); |
843 | puts ("NAND: "); | 843 | puts ("NAND: "); |
844 | nand_init(); /* go init the NAND */ | 844 | nand_init(); /* go init the NAND */ |
845 | #endif | 845 | #endif |
846 | 846 | ||
847 | /* relocate environment function pointers etc. */ | 847 | /* relocate environment function pointers etc. */ |
848 | env_relocate (); | 848 | env_relocate (); |
849 | 849 | ||
850 | /* | 850 | /* |
851 | * Fill in missing fields of bd_info. | 851 | * Fill in missing fields of bd_info. |
852 | * We do this here, where we have "normal" access to the | 852 | * We do this here, where we have "normal" access to the |
853 | * environment; we used to do this still running from ROM, | 853 | * environment; we used to do this still running from ROM, |
854 | * where had to use getenv_r(), which can be pretty slow when | 854 | * where had to use getenv_r(), which can be pretty slow when |
855 | * the environment is in EEPROM. | 855 | * the environment is in EEPROM. |
856 | */ | 856 | */ |
857 | 857 | ||
858 | #if defined(CFG_EXTBDINFO) | 858 | #if defined(CFG_EXTBDINFO) |
859 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) | 859 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) |
860 | #if defined(CONFIG_I2CFAST) | 860 | #if defined(CONFIG_I2CFAST) |
861 | /* | 861 | /* |
862 | * set bi_iic_fast for linux taking environment variable | 862 | * set bi_iic_fast for linux taking environment variable |
863 | * "i2cfast" into account | 863 | * "i2cfast" into account |
864 | */ | 864 | */ |
865 | { | 865 | { |
866 | char *s = getenv ("i2cfast"); | 866 | char *s = getenv ("i2cfast"); |
867 | if (s && ((*s == 'y') || (*s == 'Y'))) { | 867 | if (s && ((*s == 'y') || (*s == 'Y'))) { |
868 | bd->bi_iic_fast[0] = 1; | 868 | bd->bi_iic_fast[0] = 1; |
869 | bd->bi_iic_fast[1] = 1; | 869 | bd->bi_iic_fast[1] = 1; |
870 | } else { | 870 | } else { |
871 | bd->bi_iic_fast[0] = 0; | 871 | bd->bi_iic_fast[0] = 0; |
872 | bd->bi_iic_fast[1] = 0; | 872 | bd->bi_iic_fast[1] = 0; |
873 | } | 873 | } |
874 | } | 874 | } |
875 | #else | 875 | #else |
876 | bd->bi_iic_fast[0] = 0; | 876 | bd->bi_iic_fast[0] = 0; |
877 | bd->bi_iic_fast[1] = 0; | 877 | bd->bi_iic_fast[1] = 0; |
878 | #endif /* CONFIG_I2CFAST */ | 878 | #endif /* CONFIG_I2CFAST */ |
879 | #endif /* CONFIG_405GP, CONFIG_405EP */ | 879 | #endif /* CONFIG_405GP, CONFIG_405EP */ |
880 | #endif /* CFG_EXTBDINFO */ | 880 | #endif /* CFG_EXTBDINFO */ |
881 | 881 | ||
882 | #if defined(CONFIG_SC3) | 882 | #if defined(CONFIG_SC3) |
883 | sc3_read_eeprom(); | 883 | sc3_read_eeprom(); |
884 | #endif | 884 | #endif |
885 | 885 | ||
886 | #if defined (CONFIG_ID_EEPROM) || defined (CFG_I2C_MAC_OFFSET) | 886 | #if defined (CONFIG_ID_EEPROM) || defined (CFG_I2C_MAC_OFFSET) |
887 | mac_read_from_eeprom(); | 887 | mac_read_from_eeprom(); |
888 | #endif | 888 | #endif |
889 | 889 | ||
890 | s = getenv ("ethaddr"); | 890 | s = getenv ("ethaddr"); |
891 | #if defined (CONFIG_MBX) || \ | 891 | #if defined (CONFIG_MBX) || \ |
892 | defined (CONFIG_RPXCLASSIC) || \ | 892 | defined (CONFIG_RPXCLASSIC) || \ |
893 | defined(CONFIG_IAD210) || \ | 893 | defined(CONFIG_IAD210) || \ |
894 | defined(CONFIG_V38B) | 894 | defined(CONFIG_V38B) |
895 | if (s == NULL) | 895 | if (s == NULL) |
896 | board_get_enetaddr (bd->bi_enetaddr); | 896 | board_get_enetaddr (bd->bi_enetaddr); |
897 | else | 897 | else |
898 | #endif | 898 | #endif |
899 | for (i = 0; i < 6; ++i) { | 899 | for (i = 0; i < 6; ++i) { |
900 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 900 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
901 | if (s) | 901 | if (s) |
902 | s = (*e) ? e + 1 : e; | 902 | s = (*e) ? e + 1 : e; |
903 | } | 903 | } |
904 | #ifdef CONFIG_HERMES | 904 | #ifdef CONFIG_HERMES |
905 | if ((gd->board_type >> 16) == 2) | 905 | if ((gd->board_type >> 16) == 2) |
906 | bd->bi_ethspeed = gd->board_type & 0xFFFF; | 906 | bd->bi_ethspeed = gd->board_type & 0xFFFF; |
907 | else | 907 | else |
908 | bd->bi_ethspeed = 0xFFFF; | 908 | bd->bi_ethspeed = 0xFFFF; |
909 | #endif | 909 | #endif |
910 | 910 | ||
911 | #ifdef CONFIG_NX823 | 911 | #ifdef CONFIG_NX823 |
912 | load_sernum_ethaddr (); | 912 | load_sernum_ethaddr (); |
913 | #endif | 913 | #endif |
914 | 914 | ||
915 | #ifdef CONFIG_HAS_ETH1 | 915 | #ifdef CONFIG_HAS_ETH1 |
916 | /* handle the 2nd ethernet address */ | 916 | /* handle the 2nd ethernet address */ |
917 | 917 | ||
918 | s = getenv ("eth1addr"); | 918 | s = getenv ("eth1addr"); |
919 | 919 | ||
920 | for (i = 0; i < 6; ++i) { | 920 | for (i = 0; i < 6; ++i) { |
921 | bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 921 | bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
922 | if (s) | 922 | if (s) |
923 | s = (*e) ? e + 1 : e; | 923 | s = (*e) ? e + 1 : e; |
924 | } | 924 | } |
925 | #endif | 925 | #endif |
926 | #ifdef CONFIG_HAS_ETH2 | 926 | #ifdef CONFIG_HAS_ETH2 |
927 | /* handle the 3rd ethernet address */ | 927 | /* handle the 3rd ethernet address */ |
928 | 928 | ||
929 | s = getenv ("eth2addr"); | 929 | s = getenv ("eth2addr"); |
930 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) | 930 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) |
931 | if (s == NULL) | 931 | if (s == NULL) |
932 | board_get_enetaddr(bd->bi_enet2addr); | 932 | board_get_enetaddr(bd->bi_enet2addr); |
933 | else | 933 | else |
934 | #endif | 934 | #endif |
935 | for (i = 0; i < 6; ++i) { | 935 | for (i = 0; i < 6; ++i) { |
936 | bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 936 | bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
937 | if (s) | 937 | if (s) |
938 | s = (*e) ? e + 1 : e; | 938 | s = (*e) ? e + 1 : e; |
939 | } | 939 | } |
940 | #endif | 940 | #endif |
941 | 941 | ||
942 | #ifdef CONFIG_HAS_ETH3 | 942 | #ifdef CONFIG_HAS_ETH3 |
943 | /* handle 4th ethernet address */ | 943 | /* handle 4th ethernet address */ |
944 | s = getenv("eth3addr"); | 944 | s = getenv("eth3addr"); |
945 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) | 945 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) |
946 | if (s == NULL) | 946 | if (s == NULL) |
947 | board_get_enetaddr(bd->bi_enet3addr); | 947 | board_get_enetaddr(bd->bi_enet3addr); |
948 | else | 948 | else |
949 | #endif | 949 | #endif |
950 | for (i = 0; i < 6; ++i) { | 950 | for (i = 0; i < 6; ++i) { |
951 | bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 951 | bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
952 | if (s) | 952 | if (s) |
953 | s = (*e) ? e + 1 : e; | 953 | s = (*e) ? e + 1 : e; |
954 | } | 954 | } |
955 | #endif | 955 | #endif |
956 | 956 | ||
957 | #ifdef CONFIG_HAS_ETH4 | ||
958 | /* handle 5th ethernet address */ | ||
959 | s = getenv("eth4addr"); | ||
960 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) | ||
961 | if (s == NULL) | ||
962 | board_get_enetaddr(bd->bi_enet4addr); | ||
963 | else | ||
964 | #endif | ||
965 | for (i = 0; i < 6; ++i) { | ||
966 | bd->bi_enet4addr[i] = s ? simple_strtoul (s, &e, 16) : 0; | ||
967 | if (s) | ||
968 | s = (*e) ? e + 1 : e; | ||
969 | } | ||
970 | #endif | ||
971 | |||
972 | #ifdef CONFIG_HAS_ETH5 | ||
973 | /* handle 6th ethernet address */ | ||
974 | s = getenv("eth5addr"); | ||
975 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) | ||
976 | if (s == NULL) | ||
977 | board_get_enetaddr(bd->bi_enet5addr); | ||
978 | else | ||
979 | #endif | ||
980 | for (i = 0; i < 6; ++i) { | ||
981 | bd->bi_enet5addr[i] = s ? simple_strtoul (s, &e, 16) : 0; | ||
982 | if (s) | ||
983 | s = (*e) ? e + 1 : e; | ||
984 | } | ||
985 | #endif | ||
986 | |||
957 | #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \ | 987 | #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \ |
958 | defined(CONFIG_TQM8272) || \ | 988 | defined(CONFIG_TQM8272) || \ |
959 | defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \ | 989 | defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \ |
960 | defined(CONFIG_KUP4X) || defined(CONFIG_PCS440EP) | 990 | defined(CONFIG_KUP4X) || defined(CONFIG_PCS440EP) |
961 | load_sernum_ethaddr (); | 991 | load_sernum_ethaddr (); |
962 | #endif | 992 | #endif |
963 | /* IP Address */ | 993 | /* IP Address */ |
964 | bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); | 994 | bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); |
965 | 995 | ||
966 | WATCHDOG_RESET (); | 996 | WATCHDOG_RESET (); |
967 | 997 | ||
968 | #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) && !defined(CONFIG_CPC45) | 998 | #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) && !defined(CONFIG_CPC45) |
969 | /* | 999 | /* |
970 | * Do pci configuration | 1000 | * Do pci configuration |
971 | */ | 1001 | */ |
972 | pci_init (); | 1002 | pci_init (); |
973 | #endif | 1003 | #endif |
974 | 1004 | ||
975 | /** leave this here (after malloc(), environment and PCI are working) **/ | 1005 | /** leave this here (after malloc(), environment and PCI are working) **/ |
976 | /* Initialize devices */ | 1006 | /* Initialize devices */ |
977 | devices_init (); | 1007 | devices_init (); |
978 | 1008 | ||
979 | /* Initialize the jump table for applications */ | 1009 | /* Initialize the jump table for applications */ |
980 | jumptable_init (); | 1010 | jumptable_init (); |
981 | 1011 | ||
982 | #if defined(CONFIG_API) | 1012 | #if defined(CONFIG_API) |
983 | /* Initialize API */ | 1013 | /* Initialize API */ |
984 | api_init (); | 1014 | api_init (); |
985 | #endif | 1015 | #endif |
986 | 1016 | ||
987 | /* Initialize the console (after the relocation and devices init) */ | 1017 | /* Initialize the console (after the relocation and devices init) */ |
988 | console_init_r (); | 1018 | console_init_r (); |
989 | 1019 | ||
990 | #if defined(CONFIG_CCM) || \ | 1020 | #if defined(CONFIG_CCM) || \ |
991 | defined(CONFIG_COGENT) || \ | 1021 | defined(CONFIG_COGENT) || \ |
992 | defined(CONFIG_CPCI405) || \ | 1022 | defined(CONFIG_CPCI405) || \ |
993 | defined(CONFIG_EVB64260) || \ | 1023 | defined(CONFIG_EVB64260) || \ |
994 | defined(CONFIG_KUP4K) || \ | 1024 | defined(CONFIG_KUP4K) || \ |
995 | defined(CONFIG_KUP4X) || \ | 1025 | defined(CONFIG_KUP4X) || \ |
996 | defined(CONFIG_LWMON) || \ | 1026 | defined(CONFIG_LWMON) || \ |
997 | defined(CONFIG_PCU_E) || \ | 1027 | defined(CONFIG_PCU_E) || \ |
998 | defined(CONFIG_SC3) || \ | 1028 | defined(CONFIG_SC3) || \ |
999 | defined(CONFIG_W7O) || \ | 1029 | defined(CONFIG_W7O) || \ |
1000 | defined(CONFIG_MISC_INIT_R) | 1030 | defined(CONFIG_MISC_INIT_R) |
1001 | /* miscellaneous platform dependent initialisations */ | 1031 | /* miscellaneous platform dependent initialisations */ |
1002 | misc_init_r (); | 1032 | misc_init_r (); |
1003 | #endif | 1033 | #endif |
1004 | 1034 | ||
1005 | #ifdef CONFIG_HERMES | 1035 | #ifdef CONFIG_HERMES |
1006 | if (bd->bi_ethspeed != 0xFFFF) | 1036 | if (bd->bi_ethspeed != 0xFFFF) |
1007 | hermes_start_lxt980 ((int) bd->bi_ethspeed); | 1037 | hermes_start_lxt980 ((int) bd->bi_ethspeed); |
1008 | #endif | 1038 | #endif |
1009 | 1039 | ||
1010 | #if defined(CONFIG_CMD_KGDB) | 1040 | #if defined(CONFIG_CMD_KGDB) |
1011 | WATCHDOG_RESET (); | 1041 | WATCHDOG_RESET (); |
1012 | puts ("KGDB: "); | 1042 | puts ("KGDB: "); |
1013 | kgdb_init (); | 1043 | kgdb_init (); |
1014 | #endif | 1044 | #endif |
1015 | 1045 | ||
1016 | debug ("U-Boot relocated to %08lx\n", dest_addr); | 1046 | debug ("U-Boot relocated to %08lx\n", dest_addr); |
1017 | 1047 | ||
1018 | /* | 1048 | /* |
1019 | * Enable Interrupts | 1049 | * Enable Interrupts |
1020 | */ | 1050 | */ |
1021 | interrupt_init (); | 1051 | interrupt_init (); |
1022 | 1052 | ||
1023 | /* Must happen after interrupts are initialized since | 1053 | /* Must happen after interrupts are initialized since |
1024 | * an irq handler gets installed | 1054 | * an irq handler gets installed |
1025 | */ | 1055 | */ |
1026 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO | 1056 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO |
1027 | serial_buffered_init(); | 1057 | serial_buffered_init(); |
1028 | #endif | 1058 | #endif |
1029 | 1059 | ||
1030 | #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) | 1060 | #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) |
1031 | status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); | 1061 | status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); |
1032 | #endif | 1062 | #endif |
1033 | 1063 | ||
1034 | udelay (20); | 1064 | udelay (20); |
1035 | 1065 | ||
1036 | set_timer (0); | 1066 | set_timer (0); |
1037 | 1067 | ||
1038 | /* Initialize from environment */ | 1068 | /* Initialize from environment */ |
1039 | if ((s = getenv ("loadaddr")) != NULL) { | 1069 | if ((s = getenv ("loadaddr")) != NULL) { |
1040 | load_addr = simple_strtoul (s, NULL, 16); | 1070 | load_addr = simple_strtoul (s, NULL, 16); |
1041 | } | 1071 | } |
1042 | #if defined(CONFIG_CMD_NET) | 1072 | #if defined(CONFIG_CMD_NET) |
1043 | if ((s = getenv ("bootfile")) != NULL) { | 1073 | if ((s = getenv ("bootfile")) != NULL) { |
1044 | copy_filename (BootFile, s, sizeof (BootFile)); | 1074 | copy_filename (BootFile, s, sizeof (BootFile)); |
1045 | } | 1075 | } |
1046 | #endif | 1076 | #endif |
1047 | 1077 | ||
1048 | WATCHDOG_RESET (); | 1078 | WATCHDOG_RESET (); |
1049 | 1079 | ||
1050 | #if defined(CONFIG_CMD_SCSI) | 1080 | #if defined(CONFIG_CMD_SCSI) |
1051 | WATCHDOG_RESET (); | 1081 | WATCHDOG_RESET (); |
1052 | puts ("SCSI: "); | 1082 | puts ("SCSI: "); |
1053 | scsi_init (); | 1083 | scsi_init (); |
1054 | #endif | 1084 | #endif |
1055 | 1085 | ||
1056 | #if defined(CONFIG_CMD_DOC) | 1086 | #if defined(CONFIG_CMD_DOC) |
1057 | WATCHDOG_RESET (); | 1087 | WATCHDOG_RESET (); |
1058 | puts ("DOC: "); | 1088 | puts ("DOC: "); |
1059 | doc_init (); | 1089 | doc_init (); |
1060 | #endif | 1090 | #endif |
1061 | 1091 | ||
1062 | #if defined(CONFIG_CMD_NET) | 1092 | #if defined(CONFIG_CMD_NET) |
1063 | #if defined(CONFIG_NET_MULTI) | 1093 | #if defined(CONFIG_NET_MULTI) |
1064 | WATCHDOG_RESET (); | 1094 | WATCHDOG_RESET (); |
1065 | puts ("Net: "); | 1095 | puts ("Net: "); |
1066 | #endif | 1096 | #endif |
1067 | eth_initialize (bd); | 1097 | eth_initialize (bd); |
1068 | #endif | 1098 | #endif |
1069 | 1099 | ||
1070 | #if defined(CONFIG_CMD_NET) && ( \ | 1100 | #if defined(CONFIG_CMD_NET) && ( \ |
1071 | defined(CONFIG_CCM) || \ | 1101 | defined(CONFIG_CCM) || \ |
1072 | defined(CONFIG_ELPT860) || \ | 1102 | defined(CONFIG_ELPT860) || \ |
1073 | defined(CONFIG_EP8260) || \ | 1103 | defined(CONFIG_EP8260) || \ |
1074 | defined(CONFIG_IP860) || \ | 1104 | defined(CONFIG_IP860) || \ |
1075 | defined(CONFIG_IVML24) || \ | 1105 | defined(CONFIG_IVML24) || \ |
1076 | defined(CONFIG_IVMS8) || \ | 1106 | defined(CONFIG_IVMS8) || \ |
1077 | defined(CONFIG_MPC8260ADS) || \ | 1107 | defined(CONFIG_MPC8260ADS) || \ |
1078 | defined(CONFIG_MPC8266ADS) || \ | 1108 | defined(CONFIG_MPC8266ADS) || \ |
1079 | defined(CONFIG_MPC8560ADS) || \ | 1109 | defined(CONFIG_MPC8560ADS) || \ |
1080 | defined(CONFIG_PCU_E) || \ | 1110 | defined(CONFIG_PCU_E) || \ |
1081 | defined(CONFIG_RPXSUPER) || \ | 1111 | defined(CONFIG_RPXSUPER) || \ |
1082 | defined(CONFIG_STXGP3) || \ | 1112 | defined(CONFIG_STXGP3) || \ |
1083 | defined(CONFIG_SPD823TS) || \ | 1113 | defined(CONFIG_SPD823TS) || \ |
1084 | defined(CONFIG_RESET_PHY_R) ) | 1114 | defined(CONFIG_RESET_PHY_R) ) |
1085 | 1115 | ||
1086 | WATCHDOG_RESET (); | 1116 | WATCHDOG_RESET (); |
1087 | debug ("Reset Ethernet PHY\n"); | 1117 | debug ("Reset Ethernet PHY\n"); |
1088 | reset_phy (); | 1118 | reset_phy (); |
1089 | #endif | 1119 | #endif |
1090 | 1120 | ||
1091 | #ifdef CONFIG_POST | 1121 | #ifdef CONFIG_POST |
1092 | post_run (NULL, POST_RAM | post_bootmode_get(0)); | 1122 | post_run (NULL, POST_RAM | post_bootmode_get(0)); |
1093 | #endif | 1123 | #endif |
1094 | 1124 | ||
1095 | #if defined(CONFIG_CMD_PCMCIA) \ | 1125 | #if defined(CONFIG_CMD_PCMCIA) \ |
1096 | && !defined(CONFIG_CMD_IDE) | 1126 | && !defined(CONFIG_CMD_IDE) |
1097 | WATCHDOG_RESET (); | 1127 | WATCHDOG_RESET (); |
1098 | puts ("PCMCIA:"); | 1128 | puts ("PCMCIA:"); |
1099 | pcmcia_init (); | 1129 | pcmcia_init (); |
1100 | #endif | 1130 | #endif |
1101 | 1131 | ||
1102 | #if defined(CONFIG_CMD_IDE) | 1132 | #if defined(CONFIG_CMD_IDE) |
1103 | WATCHDOG_RESET (); | 1133 | WATCHDOG_RESET (); |
1104 | # ifdef CONFIG_IDE_8xx_PCCARD | 1134 | # ifdef CONFIG_IDE_8xx_PCCARD |
1105 | puts ("PCMCIA:"); | 1135 | puts ("PCMCIA:"); |
1106 | # else | 1136 | # else |
1107 | puts ("IDE: "); | 1137 | puts ("IDE: "); |
1108 | #endif | 1138 | #endif |
1109 | #if defined(CONFIG_START_IDE) | 1139 | #if defined(CONFIG_START_IDE) |
1110 | if (board_start_ide()) | 1140 | if (board_start_ide()) |
1111 | ide_init (); | 1141 | ide_init (); |
1112 | #else | 1142 | #else |
1113 | ide_init (); | 1143 | ide_init (); |
1114 | #endif | 1144 | #endif |
1115 | #endif | 1145 | #endif |
1116 | 1146 | ||
1117 | #if defined(CONFIG_CMD_SATA) | 1147 | #if defined(CONFIG_CMD_SATA) |
1118 | if (is_sata_supported()) { | 1148 | if (is_sata_supported()) { |
1119 | puts("SATA: "); | 1149 | puts("SATA: "); |
1120 | sata_initialize(); | 1150 | sata_initialize(); |
1121 | } | 1151 | } |
1122 | #endif | 1152 | #endif |
1123 | 1153 | ||
1124 | #ifdef CONFIG_LAST_STAGE_INIT | 1154 | #ifdef CONFIG_LAST_STAGE_INIT |
1125 | WATCHDOG_RESET (); | 1155 | WATCHDOG_RESET (); |
1126 | /* | 1156 | /* |
1127 | * Some parts can be only initialized if all others (like | 1157 | * Some parts can be only initialized if all others (like |
1128 | * Interrupts) are up and running (i.e. the PC-style ISA | 1158 | * Interrupts) are up and running (i.e. the PC-style ISA |
1129 | * keyboard). | 1159 | * keyboard). |
1130 | */ | 1160 | */ |
1131 | last_stage_init (); | 1161 | last_stage_init (); |
1132 | #endif | 1162 | #endif |
1133 | 1163 | ||
1134 | #if defined(CONFIG_CMD_BEDBUG) | 1164 | #if defined(CONFIG_CMD_BEDBUG) |
1135 | WATCHDOG_RESET (); | 1165 | WATCHDOG_RESET (); |
1136 | bedbug_init (); | 1166 | bedbug_init (); |
1137 | #endif | 1167 | #endif |
1138 | 1168 | ||
1139 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) | 1169 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) |
1140 | /* | 1170 | /* |
1141 | * Export available size of memory for Linux, | 1171 | * Export available size of memory for Linux, |
1142 | * taking into account the protected RAM at top of memory | 1172 | * taking into account the protected RAM at top of memory |
1143 | */ | 1173 | */ |
1144 | { | 1174 | { |
1145 | ulong pram; | 1175 | ulong pram; |
1146 | uchar memsz[32]; | 1176 | uchar memsz[32]; |
1147 | #ifdef CONFIG_PRAM | 1177 | #ifdef CONFIG_PRAM |
1148 | char *s; | 1178 | char *s; |
1149 | 1179 | ||
1150 | if ((s = getenv ("pram")) != NULL) { | 1180 | if ((s = getenv ("pram")) != NULL) { |
1151 | pram = simple_strtoul (s, NULL, 10); | 1181 | pram = simple_strtoul (s, NULL, 10); |
1152 | } else { | 1182 | } else { |
1153 | pram = CONFIG_PRAM; | 1183 | pram = CONFIG_PRAM; |
1154 | } | 1184 | } |
1155 | #else | 1185 | #else |
1156 | pram=0; | 1186 | pram=0; |
1157 | #endif | 1187 | #endif |
1158 | #ifdef CONFIG_LOGBUFFER | 1188 | #ifdef CONFIG_LOGBUFFER |
1159 | #ifndef CONFIG_ALT_LB_ADDR | 1189 | #ifndef CONFIG_ALT_LB_ADDR |
1160 | /* Also take the logbuffer into account (pram is in kB) */ | 1190 | /* Also take the logbuffer into account (pram is in kB) */ |
1161 | pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024; | 1191 | pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024; |
1162 | #endif | 1192 | #endif |
1163 | #endif | 1193 | #endif |
1164 | sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram); | 1194 | sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram); |
1165 | setenv ("mem", (char *)memsz); | 1195 | setenv ("mem", (char *)memsz); |
1166 | } | 1196 | } |
1167 | #endif | 1197 | #endif |
1168 | 1198 | ||
1169 | #ifdef CONFIG_PS2KBD | 1199 | #ifdef CONFIG_PS2KBD |
1170 | puts ("PS/2: "); | 1200 | puts ("PS/2: "); |
1171 | kbd_init(); | 1201 | kbd_init(); |
1172 | #endif | 1202 | #endif |
1173 | 1203 | ||
1174 | #ifdef CONFIG_MODEM_SUPPORT | 1204 | #ifdef CONFIG_MODEM_SUPPORT |
1175 | { | 1205 | { |
1176 | extern int do_mdm_init; | 1206 | extern int do_mdm_init; |
1177 | do_mdm_init = gd->do_mdm_init; | 1207 | do_mdm_init = gd->do_mdm_init; |
1178 | } | 1208 | } |
1179 | #endif | 1209 | #endif |
1180 | 1210 | ||
1181 | /* Initialization complete - start the monitor */ | 1211 | /* Initialization complete - start the monitor */ |
1182 | 1212 | ||
1183 | /* main_loop() can return to retry autoboot, if so just run it again. */ | 1213 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
1184 | for (;;) { | 1214 | for (;;) { |
1185 | WATCHDOG_RESET (); | 1215 | WATCHDOG_RESET (); |
1186 | main_loop (); | 1216 | main_loop (); |
1187 | } | 1217 | } |
1188 | 1218 | ||
1189 | /* NOTREACHED - no way out of command loop except booting */ | 1219 | /* NOTREACHED - no way out of command loop except booting */ |
1190 | } | 1220 | } |
1191 | 1221 | ||
1192 | void hang (void) | 1222 | void hang (void) |
1193 | { | 1223 | { |
1194 | puts ("### ERROR ### Please RESET the board ###\n"); | 1224 | puts ("### ERROR ### Please RESET the board ###\n"); |
1195 | show_boot_progress(-30); | 1225 | show_boot_progress(-30); |
1196 | for (;;); | 1226 | for (;;); |
1197 | } | 1227 | } |
1198 | 1228 | ||
1199 | #ifdef CONFIG_MODEM_SUPPORT | 1229 | #ifdef CONFIG_MODEM_SUPPORT |
1200 | /* called from main loop (common/main.c) */ | 1230 | /* called from main loop (common/main.c) */ |
1201 | /* 'inline' - We have to do it fast */ | 1231 | /* 'inline' - We have to do it fast */ |
1202 | static inline void mdm_readline(char *buf, int bufsiz) | 1232 | static inline void mdm_readline(char *buf, int bufsiz) |
1203 | { | 1233 | { |
1204 | char c; | 1234 | char c; |
1205 | char *p; | 1235 | char *p; |
1206 | int n; | 1236 | int n; |
1207 | 1237 | ||
1208 | n = 0; | 1238 | n = 0; |
1209 | p = buf; | 1239 | p = buf; |
1210 | for(;;) { | 1240 | for(;;) { |
1211 | c = serial_getc(); | 1241 | c = serial_getc(); |
1212 | 1242 | ||
1213 | /* dbg("(%c)", c); */ | 1243 | /* dbg("(%c)", c); */ |
1214 | 1244 | ||
1215 | switch(c) { | 1245 | switch(c) { |
1216 | case '\r': | 1246 | case '\r': |
1217 | break; | 1247 | break; |
1218 | case '\n': | 1248 | case '\n': |
1219 | *p = '\0'; | 1249 | *p = '\0'; |
1220 | return; | 1250 | return; |
1221 | 1251 | ||
1222 | default: | 1252 | default: |
1223 | if(n++ > bufsiz) { | 1253 | if(n++ > bufsiz) { |
1224 | *p = '\0'; | 1254 | *p = '\0'; |
1225 | return; /* sanity check */ | 1255 | return; /* sanity check */ |
1226 | } | 1256 | } |
1227 | *p = c; | 1257 | *p = c; |
1228 | p++; | 1258 | p++; |
1229 | break; | 1259 | break; |
1230 | } | 1260 | } |
1231 | } | 1261 | } |
1232 | } | 1262 | } |
1233 | 1263 | ||
1234 | extern void dbg(const char *fmt, ...); | 1264 | extern void dbg(const char *fmt, ...); |
1235 | int mdm_init (void) | 1265 | int mdm_init (void) |
1236 | { | 1266 | { |
1237 | char env_str[16]; | 1267 | char env_str[16]; |
1238 | char *init_str; | 1268 | char *init_str; |
1239 | int i; | 1269 | int i; |
1240 | extern char console_buffer[]; | 1270 | extern char console_buffer[]; |
1241 | extern void enable_putc(void); | 1271 | extern void enable_putc(void); |
1242 | extern int hwflow_onoff(int); | 1272 | extern int hwflow_onoff(int); |
1243 | 1273 | ||
1244 | enable_putc(); /* enable serial_putc() */ | 1274 | enable_putc(); /* enable serial_putc() */ |
1245 | 1275 | ||
1246 | #ifdef CONFIG_HWFLOW | 1276 | #ifdef CONFIG_HWFLOW |
1247 | init_str = getenv("mdm_flow_control"); | 1277 | init_str = getenv("mdm_flow_control"); |
1248 | if (init_str && (strcmp(init_str, "rts/cts") == 0)) | 1278 | if (init_str && (strcmp(init_str, "rts/cts") == 0)) |
1249 | hwflow_onoff (1); | 1279 | hwflow_onoff (1); |
1250 | else | 1280 | else |
1251 | hwflow_onoff(-1); | 1281 | hwflow_onoff(-1); |
1252 | #endif | 1282 | #endif |
1253 | 1283 | ||
1254 | for (i = 1;;i++) { | 1284 | for (i = 1;;i++) { |
1255 | sprintf(env_str, "mdm_init%d", i); | 1285 | sprintf(env_str, "mdm_init%d", i); |
1256 | if ((init_str = getenv(env_str)) != NULL) { | 1286 | if ((init_str = getenv(env_str)) != NULL) { |
1257 | serial_puts(init_str); | 1287 | serial_puts(init_str); |
1258 | serial_puts("\n"); | 1288 | serial_puts("\n"); |
1259 | for(;;) { | 1289 | for(;;) { |
1260 | mdm_readline(console_buffer, CFG_CBSIZE); | 1290 | mdm_readline(console_buffer, CFG_CBSIZE); |
1261 | dbg("ini%d: [%s]", i, console_buffer); | 1291 | dbg("ini%d: [%s]", i, console_buffer); |
1262 | 1292 | ||
1263 | if ((strcmp(console_buffer, "OK") == 0) || | 1293 | if ((strcmp(console_buffer, "OK") == 0) || |
1264 | (strcmp(console_buffer, "ERROR") == 0)) { | 1294 | (strcmp(console_buffer, "ERROR") == 0)) { |
1265 | dbg("ini%d: cmd done", i); | 1295 | dbg("ini%d: cmd done", i); |
1266 | break; | 1296 | break; |
1267 | } else /* in case we are originating call ... */ | 1297 | } else /* in case we are originating call ... */ |
1268 | if (strncmp(console_buffer, "CONNECT", 7) == 0) { | 1298 | if (strncmp(console_buffer, "CONNECT", 7) == 0) { |
1269 | dbg("ini%d: connect", i); | 1299 | dbg("ini%d: connect", i); |
1270 | return 0; | 1300 | return 0; |
1271 | } | 1301 | } |
1272 | } | 1302 | } |
1273 | } else | 1303 | } else |
1274 | break; /* no init string - stop modem init */ | 1304 | break; /* no init string - stop modem init */ |
1275 | 1305 | ||
1276 | udelay(100000); | 1306 | udelay(100000); |
1277 | } | 1307 | } |
1278 | 1308 | ||
1279 | udelay(100000); | 1309 | udelay(100000); |
1280 | 1310 | ||
1281 | /* final stage - wait for connect */ | 1311 | /* final stage - wait for connect */ |
1282 | for(;i > 1;) { /* if 'i' > 1 - wait for connection | 1312 | for(;i > 1;) { /* if 'i' > 1 - wait for connection |
1283 | message from modem */ | 1313 | message from modem */ |
1284 | mdm_readline(console_buffer, CFG_CBSIZE); | 1314 | mdm_readline(console_buffer, CFG_CBSIZE); |
1285 | dbg("ini_f: [%s]", console_buffer); | 1315 | dbg("ini_f: [%s]", console_buffer); |
1286 | if (strncmp(console_buffer, "CONNECT", 7) == 0) { | 1316 | if (strncmp(console_buffer, "CONNECT", 7) == 0) { |
1287 | dbg("ini_f: connected"); | 1317 | dbg("ini_f: connected"); |
1288 | return 0; | 1318 | return 0; |
1289 | } | 1319 | } |
1290 | } | 1320 | } |
1291 | 1321 | ||
1292 | return 0; | 1322 | return 0; |
1293 | } | 1323 | } |
1294 | 1324 | ||
1295 | #endif | 1325 | #endif |
1296 | 1326 | ||
1297 | #if 0 /* We could use plain global data, but the resulting code is bigger */ | 1327 | #if 0 /* We could use plain global data, but the resulting code is bigger */ |
1298 | /* | 1328 | /* |
1299 | * Pointer to initial global data area | 1329 | * Pointer to initial global data area |
1300 | * | 1330 | * |
1301 | * Here we initialize it. | 1331 | * Here we initialize it. |
1302 | */ | 1332 | */ |
1303 | #undef XTRN_DECLARE_GLOBAL_DATA_PTR | 1333 | #undef XTRN_DECLARE_GLOBAL_DATA_PTR |
1304 | #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */ | 1334 | #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */ |
1305 | DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); | 1335 | DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); |
1306 | #endif /* 0 */ | 1336 | #endif /* 0 */ |
1307 | 1337 | ||
1308 | /************************************************************************/ | 1338 | /************************************************************************/ |
1309 | 1339 |
net/eth.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2001-2004 | 2 | * (C) Copyright 2001-2004 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * See file CREDITS for list of people who contributed to this | 5 | * See file CREDITS for list of people who contributed to this |
6 | * project. | 6 | * project. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of | 10 | * published by the Free Software Foundation; either version 2 of |
11 | * the License, or (at your option) any later version. | 11 | * the License, or (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | * MA 02111-1307 USA | 21 | * MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <common.h> | 24 | #include <common.h> |
25 | #include <command.h> | 25 | #include <command.h> |
26 | #include <net.h> | 26 | #include <net.h> |
27 | #include <miiphy.h> | 27 | #include <miiphy.h> |
28 | 28 | ||
29 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI) | 29 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI) |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * CPU and board-specific Ethernet initializations. Aliased function | 32 | * CPU and board-specific Ethernet initializations. Aliased function |
33 | * signals caller to move on | 33 | * signals caller to move on |
34 | */ | 34 | */ |
35 | static int __def_eth_init(bd_t *bis) | 35 | static int __def_eth_init(bd_t *bis) |
36 | { | 36 | { |
37 | return -1; | 37 | return -1; |
38 | } | 38 | } |
39 | int cpu_eth_init(bd_t *bis) __attribute((weak, alias("__def_eth_init"))); | 39 | int cpu_eth_init(bd_t *bis) __attribute((weak, alias("__def_eth_init"))); |
40 | int board_eth_init(bd_t *bis) __attribute((weak, alias("__def_eth_init"))); | 40 | int board_eth_init(bd_t *bis) __attribute((weak, alias("__def_eth_init"))); |
41 | 41 | ||
42 | extern int au1x00_enet_initialize(bd_t*); | 42 | extern int au1x00_enet_initialize(bd_t*); |
43 | extern int fec_initialize(bd_t*); | 43 | extern int fec_initialize(bd_t*); |
44 | extern int mpc8220_fec_initialize(bd_t*); | 44 | extern int mpc8220_fec_initialize(bd_t*); |
45 | extern int mv6436x_eth_initialize(bd_t *); | 45 | extern int mv6436x_eth_initialize(bd_t *); |
46 | extern int mv6446x_eth_initialize(bd_t *); | 46 | extern int mv6446x_eth_initialize(bd_t *); |
47 | extern int ppc_4xx_eth_initialize(bd_t *); | 47 | extern int ppc_4xx_eth_initialize(bd_t *); |
48 | extern int scc_initialize(bd_t*); | 48 | extern int scc_initialize(bd_t*); |
49 | extern int npe_initialize(bd_t *); | 49 | extern int npe_initialize(bd_t *); |
50 | extern int uec_initialize(int); | 50 | extern int uec_initialize(int); |
51 | 51 | ||
52 | #ifdef CONFIG_API | 52 | #ifdef CONFIG_API |
53 | extern void (*push_packet)(volatile void *, int); | 53 | extern void (*push_packet)(volatile void *, int); |
54 | 54 | ||
55 | static struct { | 55 | static struct { |
56 | uchar data[PKTSIZE]; | 56 | uchar data[PKTSIZE]; |
57 | int length; | 57 | int length; |
58 | } eth_rcv_bufs[PKTBUFSRX]; | 58 | } eth_rcv_bufs[PKTBUFSRX]; |
59 | 59 | ||
60 | static unsigned int eth_rcv_current = 0, eth_rcv_last = 0; | 60 | static unsigned int eth_rcv_current = 0, eth_rcv_last = 0; |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | static struct eth_device *eth_devices, *eth_current; | 63 | static struct eth_device *eth_devices, *eth_current; |
64 | 64 | ||
65 | struct eth_device *eth_get_dev(void) | 65 | struct eth_device *eth_get_dev(void) |
66 | { | 66 | { |
67 | return eth_current; | 67 | return eth_current; |
68 | } | 68 | } |
69 | 69 | ||
70 | struct eth_device *eth_get_dev_by_name(char *devname) | 70 | struct eth_device *eth_get_dev_by_name(char *devname) |
71 | { | 71 | { |
72 | struct eth_device *dev, *target_dev; | 72 | struct eth_device *dev, *target_dev; |
73 | 73 | ||
74 | if (!eth_devices) | 74 | if (!eth_devices) |
75 | return NULL; | 75 | return NULL; |
76 | 76 | ||
77 | dev = eth_devices; | 77 | dev = eth_devices; |
78 | target_dev = NULL; | 78 | target_dev = NULL; |
79 | do { | 79 | do { |
80 | if (strcmp(devname, dev->name) == 0) { | 80 | if (strcmp(devname, dev->name) == 0) { |
81 | target_dev = dev; | 81 | target_dev = dev; |
82 | break; | 82 | break; |
83 | } | 83 | } |
84 | dev = dev->next; | 84 | dev = dev->next; |
85 | } while (dev != eth_devices); | 85 | } while (dev != eth_devices); |
86 | 86 | ||
87 | return target_dev; | 87 | return target_dev; |
88 | } | 88 | } |
89 | 89 | ||
90 | int eth_get_dev_index (void) | 90 | int eth_get_dev_index (void) |
91 | { | 91 | { |
92 | struct eth_device *dev; | 92 | struct eth_device *dev; |
93 | int num = 0; | 93 | int num = 0; |
94 | 94 | ||
95 | if (!eth_devices) { | 95 | if (!eth_devices) { |
96 | return (-1); | 96 | return (-1); |
97 | } | 97 | } |
98 | 98 | ||
99 | for (dev = eth_devices; dev; dev = dev->next) { | 99 | for (dev = eth_devices; dev; dev = dev->next) { |
100 | if (dev == eth_current) | 100 | if (dev == eth_current) |
101 | break; | 101 | break; |
102 | ++num; | 102 | ++num; |
103 | } | 103 | } |
104 | 104 | ||
105 | if (dev) { | 105 | if (dev) { |
106 | return (num); | 106 | return (num); |
107 | } | 107 | } |
108 | 108 | ||
109 | return (0); | 109 | return (0); |
110 | } | 110 | } |
111 | 111 | ||
112 | int eth_register(struct eth_device* dev) | 112 | int eth_register(struct eth_device* dev) |
113 | { | 113 | { |
114 | struct eth_device *d; | 114 | struct eth_device *d; |
115 | 115 | ||
116 | if (!eth_devices) { | 116 | if (!eth_devices) { |
117 | eth_current = eth_devices = dev; | 117 | eth_current = eth_devices = dev; |
118 | #ifdef CONFIG_NET_MULTI | 118 | #ifdef CONFIG_NET_MULTI |
119 | /* update current ethernet name */ | 119 | /* update current ethernet name */ |
120 | { | 120 | { |
121 | char *act = getenv("ethact"); | 121 | char *act = getenv("ethact"); |
122 | if (act == NULL || strcmp(act, eth_current->name) != 0) | 122 | if (act == NULL || strcmp(act, eth_current->name) != 0) |
123 | setenv("ethact", eth_current->name); | 123 | setenv("ethact", eth_current->name); |
124 | } | 124 | } |
125 | #endif | 125 | #endif |
126 | } else { | 126 | } else { |
127 | for (d=eth_devices; d->next!=eth_devices; d=d->next); | 127 | for (d=eth_devices; d->next!=eth_devices; d=d->next); |
128 | d->next = dev; | 128 | d->next = dev; |
129 | } | 129 | } |
130 | 130 | ||
131 | dev->state = ETH_STATE_INIT; | 131 | dev->state = ETH_STATE_INIT; |
132 | dev->next = eth_devices; | 132 | dev->next = eth_devices; |
133 | 133 | ||
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | int eth_initialize(bd_t *bis) | 137 | int eth_initialize(bd_t *bis) |
138 | { | 138 | { |
139 | char enetvar[32]; | 139 | char enetvar[32]; |
140 | unsigned char env_enetaddr[6]; | 140 | unsigned char env_enetaddr[6]; |
141 | int i, eth_number = 0; | 141 | int i, eth_number = 0; |
142 | char *tmp, *end; | 142 | char *tmp, *end; |
143 | 143 | ||
144 | eth_devices = NULL; | 144 | eth_devices = NULL; |
145 | eth_current = NULL; | 145 | eth_current = NULL; |
146 | 146 | ||
147 | show_boot_progress (64); | 147 | show_boot_progress (64); |
148 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) | 148 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) |
149 | miiphy_init(); | 149 | miiphy_init(); |
150 | #endif | 150 | #endif |
151 | /* Try board-specific initialization first. If it fails or isn't | 151 | /* Try board-specific initialization first. If it fails or isn't |
152 | * present, try the cpu-specific initialization */ | 152 | * present, try the cpu-specific initialization */ |
153 | if (board_eth_init(bis) < 0) | 153 | if (board_eth_init(bis) < 0) |
154 | cpu_eth_init(bis); | 154 | cpu_eth_init(bis); |
155 | 155 | ||
156 | #if defined(CONFIG_DB64360) || defined(CONFIG_CPCI750) | 156 | #if defined(CONFIG_DB64360) || defined(CONFIG_CPCI750) |
157 | mv6436x_eth_initialize(bis); | 157 | mv6436x_eth_initialize(bis); |
158 | #endif | 158 | #endif |
159 | #if defined(CONFIG_DB64460) || defined(CONFIG_P3Mx) | 159 | #if defined(CONFIG_DB64460) || defined(CONFIG_P3Mx) |
160 | mv6446x_eth_initialize(bis); | 160 | mv6446x_eth_initialize(bis); |
161 | #endif | 161 | #endif |
162 | #if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) && !defined(CONFIG_AP1000) | 162 | #if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) && !defined(CONFIG_AP1000) |
163 | ppc_4xx_eth_initialize(bis); | 163 | ppc_4xx_eth_initialize(bis); |
164 | #endif | 164 | #endif |
165 | #ifdef SCC_ENET | 165 | #ifdef SCC_ENET |
166 | scc_initialize(bis); | 166 | scc_initialize(bis); |
167 | #endif | 167 | #endif |
168 | #if defined(CONFIG_MPC8220_FEC) | 168 | #if defined(CONFIG_MPC8220_FEC) |
169 | mpc8220_fec_initialize(bis); | 169 | mpc8220_fec_initialize(bis); |
170 | #endif | 170 | #endif |
171 | #if defined(CONFIG_UEC_ETH1) | 171 | #if defined(CONFIG_UEC_ETH1) |
172 | uec_initialize(0); | 172 | uec_initialize(0); |
173 | #endif | 173 | #endif |
174 | #if defined(CONFIG_UEC_ETH2) | 174 | #if defined(CONFIG_UEC_ETH2) |
175 | uec_initialize(1); | 175 | uec_initialize(1); |
176 | #endif | 176 | #endif |
177 | #if defined(CONFIG_UEC_ETH3) | 177 | #if defined(CONFIG_UEC_ETH3) |
178 | uec_initialize(2); | 178 | uec_initialize(2); |
179 | #endif | 179 | #endif |
180 | #if defined(CONFIG_UEC_ETH4) | 180 | #if defined(CONFIG_UEC_ETH4) |
181 | uec_initialize(3); | 181 | uec_initialize(3); |
182 | #endif | 182 | #endif |
183 | #if defined(CONFIG_UEC_ETH5) | ||
184 | uec_initialize(4); | ||
185 | #endif | ||
186 | #if defined(CONFIG_UEC_ETH6) | ||
187 | uec_initialize(5); | ||
188 | #endif | ||
183 | 189 | ||
184 | #if defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FCC) | 190 | #if defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FCC) |
185 | fec_initialize(bis); | 191 | fec_initialize(bis); |
186 | #endif | 192 | #endif |
187 | #if defined(CONFIG_AU1X00) | 193 | #if defined(CONFIG_AU1X00) |
188 | au1x00_enet_initialize(bis); | 194 | au1x00_enet_initialize(bis); |
189 | #endif | 195 | #endif |
190 | #if defined(CONFIG_IXP4XX_NPE) | 196 | #if defined(CONFIG_IXP4XX_NPE) |
191 | npe_initialize(bis); | 197 | npe_initialize(bis); |
192 | #endif | 198 | #endif |
193 | if (!eth_devices) { | 199 | if (!eth_devices) { |
194 | puts ("No ethernet found.\n"); | 200 | puts ("No ethernet found.\n"); |
195 | show_boot_progress (-64); | 201 | show_boot_progress (-64); |
196 | } else { | 202 | } else { |
197 | struct eth_device *dev = eth_devices; | 203 | struct eth_device *dev = eth_devices; |
198 | char *ethprime = getenv ("ethprime"); | 204 | char *ethprime = getenv ("ethprime"); |
199 | 205 | ||
200 | show_boot_progress (65); | 206 | show_boot_progress (65); |
201 | do { | 207 | do { |
202 | if (eth_number) | 208 | if (eth_number) |
203 | puts (", "); | 209 | puts (", "); |
204 | 210 | ||
205 | printf("%s", dev->name); | 211 | printf("%s", dev->name); |
206 | 212 | ||
207 | if (ethprime && strcmp (dev->name, ethprime) == 0) { | 213 | if (ethprime && strcmp (dev->name, ethprime) == 0) { |
208 | eth_current = dev; | 214 | eth_current = dev; |
209 | puts (" [PRIME]"); | 215 | puts (" [PRIME]"); |
210 | } | 216 | } |
211 | 217 | ||
212 | sprintf(enetvar, eth_number ? "eth%daddr" : "ethaddr", eth_number); | 218 | sprintf(enetvar, eth_number ? "eth%daddr" : "ethaddr", eth_number); |
213 | tmp = getenv (enetvar); | 219 | tmp = getenv (enetvar); |
214 | 220 | ||
215 | for (i=0; i<6; i++) { | 221 | for (i=0; i<6; i++) { |
216 | env_enetaddr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0; | 222 | env_enetaddr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0; |
217 | if (tmp) | 223 | if (tmp) |
218 | tmp = (*end) ? end+1 : end; | 224 | tmp = (*end) ? end+1 : end; |
219 | } | 225 | } |
220 | 226 | ||
221 | if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) { | 227 | if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) { |
222 | if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) && | 228 | if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) && |
223 | memcmp(dev->enetaddr, env_enetaddr, 6)) | 229 | memcmp(dev->enetaddr, env_enetaddr, 6)) |
224 | { | 230 | { |
225 | printf ("\nWarning: %s MAC addresses don't match:\n", | 231 | printf ("\nWarning: %s MAC addresses don't match:\n", |
226 | dev->name); | 232 | dev->name); |
227 | printf ("Address in SROM is " | 233 | printf ("Address in SROM is " |
228 | "%02X:%02X:%02X:%02X:%02X:%02X\n", | 234 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
229 | dev->enetaddr[0], dev->enetaddr[1], | 235 | dev->enetaddr[0], dev->enetaddr[1], |
230 | dev->enetaddr[2], dev->enetaddr[3], | 236 | dev->enetaddr[2], dev->enetaddr[3], |
231 | dev->enetaddr[4], dev->enetaddr[5]); | 237 | dev->enetaddr[4], dev->enetaddr[5]); |
232 | printf ("Address in environment is " | 238 | printf ("Address in environment is " |
233 | "%02X:%02X:%02X:%02X:%02X:%02X\n", | 239 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
234 | env_enetaddr[0], env_enetaddr[1], | 240 | env_enetaddr[0], env_enetaddr[1], |
235 | env_enetaddr[2], env_enetaddr[3], | 241 | env_enetaddr[2], env_enetaddr[3], |
236 | env_enetaddr[4], env_enetaddr[5]); | 242 | env_enetaddr[4], env_enetaddr[5]); |
237 | } | 243 | } |
238 | 244 | ||
239 | memcpy(dev->enetaddr, env_enetaddr, 6); | 245 | memcpy(dev->enetaddr, env_enetaddr, 6); |
240 | } | 246 | } |
241 | 247 | ||
242 | eth_number++; | 248 | eth_number++; |
243 | dev = dev->next; | 249 | dev = dev->next; |
244 | } while(dev != eth_devices); | 250 | } while(dev != eth_devices); |
245 | 251 | ||
246 | #ifdef CONFIG_NET_MULTI | 252 | #ifdef CONFIG_NET_MULTI |
247 | /* update current ethernet name */ | 253 | /* update current ethernet name */ |
248 | if (eth_current) { | 254 | if (eth_current) { |
249 | char *act = getenv("ethact"); | 255 | char *act = getenv("ethact"); |
250 | if (act == NULL || strcmp(act, eth_current->name) != 0) | 256 | if (act == NULL || strcmp(act, eth_current->name) != 0) |
251 | setenv("ethact", eth_current->name); | 257 | setenv("ethact", eth_current->name); |
252 | } else | 258 | } else |
253 | setenv("ethact", NULL); | 259 | setenv("ethact", NULL); |
254 | #endif | 260 | #endif |
255 | 261 | ||
256 | putc ('\n'); | 262 | putc ('\n'); |
257 | } | 263 | } |
258 | 264 | ||
259 | return eth_number; | 265 | return eth_number; |
260 | } | 266 | } |
261 | 267 | ||
262 | void eth_set_enetaddr(int num, char *addr) { | 268 | void eth_set_enetaddr(int num, char *addr) { |
263 | struct eth_device *dev; | 269 | struct eth_device *dev; |
264 | unsigned char enetaddr[6]; | 270 | unsigned char enetaddr[6]; |
265 | char *end; | 271 | char *end; |
266 | int i; | 272 | int i; |
267 | 273 | ||
268 | debug ("eth_set_enetaddr(num=%d, addr=%s)\n", num, addr); | 274 | debug ("eth_set_enetaddr(num=%d, addr=%s)\n", num, addr); |
269 | 275 | ||
270 | if (!eth_devices) | 276 | if (!eth_devices) |
271 | return; | 277 | return; |
272 | 278 | ||
273 | for (i=0; i<6; i++) { | 279 | for (i=0; i<6; i++) { |
274 | enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0; | 280 | enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0; |
275 | if (addr) | 281 | if (addr) |
276 | addr = (*end) ? end+1 : end; | 282 | addr = (*end) ? end+1 : end; |
277 | } | 283 | } |
278 | 284 | ||
279 | dev = eth_devices; | 285 | dev = eth_devices; |
280 | while(num-- > 0) { | 286 | while(num-- > 0) { |
281 | dev = dev->next; | 287 | dev = dev->next; |
282 | 288 | ||
283 | if (dev == eth_devices) | 289 | if (dev == eth_devices) |
284 | return; | 290 | return; |
285 | } | 291 | } |
286 | 292 | ||
287 | debug ( "Setting new HW address on %s\n" | 293 | debug ( "Setting new HW address on %s\n" |
288 | "New Address is %02X:%02X:%02X:%02X:%02X:%02X\n", | 294 | "New Address is %02X:%02X:%02X:%02X:%02X:%02X\n", |
289 | dev->name, | 295 | dev->name, |
290 | enetaddr[0], enetaddr[1], | 296 | enetaddr[0], enetaddr[1], |
291 | enetaddr[2], enetaddr[3], | 297 | enetaddr[2], enetaddr[3], |
292 | enetaddr[4], enetaddr[5]); | 298 | enetaddr[4], enetaddr[5]); |
293 | 299 | ||
294 | memcpy(dev->enetaddr, enetaddr, 6); | 300 | memcpy(dev->enetaddr, enetaddr, 6); |
295 | } | 301 | } |
296 | #ifdef CONFIG_MCAST_TFTP | 302 | #ifdef CONFIG_MCAST_TFTP |
297 | /* Multicast. | 303 | /* Multicast. |
298 | * mcast_addr: multicast ipaddr from which multicast Mac is made | 304 | * mcast_addr: multicast ipaddr from which multicast Mac is made |
299 | * join: 1=join, 0=leave. | 305 | * join: 1=join, 0=leave. |
300 | */ | 306 | */ |
301 | int eth_mcast_join( IPaddr_t mcast_ip, u8 join) | 307 | int eth_mcast_join( IPaddr_t mcast_ip, u8 join) |
302 | { | 308 | { |
303 | u8 mcast_mac[6]; | 309 | u8 mcast_mac[6]; |
304 | if (!eth_current || !eth_current->mcast) | 310 | if (!eth_current || !eth_current->mcast) |
305 | return -1; | 311 | return -1; |
306 | mcast_mac[5] = htonl(mcast_ip) & 0xff; | 312 | mcast_mac[5] = htonl(mcast_ip) & 0xff; |
307 | mcast_mac[4] = (htonl(mcast_ip)>>8) & 0xff; | 313 | mcast_mac[4] = (htonl(mcast_ip)>>8) & 0xff; |
308 | mcast_mac[3] = (htonl(mcast_ip)>>16) & 0x7f; | 314 | mcast_mac[3] = (htonl(mcast_ip)>>16) & 0x7f; |
309 | mcast_mac[2] = 0x5e; | 315 | mcast_mac[2] = 0x5e; |
310 | mcast_mac[1] = 0x0; | 316 | mcast_mac[1] = 0x0; |
311 | mcast_mac[0] = 0x1; | 317 | mcast_mac[0] = 0x1; |
312 | return eth_current->mcast(eth_current, mcast_mac, join); | 318 | return eth_current->mcast(eth_current, mcast_mac, join); |
313 | } | 319 | } |
314 | 320 | ||
315 | /* the 'way' for ethernet-CRC-32. Spliced in from Linux lib/crc32.c | 321 | /* the 'way' for ethernet-CRC-32. Spliced in from Linux lib/crc32.c |
316 | * and this is the ethernet-crc method needed for TSEC -- and perhaps | 322 | * and this is the ethernet-crc method needed for TSEC -- and perhaps |
317 | * some other adapter -- hash tables | 323 | * some other adapter -- hash tables |
318 | */ | 324 | */ |
319 | #define CRCPOLY_LE 0xedb88320 | 325 | #define CRCPOLY_LE 0xedb88320 |
320 | u32 ether_crc (size_t len, unsigned char const *p) | 326 | u32 ether_crc (size_t len, unsigned char const *p) |
321 | { | 327 | { |
322 | int i; | 328 | int i; |
323 | u32 crc; | 329 | u32 crc; |
324 | crc = ~0; | 330 | crc = ~0; |
325 | while (len--) { | 331 | while (len--) { |
326 | crc ^= *p++; | 332 | crc ^= *p++; |
327 | for (i = 0; i < 8; i++) | 333 | for (i = 0; i < 8; i++) |
328 | crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0); | 334 | crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0); |
329 | } | 335 | } |
330 | /* an reverse the bits, cuz of way they arrive -- last-first */ | 336 | /* an reverse the bits, cuz of way they arrive -- last-first */ |
331 | crc = (crc >> 16) | (crc << 16); | 337 | crc = (crc >> 16) | (crc << 16); |
332 | crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00); | 338 | crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00); |
333 | crc = (crc >> 4 & 0x0f0f0f0f) | (crc << 4 & 0xf0f0f0f0); | 339 | crc = (crc >> 4 & 0x0f0f0f0f) | (crc << 4 & 0xf0f0f0f0); |
334 | crc = (crc >> 2 & 0x33333333) | (crc << 2 & 0xcccccccc); | 340 | crc = (crc >> 2 & 0x33333333) | (crc << 2 & 0xcccccccc); |
335 | crc = (crc >> 1 & 0x55555555) | (crc << 1 & 0xaaaaaaaa); | 341 | crc = (crc >> 1 & 0x55555555) | (crc << 1 & 0xaaaaaaaa); |
336 | return crc; | 342 | return crc; |
337 | } | 343 | } |
338 | 344 | ||
339 | #endif | 345 | #endif |
340 | 346 | ||
341 | 347 | ||
342 | int eth_init(bd_t *bis) | 348 | int eth_init(bd_t *bis) |
343 | { | 349 | { |
344 | struct eth_device* old_current; | 350 | struct eth_device* old_current; |
345 | 351 | ||
346 | if (!eth_current) { | 352 | if (!eth_current) { |
347 | puts ("No ethernet found.\n"); | 353 | puts ("No ethernet found.\n"); |
348 | return -1; | 354 | return -1; |
349 | } | 355 | } |
350 | 356 | ||
351 | old_current = eth_current; | 357 | old_current = eth_current; |
352 | do { | 358 | do { |
353 | debug ("Trying %s\n", eth_current->name); | 359 | debug ("Trying %s\n", eth_current->name); |
354 | 360 | ||
355 | if (eth_current->init(eth_current,bis) >= 0) { | 361 | if (eth_current->init(eth_current,bis) >= 0) { |
356 | eth_current->state = ETH_STATE_ACTIVE; | 362 | eth_current->state = ETH_STATE_ACTIVE; |
357 | 363 | ||
358 | return 0; | 364 | return 0; |
359 | } | 365 | } |
360 | debug ("FAIL\n"); | 366 | debug ("FAIL\n"); |
361 | 367 | ||
362 | eth_try_another(0); | 368 | eth_try_another(0); |
363 | } while (old_current != eth_current); | 369 | } while (old_current != eth_current); |
364 | 370 | ||
365 | return -1; | 371 | return -1; |
366 | } | 372 | } |
367 | 373 | ||
368 | void eth_halt(void) | 374 | void eth_halt(void) |
369 | { | 375 | { |
370 | if (!eth_current) | 376 | if (!eth_current) |
371 | return; | 377 | return; |
372 | 378 | ||
373 | eth_current->halt(eth_current); | 379 | eth_current->halt(eth_current); |
374 | 380 | ||
375 | eth_current->state = ETH_STATE_PASSIVE; | 381 | eth_current->state = ETH_STATE_PASSIVE; |
376 | } | 382 | } |
377 | 383 | ||
378 | int eth_send(volatile void *packet, int length) | 384 | int eth_send(volatile void *packet, int length) |
379 | { | 385 | { |
380 | if (!eth_current) | 386 | if (!eth_current) |
381 | return -1; | 387 | return -1; |
382 | 388 | ||
383 | return eth_current->send(eth_current, packet, length); | 389 | return eth_current->send(eth_current, packet, length); |
384 | } | 390 | } |
385 | 391 | ||
386 | int eth_rx(void) | 392 | int eth_rx(void) |
387 | { | 393 | { |
388 | if (!eth_current) | 394 | if (!eth_current) |
389 | return -1; | 395 | return -1; |
390 | 396 | ||
391 | return eth_current->recv(eth_current); | 397 | return eth_current->recv(eth_current); |
392 | } | 398 | } |
393 | 399 | ||
394 | #ifdef CONFIG_API | 400 | #ifdef CONFIG_API |
395 | static void eth_save_packet(volatile void *packet, int length) | 401 | static void eth_save_packet(volatile void *packet, int length) |
396 | { | 402 | { |
397 | volatile char *p = packet; | 403 | volatile char *p = packet; |
398 | int i; | 404 | int i; |
399 | 405 | ||
400 | if ((eth_rcv_last+1) % PKTBUFSRX == eth_rcv_current) | 406 | if ((eth_rcv_last+1) % PKTBUFSRX == eth_rcv_current) |
401 | return; | 407 | return; |
402 | 408 | ||
403 | if (PKTSIZE < length) | 409 | if (PKTSIZE < length) |
404 | return; | 410 | return; |
405 | 411 | ||
406 | for (i = 0; i < length; i++) | 412 | for (i = 0; i < length; i++) |
407 | eth_rcv_bufs[eth_rcv_last].data[i] = p[i]; | 413 | eth_rcv_bufs[eth_rcv_last].data[i] = p[i]; |
408 | 414 | ||
409 | eth_rcv_bufs[eth_rcv_last].length = length; | 415 | eth_rcv_bufs[eth_rcv_last].length = length; |
410 | eth_rcv_last = (eth_rcv_last + 1) % PKTBUFSRX; | 416 | eth_rcv_last = (eth_rcv_last + 1) % PKTBUFSRX; |
411 | } | 417 | } |
412 | 418 | ||
413 | int eth_receive(volatile void *packet, int length) | 419 | int eth_receive(volatile void *packet, int length) |
414 | { | 420 | { |
415 | volatile char *p = packet; | 421 | volatile char *p = packet; |
416 | void *pp = push_packet; | 422 | void *pp = push_packet; |
417 | int i; | 423 | int i; |
418 | 424 | ||
419 | if (eth_rcv_current == eth_rcv_last) { | 425 | if (eth_rcv_current == eth_rcv_last) { |
420 | push_packet = eth_save_packet; | 426 | push_packet = eth_save_packet; |
421 | eth_rx(); | 427 | eth_rx(); |
422 | push_packet = pp; | 428 | push_packet = pp; |
423 | 429 | ||
424 | if (eth_rcv_current == eth_rcv_last) | 430 | if (eth_rcv_current == eth_rcv_last) |
425 | return -1; | 431 | return -1; |
426 | } | 432 | } |
427 | 433 | ||
428 | if (length < eth_rcv_bufs[eth_rcv_current].length) | 434 | if (length < eth_rcv_bufs[eth_rcv_current].length) |
429 | return -1; | 435 | return -1; |
430 | 436 | ||
431 | length = eth_rcv_bufs[eth_rcv_current].length; | 437 | length = eth_rcv_bufs[eth_rcv_current].length; |
432 | 438 | ||
433 | for (i = 0; i < length; i++) | 439 | for (i = 0; i < length; i++) |
434 | p[i] = eth_rcv_bufs[eth_rcv_current].data[i]; | 440 | p[i] = eth_rcv_bufs[eth_rcv_current].data[i]; |
435 | 441 | ||
436 | eth_rcv_current = (eth_rcv_current + 1) % PKTBUFSRX; | 442 | eth_rcv_current = (eth_rcv_current + 1) % PKTBUFSRX; |
437 | return length; | 443 | return length; |
438 | } | 444 | } |
439 | #endif /* CONFIG_API */ | 445 | #endif /* CONFIG_API */ |
440 | 446 | ||
441 | void eth_try_another(int first_restart) | 447 | void eth_try_another(int first_restart) |
442 | { | 448 | { |
443 | static struct eth_device *first_failed = NULL; | 449 | static struct eth_device *first_failed = NULL; |
444 | char *ethrotate; | 450 | char *ethrotate; |
445 | 451 | ||
446 | /* | 452 | /* |
447 | * Do not rotate between network interfaces when | 453 | * Do not rotate between network interfaces when |
448 | * 'ethrotate' variable is set to 'no'. | 454 | * 'ethrotate' variable is set to 'no'. |
449 | */ | 455 | */ |
450 | if (((ethrotate = getenv ("ethrotate")) != NULL) && | 456 | if (((ethrotate = getenv ("ethrotate")) != NULL) && |
451 | (strcmp(ethrotate, "no") == 0)) | 457 | (strcmp(ethrotate, "no") == 0)) |
452 | return; | 458 | return; |
453 | 459 | ||
454 | if (!eth_current) | 460 | if (!eth_current) |
455 | return; | 461 | return; |
456 | 462 | ||
457 | if (first_restart) { | 463 | if (first_restart) { |
458 | first_failed = eth_current; | 464 | first_failed = eth_current; |
459 | } | 465 | } |
460 | 466 | ||
461 | eth_current = eth_current->next; | 467 | eth_current = eth_current->next; |
462 | 468 | ||
463 | #ifdef CONFIG_NET_MULTI | 469 | #ifdef CONFIG_NET_MULTI |
464 | /* update current ethernet name */ | 470 | /* update current ethernet name */ |
465 | { | 471 | { |
466 | char *act = getenv("ethact"); | 472 | char *act = getenv("ethact"); |
467 | if (act == NULL || strcmp(act, eth_current->name) != 0) | 473 | if (act == NULL || strcmp(act, eth_current->name) != 0) |
468 | setenv("ethact", eth_current->name); | 474 | setenv("ethact", eth_current->name); |
469 | } | 475 | } |
470 | #endif | 476 | #endif |
471 | 477 | ||
472 | if (first_failed == eth_current) { | 478 | if (first_failed == eth_current) { |
473 | NetRestartWrap = 1; | 479 | NetRestartWrap = 1; |
474 | } | 480 | } |
475 | } | 481 | } |
476 | 482 | ||
477 | #ifdef CONFIG_NET_MULTI | 483 | #ifdef CONFIG_NET_MULTI |
478 | void eth_set_current(void) | 484 | void eth_set_current(void) |
479 | { | 485 | { |
480 | char *act; | 486 | char *act; |
481 | struct eth_device* old_current; | 487 | struct eth_device* old_current; |
482 | 488 | ||
483 | if (!eth_current) /* XXX no current */ | 489 | if (!eth_current) /* XXX no current */ |
484 | return; | 490 | return; |
485 | 491 | ||
486 | act = getenv("ethact"); | 492 | act = getenv("ethact"); |
487 | if (act != NULL) { | 493 | if (act != NULL) { |
488 | old_current = eth_current; | 494 | old_current = eth_current; |
489 | do { | 495 | do { |
490 | if (strcmp(eth_current->name, act) == 0) | 496 | if (strcmp(eth_current->name, act) == 0) |
491 | return; | 497 | return; |
492 | eth_current = eth_current->next; | 498 | eth_current = eth_current->next; |
493 | } while (old_current != eth_current); | 499 | } while (old_current != eth_current); |
494 | } | 500 | } |
495 | 501 | ||
496 | setenv("ethact", eth_current->name); | 502 | setenv("ethact", eth_current->name); |
497 | } | 503 | } |
498 | #endif | 504 | #endif |
499 | 505 | ||
500 | char *eth_get_name (void) | 506 | char *eth_get_name (void) |
501 | { | 507 | { |
502 | return (eth_current ? eth_current->name : "unknown"); | 508 | return (eth_current ? eth_current->name : "unknown"); |
503 | } | 509 | } |
504 | #elif defined(CONFIG_CMD_NET) && !defined(CONFIG_NET_MULTI) | 510 | #elif defined(CONFIG_CMD_NET) && !defined(CONFIG_NET_MULTI) |
505 | 511 | ||
506 | extern int at91rm9200_miiphy_initialize(bd_t *bis); | 512 | extern int at91rm9200_miiphy_initialize(bd_t *bis); |
507 | extern int emac4xx_miiphy_initialize(bd_t *bis); | 513 | extern int emac4xx_miiphy_initialize(bd_t *bis); |
508 | extern int mcf52x2_miiphy_initialize(bd_t *bis); | 514 | extern int mcf52x2_miiphy_initialize(bd_t *bis); |
509 | extern int ns7520_miiphy_initialize(bd_t *bis); | 515 | extern int ns7520_miiphy_initialize(bd_t *bis); |
510 | extern int davinci_eth_miiphy_initialize(bd_t *bis); | 516 | extern int davinci_eth_miiphy_initialize(bd_t *bis); |
511 | 517 | ||
512 | 518 | ||
513 | int eth_initialize(bd_t *bis) | 519 | int eth_initialize(bd_t *bis) |
514 | { | 520 | { |
515 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) | 521 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) |
516 | miiphy_init(); | 522 | miiphy_init(); |
517 | #endif | 523 | #endif |
518 | 524 | ||
519 | #if defined(CONFIG_AT91RM9200) | 525 | #if defined(CONFIG_AT91RM9200) |
520 | at91rm9200_miiphy_initialize(bis); | 526 | at91rm9200_miiphy_initialize(bis); |
521 | #endif | 527 | #endif |
522 | #if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) \ | 528 | #if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) \ |
523 | && !defined(CONFIG_AP1000) && !defined(CONFIG_405) | 529 | && !defined(CONFIG_AP1000) && !defined(CONFIG_405) |
524 | emac4xx_miiphy_initialize(bis); | 530 | emac4xx_miiphy_initialize(bis); |
525 | #endif | 531 | #endif |
526 | #if defined(CONFIG_MCF52x2) | 532 | #if defined(CONFIG_MCF52x2) |
527 | mcf52x2_miiphy_initialize(bis); | 533 | mcf52x2_miiphy_initialize(bis); |
528 | #endif | 534 | #endif |
529 | #if defined(CONFIG_DRIVER_NS7520_ETHERNET) | 535 | #if defined(CONFIG_DRIVER_NS7520_ETHERNET) |
530 | ns7520_miiphy_initialize(bis); | 536 | ns7520_miiphy_initialize(bis); |
531 | #endif | 537 | #endif |
532 | #if defined(CONFIG_DRIVER_TI_EMAC) | 538 | #if defined(CONFIG_DRIVER_TI_EMAC) |
533 | davinci_eth_miiphy_initialize(bis); | 539 | davinci_eth_miiphy_initialize(bis); |
534 | #endif | 540 | #endif |
535 | return 0; | 541 | return 0; |
536 | } | 542 | } |
537 | #endif | 543 | #endif |
538 | 544 |
tools/env/fw_env.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2000-2008 | 2 | * (C) Copyright 2000-2008 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * (C) Copyright 2008 | 5 | * (C) Copyright 2008 |
6 | * Guennadi Liakhovetski, DENX Software Engineering, lg@denx.de. | 6 | * Guennadi Liakhovetski, DENX Software Engineering, lg@denx.de. |
7 | * | 7 | * |
8 | * See file CREDITS for list of people who contributed to this | 8 | * See file CREDITS for list of people who contributed to this |
9 | * project. | 9 | * project. |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License as | 12 | * modify it under the terms of the GNU General Public License as |
13 | * published by the Free Software Foundation; either version 2 of | 13 | * published by the Free Software Foundation; either version 2 of |
14 | * the License, or (at your option) any later version. | 14 | * the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. | 19 | * GNU General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software | 22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
24 | * MA 02111-1307 USA | 24 | * MA 02111-1307 USA |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | #include <fcntl.h> | 28 | #include <fcntl.h> |
29 | #include <stdio.h> | 29 | #include <stdio.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <stddef.h> | 31 | #include <stddef.h> |
32 | #include <string.h> | 32 | #include <string.h> |
33 | #include <sys/types.h> | 33 | #include <sys/types.h> |
34 | #include <sys/ioctl.h> | 34 | #include <sys/ioctl.h> |
35 | #include <sys/stat.h> | 35 | #include <sys/stat.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | 37 | ||
38 | #ifdef MTD_OLD | 38 | #ifdef MTD_OLD |
39 | # include <stdint.h> | 39 | # include <stdint.h> |
40 | # include <linux/mtd/mtd.h> | 40 | # include <linux/mtd/mtd.h> |
41 | #else | 41 | #else |
42 | # define __user /* nothing */ | 42 | # define __user /* nothing */ |
43 | # include <mtd/mtd-user.h> | 43 | # include <mtd/mtd-user.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #include "fw_env.h" | 46 | #include "fw_env.h" |
47 | 47 | ||
48 | #define CMD_GETENV "fw_printenv" | 48 | #define CMD_GETENV "fw_printenv" |
49 | #define CMD_SETENV "fw_setenv" | 49 | #define CMD_SETENV "fw_setenv" |
50 | 50 | ||
51 | #define min(x, y) ({ \ | 51 | #define min(x, y) ({ \ |
52 | typeof(x) _min1 = (x); \ | 52 | typeof(x) _min1 = (x); \ |
53 | typeof(y) _min2 = (y); \ | 53 | typeof(y) _min2 = (y); \ |
54 | (void) (&_min1 == &_min2); \ | 54 | (void) (&_min1 == &_min2); \ |
55 | _min1 < _min2 ? _min1 : _min2; }) | 55 | _min1 < _min2 ? _min1 : _min2; }) |
56 | 56 | ||
57 | struct envdev_s { | 57 | struct envdev_s { |
58 | char devname[16]; /* Device name */ | 58 | char devname[16]; /* Device name */ |
59 | ulong devoff; /* Device offset */ | 59 | ulong devoff; /* Device offset */ |
60 | ulong env_size; /* environment size */ | 60 | ulong env_size; /* environment size */ |
61 | ulong erase_size; /* device erase size */ | 61 | ulong erase_size; /* device erase size */ |
62 | ulong env_sectors; /* number of environment sectors */ | 62 | ulong env_sectors; /* number of environment sectors */ |
63 | uint8_t mtd_type; /* type of the MTD device */ | 63 | uint8_t mtd_type; /* type of the MTD device */ |
64 | }; | 64 | }; |
65 | 65 | ||
66 | static struct envdev_s envdevices[2] = | 66 | static struct envdev_s envdevices[2] = |
67 | { | 67 | { |
68 | { | 68 | { |
69 | .mtd_type = MTD_ABSENT, | 69 | .mtd_type = MTD_ABSENT, |
70 | }, { | 70 | }, { |
71 | .mtd_type = MTD_ABSENT, | 71 | .mtd_type = MTD_ABSENT, |
72 | }, | 72 | }, |
73 | }; | 73 | }; |
74 | static int dev_current; | 74 | static int dev_current; |
75 | 75 | ||
76 | #define DEVNAME(i) envdevices[(i)].devname | 76 | #define DEVNAME(i) envdevices[(i)].devname |
77 | #define DEVOFFSET(i) envdevices[(i)].devoff | 77 | #define DEVOFFSET(i) envdevices[(i)].devoff |
78 | #define ENVSIZE(i) envdevices[(i)].env_size | 78 | #define ENVSIZE(i) envdevices[(i)].env_size |
79 | #define DEVESIZE(i) envdevices[(i)].erase_size | 79 | #define DEVESIZE(i) envdevices[(i)].erase_size |
80 | #define ENVSECTORS(i) envdevices[(i)].env_sectors | 80 | #define ENVSECTORS(i) envdevices[(i)].env_sectors |
81 | #define DEVTYPE(i) envdevices[(i)].mtd_type | 81 | #define DEVTYPE(i) envdevices[(i)].mtd_type |
82 | 82 | ||
83 | #define CONFIG_ENV_SIZE ENVSIZE(dev_current) | 83 | #define CONFIG_ENV_SIZE ENVSIZE(dev_current) |
84 | 84 | ||
85 | #define ENV_SIZE getenvsize() | 85 | #define ENV_SIZE getenvsize() |
86 | 86 | ||
87 | struct env_image_single { | 87 | struct env_image_single { |
88 | uint32_t crc; /* CRC32 over data bytes */ | 88 | uint32_t crc; /* CRC32 over data bytes */ |
89 | char data[]; | 89 | char data[]; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | struct env_image_redundant { | 92 | struct env_image_redundant { |
93 | uint32_t crc; /* CRC32 over data bytes */ | 93 | uint32_t crc; /* CRC32 over data bytes */ |
94 | unsigned char flags; /* active or obsolete */ | 94 | unsigned char flags; /* active or obsolete */ |
95 | char data[]; | 95 | char data[]; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | enum flag_scheme { | 98 | enum flag_scheme { |
99 | FLAG_NONE, | 99 | FLAG_NONE, |
100 | FLAG_BOOLEAN, | 100 | FLAG_BOOLEAN, |
101 | FLAG_INCREMENTAL, | 101 | FLAG_INCREMENTAL, |
102 | }; | 102 | }; |
103 | 103 | ||
104 | struct environment { | 104 | struct environment { |
105 | void *image; | 105 | void *image; |
106 | uint32_t *crc; | 106 | uint32_t *crc; |
107 | unsigned char *flags; | 107 | unsigned char *flags; |
108 | char *data; | 108 | char *data; |
109 | enum flag_scheme flag_scheme; | 109 | enum flag_scheme flag_scheme; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | static struct environment environment = { | 112 | static struct environment environment = { |
113 | .flag_scheme = FLAG_NONE, | 113 | .flag_scheme = FLAG_NONE, |
114 | }; | 114 | }; |
115 | 115 | ||
116 | static int HaveRedundEnv = 0; | 116 | static int HaveRedundEnv = 0; |
117 | 117 | ||
118 | static unsigned char active_flag = 1; | 118 | static unsigned char active_flag = 1; |
119 | /* obsolete_flag must be 0 to efficiently set it on NOR flash without erasing */ | 119 | /* obsolete_flag must be 0 to efficiently set it on NOR flash without erasing */ |
120 | static unsigned char obsolete_flag = 0; | 120 | static unsigned char obsolete_flag = 0; |
121 | 121 | ||
122 | 122 | ||
123 | #define XMK_STR(x) #x | 123 | #define XMK_STR(x) #x |
124 | #define MK_STR(x) XMK_STR(x) | 124 | #define MK_STR(x) XMK_STR(x) |
125 | 125 | ||
126 | static char default_environment[] = { | 126 | static char default_environment[] = { |
127 | #if defined(CONFIG_BOOTARGS) | 127 | #if defined(CONFIG_BOOTARGS) |
128 | "bootargs=" CONFIG_BOOTARGS "\0" | 128 | "bootargs=" CONFIG_BOOTARGS "\0" |
129 | #endif | 129 | #endif |
130 | #if defined(CONFIG_BOOTCOMMAND) | 130 | #if defined(CONFIG_BOOTCOMMAND) |
131 | "bootcmd=" CONFIG_BOOTCOMMAND "\0" | 131 | "bootcmd=" CONFIG_BOOTCOMMAND "\0" |
132 | #endif | 132 | #endif |
133 | #if defined(CONFIG_RAMBOOTCOMMAND) | 133 | #if defined(CONFIG_RAMBOOTCOMMAND) |
134 | "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" | 134 | "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" |
135 | #endif | 135 | #endif |
136 | #if defined(CONFIG_NFSBOOTCOMMAND) | 136 | #if defined(CONFIG_NFSBOOTCOMMAND) |
137 | "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" | 137 | "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" |
138 | #endif | 138 | #endif |
139 | #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) | 139 | #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) |
140 | "bootdelay=" MK_STR (CONFIG_BOOTDELAY) "\0" | 140 | "bootdelay=" MK_STR (CONFIG_BOOTDELAY) "\0" |
141 | #endif | 141 | #endif |
142 | #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) | 142 | #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) |
143 | "baudrate=" MK_STR (CONFIG_BAUDRATE) "\0" | 143 | "baudrate=" MK_STR (CONFIG_BAUDRATE) "\0" |
144 | #endif | 144 | #endif |
145 | #ifdef CONFIG_LOADS_ECHO | 145 | #ifdef CONFIG_LOADS_ECHO |
146 | "loads_echo=" MK_STR (CONFIG_LOADS_ECHO) "\0" | 146 | "loads_echo=" MK_STR (CONFIG_LOADS_ECHO) "\0" |
147 | #endif | 147 | #endif |
148 | #ifdef CONFIG_ETHADDR | 148 | #ifdef CONFIG_ETHADDR |
149 | "ethaddr=" MK_STR (CONFIG_ETHADDR) "\0" | 149 | "ethaddr=" MK_STR (CONFIG_ETHADDR) "\0" |
150 | #endif | 150 | #endif |
151 | #ifdef CONFIG_ETH1ADDR | 151 | #ifdef CONFIG_ETH1ADDR |
152 | "eth1addr=" MK_STR (CONFIG_ETH1ADDR) "\0" | 152 | "eth1addr=" MK_STR (CONFIG_ETH1ADDR) "\0" |
153 | #endif | 153 | #endif |
154 | #ifdef CONFIG_ETH2ADDR | 154 | #ifdef CONFIG_ETH2ADDR |
155 | "eth2addr=" MK_STR (CONFIG_ETH2ADDR) "\0" | 155 | "eth2addr=" MK_STR (CONFIG_ETH2ADDR) "\0" |
156 | #endif | 156 | #endif |
157 | #ifdef CONFIG_ETH3ADDR | 157 | #ifdef CONFIG_ETH3ADDR |
158 | "eth3addr=" MK_STR (CONFIG_ETH3ADDR) "\0" | 158 | "eth3addr=" MK_STR (CONFIG_ETH3ADDR) "\0" |
159 | #endif | 159 | #endif |
160 | #ifdef CONFIG_ETH4ADDR | ||
161 | "eth4addr=" MK_STR (CONFIG_ETH4ADDR) "\0" | ||
162 | #endif | ||
163 | #ifdef CONFIG_ETH5ADDR | ||
164 | "eth5addr=" MK_STR (CONFIG_ETH5ADDR) "\0" | ||
165 | #endif | ||
160 | #ifdef CONFIG_ETHPRIME | 166 | #ifdef CONFIG_ETHPRIME |
161 | "ethprime=" CONFIG_ETHPRIME "\0" | 167 | "ethprime=" CONFIG_ETHPRIME "\0" |
162 | #endif | 168 | #endif |
163 | #ifdef CONFIG_IPADDR | 169 | #ifdef CONFIG_IPADDR |
164 | "ipaddr=" MK_STR (CONFIG_IPADDR) "\0" | 170 | "ipaddr=" MK_STR (CONFIG_IPADDR) "\0" |
165 | #endif | 171 | #endif |
166 | #ifdef CONFIG_SERVERIP | 172 | #ifdef CONFIG_SERVERIP |
167 | "serverip=" MK_STR (CONFIG_SERVERIP) "\0" | 173 | "serverip=" MK_STR (CONFIG_SERVERIP) "\0" |
168 | #endif | 174 | #endif |
169 | #ifdef CFG_AUTOLOAD | 175 | #ifdef CFG_AUTOLOAD |
170 | "autoload=" CFG_AUTOLOAD "\0" | 176 | "autoload=" CFG_AUTOLOAD "\0" |
171 | #endif | 177 | #endif |
172 | #ifdef CONFIG_ROOTPATH | 178 | #ifdef CONFIG_ROOTPATH |
173 | "rootpath=" MK_STR (CONFIG_ROOTPATH) "\0" | 179 | "rootpath=" MK_STR (CONFIG_ROOTPATH) "\0" |
174 | #endif | 180 | #endif |
175 | #ifdef CONFIG_GATEWAYIP | 181 | #ifdef CONFIG_GATEWAYIP |
176 | "gatewayip=" MK_STR (CONFIG_GATEWAYIP) "\0" | 182 | "gatewayip=" MK_STR (CONFIG_GATEWAYIP) "\0" |
177 | #endif | 183 | #endif |
178 | #ifdef CONFIG_NETMASK | 184 | #ifdef CONFIG_NETMASK |
179 | "netmask=" MK_STR (CONFIG_NETMASK) "\0" | 185 | "netmask=" MK_STR (CONFIG_NETMASK) "\0" |
180 | #endif | 186 | #endif |
181 | #ifdef CONFIG_HOSTNAME | 187 | #ifdef CONFIG_HOSTNAME |
182 | "hostname=" MK_STR (CONFIG_HOSTNAME) "\0" | 188 | "hostname=" MK_STR (CONFIG_HOSTNAME) "\0" |
183 | #endif | 189 | #endif |
184 | #ifdef CONFIG_BOOTFILE | 190 | #ifdef CONFIG_BOOTFILE |
185 | "bootfile=" MK_STR (CONFIG_BOOTFILE) "\0" | 191 | "bootfile=" MK_STR (CONFIG_BOOTFILE) "\0" |
186 | #endif | 192 | #endif |
187 | #ifdef CONFIG_LOADADDR | 193 | #ifdef CONFIG_LOADADDR |
188 | "loadaddr=" MK_STR (CONFIG_LOADADDR) "\0" | 194 | "loadaddr=" MK_STR (CONFIG_LOADADDR) "\0" |
189 | #endif | 195 | #endif |
190 | #ifdef CONFIG_PREBOOT | 196 | #ifdef CONFIG_PREBOOT |
191 | "preboot=" CONFIG_PREBOOT "\0" | 197 | "preboot=" CONFIG_PREBOOT "\0" |
192 | #endif | 198 | #endif |
193 | #ifdef CONFIG_CLOCKS_IN_MHZ | 199 | #ifdef CONFIG_CLOCKS_IN_MHZ |
194 | "clocks_in_mhz=" "1" "\0" | 200 | "clocks_in_mhz=" "1" "\0" |
195 | #endif | 201 | #endif |
196 | #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) | 202 | #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) |
197 | "pcidelay=" MK_STR (CONFIG_PCI_BOOTDELAY) "\0" | 203 | "pcidelay=" MK_STR (CONFIG_PCI_BOOTDELAY) "\0" |
198 | #endif | 204 | #endif |
199 | #ifdef CONFIG_EXTRA_ENV_SETTINGS | 205 | #ifdef CONFIG_EXTRA_ENV_SETTINGS |
200 | CONFIG_EXTRA_ENV_SETTINGS | 206 | CONFIG_EXTRA_ENV_SETTINGS |
201 | #endif | 207 | #endif |
202 | "\0" /* Termimate struct environment data with 2 NULs */ | 208 | "\0" /* Termimate struct environment data with 2 NULs */ |
203 | }; | 209 | }; |
204 | 210 | ||
205 | static int flash_io (int mode); | 211 | static int flash_io (int mode); |
206 | static char *envmatch (char * s1, char * s2); | 212 | static char *envmatch (char * s1, char * s2); |
207 | static int env_init (void); | 213 | static int env_init (void); |
208 | static int parse_config (void); | 214 | static int parse_config (void); |
209 | 215 | ||
210 | #if defined(CONFIG_FILE) | 216 | #if defined(CONFIG_FILE) |
211 | static int get_config (char *); | 217 | static int get_config (char *); |
212 | #endif | 218 | #endif |
213 | static inline ulong getenvsize (void) | 219 | static inline ulong getenvsize (void) |
214 | { | 220 | { |
215 | ulong rc = CONFIG_ENV_SIZE - sizeof (long); | 221 | ulong rc = CONFIG_ENV_SIZE - sizeof (long); |
216 | 222 | ||
217 | if (HaveRedundEnv) | 223 | if (HaveRedundEnv) |
218 | rc -= sizeof (char); | 224 | rc -= sizeof (char); |
219 | return rc; | 225 | return rc; |
220 | } | 226 | } |
221 | 227 | ||
222 | /* | 228 | /* |
223 | * Search the environment for a variable. | 229 | * Search the environment for a variable. |
224 | * Return the value, if found, or NULL, if not found. | 230 | * Return the value, if found, or NULL, if not found. |
225 | */ | 231 | */ |
226 | char *fw_getenv (char *name) | 232 | char *fw_getenv (char *name) |
227 | { | 233 | { |
228 | char *env, *nxt; | 234 | char *env, *nxt; |
229 | 235 | ||
230 | if (env_init ()) | 236 | if (env_init ()) |
231 | return NULL; | 237 | return NULL; |
232 | 238 | ||
233 | for (env = environment.data; *env; env = nxt + 1) { | 239 | for (env = environment.data; *env; env = nxt + 1) { |
234 | char *val; | 240 | char *val; |
235 | 241 | ||
236 | for (nxt = env; *nxt; ++nxt) { | 242 | for (nxt = env; *nxt; ++nxt) { |
237 | if (nxt >= &environment.data[ENV_SIZE]) { | 243 | if (nxt >= &environment.data[ENV_SIZE]) { |
238 | fprintf (stderr, "## Error: " | 244 | fprintf (stderr, "## Error: " |
239 | "environment not terminated\n"); | 245 | "environment not terminated\n"); |
240 | return NULL; | 246 | return NULL; |
241 | } | 247 | } |
242 | } | 248 | } |
243 | val = envmatch (name, env); | 249 | val = envmatch (name, env); |
244 | if (!val) | 250 | if (!val) |
245 | continue; | 251 | continue; |
246 | return val; | 252 | return val; |
247 | } | 253 | } |
248 | return NULL; | 254 | return NULL; |
249 | } | 255 | } |
250 | 256 | ||
251 | /* | 257 | /* |
252 | * Print the current definition of one, or more, or all | 258 | * Print the current definition of one, or more, or all |
253 | * environment variables | 259 | * environment variables |
254 | */ | 260 | */ |
255 | int fw_printenv (int argc, char *argv[]) | 261 | int fw_printenv (int argc, char *argv[]) |
256 | { | 262 | { |
257 | char *env, *nxt; | 263 | char *env, *nxt; |
258 | int i, n_flag; | 264 | int i, n_flag; |
259 | int rc = 0; | 265 | int rc = 0; |
260 | 266 | ||
261 | if (env_init ()) | 267 | if (env_init ()) |
262 | return -1; | 268 | return -1; |
263 | 269 | ||
264 | if (argc == 1) { /* Print all env variables */ | 270 | if (argc == 1) { /* Print all env variables */ |
265 | for (env = environment.data; *env; env = nxt + 1) { | 271 | for (env = environment.data; *env; env = nxt + 1) { |
266 | for (nxt = env; *nxt; ++nxt) { | 272 | for (nxt = env; *nxt; ++nxt) { |
267 | if (nxt >= &environment.data[ENV_SIZE]) { | 273 | if (nxt >= &environment.data[ENV_SIZE]) { |
268 | fprintf (stderr, "## Error: " | 274 | fprintf (stderr, "## Error: " |
269 | "environment not terminated\n"); | 275 | "environment not terminated\n"); |
270 | return -1; | 276 | return -1; |
271 | } | 277 | } |
272 | } | 278 | } |
273 | 279 | ||
274 | printf ("%s\n", env); | 280 | printf ("%s\n", env); |
275 | } | 281 | } |
276 | return 0; | 282 | return 0; |
277 | } | 283 | } |
278 | 284 | ||
279 | if (strcmp (argv[1], "-n") == 0) { | 285 | if (strcmp (argv[1], "-n") == 0) { |
280 | n_flag = 1; | 286 | n_flag = 1; |
281 | ++argv; | 287 | ++argv; |
282 | --argc; | 288 | --argc; |
283 | if (argc != 2) { | 289 | if (argc != 2) { |
284 | fprintf (stderr, "## Error: " | 290 | fprintf (stderr, "## Error: " |
285 | "`-n' option requires exactly one argument\n"); | 291 | "`-n' option requires exactly one argument\n"); |
286 | return -1; | 292 | return -1; |
287 | } | 293 | } |
288 | } else { | 294 | } else { |
289 | n_flag = 0; | 295 | n_flag = 0; |
290 | } | 296 | } |
291 | 297 | ||
292 | for (i = 1; i < argc; ++i) { /* print single env variables */ | 298 | for (i = 1; i < argc; ++i) { /* print single env variables */ |
293 | char *name = argv[i]; | 299 | char *name = argv[i]; |
294 | char *val = NULL; | 300 | char *val = NULL; |
295 | 301 | ||
296 | for (env = environment.data; *env; env = nxt + 1) { | 302 | for (env = environment.data; *env; env = nxt + 1) { |
297 | 303 | ||
298 | for (nxt = env; *nxt; ++nxt) { | 304 | for (nxt = env; *nxt; ++nxt) { |
299 | if (nxt >= &environment.data[ENV_SIZE]) { | 305 | if (nxt >= &environment.data[ENV_SIZE]) { |
300 | fprintf (stderr, "## Error: " | 306 | fprintf (stderr, "## Error: " |
301 | "environment not terminated\n"); | 307 | "environment not terminated\n"); |
302 | return -1; | 308 | return -1; |
303 | } | 309 | } |
304 | } | 310 | } |
305 | val = envmatch (name, env); | 311 | val = envmatch (name, env); |
306 | if (val) { | 312 | if (val) { |
307 | if (!n_flag) { | 313 | if (!n_flag) { |
308 | fputs (name, stdout); | 314 | fputs (name, stdout); |
309 | putc ('=', stdout); | 315 | putc ('=', stdout); |
310 | } | 316 | } |
311 | puts (val); | 317 | puts (val); |
312 | break; | 318 | break; |
313 | } | 319 | } |
314 | } | 320 | } |
315 | if (!val) { | 321 | if (!val) { |
316 | fprintf (stderr, "## Error: \"%s\" not defined\n", name); | 322 | fprintf (stderr, "## Error: \"%s\" not defined\n", name); |
317 | rc = -1; | 323 | rc = -1; |
318 | } | 324 | } |
319 | } | 325 | } |
320 | 326 | ||
321 | return rc; | 327 | return rc; |
322 | } | 328 | } |
323 | 329 | ||
324 | /* | 330 | /* |
325 | * Deletes or sets environment variables. Returns -1 and sets errno error codes: | 331 | * Deletes or sets environment variables. Returns -1 and sets errno error codes: |
326 | * 0 - OK | 332 | * 0 - OK |
327 | * EINVAL - need at least 1 argument | 333 | * EINVAL - need at least 1 argument |
328 | * EROFS - certain variables ("ethaddr", "serial#") cannot be | 334 | * EROFS - certain variables ("ethaddr", "serial#") cannot be |
329 | * modified or deleted | 335 | * modified or deleted |
330 | * | 336 | * |
331 | */ | 337 | */ |
332 | int fw_setenv (int argc, char *argv[]) | 338 | int fw_setenv (int argc, char *argv[]) |
333 | { | 339 | { |
334 | int i, len; | 340 | int i, len; |
335 | char *env, *nxt; | 341 | char *env, *nxt; |
336 | char *oldval = NULL; | 342 | char *oldval = NULL; |
337 | char *name; | 343 | char *name; |
338 | 344 | ||
339 | if (argc < 2) { | 345 | if (argc < 2) { |
340 | errno = EINVAL; | 346 | errno = EINVAL; |
341 | return -1; | 347 | return -1; |
342 | } | 348 | } |
343 | 349 | ||
344 | if (env_init ()) | 350 | if (env_init ()) |
345 | return -1; | 351 | return -1; |
346 | 352 | ||
347 | name = argv[1]; | 353 | name = argv[1]; |
348 | 354 | ||
349 | /* | 355 | /* |
350 | * search if variable with this name already exists | 356 | * search if variable with this name already exists |
351 | */ | 357 | */ |
352 | for (nxt = env = environment.data; *env; env = nxt + 1) { | 358 | for (nxt = env = environment.data; *env; env = nxt + 1) { |
353 | for (nxt = env; *nxt; ++nxt) { | 359 | for (nxt = env; *nxt; ++nxt) { |
354 | if (nxt >= &environment.data[ENV_SIZE]) { | 360 | if (nxt >= &environment.data[ENV_SIZE]) { |
355 | fprintf (stderr, "## Error: " | 361 | fprintf (stderr, "## Error: " |
356 | "environment not terminated\n"); | 362 | "environment not terminated\n"); |
357 | errno = EINVAL; | 363 | errno = EINVAL; |
358 | return -1; | 364 | return -1; |
359 | } | 365 | } |
360 | } | 366 | } |
361 | if ((oldval = envmatch (name, env)) != NULL) | 367 | if ((oldval = envmatch (name, env)) != NULL) |
362 | break; | 368 | break; |
363 | } | 369 | } |
364 | 370 | ||
365 | /* | 371 | /* |
366 | * Delete any existing definition | 372 | * Delete any existing definition |
367 | */ | 373 | */ |
368 | if (oldval) { | 374 | if (oldval) { |
369 | /* | 375 | /* |
370 | * Ethernet Address and serial# can be set only once | 376 | * Ethernet Address and serial# can be set only once |
371 | */ | 377 | */ |
372 | if ((strcmp (name, "ethaddr") == 0) || | 378 | if ((strcmp (name, "ethaddr") == 0) || |
373 | (strcmp (name, "serial#") == 0)) { | 379 | (strcmp (name, "serial#") == 0)) { |
374 | fprintf (stderr, "Can't overwrite \"%s\"\n", name); | 380 | fprintf (stderr, "Can't overwrite \"%s\"\n", name); |
375 | errno = EROFS; | 381 | errno = EROFS; |
376 | return -1; | 382 | return -1; |
377 | } | 383 | } |
378 | 384 | ||
379 | if (*++nxt == '\0') { | 385 | if (*++nxt == '\0') { |
380 | *env = '\0'; | 386 | *env = '\0'; |
381 | } else { | 387 | } else { |
382 | for (;;) { | 388 | for (;;) { |
383 | *env = *nxt++; | 389 | *env = *nxt++; |
384 | if ((*env == '\0') && (*nxt == '\0')) | 390 | if ((*env == '\0') && (*nxt == '\0')) |
385 | break; | 391 | break; |
386 | ++env; | 392 | ++env; |
387 | } | 393 | } |
388 | } | 394 | } |
389 | *++env = '\0'; | 395 | *++env = '\0'; |
390 | } | 396 | } |
391 | 397 | ||
392 | /* Delete only ? */ | 398 | /* Delete only ? */ |
393 | if (argc < 3) | 399 | if (argc < 3) |
394 | goto WRITE_FLASH; | 400 | goto WRITE_FLASH; |
395 | 401 | ||
396 | /* | 402 | /* |
397 | * Append new definition at the end | 403 | * Append new definition at the end |
398 | */ | 404 | */ |
399 | for (env = environment.data; *env || *(env + 1); ++env); | 405 | for (env = environment.data; *env || *(env + 1); ++env); |
400 | if (env > environment.data) | 406 | if (env > environment.data) |
401 | ++env; | 407 | ++env; |
402 | /* | 408 | /* |
403 | * Overflow when: | 409 | * Overflow when: |
404 | * "name" + "=" + "val" +"\0\0" > CONFIG_ENV_SIZE - (env-environment) | 410 | * "name" + "=" + "val" +"\0\0" > CONFIG_ENV_SIZE - (env-environment) |
405 | */ | 411 | */ |
406 | len = strlen (name) + 2; | 412 | len = strlen (name) + 2; |
407 | /* add '=' for first arg, ' ' for all others */ | 413 | /* add '=' for first arg, ' ' for all others */ |
408 | for (i = 2; i < argc; ++i) { | 414 | for (i = 2; i < argc; ++i) { |
409 | len += strlen (argv[i]) + 1; | 415 | len += strlen (argv[i]) + 1; |
410 | } | 416 | } |
411 | if (len > (&environment.data[ENV_SIZE] - env)) { | 417 | if (len > (&environment.data[ENV_SIZE] - env)) { |
412 | fprintf (stderr, | 418 | fprintf (stderr, |
413 | "Error: environment overflow, \"%s\" deleted\n", | 419 | "Error: environment overflow, \"%s\" deleted\n", |
414 | name); | 420 | name); |
415 | return -1; | 421 | return -1; |
416 | } | 422 | } |
417 | while ((*env = *name++) != '\0') | 423 | while ((*env = *name++) != '\0') |
418 | env++; | 424 | env++; |
419 | for (i = 2; i < argc; ++i) { | 425 | for (i = 2; i < argc; ++i) { |
420 | char *val = argv[i]; | 426 | char *val = argv[i]; |
421 | 427 | ||
422 | *env = (i == 2) ? '=' : ' '; | 428 | *env = (i == 2) ? '=' : ' '; |
423 | while ((*++env = *val++) != '\0'); | 429 | while ((*++env = *val++) != '\0'); |
424 | } | 430 | } |
425 | 431 | ||
426 | /* end is marked with double '\0' */ | 432 | /* end is marked with double '\0' */ |
427 | *++env = '\0'; | 433 | *++env = '\0'; |
428 | 434 | ||
429 | WRITE_FLASH: | 435 | WRITE_FLASH: |
430 | 436 | ||
431 | /* | 437 | /* |
432 | * Update CRC | 438 | * Update CRC |
433 | */ | 439 | */ |
434 | *environment.crc = crc32 (0, (uint8_t *) environment.data, ENV_SIZE); | 440 | *environment.crc = crc32 (0, (uint8_t *) environment.data, ENV_SIZE); |
435 | 441 | ||
436 | /* write environment back to flash */ | 442 | /* write environment back to flash */ |
437 | if (flash_io (O_RDWR)) { | 443 | if (flash_io (O_RDWR)) { |
438 | fprintf (stderr, "Error: can't write fw_env to flash\n"); | 444 | fprintf (stderr, "Error: can't write fw_env to flash\n"); |
439 | return -1; | 445 | return -1; |
440 | } | 446 | } |
441 | 447 | ||
442 | return 0; | 448 | return 0; |
443 | } | 449 | } |
444 | 450 | ||
445 | /* | 451 | /* |
446 | * Test for bad block on NAND, just returns 0 on NOR, on NAND: | 452 | * Test for bad block on NAND, just returns 0 on NOR, on NAND: |
447 | * 0 - block is good | 453 | * 0 - block is good |
448 | * > 0 - block is bad | 454 | * > 0 - block is bad |
449 | * < 0 - failed to test | 455 | * < 0 - failed to test |
450 | */ | 456 | */ |
451 | static int flash_bad_block (int fd, uint8_t mtd_type, loff_t *blockstart) | 457 | static int flash_bad_block (int fd, uint8_t mtd_type, loff_t *blockstart) |
452 | { | 458 | { |
453 | if (mtd_type == MTD_NANDFLASH) { | 459 | if (mtd_type == MTD_NANDFLASH) { |
454 | int badblock = ioctl (fd, MEMGETBADBLOCK, blockstart); | 460 | int badblock = ioctl (fd, MEMGETBADBLOCK, blockstart); |
455 | 461 | ||
456 | if (badblock < 0) { | 462 | if (badblock < 0) { |
457 | perror ("Cannot read bad block mark"); | 463 | perror ("Cannot read bad block mark"); |
458 | return badblock; | 464 | return badblock; |
459 | } | 465 | } |
460 | 466 | ||
461 | if (badblock) { | 467 | if (badblock) { |
462 | #ifdef DEBUG | 468 | #ifdef DEBUG |
463 | fprintf (stderr, "Bad block at 0x%llx, " | 469 | fprintf (stderr, "Bad block at 0x%llx, " |
464 | "skipping\n", *blockstart); | 470 | "skipping\n", *blockstart); |
465 | #endif | 471 | #endif |
466 | return badblock; | 472 | return badblock; |
467 | } | 473 | } |
468 | } | 474 | } |
469 | 475 | ||
470 | return 0; | 476 | return 0; |
471 | } | 477 | } |
472 | 478 | ||
473 | /* | 479 | /* |
474 | * Read data from flash at an offset into a provided buffer. On NAND it skips | 480 | * Read data from flash at an offset into a provided buffer. On NAND it skips |
475 | * bad blocks but makes sure it stays within ENVSECTORS (dev) starting from | 481 | * bad blocks but makes sure it stays within ENVSECTORS (dev) starting from |
476 | * the DEVOFFSET (dev) block. On NOR the loop is only run once. | 482 | * the DEVOFFSET (dev) block. On NOR the loop is only run once. |
477 | */ | 483 | */ |
478 | static int flash_read_buf (int dev, int fd, void *buf, size_t count, | 484 | static int flash_read_buf (int dev, int fd, void *buf, size_t count, |
479 | off_t offset, uint8_t mtd_type) | 485 | off_t offset, uint8_t mtd_type) |
480 | { | 486 | { |
481 | size_t blocklen; /* erase / write length - one block on NAND, | 487 | size_t blocklen; /* erase / write length - one block on NAND, |
482 | 0 on NOR */ | 488 | 0 on NOR */ |
483 | size_t processed = 0; /* progress counter */ | 489 | size_t processed = 0; /* progress counter */ |
484 | size_t readlen = count; /* current read length */ | 490 | size_t readlen = count; /* current read length */ |
485 | off_t top_of_range; /* end of the last block we may use */ | 491 | off_t top_of_range; /* end of the last block we may use */ |
486 | off_t block_seek; /* offset inside the current block to the start | 492 | off_t block_seek; /* offset inside the current block to the start |
487 | of the data */ | 493 | of the data */ |
488 | loff_t blockstart; /* running start of the current block - | 494 | loff_t blockstart; /* running start of the current block - |
489 | MEMGETBADBLOCK needs 64 bits */ | 495 | MEMGETBADBLOCK needs 64 bits */ |
490 | int rc; | 496 | int rc; |
491 | 497 | ||
492 | /* | 498 | /* |
493 | * Start of the first block to be read, relies on the fact, that | 499 | * Start of the first block to be read, relies on the fact, that |
494 | * erase sector size is always a power of 2 | 500 | * erase sector size is always a power of 2 |
495 | */ | 501 | */ |
496 | blockstart = offset & ~(DEVESIZE (dev) - 1); | 502 | blockstart = offset & ~(DEVESIZE (dev) - 1); |
497 | 503 | ||
498 | /* Offset inside a block */ | 504 | /* Offset inside a block */ |
499 | block_seek = offset - blockstart; | 505 | block_seek = offset - blockstart; |
500 | 506 | ||
501 | if (mtd_type == MTD_NANDFLASH) { | 507 | if (mtd_type == MTD_NANDFLASH) { |
502 | /* | 508 | /* |
503 | * NAND: calculate which blocks we are reading. We have | 509 | * NAND: calculate which blocks we are reading. We have |
504 | * to read one block at a time to skip bad blocks. | 510 | * to read one block at a time to skip bad blocks. |
505 | */ | 511 | */ |
506 | blocklen = DEVESIZE (dev); | 512 | blocklen = DEVESIZE (dev); |
507 | 513 | ||
508 | /* | 514 | /* |
509 | * To calculate the top of the range, we have to use the | 515 | * To calculate the top of the range, we have to use the |
510 | * global DEVOFFSET (dev), which can be different from offset | 516 | * global DEVOFFSET (dev), which can be different from offset |
511 | */ | 517 | */ |
512 | top_of_range = (DEVOFFSET (dev) & ~(blocklen - 1)) + | 518 | top_of_range = (DEVOFFSET (dev) & ~(blocklen - 1)) + |
513 | ENVSECTORS (dev) * blocklen; | 519 | ENVSECTORS (dev) * blocklen; |
514 | 520 | ||
515 | /* Limit to one block for the first read */ | 521 | /* Limit to one block for the first read */ |
516 | if (readlen > blocklen - block_seek) | 522 | if (readlen > blocklen - block_seek) |
517 | readlen = blocklen - block_seek; | 523 | readlen = blocklen - block_seek; |
518 | } else { | 524 | } else { |
519 | blocklen = 0; | 525 | blocklen = 0; |
520 | top_of_range = offset + count; | 526 | top_of_range = offset + count; |
521 | } | 527 | } |
522 | 528 | ||
523 | /* This only runs once on NOR flash */ | 529 | /* This only runs once on NOR flash */ |
524 | while (processed < count) { | 530 | while (processed < count) { |
525 | rc = flash_bad_block (fd, mtd_type, &blockstart); | 531 | rc = flash_bad_block (fd, mtd_type, &blockstart); |
526 | if (rc < 0) /* block test failed */ | 532 | if (rc < 0) /* block test failed */ |
527 | return -1; | 533 | return -1; |
528 | 534 | ||
529 | if (blockstart + block_seek + readlen > top_of_range) { | 535 | if (blockstart + block_seek + readlen > top_of_range) { |
530 | /* End of range is reached */ | 536 | /* End of range is reached */ |
531 | fprintf (stderr, | 537 | fprintf (stderr, |
532 | "Too few good blocks within range\n"); | 538 | "Too few good blocks within range\n"); |
533 | return -1; | 539 | return -1; |
534 | } | 540 | } |
535 | 541 | ||
536 | if (rc) { /* block is bad */ | 542 | if (rc) { /* block is bad */ |
537 | blockstart += blocklen; | 543 | blockstart += blocklen; |
538 | continue; | 544 | continue; |
539 | } | 545 | } |
540 | 546 | ||
541 | /* | 547 | /* |
542 | * If a block is bad, we retry in the next block at the same | 548 | * If a block is bad, we retry in the next block at the same |
543 | * offset - see common/env_nand.c::writeenv() | 549 | * offset - see common/env_nand.c::writeenv() |
544 | */ | 550 | */ |
545 | lseek (fd, blockstart + block_seek, SEEK_SET); | 551 | lseek (fd, blockstart + block_seek, SEEK_SET); |
546 | 552 | ||
547 | rc = read (fd, buf + processed, readlen); | 553 | rc = read (fd, buf + processed, readlen); |
548 | if (rc != readlen) { | 554 | if (rc != readlen) { |
549 | fprintf (stderr, "Read error on %s: %s\n", | 555 | fprintf (stderr, "Read error on %s: %s\n", |
550 | DEVNAME (dev), strerror (errno)); | 556 | DEVNAME (dev), strerror (errno)); |
551 | return -1; | 557 | return -1; |
552 | } | 558 | } |
553 | #ifdef DEBUG | 559 | #ifdef DEBUG |
554 | fprintf (stderr, "Read 0x%x bytes at 0x%llx\n", | 560 | fprintf (stderr, "Read 0x%x bytes at 0x%llx\n", |
555 | rc, blockstart + block_seek); | 561 | rc, blockstart + block_seek); |
556 | #endif | 562 | #endif |
557 | processed += readlen; | 563 | processed += readlen; |
558 | readlen = min (blocklen, count - processed); | 564 | readlen = min (blocklen, count - processed); |
559 | block_seek = 0; | 565 | block_seek = 0; |
560 | blockstart += blocklen; | 566 | blockstart += blocklen; |
561 | } | 567 | } |
562 | 568 | ||
563 | return processed; | 569 | return processed; |
564 | } | 570 | } |
565 | 571 | ||
566 | /* | 572 | /* |
567 | * Write count bytes at offset, but stay within ENVSETCORS (dev) sectors of | 573 | * Write count bytes at offset, but stay within ENVSETCORS (dev) sectors of |
568 | * DEVOFFSET (dev). Similar to the read case above, on NOR we erase and write | 574 | * DEVOFFSET (dev). Similar to the read case above, on NOR we erase and write |
569 | * the whole data at once. | 575 | * the whole data at once. |
570 | */ | 576 | */ |
571 | static int flash_write_buf (int dev, int fd, void *buf, size_t count, | 577 | static int flash_write_buf (int dev, int fd, void *buf, size_t count, |
572 | off_t offset, uint8_t mtd_type) | 578 | off_t offset, uint8_t mtd_type) |
573 | { | 579 | { |
574 | void *data; | 580 | void *data; |
575 | struct erase_info_user erase; | 581 | struct erase_info_user erase; |
576 | size_t blocklen; /* length of NAND block / NOR erase sector */ | 582 | size_t blocklen; /* length of NAND block / NOR erase sector */ |
577 | size_t erase_len; /* whole area that can be erased - may include | 583 | size_t erase_len; /* whole area that can be erased - may include |
578 | bad blocks */ | 584 | bad blocks */ |
579 | size_t erasesize; /* erase / write length - one block on NAND, | 585 | size_t erasesize; /* erase / write length - one block on NAND, |
580 | whole area on NOR */ | 586 | whole area on NOR */ |
581 | size_t processed = 0; /* progress counter */ | 587 | size_t processed = 0; /* progress counter */ |
582 | size_t write_total; /* total size to actually write - excludinig | 588 | size_t write_total; /* total size to actually write - excludinig |
583 | bad blocks */ | 589 | bad blocks */ |
584 | off_t erase_offset; /* offset to the first erase block (aligned) | 590 | off_t erase_offset; /* offset to the first erase block (aligned) |
585 | below offset */ | 591 | below offset */ |
586 | off_t block_seek; /* offset inside the erase block to the start | 592 | off_t block_seek; /* offset inside the erase block to the start |
587 | of the data */ | 593 | of the data */ |
588 | off_t top_of_range; /* end of the last block we may use */ | 594 | off_t top_of_range; /* end of the last block we may use */ |
589 | loff_t blockstart; /* running start of the current block - | 595 | loff_t blockstart; /* running start of the current block - |
590 | MEMGETBADBLOCK needs 64 bits */ | 596 | MEMGETBADBLOCK needs 64 bits */ |
591 | int rc; | 597 | int rc; |
592 | 598 | ||
593 | blocklen = DEVESIZE (dev); | 599 | blocklen = DEVESIZE (dev); |
594 | 600 | ||
595 | /* Erase sector size is always a power of 2 */ | 601 | /* Erase sector size is always a power of 2 */ |
596 | top_of_range = (DEVOFFSET (dev) & ~(blocklen - 1)) + | 602 | top_of_range = (DEVOFFSET (dev) & ~(blocklen - 1)) + |
597 | ENVSECTORS (dev) * blocklen; | 603 | ENVSECTORS (dev) * blocklen; |
598 | 604 | ||
599 | erase_offset = offset & ~(blocklen - 1); | 605 | erase_offset = offset & ~(blocklen - 1); |
600 | 606 | ||
601 | /* Maximum area we may use */ | 607 | /* Maximum area we may use */ |
602 | erase_len = top_of_range - erase_offset; | 608 | erase_len = top_of_range - erase_offset; |
603 | 609 | ||
604 | blockstart = erase_offset; | 610 | blockstart = erase_offset; |
605 | /* Offset inside a block */ | 611 | /* Offset inside a block */ |
606 | block_seek = offset - erase_offset; | 612 | block_seek = offset - erase_offset; |
607 | 613 | ||
608 | /* | 614 | /* |
609 | * Data size we actually have to write: from the start of the block | 615 | * Data size we actually have to write: from the start of the block |
610 | * to the start of the data, then count bytes of data, and to the | 616 | * to the start of the data, then count bytes of data, and to the |
611 | * end of the block | 617 | * end of the block |
612 | */ | 618 | */ |
613 | write_total = (block_seek + count + blocklen - 1) & ~(blocklen - 1); | 619 | write_total = (block_seek + count + blocklen - 1) & ~(blocklen - 1); |
614 | 620 | ||
615 | /* | 621 | /* |
616 | * Support data anywhere within erase sectors: read out the complete | 622 | * Support data anywhere within erase sectors: read out the complete |
617 | * area to be erased, replace the environment image, write the whole | 623 | * area to be erased, replace the environment image, write the whole |
618 | * block back again. | 624 | * block back again. |
619 | */ | 625 | */ |
620 | if (write_total > count) { | 626 | if (write_total > count) { |
621 | data = malloc (erase_len); | 627 | data = malloc (erase_len); |
622 | if (!data) { | 628 | if (!data) { |
623 | fprintf (stderr, | 629 | fprintf (stderr, |
624 | "Cannot malloc %u bytes: %s\n", | 630 | "Cannot malloc %u bytes: %s\n", |
625 | erase_len, strerror (errno)); | 631 | erase_len, strerror (errno)); |
626 | return -1; | 632 | return -1; |
627 | } | 633 | } |
628 | 634 | ||
629 | rc = flash_read_buf (dev, fd, data, write_total, erase_offset, | 635 | rc = flash_read_buf (dev, fd, data, write_total, erase_offset, |
630 | mtd_type); | 636 | mtd_type); |
631 | if (write_total != rc) | 637 | if (write_total != rc) |
632 | return -1; | 638 | return -1; |
633 | 639 | ||
634 | /* Overwrite the old environment */ | 640 | /* Overwrite the old environment */ |
635 | memcpy (data + block_seek, buf, count); | 641 | memcpy (data + block_seek, buf, count); |
636 | } else { | 642 | } else { |
637 | /* | 643 | /* |
638 | * We get here, iff offset is block-aligned and count is a | 644 | * We get here, iff offset is block-aligned and count is a |
639 | * multiple of blocklen - see write_total calculation above | 645 | * multiple of blocklen - see write_total calculation above |
640 | */ | 646 | */ |
641 | data = buf; | 647 | data = buf; |
642 | } | 648 | } |
643 | 649 | ||
644 | if (mtd_type == MTD_NANDFLASH) { | 650 | if (mtd_type == MTD_NANDFLASH) { |
645 | /* | 651 | /* |
646 | * NAND: calculate which blocks we are writing. We have | 652 | * NAND: calculate which blocks we are writing. We have |
647 | * to write one block at a time to skip bad blocks. | 653 | * to write one block at a time to skip bad blocks. |
648 | */ | 654 | */ |
649 | erasesize = blocklen; | 655 | erasesize = blocklen; |
650 | } else { | 656 | } else { |
651 | erasesize = erase_len; | 657 | erasesize = erase_len; |
652 | } | 658 | } |
653 | 659 | ||
654 | erase.length = erasesize; | 660 | erase.length = erasesize; |
655 | 661 | ||
656 | /* This only runs once on NOR flash */ | 662 | /* This only runs once on NOR flash */ |
657 | while (processed < write_total) { | 663 | while (processed < write_total) { |
658 | rc = flash_bad_block (fd, mtd_type, &blockstart); | 664 | rc = flash_bad_block (fd, mtd_type, &blockstart); |
659 | if (rc < 0) /* block test failed */ | 665 | if (rc < 0) /* block test failed */ |
660 | return rc; | 666 | return rc; |
661 | 667 | ||
662 | if (blockstart + erasesize > top_of_range) { | 668 | if (blockstart + erasesize > top_of_range) { |
663 | fprintf (stderr, "End of range reached, aborting\n"); | 669 | fprintf (stderr, "End of range reached, aborting\n"); |
664 | return -1; | 670 | return -1; |
665 | } | 671 | } |
666 | 672 | ||
667 | if (rc) { /* block is bad */ | 673 | if (rc) { /* block is bad */ |
668 | blockstart += blocklen; | 674 | blockstart += blocklen; |
669 | continue; | 675 | continue; |
670 | } | 676 | } |
671 | 677 | ||
672 | erase.start = blockstart; | 678 | erase.start = blockstart; |
673 | ioctl (fd, MEMUNLOCK, &erase); | 679 | ioctl (fd, MEMUNLOCK, &erase); |
674 | 680 | ||
675 | if (ioctl (fd, MEMERASE, &erase) != 0) { | 681 | if (ioctl (fd, MEMERASE, &erase) != 0) { |
676 | fprintf (stderr, "MTD erase error on %s: %s\n", | 682 | fprintf (stderr, "MTD erase error on %s: %s\n", |
677 | DEVNAME (dev), | 683 | DEVNAME (dev), |
678 | strerror (errno)); | 684 | strerror (errno)); |
679 | return -1; | 685 | return -1; |
680 | } | 686 | } |
681 | 687 | ||
682 | if (lseek (fd, blockstart, SEEK_SET) == -1) { | 688 | if (lseek (fd, blockstart, SEEK_SET) == -1) { |
683 | fprintf (stderr, | 689 | fprintf (stderr, |
684 | "Seek error on %s: %s\n", | 690 | "Seek error on %s: %s\n", |
685 | DEVNAME (dev), strerror (errno)); | 691 | DEVNAME (dev), strerror (errno)); |
686 | return -1; | 692 | return -1; |
687 | } | 693 | } |
688 | 694 | ||
689 | #ifdef DEBUG | 695 | #ifdef DEBUG |
690 | printf ("Write 0x%x bytes at 0x%llx\n", erasesize, blockstart); | 696 | printf ("Write 0x%x bytes at 0x%llx\n", erasesize, blockstart); |
691 | #endif | 697 | #endif |
692 | if (write (fd, data + processed, erasesize) != erasesize) { | 698 | if (write (fd, data + processed, erasesize) != erasesize) { |
693 | fprintf (stderr, "Write error on %s: %s\n", | 699 | fprintf (stderr, "Write error on %s: %s\n", |
694 | DEVNAME (dev), strerror (errno)); | 700 | DEVNAME (dev), strerror (errno)); |
695 | return -1; | 701 | return -1; |
696 | } | 702 | } |
697 | 703 | ||
698 | ioctl (fd, MEMLOCK, &erase); | 704 | ioctl (fd, MEMLOCK, &erase); |
699 | 705 | ||
700 | processed += blocklen; | 706 | processed += blocklen; |
701 | block_seek = 0; | 707 | block_seek = 0; |
702 | blockstart += blocklen; | 708 | blockstart += blocklen; |
703 | } | 709 | } |
704 | 710 | ||
705 | if (write_total > count) | 711 | if (write_total > count) |
706 | free (data); | 712 | free (data); |
707 | 713 | ||
708 | return processed; | 714 | return processed; |
709 | } | 715 | } |
710 | 716 | ||
711 | /* | 717 | /* |
712 | * Set obsolete flag at offset - NOR flash only | 718 | * Set obsolete flag at offset - NOR flash only |
713 | */ | 719 | */ |
714 | static int flash_flag_obsolete (int dev, int fd, off_t offset) | 720 | static int flash_flag_obsolete (int dev, int fd, off_t offset) |
715 | { | 721 | { |
716 | int rc; | 722 | int rc; |
717 | 723 | ||
718 | /* This relies on the fact, that obsolete_flag == 0 */ | 724 | /* This relies on the fact, that obsolete_flag == 0 */ |
719 | rc = lseek (fd, offset, SEEK_SET); | 725 | rc = lseek (fd, offset, SEEK_SET); |
720 | if (rc < 0) { | 726 | if (rc < 0) { |
721 | fprintf (stderr, "Cannot seek to set the flag on %s \n", | 727 | fprintf (stderr, "Cannot seek to set the flag on %s \n", |
722 | DEVNAME (dev)); | 728 | DEVNAME (dev)); |
723 | return rc; | 729 | return rc; |
724 | } | 730 | } |
725 | rc = write (fd, &obsolete_flag, sizeof (obsolete_flag)); | 731 | rc = write (fd, &obsolete_flag, sizeof (obsolete_flag)); |
726 | if (rc < 0) | 732 | if (rc < 0) |
727 | perror ("Could not set obsolete flag"); | 733 | perror ("Could not set obsolete flag"); |
728 | 734 | ||
729 | return rc; | 735 | return rc; |
730 | } | 736 | } |
731 | 737 | ||
732 | static int flash_write (int fd_current, int fd_target, int dev_target) | 738 | static int flash_write (int fd_current, int fd_target, int dev_target) |
733 | { | 739 | { |
734 | int rc; | 740 | int rc; |
735 | 741 | ||
736 | switch (environment.flag_scheme) { | 742 | switch (environment.flag_scheme) { |
737 | case FLAG_NONE: | 743 | case FLAG_NONE: |
738 | break; | 744 | break; |
739 | case FLAG_INCREMENTAL: | 745 | case FLAG_INCREMENTAL: |
740 | (*environment.flags)++; | 746 | (*environment.flags)++; |
741 | break; | 747 | break; |
742 | case FLAG_BOOLEAN: | 748 | case FLAG_BOOLEAN: |
743 | *environment.flags = active_flag; | 749 | *environment.flags = active_flag; |
744 | break; | 750 | break; |
745 | default: | 751 | default: |
746 | fprintf (stderr, "Unimplemented flash scheme %u \n", | 752 | fprintf (stderr, "Unimplemented flash scheme %u \n", |
747 | environment.flag_scheme); | 753 | environment.flag_scheme); |
748 | return -1; | 754 | return -1; |
749 | } | 755 | } |
750 | 756 | ||
751 | #ifdef DEBUG | 757 | #ifdef DEBUG |
752 | printf ("Writing new environment at 0x%lx on %s\n", | 758 | printf ("Writing new environment at 0x%lx on %s\n", |
753 | DEVOFFSET (dev_target), DEVNAME (dev_target)); | 759 | DEVOFFSET (dev_target), DEVNAME (dev_target)); |
754 | #endif | 760 | #endif |
755 | rc = flash_write_buf (dev_target, fd_target, environment.image, | 761 | rc = flash_write_buf (dev_target, fd_target, environment.image, |
756 | CONFIG_ENV_SIZE, DEVOFFSET (dev_target), | 762 | CONFIG_ENV_SIZE, DEVOFFSET (dev_target), |
757 | DEVTYPE(dev_target)); | 763 | DEVTYPE(dev_target)); |
758 | if (rc < 0) | 764 | if (rc < 0) |
759 | return rc; | 765 | return rc; |
760 | 766 | ||
761 | if (environment.flag_scheme == FLAG_BOOLEAN) { | 767 | if (environment.flag_scheme == FLAG_BOOLEAN) { |
762 | /* Have to set obsolete flag */ | 768 | /* Have to set obsolete flag */ |
763 | off_t offset = DEVOFFSET (dev_current) + | 769 | off_t offset = DEVOFFSET (dev_current) + |
764 | offsetof (struct env_image_redundant, flags); | 770 | offsetof (struct env_image_redundant, flags); |
765 | #ifdef DEBUG | 771 | #ifdef DEBUG |
766 | printf ("Setting obsolete flag in environment at 0x%lx on %s\n", | 772 | printf ("Setting obsolete flag in environment at 0x%lx on %s\n", |
767 | DEVOFFSET (dev_current), DEVNAME (dev_current)); | 773 | DEVOFFSET (dev_current), DEVNAME (dev_current)); |
768 | #endif | 774 | #endif |
769 | flash_flag_obsolete (dev_current, fd_current, offset); | 775 | flash_flag_obsolete (dev_current, fd_current, offset); |
770 | } | 776 | } |
771 | 777 | ||
772 | return 0; | 778 | return 0; |
773 | } | 779 | } |
774 | 780 | ||
775 | static int flash_read (int fd) | 781 | static int flash_read (int fd) |
776 | { | 782 | { |
777 | struct mtd_info_user mtdinfo; | 783 | struct mtd_info_user mtdinfo; |
778 | int rc; | 784 | int rc; |
779 | 785 | ||
780 | rc = ioctl (fd, MEMGETINFO, &mtdinfo); | 786 | rc = ioctl (fd, MEMGETINFO, &mtdinfo); |
781 | if (rc < 0) { | 787 | if (rc < 0) { |
782 | perror ("Cannot get MTD information"); | 788 | perror ("Cannot get MTD information"); |
783 | return -1; | 789 | return -1; |
784 | } | 790 | } |
785 | 791 | ||
786 | if (mtdinfo.type != MTD_NORFLASH && mtdinfo.type != MTD_NANDFLASH) { | 792 | if (mtdinfo.type != MTD_NORFLASH && mtdinfo.type != MTD_NANDFLASH) { |
787 | fprintf (stderr, "Unsupported flash type %u\n", mtdinfo.type); | 793 | fprintf (stderr, "Unsupported flash type %u\n", mtdinfo.type); |
788 | return -1; | 794 | return -1; |
789 | } | 795 | } |
790 | 796 | ||
791 | DEVTYPE(dev_current) = mtdinfo.type; | 797 | DEVTYPE(dev_current) = mtdinfo.type; |
792 | 798 | ||
793 | rc = flash_read_buf (dev_current, fd, environment.image, CONFIG_ENV_SIZE, | 799 | rc = flash_read_buf (dev_current, fd, environment.image, CONFIG_ENV_SIZE, |
794 | DEVOFFSET (dev_current), mtdinfo.type); | 800 | DEVOFFSET (dev_current), mtdinfo.type); |
795 | 801 | ||
796 | return (rc != CONFIG_ENV_SIZE) ? -1 : 0; | 802 | return (rc != CONFIG_ENV_SIZE) ? -1 : 0; |
797 | } | 803 | } |
798 | 804 | ||
799 | static int flash_io (int mode) | 805 | static int flash_io (int mode) |
800 | { | 806 | { |
801 | int fd_current, fd_target, rc, dev_target; | 807 | int fd_current, fd_target, rc, dev_target; |
802 | 808 | ||
803 | /* dev_current: fd_current, erase_current */ | 809 | /* dev_current: fd_current, erase_current */ |
804 | fd_current = open (DEVNAME (dev_current), mode); | 810 | fd_current = open (DEVNAME (dev_current), mode); |
805 | if (fd_current < 0) { | 811 | if (fd_current < 0) { |
806 | fprintf (stderr, | 812 | fprintf (stderr, |
807 | "Can't open %s: %s\n", | 813 | "Can't open %s: %s\n", |
808 | DEVNAME (dev_current), strerror (errno)); | 814 | DEVNAME (dev_current), strerror (errno)); |
809 | return -1; | 815 | return -1; |
810 | } | 816 | } |
811 | 817 | ||
812 | if (mode == O_RDWR) { | 818 | if (mode == O_RDWR) { |
813 | if (HaveRedundEnv) { | 819 | if (HaveRedundEnv) { |
814 | /* switch to next partition for writing */ | 820 | /* switch to next partition for writing */ |
815 | dev_target = !dev_current; | 821 | dev_target = !dev_current; |
816 | /* dev_target: fd_target, erase_target */ | 822 | /* dev_target: fd_target, erase_target */ |
817 | fd_target = open (DEVNAME (dev_target), mode); | 823 | fd_target = open (DEVNAME (dev_target), mode); |
818 | if (fd_target < 0) { | 824 | if (fd_target < 0) { |
819 | fprintf (stderr, | 825 | fprintf (stderr, |
820 | "Can't open %s: %s\n", | 826 | "Can't open %s: %s\n", |
821 | DEVNAME (dev_target), | 827 | DEVNAME (dev_target), |
822 | strerror (errno)); | 828 | strerror (errno)); |
823 | rc = -1; | 829 | rc = -1; |
824 | goto exit; | 830 | goto exit; |
825 | } | 831 | } |
826 | } else { | 832 | } else { |
827 | dev_target = dev_current; | 833 | dev_target = dev_current; |
828 | fd_target = fd_current; | 834 | fd_target = fd_current; |
829 | } | 835 | } |
830 | 836 | ||
831 | rc = flash_write (fd_current, fd_target, dev_target); | 837 | rc = flash_write (fd_current, fd_target, dev_target); |
832 | 838 | ||
833 | if (HaveRedundEnv) { | 839 | if (HaveRedundEnv) { |
834 | if (close (fd_target)) { | 840 | if (close (fd_target)) { |
835 | fprintf (stderr, | 841 | fprintf (stderr, |
836 | "I/O error on %s: %s\n", | 842 | "I/O error on %s: %s\n", |
837 | DEVNAME (dev_target), | 843 | DEVNAME (dev_target), |
838 | strerror (errno)); | 844 | strerror (errno)); |
839 | rc = -1; | 845 | rc = -1; |
840 | } | 846 | } |
841 | } | 847 | } |
842 | } else { | 848 | } else { |
843 | rc = flash_read (fd_current); | 849 | rc = flash_read (fd_current); |
844 | } | 850 | } |
845 | 851 | ||
846 | exit: | 852 | exit: |
847 | if (close (fd_current)) { | 853 | if (close (fd_current)) { |
848 | fprintf (stderr, | 854 | fprintf (stderr, |
849 | "I/O error on %s: %s\n", | 855 | "I/O error on %s: %s\n", |
850 | DEVNAME (dev_current), strerror (errno)); | 856 | DEVNAME (dev_current), strerror (errno)); |
851 | return -1; | 857 | return -1; |
852 | } | 858 | } |
853 | 859 | ||
854 | return rc; | 860 | return rc; |
855 | } | 861 | } |
856 | 862 | ||
857 | /* | 863 | /* |
858 | * s1 is either a simple 'name', or a 'name=value' pair. | 864 | * s1 is either a simple 'name', or a 'name=value' pair. |
859 | * s2 is a 'name=value' pair. | 865 | * s2 is a 'name=value' pair. |
860 | * If the names match, return the value of s2, else NULL. | 866 | * If the names match, return the value of s2, else NULL. |
861 | */ | 867 | */ |
862 | 868 | ||
863 | static char *envmatch (char * s1, char * s2) | 869 | static char *envmatch (char * s1, char * s2) |
864 | { | 870 | { |
865 | 871 | ||
866 | while (*s1 == *s2++) | 872 | while (*s1 == *s2++) |
867 | if (*s1++ == '=') | 873 | if (*s1++ == '=') |
868 | return s2; | 874 | return s2; |
869 | if (*s1 == '\0' && *(s2 - 1) == '=') | 875 | if (*s1 == '\0' && *(s2 - 1) == '=') |
870 | return s2; | 876 | return s2; |
871 | return NULL; | 877 | return NULL; |
872 | } | 878 | } |
873 | 879 | ||
874 | /* | 880 | /* |
875 | * Prevent confusion if running from erased flash memory | 881 | * Prevent confusion if running from erased flash memory |
876 | */ | 882 | */ |
877 | static int env_init (void) | 883 | static int env_init (void) |
878 | { | 884 | { |
879 | int crc0, crc0_ok; | 885 | int crc0, crc0_ok; |
880 | char flag0; | 886 | char flag0; |
881 | void *addr0; | 887 | void *addr0; |
882 | 888 | ||
883 | int crc1, crc1_ok; | 889 | int crc1, crc1_ok; |
884 | char flag1; | 890 | char flag1; |
885 | void *addr1; | 891 | void *addr1; |
886 | 892 | ||
887 | struct env_image_single *single; | 893 | struct env_image_single *single; |
888 | struct env_image_redundant *redundant; | 894 | struct env_image_redundant *redundant; |
889 | 895 | ||
890 | if (parse_config ()) /* should fill envdevices */ | 896 | if (parse_config ()) /* should fill envdevices */ |
891 | return -1; | 897 | return -1; |
892 | 898 | ||
893 | addr0 = calloc (1, CONFIG_ENV_SIZE); | 899 | addr0 = calloc (1, CONFIG_ENV_SIZE); |
894 | if (addr0 == NULL) { | 900 | if (addr0 == NULL) { |
895 | fprintf (stderr, | 901 | fprintf (stderr, |
896 | "Not enough memory for environment (%ld bytes)\n", | 902 | "Not enough memory for environment (%ld bytes)\n", |
897 | CONFIG_ENV_SIZE); | 903 | CONFIG_ENV_SIZE); |
898 | return -1; | 904 | return -1; |
899 | } | 905 | } |
900 | 906 | ||
901 | /* read environment from FLASH to local buffer */ | 907 | /* read environment from FLASH to local buffer */ |
902 | environment.image = addr0; | 908 | environment.image = addr0; |
903 | 909 | ||
904 | if (HaveRedundEnv) { | 910 | if (HaveRedundEnv) { |
905 | redundant = addr0; | 911 | redundant = addr0; |
906 | environment.crc = &redundant->crc; | 912 | environment.crc = &redundant->crc; |
907 | environment.flags = &redundant->flags; | 913 | environment.flags = &redundant->flags; |
908 | environment.data = redundant->data; | 914 | environment.data = redundant->data; |
909 | } else { | 915 | } else { |
910 | single = addr0; | 916 | single = addr0; |
911 | environment.crc = &single->crc; | 917 | environment.crc = &single->crc; |
912 | environment.flags = NULL; | 918 | environment.flags = NULL; |
913 | environment.data = single->data; | 919 | environment.data = single->data; |
914 | } | 920 | } |
915 | 921 | ||
916 | dev_current = 0; | 922 | dev_current = 0; |
917 | if (flash_io (O_RDONLY)) | 923 | if (flash_io (O_RDONLY)) |
918 | return -1; | 924 | return -1; |
919 | 925 | ||
920 | crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE); | 926 | crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE); |
921 | crc0_ok = (crc0 == *environment.crc); | 927 | crc0_ok = (crc0 == *environment.crc); |
922 | if (!HaveRedundEnv) { | 928 | if (!HaveRedundEnv) { |
923 | if (!crc0_ok) { | 929 | if (!crc0_ok) { |
924 | fprintf (stderr, | 930 | fprintf (stderr, |
925 | "Warning: Bad CRC, using default environment\n"); | 931 | "Warning: Bad CRC, using default environment\n"); |
926 | memcpy(environment.data, default_environment, sizeof default_environment); | 932 | memcpy(environment.data, default_environment, sizeof default_environment); |
927 | } | 933 | } |
928 | } else { | 934 | } else { |
929 | flag0 = *environment.flags; | 935 | flag0 = *environment.flags; |
930 | 936 | ||
931 | dev_current = 1; | 937 | dev_current = 1; |
932 | addr1 = calloc (1, CONFIG_ENV_SIZE); | 938 | addr1 = calloc (1, CONFIG_ENV_SIZE); |
933 | if (addr1 == NULL) { | 939 | if (addr1 == NULL) { |
934 | fprintf (stderr, | 940 | fprintf (stderr, |
935 | "Not enough memory for environment (%ld bytes)\n", | 941 | "Not enough memory for environment (%ld bytes)\n", |
936 | CONFIG_ENV_SIZE); | 942 | CONFIG_ENV_SIZE); |
937 | return -1; | 943 | return -1; |
938 | } | 944 | } |
939 | redundant = addr1; | 945 | redundant = addr1; |
940 | 946 | ||
941 | /* | 947 | /* |
942 | * have to set environment.image for flash_read(), careful - | 948 | * have to set environment.image for flash_read(), careful - |
943 | * other pointers in environment still point inside addr0 | 949 | * other pointers in environment still point inside addr0 |
944 | */ | 950 | */ |
945 | environment.image = addr1; | 951 | environment.image = addr1; |
946 | if (flash_io (O_RDONLY)) | 952 | if (flash_io (O_RDONLY)) |
947 | return -1; | 953 | return -1; |
948 | 954 | ||
949 | /* Check flag scheme compatibility */ | 955 | /* Check flag scheme compatibility */ |
950 | if (DEVTYPE(dev_current) == MTD_NORFLASH && | 956 | if (DEVTYPE(dev_current) == MTD_NORFLASH && |
951 | DEVTYPE(!dev_current) == MTD_NORFLASH) { | 957 | DEVTYPE(!dev_current) == MTD_NORFLASH) { |
952 | environment.flag_scheme = FLAG_BOOLEAN; | 958 | environment.flag_scheme = FLAG_BOOLEAN; |
953 | } else if (DEVTYPE(dev_current) == MTD_NANDFLASH && | 959 | } else if (DEVTYPE(dev_current) == MTD_NANDFLASH && |
954 | DEVTYPE(!dev_current) == MTD_NANDFLASH) { | 960 | DEVTYPE(!dev_current) == MTD_NANDFLASH) { |
955 | environment.flag_scheme = FLAG_INCREMENTAL; | 961 | environment.flag_scheme = FLAG_INCREMENTAL; |
956 | } else { | 962 | } else { |
957 | fprintf (stderr, "Incompatible flash types!\n"); | 963 | fprintf (stderr, "Incompatible flash types!\n"); |
958 | return -1; | 964 | return -1; |
959 | } | 965 | } |
960 | 966 | ||
961 | crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE); | 967 | crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE); |
962 | crc1_ok = (crc1 == redundant->crc); | 968 | crc1_ok = (crc1 == redundant->crc); |
963 | flag1 = redundant->flags; | 969 | flag1 = redundant->flags; |
964 | 970 | ||
965 | if (crc0_ok && !crc1_ok) { | 971 | if (crc0_ok && !crc1_ok) { |
966 | dev_current = 0; | 972 | dev_current = 0; |
967 | } else if (!crc0_ok && crc1_ok) { | 973 | } else if (!crc0_ok && crc1_ok) { |
968 | dev_current = 1; | 974 | dev_current = 1; |
969 | } else if (!crc0_ok && !crc1_ok) { | 975 | } else if (!crc0_ok && !crc1_ok) { |
970 | fprintf (stderr, | 976 | fprintf (stderr, |
971 | "Warning: Bad CRC, using default environment\n"); | 977 | "Warning: Bad CRC, using default environment\n"); |
972 | memcpy (environment.data, default_environment, | 978 | memcpy (environment.data, default_environment, |
973 | sizeof default_environment); | 979 | sizeof default_environment); |
974 | dev_current = 0; | 980 | dev_current = 0; |
975 | } else { | 981 | } else { |
976 | switch (environment.flag_scheme) { | 982 | switch (environment.flag_scheme) { |
977 | case FLAG_BOOLEAN: | 983 | case FLAG_BOOLEAN: |
978 | if (flag0 == active_flag && | 984 | if (flag0 == active_flag && |
979 | flag1 == obsolete_flag) { | 985 | flag1 == obsolete_flag) { |
980 | dev_current = 0; | 986 | dev_current = 0; |
981 | } else if (flag0 == obsolete_flag && | 987 | } else if (flag0 == obsolete_flag && |
982 | flag1 == active_flag) { | 988 | flag1 == active_flag) { |
983 | dev_current = 1; | 989 | dev_current = 1; |
984 | } else if (flag0 == flag1) { | 990 | } else if (flag0 == flag1) { |
985 | dev_current = 0; | 991 | dev_current = 0; |
986 | } else if (flag0 == 0xFF) { | 992 | } else if (flag0 == 0xFF) { |
987 | dev_current = 0; | 993 | dev_current = 0; |
988 | } else if (flag1 == 0xFF) { | 994 | } else if (flag1 == 0xFF) { |
989 | dev_current = 1; | 995 | dev_current = 1; |
990 | } else { | 996 | } else { |
991 | dev_current = 0; | 997 | dev_current = 0; |
992 | } | 998 | } |
993 | break; | 999 | break; |
994 | case FLAG_INCREMENTAL: | 1000 | case FLAG_INCREMENTAL: |
995 | if ((flag0 == 255 && flag1 == 0) || | 1001 | if ((flag0 == 255 && flag1 == 0) || |
996 | flag1 > flag0) | 1002 | flag1 > flag0) |
997 | dev_current = 1; | 1003 | dev_current = 1; |
998 | else if ((flag1 == 255 && flag0 == 0) || | 1004 | else if ((flag1 == 255 && flag0 == 0) || |
999 | flag0 > flag1) | 1005 | flag0 > flag1) |
1000 | dev_current = 0; | 1006 | dev_current = 0; |
1001 | else /* flags are equal - almost impossible */ | 1007 | else /* flags are equal - almost impossible */ |
1002 | dev_current = 0; | 1008 | dev_current = 0; |
1003 | break; | 1009 | break; |
1004 | default: | 1010 | default: |
1005 | fprintf (stderr, "Unknown flag scheme %u \n", | 1011 | fprintf (stderr, "Unknown flag scheme %u \n", |
1006 | environment.flag_scheme); | 1012 | environment.flag_scheme); |
1007 | return -1; | 1013 | return -1; |
1008 | } | 1014 | } |
1009 | } | 1015 | } |
1010 | 1016 | ||
1011 | /* | 1017 | /* |
1012 | * If we are reading, we don't need the flag and the CRC any | 1018 | * If we are reading, we don't need the flag and the CRC any |
1013 | * more, if we are writing, we will re-calculate CRC and update | 1019 | * more, if we are writing, we will re-calculate CRC and update |
1014 | * flags before writing out | 1020 | * flags before writing out |
1015 | */ | 1021 | */ |
1016 | if (dev_current) { | 1022 | if (dev_current) { |
1017 | environment.image = addr1; | 1023 | environment.image = addr1; |
1018 | environment.crc = &redundant->crc; | 1024 | environment.crc = &redundant->crc; |
1019 | environment.flags = &redundant->flags; | 1025 | environment.flags = &redundant->flags; |
1020 | environment.data = redundant->data; | 1026 | environment.data = redundant->data; |
1021 | free (addr0); | 1027 | free (addr0); |
1022 | } else { | 1028 | } else { |
1023 | environment.image = addr0; | 1029 | environment.image = addr0; |
1024 | /* Other pointers are already set */ | 1030 | /* Other pointers are already set */ |
1025 | free (addr1); | 1031 | free (addr1); |
1026 | } | 1032 | } |
1027 | } | 1033 | } |
1028 | return 0; | 1034 | return 0; |
1029 | } | 1035 | } |
1030 | 1036 | ||
1031 | 1037 | ||
1032 | static int parse_config () | 1038 | static int parse_config () |
1033 | { | 1039 | { |
1034 | struct stat st; | 1040 | struct stat st; |
1035 | 1041 | ||
1036 | #if defined(CONFIG_FILE) | 1042 | #if defined(CONFIG_FILE) |
1037 | /* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */ | 1043 | /* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */ |
1038 | if (get_config (CONFIG_FILE)) { | 1044 | if (get_config (CONFIG_FILE)) { |
1039 | fprintf (stderr, | 1045 | fprintf (stderr, |
1040 | "Cannot parse config file: %s\n", strerror (errno)); | 1046 | "Cannot parse config file: %s\n", strerror (errno)); |
1041 | return -1; | 1047 | return -1; |
1042 | } | 1048 | } |
1043 | #else | 1049 | #else |
1044 | strcpy (DEVNAME (0), DEVICE1_NAME); | 1050 | strcpy (DEVNAME (0), DEVICE1_NAME); |
1045 | DEVOFFSET (0) = DEVICE1_OFFSET; | 1051 | DEVOFFSET (0) = DEVICE1_OFFSET; |
1046 | ENVSIZE (0) = ENV1_SIZE; | 1052 | ENVSIZE (0) = ENV1_SIZE; |
1047 | DEVESIZE (0) = DEVICE1_ESIZE; | 1053 | DEVESIZE (0) = DEVICE1_ESIZE; |
1048 | ENVSECTORS (0) = DEVICE1_ENVSECTORS; | 1054 | ENVSECTORS (0) = DEVICE1_ENVSECTORS; |
1049 | #ifdef HAVE_REDUND | 1055 | #ifdef HAVE_REDUND |
1050 | strcpy (DEVNAME (1), DEVICE2_NAME); | 1056 | strcpy (DEVNAME (1), DEVICE2_NAME); |
1051 | DEVOFFSET (1) = DEVICE2_OFFSET; | 1057 | DEVOFFSET (1) = DEVICE2_OFFSET; |
1052 | ENVSIZE (1) = ENV2_SIZE; | 1058 | ENVSIZE (1) = ENV2_SIZE; |
1053 | DEVESIZE (1) = DEVICE2_ESIZE; | 1059 | DEVESIZE (1) = DEVICE2_ESIZE; |
1054 | ENVSECTORS (1) = DEVICE2_ENVSECTORS; | 1060 | ENVSECTORS (1) = DEVICE2_ENVSECTORS; |
1055 | HaveRedundEnv = 1; | 1061 | HaveRedundEnv = 1; |
1056 | #endif | 1062 | #endif |
1057 | #endif | 1063 | #endif |
1058 | if (stat (DEVNAME (0), &st)) { | 1064 | if (stat (DEVNAME (0), &st)) { |
1059 | fprintf (stderr, | 1065 | fprintf (stderr, |
1060 | "Cannot access MTD device %s: %s\n", | 1066 | "Cannot access MTD device %s: %s\n", |
1061 | DEVNAME (0), strerror (errno)); | 1067 | DEVNAME (0), strerror (errno)); |
1062 | return -1; | 1068 | return -1; |
1063 | } | 1069 | } |
1064 | 1070 | ||
1065 | if (HaveRedundEnv && stat (DEVNAME (1), &st)) { | 1071 | if (HaveRedundEnv && stat (DEVNAME (1), &st)) { |
1066 | fprintf (stderr, | 1072 | fprintf (stderr, |
1067 | "Cannot access MTD device %s: %s\n", | 1073 | "Cannot access MTD device %s: %s\n", |
1068 | DEVNAME (1), strerror (errno)); | 1074 | DEVNAME (1), strerror (errno)); |
1069 | return -1; | 1075 | return -1; |
1070 | } | 1076 | } |
1071 | return 0; | 1077 | return 0; |
1072 | } | 1078 | } |
1073 | 1079 | ||
1074 | #if defined(CONFIG_FILE) | 1080 | #if defined(CONFIG_FILE) |
1075 | static int get_config (char *fname) | 1081 | static int get_config (char *fname) |
1076 | { | 1082 | { |
1077 | FILE *fp; | 1083 | FILE *fp; |
1078 | int i = 0; | 1084 | int i = 0; |
1079 | int rc; | 1085 | int rc; |
1080 | char dump[128]; | 1086 | char dump[128]; |
1081 | 1087 | ||
1082 | fp = fopen (fname, "r"); | 1088 | fp = fopen (fname, "r"); |
1083 | if (fp == NULL) | 1089 | if (fp == NULL) |
1084 | return -1; | 1090 | return -1; |
1085 | 1091 | ||
1086 | while (i < 2 && fgets (dump, sizeof (dump), fp)) { | 1092 | while (i < 2 && fgets (dump, sizeof (dump), fp)) { |
1087 | /* Skip incomplete conversions and comment strings */ | 1093 | /* Skip incomplete conversions and comment strings */ |
1088 | if (dump[0] == '#') | 1094 | if (dump[0] == '#') |
1089 | continue; | 1095 | continue; |
1090 | 1096 | ||
1091 | rc = sscanf (dump, "%s %lx %lx %lx %lx", | 1097 | rc = sscanf (dump, "%s %lx %lx %lx %lx", |
1092 | DEVNAME (i), | 1098 | DEVNAME (i), |
1093 | &DEVOFFSET (i), | 1099 | &DEVOFFSET (i), |
1094 | &ENVSIZE (i), | 1100 | &ENVSIZE (i), |
1095 | &DEVESIZE (i), | 1101 | &DEVESIZE (i), |
1096 | &ENVSECTORS (i)); | 1102 | &ENVSECTORS (i)); |
1097 | 1103 | ||
1098 | if (rc < 4) | 1104 | if (rc < 4) |
1099 | continue; | 1105 | continue; |
1100 | 1106 | ||
1101 | if (rc < 5) | 1107 | if (rc < 5) |
1102 | /* Default - 1 sector */ | 1108 | /* Default - 1 sector */ |
1103 | ENVSECTORS (i) = 1; | 1109 | ENVSECTORS (i) = 1; |
1104 | 1110 | ||
1105 | i++; | 1111 | i++; |
1106 | } | 1112 | } |
1107 | fclose (fp); | 1113 | fclose (fp); |
1108 | 1114 | ||
1109 | HaveRedundEnv = i - 1; | 1115 | HaveRedundEnv = i - 1; |
1110 | if (!i) { /* No valid entries found */ | 1116 | if (!i) { /* No valid entries found */ |
1111 | errno = EINVAL; | 1117 | errno = EINVAL; |
1112 | return -1; | 1118 | return -1; |
1113 | } else | 1119 | } else |
1114 | return 0; | 1120 | return 0; |
1115 | } | 1121 | } |
1116 | #endif | 1122 | #endif |
1117 | 1123 |