blob: c5fd940eeb741f674d0820f20802ba8acef81077 [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>
Peng Fane5f2b222019-10-22 03:30:04 +00007#include <miiphy.h>
8#include <netdev.h>
9
10#include <asm/arch/clock.h>
Alifer Moraesc1a2a1f2020-01-14 11:22:57 -030011#include <asm/arch/sys_proto.h>
Peng Fane5f2b222019-10-22 03:30:04 +000012#include <asm/io.h>
Peng Fanf9220172019-08-27 06:26:08 +000013
14DECLARE_GLOBAL_DATA_PTR;
15
16int dram_init(void)
17{
18 gd->ram_size = PHYS_SDRAM_SIZE;
19
20 return 0;
21}
22
Peng Fane5f2b222019-10-22 03:30:04 +000023#if IS_ENABLED(CONFIG_FEC_MXC)
24static int setup_fec(void)
25{
26 struct iomuxc_gpr_base_regs *gpr =
27 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
28
29 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
30 clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
31
32 return 0;
33}
34
35int board_phy_config(struct phy_device *phydev)
36{
37 /* enable rgmii rxc skew and phy mode select to RGMII copper */
38 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
39 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
40
41 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
42 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
43 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
44 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
45
46 if (phydev->drv->config)
47 phydev->drv->config(phydev);
48 return 0;
49}
50#endif
51
Peng Fanf9220172019-08-27 06:26:08 +000052int board_init(void)
53{
Peng Fane5f2b222019-10-22 03:30:04 +000054 if (IS_ENABLED(CONFIG_FEC_MXC))
55 setup_fec();
56
Peng Fanf9220172019-08-27 06:26:08 +000057 return 0;
58}
59
Peng Fan3a7e3402019-10-09 03:08:17 +000060int board_mmc_get_env_dev(int devno)
61{
62 return devno;
63}
64
Peng Fanf9220172019-08-27 06:26:08 +000065int board_late_init(void)
66{
67#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
68 env_set("board_name", "EVK");
69 env_set("board_rev", "iMX8MM");
70#endif
71 return 0;
72}