Chandan Nath | 8a8f084 | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 1 | /* |
| 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 Rini | 47f7bca | 2012-08-13 12:03:19 -0700 | [diff] [blame] | 20 | #include <spl.h> |
Chandan Nath | 8a8f084 | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 21 | #include <asm/omap_common.h> |
| 22 | #include <asm/arch/omap.h> |
Tom Rini | f088125 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 23 | #include <asm/arch/mmc_host_def.h> |
Chandan Nath | 8a8f084 | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * This is used to verify if the configuration header |
| 27 | * was executed by rom code prior to control of transfer |
| 28 | * to the bootloader. SPL is responsible for saving and |
| 29 | * passing the boot_params pointer to the u-boot. |
| 30 | */ |
| 31 | struct omap_boot_parameters boot_params __attribute__ ((section(".data"))); |
| 32 | |
| 33 | #ifdef CONFIG_SPL_BUILD |
| 34 | /* |
| 35 | * We use static variables because global data is not ready yet. |
| 36 | * Initialized data is available in SPL right from the beginning. |
| 37 | * We would not typically need to save these parameters in regular |
| 38 | * U-Boot. This is needed only in SPL at the moment. |
| 39 | */ |
| 40 | u32 omap_bootmode = MMCSD_MODE_FAT; |
| 41 | |
Tom Rini | 8e1b836 | 2012-08-13 12:53:23 -0700 | [diff] [blame] | 42 | u32 spl_boot_device(void) |
Chandan Nath | 8a8f084 | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 43 | { |
| 44 | return (u32) (boot_params.omap_bootdevice); |
| 45 | } |
| 46 | |
Tom Rini | 37189a1 | 2012-08-14 09:19:44 -0700 | [diff] [blame] | 47 | u32 spl_boot_mode(void) |
Chandan Nath | 8a8f084 | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 48 | { |
| 49 | return omap_bootmode; |
| 50 | } |
Tom Rini | f088125 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 51 | |
Tom Rini | d7cb93b | 2012-08-14 12:26:08 -0700 | [diff] [blame] | 52 | void spl_board_init(void) |
| 53 | { |
| 54 | #ifdef CONFIG_SPL_NAND_SUPPORT |
| 55 | gpmc_init(); |
| 56 | #endif |
| 57 | } |
| 58 | |
Tom Rini | f088125 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 59 | int board_mmc_init(bd_t *bis) |
| 60 | { |
| 61 | switch (spl_boot_device()) { |
| 62 | case BOOT_DEVICE_MMC1: |
| 63 | omap_mmc_init(0, 0, 0); |
| 64 | break; |
| 65 | case BOOT_DEVICE_MMC2: |
| 66 | case BOOT_DEVICE_MMC2_2: |
| 67 | omap_mmc_init(1, 0, 0); |
| 68 | break; |
| 69 | } |
| 70 | return 0; |
| 71 | } |
Chandan Nath | 8a8f084 | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 72 | #endif |