blob: e0975fcda7050942a0b764363fa4cd2f5453d982 [file] [log] [blame]
Peng Fanf9220172019-08-27 06:26:08 +00001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2018 NXP
4 */
5
6#include <common.h>
Simon Glassed38aef2020-05-10 11:40:03 -06007#include <env.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Peng Fane5f2b222019-10-22 03:30:04 +00009#include <miiphy.h>
10#include <netdev.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060011#include <asm/global_data.h>
Peng Fane5f2b222019-10-22 03:30:04 +000012
13#include <asm/arch/clock.h>
Alifer Moraesc1a2a1f2020-01-14 11:22:57 -030014#include <asm/arch/sys_proto.h>
Peng Fane5f2b222019-10-22 03:30:04 +000015#include <asm/io.h>
Peng Fanf9220172019-08-27 06:26:08 +000016
17DECLARE_GLOBAL_DATA_PTR;
18
Peng Fane5f2b222019-10-22 03:30:04 +000019#if IS_ENABLED(CONFIG_FEC_MXC)
20static int setup_fec(void)
21{
22 struct iomuxc_gpr_base_regs *gpr =
23 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
24
25 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
26 clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
27
28 return 0;
29}
30
31int board_phy_config(struct phy_device *phydev)
32{
33 /* enable rgmii rxc skew and phy mode select to RGMII copper */
34 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
35 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
36
37 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
38 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
39 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
40 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
41
42 if (phydev->drv->config)
43 phydev->drv->config(phydev);
44 return 0;
45}
46#endif
47
Peng Fanf9220172019-08-27 06:26:08 +000048int board_init(void)
49{
Peng Fane5f2b222019-10-22 03:30:04 +000050 if (IS_ENABLED(CONFIG_FEC_MXC))
51 setup_fec();
52
Peng Fanf9220172019-08-27 06:26:08 +000053 return 0;
54}
55
Peng Fan3a7e3402019-10-09 03:08:17 +000056int board_mmc_get_env_dev(int devno)
57{
58 return devno;
59}
60
Peng Fanf9220172019-08-27 06:26:08 +000061int board_late_init(void)
62{
Tommaso Merciai1549d6b2021-12-26 18:23:11 +010063 if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) {
64 env_set("board_name", "EVK");
65 env_set("board_rev", "iMX8MM");
66 }
67
Peng Fanf9220172019-08-27 06:26:08 +000068 return 0;
69}