arm: meson-gx: add board_usb_init()/cleanup() for USB gadget
[oweals/u-boot.git] / env / remote.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
4  */
5
6 /* #define DEBUG */
7
8 #include <common.h>
9 #include <command.h>
10 #include <env_internal.h>
11 #include <linux/stddef.h>
12 #include <u-boot/crc.h>
13
14 #ifdef ENV_IS_EMBEDDED
15 env_t *env_ptr = &environment;
16 #else /* ! ENV_IS_EMBEDDED */
17 env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
18 #endif /* ENV_IS_EMBEDDED */
19
20 DECLARE_GLOBAL_DATA_PTR;
21
22 static int env_remote_init(void)
23 {
24         if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
25                 gd->env_addr = (ulong)&(env_ptr->data);
26                 gd->env_valid = ENV_VALID;
27                 return 0;
28         }
29
30         return -ENOENT;
31 }
32
33 #ifdef CONFIG_CMD_SAVEENV
34 static int env_remote_save(void)
35 {
36 #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
37         printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
38         return 1;
39 #else
40         return 0;
41 #endif
42 }
43 #endif /* CONFIG_CMD_SAVEENV */
44
45 static int env_remote_load(void)
46 {
47 #ifndef ENV_IS_EMBEDDED
48         return env_import((char *)env_ptr, 1);
49 #endif
50
51         return 0;
52 }
53
54 U_BOOT_ENV_LOCATION(remote) = {
55         .location       = ENVL_REMOTE,
56         ENV_NAME("Remote")
57         .load           = env_remote_load,
58         .save           = env_save_ptr(env_remote_save),
59         .init           = env_remote_init,
60 };