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/delay.h>
28 #include <linux/mii.h>
35 #ifdef CONFIG_SPL_BUILD
39 DECLARE_GLOBAL_DATA_PTR;
45 static void init_clocks(void)
47 /* IO0 clock at 480MHz */
48 mxs_set_ioclk(MXC_IOCLK0, 480000);
49 /* IO1 clock at 480MHz */
50 mxs_set_ioclk(MXC_IOCLK1, 480000);
52 /* SSP0 clock at 96MHz */
53 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
54 /* SSP2 clock at 160MHz */
55 mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
56 /* SSP3 clock at 96MHz */
57 mxs_set_sspclk(MXC_SSPCLK3, 96000, 0);
60 #ifdef CONFIG_SPL_BUILD
61 void board_init_f(ulong arg)
64 preloader_console_init();
67 static int boot_tiva0, boot_tiva1;
69 /* Check if TIVAs request booting via U-Boot proper */
70 void spl_board_init(void)
72 struct gpio_desc btiva0, btiva1, en_3_3v;
76 * Setup GPIO0_0 (TIVA power enable pin) to be output high
77 * to allow TIVA startup.
79 ret = dm_gpio_lookup_name("GPIO0_0", &en_3_3v);
81 printf("Cannot get GPIO0_0\n");
83 ret = dm_gpio_request(&en_3_3v, "pwr_3_3v");
85 printf("Cannot request GPIO0_0\n");
87 /* Set GPIO0_0 to HIGH */
88 dm_gpio_set_dir_flags(&en_3_3v, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
90 ret = dm_gpio_lookup_name("GPIO0_23", &btiva0);
92 printf("Cannot get GPIO0_23\n");
94 ret = dm_gpio_lookup_name("GPIO0_25", &btiva1);
96 printf("Cannot get GPIO0_25\n");
98 ret = dm_gpio_request(&btiva0, "boot-tiva0");
100 printf("Cannot request GPIO0_23\n");
102 ret = dm_gpio_request(&btiva1, "boot-tiva1");
104 printf("Cannot request GPIO0_25\n");
106 dm_gpio_set_dir_flags(&btiva0, GPIOD_IS_IN);
107 dm_gpio_set_dir_flags(&btiva1, GPIOD_IS_IN);
111 boot_tiva0 = dm_gpio_get_value(&btiva0);
112 boot_tiva1 = dm_gpio_get_value(&btiva1);
115 void board_boot_order(u32 *spl_boot_list)
117 spl_boot_list[0] = BOOT_DEVICE_MMC1;
118 spl_boot_list[1] = BOOT_DEVICE_SPI;
121 int spl_start_uboot(void)
123 /* break into full u-boot on 'c' */
124 if (serial_tstc() && serial_getc() == 'c')
127 debug("%s: btiva0: %d btiva1: %d\n", __func__, boot_tiva0, boot_tiva1);
128 return !boot_tiva0 || !boot_tiva1;
132 int board_early_init_f(void)
141 struct gpio_desc phy_rst;
144 /* Address of boot parameters */
145 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
150 ret = dm_gpio_lookup_name("GPIO4_13", &phy_rst);
152 printf("Cannot get GPIO4_13\n");
156 ret = dm_gpio_request(&phy_rst, "phy-rst");
158 printf("Cannot request GPIO4_13\n");
162 dm_gpio_set_dir_flags(&phy_rst, GPIOD_IS_IN);
170 return mxs_dram_init();
173 #ifdef CONFIG_OF_BOARD_SETUP
174 static int fdt_fixup_l2switch(void *blob)
179 if (eth_env_get_enetaddr("ethaddr", ethaddr)) {
180 ret = fdt_find_and_setprop(blob,
181 "/ahb@80080000/switch@800f0000",
182 "local-mac-address", ethaddr, 6, 1);
184 printf("%s: can't find usbether@1 node: %d\n",
191 int ft_board_setup(void *blob, bd_t *bd)
194 * i.MX28 L2 switch needs manual update (fixup) of eth MAC address
195 * (in 'local-mac-address' property) as it uses "switch@800f0000"
196 * node, not set by default FIT image handling code in
197 * "ethernet@800f0000"
199 fdt_fixup_l2switch(blob);
205 #endif /* CONFIG_SPL_BUILD */