2 * Copyright (C) 2012 Altera Corporation <www.altera.com>
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <asm/arch/reset_manager.h>
13 DECLARE_GLOBAL_DATA_PTR;
16 * Miscellaneous platform dependent initialisations
18 int board_late_init(void)
20 const unsigned int phy_nrst_gpio = 0;
21 const unsigned int usb_nrst_gpio = 35;
24 status_led_set(1, STATUS_LED_ON);
25 status_led_set(2, STATUS_LED_ON);
27 /* Address of boot parameters for ATAG (if ATAG is used) */
28 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
30 ret = gpio_request(phy_nrst_gpio, "phy_nrst_gpio");
32 gpio_direction_output(phy_nrst_gpio, 1);
34 printf("Cannot remove PHY from reset!\n");
36 ret = gpio_request(usb_nrst_gpio, "usb_nrst_gpio");
38 gpio_direction_output(usb_nrst_gpio, 1);
40 printf("Cannot remove USB from reset!\n");
47 #ifndef CONFIG_SPL_BUILD
55 /* EEPROM is at bus 0. */
56 ret = i2c_set_bus_num(0);
58 puts("Cannot select EEPROM I2C bus.\n");
62 /* EEPROM is at address 0x50. */
63 ret = eeprom_read(0x50, 0, data, sizeof(data));
65 puts("Cannot read I2C EEPROM.\n");
69 /* Check EEPROM signature. */
70 if (!(data[0] == 0xa5 && data[1] == 0x5a)) {
71 puts("Invalid I2C EEPROM signature.\n");
72 setenv("unit_serial", "invalid");
73 setenv("unit_ident", "VINing-xxxx-STD");
74 setenv("hostname", "vining-invalid");
78 /* If 'unit_serial' is already set, do nothing. */
79 if (!getenv("unit_serial")) {
80 /* This field is Big Endian ! */
81 serial = (data[0x54] << 24) | (data[0x55] << 16) |
82 (data[0x56] << 8) | (data[0x57] << 0);
83 memset(str, 0, sizeof(str));
84 sprintf(str, "%07i", serial);
85 setenv("unit_serial", str);
88 if (!getenv("unit_ident")) {
89 memset(str, 0, sizeof(str));
90 memcpy(str, &data[0x2e], 18);
91 setenv("unit_ident", str);
94 /* Set ethernet address from EEPROM. */
95 if (!getenv("ethaddr") && is_valid_ethaddr(&data[0x62]))
96 eth_setenv_enetaddr("ethaddr", &data[0x62]);