2019-12-30 09:46:21 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright 2019 NXP
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:03 +00:00
|
|
|
#include <env.h>
|
2019-12-30 09:46:21 +00:00
|
|
|
#include <errno.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-12-25 08:16:34 +00:00
|
|
|
#include <miiphy.h>
|
|
|
|
#include <netdev.h>
|
|
|
|
#include <linux/delay.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2019-12-30 09:46:21 +00:00
|
|
|
#include <asm/mach-imx/iomux-v3.h>
|
|
|
|
#include <asm-generic/gpio.h>
|
|
|
|
#include <asm/arch/imx8mp_pins.h>
|
2020-12-25 08:16:34 +00:00
|
|
|
#include <asm/arch/clock.h>
|
2019-12-30 09:46:21 +00:00
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
#include <asm/mach-imx/gpio.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2020-12-25 08:16:34 +00:00
|
|
|
static void setup_fec(void)
|
|
|
|
{
|
|
|
|
struct iomuxc_gpr_base_regs *gpr =
|
|
|
|
(struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
|
|
|
|
|
|
|
|
/* Enable RGMII TX clk output */
|
|
|
|
setbits_le32(&gpr->gpr[1], BIT(22));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int setup_eqos(void)
|
|
|
|
{
|
|
|
|
struct iomuxc_gpr_base_regs *gpr =
|
|
|
|
(struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
|
|
|
|
|
|
|
|
/* set INTF as RGMII, enable RGMII TXC clock */
|
|
|
|
clrsetbits_le32(&gpr->gpr[1],
|
|
|
|
IOMUXC_GPR_GPR1_GPR_ENET_QOS_INTF_SEL_MASK, BIT(16));
|
|
|
|
setbits_le32(&gpr->gpr[1], BIT(19) | BIT(21));
|
|
|
|
|
|
|
|
return set_clk_eqos(ENET_125MHZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CONFIG_IS_ENABLED(NET)
|
|
|
|
int board_phy_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
if (phydev->drv->config)
|
|
|
|
phydev->drv->config(phydev);
|
2019-12-30 09:46:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2020-12-25 08:16:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (CONFIG_IS_ENABLED(FEC_MXC)) {
|
|
|
|
setup_fec();
|
2021-08-16 10:44:29 +00:00
|
|
|
}
|
2020-12-25 08:16:34 +00:00
|
|
|
|
2021-08-16 10:44:29 +00:00
|
|
|
if (CONFIG_IS_ENABLED(DWC_ETH_QOS)) {
|
|
|
|
ret = setup_eqos();
|
2020-12-25 08:16:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2019-12-30 09:46:21 +00:00
|
|
|
|
|
|
|
int board_late_init(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
|
|
|
env_set("board_name", "EVK");
|
|
|
|
env_set("board_rev", "iMX8MP");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|