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