blob: fbee2c39771e628b3841350eee8faf21c1707a6d [file] [log] [blame]
Ilko Iliev2b4ed302021-04-23 09:45:52 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2018 NXP
4 */
5
Ilko Iliev2b4ed302021-04-23 09:45:52 +02006#include <miiphy.h>
7#include <asm-generic/gpio.h>
8#include <asm/arch/imx8mq_pins.h>
9#include <asm/arch/sys_proto.h>
10#include <asm/arch/clock.h>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14#define UART_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
15
16#define WDOG_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_HYS | PAD_CTL_PUE)
17
18static iomux_v3_cfg_t const wdog_pads[] = {
19 IMX8MQ_PAD_GPIO1_IO02__WDOG1_WDOG_B | MUX_PAD_CTRL(WDOG_PAD_CTRL),
20};
21
22static iomux_v3_cfg_t const uart_pads[] = {
23 IMX8MQ_PAD_UART1_RXD__UART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
24 IMX8MQ_PAD_UART1_TXD__UART1_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
25};
26
27int board_early_init_f(void)
28{
29 struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
30
31 imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
32 set_wdog_reset(wdog);
33
34 imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
35
36 return 0;
37}
38
39static int setup_fec(void)
40{
41 struct iomuxc_gpr_base_regs *gpr =
42 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
43
44 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
45 clrsetbits_le32(&gpr->gpr[1], BIT(13) | BIT(17), 0);
46 return set_clk_enet(ENET_125MHZ);
47}
48
49int board_phy_config(struct phy_device *phydev)
50{
51 /* enable rgmii rxc skew and phy mode select to RGMII copper */
52 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
53 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
54
55 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
56 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
57
58 if (phydev->drv->config)
59 phydev->drv->config(phydev);
60 return 0;
61}
62
63int board_init(void)
64{
65 setup_fec();
66
67 return 0;
68}
69
70int board_mmc_get_env_dev(int devno)
71{
72 return devno;
73}
74
75int board_late_init(void)
76{
77 if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) {
78 env_set("board_name", "imx8mq-cm");
79 env_set("board_rev", "v2.0");
80 }
81
82 return 0;
83}