1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Altera Corporation <www.altera.com>
11 #include <status_led.h>
12 #include <asm/arch/reset_manager.h>
16 #include <linux/delay.h>
18 DECLARE_GLOBAL_DATA_PTR;
21 * Miscellaneous platform dependent initialisations
23 int board_late_init(void)
25 const unsigned int phy_nrst_gpio = 0;
26 const unsigned int usb_nrst_gpio = 35;
29 status_led_set(1, CONFIG_LED_STATUS_ON);
30 status_led_set(2, CONFIG_LED_STATUS_ON);
32 /* Address of boot parameters for ATAG (if ATAG is used) */
33 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
35 ret = gpio_request(phy_nrst_gpio, "phy_nrst_gpio");
37 gpio_direction_output(phy_nrst_gpio, 1);
39 printf("Cannot remove PHY from reset!\n");
41 ret = gpio_request(usb_nrst_gpio, "usb_nrst_gpio");
43 gpio_direction_output(usb_nrst_gpio, 1);
45 printf("Cannot remove USB from reset!\n");
52 #ifndef CONFIG_SPL_BUILD
60 /* EEPROM is at address 0x50 (at bus CONFIG_SYS_EEPROM_BUS_NUM). */
61 ret = eeprom_read(0x50, 0, data, sizeof(data));
63 puts("Cannot read I2C EEPROM.\n");
67 /* Check EEPROM signature. */
68 if (!(data[0] == 0xa5 && data[1] == 0x5a)) {
69 puts("Invalid I2C EEPROM signature.\n");
70 env_set("unit_serial", "invalid");
71 env_set("unit_ident", "VINing-xxxx-STD");
72 env_set("hostname", "vining-invalid");
76 /* If 'unit_serial' is already set, do nothing. */
77 if (!env_get("unit_serial")) {
78 /* This field is Big Endian ! */
79 serial = (data[0x54] << 24) | (data[0x55] << 16) |
80 (data[0x56] << 8) | (data[0x57] << 0);
81 memset(str, 0, sizeof(str));
82 sprintf(str, "%07i", serial);
83 env_set("unit_serial", str);
86 if (!env_get("unit_ident")) {
87 memset(str, 0, sizeof(str));
88 memcpy(str, &data[0x2e], 18);
89 env_set("unit_ident", str);
92 /* Set ethernet address from EEPROM. */
93 if (!env_get("ethaddr") && is_valid_ethaddr(&data[0x62]))
94 eth_env_set_enetaddr("ethaddr", &data[0x62]);
95 if (!env_get("eth1addr") && is_valid_ethaddr(&data[0x6a]))
96 eth_env_set_enetaddr("eth1addr", &data[0x6a]);