NetBurner 3.5.6
PDF Version
SPIFlash_SFDP.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5#ifndef __SPIFLASH_SFDP_H
6#define __SPIFLASH_SFDP_H
7
8
9/*****************************************************************************
10 * Serial Flash Discover-able Parameters *
11 * ------------------------------------- *
12 * Serial Flash Discover-able Parameters (SFDP) are a mechanism for a host *
13 * to automatically be able to optimally configure a bus and driver for *
14 * using a serial flash/NVM device, without a priori knowledge. *
15 * *
16 * Further details may be found in the JEDEC Standard: Serial Flash *
17 * Discover-able Parameters (SFDP), JESD216. *
18 * *
19 *****************************************************************************/
20
21#include <basictypes.h>
22#include <bit_overlay.h>
23
24#define SFDP_PROTO_XSPI_NAND_1 0xF0
25#define SFDP_PROTO_XSPI_NAND_2 0xF1
26#define SFDP_PROTO_XSPI_NAND_3_1 0xF2
27#define SFDP_PROTO_XSPI_NAND_3_2 0xF3
28#define SFDP_PROTO_SPI_NAND_1 0xF4
29#define SFDP_PROTO_SPI_NAND_2 0xF5
30#define SFDP_PROTO_SPI_NAND_3_1 0xF6
31#define SFDP_PROTO_SPI_NAND_3_2 0xF7
32#define SFDP_PROTO_XSPI_NOR_2_5BA_8W 0xFA
33#define SFDP_PROTO_XSPI_NOR_1_3BA_8W_DTR 0xFC
34#define SFDP_PROTO_XSPI_NOR_1_4BA_20W 0xFD
35#define SFDP_PROTO_XSPI_NOR_1_4BA_8W 0xFE
36#define SFDP_PROTO_XSPI_NOR_1_3BA_8W 0xFF
37
38#define SFDP_PARAM_BASIC_PROTO 0xFF00
39#define SFDP_PARAM_SECTOR_MAP 0xFF81
40#define SFDP_PARAM_REP_PROT_MONO_CTRS 0xFF03
41#define SFDP_PARAM_4B_ADDR_INSTR_TBL 0xFF84
42#define SFDP_PARAM_XSPI_PROFILE_1_0 0xFF05
43#define SFDP_PARAM_XSPI_PROFILE_2_0 0xFF06
44#define SFDP_PARAM_STAT_CTRL_CFG_MAP 0xFF87
45#define SFDP_PARAM_STAT_CTRL_CFG_MAP_OFFSETS 0xFF88
46#define SFDP_PARAM_STAT_CTRL_CFG_MAP_XSPI_2_0 0xFF09
47#define SFDP_PARAM_CMD_SEQ_OCTAL_DDR 0xFF0A
48#define SFDP_PARAM_LONG_LAT_NVM_MSPT 0xFF8B
49#define SFDP_PARAM_X4_QUAD_IO_WITH_DS 0xFF0C
50#define SFDP_PARAM_CMD_SEQ_QUAD_DDR 0xFF8D
51
52#define SFDP_PARAM_BASIC_TBL_1_0 0xFF00
53
54#define SFDP_SIGNATURE HTONL(0x53464450)
55
56#define __str(x) #x
57
58struct sfdpHdr_t
59{
60 union {
61 uint8_t asBuf[8];
62 struct {
63 uint32_t sig;
64 uint8_t minor;
65 uint8_t major;
66 uint8_t paramCount; // total params is paramCount + 1
67 uint8_t proto;
68 };
69 };
70}__attribute__((packed));
71
72struct sfdpParamHdr_t
73{
74 union {
75 uint8_t asBuf[8];
76 uint32_t asDWBuf[2];
77 struct {
78 uint8_t paramID_lsb;
79 uint8_t minor;
80 uint8_t major;
81 uint8_t len;
82 union {
83 uint32_t __val;
84 bit_overlay<23, 0,32> tblAddr;
85 bit_overlay<31,24,32> paramID_msb;
86 };
87 }__attribute__((packed));
88 };
89 inline uint16_t id() { return (((uint32_t)paramID_msb) << 8) | (uint16_t)paramID_lsb; }
90}__attribute__((packed));
91
92#define BEGIN_FIELD(n, sz) union { \
93 uint##sz##_t __val_##n;
94#define END_FIELD() }__attribute__((packed));
95#define BITS(e, s, w, name) __BITS(e, s, w, name, #name)
96#define BIT(e, w, name) __BITS(e, e, w, name, #name)
97#define BITS_PRETTY(e, s, w, name, lbl) __BITS(e, s, w, name, lbl)
98#define BIT_PRETTY(e, w, name, lbl) __BITS(e, e, w, name, lbl)
99
100struct sfdpBasicFlashTbl_1_0
101{
102 union {
103 struct {
104#define BEGIN_FIELD(n, sz) union { \
105 uint##sz##_t __val_##n;
106#define END_FIELD() }__attribute__((packed));
107#define __BITS(e, s, w, name, lbl) bit_overlay<e,s,w> name;
108#include "sfdp_basic_tbl_1_0.inc"
109#undef __BITS
110#undef BEGIN_FIELD
111#undef END_FIELD
112 }__attribute__((packed));
113 struct{
114 uint8_t asBuf[];
115 };
116 }__attribute__((packed));
117}__attribute__((packed));
118
119struct sfdpBasicFlashTbl_1_5
120{
121 union {
122 struct {
123#define BEGIN_FIELD(n, sz) union { \
124 uint##sz##_t __val_##n;
125#define END_FIELD() }__attribute__((packed));
126#define __BITS(e, s, w, name, lbl) bit_overlay<e,s,w> name;
127#include "sfdp_basic_tbl_1_5.inc"
128#undef __BITS
129#undef BEGIN_FIELD
130#undef END_FIELD
131 }__attribute__((packed));
132 struct{
133 uint8_t asBuf[];
134 };
135 };
136}__attribute__((packed));
137
138
139
140#endif /* ----- #ifndef __SPIFLASH_SFDP_H ----- */
141