Ying-Chun Liu (PaulLiu) | 53b516c | 2021-04-22 04:50:31 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2018 NXP |
| 4 | * Copyright 2020 Linaro |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <env.h> |
| 9 | #include <init.h> |
| 10 | #include <miiphy.h> |
| 11 | #include <netdev.h> |
| 12 | |
| 13 | #include <asm/arch/clock.h> |
| 14 | #include <asm/arch/sys_proto.h> |
| 15 | #include <asm/io.h> |
| 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
| 19 | static int setup_fec(void) |
| 20 | { |
| 21 | if (IS_ENABLED(CONFIG_FEC_MXC)) { |
| 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 | |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | int board_phy_config(struct phy_device *phydev) |
| 33 | { |
| 34 | if (IS_ENABLED(CONFIG_FEC_MXC)) { |
| 35 | /* enable rgmii rxc skew and phy mode select to RGMII copper */ |
| 36 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f); |
| 37 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8); |
| 38 | |
| 39 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00); |
| 40 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee); |
| 41 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); |
| 42 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100); |
| 43 | |
| 44 | if (phydev->drv->config) |
| 45 | phydev->drv->config(phydev); |
| 46 | } |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | int board_init(void) |
| 51 | { |
| 52 | if (IS_ENABLED(CONFIG_FEC_MXC)) |
| 53 | setup_fec(); |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | int board_mmc_get_env_dev(int devno) |
| 59 | { |
| 60 | return devno; |
| 61 | } |
| 62 | |
| 63 | int board_late_init(void) |
| 64 | { |
| 65 | if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) { |
| 66 | env_set("board_name", "IOT-GATE-IMX8"); |
| 67 | env_set("board_rev", "SBC-IOTMX8"); |
| 68 | } |
| 69 | |
| 70 | return 0; |
| 71 | } |