Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Library to support early TI EVM EEPROM handling |
| 4 | * |
| 5 | * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/ |
| 6 | * Lokesh Vutla |
| 7 | * Steve Kipisz |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Simon Glass | eba6b8d | 2019-11-14 12:57:50 -0700 | [diff] [blame] | 11 | #include <eeprom.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 13 | #include <net.h> |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 14 | #include <asm/arch/hardware.h> |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 15 | #include <asm/omap_common.h> |
Cooper Jr., Franklin | f2598de | 2017-04-20 10:25:44 -0500 | [diff] [blame] | 16 | #include <dm/uclass.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 17 | #include <env.h> |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 18 | #include <i2c.h> |
Caleb Robey | 0dfcc93 | 2020-01-02 08:17:25 -0600 | [diff] [blame] | 19 | #include <mmc.h> |
| 20 | #include <errno.h> |
| 21 | #include <malloc.h> |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 22 | |
| 23 | #include "board_detect.h" |
| 24 | |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 25 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 26 | /** |
| 27 | * ti_i2c_eeprom_init - Initialize an i2c bus and probe for a device |
| 28 | * @i2c_bus: i2c bus number to initialize |
| 29 | * @dev_addr: Device address to probe for |
| 30 | * |
| 31 | * Return: 0 on success or corresponding error on failure. |
| 32 | */ |
| 33 | static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, int dev_addr) |
| 34 | { |
| 35 | int rc; |
| 36 | |
| 37 | if (i2c_bus >= 0) { |
| 38 | rc = i2c_set_bus_num(i2c_bus); |
| 39 | if (rc) |
| 40 | return rc; |
| 41 | } |
| 42 | |
| 43 | return i2c_probe(dev_addr); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * ti_i2c_eeprom_read - Read data from an EEPROM |
| 48 | * @dev_addr: The device address of the EEPROM |
| 49 | * @offset: Offset to start reading in the EEPROM |
| 50 | * @ep: Pointer to a buffer to read into |
| 51 | * @epsize: Size of buffer |
| 52 | * |
| 53 | * Return: 0 on success or corresponding result of i2c_read |
| 54 | */ |
| 55 | static int __maybe_unused ti_i2c_eeprom_read(int dev_addr, int offset, |
| 56 | uchar *ep, int epsize) |
| 57 | { |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 58 | return i2c_read(dev_addr, offset, 2, ep, epsize); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 59 | } |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 60 | #endif |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * ti_eeprom_string_cleanup() - Handle eeprom programming errors |
| 64 | * @s: eeprom string (should be NULL terminated) |
| 65 | * |
| 66 | * Some Board manufacturers do not add a NULL termination at the |
| 67 | * end of string, instead some binary information is kludged in, hence |
| 68 | * convert the string to just printable characters of ASCII chart. |
| 69 | */ |
| 70 | static void __maybe_unused ti_eeprom_string_cleanup(char *s) |
| 71 | { |
| 72 | int i, l; |
| 73 | |
| 74 | l = strlen(s); |
| 75 | for (i = 0; i < l; i++, s++) |
| 76 | if (*s < ' ' || *s > '~') { |
| 77 | *s = 0; |
| 78 | break; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | __weak void gpi2c_init(void) |
| 83 | { |
| 84 | } |
| 85 | |
| 86 | static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, |
| 87 | u32 header, u32 size, uint8_t *ep) |
| 88 | { |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 89 | int rc; |
| 90 | |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 91 | #if CONFIG_IS_ENABLED(DM_I2C) |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 92 | struct udevice *dev; |
| 93 | struct udevice *bus; |
| 94 | |
| 95 | rc = uclass_get_device_by_seq(UCLASS_I2C, bus_addr, &bus); |
| 96 | if (rc) |
| 97 | return rc; |
Andreas Dannenberg | 4803492 | 2020-01-07 13:15:53 +0530 | [diff] [blame] | 98 | rc = dm_i2c_probe(bus, dev_addr, 0, &dev); |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 99 | if (rc) |
| 100 | return rc; |
| 101 | |
| 102 | /* |
| 103 | * Read the header first then only read the other contents. |
| 104 | */ |
Nishanth Menon | 9177b30 | 2022-06-17 13:26:12 -0500 | [diff] [blame] | 105 | rc = i2c_set_chip_offset_len(dev, 1); |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 106 | if (rc) |
| 107 | return rc; |
| 108 | |
Nishanth Menon | 570c3bb | 2022-06-17 13:26:11 -0500 | [diff] [blame] | 109 | /* |
| 110 | * Skip checking result here since this could be a valid i2c read fail |
Nishanth Menon | 9177b30 | 2022-06-17 13:26:12 -0500 | [diff] [blame] | 111 | * on some boards that use 2 byte addressing. |
| 112 | * We must allow for fall through to check the data if 2 byte |
Nishanth Menon | 570c3bb | 2022-06-17 13:26:11 -0500 | [diff] [blame] | 113 | * addressing works |
| 114 | */ |
Matwey V. Kornilov | b90ca70 | 2022-08-23 19:05:34 +0300 | [diff] [blame^] | 115 | (void)dm_i2c_read(dev, 0, ep, size); |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 116 | |
| 117 | /* Corrupted data??? */ |
Matwey V. Kornilov | b90ca70 | 2022-08-23 19:05:34 +0300 | [diff] [blame^] | 118 | if (*((u32 *)ep) != header) { |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 119 | /* |
| 120 | * read the eeprom header using i2c again, but use only a |
Nishanth Menon | 9177b30 | 2022-06-17 13:26:12 -0500 | [diff] [blame] | 121 | * 2 byte address (some newer boards need this..) |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 122 | */ |
Nishanth Menon | 9177b30 | 2022-06-17 13:26:12 -0500 | [diff] [blame] | 123 | rc = i2c_set_chip_offset_len(dev, 2); |
Michal Simek | 888f10d | 2020-08-27 15:43:48 +0200 | [diff] [blame] | 124 | if (rc) |
| 125 | return rc; |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 126 | |
Matwey V. Kornilov | b90ca70 | 2022-08-23 19:05:34 +0300 | [diff] [blame^] | 127 | rc = dm_i2c_read(dev, 0, ep, size); |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 128 | if (rc) |
| 129 | return rc; |
| 130 | } |
Matwey V. Kornilov | b90ca70 | 2022-08-23 19:05:34 +0300 | [diff] [blame^] | 131 | if (*((u32 *)ep) != header) |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 132 | return -1; |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 133 | #else |
| 134 | u32 byte; |
| 135 | |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 136 | gpi2c_init(); |
| 137 | rc = ti_i2c_eeprom_init(bus_addr, dev_addr); |
| 138 | if (rc) |
| 139 | return rc; |
| 140 | |
| 141 | /* |
| 142 | * Read the header first then only read the other contents. |
| 143 | */ |
Nishanth Menon | 9177b30 | 2022-06-17 13:26:12 -0500 | [diff] [blame] | 144 | byte = 1; |
Cooper Jr., Franklin | 5b89c97 | 2017-04-20 10:25:45 -0500 | [diff] [blame] | 145 | |
Nishanth Menon | 570c3bb | 2022-06-17 13:26:11 -0500 | [diff] [blame] | 146 | /* |
| 147 | * Skip checking result here since this could be a valid i2c read fail |
Nishanth Menon | 9177b30 | 2022-06-17 13:26:12 -0500 | [diff] [blame] | 148 | * on some boards that use 2 byte addressing. |
| 149 | * We must allow for fall through to check the data if 2 byte |
Nishanth Menon | 570c3bb | 2022-06-17 13:26:11 -0500 | [diff] [blame] | 150 | * addressing works |
| 151 | */ |
Matwey V. Kornilov | b90ca70 | 2022-08-23 19:05:34 +0300 | [diff] [blame^] | 152 | (void)i2c_read(dev_addr, 0x0, byte, ep, size); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 153 | |
| 154 | /* Corrupted data??? */ |
Matwey V. Kornilov | b90ca70 | 2022-08-23 19:05:34 +0300 | [diff] [blame^] | 155 | if (*((u32 *)ep) != header) { |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 156 | /* |
| 157 | * read the eeprom header using i2c again, but use only a |
Nishanth Menon | 9177b30 | 2022-06-17 13:26:12 -0500 | [diff] [blame] | 158 | * 2 byte address (some newer boards need this..) |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 159 | */ |
Nishanth Menon | 9177b30 | 2022-06-17 13:26:12 -0500 | [diff] [blame] | 160 | byte = 2; |
Matwey V. Kornilov | b90ca70 | 2022-08-23 19:05:34 +0300 | [diff] [blame^] | 161 | rc = i2c_read(dev_addr, 0x0, byte, ep, size); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 162 | if (rc) |
| 163 | return rc; |
| 164 | } |
Matwey V. Kornilov | b90ca70 | 2022-08-23 19:05:34 +0300 | [diff] [blame^] | 165 | if (*((u32 *)ep) != header) |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 166 | return -1; |
Andreas Dannenberg | e315a66 | 2018-12-07 14:50:47 +0100 | [diff] [blame] | 167 | #endif |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 168 | return 0; |
| 169 | } |
| 170 | |
Caleb Robey | 0dfcc93 | 2020-01-02 08:17:25 -0600 | [diff] [blame] | 171 | int __maybe_unused ti_emmc_boardid_get(void) |
| 172 | { |
| 173 | int rc; |
| 174 | struct udevice *dev; |
| 175 | struct mmc *mmc; |
| 176 | struct ti_common_eeprom *ep; |
| 177 | struct ti_am_eeprom brdid; |
| 178 | struct blk_desc *bdesc; |
| 179 | uchar *buffer; |
| 180 | |
| 181 | ep = TI_EEPROM_DATA; |
| 182 | if (ep->header == TI_EEPROM_HEADER_MAGIC) |
| 183 | return 0; /* EEPROM has already been read */ |
| 184 | |
| 185 | /* Initialize with a known bad marker for emmc fails.. */ |
| 186 | ep->header = TI_DEAD_EEPROM_MAGIC; |
| 187 | ep->name[0] = 0x0; |
| 188 | ep->version[0] = 0x0; |
| 189 | ep->serial[0] = 0x0; |
| 190 | ep->config[0] = 0x0; |
| 191 | |
| 192 | /* uclass object initialization */ |
| 193 | rc = mmc_initialize(NULL); |
| 194 | if (rc) |
| 195 | return rc; |
| 196 | |
| 197 | /* Set device to /dev/mmcblk1 */ |
| 198 | rc = uclass_get_device(UCLASS_MMC, 1, &dev); |
| 199 | if (rc) |
| 200 | return rc; |
| 201 | |
| 202 | /* Grab the mmc device */ |
| 203 | mmc = mmc_get_mmc_dev(dev); |
| 204 | if (!mmc) |
| 205 | return -ENODEV; |
| 206 | |
| 207 | /* mmc hardware initialization routine */ |
| 208 | mmc_init(mmc); |
| 209 | |
| 210 | /* Set partition to /dev/mmcblk1boot1 */ |
| 211 | rc = mmc_switch_part(mmc, 2); |
| 212 | if (rc) |
| 213 | return rc; |
| 214 | |
| 215 | buffer = malloc(mmc->read_bl_len); |
| 216 | if (!buffer) |
| 217 | return -ENOMEM; |
| 218 | |
| 219 | bdesc = mmc_get_blk_desc(mmc); |
| 220 | |
| 221 | /* blk_dread returns the number of blocks read*/ |
| 222 | if (blk_dread(bdesc, 0L, 1, buffer) != 1) { |
| 223 | rc = -EIO; |
| 224 | goto cleanup; |
| 225 | } |
| 226 | |
| 227 | memcpy(&brdid, buffer, sizeof(brdid)); |
| 228 | |
| 229 | /* Write out the ep struct values */ |
| 230 | ep->header = brdid.header; |
| 231 | strlcpy(ep->name, brdid.name, TI_EEPROM_HDR_NAME_LEN + 1); |
| 232 | ti_eeprom_string_cleanup(ep->name); |
| 233 | strlcpy(ep->version, brdid.version, TI_EEPROM_HDR_REV_LEN + 1); |
| 234 | ti_eeprom_string_cleanup(ep->version); |
| 235 | strlcpy(ep->serial, brdid.serial, TI_EEPROM_HDR_SERIAL_LEN + 1); |
| 236 | ti_eeprom_string_cleanup(ep->serial); |
| 237 | |
| 238 | cleanup: |
| 239 | free(buffer); |
| 240 | |
| 241 | return rc; |
| 242 | } |
| 243 | |
Nishanth Menon | 27856ff | 2017-06-16 17:25:04 -0500 | [diff] [blame] | 244 | int __maybe_unused ti_i2c_eeprom_am_set(const char *name, const char *rev) |
| 245 | { |
| 246 | struct ti_common_eeprom *ep; |
| 247 | |
| 248 | if (!name || !rev) |
| 249 | return -1; |
| 250 | |
| 251 | ep = TI_EEPROM_DATA; |
| 252 | if (ep->header == TI_EEPROM_HEADER_MAGIC) |
| 253 | goto already_set; |
| 254 | |
| 255 | /* Set to 0 all fields */ |
| 256 | memset(ep, 0, sizeof(*ep)); |
| 257 | strncpy(ep->name, name, TI_EEPROM_HDR_NAME_LEN); |
| 258 | strncpy(ep->version, rev, TI_EEPROM_HDR_REV_LEN); |
| 259 | /* Some dummy serial number to identify the platform */ |
| 260 | strncpy(ep->serial, "0000", TI_EEPROM_HDR_SERIAL_LEN); |
| 261 | /* Mark it with a valid header */ |
| 262 | ep->header = TI_EEPROM_HEADER_MAGIC; |
| 263 | |
| 264 | already_set: |
| 265 | return 0; |
| 266 | } |
| 267 | |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 268 | int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr) |
| 269 | { |
| 270 | int rc; |
| 271 | struct ti_am_eeprom am_ep; |
| 272 | struct ti_common_eeprom *ep; |
| 273 | |
| 274 | ep = TI_EEPROM_DATA; |
Jean-Jacques Hiblot | a096a76 | 2016-12-01 10:37:03 +0100 | [diff] [blame] | 275 | #ifndef CONFIG_SPL_BUILD |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 276 | if (ep->header == TI_EEPROM_HEADER_MAGIC) |
Jean-Jacques Hiblot | a096a76 | 2016-12-01 10:37:03 +0100 | [diff] [blame] | 277 | return 0; /* EEPROM has already been read */ |
| 278 | #endif |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 279 | |
| 280 | /* Initialize with a known bad marker for i2c fails.. */ |
| 281 | ep->header = TI_DEAD_EEPROM_MAGIC; |
| 282 | ep->name[0] = 0x0; |
| 283 | ep->version[0] = 0x0; |
| 284 | ep->serial[0] = 0x0; |
Nishanth Menon | e2b0a52 | 2016-10-11 12:39:04 -0500 | [diff] [blame] | 285 | ep->config[0] = 0x0; |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 286 | |
| 287 | rc = ti_i2c_eeprom_get(bus_addr, dev_addr, TI_EEPROM_HEADER_MAGIC, |
| 288 | sizeof(am_ep), (uint8_t *)&am_ep); |
| 289 | if (rc) |
| 290 | return rc; |
| 291 | |
| 292 | ep->header = am_ep.header; |
| 293 | strlcpy(ep->name, am_ep.name, TI_EEPROM_HDR_NAME_LEN + 1); |
| 294 | ti_eeprom_string_cleanup(ep->name); |
| 295 | |
| 296 | /* BeagleBone Green '1' eeprom, board_rev: 0x1a 0x00 0x00 0x00 */ |
| 297 | if (am_ep.version[0] == 0x1a && am_ep.version[1] == 0x00 && |
| 298 | am_ep.version[2] == 0x00 && am_ep.version[3] == 0x00) |
| 299 | strlcpy(ep->version, "BBG1", TI_EEPROM_HDR_REV_LEN + 1); |
| 300 | else |
| 301 | strlcpy(ep->version, am_ep.version, TI_EEPROM_HDR_REV_LEN + 1); |
| 302 | ti_eeprom_string_cleanup(ep->version); |
| 303 | strlcpy(ep->serial, am_ep.serial, TI_EEPROM_HDR_SERIAL_LEN + 1); |
| 304 | ti_eeprom_string_cleanup(ep->serial); |
| 305 | strlcpy(ep->config, am_ep.config, TI_EEPROM_HDR_CONFIG_LEN + 1); |
| 306 | ti_eeprom_string_cleanup(ep->config); |
| 307 | |
| 308 | memcpy(ep->mac_addr, am_ep.mac_addr, |
| 309 | TI_EEPROM_HDR_NO_OF_MAC_ADDR * TI_EEPROM_HDR_ETH_ALEN); |
| 310 | |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 311 | return 0; |
| 312 | } |
| 313 | |
Lokesh Vutla | 7c08a78 | 2016-03-08 09:18:04 +0530 | [diff] [blame] | 314 | int __maybe_unused ti_i2c_eeprom_dra7_get(int bus_addr, int dev_addr) |
| 315 | { |
| 316 | int rc, offset = 0; |
| 317 | struct dra7_eeprom dra7_ep; |
| 318 | struct ti_common_eeprom *ep; |
| 319 | |
| 320 | ep = TI_EEPROM_DATA; |
Jean-Jacques Hiblot | a096a76 | 2016-12-01 10:37:03 +0100 | [diff] [blame] | 321 | #ifndef CONFIG_SPL_BUILD |
Lokesh Vutla | 7c08a78 | 2016-03-08 09:18:04 +0530 | [diff] [blame] | 322 | if (ep->header == DRA7_EEPROM_HEADER_MAGIC) |
Jean-Jacques Hiblot | a096a76 | 2016-12-01 10:37:03 +0100 | [diff] [blame] | 323 | return 0; /* EEPROM has already been read */ |
| 324 | #endif |
Lokesh Vutla | 7c08a78 | 2016-03-08 09:18:04 +0530 | [diff] [blame] | 325 | |
| 326 | /* Initialize with a known bad marker for i2c fails.. */ |
Nishanth Menon | 21e54c0 | 2016-10-11 12:39:03 -0500 | [diff] [blame] | 327 | ep->header = TI_DEAD_EEPROM_MAGIC; |
Lokesh Vutla | 7c08a78 | 2016-03-08 09:18:04 +0530 | [diff] [blame] | 328 | ep->name[0] = 0x0; |
| 329 | ep->version[0] = 0x0; |
| 330 | ep->serial[0] = 0x0; |
Nishanth Menon | e2b0a52 | 2016-10-11 12:39:04 -0500 | [diff] [blame] | 331 | ep->config[0] = 0x0; |
Lokesh Vutla | 7c08a78 | 2016-03-08 09:18:04 +0530 | [diff] [blame] | 332 | ep->emif1_size = 0; |
| 333 | ep->emif2_size = 0; |
| 334 | |
| 335 | rc = ti_i2c_eeprom_get(bus_addr, dev_addr, DRA7_EEPROM_HEADER_MAGIC, |
| 336 | sizeof(dra7_ep), (uint8_t *)&dra7_ep); |
| 337 | if (rc) |
| 338 | return rc; |
| 339 | |
| 340 | ep->header = dra7_ep.header; |
| 341 | strlcpy(ep->name, dra7_ep.name, TI_EEPROM_HDR_NAME_LEN + 1); |
| 342 | ti_eeprom_string_cleanup(ep->name); |
| 343 | |
| 344 | offset = dra7_ep.version_major - 1; |
| 345 | |
| 346 | /* Rev F is skipped */ |
| 347 | if (offset >= 5) |
| 348 | offset = offset + 1; |
| 349 | snprintf(ep->version, TI_EEPROM_HDR_REV_LEN + 1, "%c.%d", |
| 350 | 'A' + offset, dra7_ep.version_minor); |
| 351 | ti_eeprom_string_cleanup(ep->version); |
| 352 | ep->emif1_size = (u64)dra7_ep.emif1_size; |
| 353 | ep->emif2_size = (u64)dra7_ep.emif2_size; |
| 354 | strlcpy(ep->config, dra7_ep.config, TI_EEPROM_HDR_CONFIG_LEN + 1); |
| 355 | ti_eeprom_string_cleanup(ep->config); |
| 356 | |
Lokesh Vutla | 7c08a78 | 2016-03-08 09:18:04 +0530 | [diff] [blame] | 357 | return 0; |
| 358 | } |
| 359 | |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 360 | static int ti_i2c_eeprom_am6_parse_record(struct ti_am6_eeprom_record *record, |
| 361 | struct ti_am6_eeprom *ep, |
| 362 | char **mac_addr, |
| 363 | u8 mac_addr_max_cnt, |
| 364 | u8 *mac_addr_cnt) |
| 365 | { |
| 366 | switch (record->header.id) { |
| 367 | case TI_AM6_EEPROM_RECORD_BOARD_INFO: |
| 368 | if (record->header.len != sizeof(record->data.board_info)) |
| 369 | return -EINVAL; |
| 370 | |
| 371 | if (!ep) |
| 372 | break; |
| 373 | |
| 374 | /* Populate (and clean, if needed) the board name */ |
| 375 | strlcpy(ep->name, record->data.board_info.name, |
| 376 | sizeof(ep->name)); |
| 377 | ti_eeprom_string_cleanup(ep->name); |
| 378 | |
| 379 | /* Populate selected other fields from the board info record */ |
| 380 | strlcpy(ep->version, record->data.board_info.version, |
| 381 | sizeof(ep->version)); |
| 382 | strlcpy(ep->software_revision, |
| 383 | record->data.board_info.software_revision, |
| 384 | sizeof(ep->software_revision)); |
| 385 | strlcpy(ep->serial, record->data.board_info.serial, |
| 386 | sizeof(ep->serial)); |
| 387 | break; |
| 388 | case TI_AM6_EEPROM_RECORD_MAC_INFO: |
| 389 | if (record->header.len != sizeof(record->data.mac_info)) |
| 390 | return -EINVAL; |
| 391 | |
| 392 | if (!mac_addr || !mac_addr_max_cnt) |
| 393 | break; |
| 394 | |
| 395 | *mac_addr_cnt = ((record->data.mac_info.mac_control & |
| 396 | TI_AM6_EEPROM_MAC_ADDR_COUNT_MASK) >> |
| 397 | TI_AM6_EEPROM_MAC_ADDR_COUNT_SHIFT) + 1; |
| 398 | |
| 399 | /* |
| 400 | * The EEPROM can (but may not) hold a very large amount |
| 401 | * of MAC addresses, by far exceeding what we want/can store |
| 402 | * in the common memory array, so only grab what we can fit. |
| 403 | * Note that a value of 0 means 1 MAC address, and so on. |
| 404 | */ |
| 405 | *mac_addr_cnt = min(*mac_addr_cnt, mac_addr_max_cnt); |
| 406 | |
| 407 | memcpy(mac_addr, record->data.mac_info.mac_addr, |
| 408 | *mac_addr_cnt * TI_EEPROM_HDR_ETH_ALEN); |
| 409 | break; |
| 410 | case 0x00: |
| 411 | /* Illegal value... Fall through... */ |
| 412 | case 0xFF: |
| 413 | /* Illegal value... Something went horribly wrong... */ |
| 414 | return -EINVAL; |
| 415 | default: |
| 416 | pr_warn("%s: Ignoring record id %u\n", __func__, |
| 417 | record->header.id); |
| 418 | } |
| 419 | |
| 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | int __maybe_unused ti_i2c_eeprom_am6_get(int bus_addr, int dev_addr, |
| 424 | struct ti_am6_eeprom *ep, |
| 425 | char **mac_addr, |
| 426 | u8 mac_addr_max_cnt, |
| 427 | u8 *mac_addr_cnt) |
| 428 | { |
| 429 | struct udevice *dev; |
| 430 | struct udevice *bus; |
| 431 | unsigned int eeprom_addr; |
| 432 | struct ti_am6_eeprom_record_board_id board_id; |
| 433 | struct ti_am6_eeprom_record record; |
| 434 | int rc; |
Nishanth Menon | 77c94ea | 2022-06-17 13:26:10 -0500 | [diff] [blame] | 435 | int consecutive_bad_records = 0; |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 436 | |
| 437 | /* Initialize with a known bad marker for i2c fails.. */ |
| 438 | memset(ep, 0, sizeof(*ep)); |
| 439 | ep->header = TI_DEAD_EEPROM_MAGIC; |
| 440 | |
| 441 | /* Read the board ID record which is always the first EEPROM record */ |
| 442 | rc = ti_i2c_eeprom_get(bus_addr, dev_addr, TI_EEPROM_HEADER_MAGIC, |
| 443 | sizeof(board_id), (uint8_t *)&board_id); |
| 444 | if (rc) |
| 445 | return rc; |
| 446 | |
| 447 | if (board_id.header.id != TI_AM6_EEPROM_RECORD_BOARD_ID) { |
| 448 | pr_err("%s: Invalid board ID record!\n", __func__); |
| 449 | return -EINVAL; |
| 450 | } |
| 451 | |
| 452 | /* Establish DM handle to board config EEPROM */ |
| 453 | rc = uclass_get_device_by_seq(UCLASS_I2C, bus_addr, &bus); |
| 454 | if (rc) |
| 455 | return rc; |
| 456 | rc = i2c_get_chip(bus, dev_addr, 1, &dev); |
| 457 | if (rc) |
| 458 | return rc; |
| 459 | |
| 460 | ep->header = TI_EEPROM_HEADER_MAGIC; |
| 461 | |
| 462 | /* Ready to parse TLV structure. Initialize variables... */ |
| 463 | *mac_addr_cnt = 0; |
| 464 | |
| 465 | /* |
| 466 | * After the all-encompassing board ID record all other records follow |
| 467 | * a TLV-type scheme. Point to the first such record and then start |
| 468 | * parsing those one by one. |
| 469 | */ |
| 470 | eeprom_addr = sizeof(board_id); |
| 471 | |
Nishanth Menon | 77c94ea | 2022-06-17 13:26:10 -0500 | [diff] [blame] | 472 | while (consecutive_bad_records < 10) { |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 473 | rc = dm_i2c_read(dev, eeprom_addr, (uint8_t *)&record.header, |
| 474 | sizeof(record.header)); |
| 475 | if (rc) |
| 476 | return rc; |
| 477 | |
| 478 | /* |
| 479 | * Check for end of list marker. If we reached it don't go |
| 480 | * any further and stop parsing right here. |
| 481 | */ |
| 482 | if (record.header.id == TI_AM6_EEPROM_RECORD_END_LIST) |
| 483 | break; |
| 484 | |
| 485 | eeprom_addr += sizeof(record.header); |
| 486 | |
| 487 | debug("%s: dev_addr=0x%02x header.id=%u header.len=%u\n", |
| 488 | __func__, dev_addr, record.header.id, |
| 489 | record.header.len); |
| 490 | |
| 491 | /* Read record into memory if it fits */ |
| 492 | if (record.header.len <= sizeof(record.data)) { |
| 493 | rc = dm_i2c_read(dev, eeprom_addr, |
| 494 | (uint8_t *)&record.data, |
| 495 | record.header.len); |
| 496 | if (rc) |
| 497 | return rc; |
| 498 | |
| 499 | /* Process record */ |
| 500 | rc = ti_i2c_eeprom_am6_parse_record(&record, ep, |
| 501 | mac_addr, |
| 502 | mac_addr_max_cnt, |
| 503 | mac_addr_cnt); |
| 504 | if (rc) { |
| 505 | pr_err("%s: EEPROM parsing error!\n", __func__); |
| 506 | return rc; |
| 507 | } |
Nishanth Menon | 77c94ea | 2022-06-17 13:26:10 -0500 | [diff] [blame] | 508 | consecutive_bad_records = 0; |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 509 | } else { |
| 510 | /* |
| 511 | * We may get here in case of larger records which |
| 512 | * are not yet understood. |
| 513 | */ |
| 514 | pr_err("%s: Ignoring record id %u\n", __func__, |
| 515 | record.header.id); |
Nishanth Menon | 77c94ea | 2022-06-17 13:26:10 -0500 | [diff] [blame] | 516 | consecutive_bad_records++; |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | eeprom_addr += record.header.len; |
| 520 | } |
| 521 | |
| 522 | return 0; |
| 523 | } |
| 524 | |
| 525 | int __maybe_unused ti_i2c_eeprom_am6_get_base(int bus_addr, int dev_addr) |
| 526 | { |
| 527 | struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA; |
| 528 | int ret; |
| 529 | |
| 530 | /* |
| 531 | * Always execute EEPROM read by not allowing to bypass it during the |
| 532 | * first invocation of SPL which happens on the R5 core. |
| 533 | */ |
| 534 | #if !(defined(CONFIG_SPL_BUILD) && defined(CONFIG_CPU_V7R)) |
| 535 | if (ep->header == TI_EEPROM_HEADER_MAGIC) { |
| 536 | debug("%s: EEPROM has already been read\n", __func__); |
| 537 | return 0; |
| 538 | } |
| 539 | #endif |
| 540 | |
| 541 | ret = ti_i2c_eeprom_am6_get(bus_addr, dev_addr, ep, |
| 542 | (char **)ep->mac_addr, |
| 543 | AM6_EEPROM_HDR_NO_OF_MAC_ADDR, |
| 544 | &ep->mac_addr_cnt); |
| 545 | return ret; |
| 546 | } |
| 547 | |
Andreas Dannenberg | d036a21 | 2020-01-07 13:15:54 +0530 | [diff] [blame] | 548 | bool __maybe_unused board_ti_k3_is(char *name_tag) |
| 549 | { |
| 550 | struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA; |
| 551 | |
| 552 | if (ep->header == TI_DEAD_EEPROM_MAGIC) |
| 553 | return false; |
| 554 | return !strncmp(ep->name, name_tag, AM6_EEPROM_HDR_NAME_LEN); |
| 555 | } |
| 556 | |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 557 | bool __maybe_unused board_ti_is(char *name_tag) |
| 558 | { |
| 559 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 560 | |
| 561 | if (ep->header == TI_DEAD_EEPROM_MAGIC) |
| 562 | return false; |
| 563 | return !strncmp(ep->name, name_tag, TI_EEPROM_HDR_NAME_LEN); |
| 564 | } |
| 565 | |
| 566 | bool __maybe_unused board_ti_rev_is(char *rev_tag, int cmp_len) |
| 567 | { |
| 568 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 569 | int l; |
| 570 | |
| 571 | if (ep->header == TI_DEAD_EEPROM_MAGIC) |
| 572 | return false; |
| 573 | |
| 574 | l = cmp_len > TI_EEPROM_HDR_REV_LEN ? TI_EEPROM_HDR_REV_LEN : cmp_len; |
| 575 | return !strncmp(ep->version, rev_tag, l); |
| 576 | } |
| 577 | |
| 578 | char * __maybe_unused board_ti_get_rev(void) |
| 579 | { |
| 580 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 581 | |
Nishanth Menon | 23afc8a | 2016-10-11 12:39:05 -0500 | [diff] [blame] | 582 | /* if ep->header == TI_DEAD_EEPROM_MAGIC, this is empty already */ |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 583 | return ep->version; |
| 584 | } |
| 585 | |
| 586 | char * __maybe_unused board_ti_get_config(void) |
| 587 | { |
| 588 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 589 | |
Nishanth Menon | 23afc8a | 2016-10-11 12:39:05 -0500 | [diff] [blame] | 590 | /* if ep->header == TI_DEAD_EEPROM_MAGIC, this is empty already */ |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 591 | return ep->config; |
| 592 | } |
| 593 | |
| 594 | char * __maybe_unused board_ti_get_name(void) |
| 595 | { |
| 596 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 597 | |
Nishanth Menon | 23afc8a | 2016-10-11 12:39:05 -0500 | [diff] [blame] | 598 | /* if ep->header == TI_DEAD_EEPROM_MAGIC, this is empty already */ |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 599 | return ep->name; |
| 600 | } |
| 601 | |
| 602 | void __maybe_unused |
| 603 | board_ti_get_eth_mac_addr(int index, |
| 604 | u8 mac_addr[TI_EEPROM_HDR_ETH_ALEN]) |
| 605 | { |
| 606 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 607 | |
| 608 | if (ep->header == TI_DEAD_EEPROM_MAGIC) |
| 609 | goto fail; |
| 610 | |
| 611 | if (index < 0 || index >= TI_EEPROM_HDR_NO_OF_MAC_ADDR) |
| 612 | goto fail; |
| 613 | |
| 614 | memcpy(mac_addr, ep->mac_addr[index], TI_EEPROM_HDR_ETH_ALEN); |
| 615 | return; |
| 616 | |
| 617 | fail: |
| 618 | memset(mac_addr, 0, TI_EEPROM_HDR_ETH_ALEN); |
| 619 | } |
| 620 | |
Andreas Dannenberg | 5a64711 | 2019-06-04 18:08:25 -0500 | [diff] [blame] | 621 | void __maybe_unused |
| 622 | board_ti_am6_get_eth_mac_addr(int index, |
| 623 | u8 mac_addr[TI_EEPROM_HDR_ETH_ALEN]) |
| 624 | { |
| 625 | struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA; |
| 626 | |
| 627 | if (ep->header == TI_DEAD_EEPROM_MAGIC) |
| 628 | goto fail; |
| 629 | |
| 630 | if (index < 0 || index >= ep->mac_addr_cnt) |
| 631 | goto fail; |
| 632 | |
| 633 | memcpy(mac_addr, ep->mac_addr[index], TI_EEPROM_HDR_ETH_ALEN); |
| 634 | return; |
| 635 | |
| 636 | fail: |
| 637 | memset(mac_addr, 0, TI_EEPROM_HDR_ETH_ALEN); |
| 638 | } |
| 639 | |
Lokesh Vutla | 7c08a78 | 2016-03-08 09:18:04 +0530 | [diff] [blame] | 640 | u64 __maybe_unused board_ti_get_emif1_size(void) |
| 641 | { |
| 642 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 643 | |
| 644 | if (ep->header != DRA7_EEPROM_HEADER_MAGIC) |
| 645 | return 0; |
| 646 | |
| 647 | return ep->emif1_size; |
| 648 | } |
| 649 | |
| 650 | u64 __maybe_unused board_ti_get_emif2_size(void) |
| 651 | { |
| 652 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 653 | |
| 654 | if (ep->header != DRA7_EEPROM_HEADER_MAGIC) |
| 655 | return 0; |
| 656 | |
| 657 | return ep->emif2_size; |
| 658 | } |
| 659 | |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 660 | void __maybe_unused set_board_info_env(char *name) |
| 661 | { |
| 662 | char *unknown = "unknown"; |
| 663 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 664 | |
| 665 | if (name) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 666 | env_set("board_name", name); |
Tom Rini | d1449cb | 2020-06-04 15:45:08 -0400 | [diff] [blame] | 667 | else if (strlen(ep->name) != 0) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 668 | env_set("board_name", ep->name); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 669 | else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 670 | env_set("board_name", unknown); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 671 | |
Tom Rini | d1449cb | 2020-06-04 15:45:08 -0400 | [diff] [blame] | 672 | if (strlen(ep->version) != 0) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 673 | env_set("board_rev", ep->version); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 674 | else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 675 | env_set("board_rev", unknown); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 676 | |
Tom Rini | d1449cb | 2020-06-04 15:45:08 -0400 | [diff] [blame] | 677 | if (strlen(ep->serial) != 0) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 678 | env_set("board_serial", ep->serial); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 679 | else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 680 | env_set("board_serial", unknown); |
Lokesh Vutla | 35f7a97 | 2016-02-24 12:30:54 -0600 | [diff] [blame] | 681 | } |
Roger Quadros | 44c7d9a | 2017-03-14 15:04:19 +0200 | [diff] [blame] | 682 | |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 683 | void __maybe_unused set_board_info_env_am6(char *name) |
| 684 | { |
| 685 | char *unknown = "unknown"; |
| 686 | struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA; |
| 687 | |
| 688 | if (name) |
| 689 | env_set("board_name", name); |
Tom Rini | d1449cb | 2020-06-04 15:45:08 -0400 | [diff] [blame] | 690 | else if (strlen(ep->name) != 0) |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 691 | env_set("board_name", ep->name); |
| 692 | else |
| 693 | env_set("board_name", unknown); |
| 694 | |
Tom Rini | d1449cb | 2020-06-04 15:45:08 -0400 | [diff] [blame] | 695 | if (strlen(ep->version) != 0) |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 696 | env_set("board_rev", ep->version); |
| 697 | else |
| 698 | env_set("board_rev", unknown); |
| 699 | |
Tom Rini | d1449cb | 2020-06-04 15:45:08 -0400 | [diff] [blame] | 700 | if (strlen(ep->software_revision) != 0) |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 701 | env_set("board_software_revision", ep->software_revision); |
| 702 | else |
| 703 | env_set("board_software_revision", unknown); |
| 704 | |
Tom Rini | d1449cb | 2020-06-04 15:45:08 -0400 | [diff] [blame] | 705 | if (strlen(ep->serial) != 0) |
Andreas Dannenberg | f998a82 | 2019-06-04 18:08:24 -0500 | [diff] [blame] | 706 | env_set("board_serial", ep->serial); |
| 707 | else |
| 708 | env_set("board_serial", unknown); |
| 709 | } |
| 710 | |
Roger Quadros | 44c7d9a | 2017-03-14 15:04:19 +0200 | [diff] [blame] | 711 | static u64 mac_to_u64(u8 mac[6]) |
| 712 | { |
| 713 | int i; |
| 714 | u64 addr = 0; |
| 715 | |
| 716 | for (i = 0; i < 6; i++) { |
| 717 | addr <<= 8; |
| 718 | addr |= mac[i]; |
| 719 | } |
| 720 | |
| 721 | return addr; |
| 722 | } |
| 723 | |
| 724 | static void u64_to_mac(u64 addr, u8 mac[6]) |
| 725 | { |
| 726 | mac[5] = addr; |
| 727 | mac[4] = addr >> 8; |
| 728 | mac[3] = addr >> 16; |
| 729 | mac[2] = addr >> 24; |
| 730 | mac[1] = addr >> 32; |
| 731 | mac[0] = addr >> 40; |
| 732 | } |
| 733 | |
| 734 | void board_ti_set_ethaddr(int index) |
| 735 | { |
| 736 | uint8_t mac_addr[6]; |
| 737 | int i; |
| 738 | u64 mac1, mac2; |
| 739 | u8 mac_addr1[6], mac_addr2[6]; |
| 740 | int num_macs; |
| 741 | /* |
| 742 | * Export any Ethernet MAC addresses from EEPROM. |
| 743 | * The 2 MAC addresses in EEPROM define the address range. |
| 744 | */ |
| 745 | board_ti_get_eth_mac_addr(0, mac_addr1); |
| 746 | board_ti_get_eth_mac_addr(1, mac_addr2); |
| 747 | |
| 748 | if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) { |
| 749 | mac1 = mac_to_u64(mac_addr1); |
| 750 | mac2 = mac_to_u64(mac_addr2); |
| 751 | |
| 752 | /* must contain an address range */ |
| 753 | num_macs = mac2 - mac1 + 1; |
| 754 | if (num_macs <= 0) |
| 755 | return; |
| 756 | |
| 757 | if (num_macs > 50) { |
| 758 | printf("%s: Too many MAC addresses: %d. Limiting to 50\n", |
| 759 | __func__, num_macs); |
| 760 | num_macs = 50; |
| 761 | } |
| 762 | |
| 763 | for (i = 0; i < num_macs; i++) { |
| 764 | u64_to_mac(mac1 + i, mac_addr); |
| 765 | if (is_valid_ethaddr(mac_addr)) { |
Simon Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 766 | eth_env_set_enetaddr_by_index("eth", i + index, |
| 767 | mac_addr); |
Roger Quadros | 44c7d9a | 2017-03-14 15:04:19 +0200 | [diff] [blame] | 768 | } |
| 769 | } |
| 770 | } |
| 771 | } |
Cooper Jr., Franklin | e1328c7 | 2017-06-16 17:25:08 -0500 | [diff] [blame] | 772 | |
Andreas Dannenberg | 5a64711 | 2019-06-04 18:08:25 -0500 | [diff] [blame] | 773 | void board_ti_am6_set_ethaddr(int index, int count) |
| 774 | { |
| 775 | u8 mac_addr[6]; |
| 776 | int i; |
| 777 | |
| 778 | for (i = 0; i < count; i++) { |
| 779 | board_ti_am6_get_eth_mac_addr(i, mac_addr); |
| 780 | if (is_valid_ethaddr(mac_addr)) |
| 781 | eth_env_set_enetaddr_by_index("eth", i + index, |
| 782 | mac_addr); |
| 783 | } |
| 784 | } |
| 785 | |
Cooper Jr., Franklin | e1328c7 | 2017-06-16 17:25:08 -0500 | [diff] [blame] | 786 | bool __maybe_unused board_ti_was_eeprom_read(void) |
| 787 | { |
| 788 | struct ti_common_eeprom *ep = TI_EEPROM_DATA; |
| 789 | |
| 790 | if (ep->header == TI_EEPROM_HEADER_MAGIC) |
| 791 | return true; |
| 792 | else |
| 793 | return false; |
| 794 | } |