1
2
3
4
5
6
7
8
9
10
11
12#include <common.h>
13#include <asm/io.h>
14#include <asm/arch/at91_common.h>
15#include <asm/arch/at91sam9_sdramc.h>
16#include <asm/arch/gpio.h>
17
18int sdramc_initialize(unsigned int sdram_address, const struct sdramc_reg *p)
19{
20 struct sdramc_reg *reg = (struct sdramc_reg *)ATMEL_BASE_SDRAMC;
21 unsigned int i;
22
23
24 writel(p->cr, ®->cr);
25
26
27 writel(p->mdr, ®->mdr);
28
29
30
31
32
33 for (i = 0; i < 1000; i++)
34 ;
35
36
37 writel(AT91_SDRAMC_MODE_NOP, ®->mr);
38 writel(0x00000000, sdram_address);
39
40
41 writel(AT91_SDRAMC_MODE_PRECHARGE, ®->mr);
42 writel(0x00000000, sdram_address);
43
44 for (i = 0; i < 10000; i++)
45 ;
46
47
48 for (i = 0; i < 8; i++) {
49 writel(AT91_SDRAMC_MODE_REFRESH, ®->mr);
50 writel(0x00000001 + i, sdram_address + 4 + 4 * i);
51 }
52
53
54
55
56
57 writel(AT91_SDRAMC_MODE_LMR, ®->mr);
58 writel(0xcafedede, sdram_address + 0x24);
59
60
61
62
63
64
65 writel(AT91_SDRAMC_MODE_NORMAL, ®->mr);
66 writel(0x00000000, sdram_address);
67
68
69
70
71
72 writel(p->tr, ®->tr);
73
74 return 0;
75}
76