Chandan Nath | 77a73fe | 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 | 28591df | 2012-08-13 12:03:19 -0700 | [diff] [blame] | 20 | #include <spl.h> |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 21 | #include <asm/omap_common.h> |
| 22 | #include <asm/arch/omap.h> |
Tom Rini | a0b9fa5 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 23 | #include <asm/arch/mmc_host_def.h> |
Ilya Yanok | 741c57f | 2012-11-06 13:06:28 +0000 | [diff] [blame] | 24 | #include <asm/arch/sys_proto.h> |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 25 | |
SRICHARAN R | 3f30b0a | 2013-04-24 00:41:24 +0000 | [diff] [blame] | 26 | DECLARE_GLOBAL_DATA_PTR; |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 27 | |
Tom Rini | 51df26c | 2013-05-31 12:31:59 -0400 | [diff] [blame] | 28 | void save_omap_boot_params(void) |
| 29 | { |
| 30 | u32 rom_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS); |
| 31 | u8 boot_device; |
| 32 | u32 dev_desc, dev_data; |
| 33 | |
| 34 | if ((rom_params < NON_SECURE_SRAM_START) || |
| 35 | (rom_params > NON_SECURE_SRAM_END)) |
| 36 | return; |
| 37 | |
| 38 | /* |
| 39 | * rom_params can be type casted to omap_boot_parameters and |
| 40 | * used. But it not correct to assume that romcode structure |
| 41 | * encoding would be same as u-boot. So use the defined offsets. |
| 42 | */ |
| 43 | gd->arch.omap_boot_params.omap_bootdevice = boot_device = |
| 44 | *((u8 *)(rom_params + BOOT_DEVICE_OFFSET)); |
| 45 | |
| 46 | gd->arch.omap_boot_params.ch_flags = |
| 47 | *((u8 *)(rom_params + CH_FLAGS_OFFSET)); |
| 48 | |
| 49 | if ((boot_device >= MMC_BOOT_DEVICES_START) && |
| 50 | (boot_device <= MMC_BOOT_DEVICES_END)) { |
| 51 | #if !defined(CONFIG_AM33XX) && !defined(CONFIG_TI81XX) |
| 52 | if ((omap_hw_init_context() == |
| 53 | OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)) { |
| 54 | gd->arch.omap_boot_params.omap_bootmode = |
| 55 | *((u8 *)(rom_params + BOOT_MODE_OFFSET)); |
| 56 | } else |
| 57 | #endif |
| 58 | { |
| 59 | dev_desc = *((u32 *)(rom_params + DEV_DESC_PTR_OFFSET)); |
| 60 | dev_data = *((u32 *)(dev_desc + DEV_DATA_PTR_OFFSET)); |
| 61 | gd->arch.omap_boot_params.omap_bootmode = |
| 62 | *((u32 *)(dev_data + BOOT_MODE_OFFSET)); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 67 | #ifdef CONFIG_SPL_BUILD |
Tom Rini | 0be93ff | 2012-08-13 12:53:23 -0700 | [diff] [blame] | 68 | u32 spl_boot_device(void) |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 69 | { |
SRICHARAN R | 3f30b0a | 2013-04-24 00:41:24 +0000 | [diff] [blame] | 70 | return (u32) (gd->arch.omap_boot_params.omap_bootdevice); |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Tom Rini | a76ff95 | 2012-08-14 09:19:44 -0700 | [diff] [blame] | 73 | u32 spl_boot_mode(void) |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 74 | { |
SRICHARAN R | 3f30b0a | 2013-04-24 00:41:24 +0000 | [diff] [blame] | 75 | return gd->arch.omap_boot_params.omap_bootmode; |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 76 | } |
Tom Rini | a0b9fa5 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 77 | |
Tom Rini | 9e0c260 | 2012-08-14 12:26:08 -0700 | [diff] [blame] | 78 | void spl_board_init(void) |
| 79 | { |
| 80 | #ifdef CONFIG_SPL_NAND_SUPPORT |
| 81 | gpmc_init(); |
| 82 | #endif |
Ilya Yanok | 87b82cc | 2013-02-05 11:36:25 +0000 | [diff] [blame] | 83 | #if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT) |
| 84 | arch_misc_init(); |
| 85 | #endif |
Tom Rini | 9e0c260 | 2012-08-14 12:26:08 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Tom Rini | a0b9fa5 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 88 | int board_mmc_init(bd_t *bis) |
| 89 | { |
| 90 | switch (spl_boot_device()) { |
| 91 | case BOOT_DEVICE_MMC1: |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 92 | omap_mmc_init(0, 0, 0, -1, -1); |
Tom Rini | a0b9fa5 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 93 | break; |
| 94 | case BOOT_DEVICE_MMC2: |
| 95 | case BOOT_DEVICE_MMC2_2: |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 96 | omap_mmc_init(1, 0, 0, -1, -1); |
Tom Rini | a0b9fa5 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 97 | break; |
| 98 | } |
| 99 | return 0; |
| 100 | } |
SRICHARAN R | 3f30b0a | 2013-04-24 00:41:24 +0000 | [diff] [blame] | 101 | |
| 102 | void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) |
| 103 | { |
| 104 | typedef void __noreturn (*image_entry_noargs_t)(u32 *); |
| 105 | image_entry_noargs_t image_entry = |
| 106 | (image_entry_noargs_t) spl_image->entry_point; |
| 107 | |
| 108 | debug("image entry point: 0x%X\n", spl_image->entry_point); |
| 109 | /* Pass the saved boot_params from rom code */ |
| 110 | image_entry((u32 *)&gd->arch.omap_boot_params); |
| 111 | } |
Chandan Nath | 77a73fe | 2012-01-09 20:38:59 +0000 | [diff] [blame] | 112 | #endif |