Commit dd07d338dab13e7bee6c1c260d885d7c5716fb52
1 parent
b0aaad915b
Exists in
smarc_8mm-imx_v2019.04_4.19.35_1.1.0
and in
1 other branch
MLK-18243-17: arm: mach-imx: fix sd to mmc1 and emmc to mmc2 for i.MX8MM
Since the SD is usdhc2 and eMMC is usdhc3, this cause mapping problem for spl_boot_device. So far hard coded them to correct MMC index, so that SD and eMMC boot can work. Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com> (cherry picked from commit 3e4123fb3d6945a466563f4505a56bb0ea6f4ca0) (cherry picked from commit 6c6206ad1a5a3c70118a3ecf526b0ff00088adf7)
Showing 1 changed file with 9 additions and 0 deletions Inline Diff
arch/arm/mach-imx/spl.c
| 1 | // SPDX-License-Identifier: GPL-2.0+ | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (C) 2014 Gateworks Corporation | 3 | * Copyright (C) 2014 Gateworks Corporation |
| 4 | * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. | 4 | * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. |
| 5 | * | 5 | * |
| 6 | * Author: Tim Harvey <tharvey@gateworks.com> | 6 | * Author: Tim Harvey <tharvey@gateworks.com> |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <common.h> | 9 | #include <common.h> |
| 10 | #include <asm/io.h> | 10 | #include <asm/io.h> |
| 11 | #include <asm/arch/imx-regs.h> | 11 | #include <asm/arch/imx-regs.h> |
| 12 | #include <asm/arch/sys_proto.h> | 12 | #include <asm/arch/sys_proto.h> |
| 13 | #include <asm/spl.h> | 13 | #include <asm/spl.h> |
| 14 | #include <spl.h> | 14 | #include <spl.h> |
| 15 | #include <asm/mach-imx/hab.h> | 15 | #include <asm/mach-imx/hab.h> |
| 16 | #include <asm/mach-imx/boot_mode.h> | 16 | #include <asm/mach-imx/boot_mode.h> |
| 17 | #include <g_dnl.h> | 17 | #include <g_dnl.h> |
| 18 | 18 | ||
| 19 | DECLARE_GLOBAL_DATA_PTR; | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | 20 | ||
| 21 | #if defined(CONFIG_MX6) | 21 | #if defined(CONFIG_MX6) |
| 22 | /* determine boot device from SRC_SBMR1 (BOOT_CFG[4:1]) or SRC_GPR9 register */ | 22 | /* determine boot device from SRC_SBMR1 (BOOT_CFG[4:1]) or SRC_GPR9 register */ |
| 23 | u32 spl_boot_device(void) | 23 | u32 spl_boot_device(void) |
| 24 | { | 24 | { |
| 25 | unsigned int bmode = readl(&src_base->sbmr2); | 25 | unsigned int bmode = readl(&src_base->sbmr2); |
| 26 | u32 reg = imx6_src_get_boot_mode(); | 26 | u32 reg = imx6_src_get_boot_mode(); |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
| 29 | * Check for BMODE if serial downloader is enabled | 29 | * Check for BMODE if serial downloader is enabled |
| 30 | * BOOT_MODE - see IMX6DQRM Table 8-1 | 30 | * BOOT_MODE - see IMX6DQRM Table 8-1 |
| 31 | */ | 31 | */ |
| 32 | if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */ | 32 | if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */ |
| 33 | return BOOT_DEVICE_BOARD; | 33 | return BOOT_DEVICE_BOARD; |
| 34 | 34 | ||
| 35 | /* | 35 | /* |
| 36 | * The above method does not detect that the boot ROM used | 36 | * The above method does not detect that the boot ROM used |
| 37 | * serial downloader in case the boot ROM decided to use the | 37 | * serial downloader in case the boot ROM decided to use the |
| 38 | * serial downloader as a fall back (primary boot source failed). | 38 | * serial downloader as a fall back (primary boot source failed). |
| 39 | * | 39 | * |
| 40 | * Infer that the boot ROM used the USB serial downloader by | 40 | * Infer that the boot ROM used the USB serial downloader by |
| 41 | * checking whether the USB PHY is currently active... This | 41 | * checking whether the USB PHY is currently active... This |
| 42 | * assumes that SPL did not (yet) initialize the USB PHY... | 42 | * assumes that SPL did not (yet) initialize the USB PHY... |
| 43 | */ | 43 | */ |
| 44 | if (is_usbotg_phy_active()) | 44 | if (is_usbotg_phy_active()) |
| 45 | return BOOT_DEVICE_BOARD; | 45 | return BOOT_DEVICE_BOARD; |
| 46 | 46 | ||
| 47 | /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */ | 47 | /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */ |
| 48 | switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) { | 48 | switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) { |
| 49 | /* EIM: See 8.5.1, Table 8-9 */ | 49 | /* EIM: See 8.5.1, Table 8-9 */ |
| 50 | case IMX6_BMODE_EMI: | 50 | case IMX6_BMODE_EMI: |
| 51 | /* BOOT_CFG1[3]: NOR/OneNAND Selection */ | 51 | /* BOOT_CFG1[3]: NOR/OneNAND Selection */ |
| 52 | switch ((reg & IMX6_BMODE_EMI_MASK) >> IMX6_BMODE_EMI_SHIFT) { | 52 | switch ((reg & IMX6_BMODE_EMI_MASK) >> IMX6_BMODE_EMI_SHIFT) { |
| 53 | case IMX6_BMODE_ONENAND: | 53 | case IMX6_BMODE_ONENAND: |
| 54 | return BOOT_DEVICE_ONENAND; | 54 | return BOOT_DEVICE_ONENAND; |
| 55 | case IMX6_BMODE_NOR: | 55 | case IMX6_BMODE_NOR: |
| 56 | return BOOT_DEVICE_NOR; | 56 | return BOOT_DEVICE_NOR; |
| 57 | break; | 57 | break; |
| 58 | } | 58 | } |
| 59 | /* Reserved: Used to force Serial Downloader */ | 59 | /* Reserved: Used to force Serial Downloader */ |
| 60 | case IMX6_BMODE_RESERVED: | 60 | case IMX6_BMODE_RESERVED: |
| 61 | return BOOT_DEVICE_BOARD; | 61 | return BOOT_DEVICE_BOARD; |
| 62 | /* SATA: See 8.5.4, Table 8-20 */ | 62 | /* SATA: See 8.5.4, Table 8-20 */ |
| 63 | #if !defined(CONFIG_MX6UL) && !defined(CONFIG_MX6ULL) | 63 | #if !defined(CONFIG_MX6UL) && !defined(CONFIG_MX6ULL) |
| 64 | case IMX6_BMODE_SATA: | 64 | case IMX6_BMODE_SATA: |
| 65 | return BOOT_DEVICE_SATA; | 65 | return BOOT_DEVICE_SATA; |
| 66 | #endif | 66 | #endif |
| 67 | /* Serial ROM: See 8.5.5.1, Table 8-22 */ | 67 | /* Serial ROM: See 8.5.5.1, Table 8-22 */ |
| 68 | case IMX6_BMODE_SERIAL_ROM: | 68 | case IMX6_BMODE_SERIAL_ROM: |
| 69 | /* BOOT_CFG4[2:0] */ | 69 | /* BOOT_CFG4[2:0] */ |
| 70 | switch ((reg & IMX6_BMODE_SERIAL_ROM_MASK) >> | 70 | switch ((reg & IMX6_BMODE_SERIAL_ROM_MASK) >> |
| 71 | IMX6_BMODE_SERIAL_ROM_SHIFT) { | 71 | IMX6_BMODE_SERIAL_ROM_SHIFT) { |
| 72 | case IMX6_BMODE_ECSPI1: | 72 | case IMX6_BMODE_ECSPI1: |
| 73 | case IMX6_BMODE_ECSPI2: | 73 | case IMX6_BMODE_ECSPI2: |
| 74 | case IMX6_BMODE_ECSPI3: | 74 | case IMX6_BMODE_ECSPI3: |
| 75 | case IMX6_BMODE_ECSPI4: | 75 | case IMX6_BMODE_ECSPI4: |
| 76 | case IMX6_BMODE_ECSPI5: | 76 | case IMX6_BMODE_ECSPI5: |
| 77 | return BOOT_DEVICE_SPI; | 77 | return BOOT_DEVICE_SPI; |
| 78 | case IMX6_BMODE_I2C1: | 78 | case IMX6_BMODE_I2C1: |
| 79 | case IMX6_BMODE_I2C2: | 79 | case IMX6_BMODE_I2C2: |
| 80 | case IMX6_BMODE_I2C3: | 80 | case IMX6_BMODE_I2C3: |
| 81 | return BOOT_DEVICE_I2C; | 81 | return BOOT_DEVICE_I2C; |
| 82 | } | 82 | } |
| 83 | break; | 83 | break; |
| 84 | /* SD/eSD: 8.5.3, Table 8-15 */ | 84 | /* SD/eSD: 8.5.3, Table 8-15 */ |
| 85 | case IMX6_BMODE_SD: | 85 | case IMX6_BMODE_SD: |
| 86 | case IMX6_BMODE_ESD: | 86 | case IMX6_BMODE_ESD: |
| 87 | return BOOT_DEVICE_MMC1; | 87 | return BOOT_DEVICE_MMC1; |
| 88 | /* MMC/eMMC: 8.5.3 */ | 88 | /* MMC/eMMC: 8.5.3 */ |
| 89 | case IMX6_BMODE_MMC: | 89 | case IMX6_BMODE_MMC: |
| 90 | case IMX6_BMODE_EMMC: | 90 | case IMX6_BMODE_EMMC: |
| 91 | return BOOT_DEVICE_MMC1; | 91 | return BOOT_DEVICE_MMC1; |
| 92 | /* NAND Flash: 8.5.2, Table 8-10 */ | 92 | /* NAND Flash: 8.5.2, Table 8-10 */ |
| 93 | case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: | 93 | case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: |
| 94 | return BOOT_DEVICE_NAND; | 94 | return BOOT_DEVICE_NAND; |
| 95 | } | 95 | } |
| 96 | return BOOT_DEVICE_NONE; | 96 | return BOOT_DEVICE_NONE; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | #elif defined(CONFIG_MX7) || defined(CONFIG_IMX8M) || defined(CONFIG_IMX8) | 99 | #elif defined(CONFIG_MX7) || defined(CONFIG_IMX8M) || defined(CONFIG_IMX8) |
| 100 | /* Translate iMX7/i.MX8M boot device to the SPL boot device enumeration */ | 100 | /* Translate iMX7/i.MX8M boot device to the SPL boot device enumeration */ |
| 101 | u32 spl_boot_device(void) | 101 | u32 spl_boot_device(void) |
| 102 | { | 102 | { |
| 103 | #if defined(CONFIG_MX7) | 103 | #if defined(CONFIG_MX7) |
| 104 | unsigned int bmode = readl(&src_base->sbmr2); | 104 | unsigned int bmode = readl(&src_base->sbmr2); |
| 105 | 105 | ||
| 106 | /* | 106 | /* |
| 107 | * Check for BMODE if serial downloader is enabled | 107 | * Check for BMODE if serial downloader is enabled |
| 108 | * BOOT_MODE - see IMX7DRM Table 6-24 | 108 | * BOOT_MODE - see IMX7DRM Table 6-24 |
| 109 | */ | 109 | */ |
| 110 | if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */ | 110 | if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */ |
| 111 | return BOOT_DEVICE_BOARD; | 111 | return BOOT_DEVICE_BOARD; |
| 112 | 112 | ||
| 113 | /* | 113 | /* |
| 114 | * The above method does not detect that the boot ROM used | 114 | * The above method does not detect that the boot ROM used |
| 115 | * serial downloader in case the boot ROM decided to use the | 115 | * serial downloader in case the boot ROM decided to use the |
| 116 | * serial downloader as a fall back (primary boot source failed). | 116 | * serial downloader as a fall back (primary boot source failed). |
| 117 | * | 117 | * |
| 118 | * Infer that the boot ROM used the USB serial downloader by | 118 | * Infer that the boot ROM used the USB serial downloader by |
| 119 | * checking whether the USB PHY is currently active... This | 119 | * checking whether the USB PHY is currently active... This |
| 120 | * assumes that SPL did not (yet) initialize the USB PHY... | 120 | * assumes that SPL did not (yet) initialize the USB PHY... |
| 121 | */ | 121 | */ |
| 122 | if (is_boot_from_usb()) | 122 | if (is_boot_from_usb()) |
| 123 | return BOOT_DEVICE_BOARD; | 123 | return BOOT_DEVICE_BOARD; |
| 124 | #endif | 124 | #endif |
| 125 | 125 | ||
| 126 | enum boot_device boot_device_spl = get_boot_device(); | 126 | enum boot_device boot_device_spl = get_boot_device(); |
| 127 | 127 | ||
| 128 | switch (boot_device_spl) { | 128 | switch (boot_device_spl) { |
| 129 | #if defined(CONFIG_MX7) | 129 | #if defined(CONFIG_MX7) |
| 130 | case SD1_BOOT: | 130 | case SD1_BOOT: |
| 131 | case MMC1_BOOT: | 131 | case MMC1_BOOT: |
| 132 | case SD2_BOOT: | 132 | case SD2_BOOT: |
| 133 | case MMC2_BOOT: | 133 | case MMC2_BOOT: |
| 134 | case SD3_BOOT: | 134 | case SD3_BOOT: |
| 135 | case MMC3_BOOT: | 135 | case MMC3_BOOT: |
| 136 | return BOOT_DEVICE_MMC1; | 136 | return BOOT_DEVICE_MMC1; |
| 137 | #elif defined(CONFIG_IMX8) | 137 | #elif defined(CONFIG_IMX8) |
| 138 | case MMC1_BOOT: | 138 | case MMC1_BOOT: |
| 139 | return BOOT_DEVICE_MMC1; | 139 | return BOOT_DEVICE_MMC1; |
| 140 | case SD2_BOOT: | 140 | case SD2_BOOT: |
| 141 | return BOOT_DEVICE_MMC2_2; | 141 | return BOOT_DEVICE_MMC2_2; |
| 142 | case SD3_BOOT: | 142 | case SD3_BOOT: |
| 143 | return BOOT_DEVICE_MMC1; | 143 | return BOOT_DEVICE_MMC1; |
| 144 | case FLEXSPI_BOOT: | 144 | case FLEXSPI_BOOT: |
| 145 | return BOOT_DEVICE_SPI; | 145 | return BOOT_DEVICE_SPI; |
| 146 | #elif defined(CONFIG_IMX8M) | 146 | #elif defined(CONFIG_IMX8M) |
| 147 | case SD1_BOOT: | 147 | case SD1_BOOT: |
| 148 | case MMC1_BOOT: | 148 | case MMC1_BOOT: |
| 149 | return BOOT_DEVICE_MMC1; | 149 | return BOOT_DEVICE_MMC1; |
| 150 | #if defined(CONFIG_IMX8MM) | ||
| 150 | case SD2_BOOT: | 151 | case SD2_BOOT: |
| 151 | case MMC2_BOOT: | 152 | case MMC2_BOOT: |
| 153 | return BOOT_DEVICE_MMC1; | ||
| 154 | case SD3_BOOT: | ||
| 155 | case MMC3_BOOT: | ||
| 152 | return BOOT_DEVICE_MMC2; | 156 | return BOOT_DEVICE_MMC2; |
| 157 | #else | ||
| 158 | case SD2_BOOT: | ||
| 159 | case MMC2_BOOT: | ||
| 160 | return BOOT_DEVICE_MMC2; | ||
| 161 | #endif | ||
| 153 | #endif | 162 | #endif |
| 154 | case NAND_BOOT: | 163 | case NAND_BOOT: |
| 155 | return BOOT_DEVICE_NAND; | 164 | return BOOT_DEVICE_NAND; |
| 156 | case SPI_NOR_BOOT: | 165 | case SPI_NOR_BOOT: |
| 157 | return BOOT_DEVICE_SPI; | 166 | return BOOT_DEVICE_SPI; |
| 158 | case USB_BOOT: | 167 | case USB_BOOT: |
| 159 | return BOOT_DEVICE_USB; | 168 | return BOOT_DEVICE_USB; |
| 160 | default: | 169 | default: |
| 161 | return BOOT_DEVICE_NONE; | 170 | return BOOT_DEVICE_NONE; |
| 162 | } | 171 | } |
| 163 | } | 172 | } |
| 164 | #endif /* CONFIG_MX7 || CONFIG_IMX8M || CONFIG_IMX8 */ | 173 | #endif /* CONFIG_MX7 || CONFIG_IMX8M || CONFIG_IMX8 */ |
| 165 | 174 | ||
| 166 | #ifdef CONFIG_SPL_USB_GADGET | 175 | #ifdef CONFIG_SPL_USB_GADGET |
| 167 | int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) | 176 | int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) |
| 168 | { | 177 | { |
| 169 | put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM + 0xfff, &dev->idProduct); | 178 | put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM + 0xfff, &dev->idProduct); |
| 170 | 179 | ||
| 171 | return 0; | 180 | return 0; |
| 172 | } | 181 | } |
| 173 | #endif | 182 | #endif |
| 174 | 183 | ||
| 175 | #if defined(CONFIG_SPL_MMC_SUPPORT) | 184 | #if defined(CONFIG_SPL_MMC_SUPPORT) |
| 176 | /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ | 185 | /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ |
| 177 | u32 spl_boot_mode(const u32 boot_device) | 186 | u32 spl_boot_mode(const u32 boot_device) |
| 178 | { | 187 | { |
| 179 | #if defined(CONFIG_MX7) || defined(CONFIG_IMX8M) || defined(CONFIG_IMX8) | 188 | #if defined(CONFIG_MX7) || defined(CONFIG_IMX8M) || defined(CONFIG_IMX8) |
| 180 | switch (get_boot_device()) { | 189 | switch (get_boot_device()) { |
| 181 | /* for MMC return either RAW or FAT mode */ | 190 | /* for MMC return either RAW or FAT mode */ |
| 182 | case SD1_BOOT: | 191 | case SD1_BOOT: |
| 183 | case SD2_BOOT: | 192 | case SD2_BOOT: |
| 184 | case SD3_BOOT: | 193 | case SD3_BOOT: |
| 185 | #if defined(CONFIG_SPL_FAT_SUPPORT) | 194 | #if defined(CONFIG_SPL_FAT_SUPPORT) |
| 186 | return MMCSD_MODE_FS; | 195 | return MMCSD_MODE_FS; |
| 187 | #else | 196 | #else |
| 188 | return MMCSD_MODE_RAW; | 197 | return MMCSD_MODE_RAW; |
| 189 | #endif | 198 | #endif |
| 190 | break; | 199 | break; |
| 191 | case MMC1_BOOT: | 200 | case MMC1_BOOT: |
| 192 | case MMC2_BOOT: | 201 | case MMC2_BOOT: |
| 193 | case MMC3_BOOT: | 202 | case MMC3_BOOT: |
| 194 | #if defined(CONFIG_SPL_FAT_SUPPORT) | 203 | #if defined(CONFIG_SPL_FAT_SUPPORT) |
| 195 | return MMCSD_MODE_FS; | 204 | return MMCSD_MODE_FS; |
| 196 | #elif defined(CONFIG_SUPPORT_EMMC_BOOT) | 205 | #elif defined(CONFIG_SUPPORT_EMMC_BOOT) |
| 197 | return MMCSD_MODE_EMMCBOOT; | 206 | return MMCSD_MODE_EMMCBOOT; |
| 198 | #else | 207 | #else |
| 199 | return MMCSD_MODE_RAW; | 208 | return MMCSD_MODE_RAW; |
| 200 | #endif | 209 | #endif |
| 201 | break; | 210 | break; |
| 202 | default: | 211 | default: |
| 203 | puts("spl: ERROR: unsupported device\n"); | 212 | puts("spl: ERROR: unsupported device\n"); |
| 204 | hang(); | 213 | hang(); |
| 205 | } | 214 | } |
| 206 | 215 | ||
| 207 | #else /* defined(CONFIG_MX7) || defined(CONFIG_IMX8M) */ | 216 | #else /* defined(CONFIG_MX7) || defined(CONFIG_IMX8M) */ |
| 208 | switch (spl_boot_device()) { | 217 | switch (spl_boot_device()) { |
| 209 | /* for MMC return either RAW or FAT mode */ | 218 | /* for MMC return either RAW or FAT mode */ |
| 210 | case BOOT_DEVICE_MMC1: | 219 | case BOOT_DEVICE_MMC1: |
| 211 | case BOOT_DEVICE_MMC2: | 220 | case BOOT_DEVICE_MMC2: |
| 212 | case BOOT_DEVICE_MMC2_2: | 221 | case BOOT_DEVICE_MMC2_2: |
| 213 | #if defined(CONFIG_SPL_FS_FAT) | 222 | #if defined(CONFIG_SPL_FS_FAT) |
| 214 | return MMCSD_MODE_FS; | 223 | return MMCSD_MODE_FS; |
| 215 | #elif defined(CONFIG_SUPPORT_EMMC_BOOT) | 224 | #elif defined(CONFIG_SUPPORT_EMMC_BOOT) |
| 216 | return MMCSD_MODE_EMMCBOOT; | 225 | return MMCSD_MODE_EMMCBOOT; |
| 217 | #else | 226 | #else |
| 218 | return MMCSD_MODE_RAW; | 227 | return MMCSD_MODE_RAW; |
| 219 | #endif | 228 | #endif |
| 220 | break; | 229 | break; |
| 221 | default: | 230 | default: |
| 222 | puts("spl: ERROR: unsupported device\n"); | 231 | puts("spl: ERROR: unsupported device\n"); |
| 223 | hang(); | 232 | hang(); |
| 224 | } | 233 | } |
| 225 | #endif | 234 | #endif |
| 226 | } | 235 | } |
| 227 | #endif | 236 | #endif |
| 228 | 237 | ||
| 229 | #if defined(CONFIG_SECURE_BOOT) | 238 | #if defined(CONFIG_SECURE_BOOT) |
| 230 | 239 | ||
| 231 | /* | 240 | /* |
| 232 | * +------------+ 0x0 (DDR_UIMAGE_START) - | 241 | * +------------+ 0x0 (DDR_UIMAGE_START) - |
| 233 | * | Header | | | 242 | * | Header | | |
| 234 | * +------------+ 0x40 | | 243 | * +------------+ 0x40 | |
| 235 | * | | | | 244 | * | | | |
| 236 | * | | | | 245 | * | | | |
| 237 | * | | | | 246 | * | | | |
| 238 | * | | | | 247 | * | | | |
| 239 | * | Image Data | | | 248 | * | Image Data | | |
| 240 | * . | | | 249 | * . | | |
| 241 | * . | > Stuff to be authenticated ----+ | 250 | * . | > Stuff to be authenticated ----+ |
| 242 | * . | | | | 251 | * . | | | |
| 243 | * | | | | | 252 | * | | | | |
| 244 | * | | | | | 253 | * | | | | |
| 245 | * +------------+ | | | 254 | * +------------+ | | |
| 246 | * | | | | | 255 | * | | | | |
| 247 | * | Fill Data | | | | 256 | * | Fill Data | | | |
| 248 | * | | | | | 257 | * | | | | |
| 249 | * +------------+ Align to ALIGN_SIZE | | | 258 | * +------------+ Align to ALIGN_SIZE | | |
| 250 | * | IVT | | | | 259 | * | IVT | | | |
| 251 | * +------------+ + IVT_SIZE - | | 260 | * +------------+ + IVT_SIZE - | |
| 252 | * | | | | 261 | * | | | |
| 253 | * | CSF DATA | <---------------------------------------------------------+ | 262 | * | CSF DATA | <---------------------------------------------------------+ |
| 254 | * | | | 263 | * | | |
| 255 | * +------------+ | 264 | * +------------+ |
| 256 | * | | | 265 | * | | |
| 257 | * | Fill Data | | 266 | * | Fill Data | |
| 258 | * | | | 267 | * | | |
| 259 | * +------------+ + CSF_PAD_SIZE | 268 | * +------------+ + CSF_PAD_SIZE |
| 260 | */ | 269 | */ |
| 261 | 270 | ||
| 262 | __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) | 271 | __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) |
| 263 | { | 272 | { |
| 264 | typedef void __noreturn (*image_entry_noargs_t)(void); | 273 | typedef void __noreturn (*image_entry_noargs_t)(void); |
| 265 | uint32_t offset; | 274 | uint32_t offset; |
| 266 | 275 | ||
| 267 | image_entry_noargs_t image_entry = | 276 | image_entry_noargs_t image_entry = |
| 268 | (image_entry_noargs_t)(unsigned long)spl_image->entry_point; | 277 | (image_entry_noargs_t)(unsigned long)spl_image->entry_point; |
| 269 | 278 | ||
| 270 | debug("image entry point: 0x%lX\n", spl_image->entry_point); | 279 | debug("image entry point: 0x%lX\n", spl_image->entry_point); |
| 271 | 280 | ||
| 272 | if (spl_image->flags & SPL_FIT_FOUND) { | 281 | if (spl_image->flags & SPL_FIT_FOUND) { |
| 273 | image_entry(); | 282 | image_entry(); |
| 274 | } else { | 283 | } else { |
| 275 | /* | 284 | /* |
| 276 | * HAB looks for the CSF at the end of the authenticated | 285 | * HAB looks for the CSF at the end of the authenticated |
| 277 | * data therefore, we need to subtract the size of the | 286 | * data therefore, we need to subtract the size of the |
| 278 | * CSF from the actual filesize | 287 | * CSF from the actual filesize |
| 279 | */ | 288 | */ |
| 280 | offset = spl_image->size - CONFIG_CSF_SIZE; | 289 | offset = spl_image->size - CONFIG_CSF_SIZE; |
| 281 | if (!imx_hab_authenticate_image(spl_image->load_addr, | 290 | if (!imx_hab_authenticate_image(spl_image->load_addr, |
| 282 | offset + IVT_SIZE + | 291 | offset + IVT_SIZE + |
| 283 | CSF_PAD_SIZE, offset)) { | 292 | CSF_PAD_SIZE, offset)) { |
| 284 | image_entry(); | 293 | image_entry(); |
| 285 | } else { | 294 | } else { |
| 286 | puts("spl: ERROR: image authentication fail\n"); | 295 | puts("spl: ERROR: image authentication fail\n"); |
| 287 | hang(); | 296 | hang(); |
| 288 | } | 297 | } |
| 289 | } | 298 | } |
| 290 | } | 299 | } |
| 291 | 300 | ||
| 292 | ulong board_spl_fit_size_align(ulong size) | 301 | ulong board_spl_fit_size_align(ulong size) |
| 293 | { | 302 | { |
| 294 | /* | 303 | /* |
| 295 | * HAB authenticate_image requests the IVT offset is | 304 | * HAB authenticate_image requests the IVT offset is |
| 296 | * aligned to 0x1000 | 305 | * aligned to 0x1000 |
| 297 | */ | 306 | */ |
| 298 | 307 | ||
| 299 | size = ALIGN(size, 0x1000); | 308 | size = ALIGN(size, 0x1000); |
| 300 | size += CONFIG_CSF_SIZE; | 309 | size += CONFIG_CSF_SIZE; |
| 301 | 310 | ||
| 302 | return size; | 311 | return size; |
| 303 | } | 312 | } |
| 304 | 313 | ||
| 305 | void board_spl_fit_post_load(ulong load_addr, size_t length) | 314 | void board_spl_fit_post_load(ulong load_addr, size_t length) |
| 306 | { | 315 | { |
| 307 | u32 offset = length - CONFIG_CSF_SIZE; | 316 | u32 offset = length - CONFIG_CSF_SIZE; |
| 308 | 317 | ||
| 309 | if (imx_hab_authenticate_image(load_addr, | 318 | if (imx_hab_authenticate_image(load_addr, |
| 310 | offset + IVT_SIZE + CSF_PAD_SIZE, | 319 | offset + IVT_SIZE + CSF_PAD_SIZE, |
| 311 | offset)) { | 320 | offset)) { |
| 312 | puts("spl: ERROR: image authentication unsuccessful\n"); | 321 | puts("spl: ERROR: image authentication unsuccessful\n"); |
| 313 | hang(); | 322 | hang(); |
| 314 | } | 323 | } |
| 315 | } | 324 | } |
| 316 | 325 | ||
| 317 | #endif | 326 | #endif |
| 318 | 327 | ||
| 319 | #if defined(CONFIG_MX6) && defined(CONFIG_SPL_OS_BOOT) | 328 | #if defined(CONFIG_MX6) && defined(CONFIG_SPL_OS_BOOT) |
| 320 | int dram_init_banksize(void) | 329 | int dram_init_banksize(void) |
| 321 | { | 330 | { |
| 322 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; | 331 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 323 | gd->bd->bi_dram[0].size = imx_ddr_size(); | 332 | gd->bd->bi_dram[0].size = imx_ddr_size(); |
| 324 | 333 | ||
| 325 | return 0; | 334 | return 0; |
| 326 | } | 335 | } |
| 327 | #endif | 336 | #endif |
| 328 | 337 |