OpenOCD
cfi.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2005 by Dominic Rath *
5  * Dominic.Rath@gmx.de *
6  ***************************************************************************/
7 
8 #ifndef OPENOCD_FLASH_NOR_CFI_H
9 #define OPENOCD_FLASH_NOR_CFI_H
10 
11 #define CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7 0xE0 /* DQ5..DQ7 */
12 #define CFI_STATUS_POLL_MASK_DQ6_DQ7 0xC0 /* DQ6..DQ7 */
13 
15  bool x16_as_x8;
17  bool not_cfi;
18  bool probed;
19 
21  bool data_swap;
22 
23  uint16_t manufacturer;
24  uint16_t device_id;
25 
26  uint8_t qry[3];
27 
28  /* identification string */
29  uint16_t pri_id;
30  uint16_t pri_addr;
31  uint16_t alt_id;
32  uint16_t alt_addr;
33 
34  /* device-system interface */
35  uint8_t vcc_min;
36  uint8_t vcc_max;
37  uint8_t vpp_min;
38  uint8_t vpp_max;
47 
49 
50  /* flash geometry */
51  uint32_t dev_size;
52  uint16_t interface_desc;
55  uint32_t *erase_region_info;
56 
57  void *pri_ext;
58  void *alt_ext;
59 
60  /* calculated timeouts */
65 
66  /* memory accessors */
68  uint32_t count, const uint8_t *buffer);
70  uint32_t count, uint8_t *buffer);
71 };
72 
73 /* Intel primary extended query table
74  * as defined for the Advanced+ Boot Block Flash Memory (C3)
75  * and used by the linux kernel cfi driver (as of 2.6.14)
76  */
78  uint8_t pri[3];
79  uint8_t major_version;
80  uint8_t minor_version;
81  uint32_t feature_support;
84  uint8_t vcc_optimal;
85  uint8_t vpp_optimal;
87  uint16_t prot_reg_addr;
90  uint8_t extra[0];
91 };
92 
93 /* Spansion primary extended query table as defined for and used by
94  * the linux kernel cfi driver (as of 2.6.15)
95  */
97  uint8_t pri[3];
98  uint8_t major_version;
99  uint8_t minor_version;
100  uint8_t silicon_revision; /* bits 1-0: Address Sensitive Unlock */
101  uint8_t erase_suspend;
102  uint8_t blk_prot;
106  uint8_t burst_mode;
107  uint8_t page_mode;
108  uint8_t vpp_min;
109  uint8_t vpp_max;
110  uint8_t top_bottom;
112  uint32_t _unlock1;
113  uint32_t _unlock2;
114 };
115 
116 /* Atmel primary extended query table as defined for and used by
117  * the linux kernel cfi driver (as of 2.6.20+)
118  */
120  uint8_t pri[3];
121  uint8_t major_version;
122  uint8_t minor_version;
123  uint8_t features;
124  uint8_t bottom_boot;
125  uint8_t burst_mode;
126  uint8_t page_mode;
127 };
128 
129 enum {
132 };
133 
135  uint32_t unlock1;
136  uint32_t unlock2;
137 };
138 
139 struct cfi_fixup {
140  uint16_t mfr;
141  uint16_t id;
142  void (*fixup)(struct flash_bank *bank, const void *param);
143  const void *param;
144 };
145 
146 int cfi_erase(struct flash_bank *bank, unsigned int first, unsigned int last);
147 int cfi_protect(struct flash_bank *bank, int set, unsigned int first,
148  unsigned int last);
149 int cfi_probe(struct flash_bank *bank);
150 int cfi_auto_probe(struct flash_bank *bank);
151 int cfi_protect_check(struct flash_bank *bank);
152 int cfi_get_info(struct flash_bank *bank, struct command_invocation *cmd);
153 int cfi_flash_bank_cmd(struct flash_bank *bank, unsigned int argc, const char **argv);
154 
155 uint32_t cfi_flash_address(struct flash_bank *bank, int sector, uint32_t offset);
157 int cfi_send_command(struct flash_bank *bank, uint8_t cmd, uint32_t address);
158 int cfi_write_word(struct flash_bank *bank, uint8_t *word, uint32_t address);
160 int cfi_reset(struct flash_bank *bank);
161 
163  uint32_t count, uint8_t *buffer);
164 
165 #define CFI_MFR_AMD 0x0001
166 #define CFI_MFR_FUJITSU 0x0004
167 #define CFI_MFR_ATMEL 0x001F
168 #define CFI_MFR_ST 0x0020 /* STMicroelectronics */
169 #define CFI_MFR_AMIC 0x0037
170 #define CFI_MFR_SST 0x00BF
171 #define CFI_MFR_MX 0x00C2
172 #define CFI_MFR_EON 0x007F
173 
174 #define CFI_MFR_ANY 0xffff
175 #define CFI_ID_ANY 0xffff
176 
177 #define CFI_MAX_BUS_WIDTH 4
178 #define CFI_MAX_CHIP_WIDTH 4
179 
180 #endif /* OPENOCD_FLASH_NOR_CFI_H */
uint32_t cfi_flash_address(struct flash_bank *bank, int sector, uint32_t offset)
Definition: cfi.c:100
@ CFI_UNLOCK_555_2AA
Definition: cfi.h:130
@ CFI_UNLOCK_5555_2AAA
Definition: cfi.h:131
int cfi_write_word(struct flash_bank *bank, uint8_t *word, uint32_t address)
Definition: cfi.c:2170
int cfi_protect_check(struct flash_bank *bank)
Definition: cfi.c:2930
int cfi_probe(struct flash_bank *bank)
Definition: cfi.c:2532
int cfi_auto_probe(struct flash_bank *bank)
Definition: cfi.c:2864
int cfi_get_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: cfi.c:2956
int cfi_reset(struct flash_bank *bank)
Definition: cfi.c:282
int cfi_target_read_memory(struct flash_bank *bank, target_addr_t addr, uint32_t count, uint8_t *buffer)
Definition: cfi.c:131
int cfi_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: cfi.c:1073
int cfi_send_command(struct flash_bank *bank, uint8_t cmd, uint32_t address)
Definition: cfi.c:162
int cfi_flash_bank_cmd(struct flash_bank *bank, unsigned int argc, const char **argv)
Definition: cfi.c:778
int cfi_spansion_wait_status_busy(struct flash_bank *bank, int timeout)
Definition: cfi.c:363
int cfi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: cfi.c:931
int cfi_spansion_unlock_seq(struct flash_bank *bank)
Definition: cfi.c:876
uint8_t bank
Definition: esirisc.c:135
uint32_t addr
Definition: nuttx.c:65
uint8_t bottom_boot
Definition: cfi.h:124
uint8_t minor_version
Definition: cfi.h:122
uint8_t pri[3]
Definition: cfi.h:120
uint8_t major_version
Definition: cfi.h:121
uint8_t burst_mode
Definition: cfi.h:125
uint8_t page_mode
Definition: cfi.h:126
uint8_t features
Definition: cfi.h:123
Definition: cfi.h:139
void(* fixup)(struct flash_bank *bank, const void *param)
Definition: cfi.h:142
uint16_t mfr
Definition: cfi.h:140
uint16_t id
Definition: cfi.h:141
const void * param
Definition: cfi.h:143
uint8_t block_erase_timeout_typ
Definition: cfi.h:41
uint8_t num_erase_regions
Definition: cfi.h:54
int(* read_mem)(struct flash_bank *bank, target_addr_t addr, uint32_t count, uint8_t *buffer)
Definition: cfi.h:69
uint16_t alt_addr
Definition: cfi.h:32
unsigned buf_write_timeout
Definition: cfi.h:62
uint8_t chip_erase_timeout_max
Definition: cfi.h:46
uint16_t alt_id
Definition: cfi.h:31
uint8_t vpp_min
Definition: cfi.h:37
uint16_t max_buf_write_size
Definition: cfi.h:53
uint8_t vpp_max
Definition: cfi.h:38
uint32_t * erase_region_info
Definition: cfi.h:55
uint16_t pri_addr
Definition: cfi.h:30
unsigned block_erase_timeout
Definition: cfi.h:63
void * alt_ext
Definition: cfi.h:58
bool probed
Definition: cfi.h:18
uint8_t status_poll_mask
Definition: cfi.h:48
unsigned chip_erase_timeout
Definition: cfi.h:64
uint8_t qry[3]
Definition: cfi.h:26
bool not_cfi
Definition: cfi.h:17
uint16_t interface_desc
Definition: cfi.h:52
uint8_t word_write_timeout_max
Definition: cfi.h:43
uint8_t word_write_timeout_typ
Definition: cfi.h:39
uint32_t dev_size
Definition: cfi.h:51
uint8_t vcc_min
Definition: cfi.h:35
enum target_endianness endianness
Definition: cfi.h:20
uint8_t buf_write_timeout_typ
Definition: cfi.h:40
uint8_t chip_erase_timeout_typ
Definition: cfi.h:42
bool x16_as_x8
Definition: cfi.h:15
bool data_swap
Definition: cfi.h:21
unsigned word_write_timeout
Definition: cfi.h:61
uint16_t pri_id
Definition: cfi.h:29
void * pri_ext
Definition: cfi.h:57
uint8_t buf_write_timeout_max
Definition: cfi.h:44
int(* write_mem)(struct flash_bank *bank, target_addr_t addr, uint32_t count, const uint8_t *buffer)
Definition: cfi.h:67
uint8_t vcc_max
Definition: cfi.h:36
uint8_t block_erase_timeout_max
Definition: cfi.h:45
uint16_t manufacturer
Definition: cfi.h:23
uint16_t device_id
Definition: cfi.h:24
bool jedec_probe
Definition: cfi.h:16
uint8_t major_version
Definition: cfi.h:79
uint8_t vpp_optimal
Definition: cfi.h:85
uint16_t prot_reg_addr
Definition: cfi.h:87
uint32_t feature_support
Definition: cfi.h:81
uint16_t blk_status_reg_mask
Definition: cfi.h:83
uint8_t pri[3]
Definition: cfi.h:78
uint8_t user_prot_reg_size
Definition: cfi.h:89
uint8_t vcc_optimal
Definition: cfi.h:84
uint8_t fact_prot_reg_size
Definition: cfi.h:88
uint8_t minor_version
Definition: cfi.h:80
uint8_t num_protection_fields
Definition: cfi.h:86
uint8_t suspend_cmd_support
Definition: cfi.h:82
uint8_t extra[0]
Definition: cfi.h:90
uint8_t tmp_blk_unprotected
Definition: cfi.h:103
uint8_t vpp_max
Definition: cfi.h:109
uint8_t simultaneous_ops
Definition: cfi.h:105
uint8_t burst_mode
Definition: cfi.h:106
uint8_t top_bottom
Definition: cfi.h:110
uint8_t vpp_min
Definition: cfi.h:108
uint8_t blk_prot_unprot
Definition: cfi.h:104
uint32_t _unlock1
Definition: cfi.h:112
uint8_t blk_prot
Definition: cfi.h:102
uint8_t erase_suspend
Definition: cfi.h:101
uint8_t page_mode
Definition: cfi.h:107
uint8_t pri[3]
Definition: cfi.h:97
uint8_t silicon_revision
Definition: cfi.h:100
uint8_t minor_version
Definition: cfi.h:99
uint32_t _unlock2
Definition: cfi.h:113
int _reversed_geometry
Definition: cfi.h:111
uint8_t major_version
Definition: cfi.h:98
uint32_t unlock2
Definition: cfi.h:136
uint32_t unlock1
Definition: cfi.h:135
When run_command is called, a new instance will be created on the stack, filled with the proper value...
Definition: command.h:76
Provides details of a flash bank, available either on-chip or through a major interface.
Definition: nor/core.h:75
Definition: psoc6.c:84
target_endianness
Definition: target.h:84
uint64_t target_addr_t
Definition: types.h:335
uint8_t cmd
Definition: vdebug.c:1
uint8_t offset[4]
Definition: vdebug.c:9
uint8_t count[4]
Definition: vdebug.c:22