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 | #if CONFIG_IS_ENABLED(NET) |
| 33 | int board_phy_config(struct phy_device *phydev) |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 34 | { |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 35 | if (phydev->drv->config) |
| 36 | phydev->drv->config(phydev); |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 37 | return 0; |
| 38 | } |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 39 | #endif |
| 40 | |
| 41 | int board_init(void) |
| 42 | { |
| 43 | int ret = 0; |
| 44 | |
Simon Glass | b42427e | 2023-02-05 17:54:16 -0700 | [diff] [blame] | 45 | if (IS_ENABLED(CONFIG_FEC_MXC)) { |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 46 | setup_fec(); |
Ye Li | 82da0f5 | 2021-08-16 18:44:29 +0800 | [diff] [blame] | 47 | } |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 48 | |
Peng Fan | 4f0c97b | 2020-12-25 16:16:34 +0800 | [diff] [blame] | 49 | return ret; |
| 50 | } |
Peng Fan | c47e09d | 2019-12-30 17:46:21 +0800 | [diff] [blame] | 51 | |
| 52 | int board_late_init(void) |
| 53 | { |
| 54 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 55 | env_set("board_name", "EVK"); |
| 56 | env_set("board_rev", "iMX8MP"); |
| 57 | #endif |
| 58 | |
| 59 | return 0; |
| 60 | } |