OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [tools/] [ddr_init.c] - Blame information for rev 268

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 268 rhoads
/*--------------------------------------------------------------------
2
 * TITLE: Plasma DDR Initialization
3
 * AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
 * DATE CREATED: 12/17/05
5
 * FILENAME: ddr_init.c
6
 * PROJECT: Plasma CPU core
7
 * COPYRIGHT: Software placed into the public domain by the author.
8
 *    Software 'as is' without warranty.  Author liable for nothing.
9
 * DESCRIPTION:
10
 *    Plasma DDR Initialization
11
 *--------------------------------------------------------------------*/
12
#define DDR_BASE 0x10000000
13
#define MemoryRead(A) (*(volatile int*)(A))
14
#define MemoryWrite(A,V) *(volatile int*)(A)=(V)
15
 
16
extern void putchar(int value);
17
extern int puts(const char *string);
18
extern void print_hex(unsigned long num);
19
 
20
//SD_A  <= address_reg(25 downto 13);  --address row
21
//SD_BA <= address_reg(12 downto 11);  --bank_address
22
//cmd   := address_reg(6 downto 4);    --bits RAS & CAS & WE
23
int DdrInitData[] = {
24
// AddressLines    Bank        Command
25
   (0x000 << 13) | (0 << 11) | (7 << 4),  //CKE=1; NOP="111"
26
   (0x400 << 13) | (0 << 11) | (2 << 4),  //A10=1; PRECHARGE ALL="010"
27
#ifndef DLL_DISABLE
28
   (0x000 << 13) | (1 << 11) | (0 << 4),  //enable DLL; BA="01"; LMR="000"
29
#else
30
   (0x001 << 13) | (1 << 11) | (0 << 4),  //disable DLL; BA="01"; LMR="000"
31
#endif
32
   (0x121 << 13) | (0 << 11) | (0 << 4),  //reset DLL, CL=2, BL=2; LMR="000"
33
   (0x400 << 13) | (0 << 11) | (2 << 4),  //A10=1; PRECHARGE ALL="010" 
34
   (0x000 << 13) | (0 << 11) | (1 << 4),  //AUTO REFRESH="001"
35
   (0x000 << 13) | (0 << 11) | (1 << 4),  //AUTO REFRESH="001
36
   (0x021 << 13) | (0 << 11) | (0 << 4)   //clear DLL, CL=2, BL=2; LMR="000"
37
};
38
 
39
int DdrInit(void)
40
{
41
   int i, j, k=0;
42
   for(i = 0; i < sizeof(DdrInitData)/sizeof(int); ++i)
43
   {
44
      MemoryWrite(DDR_BASE + DdrInitData[i], 0);
45
      for(j = 0; j < 4; ++j)
46
         ++k;
47
   }
48
   for(j = 0; j < 100; ++j)
49
      ++k;
50
   k += MemoryRead(DDR_BASE);  //Enable DDR
51
   return k;
52
}
53
 
54
#ifdef DDR_TEST_MAIN
55
int main()
56
{
57
   volatile int *ptr = (int*)DDR_BASE;
58
   int i;
59
 
60
   DdrInit();
61
 
62
   ptr[0] = 0x12345678;
63
   if(ptr[0] != 0x12345678)
64
      putchar('X');
65
   for(i = 0; i < 10; ++i)
66
   {
67
      ptr[i] = i;
68
   }
69
 
70
   for(i = 0; i < 10; ++i)
71
   {
72
      if(ptr[i] != i)
73
         putchar('A' + i);
74
   }
75
   *(unsigned char*)DDR_BASE = 0x23;
76
   *(unsigned char*)(DDR_BASE+1) = 0x45;
77
   *(unsigned char*)(DDR_BASE+2) = 0x67;
78
   *(unsigned char*)(DDR_BASE+3) = 0x89;
79
   if(ptr[0] != 0x23456789)
80
      putchar('Y');
81
   puts("\r\ndone\r\n");
82
   return 0;
83
}
84
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.