]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/omap-common/boot-common.c
Merge branch 'master' of git://git.denx.de/u-boot-spi
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / omap-common / boot-common.c
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  * SPDX-License-Identifier:     GPL-2.0+
9  */
10
11 #include <common.h>
12 #include <spl.h>
13 #include <asm/omap_common.h>
14 #include <asm/arch/omap.h>
15 #include <asm/arch/mmc_host_def.h>
16 #include <asm/arch/sys_proto.h>
17 #include <watchdog.h>
18
19 DECLARE_GLOBAL_DATA_PTR;
20
21 void save_omap_boot_params(void)
22 {
23         u32 rom_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS);
24         u8 boot_device;
25         u32 dev_desc, dev_data;
26
27         if ((rom_params <  NON_SECURE_SRAM_START) ||
28             (rom_params > NON_SECURE_SRAM_END))
29                 return;
30
31         /*
32          * rom_params can be type casted to omap_boot_parameters and
33          * used. But it not correct to assume that romcode structure
34          * encoding would be same as u-boot. So use the defined offsets.
35          */
36         gd->arch.omap_boot_params.omap_bootdevice = boot_device =
37                                    *((u8 *)(rom_params + BOOT_DEVICE_OFFSET));
38
39         gd->arch.omap_boot_params.ch_flags =
40                                 *((u8 *)(rom_params + CH_FLAGS_OFFSET));
41
42         if ((boot_device >= MMC_BOOT_DEVICES_START) &&
43             (boot_device <= MMC_BOOT_DEVICES_END)) {
44 #if !defined(CONFIG_AM33XX) && !defined(CONFIG_TI81XX) && \
45         !defined(CONFIG_AM43XX)
46                 if ((omap_hw_init_context() ==
47                                       OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)) {
48                         gd->arch.omap_boot_params.omap_bootmode =
49                         *((u8 *)(rom_params + BOOT_MODE_OFFSET));
50                 } else
51 #endif
52                 {
53                         dev_desc = *((u32 *)(rom_params + DEV_DESC_PTR_OFFSET));
54                         dev_data = *((u32 *)(dev_desc + DEV_DATA_PTR_OFFSET));
55                         gd->arch.omap_boot_params.omap_bootmode =
56                                         *((u32 *)(dev_data + BOOT_MODE_OFFSET));
57                 }
58         }
59 }
60
61 #ifdef CONFIG_SPL_BUILD
62 u32 spl_boot_device(void)
63 {
64         return (u32) (gd->arch.omap_boot_params.omap_bootdevice);
65 }
66
67 u32 spl_boot_mode(void)
68 {
69         u32 val = gd->arch.omap_boot_params.omap_bootmode;
70
71         if (val == MMCSD_MODE_RAW)
72                 return MMCSD_MODE_RAW;
73         else if (val == MMCSD_MODE_FAT)
74                 return MMCSD_MODE_FAT;
75         else
76 #ifdef CONFIG_SUPPORT_EMMC_BOOT
77                 return MMCSD_MODE_EMMCBOOT;
78 #else
79                 return MMCSD_MODE_UNDEFINED;
80 #endif
81 }
82
83 void spl_board_init(void)
84 {
85 #ifdef CONFIG_SPL_NAND_SUPPORT
86         gpmc_init();
87 #endif
88 #if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
89         arch_misc_init();
90 #endif
91 #if defined(CONFIG_HW_WATCHDOG)
92         hw_watchdog_init();
93 #endif
94 #ifdef CONFIG_AM33XX
95         am33xx_spl_board_init();
96 #endif
97 }
98
99 int board_mmc_init(bd_t *bis)
100 {
101         switch (spl_boot_device()) {
102         case BOOT_DEVICE_MMC1:
103                 omap_mmc_init(0, 0, 0, -1, -1);
104                 break;
105         case BOOT_DEVICE_MMC2:
106         case BOOT_DEVICE_MMC2_2:
107                 omap_mmc_init(1, 0, 0, -1, -1);
108                 break;
109         }
110         return 0;
111 }
112
113 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
114 {
115         typedef void __noreturn (*image_entry_noargs_t)(u32 *);
116         image_entry_noargs_t image_entry =
117                         (image_entry_noargs_t) spl_image->entry_point;
118
119         debug("image entry point: 0x%X\n", spl_image->entry_point);
120         /* Pass the saved boot_params from rom code */
121         image_entry((u32 *)&gd->arch.omap_boot_params);
122 }
123 #endif