blob: c53200f5c6fef36d0f7e8c248161b4dbffda0f8e [file] [log] [blame]
Haavard Skinnemoen8c664972008-05-16 11:10:35 +02001/*
Wolfgang Denkea882ba2010-06-20 23:33:59 +02002 * (C) Copyright 2000-2010
Haavard Skinnemoen8c664972008-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 Teki402ba1e2013-07-29 22:12:52 +053010 * SPDX-License-Identifier: GPL-2.0+
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020011 */
12#include <common.h>
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020013#include <environment.h>
Mike Frysinger5b3375a2008-12-11 06:23:37 -050014#include <malloc.h>
Simon Glass843c9e82014-10-13 23:41:55 -060015#include <spi.h>
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020016#include <spi_flash.h>
Wolfgang Denkea882ba2010-06-20 23:33:59 +020017#include <search.h>
18#include <errno.h>
Gong Qianyu19c31282016-01-26 15:06:42 +080019#include <dm/device-internal.h>
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020020
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020021#ifndef CONFIG_ENV_SPI_BUS
22# define CONFIG_ENV_SPI_BUS 0
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020023#endif
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020024#ifndef CONFIG_ENV_SPI_CS
Igor Grinbergeb58a7f2011-11-07 01:14:08 +000025# define CONFIG_ENV_SPI_CS 0
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020026#endif
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020027#ifndef CONFIG_ENV_SPI_MAX_HZ
28# define CONFIG_ENV_SPI_MAX_HZ 1000000
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020029#endif
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +020030#ifndef CONFIG_ENV_SPI_MODE
31# define CONFIG_ENV_SPI_MODE SPI_MODE_3
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020032#endif
33
Wolfgang Wegner7319bca2010-04-23 17:22:55 +020034#ifdef CONFIG_ENV_OFFSET_REDUND
Igor Grinbergeb58a7f2011-11-07 01:14:08 +000035static ulong env_offset = CONFIG_ENV_OFFSET;
36static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND;
Wolfgang Wegner7319bca2010-04-23 17:22:55 +020037
Igor Grinbergeb58a7f2011-11-07 01:14:08 +000038#define ACTIVE_FLAG 1
39#define OBSOLETE_FLAG 0
Stefano Babica3110f02010-10-27 11:06:20 +020040#endif /* CONFIG_ENV_OFFSET_REDUND */
Wolfgang Wegner7319bca2010-04-23 17:22:55 +020041
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020042DECLARE_GLOBAL_DATA_PTR;
43
Igor Grinbergeb58a7f2011-11-07 01:14:08 +000044char *env_name_spec = "SPI Flash";
Haavard Skinnemoen8c664972008-05-16 11:10:35 +020045
46static struct spi_flash *env_flash;
47
Wolfgang Wegner7319bca2010-04-23 17:22:55 +020048#if defined(CONFIG_ENV_OFFSET_REDUND)
Wolfgang Wegner7319bca2010-04-23 17:22:55 +020049int saveenv(void)
50{
Tom Rinicd0f4fa2013-04-05 14:55:21 -040051 env_t env_new;
Marek Vasut7ce15262014-03-05 19:59:50 +010052 char *saved_buffer = NULL, flag = OBSOLETE_FLAG;
Igor Grinbergeb58a7f2011-11-07 01:14:08 +000053 u32 saved_size, saved_offset, sector = 1;
Wolfgang Denkea882ba2010-06-20 23:33:59 +020054 int ret;
Gong Qianyu19c31282016-01-26 15:06:42 +080055#ifdef CONFIG_DM_SPI_FLASH
56 struct udevice *new;
57
Vignesh R96907c02016-07-06 10:04:28 +053058 /* speed and mode will be read from DT */
Gong Qianyu19c31282016-01-26 15:06:42 +080059 ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
Vignesh R96907c02016-07-06 10:04:28 +053060 0, 0, &new);
Gong Qianyu19c31282016-01-26 15:06:42 +080061 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 Wegner7319bca2010-04-23 17:22:55 +020068
69 if (!env_flash) {
Stefano Babica3110f02010-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 Wegner7319bca2010-04-23 17:22:55 +020077 }
Gong Qianyu19c31282016-01-26 15:06:42 +080078#endif
Wolfgang Wegner7319bca2010-04-23 17:22:55 +020079
Marek Vasut7ce15262014-03-05 19:59:50 +010080 ret = env_export(&env_new);
81 if (ret)
82 return ret;
Tom Rinicd0f4fa2013-04-05 14:55:21 -040083 env_new.flags = ACTIVE_FLAG;
Wolfgang Denkea882ba2010-06-20 23:33:59 +020084
Stefano Babica3110f02010-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 Wegner7319bca2010-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 Babu7dd01742015-08-17 13:29:49 +053097 saved_buffer = memalign(ARCH_DMA_MINALIGN, saved_size);
Wolfgang Wegner7319bca2010-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 Wegner7319bca2010-04-23 17:22:55 +0200121
Stefano Babica3110f02010-10-27 11:06:20 +0200122 ret = spi_flash_write(env_flash, env_new_offset,
Tom Rinicd0f4fa2013-04-05 14:55:21 -0400123 CONFIG_ENV_SIZE, &env_new);
Wolfgang Wegner7319bca2010-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 Grinbergeb58a7f2011-11-07 01:14:08 +0000134 ret = spi_flash_write(env_flash, env_offset + offsetof(env_t, flags),
Tom Rinicd0f4fa2013-04-05 14:55:21 -0400135 sizeof(env_new.flags), &flag);
Stefano Babica3110f02010-10-27 11:06:20 +0200136 if (ret)
137 goto done;
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200138
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200139 puts("done\n");
140
Igor Grinbergeb58a7f2011-11-07 01:14:08 +0000141 gd->env_valid = gd->env_valid == 2 ? 1 : 2;
Stefano Babica3110f02010-10-27 11:06:20 +0200142
thomas.langer@lantiq.com2dc55d92011-03-29 02:35:14 +0000143 printf("Valid environment: %d\n", (int)gd->env_valid);
Stefano Babica3110f02010-10-27 11:06:20 +0200144
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200145 done:
146 if (saved_buffer)
147 free(saved_buffer);
Igor Grinbergeb58a7f2011-11-07 01:14:08 +0000148
Wolfgang Wegner7319bca2010-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 Babica3110f02010-10-27 11:06:20 +0200158 env_t *ep = NULL;
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200159
Ravi Babu7dd01742015-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 Denkea882ba2010-06-20 23:33:59 +0200164 if (!tmp_env1 || !tmp_env2) {
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200165 set_default_env("!malloc() failed");
thomas.langer@lantiq.com2dc55d92011-03-29 02:35:14 +0000166 goto out;
Wolfgang Wegner7319bca2010-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 Denkea882ba2010-06-20 23:33:59 +0200171 if (!env_flash) {
172 set_default_env("!spi_flash_probe() failed");
thomas.langer@lantiq.com2dc55d92011-03-29 02:35:14 +0000173 goto out;
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200174 }
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200175
176 ret = spi_flash_read(env_flash, CONFIG_ENV_OFFSET,
177 CONFIG_ENV_SIZE, tmp_env1);
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200178 if (ret) {
179 set_default_env("!spi_flash_read() failed");
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200180 goto err_read;
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200181 }
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200182
183 if (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc)
184 crc1_ok = 1;
Wolfgang Wegner7319bca2010-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 Wegner7319bca2010-04-23 17:22:55 +0200191 }
192
Stefano Babica3110f02010-10-27 11:06:20 +0200193 if (!crc1_ok && !crc2_ok) {
Stefano Babica3110f02010-10-27 11:06:20 +0200194 set_default_env("!bad CRC");
thomas.langer@lantiq.com2dc55d92011-03-29 02:35:14 +0000195 goto err_read;
Stefano Babica3110f02010-10-27 11:06:20 +0200196 } else if (crc1_ok && !crc2_ok) {
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200197 gd->env_valid = 1;
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200198 } else if (!crc1_ok && crc2_ok) {
Stefano Babica3110f02010-10-27 11:06:20 +0200199 gd->env_valid = 2;
thomas.langer@lantiq.com2dc55d92011-03-29 02:35:14 +0000200 } else if (tmp_env1->flags == ACTIVE_FLAG &&
201 tmp_env2->flags == OBSOLETE_FLAG) {
202 gd->env_valid = 1;
203 } else if (tmp_env1->flags == OBSOLETE_FLAG &&
204 tmp_env2->flags == ACTIVE_FLAG) {
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200205 gd->env_valid = 2;
thomas.langer@lantiq.com2dc55d92011-03-29 02:35:14 +0000206 } else if (tmp_env1->flags == tmp_env2->flags) {
Mario Schuknecht5e8397d2015-03-24 08:59:00 +0100207 gd->env_valid = 1;
thomas.langer@lantiq.com2dc55d92011-03-29 02:35:14 +0000208 } else if (tmp_env1->flags == 0xFF) {
Mario Schuknecht5e8397d2015-03-24 08:59:00 +0100209 gd->env_valid = 1;
210 } else if (tmp_env2->flags == 0xFF) {
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200211 gd->env_valid = 2;
Wolfgang Wegner7319bca2010-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 Schuknecht5e8397d2015-03-24 08:59:00 +0100217 gd->env_valid = 1;
Stefano Babica3110f02010-10-27 11:06:20 +0200218 }
219
Stefano Babica3110f02010-10-27 11:06:20 +0200220 if (gd->env_valid == 1)
221 ep = tmp_env1;
222 else
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200223 ep = tmp_env2;
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200224
Stefano Babica3110f02010-10-27 11:06:20 +0200225 ret = env_import((char *)ep, 0);
226 if (!ret) {
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200227 error("Cannot import environment: errno = %d\n", errno);
Peng Fan9a5d9932016-03-28 17:26:27 +0800228 set_default_env("!env_import failed");
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200229 }
230
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200231err_read:
232 spi_flash_free(env_flash);
233 env_flash = NULL;
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200234out:
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200235 free(tmp_env1);
236 free(tmp_env2);
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200237}
238#else
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200239int saveenv(void)
240{
Igor Grinbergeb58a7f2011-11-07 01:14:08 +0000241 u32 saved_size, saved_offset, sector = 1;
Marek Vasut7ce15262014-03-05 19:59:50 +0100242 char *saved_buffer = NULL;
Igor Grinbergeb58a7f2011-11-07 01:14:08 +0000243 int ret = 1;
Tom Rinicd0f4fa2013-04-05 14:55:21 -0400244 env_t env_new;
Gong Qianyu19c31282016-01-26 15:06:42 +0800245#ifdef CONFIG_DM_SPI_FLASH
246 struct udevice *new;
247
Vignesh R96907c02016-07-06 10:04:28 +0530248 /* speed and mode will be read from DT */
Gong Qianyu19c31282016-01-26 15:06:42 +0800249 ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
Vignesh R96907c02016-07-06 10:04:28 +0530250 0, 0, &new);
Gong Qianyu19c31282016-01-26 15:06:42 +0800251 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 Liew07efc9e2008-08-06 19:37:17 -0500258
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200259 if (!env_flash) {
Stefano Babica3110f02010-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 Skinnemoen8c664972008-05-16 11:10:35 +0200267 }
Gong Qianyu19c31282016-01-26 15:06:42 +0800268#endif
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200269
Mike Frysinger5b3375a2008-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 Grinbergeb58a7f2011-11-07 01:14:08 +0000275 if (!saved_buffer)
Mike Frysinger5b3375a2008-12-11 06:23:37 -0500276 goto done;
Igor Grinbergeb58a7f2011-11-07 01:14:08 +0000277
Stefano Babica3110f02010-10-27 11:06:20 +0200278 ret = spi_flash_read(env_flash, saved_offset,
279 saved_size, saved_buffer);
Mike Frysinger5b3375a2008-12-11 06:23:37 -0500280 if (ret)
281 goto done;
282 }
283
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-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 Liew07efc9e2008-08-06 19:37:17 -0500287 sector++;
288 }
289
Marek Vasut7ce15262014-03-05 19:59:50 +0100290 ret = env_export(&env_new);
291 if (ret)
Stefano Babica3110f02010-10-27 11:06:20 +0200292 goto done;
Stefano Babica3110f02010-10-27 11:06:20 +0200293
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200294 puts("Erasing SPI flash...");
Stefano Babica3110f02010-10-27 11:06:20 +0200295 ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET,
296 sector * CONFIG_ENV_SECT_SIZE);
Mike Frysinger5b3375a2008-12-11 06:23:37 -0500297 if (ret)
298 goto done;
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200299
300 puts("Writing to SPI flash...");
Stefano Babica3110f02010-10-27 11:06:20 +0200301 ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET,
Tom Rinicd0f4fa2013-04-05 14:55:21 -0400302 CONFIG_ENV_SIZE, &env_new);
Mike Frysinger5b3375a2008-12-11 06:23:37 -0500303 if (ret)
304 goto done;
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200305
Mike Frysinger5b3375a2008-12-11 06:23:37 -0500306 if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
Stefano Babica3110f02010-10-27 11:06:20 +0200307 ret = spi_flash_write(env_flash, saved_offset,
308 saved_size, saved_buffer);
Mike Frysinger5b3375a2008-12-11 06:23:37 -0500309 if (ret)
310 goto done;
311 }
312
313 ret = 0;
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200314 puts("done\n");
Mike Frysinger5b3375a2008-12-11 06:23:37 -0500315
316 done:
317 if (saved_buffer)
318 free(saved_buffer);
Igor Grinbergeb58a7f2011-11-07 01:14:08 +0000319
Mike Frysinger5b3375a2008-12-11 06:23:37 -0500320 return ret;
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200321}
322
323void env_relocate_spec(void)
324{
325 int ret;
Ying Zhang5a89fa92014-01-24 15:50:07 +0800326 char *buf = NULL;
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200327
Ravi Babu7dd01742015-08-17 13:29:49 +0530328 buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE);
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-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 Denkea882ba2010-06-20 23:33:59 +0200331 if (!env_flash) {
332 set_default_env("!spi_flash_probe() failed");
Ying Zhang5a89fa92014-01-24 15:50:07 +0800333 if (buf)
334 free(buf);
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200335 return;
336 }
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200337
Wolfgang Denkea882ba2010-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 }
344
345 ret = env_import(buf, 1);
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200346 if (ret)
Wolfgang Denkea882ba2010-06-20 23:33:59 +0200347 gd->env_valid = 1;
348out:
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200349 spi_flash_free(env_flash);
Ying Zhang5a89fa92014-01-24 15:50:07 +0800350 if (buf)
351 free(buf);
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200352 env_flash = NULL;
Haavard Skinnemoen8c664972008-05-16 11:10:35 +0200353}
Wolfgang Wegner7319bca2010-04-23 17:22:55 +0200354#endif
Haavard Skinnemoen8c664972008-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}