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