blob: 273098ceb605a6b2059dadc44d45f37c392b2c68 [file] [log] [blame]
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +02001/*
Wolfgang Denk460a9ff2010-06-20 23:33:59 +02002 * (C) Copyright 2000-2010
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +02003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6 * Andreas Heppel <aheppel@sysgo.de>
7 *
8 * (C) Copyright 2008 Atmel Corporation
9 *
Jagannadha Sutradharudu Tekib1df9222013-07-29 22:12:52 +053010 * SPDX-License-Identifier: GPL-2.0+
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020011 */
12#include <common.h>
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020013#include <environment.h>
Mike Frysinger9af10d52008-12-11 06:23:37 -050014#include <malloc.h>
Simon Glassdef92152014-10-13 23:41:55 -060015#include <spi.h>
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020016#include <spi_flash.h>
Wolfgang Denk460a9ff2010-06-20 23:33:59 +020017#include <search.h>
18#include <errno.h>
Gong Qianyu6d85a602016-01-26 15:06:42 +080019#include <dm/device-internal.h>
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020020
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +020021#ifndef CONFIG_ENV_SPI_BUS
22# define CONFIG_ENV_SPI_BUS 0
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020023#endif
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +020024#ifndef CONFIG_ENV_SPI_CS
Igor Grinbergc3c1bed2011-11-07 01:14:08 +000025# define CONFIG_ENV_SPI_CS 0
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020026#endif
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +020027#ifndef CONFIG_ENV_SPI_MAX_HZ
28# define CONFIG_ENV_SPI_MAX_HZ 1000000
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020029#endif
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +020030#ifndef CONFIG_ENV_SPI_MODE
31# define CONFIG_ENV_SPI_MODE SPI_MODE_3
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020032#endif
33
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020034#ifdef CONFIG_ENV_OFFSET_REDUND
Igor Grinbergc3c1bed2011-11-07 01:14:08 +000035static ulong env_offset = CONFIG_ENV_OFFSET;
36static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020037
Igor Grinbergc3c1bed2011-11-07 01:14:08 +000038#define ACTIVE_FLAG 1
39#define OBSOLETE_FLAG 0
Stefano Babic5f6c2862010-10-27 11:06:20 +020040#endif /* CONFIG_ENV_OFFSET_REDUND */
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020041
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020042DECLARE_GLOBAL_DATA_PTR;
43
Igor Grinbergc3c1bed2011-11-07 01:14:08 +000044char *env_name_spec = "SPI Flash";
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +020045
46static struct spi_flash *env_flash;
47
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020048#if defined(CONFIG_ENV_OFFSET_REDUND)
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020049int saveenv(void)
50{
Tom Rinia840b8e2013-04-05 14:55:21 -040051 env_t env_new;
Marek Vasutd73c1292014-03-05 19:59:50 +010052 char *saved_buffer = NULL, flag = OBSOLETE_FLAG;
Igor Grinbergc3c1bed2011-11-07 01:14:08 +000053 u32 saved_size, saved_offset, sector = 1;
Wolfgang Denk460a9ff2010-06-20 23:33:59 +020054 int ret;
Gong Qianyu6d85a602016-01-26 15:06:42 +080055#ifdef CONFIG_DM_SPI_FLASH
56 struct udevice *new;
57
58 ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
59 CONFIG_ENV_SPI_MAX_HZ,
60 CONFIG_ENV_SPI_MODE, &new);
61 if (ret) {
62 set_default_env("!spi_flash_probe_bus_cs() failed");
63 return 1;
64 }
65
66 env_flash = dev_get_uclass_priv(new);
67#else
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020068
69 if (!env_flash) {
Stefano Babic5f6c2862010-10-27 11:06:20 +020070 env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
71 CONFIG_ENV_SPI_CS,
72 CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
73 if (!env_flash) {
74 set_default_env("!spi_flash_probe() failed");
75 return 1;
76 }
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020077 }
Gong Qianyu6d85a602016-01-26 15:06:42 +080078#endif
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020079
Marek Vasutd73c1292014-03-05 19:59:50 +010080 ret = env_export(&env_new);
81 if (ret)
82 return ret;
Tom Rinia840b8e2013-04-05 14:55:21 -040083 env_new.flags = ACTIVE_FLAG;
Wolfgang Denk460a9ff2010-06-20 23:33:59 +020084
Stefano Babic5f6c2862010-10-27 11:06:20 +020085 if (gd->env_valid == 1) {
86 env_new_offset = CONFIG_ENV_OFFSET_REDUND;
87 env_offset = CONFIG_ENV_OFFSET;
88 } else {
89 env_new_offset = CONFIG_ENV_OFFSET;
90 env_offset = CONFIG_ENV_OFFSET_REDUND;
91 }
92
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020093 /* Is the sector larger than the env (i.e. embedded) */
94 if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
95 saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE;
96 saved_offset = env_new_offset + CONFIG_ENV_SIZE;
Ravi Babu20d93fc2015-08-17 13:29:49 +053097 saved_buffer = memalign(ARCH_DMA_MINALIGN, saved_size);
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +020098 if (!saved_buffer) {
99 ret = 1;
100 goto done;
101 }
102 ret = spi_flash_read(env_flash, saved_offset,
103 saved_size, saved_buffer);
104 if (ret)
105 goto done;
106 }
107
108 if (CONFIG_ENV_SIZE > CONFIG_ENV_SECT_SIZE) {
109 sector = CONFIG_ENV_SIZE / CONFIG_ENV_SECT_SIZE;
110 if (CONFIG_ENV_SIZE % CONFIG_ENV_SECT_SIZE)
111 sector++;
112 }
113
114 puts("Erasing SPI flash...");
115 ret = spi_flash_erase(env_flash, env_new_offset,
116 sector * CONFIG_ENV_SECT_SIZE);
117 if (ret)
118 goto done;
119
120 puts("Writing to SPI flash...");
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200121
Stefano Babic5f6c2862010-10-27 11:06:20 +0200122 ret = spi_flash_write(env_flash, env_new_offset,
Tom Rinia840b8e2013-04-05 14:55:21 -0400123 CONFIG_ENV_SIZE, &env_new);
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200124 if (ret)
125 goto done;
126
127 if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
128 ret = spi_flash_write(env_flash, saved_offset,
129 saved_size, saved_buffer);
130 if (ret)
131 goto done;
132 }
133
Igor Grinbergc3c1bed2011-11-07 01:14:08 +0000134 ret = spi_flash_write(env_flash, env_offset + offsetof(env_t, flags),
Tom Rinia840b8e2013-04-05 14:55:21 -0400135 sizeof(env_new.flags), &flag);
Stefano Babic5f6c2862010-10-27 11:06:20 +0200136 if (ret)
137 goto done;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200138
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200139 puts("done\n");
140
Igor Grinbergc3c1bed2011-11-07 01:14:08 +0000141 gd->env_valid = gd->env_valid == 2 ? 1 : 2;
Stefano Babic5f6c2862010-10-27 11:06:20 +0200142
thomas.langer@lantiq.com97dfdcf2011-03-29 02:35:14 +0000143 printf("Valid environment: %d\n", (int)gd->env_valid);
Stefano Babic5f6c2862010-10-27 11:06:20 +0200144
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200145 done:
146 if (saved_buffer)
147 free(saved_buffer);
Igor Grinbergc3c1bed2011-11-07 01:14:08 +0000148
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200149 return ret;
150}
151
152void env_relocate_spec(void)
153{
154 int ret;
155 int crc1_ok = 0, crc2_ok = 0;
156 env_t *tmp_env1 = NULL;
157 env_t *tmp_env2 = NULL;
Stefano Babic5f6c2862010-10-27 11:06:20 +0200158 env_t *ep = NULL;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200159
Ravi Babu20d93fc2015-08-17 13:29:49 +0530160 tmp_env1 = (env_t *)memalign(ARCH_DMA_MINALIGN,
161 CONFIG_ENV_SIZE);
162 tmp_env2 = (env_t *)memalign(ARCH_DMA_MINALIGN,
163 CONFIG_ENV_SIZE);
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200164 if (!tmp_env1 || !tmp_env2) {
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200165 set_default_env("!malloc() failed");
thomas.langer@lantiq.com97dfdcf2011-03-29 02:35:14 +0000166 goto out;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200167 }
168
169 env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
170 CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200171 if (!env_flash) {
172 set_default_env("!spi_flash_probe() failed");
thomas.langer@lantiq.com97dfdcf2011-03-29 02:35:14 +0000173 goto out;
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200174 }
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200175
176 ret = spi_flash_read(env_flash, CONFIG_ENV_OFFSET,
177 CONFIG_ENV_SIZE, tmp_env1);
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200178 if (ret) {
179 set_default_env("!spi_flash_read() failed");
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200180 goto err_read;
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200181 }
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200182
183 if (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc)
184 crc1_ok = 1;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200185
186 ret = spi_flash_read(env_flash, CONFIG_ENV_OFFSET_REDUND,
187 CONFIG_ENV_SIZE, tmp_env2);
188 if (!ret) {
189 if (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc)
190 crc2_ok = 1;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200191 }
192
Stefano Babic5f6c2862010-10-27 11:06:20 +0200193 if (!crc1_ok && !crc2_ok) {
Stefano Babic5f6c2862010-10-27 11:06:20 +0200194 set_default_env("!bad CRC");
thomas.langer@lantiq.com97dfdcf2011-03-29 02:35:14 +0000195 goto err_read;
Stefano Babic5f6c2862010-10-27 11:06:20 +0200196 } else if (crc1_ok && !crc2_ok) {
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200197 gd->env_valid = 1;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200198 } else if (!crc1_ok && crc2_ok) {
thomas.langer@lantiq.com97dfdcf2011-03-29 02:35:14 +0000199 gd->env_valid = 2;
200 } else if (tmp_env1->flags == ACTIVE_FLAG &&
201 tmp_env2->flags == OBSOLETE_FLAG) {
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200202 gd->env_valid = 1;
thomas.langer@lantiq.com97dfdcf2011-03-29 02:35:14 +0000203 } else if (tmp_env1->flags == OBSOLETE_FLAG &&
204 tmp_env2->flags == ACTIVE_FLAG) {
Stefano Babic5f6c2862010-10-27 11:06:20 +0200205 gd->env_valid = 2;
thomas.langer@lantiq.com97dfdcf2011-03-29 02:35:14 +0000206 } else if (tmp_env1->flags == tmp_env2->flags) {
Mario Schuknecht12f1a542015-03-24 08:59:00 +0100207 gd->env_valid = 1;
thomas.langer@lantiq.com97dfdcf2011-03-29 02:35:14 +0000208 } else if (tmp_env1->flags == 0xFF) {
Mario Schuknecht12f1a542015-03-24 08:59:00 +0100209 gd->env_valid = 1;
210 } else if (tmp_env2->flags == 0xFF) {
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200211 gd->env_valid = 2;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200212 } else {
213 /*
214 * this differs from code in env_flash.c, but I think a sane
215 * default path is desirable.
216 */
Mario Schuknecht12f1a542015-03-24 08:59:00 +0100217 gd->env_valid = 1;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200218 }
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200219
Stefano Babic5f6c2862010-10-27 11:06:20 +0200220 if (gd->env_valid == 1)
221 ep = tmp_env1;
222 else
223 ep = tmp_env2;
224
225 ret = env_import((char *)ep, 0);
226 if (!ret) {
227 error("Cannot import environment: errno = %d\n", errno);
Peng Fan3e21c722016-03-28 17:26:27 +0800228 set_default_env("!env_import failed");
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200229 }
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200230
231err_read:
232 spi_flash_free(env_flash);
233 env_flash = NULL;
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200234out:
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200235 free(tmp_env1);
236 free(tmp_env2);
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200237}
238#else
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200239int saveenv(void)
240{
Igor Grinbergc3c1bed2011-11-07 01:14:08 +0000241 u32 saved_size, saved_offset, sector = 1;
Marek Vasutd73c1292014-03-05 19:59:50 +0100242 char *saved_buffer = NULL;
Igor Grinbergc3c1bed2011-11-07 01:14:08 +0000243 int ret = 1;
Tom Rinia840b8e2013-04-05 14:55:21 -0400244 env_t env_new;
Gong Qianyu6d85a602016-01-26 15:06:42 +0800245#ifdef CONFIG_DM_SPI_FLASH
246 struct udevice *new;
247
248 ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
249 CONFIG_ENV_SPI_MAX_HZ,
250 CONFIG_ENV_SPI_MODE, &new);
251 if (ret) {
252 set_default_env("!spi_flash_probe_bus_cs() failed");
253 return 1;
254 }
255
256 env_flash = dev_get_uclass_priv(new);
257#else
TsiChung Liew08792d72008-08-06 19:37:17 -0500258
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200259 if (!env_flash) {
Stefano Babic5f6c2862010-10-27 11:06:20 +0200260 env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
261 CONFIG_ENV_SPI_CS,
262 CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
263 if (!env_flash) {
264 set_default_env("!spi_flash_probe() failed");
265 return 1;
266 }
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200267 }
Gong Qianyu6d85a602016-01-26 15:06:42 +0800268#endif
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200269
Mike Frysinger9af10d52008-12-11 06:23:37 -0500270 /* Is the sector larger than the env (i.e. embedded) */
271 if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
272 saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE;
273 saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE;
274 saved_buffer = malloc(saved_size);
Igor Grinbergc3c1bed2011-11-07 01:14:08 +0000275 if (!saved_buffer)
Mike Frysinger9af10d52008-12-11 06:23:37 -0500276 goto done;
Igor Grinbergc3c1bed2011-11-07 01:14:08 +0000277
Stefano Babic5f6c2862010-10-27 11:06:20 +0200278 ret = spi_flash_read(env_flash, saved_offset,
279 saved_size, saved_buffer);
Mike Frysinger9af10d52008-12-11 06:23:37 -0500280 if (ret)
281 goto done;
282 }
283
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +0200284 if (CONFIG_ENV_SIZE > CONFIG_ENV_SECT_SIZE) {
285 sector = CONFIG_ENV_SIZE / CONFIG_ENV_SECT_SIZE;
286 if (CONFIG_ENV_SIZE % CONFIG_ENV_SECT_SIZE)
TsiChung Liew08792d72008-08-06 19:37:17 -0500287 sector++;
288 }
289
Marek Vasutd73c1292014-03-05 19:59:50 +0100290 ret = env_export(&env_new);
291 if (ret)
Stefano Babic5f6c2862010-10-27 11:06:20 +0200292 goto done;
Stefano Babic5f6c2862010-10-27 11:06:20 +0200293
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200294 puts("Erasing SPI flash...");
Stefano Babic5f6c2862010-10-27 11:06:20 +0200295 ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET,
296 sector * CONFIG_ENV_SECT_SIZE);
Mike Frysinger9af10d52008-12-11 06:23:37 -0500297 if (ret)
298 goto done;
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200299
300 puts("Writing to SPI flash...");
Stefano Babic5f6c2862010-10-27 11:06:20 +0200301 ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET,
Tom Rinia840b8e2013-04-05 14:55:21 -0400302 CONFIG_ENV_SIZE, &env_new);
Mike Frysinger9af10d52008-12-11 06:23:37 -0500303 if (ret)
304 goto done;
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200305
Mike Frysinger9af10d52008-12-11 06:23:37 -0500306 if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
Stefano Babic5f6c2862010-10-27 11:06:20 +0200307 ret = spi_flash_write(env_flash, saved_offset,
308 saved_size, saved_buffer);
Mike Frysinger9af10d52008-12-11 06:23:37 -0500309 if (ret)
310 goto done;
311 }
312
313 ret = 0;
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200314 puts("done\n");
Mike Frysinger9af10d52008-12-11 06:23:37 -0500315
316 done:
317 if (saved_buffer)
318 free(saved_buffer);
Igor Grinbergc3c1bed2011-11-07 01:14:08 +0000319
Mike Frysinger9af10d52008-12-11 06:23:37 -0500320 return ret;
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200321}
322
323void env_relocate_spec(void)
324{
325 int ret;
Ying Zhang354846f2014-01-24 15:50:07 +0800326 char *buf = NULL;
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200327
Ravi Babu20d93fc2015-08-17 13:29:49 +0530328 buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE);
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +0200329 env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
330 CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200331 if (!env_flash) {
332 set_default_env("!spi_flash_probe() failed");
Ying Zhang354846f2014-01-24 15:50:07 +0800333 if (buf)
334 free(buf);
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200335 return;
336 }
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200337
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200338 ret = spi_flash_read(env_flash,
339 CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, buf);
340 if (ret) {
341 set_default_env("!spi_flash_read() failed");
342 goto out;
343 }
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200344
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200345 ret = env_import(buf, 1);
Wolfgang Denk460a9ff2010-06-20 23:33:59 +0200346 if (ret)
347 gd->env_valid = 1;
348out:
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200349 spi_flash_free(env_flash);
Ying Zhang354846f2014-01-24 15:50:07 +0800350 if (buf)
351 free(buf);
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200352 env_flash = NULL;
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200353}
Wolfgang Wegner0cae3d42010-04-23 17:22:55 +0200354#endif
Haavard Skinnemoeneb8951c2008-05-16 11:10:35 +0200355
356int env_init(void)
357{
358 /* SPI flash isn't usable before relocation */
359 gd->env_addr = (ulong)&default_environment[0];
360 gd->env_valid = 1;
361
362 return 0;
363}