blob: e73a498733be1c911295047694548d8db5db71dd [file] [log] [blame]
Peng Fanb72606c2022-07-26 16:41:10 +08001// 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
22DECLARE_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
27static 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
32int 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 Fan7aaa58a2022-07-26 16:41:18 +080041static int setup_fec(void)
42{
43 return set_clk_enet(ENET_125MHZ);
44}
45
46int board_phy_config(struct phy_device *phydev)
47{
48 if (phydev->drv->config)
49 phydev->drv->config(phydev);
50
51 return 0;
52}
53
54static 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 Fanb72606c2022-07-26 16:41:10 +080067int board_init(void)
68{
Simon Glassb42427e2023-02-05 17:54:16 -070069 if (IS_ENABLED(CONFIG_FEC_MXC))
Peng Fan7aaa58a2022-07-26 16:41:18 +080070 setup_fec();
71
Simon Glassf6b52f32023-02-05 15:39:39 -070072 if (IS_ENABLED(CONFIG_DWC_ETH_QOS))
Peng Fan7aaa58a2022-07-26 16:41:18 +080073 setup_eqos();
74
Peng Fanb72606c2022-07-26 16:41:10 +080075 return 0;
76}
77
78int 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}