1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2018 Marvell International Ltd.
5 * https://spdx.org/licenses
17 #include <linux/compiler.h>
18 #include <linux/libfdt.h>
19 #include <fdt_support.h>
20 #include <asm/arch/smc.h>
21 #include <asm/arch/soc.h>
22 #include <asm/arch/board.h>
25 DECLARE_GLOBAL_DATA_PTR;
27 void octeontx_cleanup_ethaddr(void)
31 for (int i = 0; i < 20; i++) {
32 sprintf(ename, i ? "eth%daddr" : "ethaddr", i);
38 int octeontx_board_has_pmp(void)
40 return (otx_is_board("sff8104") || otx_is_board("nas8104"));
43 int board_early_init_r(void)
51 if (IS_ENABLED(CONFIG_NET_OCTEONTX))
64 gd->ram_size = smc_dram_size(0);
65 gd->ram_size -= CONFIG_SYS_SDRAM_BASE;
71 void board_late_probe_devices(void)
76 /* Probe MAC(BGX) and NIC PF devices before Network stack init */
77 bgx_cnt = otx_is_soc(CN81XX) ? 2 : 4;
78 for (i = 0; i < bgx_cnt; i++) {
79 err = dm_pci_find_device(PCI_VENDOR_ID_CAVIUM,
80 PCI_DEVICE_ID_CAVIUM_BGX, i, &dev);
82 debug("%s BGX%d device not found\n", __func__, i);
84 if (otx_is_soc(CN81XX)) {
85 err = dm_pci_find_device(PCI_VENDOR_ID_CAVIUM,
86 PCI_DEVICE_ID_CAVIUM_RGX, 0, &dev);
88 debug("%s RGX device not found\n", __func__);
90 err = dm_pci_find_device(PCI_VENDOR_ID_CAVIUM,
91 PCI_DEVICE_ID_CAVIUM_NIC, 0, &dev);
93 debug("NIC PF device not found\n");
97 * Board late initialization routine.
99 int board_late_init(void)
102 char boardserial[150], boardrev[150];
103 bool save_env = false;
107 * Try to cleanup ethaddr env variables, this is needed
108 * as with each boot, configuration of network interfaces can change.
110 octeontx_cleanup_ethaddr();
112 snprintf(boardname, sizeof(boardname), "%s> ", fdt_get_board_model());
113 env_set("prompt", boardname);
115 set_working_fdt_addr(env_get_hex("fdtcontroladdr", fdt_base_addr));
117 str = fdt_get_board_revision();
119 snprintf(boardrev, sizeof(boardrev), "%s", str);
120 if (env_get("boardrev") &&
121 strcmp(boardrev, env_get("boardrev")))
123 env_set("boardrev", boardrev);
126 str = fdt_get_board_serial();
128 snprintf(boardserial, sizeof(boardserial), "%s", str);
129 if (env_get("serial#") &&
130 strcmp(boardserial, env_get("serial#")))
132 env_set("serial#", boardserial);
135 if (IS_ENABLED(CONFIG_NET_OCTEONTX))
136 board_late_probe_devices();
145 * Invoked before relocation, so limit to stack variables.
149 printf("Board: %s\n", fdt_get_board_model());