1 /*
2  * Copyright (c) 2021-2023, STMicroelectronics - All Rights Reserved
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 #ifndef STM32MP_IO_STORAGE_H
7 #define STM32MP_IO_STORAGE_H
8 
9 #include <stdint.h>
10 
11 #include <drivers/io/io_storage.h>
12 
13 /*******************************************************************************
14  * STM32MP1 RAW partition offset for devices without GPT
15  ******************************************************************************/
16 #define STM32MP_EMMC_BOOT_FIP_OFFSET	U(0x00040000)
17 #if PSA_FWU_SUPPORT
18 #define STM32MP_NOR_METADATA1_OFFSET	U(0x00080000)
19 #define STM32MP_NOR_METADATA2_OFFSET	U(0x000C0000)
20 #define STM32MP_NOR_FIP_A_OFFSET	U(0x00100000)
21 #define STM32MP_NOR_FIP_A_GUID		(const struct efi_guid)EFI_GUID(0x4fd84c93,  \
22 					0x54ef, 0x463f, 0xa7, 0xef, 0xae, 0x25, 0xff,\
23 					0x88, 0x70, 0x87)
24 
25 #define STM32MP_NOR_FIP_B_OFFSET	U(0x00500000)
26 #define STM32MP_NOR_FIP_B_GUID		(const struct efi_guid)EFI_GUID(0x09c54952,  \
27 					0xd5bf, 0x45af, 0xac, 0xee, 0x33, 0x53, 0x03,\
28 					0x76, 0x6f, 0xb3)
29 
30 #define STM32MP_NAND_METADATA1_OFFSET	U(0x00100000)
31 #define STM32MP_NAND_METADATA2_OFFSET	U(0x00180000)
32 #define STM32MP_NAND_FIP_A_OFFSET	U(0x00200000)
33 #define STM32MP_NAND_FIP_A_GUID		(const struct efi_guid)EFI_GUID(0x4fd84c93,  \
34 					0x54ef, 0x463f, 0xa7, 0xef, 0xae, 0x25, 0xff,\
35 					0x88, 0x70, 0x87)
36 
37 #define STM32MP_NAND_FIP_B_OFFSET	U(0x00A00000)
38 #define STM32MP_NAND_FIP_B_GUID		(const struct efi_guid)EFI_GUID(0x09c54952,  \
39 					0xd5bf, 0x45af, 0xac, 0xee, 0x33, 0x53, 0x03,\
40 					0x76, 0x6f, 0xb3)
41 
42 #define STM32MP_NAND_FIP_B_MAX_OFFSET	U(0x01200000)
43 #else /* PSA_FWU_SUPPORT */
44 #ifndef STM32MP_NOR_FIP_OFFSET
45 #define STM32MP_NOR_FIP_OFFSET		U(0x00080000)
46 #endif
47 #ifndef STM32MP_NAND_FIP_OFFSET
48 #define STM32MP_NAND_FIP_OFFSET		U(0x00200000)
49 #endif
50 #endif /* PSA_FWU_SUPPORT */
51 
52 /*
53  * Only used for MTD devices that need some backup blocks.
54  * Must define a maximum size for a partition.
55  */
56 #define PLATFORM_MTD_MAX_PART_SIZE	U(0x00400000)
57 
58 #define FIP_IMAGE_NAME			"fip"
59 #define METADATA_PART_1			"metadata1"
60 #define METADATA_PART_2			"metadata2"
61 
62 /* IO devices handle */
63 extern uintptr_t storage_dev_handle;
64 extern uintptr_t fip_dev_handle;
65 extern uintptr_t enc_dev_handle;
66 
67 extern io_block_spec_t image_block_spec;
68 
69 /* Function declarations */
70 int open_fip(const uintptr_t spec);
71 #ifndef DECRYPTION_SUPPORT_none
72 int open_enc_fip(const uintptr_t spec);
73 #endif
74 int open_storage(const uintptr_t spec);
75 
76 #endif /* STM32MP_IO_STORAGE_H */
77