Michal Simek | 014d304 | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Michal Simek | 53f4436 | 2023-01-06 09:38:52 +0100 | [diff] [blame] | 3 | * (C) Copyright 2014 - 2022, Xilinx, Inc. |
| 4 | * (C) Copyright 2022 - 2023, Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * Michal Simek <michal.simek@amd.com> |
Michal Simek | 014d304 | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Sughosh Ganu | ccb3646 | 2022-04-15 11:29:34 +0530 | [diff] [blame] | 10 | #include <efi.h> |
| 11 | #include <efi_loader.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 12 | #include <env.h> |
Michal Simek | aa97561 | 2022-08-25 14:23:10 +0200 | [diff] [blame] | 13 | #include <image.h> |
Algapally Santosh Sagar | d1c1b1e | 2023-01-19 22:36:14 -0700 | [diff] [blame] | 14 | #include <init.h> |
Michal Simek | aa97561 | 2022-08-25 14:23:10 +0200 | [diff] [blame] | 15 | #include <lmb.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 16 | #include <log.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 17 | #include <asm/global_data.h> |
Michal Simek | 878ba36 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 18 | #include <asm/sections.h> |
Michal Simek | 014d304 | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 19 | #include <dm/uclass.h> |
| 20 | #include <i2c.h> |
Michal Simek | b90b97e | 2020-04-08 10:51:36 +0200 | [diff] [blame] | 21 | #include <linux/sizes.h> |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 22 | #include <malloc.h> |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 23 | #include "board.h" |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 24 | #include <dm.h> |
| 25 | #include <i2c_eeprom.h> |
| 26 | #include <net.h> |
Michal Simek | fe49df9 | 2020-10-26 12:26:13 +0100 | [diff] [blame] | 27 | #include <generated/dt.h> |
Michal Simek | 53f4436 | 2023-01-06 09:38:52 +0100 | [diff] [blame] | 28 | #include <slre.h> |
T Karthik Reddy | c8fa40a | 2021-08-10 06:50:20 -0600 | [diff] [blame] | 29 | #include <soc.h> |
Michal Simek | e045351 | 2021-08-11 14:23:54 +0200 | [diff] [blame] | 30 | #include <linux/ctype.h> |
Sughosh Ganu | ccb3646 | 2022-04-15 11:29:34 +0530 | [diff] [blame] | 31 | #include <linux/kernel.h> |
Michal Simek | 7459d4a | 2022-07-21 16:19:17 +0200 | [diff] [blame] | 32 | #include <uuid.h> |
Michal Simek | 014d304 | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 33 | |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 34 | #include "fru.h" |
| 35 | |
Simon Glass | b819621 | 2023-02-05 15:39:42 -0700 | [diff] [blame] | 36 | #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) |
Sughosh Ganu | ccb3646 | 2022-04-15 11:29:34 +0530 | [diff] [blame] | 37 | struct efi_fw_image fw_images[] = { |
| 38 | #if defined(XILINX_BOOT_IMAGE_GUID) |
| 39 | { |
| 40 | .image_type_id = XILINX_BOOT_IMAGE_GUID, |
| 41 | .fw_name = u"XILINX-BOOT", |
| 42 | .image_index = 1, |
| 43 | }, |
| 44 | #endif |
| 45 | #if defined(XILINX_UBOOT_IMAGE_GUID) |
| 46 | { |
| 47 | .image_type_id = XILINX_UBOOT_IMAGE_GUID, |
| 48 | .fw_name = u"XILINX-UBOOT", |
| 49 | .image_index = 2, |
| 50 | }, |
| 51 | #endif |
| 52 | }; |
| 53 | |
| 54 | struct efi_capsule_update_info update_info = { |
Masahisa Kojima | 5d2438b | 2023-06-07 14:41:51 +0900 | [diff] [blame] | 55 | .num_images = ARRAY_SIZE(fw_images), |
Sughosh Ganu | ccb3646 | 2022-04-15 11:29:34 +0530 | [diff] [blame] | 56 | .images = fw_images, |
| 57 | }; |
| 58 | |
Sughosh Ganu | ccb3646 | 2022-04-15 11:29:34 +0530 | [diff] [blame] | 59 | #endif /* EFI_HAVE_CAPSULE_SUPPORT */ |
| 60 | |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 61 | #define EEPROM_HEADER_MAGIC 0xdaaddeed |
| 62 | #define EEPROM_HDR_MANUFACTURER_LEN 16 |
| 63 | #define EEPROM_HDR_NAME_LEN 16 |
| 64 | #define EEPROM_HDR_REV_LEN 8 |
| 65 | #define EEPROM_HDR_SERIAL_LEN 20 |
| 66 | #define EEPROM_HDR_NO_OF_MAC_ADDR 4 |
| 67 | #define EEPROM_HDR_ETH_ALEN ETH_ALEN |
Michal Simek | 7459d4a | 2022-07-21 16:19:17 +0200 | [diff] [blame] | 68 | #define EEPROM_HDR_UUID_LEN 16 |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 69 | |
| 70 | struct xilinx_board_description { |
| 71 | u32 header; |
| 72 | char manufacturer[EEPROM_HDR_MANUFACTURER_LEN + 1]; |
| 73 | char name[EEPROM_HDR_NAME_LEN + 1]; |
| 74 | char revision[EEPROM_HDR_REV_LEN + 1]; |
| 75 | char serial[EEPROM_HDR_SERIAL_LEN + 1]; |
| 76 | u8 mac_addr[EEPROM_HDR_NO_OF_MAC_ADDR][EEPROM_HDR_ETH_ALEN + 1]; |
Michal Simek | 7459d4a | 2022-07-21 16:19:17 +0200 | [diff] [blame] | 77 | char uuid[EEPROM_HDR_UUID_LEN + 1]; |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 78 | }; |
| 79 | |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 80 | static int highest_id = -1; |
Michal Simek | e98ae1d | 2021-08-12 12:30:36 +0200 | [diff] [blame] | 81 | static struct xilinx_board_description *board_info; |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 82 | |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 83 | #define XILINX_I2C_DETECTION_BITS sizeof(struct fru_common_hdr) |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 84 | |
| 85 | /* Variable which stores pointer to array which stores eeprom content */ |
| 86 | struct xilinx_legacy_format { |
| 87 | char board_sn[18]; /* 0x0 */ |
| 88 | char unused0[14]; /* 0x12 */ |
Michal Simek | b2df1df | 2023-01-24 16:19:26 +0100 | [diff] [blame] | 89 | char eth_mac[ETH_ALEN]; /* 0x20 */ |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 90 | char unused1[170]; /* 0x26 */ |
| 91 | char board_name[11]; /* 0xd0 */ |
| 92 | char unused2[5]; /* 0xdc */ |
| 93 | char board_revision[3]; /* 0xe0 */ |
| 94 | char unused3[29]; /* 0xe3 */ |
| 95 | }; |
| 96 | |
| 97 | static void xilinx_eeprom_legacy_cleanup(char *eeprom, int size) |
| 98 | { |
| 99 | int i; |
Venkatesh Yadav Abbarapu | 3be370d | 2022-09-26 12:22:42 +0530 | [diff] [blame] | 100 | unsigned char byte; |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 101 | |
| 102 | for (i = 0; i < size; i++) { |
| 103 | byte = eeprom[i]; |
| 104 | |
Michal Simek | d432cbb | 2023-01-24 16:19:27 +0100 | [diff] [blame] | 105 | /* Remove all non printable chars but ignore MAC address */ |
| 106 | if ((i < offsetof(struct xilinx_legacy_format, eth_mac) || |
| 107 | i >= offsetof(struct xilinx_legacy_format, unused1)) && |
| 108 | (byte < '!' || byte > '~')) { |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 109 | eeprom[i] = 0; |
Michal Simek | d432cbb | 2023-01-24 16:19:27 +0100 | [diff] [blame] | 110 | continue; |
| 111 | } |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 112 | |
| 113 | /* Convert strings to lower case */ |
| 114 | if (byte >= 'A' && byte <= 'Z') |
| 115 | eeprom[i] = byte + 'a' - 'A'; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | static int xilinx_read_eeprom_legacy(struct udevice *dev, char *name, |
| 120 | struct xilinx_board_description *desc) |
| 121 | { |
| 122 | int ret, size; |
| 123 | struct xilinx_legacy_format *eeprom_content; |
| 124 | bool eth_valid = false; |
| 125 | |
| 126 | size = sizeof(*eeprom_content); |
| 127 | |
| 128 | eeprom_content = calloc(1, size); |
| 129 | if (!eeprom_content) |
| 130 | return -ENOMEM; |
| 131 | |
| 132 | debug("%s: I2C EEPROM read pass data at %p\n", __func__, |
| 133 | eeprom_content); |
| 134 | |
| 135 | ret = dm_i2c_read(dev, 0, (uchar *)eeprom_content, size); |
| 136 | if (ret) { |
| 137 | debug("%s: I2C EEPROM read failed\n", __func__); |
| 138 | free(eeprom_content); |
| 139 | return ret; |
| 140 | } |
| 141 | |
| 142 | xilinx_eeprom_legacy_cleanup((char *)eeprom_content, size); |
| 143 | |
Michal Simek | daccab2 | 2023-01-24 16:19:28 +0100 | [diff] [blame] | 144 | /* Terminating \0 chars are the part of desc fields already */ |
| 145 | strlcpy(desc->name, eeprom_content->board_name, |
| 146 | sizeof(eeprom_content->board_name) + 1); |
| 147 | strlcpy(desc->revision, eeprom_content->board_revision, |
| 148 | sizeof(eeprom_content->board_revision) + 1); |
| 149 | strlcpy(desc->serial, eeprom_content->board_sn, |
| 150 | sizeof(eeprom_content->board_sn) + 1); |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 151 | |
| 152 | eth_valid = is_valid_ethaddr((const u8 *)eeprom_content->eth_mac); |
| 153 | if (eth_valid) |
Michal Simek | daccab2 | 2023-01-24 16:19:28 +0100 | [diff] [blame] | 154 | memcpy(desc->mac_addr[0], eeprom_content->eth_mac, ETH_ALEN); |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 155 | |
Michal Simek | daccab2 | 2023-01-24 16:19:28 +0100 | [diff] [blame] | 156 | printf("Xilinx I2C Legacy format at %s:\n", name); |
| 157 | printf(" Board name:\t%s\n", desc->name); |
| 158 | printf(" Board rev:\t%s\n", desc->revision); |
| 159 | printf(" Board SN:\t%s\n", desc->serial); |
| 160 | |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 161 | if (eth_valid) |
Michal Simek | daccab2 | 2023-01-24 16:19:28 +0100 | [diff] [blame] | 162 | printf(" Ethernet mac:\t%pM\n", desc->mac_addr); |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 163 | |
| 164 | desc->header = EEPROM_HEADER_MAGIC; |
| 165 | |
| 166 | free(eeprom_content); |
| 167 | |
| 168 | return ret; |
| 169 | } |
| 170 | |
| 171 | static bool xilinx_detect_legacy(u8 *buffer) |
| 172 | { |
| 173 | int i; |
| 174 | char c; |
| 175 | |
| 176 | for (i = 0; i < XILINX_I2C_DETECTION_BITS; i++) { |
| 177 | c = buffer[i]; |
| 178 | |
| 179 | if (c < '0' || c > '9') |
| 180 | return false; |
| 181 | } |
| 182 | |
| 183 | return true; |
| 184 | } |
| 185 | |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 186 | static int xilinx_read_eeprom_fru(struct udevice *dev, char *name, |
| 187 | struct xilinx_board_description *desc) |
| 188 | { |
Michal Simek | be5f572 | 2021-08-12 11:03:49 +0200 | [diff] [blame] | 189 | int i, ret, eeprom_size; |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 190 | u8 *fru_content; |
Ashok Reddy Soma | 9f60e44 | 2022-02-23 15:00:59 +0100 | [diff] [blame] | 191 | u8 id = 0; |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 192 | |
| 193 | /* FIXME this is shortcut - if eeprom type is wrong it will fail */ |
| 194 | eeprom_size = i2c_eeprom_size(dev); |
| 195 | |
| 196 | fru_content = calloc(1, eeprom_size); |
| 197 | if (!fru_content) |
| 198 | return -ENOMEM; |
| 199 | |
| 200 | debug("%s: I2C EEPROM read pass data at %p\n", __func__, |
| 201 | fru_content); |
| 202 | |
| 203 | ret = dm_i2c_read(dev, 0, (uchar *)fru_content, |
| 204 | eeprom_size); |
| 205 | if (ret) { |
| 206 | debug("%s: I2C EEPROM read failed\n", __func__); |
Michal Simek | aada8a6 | 2021-08-13 09:17:10 +0200 | [diff] [blame] | 207 | goto end; |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 208 | } |
| 209 | |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 210 | fru_capture((unsigned long)fru_content); |
Simon Glass | d2c5a3d | 2023-02-05 15:39:38 -0700 | [diff] [blame] | 211 | if (gd->flags & GD_FLG_RELOC || (_DEBUG && IS_ENABLED(CONFIG_DTB_RESELECT))) { |
Michal Simek | e045351 | 2021-08-11 14:23:54 +0200 | [diff] [blame] | 212 | printf("Xilinx I2C FRU format at %s:\n", name); |
| 213 | ret = fru_display(0); |
| 214 | if (ret) { |
| 215 | printf("FRU format decoding failed.\n"); |
| 216 | goto end; |
| 217 | } |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | if (desc->header == EEPROM_HEADER_MAGIC) { |
| 221 | debug("Information already filled\n"); |
Michal Simek | aada8a6 | 2021-08-13 09:17:10 +0200 | [diff] [blame] | 222 | ret = -EINVAL; |
| 223 | goto end; |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | /* It is clear that FRU was captured and structures were filled */ |
Michal Simek | b5f206e | 2022-07-21 16:19:18 +0200 | [diff] [blame] | 227 | strlcpy(desc->manufacturer, (char *)fru_data.brd.manufacturer_name, |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 228 | sizeof(desc->manufacturer)); |
Michal Simek | b5f206e | 2022-07-21 16:19:18 +0200 | [diff] [blame] | 229 | strlcpy(desc->uuid, (char *)fru_data.brd.uuid, |
Michal Simek | 7459d4a | 2022-07-21 16:19:17 +0200 | [diff] [blame] | 230 | sizeof(desc->uuid)); |
Michal Simek | b5f206e | 2022-07-21 16:19:18 +0200 | [diff] [blame] | 231 | strlcpy(desc->name, (char *)fru_data.brd.product_name, |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 232 | sizeof(desc->name)); |
Michal Simek | be5f572 | 2021-08-12 11:03:49 +0200 | [diff] [blame] | 233 | for (i = 0; i < sizeof(desc->name); i++) { |
| 234 | if (desc->name[i] == ' ') |
| 235 | desc->name[i] = '\0'; |
| 236 | } |
Michal Simek | b5f206e | 2022-07-21 16:19:18 +0200 | [diff] [blame] | 237 | strlcpy(desc->revision, (char *)fru_data.brd.rev, |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 238 | sizeof(desc->revision)); |
Michal Simek | 904fb97 | 2022-06-06 09:31:27 +0200 | [diff] [blame] | 239 | for (i = 0; i < sizeof(desc->revision); i++) { |
| 240 | if (desc->revision[i] == ' ') |
| 241 | desc->revision[i] = '\0'; |
| 242 | } |
Michal Simek | b5f206e | 2022-07-21 16:19:18 +0200 | [diff] [blame] | 243 | strlcpy(desc->serial, (char *)fru_data.brd.serial_number, |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 244 | sizeof(desc->serial)); |
Ashok Reddy Soma | 9f60e44 | 2022-02-23 15:00:59 +0100 | [diff] [blame] | 245 | |
| 246 | while (id < EEPROM_HDR_NO_OF_MAC_ADDR) { |
| 247 | if (is_valid_ethaddr((const u8 *)fru_data.mac.macid[id])) |
| 248 | memcpy(&desc->mac_addr[id], |
| 249 | (char *)fru_data.mac.macid[id], ETH_ALEN); |
| 250 | id++; |
| 251 | } |
| 252 | |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 253 | desc->header = EEPROM_HEADER_MAGIC; |
| 254 | |
Michal Simek | aada8a6 | 2021-08-13 09:17:10 +0200 | [diff] [blame] | 255 | end: |
| 256 | free(fru_content); |
| 257 | return ret; |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | static bool xilinx_detect_fru(u8 *buffer) |
| 261 | { |
| 262 | u8 checksum = 0; |
| 263 | int i; |
| 264 | |
| 265 | checksum = fru_checksum((u8 *)buffer, sizeof(struct fru_common_hdr)); |
| 266 | if (checksum) { |
| 267 | debug("%s Common header CRC FAIL\n", __func__); |
| 268 | return false; |
| 269 | } |
| 270 | |
| 271 | bool all_zeros = true; |
| 272 | /* Checksum over all zeros is also zero that's why detect this case */ |
| 273 | for (i = 0; i < sizeof(struct fru_common_hdr); i++) { |
| 274 | if (buffer[i] != 0) |
| 275 | all_zeros = false; |
| 276 | } |
| 277 | |
| 278 | if (all_zeros) |
| 279 | return false; |
| 280 | |
| 281 | debug("%s Common header CRC PASS\n", __func__); |
| 282 | return true; |
| 283 | } |
| 284 | |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 285 | static int xilinx_read_eeprom_single(char *name, |
| 286 | struct xilinx_board_description *desc) |
| 287 | { |
| 288 | int ret; |
| 289 | struct udevice *dev; |
| 290 | ofnode eeprom; |
| 291 | u8 buffer[XILINX_I2C_DETECTION_BITS]; |
| 292 | |
| 293 | eeprom = ofnode_get_aliases_node(name); |
| 294 | if (!ofnode_valid(eeprom)) |
| 295 | return -ENODEV; |
| 296 | |
| 297 | ret = uclass_get_device_by_ofnode(UCLASS_I2C_EEPROM, eeprom, &dev); |
| 298 | if (ret) |
| 299 | return ret; |
| 300 | |
| 301 | ret = dm_i2c_read(dev, 0, buffer, sizeof(buffer)); |
| 302 | if (ret) { |
| 303 | debug("%s: I2C EEPROM read failed\n", __func__); |
| 304 | return ret; |
| 305 | } |
| 306 | |
| 307 | debug("%s: i2c memory detected: %s\n", __func__, name); |
| 308 | |
Simon Glass | 631bec2 | 2023-02-05 15:36:31 -0700 | [diff] [blame] | 309 | if (IS_ENABLED(CONFIG_CMD_FRU) && xilinx_detect_fru(buffer)) |
Michal Simek | 207e062 | 2020-08-03 16:14:23 +0200 | [diff] [blame] | 310 | return xilinx_read_eeprom_fru(dev, name, desc); |
| 311 | |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 312 | if (xilinx_detect_legacy(buffer)) |
| 313 | return xilinx_read_eeprom_legacy(dev, name, desc); |
| 314 | |
| 315 | return -ENODEV; |
| 316 | } |
| 317 | |
| 318 | __maybe_unused int xilinx_read_eeprom(void) |
| 319 | { |
Michal Simek | e98ae1d | 2021-08-12 12:30:36 +0200 | [diff] [blame] | 320 | int id; |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 321 | char name_buf[8]; /* 8 bytes should be enough for nvmem+number */ |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 322 | struct xilinx_board_description *desc; |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 323 | |
| 324 | highest_id = dev_read_alias_highest_id("nvmem"); |
| 325 | /* No nvmem aliases present */ |
| 326 | if (highest_id < 0) |
| 327 | return -EINVAL; |
| 328 | |
Michal Simek | e98ae1d | 2021-08-12 12:30:36 +0200 | [diff] [blame] | 329 | board_info = calloc(1, sizeof(*desc) * (highest_id + 1)); |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 330 | if (!board_info) |
| 331 | return -ENOMEM; |
| 332 | |
| 333 | debug("%s: Highest ID %d, board_info %p\n", __func__, |
| 334 | highest_id, board_info); |
| 335 | |
| 336 | for (id = 0; id <= highest_id; id++) { |
| 337 | snprintf(name_buf, sizeof(name_buf), "nvmem%d", id); |
| 338 | |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 339 | /* Alloc structure */ |
Michal Simek | e98ae1d | 2021-08-12 12:30:36 +0200 | [diff] [blame] | 340 | desc = &board_info[id]; |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 341 | |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 342 | /* Ignoring return value for supporting multiple chips */ |
Michal Simek | e98ae1d | 2021-08-12 12:30:36 +0200 | [diff] [blame] | 343 | xilinx_read_eeprom_single(name_buf, desc); |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 344 | } |
| 345 | |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 346 | /* |
| 347 | * Consider to clean board_info structure when board/cards are not |
| 348 | * detected. |
| 349 | */ |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 350 | |
| 351 | return 0; |
| 352 | } |
| 353 | |
Michal Simek | 1a50529 | 2022-02-17 14:28:38 +0100 | [diff] [blame] | 354 | #if defined(CONFIG_OF_BOARD) |
Ilias Apalodimas | ab5348a | 2021-10-26 09:12:33 +0300 | [diff] [blame] | 355 | void *board_fdt_blob_setup(int *err) |
Ibai Erkiaga | 6f65820 | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 356 | { |
Michal Simek | ddf69ae | 2020-09-04 16:21:47 +0200 | [diff] [blame] | 357 | void *fdt_blob; |
Michal Simek | c89f429 | 2020-03-19 10:23:56 +0100 | [diff] [blame] | 358 | |
Ilias Apalodimas | ab5348a | 2021-10-26 09:12:33 +0300 | [diff] [blame] | 359 | *err = 0; |
Michal Simek | 663c162 | 2021-01-04 11:07:28 +0100 | [diff] [blame] | 360 | if (!IS_ENABLED(CONFIG_SPL_BUILD) && |
| 361 | !IS_ENABLED(CONFIG_VERSAL_NO_DDR) && |
Michal Simek | 6d4317b | 2021-02-02 13:33:22 +0100 | [diff] [blame] | 362 | !IS_ENABLED(CONFIG_ZYNQMP_NO_DDR)) { |
Michal Simek | 9b9d01e | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 363 | fdt_blob = (void *)CONFIG_XILINX_OF_BOARD_DTB_ADDR; |
Ibai Erkiaga | 6f65820 | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 364 | |
Michal Simek | 9b9d01e | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 365 | if (fdt_magic(fdt_blob) == FDT_MAGIC) |
| 366 | return fdt_blob; |
Michal Simek | 878ba36 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 367 | |
Michal Simek | 9b9d01e | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 368 | debug("DTB is not passed via %p\n", fdt_blob); |
| 369 | } |
Michal Simek | 878ba36 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 370 | |
Michal Simek | 9b9d01e | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 371 | if (IS_ENABLED(CONFIG_SPL_BUILD)) { |
| 372 | /* |
| 373 | * FDT is at end of BSS unless it is in a different memory |
| 374 | * region |
| 375 | */ |
| 376 | if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS)) |
Shiji Yang | eff11fa | 2023-08-03 09:47:17 +0800 | [diff] [blame] | 377 | fdt_blob = (ulong *)_image_binary_end; |
Michal Simek | 9b9d01e | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 378 | else |
Shiji Yang | eff11fa | 2023-08-03 09:47:17 +0800 | [diff] [blame] | 379 | fdt_blob = (ulong *)__bss_end; |
Michal Simek | 9b9d01e | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 380 | } else { |
| 381 | /* FDT is at end of image */ |
Shiji Yang | eff11fa | 2023-08-03 09:47:17 +0800 | [diff] [blame] | 382 | fdt_blob = (ulong *)_end; |
Michal Simek | 9b9d01e | 2021-01-04 11:03:36 +0100 | [diff] [blame] | 383 | } |
Michal Simek | 878ba36 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 384 | |
| 385 | if (fdt_magic(fdt_blob) == FDT_MAGIC) |
| 386 | return fdt_blob; |
| 387 | |
| 388 | debug("DTB is also not passed via %p\n", fdt_blob); |
Ibai Erkiaga | 6f65820 | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 389 | |
Michal Simek | 1a50529 | 2022-02-17 14:28:38 +0100 | [diff] [blame] | 390 | *err = -EINVAL; |
Michal Simek | 878ba36 | 2019-12-19 17:45:15 +0100 | [diff] [blame] | 391 | return NULL; |
Ibai Erkiaga | 6f65820 | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 392 | } |
| 393 | #endif |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 394 | |
Michal Simek | 67ed85d | 2020-10-22 11:14:20 +0200 | [diff] [blame] | 395 | #if defined(CONFIG_BOARD_LATE_INIT) |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 396 | static int env_set_by_index(const char *name, int index, char *data) |
| 397 | { |
| 398 | char var[32]; |
| 399 | |
| 400 | if (!index) |
| 401 | sprintf(var, "board_%s", name); |
| 402 | else |
| 403 | sprintf(var, "card%d_%s", index, name); |
| 404 | |
| 405 | return env_set(var, data); |
| 406 | } |
| 407 | |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 408 | int board_late_init_xilinx(void) |
| 409 | { |
Michal Simek | bd07b5d | 2020-08-12 12:16:49 +0200 | [diff] [blame] | 410 | u32 ret = 0; |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 411 | int i, id, macid = 0; |
| 412 | struct xilinx_board_description *desc; |
Ricardo Salveti | d35ccf2 | 2022-01-20 16:17:30 -0300 | [diff] [blame] | 413 | phys_size_t bootm_size = gd->ram_top - gd->ram_base; |
Michal Simek | bb70b77 | 2023-08-31 09:04:28 +0200 | [diff] [blame] | 414 | u64 bootscr_flash_offset, bootscr_flash_size; |
T Karthik Reddy | 17b7f66 | 2020-04-01 06:01:21 -0600 | [diff] [blame] | 415 | |
Simon Glass | 117038a | 2023-02-05 15:40:14 -0700 | [diff] [blame] | 416 | if (!IS_ENABLED(CONFIG_MICROBLAZE)) { |
T Karthik Reddy | 17b7f66 | 2020-04-01 06:01:21 -0600 | [diff] [blame] | 417 | ulong scriptaddr; |
Algapally Santosh Sagar | 473705e | 2023-08-31 08:59:06 +0200 | [diff] [blame] | 418 | u64 bootscr_address; |
| 419 | u64 bootscr_offset; |
T Karthik Reddy | 17b7f66 | 2020-04-01 06:01:21 -0600 | [diff] [blame] | 420 | |
Algapally Santosh Sagar | 473705e | 2023-08-31 08:59:06 +0200 | [diff] [blame] | 421 | /* Fetch bootscr_address/bootscr_offset from DT and update */ |
| 422 | if (!ofnode_read_bootscript_address(&bootscr_address, |
| 423 | &bootscr_offset)) { |
| 424 | if (bootscr_offset) |
| 425 | ret |= env_set_hex("scriptaddr", |
| 426 | gd->ram_base + |
| 427 | bootscr_offset); |
| 428 | else |
| 429 | ret |= env_set_hex("scriptaddr", |
| 430 | bootscr_address); |
| 431 | } else { |
| 432 | /* Update scriptaddr(bootscr offset) from env */ |
| 433 | scriptaddr = env_get_hex("scriptaddr", 0); |
| 434 | ret |= env_set_hex("scriptaddr", |
| 435 | gd->ram_base + scriptaddr); |
| 436 | } |
T Karthik Reddy | 17b7f66 | 2020-04-01 06:01:21 -0600 | [diff] [blame] | 437 | } |
Michal Simek | c86ce0c | 2020-08-12 12:17:53 +0200 | [diff] [blame] | 438 | |
Michal Simek | bb70b77 | 2023-08-31 09:04:28 +0200 | [diff] [blame] | 439 | if (!ofnode_read_bootscript_flash(&bootscr_flash_offset, |
| 440 | &bootscr_flash_size)) { |
| 441 | ret |= env_set_hex("script_offset_f", bootscr_flash_offset); |
| 442 | ret |= env_set_hex("script_size_f", bootscr_flash_size); |
| 443 | } else { |
| 444 | debug("!!! Please define bootscr-flash-offset via DT !!!\n"); |
| 445 | ret |= env_set_hex("script_offset_f", |
| 446 | CONFIG_BOOT_SCRIPT_OFFSET); |
| 447 | } |
| 448 | |
Simon Glass | 117038a | 2023-02-05 15:40:14 -0700 | [diff] [blame] | 449 | if (IS_ENABLED(CONFIG_ARCH_ZYNQ) || IS_ENABLED(CONFIG_MICROBLAZE)) |
Michal Simek | c86ce0c | 2020-08-12 12:17:53 +0200 | [diff] [blame] | 450 | bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M)); |
Michal Simek | bd07b5d | 2020-08-12 12:16:49 +0200 | [diff] [blame] | 451 | |
Michal Simek | bd07b5d | 2020-08-12 12:16:49 +0200 | [diff] [blame] | 452 | ret |= env_set_addr("bootm_low", (void *)gd->ram_base); |
Michal Simek | c86ce0c | 2020-08-12 12:17:53 +0200 | [diff] [blame] | 453 | ret |= env_set_addr("bootm_size", (void *)bootm_size); |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 454 | |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 455 | for (id = 0; id <= highest_id; id++) { |
Michal Simek | e98ae1d | 2021-08-12 12:30:36 +0200 | [diff] [blame] | 456 | desc = &board_info[id]; |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 457 | if (desc && desc->header == EEPROM_HEADER_MAGIC) { |
| 458 | if (desc->manufacturer[0]) |
| 459 | ret |= env_set_by_index("manufacturer", id, |
| 460 | desc->manufacturer); |
| 461 | if (desc->name[0]) |
| 462 | ret |= env_set_by_index("name", id, |
| 463 | desc->name); |
| 464 | if (desc->revision[0]) |
| 465 | ret |= env_set_by_index("rev", id, |
| 466 | desc->revision); |
| 467 | if (desc->serial[0]) |
| 468 | ret |= env_set_by_index("serial", id, |
| 469 | desc->serial); |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 470 | |
Michal Simek | 7459d4a | 2022-07-21 16:19:17 +0200 | [diff] [blame] | 471 | if (desc->uuid[0]) { |
Venkatesh Yadav Abbarapu | 3be370d | 2022-09-26 12:22:42 +0530 | [diff] [blame] | 472 | unsigned char uuid[UUID_STR_LEN + 1]; |
| 473 | unsigned char *t = desc->uuid; |
Michal Simek | 7459d4a | 2022-07-21 16:19:17 +0200 | [diff] [blame] | 474 | |
| 475 | memset(uuid, 0, UUID_STR_LEN + 1); |
| 476 | |
| 477 | sprintf(uuid, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", |
| 478 | t[0], t[1], t[2], t[3], t[4], t[5], |
| 479 | t[6], t[7], t[8], t[9], t[10], t[11], |
| 480 | t[12], t[13], t[14], t[15]); |
| 481 | ret |= env_set_by_index("uuid", id, uuid); |
| 482 | } |
| 483 | |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 484 | if (!CONFIG_IS_ENABLED(NET)) |
| 485 | continue; |
| 486 | |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 487 | for (i = 0; i < EEPROM_HDR_NO_OF_MAC_ADDR; i++) { |
Michal Simek | 0bb24e1 | 2020-08-03 12:57:05 +0200 | [diff] [blame] | 488 | if (is_valid_ethaddr((const u8 *)desc->mac_addr[i])) |
| 489 | ret |= eth_env_set_enetaddr_by_index("eth", |
| 490 | macid++, desc->mac_addr[i]); |
| 491 | } |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 492 | } |
| 493 | } |
| 494 | |
Michal Simek | bd07b5d | 2020-08-12 12:16:49 +0200 | [diff] [blame] | 495 | if (ret) |
| 496 | printf("%s: Saving run time variables FAILED\n", __func__); |
Michal Simek | 8ba62d2 | 2020-07-09 15:57:56 +0200 | [diff] [blame] | 497 | |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 498 | return 0; |
| 499 | } |
Michal Simek | 67ed85d | 2020-10-22 11:14:20 +0200 | [diff] [blame] | 500 | #endif |
Michal Simek | fe49df9 | 2020-10-26 12:26:13 +0100 | [diff] [blame] | 501 | |
Michal Simek | c88975e | 2021-07-23 09:55:59 +0200 | [diff] [blame] | 502 | static char *board_name = DEVICE_TREE; |
| 503 | |
Michal Simek | fe49df9 | 2020-10-26 12:26:13 +0100 | [diff] [blame] | 504 | int __maybe_unused board_fit_config_name_match(const char *name) |
| 505 | { |
Michal Simek | c88975e | 2021-07-23 09:55:59 +0200 | [diff] [blame] | 506 | debug("%s: Check %s, default %s\n", __func__, name, board_name); |
Michal Simek | fe49df9 | 2020-10-26 12:26:13 +0100 | [diff] [blame] | 507 | |
Michal Simek | 53f4436 | 2023-01-06 09:38:52 +0100 | [diff] [blame] | 508 | #if !defined(CONFIG_SPL_BUILD) |
Simon Glass | f34ccae | 2023-02-05 15:40:37 -0700 | [diff] [blame] | 509 | if (IS_ENABLED(CONFIG_REGEX)) { |
Michal Simek | 53f4436 | 2023-01-06 09:38:52 +0100 | [diff] [blame] | 510 | struct slre slre; |
| 511 | int ret; |
| 512 | |
| 513 | ret = slre_compile(&slre, name); |
| 514 | if (ret) { |
| 515 | ret = slre_match(&slre, board_name, strlen(board_name), |
| 516 | NULL); |
| 517 | debug("%s: name match ret = %d\n", __func__, ret); |
| 518 | return !ret; |
| 519 | } |
| 520 | } |
| 521 | #endif |
| 522 | |
Michal Simek | c88975e | 2021-07-23 09:55:59 +0200 | [diff] [blame] | 523 | if (!strcmp(name, board_name)) |
Michal Simek | fe49df9 | 2020-10-26 12:26:13 +0100 | [diff] [blame] | 524 | return 0; |
| 525 | |
| 526 | return -1; |
| 527 | } |
T Karthik Reddy | c8fa40a | 2021-08-10 06:50:20 -0600 | [diff] [blame] | 528 | |
Simon Glass | d2c5a3d | 2023-02-05 15:39:38 -0700 | [diff] [blame] | 529 | #if IS_ENABLED(CONFIG_DTB_RESELECT) |
Michal Simek | e045351 | 2021-08-11 14:23:54 +0200 | [diff] [blame] | 530 | #define MAX_NAME_LENGTH 50 |
| 531 | |
Michal Simek | afb2857 | 2021-07-23 09:59:59 +0200 | [diff] [blame] | 532 | char * __maybe_unused __weak board_name_decode(void) |
| 533 | { |
Michal Simek | e045351 | 2021-08-11 14:23:54 +0200 | [diff] [blame] | 534 | char *board_local_name; |
| 535 | struct xilinx_board_description *desc; |
| 536 | int i, id; |
| 537 | |
| 538 | board_local_name = calloc(1, MAX_NAME_LENGTH); |
| 539 | if (!board_info) |
| 540 | return NULL; |
| 541 | |
| 542 | for (id = 0; id <= highest_id; id++) { |
| 543 | desc = &board_info[id]; |
| 544 | |
| 545 | /* No board description */ |
| 546 | if (!desc) |
| 547 | goto error; |
| 548 | |
| 549 | /* Board is not detected */ |
| 550 | if (desc->header != EEPROM_HEADER_MAGIC) |
| 551 | continue; |
| 552 | |
| 553 | /* The first string should be soc name */ |
| 554 | if (!id) |
| 555 | strcat(board_local_name, CONFIG_SYS_BOARD); |
| 556 | |
| 557 | /* |
| 558 | * For two purpose here: |
| 559 | * soc_name- eg: zynqmp- |
| 560 | * and between base board and CC eg: ..revA-sck... |
| 561 | */ |
| 562 | strcat(board_local_name, "-"); |
| 563 | |
| 564 | if (desc->name[0]) { |
| 565 | /* For DT composition name needs to be lowercase */ |
| 566 | for (i = 0; i < sizeof(desc->name); i++) |
| 567 | desc->name[i] = tolower(desc->name[i]); |
| 568 | |
| 569 | strcat(board_local_name, desc->name); |
| 570 | } |
| 571 | if (desc->revision[0]) { |
| 572 | strcat(board_local_name, "-rev"); |
| 573 | |
| 574 | /* And revision needs to be uppercase */ |
| 575 | for (i = 0; i < sizeof(desc->revision); i++) |
| 576 | desc->revision[i] = toupper(desc->revision[i]); |
| 577 | |
| 578 | strcat(board_local_name, desc->revision); |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | /* |
| 583 | * Longer strings will end up with buffer overflow and potential |
| 584 | * attacks that's why check it |
| 585 | */ |
| 586 | if (strlen(board_local_name) >= MAX_NAME_LENGTH) |
| 587 | panic("Board name can't be determined\n"); |
| 588 | |
| 589 | if (strlen(board_local_name)) |
| 590 | return board_local_name; |
| 591 | |
| 592 | error: |
| 593 | free(board_local_name); |
Michal Simek | afb2857 | 2021-07-23 09:59:59 +0200 | [diff] [blame] | 594 | return NULL; |
| 595 | } |
| 596 | |
| 597 | bool __maybe_unused __weak board_detection(void) |
| 598 | { |
Michal Simek | e045351 | 2021-08-11 14:23:54 +0200 | [diff] [blame] | 599 | if (CONFIG_IS_ENABLED(DM_I2C) && CONFIG_IS_ENABLED(I2C_EEPROM)) { |
| 600 | int ret; |
| 601 | |
| 602 | ret = xilinx_read_eeprom(); |
| 603 | return !ret ? true : false; |
| 604 | } |
| 605 | |
Michal Simek | afb2857 | 2021-07-23 09:59:59 +0200 | [diff] [blame] | 606 | return false; |
| 607 | } |
| 608 | |
Michal Simek | 4c8e4ee | 2022-09-06 12:40:41 +0200 | [diff] [blame] | 609 | bool __maybe_unused __weak soc_detection(void) |
| 610 | { |
| 611 | return false; |
| 612 | } |
| 613 | |
| 614 | char * __maybe_unused __weak soc_name_decode(void) |
| 615 | { |
| 616 | return NULL; |
| 617 | } |
| 618 | |
Michal Simek | afb2857 | 2021-07-23 09:59:59 +0200 | [diff] [blame] | 619 | int embedded_dtb_select(void) |
| 620 | { |
Michal Simek | 4c8e4ee | 2022-09-06 12:40:41 +0200 | [diff] [blame] | 621 | if (soc_detection()) { |
| 622 | char *soc_local_name; |
| 623 | |
| 624 | soc_local_name = soc_name_decode(); |
| 625 | if (soc_local_name) { |
| 626 | board_name = soc_local_name; |
| 627 | printf("Detected SOC name: %s\n", board_name); |
| 628 | |
| 629 | /* Time to change DTB on fly */ |
| 630 | /* Both ways should work here */ |
| 631 | /* fdtdec_resetup(&rescan); */ |
| 632 | return fdtdec_setup(); |
| 633 | } |
| 634 | } |
| 635 | |
Michal Simek | afb2857 | 2021-07-23 09:59:59 +0200 | [diff] [blame] | 636 | if (board_detection()) { |
| 637 | char *board_local_name; |
| 638 | |
| 639 | board_local_name = board_name_decode(); |
| 640 | if (board_local_name) { |
| 641 | board_name = board_local_name; |
Michal Simek | e045351 | 2021-08-11 14:23:54 +0200 | [diff] [blame] | 642 | printf("Detected name: %s\n", board_name); |
Michal Simek | afb2857 | 2021-07-23 09:59:59 +0200 | [diff] [blame] | 643 | |
| 644 | /* Time to change DTB on fly */ |
| 645 | /* Both ways should work here */ |
| 646 | /* fdtdec_resetup(&rescan); */ |
| 647 | fdtdec_setup(); |
| 648 | } |
| 649 | } |
| 650 | return 0; |
| 651 | } |
| 652 | #endif |
Michal Simek | aa97561 | 2022-08-25 14:23:10 +0200 | [diff] [blame] | 653 | |
| 654 | #if defined(CONFIG_LMB) |
Michal Simek | 962c10a | 2023-11-06 12:56:47 +0100 | [diff] [blame^] | 655 | |
| 656 | #ifndef MMU_SECTION_SIZE |
| 657 | #define MMU_SECTION_SIZE (1 * 1024 * 1024) |
| 658 | #endif |
| 659 | |
Heinrich Schuchardt | 51a9aac | 2023-08-12 20:16:58 +0200 | [diff] [blame] | 660 | phys_addr_t board_get_usable_ram_top(phys_size_t total_size) |
Michal Simek | aa97561 | 2022-08-25 14:23:10 +0200 | [diff] [blame] | 661 | { |
| 662 | phys_size_t size; |
| 663 | phys_addr_t reg; |
| 664 | struct lmb lmb; |
| 665 | |
| 666 | if (!total_size) |
| 667 | return gd->ram_top; |
| 668 | |
| 669 | if (!IS_ALIGNED((ulong)gd->fdt_blob, 0x8)) |
| 670 | panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob); |
| 671 | |
| 672 | /* found enough not-reserved memory to relocated U-Boot */ |
| 673 | lmb_init(&lmb); |
| 674 | lmb_add(&lmb, gd->ram_base, gd->ram_size); |
| 675 | boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob); |
| 676 | size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE); |
| 677 | reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE); |
| 678 | |
| 679 | if (!reg) |
| 680 | reg = gd->ram_top - size; |
| 681 | |
| 682 | return reg + size; |
| 683 | } |
| 684 | #endif |