Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2018 NXP |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Peng Fan | e5f2b22 | 2019-10-22 03:30:04 +0000 | [diff] [blame] | 7 | #include <miiphy.h> |
| 8 | #include <netdev.h> |
| 9 | |
| 10 | #include <asm/arch/clock.h> |
Alifer Moraes | c1a2a1f | 2020-01-14 11:22:57 -0300 | [diff] [blame] | 11 | #include <asm/arch/sys_proto.h> |
Peng Fan | e5f2b22 | 2019-10-22 03:30:04 +0000 | [diff] [blame] | 12 | #include <asm/io.h> |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | int dram_init(void) |
| 17 | { |
Igor Opaniuk | 38bd533 | 2020-03-27 12:28:19 +0200 | [diff] [blame^] | 18 | /* rom_pointer[1] contains the size of TEE occupies */ |
| 19 | if (rom_pointer[1]) |
| 20 | gd->ram_size = PHYS_SDRAM_SIZE - rom_pointer[1]; |
| 21 | else |
| 22 | gd->ram_size = PHYS_SDRAM_SIZE; |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 23 | |
| 24 | return 0; |
| 25 | } |
| 26 | |
Peng Fan | e5f2b22 | 2019-10-22 03:30:04 +0000 | [diff] [blame] | 27 | #if IS_ENABLED(CONFIG_FEC_MXC) |
| 28 | static int setup_fec(void) |
| 29 | { |
| 30 | struct iomuxc_gpr_base_regs *gpr = |
| 31 | (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; |
| 32 | |
| 33 | /* Use 125M anatop REF_CLK1 for ENET1, not from external */ |
| 34 | clrsetbits_le32(&gpr->gpr[1], 0x2000, 0); |
| 35 | |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | int board_phy_config(struct phy_device *phydev) |
| 40 | { |
| 41 | /* enable rgmii rxc skew and phy mode select to RGMII copper */ |
| 42 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f); |
| 43 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8); |
| 44 | |
| 45 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00); |
| 46 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee); |
| 47 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); |
| 48 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100); |
| 49 | |
| 50 | if (phydev->drv->config) |
| 51 | phydev->drv->config(phydev); |
| 52 | return 0; |
| 53 | } |
| 54 | #endif |
| 55 | |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 56 | int board_init(void) |
| 57 | { |
Peng Fan | e5f2b22 | 2019-10-22 03:30:04 +0000 | [diff] [blame] | 58 | if (IS_ENABLED(CONFIG_FEC_MXC)) |
| 59 | setup_fec(); |
| 60 | |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
Peng Fan | 3a7e340 | 2019-10-09 03:08:17 +0000 | [diff] [blame] | 64 | int board_mmc_get_env_dev(int devno) |
| 65 | { |
| 66 | return devno; |
| 67 | } |
| 68 | |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 69 | int board_late_init(void) |
| 70 | { |
| 71 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 72 | env_set("board_name", "EVK"); |
| 73 | env_set("board_rev", "iMX8MM"); |
| 74 | #endif |
| 75 | return 0; |
| 76 | } |