Peng Fan | a181afe | 2019-09-16 03:09:55 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2019 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> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Marek Vasut | f87338f | 2022-02-19 17:13:54 +0100 | [diff] [blame^] | 10 | #include <miiphy.h> |
| 11 | #include <netdev.h> |
| 12 | #include <asm/io.h> |
Peng Fan | a181afe | 2019-09-16 03:09:55 +0000 | [diff] [blame] | 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
Marek Vasut | f87338f | 2022-02-19 17:13:54 +0100 | [diff] [blame^] | 16 | int board_mmc_get_env_dev(int devno) |
Peng Fan | a181afe | 2019-09-16 03:09:55 +0000 | [diff] [blame] | 17 | { |
Marek Vasut | f87338f | 2022-02-19 17:13:54 +0100 | [diff] [blame^] | 18 | return devno; |
| 19 | } |
| 20 | |
| 21 | static void setup_fec(void) |
| 22 | { |
| 23 | struct iomuxc_gpr_base_regs *gpr = |
| 24 | (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; |
| 25 | |
| 26 | /* Use 125M anatop REF_CLK1 for ENET1, not from external */ |
| 27 | clrsetbits_le32(&gpr->gpr[1], 0x2000, 0); |
| 28 | } |
| 29 | |
| 30 | int board_phy_config(struct phy_device *phydev) |
| 31 | { |
| 32 | /* enable rgmii rxc skew and phy mode select to RGMII copper */ |
| 33 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f); |
| 34 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8); |
| 35 | |
| 36 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00); |
| 37 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee); |
| 38 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); |
| 39 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100); |
| 40 | |
| 41 | if (phydev->drv->config) |
| 42 | phydev->drv->config(phydev); |
Peng Fan | a181afe | 2019-09-16 03:09:55 +0000 | [diff] [blame] | 43 | return 0; |
| 44 | } |
| 45 | |
Marek Vasut | f87338f | 2022-02-19 17:13:54 +0100 | [diff] [blame^] | 46 | int board_init(void) |
Peng Fan | 42219a7 | 2020-01-06 16:16:32 +0800 | [diff] [blame] | 47 | { |
Marek Vasut | f87338f | 2022-02-19 17:13:54 +0100 | [diff] [blame^] | 48 | setup_fec(); |
| 49 | |
| 50 | return 0; |
Peng Fan | 42219a7 | 2020-01-06 16:16:32 +0800 | [diff] [blame] | 51 | } |
| 52 | |
Peng Fan | a181afe | 2019-09-16 03:09:55 +0000 | [diff] [blame] | 53 | int board_late_init(void) |
| 54 | { |
| 55 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 56 | env_set("board_name", "DDR4 EVK"); |
| 57 | env_set("board_rev", "iMX8MN"); |
| 58 | #endif |
| 59 | return 0; |
| 60 | } |