blob: 3f1ecce10f8833c2a5ce49d4257be74d91076222 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peng Fan81590632016-08-11 14:02:57 +08002/*
3 * Copyright (C) 2016 Freescale Semiconductor, Inc.
Peng Fan81590632016-08-11 14:02:57 +08004 */
5
Simon Glassa7b51302019-11-14 12:57:46 -07006#include <init.h>
Peng Fan81590632016-08-11 14:02:57 +08007#include <asm/arch/clock.h>
8#include <asm/arch/iomux.h>
9#include <asm/arch/imx-regs.h>
10#include <asm/arch/crm_regs.h>
11#include <asm/arch/mx6-pins.h>
12#include <asm/arch/sys_proto.h>
13#include <asm/gpio.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020014#include <asm/mach-imx/iomux-v3.h>
15#include <asm/mach-imx/boot_mode.h>
Peng Fan81590632016-08-11 14:02:57 +080016#include <asm/io.h>
17#include <common.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060018#include <env.h>
Yangbo Lu73340382019-06-21 11:42:28 +080019#include <fsl_esdhc_imx.h>
Peng Fan81590632016-08-11 14:02:57 +080020#include <linux/sizes.h>
21#include <mmc.h>
Fabio Estevam4ada4f02020-02-03 14:23:58 -030022#include <miiphy.h>
Peng Fan81590632016-08-11 14:02:57 +080023
24DECLARE_GLOBAL_DATA_PTR;
25
26#define UART_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
27 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
28 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
29
30int dram_init(void)
31{
32 gd->ram_size = imx_ddr_size();
33
34 return 0;
35}
36
37static iomux_v3_cfg_t const uart1_pads[] = {
38 MX6_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
39 MX6_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
40};
41
42static void setup_iomux_uart(void)
43{
44 imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
45}
46
47int board_mmc_get_env_dev(int devno)
48{
49 return devno;
50}
51
52int mmc_map_to_kernel_blk(int devno)
53{
54 return devno;
55}
56
57int board_early_init_f(void)
58{
59 setup_iomux_uart();
60
61 return 0;
62}
63
Fabio Estevam4ada4f02020-02-03 14:23:58 -030064#ifdef CONFIG_FEC_MXC
65static int setup_fec(int fec_id)
66{
67 struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
68 int ret;
69
70 if (fec_id == 0) {
71 /*
72 * Use 50MHz anatop loopback REF_CLK1 for ENET1,
73 * clear gpr1[13], set gpr1[17].
74 */
75 clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC1_MASK,
76 IOMUX_GPR1_FEC1_CLOCK_MUX1_SEL_MASK);
77 } else {
78 /*
79 * Use 50MHz anatop loopback REF_CLK2 for ENET2,
80 * clear gpr1[14], set gpr1[18].
81 */
82 clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC2_MASK,
83 IOMUX_GPR1_FEC2_CLOCK_MUX1_SEL_MASK);
84 }
85
86 ret = enable_fec_anatop_clock(fec_id, ENET_50MHZ);
87 if (ret)
88 return ret;
89
90 enable_enet_clk(1);
91
92 return 0;
93}
94
95int board_phy_config(struct phy_device *phydev)
96{
97 phy_write(phydev, MDIO_DEVAD_NONE, 0x1f, 0x8190);
98
99 if (phydev->drv->config)
100 phydev->drv->config(phydev);
101
102 return 0;
103}
104#endif
105
Peng Fan81590632016-08-11 14:02:57 +0800106int board_init(void)
107{
108 /* Address of boot parameters */
109 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
110
Fabio Estevam4ada4f02020-02-03 14:23:58 -0300111#ifdef CONFIG_FEC_MXC
112 setup_fec(CONFIG_FEC_ENET_DEV);
113#endif
114
Peng Fan81590632016-08-11 14:02:57 +0800115 return 0;
116}
117
118#ifdef CONFIG_CMD_BMODE
119static const struct boot_mode board_boot_modes[] = {
120 /* 4 bit bus width */
121 {"sd1", MAKE_CFGVAL(0x42, 0x20, 0x00, 0x00)},
122 {"sd2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)},
123 {"qspi1", MAKE_CFGVAL(0x10, 0x00, 0x00, 0x00)},
124 {NULL, 0},
125};
126#endif
127
128int board_late_init(void)
129{
130#ifdef CONFIG_CMD_BMODE
131 add_board_boot_modes(board_boot_modes);
132#endif
133
134#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
Peng Fan5098eae2019-08-08 09:55:57 +0000135 if (is_cpu_type(MXC_CPU_MX6ULZ))
136 env_set("board_name", "ULZ-EVK");
137 else
138 env_set("board_name", "EVK");
Simon Glass6a38e412017-08-03 12:22:09 -0600139 env_set("board_rev", "14X14");
Peng Fan81590632016-08-11 14:02:57 +0800140#endif
141
142 return 0;
143}
144
145int checkboard(void)
146{
Peng Fan5098eae2019-08-08 09:55:57 +0000147 if (is_cpu_type(MXC_CPU_MX6ULZ))
148 puts("Board: MX6ULZ 14x14 EVK\n");
149 else
150 puts("Board: MX6ULL 14x14 EVK\n");
Peng Fan81590632016-08-11 14:02:57 +0800151
152 return 0;
153}