blob: 2b584e0a53755ec0164a0412a9449a57760af13f [file] [log] [blame]
Chandan Nath8a8f0842012-01-09 20:38:59 +00001/*
2 * boot-common.c
3 *
4 * Common bootmode functions for omap based boards
5 *
6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <common.h>
Tom Rini47f7bca2012-08-13 12:03:19 -070020#include <spl.h>
Chandan Nath8a8f0842012-01-09 20:38:59 +000021#include <asm/omap_common.h>
22#include <asm/arch/omap.h>
Tom Rinif0881252012-08-14 10:25:15 -070023#include <asm/arch/mmc_host_def.h>
Ilya Yanok1befaff2012-11-06 13:06:28 +000024#include <asm/arch/sys_proto.h>
Chandan Nath8a8f0842012-01-09 20:38:59 +000025
26/*
27 * This is used to verify if the configuration header
28 * was executed by rom code prior to control of transfer
29 * to the bootloader. SPL is responsible for saving and
30 * passing the boot_params pointer to the u-boot.
31 */
32struct omap_boot_parameters boot_params __attribute__ ((section(".data")));
33
34#ifdef CONFIG_SPL_BUILD
35/*
36 * We use static variables because global data is not ready yet.
37 * Initialized data is available in SPL right from the beginning.
38 * We would not typically need to save these parameters in regular
39 * U-Boot. This is needed only in SPL at the moment.
40 */
41u32 omap_bootmode = MMCSD_MODE_FAT;
42
Tom Rini8e1b8362012-08-13 12:53:23 -070043u32 spl_boot_device(void)
Chandan Nath8a8f0842012-01-09 20:38:59 +000044{
45 return (u32) (boot_params.omap_bootdevice);
46}
47
Tom Rini37189a12012-08-14 09:19:44 -070048u32 spl_boot_mode(void)
Chandan Nath8a8f0842012-01-09 20:38:59 +000049{
50 return omap_bootmode;
51}
Tom Rinif0881252012-08-14 10:25:15 -070052
Tom Rinid7cb93b2012-08-14 12:26:08 -070053void spl_board_init(void)
54{
55#ifdef CONFIG_SPL_NAND_SUPPORT
56 gpmc_init();
57#endif
58}
59
Tom Rinif0881252012-08-14 10:25:15 -070060int board_mmc_init(bd_t *bis)
61{
62 switch (spl_boot_device()) {
63 case BOOT_DEVICE_MMC1:
64 omap_mmc_init(0, 0, 0);
65 break;
66 case BOOT_DEVICE_MMC2:
67 case BOOT_DEVICE_MMC2_2:
68 omap_mmc_init(1, 0, 0);
69 break;
70 }
71 return 0;
72}
Chandan Nath8a8f0842012-01-09 20:38:59 +000073#endif