Michal Simek | 9755e3d | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 3 | * (C) Copyright 2014 - 2020 Xilinx, Inc. |
Michal Simek | 9755e3d | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 4 | * Michal Simek <michal.simek@xilinx.com> |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <env.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Michal Simek | fc274a5 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 11 | #include <asm/sections.h> |
Michal Simek | 9755e3d | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 12 | #include <dm/uclass.h> |
| 13 | #include <i2c.h> |
Michal Simek | a29511e | 2020-04-08 10:51:36 +0200 | [diff] [blame] | 14 | #include <linux/sizes.h> |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 15 | #include <malloc.h> |
Michal Simek | 80fdef1 | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 16 | #include "board.h" |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 17 | #include <dm.h> |
| 18 | #include <i2c_eeprom.h> |
| 19 | #include <net.h> |
Michal Simek | 05af483 | 2020-10-26 12:26:13 +0100 | [diff] [blame] | 20 | #include <generated/dt.h> |
Michal Simek | 9755e3d | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 21 | |
Michal Simek | f149b39 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 22 | #include "fru.h" |
| 23 | |
Michal Simek | 9fea3b1 | 2020-08-03 12:59:28 +0200 | [diff] [blame] | 24 | #if defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET) |
Michal Simek | 829e8c7 | 2019-01-21 16:29:07 +0100 | [diff] [blame] | 25 | int zynq_board_read_rom_ethaddr(unsigned char *ethaddr) |
| 26 | { |
| 27 | int ret = -EINVAL; |
Michal Simek | 829e8c7 | 2019-01-21 16:29:07 +0100 | [diff] [blame] | 28 | struct udevice *dev; |
| 29 | ofnode eeprom; |
| 30 | |
| 31 | eeprom = ofnode_get_chosen_node("xlnx,eeprom"); |
| 32 | if (!ofnode_valid(eeprom)) |
| 33 | return -ENODEV; |
| 34 | |
| 35 | debug("%s: Path to EEPROM %s\n", __func__, |
Simon Glass | 14ca9f7 | 2020-01-27 08:49:43 -0700 | [diff] [blame] | 36 | ofnode_read_chosen_string("xlnx,eeprom")); |
Michal Simek | 829e8c7 | 2019-01-21 16:29:07 +0100 | [diff] [blame] | 37 | |
| 38 | ret = uclass_get_device_by_ofnode(UCLASS_I2C_EEPROM, eeprom, &dev); |
| 39 | if (ret) |
| 40 | return ret; |
| 41 | |
| 42 | ret = dm_i2c_read(dev, CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET, ethaddr, 6); |
| 43 | if (ret) |
| 44 | debug("%s: I2C EEPROM MAC address read failed\n", __func__); |
| 45 | else |
| 46 | debug("%s: I2C EEPROM MAC %pM\n", __func__, ethaddr); |
Michal Simek | 829e8c7 | 2019-01-21 16:29:07 +0100 | [diff] [blame] | 47 | |
| 48 | return ret; |
| 49 | } |
Michal Simek | 9fea3b1 | 2020-08-03 12:59:28 +0200 | [diff] [blame] | 50 | #endif |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 51 | |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 52 | #define EEPROM_HEADER_MAGIC 0xdaaddeed |
| 53 | #define EEPROM_HDR_MANUFACTURER_LEN 16 |
| 54 | #define EEPROM_HDR_NAME_LEN 16 |
| 55 | #define EEPROM_HDR_REV_LEN 8 |
| 56 | #define EEPROM_HDR_SERIAL_LEN 20 |
| 57 | #define EEPROM_HDR_NO_OF_MAC_ADDR 4 |
| 58 | #define EEPROM_HDR_ETH_ALEN ETH_ALEN |
| 59 | |
| 60 | struct xilinx_board_description { |
| 61 | u32 header; |
| 62 | char manufacturer[EEPROM_HDR_MANUFACTURER_LEN + 1]; |
| 63 | char name[EEPROM_HDR_NAME_LEN + 1]; |
| 64 | char revision[EEPROM_HDR_REV_LEN + 1]; |
| 65 | char serial[EEPROM_HDR_SERIAL_LEN + 1]; |
| 66 | u8 mac_addr[EEPROM_HDR_NO_OF_MAC_ADDR][EEPROM_HDR_ETH_ALEN + 1]; |
| 67 | }; |
| 68 | |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 69 | static int highest_id = -1; |
| 70 | static struct xilinx_board_description **board_info; |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 71 | |
Michal Simek | f149b39 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 72 | #define XILINX_I2C_DETECTION_BITS sizeof(struct fru_common_hdr) |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 73 | |
| 74 | /* Variable which stores pointer to array which stores eeprom content */ |
| 75 | struct xilinx_legacy_format { |
| 76 | char board_sn[18]; /* 0x0 */ |
| 77 | char unused0[14]; /* 0x12 */ |
| 78 | char eth_mac[6]; /* 0x20 */ |
| 79 | char unused1[170]; /* 0x26 */ |
| 80 | char board_name[11]; /* 0xd0 */ |
| 81 | char unused2[5]; /* 0xdc */ |
| 82 | char board_revision[3]; /* 0xe0 */ |
| 83 | char unused3[29]; /* 0xe3 */ |
| 84 | }; |
| 85 | |
| 86 | static void xilinx_eeprom_legacy_cleanup(char *eeprom, int size) |
| 87 | { |
| 88 | int i; |
| 89 | char byte; |
| 90 | |
| 91 | for (i = 0; i < size; i++) { |
| 92 | byte = eeprom[i]; |
| 93 | |
| 94 | /* Remove all ffs and spaces */ |
| 95 | if (byte == 0xff || byte == ' ') |
| 96 | eeprom[i] = 0; |
| 97 | |
| 98 | /* Convert strings to lower case */ |
| 99 | if (byte >= 'A' && byte <= 'Z') |
| 100 | eeprom[i] = byte + 'a' - 'A'; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | static int xilinx_read_eeprom_legacy(struct udevice *dev, char *name, |
| 105 | struct xilinx_board_description *desc) |
| 106 | { |
| 107 | int ret, size; |
| 108 | struct xilinx_legacy_format *eeprom_content; |
| 109 | bool eth_valid = false; |
| 110 | |
| 111 | size = sizeof(*eeprom_content); |
| 112 | |
| 113 | eeprom_content = calloc(1, size); |
| 114 | if (!eeprom_content) |
| 115 | return -ENOMEM; |
| 116 | |
| 117 | debug("%s: I2C EEPROM read pass data at %p\n", __func__, |
| 118 | eeprom_content); |
| 119 | |
| 120 | ret = dm_i2c_read(dev, 0, (uchar *)eeprom_content, size); |
| 121 | if (ret) { |
| 122 | debug("%s: I2C EEPROM read failed\n", __func__); |
| 123 | free(eeprom_content); |
| 124 | return ret; |
| 125 | } |
| 126 | |
| 127 | xilinx_eeprom_legacy_cleanup((char *)eeprom_content, size); |
| 128 | |
| 129 | printf("Xilinx I2C Legacy format at %s:\n", name); |
| 130 | printf(" Board name:\t%s\n", eeprom_content->board_name); |
| 131 | printf(" Board rev:\t%s\n", eeprom_content->board_revision); |
| 132 | printf(" Board SN:\t%s\n", eeprom_content->board_sn); |
| 133 | |
| 134 | eth_valid = is_valid_ethaddr((const u8 *)eeprom_content->eth_mac); |
| 135 | if (eth_valid) |
| 136 | printf(" Ethernet mac:\t%pM\n", eeprom_content->eth_mac); |
| 137 | |
| 138 | /* Terminating \0 chars ensure end of string */ |
| 139 | strcpy(desc->name, eeprom_content->board_name); |
| 140 | strcpy(desc->revision, eeprom_content->board_revision); |
| 141 | strcpy(desc->serial, eeprom_content->board_sn); |
| 142 | if (eth_valid) |
| 143 | memcpy(desc->mac_addr[0], eeprom_content->eth_mac, ETH_ALEN); |
| 144 | |
| 145 | desc->header = EEPROM_HEADER_MAGIC; |
| 146 | |
| 147 | free(eeprom_content); |
| 148 | |
| 149 | return ret; |
| 150 | } |
| 151 | |
| 152 | static bool xilinx_detect_legacy(u8 *buffer) |
| 153 | { |
| 154 | int i; |
| 155 | char c; |
| 156 | |
| 157 | for (i = 0; i < XILINX_I2C_DETECTION_BITS; i++) { |
| 158 | c = buffer[i]; |
| 159 | |
| 160 | if (c < '0' || c > '9') |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | return true; |
| 165 | } |
| 166 | |
Michal Simek | f149b39 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 167 | static int xilinx_read_eeprom_fru(struct udevice *dev, char *name, |
| 168 | struct xilinx_board_description *desc) |
| 169 | { |
| 170 | int ret, eeprom_size; |
| 171 | u8 *fru_content; |
| 172 | |
| 173 | /* FIXME this is shortcut - if eeprom type is wrong it will fail */ |
| 174 | eeprom_size = i2c_eeprom_size(dev); |
| 175 | |
| 176 | fru_content = calloc(1, eeprom_size); |
| 177 | if (!fru_content) |
| 178 | return -ENOMEM; |
| 179 | |
| 180 | debug("%s: I2C EEPROM read pass data at %p\n", __func__, |
| 181 | fru_content); |
| 182 | |
| 183 | ret = dm_i2c_read(dev, 0, (uchar *)fru_content, |
| 184 | eeprom_size); |
| 185 | if (ret) { |
| 186 | debug("%s: I2C EEPROM read failed\n", __func__); |
| 187 | free(fru_content); |
| 188 | return ret; |
| 189 | } |
| 190 | |
| 191 | printf("Xilinx I2C FRU format at %s:\n", name); |
| 192 | fru_capture((unsigned long)fru_content); |
| 193 | ret = fru_display(0); |
| 194 | if (ret) { |
| 195 | printf("FRU format decoding failed.\n"); |
| 196 | return ret; |
| 197 | } |
| 198 | |
| 199 | if (desc->header == EEPROM_HEADER_MAGIC) { |
| 200 | debug("Information already filled\n"); |
| 201 | return -EINVAL; |
| 202 | } |
| 203 | |
| 204 | /* It is clear that FRU was captured and structures were filled */ |
| 205 | strncpy(desc->manufacturer, (char *)fru_data.brd.manufacturer_name, |
| 206 | sizeof(desc->manufacturer)); |
| 207 | strncpy(desc->name, (char *)fru_data.brd.product_name, |
| 208 | sizeof(desc->name)); |
| 209 | strncpy(desc->revision, (char *)fru_data.brd.rev, |
| 210 | sizeof(desc->revision)); |
| 211 | strncpy(desc->serial, (char *)fru_data.brd.serial_number, |
| 212 | sizeof(desc->serial)); |
| 213 | desc->header = EEPROM_HEADER_MAGIC; |
| 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | static bool xilinx_detect_fru(u8 *buffer) |
| 219 | { |
| 220 | u8 checksum = 0; |
| 221 | int i; |
| 222 | |
| 223 | checksum = fru_checksum((u8 *)buffer, sizeof(struct fru_common_hdr)); |
| 224 | if (checksum) { |
| 225 | debug("%s Common header CRC FAIL\n", __func__); |
| 226 | return false; |
| 227 | } |
| 228 | |
| 229 | bool all_zeros = true; |
| 230 | /* Checksum over all zeros is also zero that's why detect this case */ |
| 231 | for (i = 0; i < sizeof(struct fru_common_hdr); i++) { |
| 232 | if (buffer[i] != 0) |
| 233 | all_zeros = false; |
| 234 | } |
| 235 | |
| 236 | if (all_zeros) |
| 237 | return false; |
| 238 | |
| 239 | debug("%s Common header CRC PASS\n", __func__); |
| 240 | return true; |
| 241 | } |
| 242 | |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 243 | static int xilinx_read_eeprom_single(char *name, |
| 244 | struct xilinx_board_description *desc) |
| 245 | { |
| 246 | int ret; |
| 247 | struct udevice *dev; |
| 248 | ofnode eeprom; |
| 249 | u8 buffer[XILINX_I2C_DETECTION_BITS]; |
| 250 | |
| 251 | eeprom = ofnode_get_aliases_node(name); |
| 252 | if (!ofnode_valid(eeprom)) |
| 253 | return -ENODEV; |
| 254 | |
| 255 | ret = uclass_get_device_by_ofnode(UCLASS_I2C_EEPROM, eeprom, &dev); |
| 256 | if (ret) |
| 257 | return ret; |
| 258 | |
| 259 | ret = dm_i2c_read(dev, 0, buffer, sizeof(buffer)); |
| 260 | if (ret) { |
| 261 | debug("%s: I2C EEPROM read failed\n", __func__); |
| 262 | return ret; |
| 263 | } |
| 264 | |
| 265 | debug("%s: i2c memory detected: %s\n", __func__, name); |
| 266 | |
Michal Simek | f149b39 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 267 | if (CONFIG_IS_ENABLED(CMD_FRU) && xilinx_detect_fru(buffer)) |
| 268 | return xilinx_read_eeprom_fru(dev, name, desc); |
| 269 | |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 270 | if (xilinx_detect_legacy(buffer)) |
| 271 | return xilinx_read_eeprom_legacy(dev, name, desc); |
| 272 | |
| 273 | return -ENODEV; |
| 274 | } |
| 275 | |
| 276 | __maybe_unused int xilinx_read_eeprom(void) |
| 277 | { |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 278 | int id, ret; |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 279 | char name_buf[8]; /* 8 bytes should be enough for nvmem+number */ |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 280 | struct xilinx_board_description *desc; |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 281 | |
| 282 | highest_id = dev_read_alias_highest_id("nvmem"); |
| 283 | /* No nvmem aliases present */ |
| 284 | if (highest_id < 0) |
| 285 | return -EINVAL; |
| 286 | |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 287 | board_info = calloc(1, sizeof(desc) * highest_id); |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 288 | if (!board_info) |
| 289 | return -ENOMEM; |
| 290 | |
| 291 | debug("%s: Highest ID %d, board_info %p\n", __func__, |
| 292 | highest_id, board_info); |
| 293 | |
| 294 | for (id = 0; id <= highest_id; id++) { |
| 295 | snprintf(name_buf, sizeof(name_buf), "nvmem%d", id); |
| 296 | |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 297 | /* Alloc structure */ |
| 298 | desc = board_info[id]; |
| 299 | if (!desc) { |
| 300 | desc = calloc(1, sizeof(*desc)); |
| 301 | if (!desc) |
| 302 | return -ENOMEM; |
| 303 | |
| 304 | board_info[id] = desc; |
| 305 | } |
| 306 | |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 307 | /* Ignoring return value for supporting multiple chips */ |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 308 | ret = xilinx_read_eeprom_single(name_buf, desc); |
| 309 | if (ret) { |
| 310 | free(desc); |
| 311 | board_info[id] = NULL; |
| 312 | } |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 313 | } |
| 314 | |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 315 | /* |
| 316 | * Consider to clean board_info structure when board/cards are not |
| 317 | * detected. |
| 318 | */ |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 319 | |
| 320 | return 0; |
| 321 | } |
| 322 | |
Michal Simek | fc274a5 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 323 | #if defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE) |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 324 | void *board_fdt_blob_setup(void) |
| 325 | { |
Michal Simek | e2572b5 | 2020-09-04 16:21:47 +0200 | [diff] [blame] | 326 | void *fdt_blob; |
Michal Simek | 453bb77 | 2020-03-19 10:23:56 +0100 | [diff] [blame] | 327 | |
Michal Simek | a672b98 | 2021-01-04 11:07:28 +0100 | [diff] [blame] | 328 | if (!IS_ENABLED(CONFIG_SPL_BUILD) && |
| 329 | !IS_ENABLED(CONFIG_VERSAL_NO_DDR) && |
Michal Simek | fc3c6fd | 2021-02-02 13:33:22 +0100 | [diff] [blame] | 330 | !IS_ENABLED(CONFIG_ZYNQMP_NO_DDR)) { |
Michal Simek | 506009f | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 331 | fdt_blob = (void *)CONFIG_XILINX_OF_BOARD_DTB_ADDR; |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 332 | |
Michal Simek | 506009f | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 333 | if (fdt_magic(fdt_blob) == FDT_MAGIC) |
| 334 | return fdt_blob; |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 335 | |
Michal Simek | 506009f | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 336 | debug("DTB is not passed via %p\n", fdt_blob); |
| 337 | } |
Michal Simek | fc274a5 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 338 | |
Michal Simek | 506009f | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 339 | if (IS_ENABLED(CONFIG_SPL_BUILD)) { |
| 340 | /* |
| 341 | * FDT is at end of BSS unless it is in a different memory |
| 342 | * region |
| 343 | */ |
| 344 | if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS)) |
| 345 | fdt_blob = (ulong *)&_image_binary_end; |
| 346 | else |
| 347 | fdt_blob = (ulong *)&__bss_end; |
| 348 | } else { |
| 349 | /* FDT is at end of image */ |
| 350 | fdt_blob = (ulong *)&_end; |
| 351 | } |
Michal Simek | fc274a5 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 352 | |
| 353 | if (fdt_magic(fdt_blob) == FDT_MAGIC) |
| 354 | return fdt_blob; |
| 355 | |
| 356 | debug("DTB is also not passed via %p\n", fdt_blob); |
| 357 | |
| 358 | return NULL; |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 359 | } |
| 360 | #endif |
Michal Simek | 80fdef1 | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 361 | |
Michal Simek | 7c553ac | 2020-10-22 11:14:20 +0200 | [diff] [blame] | 362 | #if defined(CONFIG_BOARD_LATE_INIT) |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 363 | static int env_set_by_index(const char *name, int index, char *data) |
| 364 | { |
| 365 | char var[32]; |
| 366 | |
| 367 | if (!index) |
| 368 | sprintf(var, "board_%s", name); |
| 369 | else |
| 370 | sprintf(var, "card%d_%s", index, name); |
| 371 | |
| 372 | return env_set(var, data); |
| 373 | } |
| 374 | |
Michal Simek | 80fdef1 | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 375 | int board_late_init_xilinx(void) |
| 376 | { |
Michal Simek | ca0f616 | 2020-08-12 12:16:49 +0200 | [diff] [blame] | 377 | u32 ret = 0; |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 378 | int i, id, macid = 0; |
| 379 | struct xilinx_board_description *desc; |
Michal Simek | 2570cc6 | 2020-08-12 12:17:53 +0200 | [diff] [blame] | 380 | phys_size_t bootm_size = gd->ram_size; |
T Karthik Reddy | d388ced | 2020-04-01 06:01:21 -0600 | [diff] [blame] | 381 | |
T Karthik Reddy | 25484d9 | 2021-04-02 01:49:17 -0600 | [diff] [blame^] | 382 | if (!CONFIG_IS_ENABLED(MICROBLAZE)) { |
T Karthik Reddy | d388ced | 2020-04-01 06:01:21 -0600 | [diff] [blame] | 383 | ulong scriptaddr; |
| 384 | |
| 385 | scriptaddr = env_get_hex("scriptaddr", 0); |
T Karthik Reddy | 25484d9 | 2021-04-02 01:49:17 -0600 | [diff] [blame^] | 386 | ret |= env_set_hex("scriptaddr", gd->ram_base + scriptaddr); |
T Karthik Reddy | d388ced | 2020-04-01 06:01:21 -0600 | [diff] [blame] | 387 | } |
Michal Simek | 2570cc6 | 2020-08-12 12:17:53 +0200 | [diff] [blame] | 388 | |
Michal Simek | 1230582 | 2020-10-23 07:54:18 +0200 | [diff] [blame] | 389 | if (CONFIG_IS_ENABLED(ARCH_ZYNQ) || CONFIG_IS_ENABLED(MICROBLAZE)) |
Michal Simek | 2570cc6 | 2020-08-12 12:17:53 +0200 | [diff] [blame] | 390 | bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M)); |
Michal Simek | 80fdef1 | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 391 | |
Michal Simek | ca0f616 | 2020-08-12 12:16:49 +0200 | [diff] [blame] | 392 | ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET); |
| 393 | |
| 394 | ret |= env_set_addr("bootm_low", (void *)gd->ram_base); |
Michal Simek | 2570cc6 | 2020-08-12 12:17:53 +0200 | [diff] [blame] | 395 | ret |= env_set_addr("bootm_size", (void *)bootm_size); |
Michal Simek | ca0f616 | 2020-08-12 12:16:49 +0200 | [diff] [blame] | 396 | |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 397 | for (id = 0; id <= highest_id; id++) { |
| 398 | desc = board_info[id]; |
| 399 | if (desc && desc->header == EEPROM_HEADER_MAGIC) { |
| 400 | if (desc->manufacturer[0]) |
| 401 | ret |= env_set_by_index("manufacturer", id, |
| 402 | desc->manufacturer); |
| 403 | if (desc->name[0]) |
| 404 | ret |= env_set_by_index("name", id, |
| 405 | desc->name); |
| 406 | if (desc->revision[0]) |
| 407 | ret |= env_set_by_index("rev", id, |
| 408 | desc->revision); |
| 409 | if (desc->serial[0]) |
| 410 | ret |= env_set_by_index("serial", id, |
| 411 | desc->serial); |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 412 | |
| 413 | if (!CONFIG_IS_ENABLED(NET)) |
| 414 | continue; |
| 415 | |
Michal Simek | a03b594 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 416 | for (i = 0; i < EEPROM_HDR_NO_OF_MAC_ADDR; i++) { |
| 417 | if (!desc->mac_addr[i]) |
| 418 | continue; |
| 419 | |
| 420 | if (is_valid_ethaddr((const u8 *)desc->mac_addr[i])) |
| 421 | ret |= eth_env_set_enetaddr_by_index("eth", |
| 422 | macid++, desc->mac_addr[i]); |
| 423 | } |
Michal Simek | d61728c | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | |
Michal Simek | ca0f616 | 2020-08-12 12:16:49 +0200 | [diff] [blame] | 427 | if (ret) |
| 428 | printf("%s: Saving run time variables FAILED\n", __func__); |
Michal Simek | c8da651 | 2020-07-09 15:57:56 +0200 | [diff] [blame] | 429 | |
Michal Simek | 80fdef1 | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 430 | return 0; |
| 431 | } |
Michal Simek | 7c553ac | 2020-10-22 11:14:20 +0200 | [diff] [blame] | 432 | #endif |
Michal Simek | 05af483 | 2020-10-26 12:26:13 +0100 | [diff] [blame] | 433 | |
| 434 | int __maybe_unused board_fit_config_name_match(const char *name) |
| 435 | { |
| 436 | debug("%s: Check %s, default %s\n", __func__, name, DEVICE_TREE); |
| 437 | |
| 438 | if (!strcmp(name, DEVICE_TREE)) |
| 439 | return 0; |
| 440 | |
| 441 | return -1; |
| 442 | } |