bios: more DDR diagnostic functions
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 14 May 2012 18:07:57 +0000 (20:07 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 14 May 2012 18:07:57 +0000 (20:07 +0200)
software/bios/ddrinit.c
software/bios/ddrinit.h
software/bios/main.c

index 563221a117c3880eec0cb2529890272bf32111d5..c4f4173f4affda0add089b421f945df1edf1f63c 100644 (file)
@@ -81,6 +81,43 @@ static void init_sequence(void)
        cdelay(200);
 }
 
+void ddrsw(void)
+{
+       CSR_DFII_CONTROL = DFII_CONTROL_CKE;
+       printf("DDR now under software control\n");
+}
+
+void ddrhw(void)
+{
+       CSR_DFII_CONTROL = DFII_CONTROL_SEL|DFII_CONTROL_CKE;
+       printf("DDR now under hardware control\n");
+}
+
+void ddrrow(char *_row)
+{
+       char *c;
+       unsigned int row;
+       
+       if(*_row == 0) {
+               setaddr(0x0000);
+               CSR_DFII_BA_P0 = 0;
+               CSR_DFII_COMMAND_P0 = DFII_COMMAND_RAS|DFII_COMMAND_WE|DFII_COMMAND_CS;
+               cdelay(15);
+               printf("Precharged\n");
+       } else {
+               row = strtoul(_row, &c, 0);
+               if(*c != 0) {
+                       printf("incorrect row\n");
+                       return;
+               }
+               setaddr(row);
+               CSR_DFII_BA_P0 = 0;
+               CSR_DFII_COMMAND_P0 = DFII_COMMAND_RAS|DFII_COMMAND_CS;
+               cdelay(15);
+               printf("Activated row %d\n", row);
+       }
+}
+
 void ddrrd(char *startaddr)
 {
        char *c;
@@ -141,10 +178,5 @@ int ddrinit(void)
        
        init_sequence();
        
-       setaddr(0x0000);
-       CSR_DFII_BA_P0 = 0;
-       CSR_DFII_COMMAND_P0 = DFII_COMMAND_RAS|DFII_COMMAND_CS;
-       cdelay(15);
-       
        return 1;
 }
index 2c2a6771a5dc0db233657e6009a47ec2641524fb..cabffd345e4553cd9272b6b31360e51a0409d543 100644 (file)
@@ -19,6 +19,9 @@
 #define __DDRINIT_H
 
 int ddrinit(void);
+void ddrsw(void);
+void ddrhw(void);
+void ddrrow(char *_row);
 void ddrrd(char *startaddr);
 void ddrwr(char *startaddr);
 
index bc3c8cd6fc70caf06508e05377c3bfbce8c5041c..5a72cf16a849a9ab6f49d01f38796347b579197e 100644 (file)
@@ -353,6 +353,9 @@ static void do_command(char *c)
        else if(strcmp(token, "wcsr") == 0) wcsr(get_token(&c), get_token(&c));
        
        else if(strcmp(token, "ddrinit") == 0) ddrinit();
+       else if(strcmp(token, "ddrrow") == 0) ddrrow(get_token(&c));
+       else if(strcmp(token, "ddrsw") == 0) ddrsw();
+       else if(strcmp(token, "ddrhw") == 0) ddrhw();
        else if(strcmp(token, "ddrrd") == 0) ddrrd(get_token(&c));
        else if(strcmp(token, "ddrwr") == 0) ddrwr(get_token(&c));