This source file includes following definitions.
- omap2_sms_save_context
- omap2_sms_restore_context
- omap2_sdrc_get_params
- omap2_set_globals_sdrc
- omap2_sdrc_init
1
2
3
4
5
6
7
8
9
10
11
12 #undef DEBUG
13
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/device.h>
17 #include <linux/list.h>
18 #include <linux/errno.h>
19 #include <linux/delay.h>
20 #include <linux/clk.h>
21 #include <linux/io.h>
22
23 #include "common.h"
24 #include "clock.h"
25 #include "sdrc.h"
26
27 static struct omap_sdrc_params *sdrc_init_params_cs0, *sdrc_init_params_cs1;
28
29 void __iomem *omap2_sdrc_base;
30 void __iomem *omap2_sms_base;
31
32 struct omap2_sms_regs {
33 u32 sms_sysconfig;
34 };
35
36 static struct omap2_sms_regs sms_context;
37
38
39 #define SDRC_POWER_EXTCLKDIS_SHIFT 3
40 #define SDRC_POWER_PWDENA_SHIFT 2
41 #define SDRC_POWER_PAGEPOLICY_SHIFT 0
42
43
44
45
46
47
48 void omap2_sms_save_context(void)
49 {
50 sms_context.sms_sysconfig = sms_read_reg(SMS_SYSCONFIG);
51 }
52
53
54
55
56
57
58 void omap2_sms_restore_context(void)
59 {
60 sms_write_reg(sms_context.sms_sysconfig, SMS_SYSCONFIG);
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 int omap2_sdrc_get_params(unsigned long r,
86 struct omap_sdrc_params **sdrc_cs0,
87 struct omap_sdrc_params **sdrc_cs1)
88 {
89 struct omap_sdrc_params *sp0, *sp1;
90
91 if (!sdrc_init_params_cs0)
92 return -1;
93
94 sp0 = sdrc_init_params_cs0;
95 sp1 = sdrc_init_params_cs1;
96
97 while (sp0->rate && sp0->rate != r) {
98 sp0++;
99 if (sdrc_init_params_cs1)
100 sp1++;
101 }
102
103 if (!sp0->rate)
104 return -1;
105
106 *sdrc_cs0 = sp0;
107 *sdrc_cs1 = sp1;
108 return 0;
109 }
110
111
112 void __init omap2_set_globals_sdrc(void __iomem *sdrc, void __iomem *sms)
113 {
114 omap2_sdrc_base = sdrc;
115 omap2_sms_base = sms;
116 }
117
118
119
120
121
122
123
124
125
126
127 void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
128 struct omap_sdrc_params *sdrc_cs1)
129 {
130 u32 l;
131
132 l = sms_read_reg(SMS_SYSCONFIG);
133 l &= ~(0x3 << 3);
134 l |= (0x2 << 3);
135 sms_write_reg(l, SMS_SYSCONFIG);
136
137 l = sdrc_read_reg(SDRC_SYSCONFIG);
138 l &= ~(0x3 << 3);
139 l |= (0x2 << 3);
140 sdrc_write_reg(l, SDRC_SYSCONFIG);
141
142 sdrc_init_params_cs0 = sdrc_cs0;
143 sdrc_init_params_cs1 = sdrc_cs1;
144
145
146
147
148
149
150 l = (1 << SDRC_POWER_EXTCLKDIS_SHIFT) |
151 (1 << SDRC_POWER_PAGEPOLICY_SHIFT);
152 sdrc_write_reg(l, SDRC_POWER);
153 omap2_sms_save_context();
154 }