3d873450729ddbe333cd5a99ec0e8b16b06e28e4
9 static void dfii_setcontrol(const struct gramCtx
*ctx
, uint32_t val
) {
11 gram_write(ctx
, (void*)&(ctx
->core
->control
), val
);
13 writel(val
, (unsigned long)&(ctx
->core
->control
));
17 void dfii_reset(const struct gramCtx
*ctx
) {
18 dfii_set_p0_address(ctx
, 0);
19 dfii_set_p0_baddress(ctx
, 0);
20 dfii_setcontrol(ctx
, DFII_CONTROL_ODT
|DFII_CONTROL_RESET
);
23 void dfii_setsw(const struct gramCtx
*ctx
, bool software_control
) {
24 if (software_control
) {
25 dfii_setcontrol(ctx
, DFII_CONTROL_CKE
|DFII_CONTROL_ODT
|
28 dfii_setcontrol(ctx
, DFII_CONTROL_SEL
);
32 void dfii_set_p0_address(const struct gramCtx
*ctx
, uint32_t val
) {
34 gram_write(ctx
, (void*)&(ctx
->core
->phases
[0].address
), val
);
36 writel(val
, (unsigned long)&(ctx
->core
->phases
[0].address
));
40 void dfii_set_p0_baddress(const struct gramCtx
*ctx
, uint32_t val
) {
42 gram_write(ctx
, (void*)&(ctx
->core
->phases
[0].baddress
), val
);
44 writel(val
, (unsigned long)&(ctx
->core
->phases
[0].baddress
));
48 void dfii_p0_command(const struct gramCtx
*ctx
, uint32_t cmd
) {
50 gram_write(ctx
, (void*)&(ctx
->core
->phases
[0].command
), cmd
);
51 gram_write(ctx
, (void*)&(ctx
->core
->phases
[0].command_issue
), 1);
53 writel(cmd
, (unsigned long)&(ctx
->core
->phases
[0].command
));
54 writel(1, (unsigned long)&(ctx
->core
->phases
[0].command_issue
));
58 /* Set MRx register */
59 static void dfii_set_mr(const struct gramCtx
*ctx
, uint8_t mr
, uint16_t val
) {
60 dfii_set_p0_address(ctx
, val
);
61 dfii_set_p0_baddress(ctx
, mr
);
62 dfii_p0_command(ctx
, DFII_COMMAND_RAS
|DFII_COMMAND_CAS
|DFII_COMMAND_WE
|DFII_COMMAND_CS
);
65 //comment these in to speed up icarus verilog simulations dramatically
66 //#define LONG_TIMER_MULT 1
67 //#define SHORT_TIMER_MULT 1
69 #define MR0_DLL_RESET (1 << 8)
70 void dfii_initseq(const struct gramCtx
*ctx
, const struct gramProfile
*profile
) {
72 dfii_set_p0_address(ctx
, 0x0);
73 dfii_set_p0_baddress(ctx
, 0);
74 dfii_setcontrol(ctx
, DFII_CONTROL_ODT
|DFII_CONTROL_RESET
);
75 //cdelay(5*LONG_TIMER_MULT);
78 //dfii_set_p0_address(ctx, 0x0);
79 //dfii_set_p0_baddress(ctx, 0);
80 dfii_setcontrol(ctx
, DFII_CONTROL_CKE
|DFII_CONTROL_ODT
|DFII_CONTROL_RESET
);
81 cdelay(1*LONG_TIMER_MULT
);
83 /* Load Mode Register 2, CWL=5 */
84 dfii_set_mr(ctx
, 2, profile
->mode_registers
[2]);
86 /* Load Mode Register 3 */
87 dfii_set_mr(ctx
, 3, profile
->mode_registers
[3]);
89 /* Load Mode Register 1 */
90 dfii_set_mr(ctx
, 1, profile
->mode_registers
[1]);
92 /* Load Mode Register 0, CL=6, BL=8 */
93 dfii_set_mr(ctx
, 0, profile
->mode_registers
[0]);
94 if (profile
->mode_registers
[0] & MR0_DLL_RESET
) {
95 cdelay(1*SHORT_TIMER_MULT
);
96 dfii_set_mr(ctx
, 0, profile
->mode_registers
[0] & ~MR0_DLL_RESET
);
98 cdelay(6*SHORT_TIMER_MULT
);
101 dfii_set_p0_address(ctx
, 0x400);
102 dfii_set_p0_baddress(ctx
, 0);
103 dfii_p0_command(ctx
, DFII_COMMAND_WE
|DFII_COMMAND_CS
);
104 cdelay(6*SHORT_TIMER_MULT
);