blob: 1f95f3b0c4a99a438f2a252d3aa359e95b3d7c33 [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 Glass97589732020-05-10 11:40:02 -06007#include <init.h>
Peng Fane5f2b222019-10-22 03:30:04 +00008#include <miiphy.h>
9#include <netdev.h>
10
11#include <asm/arch/clock.h>
Alifer Moraesc1a2a1f2020-01-14 11:22:57 -030012#include <asm/arch/sys_proto.h>
Peng Fane5f2b222019-10-22 03:30:04 +000013#include <asm/io.h>
Peng Fanf9220172019-08-27 06:26:08 +000014
15DECLARE_GLOBAL_DATA_PTR;
16
17int dram_init(void)
18{
Igor Opaniuk38bd5332020-03-27 12:28:19 +020019 /* rom_pointer[1] contains the size of TEE occupies */
20 if (rom_pointer[1])
21 gd->ram_size = PHYS_SDRAM_SIZE - rom_pointer[1];
22 else
23 gd->ram_size = PHYS_SDRAM_SIZE;
Peng Fanf9220172019-08-27 06:26:08 +000024
25 return 0;
26}
27
Peng Fane5f2b222019-10-22 03:30:04 +000028#if IS_ENABLED(CONFIG_FEC_MXC)
29static int setup_fec(void)
30{
31 struct iomuxc_gpr_base_regs *gpr =
32 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
33
34 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
35 clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
36
37 return 0;
38}
39
40int board_phy_config(struct phy_device *phydev)
41{
42 /* enable rgmii rxc skew and phy mode select to RGMII copper */
43 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
44 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
45
46 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
47 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
48 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
49 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
50
51 if (phydev->drv->config)
52 phydev->drv->config(phydev);
53 return 0;
54}
55#endif
56
Peng Fanf9220172019-08-27 06:26:08 +000057int board_init(void)
58{
Peng Fane5f2b222019-10-22 03:30:04 +000059 if (IS_ENABLED(CONFIG_FEC_MXC))
60 setup_fec();
61
Peng Fanf9220172019-08-27 06:26:08 +000062 return 0;
63}
64
Peng Fan3a7e3402019-10-09 03:08:17 +000065int board_mmc_get_env_dev(int devno)
66{
67 return devno;
68}
69
Peng Fanf9220172019-08-27 06:26:08 +000070int board_late_init(void)
71{
72#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
73 env_set("board_name", "EVK");
74 env_set("board_rev", "iMX8MM");
75#endif
76 return 0;
77}