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
19 #include <asm/arch/imx-regs.h>
20 #include <asm/arch/iomux-mx28.h>
21 #include <asm/arch/clock.h>
22 #include <asm/arch/sys_proto.h>
23 #include <linux/mii.h>
30 #ifdef CONFIG_SPL_BUILD
34 DECLARE_GLOBAL_DATA_PTR;
40 static void init_clocks(void)
42 /* IO0 clock at 480MHz */
43 mxs_set_ioclk(MXC_IOCLK0, 480000);
44 /* IO1 clock at 480MHz */
45 mxs_set_ioclk(MXC_IOCLK1, 480000);
47 /* SSP0 clock at 96MHz */
48 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
49 /* SSP2 clock at 160MHz */
50 mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
51 /* SSP3 clock at 96MHz */
52 mxs_set_sspclk(MXC_SSPCLK3, 96000, 0);
55 #ifdef CONFIG_SPL_BUILD
56 void board_init_f(ulong arg)
59 preloader_console_init();
62 static int boot_tiva0, boot_tiva1;
64 /* Check if TIVAs request booting via U-Boot proper */
65 void spl_board_init(void)
67 struct gpio_desc btiva0, btiva1;
70 ret = dm_gpio_lookup_name("GPIO0_23", &btiva0);
72 printf("Cannot get GPIO0_23\n");
74 ret = dm_gpio_lookup_name("GPIO0_25", &btiva1);
76 printf("Cannot get GPIO0_25\n");
78 ret = dm_gpio_request(&btiva0, "boot-tiva0");
80 printf("Cannot request GPIO0_23\n");
82 ret = dm_gpio_request(&btiva1, "boot-tiva1");
84 printf("Cannot request GPIO0_25\n");
86 dm_gpio_set_dir_flags(&btiva0, GPIOD_IS_IN);
87 dm_gpio_set_dir_flags(&btiva1, GPIOD_IS_IN);
91 boot_tiva0 = dm_gpio_get_value(&btiva0);
92 boot_tiva1 = dm_gpio_get_value(&btiva1);
95 void board_boot_order(u32 *spl_boot_list)
97 spl_boot_list[0] = BOOT_DEVICE_MMC1;
98 spl_boot_list[1] = BOOT_DEVICE_SPI;
101 int spl_start_uboot(void)
103 /* break into full u-boot on 'c' */
104 if (serial_tstc() && serial_getc() == 'c')
107 debug("%s: btiva0: %d btiva1: %d\n", __func__, boot_tiva0, boot_tiva1);
108 return !boot_tiva0 || !boot_tiva1;
112 int board_early_init_f(void)
121 struct gpio_desc phy_rst;
124 /* Address of boot parameters */
125 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
130 ret = dm_gpio_lookup_name("GPIO4_13", &phy_rst);
132 printf("Cannot get GPIO4_13\n");
136 ret = dm_gpio_request(&phy_rst, "phy-rst");
138 printf("Cannot request GPIO4_13\n");
142 dm_gpio_set_dir_flags(&phy_rst, GPIOD_IS_IN);
150 return mxs_dram_init();
153 #endif /* CONFIG_SPL_BUILD */