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 D2000 Microcontrollers.
10  *
11  * @defgroup groupD2000Flash Quark D2000 Flash Layout
12  * @{
13  */
14 
15 typedef struct {
16  QM_RW uint16_t osc_trim_16mhz; /**< 16MHz Oscillator trim code. */
17  QM_RW uint16_t osc_trim_32mhz; /**< 32MHz Oscillator trim code. */
18  QM_RW uint16_t osc_trim_4mhz; /**< 4MHz Oscillator trim code. */
19  QM_RW uint16_t osc_trim_8mhz; /**< 8MHz Oscillator trim code. */
20 } qm_flash_otp_trim_t;
21 
22 #if (UNIT_TEST)
23 extern uint8_t test_flash_page[0x800];
24 #define QM_FLASH_OTP_TRIM_CODE_BASE (&test_flash_page[0])
25 #else
26 #define QM_FLASH_OTP_TRIM_CODE_BASE (0x4)
27 #endif
28 
29 #define QM_FLASH_OTP_TRIM_CODE \
30  ((qm_flash_otp_trim_t *)QM_FLASH_OTP_TRIM_CODE_BASE)
31 #define QM_FLASH_OTP_SOC_DATA_VALID (0x24535021) /* $SP! */
32 #define QM_FLASH_OTP_TRIM_MAGIC (QM_FLASH_OTP_SOC_DATA_VALID)
33 
34 typedef union {
35  struct trim_fields {
36  QM_RW uint16_t
37  osc_trim_32mhz; /**< 32MHz Oscillator trim code. */
38  QM_RW uint16_t
39  osc_trim_16mhz; /**< 16MHz Oscillator trim code. */
40  QM_RW uint16_t osc_trim_8mhz; /**< 8MHz Oscillator trim code. */
41  QM_RW uint16_t osc_trim_4mhz; /**< 4MHz Oscillator trim code. */
42  } fields;
43  QM_RW uint32_t osc_trim_u32[2]; /**< Oscillator trim code array.*/
44  QM_RW uint16_t osc_trim_u16[4]; /**< Oscillator trim code array.*/
45 } qm_flash_data_trim_t;
46 
47 #if (UNIT_TEST)
48 #define QM_FLASH_DATA_TRIM_BASE (&test_flash_page[100])
49 #define QM_FLASH_DATA_TRIM_OFFSET (100)
50 #else
51 #define QM_FLASH_DATA_TRIM_BASE (QM_FLASH_REGION_DATA_0_BASE)
52 #define QM_FLASH_DATA_TRIM_OFFSET ((uint32_t)QM_FLASH_DATA_TRIM_BASE & 0x3FFFF)
53 #endif
54 
55 #define QM_FLASH_DATA_TRIM ((qm_flash_data_trim_t *)QM_FLASH_DATA_TRIM_BASE)
56 #define QM_FLASH_DATA_TRIM_CODE (&QM_FLASH_DATA_TRIM->fields)
57 #define QM_FLASH_DATA_TRIM_REGION QM_FLASH_REGION_DATA
58 
59 #define QM_FLASH_TRIM_PRESENT_MASK (0xFC00)
60 #define QM_FLASH_TRIM_PRESENT (0x7C00)
61 
62 /*
63  * Bootloader data
64  */
65 
66 /* The flash address where the BL-Data Section starts. */
67 #define BL_DATA_FLASH_REGION_BASE QM_FLASH_REGION_DATA_0_BASE
68 /* The flash page where the BL-Data Section starts. */
69 #define BL_DATA_SECTION_BASE_PAGE (0)
70 
71 /* The size (in pages) of the System flash region of Quark D2000. */
72 #define QM_FLASH_REGION_SYS_0_PAGES (16)
73 
74 /**
75  * @}
76  */
77 
78 #endif /* __FLASH_LAYOUT_H__ */