blob: de45f8b1d24bee69c1992fbf5d59f4caa48bef05 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peng Fan55a42b32016-08-11 14:02:57 +08002/*
3 * Copyright (C) 2016 Freescale Semiconductor, Inc.
Peng Fan55a42b32016-08-11 14:02:57 +08004 */
5
Simon Glass52559322019-11-14 12:57:46 -07006#include <init.h>
Peng Fan55a42b32016-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>
Simon Glass401d1c42020-10-30 21:38:53 -060013#include <asm/global_data.h>
Peng Fan55a42b32016-08-11 14:02:57 +080014#include <asm/gpio.h>
Stefano Babic552a8482017-06-29 10:16:06 +020015#include <asm/mach-imx/iomux-v3.h>
16#include <asm/mach-imx/boot_mode.h>
Peng Fan55a42b32016-08-11 14:02:57 +080017#include <asm/io.h>
18#include <common.h>
Simon Glass9fb625c2019-08-01 09:46:51 -060019#include <env.h>
Yangbo Lue37ac712019-06-21 11:42:28 +080020#include <fsl_esdhc_imx.h>
Peng Fan55a42b32016-08-11 14:02:57 +080021#include <linux/sizes.h>
22#include <mmc.h>
Fabio Estevam03279b72020-02-03 14:23:58 -030023#include <miiphy.h>
Peng Fan55a42b32016-08-11 14:02:57 +080024
25DECLARE_GLOBAL_DATA_PTR;
26
Peng Fan55a42b32016-08-11 14:02:57 +080027int dram_init(void)
28{
29 gd->ram_size = imx_ddr_size();
30
31 return 0;
32}
33
Peng Fan55a42b32016-08-11 14:02:57 +080034int board_mmc_get_env_dev(int devno)
35{
36 return devno;
37}
38
39int mmc_map_to_kernel_blk(int devno)
40{
41 return devno;
42}
43
44int board_early_init_f(void)
45{
Peng Fan55a42b32016-08-11 14:02:57 +080046 return 0;
47}
48
Fabio Estevam03279b72020-02-03 14:23:58 -030049#ifdef CONFIG_FEC_MXC
50static int setup_fec(int fec_id)
51{
52 struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
53 int ret;
54
55 if (fec_id == 0) {
56 /*
57 * Use 50MHz anatop loopback REF_CLK1 for ENET1,
58 * clear gpr1[13], set gpr1[17].
59 */
60 clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC1_MASK,
61 IOMUX_GPR1_FEC1_CLOCK_MUX1_SEL_MASK);
62 } else {
63 /*
64 * Use 50MHz anatop loopback REF_CLK2 for ENET2,
65 * clear gpr1[14], set gpr1[18].
66 */
67 clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC2_MASK,
68 IOMUX_GPR1_FEC2_CLOCK_MUX1_SEL_MASK);
69 }
70
71 ret = enable_fec_anatop_clock(fec_id, ENET_50MHZ);
72 if (ret)
73 return ret;
74
75 enable_enet_clk(1);
76
77 return 0;
78}
79
80int board_phy_config(struct phy_device *phydev)
81{
82 phy_write(phydev, MDIO_DEVAD_NONE, 0x1f, 0x8190);
83
84 if (phydev->drv->config)
85 phydev->drv->config(phydev);
86
87 return 0;
88}
89#endif
90
Peng Fan55a42b32016-08-11 14:02:57 +080091int board_init(void)
92{
93 /* Address of boot parameters */
94 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
95
Fabio Estevam03279b72020-02-03 14:23:58 -030096#ifdef CONFIG_FEC_MXC
Tom Rini4daffb52022-12-04 10:03:52 -050097 setup_fec(CFG_FEC_ENET_DEV);
Fabio Estevam03279b72020-02-03 14:23:58 -030098#endif
99
Peng Fan55a42b32016-08-11 14:02:57 +0800100 return 0;
101}
102
103#ifdef CONFIG_CMD_BMODE
104static const struct boot_mode board_boot_modes[] = {
105 /* 4 bit bus width */
106 {"sd1", MAKE_CFGVAL(0x42, 0x20, 0x00, 0x00)},
107 {"sd2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)},
108 {"qspi1", MAKE_CFGVAL(0x10, 0x00, 0x00, 0x00)},
109 {NULL, 0},
110};
111#endif
112
113int board_late_init(void)
114{
115#ifdef CONFIG_CMD_BMODE
116 add_board_boot_modes(board_boot_modes);
117#endif
118
119#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
Peng Fan1d293e62019-08-08 09:55:57 +0000120 if (is_cpu_type(MXC_CPU_MX6ULZ))
121 env_set("board_name", "ULZ-EVK");
122 else
123 env_set("board_name", "EVK");
Simon Glass382bee52017-08-03 12:22:09 -0600124 env_set("board_rev", "14X14");
Peng Fan55a42b32016-08-11 14:02:57 +0800125#endif
126
127 return 0;
128}
129
130int checkboard(void)
131{
Peng Fan1d293e62019-08-08 09:55:57 +0000132 if (is_cpu_type(MXC_CPU_MX6ULZ))
133 puts("Board: MX6ULZ 14x14 EVK\n");
134 else
135 puts("Board: MX6ULL 14x14 EVK\n");
Peng Fan55a42b32016-08-11 14:02:57 +0800136
137 return 0;
138}