1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Altera Corporation <www.altera.com>
9 #include <status_led.h>
10 #include <asm/arch/reset_manager.h>
15 DECLARE_GLOBAL_DATA_PTR;
18 * Miscellaneous platform dependent initialisations
20 int board_late_init(void)
22 const unsigned int phy_nrst_gpio = 0;
23 const unsigned int usb_nrst_gpio = 35;
26 status_led_set(1, CONFIG_LED_STATUS_ON);
27 status_led_set(2, CONFIG_LED_STATUS_ON);
29 /* Address of boot parameters for ATAG (if ATAG is used) */
30 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
32 ret = gpio_request(phy_nrst_gpio, "phy_nrst_gpio");
34 gpio_direction_output(phy_nrst_gpio, 1);
36 printf("Cannot remove PHY from reset!\n");
38 ret = gpio_request(usb_nrst_gpio, "usb_nrst_gpio");
40 gpio_direction_output(usb_nrst_gpio, 1);
42 printf("Cannot remove USB from reset!\n");
49 #ifndef CONFIG_SPL_BUILD
57 /* EEPROM is at address 0x50 (at bus CONFIG_SYS_EEPROM_BUS_NUM). */
58 ret = eeprom_read(0x50, 0, data, sizeof(data));
60 puts("Cannot read I2C EEPROM.\n");
64 /* Check EEPROM signature. */
65 if (!(data[0] == 0xa5 && data[1] == 0x5a)) {
66 puts("Invalid I2C EEPROM signature.\n");
67 env_set("unit_serial", "invalid");
68 env_set("unit_ident", "VINing-xxxx-STD");
69 env_set("hostname", "vining-invalid");
73 /* If 'unit_serial' is already set, do nothing. */
74 if (!env_get("unit_serial")) {
75 /* This field is Big Endian ! */
76 serial = (data[0x54] << 24) | (data[0x55] << 16) |
77 (data[0x56] << 8) | (data[0x57] << 0);
78 memset(str, 0, sizeof(str));
79 sprintf(str, "%07i", serial);
80 env_set("unit_serial", str);
83 if (!env_get("unit_ident")) {
84 memset(str, 0, sizeof(str));
85 memcpy(str, &data[0x2e], 18);
86 env_set("unit_ident", str);
89 /* Set ethernet address from EEPROM. */
90 if (!env_get("ethaddr") && is_valid_ethaddr(&data[0x62]))
91 eth_env_set_enetaddr("ethaddr", &data[0x62]);
92 if (!env_get("eth1addr") && is_valid_ethaddr(&data[0x6a]))
93 eth_env_set_enetaddr("eth1addr", &data[0x6a]);