1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Copyright 2022 Marek Vasut <marex@denx.de> 4 */ 5 6#include <common.h> 7#include <asm/arch/clock.h> 8#include <asm/arch/imx8mm_pins.h> 9#include <asm/io.h> 10#include <dm.h> 11#include <dm/device-internal.h> 12#include <linux/bitfield.h> 13#include <malloc.h> 14#include <spl.h> 15 16#include "../common/common.h" 17 18DECLARE_GLOBAL_DATA_PTR; 19 20int board_init(void) 21{ 22 return 0; 23} 24 25int board_late_init(void) 26{ 27 struct udevice *dev; 28 int ret; 29 30 dmo_setup_boot_device(); 31 dmo_setup_mac_address(); 32 33 ret = uclass_get_device_by_name(UCLASS_MISC, "usb-hub@2c", &dev); 34 if (ret) 35 printf("Error bringing up USB hub (%d)\n", ret); 36 37 return 0; 38} 39 40int fdtdec_board_setup(const void *fdt_blob) 41{ 42 const void __iomem *mux = (void __iomem *)IOMUXC_BASE_ADDR + 43 FIELD_GET(MUX_CTRL_OFS_MASK, IMX8MM_PAD_ENET_MDC_GPIO1_IO16); 44 const char *phy_compat = "ethernet-phy-ieee802.3-c22"; 45 bool is_bcmphy; 46 int phy_node; 47 int ret; 48 49 /* Do nothing if not i.MX8MM eDM SBC */ 50 ret = fdt_node_check_compatible(fdt_blob, 0, "dmo,imx8mm-data-modul-edm-sbc"); 51 if (ret) 52 return 0; 53 54 /* 55 * If GPIO1_16 RGMII_MDC is HIGH, then R530 is populated. 56 * R530 is populated only on boards with AR8031 PHY. 57 * 58 * If GPIO1_16 RGMII_MDC is LOW, then the in-SoM pull down 59 * is the dominant pull resistor. This is the case on boards 60 * with BCM54213PE PHY. 61 */ 62 setbits_le32(mux, IOMUX_CONFIG_SION); 63 is_bcmphy = !(readl(GPIO1_BASE_ADDR) & BIT(16)); 64 clrbits_le32(mux, IOMUX_CONFIG_SION); 65 66 phy_node = fdt_node_offset_by_compatible(fdt_blob, -1, phy_compat); 67 if (phy_node < 0) 68 return 0; 69 70 /* 71 * Update PHY MDC address in control DT based on the populated 72 * PHY type. AR8031 is at address 0, BCM54213PE is at address 1. 73 */ 74 fdt_setprop_inplace_u32((void *)fdt_blob, phy_node, 75 "reg", is_bcmphy ? 1 : 0); 76 77 return 0; 78} 79