Commit 79e03dd7abaf42211c2bd50e64259afe62e0587b
Committed by
Ye Li
1 parent
49bccf9245
Exists in
smarc_8mq_lf_v2020.04
and in
4 other branches
MA-15208 Remap mmc device id in spl
MMC device id remap function "board_mmc_get_env_dev()" was removed in u-boot v2019 because we add the mmc device aliases in dts file. But we still need to remap the mmc device id in spl or read/write rpmb keyslot package will fail. This patch adds mmc device id remap function in spl to get the correct device id. Test: boot on imx8mm with trusty enabled. Change-Id: I41c46494326d9eb2658d2cda692968fb895d0292 Signed-off-by: Ji Luo <ji.luo@nxp.com> (cherry picked from commit c079188d06b3669df7836e1b8c6126558b1fa39e)
Showing 1 changed file with 41 additions and 28 deletions Side-by-side Diff
lib/avb/fsl/fsl_avbkey.c
... | ... | @@ -30,8 +30,7 @@ |
30 | 30 | #ifdef CONFIG_ARCH_IMX8 |
31 | 31 | #include <asm/arch/sci/sci.h> |
32 | 32 | #endif |
33 | - | |
34 | -#if defined(CONFIG_SPL_BUILD) | |
33 | +#ifdef CONFIG_SPL_BUILD | |
35 | 34 | #include <spl.h> |
36 | 35 | #endif |
37 | 36 | |
38 | 37 | |
39 | 38 | |
40 | 39 | |
... | ... | @@ -45,14 +44,35 @@ |
45 | 44 | |
46 | 45 | extern int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value); |
47 | 46 | |
48 | -#ifdef AVB_RPMB | |
49 | -static int mmc_dev_no = -1; | |
47 | +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MMC_SUPPORT) | |
48 | +int spl_get_mmc_dev(void) | |
49 | +{ | |
50 | + u32 dev_no = spl_boot_device(); | |
51 | + switch (dev_no) { | |
52 | + case BOOT_DEVICE_MMC1: | |
53 | + return 0; | |
54 | + case BOOT_DEVICE_MMC2: | |
55 | + case BOOT_DEVICE_MMC2_2: | |
56 | + return 1; | |
57 | + } | |
50 | 58 | |
59 | +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT | |
60 | + printf("spl: unsupported mmc boot device.\n"); | |
61 | +#endif | |
62 | + | |
63 | + return -ENODEV; | |
64 | +} | |
65 | +#endif | |
66 | + | |
67 | +#ifdef AVB_RPMB | |
51 | 68 | struct mmc *get_mmc(void) { |
52 | - extern int mmc_get_env_devno(void); | |
69 | + int mmc_dev_no; | |
53 | 70 | struct mmc *mmc; |
54 | - if (mmc_dev_no < 0 && (mmc_dev_no = mmc_get_env_dev()) < 0) | |
55 | - return NULL; | |
71 | +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MMC_SUPPORT) | |
72 | + mmc_dev_no = spl_get_mmc_dev(); | |
73 | +#else | |
74 | + mmc_dev_no = mmc_get_env_dev(); | |
75 | +#endif | |
56 | 76 | mmc = find_mmc_device(mmc_dev_no); |
57 | 77 | if (!mmc || mmc_init(mmc)) |
58 | 78 | return NULL; |
59 | 79 | |
... | ... | @@ -70,33 +90,14 @@ |
70 | 90 | 0x100)); |
71 | 91 | } |
72 | 92 | |
73 | -#if defined(CONFIG_SPL_BUILD) | |
74 | -static int spl_mmc_get_device_index(u32 boot_device) | |
75 | -{ | |
76 | - switch (boot_device) { | |
77 | - case BOOT_DEVICE_MMC1: | |
78 | - return 0; | |
79 | - case BOOT_DEVICE_MMC2: | |
80 | - case BOOT_DEVICE_MMC2_2: | |
81 | - return 1; | |
82 | - } | |
83 | - | |
84 | -#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT | |
85 | - printf("spl: unsupported mmc boot device.\n"); | |
86 | -#endif | |
87 | - | |
88 | - return -ENODEV; | |
89 | -} | |
90 | -#endif | |
91 | - | |
92 | 93 | int read_keyslot_package(struct keyslot_package* kp) { |
93 | 94 | char original_part; |
94 | 95 | int blksz; |
95 | 96 | unsigned char* fill = NULL; |
96 | 97 | int ret = 0; |
97 | 98 | /* load tee from boot1 of eMMC. */ |
98 | -#if defined(CONFIG_SPL_BUILD) | |
99 | - int mmcc = spl_mmc_get_device_index(spl_boot_device()); | |
99 | +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MMC_SUPPORT) | |
100 | + int mmcc = spl_get_mmc_dev(); | |
100 | 101 | #else |
101 | 102 | int mmcc = mmc_get_env_dev(); |
102 | 103 | #endif |
103 | 104 | |
... | ... | @@ -184,7 +185,11 @@ |
184 | 185 | struct blk_desc *desc = NULL; |
185 | 186 | |
186 | 187 | /* Get current mmc device. */ |
188 | +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MMC_SUPPORT) | |
189 | + mmcc = spl_get_mmc_dev(); | |
190 | +#else | |
187 | 191 | mmcc = mmc_get_env_dev(); |
192 | +#endif | |
188 | 193 | mmc = find_mmc_device(mmcc); |
189 | 194 | if (!mmc) { |
190 | 195 | printf("error - cannot find '%d' mmc device\n", mmcc); |
191 | 196 | |
... | ... | @@ -580,7 +585,11 @@ |
580 | 585 | |
581 | 586 | int ret = -1; |
582 | 587 | /* load tee from boot1 of eMMC. */ |
588 | +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MMC_SUPPORT) | |
589 | + int mmcc = spl_get_mmc_dev(); | |
590 | +#else | |
583 | 591 | int mmcc = mmc_get_env_dev(); |
592 | +#endif | |
584 | 593 | struct blk_desc *dev_desc = NULL; |
585 | 594 | |
586 | 595 | struct mmc *mmc; |
587 | 596 | |
... | ... | @@ -1170,7 +1179,11 @@ |
1170 | 1179 | memcpy(rpmb_key, key, RPMBKEY_LENGTH); |
1171 | 1180 | |
1172 | 1181 | /* Get current mmc device. */ |
1182 | +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MMC_SUPPORT) | |
1183 | + mmcc = spl_get_mmc_dev(); | |
1184 | +#else | |
1173 | 1185 | mmcc = mmc_get_env_dev(); |
1186 | +#endif | |
1174 | 1187 | mmc = find_mmc_device(mmcc); |
1175 | 1188 | if (!mmc) { |
1176 | 1189 | printf("error - cannot find '%d' mmc device\n", mmcc); |