blob: bff7e9c82a1ef0be65d6b9bd0f52cca312bcfc74 [file] [log] [blame]
Chandan Nath77a73fe2012-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 Rini28591df2012-08-13 12:03:19 -070020#include <spl.h>
Chandan Nath77a73fe2012-01-09 20:38:59 +000021#include <asm/omap_common.h>
22#include <asm/arch/omap.h>
Tom Rinia0b9fa52012-08-14 10:25:15 -070023#include <asm/arch/mmc_host_def.h>
Ilya Yanok741c57f2012-11-06 13:06:28 +000024#include <asm/arch/sys_proto.h>
Chandan Nath77a73fe2012-01-09 20:38:59 +000025
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000026DECLARE_GLOBAL_DATA_PTR;
Chandan Nath77a73fe2012-01-09 20:38:59 +000027
28#ifdef CONFIG_SPL_BUILD
Tom Rini0be93ff2012-08-13 12:53:23 -070029u32 spl_boot_device(void)
Chandan Nath77a73fe2012-01-09 20:38:59 +000030{
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000031 return (u32) (gd->arch.omap_boot_params.omap_bootdevice);
Chandan Nath77a73fe2012-01-09 20:38:59 +000032}
33
Tom Rinia76ff952012-08-14 09:19:44 -070034u32 spl_boot_mode(void)
Chandan Nath77a73fe2012-01-09 20:38:59 +000035{
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000036 return gd->arch.omap_boot_params.omap_bootmode;
Chandan Nath77a73fe2012-01-09 20:38:59 +000037}
Tom Rinia0b9fa52012-08-14 10:25:15 -070038
Tom Rini9e0c2602012-08-14 12:26:08 -070039void spl_board_init(void)
40{
41#ifdef CONFIG_SPL_NAND_SUPPORT
42 gpmc_init();
43#endif
Ilya Yanok87b82cc2013-02-05 11:36:25 +000044#if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
45 arch_misc_init();
46#endif
Tom Rini9e0c2602012-08-14 12:26:08 -070047}
48
Tom Rinia0b9fa52012-08-14 10:25:15 -070049int board_mmc_init(bd_t *bis)
50{
51 switch (spl_boot_device()) {
52 case BOOT_DEVICE_MMC1:
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +000053 omap_mmc_init(0, 0, 0, -1, -1);
Tom Rinia0b9fa52012-08-14 10:25:15 -070054 break;
55 case BOOT_DEVICE_MMC2:
56 case BOOT_DEVICE_MMC2_2:
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +000057 omap_mmc_init(1, 0, 0, -1, -1);
Tom Rinia0b9fa52012-08-14 10:25:15 -070058 break;
59 }
60 return 0;
61}
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000062
63void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
64{
65 typedef void __noreturn (*image_entry_noargs_t)(u32 *);
66 image_entry_noargs_t image_entry =
67 (image_entry_noargs_t) spl_image->entry_point;
68
69 debug("image entry point: 0x%X\n", spl_image->entry_point);
70 /* Pass the saved boot_params from rom code */
71 image_entry((u32 *)&gd->arch.omap_boot_params);
72}
Chandan Nath77a73fe2012-01-09 20:38:59 +000073#endif