1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2019 DENX Software Engineering
8 * Copyright (C) 2018 DENX Software Engineering
12 * on behalf of DENX Software Engineering GmbH
17 #include <fdt_support.h>
21 #include <asm/global_data.h>
24 #include <asm/arch/imx-regs.h>
25 #include <asm/arch/iomux-mx28.h>
26 #include <asm/arch/clock.h>
27 #include <asm/arch/sys_proto.h>
28 #include <linux/delay.h>
29 #include <linux/mii.h>
36 #ifdef CONFIG_SPL_BUILD
40 DECLARE_GLOBAL_DATA_PTR;
46 static void init_clocks(void)
48 /* IO0 clock at 480MHz */
49 mxs_set_ioclk(MXC_IOCLK0, 480000);
50 /* IO1 clock at 480MHz */
51 mxs_set_ioclk(MXC_IOCLK1, 480000);
53 /* SSP0 clock at 96MHz */
54 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
55 /* SSP2 clock at 160MHz */
56 mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
57 /* SSP3 clock at 96MHz */
58 mxs_set_sspclk(MXC_SSPCLK3, 96000, 0);
61 #ifdef CONFIG_SPL_BUILD
62 void board_init_f(ulong arg)
65 preloader_console_init();
68 static int boot_tiva0, boot_tiva1;
70 /* Check if TIVAs request booting via U-Boot proper */
71 void spl_board_init(void)
73 struct gpio_desc btiva0, btiva1, en_3_3v;
77 * Setup GPIO0_0 (TIVA power enable pin) to be output high
78 * to allow TIVA startup.
80 ret = dm_gpio_lookup_name("GPIO0_0", &en_3_3v);
82 printf("Cannot get GPIO0_0\n");
84 ret = dm_gpio_request(&en_3_3v, "pwr_3_3v");
86 printf("Cannot request GPIO0_0\n");
88 /* Set GPIO0_0 to HIGH */
89 dm_gpio_set_dir_flags(&en_3_3v, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
91 ret = dm_gpio_lookup_name("GPIO0_23", &btiva0);
93 printf("Cannot get GPIO0_23\n");
95 ret = dm_gpio_lookup_name("GPIO0_25", &btiva1);
97 printf("Cannot get GPIO0_25\n");
99 ret = dm_gpio_request(&btiva0, "boot-tiva0");
101 printf("Cannot request GPIO0_23\n");
103 ret = dm_gpio_request(&btiva1, "boot-tiva1");
105 printf("Cannot request GPIO0_25\n");
107 dm_gpio_set_dir_flags(&btiva0, GPIOD_IS_IN);
108 dm_gpio_set_dir_flags(&btiva1, GPIOD_IS_IN);
112 boot_tiva0 = dm_gpio_get_value(&btiva0);
113 boot_tiva1 = dm_gpio_get_value(&btiva1);
116 void board_boot_order(u32 *spl_boot_list)
118 spl_boot_list[0] = BOOT_DEVICE_MMC1;
119 spl_boot_list[1] = BOOT_DEVICE_SPI;
120 spl_boot_list[2] = BOOT_DEVICE_UART;
123 int spl_start_uboot(void)
125 /* break into full u-boot on 'c' */
126 if (serial_tstc() && serial_getc() == 'c')
129 debug("%s: btiva0: %d btiva1: %d\n", __func__, boot_tiva0, boot_tiva1);
130 return !boot_tiva0 || !boot_tiva1;
134 int board_early_init_f(void)
143 struct gpio_desc phy_rst;
146 /* Address of boot parameters */
147 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
152 ret = dm_gpio_lookup_name("GPIO4_13", &phy_rst);
154 printf("Cannot get GPIO4_13\n");
158 ret = dm_gpio_request(&phy_rst, "phy-rst");
160 printf("Cannot request GPIO4_13\n");
164 dm_gpio_set_dir_flags(&phy_rst, GPIOD_IS_IN);
172 return mxs_dram_init();
175 #ifdef CONFIG_OF_BOARD_SETUP
176 static int fdt_fixup_l2switch(void *blob)
181 if (eth_env_get_enetaddr("ethaddr", ethaddr)) {
182 ret = fdt_find_and_setprop(blob,
183 "/ahb@80080000/switch@800f0000",
184 "local-mac-address", ethaddr, 6, 1);
186 printf("%s: can't find usbether@1 node: %d\n",
193 int ft_board_setup(void *blob, struct bd_info *bd)
196 * i.MX28 L2 switch needs manual update (fixup) of eth MAC address
197 * (in 'local-mac-address' property) as it uses "switch@800f0000"
198 * node, not set by default FIT image handling code in
199 * "ethernet@800f0000"
201 fdt_fixup_l2switch(blob);
207 #endif /* CONFIG_SPL_BUILD */