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> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 11 | #include <asm/global_data.h> |
Peng Fan | e5f2b22 | 2019-10-22 03:30:04 +0000 | [diff] [blame] | 12 | |
| 13 | #include <asm/arch/clock.h> |
Alifer Moraes | c1a2a1f | 2020-01-14 11:22:57 -0300 | [diff] [blame] | 14 | #include <asm/arch/sys_proto.h> |
Peng Fan | e5f2b22 | 2019-10-22 03:30:04 +0000 | [diff] [blame] | 15 | #include <asm/io.h> |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
Peng Fan | e5f2b22 | 2019-10-22 03:30:04 +0000 | [diff] [blame] | 19 | #if IS_ENABLED(CONFIG_FEC_MXC) |
| 20 | static 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 | |
| 31 | int 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 Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 48 | int board_init(void) |
| 49 | { |
Peng Fan | e5f2b22 | 2019-10-22 03:30:04 +0000 | [diff] [blame] | 50 | if (IS_ENABLED(CONFIG_FEC_MXC)) |
| 51 | setup_fec(); |
| 52 | |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 53 | return 0; |
| 54 | } |
| 55 | |
Peng Fan | 3a7e340 | 2019-10-09 03:08:17 +0000 | [diff] [blame] | 56 | int board_mmc_get_env_dev(int devno) |
| 57 | { |
| 58 | return devno; |
| 59 | } |
| 60 | |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 61 | int board_late_init(void) |
| 62 | { |
Tommaso Merciai | 1549d6b | 2021-12-26 18:23:11 +0100 | [diff] [blame] | 63 | if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) { |
| 64 | env_set("board_name", "EVK"); |
| 65 | env_set("board_rev", "iMX8MM"); |
| 66 | } |
| 67 | |
Peng Fan | f922017 | 2019-08-27 06:26:08 +0000 | [diff] [blame] | 68 | return 0; |
| 69 | } |