blob: 9f1878def13a63d29cf9ba7e11dfd6f1686fe5ff [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Terry Lvb4eceac2010-05-17 10:57:01 +08002/*
Mingkai Hua55fce32011-01-24 17:09:55 +00003 * (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
Terry Lvb4eceac2010-05-17 10:57:01 +08004 */
5
6/* #define DEBUG */
7
8#include <common.h>
9
10#include <command.h>
Simon Glass97385862019-08-01 09:47:00 -060011#include <env.h>
Simon Glass9d1f6192019-08-02 09:44:25 -060012#include <env_internal.h>
Philipp Tomsich8ab507b2017-05-16 00:16:31 +020013#include <fdtdec.h>
Terry Lvb4eceac2010-05-17 10:57:01 +080014#include <linux/stddef.h>
15#include <malloc.h>
Simon Glass2dd337a2015-09-02 17:24:58 -060016#include <memalign.h>
Terry Lvb4eceac2010-05-17 10:57:01 +080017#include <mmc.h>
Jorge Ramirez-Ortiz03ab46c2017-11-06 14:16:37 +010018#include <part.h>
Lei Wen9f84f212010-11-10 07:39:23 +080019#include <search.h>
Lei Wenff833ed2010-10-13 11:07:21 +080020#include <errno.h>
Terry Lvb4eceac2010-05-17 10:57:01 +080021
Jorge Ramirez-Ortiz03ab46c2017-11-06 14:16:37 +010022#define __STR(X) #X
23#define STR(X) __STR(X)
24
Michael Heimpolda1d25a32013-04-10 10:36:19 +000025#if defined(CONFIG_ENV_SIZE_REDUND) && \
26 (CONFIG_ENV_SIZE_REDUND != CONFIG_ENV_SIZE)
27#error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
28#endif
29
Terry Lvb4eceac2010-05-17 10:57:01 +080030DECLARE_GLOBAL_DATA_PTR;
31
Mingkai Hua55fce32011-01-24 17:09:55 +000032#if !defined(CONFIG_ENV_OFFSET)
33#define CONFIG_ENV_OFFSET 0
34#endif
35
Philipp Tomsich8ab507b2017-05-16 00:16:31 +020036#if CONFIG_IS_ENABLED(OF_CONTROL)
Jorge Ramirez-Ortiz03ab46c2017-11-06 14:16:37 +010037static inline int mmc_offset_try_partition(const char *str, s64 *val)
38{
39 disk_partition_t info;
40 struct blk_desc *desc;
41 int len, i, ret;
42
43 ret = blk_get_device_by_str("mmc", STR(CONFIG_SYS_MMC_ENV_DEV), &desc);
44 if (ret < 0)
45 return (ret);
46
47 for (i = 1;;i++) {
48 ret = part_get_info(desc, i, &info);
49 if (ret < 0)
50 return ret;
51
52 if (!strncmp((const char *)info.name, str, sizeof(str)))
53 break;
54 }
55
56 /* round up to info.blksz */
57 len = (CONFIG_ENV_SIZE + info.blksz - 1) & ~(info.blksz - 1);
58
59 /* use the top of the partion for the environment */
60 *val = (info.start + info.size - 1) - len / info.blksz;
61
62 return 0;
63}
64
Philipp Tomsich8ab507b2017-05-16 00:16:31 +020065static inline s64 mmc_offset(int copy)
66{
Jorge Ramirez-Ortiz03ab46c2017-11-06 14:16:37 +010067 const struct {
68 const char *offset_redund;
69 const char *partition;
70 const char *offset;
71 } dt_prop = {
72 .offset_redund = "u-boot,mmc-env-offset-redundant",
73 .partition = "u-boot,mmc-env-partition",
74 .offset = "u-boot,mmc-env-offset",
75 };
Philipp Tomsich745d8de2017-11-21 23:29:40 +010076 s64 val = 0, defvalue;
Jorge Ramirez-Ortiz03ab46c2017-11-06 14:16:37 +010077 const char *propname;
78 const char *str;
79 int err;
80
81 /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */
82 str = fdtdec_get_config_string(gd->fdt_blob, dt_prop.partition);
83 if (str) {
84 /* try to place the environment at end of the partition */
85 err = mmc_offset_try_partition(str, &val);
86 if (!err)
87 return val;
88 }
89
90 defvalue = CONFIG_ENV_OFFSET;
91 propname = dt_prop.offset;
Philipp Tomsich8ab507b2017-05-16 00:16:31 +020092
93#if defined(CONFIG_ENV_OFFSET_REDUND)
94 if (copy) {
Philipp Tomsich8ab507b2017-05-16 00:16:31 +020095 defvalue = CONFIG_ENV_OFFSET_REDUND;
Jorge Ramirez-Ortiz03ab46c2017-11-06 14:16:37 +010096 propname = dt_prop.offset_redund;
Philipp Tomsich8ab507b2017-05-16 00:16:31 +020097 }
98#endif
Philipp Tomsich8ab507b2017-05-16 00:16:31 +020099 return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue);
100}
101#else
102static inline s64 mmc_offset(int copy)
Mingkai Hua55fce32011-01-24 17:09:55 +0000103{
Philipp Tomsich8ab507b2017-05-16 00:16:31 +0200104 s64 offset = CONFIG_ENV_OFFSET;
Stephen Warren24dc2032013-06-11 15:14:02 -0600105
Philipp Tomsich8ab507b2017-05-16 00:16:31 +0200106#if defined(CONFIG_ENV_OFFSET_REDUND)
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000107 if (copy)
Stephen Warren24dc2032013-06-11 15:14:02 -0600108 offset = CONFIG_ENV_OFFSET_REDUND;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000109#endif
Philipp Tomsich8ab507b2017-05-16 00:16:31 +0200110 return offset;
111}
112#endif
113
114__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
115{
116 s64 offset = mmc_offset(copy);
Stephen Warren24dc2032013-06-11 15:14:02 -0600117
118 if (offset < 0)
119 offset += mmc->capacity;
120
121 *env_addr = offset;
122
Mingkai Hua55fce32011-01-24 17:09:55 +0000123 return 0;
124}
Mingkai Hua55fce32011-01-24 17:09:55 +0000125
Clemens Gruberf7b61442016-01-20 15:43:37 +0100126__weak int mmc_get_env_dev(void)
127{
128 return CONFIG_SYS_MMC_ENV_DEV;
129}
130
Tom Rinic929f822014-03-28 12:03:34 -0400131#ifdef CONFIG_SYS_MMC_ENV_PART
Dmitry Lifshitz97d2fb92014-07-30 13:19:06 +0300132__weak uint mmc_get_env_part(struct mmc *mmc)
133{
134 return CONFIG_SYS_MMC_ENV_PART;
135}
136
Stephen Warren1e0f92a2015-12-07 11:38:49 -0700137static unsigned char env_mmc_orig_hwpart;
138
Dmitry Lifshitz97d2fb92014-07-30 13:19:06 +0300139static int mmc_set_env_part(struct mmc *mmc)
140{
141 uint part = mmc_get_env_part(mmc);
Clemens Gruberf7b61442016-01-20 15:43:37 +0100142 int dev = mmc_get_env_dev();
Dmitry Lifshitz97d2fb92014-07-30 13:19:06 +0300143 int ret = 0;
Tom Rinic929f822014-03-28 12:03:34 -0400144
Simon Glass11f2bb62016-05-01 13:52:29 -0600145 env_mmc_orig_hwpart = mmc_get_blk_desc(mmc)->hwpart;
146 ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part);
Stephen Warren1e0f92a2015-12-07 11:38:49 -0700147 if (ret)
148 puts("MMC partition switch failed\n");
Dmitry Lifshitz97d2fb92014-07-30 13:19:06 +0300149
150 return ret;
151}
152#else
153static inline int mmc_set_env_part(struct mmc *mmc) {return 0; };
Tom Rinic929f822014-03-28 12:03:34 -0400154#endif
155
Tim Harveyeda75c32015-05-08 14:52:09 -0700156static const char *init_mmc_for_env(struct mmc *mmc)
Dmitry Lifshitz97d2fb92014-07-30 13:19:06 +0300157{
Tim Harveyeda75c32015-05-08 14:52:09 -0700158 if (!mmc)
Yaniv Levinskyb2bb9bc2018-06-24 19:16:57 +0300159 return "No MMC card found";
Terry Lvb4eceac2010-05-17 10:57:01 +0800160
Sjoerd Simons5e4546d2018-03-22 22:53:50 +0100161#if CONFIG_IS_ENABLED(BLK)
Simon Glass1d9907c2017-05-27 11:37:18 -0600162 struct udevice *dev;
163
164 if (blk_get_from_parent(mmc->dev, &dev))
Yaniv Levinskyb2bb9bc2018-06-24 19:16:57 +0300165 return "No block device";
Simon Glass1d9907c2017-05-27 11:37:18 -0600166#else
Tim Harveyeda75c32015-05-08 14:52:09 -0700167 if (mmc_init(mmc))
Yaniv Levinskyb2bb9bc2018-06-24 19:16:57 +0300168 return "MMC init failed";
Simon Glass86d78c72017-04-23 20:02:04 -0600169#endif
Tim Harveyeda75c32015-05-08 14:52:09 -0700170 if (mmc_set_env_part(mmc))
Yaniv Levinskyb2bb9bc2018-06-24 19:16:57 +0300171 return "MMC partition switch failed";
Tim Harveyeda75c32015-05-08 14:52:09 -0700172
173 return NULL;
Terry Lvb4eceac2010-05-17 10:57:01 +0800174}
175
Stephen Warren27ee0f32012-07-30 10:55:44 +0000176static void fini_mmc_for_env(struct mmc *mmc)
177{
178#ifdef CONFIG_SYS_MMC_ENV_PART
Clemens Gruberf7b61442016-01-20 15:43:37 +0100179 int dev = mmc_get_env_dev();
Tom Rinic929f822014-03-28 12:03:34 -0400180
Simon Glass11f2bb62016-05-01 13:52:29 -0600181 blk_select_hwpart_devnum(IF_TYPE_MMC, dev, env_mmc_orig_hwpart);
Stephen Warren27ee0f32012-07-30 10:55:44 +0000182#endif
183}
184
Simon Glass082af922017-08-03 12:22:01 -0600185#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_SPL_BUILD)
Igor Grinbergecbfb622011-11-07 01:14:05 +0000186static inline int write_env(struct mmc *mmc, unsigned long size,
187 unsigned long offset, const void *buffer)
Terry Lvb4eceac2010-05-17 10:57:01 +0800188{
189 uint blk_start, blk_cnt, n;
Simon Glassda898922016-05-14 14:03:03 -0600190 struct blk_desc *desc = mmc_get_blk_desc(mmc);
Terry Lvb4eceac2010-05-17 10:57:01 +0800191
Igor Grinbergecbfb622011-11-07 01:14:05 +0000192 blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
193 blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
Terry Lvb4eceac2010-05-17 10:57:01 +0800194
Simon Glassda898922016-05-14 14:03:03 -0600195 n = blk_dwrite(desc, blk_start, blk_cnt, (u_char *)buffer);
Terry Lvb4eceac2010-05-17 10:57:01 +0800196
197 return (n == blk_cnt) ? 0 : -1;
198}
199
Simon Glass082af922017-08-03 12:22:01 -0600200static int env_mmc_save(void)
Terry Lvb4eceac2010-05-17 10:57:01 +0800201{
Tom Rinia840b8e2013-04-05 14:55:21 -0400202 ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
Clemens Gruberf7b61442016-01-20 15:43:37 +0100203 int dev = mmc_get_env_dev();
204 struct mmc *mmc = find_mmc_device(dev);
Igor Grinbergecbfb622011-11-07 01:14:05 +0000205 u32 offset;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000206 int ret, copy = 0;
Tim Harveyeda75c32015-05-08 14:52:09 -0700207 const char *errmsg;
Terry Lvb4eceac2010-05-17 10:57:01 +0800208
Tim Harveyeda75c32015-05-08 14:52:09 -0700209 errmsg = init_mmc_for_env(mmc);
210 if (errmsg) {
211 printf("%s\n", errmsg);
Terry Lvb4eceac2010-05-17 10:57:01 +0800212 return 1;
Tim Harveyeda75c32015-05-08 14:52:09 -0700213 }
Terry Lvb4eceac2010-05-17 10:57:01 +0800214
Marek Vasutd73c1292014-03-05 19:59:50 +0100215 ret = env_export(env_new);
216 if (ret)
Stephen Warren27ee0f32012-07-30 10:55:44 +0000217 goto fini;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000218
219#ifdef CONFIG_ENV_OFFSET_REDUND
Simon Glass4bc2ad22017-08-03 12:21:56 -0600220 if (gd->env_valid == ENV_VALID)
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000221 copy = 1;
222#endif
223
224 if (mmc_get_env_addr(mmc, copy, &offset)) {
225 ret = 1;
226 goto fini;
227 }
228
Clemens Gruberf7b61442016-01-20 15:43:37 +0100229 printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "", dev);
Stephen Warren42a3c442012-05-24 11:38:33 +0000230 if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) {
Terry Lvb4eceac2010-05-17 10:57:01 +0800231 puts("failed\n");
Stephen Warren27ee0f32012-07-30 10:55:44 +0000232 ret = 1;
233 goto fini;
Terry Lvb4eceac2010-05-17 10:57:01 +0800234 }
235
Stephen Warren27ee0f32012-07-30 10:55:44 +0000236 ret = 0;
237
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000238#ifdef CONFIG_ENV_OFFSET_REDUND
Simon Glass4bc2ad22017-08-03 12:21:56 -0600239 gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000240#endif
241
Stephen Warren27ee0f32012-07-30 10:55:44 +0000242fini:
243 fini_mmc_for_env(mmc);
244 return ret;
Terry Lvb4eceac2010-05-17 10:57:01 +0800245}
Frank Wunderlich81f087e2019-06-29 11:36:20 +0200246
247#if defined(CONFIG_CMD_ERASEENV)
248static inline int erase_env(struct mmc *mmc, unsigned long size,
249 unsigned long offset)
250{
251 uint blk_start, blk_cnt, n;
252 struct blk_desc *desc = mmc_get_blk_desc(mmc);
253
254 blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
255 blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
256
257 n = blk_derase(desc, blk_start, blk_cnt);
258 printf("%d blocks erased: %s\n", n, (n == blk_cnt) ? "OK" : "ERROR");
259
260 return (n == blk_cnt) ? 0 : 1;
261}
262
263static int env_mmc_erase(void)
264{
265 int dev = mmc_get_env_dev();
266 struct mmc *mmc = find_mmc_device(dev);
267 int ret, copy = 0;
268 u32 offset;
269 const char *errmsg;
270
271 errmsg = init_mmc_for_env(mmc);
272 if (errmsg) {
273 printf("%s\n", errmsg);
274 return 1;
275 }
276
277 if (mmc_get_env_addr(mmc, copy, &offset))
278 return CMD_RET_FAILURE;
279
280 ret = erase_env(mmc, CONFIG_ENV_SIZE, offset);
281
282#ifdef CONFIG_ENV_OFFSET_REDUND
283 copy = 1;
284
285 if (mmc_get_env_addr(mmc, copy, &offset))
286 return CMD_RET_FAILURE;
287
288 ret |= erase_env(mmc, CONFIG_ENV_SIZE, offset);
289#endif
290
291 return ret;
292}
293#endif /* CONFIG_CMD_ERASEENV */
Simon Glass082af922017-08-03 12:22:01 -0600294#endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
Terry Lvb4eceac2010-05-17 10:57:01 +0800295
Igor Grinbergecbfb622011-11-07 01:14:05 +0000296static inline int read_env(struct mmc *mmc, unsigned long size,
297 unsigned long offset, const void *buffer)
Terry Lvb4eceac2010-05-17 10:57:01 +0800298{
299 uint blk_start, blk_cnt, n;
Simon Glassda898922016-05-14 14:03:03 -0600300 struct blk_desc *desc = mmc_get_blk_desc(mmc);
Terry Lvb4eceac2010-05-17 10:57:01 +0800301
Igor Grinbergecbfb622011-11-07 01:14:05 +0000302 blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len;
303 blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len;
Terry Lvb4eceac2010-05-17 10:57:01 +0800304
Simon Glassda898922016-05-14 14:03:03 -0600305 n = blk_dread(desc, blk_start, blk_cnt, (uchar *)buffer);
Terry Lvb4eceac2010-05-17 10:57:01 +0800306
307 return (n == blk_cnt) ? 0 : -1;
308}
309
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000310#ifdef CONFIG_ENV_OFFSET_REDUND
Simon Glass99778492017-08-03 12:22:17 -0600311static int env_mmc_load(void)
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000312{
313#if !defined(ENV_IS_EMBEDDED)
Tom Rinic929f822014-03-28 12:03:34 -0400314 struct mmc *mmc;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000315 u32 offset1, offset2;
316 int read1_fail = 0, read2_fail = 0;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000317 int ret;
Clemens Gruberf7b61442016-01-20 15:43:37 +0100318 int dev = mmc_get_env_dev();
Tim Harveyeda75c32015-05-08 14:52:09 -0700319 const char *errmsg = NULL;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000320
Markus Niebel6ef41fd2013-10-04 15:48:03 +0200321 ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1);
322 ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env2, 1);
323
Faiz Abbasaae518f2018-02-12 19:24:31 +0530324 mmc_initialize(NULL);
325
Tom Rinic929f822014-03-28 12:03:34 -0400326 mmc = find_mmc_device(dev);
327
Tim Harveyeda75c32015-05-08 14:52:09 -0700328 errmsg = init_mmc_for_env(mmc);
329 if (errmsg) {
Simon Glass99778492017-08-03 12:22:17 -0600330 ret = -EIO;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000331 goto err;
332 }
333
334 if (mmc_get_env_addr(mmc, 0, &offset1) ||
335 mmc_get_env_addr(mmc, 1, &offset2)) {
Simon Glass99778492017-08-03 12:22:17 -0600336 ret = -EIO;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000337 goto fini;
338 }
339
340 read1_fail = read_env(mmc, CONFIG_ENV_SIZE, offset1, tmp_env1);
341 read2_fail = read_env(mmc, CONFIG_ENV_SIZE, offset2, tmp_env2);
342
Simon Goldschmidte07096e2018-01-31 14:47:11 +0100343 ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
344 read2_fail);
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000345
346fini:
347 fini_mmc_for_env(mmc);
348err:
349 if (ret)
Simon Glass97385862019-08-01 09:47:00 -0600350 env_set_default(errmsg, 0);
Simon Glass99778492017-08-03 12:22:17 -0600351
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000352#endif
Simon Glass99778492017-08-03 12:22:17 -0600353 return ret;
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000354}
355#else /* ! CONFIG_ENV_OFFSET_REDUND */
Simon Glass99778492017-08-03 12:22:17 -0600356static int env_mmc_load(void)
Terry Lvb4eceac2010-05-17 10:57:01 +0800357{
358#if !defined(ENV_IS_EMBEDDED)
Tom Rinia840b8e2013-04-05 14:55:21 -0400359 ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
Tom Rinic929f822014-03-28 12:03:34 -0400360 struct mmc *mmc;
Mingkai Hua55fce32011-01-24 17:09:55 +0000361 u32 offset;
Stephen Warren27ee0f32012-07-30 10:55:44 +0000362 int ret;
Clemens Gruberf7b61442016-01-20 15:43:37 +0100363 int dev = mmc_get_env_dev();
Tim Harveyeda75c32015-05-08 14:52:09 -0700364 const char *errmsg;
Tom Rinic929f822014-03-28 12:03:34 -0400365
Tom Rinic929f822014-03-28 12:03:34 -0400366 mmc = find_mmc_device(dev);
Stephen Warren27ee0f32012-07-30 10:55:44 +0000367
Tim Harveyeda75c32015-05-08 14:52:09 -0700368 errmsg = init_mmc_for_env(mmc);
369 if (errmsg) {
Simon Glass99778492017-08-03 12:22:17 -0600370 ret = -EIO;
Stephen Warren27ee0f32012-07-30 10:55:44 +0000371 goto err;
372 }
Terry Lvb4eceac2010-05-17 10:57:01 +0800373
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000374 if (mmc_get_env_addr(mmc, 0, &offset)) {
Simon Glass99778492017-08-03 12:22:17 -0600375 ret = -EIO;
Stephen Warren27ee0f32012-07-30 10:55:44 +0000376 goto fini;
377 }
Terry Lvb4eceac2010-05-17 10:57:01 +0800378
Tom Rinia840b8e2013-04-05 14:55:21 -0400379 if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
Tim Harveyeda75c32015-05-08 14:52:09 -0700380 errmsg = "!read failed";
Simon Glass99778492017-08-03 12:22:17 -0600381 ret = -EIO;
Stephen Warren27ee0f32012-07-30 10:55:44 +0000382 goto fini;
383 }
Terry Lvb4eceac2010-05-17 10:57:01 +0800384
Simon Goldschmidt35b4c322018-01-31 14:47:12 +0100385 ret = env_import(buf, 1);
Stephen Warren27ee0f32012-07-30 10:55:44 +0000386
387fini:
388 fini_mmc_for_env(mmc);
389err:
390 if (ret)
Simon Glass97385862019-08-01 09:47:00 -0600391 env_set_default(errmsg, 0);
Terry Lvb4eceac2010-05-17 10:57:01 +0800392#endif
Simon Glass99778492017-08-03 12:22:17 -0600393 return ret;
Terry Lvb4eceac2010-05-17 10:57:01 +0800394}
Michael Heimpolda1d25a32013-04-10 10:36:19 +0000395#endif /* CONFIG_ENV_OFFSET_REDUND */
Simon Glassc10a88e2017-08-03 12:21:58 -0600396
397U_BOOT_ENV_LOCATION(mmc) = {
398 .location = ENVL_MMC,
Simon Glassd8273ed2017-08-03 12:22:03 -0600399 ENV_NAME("MMC")
Simon Glass082af922017-08-03 12:22:01 -0600400 .load = env_mmc_load,
Simon Glassc10a88e2017-08-03 12:21:58 -0600401#ifndef CONFIG_SPL_BUILD
Simon Glass082af922017-08-03 12:22:01 -0600402 .save = env_save_ptr(env_mmc_save),
Frank Wunderlich81f087e2019-06-29 11:36:20 +0200403#if defined(CONFIG_CMD_ERASEENV)
404 .erase = env_mmc_erase,
405#endif
Simon Glassc10a88e2017-08-03 12:21:58 -0600406#endif
Simon Glassc10a88e2017-08-03 12:21:58 -0600407};