1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2019 DENX Software Engineering
6 * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
8 * Copyright (C) 2018 DENX Software Engineering
9 * Måns Rullgård, DENX Software Engineering, mans@mansr.com
11 * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
12 * on behalf of DENX Software Engineering GmbH
17 #include <fdt_support.h>
23 #include <asm/arch/imx-regs.h>
24 #include <asm/arch/iomux-mx28.h>
25 #include <asm/arch/clock.h>
26 #include <asm/arch/sys_proto.h>
27 #include <linux/mii.h>
34 #ifdef CONFIG_SPL_BUILD
38 DECLARE_GLOBAL_DATA_PTR;
44 static void init_clocks(void)
46 /* IO0 clock at 480MHz */
47 mxs_set_ioclk(MXC_IOCLK0, 480000);
48 /* IO1 clock at 480MHz */
49 mxs_set_ioclk(MXC_IOCLK1, 480000);
51 /* SSP0 clock at 96MHz */
52 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
53 /* SSP2 clock at 160MHz */
54 mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
55 /* SSP3 clock at 96MHz */
56 mxs_set_sspclk(MXC_SSPCLK3, 96000, 0);
59 #ifdef CONFIG_SPL_BUILD
60 void board_init_f(ulong arg)
63 preloader_console_init();
66 static int boot_tiva0, boot_tiva1;
68 /* Check if TIVAs request booting via U-Boot proper */
69 void spl_board_init(void)
71 struct gpio_desc btiva0, btiva1, en_3_3v;
75 * Setup GPIO0_0 (TIVA power enable pin) to be output high
76 * to allow TIVA startup.
78 ret = dm_gpio_lookup_name("GPIO0_0", &en_3_3v);
80 printf("Cannot get GPIO0_0\n");
82 ret = dm_gpio_request(&en_3_3v, "pwr_3_3v");
84 printf("Cannot request GPIO0_0\n");
86 /* Set GPIO0_0 to HIGH */
87 dm_gpio_set_dir_flags(&en_3_3v, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
89 ret = dm_gpio_lookup_name("GPIO0_23", &btiva0);
91 printf("Cannot get GPIO0_23\n");
93 ret = dm_gpio_lookup_name("GPIO0_25", &btiva1);
95 printf("Cannot get GPIO0_25\n");
97 ret = dm_gpio_request(&btiva0, "boot-tiva0");
99 printf("Cannot request GPIO0_23\n");
101 ret = dm_gpio_request(&btiva1, "boot-tiva1");
103 printf("Cannot request GPIO0_25\n");
105 dm_gpio_set_dir_flags(&btiva0, GPIOD_IS_IN);
106 dm_gpio_set_dir_flags(&btiva1, GPIOD_IS_IN);
110 boot_tiva0 = dm_gpio_get_value(&btiva0);
111 boot_tiva1 = dm_gpio_get_value(&btiva1);
114 void board_boot_order(u32 *spl_boot_list)
116 spl_boot_list[0] = BOOT_DEVICE_MMC1;
117 spl_boot_list[1] = BOOT_DEVICE_SPI;
120 int spl_start_uboot(void)
122 /* break into full u-boot on 'c' */
123 if (serial_tstc() && serial_getc() == 'c')
126 debug("%s: btiva0: %d btiva1: %d\n", __func__, boot_tiva0, boot_tiva1);
127 return !boot_tiva0 || !boot_tiva1;
131 int board_early_init_f(void)
140 struct gpio_desc phy_rst;
143 /* Address of boot parameters */
144 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
149 ret = dm_gpio_lookup_name("GPIO4_13", &phy_rst);
151 printf("Cannot get GPIO4_13\n");
155 ret = dm_gpio_request(&phy_rst, "phy-rst");
157 printf("Cannot request GPIO4_13\n");
161 dm_gpio_set_dir_flags(&phy_rst, GPIOD_IS_IN);
169 return mxs_dram_init();
172 #ifdef CONFIG_OF_BOARD_SETUP
173 static int fdt_fixup_l2switch(void *blob)
178 if (eth_env_get_enetaddr("ethaddr", ethaddr)) {
179 ret = fdt_find_and_setprop(blob,
180 "/ahb@80080000/switch@800f0000",
181 "local-mac-address", ethaddr, 6, 1);
183 printf("%s: can't find usbether@1 node: %d\n",
190 int ft_board_setup(void *blob, bd_t *bd)
193 * i.MX28 L2 switch needs manual update (fixup) of eth MAC address
194 * (in 'local-mac-address' property) as it uses "switch@800f0000"
195 * node, not set by default FIT image handling code in
196 * "ethernet@800f0000"
198 fdt_fixup_l2switch(blob);
204 #endif /* CONFIG_SPL_BUILD */