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>
10 #include <efi_loader.h>
11 #include <fdt_support.h>
12 #include <linux/errno.h>
13 #include <linux/kernel.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 #if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT)
19 struct efi_fw_image fw_images[] = {
21 .image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID,
22 .fw_name = u"KONTROL-SL-MX8MM-UBOOT",
27 struct efi_capsule_update_info update_info = {
28 .dfu_string = "sf 0:0=flash-bin raw 0x400 0x1f0000",
32 u8 num_image_type_guids = ARRAY_SIZE(fw_images);
33 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
35 int board_phys_sdram_size(phys_size_t *size)
37 u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR);
41 } else if (ddr_size == 3) {
43 } else if (ddr_size == 2) {
45 } else if (ddr_size == 1) {
48 printf("Unknown DDR type!!!\n");
56 * If the SoM is mounted on a baseboard with a USB ethernet controller,
57 * there might be an additional MAC address programmed to the MAC OTP fuses.
58 * Although the i.MX8MM has only one MAC, the MAC0, MAC1 and MAC2 registers
59 * in the OTP fuses can still be used to store two separate addresses.
60 * Try to read the secondary address from MAC1 and MAC2 and adjust the
61 * devicetree so Linux can pick up the MAC address.
63 int fdt_set_usb_eth_addr(void *blob)
65 u32 value = readl(OCOTP_BASE_ADDR + 0x660);
74 value = readl(OCOTP_BASE_ADDR + 0x650);
78 node = fdt_path_offset(blob, fdt_get_alias(blob, "ethernet1"));
81 * There is no node for the USB ethernet in the devicetree. Just skip.
86 if (is_zero_ethaddr(mac)) {
87 printf("\nNo MAC address for USB ethernet set in OTP fuses!\n");
91 if (!is_valid_ethaddr(mac)) {
92 printf("\nInvalid MAC address for USB ethernet set in OTP fuses!\n");
96 ret = fdt_setprop(blob, node, "local-mac-address", &mac, 6);
98 ret = fdt_setprop(blob, node, "mac-address", &mac, 6);
101 printf("\nMissing mac-address or local-mac-address property in dt, skip setting MAC address for USB ethernet\n");
106 int ft_board_setup(void *blob, struct bd_info *bd)
108 int ret = fdt_set_usb_eth_addr(blob);
113 return fdt_fixup_memory(blob, PHYS_SDRAM, gd->ram_size);