Peng Fan | b72606c | 2022-07-26 16:41:10 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2022 NXP |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <env.h> |
| 8 | #include <init.h> |
| 9 | #include <miiphy.h> |
| 10 | #include <netdev.h> |
| 11 | #include <asm/global_data.h> |
| 12 | #include <asm/arch-imx9/ccm_regs.h> |
| 13 | #include <asm/arch/sys_proto.h> |
| 14 | #include <asm/arch-imx9/imx93_pins.h> |
| 15 | #include <asm/arch/clock.h> |
| 16 | #include <power/pmic.h> |
| 17 | #include <dm/device.h> |
| 18 | #include <dm/uclass.h> |
| 19 | #include <usb.h> |
| 20 | #include <dwc3-uboot.h> |
| 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
| 24 | #define UART_PAD_CTRL (PAD_CTL_DSE(6) | PAD_CTL_FSEL2) |
| 25 | #define WDOG_PAD_CTRL (PAD_CTL_DSE(6) | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE) |
| 26 | |
| 27 | static iomux_v3_cfg_t const uart_pads[] = { |
| 28 | MX93_PAD_UART1_RXD__LPUART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 29 | MX93_PAD_UART1_TXD__LPUART1_TX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 30 | }; |
| 31 | |
| 32 | int board_early_init_f(void) |
| 33 | { |
| 34 | imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads)); |
| 35 | |
| 36 | init_uart_clk(LPUART1_CLK_ROOT); |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | |
Peng Fan | 7aaa58a | 2022-07-26 16:41:18 +0800 | [diff] [blame] | 41 | static int setup_fec(void) |
| 42 | { |
| 43 | return set_clk_enet(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 | |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static int setup_eqos(void) |
| 55 | { |
| 56 | struct blk_ctrl_wakeupmix_regs *bctrl = |
| 57 | (struct blk_ctrl_wakeupmix_regs *)BLK_CTRL_WAKEUPMIX_BASE_ADDR; |
| 58 | |
| 59 | /* set INTF as RGMII, enable RGMII TXC clock */ |
| 60 | clrsetbits_le32(&bctrl->eqos_gpr, |
| 61 | BCTRL_GPR_ENET_QOS_INTF_MODE_MASK, |
| 62 | BCTRL_GPR_ENET_QOS_INTF_SEL_RGMII | BCTRL_GPR_ENET_QOS_CLK_GEN_EN); |
| 63 | |
| 64 | return set_clk_eqos(ENET_125MHZ); |
| 65 | } |
| 66 | |
Peng Fan | b72606c | 2022-07-26 16:41:10 +0800 | [diff] [blame] | 67 | int board_init(void) |
| 68 | { |
Peng Fan | 7aaa58a | 2022-07-26 16:41:18 +0800 | [diff] [blame] | 69 | if (CONFIG_IS_ENABLED(FEC_MXC)) |
| 70 | setup_fec(); |
| 71 | |
Simon Glass | f6b52f3 | 2023-02-05 15:39:39 -0700 | [diff] [blame^] | 72 | if (IS_ENABLED(CONFIG_DWC_ETH_QOS)) |
Peng Fan | 7aaa58a | 2022-07-26 16:41:18 +0800 | [diff] [blame] | 73 | setup_eqos(); |
| 74 | |
Peng Fan | b72606c | 2022-07-26 16:41:10 +0800 | [diff] [blame] | 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | int board_late_init(void) |
| 79 | { |
| 80 | #ifdef CONFIG_ENV_IS_IN_MMC |
| 81 | board_late_mmc_env_init(); |
| 82 | #endif |
| 83 | |
| 84 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 85 | env_set("board_name", "11X11_EVK"); |
| 86 | env_set("board_rev", "iMX93"); |
| 87 | #endif |
| 88 | return 0; |
| 89 | } |