Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [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> |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 8 | #include <errno.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 10 | #include <miiphy.h> |
| 11 | #include <netdev.h> |
| 12 | #include <linux/delay.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 14 | #include <asm/mach-imx/iomux-v3.h> |
| 15 | #include <asm-generic/gpio.h> |
| 16 | #include <asm/arch/imx8mp_pins.h> |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 17 | #include <asm/arch/clock.h> |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 18 | #include <asm/arch/sys_proto.h> |
| 19 | #include <asm/mach-imx/gpio.h> |
| 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 23 | static void setup_fec(void) |
| 24 | { |
| 25 | struct iomuxc_gpr_base_regs *gpr = |
| 26 | (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; |
| 27 | |
| 28 | /* Enable RGMII TX clk output */ |
| 29 | setbits_le32(&gpr->gpr[1], BIT(22)); |
| 30 | } |
| 31 | |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 32 | static int setup_eqos(void) |
| 33 | { |
| 34 | struct iomuxc_gpr_base_regs *gpr = |
| 35 | (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; |
| 36 | |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 37 | /* set INTF as RGMII, enable RGMII TXC clock */ |
| 38 | clrsetbits_le32(&gpr->gpr[1], |
| 39 | IOMUXC_GPR_GPR1_GPR_ENET_QOS_INTF_SEL_MASK, BIT(16)); |
| 40 | setbits_le32(&gpr->gpr[1], BIT(19) | BIT(21)); |
| 41 | |
| 42 | return set_clk_eqos(ENET_125MHZ); |
| 43 | } |
| 44 | |
| 45 | #if CONFIG_IS_ENABLED(NET) |
| 46 | int board_phy_config(struct phy_device *phydev) |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 47 | { |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 48 | if (phydev->drv->config) |
| 49 | phydev->drv->config(phydev); |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 50 | return 0; |
| 51 | } |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 52 | #endif |
| 53 | |
| 54 | int board_init(void) |
| 55 | { |
| 56 | int ret = 0; |
| 57 | |
| 58 | if (CONFIG_IS_ENABLED(FEC_MXC)) { |
| 59 | setup_fec(); |
Ye Li | 82da0f5 | 2021-08-16 18:44:29 +0800 | [diff] [blame] | 60 | } |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 61 | |
Ye Li | 82da0f5 | 2021-08-16 18:44:29 +0800 | [diff] [blame] | 62 | if (CONFIG_IS_ENABLED(DWC_ETH_QOS)) { |
| 63 | ret = setup_eqos(); |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | return ret; |
| 67 | } |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 68 | |
| 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", "iMX8MP"); |
| 74 | #endif |
| 75 | |
| 76 | return 0; |
| 77 | } |