Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * Read FactorySet information from EEPROM into global structure. |
| 5 | * (C) Copyright 2013 Siemens Schweiz AG |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #if !defined(CONFIG_SPL_BUILD) |
| 9 | |
| 10 | #include <common.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 11 | #include <env.h> |
Anatolij Gustschin | d0d75f5 | 2019-07-10 19:44:15 +0200 | [diff] [blame] | 12 | #include <dm.h> |
Tom Rini | fb76807 | 2019-08-12 18:47:53 -0400 | [diff] [blame] | 13 | #include <env_internal.h> |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 14 | #include <i2c.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 15 | #include <log.h> |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 16 | #include <asm/io.h> |
Anatolij Gustschin | 49234a3 | 2020-01-07 16:37:42 +0100 | [diff] [blame] | 17 | #if !CONFIG_IS_ENABLED(TARGET_GIEDI) && !CONFIG_IS_ENABLED(TARGET_DENEB) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 18 | #include <asm/arch/cpu.h> |
Anatolij Gustschin | 49234a3 | 2020-01-07 16:37:42 +0100 | [diff] [blame] | 19 | #endif |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 20 | #include <asm/arch/sys_proto.h> |
| 21 | #include <asm/unaligned.h> |
| 22 | #include <net.h> |
Samuel Egli | 8069bfe | 2013-11-04 14:05:03 +0100 | [diff] [blame] | 23 | #include <errno.h> |
| 24 | #include <g_dnl.h> |
Enrico Leto | 096bfdc | 2024-01-24 15:43:49 +0100 | [diff] [blame] | 25 | #include "eeprom.h" |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 26 | #include "factoryset.h" |
| 27 | |
Enrico Leto | 096bfdc | 2024-01-24 15:43:49 +0100 | [diff] [blame] | 28 | #define EEPR_PG_SZ 0x80 |
| 29 | #define OFF_PG (SIEMENS_EE_ADDR_FACTORYSET / EEPR_PG_SZ) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 30 | |
| 31 | /* Global variable that contains necessary information from FactorySet */ |
| 32 | struct factorysetcontainer factory_dat; |
| 33 | |
| 34 | #define fact_get_char(i) *((char *)&eeprom_buf[i]) |
| 35 | |
| 36 | static int fact_match(unsigned char *eeprom_buf, uchar *s1, int i2) |
| 37 | { |
| 38 | if (s1 == NULL) |
| 39 | return -1; |
| 40 | |
| 41 | while (*s1 == fact_get_char(i2++)) |
| 42 | if (*s1++ == '=') |
| 43 | return i2; |
| 44 | |
| 45 | if (*s1 == '\0' && fact_get_char(i2-1) == '=') |
| 46 | return i2; |
| 47 | |
| 48 | return -1; |
| 49 | } |
| 50 | |
| 51 | static int get_factory_val(unsigned char *eeprom_buf, int size, uchar *name, |
| 52 | uchar *buf, int len) |
| 53 | { |
| 54 | int i, nxt = 0; |
| 55 | |
| 56 | for (i = 0; fact_get_char(i) != '\0'; i = nxt + 1) { |
| 57 | int val, n; |
| 58 | |
| 59 | for (nxt = i; fact_get_char(nxt) != '\0'; ++nxt) { |
| 60 | if (nxt >= size) |
| 61 | return -1; |
| 62 | } |
| 63 | |
| 64 | val = fact_match(eeprom_buf, (uchar *)name, i); |
| 65 | if (val < 0) |
| 66 | continue; |
| 67 | |
| 68 | /* found; copy out */ |
| 69 | for (n = 0; n < len; ++n, ++buf) { |
| 70 | *buf = fact_get_char(val++); |
| 71 | if (*buf == '\0') |
| 72 | return n; |
| 73 | } |
| 74 | |
| 75 | if (n) |
| 76 | *--buf = '\0'; |
| 77 | |
| 78 | printf("env_buf [%d bytes] too small for value of \"%s\"\n", |
| 79 | len, name); |
| 80 | |
| 81 | return n; |
| 82 | } |
| 83 | return -1; |
| 84 | } |
| 85 | |
| 86 | static |
| 87 | int get_factory_record_val(unsigned char *eeprom_buf, int size, uchar *record, |
| 88 | uchar *name, uchar *buf, int len) |
| 89 | { |
| 90 | int ret = -1; |
| 91 | int i, nxt = 0; |
| 92 | int c; |
| 93 | unsigned char end = 0xff; |
Heiko Schocher | 6596b85 | 2014-11-18 11:51:04 +0100 | [diff] [blame] | 94 | unsigned char tmp; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 95 | |
| 96 | for (i = 0; fact_get_char(i) != end; i = nxt) { |
| 97 | nxt = i + 1; |
| 98 | if (fact_get_char(i) == '>') { |
| 99 | int pos; |
| 100 | int endpos; |
| 101 | int z; |
Heiko Schocher | 6596b85 | 2014-11-18 11:51:04 +0100 | [diff] [blame] | 102 | int level = 0; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 103 | |
| 104 | c = strncmp((char *)&eeprom_buf[i + 1], (char *)record, |
| 105 | strlen((char *)record)); |
| 106 | if (c == 0) { |
| 107 | /* record found */ |
| 108 | pos = i + strlen((char *)record) + 2; |
| 109 | nxt = pos; |
| 110 | /* search for "<" */ |
| 111 | c = -1; |
| 112 | for (z = pos; fact_get_char(z) != end; z++) { |
Heiko Schocher | 6596b85 | 2014-11-18 11:51:04 +0100 | [diff] [blame] | 113 | if (fact_get_char(z) == '<') { |
| 114 | if (level == 0) { |
| 115 | endpos = z; |
| 116 | nxt = endpos; |
| 117 | c = 0; |
| 118 | break; |
| 119 | } else { |
| 120 | level--; |
| 121 | } |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 122 | } |
Heiko Schocher | 6596b85 | 2014-11-18 11:51:04 +0100 | [diff] [blame] | 123 | if (fact_get_char(z) == '>') |
| 124 | level++; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 125 | } |
Heiko Schocher | 6596b85 | 2014-11-18 11:51:04 +0100 | [diff] [blame] | 126 | } else { |
| 127 | continue; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 128 | } |
| 129 | if (c == 0) { |
| 130 | /* end found -> call get_factory_val */ |
Heiko Schocher | 6596b85 | 2014-11-18 11:51:04 +0100 | [diff] [blame] | 131 | tmp = eeprom_buf[endpos]; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 132 | eeprom_buf[endpos] = end; |
| 133 | ret = get_factory_val(&eeprom_buf[pos], |
Heiko Schocher | 6596b85 | 2014-11-18 11:51:04 +0100 | [diff] [blame] | 134 | endpos - pos, name, buf, len); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 135 | /* fix buffer */ |
Heiko Schocher | 6596b85 | 2014-11-18 11:51:04 +0100 | [diff] [blame] | 136 | eeprom_buf[endpos] = tmp; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 137 | debug("%s: %s.%s = %s\n", |
| 138 | __func__, record, name, buf); |
| 139 | return ret; |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | return ret; |
| 144 | } |
| 145 | |
| 146 | int factoryset_read_eeprom(int i2c_addr) |
| 147 | { |
| 148 | int i, pages = 0, size = 0; |
| 149 | unsigned char eeprom_buf[0x3c00], hdr[4], buf[MAX_STRING_LENGTH]; |
| 150 | unsigned char *cp, *cp1; |
| 151 | |
Marek Vasut | 7f8d436 | 2018-02-16 16:41:18 +0100 | [diff] [blame] | 152 | #if defined(CONFIG_DFU_OVER_USB) |
Maxime Ripard | 7f78b9d | 2017-09-07 08:58:08 +0200 | [diff] [blame] | 153 | factory_dat.usb_vendor_id = CONFIG_USB_GADGET_VENDOR_NUM; |
| 154 | factory_dat.usb_product_id = CONFIG_USB_GADGET_PRODUCT_NUM; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 155 | #endif |
Anatolij Gustschin | d0d75f5 | 2019-07-10 19:44:15 +0200 | [diff] [blame] | 156 | |
Enrico Leto | 32f433f | 2024-01-24 15:43:50 +0100 | [diff] [blame^] | 157 | if (siemens_ee_read_data(SIEMENS_EE_ADDR_FACTORYSET, hdr, sizeof(hdr))) |
Anatolij Gustschin | d0d75f5 | 2019-07-10 19:44:15 +0200 | [diff] [blame] | 158 | goto err; |
| 159 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 160 | if ((hdr[0] != 0x99) || (hdr[1] != 0x80)) { |
| 161 | printf("FactorySet is not right in eeprom.\n"); |
| 162 | return 1; |
| 163 | } |
| 164 | |
| 165 | /* get FactorySet size */ |
| 166 | size = (hdr[2] << 8) + hdr[3] + sizeof(hdr); |
| 167 | if (size > 0x3bfa) |
| 168 | size = 0x3bfa; |
| 169 | |
| 170 | pages = size / EEPR_PG_SZ; |
| 171 | |
| 172 | /* |
| 173 | * read the eeprom using i2c |
| 174 | * I can not read entire eeprom in once, so separate into several |
| 175 | * times. Furthermore, fetch eeprom take longer time, so we fetch |
| 176 | * data after every time we got a record from eeprom |
| 177 | */ |
| 178 | debug("Read eeprom page :\n"); |
Enrico Leto | 32f433f | 2024-01-24 15:43:50 +0100 | [diff] [blame^] | 179 | for (i = 0; i < pages; i++) |
| 180 | if (siemens_ee_read_data((OFF_PG + i) * EEPR_PG_SZ, |
| 181 | eeprom_buf + (i * EEPR_PG_SZ), EEPR_PG_SZ)) |
Anatolij Gustschin | d0d75f5 | 2019-07-10 19:44:15 +0200 | [diff] [blame] | 182 | goto err; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 183 | |
Enrico Leto | 32f433f | 2024-01-24 15:43:50 +0100 | [diff] [blame^] | 184 | if (size % EEPR_PG_SZ) |
| 185 | if (siemens_ee_read_data((OFF_PG + pages) * EEPR_PG_SZ, |
| 186 | eeprom_buf + (pages * EEPR_PG_SZ), |
| 187 | size % EEPR_PG_SZ)) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 188 | goto err; |
| 189 | |
| 190 | /* we do below just for eeprom align */ |
| 191 | for (i = 0; i < size; i++) |
| 192 | if (eeprom_buf[i] == '\n') |
| 193 | eeprom_buf[i] = 0; |
| 194 | |
| 195 | /* skip header */ |
| 196 | size -= sizeof(hdr); |
| 197 | cp = (uchar *)eeprom_buf + sizeof(hdr); |
| 198 | |
| 199 | /* get mac address */ |
| 200 | get_factory_record_val(cp, size, (uchar *)"ETH1", (uchar *)"mac", |
| 201 | buf, MAX_STRING_LENGTH); |
| 202 | cp1 = buf; |
| 203 | for (i = 0; i < 6; i++) { |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 204 | factory_dat.mac[i] = hextoul((char *)cp1, NULL); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 205 | cp1 += 3; |
| 206 | } |
| 207 | |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 208 | #if CONFIG_IS_ENABLED(TARGET_GIEDI) || CONFIG_IS_ENABLED(TARGET_DENEB) |
| 209 | /* get mac address for WLAN */ |
Enrico Leto | 32f433f | 2024-01-24 15:43:50 +0100 | [diff] [blame^] | 210 | if (get_factory_record_val(cp, size, (uchar *)"WLAN1", (uchar *)"mac", |
| 211 | buf, MAX_STRING_LENGTH) > 0) { |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 212 | cp1 = buf; |
| 213 | for (i = 0; i < 6; i++) { |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 214 | factory_dat.mac_wlan[i] = hextoul((char *)cp1, NULL); |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 215 | cp1 += 3; |
| 216 | } |
| 217 | } |
| 218 | #endif |
| 219 | |
Marek Vasut | 7f8d436 | 2018-02-16 16:41:18 +0100 | [diff] [blame] | 220 | #if defined(CONFIG_DFU_OVER_USB) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 221 | /* read vid and pid for dfu mode */ |
| 222 | if (0 <= get_factory_record_val(cp, size, (uchar *)"USBD1", |
| 223 | (uchar *)"vid", buf, |
| 224 | MAX_STRING_LENGTH)) { |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 225 | factory_dat.usb_vendor_id = hextoul((char *)buf, NULL); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | if (0 <= get_factory_record_val(cp, size, (uchar *)"USBD1", |
| 229 | (uchar *)"pid", buf, |
| 230 | MAX_STRING_LENGTH)) { |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 231 | factory_dat.usb_product_id = hextoul((char *)buf, NULL); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 232 | } |
| 233 | printf("DFU USB: VID = 0x%4x, PID = 0x%4x\n", factory_dat.usb_vendor_id, |
| 234 | factory_dat.usb_product_id); |
| 235 | #endif |
Samuel Egli | 8069bfe | 2013-11-04 14:05:03 +0100 | [diff] [blame] | 236 | if (0 <= get_factory_record_val(cp, size, (uchar *)"DEV", |
| 237 | (uchar *)"num", factory_dat.serial, |
| 238 | MAX_STRING_LENGTH)) { |
| 239 | debug("serial number: %s\n", factory_dat.serial); |
| 240 | } |
| 241 | if (0 <= get_factory_record_val(cp, size, (uchar *)"DEV", |
| 242 | (uchar *)"ver", buf, |
| 243 | MAX_STRING_LENGTH)) { |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 244 | factory_dat.version = hextoul((char *)buf, NULL); |
Samuel Egli | 8069bfe | 2013-11-04 14:05:03 +0100 | [diff] [blame] | 245 | debug("version number: %d\n", factory_dat.version); |
| 246 | } |
Heiko Schocher | faf2dc6 | 2014-11-18 11:51:06 +0100 | [diff] [blame] | 247 | /* Get ASN from factory set if available */ |
| 248 | if (0 <= get_factory_record_val(cp, size, (uchar *)"DEV", |
| 249 | (uchar *)"id", factory_dat.asn, |
| 250 | MAX_STRING_LENGTH)) { |
| 251 | debug("factoryset asn: %s\n", factory_dat.asn); |
| 252 | } else { |
| 253 | factory_dat.asn[0] = 0; |
| 254 | } |
Heiko Schocher | 7b90565 | 2014-11-18 11:51:05 +0100 | [diff] [blame] | 255 | /* Get COMP/ver from factory set if available */ |
| 256 | if (0 <= get_factory_record_val(cp, size, (uchar *)"COMP", |
| 257 | (uchar *)"ver", |
| 258 | factory_dat.comp_version, |
| 259 | MAX_STRING_LENGTH)) { |
| 260 | debug("factoryset COMP/ver: %s\n", factory_dat.comp_version); |
| 261 | } else { |
| 262 | strcpy((char *)factory_dat.comp_version, "1.0"); |
| 263 | } |
| 264 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 265 | return 0; |
| 266 | |
| 267 | err: |
| 268 | printf("Could not read the EEPROM; something fundamentally wrong on the I2C bus.\n"); |
| 269 | return 1; |
| 270 | } |
| 271 | |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 272 | static int get_mac_from_efuse(uint8_t mac[6]) |
| 273 | { |
| 274 | #ifdef CONFIG_AM33XX |
| 275 | struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
| 276 | uint32_t mac_hi, mac_lo; |
| 277 | |
| 278 | mac_lo = readl(&cdev->macid0l); |
| 279 | mac_hi = readl(&cdev->macid0h); |
| 280 | |
| 281 | mac[0] = mac_hi & 0xFF; |
| 282 | mac[1] = (mac_hi & 0xFF00) >> 8; |
| 283 | mac[2] = (mac_hi & 0xFF0000) >> 16; |
| 284 | mac[3] = (mac_hi & 0xFF000000) >> 24; |
| 285 | mac[4] = mac_lo & 0xFF; |
| 286 | mac[5] = (mac_lo & 0xFF00) >> 8; |
| 287 | #else |
| 288 | /* unhandled */ |
| 289 | memset(mac, 0, 6); |
| 290 | #endif |
| 291 | if (!is_valid_ethaddr(mac)) { |
| 292 | puts("Warning: ethaddr not set by FactorySet or E-fuse. "); |
| 293 | puts("Set <ethaddr> variable to overcome this.\n"); |
| 294 | return -1; |
| 295 | } |
| 296 | return 0; |
| 297 | } |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 298 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 299 | static int factoryset_mac_env_set(void) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 300 | { |
| 301 | uint8_t mac_addr[6]; |
| 302 | |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 303 | /* Set mac from factoryset or try reading E-fuse */ |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 304 | debug("FactorySet: Set mac address\n"); |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 305 | if (is_valid_ethaddr(factory_dat.mac)) { |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 306 | memcpy(mac_addr, factory_dat.mac, 6); |
| 307 | } else { |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 308 | debug("Warning: FactorySet: <ethaddr> not set. Fallback to E-fuse\n"); |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 309 | if (get_mac_from_efuse(mac_addr) < 0) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 310 | return -1; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 311 | } |
| 312 | |
Simon Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 313 | eth_env_set_enetaddr("ethaddr", mac_addr); |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 314 | |
| 315 | #if CONFIG_IS_ENABLED(TARGET_GIEDI) || CONFIG_IS_ENABLED(TARGET_DENEB) |
| 316 | eth_env_set_enetaddr("eth1addr", mac_addr); |
| 317 | |
| 318 | /* wlan mac */ |
| 319 | if (is_valid_ethaddr(factory_dat.mac_wlan)) |
| 320 | eth_env_set_enetaddr("eth2addr", factory_dat.mac_wlan); |
| 321 | #endif |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 322 | return 0; |
| 323 | } |
| 324 | |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 325 | static void factoryset_dtb_env_set(void) |
| 326 | { |
| 327 | /* Set ASN in environment*/ |
| 328 | if (factory_dat.asn[0] != 0) { |
| 329 | env_set("dtb_name", (char *)factory_dat.asn); |
| 330 | } else { |
| 331 | /* dtb suffix gets added in load script */ |
| 332 | env_set("dtb_name", "default"); |
| 333 | } |
| 334 | } |
| 335 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 336 | int factoryset_env_set(void) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 337 | { |
| 338 | int ret = 0; |
| 339 | |
Anatolij Gustschin | 8e9821e | 2019-07-10 19:44:16 +0200 | [diff] [blame] | 340 | factoryset_dtb_env_set(); |
| 341 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 342 | if (factoryset_mac_env_set() < 0) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 343 | ret = -1; |
| 344 | |
| 345 | return ret; |
| 346 | } |
| 347 | |
Lukasz Majewski | 44b5b38 | 2013-10-08 14:30:41 +0200 | [diff] [blame] | 348 | int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 349 | { |
| 350 | put_unaligned(factory_dat.usb_vendor_id, &dev->idVendor); |
| 351 | put_unaligned(factory_dat.usb_product_id, &dev->idProduct); |
Samuel Egli | 8069bfe | 2013-11-04 14:05:03 +0100 | [diff] [blame] | 352 | g_dnl_set_serialnumber((char *)factory_dat.serial); |
| 353 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 354 | return 0; |
| 355 | } |
Samuel Egli | 8069bfe | 2013-11-04 14:05:03 +0100 | [diff] [blame] | 356 | |
| 357 | int g_dnl_get_board_bcd_device_number(int gcnum) |
| 358 | { |
| 359 | return factory_dat.version; |
| 360 | } |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 361 | #endif /* defined(CONFIG_SPL_BUILD) */ |