Martyn Welch | 56f96e6 | 2022-10-25 10:55:02 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Based on vendor support provided by AVNET Embedded |
| 4 | * |
| 5 | * Copyright (C) 2021 AVNET Embedded, MSC Technologies GmbH |
| 6 | * Copyright 2021 General Electric Company |
| 7 | * Copyright 2021 Collabora Ltd. |
| 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <errno.h> |
| 12 | #include <miiphy.h> |
| 13 | #include <netdev.h> |
| 14 | #include <asm/arch/clock.h> |
| 15 | #include <asm/arch/imx8mp_pins.h> |
| 16 | #include <asm/arch/sys_proto.h> |
| 17 | #include <asm/mach-imx/gpio.h> |
| 18 | #include <asm/mach-imx/iomux-v3.h> |
| 19 | #include <asm-generic/gpio.h> |
| 20 | #include <linux/delay.h> |
| 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
| 24 | static void setup_fec(void) |
| 25 | { |
| 26 | struct iomuxc_gpr_base_regs *gpr = |
| 27 | (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; |
| 28 | |
| 29 | /* Enable RGMII TX clk output */ |
| 30 | setbits_le32(&gpr->gpr[1], BIT(22)); |
| 31 | } |
| 32 | |
| 33 | static int setup_eqos(void) |
| 34 | { |
| 35 | struct iomuxc_gpr_base_regs *gpr = |
| 36 | (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; |
| 37 | |
| 38 | /* set INTF as RGMII, enable RGMII TXC clock */ |
| 39 | clrsetbits_le32(&gpr->gpr[1], |
| 40 | IOMUXC_GPR_GPR1_GPR_ENET_QOS_INTF_SEL_MASK, BIT(16)); |
| 41 | setbits_le32(&gpr->gpr[1], BIT(19) | BIT(21)); |
| 42 | |
| 43 | return set_clk_eqos(ENET_125MHZ); |
| 44 | } |
| 45 | |
| 46 | int board_phy_config(struct phy_device *phydev) |
| 47 | { |
| 48 | if (phydev->drv->config) |
| 49 | phydev->drv->config(phydev); |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | int board_init(void) |
| 54 | { |
| 55 | setup_fec(); |
| 56 | |
| 57 | setup_eqos(); |
| 58 | |
| 59 | return 0; |
| 60 | } |