Intel® Quark™ Microcontroller Software Interface  1.4.0
Intel® Quark™ Microcontroller BSP
flash_layout.h
1 /*
2  * {% copyright %}
3  */
4 
5 #ifndef __FLASH_LAYOUT_H__
6 #define __FLASH_LAYOUT_H__
7 
8 /**
9  * Flash Layout for Quark SE Microcontrollers.
10  *
11  * @defgroup groupSEFlash Quark SE Flash Layout
12  * @{
13  */
14 
15 typedef struct {
16  QM_RW uint32_t magic; /**< Magic Number. */
17  QM_RW uint16_t version; /**< 0x0100. */
18  QM_RW uint16_t reserved; /**< Reserved. */
19  QM_RW uint16_t osc_trim_32mhz; /**< 32MHz Oscillator trim code. */
20  QM_RW uint16_t osc_trim_16mhz; /**< 16MHz Oscillator trim code. */
21  QM_RW uint16_t osc_trim_8mhz; /**< 8MHz Oscillator trim code. */
22  QM_RW uint16_t osc_trim_4mhz; /**< 4MHz Oscillator trim code. */
23 } qm_flash_otp_trim_t;
24 
25 #if (UNIT_TEST)
26 extern uint8_t test_flash_page[0x800];
27 #define QM_FLASH_OTP_TRIM_CODE_BASE (&test_flash_page[0])
28 #else
29 #define QM_FLASH_OTP_TRIM_CODE_BASE (0xFFFFE1F0)
30 #endif
31 
32 #define QM_FLASH_OTP_TRIM_CODE \
33  ((qm_flash_otp_trim_t *)QM_FLASH_OTP_TRIM_CODE_BASE)
34 #define QM_FLASH_OTP_SOC_DATA_VALID (0x24535021) /* $SP! */
35 #define QM_FLASH_OTP_TRIM_MAGIC (QM_FLASH_OTP_TRIM_CODE->magic)
36 
37 typedef union {
38  struct trim_fields {
39  QM_RW uint16_t
40  osc_trim_32mhz; /**< 32MHz Oscillator trim code. */
41  QM_RW uint16_t
42  osc_trim_16mhz; /**< 16MHz Oscillator trim code. */
43  QM_RW uint16_t osc_trim_8mhz; /**< 8MHz Oscillator trim code. */
44  QM_RW uint16_t osc_trim_4mhz; /**< 4MHz Oscillator trim code. */
45  } fields;
46  QM_RW uint32_t osc_trim_u32[2]; /**< Oscillator trim code array.*/
47  QM_RW uint16_t osc_trim_u16[4]; /**< Oscillator trim code array.*/
48 } qm_flash_data_trim_t;
49 
50 #if (UNIT_TEST)
51 #define QM_FLASH_DATA_TRIM_BASE (&test_flash_page[100])
52 #define QM_FLASH_DATA_TRIM_OFFSET (100)
53 #else
54 #define QM_FLASH_DATA_TRIM_BASE (0x4002F000)
55 #define QM_FLASH_DATA_TRIM_OFFSET ((uint32_t)QM_FLASH_DATA_TRIM_BASE & 0x3FFFF)
56 #endif
57 
58 #define QM_FLASH_DATA_TRIM ((qm_flash_data_trim_t *)QM_FLASH_DATA_TRIM_BASE)
59 #define QM_FLASH_DATA_TRIM_CODE (&QM_FLASH_DATA_TRIM->fields)
60 #define QM_FLASH_DATA_TRIM_REGION QM_FLASH_REGION_SYS
61 
62 #define QM_FLASH_TRIM_PRESENT_MASK (0xFC00)
63 #define QM_FLASH_TRIM_PRESENT (0x0000)
64 
65 /*
66  * Bootloader data
67  */
68 
69 /* The flash address where the BL-Data Section starts. */
70 #define BL_DATA_FLASH_REGION_BASE QM_FLASH_REGION_SYS_0_BASE
71 /* The flash page where the BL-Data Section starts. */
72 #define BL_DATA_SECTION_BASE_PAGE (94)
73 
74 /* The size (in pages) of the System_0 flash region of Quark SE. */
75 #define QM_FLASH_REGION_SYS_0_PAGES (96)
76 /* The size (in pages) of the System_1 flash region of Quark SE. */
77 #define QM_FLASH_REGION_SYS_1_PAGES (96)
78 
79 /**
80  * @}
81  */
82 
83 #endif /* __FLASH_LAYOUT_H__ */