blob: 79a68fbcfb3a02c295b4a1936b160a32166afd88 [file] [log] [blame]
Lad, Prabhakar0d986e62012-06-24 21:35:20 +00001/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#include <common.h>
20#include <mmc.h>
21
22DECLARE_GLOBAL_DATA_PTR;
23
24static void mmc_load_image(struct mmc *mmc)
25{
26 s32 err;
27 void (*uboot)(void) __noreturn;
28
29 err = mmc->block_dev.block_read(0, CONFIG_SYS_MMC_U_BOOT_OFFS,
30 CONFIG_SYS_MMC_U_BOOT_SIZE/512,
31 (u32 *)CONFIG_SYS_TEXT_BASE);
32
33 if (err <= 0) {
34 printf("spl: error reading image %s, err - %d\n",
35 "u-boot.img", err);
36 hang();
37 }
38 uboot = (void *) CONFIG_SYS_TEXT_BASE;
39 (*uboot)();
40}
41
42void spl_mmc_load(void)
43{
44 struct mmc *mmc;
45 int err;
46 void (mmc_load_image)(struct mmc *mmc) __noreturn;
47
48 mmc_initialize(gd->bd);
49 mmc = find_mmc_device(0);
50 if (!mmc) {
51 puts("spl: mmc device not found!!\n");
52 hang();
53 } else {
54 puts("spl: mmc device found\n");
55 }
56 err = mmc_init(mmc);
57 if (err) {
58 printf("spl: mmc init failed: err - %d\n", err);
59 hang();
60 }
61 mmc_load_image(mmc);
62}