blob: e67ef90bcecf139e10216f3017090931f2b8f4a3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Terry Lva8060352010-05-17 10:57:01 +08002/*
Mingkai Hu97039ab2011-01-24 17:09:55 +00003 * (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
Terry Lva8060352010-05-17 10:57:01 +08004 */
5
6/* #define DEBUG */
7
8#include <common.h>
9
10#include <command.h>
Simon Glass0ac7d722019-08-01 09:47:00 -060011#include <env.h>
Simon Glassf3998fd2019-08-02 09:44:25 -060012#include <env_internal.h>
Philipp Tomsichf8b8a552017-05-16 00:16:31 +020013#include <fdtdec.h>
Terry Lva8060352010-05-17 10:57:01 +080014#include <linux/stddef.h>
15#include <malloc.h>
Simon Glasscf92e052015-09-02 17:24:58 -060016#include <memalign.h>
Terry Lva8060352010-05-17 10:57:01 +080017#include <mmc.h>
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010018#include <part.h>
Lei Wen6d1d51b2010-11-10 07:39:23 +080019#include <search.h>
Lei Wene79f4832010-10-13 11:07:21 +080020#include <errno.h>
Terry Lva8060352010-05-17 10:57:01 +080021
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010022#define __STR(X) #X
23#define STR(X) __STR(X)
24
Terry Lva8060352010-05-17 10:57:01 +080025DECLARE_GLOBAL_DATA_PTR;
26
Patrick Delaunay2b2f7272020-06-15 10:38:55 +020027#if !defined(CONFIG_SYS_MMC_ENV_DEV)
28#define CONFIG_SYS_MMC_ENV_DEV 0
29#endif
30
31__weak int mmc_get_env_dev(void)
32{
33 return CONFIG_SYS_MMC_ENV_DEV;
34}
35
Philipp Tomsichf8b8a552017-05-16 00:16:31 +020036#if CONFIG_IS_ENABLED(OF_CONTROL)
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010037static inline int mmc_offset_try_partition(const char *str, s64 *val)
38{
Simon Glass05289792020-05-10 11:39:57 -060039 struct disk_partition info;
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010040 struct blk_desc *desc;
41 int len, i, ret;
Patrick Delaunay2b2f7272020-06-15 10:38:55 +020042 char dev_str[4];
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010043
Patrick Delaunay2b2f7272020-06-15 10:38:55 +020044 snprintf(dev_str, sizeof(dev_str), "%d", mmc_get_env_dev());
45 ret = blk_get_device_by_str("mmc", dev_str, &desc);
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010046 if (ret < 0)
47 return (ret);
48
49 for (i = 1;;i++) {
50 ret = part_get_info(desc, i, &info);
51 if (ret < 0)
52 return ret;
53
54 if (!strncmp((const char *)info.name, str, sizeof(str)))
55 break;
56 }
57
58 /* round up to info.blksz */
59 len = (CONFIG_ENV_SIZE + info.blksz - 1) & ~(info.blksz - 1);
60
61 /* use the top of the partion for the environment */
62 *val = (info.start + info.size - 1) - len / info.blksz;
63
64 return 0;
65}
66
Philipp Tomsichf8b8a552017-05-16 00:16:31 +020067static inline s64 mmc_offset(int copy)
Mingkai Hu97039ab2011-01-24 17:09:55 +000068{
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010069 const struct {
70 const char *offset_redund;
71 const char *partition;
72 const char *offset;
73 } dt_prop = {
74 .offset_redund = "u-boot,mmc-env-offset-redundant",
75 .partition = "u-boot,mmc-env-partition",
76 .offset = "u-boot,mmc-env-offset",
77 };
Philipp Tomsichfd374662017-11-21 23:29:40 +010078 s64 val = 0, defvalue;
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010079 const char *propname;
80 const char *str;
81 int err;
82
83 /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */
84 str = fdtdec_get_config_string(gd->fdt_blob, dt_prop.partition);
85 if (str) {
86 /* try to place the environment at end of the partition */
87 err = mmc_offset_try_partition(str, &val);
88 if (!err)
89 return val;
90 }
91
92 defvalue = CONFIG_ENV_OFFSET;
93 propname = dt_prop.offset;
Stephen Warren5c088ee2013-06-11 15:14:02 -060094
Philipp Tomsichf8b8a552017-05-16 00:16:31 +020095#if defined(CONFIG_ENV_OFFSET_REDUND)
96 if (copy) {
Philipp Tomsichf8b8a552017-05-16 00:16:31 +020097 defvalue = CONFIG_ENV_OFFSET_REDUND;
Jorge Ramirez-Ortizc9e87ba2017-11-06 14:16:37 +010098 propname = dt_prop.offset_redund;
Philipp Tomsichf8b8a552017-05-16 00:16:31 +020099 }
100#endif
Philipp Tomsichf8b8a552017-05-16 00:16:31 +0200101 return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue);
102}
103#else
104static inline s64 mmc_offset(int copy)
105{
106 s64 offset = CONFIG_ENV_OFFSET;
107
108#if defined(CONFIG_ENV_OFFSET_REDUND)
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000109 if (copy)
Stephen Warren5c088ee2013-06-11 15:14:02 -0600110 offset = CONFIG_ENV_OFFSET_REDUND;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000111#endif
Philipp Tomsichf8b8a552017-05-16 00:16:31 +0200112 return offset;
113}
114#endif
115
116__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
117{
118 s64 offset = mmc_offset(copy);
Stephen Warren5c088ee2013-06-11 15:14:02 -0600119
120 if (offset < 0)
121 offset += mmc->capacity;
122
123 *env_addr = offset;
124
Mingkai Hu97039ab2011-01-24 17:09:55 +0000125 return 0;
126}
Mingkai Hu97039ab2011-01-24 17:09:55 +0000127
Tom Rinib9c8cca2014-03-28 12:03:34 -0400128#ifdef CONFIG_SYS_MMC_ENV_PART
Dmitry Lifshitz6e7b7df2014-07-30 13:19:06 +0300129__weak uint mmc_get_env_part(struct mmc *mmc)
130{
131 return CONFIG_SYS_MMC_ENV_PART;
132}
133
Stephen Warren873cc1d2015-12-07 11:38:49 -0700134static unsigned char env_mmc_orig_hwpart;
135
Dmitry Lifshitz6e7b7df2014-07-30 13:19:06 +0300136static int mmc_set_env_part(struct mmc *mmc)
137{
138 uint part = mmc_get_env_part(mmc);
Clemens Grubere92029c2016-01-20 15:43:37 +0100139 int dev = mmc_get_env_dev();
Dmitry Lifshitz6e7b7df2014-07-30 13:19:06 +0300140 int ret = 0;
Tom Rinib9c8cca2014-03-28 12:03:34 -0400141
Simon Glass69f45cd2016-05-01 13:52:29 -0600142 env_mmc_orig_hwpart = mmc_get_blk_desc(mmc)->hwpart;
143 ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part);
Stephen Warren873cc1d2015-12-07 11:38:49 -0700144 if (ret)
145 puts("MMC partition switch failed\n");
Dmitry Lifshitz6e7b7df2014-07-30 13:19:06 +0300146
147 return ret;
148}
149#else
150static inline int mmc_set_env_part(struct mmc *mmc) {return 0; };
Tom Rinib9c8cca2014-03-28 12:03:34 -0400151#endif
152
Tim Harveyc75648d2015-05-08 14:52:09 -0700153static const char *init_mmc_for_env(struct mmc *mmc)
Dmitry Lifshitz6e7b7df2014-07-30 13:19:06 +0300154{
Tim Harveyc75648d2015-05-08 14:52:09 -0700155 if (!mmc)
Yaniv Levinskyc5d548a2018-06-24 19:16:57 +0300156 return "No MMC card found";
Terry Lva8060352010-05-17 10:57:01 +0800157
Sjoerd Simonsd48b8d12018-03-22 22:53:50 +0100158#if CONFIG_IS_ENABLED(BLK)
Simon Glass01b73fe2017-05-27 11:37:18 -0600159 struct udevice *dev;
160
161 if (blk_get_from_parent(mmc->dev, &dev))
Yaniv Levinskyc5d548a2018-06-24 19:16:57 +0300162 return "No block device";
Simon Glass01b73fe2017-05-27 11:37:18 -0600163#else
Tim Harveyc75648d2015-05-08 14:52:09 -0700164 if (mmc_init(mmc))
Yaniv Levinskyc5d548a2018-06-24 19:16:57 +0300165 return "MMC init failed";
Simon Glasse7017a32017-04-23 20:02:04 -0600166#endif
Tim Harveyc75648d2015-05-08 14:52:09 -0700167 if (mmc_set_env_part(mmc))
Yaniv Levinskyc5d548a2018-06-24 19:16:57 +0300168 return "MMC partition switch failed";
Tim Harveyc75648d2015-05-08 14:52:09 -0700169
170 return NULL;
Terry Lva8060352010-05-17 10:57:01 +0800171}
172
Stephen Warren9404a5f2012-07-30 10:55:44 +0000173static void fini_mmc_for_env(struct mmc *mmc)
174{
175#ifdef CONFIG_SYS_MMC_ENV_PART
Clemens Grubere92029c2016-01-20 15:43:37 +0100176 int dev = mmc_get_env_dev();
Tom Rinib9c8cca2014-03-28 12:03:34 -0400177
Simon Glass69f45cd2016-05-01 13:52:29 -0600178 blk_select_hwpart_devnum(IF_TYPE_MMC, dev, env_mmc_orig_hwpart);
Stephen Warren9404a5f2012-07-30 10:55:44 +0000179#endif
180}
181
Simon Glasse5bce242017-08-03 12:22:01 -0600182#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_SPL_BUILD)
Igor Grinberge8db8f72011-11-07 01:14:05 +0000183static inline int write_env(struct mmc *mmc, unsigned long size,
184 unsigned long offset, const void *buffer)
Terry Lva8060352010-05-17 10:57:01 +0800185{
186 uint blk_start, blk_cnt, n;
Simon Glass5461acb2016-05-14 14:03:03 -0600187 struct blk_desc *desc = mmc_get_blk_desc(mmc);
Terry Lva8060352010-05-17 10:57:01 +0800188
Igor Grinberge8db8f72011-11-07 01:14:05 +0000189 blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
190 blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
Terry Lva8060352010-05-17 10:57:01 +0800191
Simon Glass5461acb2016-05-14 14:03:03 -0600192 n = blk_dwrite(desc, blk_start, blk_cnt, (u_char *)buffer);
Terry Lva8060352010-05-17 10:57:01 +0800193
194 return (n == blk_cnt) ? 0 : -1;
195}
196
Simon Glasse5bce242017-08-03 12:22:01 -0600197static int env_mmc_save(void)
Terry Lva8060352010-05-17 10:57:01 +0800198{
Tom Rinicd0f4fa2013-04-05 14:55:21 -0400199 ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
Clemens Grubere92029c2016-01-20 15:43:37 +0100200 int dev = mmc_get_env_dev();
201 struct mmc *mmc = find_mmc_device(dev);
Igor Grinberge8db8f72011-11-07 01:14:05 +0000202 u32 offset;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000203 int ret, copy = 0;
Tim Harveyc75648d2015-05-08 14:52:09 -0700204 const char *errmsg;
Terry Lva8060352010-05-17 10:57:01 +0800205
Tim Harveyc75648d2015-05-08 14:52:09 -0700206 errmsg = init_mmc_for_env(mmc);
207 if (errmsg) {
208 printf("%s\n", errmsg);
Mingkai Hu97039ab2011-01-24 17:09:55 +0000209 return 1;
Tim Harveyc75648d2015-05-08 14:52:09 -0700210 }
Mingkai Hu97039ab2011-01-24 17:09:55 +0000211
Marek Vasut7ce15262014-03-05 19:59:50 +0100212 ret = env_export(env_new);
213 if (ret)
Stephen Warren9404a5f2012-07-30 10:55:44 +0000214 goto fini;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000215
216#ifdef CONFIG_ENV_OFFSET_REDUND
Simon Glass203e94f2017-08-03 12:21:56 -0600217 if (gd->env_valid == ENV_VALID)
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000218 copy = 1;
219#endif
220
221 if (mmc_get_env_addr(mmc, copy, &offset)) {
222 ret = 1;
223 goto fini;
224 }
225
Clemens Grubere92029c2016-01-20 15:43:37 +0100226 printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "", dev);
Stephen Warren4036b632012-05-24 11:38:33 +0000227 if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) {
Terry Lva8060352010-05-17 10:57:01 +0800228 puts("failed\n");
Stephen Warren9404a5f2012-07-30 10:55:44 +0000229 ret = 1;
230 goto fini;
Terry Lva8060352010-05-17 10:57:01 +0800231 }
232
Stephen Warren9404a5f2012-07-30 10:55:44 +0000233 ret = 0;
234
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000235#ifdef CONFIG_ENV_OFFSET_REDUND
Simon Glass203e94f2017-08-03 12:21:56 -0600236 gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000237#endif
238
Stephen Warren9404a5f2012-07-30 10:55:44 +0000239fini:
240 fini_mmc_for_env(mmc);
241 return ret;
Terry Lva8060352010-05-17 10:57:01 +0800242}
Frank Wunderlich34853922019-06-29 11:36:20 +0200243
244#if defined(CONFIG_CMD_ERASEENV)
245static inline int erase_env(struct mmc *mmc, unsigned long size,
246 unsigned long offset)
247{
248 uint blk_start, blk_cnt, n;
249 struct blk_desc *desc = mmc_get_blk_desc(mmc);
250
251 blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
252 blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
253
254 n = blk_derase(desc, blk_start, blk_cnt);
255 printf("%d blocks erased: %s\n", n, (n == blk_cnt) ? "OK" : "ERROR");
256
257 return (n == blk_cnt) ? 0 : 1;
258}
259
260static int env_mmc_erase(void)
261{
262 int dev = mmc_get_env_dev();
263 struct mmc *mmc = find_mmc_device(dev);
264 int ret, copy = 0;
265 u32 offset;
266 const char *errmsg;
267
268 errmsg = init_mmc_for_env(mmc);
269 if (errmsg) {
270 printf("%s\n", errmsg);
271 return 1;
272 }
273
274 if (mmc_get_env_addr(mmc, copy, &offset))
275 return CMD_RET_FAILURE;
276
277 ret = erase_env(mmc, CONFIG_ENV_SIZE, offset);
278
279#ifdef CONFIG_ENV_OFFSET_REDUND
280 copy = 1;
281
282 if (mmc_get_env_addr(mmc, copy, &offset))
283 return CMD_RET_FAILURE;
284
285 ret |= erase_env(mmc, CONFIG_ENV_SIZE, offset);
286#endif
287
288 return ret;
289}
290#endif /* CONFIG_CMD_ERASEENV */
Simon Glasse5bce242017-08-03 12:22:01 -0600291#endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
Terry Lva8060352010-05-17 10:57:01 +0800292
Igor Grinberge8db8f72011-11-07 01:14:05 +0000293static inline int read_env(struct mmc *mmc, unsigned long size,
294 unsigned long offset, const void *buffer)
Terry Lva8060352010-05-17 10:57:01 +0800295{
296 uint blk_start, blk_cnt, n;
Simon Glass5461acb2016-05-14 14:03:03 -0600297 struct blk_desc *desc = mmc_get_blk_desc(mmc);
Terry Lva8060352010-05-17 10:57:01 +0800298
Igor Grinberge8db8f72011-11-07 01:14:05 +0000299 blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len;
300 blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len;
Terry Lva8060352010-05-17 10:57:01 +0800301
Simon Glass5461acb2016-05-14 14:03:03 -0600302 n = blk_dread(desc, blk_start, blk_cnt, (uchar *)buffer);
Terry Lva8060352010-05-17 10:57:01 +0800303
304 return (n == blk_cnt) ? 0 : -1;
305}
306
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000307#ifdef CONFIG_ENV_OFFSET_REDUND
Simon Glassc5951992017-08-03 12:22:17 -0600308static int env_mmc_load(void)
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000309{
310#if !defined(ENV_IS_EMBEDDED)
Tom Rinib9c8cca2014-03-28 12:03:34 -0400311 struct mmc *mmc;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000312 u32 offset1, offset2;
313 int read1_fail = 0, read2_fail = 0;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000314 int ret;
Clemens Grubere92029c2016-01-20 15:43:37 +0100315 int dev = mmc_get_env_dev();
Tim Harveyc75648d2015-05-08 14:52:09 -0700316 const char *errmsg = NULL;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000317
Markus Niebel452a2722013-10-04 15:48:03 +0200318 ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1);
319 ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env2, 1);
320
Faiz Abbas26862b42018-02-12 19:24:31 +0530321 mmc_initialize(NULL);
322
Tom Rinib9c8cca2014-03-28 12:03:34 -0400323 mmc = find_mmc_device(dev);
324
Tim Harveyc75648d2015-05-08 14:52:09 -0700325 errmsg = init_mmc_for_env(mmc);
326 if (errmsg) {
Simon Glassc5951992017-08-03 12:22:17 -0600327 ret = -EIO;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000328 goto err;
329 }
330
331 if (mmc_get_env_addr(mmc, 0, &offset1) ||
332 mmc_get_env_addr(mmc, 1, &offset2)) {
Simon Glassc5951992017-08-03 12:22:17 -0600333 ret = -EIO;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000334 goto fini;
335 }
336
337 read1_fail = read_env(mmc, CONFIG_ENV_SIZE, offset1, tmp_env1);
338 read2_fail = read_env(mmc, CONFIG_ENV_SIZE, offset2, tmp_env2);
339
Simon Goldschmidt31f044b2018-01-31 14:47:11 +0100340 ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
341 read2_fail);
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000342
343fini:
344 fini_mmc_for_env(mmc);
345err:
346 if (ret)
Simon Glass0ac7d722019-08-01 09:47:00 -0600347 env_set_default(errmsg, 0);
Simon Glassc5951992017-08-03 12:22:17 -0600348
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000349#endif
Simon Glassc5951992017-08-03 12:22:17 -0600350 return ret;
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000351}
352#else /* ! CONFIG_ENV_OFFSET_REDUND */
Simon Glassc5951992017-08-03 12:22:17 -0600353static int env_mmc_load(void)
Terry Lva8060352010-05-17 10:57:01 +0800354{
355#if !defined(ENV_IS_EMBEDDED)
Tom Rinicd0f4fa2013-04-05 14:55:21 -0400356 ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
Tom Rinib9c8cca2014-03-28 12:03:34 -0400357 struct mmc *mmc;
Mingkai Hu97039ab2011-01-24 17:09:55 +0000358 u32 offset;
Stephen Warren9404a5f2012-07-30 10:55:44 +0000359 int ret;
Clemens Grubere92029c2016-01-20 15:43:37 +0100360 int dev = mmc_get_env_dev();
Tim Harveyc75648d2015-05-08 14:52:09 -0700361 const char *errmsg;
Pankit Garg0536b442019-11-19 09:49:31 +0000362 env_t *ep = NULL;
Tom Rinib9c8cca2014-03-28 12:03:34 -0400363
Tom Rinib9c8cca2014-03-28 12:03:34 -0400364 mmc = find_mmc_device(dev);
Terry Lva8060352010-05-17 10:57:01 +0800365
Tim Harveyc75648d2015-05-08 14:52:09 -0700366 errmsg = init_mmc_for_env(mmc);
367 if (errmsg) {
Simon Glassc5951992017-08-03 12:22:17 -0600368 ret = -EIO;
Stephen Warren9404a5f2012-07-30 10:55:44 +0000369 goto err;
370 }
Terry Lva8060352010-05-17 10:57:01 +0800371
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000372 if (mmc_get_env_addr(mmc, 0, &offset)) {
Simon Glassc5951992017-08-03 12:22:17 -0600373 ret = -EIO;
Stephen Warren9404a5f2012-07-30 10:55:44 +0000374 goto fini;
375 }
376
Tom Rinicd0f4fa2013-04-05 14:55:21 -0400377 if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
Tim Harveyc75648d2015-05-08 14:52:09 -0700378 errmsg = "!read failed";
Simon Glassc5951992017-08-03 12:22:17 -0600379 ret = -EIO;
Stephen Warren9404a5f2012-07-30 10:55:44 +0000380 goto fini;
381 }
Terry Lva8060352010-05-17 10:57:01 +0800382
Simon Goldschmidt2166ebf2018-01-31 14:47:12 +0100383 ret = env_import(buf, 1);
Pankit Garg0536b442019-11-19 09:49:31 +0000384 if (!ret) {
385 ep = (env_t *)buf;
386 gd->env_addr = (ulong)&ep->data;
387 }
Stephen Warren9404a5f2012-07-30 10:55:44 +0000388
389fini:
390 fini_mmc_for_env(mmc);
391err:
392 if (ret)
Simon Glass0ac7d722019-08-01 09:47:00 -0600393 env_set_default(errmsg, 0);
Terry Lva8060352010-05-17 10:57:01 +0800394#endif
Simon Glassc5951992017-08-03 12:22:17 -0600395 return ret;
Terry Lva8060352010-05-17 10:57:01 +0800396}
Michael Heimpoldd196bd82013-04-10 10:36:19 +0000397#endif /* CONFIG_ENV_OFFSET_REDUND */
Simon Glass4415f1d2017-08-03 12:21:58 -0600398
399U_BOOT_ENV_LOCATION(mmc) = {
400 .location = ENVL_MMC,
Simon Glassac358be2017-08-03 12:22:03 -0600401 ENV_NAME("MMC")
Simon Glasse5bce242017-08-03 12:22:01 -0600402 .load = env_mmc_load,
Simon Glass4415f1d2017-08-03 12:21:58 -0600403#ifndef CONFIG_SPL_BUILD
Simon Glasse5bce242017-08-03 12:22:01 -0600404 .save = env_save_ptr(env_mmc_save),
Frank Wunderlich34853922019-06-29 11:36:20 +0200405#if defined(CONFIG_CMD_ERASEENV)
406 .erase = env_mmc_erase,
407#endif
Simon Glass4415f1d2017-08-03 12:21:58 -0600408#endif
Simon Glass4415f1d2017-08-03 12:21:58 -0600409};