1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2019 Kontron Electronics GmbH
6 #include <asm/arch/imx-regs.h>
7 #include <asm/global_data.h>
9 #include <fdt_support.h>
10 #include <linux/errno.h>
13 DECLARE_GLOBAL_DATA_PTR;
15 int board_phys_sdram_size(phys_size_t *size)
17 u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR);
21 } else if (ddr_size == 3) {
23 } else if (ddr_size == 2) {
25 } else if (ddr_size == 1) {
28 printf("Unknown DDR type!!!\n");
36 * If the SoM is mounted on a baseboard with a USB ethernet controller,
37 * there might be an additional MAC address programmed to the MAC OTP fuses.
38 * Although the i.MX8MM has only one MAC, the MAC0, MAC1 and MAC2 registers
39 * in the OTP fuses can still be used to store two separate addresses.
40 * Try to read the secondary address from MAC1 and MAC2 and adjust the
41 * devicetree so Linux can pick up the MAC address.
43 int fdt_set_usb_eth_addr(void *blob)
45 u32 value = readl(OCOTP_BASE_ADDR + 0x660);
54 value = readl(OCOTP_BASE_ADDR + 0x650);
58 node = fdt_path_offset(blob, fdt_get_alias(blob, "ethernet1"));
61 * There is no node for the USB ethernet in the devicetree. Just skip.
66 if (is_zero_ethaddr(mac)) {
67 printf("\nNo MAC address for USB ethernet set in OTP fuses!\n");
71 if (!is_valid_ethaddr(mac)) {
72 printf("\nInvalid MAC address for USB ethernet set in OTP fuses!\n");
76 ret = fdt_setprop(blob, node, "local-mac-address", &mac, 6);
78 ret = fdt_setprop(blob, node, "mac-address", &mac, 6);
81 printf("\nMissing mac-address or local-mac-address property in dt, skip setting MAC address for USB ethernet\n");
86 int ft_board_setup(void *blob, struct bd_info *bd)
88 int ret = fdt_set_usb_eth_addr(blob);
93 return fdt_fixup_memory(blob, PHYS_SDRAM, gd->ram_size);