cp1 += 3;
}
+#if CONFIG_IS_ENABLED(TARGET_GIEDI) || CONFIG_IS_ENABLED(TARGET_DENEB)
+ /* get mac address for WLAN */
+ ret = get_factory_record_val(cp, size, (uchar *)"WLAN1", (uchar *)"mac",
+ buf, MAX_STRING_LENGTH);
+ if (ret > 0) {
+ cp1 = buf;
+ for (i = 0; i < 6; i++) {
+ factory_dat.mac_wlan[i] = simple_strtoul((char *)cp1,
+ NULL, 16);
+ cp1 += 3;
+ }
+ }
+#endif
+
#if defined(CONFIG_DFU_OVER_USB)
/* read vid and pid for dfu mode */
if (0 <= get_factory_record_val(cp, size, (uchar *)"USBD1",
return 1;
}
-static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
+static int get_mac_from_efuse(uint8_t mac[6])
+{
+#ifdef CONFIG_AM33XX
+ struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
+ uint32_t mac_hi, mac_lo;
+
+ mac_lo = readl(&cdev->macid0l);
+ mac_hi = readl(&cdev->macid0h);
+
+ mac[0] = mac_hi & 0xFF;
+ mac[1] = (mac_hi & 0xFF00) >> 8;
+ mac[2] = (mac_hi & 0xFF0000) >> 16;
+ mac[3] = (mac_hi & 0xFF000000) >> 24;
+ mac[4] = mac_lo & 0xFF;
+ mac[5] = (mac_lo & 0xFF00) >> 8;
+#else
+ /* unhandled */
+ memset(mac, 0, 6);
+#endif
+ if (!is_valid_ethaddr(mac)) {
+ puts("Warning: ethaddr not set by FactorySet or E-fuse. ");
+ puts("Set <ethaddr> variable to overcome this.\n");
+ return -1;
+ }
+ return 0;
+}
static int factoryset_mac_env_set(void)
{
uint8_t mac_addr[6];
+ /* Set mac from factoryset or try reading E-fuse */
debug("FactorySet: Set mac address\n");
if (is_valid_ethaddr(factory_dat.mac)) {
memcpy(mac_addr, factory_dat.mac, 6);
} else {
- uint32_t mac_hi, mac_lo;
-
debug("Warning: FactorySet: <ethaddr> not set. Fallback to E-fuse\n");
- mac_lo = readl(&cdev->macid0l);
- mac_hi = readl(&cdev->macid0h);
-
- mac_addr[0] = mac_hi & 0xFF;
- mac_addr[1] = (mac_hi & 0xFF00) >> 8;
- mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
- mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
- mac_addr[4] = mac_lo & 0xFF;
- mac_addr[5] = (mac_lo & 0xFF00) >> 8;
- if (!is_valid_ethaddr(mac_addr)) {
- printf("Warning: ethaddr not set by FactorySet or E-fuse. Set <ethaddr> variable to overcome this.\n");
+ if (get_mac_from_efuse(mac_addr) < 0)
return -1;
- }
}
eth_env_set_enetaddr("ethaddr", mac_addr);
+
+#if CONFIG_IS_ENABLED(TARGET_GIEDI) || CONFIG_IS_ENABLED(TARGET_DENEB)
+ eth_env_set_enetaddr("eth1addr", mac_addr);
+
+ /* wlan mac */
+ if (is_valid_ethaddr(factory_dat.mac_wlan))
+ eth_env_set_enetaddr("eth2addr", factory_dat.mac_wlan);
+#endif
return 0;
}
+static void factoryset_dtb_env_set(void)
+{
+ /* Set ASN in environment*/
+ if (factory_dat.asn[0] != 0) {
+ env_set("dtb_name", (char *)factory_dat.asn);
+ } else {
+ /* dtb suffix gets added in load script */
+ env_set("dtb_name", "default");
+ }
+}
+
int factoryset_env_set(void)
{
int ret = 0;
+ factoryset_dtb_env_set();
+
if (factoryset_mac_env_set() < 0)
ret = -1;