unsik Kim <donari75@gmail.com>:
[openocd.git] / src / flash / mflash.h
1 /***************************************************************************
2 * Copyright (C) 2007-2008 by unsik Kim <donari75@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
19
20 #ifndef _MFLASH_H
21 #define _MFLASH_H
22
23 #include "target.h"
24
25 typedef unsigned long mg_io_uint32;
26 typedef unsigned short mg_io_uint16;
27 typedef unsigned char mg_io_uint8;
28
29 typedef struct mflash_gpio_num_s
30 {
31 char port[2];
32 signed short num;
33 } mflash_gpio_num_t;
34
35 typedef struct mflash_gpio_drv_s
36 {
37 char *name;
38 int (*set_gpio_to_output) (mflash_gpio_num_t gpio);
39 int (*set_gpio_output_val) (mflash_gpio_num_t gpio, u8 val);
40 } mflash_gpio_drv_t;
41
42 typedef struct _mg_io_type_drv_info {
43
44 mg_io_uint16 general_configuration; /* 00 */
45 mg_io_uint16 number_of_cylinders; /* 01 */
46 mg_io_uint16 reserved1; /* 02 */
47 mg_io_uint16 number_of_heads; /* 03 */
48 mg_io_uint16 unformatted_bytes_per_track; /* 04 */
49 mg_io_uint16 unformatted_bytes_per_sector; /* 05 */
50 mg_io_uint16 sectors_per_track; /* 06 */
51 mg_io_uint8 vendor_unique1[6]; /* 07/08/09 */
52
53 mg_io_uint8 serial_number[20]; /* 10~19 */
54
55 mg_io_uint16 buffer_type; /* 20 */
56 mg_io_uint16 buffer_sector_size; /* 21 */
57 mg_io_uint16 number_of_ecc_bytes; /* 22 */
58
59 mg_io_uint8 firmware_revision[8]; /* 23~26 */
60 mg_io_uint8 model_number[40]; /* 27 */
61
62 mg_io_uint8 maximum_block_transfer; /* 47 low byte */
63 mg_io_uint8 vendor_unique2; /* 47 high byte */
64 mg_io_uint16 dword_io; /* 48 */
65
66 mg_io_uint16 capabilities; /* 49 */
67 mg_io_uint16 reserved2; /* 50 */
68
69 mg_io_uint8 vendor_unique3; /* 51 low byte */
70 mg_io_uint8 pio_cycle_timing_mode; /* 51 high byte */
71 mg_io_uint8 vendor_unique4; /* 52 low byte */
72 mg_io_uint8 dma_cycle_timing_mode; /* 52 high byte */
73 mg_io_uint16 translation_fields_valid; /* 53 (low bit) */
74 mg_io_uint16 number_of_current_cylinders; /* 54 */
75 mg_io_uint16 number_of_current_heads; /* 55 */
76 mg_io_uint16 current_sectors_per_track; /* 56 */
77 mg_io_uint16 current_sector_capacity_lo; /* 57 & 58 */
78 mg_io_uint16 current_sector_capacity_hi; /* 57 & 58 */
79 mg_io_uint8 multi_sector_count; /* 59 low */
80 mg_io_uint8 multi_sector_setting_valid; /* 59 high (low bit) */
81
82 mg_io_uint16 total_user_addressable_sectors_lo; /* 60 & 61 */
83 mg_io_uint16 total_user_addressable_sectors_hi; /* 60 & 61 */
84
85 mg_io_uint8 single_dma_modes_supported; /* 62 low byte */
86 mg_io_uint8 single_dma_transfer_active; /* 62 high byte */
87 mg_io_uint8 multi_dma_modes_supported; /* 63 low byte */
88 mg_io_uint8 multi_dma_transfer_active; /* 63 high byte */
89 mg_io_uint16 adv_pio_mode;
90 mg_io_uint16 min_dma_cyc;
91 mg_io_uint16 recommend_dma_cyc;
92 mg_io_uint16 min_pio_cyc_no_iordy;
93 mg_io_uint16 min_pio_cyc_with_iordy;
94 mg_io_uint8 reserved3[22];
95 mg_io_uint16 major_ver_num;
96 mg_io_uint16 minor_ver_num;
97 mg_io_uint16 feature_cmd_set_suprt0;
98 mg_io_uint16 feature_cmd_set_suprt1;
99 mg_io_uint16 feature_cmd_set_suprt2;
100 mg_io_uint16 feature_cmd_set_en0;
101 mg_io_uint16 feature_cmd_set_en1;
102 mg_io_uint16 feature_cmd_set_en2;
103 mg_io_uint16 reserved4;
104 mg_io_uint16 req_time_for_security_er_done;
105 mg_io_uint16 req_time_for_enhan_security_er_done;
106 mg_io_uint16 adv_pwr_mgm_lvl_val;
107 mg_io_uint16 reserved5;
108 mg_io_uint16 re_of_hw_rst;
109 mg_io_uint8 reserved6[68];
110 mg_io_uint16 security_stas;
111 mg_io_uint8 vendor_uniq_bytes[62];
112 mg_io_uint16 cfa_pwr_mode;
113 mg_io_uint8 reserved7[186];
114
115 mg_io_uint16 scts_per_secure_data_unit;
116 mg_io_uint16 integrity_word;
117
118 } mg_io_type_drv_info;
119
120 typedef struct mg_drv_info_s {
121 mg_io_type_drv_info drv_id;
122 u32 tot_sects;
123 } mg_drv_info_t;
124
125 typedef struct mflash_bank_s
126 {
127 u32 base;
128
129 mflash_gpio_num_t rst_pin;
130
131 mflash_gpio_drv_t *gpio_drv;
132 target_t *target;
133 mg_drv_info_t *drv_info;
134
135 u8 proved;
136 } mflash_bank_t;
137
138 extern int mflash_register_commands(struct command_context_s *cmd_ctx);
139 extern int mflash_init_drivers(struct command_context_s *cmd_ctx);
140
141 #define MG_MFLASH_SECTOR_SIZE (0x200) /* 512Bytes = 2^9 */
142 #define MG_MFLASH_SECTOR_SIZE_MASK (0x200-1)
143 #define MG_MFLASH_SECTOR_SIZE_SHIFT (9)
144
145 #define MG_BUFFER_OFFSET 0x8000
146 #define MG_REG_OFFSET 0xC000
147 #define MG_REG_FEATURE 0x2 /* write case */
148 #define MG_REG_ERROR 0x2 /* read case */
149 #define MG_REG_SECT_CNT 0x4
150 #define MG_REG_SECT_NUM 0x6
151 #define MG_REG_CYL_LOW 0x8
152 #define MG_REG_CYL_HIGH 0xA
153 #define MG_REG_DRV_HEAD 0xC
154 #define MG_REG_COMMAND 0xE /* write case */
155 #define MG_REG_STATUS 0xE /* read case */
156 #define MG_REG_DRV_CTRL 0x10
157 #define MG_REG_BURST_CTRL 0x12
158
159 #define MG_OEM_DISK_WAIT_TIME_LONG 15000 /* msec */
160 #define MG_OEM_DISK_WAIT_TIME_NORMAL 3000 /* msec */
161 #define MG_OEM_DISK_WAIT_TIME_SHORT 1000 /* msec */
162
163 typedef enum _mg_io_type_wait{
164
165 mg_io_wait_bsy = 1,
166 mg_io_wait_not_bsy = 2,
167 mg_io_wait_rdy = 3,
168 mg_io_wait_drq = 4, /* wait for data request */
169 mg_io_wait_drq_noerr = 5, /* wait for DRQ but ignore the error status bit */
170 mg_io_wait_rdy_noerr = 6 /* wait for ready, but ignore error status bit */
171
172 } mg_io_type_wait;
173
174 /*= "Status Register" bit masks. */
175 typedef enum _mg_io_type_rbit_status{
176
177 mg_io_rbit_status_error = 0x01, /* error bit in status register */
178 mg_io_rbit_status_corrected_error = 0x04, /* corrected error in status register */
179 mg_io_rbit_status_data_req = 0x08, /* data request bit in status register */
180 mg_io_rbit_status_seek_done = 0x10, /* DSC - Drive Seek Complete */
181 mg_io_rbit_status_write_fault = 0x20, /* DWF - Drive Write Fault */
182 mg_io_rbit_status_ready = 0x40,
183 mg_io_rbit_status_busy = 0x80
184
185 } mg_io_type_rbit_status;
186
187 /*= "Error Register" bit masks. */
188 typedef enum _mg_io_type_rbit_error{
189
190 mg_io_rbit_err_general = 0x01,
191 mg_io_rbit_err_aborted = 0x04,
192 mg_io_rbit_err_bad_sect_num = 0x10,
193 mg_io_rbit_err_uncorrectable = 0x40,
194 mg_io_rbit_err_bad_block = 0x80
195
196 } mg_io_type_rbit_error;
197
198 /* = "Device Control Register" bit. */
199 typedef enum _mg_io_type_rbit_devc{
200
201 mg_io_rbit_devc_intr = 0x02, /* interrupt enable bit (1:disable, 0:enable) */
202 mg_io_rbit_devc_srst = 0x04 /* softwrae reset bit (1:assert, 0:de-assert) */
203
204 } mg_io_type_rbit_devc;
205
206 /* "Drive Select/Head Register" values. */
207 typedef enum _mg_io_type_rval_dev{
208
209 mg_io_rval_dev_must_be_on = 0x80, /* These 1 bits are always on */
210 mg_io_rval_dev_drv_master = (0x00 | mg_io_rval_dev_must_be_on), /* Master */
211 mg_io_rval_dev_drv_slave0 = (0x10 | mg_io_rval_dev_must_be_on), /* Slave0 */
212 mg_io_rval_dev_drv_slave1 = (0x20 | mg_io_rval_dev_must_be_on), /* Slave1 */
213 mg_io_rval_dev_drv_slave2 = (0x30 | mg_io_rval_dev_must_be_on), /* Slave2 */
214 mg_io_rval_dev_lba_mode = (0x40 | mg_io_rval_dev_must_be_on)
215
216 } mg_io_type_rval_dev;
217
218 typedef enum _mg_io_type_cmd
219 {
220 mg_io_cmd_read =0x20,
221 mg_io_cmd_write =0x30,
222
223 mg_io_cmd_setmul =0xC6,
224 mg_io_cmd_readmul =0xC4,
225 mg_io_cmd_writemul =0xC5,
226
227 mg_io_cmd_idle =0x97, /* 0xE3 */
228 mg_io_cmd_idle_immediate =0x95, /* 0xE1 */
229
230 mg_io_cmd_setsleep =0x99, /* 0xE6 */
231 mg_io_cmd_stdby =0x96, /* 0xE2 */
232 mg_io_cmd_stdby_immediate =0x94, /* 0xE0 */
233
234 mg_io_cmd_identify =0xEC,
235 mg_io_cmd_set_feature =0xEF,
236
237 mg_io_cmd_confirm_write =0x3C,
238 mg_io_cmd_confirm_read =0x40,
239 mg_io_cmd_wakeup =0xC3
240
241 } mg_io_type_cmd;
242
243 #endif

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)