OpenSSD Cosmos+ Platform Firmware  0.0.2
The firmware of Cosmos+ OpenSSD Platform for TOSHIBA nand flash module.
nsc_driver.c File Reference
#include "nsc_driver.h"
#include "xparameters.h"
#include <assert.h>
Include dependency graph for nsc_driver.c:

Go to the source code of this file.

Data Structures

struct  iodelay_if
 

Functions

void nfc_set_dqs_delay (int channel, unsigned int newValue)
 
void nfc_set_dq_delay (int channel, unsigned int newValue)
 
void V2FInitializeHandle (T4REGS *t4regs, void *t4nscRegisterBaseAddress)
 
void __attribute__ ((optimize("O0")))
 
void V2FGetReadyBusy (T4REGS *t4regs, unsigned int *report)
 
void V2FReadIdAsync (T4REGS *t4regs, int way, unsigned int *statusReport, unsigned int *completion)
 
void V2FReadIdSync (T4REGS *t4regs, int way, unsigned int *statusReport)
 

Function Documentation

◆ __attribute__()

unsigned int __attribute__ ( (optimize("O0"))  )

payload = feature0x01; while (V2FIsControllerBusy(t4regs)); V2FSetFeaturesT(t4regs, way, 0x01, payload); do { while (V2FIsControllerBusy(t4regs)); V2FGetReadyBusy(t4regs, status); while (!(*status & 1)); status >>= 16; } while (!(*status & (1 << way)));

Definition at line 110 of file nsc_driver.c.

111{
112 T4REG_CMD_SET_SCRAMBLER setScramblerCmd;
113
115
116 V2FFillRegisters(t4regs, T4REG_CMD_SET_SCRAMBLER, setScramblerCmd);
117 V2FIssueCommand(t4regs);
118}
#define V2FIssueCommand(t4regs)
Definition: nsc_driver.h:98
#define T4NSC_CMD_SET_SCRAMBLER_ENABLE
Definition: nsc_driver.h:71
#define T4NSC_CMD_SET_SCRAMBLER_DISABLE
Definition: nsc_driver.h:70
#define V2FFillRegisters(t4regs, cmdtype, cmdpayload)
Definition: nsc_driver.h:97
unsigned int cmdSelect
Definition: nsc_driver.h:240

◆ nfc_set_dq_delay()

void nfc_set_dq_delay ( int  channel,
unsigned int  newValue 
)

Definition at line 78 of file nsc_driver.c.

79{
80 volatile unsigned int *ctrl0 = (volatile unsigned int *)XPAR_IODELAY_IF_0_BASEADDR;
81 volatile iodelay_if *data0 = (volatile iodelay_if *)(XPAR_IODELAY_IF_0_BASEADDR + 0x8000);
82 volatile unsigned int *ctrl1 = (volatile unsigned int *)XPAR_IODELAY_IF_0_BASEADDR;
83 volatile iodelay_if *data1 = (volatile iodelay_if *)(XPAR_IODELAY_IF_0_BASEADDR + 0x8000);
84
85 int i;
86 if (channel < 4)
87 {
88 for (i = 0; i < 8; i++)
89 data0->delayVal[channel * 8 + i] = newValue;
90 ctrl0[1] = 1;
91 }
92 else
93 {
94 for (i = 0; i < 8; i++)
95 data1->delayVal[(channel % 4) * 8 + i] = newValue;
96 ctrl1[1] = 1;
97 }
98}
#define XPAR_IODELAY_IF_0_BASEADDR
Definition: bsp.h:12
unsigned char delayVal[32]
Definition: nsc_driver.c:56

◆ nfc_set_dqs_delay()

void nfc_set_dqs_delay ( int  channel,
unsigned int  newValue 
)

Definition at line 59 of file nsc_driver.c.

60{
61 volatile unsigned int *ctrl0 = (volatile unsigned int *)XPAR_IODELAY_IF_0_DQS_BASEADDR;
62 volatile iodelay_if *data0 = (volatile iodelay_if *)(XPAR_IODELAY_IF_0_DQS_BASEADDR + 0x8000);
63 volatile unsigned int *ctrl1 = (volatile unsigned int *)XPAR_IODELAY_IF_1_DQS_BASEADDR;
64 volatile iodelay_if *data1 = (volatile iodelay_if *)(XPAR_IODELAY_IF_1_DQS_BASEADDR + 0x8000);
65
66 if (channel < 4)
67 {
68 data0->delayVal[channel] = newValue;
69 ctrl0[1] = 1;
70 }
71 else
72 {
73 data1->delayVal[channel % 4] = newValue;
74 ctrl1[1] = 1;
75 }
76}
#define XPAR_IODELAY_IF_0_DQS_BASEADDR
Definition: bsp.h:14
#define XPAR_IODELAY_IF_1_DQS_BASEADDR
Definition: bsp.h:15

◆ V2FGetReadyBusy()

void V2FGetReadyBusy ( T4REGS t4regs,
unsigned int *  report 
)

Definition at line 151 of file nsc_driver.c.

152{
153 T4REG_CMD_GET_READYBUSY getReadyBusyCmd;
154
155 getReadyBusyCmd.cmdSelect = T4NSC_CMD_GET_READYBUSY;
156 getReadyBusyCmd.reserved = 0;
157 getReadyBusyCmd.reportAddress = (unsigned int)report;
158
159 V2FFillRegisters(t4regs, T4REG_CMD_GET_READYBUSY, getReadyBusyCmd);
160 V2FIssueCommand(t4regs);
161}
#define T4NSC_CMD_GET_READYBUSY
Definition: nsc_driver.h:64
unsigned int reportAddress
Definition: nsc_driver.h:225
unsigned int cmdSelect
Definition: nsc_driver.h:223
unsigned int reserved
Definition: nsc_driver.h:224

◆ V2FInitializeHandle()

void V2FInitializeHandle ( T4REGS t4regs,
void *  t4nscRegisterBaseAddress 
)

Definition at line 100 of file nsc_driver.c.

101{
102 t4regs->t4regID = (T4REG_ID *)((unsigned int)t4nscRegisterBaseAddress + 0);
103 t4regs->t4regCFG = (T4REG_CFG *)((unsigned int)t4nscRegisterBaseAddress + 0x1000);
104 t4regs->t4regEXT = (T4REG_EXT *)((unsigned int)t4nscRegisterBaseAddress + 0x2000);
105 t4regs->t4regCC = (T4REG_CC *)((unsigned int)t4nscRegisterBaseAddress + 0x3000);
106 t4regs->t4regBP = (T4REG_BP *)((unsigned int)t4nscRegisterBaseAddress + 0x3800);
107 t4regs->t4regSP = (T4REG_SP *)((unsigned int)t4nscRegisterBaseAddress + 0x4000);
108}
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

◆ V2FReadIdAsync()

void V2FReadIdAsync ( T4REGS t4regs,
int  way,
unsigned int *  statusReport,
unsigned int *  completion 
)

Definition at line 316 of file nsc_driver.c.

317{
318 T4REG_CMD_READ_ID readIdCmd;
319
320 readIdCmd.cmdSelect = T4NSC_CMD_READ_ID;
321 readIdCmd.waySelect = 1 << way;
322 readIdCmd.colAddress = 0x0090;
323 readIdCmd.length = 3;
324 readIdCmd.reportAddress = (unsigned int)statusReport;
325 readIdCmd.completionReportAddress = (unsigned int)completion;
326
327 while (V2FIsControllerBusy(t4regs))
328 ;
329 V2FFillRegisters(t4regs, T4REG_CMD_READ_ID, readIdCmd);
330 V2FIssueCommand(t4regs);
331}
#define V2FIsControllerBusy(t4regs)
Definition: nsc_driver.h:100
#define T4NSC_CMD_READ_ID
Definition: nsc_driver.h:87
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
Here is the caller graph for this function:

◆ V2FReadIdSync()

void V2FReadIdSync ( T4REGS t4regs,
int  way,
unsigned int *  statusReport 
)

Definition at line 333 of file nsc_driver.c.

334{
335 unsigned char buf[8] = {0};
336 int i;
337 for (i = 0; i < 8; i++)
338 ((unsigned char *)statusReport)[i] = 0;
339 unsigned int *completion = &statusReport[4];
340 *completion = 0;
341 V2FReadIdAsync(t4regs, way, statusReport, completion);
342 while (*completion == 0)
343 ;
344
345 for (i = 0; i < 6; i++)
346 buf[i] = ((unsigned char *)statusReport)[i * 2];
347 for (i = 0; i < 8; i++)
348 ((unsigned char *)statusReport)[i] = buf[i];
349}
void V2FReadIdAsync(T4REGS *t4regs, int way, unsigned int *statusReport, unsigned int *completion)
Definition: nsc_driver.c:316
Here is the call graph for this function:
Here is the caller graph for this function: