OpenSSD Cosmos+ Platform Firmware  0.0.2
The firmware of Cosmos+ OpenSSD Platform for TOSHIBA nand flash module.
nsc_driver.h
Go to the documentation of this file.
1
2// fmc_driver.h for Cosmos+ OpenSSD
3// Copyright (c) 2016 Hanyang University ENC Lab.
4// Contributed by Yong Ho Song <yhsong@enc.hanyang.ac.kr>
5// Kibin Park <kbpark@enc.hanyang.ac.kr>
6// Jaewook Kwak <jwkwak@enc.hanyang.ac.kr>
7//
8// This file is part of Cosmos+ OpenSSD.
9//
10// Cosmos+ OpenSSD is free software; you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation; either version 3, or (at your option)
13// any later version.
14//
15// Cosmos+ OpenSSD is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18// See the GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Cosmos+ OpenSSD; see the file COPYING.
22// If not, see <http://www.gnu.org/licenses/>.
24
26// Company: ENC Lab. <http://enc.hanyang.ac.kr>
27// Engineer: Kibin Park <kbpark@enc.hanyang.ac.kr>
28//
29// Project Name: Cosmos+ OpenSSD
30// Design Name: Cosmos+ Firmware
31// Module Name: NAND Storage Controller Driver
32// File Name: nsc_driver.h
33//
34// Version: v1.2.0
35//
36// Description:
37// - define parameters, data structure and functions of NAND storage controller driver
39
41// Revision History:
42//
43// * v1.2.0
44// - Completion flag checker is added
45// - Way ready checker is added
46// - Request status report checker is added
47//
48// * v1.1.0
49// - V2FReadPageTransferAsync needs additional input (rowAddress)
50// - Opcode of some commands is modified
51// - LLSCommand_ReadRawPage is deleted
52//
53// * v1.0.0
54// - First draft
56
57#ifndef FMC_DRIVER_H_
58#define FMC_DRIVER_H_
59
60#include "t4nsc_pm.h"
61
62#define T4NSC_CMD_NAND_RESET 4
63#define T4NSC_CMD_MODE_CHANGE 32
64#define T4NSC_CMD_GET_READYBUSY 108
65#define T4NSC_CMD_SET_FEATURESA 124
66#define T4NSC_CMD_SET_LUN_FEATUREST 132
67#define T4NSC_CMD_SET_FEATUREST 144
68#define T4NSC_CMD_GET_LUN_FEATUREST 192
69#define T4NSC_CMD_GET_FEATUREST 204
70#define T4NSC_CMD_SET_SCRAMBLER_DISABLE 264
71#define T4NSC_CMD_SET_SCRAMBLER_ENABLE 284
72#define T4NSC_CMD_READ_STATUS 304
73#define T4NSC_CMD_ERASE_BLOCK 352
74#define T4NSC_CMD_READ_PAGE_TRIGGER 384
75#define T4NSC_CMD_SINGLE_STATE_READ_PAGE_TRIGGER 392
76#define T4NSC_CMD_READ_PAGE_TRIGGER_WRLPRE_LSB 404
77#define T4NSC_CMD_READ_PAGE_TRIGGER_WRLPRE_CSB 412
78#define T4NSC_CMD_READ_PAGE_TRIGGER_WRLPRE_MSB 420
79#define T4NSC_CMD_READ_PAGE_TRIGGER_LSB 428
80#define T4NSC_CMD_READ_PAGE_TRIGGER_CSB 436
81#define T4NSC_CMD_READ_PAGE_TRIGGER_MSB 444
82#define T4NSC_CMD_READ_PAGE_TRIGGER_PSLC 452
83#define T4NSC_CMD_READ_TRANSFER_RAW 500
84#define T4NSC_CMD_PROGRAM_PAGE_RAW 568
85#define T4NSC_CMD_PROGRAM_PAGE_RAW_xSB 576
86#define T4NSC_CMD_PROGRAM_PAGE_RAW_PSLC 580
87#define T4NSC_CMD_READ_ID 756
88#define T4NSC_CMD_END_OF_COMMON 824
89
90#define T4NSC_CMD_READ_TRANSFER_PSLC (T4NSC_CMD_END_OF_COMMON + 0)
91#define T4NSC_CMD_PROGRAM_PAGE_PSLC (T4NSC_CMD_END_OF_COMMON + 112)
92#define T4NSC_CMD_READ_TRANSFER (T4NSC_CMD_END_OF_COMMON + 204)
93#define T4NSC_CMD_PROGRAM_PAGES (T4NSC_CMD_END_OF_COMMON + 616)
94#define T4NSC_CMD_FSP_PAGES (T4NSC_CMD_END_OF_COMMON + 960)
95#define T4NSC_CMD_END_OF_PLAINOPS (T4NSC_CMD_END_OF_COMMON + 1308)
96
97#define V2FFillRegisters(t4regs, cmdtype, cmdpayload) (*((volatile cmdtype *)((t4regs)->t4regSP)) = (cmdpayload))
98#define V2FIssueCommand(t4regs) (((t4regs)->t4regCC)->issueCmd = 1)
99
100#define V2FIsControllerBusy(t4regs) ((t4regs)->t4regID->queueNotFull == 0)
101#define V2FGetFreeQueueCount(t4regs) (32 - ((t4regs)->t4regID->queueCount))
102#define V2FGetNANDReadyBusy(t4regs, way) !!((t4regs)->t4regBP->nandReadyBusy & (1 << (way)))
103
104#define V2FCrcValid(errorInformation) !!(*((uint32_t *)(errorInformation)) & 0x10000000)
105#define V2FWorstChunkErrorCount(errorInformation) ((*((uint32_t *)(errorInformation)) & 0x00FF0000) >> 16)
106#define V2FPageDecodeSuccess(secErrorInformation) \
107 ((*((uint32_t *)(secErrorInformation)) & 0xFFFFFFFF) == 0xFFFFFFFF)
108
109#define V2FEnterToggleMode(dev, way, payLoadAddr) V2FSetFeaturesSync(dev, way, 0x17, 0x06, 0, payLoadAddr)
110
111#define V2FWayReady(readyBusy, wayNo) (((readyBusy) >> (wayNo)) & 1)
112#define V2FTransferComplete(completeFlag) ((completeFlag)&1)
113#define V2FRequestReportDone(statusReport) ((statusReport)&1)
114#define V2FEliminateReportDoneFlag(statusReport) ((statusReport) >> 1)
115#define V2FRequestComplete(statusReport) (((statusReport)&0x60) == 0x60)
116#define V2FRequestFail(statusReport) ((statusReport)&3)
117
118typedef struct
119{
120 unsigned int cmdSelect;
121 unsigned int rowAddress;
122 unsigned int userData;
123 unsigned int dataAddress;
124 unsigned int spareAddress;
125 unsigned int errorCountAddress;
126 unsigned int completionAddress;
127 unsigned int waySelection;
128 unsigned int channelBusy;
129 unsigned int readyBusy;
131
132typedef struct
133{
134 unsigned int queueNotFull : 1;
135 unsigned int version : 31;
136 unsigned int queueCount;
137} T4REG_ID;
138
139typedef struct
140{
141 unsigned int reserved;
142} T4REG_CFG;
143
144typedef struct
145{
147} T4REG_EXT;
148
149typedef struct
150{
151 unsigned int issueCmd;
152} T4REG_CC;
153
154typedef struct
155{
156 unsigned int nandReadyBusy;
157} T4REG_BP;
158
159typedef struct
160{
161 unsigned int cmdSelect;
162 unsigned int waySelect;
163 unsigned int sr[30];
164} T4REG_SP;
165
166typedef struct
167{
168 // Identification and status register
169 volatile T4REG_ID *t4regID;
170 // Configuration register
172 // Extension module access interface
174 // Dispatcher core control register
175 volatile T4REG_CC *t4regCC;
176 // Signal bypass register
177 volatile T4REG_BP *t4regBP;
178 // Scratchpad (arguments passing) register
179 volatile T4REG_SP *t4regSP;
180} T4REGS;
181
182typedef struct
183{
184 unsigned int cmdSelect;
185 unsigned int waySelect;
187
188typedef struct
189{
190 unsigned int cmdSelect;
191 unsigned int waySelect;
192 unsigned int payloadAddress;
194
195typedef struct
196{
197 unsigned int cmdSelect;
198 unsigned int waySelect;
199 unsigned int payloadAddress;
200 unsigned int setFeaturesAddress;
202
203typedef struct
204{
205 unsigned int cmdSelect;
206 unsigned int waySelect;
207 unsigned int payloadAddress;
208 unsigned int setFeaturesAddress;
209 unsigned int lunSelect;
211
212typedef struct
213{
214 unsigned int cmdSelect;
215 unsigned int waySelect;
216 unsigned int reportAddress;
217 unsigned int getFeaturesAddress;
218 unsigned int completionAddress;
220
221typedef struct
222{
223 unsigned int cmdSelect;
224 unsigned int reserved;
225 unsigned int reportAddress;
227
228typedef struct
229{
230 unsigned int cmdSelect;
231 unsigned int waySelect;
232 unsigned int reportAddress;
233 unsigned int getFeaturesAddress;
234 unsigned int completionAddress;
235 unsigned int lunSelect;
237
238typedef struct
239{
240 unsigned int cmdSelect;
242
243typedef struct
244{
245 unsigned int cmdSelect;
246 unsigned int waySelect;
247 unsigned int reportAddress;
249
250typedef struct
251{
252 unsigned int cmdSelect;
253 unsigned int waySelect;
254 unsigned int rowAddress;
256
257typedef struct
258{
259 unsigned int cmdSelect;
260 unsigned int waySelect;
261 unsigned int rowAddress;
263
264typedef struct
265{
266 unsigned int cmdSelect;
267 unsigned int waySelect;
268 unsigned int rowAddress;
269 unsigned int stateSelect;
271
272typedef struct
273{
274 unsigned int cmdSelect;
275 unsigned int waySelect;
276 unsigned int rowAddress;
277 unsigned int pageDataAddress;
278 unsigned int spareDataAddress;
279 unsigned int errorInfoAddress;
282
283typedef struct
284{
285 unsigned int cmdSelect;
286 unsigned int waySelect;
287 unsigned int rowAddress;
288 unsigned int pageDataAddress;
289 unsigned int spareDataAddress;
291
292typedef struct
293{
294 unsigned int cmdSelect;
295 unsigned int waySelect;
296 unsigned int rowAddress;
297 struct
298 {
299 unsigned int pageDataAddress;
300 unsigned int spareDataAddress;
301 unsigned int errorInfoAddress;
302 } Subpages[4];
305
306typedef struct
307{
308 unsigned int cmdSelect;
309 unsigned int waySelect;
310 unsigned int rowAddress;
311 struct
312 {
313 unsigned int pageDataAddress;
314 unsigned int spareDataAddress;
315 } Subpages[4];
317
318typedef struct
319{
320 unsigned int cmdSelect;
321 unsigned int waySelect;
322 unsigned int rowAddress;
323 unsigned int option;
324 struct
325 {
326 unsigned int pageDataAddress;
327 unsigned int spareDataAddress;
328 } Subpages[4];
330
331#define T4NSC_CMD_FSP_TRANSFER_OPTION_LSB_PASSNEXT 3
332#define T4NSC_CMD_FSP_TRANSFER_OPTION_LSB_COMMIT 2
333#define T4NSC_CMD_FSP_TRANSFER_OPTION_CSB_PASSNEXT 5
334#define T4NSC_CMD_FSP_TRANSFER_OPTION_CSB_COMMIT 4
335#define T4NSC_CMD_FSP_TRANSFER_OPTION_MSB_COMMIT 6
336
337typedef struct
338{
339 unsigned int cmdSelect;
340 unsigned int waySelect;
341 unsigned int colAddress;
342 unsigned int wordLength;
343 unsigned int pageDataAddress;
346
347typedef struct
348{
349 unsigned int cmdSelect;
350 unsigned int waySelect;
351 unsigned int rowAddress;
352 unsigned int colAddress;
353 unsigned int wordLength;
354 unsigned int pageDataAddress;
356
357typedef struct
358{
359 unsigned int cmdSelect;
360 unsigned int waySelect;
361 unsigned int rowAddress;
362 unsigned int colAddress;
363 unsigned int wordLength;
364 unsigned int pageDataAddress;
365 unsigned int option;
367
368#define T4NSC_CMD_FSP_TRANSFER_OPTION_LSB_PASSNEXT 3
369#define T4NSC_CMD_FSP_TRANSFER_OPTION_LSB_COMMIT 2
370#define T4NSC_CMD_FSP_TRANSFER_OPTION_CSB_PASSNEXT 5
371#define T4NSC_CMD_FSP_TRANSFER_OPTION_CSB_COMMIT 4
372#define T4NSC_CMD_FSP_TRANSFER_OPTION_MSB_COMMIT 6
373
374typedef struct
375{
376 unsigned int cmdSelect;
377 unsigned int reserved;
378 unsigned int pageBufferAddress;
379 unsigned int spareBufferAddress;
381
382typedef struct
383{
384 unsigned int cmdSelect;
385 unsigned int waySelect;
386 unsigned int rowAddress;
387 struct
388 {
389 unsigned int pageBufferIndex : 16;
390 unsigned int spareBufferIndex : 16;
391 } Subpages[4];
394
395typedef struct
396{
397 unsigned int cmdSelect;
398 unsigned int waySelect;
399 unsigned int rowAddress;
400 struct
401 {
402 unsigned int pageBufferIndex : 16;
403 unsigned int spareBufferIndex : 16;
404 } Subpages[4];
406
407typedef struct
408{
409 unsigned int cmdSelect;
410 unsigned int waySelect;
411 unsigned int colAddress;
412 unsigned int length;
413 unsigned int reportAddress;
416
417typedef struct
418{
419 unsigned int crcSuccess : 1;
420 unsigned int spareSuccess : 1;
421 unsigned int pageSuccess : 32;
422 unsigned int totalErrorCount : 8;
423 unsigned int worstErrorCount : 5;
424 unsigned int chunk0ErrorCount : 5;
425 unsigned int chunk1ErrorCount : 5;
426 unsigned int chunk2ErrorCount : 5;
427 unsigned int chunk3ErrorCount : 5;
428 unsigned int chunk4ErrorCount : 5;
429 unsigned int chunk5ErrorCount : 5;
430 unsigned int chunk6ErrorCount : 5;
431 unsigned int chunk7ErrorCount : 5;
433
434void nfc_set_dqs_delay(int channel, unsigned int newValue);
435void nfc_set_dq_delay(int channel, unsigned int newValue);
436void V2FInitializeHandle(T4REGS *t4regs, void *t4nscRegisterBaseAddress);
437void V2FResetSync(T4REGS *t4regs, int way);
438void V2FSetFeaturesSync(T4REGS *t4regs, int way, unsigned int feature0x02, unsigned int feature0x10,
439 unsigned int feature0x01, unsigned int payLoadAddr);
440void V2FReadPageTriggerAsync(T4REGS *t4regs, int way, unsigned int rowAddress);
441void V2FReadPageTransferAsync(T4REGS *t4regs, int way, void *pageDataBuffer, void *spareDataBuffer,
442 unsigned int *errorInformation, unsigned int *completion, unsigned int rowAddress);
443void V2FReadPageTransferRawAsync(T4REGS *t4regs, int way, void *pageDataBuffer, unsigned int *completion);
444void V2FProgramPageAsync(T4REGS *t4regs, int way, unsigned int rowAddress, void *pageDataBuffer,
445 void *spareDataBuffer);
446void V2FEraseBlockAsync(T4REGS *t4regs, int way, unsigned int rowAddress);
447void V2FStatusCheckAsync(T4REGS *t4regs, int way, unsigned int *statusReport);
448void V2FReadIdAsync(T4REGS *t4regs, int way, unsigned int *statusReport, unsigned int *completion);
449void V2FReadIdSync(T4REGS *t4regs, int way, unsigned int *statusReport);
450unsigned int V2FReadyBusyAsync(T4REGS *t4regs);
451
452#endif /* FMC_DRIVER_H_ */
void V2FReadPageTransferAsync(T4REGS *t4regs, int way, void *pageDataBuffer, void *spareDataBuffer, unsigned int *errorInformation, unsigned int *completion, unsigned int rowAddress)
void V2FReadPageTransferRawAsync(T4REGS *t4regs, int way, void *pageDataBuffer, unsigned int *completion)
void V2FReadPageTriggerAsync(T4REGS *t4regs, int way, unsigned int rowAddress)
void V2FStatusCheckAsync(T4REGS *t4regs, int way, unsigned int *statusReport)
void V2FEraseBlockAsync(T4REGS *t4regs, int way, unsigned int rowAddress)
void V2FInitializeHandle(T4REGS *t4regs, void *t4nscRegisterBaseAddress)
Definition: nsc_driver.c:100
void V2FSetFeaturesSync(T4REGS *t4regs, int way, unsigned int feature0x02, unsigned int feature0x10, unsigned int feature0x01, unsigned int payLoadAddr)
void V2FProgramPageAsync(T4REGS *t4regs, int way, unsigned int rowAddress, void *pageDataBuffer, void *spareDataBuffer)
void V2FReadIdAsync(T4REGS *t4regs, int way, unsigned int *statusReport, unsigned int *completion)
Definition: nsc_driver.c:316
void nfc_set_dq_delay(int channel, unsigned int newValue)
Definition: nsc_driver.c:78
void nfc_set_dqs_delay(int channel, unsigned int newValue)
Definition: nsc_driver.c:59
unsigned int V2FReadyBusyAsync(T4REGS *t4regs)
void V2FReadIdSync(T4REGS *t4regs, int way, unsigned int *statusReport)
Definition: nsc_driver.c:333
void V2FResetSync(T4REGS *t4regs, int way)
unsigned int crcSuccess
Definition: nsc_driver.h:419
unsigned int chunk7ErrorCount
Definition: nsc_driver.h:431
unsigned int chunk2ErrorCount
Definition: nsc_driver.h:426
unsigned int chunk0ErrorCount
Definition: nsc_driver.h:424
unsigned int chunk1ErrorCount
Definition: nsc_driver.h:425
unsigned int pageSuccess
Definition: nsc_driver.h:421
unsigned int chunk6ErrorCount
Definition: nsc_driver.h:430
unsigned int chunk5ErrorCount
Definition: nsc_driver.h:429
unsigned int chunk4ErrorCount
Definition: nsc_driver.h:428
unsigned int spareSuccess
Definition: nsc_driver.h:420
unsigned int totalErrorCount
Definition: nsc_driver.h:422
unsigned int chunk3ErrorCount
Definition: nsc_driver.h:427
unsigned int worstErrorCount
Definition: nsc_driver.h:423
volatile T4REG_CC * t4regCC
Definition: nsc_driver.h:175
volatile T4REG_BP * t4regBP
Definition: nsc_driver.h:177
volatile T4REG_ID * t4regID
Definition: nsc_driver.h:169
volatile T4REG_EXT * t4regEXT
Definition: nsc_driver.h:173
volatile T4REG_CFG * t4regCFG
Definition: nsc_driver.h:171
volatile T4REG_SP * t4regSP
Definition: nsc_driver.h:179
unsigned int nandReadyBusy
Definition: nsc_driver.h:156
unsigned int issueCmd
Definition: nsc_driver.h:151
unsigned int reserved
Definition: nsc_driver.h:141
unsigned int cmdSelect
Definition: nsc_driver.h:252
unsigned int rowAddress
Definition: nsc_driver.h:254
unsigned int waySelect
Definition: nsc_driver.h:253
unsigned int rowAddress
Definition: nsc_driver.h:322
unsigned int option
Definition: nsc_driver.h:323
unsigned int cmdSelect
Definition: nsc_driver.h:320
unsigned int waySelect
Definition: nsc_driver.h:321
unsigned int pageDataAddress
Definition: nsc_driver.h:326
unsigned int spareDataAddress
Definition: nsc_driver.h:327
unsigned int reportAddress
Definition: nsc_driver.h:216
unsigned int waySelect
Definition: nsc_driver.h:215
unsigned int completionAddress
Definition: nsc_driver.h:218
unsigned int cmdSelect
Definition: nsc_driver.h:214
unsigned int getFeaturesAddress
Definition: nsc_driver.h:217
unsigned int completionAddress
Definition: nsc_driver.h:234
unsigned int reportAddress
Definition: nsc_driver.h:232
unsigned int getFeaturesAddress
Definition: nsc_driver.h:233
unsigned int reportAddress
Definition: nsc_driver.h:225
unsigned int cmdSelect
Definition: nsc_driver.h:223
unsigned int reserved
Definition: nsc_driver.h:224
unsigned int cmdSelect
Definition: nsc_driver.h:190
unsigned int payloadAddress
Definition: nsc_driver.h:192
unsigned int waySelect
Definition: nsc_driver.h:191
unsigned int cmdSelect
Definition: nsc_driver.h:184
unsigned int waySelect
Definition: nsc_driver.h:185
unsigned int length
Definition: nsc_driver.h:412
unsigned int completionReportAddress
Definition: nsc_driver.h:414
unsigned int waySelect
Definition: nsc_driver.h:410
unsigned int reportAddress
Definition: nsc_driver.h:413
unsigned int cmdSelect
Definition: nsc_driver.h:409
unsigned int colAddress
Definition: nsc_driver.h:411
unsigned int completionReportAddress
Definition: nsc_driver.h:303
unsigned int waySelect
Definition: nsc_driver.h:246
unsigned int reportAddress
Definition: nsc_driver.h:247
unsigned int cmdSelect
Definition: nsc_driver.h:245
unsigned int setFeaturesAddress
Definition: nsc_driver.h:200
unsigned int waySelect
Definition: nsc_driver.h:198
unsigned int cmdSelect
Definition: nsc_driver.h:197
unsigned int payloadAddress
Definition: nsc_driver.h:199
unsigned int setFeaturesAddress
Definition: nsc_driver.h:208
unsigned int payloadAddress
Definition: nsc_driver.h:207
unsigned int cmdSelect
Definition: nsc_driver.h:240
T4EXT_PM perfMonitor
Definition: nsc_driver.h:146
unsigned int queueNotFull
Definition: nsc_driver.h:134
unsigned int version
Definition: nsc_driver.h:135
unsigned int queueCount
Definition: nsc_driver.h:136
unsigned int cmdSelect
Definition: nsc_driver.h:161
unsigned int waySelect
Definition: nsc_driver.h:162
unsigned int cmdSelect
Definition: nsc_driver.h:120
unsigned int channelBusy
Definition: nsc_driver.h:128
unsigned int spareAddress
Definition: nsc_driver.h:124
unsigned int completionAddress
Definition: nsc_driver.h:126
unsigned int readyBusy
Definition: nsc_driver.h:129
unsigned int dataAddress
Definition: nsc_driver.h:123
unsigned int errorCountAddress
Definition: nsc_driver.h:125
unsigned int userData
Definition: nsc_driver.h:122
unsigned int rowAddress
Definition: nsc_driver.h:121
unsigned int waySelection
Definition: nsc_driver.h:127