]> git.ipfire.org Git - thirdparty/u-boot.git/blame - env/remote.c
board: puma: use dtb given on the commandline instead of using u-boot.dtb
[thirdparty/u-boot.git] / env / remote.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
0a85a9e7
LG
2/*
3 * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
0a85a9e7
LG
4 */
5
6/* #define DEBUG */
7
8#include <common.h>
9#include <command.h>
f3998fdc 10#include <env_internal.h>
0a85a9e7 11#include <linux/stddef.h>
3db71108 12#include <u-boot/crc.h>
0a85a9e7 13
0a85a9e7 14#ifdef ENV_IS_EMBEDDED
46d9d1c3 15static env_t *env_ptr = &environment;
0a85a9e7 16#else /* ! ENV_IS_EMBEDDED */
46d9d1c3 17static env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
0a85a9e7
LG
18#endif /* ENV_IS_EMBEDDED */
19
20DECLARE_GLOBAL_DATA_PTR;
21
e5bce247 22static int env_remote_init(void)
0a85a9e7
LG
23{
24 if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
25 gd->env_addr = (ulong)&(env_ptr->data);
203e94f6 26 gd->env_valid = ENV_VALID;
0a85a9e7
LG
27 return 0;
28 }
29
7938822a 30 return -ENOENT;
0a85a9e7
LG
31}
32
33#ifdef CONFIG_CMD_SAVEENV
e5bce247 34static int env_remote_save(void)
0a85a9e7 35{
461632bd
LG
36#ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
37 printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
0a85a9e7
LG
38 return 1;
39#else
40 return 0;
41#endif
42}
43#endif /* CONFIG_CMD_SAVEENV */
44
c5951991 45static int env_remote_load(void)
0a85a9e7
LG
46{
47#ifndef ENV_IS_EMBEDDED
2166ebf7 48 return env_import((char *)env_ptr, 1);
0a85a9e7 49#endif
c5951991
SG
50
51 return 0;
0a85a9e7 52}
4415f1d1
SG
53
54U_BOOT_ENV_LOCATION(remote) = {
55 .location = ENVL_REMOTE,
ac358beb 56 ENV_NAME("Remote")
e5bce247
SG
57 .load = env_remote_load,
58 .save = env_save_ptr(env_remote_save),
59 .init = env_remote_init,
4415f1d1 60};