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