#include #ifdef DFII_BASE #include #include #include #include #include #include "sdram.h" static void cdelay(int i) { while(i > 0) { #if defined (__lm32__) __asm__ volatile("nop"); #elif defined (__or1k__) __asm__ volatile("l.nop"); #else #error Unsupported architecture #endif i--; } } void sdrsw(void) { dfii_control_write(DFII_CONTROL_CKE|DFII_CONTROL_ODT|DFII_CONTROL_RESET_N); printf("SDRAM now under software control\n"); } void sdrhw(void) { dfii_control_write(DFII_CONTROL_SEL); printf("SDRAM now under hardware control\n"); } void sdrrow(char *_row) { char *c; unsigned int row; if(*_row == 0) { dfii_pi0_address_write(0x0000); dfii_pi0_baddress_write(0); 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; } dfii_pi0_address_write(row); dfii_pi0_baddress_write(0); command_p0(DFII_COMMAND_RAS|DFII_COMMAND_CS); cdelay(15); printf("Activated row %d\n", row); } } void sdrrd(char *startaddr) { char *c; unsigned int addr; int i; int p; if(*startaddr == 0) { printf("sdrrd
\n"); return; } addr = strtoul(startaddr, &c, 0); if(*c != 0) { printf("incorrect address\n"); return; } dfii_pird_address_write(addr); dfii_pird_baddress_write(0); command_prd(DFII_COMMAND_CAS|DFII_COMMAND_CS|DFII_COMMAND_RDDATA); cdelay(15); for(p=0;p\n"); return; } addr = strtoul(startaddr, &c, 0); if(*c != 0) { printf("incorrect address\n"); return; } for(p=0;p