root / hw / omap.c @ b94ec3ec
History | View | Annotate | Download (158.6 kB)
1 | c3d2689d | balrog | /*
|
---|---|---|---|
2 | c3d2689d | balrog | * TI OMAP processors emulation.
|
3 | c3d2689d | balrog | *
|
4 | c3d2689d | balrog | * Copyright (C) 2006-2007 Andrzej Zaborowski <balrog@zabor.org>
|
5 | c3d2689d | balrog | *
|
6 | c3d2689d | balrog | * This program is free software; you can redistribute it and/or
|
7 | c3d2689d | balrog | * modify it under the terms of the GNU General Public License as
|
8 | c3d2689d | balrog | * published by the Free Software Foundation; either version 2 of
|
9 | c3d2689d | balrog | * the License, or (at your option) any later version.
|
10 | c3d2689d | balrog | *
|
11 | c3d2689d | balrog | * This program is distributed in the hope that it will be useful,
|
12 | c3d2689d | balrog | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | c3d2689d | balrog | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | c3d2689d | balrog | * GNU General Public License for more details.
|
15 | c3d2689d | balrog | *
|
16 | c3d2689d | balrog | * You should have received a copy of the GNU General Public License
|
17 | c3d2689d | balrog | * along with this program; if not, write to the Free Software
|
18 | c3d2689d | balrog | * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
19 | c3d2689d | balrog | * MA 02111-1307 USA
|
20 | c3d2689d | balrog | */
|
21 | 87ecb68b | pbrook | #include "hw.h" |
22 | 87ecb68b | pbrook | #include "arm-misc.h" |
23 | 87ecb68b | pbrook | #include "omap.h" |
24 | 87ecb68b | pbrook | #include "sysemu.h" |
25 | 87ecb68b | pbrook | #include "qemu-timer.h" |
26 | 87ecb68b | pbrook | /* We use pc-style serial ports. */
|
27 | 87ecb68b | pbrook | #include "pc.h" |
28 | c3d2689d | balrog | |
29 | c3d2689d | balrog | /* Should signal the TCMI */
|
30 | 66450b15 | balrog | uint32_t omap_badwidth_read8(void *opaque, target_phys_addr_t addr)
|
31 | 66450b15 | balrog | { |
32 | 02645926 | balrog | uint8_t ret; |
33 | 02645926 | balrog | |
34 | 66450b15 | balrog | OMAP_8B_REG(addr); |
35 | b854bc19 | balrog | cpu_physical_memory_read(addr, (void *) &ret, 1); |
36 | 02645926 | balrog | return ret;
|
37 | 66450b15 | balrog | } |
38 | 66450b15 | balrog | |
39 | 66450b15 | balrog | void omap_badwidth_write8(void *opaque, target_phys_addr_t addr, |
40 | 66450b15 | balrog | uint32_t value) |
41 | 66450b15 | balrog | { |
42 | b854bc19 | balrog | uint8_t val8 = value; |
43 | b854bc19 | balrog | |
44 | 66450b15 | balrog | OMAP_8B_REG(addr); |
45 | b854bc19 | balrog | cpu_physical_memory_write(addr, (void *) &val8, 1); |
46 | 66450b15 | balrog | } |
47 | 66450b15 | balrog | |
48 | b30bb3a2 | balrog | uint32_t omap_badwidth_read16(void *opaque, target_phys_addr_t addr)
|
49 | c3d2689d | balrog | { |
50 | b854bc19 | balrog | uint16_t ret; |
51 | b854bc19 | balrog | |
52 | c3d2689d | balrog | OMAP_16B_REG(addr); |
53 | b854bc19 | balrog | cpu_physical_memory_read(addr, (void *) &ret, 2); |
54 | b854bc19 | balrog | return ret;
|
55 | c3d2689d | balrog | } |
56 | c3d2689d | balrog | |
57 | b30bb3a2 | balrog | void omap_badwidth_write16(void *opaque, target_phys_addr_t addr, |
58 | c3d2689d | balrog | uint32_t value) |
59 | c3d2689d | balrog | { |
60 | b854bc19 | balrog | uint16_t val16 = value; |
61 | b854bc19 | balrog | |
62 | c3d2689d | balrog | OMAP_16B_REG(addr); |
63 | b854bc19 | balrog | cpu_physical_memory_write(addr, (void *) &val16, 2); |
64 | c3d2689d | balrog | } |
65 | c3d2689d | balrog | |
66 | b30bb3a2 | balrog | uint32_t omap_badwidth_read32(void *opaque, target_phys_addr_t addr)
|
67 | c3d2689d | balrog | { |
68 | b854bc19 | balrog | uint32_t ret; |
69 | b854bc19 | balrog | |
70 | c3d2689d | balrog | OMAP_32B_REG(addr); |
71 | b854bc19 | balrog | cpu_physical_memory_read(addr, (void *) &ret, 4); |
72 | b854bc19 | balrog | return ret;
|
73 | c3d2689d | balrog | } |
74 | c3d2689d | balrog | |
75 | b30bb3a2 | balrog | void omap_badwidth_write32(void *opaque, target_phys_addr_t addr, |
76 | c3d2689d | balrog | uint32_t value) |
77 | c3d2689d | balrog | { |
78 | c3d2689d | balrog | OMAP_32B_REG(addr); |
79 | b854bc19 | balrog | cpu_physical_memory_write(addr, (void *) &value, 4); |
80 | c3d2689d | balrog | } |
81 | c3d2689d | balrog | |
82 | c3d2689d | balrog | /* Interrupt Handlers */
|
83 | 106627d0 | balrog | struct omap_intr_handler_bank_s {
|
84 | c3d2689d | balrog | uint32_t irqs; |
85 | 106627d0 | balrog | uint32_t inputs; |
86 | c3d2689d | balrog | uint32_t mask; |
87 | c3d2689d | balrog | uint32_t fiq; |
88 | 106627d0 | balrog | uint32_t sens_edge; |
89 | 106627d0 | balrog | unsigned char priority[32]; |
90 | c3d2689d | balrog | }; |
91 | c3d2689d | balrog | |
92 | 106627d0 | balrog | struct omap_intr_handler_s {
|
93 | 106627d0 | balrog | qemu_irq *pins; |
94 | 106627d0 | balrog | qemu_irq parent_intr[2];
|
95 | 106627d0 | balrog | target_phys_addr_t base; |
96 | 106627d0 | balrog | unsigned char nbanks; |
97 | c3d2689d | balrog | |
98 | 106627d0 | balrog | /* state */
|
99 | 106627d0 | balrog | uint32_t new_agr[2];
|
100 | 106627d0 | balrog | int sir_intr[2]; |
101 | 106627d0 | balrog | struct omap_intr_handler_bank_s banks[];
|
102 | 106627d0 | balrog | }; |
103 | c3d2689d | balrog | |
104 | 106627d0 | balrog | static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq) |
105 | 106627d0 | balrog | { |
106 | 106627d0 | balrog | int i, j, sir_intr, p_intr, p, f;
|
107 | 106627d0 | balrog | uint32_t level; |
108 | 106627d0 | balrog | sir_intr = 0;
|
109 | 106627d0 | balrog | p_intr = 255;
|
110 | 106627d0 | balrog | |
111 | 106627d0 | balrog | /* Find the interrupt line with the highest dynamic priority.
|
112 | 106627d0 | balrog | * Note: 0 denotes the hightest priority.
|
113 | 106627d0 | balrog | * If all interrupts have the same priority, the default order is IRQ_N,
|
114 | 106627d0 | balrog | * IRQ_N-1,...,IRQ_0. */
|
115 | 106627d0 | balrog | for (j = 0; j < s->nbanks; ++j) { |
116 | 106627d0 | balrog | level = s->banks[j].irqs & ~s->banks[j].mask & |
117 | 106627d0 | balrog | (is_fiq ? s->banks[j].fiq : ~s->banks[j].fiq); |
118 | 106627d0 | balrog | for (f = ffs(level), i = f - 1, level >>= f - 1; f; i += f, |
119 | 106627d0 | balrog | level >>= f) { |
120 | 106627d0 | balrog | p = s->banks[j].priority[i]; |
121 | 106627d0 | balrog | if (p <= p_intr) {
|
122 | 106627d0 | balrog | p_intr = p; |
123 | 106627d0 | balrog | sir_intr = 32 * j + i;
|
124 | 106627d0 | balrog | } |
125 | 106627d0 | balrog | f = ffs(level >> 1);
|
126 | 106627d0 | balrog | } |
127 | cfa0b71d | balrog | } |
128 | 106627d0 | balrog | s->sir_intr[is_fiq] = sir_intr; |
129 | c3d2689d | balrog | } |
130 | c3d2689d | balrog | |
131 | 106627d0 | balrog | static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq) |
132 | c3d2689d | balrog | { |
133 | 106627d0 | balrog | int i;
|
134 | 106627d0 | balrog | uint32_t has_intr = 0;
|
135 | c3d2689d | balrog | |
136 | 106627d0 | balrog | for (i = 0; i < s->nbanks; ++i) |
137 | 106627d0 | balrog | has_intr |= s->banks[i].irqs & ~s->banks[i].mask & |
138 | 106627d0 | balrog | (is_fiq ? s->banks[i].fiq : ~s->banks[i].fiq); |
139 | c3d2689d | balrog | |
140 | 106627d0 | balrog | if (s->new_agr[is_fiq] && has_intr) {
|
141 | 106627d0 | balrog | s->new_agr[is_fiq] = 0;
|
142 | 106627d0 | balrog | omap_inth_sir_update(s, is_fiq); |
143 | 106627d0 | balrog | qemu_set_irq(s->parent_intr[is_fiq], 1);
|
144 | c3d2689d | balrog | } |
145 | c3d2689d | balrog | } |
146 | c3d2689d | balrog | |
147 | c3d2689d | balrog | #define INT_FALLING_EDGE 0 |
148 | c3d2689d | balrog | #define INT_LOW_LEVEL 1 |
149 | c3d2689d | balrog | |
150 | c3d2689d | balrog | static void omap_set_intr(void *opaque, int irq, int req) |
151 | c3d2689d | balrog | { |
152 | c3d2689d | balrog | struct omap_intr_handler_s *ih = (struct omap_intr_handler_s *) opaque; |
153 | c3d2689d | balrog | uint32_t rise; |
154 | c3d2689d | balrog | |
155 | 106627d0 | balrog | struct omap_intr_handler_bank_s *bank = &ih->banks[irq >> 5]; |
156 | 106627d0 | balrog | int n = irq & 31; |
157 | 106627d0 | balrog | |
158 | c3d2689d | balrog | if (req) {
|
159 | 106627d0 | balrog | rise = ~bank->irqs & (1 << n);
|
160 | 106627d0 | balrog | if (~bank->sens_edge & (1 << n)) |
161 | 106627d0 | balrog | rise &= ~bank->inputs & (1 << n);
|
162 | 106627d0 | balrog | |
163 | 106627d0 | balrog | bank->inputs |= (1 << n);
|
164 | 106627d0 | balrog | if (rise) {
|
165 | 106627d0 | balrog | bank->irqs |= rise; |
166 | 106627d0 | balrog | omap_inth_update(ih, 0);
|
167 | 106627d0 | balrog | omap_inth_update(ih, 1);
|
168 | 106627d0 | balrog | } |
169 | c3d2689d | balrog | } else {
|
170 | 106627d0 | balrog | rise = bank->sens_edge & bank->irqs & (1 << n);
|
171 | 106627d0 | balrog | bank->irqs &= ~rise; |
172 | 106627d0 | balrog | bank->inputs &= ~(1 << n);
|
173 | c3d2689d | balrog | } |
174 | c3d2689d | balrog | } |
175 | c3d2689d | balrog | |
176 | c3d2689d | balrog | static uint32_t omap_inth_read(void *opaque, target_phys_addr_t addr) |
177 | c3d2689d | balrog | { |
178 | c3d2689d | balrog | struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque; |
179 | c3d2689d | balrog | int i, offset = addr - s->base;
|
180 | 106627d0 | balrog | int bank_no = offset >> 8; |
181 | 106627d0 | balrog | int line_no;
|
182 | 106627d0 | balrog | struct omap_intr_handler_bank_s *bank = &s->banks[bank_no];
|
183 | 106627d0 | balrog | offset &= 0xff;
|
184 | c3d2689d | balrog | |
185 | c3d2689d | balrog | switch (offset) {
|
186 | c3d2689d | balrog | case 0x00: /* ITR */ |
187 | 106627d0 | balrog | return bank->irqs;
|
188 | c3d2689d | balrog | |
189 | c3d2689d | balrog | case 0x04: /* MIR */ |
190 | 106627d0 | balrog | return bank->mask;
|
191 | c3d2689d | balrog | |
192 | c3d2689d | balrog | case 0x10: /* SIR_IRQ_CODE */ |
193 | 106627d0 | balrog | case 0x14: /* SIR_FIQ_CODE */ |
194 | 106627d0 | balrog | if (bank_no != 0) |
195 | 106627d0 | balrog | break;
|
196 | 106627d0 | balrog | line_no = s->sir_intr[(offset - 0x10) >> 2]; |
197 | 106627d0 | balrog | bank = &s->banks[line_no >> 5];
|
198 | 106627d0 | balrog | i = line_no & 31;
|
199 | 106627d0 | balrog | if (((bank->sens_edge >> i) & 1) == INT_FALLING_EDGE) |
200 | 106627d0 | balrog | bank->irqs &= ~(1 << i);
|
201 | f2df5260 | balrog | return line_no;
|
202 | c3d2689d | balrog | |
203 | c3d2689d | balrog | case 0x18: /* CONTROL_REG */ |
204 | 106627d0 | balrog | if (bank_no != 0) |
205 | 106627d0 | balrog | break;
|
206 | c3d2689d | balrog | return 0; |
207 | c3d2689d | balrog | |
208 | c3d2689d | balrog | case 0x1c: /* ILR0 */ |
209 | c3d2689d | balrog | case 0x20: /* ILR1 */ |
210 | c3d2689d | balrog | case 0x24: /* ILR2 */ |
211 | c3d2689d | balrog | case 0x28: /* ILR3 */ |
212 | c3d2689d | balrog | case 0x2c: /* ILR4 */ |
213 | c3d2689d | balrog | case 0x30: /* ILR5 */ |
214 | c3d2689d | balrog | case 0x34: /* ILR6 */ |
215 | c3d2689d | balrog | case 0x38: /* ILR7 */ |
216 | c3d2689d | balrog | case 0x3c: /* ILR8 */ |
217 | c3d2689d | balrog | case 0x40: /* ILR9 */ |
218 | c3d2689d | balrog | case 0x44: /* ILR10 */ |
219 | c3d2689d | balrog | case 0x48: /* ILR11 */ |
220 | c3d2689d | balrog | case 0x4c: /* ILR12 */ |
221 | c3d2689d | balrog | case 0x50: /* ILR13 */ |
222 | c3d2689d | balrog | case 0x54: /* ILR14 */ |
223 | c3d2689d | balrog | case 0x58: /* ILR15 */ |
224 | c3d2689d | balrog | case 0x5c: /* ILR16 */ |
225 | c3d2689d | balrog | case 0x60: /* ILR17 */ |
226 | c3d2689d | balrog | case 0x64: /* ILR18 */ |
227 | c3d2689d | balrog | case 0x68: /* ILR19 */ |
228 | c3d2689d | balrog | case 0x6c: /* ILR20 */ |
229 | c3d2689d | balrog | case 0x70: /* ILR21 */ |
230 | c3d2689d | balrog | case 0x74: /* ILR22 */ |
231 | c3d2689d | balrog | case 0x78: /* ILR23 */ |
232 | c3d2689d | balrog | case 0x7c: /* ILR24 */ |
233 | c3d2689d | balrog | case 0x80: /* ILR25 */ |
234 | c3d2689d | balrog | case 0x84: /* ILR26 */ |
235 | c3d2689d | balrog | case 0x88: /* ILR27 */ |
236 | c3d2689d | balrog | case 0x8c: /* ILR28 */ |
237 | c3d2689d | balrog | case 0x90: /* ILR29 */ |
238 | c3d2689d | balrog | case 0x94: /* ILR30 */ |
239 | c3d2689d | balrog | case 0x98: /* ILR31 */ |
240 | c3d2689d | balrog | i = (offset - 0x1c) >> 2; |
241 | 106627d0 | balrog | return (bank->priority[i] << 2) | |
242 | 106627d0 | balrog | (((bank->sens_edge >> i) & 1) << 1) | |
243 | 106627d0 | balrog | ((bank->fiq >> i) & 1);
|
244 | c3d2689d | balrog | |
245 | c3d2689d | balrog | case 0x9c: /* ISR */ |
246 | c3d2689d | balrog | return 0x00000000; |
247 | c3d2689d | balrog | |
248 | c3d2689d | balrog | } |
249 | 106627d0 | balrog | OMAP_BAD_REG(addr); |
250 | c3d2689d | balrog | return 0; |
251 | c3d2689d | balrog | } |
252 | c3d2689d | balrog | |
253 | c3d2689d | balrog | static void omap_inth_write(void *opaque, target_phys_addr_t addr, |
254 | c3d2689d | balrog | uint32_t value) |
255 | c3d2689d | balrog | { |
256 | c3d2689d | balrog | struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque; |
257 | c3d2689d | balrog | int i, offset = addr - s->base;
|
258 | 106627d0 | balrog | int bank_no = offset >> 8; |
259 | 106627d0 | balrog | struct omap_intr_handler_bank_s *bank = &s->banks[bank_no];
|
260 | 106627d0 | balrog | offset &= 0xff;
|
261 | c3d2689d | balrog | |
262 | c3d2689d | balrog | switch (offset) {
|
263 | c3d2689d | balrog | case 0x00: /* ITR */ |
264 | 106627d0 | balrog | /* Important: ignore the clearing if the IRQ is level-triggered and
|
265 | 106627d0 | balrog | the input bit is 1 */
|
266 | 106627d0 | balrog | bank->irqs &= value | (bank->inputs & bank->sens_edge); |
267 | c3d2689d | balrog | return;
|
268 | c3d2689d | balrog | |
269 | c3d2689d | balrog | case 0x04: /* MIR */ |
270 | 106627d0 | balrog | bank->mask = value; |
271 | 106627d0 | balrog | omap_inth_update(s, 0);
|
272 | 106627d0 | balrog | omap_inth_update(s, 1);
|
273 | c3d2689d | balrog | return;
|
274 | c3d2689d | balrog | |
275 | c3d2689d | balrog | case 0x10: /* SIR_IRQ_CODE */ |
276 | c3d2689d | balrog | case 0x14: /* SIR_FIQ_CODE */ |
277 | c3d2689d | balrog | OMAP_RO_REG(addr); |
278 | c3d2689d | balrog | break;
|
279 | c3d2689d | balrog | |
280 | c3d2689d | balrog | case 0x18: /* CONTROL_REG */ |
281 | 106627d0 | balrog | if (bank_no != 0) |
282 | 106627d0 | balrog | break;
|
283 | 106627d0 | balrog | if (value & 2) { |
284 | 106627d0 | balrog | qemu_set_irq(s->parent_intr[1], 0); |
285 | 106627d0 | balrog | s->new_agr[1] = ~0; |
286 | 106627d0 | balrog | omap_inth_update(s, 1);
|
287 | 106627d0 | balrog | } |
288 | 106627d0 | balrog | if (value & 1) { |
289 | 106627d0 | balrog | qemu_set_irq(s->parent_intr[0], 0); |
290 | 106627d0 | balrog | s->new_agr[0] = ~0; |
291 | 106627d0 | balrog | omap_inth_update(s, 0);
|
292 | 106627d0 | balrog | } |
293 | c3d2689d | balrog | return;
|
294 | c3d2689d | balrog | |
295 | c3d2689d | balrog | case 0x1c: /* ILR0 */ |
296 | c3d2689d | balrog | case 0x20: /* ILR1 */ |
297 | c3d2689d | balrog | case 0x24: /* ILR2 */ |
298 | c3d2689d | balrog | case 0x28: /* ILR3 */ |
299 | c3d2689d | balrog | case 0x2c: /* ILR4 */ |
300 | c3d2689d | balrog | case 0x30: /* ILR5 */ |
301 | c3d2689d | balrog | case 0x34: /* ILR6 */ |
302 | c3d2689d | balrog | case 0x38: /* ILR7 */ |
303 | c3d2689d | balrog | case 0x3c: /* ILR8 */ |
304 | c3d2689d | balrog | case 0x40: /* ILR9 */ |
305 | c3d2689d | balrog | case 0x44: /* ILR10 */ |
306 | c3d2689d | balrog | case 0x48: /* ILR11 */ |
307 | c3d2689d | balrog | case 0x4c: /* ILR12 */ |
308 | c3d2689d | balrog | case 0x50: /* ILR13 */ |
309 | c3d2689d | balrog | case 0x54: /* ILR14 */ |
310 | c3d2689d | balrog | case 0x58: /* ILR15 */ |
311 | c3d2689d | balrog | case 0x5c: /* ILR16 */ |
312 | c3d2689d | balrog | case 0x60: /* ILR17 */ |
313 | c3d2689d | balrog | case 0x64: /* ILR18 */ |
314 | c3d2689d | balrog | case 0x68: /* ILR19 */ |
315 | c3d2689d | balrog | case 0x6c: /* ILR20 */ |
316 | c3d2689d | balrog | case 0x70: /* ILR21 */ |
317 | c3d2689d | balrog | case 0x74: /* ILR22 */ |
318 | c3d2689d | balrog | case 0x78: /* ILR23 */ |
319 | c3d2689d | balrog | case 0x7c: /* ILR24 */ |
320 | c3d2689d | balrog | case 0x80: /* ILR25 */ |
321 | c3d2689d | balrog | case 0x84: /* ILR26 */ |
322 | c3d2689d | balrog | case 0x88: /* ILR27 */ |
323 | c3d2689d | balrog | case 0x8c: /* ILR28 */ |
324 | c3d2689d | balrog | case 0x90: /* ILR29 */ |
325 | c3d2689d | balrog | case 0x94: /* ILR30 */ |
326 | c3d2689d | balrog | case 0x98: /* ILR31 */ |
327 | c3d2689d | balrog | i = (offset - 0x1c) >> 2; |
328 | 106627d0 | balrog | bank->priority[i] = (value >> 2) & 0x1f; |
329 | 106627d0 | balrog | bank->sens_edge &= ~(1 << i);
|
330 | 106627d0 | balrog | bank->sens_edge |= ((value >> 1) & 1) << i; |
331 | 106627d0 | balrog | bank->fiq &= ~(1 << i);
|
332 | 106627d0 | balrog | bank->fiq |= (value & 1) << i;
|
333 | c3d2689d | balrog | return;
|
334 | c3d2689d | balrog | |
335 | c3d2689d | balrog | case 0x9c: /* ISR */ |
336 | c3d2689d | balrog | for (i = 0; i < 32; i ++) |
337 | c3d2689d | balrog | if (value & (1 << i)) { |
338 | 106627d0 | balrog | omap_set_intr(s, 32 * bank_no + i, 1); |
339 | c3d2689d | balrog | return;
|
340 | c3d2689d | balrog | } |
341 | c3d2689d | balrog | return;
|
342 | c3d2689d | balrog | } |
343 | 106627d0 | balrog | OMAP_BAD_REG(addr); |
344 | c3d2689d | balrog | } |
345 | c3d2689d | balrog | |
346 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_inth_readfn[] = {
|
347 | c3d2689d | balrog | omap_badwidth_read32, |
348 | c3d2689d | balrog | omap_badwidth_read32, |
349 | c3d2689d | balrog | omap_inth_read, |
350 | c3d2689d | balrog | }; |
351 | c3d2689d | balrog | |
352 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_inth_writefn[] = {
|
353 | c3d2689d | balrog | omap_inth_write, |
354 | c3d2689d | balrog | omap_inth_write, |
355 | c3d2689d | balrog | omap_inth_write, |
356 | c3d2689d | balrog | }; |
357 | c3d2689d | balrog | |
358 | 106627d0 | balrog | void omap_inth_reset(struct omap_intr_handler_s *s) |
359 | c3d2689d | balrog | { |
360 | 106627d0 | balrog | int i;
|
361 | 106627d0 | balrog | |
362 | 106627d0 | balrog | for (i = 0; i < s->nbanks; ++i){ |
363 | 106627d0 | balrog | s->banks[i].irqs = 0x00000000;
|
364 | 106627d0 | balrog | s->banks[i].mask = 0xffffffff;
|
365 | 106627d0 | balrog | s->banks[i].sens_edge = 0x00000000;
|
366 | 106627d0 | balrog | s->banks[i].fiq = 0x00000000;
|
367 | 106627d0 | balrog | s->banks[i].inputs = 0x00000000;
|
368 | 106627d0 | balrog | memset(s->banks[i].priority, 0, sizeof(s->banks[i].priority)); |
369 | 106627d0 | balrog | } |
370 | c3d2689d | balrog | |
371 | 106627d0 | balrog | s->new_agr[0] = ~0; |
372 | 106627d0 | balrog | s->new_agr[1] = ~0; |
373 | 106627d0 | balrog | s->sir_intr[0] = 0; |
374 | 106627d0 | balrog | s->sir_intr[1] = 0; |
375 | 106627d0 | balrog | |
376 | 106627d0 | balrog | qemu_set_irq(s->parent_intr[0], 0); |
377 | 106627d0 | balrog | qemu_set_irq(s->parent_intr[1], 0); |
378 | c3d2689d | balrog | } |
379 | c3d2689d | balrog | |
380 | c3d2689d | balrog | struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base,
|
381 | 106627d0 | balrog | unsigned long size, unsigned char nbanks, |
382 | 106627d0 | balrog | qemu_irq parent_irq, qemu_irq parent_fiq, omap_clk clk) |
383 | c3d2689d | balrog | { |
384 | c3d2689d | balrog | int iomemtype;
|
385 | c3d2689d | balrog | struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) |
386 | 106627d0 | balrog | qemu_mallocz(sizeof(struct omap_intr_handler_s) + |
387 | 106627d0 | balrog | sizeof(struct omap_intr_handler_bank_s) * nbanks); |
388 | c3d2689d | balrog | |
389 | 106627d0 | balrog | s->parent_intr[0] = parent_irq;
|
390 | 106627d0 | balrog | s->parent_intr[1] = parent_fiq;
|
391 | c3d2689d | balrog | s->base = base; |
392 | 106627d0 | balrog | s->nbanks = nbanks; |
393 | 106627d0 | balrog | s->pins = qemu_allocate_irqs(omap_set_intr, s, nbanks * 32);
|
394 | 106627d0 | balrog | |
395 | c3d2689d | balrog | omap_inth_reset(s); |
396 | c3d2689d | balrog | |
397 | c3d2689d | balrog | iomemtype = cpu_register_io_memory(0, omap_inth_readfn,
|
398 | c3d2689d | balrog | omap_inth_writefn, s); |
399 | c3d2689d | balrog | cpu_register_physical_memory(s->base, size, iomemtype); |
400 | c3d2689d | balrog | |
401 | c3d2689d | balrog | return s;
|
402 | c3d2689d | balrog | } |
403 | c3d2689d | balrog | |
404 | c3d2689d | balrog | /* OMAP1 DMA module */
|
405 | c3d2689d | balrog | struct omap_dma_channel_s {
|
406 | 089b7c0a | balrog | /* transfer data */
|
407 | c3d2689d | balrog | int burst[2]; |
408 | c3d2689d | balrog | int pack[2]; |
409 | c3d2689d | balrog | enum omap_dma_port port[2]; |
410 | c3d2689d | balrog | target_phys_addr_t addr[2];
|
411 | c3d2689d | balrog | omap_dma_addressing_t mode[2];
|
412 | 089b7c0a | balrog | uint16_t elements; |
413 | 089b7c0a | balrog | uint16_t frames; |
414 | 089b7c0a | balrog | int16_t frame_index[2];
|
415 | 089b7c0a | balrog | int16_t element_index[2];
|
416 | c3d2689d | balrog | int data_type;
|
417 | 089b7c0a | balrog | |
418 | 089b7c0a | balrog | /* transfer type */
|
419 | 089b7c0a | balrog | int transparent_copy;
|
420 | 089b7c0a | balrog | int constant_fill;
|
421 | 089b7c0a | balrog | uint32_t color; |
422 | 089b7c0a | balrog | |
423 | 089b7c0a | balrog | /* auto init and linked channel data */
|
424 | c3d2689d | balrog | int end_prog;
|
425 | c3d2689d | balrog | int repeat;
|
426 | c3d2689d | balrog | int auto_init;
|
427 | 089b7c0a | balrog | int link_enabled;
|
428 | 089b7c0a | balrog | int link_next_ch;
|
429 | 089b7c0a | balrog | |
430 | 089b7c0a | balrog | /* interruption data */
|
431 | c3d2689d | balrog | int interrupts;
|
432 | c3d2689d | balrog | int status;
|
433 | 089b7c0a | balrog | |
434 | 089b7c0a | balrog | /* state data */
|
435 | 089b7c0a | balrog | int active;
|
436 | 089b7c0a | balrog | int enable;
|
437 | 089b7c0a | balrog | int sync;
|
438 | 089b7c0a | balrog | int pending_request;
|
439 | 089b7c0a | balrog | int waiting_end_prog;
|
440 | c3d2689d | balrog | uint16_t cpc; |
441 | c3d2689d | balrog | |
442 | 089b7c0a | balrog | /* sync type */
|
443 | 089b7c0a | balrog | int fs;
|
444 | 089b7c0a | balrog | int bs;
|
445 | 089b7c0a | balrog | |
446 | 089b7c0a | balrog | /* compatibility */
|
447 | 089b7c0a | balrog | int omap_3_1_compatible_disable;
|
448 | 089b7c0a | balrog | |
449 | 11e0fc3f | balrog | qemu_irq irq; |
450 | 11e0fc3f | balrog | struct omap_dma_channel_s *sibling;
|
451 | 11e0fc3f | balrog | |
452 | c3d2689d | balrog | struct omap_dma_reg_set_s {
|
453 | c3d2689d | balrog | target_phys_addr_t src, dest; |
454 | c3d2689d | balrog | int frame;
|
455 | c3d2689d | balrog | int element;
|
456 | c3d2689d | balrog | int frame_delta[2]; |
457 | c3d2689d | balrog | int elem_delta[2]; |
458 | c3d2689d | balrog | int frames;
|
459 | c3d2689d | balrog | int elements;
|
460 | c3d2689d | balrog | } active_set; |
461 | 089b7c0a | balrog | |
462 | 089b7c0a | balrog | /* unused parameters */
|
463 | 089b7c0a | balrog | int priority;
|
464 | 089b7c0a | balrog | int interleave_disabled;
|
465 | 089b7c0a | balrog | int type;
|
466 | c3d2689d | balrog | }; |
467 | c3d2689d | balrog | |
468 | c3d2689d | balrog | struct omap_dma_s {
|
469 | c3d2689d | balrog | QEMUTimer *tm; |
470 | c3d2689d | balrog | struct omap_mpu_state_s *mpu;
|
471 | c3d2689d | balrog | target_phys_addr_t base; |
472 | c3d2689d | balrog | omap_clk clk; |
473 | c3d2689d | balrog | int64_t delay; |
474 | 1af2b62d | balrog | uint32_t drq; |
475 | 089b7c0a | balrog | enum omap_dma_model model;
|
476 | 089b7c0a | balrog | int omap_3_1_mapping_disabled;
|
477 | c3d2689d | balrog | |
478 | c3d2689d | balrog | uint16_t gcr; |
479 | c3d2689d | balrog | int run_count;
|
480 | c3d2689d | balrog | |
481 | c3d2689d | balrog | int chans;
|
482 | c3d2689d | balrog | struct omap_dma_channel_s ch[16]; |
483 | c3d2689d | balrog | struct omap_dma_lcd_channel_s lcd_ch;
|
484 | c3d2689d | balrog | }; |
485 | c3d2689d | balrog | |
486 | 089b7c0a | balrog | /* Interrupts */
|
487 | 089b7c0a | balrog | #define TIMEOUT_INTR (1 << 0) |
488 | 089b7c0a | balrog | #define EVENT_DROP_INTR (1 << 1) |
489 | 089b7c0a | balrog | #define HALF_FRAME_INTR (1 << 2) |
490 | 089b7c0a | balrog | #define END_FRAME_INTR (1 << 3) |
491 | 089b7c0a | balrog | #define LAST_FRAME_INTR (1 << 4) |
492 | 089b7c0a | balrog | #define END_BLOCK_INTR (1 << 5) |
493 | 089b7c0a | balrog | #define SYNC (1 << 6) |
494 | 089b7c0a | balrog | |
495 | c3d2689d | balrog | static void omap_dma_interrupts_update(struct omap_dma_s *s) |
496 | c3d2689d | balrog | { |
497 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch = s->ch;
|
498 | 11e0fc3f | balrog | int i;
|
499 | 089b7c0a | balrog | |
500 | 089b7c0a | balrog | if (s->omap_3_1_mapping_disabled) {
|
501 | 11e0fc3f | balrog | for (i = 0; i < s->chans; i ++, ch ++) |
502 | 11e0fc3f | balrog | if (ch->status)
|
503 | 11e0fc3f | balrog | qemu_irq_raise(ch->irq); |
504 | 089b7c0a | balrog | } else {
|
505 | 089b7c0a | balrog | /* First three interrupts are shared between two channels each. */
|
506 | 11e0fc3f | balrog | for (i = 0; i < 6; i ++, ch ++) { |
507 | 11e0fc3f | balrog | if (ch->status || (ch->sibling && ch->sibling->status))
|
508 | 11e0fc3f | balrog | qemu_irq_raise(ch->irq); |
509 | 089b7c0a | balrog | } |
510 | 089b7c0a | balrog | } |
511 | c3d2689d | balrog | } |
512 | c3d2689d | balrog | |
513 | 11e0fc3f | balrog | static void omap_dma_channel_load(struct omap_dma_s *s, |
514 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch)
|
515 | c3d2689d | balrog | { |
516 | 11e0fc3f | balrog | struct omap_dma_reg_set_s *a = &ch->active_set;
|
517 | c3d2689d | balrog | int i;
|
518 | 11e0fc3f | balrog | int omap_3_1 = !ch->omap_3_1_compatible_disable;
|
519 | c3d2689d | balrog | |
520 | c3d2689d | balrog | /*
|
521 | c3d2689d | balrog | * TODO: verify address ranges and alignment
|
522 | c3d2689d | balrog | * TODO: port endianness
|
523 | c3d2689d | balrog | */
|
524 | c3d2689d | balrog | |
525 | 11e0fc3f | balrog | a->src = ch->addr[0];
|
526 | 11e0fc3f | balrog | a->dest = ch->addr[1];
|
527 | 11e0fc3f | balrog | a->frames = ch->frames; |
528 | 11e0fc3f | balrog | a->elements = ch->elements; |
529 | c3d2689d | balrog | a->frame = 0;
|
530 | c3d2689d | balrog | a->element = 0;
|
531 | c3d2689d | balrog | |
532 | 11e0fc3f | balrog | if (unlikely(!ch->elements || !ch->frames)) {
|
533 | c3d2689d | balrog | printf("%s: bad DMA request\n", __FUNCTION__);
|
534 | c3d2689d | balrog | return;
|
535 | c3d2689d | balrog | } |
536 | c3d2689d | balrog | |
537 | c3d2689d | balrog | for (i = 0; i < 2; i ++) |
538 | 11e0fc3f | balrog | switch (ch->mode[i]) {
|
539 | c3d2689d | balrog | case constant:
|
540 | c3d2689d | balrog | a->elem_delta[i] = 0;
|
541 | c3d2689d | balrog | a->frame_delta[i] = 0;
|
542 | c3d2689d | balrog | break;
|
543 | c3d2689d | balrog | case post_incremented:
|
544 | 11e0fc3f | balrog | a->elem_delta[i] = ch->data_type; |
545 | c3d2689d | balrog | a->frame_delta[i] = 0;
|
546 | c3d2689d | balrog | break;
|
547 | c3d2689d | balrog | case single_index:
|
548 | 11e0fc3f | balrog | a->elem_delta[i] = ch->data_type + |
549 | 11e0fc3f | balrog | ch->element_index[omap_3_1 ? 0 : i] - 1; |
550 | c3d2689d | balrog | a->frame_delta[i] = 0;
|
551 | c3d2689d | balrog | break;
|
552 | c3d2689d | balrog | case double_index:
|
553 | 11e0fc3f | balrog | a->elem_delta[i] = ch->data_type + |
554 | 11e0fc3f | balrog | ch->element_index[omap_3_1 ? 0 : i] - 1; |
555 | 11e0fc3f | balrog | a->frame_delta[i] = ch->frame_index[omap_3_1 ? 0 : i] -
|
556 | 11e0fc3f | balrog | ch->element_index[omap_3_1 ? 0 : i];
|
557 | c3d2689d | balrog | break;
|
558 | c3d2689d | balrog | default:
|
559 | c3d2689d | balrog | break;
|
560 | c3d2689d | balrog | } |
561 | c3d2689d | balrog | } |
562 | c3d2689d | balrog | |
563 | 11e0fc3f | balrog | static void omap_dma_activate_channel(struct omap_dma_s *s, |
564 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch)
|
565 | c3d2689d | balrog | { |
566 | 11e0fc3f | balrog | if (!ch->active) {
|
567 | 11e0fc3f | balrog | ch->active = 1;
|
568 | 11e0fc3f | balrog | if (ch->sync)
|
569 | 11e0fc3f | balrog | ch->status |= SYNC; |
570 | 089b7c0a | balrog | s->run_count ++; |
571 | 089b7c0a | balrog | } |
572 | 089b7c0a | balrog | |
573 | 089b7c0a | balrog | if (s->delay && !qemu_timer_pending(s->tm))
|
574 | 089b7c0a | balrog | qemu_mod_timer(s->tm, qemu_get_clock(vm_clock) + s->delay); |
575 | 089b7c0a | balrog | } |
576 | 089b7c0a | balrog | |
577 | 11e0fc3f | balrog | static void omap_dma_deactivate_channel(struct omap_dma_s *s, |
578 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch)
|
579 | 089b7c0a | balrog | { |
580 | 089b7c0a | balrog | /* Update cpc */
|
581 | 11e0fc3f | balrog | ch->cpc = ch->active_set.dest & 0xffff;
|
582 | 089b7c0a | balrog | |
583 | 11e0fc3f | balrog | if (ch->pending_request && !ch->waiting_end_prog) {
|
584 | 089b7c0a | balrog | /* Don't deactivate the channel */
|
585 | 11e0fc3f | balrog | ch->pending_request = 0;
|
586 | c3d2689d | balrog | return;
|
587 | 089b7c0a | balrog | } |
588 | c3d2689d | balrog | |
589 | 089b7c0a | balrog | /* Don't deactive the channel if it is synchronized and the DMA request is
|
590 | 089b7c0a | balrog | active */
|
591 | 11e0fc3f | balrog | if (ch->sync && (s->drq & (1 << ch->sync))) |
592 | c3d2689d | balrog | return;
|
593 | 089b7c0a | balrog | |
594 | 11e0fc3f | balrog | if (ch->active) {
|
595 | 11e0fc3f | balrog | ch->active = 0;
|
596 | 11e0fc3f | balrog | ch->status &= ~SYNC; |
597 | 089b7c0a | balrog | s->run_count --; |
598 | c3d2689d | balrog | } |
599 | c3d2689d | balrog | |
600 | 089b7c0a | balrog | if (!s->run_count)
|
601 | 089b7c0a | balrog | qemu_del_timer(s->tm); |
602 | 089b7c0a | balrog | } |
603 | c3d2689d | balrog | |
604 | 11e0fc3f | balrog | static void omap_dma_enable_channel(struct omap_dma_s *s, |
605 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch)
|
606 | 089b7c0a | balrog | { |
607 | 11e0fc3f | balrog | if (!ch->enable) {
|
608 | 11e0fc3f | balrog | ch->enable = 1;
|
609 | 11e0fc3f | balrog | ch->waiting_end_prog = 0;
|
610 | 11e0fc3f | balrog | omap_dma_channel_load(s, ch); |
611 | 11e0fc3f | balrog | if ((!ch->sync) || (s->drq & (1 << ch->sync))) |
612 | 11e0fc3f | balrog | omap_dma_activate_channel(s, ch); |
613 | 089b7c0a | balrog | } |
614 | 089b7c0a | balrog | } |
615 | c3d2689d | balrog | |
616 | 11e0fc3f | balrog | static void omap_dma_disable_channel(struct omap_dma_s *s, |
617 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch)
|
618 | 089b7c0a | balrog | { |
619 | 11e0fc3f | balrog | if (ch->enable) {
|
620 | 11e0fc3f | balrog | ch->enable = 0;
|
621 | 089b7c0a | balrog | /* Discard any pending request */
|
622 | 11e0fc3f | balrog | ch->pending_request = 0;
|
623 | 11e0fc3f | balrog | omap_dma_deactivate_channel(s, ch); |
624 | 089b7c0a | balrog | } |
625 | 089b7c0a | balrog | } |
626 | c3d2689d | balrog | |
627 | 11e0fc3f | balrog | static void omap_dma_channel_end_prog(struct omap_dma_s *s, |
628 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch)
|
629 | 089b7c0a | balrog | { |
630 | 11e0fc3f | balrog | if (ch->waiting_end_prog) {
|
631 | 11e0fc3f | balrog | ch->waiting_end_prog = 0;
|
632 | 11e0fc3f | balrog | if (!ch->sync || ch->pending_request) {
|
633 | 11e0fc3f | balrog | ch->pending_request = 0;
|
634 | 11e0fc3f | balrog | omap_dma_activate_channel(s, ch); |
635 | 089b7c0a | balrog | } |
636 | c3d2689d | balrog | } |
637 | c3d2689d | balrog | } |
638 | c3d2689d | balrog | |
639 | 089b7c0a | balrog | static void omap_dma_enable_3_1_mapping(struct omap_dma_s *s) |
640 | c3d2689d | balrog | { |
641 | 089b7c0a | balrog | s->omap_3_1_mapping_disabled = 0;
|
642 | 089b7c0a | balrog | s->chans = 9;
|
643 | 089b7c0a | balrog | } |
644 | c3d2689d | balrog | |
645 | 089b7c0a | balrog | static void omap_dma_disable_3_1_mapping(struct omap_dma_s *s) |
646 | 089b7c0a | balrog | { |
647 | 089b7c0a | balrog | s->omap_3_1_mapping_disabled = 1;
|
648 | 089b7c0a | balrog | s->chans = 16;
|
649 | 089b7c0a | balrog | } |
650 | 089b7c0a | balrog | |
651 | 089b7c0a | balrog | static void omap_dma_process_request(struct omap_dma_s *s, int request) |
652 | 089b7c0a | balrog | { |
653 | 089b7c0a | balrog | int channel;
|
654 | 089b7c0a | balrog | int drop_event = 0; |
655 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch = s->ch;
|
656 | 11e0fc3f | balrog | |
657 | 11e0fc3f | balrog | for (channel = 0; channel < s->chans; channel ++, ch ++) { |
658 | 11e0fc3f | balrog | if (ch->enable && ch->sync == request) {
|
659 | 11e0fc3f | balrog | if (!ch->active)
|
660 | 11e0fc3f | balrog | omap_dma_activate_channel(s, ch); |
661 | 11e0fc3f | balrog | else if (!ch->pending_request) |
662 | 11e0fc3f | balrog | ch->pending_request = 1;
|
663 | 089b7c0a | balrog | else {
|
664 | 089b7c0a | balrog | /* Request collision */
|
665 | 089b7c0a | balrog | /* Second request received while processing other request */
|
666 | 11e0fc3f | balrog | ch->status |= EVENT_DROP_INTR; |
667 | 089b7c0a | balrog | drop_event = 1;
|
668 | 089b7c0a | balrog | } |
669 | 089b7c0a | balrog | } |
670 | 089b7c0a | balrog | } |
671 | 089b7c0a | balrog | |
672 | 089b7c0a | balrog | if (drop_event)
|
673 | 089b7c0a | balrog | omap_dma_interrupts_update(s); |
674 | c3d2689d | balrog | } |
675 | c3d2689d | balrog | |
676 | c3d2689d | balrog | static void omap_dma_channel_run(struct omap_dma_s *s) |
677 | c3d2689d | balrog | { |
678 | 11e0fc3f | balrog | int n = s->chans;
|
679 | c3d2689d | balrog | uint16_t status; |
680 | c3d2689d | balrog | uint8_t value[4];
|
681 | c3d2689d | balrog | struct omap_dma_port_if_s *src_p, *dest_p;
|
682 | c3d2689d | balrog | struct omap_dma_reg_set_s *a;
|
683 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch;
|
684 | c3d2689d | balrog | |
685 | 11e0fc3f | balrog | for (ch = s->ch; n; n --, ch ++) {
|
686 | 11e0fc3f | balrog | if (!ch->active)
|
687 | 089b7c0a | balrog | continue;
|
688 | 089b7c0a | balrog | |
689 | 11e0fc3f | balrog | a = &ch->active_set; |
690 | c3d2689d | balrog | |
691 | 11e0fc3f | balrog | src_p = &s->mpu->port[ch->port[0]];
|
692 | 11e0fc3f | balrog | dest_p = &s->mpu->port[ch->port[1]];
|
693 | 11e0fc3f | balrog | if ((!ch->constant_fill && !src_p->addr_valid(s->mpu, a->src)) ||
|
694 | 089b7c0a | balrog | (!dest_p->addr_valid(s->mpu, a->dest))) { |
695 | c3d2689d | balrog | #if 0
|
696 | c3d2689d | balrog | /* Bus time-out */
|
697 | 11e0fc3f | balrog | if (ch->interrupts & TIMEOUT_INTR)
|
698 | 11e0fc3f | balrog | ch->status |= TIMEOUT_INTR;
|
699 | 089b7c0a | balrog | omap_dma_deactivate_channel(s, ch);
|
700 | c3d2689d | balrog | continue;
|
701 | c3d2689d | balrog | #endif
|
702 | 11e0fc3f | balrog | printf("%s: Bus time-out in DMA%i operation\n",
|
703 | 11e0fc3f | balrog | __FUNCTION__, s->chans - n); |
704 | c3d2689d | balrog | } |
705 | c3d2689d | balrog | |
706 | 11e0fc3f | balrog | status = ch->status; |
707 | 11e0fc3f | balrog | while (status == ch->status && ch->active) {
|
708 | c3d2689d | balrog | /* Transfer a single element */
|
709 | 089b7c0a | balrog | /* FIXME: check the endianness */
|
710 | 11e0fc3f | balrog | if (!ch->constant_fill)
|
711 | 11e0fc3f | balrog | cpu_physical_memory_read(a->src, value, ch->data_type); |
712 | 089b7c0a | balrog | else
|
713 | 11e0fc3f | balrog | *(uint32_t *) value = ch->color; |
714 | 089b7c0a | balrog | |
715 | 11e0fc3f | balrog | if (!ch->transparent_copy ||
|
716 | 11e0fc3f | balrog | *(uint32_t *) value != ch->color) |
717 | 11e0fc3f | balrog | cpu_physical_memory_write(a->dest, value, ch->data_type); |
718 | c3d2689d | balrog | |
719 | c3d2689d | balrog | a->src += a->elem_delta[0];
|
720 | c3d2689d | balrog | a->dest += a->elem_delta[1];
|
721 | c3d2689d | balrog | a->element ++; |
722 | c3d2689d | balrog | |
723 | 089b7c0a | balrog | /* If the channel is element synchronized, deactivate it */
|
724 | 11e0fc3f | balrog | if (ch->sync && !ch->fs && !ch->bs)
|
725 | 089b7c0a | balrog | omap_dma_deactivate_channel(s, ch); |
726 | 089b7c0a | balrog | |
727 | 089b7c0a | balrog | /* If it is the last frame, set the LAST_FRAME interrupt */
|
728 | 089b7c0a | balrog | if (a->element == 1 && a->frame == a->frames - 1) |
729 | 11e0fc3f | balrog | if (ch->interrupts & LAST_FRAME_INTR)
|
730 | 11e0fc3f | balrog | ch->status |= LAST_FRAME_INTR; |
731 | 089b7c0a | balrog | |
732 | 089b7c0a | balrog | /* If the half of the frame was reached, set the HALF_FRAME
|
733 | 089b7c0a | balrog | interrupt */
|
734 | 089b7c0a | balrog | if (a->element == (a->elements >> 1)) |
735 | 11e0fc3f | balrog | if (ch->interrupts & HALF_FRAME_INTR)
|
736 | 11e0fc3f | balrog | ch->status |= HALF_FRAME_INTR; |
737 | 089b7c0a | balrog | |
738 | c3d2689d | balrog | if (a->element == a->elements) {
|
739 | 089b7c0a | balrog | /* End of Frame */
|
740 | c3d2689d | balrog | a->element = 0;
|
741 | c3d2689d | balrog | a->src += a->frame_delta[0];
|
742 | c3d2689d | balrog | a->dest += a->frame_delta[1];
|
743 | c3d2689d | balrog | a->frame ++; |
744 | c3d2689d | balrog | |
745 | 089b7c0a | balrog | /* If the channel is frame synchronized, deactivate it */
|
746 | 11e0fc3f | balrog | if (ch->sync && ch->fs)
|
747 | 089b7c0a | balrog | omap_dma_deactivate_channel(s, ch); |
748 | c3d2689d | balrog | |
749 | 089b7c0a | balrog | /* If the channel is async, update cpc */
|
750 | 11e0fc3f | balrog | if (!ch->sync)
|
751 | 11e0fc3f | balrog | ch->cpc = a->dest & 0xffff;
|
752 | c3d2689d | balrog | |
753 | 089b7c0a | balrog | /* Set the END_FRAME interrupt */
|
754 | 11e0fc3f | balrog | if (ch->interrupts & END_FRAME_INTR)
|
755 | 11e0fc3f | balrog | ch->status |= END_FRAME_INTR; |
756 | c3d2689d | balrog | |
757 | 089b7c0a | balrog | if (a->frame == a->frames) {
|
758 | 089b7c0a | balrog | /* End of Block */
|
759 | 089b7c0a | balrog | /* Disable the channel */
|
760 | 089b7c0a | balrog | |
761 | 11e0fc3f | balrog | if (ch->omap_3_1_compatible_disable) {
|
762 | 089b7c0a | balrog | omap_dma_disable_channel(s, ch); |
763 | 11e0fc3f | balrog | if (ch->link_enabled)
|
764 | 11e0fc3f | balrog | omap_dma_enable_channel(s, |
765 | 11e0fc3f | balrog | &s->ch[ch->link_next_ch]); |
766 | 089b7c0a | balrog | } else {
|
767 | 11e0fc3f | balrog | if (!ch->auto_init)
|
768 | 089b7c0a | balrog | omap_dma_disable_channel(s, ch); |
769 | 11e0fc3f | balrog | else if (ch->repeat || ch->end_prog) |
770 | 089b7c0a | balrog | omap_dma_channel_load(s, ch); |
771 | 089b7c0a | balrog | else {
|
772 | 11e0fc3f | balrog | ch->waiting_end_prog = 1;
|
773 | 089b7c0a | balrog | omap_dma_deactivate_channel(s, ch); |
774 | 089b7c0a | balrog | } |
775 | 089b7c0a | balrog | } |
776 | 089b7c0a | balrog | |
777 | 11e0fc3f | balrog | if (ch->interrupts & END_BLOCK_INTR)
|
778 | 11e0fc3f | balrog | ch->status |= END_BLOCK_INTR; |
779 | c3d2689d | balrog | } |
780 | c3d2689d | balrog | } |
781 | c3d2689d | balrog | } |
782 | c3d2689d | balrog | } |
783 | c3d2689d | balrog | |
784 | c3d2689d | balrog | omap_dma_interrupts_update(s); |
785 | c3d2689d | balrog | if (s->run_count && s->delay)
|
786 | c3d2689d | balrog | qemu_mod_timer(s->tm, qemu_get_clock(vm_clock) + s->delay); |
787 | c3d2689d | balrog | } |
788 | c3d2689d | balrog | |
789 | 089b7c0a | balrog | static void omap_dma_reset(struct omap_dma_s *s) |
790 | 089b7c0a | balrog | { |
791 | 089b7c0a | balrog | int i;
|
792 | 089b7c0a | balrog | |
793 | 089b7c0a | balrog | qemu_del_timer(s->tm); |
794 | 089b7c0a | balrog | s->gcr = 0x0004;
|
795 | 089b7c0a | balrog | s->drq = 0x00000000;
|
796 | 089b7c0a | balrog | s->run_count = 0;
|
797 | 089b7c0a | balrog | s->lcd_ch.src = emiff; |
798 | 089b7c0a | balrog | s->lcd_ch.condition = 0;
|
799 | 089b7c0a | balrog | s->lcd_ch.interrupts = 0;
|
800 | 089b7c0a | balrog | s->lcd_ch.dual = 0;
|
801 | 089b7c0a | balrog | omap_dma_enable_3_1_mapping(s); |
802 | 11e0fc3f | balrog | for (i = 0; i < s->chans; i ++) { |
803 | 11e0fc3f | balrog | memset(&s->ch[i].burst, 0, sizeof(s->ch[i].burst)); |
804 | 11e0fc3f | balrog | memset(&s->ch[i].port, 0, sizeof(s->ch[i].port)); |
805 | 11e0fc3f | balrog | memset(&s->ch[i].mode, 0, sizeof(s->ch[i].mode)); |
806 | 11e0fc3f | balrog | memset(&s->ch[i].elements, 0, sizeof(s->ch[i].elements)); |
807 | 11e0fc3f | balrog | memset(&s->ch[i].frames, 0, sizeof(s->ch[i].frames)); |
808 | 11e0fc3f | balrog | memset(&s->ch[i].frame_index, 0, sizeof(s->ch[i].frame_index)); |
809 | 11e0fc3f | balrog | memset(&s->ch[i].element_index, 0, sizeof(s->ch[i].element_index)); |
810 | 11e0fc3f | balrog | memset(&s->ch[i].data_type, 0, sizeof(s->ch[i].data_type)); |
811 | 11e0fc3f | balrog | memset(&s->ch[i].transparent_copy, 0,
|
812 | 11e0fc3f | balrog | sizeof(s->ch[i].transparent_copy));
|
813 | 11e0fc3f | balrog | memset(&s->ch[i].constant_fill, 0, sizeof(s->ch[i].constant_fill)); |
814 | 11e0fc3f | balrog | memset(&s->ch[i].color, 0, sizeof(s->ch[i].color)); |
815 | 11e0fc3f | balrog | memset(&s->ch[i].end_prog, 0, sizeof(s->ch[i].end_prog)); |
816 | 11e0fc3f | balrog | memset(&s->ch[i].repeat, 0, sizeof(s->ch[i].repeat)); |
817 | 11e0fc3f | balrog | memset(&s->ch[i].auto_init, 0, sizeof(s->ch[i].auto_init)); |
818 | 11e0fc3f | balrog | memset(&s->ch[i].link_enabled, 0, sizeof(s->ch[i].link_enabled)); |
819 | 11e0fc3f | balrog | memset(&s->ch[i].link_next_ch, 0, sizeof(s->ch[i].link_next_ch)); |
820 | 089b7c0a | balrog | s->ch[i].interrupts = 0x0003;
|
821 | 11e0fc3f | balrog | memset(&s->ch[i].status, 0, sizeof(s->ch[i].status)); |
822 | 11e0fc3f | balrog | memset(&s->ch[i].active, 0, sizeof(s->ch[i].active)); |
823 | 11e0fc3f | balrog | memset(&s->ch[i].enable, 0, sizeof(s->ch[i].enable)); |
824 | 11e0fc3f | balrog | memset(&s->ch[i].sync, 0, sizeof(s->ch[i].sync)); |
825 | 11e0fc3f | balrog | memset(&s->ch[i].pending_request, 0, sizeof(s->ch[i].pending_request)); |
826 | 11e0fc3f | balrog | memset(&s->ch[i].waiting_end_prog, 0,
|
827 | 11e0fc3f | balrog | sizeof(s->ch[i].waiting_end_prog));
|
828 | 11e0fc3f | balrog | memset(&s->ch[i].cpc, 0, sizeof(s->ch[i].cpc)); |
829 | 11e0fc3f | balrog | memset(&s->ch[i].fs, 0, sizeof(s->ch[i].fs)); |
830 | 11e0fc3f | balrog | memset(&s->ch[i].bs, 0, sizeof(s->ch[i].bs)); |
831 | 11e0fc3f | balrog | memset(&s->ch[i].omap_3_1_compatible_disable, 0,
|
832 | 11e0fc3f | balrog | sizeof(s->ch[i].omap_3_1_compatible_disable));
|
833 | 11e0fc3f | balrog | memset(&s->ch[i].active_set, 0, sizeof(s->ch[i].active_set)); |
834 | 11e0fc3f | balrog | memset(&s->ch[i].priority, 0, sizeof(s->ch[i].priority)); |
835 | 11e0fc3f | balrog | memset(&s->ch[i].interleave_disabled, 0,
|
836 | 11e0fc3f | balrog | sizeof(s->ch[i].interleave_disabled));
|
837 | 11e0fc3f | balrog | memset(&s->ch[i].type, 0, sizeof(s->ch[i].type)); |
838 | 11e0fc3f | balrog | } |
839 | 089b7c0a | balrog | } |
840 | 089b7c0a | balrog | |
841 | 11e0fc3f | balrog | static int omap_dma_ch_reg_read(struct omap_dma_s *s, |
842 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch, int reg, uint16_t *value) |
843 | 089b7c0a | balrog | { |
844 | c3d2689d | balrog | switch (reg) {
|
845 | c3d2689d | balrog | case 0x00: /* SYS_DMA_CSDP_CH0 */ |
846 | 11e0fc3f | balrog | *value = (ch->burst[1] << 14) | |
847 | 11e0fc3f | balrog | (ch->pack[1] << 13) | |
848 | 11e0fc3f | balrog | (ch->port[1] << 9) | |
849 | 11e0fc3f | balrog | (ch->burst[0] << 7) | |
850 | 11e0fc3f | balrog | (ch->pack[0] << 6) | |
851 | 11e0fc3f | balrog | (ch->port[0] << 2) | |
852 | 11e0fc3f | balrog | (ch->data_type >> 1);
|
853 | c3d2689d | balrog | break;
|
854 | c3d2689d | balrog | |
855 | c3d2689d | balrog | case 0x02: /* SYS_DMA_CCR_CH0 */ |
856 | 089b7c0a | balrog | if (s->model == omap_dma_3_1)
|
857 | 11e0fc3f | balrog | *value = 0 << 10; /* FIFO_FLUSH reads as 0 */ |
858 | 089b7c0a | balrog | else
|
859 | 11e0fc3f | balrog | *value = ch->omap_3_1_compatible_disable << 10;
|
860 | 11e0fc3f | balrog | *value |= (ch->mode[1] << 14) | |
861 | 11e0fc3f | balrog | (ch->mode[0] << 12) | |
862 | 11e0fc3f | balrog | (ch->end_prog << 11) |
|
863 | 11e0fc3f | balrog | (ch->repeat << 9) |
|
864 | 11e0fc3f | balrog | (ch->auto_init << 8) |
|
865 | 11e0fc3f | balrog | (ch->enable << 7) |
|
866 | 11e0fc3f | balrog | (ch->priority << 6) |
|
867 | 11e0fc3f | balrog | (ch->fs << 5) | ch->sync;
|
868 | c3d2689d | balrog | break;
|
869 | c3d2689d | balrog | |
870 | c3d2689d | balrog | case 0x04: /* SYS_DMA_CICR_CH0 */ |
871 | 11e0fc3f | balrog | *value = ch->interrupts; |
872 | c3d2689d | balrog | break;
|
873 | c3d2689d | balrog | |
874 | c3d2689d | balrog | case 0x06: /* SYS_DMA_CSR_CH0 */ |
875 | 11e0fc3f | balrog | *value = ch->status; |
876 | 11e0fc3f | balrog | ch->status &= SYNC; |
877 | 11e0fc3f | balrog | if (!ch->omap_3_1_compatible_disable && ch->sibling) {
|
878 | 11e0fc3f | balrog | *value |= (ch->sibling->status & 0x3f) << 6; |
879 | 11e0fc3f | balrog | ch->sibling->status &= SYNC; |
880 | 089b7c0a | balrog | } |
881 | 11e0fc3f | balrog | qemu_irq_lower(ch->irq); |
882 | c3d2689d | balrog | break;
|
883 | c3d2689d | balrog | |
884 | c3d2689d | balrog | case 0x08: /* SYS_DMA_CSSA_L_CH0 */ |
885 | 11e0fc3f | balrog | *value = ch->addr[0] & 0x0000ffff; |
886 | c3d2689d | balrog | break;
|
887 | c3d2689d | balrog | |
888 | c3d2689d | balrog | case 0x0a: /* SYS_DMA_CSSA_U_CH0 */ |
889 | 11e0fc3f | balrog | *value = ch->addr[0] >> 16; |
890 | c3d2689d | balrog | break;
|
891 | c3d2689d | balrog | |
892 | c3d2689d | balrog | case 0x0c: /* SYS_DMA_CDSA_L_CH0 */ |
893 | 11e0fc3f | balrog | *value = ch->addr[1] & 0x0000ffff; |
894 | c3d2689d | balrog | break;
|
895 | c3d2689d | balrog | |
896 | c3d2689d | balrog | case 0x0e: /* SYS_DMA_CDSA_U_CH0 */ |
897 | 11e0fc3f | balrog | *value = ch->addr[1] >> 16; |
898 | c3d2689d | balrog | break;
|
899 | c3d2689d | balrog | |
900 | c3d2689d | balrog | case 0x10: /* SYS_DMA_CEN_CH0 */ |
901 | 11e0fc3f | balrog | *value = ch->elements; |
902 | c3d2689d | balrog | break;
|
903 | c3d2689d | balrog | |
904 | c3d2689d | balrog | case 0x12: /* SYS_DMA_CFN_CH0 */ |
905 | 11e0fc3f | balrog | *value = ch->frames; |
906 | c3d2689d | balrog | break;
|
907 | c3d2689d | balrog | |
908 | c3d2689d | balrog | case 0x14: /* SYS_DMA_CFI_CH0 */ |
909 | 11e0fc3f | balrog | *value = ch->frame_index[0];
|
910 | c3d2689d | balrog | break;
|
911 | c3d2689d | balrog | |
912 | c3d2689d | balrog | case 0x16: /* SYS_DMA_CEI_CH0 */ |
913 | 11e0fc3f | balrog | *value = ch->element_index[0];
|
914 | 089b7c0a | balrog | break;
|
915 | 089b7c0a | balrog | |
916 | 089b7c0a | balrog | case 0x18: /* SYS_DMA_CPC_CH0 or DMA_CSAC */ |
917 | 11e0fc3f | balrog | if (ch->omap_3_1_compatible_disable)
|
918 | 11e0fc3f | balrog | *value = ch->active_set.src & 0xffff; /* CSAC */ |
919 | 089b7c0a | balrog | else
|
920 | 11e0fc3f | balrog | *value = ch->cpc; |
921 | 089b7c0a | balrog | break;
|
922 | 089b7c0a | balrog | |
923 | 089b7c0a | balrog | case 0x1a: /* DMA_CDAC */ |
924 | 11e0fc3f | balrog | *value = ch->active_set.dest & 0xffff; /* CDAC */ |
925 | 089b7c0a | balrog | break;
|
926 | 089b7c0a | balrog | |
927 | 089b7c0a | balrog | case 0x1c: /* DMA_CDEI */ |
928 | 11e0fc3f | balrog | *value = ch->element_index[1];
|
929 | 089b7c0a | balrog | break;
|
930 | 089b7c0a | balrog | |
931 | 089b7c0a | balrog | case 0x1e: /* DMA_CDFI */ |
932 | 11e0fc3f | balrog | *value = ch->frame_index[1];
|
933 | 089b7c0a | balrog | break;
|
934 | 089b7c0a | balrog | |
935 | 089b7c0a | balrog | case 0x20: /* DMA_COLOR_L */ |
936 | 11e0fc3f | balrog | *value = ch->color & 0xffff;
|
937 | 089b7c0a | balrog | break;
|
938 | 089b7c0a | balrog | |
939 | 089b7c0a | balrog | case 0x22: /* DMA_COLOR_U */ |
940 | 11e0fc3f | balrog | *value = ch->color >> 16;
|
941 | c3d2689d | balrog | break;
|
942 | c3d2689d | balrog | |
943 | 089b7c0a | balrog | case 0x24: /* DMA_CCR2 */ |
944 | 11e0fc3f | balrog | *value = (ch->bs << 2) |
|
945 | 11e0fc3f | balrog | (ch->transparent_copy << 1) |
|
946 | 11e0fc3f | balrog | ch->constant_fill; |
947 | 089b7c0a | balrog | break;
|
948 | 089b7c0a | balrog | |
949 | 089b7c0a | balrog | case 0x28: /* DMA_CLNK_CTRL */ |
950 | 11e0fc3f | balrog | *value = (ch->link_enabled << 15) |
|
951 | 11e0fc3f | balrog | (ch->link_next_ch & 0xf);
|
952 | 089b7c0a | balrog | break;
|
953 | 089b7c0a | balrog | |
954 | 089b7c0a | balrog | case 0x2a: /* DMA_LCH_CTRL */ |
955 | 11e0fc3f | balrog | *value = (ch->interleave_disabled << 15) |
|
956 | 11e0fc3f | balrog | ch->type; |
957 | c3d2689d | balrog | break;
|
958 | c3d2689d | balrog | |
959 | c3d2689d | balrog | default:
|
960 | c3d2689d | balrog | return 1; |
961 | c3d2689d | balrog | } |
962 | c3d2689d | balrog | return 0; |
963 | c3d2689d | balrog | } |
964 | c3d2689d | balrog | |
965 | c3d2689d | balrog | static int omap_dma_ch_reg_write(struct omap_dma_s *s, |
966 | 11e0fc3f | balrog | struct omap_dma_channel_s *ch, int reg, uint16_t value) |
967 | 089b7c0a | balrog | { |
968 | c3d2689d | balrog | switch (reg) {
|
969 | c3d2689d | balrog | case 0x00: /* SYS_DMA_CSDP_CH0 */ |
970 | 11e0fc3f | balrog | ch->burst[1] = (value & 0xc000) >> 14; |
971 | 11e0fc3f | balrog | ch->pack[1] = (value & 0x2000) >> 13; |
972 | 11e0fc3f | balrog | ch->port[1] = (enum omap_dma_port) ((value & 0x1e00) >> 9); |
973 | 11e0fc3f | balrog | ch->burst[0] = (value & 0x0180) >> 7; |
974 | 11e0fc3f | balrog | ch->pack[0] = (value & 0x0040) >> 6; |
975 | 11e0fc3f | balrog | ch->port[0] = (enum omap_dma_port) ((value & 0x003c) >> 2); |
976 | 11e0fc3f | balrog | ch->data_type = (1 << (value & 3)); |
977 | 11e0fc3f | balrog | if (ch->port[0] >= omap_dma_port_last) |
978 | c3d2689d | balrog | printf("%s: invalid DMA port %i\n", __FUNCTION__,
|
979 | 11e0fc3f | balrog | ch->port[0]);
|
980 | 11e0fc3f | balrog | if (ch->port[1] >= omap_dma_port_last) |
981 | c3d2689d | balrog | printf("%s: invalid DMA port %i\n", __FUNCTION__,
|
982 | 11e0fc3f | balrog | ch->port[1]);
|
983 | c3d2689d | balrog | if ((value & 3) == 3) |
984 | 11e0fc3f | balrog | printf("%s: bad data_type for DMA channel\n", __FUNCTION__);
|
985 | c3d2689d | balrog | break;
|
986 | c3d2689d | balrog | |
987 | c3d2689d | balrog | case 0x02: /* SYS_DMA_CCR_CH0 */ |
988 | 11e0fc3f | balrog | ch->mode[1] = (omap_dma_addressing_t) ((value & 0xc000) >> 14); |
989 | 11e0fc3f | balrog | ch->mode[0] = (omap_dma_addressing_t) ((value & 0x3000) >> 12); |
990 | 11e0fc3f | balrog | ch->end_prog = (value & 0x0800) >> 11; |
991 | 089b7c0a | balrog | if (s->model > omap_dma_3_1)
|
992 | 11e0fc3f | balrog | ch->omap_3_1_compatible_disable = (value >> 10) & 0x1; |
993 | 11e0fc3f | balrog | ch->repeat = (value & 0x0200) >> 9; |
994 | 11e0fc3f | balrog | ch->auto_init = (value & 0x0100) >> 8; |
995 | 11e0fc3f | balrog | ch->priority = (value & 0x0040) >> 6; |
996 | 11e0fc3f | balrog | ch->fs = (value & 0x0020) >> 5; |
997 | 11e0fc3f | balrog | ch->sync = value & 0x001f;
|
998 | 089b7c0a | balrog | |
999 | 089b7c0a | balrog | if (value & 0x0080) |
1000 | 089b7c0a | balrog | omap_dma_enable_channel(s, ch); |
1001 | 089b7c0a | balrog | else
|
1002 | 089b7c0a | balrog | omap_dma_disable_channel(s, ch); |
1003 | 089b7c0a | balrog | |
1004 | 11e0fc3f | balrog | if (ch->end_prog)
|
1005 | 089b7c0a | balrog | omap_dma_channel_end_prog(s, ch); |
1006 | 089b7c0a | balrog | |
1007 | c3d2689d | balrog | break;
|
1008 | c3d2689d | balrog | |
1009 | c3d2689d | balrog | case 0x04: /* SYS_DMA_CICR_CH0 */ |
1010 | 11e0fc3f | balrog | ch->interrupts = value; |
1011 | c3d2689d | balrog | break;
|
1012 | c3d2689d | balrog | |
1013 | c3d2689d | balrog | case 0x06: /* SYS_DMA_CSR_CH0 */ |
1014 | 11e0fc3f | balrog | OMAP_RO_REG((target_phys_addr_t) reg); |
1015 | 11e0fc3f | balrog | break;
|
1016 | c3d2689d | balrog | |
1017 | c3d2689d | balrog | case 0x08: /* SYS_DMA_CSSA_L_CH0 */ |
1018 | 11e0fc3f | balrog | ch->addr[0] &= 0xffff0000; |
1019 | 11e0fc3f | balrog | ch->addr[0] |= value;
|
1020 | c3d2689d | balrog | break;
|
1021 | c3d2689d | balrog | |
1022 | c3d2689d | balrog | case 0x0a: /* SYS_DMA_CSSA_U_CH0 */ |
1023 | 11e0fc3f | balrog | ch->addr[0] &= 0x0000ffff; |
1024 | 11e0fc3f | balrog | ch->addr[0] |= (uint32_t) value << 16; |
1025 | c3d2689d | balrog | break;
|
1026 | c3d2689d | balrog | |
1027 | c3d2689d | balrog | case 0x0c: /* SYS_DMA_CDSA_L_CH0 */ |
1028 | 11e0fc3f | balrog | ch->addr[1] &= 0xffff0000; |
1029 | 11e0fc3f | balrog | ch->addr[1] |= value;
|
1030 | c3d2689d | balrog | break;
|
1031 | c3d2689d | balrog | |
1032 | c3d2689d | balrog | case 0x0e: /* SYS_DMA_CDSA_U_CH0 */ |
1033 | 11e0fc3f | balrog | ch->addr[1] &= 0x0000ffff; |
1034 | 11e0fc3f | balrog | ch->addr[1] |= (uint32_t) value << 16; |
1035 | c3d2689d | balrog | break;
|
1036 | c3d2689d | balrog | |
1037 | c3d2689d | balrog | case 0x10: /* SYS_DMA_CEN_CH0 */ |
1038 | 11e0fc3f | balrog | ch->elements = value; |
1039 | c3d2689d | balrog | break;
|
1040 | c3d2689d | balrog | |
1041 | c3d2689d | balrog | case 0x12: /* SYS_DMA_CFN_CH0 */ |
1042 | 11e0fc3f | balrog | ch->frames = value; |
1043 | c3d2689d | balrog | break;
|
1044 | c3d2689d | balrog | |
1045 | c3d2689d | balrog | case 0x14: /* SYS_DMA_CFI_CH0 */ |
1046 | 11e0fc3f | balrog | ch->frame_index[0] = (int16_t) value;
|
1047 | c3d2689d | balrog | break;
|
1048 | c3d2689d | balrog | |
1049 | c3d2689d | balrog | case 0x16: /* SYS_DMA_CEI_CH0 */ |
1050 | 11e0fc3f | balrog | ch->element_index[0] = (int16_t) value;
|
1051 | c3d2689d | balrog | break;
|
1052 | c3d2689d | balrog | |
1053 | 089b7c0a | balrog | case 0x18: /* SYS_DMA_CPC_CH0 or DMA_CSAC */ |
1054 | 089b7c0a | balrog | OMAP_RO_REG((target_phys_addr_t) reg); |
1055 | 089b7c0a | balrog | break;
|
1056 | 089b7c0a | balrog | |
1057 | 089b7c0a | balrog | case 0x1c: /* DMA_CDEI */ |
1058 | 11e0fc3f | balrog | ch->element_index[1] = (int16_t) value;
|
1059 | 089b7c0a | balrog | break;
|
1060 | 089b7c0a | balrog | |
1061 | 089b7c0a | balrog | case 0x1e: /* DMA_CDFI */ |
1062 | 11e0fc3f | balrog | ch->frame_index[1] = (int16_t) value;
|
1063 | 089b7c0a | balrog | break;
|
1064 | 089b7c0a | balrog | |
1065 | 089b7c0a | balrog | case 0x20: /* DMA_COLOR_L */ |
1066 | 11e0fc3f | balrog | ch->color &= 0xffff0000;
|
1067 | 11e0fc3f | balrog | ch->color |= value; |
1068 | 089b7c0a | balrog | break;
|
1069 | 089b7c0a | balrog | |
1070 | 089b7c0a | balrog | case 0x22: /* DMA_COLOR_U */ |
1071 | 11e0fc3f | balrog | ch->color &= 0xffff;
|
1072 | 11e0fc3f | balrog | ch->color |= value << 16;
|
1073 | 089b7c0a | balrog | break;
|
1074 | 089b7c0a | balrog | |
1075 | 089b7c0a | balrog | case 0x24: /* DMA_CCR2 */ |
1076 | 11e0fc3f | balrog | ch->bs = (value >> 2) & 0x1; |
1077 | 11e0fc3f | balrog | ch->transparent_copy = (value >> 1) & 0x1; |
1078 | 11e0fc3f | balrog | ch->constant_fill = value & 0x1;
|
1079 | 089b7c0a | balrog | break;
|
1080 | 089b7c0a | balrog | |
1081 | 089b7c0a | balrog | case 0x28: /* DMA_CLNK_CTRL */ |
1082 | 11e0fc3f | balrog | ch->link_enabled = (value >> 15) & 0x1; |
1083 | 089b7c0a | balrog | if (value & (1 << 14)) { /* Stop_Lnk */ |
1084 | 11e0fc3f | balrog | ch->link_enabled = 0;
|
1085 | 089b7c0a | balrog | omap_dma_disable_channel(s, ch); |
1086 | 089b7c0a | balrog | } |
1087 | 11e0fc3f | balrog | ch->link_next_ch = value & 0x1f;
|
1088 | 089b7c0a | balrog | break;
|
1089 | 089b7c0a | balrog | |
1090 | 089b7c0a | balrog | case 0x2a: /* DMA_LCH_CTRL */ |
1091 | 11e0fc3f | balrog | ch->interleave_disabled = (value >> 15) & 0x1; |
1092 | 11e0fc3f | balrog | ch->type = value & 0xf;
|
1093 | 089b7c0a | balrog | break;
|
1094 | c3d2689d | balrog | |
1095 | c3d2689d | balrog | default:
|
1096 | 089b7c0a | balrog | return 1; |
1097 | c3d2689d | balrog | } |
1098 | c3d2689d | balrog | return 0; |
1099 | c3d2689d | balrog | } |
1100 | c3d2689d | balrog | |
1101 | 11e0fc3f | balrog | static int omap_dma_3_2_lcd_write(struct omap_dma_lcd_channel_s *s, int offset, |
1102 | 089b7c0a | balrog | uint16_t value) |
1103 | c3d2689d | balrog | { |
1104 | c3d2689d | balrog | switch (offset) {
|
1105 | 089b7c0a | balrog | case 0xbc0: /* DMA_LCD_CSDP */ |
1106 | 11e0fc3f | balrog | s->brust_f2 = (value >> 14) & 0x3; |
1107 | 11e0fc3f | balrog | s->pack_f2 = (value >> 13) & 0x1; |
1108 | 11e0fc3f | balrog | s->data_type_f2 = (1 << ((value >> 11) & 0x3)); |
1109 | 11e0fc3f | balrog | s->brust_f1 = (value >> 7) & 0x3; |
1110 | 11e0fc3f | balrog | s->pack_f1 = (value >> 6) & 0x1; |
1111 | 11e0fc3f | balrog | s->data_type_f1 = (1 << ((value >> 0) & 0x3)); |
1112 | 089b7c0a | balrog | break;
|
1113 | c3d2689d | balrog | |
1114 | 089b7c0a | balrog | case 0xbc2: /* DMA_LCD_CCR */ |
1115 | 11e0fc3f | balrog | s->mode_f2 = (value >> 14) & 0x3; |
1116 | 11e0fc3f | balrog | s->mode_f1 = (value >> 12) & 0x3; |
1117 | 11e0fc3f | balrog | s->end_prog = (value >> 11) & 0x1; |
1118 | 11e0fc3f | balrog | s->omap_3_1_compatible_disable = (value >> 10) & 0x1; |
1119 | 11e0fc3f | balrog | s->repeat = (value >> 9) & 0x1; |
1120 | 11e0fc3f | balrog | s->auto_init = (value >> 8) & 0x1; |
1121 | 11e0fc3f | balrog | s->running = (value >> 7) & 0x1; |
1122 | 11e0fc3f | balrog | s->priority = (value >> 6) & 0x1; |
1123 | 11e0fc3f | balrog | s->bs = (value >> 4) & 0x1; |
1124 | 089b7c0a | balrog | break;
|
1125 | 089b7c0a | balrog | |
1126 | 089b7c0a | balrog | case 0xbc4: /* DMA_LCD_CTRL */ |
1127 | 11e0fc3f | balrog | s->dst = (value >> 8) & 0x1; |
1128 | 11e0fc3f | balrog | s->src = ((value >> 6) & 0x3) << 1; |
1129 | 11e0fc3f | balrog | s->condition = 0;
|
1130 | 089b7c0a | balrog | /* Assume no bus errors and thus no BUS_ERROR irq bits. */
|
1131 | 11e0fc3f | balrog | s->interrupts = (value >> 1) & 1; |
1132 | 11e0fc3f | balrog | s->dual = value & 1;
|
1133 | 089b7c0a | balrog | break;
|
1134 | c3d2689d | balrog | |
1135 | 089b7c0a | balrog | case 0xbc8: /* TOP_B1_L */ |
1136 | 11e0fc3f | balrog | s->src_f1_top &= 0xffff0000;
|
1137 | 11e0fc3f | balrog | s->src_f1_top |= 0x0000ffff & value;
|
1138 | 089b7c0a | balrog | break;
|
1139 | c3d2689d | balrog | |
1140 | 089b7c0a | balrog | case 0xbca: /* TOP_B1_U */ |
1141 | 11e0fc3f | balrog | s->src_f1_top &= 0x0000ffff;
|
1142 | 11e0fc3f | balrog | s->src_f1_top |= value << 16;
|
1143 | 089b7c0a | balrog | break;
|
1144 | c3d2689d | balrog | |
1145 | 089b7c0a | balrog | case 0xbcc: /* BOT_B1_L */ |
1146 | 11e0fc3f | balrog | s->src_f1_bottom &= 0xffff0000;
|
1147 | 11e0fc3f | balrog | s->src_f1_bottom |= 0x0000ffff & value;
|
1148 | 089b7c0a | balrog | break;
|
1149 | c3d2689d | balrog | |
1150 | 089b7c0a | balrog | case 0xbce: /* BOT_B1_U */ |
1151 | 11e0fc3f | balrog | s->src_f1_bottom &= 0x0000ffff;
|
1152 | 11e0fc3f | balrog | s->src_f1_bottom |= (uint32_t) value << 16;
|
1153 | 089b7c0a | balrog | break;
|
1154 | c3d2689d | balrog | |
1155 | 089b7c0a | balrog | case 0xbd0: /* TOP_B2_L */ |
1156 | 11e0fc3f | balrog | s->src_f2_top &= 0xffff0000;
|
1157 | 11e0fc3f | balrog | s->src_f2_top |= 0x0000ffff & value;
|
1158 | 089b7c0a | balrog | break;
|
1159 | c3d2689d | balrog | |
1160 | 089b7c0a | balrog | case 0xbd2: /* TOP_B2_U */ |
1161 | 11e0fc3f | balrog | s->src_f2_top &= 0x0000ffff;
|
1162 | 11e0fc3f | balrog | s->src_f2_top |= (uint32_t) value << 16;
|
1163 | 089b7c0a | balrog | break;
|
1164 | c3d2689d | balrog | |
1165 | 089b7c0a | balrog | case 0xbd4: /* BOT_B2_L */ |
1166 | 11e0fc3f | balrog | s->src_f2_bottom &= 0xffff0000;
|
1167 | 11e0fc3f | balrog | s->src_f2_bottom |= 0x0000ffff & value;
|
1168 | 089b7c0a | balrog | break;
|
1169 | c3d2689d | balrog | |
1170 | 089b7c0a | balrog | case 0xbd6: /* BOT_B2_U */ |
1171 | 11e0fc3f | balrog | s->src_f2_bottom &= 0x0000ffff;
|
1172 | 11e0fc3f | balrog | s->src_f2_bottom |= (uint32_t) value << 16;
|
1173 | 089b7c0a | balrog | break;
|
1174 | c3d2689d | balrog | |
1175 | 089b7c0a | balrog | case 0xbd8: /* DMA_LCD_SRC_EI_B1 */ |
1176 | 11e0fc3f | balrog | s->element_index_f1 = value; |
1177 | 089b7c0a | balrog | break;
|
1178 | c3d2689d | balrog | |
1179 | 089b7c0a | balrog | case 0xbda: /* DMA_LCD_SRC_FI_B1_L */ |
1180 | 11e0fc3f | balrog | s->frame_index_f1 &= 0xffff0000;
|
1181 | 11e0fc3f | balrog | s->frame_index_f1 |= 0x0000ffff & value;
|
1182 | 089b7c0a | balrog | break;
|
1183 | 089b7c0a | balrog | |
1184 | 089b7c0a | balrog | case 0xbf4: /* DMA_LCD_SRC_FI_B1_U */ |
1185 | 11e0fc3f | balrog | s->frame_index_f1 &= 0x0000ffff;
|
1186 | 11e0fc3f | balrog | s->frame_index_f1 |= (uint32_t) value << 16;
|
1187 | 089b7c0a | balrog | break;
|
1188 | 089b7c0a | balrog | |
1189 | 089b7c0a | balrog | case 0xbdc: /* DMA_LCD_SRC_EI_B2 */ |
1190 | 11e0fc3f | balrog | s->element_index_f2 = value; |
1191 | 089b7c0a | balrog | break;
|
1192 | 089b7c0a | balrog | |
1193 | 089b7c0a | balrog | case 0xbde: /* DMA_LCD_SRC_FI_B2_L */ |
1194 | 11e0fc3f | balrog | s->frame_index_f2 &= 0xffff0000;
|
1195 | 11e0fc3f | balrog | s->frame_index_f2 |= 0x0000ffff & value;
|
1196 | 089b7c0a | balrog | break;
|
1197 | 089b7c0a | balrog | |
1198 | 089b7c0a | balrog | case 0xbf6: /* DMA_LCD_SRC_FI_B2_U */ |
1199 | 11e0fc3f | balrog | s->frame_index_f2 &= 0x0000ffff;
|
1200 | 11e0fc3f | balrog | s->frame_index_f2 |= (uint32_t) value << 16;
|
1201 | 089b7c0a | balrog | break;
|
1202 | 089b7c0a | balrog | |
1203 | 089b7c0a | balrog | case 0xbe0: /* DMA_LCD_SRC_EN_B1 */ |
1204 | 11e0fc3f | balrog | s->elements_f1 = value; |
1205 | 089b7c0a | balrog | break;
|
1206 | 089b7c0a | balrog | |
1207 | 089b7c0a | balrog | case 0xbe4: /* DMA_LCD_SRC_FN_B1 */ |
1208 | 11e0fc3f | balrog | s->frames_f1 = value; |
1209 | 089b7c0a | balrog | break;
|
1210 | 089b7c0a | balrog | |
1211 | 089b7c0a | balrog | case 0xbe2: /* DMA_LCD_SRC_EN_B2 */ |
1212 | 11e0fc3f | balrog | s->elements_f2 = value; |
1213 | 089b7c0a | balrog | break;
|
1214 | 089b7c0a | balrog | |
1215 | 089b7c0a | balrog | case 0xbe6: /* DMA_LCD_SRC_FN_B2 */ |
1216 | 11e0fc3f | balrog | s->frames_f2 = value; |
1217 | 089b7c0a | balrog | break;
|
1218 | 089b7c0a | balrog | |
1219 | 089b7c0a | balrog | case 0xbea: /* DMA_LCD_LCH_CTRL */ |
1220 | 11e0fc3f | balrog | s->lch_type = value & 0xf;
|
1221 | 089b7c0a | balrog | break;
|
1222 | 089b7c0a | balrog | |
1223 | 089b7c0a | balrog | default:
|
1224 | 089b7c0a | balrog | return 1; |
1225 | 089b7c0a | balrog | } |
1226 | c3d2689d | balrog | return 0; |
1227 | c3d2689d | balrog | } |
1228 | c3d2689d | balrog | |
1229 | 11e0fc3f | balrog | static int omap_dma_3_2_lcd_read(struct omap_dma_lcd_channel_s *s, int offset, |
1230 | 089b7c0a | balrog | uint16_t *ret) |
1231 | c3d2689d | balrog | { |
1232 | c3d2689d | balrog | switch (offset) {
|
1233 | 089b7c0a | balrog | case 0xbc0: /* DMA_LCD_CSDP */ |
1234 | 11e0fc3f | balrog | *ret = (s->brust_f2 << 14) |
|
1235 | 11e0fc3f | balrog | (s->pack_f2 << 13) |
|
1236 | 11e0fc3f | balrog | ((s->data_type_f2 >> 1) << 11) | |
1237 | 11e0fc3f | balrog | (s->brust_f1 << 7) |
|
1238 | 11e0fc3f | balrog | (s->pack_f1 << 6) |
|
1239 | 11e0fc3f | balrog | ((s->data_type_f1 >> 1) << 0); |
1240 | 089b7c0a | balrog | break;
|
1241 | 089b7c0a | balrog | |
1242 | 089b7c0a | balrog | case 0xbc2: /* DMA_LCD_CCR */ |
1243 | 11e0fc3f | balrog | *ret = (s->mode_f2 << 14) |
|
1244 | 11e0fc3f | balrog | (s->mode_f1 << 12) |
|
1245 | 11e0fc3f | balrog | (s->end_prog << 11) |
|
1246 | 11e0fc3f | balrog | (s->omap_3_1_compatible_disable << 10) |
|
1247 | 11e0fc3f | balrog | (s->repeat << 9) |
|
1248 | 11e0fc3f | balrog | (s->auto_init << 8) |
|
1249 | 11e0fc3f | balrog | (s->running << 7) |
|
1250 | 11e0fc3f | balrog | (s->priority << 6) |
|
1251 | 11e0fc3f | balrog | (s->bs << 4);
|
1252 | 089b7c0a | balrog | break;
|
1253 | 089b7c0a | balrog | |
1254 | 089b7c0a | balrog | case 0xbc4: /* DMA_LCD_CTRL */ |
1255 | 11e0fc3f | balrog | qemu_irq_lower(s->irq); |
1256 | 11e0fc3f | balrog | *ret = (s->dst << 8) |
|
1257 | 11e0fc3f | balrog | ((s->src & 0x6) << 5) | |
1258 | 11e0fc3f | balrog | (s->condition << 3) |
|
1259 | 11e0fc3f | balrog | (s->interrupts << 1) |
|
1260 | 11e0fc3f | balrog | s->dual; |
1261 | 089b7c0a | balrog | break;
|
1262 | 089b7c0a | balrog | |
1263 | 089b7c0a | balrog | case 0xbc8: /* TOP_B1_L */ |
1264 | 11e0fc3f | balrog | *ret = s->src_f1_top & 0xffff;
|
1265 | 089b7c0a | balrog | break;
|
1266 | 089b7c0a | balrog | |
1267 | 089b7c0a | balrog | case 0xbca: /* TOP_B1_U */ |
1268 | 11e0fc3f | balrog | *ret = s->src_f1_top >> 16;
|
1269 | 089b7c0a | balrog | break;
|
1270 | 089b7c0a | balrog | |
1271 | 089b7c0a | balrog | case 0xbcc: /* BOT_B1_L */ |
1272 | 11e0fc3f | balrog | *ret = s->src_f1_bottom & 0xffff;
|
1273 | 089b7c0a | balrog | break;
|
1274 | 089b7c0a | balrog | |
1275 | 089b7c0a | balrog | case 0xbce: /* BOT_B1_U */ |
1276 | 11e0fc3f | balrog | *ret = s->src_f1_bottom >> 16;
|
1277 | 089b7c0a | balrog | break;
|
1278 | 089b7c0a | balrog | |
1279 | 089b7c0a | balrog | case 0xbd0: /* TOP_B2_L */ |
1280 | 11e0fc3f | balrog | *ret = s->src_f2_top & 0xffff;
|
1281 | 089b7c0a | balrog | break;
|
1282 | 089b7c0a | balrog | |
1283 | 089b7c0a | balrog | case 0xbd2: /* TOP_B2_U */ |
1284 | 11e0fc3f | balrog | *ret = s->src_f2_top >> 16;
|
1285 | 089b7c0a | balrog | break;
|
1286 | 089b7c0a | balrog | |
1287 | 089b7c0a | balrog | case 0xbd4: /* BOT_B2_L */ |
1288 | 11e0fc3f | balrog | *ret = s->src_f2_bottom & 0xffff;
|
1289 | c3d2689d | balrog | break;
|
1290 | c3d2689d | balrog | |
1291 | 089b7c0a | balrog | case 0xbd6: /* BOT_B2_U */ |
1292 | 11e0fc3f | balrog | *ret = s->src_f2_bottom >> 16;
|
1293 | 089b7c0a | balrog | break;
|
1294 | 089b7c0a | balrog | |
1295 | 089b7c0a | balrog | case 0xbd8: /* DMA_LCD_SRC_EI_B1 */ |
1296 | 11e0fc3f | balrog | *ret = s->element_index_f1; |
1297 | 089b7c0a | balrog | break;
|
1298 | 089b7c0a | balrog | |
1299 | 089b7c0a | balrog | case 0xbda: /* DMA_LCD_SRC_FI_B1_L */ |
1300 | 11e0fc3f | balrog | *ret = s->frame_index_f1 & 0xffff;
|
1301 | 089b7c0a | balrog | break;
|
1302 | 089b7c0a | balrog | |
1303 | 089b7c0a | balrog | case 0xbf4: /* DMA_LCD_SRC_FI_B1_U */ |
1304 | 11e0fc3f | balrog | *ret = s->frame_index_f1 >> 16;
|
1305 | 089b7c0a | balrog | break;
|
1306 | 089b7c0a | balrog | |
1307 | 089b7c0a | balrog | case 0xbdc: /* DMA_LCD_SRC_EI_B2 */ |
1308 | 11e0fc3f | balrog | *ret = s->element_index_f2; |
1309 | 089b7c0a | balrog | break;
|
1310 | 089b7c0a | balrog | |
1311 | 089b7c0a | balrog | case 0xbde: /* DMA_LCD_SRC_FI_B2_L */ |
1312 | 11e0fc3f | balrog | *ret = s->frame_index_f2 & 0xffff;
|
1313 | 089b7c0a | balrog | break;
|
1314 | 089b7c0a | balrog | |
1315 | 089b7c0a | balrog | case 0xbf6: /* DMA_LCD_SRC_FI_B2_U */ |
1316 | 11e0fc3f | balrog | *ret = s->frame_index_f2 >> 16;
|
1317 | 089b7c0a | balrog | break;
|
1318 | 089b7c0a | balrog | |
1319 | 089b7c0a | balrog | case 0xbe0: /* DMA_LCD_SRC_EN_B1 */ |
1320 | 11e0fc3f | balrog | *ret = s->elements_f1; |
1321 | 089b7c0a | balrog | break;
|
1322 | 089b7c0a | balrog | |
1323 | 089b7c0a | balrog | case 0xbe4: /* DMA_LCD_SRC_FN_B1 */ |
1324 | 11e0fc3f | balrog | *ret = s->frames_f1; |
1325 | 089b7c0a | balrog | break;
|
1326 | 089b7c0a | balrog | |
1327 | 089b7c0a | balrog | case 0xbe2: /* DMA_LCD_SRC_EN_B2 */ |
1328 | 11e0fc3f | balrog | *ret = s->elements_f2; |
1329 | 089b7c0a | balrog | break;
|
1330 | 089b7c0a | balrog | |
1331 | 089b7c0a | balrog | case 0xbe6: /* DMA_LCD_SRC_FN_B2 */ |
1332 | 11e0fc3f | balrog | *ret = s->frames_f2; |
1333 | 089b7c0a | balrog | break;
|
1334 | 089b7c0a | balrog | |
1335 | 089b7c0a | balrog | case 0xbea: /* DMA_LCD_LCH_CTRL */ |
1336 | 11e0fc3f | balrog | *ret = s->lch_type; |
1337 | 089b7c0a | balrog | break;
|
1338 | 089b7c0a | balrog | |
1339 | 089b7c0a | balrog | default:
|
1340 | 089b7c0a | balrog | return 1; |
1341 | 089b7c0a | balrog | } |
1342 | 089b7c0a | balrog | return 0; |
1343 | 089b7c0a | balrog | } |
1344 | 089b7c0a | balrog | |
1345 | 11e0fc3f | balrog | static int omap_dma_3_1_lcd_write(struct omap_dma_lcd_channel_s *s, int offset, |
1346 | 089b7c0a | balrog | uint16_t value) |
1347 | 089b7c0a | balrog | { |
1348 | 089b7c0a | balrog | switch (offset) {
|
1349 | c3d2689d | balrog | case 0x300: /* SYS_DMA_LCD_CTRL */ |
1350 | 11e0fc3f | balrog | s->src = (value & 0x40) ? imif : emiff;
|
1351 | 11e0fc3f | balrog | s->condition = 0;
|
1352 | c3d2689d | balrog | /* Assume no bus errors and thus no BUS_ERROR irq bits. */
|
1353 | 11e0fc3f | balrog | s->interrupts = (value >> 1) & 1; |
1354 | 11e0fc3f | balrog | s->dual = value & 1;
|
1355 | c3d2689d | balrog | break;
|
1356 | c3d2689d | balrog | |
1357 | c3d2689d | balrog | case 0x302: /* SYS_DMA_LCD_TOP_F1_L */ |
1358 | 11e0fc3f | balrog | s->src_f1_top &= 0xffff0000;
|
1359 | 11e0fc3f | balrog | s->src_f1_top |= 0x0000ffff & value;
|
1360 | c3d2689d | balrog | break;
|
1361 | c3d2689d | balrog | |
1362 | c3d2689d | balrog | case 0x304: /* SYS_DMA_LCD_TOP_F1_U */ |
1363 | 11e0fc3f | balrog | s->src_f1_top &= 0x0000ffff;
|
1364 | 11e0fc3f | balrog | s->src_f1_top |= value << 16;
|
1365 | c3d2689d | balrog | break;
|
1366 | c3d2689d | balrog | |
1367 | c3d2689d | balrog | case 0x306: /* SYS_DMA_LCD_BOT_F1_L */ |
1368 | 11e0fc3f | balrog | s->src_f1_bottom &= 0xffff0000;
|
1369 | 11e0fc3f | balrog | s->src_f1_bottom |= 0x0000ffff & value;
|
1370 | c3d2689d | balrog | break;
|
1371 | c3d2689d | balrog | |
1372 | c3d2689d | balrog | case 0x308: /* SYS_DMA_LCD_BOT_F1_U */ |
1373 | 11e0fc3f | balrog | s->src_f1_bottom &= 0x0000ffff;
|
1374 | 11e0fc3f | balrog | s->src_f1_bottom |= value << 16;
|
1375 | c3d2689d | balrog | break;
|
1376 | c3d2689d | balrog | |
1377 | c3d2689d | balrog | case 0x30a: /* SYS_DMA_LCD_TOP_F2_L */ |
1378 | 11e0fc3f | balrog | s->src_f2_top &= 0xffff0000;
|
1379 | 11e0fc3f | balrog | s->src_f2_top |= 0x0000ffff & value;
|
1380 | c3d2689d | balrog | break;
|
1381 | c3d2689d | balrog | |
1382 | c3d2689d | balrog | case 0x30c: /* SYS_DMA_LCD_TOP_F2_U */ |
1383 | 11e0fc3f | balrog | s->src_f2_top &= 0x0000ffff;
|
1384 | 11e0fc3f | balrog | s->src_f2_top |= value << 16;
|
1385 | c3d2689d | balrog | break;
|
1386 | c3d2689d | balrog | |
1387 | c3d2689d | balrog | case 0x30e: /* SYS_DMA_LCD_BOT_F2_L */ |
1388 | 11e0fc3f | balrog | s->src_f2_bottom &= 0xffff0000;
|
1389 | 11e0fc3f | balrog | s->src_f2_bottom |= 0x0000ffff & value;
|
1390 | c3d2689d | balrog | break;
|
1391 | c3d2689d | balrog | |
1392 | c3d2689d | balrog | case 0x310: /* SYS_DMA_LCD_BOT_F2_U */ |
1393 | 11e0fc3f | balrog | s->src_f2_bottom &= 0x0000ffff;
|
1394 | 11e0fc3f | balrog | s->src_f2_bottom |= value << 16;
|
1395 | c3d2689d | balrog | break;
|
1396 | c3d2689d | balrog | |
1397 | 089b7c0a | balrog | default:
|
1398 | 089b7c0a | balrog | return 1; |
1399 | 089b7c0a | balrog | } |
1400 | 089b7c0a | balrog | return 0; |
1401 | 089b7c0a | balrog | } |
1402 | 089b7c0a | balrog | |
1403 | 11e0fc3f | balrog | static int omap_dma_3_1_lcd_read(struct omap_dma_lcd_channel_s *s, int offset, |
1404 | 089b7c0a | balrog | uint16_t *ret) |
1405 | 089b7c0a | balrog | { |
1406 | 089b7c0a | balrog | int i;
|
1407 | 089b7c0a | balrog | |
1408 | 089b7c0a | balrog | switch (offset) {
|
1409 | 089b7c0a | balrog | case 0x300: /* SYS_DMA_LCD_CTRL */ |
1410 | 11e0fc3f | balrog | i = s->condition; |
1411 | 11e0fc3f | balrog | s->condition = 0;
|
1412 | 11e0fc3f | balrog | qemu_irq_lower(s->irq); |
1413 | 11e0fc3f | balrog | *ret = ((s->src == imif) << 6) | (i << 3) | |
1414 | 11e0fc3f | balrog | (s->interrupts << 1) | s->dual;
|
1415 | 089b7c0a | balrog | break;
|
1416 | 089b7c0a | balrog | |
1417 | 089b7c0a | balrog | case 0x302: /* SYS_DMA_LCD_TOP_F1_L */ |
1418 | 11e0fc3f | balrog | *ret = s->src_f1_top & 0xffff;
|
1419 | 089b7c0a | balrog | break;
|
1420 | 089b7c0a | balrog | |
1421 | 089b7c0a | balrog | case 0x304: /* SYS_DMA_LCD_TOP_F1_U */ |
1422 | 11e0fc3f | balrog | *ret = s->src_f1_top >> 16;
|
1423 | 089b7c0a | balrog | break;
|
1424 | 089b7c0a | balrog | |
1425 | 089b7c0a | balrog | case 0x306: /* SYS_DMA_LCD_BOT_F1_L */ |
1426 | 11e0fc3f | balrog | *ret = s->src_f1_bottom & 0xffff;
|
1427 | 089b7c0a | balrog | break;
|
1428 | 089b7c0a | balrog | |
1429 | 089b7c0a | balrog | case 0x308: /* SYS_DMA_LCD_BOT_F1_U */ |
1430 | 11e0fc3f | balrog | *ret = s->src_f1_bottom >> 16;
|
1431 | 089b7c0a | balrog | break;
|
1432 | 089b7c0a | balrog | |
1433 | 089b7c0a | balrog | case 0x30a: /* SYS_DMA_LCD_TOP_F2_L */ |
1434 | 11e0fc3f | balrog | *ret = s->src_f2_top & 0xffff;
|
1435 | 089b7c0a | balrog | break;
|
1436 | 089b7c0a | balrog | |
1437 | 089b7c0a | balrog | case 0x30c: /* SYS_DMA_LCD_TOP_F2_U */ |
1438 | 11e0fc3f | balrog | *ret = s->src_f2_top >> 16;
|
1439 | 089b7c0a | balrog | break;
|
1440 | 089b7c0a | balrog | |
1441 | 089b7c0a | balrog | case 0x30e: /* SYS_DMA_LCD_BOT_F2_L */ |
1442 | 11e0fc3f | balrog | *ret = s->src_f2_bottom & 0xffff;
|
1443 | 089b7c0a | balrog | break;
|
1444 | 089b7c0a | balrog | |
1445 | 089b7c0a | balrog | case 0x310: /* SYS_DMA_LCD_BOT_F2_U */ |
1446 | 11e0fc3f | balrog | *ret = s->src_f2_bottom >> 16;
|
1447 | 089b7c0a | balrog | break;
|
1448 | 089b7c0a | balrog | |
1449 | 089b7c0a | balrog | default:
|
1450 | 089b7c0a | balrog | return 1; |
1451 | 089b7c0a | balrog | } |
1452 | 089b7c0a | balrog | return 0; |
1453 | 089b7c0a | balrog | } |
1454 | 089b7c0a | balrog | |
1455 | 089b7c0a | balrog | static int omap_dma_sys_write(struct omap_dma_s *s, int offset, uint16_t value) |
1456 | 089b7c0a | balrog | { |
1457 | 089b7c0a | balrog | switch (offset) {
|
1458 | c3d2689d | balrog | case 0x400: /* SYS_DMA_GCR */ |
1459 | 089b7c0a | balrog | s->gcr = value; |
1460 | 089b7c0a | balrog | break;
|
1461 | 089b7c0a | balrog | |
1462 | 089b7c0a | balrog | case 0x404: /* DMA_GSCR */ |
1463 | 089b7c0a | balrog | if (value & 0x8) |
1464 | 089b7c0a | balrog | omap_dma_disable_3_1_mapping(s); |
1465 | 089b7c0a | balrog | else
|
1466 | 089b7c0a | balrog | omap_dma_enable_3_1_mapping(s); |
1467 | 089b7c0a | balrog | break;
|
1468 | 089b7c0a | balrog | |
1469 | 089b7c0a | balrog | case 0x408: /* DMA_GRST */ |
1470 | 089b7c0a | balrog | if (value & 0x1) |
1471 | 089b7c0a | balrog | omap_dma_reset(s); |
1472 | c3d2689d | balrog | break;
|
1473 | c3d2689d | balrog | |
1474 | c3d2689d | balrog | default:
|
1475 | 089b7c0a | balrog | return 1; |
1476 | c3d2689d | balrog | } |
1477 | 089b7c0a | balrog | return 0; |
1478 | 089b7c0a | balrog | } |
1479 | 089b7c0a | balrog | |
1480 | 089b7c0a | balrog | static int omap_dma_sys_read(struct omap_dma_s *s, int offset, |
1481 | 089b7c0a | balrog | uint16_t *ret) |
1482 | 089b7c0a | balrog | { |
1483 | 089b7c0a | balrog | switch (offset) {
|
1484 | 089b7c0a | balrog | case 0x400: /* SYS_DMA_GCR */ |
1485 | 089b7c0a | balrog | *ret = s->gcr; |
1486 | 089b7c0a | balrog | break;
|
1487 | 089b7c0a | balrog | |
1488 | 089b7c0a | balrog | case 0x404: /* DMA_GSCR */ |
1489 | 089b7c0a | balrog | *ret = s->omap_3_1_mapping_disabled << 3;
|
1490 | 089b7c0a | balrog | break;
|
1491 | 089b7c0a | balrog | |
1492 | 089b7c0a | balrog | case 0x408: /* DMA_GRST */ |
1493 | 089b7c0a | balrog | *ret = 0;
|
1494 | 089b7c0a | balrog | break;
|
1495 | 089b7c0a | balrog | |
1496 | 089b7c0a | balrog | case 0x442: /* DMA_HW_ID */ |
1497 | 089b7c0a | balrog | case 0x444: /* DMA_PCh2_ID */ |
1498 | 089b7c0a | balrog | case 0x446: /* DMA_PCh0_ID */ |
1499 | 089b7c0a | balrog | case 0x448: /* DMA_PCh1_ID */ |
1500 | 089b7c0a | balrog | case 0x44a: /* DMA_PChG_ID */ |
1501 | 089b7c0a | balrog | case 0x44c: /* DMA_PChD_ID */ |
1502 | 089b7c0a | balrog | *ret = 1;
|
1503 | 089b7c0a | balrog | break;
|
1504 | 089b7c0a | balrog | |
1505 | 089b7c0a | balrog | case 0x44e: /* DMA_CAPS_0_U */ |
1506 | 089b7c0a | balrog | *ret = (1 << 3) | /* Constant Fill Capacity */ |
1507 | 089b7c0a | balrog | (1 << 2); /* Transparent BLT Capacity */ |
1508 | 089b7c0a | balrog | break;
|
1509 | 089b7c0a | balrog | |
1510 | 089b7c0a | balrog | case 0x450: /* DMA_CAPS_0_L */ |
1511 | 089b7c0a | balrog | case 0x452: /* DMA_CAPS_1_U */ |
1512 | 089b7c0a | balrog | *ret = 0;
|
1513 | 089b7c0a | balrog | break;
|
1514 | 089b7c0a | balrog | |
1515 | 089b7c0a | balrog | case 0x454: /* DMA_CAPS_1_L */ |
1516 | 089b7c0a | balrog | *ret = (1 << 1); /* 1-bit palletized capability */ |
1517 | 089b7c0a | balrog | break;
|
1518 | 089b7c0a | balrog | |
1519 | 089b7c0a | balrog | case 0x456: /* DMA_CAPS_2 */ |
1520 | 089b7c0a | balrog | *ret = (1 << 8) | /* SSDIC */ |
1521 | 089b7c0a | balrog | (1 << 7) | /* DDIAC */ |
1522 | 089b7c0a | balrog | (1 << 6) | /* DSIAC */ |
1523 | 089b7c0a | balrog | (1 << 5) | /* DPIAC */ |
1524 | 089b7c0a | balrog | (1 << 4) | /* DCAC */ |
1525 | 089b7c0a | balrog | (1 << 3) | /* SDIAC */ |
1526 | 089b7c0a | balrog | (1 << 2) | /* SSIAC */ |
1527 | 089b7c0a | balrog | (1 << 1) | /* SPIAC */ |
1528 | 089b7c0a | balrog | 1; /* SCAC */ |
1529 | 089b7c0a | balrog | break;
|
1530 | 089b7c0a | balrog | |
1531 | 089b7c0a | balrog | case 0x458: /* DMA_CAPS_3 */ |
1532 | 089b7c0a | balrog | *ret = (1 << 5) | /* CCC */ |
1533 | 089b7c0a | balrog | (1 << 4) | /* IC */ |
1534 | 089b7c0a | balrog | (1 << 3) | /* ARC */ |
1535 | 089b7c0a | balrog | (1 << 2) | /* AEC */ |
1536 | 089b7c0a | balrog | (1 << 1) | /* FSC */ |
1537 | 089b7c0a | balrog | 1; /* ESC */ |
1538 | 089b7c0a | balrog | break;
|
1539 | 089b7c0a | balrog | |
1540 | 089b7c0a | balrog | case 0x45a: /* DMA_CAPS_4 */ |
1541 | 089b7c0a | balrog | *ret = (1 << 6) | /* SSC */ |
1542 | 089b7c0a | balrog | (1 << 5) | /* BIC */ |
1543 | 089b7c0a | balrog | (1 << 4) | /* LFIC */ |
1544 | 089b7c0a | balrog | (1 << 3) | /* FIC */ |
1545 | 089b7c0a | balrog | (1 << 2) | /* HFIC */ |
1546 | 089b7c0a | balrog | (1 << 1) | /* EDIC */ |
1547 | 089b7c0a | balrog | 1; /* TOIC */ |
1548 | 089b7c0a | balrog | break;
|
1549 | 089b7c0a | balrog | |
1550 | 089b7c0a | balrog | case 0x460: /* DMA_PCh2_SR */ |
1551 | 089b7c0a | balrog | case 0x480: /* DMA_PCh0_SR */ |
1552 | 089b7c0a | balrog | case 0x482: /* DMA_PCh1_SR */ |
1553 | 089b7c0a | balrog | case 0x4c0: /* DMA_PChD_SR_0 */ |
1554 | 089b7c0a | balrog | printf("%s: Physical Channel Status Registers not implemented.\n",
|
1555 | 089b7c0a | balrog | __FUNCTION__); |
1556 | 089b7c0a | balrog | *ret = 0xff;
|
1557 | 089b7c0a | balrog | break;
|
1558 | 089b7c0a | balrog | |
1559 | 089b7c0a | balrog | default:
|
1560 | 089b7c0a | balrog | return 1; |
1561 | 089b7c0a | balrog | } |
1562 | 089b7c0a | balrog | return 0; |
1563 | 089b7c0a | balrog | } |
1564 | 089b7c0a | balrog | |
1565 | 089b7c0a | balrog | static uint32_t omap_dma_read(void *opaque, target_phys_addr_t addr) |
1566 | 089b7c0a | balrog | { |
1567 | 089b7c0a | balrog | struct omap_dma_s *s = (struct omap_dma_s *) opaque; |
1568 | 089b7c0a | balrog | int reg, ch, offset = addr - s->base;
|
1569 | 089b7c0a | balrog | uint16_t ret; |
1570 | 089b7c0a | balrog | |
1571 | 089b7c0a | balrog | switch (offset) {
|
1572 | 089b7c0a | balrog | case 0x300 ... 0x3fe: |
1573 | 089b7c0a | balrog | if (s->model == omap_dma_3_1 || !s->omap_3_1_mapping_disabled) {
|
1574 | 11e0fc3f | balrog | if (omap_dma_3_1_lcd_read(&s->lcd_ch, offset, &ret))
|
1575 | 089b7c0a | balrog | break;
|
1576 | 089b7c0a | balrog | return ret;
|
1577 | 089b7c0a | balrog | } |
1578 | 089b7c0a | balrog | /* Fall through. */
|
1579 | 089b7c0a | balrog | case 0x000 ... 0x2fe: |
1580 | 089b7c0a | balrog | reg = offset & 0x3f;
|
1581 | 089b7c0a | balrog | ch = (offset >> 6) & 0x0f; |
1582 | 11e0fc3f | balrog | if (omap_dma_ch_reg_read(s, &s->ch[ch], reg, &ret))
|
1583 | 089b7c0a | balrog | break;
|
1584 | 089b7c0a | balrog | return ret;
|
1585 | 089b7c0a | balrog | |
1586 | 089b7c0a | balrog | case 0x404 ... 0x4fe: |
1587 | 089b7c0a | balrog | if (s->model == omap_dma_3_1)
|
1588 | 089b7c0a | balrog | break;
|
1589 | 089b7c0a | balrog | /* Fall through. */
|
1590 | 089b7c0a | balrog | case 0x400: |
1591 | 089b7c0a | balrog | if (omap_dma_sys_read(s, offset, &ret))
|
1592 | 089b7c0a | balrog | break;
|
1593 | 089b7c0a | balrog | return ret;
|
1594 | 089b7c0a | balrog | |
1595 | 089b7c0a | balrog | case 0xb00 ... 0xbfe: |
1596 | 089b7c0a | balrog | if (s->model == omap_dma_3_2 && s->omap_3_1_mapping_disabled) {
|
1597 | 11e0fc3f | balrog | if (omap_dma_3_2_lcd_read(&s->lcd_ch, offset, &ret))
|
1598 | 089b7c0a | balrog | break;
|
1599 | 089b7c0a | balrog | return ret;
|
1600 | 089b7c0a | balrog | } |
1601 | 089b7c0a | balrog | break;
|
1602 | 089b7c0a | balrog | } |
1603 | 089b7c0a | balrog | |
1604 | 089b7c0a | balrog | OMAP_BAD_REG(addr); |
1605 | 089b7c0a | balrog | return 0; |
1606 | 089b7c0a | balrog | } |
1607 | 089b7c0a | balrog | |
1608 | 089b7c0a | balrog | static void omap_dma_write(void *opaque, target_phys_addr_t addr, |
1609 | 089b7c0a | balrog | uint32_t value) |
1610 | 089b7c0a | balrog | { |
1611 | 089b7c0a | balrog | struct omap_dma_s *s = (struct omap_dma_s *) opaque; |
1612 | 089b7c0a | balrog | int reg, ch, offset = addr - s->base;
|
1613 | 089b7c0a | balrog | |
1614 | 089b7c0a | balrog | switch (offset) {
|
1615 | 089b7c0a | balrog | case 0x300 ... 0x3fe: |
1616 | 089b7c0a | balrog | if (s->model == omap_dma_3_1 || !s->omap_3_1_mapping_disabled) {
|
1617 | 11e0fc3f | balrog | if (omap_dma_3_1_lcd_write(&s->lcd_ch, offset, value))
|
1618 | 089b7c0a | balrog | break;
|
1619 | 089b7c0a | balrog | return;
|
1620 | 089b7c0a | balrog | } |
1621 | 089b7c0a | balrog | /* Fall through. */
|
1622 | 089b7c0a | balrog | case 0x000 ... 0x2fe: |
1623 | 089b7c0a | balrog | reg = offset & 0x3f;
|
1624 | 089b7c0a | balrog | ch = (offset >> 6) & 0x0f; |
1625 | 11e0fc3f | balrog | if (omap_dma_ch_reg_write(s, &s->ch[ch], reg, value))
|
1626 | 089b7c0a | balrog | break;
|
1627 | 089b7c0a | balrog | return;
|
1628 | 089b7c0a | balrog | |
1629 | 089b7c0a | balrog | case 0x404 ... 0x4fe: |
1630 | 089b7c0a | balrog | if (s->model == omap_dma_3_1)
|
1631 | 089b7c0a | balrog | break;
|
1632 | 089b7c0a | balrog | case 0x400: |
1633 | 089b7c0a | balrog | /* Fall through. */
|
1634 | 089b7c0a | balrog | if (omap_dma_sys_write(s, offset, value))
|
1635 | 089b7c0a | balrog | break;
|
1636 | 089b7c0a | balrog | return;
|
1637 | 089b7c0a | balrog | |
1638 | 089b7c0a | balrog | case 0xb00 ... 0xbfe: |
1639 | 089b7c0a | balrog | if (s->model == omap_dma_3_2 && s->omap_3_1_mapping_disabled) {
|
1640 | 11e0fc3f | balrog | if (omap_dma_3_2_lcd_write(&s->lcd_ch, offset, value))
|
1641 | 089b7c0a | balrog | break;
|
1642 | 089b7c0a | balrog | return;
|
1643 | 089b7c0a | balrog | } |
1644 | 089b7c0a | balrog | break;
|
1645 | 089b7c0a | balrog | } |
1646 | 089b7c0a | balrog | |
1647 | 089b7c0a | balrog | OMAP_BAD_REG(addr); |
1648 | c3d2689d | balrog | } |
1649 | c3d2689d | balrog | |
1650 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_dma_readfn[] = {
|
1651 | c3d2689d | balrog | omap_badwidth_read16, |
1652 | c3d2689d | balrog | omap_dma_read, |
1653 | c3d2689d | balrog | omap_badwidth_read16, |
1654 | c3d2689d | balrog | }; |
1655 | c3d2689d | balrog | |
1656 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_dma_writefn[] = {
|
1657 | c3d2689d | balrog | omap_badwidth_write16, |
1658 | c3d2689d | balrog | omap_dma_write, |
1659 | c3d2689d | balrog | omap_badwidth_write16, |
1660 | c3d2689d | balrog | }; |
1661 | c3d2689d | balrog | |
1662 | c3d2689d | balrog | static void omap_dma_request(void *opaque, int drq, int req) |
1663 | c3d2689d | balrog | { |
1664 | c3d2689d | balrog | struct omap_dma_s *s = (struct omap_dma_s *) opaque; |
1665 | 1af2b62d | balrog | /* The request pins are level triggered. */
|
1666 | 1af2b62d | balrog | if (req) {
|
1667 | 1af2b62d | balrog | if (~s->drq & (1 << drq)) { |
1668 | 1af2b62d | balrog | s->drq |= 1 << drq;
|
1669 | 089b7c0a | balrog | omap_dma_process_request(s, drq); |
1670 | 1af2b62d | balrog | } |
1671 | 1af2b62d | balrog | } else
|
1672 | 1af2b62d | balrog | s->drq &= ~(1 << drq);
|
1673 | c3d2689d | balrog | } |
1674 | c3d2689d | balrog | |
1675 | c3d2689d | balrog | static void omap_dma_clk_update(void *opaque, int line, int on) |
1676 | c3d2689d | balrog | { |
1677 | c3d2689d | balrog | struct omap_dma_s *s = (struct omap_dma_s *) opaque; |
1678 | c3d2689d | balrog | |
1679 | c3d2689d | balrog | if (on) {
|
1680 | 73560bc8 | balrog | /* TODO: make a clever calculation */
|
1681 | 73560bc8 | balrog | s->delay = ticks_per_sec >> 8;
|
1682 | c3d2689d | balrog | if (s->run_count)
|
1683 | c3d2689d | balrog | qemu_mod_timer(s->tm, qemu_get_clock(vm_clock) + s->delay); |
1684 | c3d2689d | balrog | } else {
|
1685 | c3d2689d | balrog | s->delay = 0;
|
1686 | c3d2689d | balrog | qemu_del_timer(s->tm); |
1687 | c3d2689d | balrog | } |
1688 | c3d2689d | balrog | } |
1689 | c3d2689d | balrog | |
1690 | 089b7c0a | balrog | struct omap_dma_s *omap_dma_init(target_phys_addr_t base, qemu_irq *irqs,
|
1691 | 089b7c0a | balrog | qemu_irq lcd_irq, struct omap_mpu_state_s *mpu, omap_clk clk,
|
1692 | 089b7c0a | balrog | enum omap_dma_model model)
|
1693 | c3d2689d | balrog | { |
1694 | 11e0fc3f | balrog | int iomemtype, num_irqs, memsize, i;
|
1695 | c3d2689d | balrog | struct omap_dma_s *s = (struct omap_dma_s *) |
1696 | c3d2689d | balrog | qemu_mallocz(sizeof(struct omap_dma_s)); |
1697 | c3d2689d | balrog | |
1698 | 089b7c0a | balrog | if (model == omap_dma_3_1) {
|
1699 | 089b7c0a | balrog | num_irqs = 6;
|
1700 | 089b7c0a | balrog | memsize = 0x800;
|
1701 | 089b7c0a | balrog | } else {
|
1702 | 089b7c0a | balrog | num_irqs = 16;
|
1703 | 089b7c0a | balrog | memsize = 0xc00;
|
1704 | 089b7c0a | balrog | } |
1705 | c3d2689d | balrog | s->base = base; |
1706 | 089b7c0a | balrog | s->model = model; |
1707 | c3d2689d | balrog | s->mpu = mpu; |
1708 | c3d2689d | balrog | s->clk = clk; |
1709 | 089b7c0a | balrog | s->lcd_ch.irq = lcd_irq; |
1710 | c3d2689d | balrog | s->lcd_ch.mpu = mpu; |
1711 | 11e0fc3f | balrog | while (num_irqs --)
|
1712 | 11e0fc3f | balrog | s->ch[num_irqs].irq = irqs[num_irqs]; |
1713 | 11e0fc3f | balrog | for (i = 0; i < 3; i ++) { |
1714 | 11e0fc3f | balrog | s->ch[i].sibling = &s->ch[i + 6];
|
1715 | 11e0fc3f | balrog | s->ch[i + 6].sibling = &s->ch[i];
|
1716 | 11e0fc3f | balrog | } |
1717 | c3d2689d | balrog | s->tm = qemu_new_timer(vm_clock, (QEMUTimerCB *) omap_dma_channel_run, s); |
1718 | c3d2689d | balrog | omap_clk_adduser(s->clk, qemu_allocate_irqs(omap_dma_clk_update, s, 1)[0]); |
1719 | c3d2689d | balrog | mpu->drq = qemu_allocate_irqs(omap_dma_request, s, 32);
|
1720 | c3d2689d | balrog | omap_dma_reset(s); |
1721 | 1af2b62d | balrog | omap_dma_clk_update(s, 0, 1); |
1722 | c3d2689d | balrog | |
1723 | c3d2689d | balrog | iomemtype = cpu_register_io_memory(0, omap_dma_readfn,
|
1724 | c3d2689d | balrog | omap_dma_writefn, s); |
1725 | 089b7c0a | balrog | cpu_register_physical_memory(s->base, memsize, iomemtype); |
1726 | c3d2689d | balrog | |
1727 | c3d2689d | balrog | return s;
|
1728 | c3d2689d | balrog | } |
1729 | c3d2689d | balrog | |
1730 | c3d2689d | balrog | /* DMA ports */
|
1731 | b854bc19 | balrog | static int omap_validate_emiff_addr(struct omap_mpu_state_s *s, |
1732 | c3d2689d | balrog | target_phys_addr_t addr) |
1733 | c3d2689d | balrog | { |
1734 | c3d2689d | balrog | return addr >= OMAP_EMIFF_BASE && addr < OMAP_EMIFF_BASE + s->sdram_size;
|
1735 | c3d2689d | balrog | } |
1736 | c3d2689d | balrog | |
1737 | b854bc19 | balrog | static int omap_validate_emifs_addr(struct omap_mpu_state_s *s, |
1738 | c3d2689d | balrog | target_phys_addr_t addr) |
1739 | c3d2689d | balrog | { |
1740 | c3d2689d | balrog | return addr >= OMAP_EMIFS_BASE && addr < OMAP_EMIFF_BASE;
|
1741 | c3d2689d | balrog | } |
1742 | c3d2689d | balrog | |
1743 | b854bc19 | balrog | static int omap_validate_imif_addr(struct omap_mpu_state_s *s, |
1744 | c3d2689d | balrog | target_phys_addr_t addr) |
1745 | c3d2689d | balrog | { |
1746 | c3d2689d | balrog | return addr >= OMAP_IMIF_BASE && addr < OMAP_IMIF_BASE + s->sram_size;
|
1747 | c3d2689d | balrog | } |
1748 | c3d2689d | balrog | |
1749 | b854bc19 | balrog | static int omap_validate_tipb_addr(struct omap_mpu_state_s *s, |
1750 | c3d2689d | balrog | target_phys_addr_t addr) |
1751 | c3d2689d | balrog | { |
1752 | c3d2689d | balrog | return addr >= 0xfffb0000 && addr < 0xffff0000; |
1753 | c3d2689d | balrog | } |
1754 | c3d2689d | balrog | |
1755 | b854bc19 | balrog | static int omap_validate_local_addr(struct omap_mpu_state_s *s, |
1756 | c3d2689d | balrog | target_phys_addr_t addr) |
1757 | c3d2689d | balrog | { |
1758 | c3d2689d | balrog | return addr >= OMAP_LOCALBUS_BASE && addr < OMAP_LOCALBUS_BASE + 0x1000000; |
1759 | c3d2689d | balrog | } |
1760 | c3d2689d | balrog | |
1761 | b854bc19 | balrog | static int omap_validate_tipb_mpui_addr(struct omap_mpu_state_s *s, |
1762 | c3d2689d | balrog | target_phys_addr_t addr) |
1763 | c3d2689d | balrog | { |
1764 | c3d2689d | balrog | return addr >= 0xe1010000 && addr < 0xe1020004; |
1765 | c3d2689d | balrog | } |
1766 | c3d2689d | balrog | |
1767 | c3d2689d | balrog | /* MPU OS timers */
|
1768 | c3d2689d | balrog | struct omap_mpu_timer_s {
|
1769 | c3d2689d | balrog | qemu_irq irq; |
1770 | c3d2689d | balrog | omap_clk clk; |
1771 | c3d2689d | balrog | target_phys_addr_t base; |
1772 | c3d2689d | balrog | uint32_t val; |
1773 | c3d2689d | balrog | int64_t time; |
1774 | c3d2689d | balrog | QEMUTimer *timer; |
1775 | c3d2689d | balrog | int64_t rate; |
1776 | c3d2689d | balrog | int it_ena;
|
1777 | c3d2689d | balrog | |
1778 | c3d2689d | balrog | int enable;
|
1779 | c3d2689d | balrog | int ptv;
|
1780 | c3d2689d | balrog | int ar;
|
1781 | c3d2689d | balrog | int st;
|
1782 | c3d2689d | balrog | uint32_t reset_val; |
1783 | c3d2689d | balrog | }; |
1784 | c3d2689d | balrog | |
1785 | c3d2689d | balrog | static inline uint32_t omap_timer_read(struct omap_mpu_timer_s *timer) |
1786 | c3d2689d | balrog | { |
1787 | c3d2689d | balrog | uint64_t distance = qemu_get_clock(vm_clock) - timer->time; |
1788 | c3d2689d | balrog | |
1789 | c3d2689d | balrog | if (timer->st && timer->enable && timer->rate)
|
1790 | c3d2689d | balrog | return timer->val - muldiv64(distance >> (timer->ptv + 1), |
1791 | c3d2689d | balrog | timer->rate, ticks_per_sec); |
1792 | c3d2689d | balrog | else
|
1793 | c3d2689d | balrog | return timer->val;
|
1794 | c3d2689d | balrog | } |
1795 | c3d2689d | balrog | |
1796 | c3d2689d | balrog | static inline void omap_timer_sync(struct omap_mpu_timer_s *timer) |
1797 | c3d2689d | balrog | { |
1798 | c3d2689d | balrog | timer->val = omap_timer_read(timer); |
1799 | c3d2689d | balrog | timer->time = qemu_get_clock(vm_clock); |
1800 | c3d2689d | balrog | } |
1801 | c3d2689d | balrog | |
1802 | c3d2689d | balrog | static inline void omap_timer_update(struct omap_mpu_timer_s *timer) |
1803 | c3d2689d | balrog | { |
1804 | c3d2689d | balrog | int64_t expires; |
1805 | c3d2689d | balrog | |
1806 | c3d2689d | balrog | if (timer->enable && timer->st && timer->rate) {
|
1807 | c3d2689d | balrog | timer->val = timer->reset_val; /* Should skip this on clk enable */
|
1808 | b854bc19 | balrog | expires = muldiv64(timer->val << (timer->ptv + 1),
|
1809 | c3d2689d | balrog | ticks_per_sec, timer->rate); |
1810 | b854bc19 | balrog | |
1811 | b854bc19 | balrog | /* If timer expiry would be sooner than in about 1 ms and
|
1812 | b854bc19 | balrog | * auto-reload isn't set, then fire immediately. This is a hack
|
1813 | b854bc19 | balrog | * to make systems like PalmOS run in acceptable time. PalmOS
|
1814 | b854bc19 | balrog | * sets the interval to a very low value and polls the status bit
|
1815 | b854bc19 | balrog | * in a busy loop when it wants to sleep just a couple of CPU
|
1816 | b854bc19 | balrog | * ticks. */
|
1817 | b854bc19 | balrog | if (expires > (ticks_per_sec >> 10) || timer->ar) |
1818 | b854bc19 | balrog | qemu_mod_timer(timer->timer, timer->time + expires); |
1819 | b854bc19 | balrog | else {
|
1820 | b854bc19 | balrog | timer->val = 0;
|
1821 | b854bc19 | balrog | timer->st = 0;
|
1822 | b854bc19 | balrog | if (timer->it_ena)
|
1823 | 106627d0 | balrog | /* Edge-triggered irq */
|
1824 | 106627d0 | balrog | qemu_irq_pulse(timer->irq); |
1825 | b854bc19 | balrog | } |
1826 | c3d2689d | balrog | } else
|
1827 | c3d2689d | balrog | qemu_del_timer(timer->timer); |
1828 | c3d2689d | balrog | } |
1829 | c3d2689d | balrog | |
1830 | c3d2689d | balrog | static void omap_timer_tick(void *opaque) |
1831 | c3d2689d | balrog | { |
1832 | c3d2689d | balrog | struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque; |
1833 | c3d2689d | balrog | omap_timer_sync(timer); |
1834 | c3d2689d | balrog | |
1835 | c3d2689d | balrog | if (!timer->ar) {
|
1836 | c3d2689d | balrog | timer->val = 0;
|
1837 | c3d2689d | balrog | timer->st = 0;
|
1838 | c3d2689d | balrog | } |
1839 | c3d2689d | balrog | |
1840 | c3d2689d | balrog | if (timer->it_ena)
|
1841 | 106627d0 | balrog | /* Edge-triggered irq */
|
1842 | 106627d0 | balrog | qemu_irq_pulse(timer->irq); |
1843 | c3d2689d | balrog | omap_timer_update(timer); |
1844 | c3d2689d | balrog | } |
1845 | c3d2689d | balrog | |
1846 | c3d2689d | balrog | static void omap_timer_clk_update(void *opaque, int line, int on) |
1847 | c3d2689d | balrog | { |
1848 | c3d2689d | balrog | struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque; |
1849 | c3d2689d | balrog | |
1850 | c3d2689d | balrog | omap_timer_sync(timer); |
1851 | c3d2689d | balrog | timer->rate = on ? omap_clk_getrate(timer->clk) : 0;
|
1852 | c3d2689d | balrog | omap_timer_update(timer); |
1853 | c3d2689d | balrog | } |
1854 | c3d2689d | balrog | |
1855 | c3d2689d | balrog | static void omap_timer_clk_setup(struct omap_mpu_timer_s *timer) |
1856 | c3d2689d | balrog | { |
1857 | c3d2689d | balrog | omap_clk_adduser(timer->clk, |
1858 | c3d2689d | balrog | qemu_allocate_irqs(omap_timer_clk_update, timer, 1)[0]); |
1859 | c3d2689d | balrog | timer->rate = omap_clk_getrate(timer->clk); |
1860 | c3d2689d | balrog | } |
1861 | c3d2689d | balrog | |
1862 | c3d2689d | balrog | static uint32_t omap_mpu_timer_read(void *opaque, target_phys_addr_t addr) |
1863 | c3d2689d | balrog | { |
1864 | c3d2689d | balrog | struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque; |
1865 | c3d2689d | balrog | int offset = addr - s->base;
|
1866 | c3d2689d | balrog | |
1867 | c3d2689d | balrog | switch (offset) {
|
1868 | c3d2689d | balrog | case 0x00: /* CNTL_TIMER */ |
1869 | c3d2689d | balrog | return (s->enable << 5) | (s->ptv << 2) | (s->ar << 1) | s->st; |
1870 | c3d2689d | balrog | |
1871 | c3d2689d | balrog | case 0x04: /* LOAD_TIM */ |
1872 | c3d2689d | balrog | break;
|
1873 | c3d2689d | balrog | |
1874 | c3d2689d | balrog | case 0x08: /* READ_TIM */ |
1875 | c3d2689d | balrog | return omap_timer_read(s);
|
1876 | c3d2689d | balrog | } |
1877 | c3d2689d | balrog | |
1878 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
1879 | c3d2689d | balrog | return 0; |
1880 | c3d2689d | balrog | } |
1881 | c3d2689d | balrog | |
1882 | c3d2689d | balrog | static void omap_mpu_timer_write(void *opaque, target_phys_addr_t addr, |
1883 | c3d2689d | balrog | uint32_t value) |
1884 | c3d2689d | balrog | { |
1885 | c3d2689d | balrog | struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque; |
1886 | c3d2689d | balrog | int offset = addr - s->base;
|
1887 | c3d2689d | balrog | |
1888 | c3d2689d | balrog | switch (offset) {
|
1889 | c3d2689d | balrog | case 0x00: /* CNTL_TIMER */ |
1890 | c3d2689d | balrog | omap_timer_sync(s); |
1891 | c3d2689d | balrog | s->enable = (value >> 5) & 1; |
1892 | c3d2689d | balrog | s->ptv = (value >> 2) & 7; |
1893 | c3d2689d | balrog | s->ar = (value >> 1) & 1; |
1894 | c3d2689d | balrog | s->st = value & 1;
|
1895 | c3d2689d | balrog | omap_timer_update(s); |
1896 | c3d2689d | balrog | return;
|
1897 | c3d2689d | balrog | |
1898 | c3d2689d | balrog | case 0x04: /* LOAD_TIM */ |
1899 | c3d2689d | balrog | s->reset_val = value; |
1900 | c3d2689d | balrog | return;
|
1901 | c3d2689d | balrog | |
1902 | c3d2689d | balrog | case 0x08: /* READ_TIM */ |
1903 | c3d2689d | balrog | OMAP_RO_REG(addr); |
1904 | c3d2689d | balrog | break;
|
1905 | c3d2689d | balrog | |
1906 | c3d2689d | balrog | default:
|
1907 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
1908 | c3d2689d | balrog | } |
1909 | c3d2689d | balrog | } |
1910 | c3d2689d | balrog | |
1911 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_mpu_timer_readfn[] = {
|
1912 | c3d2689d | balrog | omap_badwidth_read32, |
1913 | c3d2689d | balrog | omap_badwidth_read32, |
1914 | c3d2689d | balrog | omap_mpu_timer_read, |
1915 | c3d2689d | balrog | }; |
1916 | c3d2689d | balrog | |
1917 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_mpu_timer_writefn[] = {
|
1918 | c3d2689d | balrog | omap_badwidth_write32, |
1919 | c3d2689d | balrog | omap_badwidth_write32, |
1920 | c3d2689d | balrog | omap_mpu_timer_write, |
1921 | c3d2689d | balrog | }; |
1922 | c3d2689d | balrog | |
1923 | c3d2689d | balrog | static void omap_mpu_timer_reset(struct omap_mpu_timer_s *s) |
1924 | c3d2689d | balrog | { |
1925 | c3d2689d | balrog | qemu_del_timer(s->timer); |
1926 | c3d2689d | balrog | s->enable = 0;
|
1927 | c3d2689d | balrog | s->reset_val = 31337;
|
1928 | c3d2689d | balrog | s->val = 0;
|
1929 | c3d2689d | balrog | s->ptv = 0;
|
1930 | c3d2689d | balrog | s->ar = 0;
|
1931 | c3d2689d | balrog | s->st = 0;
|
1932 | c3d2689d | balrog | s->it_ena = 1;
|
1933 | c3d2689d | balrog | } |
1934 | c3d2689d | balrog | |
1935 | c3d2689d | balrog | struct omap_mpu_timer_s *omap_mpu_timer_init(target_phys_addr_t base,
|
1936 | c3d2689d | balrog | qemu_irq irq, omap_clk clk) |
1937 | c3d2689d | balrog | { |
1938 | c3d2689d | balrog | int iomemtype;
|
1939 | c3d2689d | balrog | struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) |
1940 | c3d2689d | balrog | qemu_mallocz(sizeof(struct omap_mpu_timer_s)); |
1941 | c3d2689d | balrog | |
1942 | c3d2689d | balrog | s->irq = irq; |
1943 | c3d2689d | balrog | s->clk = clk; |
1944 | c3d2689d | balrog | s->base = base; |
1945 | c3d2689d | balrog | s->timer = qemu_new_timer(vm_clock, omap_timer_tick, s); |
1946 | c3d2689d | balrog | omap_mpu_timer_reset(s); |
1947 | c3d2689d | balrog | omap_timer_clk_setup(s); |
1948 | c3d2689d | balrog | |
1949 | c3d2689d | balrog | iomemtype = cpu_register_io_memory(0, omap_mpu_timer_readfn,
|
1950 | c3d2689d | balrog | omap_mpu_timer_writefn, s); |
1951 | c3d2689d | balrog | cpu_register_physical_memory(s->base, 0x100, iomemtype);
|
1952 | c3d2689d | balrog | |
1953 | c3d2689d | balrog | return s;
|
1954 | c3d2689d | balrog | } |
1955 | c3d2689d | balrog | |
1956 | c3d2689d | balrog | /* Watchdog timer */
|
1957 | c3d2689d | balrog | struct omap_watchdog_timer_s {
|
1958 | c3d2689d | balrog | struct omap_mpu_timer_s timer;
|
1959 | c3d2689d | balrog | uint8_t last_wr; |
1960 | c3d2689d | balrog | int mode;
|
1961 | c3d2689d | balrog | int free;
|
1962 | c3d2689d | balrog | int reset;
|
1963 | c3d2689d | balrog | }; |
1964 | c3d2689d | balrog | |
1965 | c3d2689d | balrog | static uint32_t omap_wd_timer_read(void *opaque, target_phys_addr_t addr) |
1966 | c3d2689d | balrog | { |
1967 | c3d2689d | balrog | struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque; |
1968 | c3d2689d | balrog | int offset = addr - s->timer.base;
|
1969 | c3d2689d | balrog | |
1970 | c3d2689d | balrog | switch (offset) {
|
1971 | c3d2689d | balrog | case 0x00: /* CNTL_TIMER */ |
1972 | c3d2689d | balrog | return (s->timer.ptv << 9) | (s->timer.ar << 8) | |
1973 | c3d2689d | balrog | (s->timer.st << 7) | (s->free << 1); |
1974 | c3d2689d | balrog | |
1975 | c3d2689d | balrog | case 0x04: /* READ_TIMER */ |
1976 | c3d2689d | balrog | return omap_timer_read(&s->timer);
|
1977 | c3d2689d | balrog | |
1978 | c3d2689d | balrog | case 0x08: /* TIMER_MODE */ |
1979 | c3d2689d | balrog | return s->mode << 15; |
1980 | c3d2689d | balrog | } |
1981 | c3d2689d | balrog | |
1982 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
1983 | c3d2689d | balrog | return 0; |
1984 | c3d2689d | balrog | } |
1985 | c3d2689d | balrog | |
1986 | c3d2689d | balrog | static void omap_wd_timer_write(void *opaque, target_phys_addr_t addr, |
1987 | c3d2689d | balrog | uint32_t value) |
1988 | c3d2689d | balrog | { |
1989 | c3d2689d | balrog | struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque; |
1990 | c3d2689d | balrog | int offset = addr - s->timer.base;
|
1991 | c3d2689d | balrog | |
1992 | c3d2689d | balrog | switch (offset) {
|
1993 | c3d2689d | balrog | case 0x00: /* CNTL_TIMER */ |
1994 | c3d2689d | balrog | omap_timer_sync(&s->timer); |
1995 | c3d2689d | balrog | s->timer.ptv = (value >> 9) & 7; |
1996 | c3d2689d | balrog | s->timer.ar = (value >> 8) & 1; |
1997 | c3d2689d | balrog | s->timer.st = (value >> 7) & 1; |
1998 | c3d2689d | balrog | s->free = (value >> 1) & 1; |
1999 | c3d2689d | balrog | omap_timer_update(&s->timer); |
2000 | c3d2689d | balrog | break;
|
2001 | c3d2689d | balrog | |
2002 | c3d2689d | balrog | case 0x04: /* LOAD_TIMER */ |
2003 | c3d2689d | balrog | s->timer.reset_val = value & 0xffff;
|
2004 | c3d2689d | balrog | break;
|
2005 | c3d2689d | balrog | |
2006 | c3d2689d | balrog | case 0x08: /* TIMER_MODE */ |
2007 | c3d2689d | balrog | if (!s->mode && ((value >> 15) & 1)) |
2008 | c3d2689d | balrog | omap_clk_get(s->timer.clk); |
2009 | c3d2689d | balrog | s->mode |= (value >> 15) & 1; |
2010 | c3d2689d | balrog | if (s->last_wr == 0xf5) { |
2011 | c3d2689d | balrog | if ((value & 0xff) == 0xa0) { |
2012 | d8f699cb | balrog | if (s->mode) {
|
2013 | d8f699cb | balrog | s->mode = 0;
|
2014 | d8f699cb | balrog | omap_clk_put(s->timer.clk); |
2015 | d8f699cb | balrog | } |
2016 | c3d2689d | balrog | } else {
|
2017 | c3d2689d | balrog | /* XXX: on T|E hardware somehow this has no effect,
|
2018 | c3d2689d | balrog | * on Zire 71 it works as specified. */
|
2019 | c3d2689d | balrog | s->reset = 1;
|
2020 | c3d2689d | balrog | qemu_system_reset_request(); |
2021 | c3d2689d | balrog | } |
2022 | c3d2689d | balrog | } |
2023 | c3d2689d | balrog | s->last_wr = value & 0xff;
|
2024 | c3d2689d | balrog | break;
|
2025 | c3d2689d | balrog | |
2026 | c3d2689d | balrog | default:
|
2027 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2028 | c3d2689d | balrog | } |
2029 | c3d2689d | balrog | } |
2030 | c3d2689d | balrog | |
2031 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_wd_timer_readfn[] = {
|
2032 | c3d2689d | balrog | omap_badwidth_read16, |
2033 | c3d2689d | balrog | omap_wd_timer_read, |
2034 | c3d2689d | balrog | omap_badwidth_read16, |
2035 | c3d2689d | balrog | }; |
2036 | c3d2689d | balrog | |
2037 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_wd_timer_writefn[] = {
|
2038 | c3d2689d | balrog | omap_badwidth_write16, |
2039 | c3d2689d | balrog | omap_wd_timer_write, |
2040 | c3d2689d | balrog | omap_badwidth_write16, |
2041 | c3d2689d | balrog | }; |
2042 | c3d2689d | balrog | |
2043 | c3d2689d | balrog | static void omap_wd_timer_reset(struct omap_watchdog_timer_s *s) |
2044 | c3d2689d | balrog | { |
2045 | c3d2689d | balrog | qemu_del_timer(s->timer.timer); |
2046 | c3d2689d | balrog | if (!s->mode)
|
2047 | c3d2689d | balrog | omap_clk_get(s->timer.clk); |
2048 | c3d2689d | balrog | s->mode = 1;
|
2049 | c3d2689d | balrog | s->free = 1;
|
2050 | c3d2689d | balrog | s->reset = 0;
|
2051 | c3d2689d | balrog | s->timer.enable = 1;
|
2052 | c3d2689d | balrog | s->timer.it_ena = 1;
|
2053 | c3d2689d | balrog | s->timer.reset_val = 0xffff;
|
2054 | c3d2689d | balrog | s->timer.val = 0;
|
2055 | c3d2689d | balrog | s->timer.st = 0;
|
2056 | c3d2689d | balrog | s->timer.ptv = 0;
|
2057 | c3d2689d | balrog | s->timer.ar = 0;
|
2058 | c3d2689d | balrog | omap_timer_update(&s->timer); |
2059 | c3d2689d | balrog | } |
2060 | c3d2689d | balrog | |
2061 | c3d2689d | balrog | struct omap_watchdog_timer_s *omap_wd_timer_init(target_phys_addr_t base,
|
2062 | c3d2689d | balrog | qemu_irq irq, omap_clk clk) |
2063 | c3d2689d | balrog | { |
2064 | c3d2689d | balrog | int iomemtype;
|
2065 | c3d2689d | balrog | struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) |
2066 | c3d2689d | balrog | qemu_mallocz(sizeof(struct omap_watchdog_timer_s)); |
2067 | c3d2689d | balrog | |
2068 | c3d2689d | balrog | s->timer.irq = irq; |
2069 | c3d2689d | balrog | s->timer.clk = clk; |
2070 | c3d2689d | balrog | s->timer.base = base; |
2071 | c3d2689d | balrog | s->timer.timer = qemu_new_timer(vm_clock, omap_timer_tick, &s->timer); |
2072 | c3d2689d | balrog | omap_wd_timer_reset(s); |
2073 | c3d2689d | balrog | omap_timer_clk_setup(&s->timer); |
2074 | c3d2689d | balrog | |
2075 | c3d2689d | balrog | iomemtype = cpu_register_io_memory(0, omap_wd_timer_readfn,
|
2076 | c3d2689d | balrog | omap_wd_timer_writefn, s); |
2077 | c3d2689d | balrog | cpu_register_physical_memory(s->timer.base, 0x100, iomemtype);
|
2078 | c3d2689d | balrog | |
2079 | c3d2689d | balrog | return s;
|
2080 | c3d2689d | balrog | } |
2081 | c3d2689d | balrog | |
2082 | c3d2689d | balrog | /* 32-kHz timer */
|
2083 | c3d2689d | balrog | struct omap_32khz_timer_s {
|
2084 | c3d2689d | balrog | struct omap_mpu_timer_s timer;
|
2085 | c3d2689d | balrog | }; |
2086 | c3d2689d | balrog | |
2087 | c3d2689d | balrog | static uint32_t omap_os_timer_read(void *opaque, target_phys_addr_t addr) |
2088 | c3d2689d | balrog | { |
2089 | c3d2689d | balrog | struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque; |
2090 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
2091 | c3d2689d | balrog | |
2092 | c3d2689d | balrog | switch (offset) {
|
2093 | c3d2689d | balrog | case 0x00: /* TVR */ |
2094 | c3d2689d | balrog | return s->timer.reset_val;
|
2095 | c3d2689d | balrog | |
2096 | c3d2689d | balrog | case 0x04: /* TCR */ |
2097 | c3d2689d | balrog | return omap_timer_read(&s->timer);
|
2098 | c3d2689d | balrog | |
2099 | c3d2689d | balrog | case 0x08: /* CR */ |
2100 | c3d2689d | balrog | return (s->timer.ar << 3) | (s->timer.it_ena << 2) | s->timer.st; |
2101 | c3d2689d | balrog | |
2102 | c3d2689d | balrog | default:
|
2103 | c3d2689d | balrog | break;
|
2104 | c3d2689d | balrog | } |
2105 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2106 | c3d2689d | balrog | return 0; |
2107 | c3d2689d | balrog | } |
2108 | c3d2689d | balrog | |
2109 | c3d2689d | balrog | static void omap_os_timer_write(void *opaque, target_phys_addr_t addr, |
2110 | c3d2689d | balrog | uint32_t value) |
2111 | c3d2689d | balrog | { |
2112 | c3d2689d | balrog | struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque; |
2113 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
2114 | c3d2689d | balrog | |
2115 | c3d2689d | balrog | switch (offset) {
|
2116 | c3d2689d | balrog | case 0x00: /* TVR */ |
2117 | c3d2689d | balrog | s->timer.reset_val = value & 0x00ffffff;
|
2118 | c3d2689d | balrog | break;
|
2119 | c3d2689d | balrog | |
2120 | c3d2689d | balrog | case 0x04: /* TCR */ |
2121 | c3d2689d | balrog | OMAP_RO_REG(addr); |
2122 | c3d2689d | balrog | break;
|
2123 | c3d2689d | balrog | |
2124 | c3d2689d | balrog | case 0x08: /* CR */ |
2125 | c3d2689d | balrog | s->timer.ar = (value >> 3) & 1; |
2126 | c3d2689d | balrog | s->timer.it_ena = (value >> 2) & 1; |
2127 | c3d2689d | balrog | if (s->timer.st != (value & 1) || (value & 2)) { |
2128 | c3d2689d | balrog | omap_timer_sync(&s->timer); |
2129 | c3d2689d | balrog | s->timer.enable = value & 1;
|
2130 | c3d2689d | balrog | s->timer.st = value & 1;
|
2131 | c3d2689d | balrog | omap_timer_update(&s->timer); |
2132 | c3d2689d | balrog | } |
2133 | c3d2689d | balrog | break;
|
2134 | c3d2689d | balrog | |
2135 | c3d2689d | balrog | default:
|
2136 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2137 | c3d2689d | balrog | } |
2138 | c3d2689d | balrog | } |
2139 | c3d2689d | balrog | |
2140 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_os_timer_readfn[] = {
|
2141 | c3d2689d | balrog | omap_badwidth_read32, |
2142 | c3d2689d | balrog | omap_badwidth_read32, |
2143 | c3d2689d | balrog | omap_os_timer_read, |
2144 | c3d2689d | balrog | }; |
2145 | c3d2689d | balrog | |
2146 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_os_timer_writefn[] = {
|
2147 | c3d2689d | balrog | omap_badwidth_write32, |
2148 | c3d2689d | balrog | omap_badwidth_write32, |
2149 | c3d2689d | balrog | omap_os_timer_write, |
2150 | c3d2689d | balrog | }; |
2151 | c3d2689d | balrog | |
2152 | c3d2689d | balrog | static void omap_os_timer_reset(struct omap_32khz_timer_s *s) |
2153 | c3d2689d | balrog | { |
2154 | c3d2689d | balrog | qemu_del_timer(s->timer.timer); |
2155 | c3d2689d | balrog | s->timer.enable = 0;
|
2156 | c3d2689d | balrog | s->timer.it_ena = 0;
|
2157 | c3d2689d | balrog | s->timer.reset_val = 0x00ffffff;
|
2158 | c3d2689d | balrog | s->timer.val = 0;
|
2159 | c3d2689d | balrog | s->timer.st = 0;
|
2160 | c3d2689d | balrog | s->timer.ptv = 0;
|
2161 | c3d2689d | balrog | s->timer.ar = 1;
|
2162 | c3d2689d | balrog | } |
2163 | c3d2689d | balrog | |
2164 | c3d2689d | balrog | struct omap_32khz_timer_s *omap_os_timer_init(target_phys_addr_t base,
|
2165 | c3d2689d | balrog | qemu_irq irq, omap_clk clk) |
2166 | c3d2689d | balrog | { |
2167 | c3d2689d | balrog | int iomemtype;
|
2168 | c3d2689d | balrog | struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) |
2169 | c3d2689d | balrog | qemu_mallocz(sizeof(struct omap_32khz_timer_s)); |
2170 | c3d2689d | balrog | |
2171 | c3d2689d | balrog | s->timer.irq = irq; |
2172 | c3d2689d | balrog | s->timer.clk = clk; |
2173 | c3d2689d | balrog | s->timer.base = base; |
2174 | c3d2689d | balrog | s->timer.timer = qemu_new_timer(vm_clock, omap_timer_tick, &s->timer); |
2175 | c3d2689d | balrog | omap_os_timer_reset(s); |
2176 | c3d2689d | balrog | omap_timer_clk_setup(&s->timer); |
2177 | c3d2689d | balrog | |
2178 | c3d2689d | balrog | iomemtype = cpu_register_io_memory(0, omap_os_timer_readfn,
|
2179 | c3d2689d | balrog | omap_os_timer_writefn, s); |
2180 | c3d2689d | balrog | cpu_register_physical_memory(s->timer.base, 0x800, iomemtype);
|
2181 | c3d2689d | balrog | |
2182 | c3d2689d | balrog | return s;
|
2183 | c3d2689d | balrog | } |
2184 | c3d2689d | balrog | |
2185 | c3d2689d | balrog | /* Ultra Low-Power Device Module */
|
2186 | c3d2689d | balrog | static uint32_t omap_ulpd_pm_read(void *opaque, target_phys_addr_t addr) |
2187 | c3d2689d | balrog | { |
2188 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2189 | c3d2689d | balrog | int offset = addr - s->ulpd_pm_base;
|
2190 | c3d2689d | balrog | uint16_t ret; |
2191 | c3d2689d | balrog | |
2192 | c3d2689d | balrog | switch (offset) {
|
2193 | c3d2689d | balrog | case 0x14: /* IT_STATUS */ |
2194 | c3d2689d | balrog | ret = s->ulpd_pm_regs[offset >> 2];
|
2195 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] = 0; |
2196 | c3d2689d | balrog | qemu_irq_lower(s->irq[1][OMAP_INT_GAUGE_32K]);
|
2197 | c3d2689d | balrog | return ret;
|
2198 | c3d2689d | balrog | |
2199 | c3d2689d | balrog | case 0x18: /* Reserved */ |
2200 | c3d2689d | balrog | case 0x1c: /* Reserved */ |
2201 | c3d2689d | balrog | case 0x20: /* Reserved */ |
2202 | c3d2689d | balrog | case 0x28: /* Reserved */ |
2203 | c3d2689d | balrog | case 0x2c: /* Reserved */ |
2204 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2205 | c3d2689d | balrog | case 0x00: /* COUNTER_32_LSB */ |
2206 | c3d2689d | balrog | case 0x04: /* COUNTER_32_MSB */ |
2207 | c3d2689d | balrog | case 0x08: /* COUNTER_HIGH_FREQ_LSB */ |
2208 | c3d2689d | balrog | case 0x0c: /* COUNTER_HIGH_FREQ_MSB */ |
2209 | c3d2689d | balrog | case 0x10: /* GAUGING_CTRL */ |
2210 | c3d2689d | balrog | case 0x24: /* SETUP_ANALOG_CELL3_ULPD1 */ |
2211 | c3d2689d | balrog | case 0x30: /* CLOCK_CTRL */ |
2212 | c3d2689d | balrog | case 0x34: /* SOFT_REQ */ |
2213 | c3d2689d | balrog | case 0x38: /* COUNTER_32_FIQ */ |
2214 | c3d2689d | balrog | case 0x3c: /* DPLL_CTRL */ |
2215 | c3d2689d | balrog | case 0x40: /* STATUS_REQ */ |
2216 | c3d2689d | balrog | /* XXX: check clk::usecount state for every clock */
|
2217 | c3d2689d | balrog | case 0x48: /* LOCL_TIME */ |
2218 | c3d2689d | balrog | case 0x4c: /* APLL_CTRL */ |
2219 | c3d2689d | balrog | case 0x50: /* POWER_CTRL */ |
2220 | c3d2689d | balrog | return s->ulpd_pm_regs[offset >> 2]; |
2221 | c3d2689d | balrog | } |
2222 | c3d2689d | balrog | |
2223 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2224 | c3d2689d | balrog | return 0; |
2225 | c3d2689d | balrog | } |
2226 | c3d2689d | balrog | |
2227 | c3d2689d | balrog | static inline void omap_ulpd_clk_update(struct omap_mpu_state_s *s, |
2228 | c3d2689d | balrog | uint16_t diff, uint16_t value) |
2229 | c3d2689d | balrog | { |
2230 | c3d2689d | balrog | if (diff & (1 << 4)) /* USB_MCLK_EN */ |
2231 | c3d2689d | balrog | omap_clk_onoff(omap_findclk(s, "usb_clk0"), (value >> 4) & 1); |
2232 | c3d2689d | balrog | if (diff & (1 << 5)) /* DIS_USB_PVCI_CLK */ |
2233 | c3d2689d | balrog | omap_clk_onoff(omap_findclk(s, "usb_w2fc_ck"), (~value >> 5) & 1); |
2234 | c3d2689d | balrog | } |
2235 | c3d2689d | balrog | |
2236 | c3d2689d | balrog | static inline void omap_ulpd_req_update(struct omap_mpu_state_s *s, |
2237 | c3d2689d | balrog | uint16_t diff, uint16_t value) |
2238 | c3d2689d | balrog | { |
2239 | c3d2689d | balrog | if (diff & (1 << 0)) /* SOFT_DPLL_REQ */ |
2240 | c3d2689d | balrog | omap_clk_canidle(omap_findclk(s, "dpll4"), (~value >> 0) & 1); |
2241 | c3d2689d | balrog | if (diff & (1 << 1)) /* SOFT_COM_REQ */ |
2242 | c3d2689d | balrog | omap_clk_canidle(omap_findclk(s, "com_mclk_out"), (~value >> 1) & 1); |
2243 | c3d2689d | balrog | if (diff & (1 << 2)) /* SOFT_SDW_REQ */ |
2244 | c3d2689d | balrog | omap_clk_canidle(omap_findclk(s, "bt_mclk_out"), (~value >> 2) & 1); |
2245 | c3d2689d | balrog | if (diff & (1 << 3)) /* SOFT_USB_REQ */ |
2246 | c3d2689d | balrog | omap_clk_canidle(omap_findclk(s, "usb_clk0"), (~value >> 3) & 1); |
2247 | c3d2689d | balrog | } |
2248 | c3d2689d | balrog | |
2249 | c3d2689d | balrog | static void omap_ulpd_pm_write(void *opaque, target_phys_addr_t addr, |
2250 | c3d2689d | balrog | uint32_t value) |
2251 | c3d2689d | balrog | { |
2252 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2253 | c3d2689d | balrog | int offset = addr - s->ulpd_pm_base;
|
2254 | c3d2689d | balrog | int64_t now, ticks; |
2255 | c3d2689d | balrog | int div, mult;
|
2256 | c3d2689d | balrog | static const int bypass_div[4] = { 1, 2, 4, 4 }; |
2257 | c3d2689d | balrog | uint16_t diff; |
2258 | c3d2689d | balrog | |
2259 | c3d2689d | balrog | switch (offset) {
|
2260 | c3d2689d | balrog | case 0x00: /* COUNTER_32_LSB */ |
2261 | c3d2689d | balrog | case 0x04: /* COUNTER_32_MSB */ |
2262 | c3d2689d | balrog | case 0x08: /* COUNTER_HIGH_FREQ_LSB */ |
2263 | c3d2689d | balrog | case 0x0c: /* COUNTER_HIGH_FREQ_MSB */ |
2264 | c3d2689d | balrog | case 0x14: /* IT_STATUS */ |
2265 | c3d2689d | balrog | case 0x40: /* STATUS_REQ */ |
2266 | c3d2689d | balrog | OMAP_RO_REG(addr); |
2267 | c3d2689d | balrog | break;
|
2268 | c3d2689d | balrog | |
2269 | c3d2689d | balrog | case 0x10: /* GAUGING_CTRL */ |
2270 | c3d2689d | balrog | /* Bits 0 and 1 seem to be confused in the OMAP 310 TRM */
|
2271 | c3d2689d | balrog | if ((s->ulpd_pm_regs[offset >> 2] ^ value) & 1) { |
2272 | c3d2689d | balrog | now = qemu_get_clock(vm_clock); |
2273 | c3d2689d | balrog | |
2274 | c3d2689d | balrog | if (value & 1) |
2275 | c3d2689d | balrog | s->ulpd_gauge_start = now; |
2276 | c3d2689d | balrog | else {
|
2277 | c3d2689d | balrog | now -= s->ulpd_gauge_start; |
2278 | c3d2689d | balrog | |
2279 | c3d2689d | balrog | /* 32-kHz ticks */
|
2280 | c3d2689d | balrog | ticks = muldiv64(now, 32768, ticks_per_sec);
|
2281 | c3d2689d | balrog | s->ulpd_pm_regs[0x00 >> 2] = (ticks >> 0) & 0xffff; |
2282 | c3d2689d | balrog | s->ulpd_pm_regs[0x04 >> 2] = (ticks >> 16) & 0xffff; |
2283 | c3d2689d | balrog | if (ticks >> 32) /* OVERFLOW_32K */ |
2284 | c3d2689d | balrog | s->ulpd_pm_regs[0x14 >> 2] |= 1 << 2; |
2285 | c3d2689d | balrog | |
2286 | c3d2689d | balrog | /* High frequency ticks */
|
2287 | c3d2689d | balrog | ticks = muldiv64(now, 12000000, ticks_per_sec);
|
2288 | c3d2689d | balrog | s->ulpd_pm_regs[0x08 >> 2] = (ticks >> 0) & 0xffff; |
2289 | c3d2689d | balrog | s->ulpd_pm_regs[0x0c >> 2] = (ticks >> 16) & 0xffff; |
2290 | c3d2689d | balrog | if (ticks >> 32) /* OVERFLOW_HI_FREQ */ |
2291 | c3d2689d | balrog | s->ulpd_pm_regs[0x14 >> 2] |= 1 << 1; |
2292 | c3d2689d | balrog | |
2293 | c3d2689d | balrog | s->ulpd_pm_regs[0x14 >> 2] |= 1 << 0; /* IT_GAUGING */ |
2294 | c3d2689d | balrog | qemu_irq_raise(s->irq[1][OMAP_INT_GAUGE_32K]);
|
2295 | c3d2689d | balrog | } |
2296 | c3d2689d | balrog | } |
2297 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] = value;
|
2298 | c3d2689d | balrog | break;
|
2299 | c3d2689d | balrog | |
2300 | c3d2689d | balrog | case 0x18: /* Reserved */ |
2301 | c3d2689d | balrog | case 0x1c: /* Reserved */ |
2302 | c3d2689d | balrog | case 0x20: /* Reserved */ |
2303 | c3d2689d | balrog | case 0x28: /* Reserved */ |
2304 | c3d2689d | balrog | case 0x2c: /* Reserved */ |
2305 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2306 | c3d2689d | balrog | case 0x24: /* SETUP_ANALOG_CELL3_ULPD1 */ |
2307 | c3d2689d | balrog | case 0x38: /* COUNTER_32_FIQ */ |
2308 | c3d2689d | balrog | case 0x48: /* LOCL_TIME */ |
2309 | c3d2689d | balrog | case 0x50: /* POWER_CTRL */ |
2310 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] = value;
|
2311 | c3d2689d | balrog | break;
|
2312 | c3d2689d | balrog | |
2313 | c3d2689d | balrog | case 0x30: /* CLOCK_CTRL */ |
2314 | c3d2689d | balrog | diff = s->ulpd_pm_regs[offset >> 2] ^ value;
|
2315 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] = value & 0x3f; |
2316 | c3d2689d | balrog | omap_ulpd_clk_update(s, diff, value); |
2317 | c3d2689d | balrog | break;
|
2318 | c3d2689d | balrog | |
2319 | c3d2689d | balrog | case 0x34: /* SOFT_REQ */ |
2320 | c3d2689d | balrog | diff = s->ulpd_pm_regs[offset >> 2] ^ value;
|
2321 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] = value & 0x1f; |
2322 | c3d2689d | balrog | omap_ulpd_req_update(s, diff, value); |
2323 | c3d2689d | balrog | break;
|
2324 | c3d2689d | balrog | |
2325 | c3d2689d | balrog | case 0x3c: /* DPLL_CTRL */ |
2326 | c3d2689d | balrog | /* XXX: OMAP310 TRM claims bit 3 is PLL_ENABLE, and bit 4 is
|
2327 | c3d2689d | balrog | * omitted altogether, probably a typo. */
|
2328 | c3d2689d | balrog | /* This register has identical semantics with DPLL(1:3) control
|
2329 | c3d2689d | balrog | * registers, see omap_dpll_write() */
|
2330 | c3d2689d | balrog | diff = s->ulpd_pm_regs[offset >> 2] & value;
|
2331 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] = value & 0x2fff; |
2332 | c3d2689d | balrog | if (diff & (0x3ff << 2)) { |
2333 | c3d2689d | balrog | if (value & (1 << 4)) { /* PLL_ENABLE */ |
2334 | c3d2689d | balrog | div = ((value >> 5) & 3) + 1; /* PLL_DIV */ |
2335 | c3d2689d | balrog | mult = MIN((value >> 7) & 0x1f, 1); /* PLL_MULT */ |
2336 | c3d2689d | balrog | } else {
|
2337 | c3d2689d | balrog | div = bypass_div[((value >> 2) & 3)]; /* BYPASS_DIV */ |
2338 | c3d2689d | balrog | mult = 1;
|
2339 | c3d2689d | balrog | } |
2340 | c3d2689d | balrog | omap_clk_setrate(omap_findclk(s, "dpll4"), div, mult);
|
2341 | c3d2689d | balrog | } |
2342 | c3d2689d | balrog | |
2343 | c3d2689d | balrog | /* Enter the desired mode. */
|
2344 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] =
|
2345 | c3d2689d | balrog | (s->ulpd_pm_regs[offset >> 2] & 0xfffe) | |
2346 | c3d2689d | balrog | ((s->ulpd_pm_regs[offset >> 2] >> 4) & 1); |
2347 | c3d2689d | balrog | |
2348 | c3d2689d | balrog | /* Act as if the lock is restored. */
|
2349 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] |= 2; |
2350 | c3d2689d | balrog | break;
|
2351 | c3d2689d | balrog | |
2352 | c3d2689d | balrog | case 0x4c: /* APLL_CTRL */ |
2353 | c3d2689d | balrog | diff = s->ulpd_pm_regs[offset >> 2] & value;
|
2354 | c3d2689d | balrog | s->ulpd_pm_regs[offset >> 2] = value & 0xf; |
2355 | c3d2689d | balrog | if (diff & (1 << 0)) /* APLL_NDPLL_SWITCH */ |
2356 | c3d2689d | balrog | omap_clk_reparent(omap_findclk(s, "ck_48m"), omap_findclk(s,
|
2357 | c3d2689d | balrog | (value & (1 << 0)) ? "apll" : "dpll4")); |
2358 | c3d2689d | balrog | break;
|
2359 | c3d2689d | balrog | |
2360 | c3d2689d | balrog | default:
|
2361 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2362 | c3d2689d | balrog | } |
2363 | c3d2689d | balrog | } |
2364 | c3d2689d | balrog | |
2365 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_ulpd_pm_readfn[] = {
|
2366 | c3d2689d | balrog | omap_badwidth_read16, |
2367 | c3d2689d | balrog | omap_ulpd_pm_read, |
2368 | c3d2689d | balrog | omap_badwidth_read16, |
2369 | c3d2689d | balrog | }; |
2370 | c3d2689d | balrog | |
2371 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_ulpd_pm_writefn[] = {
|
2372 | c3d2689d | balrog | omap_badwidth_write16, |
2373 | c3d2689d | balrog | omap_ulpd_pm_write, |
2374 | c3d2689d | balrog | omap_badwidth_write16, |
2375 | c3d2689d | balrog | }; |
2376 | c3d2689d | balrog | |
2377 | c3d2689d | balrog | static void omap_ulpd_pm_reset(struct omap_mpu_state_s *mpu) |
2378 | c3d2689d | balrog | { |
2379 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x00 >> 2] = 0x0001; |
2380 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x04 >> 2] = 0x0000; |
2381 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x08 >> 2] = 0x0001; |
2382 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x0c >> 2] = 0x0000; |
2383 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x10 >> 2] = 0x0000; |
2384 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x18 >> 2] = 0x01; |
2385 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x1c >> 2] = 0x01; |
2386 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x20 >> 2] = 0x01; |
2387 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x24 >> 2] = 0x03ff; |
2388 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x28 >> 2] = 0x01; |
2389 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x2c >> 2] = 0x01; |
2390 | c3d2689d | balrog | omap_ulpd_clk_update(mpu, mpu->ulpd_pm_regs[0x30 >> 2], 0x0000); |
2391 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x30 >> 2] = 0x0000; |
2392 | c3d2689d | balrog | omap_ulpd_req_update(mpu, mpu->ulpd_pm_regs[0x34 >> 2], 0x0000); |
2393 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x34 >> 2] = 0x0000; |
2394 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x38 >> 2] = 0x0001; |
2395 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x3c >> 2] = 0x2211; |
2396 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x40 >> 2] = 0x0000; /* FIXME: dump a real STATUS_REQ */ |
2397 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x48 >> 2] = 0x960; |
2398 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x4c >> 2] = 0x08; |
2399 | c3d2689d | balrog | mpu->ulpd_pm_regs[0x50 >> 2] = 0x08; |
2400 | c3d2689d | balrog | omap_clk_setrate(omap_findclk(mpu, "dpll4"), 1, 4); |
2401 | c3d2689d | balrog | omap_clk_reparent(omap_findclk(mpu, "ck_48m"), omap_findclk(mpu, "dpll4")); |
2402 | c3d2689d | balrog | } |
2403 | c3d2689d | balrog | |
2404 | c3d2689d | balrog | static void omap_ulpd_pm_init(target_phys_addr_t base, |
2405 | c3d2689d | balrog | struct omap_mpu_state_s *mpu)
|
2406 | c3d2689d | balrog | { |
2407 | c3d2689d | balrog | int iomemtype = cpu_register_io_memory(0, omap_ulpd_pm_readfn, |
2408 | c3d2689d | balrog | omap_ulpd_pm_writefn, mpu); |
2409 | c3d2689d | balrog | |
2410 | c3d2689d | balrog | mpu->ulpd_pm_base = base; |
2411 | c3d2689d | balrog | cpu_register_physical_memory(mpu->ulpd_pm_base, 0x800, iomemtype);
|
2412 | c3d2689d | balrog | omap_ulpd_pm_reset(mpu); |
2413 | c3d2689d | balrog | } |
2414 | c3d2689d | balrog | |
2415 | c3d2689d | balrog | /* OMAP Pin Configuration */
|
2416 | c3d2689d | balrog | static uint32_t omap_pin_cfg_read(void *opaque, target_phys_addr_t addr) |
2417 | c3d2689d | balrog | { |
2418 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2419 | c3d2689d | balrog | int offset = addr - s->pin_cfg_base;
|
2420 | c3d2689d | balrog | |
2421 | c3d2689d | balrog | switch (offset) {
|
2422 | c3d2689d | balrog | case 0x00: /* FUNC_MUX_CTRL_0 */ |
2423 | c3d2689d | balrog | case 0x04: /* FUNC_MUX_CTRL_1 */ |
2424 | c3d2689d | balrog | case 0x08: /* FUNC_MUX_CTRL_2 */ |
2425 | c3d2689d | balrog | return s->func_mux_ctrl[offset >> 2]; |
2426 | c3d2689d | balrog | |
2427 | c3d2689d | balrog | case 0x0c: /* COMP_MODE_CTRL_0 */ |
2428 | c3d2689d | balrog | return s->comp_mode_ctrl[0]; |
2429 | c3d2689d | balrog | |
2430 | c3d2689d | balrog | case 0x10: /* FUNC_MUX_CTRL_3 */ |
2431 | c3d2689d | balrog | case 0x14: /* FUNC_MUX_CTRL_4 */ |
2432 | c3d2689d | balrog | case 0x18: /* FUNC_MUX_CTRL_5 */ |
2433 | c3d2689d | balrog | case 0x1c: /* FUNC_MUX_CTRL_6 */ |
2434 | c3d2689d | balrog | case 0x20: /* FUNC_MUX_CTRL_7 */ |
2435 | c3d2689d | balrog | case 0x24: /* FUNC_MUX_CTRL_8 */ |
2436 | c3d2689d | balrog | case 0x28: /* FUNC_MUX_CTRL_9 */ |
2437 | c3d2689d | balrog | case 0x2c: /* FUNC_MUX_CTRL_A */ |
2438 | c3d2689d | balrog | case 0x30: /* FUNC_MUX_CTRL_B */ |
2439 | c3d2689d | balrog | case 0x34: /* FUNC_MUX_CTRL_C */ |
2440 | c3d2689d | balrog | case 0x38: /* FUNC_MUX_CTRL_D */ |
2441 | c3d2689d | balrog | return s->func_mux_ctrl[(offset >> 2) - 1]; |
2442 | c3d2689d | balrog | |
2443 | c3d2689d | balrog | case 0x40: /* PULL_DWN_CTRL_0 */ |
2444 | c3d2689d | balrog | case 0x44: /* PULL_DWN_CTRL_1 */ |
2445 | c3d2689d | balrog | case 0x48: /* PULL_DWN_CTRL_2 */ |
2446 | c3d2689d | balrog | case 0x4c: /* PULL_DWN_CTRL_3 */ |
2447 | c3d2689d | balrog | return s->pull_dwn_ctrl[(offset & 0xf) >> 2]; |
2448 | c3d2689d | balrog | |
2449 | c3d2689d | balrog | case 0x50: /* GATE_INH_CTRL_0 */ |
2450 | c3d2689d | balrog | return s->gate_inh_ctrl[0]; |
2451 | c3d2689d | balrog | |
2452 | c3d2689d | balrog | case 0x60: /* VOLTAGE_CTRL_0 */ |
2453 | c3d2689d | balrog | return s->voltage_ctrl[0]; |
2454 | c3d2689d | balrog | |
2455 | c3d2689d | balrog | case 0x70: /* TEST_DBG_CTRL_0 */ |
2456 | c3d2689d | balrog | return s->test_dbg_ctrl[0]; |
2457 | c3d2689d | balrog | |
2458 | c3d2689d | balrog | case 0x80: /* MOD_CONF_CTRL_0 */ |
2459 | c3d2689d | balrog | return s->mod_conf_ctrl[0]; |
2460 | c3d2689d | balrog | } |
2461 | c3d2689d | balrog | |
2462 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2463 | c3d2689d | balrog | return 0; |
2464 | c3d2689d | balrog | } |
2465 | c3d2689d | balrog | |
2466 | c3d2689d | balrog | static inline void omap_pin_funcmux0_update(struct omap_mpu_state_s *s, |
2467 | c3d2689d | balrog | uint32_t diff, uint32_t value) |
2468 | c3d2689d | balrog | { |
2469 | c3d2689d | balrog | if (s->compat1509) {
|
2470 | c3d2689d | balrog | if (diff & (1 << 9)) /* BLUETOOTH */ |
2471 | c3d2689d | balrog | omap_clk_onoff(omap_findclk(s, "bt_mclk_out"),
|
2472 | c3d2689d | balrog | (~value >> 9) & 1); |
2473 | c3d2689d | balrog | if (diff & (1 << 7)) /* USB.CLKO */ |
2474 | c3d2689d | balrog | omap_clk_onoff(omap_findclk(s, "usb.clko"),
|
2475 | c3d2689d | balrog | (value >> 7) & 1); |
2476 | c3d2689d | balrog | } |
2477 | c3d2689d | balrog | } |
2478 | c3d2689d | balrog | |
2479 | c3d2689d | balrog | static inline void omap_pin_funcmux1_update(struct omap_mpu_state_s *s, |
2480 | c3d2689d | balrog | uint32_t diff, uint32_t value) |
2481 | c3d2689d | balrog | { |
2482 | c3d2689d | balrog | if (s->compat1509) {
|
2483 | c3d2689d | balrog | if (diff & (1 << 31)) /* MCBSP3_CLK_HIZ_DI */ |
2484 | c3d2689d | balrog | omap_clk_onoff(omap_findclk(s, "mcbsp3.clkx"),
|
2485 | c3d2689d | balrog | (value >> 31) & 1); |
2486 | c3d2689d | balrog | if (diff & (1 << 1)) /* CLK32K */ |
2487 | c3d2689d | balrog | omap_clk_onoff(omap_findclk(s, "clk32k_out"),
|
2488 | c3d2689d | balrog | (~value >> 1) & 1); |
2489 | c3d2689d | balrog | } |
2490 | c3d2689d | balrog | } |
2491 | c3d2689d | balrog | |
2492 | c3d2689d | balrog | static inline void omap_pin_modconf1_update(struct omap_mpu_state_s *s, |
2493 | c3d2689d | balrog | uint32_t diff, uint32_t value) |
2494 | c3d2689d | balrog | { |
2495 | c3d2689d | balrog | if (diff & (1 << 31)) /* CONF_MOD_UART3_CLK_MODE_R */ |
2496 | c3d2689d | balrog | omap_clk_reparent(omap_findclk(s, "uart3_ck"),
|
2497 | c3d2689d | balrog | omap_findclk(s, ((value >> 31) & 1) ? |
2498 | c3d2689d | balrog | "ck_48m" : "armper_ck")); |
2499 | c3d2689d | balrog | if (diff & (1 << 30)) /* CONF_MOD_UART2_CLK_MODE_R */ |
2500 | c3d2689d | balrog | omap_clk_reparent(omap_findclk(s, "uart2_ck"),
|
2501 | c3d2689d | balrog | omap_findclk(s, ((value >> 30) & 1) ? |
2502 | c3d2689d | balrog | "ck_48m" : "armper_ck")); |
2503 | c3d2689d | balrog | if (diff & (1 << 29)) /* CONF_MOD_UART1_CLK_MODE_R */ |
2504 | c3d2689d | balrog | omap_clk_reparent(omap_findclk(s, "uart1_ck"),
|
2505 | c3d2689d | balrog | omap_findclk(s, ((value >> 29) & 1) ? |
2506 | c3d2689d | balrog | "ck_48m" : "armper_ck")); |
2507 | c3d2689d | balrog | if (diff & (1 << 23)) /* CONF_MOD_MMC_SD_CLK_REQ_R */ |
2508 | c3d2689d | balrog | omap_clk_reparent(omap_findclk(s, "mmc_ck"),
|
2509 | c3d2689d | balrog | omap_findclk(s, ((value >> 23) & 1) ? |
2510 | c3d2689d | balrog | "ck_48m" : "armper_ck")); |
2511 | c3d2689d | balrog | if (diff & (1 << 12)) /* CONF_MOD_COM_MCLK_12_48_S */ |
2512 | c3d2689d | balrog | omap_clk_reparent(omap_findclk(s, "com_mclk_out"),
|
2513 | c3d2689d | balrog | omap_findclk(s, ((value >> 12) & 1) ? |
2514 | c3d2689d | balrog | "ck_48m" : "armper_ck")); |
2515 | c3d2689d | balrog | if (diff & (1 << 9)) /* CONF_MOD_USB_HOST_HHC_UHO */ |
2516 | c3d2689d | balrog | omap_clk_onoff(omap_findclk(s, "usb_hhc_ck"), (value >> 9) & 1); |
2517 | c3d2689d | balrog | } |
2518 | c3d2689d | balrog | |
2519 | c3d2689d | balrog | static void omap_pin_cfg_write(void *opaque, target_phys_addr_t addr, |
2520 | c3d2689d | balrog | uint32_t value) |
2521 | c3d2689d | balrog | { |
2522 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2523 | c3d2689d | balrog | int offset = addr - s->pin_cfg_base;
|
2524 | c3d2689d | balrog | uint32_t diff; |
2525 | c3d2689d | balrog | |
2526 | c3d2689d | balrog | switch (offset) {
|
2527 | c3d2689d | balrog | case 0x00: /* FUNC_MUX_CTRL_0 */ |
2528 | c3d2689d | balrog | diff = s->func_mux_ctrl[offset >> 2] ^ value;
|
2529 | c3d2689d | balrog | s->func_mux_ctrl[offset >> 2] = value;
|
2530 | c3d2689d | balrog | omap_pin_funcmux0_update(s, diff, value); |
2531 | c3d2689d | balrog | return;
|
2532 | c3d2689d | balrog | |
2533 | c3d2689d | balrog | case 0x04: /* FUNC_MUX_CTRL_1 */ |
2534 | c3d2689d | balrog | diff = s->func_mux_ctrl[offset >> 2] ^ value;
|
2535 | c3d2689d | balrog | s->func_mux_ctrl[offset >> 2] = value;
|
2536 | c3d2689d | balrog | omap_pin_funcmux1_update(s, diff, value); |
2537 | c3d2689d | balrog | return;
|
2538 | c3d2689d | balrog | |
2539 | c3d2689d | balrog | case 0x08: /* FUNC_MUX_CTRL_2 */ |
2540 | c3d2689d | balrog | s->func_mux_ctrl[offset >> 2] = value;
|
2541 | c3d2689d | balrog | return;
|
2542 | c3d2689d | balrog | |
2543 | c3d2689d | balrog | case 0x0c: /* COMP_MODE_CTRL_0 */ |
2544 | c3d2689d | balrog | s->comp_mode_ctrl[0] = value;
|
2545 | c3d2689d | balrog | s->compat1509 = (value != 0x0000eaef);
|
2546 | c3d2689d | balrog | omap_pin_funcmux0_update(s, ~0, s->func_mux_ctrl[0]); |
2547 | c3d2689d | balrog | omap_pin_funcmux1_update(s, ~0, s->func_mux_ctrl[1]); |
2548 | c3d2689d | balrog | return;
|
2549 | c3d2689d | balrog | |
2550 | c3d2689d | balrog | case 0x10: /* FUNC_MUX_CTRL_3 */ |
2551 | c3d2689d | balrog | case 0x14: /* FUNC_MUX_CTRL_4 */ |
2552 | c3d2689d | balrog | case 0x18: /* FUNC_MUX_CTRL_5 */ |
2553 | c3d2689d | balrog | case 0x1c: /* FUNC_MUX_CTRL_6 */ |
2554 | c3d2689d | balrog | case 0x20: /* FUNC_MUX_CTRL_7 */ |
2555 | c3d2689d | balrog | case 0x24: /* FUNC_MUX_CTRL_8 */ |
2556 | c3d2689d | balrog | case 0x28: /* FUNC_MUX_CTRL_9 */ |
2557 | c3d2689d | balrog | case 0x2c: /* FUNC_MUX_CTRL_A */ |
2558 | c3d2689d | balrog | case 0x30: /* FUNC_MUX_CTRL_B */ |
2559 | c3d2689d | balrog | case 0x34: /* FUNC_MUX_CTRL_C */ |
2560 | c3d2689d | balrog | case 0x38: /* FUNC_MUX_CTRL_D */ |
2561 | c3d2689d | balrog | s->func_mux_ctrl[(offset >> 2) - 1] = value; |
2562 | c3d2689d | balrog | return;
|
2563 | c3d2689d | balrog | |
2564 | c3d2689d | balrog | case 0x40: /* PULL_DWN_CTRL_0 */ |
2565 | c3d2689d | balrog | case 0x44: /* PULL_DWN_CTRL_1 */ |
2566 | c3d2689d | balrog | case 0x48: /* PULL_DWN_CTRL_2 */ |
2567 | c3d2689d | balrog | case 0x4c: /* PULL_DWN_CTRL_3 */ |
2568 | c3d2689d | balrog | s->pull_dwn_ctrl[(offset & 0xf) >> 2] = value; |
2569 | c3d2689d | balrog | return;
|
2570 | c3d2689d | balrog | |
2571 | c3d2689d | balrog | case 0x50: /* GATE_INH_CTRL_0 */ |
2572 | c3d2689d | balrog | s->gate_inh_ctrl[0] = value;
|
2573 | c3d2689d | balrog | return;
|
2574 | c3d2689d | balrog | |
2575 | c3d2689d | balrog | case 0x60: /* VOLTAGE_CTRL_0 */ |
2576 | c3d2689d | balrog | s->voltage_ctrl[0] = value;
|
2577 | c3d2689d | balrog | return;
|
2578 | c3d2689d | balrog | |
2579 | c3d2689d | balrog | case 0x70: /* TEST_DBG_CTRL_0 */ |
2580 | c3d2689d | balrog | s->test_dbg_ctrl[0] = value;
|
2581 | c3d2689d | balrog | return;
|
2582 | c3d2689d | balrog | |
2583 | c3d2689d | balrog | case 0x80: /* MOD_CONF_CTRL_0 */ |
2584 | c3d2689d | balrog | diff = s->mod_conf_ctrl[0] ^ value;
|
2585 | c3d2689d | balrog | s->mod_conf_ctrl[0] = value;
|
2586 | c3d2689d | balrog | omap_pin_modconf1_update(s, diff, value); |
2587 | c3d2689d | balrog | return;
|
2588 | c3d2689d | balrog | |
2589 | c3d2689d | balrog | default:
|
2590 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2591 | c3d2689d | balrog | } |
2592 | c3d2689d | balrog | } |
2593 | c3d2689d | balrog | |
2594 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_pin_cfg_readfn[] = {
|
2595 | c3d2689d | balrog | omap_badwidth_read32, |
2596 | c3d2689d | balrog | omap_badwidth_read32, |
2597 | c3d2689d | balrog | omap_pin_cfg_read, |
2598 | c3d2689d | balrog | }; |
2599 | c3d2689d | balrog | |
2600 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_pin_cfg_writefn[] = {
|
2601 | c3d2689d | balrog | omap_badwidth_write32, |
2602 | c3d2689d | balrog | omap_badwidth_write32, |
2603 | c3d2689d | balrog | omap_pin_cfg_write, |
2604 | c3d2689d | balrog | }; |
2605 | c3d2689d | balrog | |
2606 | c3d2689d | balrog | static void omap_pin_cfg_reset(struct omap_mpu_state_s *mpu) |
2607 | c3d2689d | balrog | { |
2608 | c3d2689d | balrog | /* Start in Compatibility Mode. */
|
2609 | c3d2689d | balrog | mpu->compat1509 = 1;
|
2610 | c3d2689d | balrog | omap_pin_funcmux0_update(mpu, mpu->func_mux_ctrl[0], 0); |
2611 | c3d2689d | balrog | omap_pin_funcmux1_update(mpu, mpu->func_mux_ctrl[1], 0); |
2612 | c3d2689d | balrog | omap_pin_modconf1_update(mpu, mpu->mod_conf_ctrl[0], 0); |
2613 | c3d2689d | balrog | memset(mpu->func_mux_ctrl, 0, sizeof(mpu->func_mux_ctrl)); |
2614 | c3d2689d | balrog | memset(mpu->comp_mode_ctrl, 0, sizeof(mpu->comp_mode_ctrl)); |
2615 | c3d2689d | balrog | memset(mpu->pull_dwn_ctrl, 0, sizeof(mpu->pull_dwn_ctrl)); |
2616 | c3d2689d | balrog | memset(mpu->gate_inh_ctrl, 0, sizeof(mpu->gate_inh_ctrl)); |
2617 | c3d2689d | balrog | memset(mpu->voltage_ctrl, 0, sizeof(mpu->voltage_ctrl)); |
2618 | c3d2689d | balrog | memset(mpu->test_dbg_ctrl, 0, sizeof(mpu->test_dbg_ctrl)); |
2619 | c3d2689d | balrog | memset(mpu->mod_conf_ctrl, 0, sizeof(mpu->mod_conf_ctrl)); |
2620 | c3d2689d | balrog | } |
2621 | c3d2689d | balrog | |
2622 | c3d2689d | balrog | static void omap_pin_cfg_init(target_phys_addr_t base, |
2623 | c3d2689d | balrog | struct omap_mpu_state_s *mpu)
|
2624 | c3d2689d | balrog | { |
2625 | c3d2689d | balrog | int iomemtype = cpu_register_io_memory(0, omap_pin_cfg_readfn, |
2626 | c3d2689d | balrog | omap_pin_cfg_writefn, mpu); |
2627 | c3d2689d | balrog | |
2628 | c3d2689d | balrog | mpu->pin_cfg_base = base; |
2629 | c3d2689d | balrog | cpu_register_physical_memory(mpu->pin_cfg_base, 0x800, iomemtype);
|
2630 | c3d2689d | balrog | omap_pin_cfg_reset(mpu); |
2631 | c3d2689d | balrog | } |
2632 | c3d2689d | balrog | |
2633 | c3d2689d | balrog | /* Device Identification, Die Identification */
|
2634 | c3d2689d | balrog | static uint32_t omap_id_read(void *opaque, target_phys_addr_t addr) |
2635 | c3d2689d | balrog | { |
2636 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2637 | c3d2689d | balrog | |
2638 | c3d2689d | balrog | switch (addr) {
|
2639 | c3d2689d | balrog | case 0xfffe1800: /* DIE_ID_LSB */ |
2640 | c3d2689d | balrog | return 0xc9581f0e; |
2641 | c3d2689d | balrog | case 0xfffe1804: /* DIE_ID_MSB */ |
2642 | c3d2689d | balrog | return 0xa8858bfa; |
2643 | c3d2689d | balrog | |
2644 | c3d2689d | balrog | case 0xfffe2000: /* PRODUCT_ID_LSB */ |
2645 | c3d2689d | balrog | return 0x00aaaafc; |
2646 | c3d2689d | balrog | case 0xfffe2004: /* PRODUCT_ID_MSB */ |
2647 | c3d2689d | balrog | return 0xcafeb574; |
2648 | c3d2689d | balrog | |
2649 | c3d2689d | balrog | case 0xfffed400: /* JTAG_ID_LSB */ |
2650 | c3d2689d | balrog | switch (s->mpu_model) {
|
2651 | c3d2689d | balrog | case omap310:
|
2652 | c3d2689d | balrog | return 0x03310315; |
2653 | c3d2689d | balrog | case omap1510:
|
2654 | c3d2689d | balrog | return 0x03310115; |
2655 | c3d2689d | balrog | } |
2656 | c3d2689d | balrog | break;
|
2657 | c3d2689d | balrog | |
2658 | c3d2689d | balrog | case 0xfffed404: /* JTAG_ID_MSB */ |
2659 | c3d2689d | balrog | switch (s->mpu_model) {
|
2660 | c3d2689d | balrog | case omap310:
|
2661 | c3d2689d | balrog | return 0xfb57402f; |
2662 | c3d2689d | balrog | case omap1510:
|
2663 | c3d2689d | balrog | return 0xfb47002f; |
2664 | c3d2689d | balrog | } |
2665 | c3d2689d | balrog | break;
|
2666 | c3d2689d | balrog | } |
2667 | c3d2689d | balrog | |
2668 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2669 | c3d2689d | balrog | return 0; |
2670 | c3d2689d | balrog | } |
2671 | c3d2689d | balrog | |
2672 | c3d2689d | balrog | static void omap_id_write(void *opaque, target_phys_addr_t addr, |
2673 | c3d2689d | balrog | uint32_t value) |
2674 | c3d2689d | balrog | { |
2675 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2676 | c3d2689d | balrog | } |
2677 | c3d2689d | balrog | |
2678 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_id_readfn[] = {
|
2679 | c3d2689d | balrog | omap_badwidth_read32, |
2680 | c3d2689d | balrog | omap_badwidth_read32, |
2681 | c3d2689d | balrog | omap_id_read, |
2682 | c3d2689d | balrog | }; |
2683 | c3d2689d | balrog | |
2684 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_id_writefn[] = {
|
2685 | c3d2689d | balrog | omap_badwidth_write32, |
2686 | c3d2689d | balrog | omap_badwidth_write32, |
2687 | c3d2689d | balrog | omap_id_write, |
2688 | c3d2689d | balrog | }; |
2689 | c3d2689d | balrog | |
2690 | c3d2689d | balrog | static void omap_id_init(struct omap_mpu_state_s *mpu) |
2691 | c3d2689d | balrog | { |
2692 | c3d2689d | balrog | int iomemtype = cpu_register_io_memory(0, omap_id_readfn, |
2693 | c3d2689d | balrog | omap_id_writefn, mpu); |
2694 | c3d2689d | balrog | cpu_register_physical_memory(0xfffe1800, 0x800, iomemtype); |
2695 | c3d2689d | balrog | cpu_register_physical_memory(0xfffed400, 0x100, iomemtype); |
2696 | c3d2689d | balrog | if (!cpu_is_omap15xx(mpu))
|
2697 | c3d2689d | balrog | cpu_register_physical_memory(0xfffe2000, 0x800, iomemtype); |
2698 | c3d2689d | balrog | } |
2699 | c3d2689d | balrog | |
2700 | c3d2689d | balrog | /* MPUI Control (Dummy) */
|
2701 | c3d2689d | balrog | static uint32_t omap_mpui_read(void *opaque, target_phys_addr_t addr) |
2702 | c3d2689d | balrog | { |
2703 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2704 | c3d2689d | balrog | int offset = addr - s->mpui_base;
|
2705 | c3d2689d | balrog | |
2706 | c3d2689d | balrog | switch (offset) {
|
2707 | c3d2689d | balrog | case 0x00: /* CTRL */ |
2708 | c3d2689d | balrog | return s->mpui_ctrl;
|
2709 | c3d2689d | balrog | case 0x04: /* DEBUG_ADDR */ |
2710 | c3d2689d | balrog | return 0x01ffffff; |
2711 | c3d2689d | balrog | case 0x08: /* DEBUG_DATA */ |
2712 | c3d2689d | balrog | return 0xffffffff; |
2713 | c3d2689d | balrog | case 0x0c: /* DEBUG_FLAG */ |
2714 | c3d2689d | balrog | return 0x00000800; |
2715 | c3d2689d | balrog | case 0x10: /* STATUS */ |
2716 | c3d2689d | balrog | return 0x00000000; |
2717 | c3d2689d | balrog | |
2718 | c3d2689d | balrog | /* Not in OMAP310 */
|
2719 | c3d2689d | balrog | case 0x14: /* DSP_STATUS */ |
2720 | c3d2689d | balrog | case 0x18: /* DSP_BOOT_CONFIG */ |
2721 | c3d2689d | balrog | return 0x00000000; |
2722 | c3d2689d | balrog | case 0x1c: /* DSP_MPUI_CONFIG */ |
2723 | c3d2689d | balrog | return 0x0000ffff; |
2724 | c3d2689d | balrog | } |
2725 | c3d2689d | balrog | |
2726 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2727 | c3d2689d | balrog | return 0; |
2728 | c3d2689d | balrog | } |
2729 | c3d2689d | balrog | |
2730 | c3d2689d | balrog | static void omap_mpui_write(void *opaque, target_phys_addr_t addr, |
2731 | c3d2689d | balrog | uint32_t value) |
2732 | c3d2689d | balrog | { |
2733 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2734 | c3d2689d | balrog | int offset = addr - s->mpui_base;
|
2735 | c3d2689d | balrog | |
2736 | c3d2689d | balrog | switch (offset) {
|
2737 | c3d2689d | balrog | case 0x00: /* CTRL */ |
2738 | c3d2689d | balrog | s->mpui_ctrl = value & 0x007fffff;
|
2739 | c3d2689d | balrog | break;
|
2740 | c3d2689d | balrog | |
2741 | c3d2689d | balrog | case 0x04: /* DEBUG_ADDR */ |
2742 | c3d2689d | balrog | case 0x08: /* DEBUG_DATA */ |
2743 | c3d2689d | balrog | case 0x0c: /* DEBUG_FLAG */ |
2744 | c3d2689d | balrog | case 0x10: /* STATUS */ |
2745 | c3d2689d | balrog | /* Not in OMAP310 */
|
2746 | c3d2689d | balrog | case 0x14: /* DSP_STATUS */ |
2747 | c3d2689d | balrog | OMAP_RO_REG(addr); |
2748 | c3d2689d | balrog | case 0x18: /* DSP_BOOT_CONFIG */ |
2749 | c3d2689d | balrog | case 0x1c: /* DSP_MPUI_CONFIG */ |
2750 | c3d2689d | balrog | break;
|
2751 | c3d2689d | balrog | |
2752 | c3d2689d | balrog | default:
|
2753 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2754 | c3d2689d | balrog | } |
2755 | c3d2689d | balrog | } |
2756 | c3d2689d | balrog | |
2757 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_mpui_readfn[] = {
|
2758 | c3d2689d | balrog | omap_badwidth_read32, |
2759 | c3d2689d | balrog | omap_badwidth_read32, |
2760 | c3d2689d | balrog | omap_mpui_read, |
2761 | c3d2689d | balrog | }; |
2762 | c3d2689d | balrog | |
2763 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_mpui_writefn[] = {
|
2764 | c3d2689d | balrog | omap_badwidth_write32, |
2765 | c3d2689d | balrog | omap_badwidth_write32, |
2766 | c3d2689d | balrog | omap_mpui_write, |
2767 | c3d2689d | balrog | }; |
2768 | c3d2689d | balrog | |
2769 | c3d2689d | balrog | static void omap_mpui_reset(struct omap_mpu_state_s *s) |
2770 | c3d2689d | balrog | { |
2771 | c3d2689d | balrog | s->mpui_ctrl = 0x0003ff1b;
|
2772 | c3d2689d | balrog | } |
2773 | c3d2689d | balrog | |
2774 | c3d2689d | balrog | static void omap_mpui_init(target_phys_addr_t base, |
2775 | c3d2689d | balrog | struct omap_mpu_state_s *mpu)
|
2776 | c3d2689d | balrog | { |
2777 | c3d2689d | balrog | int iomemtype = cpu_register_io_memory(0, omap_mpui_readfn, |
2778 | c3d2689d | balrog | omap_mpui_writefn, mpu); |
2779 | c3d2689d | balrog | |
2780 | c3d2689d | balrog | mpu->mpui_base = base; |
2781 | c3d2689d | balrog | cpu_register_physical_memory(mpu->mpui_base, 0x100, iomemtype);
|
2782 | c3d2689d | balrog | |
2783 | c3d2689d | balrog | omap_mpui_reset(mpu); |
2784 | c3d2689d | balrog | } |
2785 | c3d2689d | balrog | |
2786 | c3d2689d | balrog | /* TIPB Bridges */
|
2787 | c3d2689d | balrog | struct omap_tipb_bridge_s {
|
2788 | c3d2689d | balrog | target_phys_addr_t base; |
2789 | c3d2689d | balrog | qemu_irq abort; |
2790 | c3d2689d | balrog | |
2791 | c3d2689d | balrog | int width_intr;
|
2792 | c3d2689d | balrog | uint16_t control; |
2793 | c3d2689d | balrog | uint16_t alloc; |
2794 | c3d2689d | balrog | uint16_t buffer; |
2795 | c3d2689d | balrog | uint16_t enh_control; |
2796 | c3d2689d | balrog | }; |
2797 | c3d2689d | balrog | |
2798 | c3d2689d | balrog | static uint32_t omap_tipb_bridge_read(void *opaque, target_phys_addr_t addr) |
2799 | c3d2689d | balrog | { |
2800 | c3d2689d | balrog | struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque; |
2801 | c3d2689d | balrog | int offset = addr - s->base;
|
2802 | c3d2689d | balrog | |
2803 | c3d2689d | balrog | switch (offset) {
|
2804 | c3d2689d | balrog | case 0x00: /* TIPB_CNTL */ |
2805 | c3d2689d | balrog | return s->control;
|
2806 | c3d2689d | balrog | case 0x04: /* TIPB_BUS_ALLOC */ |
2807 | c3d2689d | balrog | return s->alloc;
|
2808 | c3d2689d | balrog | case 0x08: /* MPU_TIPB_CNTL */ |
2809 | c3d2689d | balrog | return s->buffer;
|
2810 | c3d2689d | balrog | case 0x0c: /* ENHANCED_TIPB_CNTL */ |
2811 | c3d2689d | balrog | return s->enh_control;
|
2812 | c3d2689d | balrog | case 0x10: /* ADDRESS_DBG */ |
2813 | c3d2689d | balrog | case 0x14: /* DATA_DEBUG_LOW */ |
2814 | c3d2689d | balrog | case 0x18: /* DATA_DEBUG_HIGH */ |
2815 | c3d2689d | balrog | return 0xffff; |
2816 | c3d2689d | balrog | case 0x1c: /* DEBUG_CNTR_SIG */ |
2817 | c3d2689d | balrog | return 0x00f8; |
2818 | c3d2689d | balrog | } |
2819 | c3d2689d | balrog | |
2820 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2821 | c3d2689d | balrog | return 0; |
2822 | c3d2689d | balrog | } |
2823 | c3d2689d | balrog | |
2824 | c3d2689d | balrog | static void omap_tipb_bridge_write(void *opaque, target_phys_addr_t addr, |
2825 | c3d2689d | balrog | uint32_t value) |
2826 | c3d2689d | balrog | { |
2827 | c3d2689d | balrog | struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque; |
2828 | c3d2689d | balrog | int offset = addr - s->base;
|
2829 | c3d2689d | balrog | |
2830 | c3d2689d | balrog | switch (offset) {
|
2831 | c3d2689d | balrog | case 0x00: /* TIPB_CNTL */ |
2832 | c3d2689d | balrog | s->control = value & 0xffff;
|
2833 | c3d2689d | balrog | break;
|
2834 | c3d2689d | balrog | |
2835 | c3d2689d | balrog | case 0x04: /* TIPB_BUS_ALLOC */ |
2836 | c3d2689d | balrog | s->alloc = value & 0x003f;
|
2837 | c3d2689d | balrog | break;
|
2838 | c3d2689d | balrog | |
2839 | c3d2689d | balrog | case 0x08: /* MPU_TIPB_CNTL */ |
2840 | c3d2689d | balrog | s->buffer = value & 0x0003;
|
2841 | c3d2689d | balrog | break;
|
2842 | c3d2689d | balrog | |
2843 | c3d2689d | balrog | case 0x0c: /* ENHANCED_TIPB_CNTL */ |
2844 | c3d2689d | balrog | s->width_intr = !(value & 2);
|
2845 | c3d2689d | balrog | s->enh_control = value & 0x000f;
|
2846 | c3d2689d | balrog | break;
|
2847 | c3d2689d | balrog | |
2848 | c3d2689d | balrog | case 0x10: /* ADDRESS_DBG */ |
2849 | c3d2689d | balrog | case 0x14: /* DATA_DEBUG_LOW */ |
2850 | c3d2689d | balrog | case 0x18: /* DATA_DEBUG_HIGH */ |
2851 | c3d2689d | balrog | case 0x1c: /* DEBUG_CNTR_SIG */ |
2852 | c3d2689d | balrog | OMAP_RO_REG(addr); |
2853 | c3d2689d | balrog | break;
|
2854 | c3d2689d | balrog | |
2855 | c3d2689d | balrog | default:
|
2856 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2857 | c3d2689d | balrog | } |
2858 | c3d2689d | balrog | } |
2859 | c3d2689d | balrog | |
2860 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_tipb_bridge_readfn[] = {
|
2861 | c3d2689d | balrog | omap_badwidth_read16, |
2862 | c3d2689d | balrog | omap_tipb_bridge_read, |
2863 | c3d2689d | balrog | omap_tipb_bridge_read, |
2864 | c3d2689d | balrog | }; |
2865 | c3d2689d | balrog | |
2866 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_tipb_bridge_writefn[] = {
|
2867 | c3d2689d | balrog | omap_badwidth_write16, |
2868 | c3d2689d | balrog | omap_tipb_bridge_write, |
2869 | c3d2689d | balrog | omap_tipb_bridge_write, |
2870 | c3d2689d | balrog | }; |
2871 | c3d2689d | balrog | |
2872 | c3d2689d | balrog | static void omap_tipb_bridge_reset(struct omap_tipb_bridge_s *s) |
2873 | c3d2689d | balrog | { |
2874 | c3d2689d | balrog | s->control = 0xffff;
|
2875 | c3d2689d | balrog | s->alloc = 0x0009;
|
2876 | c3d2689d | balrog | s->buffer = 0x0000;
|
2877 | c3d2689d | balrog | s->enh_control = 0x000f;
|
2878 | c3d2689d | balrog | } |
2879 | c3d2689d | balrog | |
2880 | c3d2689d | balrog | struct omap_tipb_bridge_s *omap_tipb_bridge_init(target_phys_addr_t base,
|
2881 | c3d2689d | balrog | qemu_irq abort_irq, omap_clk clk) |
2882 | c3d2689d | balrog | { |
2883 | c3d2689d | balrog | int iomemtype;
|
2884 | c3d2689d | balrog | struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) |
2885 | c3d2689d | balrog | qemu_mallocz(sizeof(struct omap_tipb_bridge_s)); |
2886 | c3d2689d | balrog | |
2887 | c3d2689d | balrog | s->abort = abort_irq; |
2888 | c3d2689d | balrog | s->base = base; |
2889 | c3d2689d | balrog | omap_tipb_bridge_reset(s); |
2890 | c3d2689d | balrog | |
2891 | c3d2689d | balrog | iomemtype = cpu_register_io_memory(0, omap_tipb_bridge_readfn,
|
2892 | c3d2689d | balrog | omap_tipb_bridge_writefn, s); |
2893 | c3d2689d | balrog | cpu_register_physical_memory(s->base, 0x100, iomemtype);
|
2894 | c3d2689d | balrog | |
2895 | c3d2689d | balrog | return s;
|
2896 | c3d2689d | balrog | } |
2897 | c3d2689d | balrog | |
2898 | c3d2689d | balrog | /* Dummy Traffic Controller's Memory Interface */
|
2899 | c3d2689d | balrog | static uint32_t omap_tcmi_read(void *opaque, target_phys_addr_t addr) |
2900 | c3d2689d | balrog | { |
2901 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2902 | c3d2689d | balrog | int offset = addr - s->tcmi_base;
|
2903 | c3d2689d | balrog | uint32_t ret; |
2904 | c3d2689d | balrog | |
2905 | c3d2689d | balrog | switch (offset) {
|
2906 | d8f699cb | balrog | case 0x00: /* IMIF_PRIO */ |
2907 | d8f699cb | balrog | case 0x04: /* EMIFS_PRIO */ |
2908 | d8f699cb | balrog | case 0x08: /* EMIFF_PRIO */ |
2909 | d8f699cb | balrog | case 0x0c: /* EMIFS_CONFIG */ |
2910 | d8f699cb | balrog | case 0x10: /* EMIFS_CS0_CONFIG */ |
2911 | d8f699cb | balrog | case 0x14: /* EMIFS_CS1_CONFIG */ |
2912 | d8f699cb | balrog | case 0x18: /* EMIFS_CS2_CONFIG */ |
2913 | d8f699cb | balrog | case 0x1c: /* EMIFS_CS3_CONFIG */ |
2914 | d8f699cb | balrog | case 0x24: /* EMIFF_MRS */ |
2915 | d8f699cb | balrog | case 0x28: /* TIMEOUT1 */ |
2916 | d8f699cb | balrog | case 0x2c: /* TIMEOUT2 */ |
2917 | d8f699cb | balrog | case 0x30: /* TIMEOUT3 */ |
2918 | d8f699cb | balrog | case 0x3c: /* EMIFF_SDRAM_CONFIG_2 */ |
2919 | d8f699cb | balrog | case 0x40: /* EMIFS_CFG_DYN_WAIT */ |
2920 | c3d2689d | balrog | return s->tcmi_regs[offset >> 2]; |
2921 | c3d2689d | balrog | |
2922 | d8f699cb | balrog | case 0x20: /* EMIFF_SDRAM_CONFIG */ |
2923 | c3d2689d | balrog | ret = s->tcmi_regs[offset >> 2];
|
2924 | c3d2689d | balrog | s->tcmi_regs[offset >> 2] &= ~1; /* XXX: Clear SLRF on SDRAM access */ |
2925 | c3d2689d | balrog | /* XXX: We can try using the VGA_DIRTY flag for this */
|
2926 | c3d2689d | balrog | return ret;
|
2927 | c3d2689d | balrog | } |
2928 | c3d2689d | balrog | |
2929 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2930 | c3d2689d | balrog | return 0; |
2931 | c3d2689d | balrog | } |
2932 | c3d2689d | balrog | |
2933 | c3d2689d | balrog | static void omap_tcmi_write(void *opaque, target_phys_addr_t addr, |
2934 | c3d2689d | balrog | uint32_t value) |
2935 | c3d2689d | balrog | { |
2936 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
2937 | c3d2689d | balrog | int offset = addr - s->tcmi_base;
|
2938 | c3d2689d | balrog | |
2939 | c3d2689d | balrog | switch (offset) {
|
2940 | d8f699cb | balrog | case 0x00: /* IMIF_PRIO */ |
2941 | d8f699cb | balrog | case 0x04: /* EMIFS_PRIO */ |
2942 | d8f699cb | balrog | case 0x08: /* EMIFF_PRIO */ |
2943 | d8f699cb | balrog | case 0x10: /* EMIFS_CS0_CONFIG */ |
2944 | d8f699cb | balrog | case 0x14: /* EMIFS_CS1_CONFIG */ |
2945 | d8f699cb | balrog | case 0x18: /* EMIFS_CS2_CONFIG */ |
2946 | d8f699cb | balrog | case 0x1c: /* EMIFS_CS3_CONFIG */ |
2947 | d8f699cb | balrog | case 0x20: /* EMIFF_SDRAM_CONFIG */ |
2948 | d8f699cb | balrog | case 0x24: /* EMIFF_MRS */ |
2949 | d8f699cb | balrog | case 0x28: /* TIMEOUT1 */ |
2950 | d8f699cb | balrog | case 0x2c: /* TIMEOUT2 */ |
2951 | d8f699cb | balrog | case 0x30: /* TIMEOUT3 */ |
2952 | d8f699cb | balrog | case 0x3c: /* EMIFF_SDRAM_CONFIG_2 */ |
2953 | d8f699cb | balrog | case 0x40: /* EMIFS_CFG_DYN_WAIT */ |
2954 | c3d2689d | balrog | s->tcmi_regs[offset >> 2] = value;
|
2955 | c3d2689d | balrog | break;
|
2956 | d8f699cb | balrog | case 0x0c: /* EMIFS_CONFIG */ |
2957 | c3d2689d | balrog | s->tcmi_regs[offset >> 2] = (value & 0xf) | (1 << 4); |
2958 | c3d2689d | balrog | break;
|
2959 | c3d2689d | balrog | |
2960 | c3d2689d | balrog | default:
|
2961 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
2962 | c3d2689d | balrog | } |
2963 | c3d2689d | balrog | } |
2964 | c3d2689d | balrog | |
2965 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_tcmi_readfn[] = {
|
2966 | c3d2689d | balrog | omap_badwidth_read32, |
2967 | c3d2689d | balrog | omap_badwidth_read32, |
2968 | c3d2689d | balrog | omap_tcmi_read, |
2969 | c3d2689d | balrog | }; |
2970 | c3d2689d | balrog | |
2971 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_tcmi_writefn[] = {
|
2972 | c3d2689d | balrog | omap_badwidth_write32, |
2973 | c3d2689d | balrog | omap_badwidth_write32, |
2974 | c3d2689d | balrog | omap_tcmi_write, |
2975 | c3d2689d | balrog | }; |
2976 | c3d2689d | balrog | |
2977 | c3d2689d | balrog | static void omap_tcmi_reset(struct omap_mpu_state_s *mpu) |
2978 | c3d2689d | balrog | { |
2979 | c3d2689d | balrog | mpu->tcmi_regs[0x00 >> 2] = 0x00000000; |
2980 | c3d2689d | balrog | mpu->tcmi_regs[0x04 >> 2] = 0x00000000; |
2981 | c3d2689d | balrog | mpu->tcmi_regs[0x08 >> 2] = 0x00000000; |
2982 | c3d2689d | balrog | mpu->tcmi_regs[0x0c >> 2] = 0x00000010; |
2983 | c3d2689d | balrog | mpu->tcmi_regs[0x10 >> 2] = 0x0010fffb; |
2984 | c3d2689d | balrog | mpu->tcmi_regs[0x14 >> 2] = 0x0010fffb; |
2985 | c3d2689d | balrog | mpu->tcmi_regs[0x18 >> 2] = 0x0010fffb; |
2986 | c3d2689d | balrog | mpu->tcmi_regs[0x1c >> 2] = 0x0010fffb; |
2987 | c3d2689d | balrog | mpu->tcmi_regs[0x20 >> 2] = 0x00618800; |
2988 | c3d2689d | balrog | mpu->tcmi_regs[0x24 >> 2] = 0x00000037; |
2989 | c3d2689d | balrog | mpu->tcmi_regs[0x28 >> 2] = 0x00000000; |
2990 | c3d2689d | balrog | mpu->tcmi_regs[0x2c >> 2] = 0x00000000; |
2991 | c3d2689d | balrog | mpu->tcmi_regs[0x30 >> 2] = 0x00000000; |
2992 | c3d2689d | balrog | mpu->tcmi_regs[0x3c >> 2] = 0x00000003; |
2993 | c3d2689d | balrog | mpu->tcmi_regs[0x40 >> 2] = 0x00000000; |
2994 | c3d2689d | balrog | } |
2995 | c3d2689d | balrog | |
2996 | c3d2689d | balrog | static void omap_tcmi_init(target_phys_addr_t base, |
2997 | c3d2689d | balrog | struct omap_mpu_state_s *mpu)
|
2998 | c3d2689d | balrog | { |
2999 | c3d2689d | balrog | int iomemtype = cpu_register_io_memory(0, omap_tcmi_readfn, |
3000 | c3d2689d | balrog | omap_tcmi_writefn, mpu); |
3001 | c3d2689d | balrog | |
3002 | c3d2689d | balrog | mpu->tcmi_base = base; |
3003 | c3d2689d | balrog | cpu_register_physical_memory(mpu->tcmi_base, 0x100, iomemtype);
|
3004 | c3d2689d | balrog | omap_tcmi_reset(mpu); |
3005 | c3d2689d | balrog | } |
3006 | c3d2689d | balrog | |
3007 | c3d2689d | balrog | /* Digital phase-locked loops control */
|
3008 | c3d2689d | balrog | static uint32_t omap_dpll_read(void *opaque, target_phys_addr_t addr) |
3009 | c3d2689d | balrog | { |
3010 | c3d2689d | balrog | struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque; |
3011 | c3d2689d | balrog | int offset = addr - s->base;
|
3012 | c3d2689d | balrog | |
3013 | c3d2689d | balrog | if (offset == 0x00) /* CTL_REG */ |
3014 | c3d2689d | balrog | return s->mode;
|
3015 | c3d2689d | balrog | |
3016 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
3017 | c3d2689d | balrog | return 0; |
3018 | c3d2689d | balrog | } |
3019 | c3d2689d | balrog | |
3020 | c3d2689d | balrog | static void omap_dpll_write(void *opaque, target_phys_addr_t addr, |
3021 | c3d2689d | balrog | uint32_t value) |
3022 | c3d2689d | balrog | { |
3023 | c3d2689d | balrog | struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque; |
3024 | c3d2689d | balrog | uint16_t diff; |
3025 | c3d2689d | balrog | int offset = addr - s->base;
|
3026 | c3d2689d | balrog | static const int bypass_div[4] = { 1, 2, 4, 4 }; |
3027 | c3d2689d | balrog | int div, mult;
|
3028 | c3d2689d | balrog | |
3029 | c3d2689d | balrog | if (offset == 0x00) { /* CTL_REG */ |
3030 | c3d2689d | balrog | /* See omap_ulpd_pm_write() too */
|
3031 | c3d2689d | balrog | diff = s->mode & value; |
3032 | c3d2689d | balrog | s->mode = value & 0x2fff;
|
3033 | c3d2689d | balrog | if (diff & (0x3ff << 2)) { |
3034 | c3d2689d | balrog | if (value & (1 << 4)) { /* PLL_ENABLE */ |
3035 | c3d2689d | balrog | div = ((value >> 5) & 3) + 1; /* PLL_DIV */ |
3036 | c3d2689d | balrog | mult = MIN((value >> 7) & 0x1f, 1); /* PLL_MULT */ |
3037 | c3d2689d | balrog | } else {
|
3038 | c3d2689d | balrog | div = bypass_div[((value >> 2) & 3)]; /* BYPASS_DIV */ |
3039 | c3d2689d | balrog | mult = 1;
|
3040 | c3d2689d | balrog | } |
3041 | c3d2689d | balrog | omap_clk_setrate(s->dpll, div, mult); |
3042 | c3d2689d | balrog | } |
3043 | c3d2689d | balrog | |
3044 | c3d2689d | balrog | /* Enter the desired mode. */
|
3045 | c3d2689d | balrog | s->mode = (s->mode & 0xfffe) | ((s->mode >> 4) & 1); |
3046 | c3d2689d | balrog | |
3047 | c3d2689d | balrog | /* Act as if the lock is restored. */
|
3048 | c3d2689d | balrog | s->mode |= 2;
|
3049 | c3d2689d | balrog | } else {
|
3050 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
3051 | c3d2689d | balrog | } |
3052 | c3d2689d | balrog | } |
3053 | c3d2689d | balrog | |
3054 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_dpll_readfn[] = {
|
3055 | c3d2689d | balrog | omap_badwidth_read16, |
3056 | c3d2689d | balrog | omap_dpll_read, |
3057 | c3d2689d | balrog | omap_badwidth_read16, |
3058 | c3d2689d | balrog | }; |
3059 | c3d2689d | balrog | |
3060 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_dpll_writefn[] = {
|
3061 | c3d2689d | balrog | omap_badwidth_write16, |
3062 | c3d2689d | balrog | omap_dpll_write, |
3063 | c3d2689d | balrog | omap_badwidth_write16, |
3064 | c3d2689d | balrog | }; |
3065 | c3d2689d | balrog | |
3066 | c3d2689d | balrog | static void omap_dpll_reset(struct dpll_ctl_s *s) |
3067 | c3d2689d | balrog | { |
3068 | c3d2689d | balrog | s->mode = 0x2002;
|
3069 | c3d2689d | balrog | omap_clk_setrate(s->dpll, 1, 1); |
3070 | c3d2689d | balrog | } |
3071 | c3d2689d | balrog | |
3072 | c3d2689d | balrog | static void omap_dpll_init(struct dpll_ctl_s *s, target_phys_addr_t base, |
3073 | c3d2689d | balrog | omap_clk clk) |
3074 | c3d2689d | balrog | { |
3075 | c3d2689d | balrog | int iomemtype = cpu_register_io_memory(0, omap_dpll_readfn, |
3076 | c3d2689d | balrog | omap_dpll_writefn, s); |
3077 | c3d2689d | balrog | |
3078 | c3d2689d | balrog | s->base = base; |
3079 | c3d2689d | balrog | s->dpll = clk; |
3080 | c3d2689d | balrog | omap_dpll_reset(s); |
3081 | c3d2689d | balrog | |
3082 | c3d2689d | balrog | cpu_register_physical_memory(s->base, 0x100, iomemtype);
|
3083 | c3d2689d | balrog | } |
3084 | c3d2689d | balrog | |
3085 | c3d2689d | balrog | /* UARTs */
|
3086 | c3d2689d | balrog | struct omap_uart_s {
|
3087 | c3d2689d | balrog | SerialState *serial; /* TODO */
|
3088 | c3d2689d | balrog | }; |
3089 | c3d2689d | balrog | |
3090 | c3d2689d | balrog | static void omap_uart_reset(struct omap_uart_s *s) |
3091 | c3d2689d | balrog | { |
3092 | c3d2689d | balrog | } |
3093 | c3d2689d | balrog | |
3094 | c3d2689d | balrog | struct omap_uart_s *omap_uart_init(target_phys_addr_t base,
|
3095 | c3d2689d | balrog | qemu_irq irq, omap_clk clk, CharDriverState *chr) |
3096 | c3d2689d | balrog | { |
3097 | c3d2689d | balrog | struct omap_uart_s *s = (struct omap_uart_s *) |
3098 | c3d2689d | balrog | qemu_mallocz(sizeof(struct omap_uart_s)); |
3099 | c3d2689d | balrog | if (chr)
|
3100 | c3d2689d | balrog | s->serial = serial_mm_init(base, 2, irq, chr, 1); |
3101 | c3d2689d | balrog | return s;
|
3102 | c3d2689d | balrog | } |
3103 | c3d2689d | balrog | |
3104 | c3d2689d | balrog | /* MPU Clock/Reset/Power Mode Control */
|
3105 | c3d2689d | balrog | static uint32_t omap_clkm_read(void *opaque, target_phys_addr_t addr) |
3106 | c3d2689d | balrog | { |
3107 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
3108 | c3d2689d | balrog | int offset = addr - s->clkm.mpu_base;
|
3109 | c3d2689d | balrog | |
3110 | c3d2689d | balrog | switch (offset) {
|
3111 | c3d2689d | balrog | case 0x00: /* ARM_CKCTL */ |
3112 | c3d2689d | balrog | return s->clkm.arm_ckctl;
|
3113 | c3d2689d | balrog | |
3114 | c3d2689d | balrog | case 0x04: /* ARM_IDLECT1 */ |
3115 | c3d2689d | balrog | return s->clkm.arm_idlect1;
|
3116 | c3d2689d | balrog | |
3117 | c3d2689d | balrog | case 0x08: /* ARM_IDLECT2 */ |
3118 | c3d2689d | balrog | return s->clkm.arm_idlect2;
|
3119 | c3d2689d | balrog | |
3120 | c3d2689d | balrog | case 0x0c: /* ARM_EWUPCT */ |
3121 | c3d2689d | balrog | return s->clkm.arm_ewupct;
|
3122 | c3d2689d | balrog | |
3123 | c3d2689d | balrog | case 0x10: /* ARM_RSTCT1 */ |
3124 | c3d2689d | balrog | return s->clkm.arm_rstct1;
|
3125 | c3d2689d | balrog | |
3126 | c3d2689d | balrog | case 0x14: /* ARM_RSTCT2 */ |
3127 | c3d2689d | balrog | return s->clkm.arm_rstct2;
|
3128 | c3d2689d | balrog | |
3129 | c3d2689d | balrog | case 0x18: /* ARM_SYSST */ |
3130 | d8f699cb | balrog | return (s->clkm.clocking_scheme << 11) | s->clkm.cold_start; |
3131 | c3d2689d | balrog | |
3132 | c3d2689d | balrog | case 0x1c: /* ARM_CKOUT1 */ |
3133 | c3d2689d | balrog | return s->clkm.arm_ckout1;
|
3134 | c3d2689d | balrog | |
3135 | c3d2689d | balrog | case 0x20: /* ARM_CKOUT2 */ |
3136 | c3d2689d | balrog | break;
|
3137 | c3d2689d | balrog | } |
3138 | c3d2689d | balrog | |
3139 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
3140 | c3d2689d | balrog | return 0; |
3141 | c3d2689d | balrog | } |
3142 | c3d2689d | balrog | |
3143 | c3d2689d | balrog | static inline void omap_clkm_ckctl_update(struct omap_mpu_state_s *s, |
3144 | c3d2689d | balrog | uint16_t diff, uint16_t value) |
3145 | c3d2689d | balrog | { |
3146 | c3d2689d | balrog | omap_clk clk; |
3147 | c3d2689d | balrog | |
3148 | c3d2689d | balrog | if (diff & (1 << 14)) { /* ARM_INTHCK_SEL */ |
3149 | c3d2689d | balrog | if (value & (1 << 14)) |
3150 | c3d2689d | balrog | /* Reserved */;
|
3151 | c3d2689d | balrog | else {
|
3152 | c3d2689d | balrog | clk = omap_findclk(s, "arminth_ck");
|
3153 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "tc_ck"));
|
3154 | c3d2689d | balrog | } |
3155 | c3d2689d | balrog | } |
3156 | c3d2689d | balrog | if (diff & (1 << 12)) { /* ARM_TIMXO */ |
3157 | c3d2689d | balrog | clk = omap_findclk(s, "armtim_ck");
|
3158 | c3d2689d | balrog | if (value & (1 << 12)) |
3159 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "clkin"));
|
3160 | c3d2689d | balrog | else
|
3161 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "ck_gen1"));
|
3162 | c3d2689d | balrog | } |
3163 | c3d2689d | balrog | /* XXX: en_dspck */
|
3164 | c3d2689d | balrog | if (diff & (3 << 10)) { /* DSPMMUDIV */ |
3165 | c3d2689d | balrog | clk = omap_findclk(s, "dspmmu_ck");
|
3166 | c3d2689d | balrog | omap_clk_setrate(clk, 1 << ((value >> 10) & 3), 1); |
3167 | c3d2689d | balrog | } |
3168 | c3d2689d | balrog | if (diff & (3 << 8)) { /* TCDIV */ |
3169 | c3d2689d | balrog | clk = omap_findclk(s, "tc_ck");
|
3170 | c3d2689d | balrog | omap_clk_setrate(clk, 1 << ((value >> 8) & 3), 1); |
3171 | c3d2689d | balrog | } |
3172 | c3d2689d | balrog | if (diff & (3 << 6)) { /* DSPDIV */ |
3173 | c3d2689d | balrog | clk = omap_findclk(s, "dsp_ck");
|
3174 | c3d2689d | balrog | omap_clk_setrate(clk, 1 << ((value >> 6) & 3), 1); |
3175 | c3d2689d | balrog | } |
3176 | c3d2689d | balrog | if (diff & (3 << 4)) { /* ARMDIV */ |
3177 | c3d2689d | balrog | clk = omap_findclk(s, "arm_ck");
|
3178 | c3d2689d | balrog | omap_clk_setrate(clk, 1 << ((value >> 4) & 3), 1); |
3179 | c3d2689d | balrog | } |
3180 | c3d2689d | balrog | if (diff & (3 << 2)) { /* LCDDIV */ |
3181 | c3d2689d | balrog | clk = omap_findclk(s, "lcd_ck");
|
3182 | c3d2689d | balrog | omap_clk_setrate(clk, 1 << ((value >> 2) & 3), 1); |
3183 | c3d2689d | balrog | } |
3184 | c3d2689d | balrog | if (diff & (3 << 0)) { /* PERDIV */ |
3185 | c3d2689d | balrog | clk = omap_findclk(s, "armper_ck");
|
3186 | c3d2689d | balrog | omap_clk_setrate(clk, 1 << ((value >> 0) & 3), 1); |
3187 | c3d2689d | balrog | } |
3188 | c3d2689d | balrog | } |
3189 | c3d2689d | balrog | |
3190 | c3d2689d | balrog | static inline void omap_clkm_idlect1_update(struct omap_mpu_state_s *s, |
3191 | c3d2689d | balrog | uint16_t diff, uint16_t value) |
3192 | c3d2689d | balrog | { |
3193 | c3d2689d | balrog | omap_clk clk; |
3194 | c3d2689d | balrog | |
3195 | c3d2689d | balrog | if (value & (1 << 11)) /* SETARM_IDLE */ |
3196 | c3d2689d | balrog | cpu_interrupt(s->env, CPU_INTERRUPT_HALT); |
3197 | c3d2689d | balrog | if (!(value & (1 << 10))) /* WKUP_MODE */ |
3198 | c3d2689d | balrog | qemu_system_shutdown_request(); /* XXX: disable wakeup from IRQ */
|
3199 | c3d2689d | balrog | |
3200 | c3d2689d | balrog | #define SET_CANIDLE(clock, bit) \
|
3201 | c3d2689d | balrog | if (diff & (1 << bit)) { \ |
3202 | c3d2689d | balrog | clk = omap_findclk(s, clock); \ |
3203 | c3d2689d | balrog | omap_clk_canidle(clk, (value >> bit) & 1); \
|
3204 | c3d2689d | balrog | } |
3205 | c3d2689d | balrog | SET_CANIDLE("mpuwd_ck", 0) /* IDLWDT_ARM */ |
3206 | c3d2689d | balrog | SET_CANIDLE("armxor_ck", 1) /* IDLXORP_ARM */ |
3207 | c3d2689d | balrog | SET_CANIDLE("mpuper_ck", 2) /* IDLPER_ARM */ |
3208 | c3d2689d | balrog | SET_CANIDLE("lcd_ck", 3) /* IDLLCD_ARM */ |
3209 | c3d2689d | balrog | SET_CANIDLE("lb_ck", 4) /* IDLLB_ARM */ |
3210 | c3d2689d | balrog | SET_CANIDLE("hsab_ck", 5) /* IDLHSAB_ARM */ |
3211 | c3d2689d | balrog | SET_CANIDLE("tipb_ck", 6) /* IDLIF_ARM */ |
3212 | c3d2689d | balrog | SET_CANIDLE("dma_ck", 6) /* IDLIF_ARM */ |
3213 | c3d2689d | balrog | SET_CANIDLE("tc_ck", 6) /* IDLIF_ARM */ |
3214 | c3d2689d | balrog | SET_CANIDLE("dpll1", 7) /* IDLDPLL_ARM */ |
3215 | c3d2689d | balrog | SET_CANIDLE("dpll2", 7) /* IDLDPLL_ARM */ |
3216 | c3d2689d | balrog | SET_CANIDLE("dpll3", 7) /* IDLDPLL_ARM */ |
3217 | c3d2689d | balrog | SET_CANIDLE("mpui_ck", 8) /* IDLAPI_ARM */ |
3218 | c3d2689d | balrog | SET_CANIDLE("armtim_ck", 9) /* IDLTIM_ARM */ |
3219 | c3d2689d | balrog | } |
3220 | c3d2689d | balrog | |
3221 | c3d2689d | balrog | static inline void omap_clkm_idlect2_update(struct omap_mpu_state_s *s, |
3222 | c3d2689d | balrog | uint16_t diff, uint16_t value) |
3223 | c3d2689d | balrog | { |
3224 | c3d2689d | balrog | omap_clk clk; |
3225 | c3d2689d | balrog | |
3226 | c3d2689d | balrog | #define SET_ONOFF(clock, bit) \
|
3227 | c3d2689d | balrog | if (diff & (1 << bit)) { \ |
3228 | c3d2689d | balrog | clk = omap_findclk(s, clock); \ |
3229 | c3d2689d | balrog | omap_clk_onoff(clk, (value >> bit) & 1); \
|
3230 | c3d2689d | balrog | } |
3231 | c3d2689d | balrog | SET_ONOFF("mpuwd_ck", 0) /* EN_WDTCK */ |
3232 | c3d2689d | balrog | SET_ONOFF("armxor_ck", 1) /* EN_XORPCK */ |
3233 | c3d2689d | balrog | SET_ONOFF("mpuper_ck", 2) /* EN_PERCK */ |
3234 | c3d2689d | balrog | SET_ONOFF("lcd_ck", 3) /* EN_LCDCK */ |
3235 | c3d2689d | balrog | SET_ONOFF("lb_ck", 4) /* EN_LBCK */ |
3236 | c3d2689d | balrog | SET_ONOFF("hsab_ck", 5) /* EN_HSABCK */ |
3237 | c3d2689d | balrog | SET_ONOFF("mpui_ck", 6) /* EN_APICK */ |
3238 | c3d2689d | balrog | SET_ONOFF("armtim_ck", 7) /* EN_TIMCK */ |
3239 | c3d2689d | balrog | SET_CANIDLE("dma_ck", 8) /* DMACK_REQ */ |
3240 | c3d2689d | balrog | SET_ONOFF("arm_gpio_ck", 9) /* EN_GPIOCK */ |
3241 | c3d2689d | balrog | SET_ONOFF("lbfree_ck", 10) /* EN_LBFREECK */ |
3242 | c3d2689d | balrog | } |
3243 | c3d2689d | balrog | |
3244 | c3d2689d | balrog | static inline void omap_clkm_ckout1_update(struct omap_mpu_state_s *s, |
3245 | c3d2689d | balrog | uint16_t diff, uint16_t value) |
3246 | c3d2689d | balrog | { |
3247 | c3d2689d | balrog | omap_clk clk; |
3248 | c3d2689d | balrog | |
3249 | c3d2689d | balrog | if (diff & (3 << 4)) { /* TCLKOUT */ |
3250 | c3d2689d | balrog | clk = omap_findclk(s, "tclk_out");
|
3251 | c3d2689d | balrog | switch ((value >> 4) & 3) { |
3252 | c3d2689d | balrog | case 1: |
3253 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "ck_gen3"));
|
3254 | c3d2689d | balrog | omap_clk_onoff(clk, 1);
|
3255 | c3d2689d | balrog | break;
|
3256 | c3d2689d | balrog | case 2: |
3257 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "tc_ck"));
|
3258 | c3d2689d | balrog | omap_clk_onoff(clk, 1);
|
3259 | c3d2689d | balrog | break;
|
3260 | c3d2689d | balrog | default:
|
3261 | c3d2689d | balrog | omap_clk_onoff(clk, 0);
|
3262 | c3d2689d | balrog | } |
3263 | c3d2689d | balrog | } |
3264 | c3d2689d | balrog | if (diff & (3 << 2)) { /* DCLKOUT */ |
3265 | c3d2689d | balrog | clk = omap_findclk(s, "dclk_out");
|
3266 | c3d2689d | balrog | switch ((value >> 2) & 3) { |
3267 | c3d2689d | balrog | case 0: |
3268 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "dspmmu_ck"));
|
3269 | c3d2689d | balrog | break;
|
3270 | c3d2689d | balrog | case 1: |
3271 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "ck_gen2"));
|
3272 | c3d2689d | balrog | break;
|
3273 | c3d2689d | balrog | case 2: |
3274 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "dsp_ck"));
|
3275 | c3d2689d | balrog | break;
|
3276 | c3d2689d | balrog | case 3: |
3277 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "ck_ref14"));
|
3278 | c3d2689d | balrog | break;
|
3279 | c3d2689d | balrog | } |
3280 | c3d2689d | balrog | } |
3281 | c3d2689d | balrog | if (diff & (3 << 0)) { /* ACLKOUT */ |
3282 | c3d2689d | balrog | clk = omap_findclk(s, "aclk_out");
|
3283 | c3d2689d | balrog | switch ((value >> 0) & 3) { |
3284 | c3d2689d | balrog | case 1: |
3285 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "ck_gen1"));
|
3286 | c3d2689d | balrog | omap_clk_onoff(clk, 1);
|
3287 | c3d2689d | balrog | break;
|
3288 | c3d2689d | balrog | case 2: |
3289 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "arm_ck"));
|
3290 | c3d2689d | balrog | omap_clk_onoff(clk, 1);
|
3291 | c3d2689d | balrog | break;
|
3292 | c3d2689d | balrog | case 3: |
3293 | c3d2689d | balrog | omap_clk_reparent(clk, omap_findclk(s, "ck_ref14"));
|
3294 | c3d2689d | balrog | omap_clk_onoff(clk, 1);
|
3295 | c3d2689d | balrog | break;
|
3296 | c3d2689d | balrog | default:
|
3297 | c3d2689d | balrog | omap_clk_onoff(clk, 0);
|
3298 | c3d2689d | balrog | } |
3299 | c3d2689d | balrog | } |
3300 | c3d2689d | balrog | } |
3301 | c3d2689d | balrog | |
3302 | c3d2689d | balrog | static void omap_clkm_write(void *opaque, target_phys_addr_t addr, |
3303 | c3d2689d | balrog | uint32_t value) |
3304 | c3d2689d | balrog | { |
3305 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
3306 | c3d2689d | balrog | int offset = addr - s->clkm.mpu_base;
|
3307 | c3d2689d | balrog | uint16_t diff; |
3308 | c3d2689d | balrog | omap_clk clk; |
3309 | c3d2689d | balrog | static const char *clkschemename[8] = { |
3310 | c3d2689d | balrog | "fully synchronous", "fully asynchronous", "synchronous scalable", |
3311 | c3d2689d | balrog | "mix mode 1", "mix mode 2", "bypass mode", "mix mode 3", "mix mode 4", |
3312 | c3d2689d | balrog | }; |
3313 | c3d2689d | balrog | |
3314 | c3d2689d | balrog | switch (offset) {
|
3315 | c3d2689d | balrog | case 0x00: /* ARM_CKCTL */ |
3316 | c3d2689d | balrog | diff = s->clkm.arm_ckctl ^ value; |
3317 | c3d2689d | balrog | s->clkm.arm_ckctl = value & 0x7fff;
|
3318 | c3d2689d | balrog | omap_clkm_ckctl_update(s, diff, value); |
3319 | c3d2689d | balrog | return;
|
3320 | c3d2689d | balrog | |
3321 | c3d2689d | balrog | case 0x04: /* ARM_IDLECT1 */ |
3322 | c3d2689d | balrog | diff = s->clkm.arm_idlect1 ^ value; |
3323 | c3d2689d | balrog | s->clkm.arm_idlect1 = value & 0x0fff;
|
3324 | c3d2689d | balrog | omap_clkm_idlect1_update(s, diff, value); |
3325 | c3d2689d | balrog | return;
|
3326 | c3d2689d | balrog | |
3327 | c3d2689d | balrog | case 0x08: /* ARM_IDLECT2 */ |
3328 | c3d2689d | balrog | diff = s->clkm.arm_idlect2 ^ value; |
3329 | c3d2689d | balrog | s->clkm.arm_idlect2 = value & 0x07ff;
|
3330 | c3d2689d | balrog | omap_clkm_idlect2_update(s, diff, value); |
3331 | c3d2689d | balrog | return;
|
3332 | c3d2689d | balrog | |
3333 | c3d2689d | balrog | case 0x0c: /* ARM_EWUPCT */ |
3334 | c3d2689d | balrog | diff = s->clkm.arm_ewupct ^ value; |
3335 | c3d2689d | balrog | s->clkm.arm_ewupct = value & 0x003f;
|
3336 | c3d2689d | balrog | return;
|
3337 | c3d2689d | balrog | |
3338 | c3d2689d | balrog | case 0x10: /* ARM_RSTCT1 */ |
3339 | c3d2689d | balrog | diff = s->clkm.arm_rstct1 ^ value; |
3340 | c3d2689d | balrog | s->clkm.arm_rstct1 = value & 0x0007;
|
3341 | c3d2689d | balrog | if (value & 9) { |
3342 | c3d2689d | balrog | qemu_system_reset_request(); |
3343 | c3d2689d | balrog | s->clkm.cold_start = 0xa;
|
3344 | c3d2689d | balrog | } |
3345 | c3d2689d | balrog | if (diff & ~value & 4) { /* DSP_RST */ |
3346 | c3d2689d | balrog | omap_mpui_reset(s); |
3347 | c3d2689d | balrog | omap_tipb_bridge_reset(s->private_tipb); |
3348 | c3d2689d | balrog | omap_tipb_bridge_reset(s->public_tipb); |
3349 | c3d2689d | balrog | } |
3350 | c3d2689d | balrog | if (diff & 2) { /* DSP_EN */ |
3351 | c3d2689d | balrog | clk = omap_findclk(s, "dsp_ck");
|
3352 | c3d2689d | balrog | omap_clk_canidle(clk, (~value >> 1) & 1); |
3353 | c3d2689d | balrog | } |
3354 | c3d2689d | balrog | return;
|
3355 | c3d2689d | balrog | |
3356 | c3d2689d | balrog | case 0x14: /* ARM_RSTCT2 */ |
3357 | c3d2689d | balrog | s->clkm.arm_rstct2 = value & 0x0001;
|
3358 | c3d2689d | balrog | return;
|
3359 | c3d2689d | balrog | |
3360 | c3d2689d | balrog | case 0x18: /* ARM_SYSST */ |
3361 | c3d2689d | balrog | if ((s->clkm.clocking_scheme ^ (value >> 11)) & 7) { |
3362 | c3d2689d | balrog | s->clkm.clocking_scheme = (value >> 11) & 7; |
3363 | c3d2689d | balrog | printf("%s: clocking scheme set to %s\n", __FUNCTION__,
|
3364 | c3d2689d | balrog | clkschemename[s->clkm.clocking_scheme]); |
3365 | c3d2689d | balrog | } |
3366 | c3d2689d | balrog | s->clkm.cold_start &= value & 0x3f;
|
3367 | c3d2689d | balrog | return;
|
3368 | c3d2689d | balrog | |
3369 | c3d2689d | balrog | case 0x1c: /* ARM_CKOUT1 */ |
3370 | c3d2689d | balrog | diff = s->clkm.arm_ckout1 ^ value; |
3371 | c3d2689d | balrog | s->clkm.arm_ckout1 = value & 0x003f;
|
3372 | c3d2689d | balrog | omap_clkm_ckout1_update(s, diff, value); |
3373 | c3d2689d | balrog | return;
|
3374 | c3d2689d | balrog | |
3375 | c3d2689d | balrog | case 0x20: /* ARM_CKOUT2 */ |
3376 | c3d2689d | balrog | default:
|
3377 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
3378 | c3d2689d | balrog | } |
3379 | c3d2689d | balrog | } |
3380 | c3d2689d | balrog | |
3381 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_clkm_readfn[] = {
|
3382 | c3d2689d | balrog | omap_badwidth_read16, |
3383 | c3d2689d | balrog | omap_clkm_read, |
3384 | c3d2689d | balrog | omap_badwidth_read16, |
3385 | c3d2689d | balrog | }; |
3386 | c3d2689d | balrog | |
3387 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_clkm_writefn[] = {
|
3388 | c3d2689d | balrog | omap_badwidth_write16, |
3389 | c3d2689d | balrog | omap_clkm_write, |
3390 | c3d2689d | balrog | omap_badwidth_write16, |
3391 | c3d2689d | balrog | }; |
3392 | c3d2689d | balrog | |
3393 | c3d2689d | balrog | static uint32_t omap_clkdsp_read(void *opaque, target_phys_addr_t addr) |
3394 | c3d2689d | balrog | { |
3395 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
3396 | c3d2689d | balrog | int offset = addr - s->clkm.dsp_base;
|
3397 | c3d2689d | balrog | |
3398 | c3d2689d | balrog | switch (offset) {
|
3399 | c3d2689d | balrog | case 0x04: /* DSP_IDLECT1 */ |
3400 | c3d2689d | balrog | return s->clkm.dsp_idlect1;
|
3401 | c3d2689d | balrog | |
3402 | c3d2689d | balrog | case 0x08: /* DSP_IDLECT2 */ |
3403 | c3d2689d | balrog | return s->clkm.dsp_idlect2;
|
3404 | c3d2689d | balrog | |
3405 | c3d2689d | balrog | case 0x14: /* DSP_RSTCT2 */ |
3406 | c3d2689d | balrog | return s->clkm.dsp_rstct2;
|
3407 | c3d2689d | balrog | |
3408 | c3d2689d | balrog | case 0x18: /* DSP_SYSST */ |
3409 | d8f699cb | balrog | return (s->clkm.clocking_scheme << 11) | s->clkm.cold_start | |
3410 | c3d2689d | balrog | (s->env->halted << 6); /* Quite useless... */ |
3411 | c3d2689d | balrog | } |
3412 | c3d2689d | balrog | |
3413 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
3414 | c3d2689d | balrog | return 0; |
3415 | c3d2689d | balrog | } |
3416 | c3d2689d | balrog | |
3417 | c3d2689d | balrog | static inline void omap_clkdsp_idlect1_update(struct omap_mpu_state_s *s, |
3418 | c3d2689d | balrog | uint16_t diff, uint16_t value) |
3419 | c3d2689d | balrog | { |
3420 | c3d2689d | balrog | omap_clk clk; |
3421 | c3d2689d | balrog | |
3422 | c3d2689d | balrog | SET_CANIDLE("dspxor_ck", 1); /* IDLXORP_DSP */ |
3423 | c3d2689d | balrog | } |
3424 | c3d2689d | balrog | |
3425 | c3d2689d | balrog | static inline void omap_clkdsp_idlect2_update(struct omap_mpu_state_s *s, |
3426 | c3d2689d | balrog | uint16_t diff, uint16_t value) |
3427 | c3d2689d | balrog | { |
3428 | c3d2689d | balrog | omap_clk clk; |
3429 | c3d2689d | balrog | |
3430 | c3d2689d | balrog | SET_ONOFF("dspxor_ck", 1); /* EN_XORPCK */ |
3431 | c3d2689d | balrog | } |
3432 | c3d2689d | balrog | |
3433 | c3d2689d | balrog | static void omap_clkdsp_write(void *opaque, target_phys_addr_t addr, |
3434 | c3d2689d | balrog | uint32_t value) |
3435 | c3d2689d | balrog | { |
3436 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
3437 | c3d2689d | balrog | int offset = addr - s->clkm.dsp_base;
|
3438 | c3d2689d | balrog | uint16_t diff; |
3439 | c3d2689d | balrog | |
3440 | c3d2689d | balrog | switch (offset) {
|
3441 | c3d2689d | balrog | case 0x04: /* DSP_IDLECT1 */ |
3442 | c3d2689d | balrog | diff = s->clkm.dsp_idlect1 ^ value; |
3443 | c3d2689d | balrog | s->clkm.dsp_idlect1 = value & 0x01f7;
|
3444 | c3d2689d | balrog | omap_clkdsp_idlect1_update(s, diff, value); |
3445 | c3d2689d | balrog | break;
|
3446 | c3d2689d | balrog | |
3447 | c3d2689d | balrog | case 0x08: /* DSP_IDLECT2 */ |
3448 | c3d2689d | balrog | s->clkm.dsp_idlect2 = value & 0x0037;
|
3449 | c3d2689d | balrog | diff = s->clkm.dsp_idlect1 ^ value; |
3450 | c3d2689d | balrog | omap_clkdsp_idlect2_update(s, diff, value); |
3451 | c3d2689d | balrog | break;
|
3452 | c3d2689d | balrog | |
3453 | c3d2689d | balrog | case 0x14: /* DSP_RSTCT2 */ |
3454 | c3d2689d | balrog | s->clkm.dsp_rstct2 = value & 0x0001;
|
3455 | c3d2689d | balrog | break;
|
3456 | c3d2689d | balrog | |
3457 | c3d2689d | balrog | case 0x18: /* DSP_SYSST */ |
3458 | c3d2689d | balrog | s->clkm.cold_start &= value & 0x3f;
|
3459 | c3d2689d | balrog | break;
|
3460 | c3d2689d | balrog | |
3461 | c3d2689d | balrog | default:
|
3462 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
3463 | c3d2689d | balrog | } |
3464 | c3d2689d | balrog | } |
3465 | c3d2689d | balrog | |
3466 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_clkdsp_readfn[] = {
|
3467 | c3d2689d | balrog | omap_badwidth_read16, |
3468 | c3d2689d | balrog | omap_clkdsp_read, |
3469 | c3d2689d | balrog | omap_badwidth_read16, |
3470 | c3d2689d | balrog | }; |
3471 | c3d2689d | balrog | |
3472 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_clkdsp_writefn[] = {
|
3473 | c3d2689d | balrog | omap_badwidth_write16, |
3474 | c3d2689d | balrog | omap_clkdsp_write, |
3475 | c3d2689d | balrog | omap_badwidth_write16, |
3476 | c3d2689d | balrog | }; |
3477 | c3d2689d | balrog | |
3478 | c3d2689d | balrog | static void omap_clkm_reset(struct omap_mpu_state_s *s) |
3479 | c3d2689d | balrog | { |
3480 | c3d2689d | balrog | if (s->wdt && s->wdt->reset)
|
3481 | c3d2689d | balrog | s->clkm.cold_start = 0x6;
|
3482 | c3d2689d | balrog | s->clkm.clocking_scheme = 0;
|
3483 | c3d2689d | balrog | omap_clkm_ckctl_update(s, ~0, 0x3000); |
3484 | c3d2689d | balrog | s->clkm.arm_ckctl = 0x3000;
|
3485 | d8f699cb | balrog | omap_clkm_idlect1_update(s, s->clkm.arm_idlect1 ^ 0x0400, 0x0400); |
3486 | c3d2689d | balrog | s->clkm.arm_idlect1 = 0x0400;
|
3487 | d8f699cb | balrog | omap_clkm_idlect2_update(s, s->clkm.arm_idlect2 ^ 0x0100, 0x0100); |
3488 | c3d2689d | balrog | s->clkm.arm_idlect2 = 0x0100;
|
3489 | c3d2689d | balrog | s->clkm.arm_ewupct = 0x003f;
|
3490 | c3d2689d | balrog | s->clkm.arm_rstct1 = 0x0000;
|
3491 | c3d2689d | balrog | s->clkm.arm_rstct2 = 0x0000;
|
3492 | c3d2689d | balrog | s->clkm.arm_ckout1 = 0x0015;
|
3493 | c3d2689d | balrog | s->clkm.dpll1_mode = 0x2002;
|
3494 | c3d2689d | balrog | omap_clkdsp_idlect1_update(s, s->clkm.dsp_idlect1 ^ 0x0040, 0x0040); |
3495 | c3d2689d | balrog | s->clkm.dsp_idlect1 = 0x0040;
|
3496 | c3d2689d | balrog | omap_clkdsp_idlect2_update(s, ~0, 0x0000); |
3497 | c3d2689d | balrog | s->clkm.dsp_idlect2 = 0x0000;
|
3498 | c3d2689d | balrog | s->clkm.dsp_rstct2 = 0x0000;
|
3499 | c3d2689d | balrog | } |
3500 | c3d2689d | balrog | |
3501 | c3d2689d | balrog | static void omap_clkm_init(target_phys_addr_t mpu_base, |
3502 | c3d2689d | balrog | target_phys_addr_t dsp_base, struct omap_mpu_state_s *s)
|
3503 | c3d2689d | balrog | { |
3504 | c3d2689d | balrog | int iomemtype[2] = { |
3505 | c3d2689d | balrog | cpu_register_io_memory(0, omap_clkm_readfn, omap_clkm_writefn, s),
|
3506 | c3d2689d | balrog | cpu_register_io_memory(0, omap_clkdsp_readfn, omap_clkdsp_writefn, s),
|
3507 | c3d2689d | balrog | }; |
3508 | c3d2689d | balrog | |
3509 | c3d2689d | balrog | s->clkm.mpu_base = mpu_base; |
3510 | c3d2689d | balrog | s->clkm.dsp_base = dsp_base; |
3511 | d8f699cb | balrog | s->clkm.arm_idlect1 = 0x03ff;
|
3512 | d8f699cb | balrog | s->clkm.arm_idlect2 = 0x0100;
|
3513 | d8f699cb | balrog | s->clkm.dsp_idlect1 = 0x0002;
|
3514 | c3d2689d | balrog | omap_clkm_reset(s); |
3515 | d8f699cb | balrog | s->clkm.cold_start = 0x3a;
|
3516 | c3d2689d | balrog | |
3517 | c3d2689d | balrog | cpu_register_physical_memory(s->clkm.mpu_base, 0x100, iomemtype[0]); |
3518 | c3d2689d | balrog | cpu_register_physical_memory(s->clkm.dsp_base, 0x1000, iomemtype[1]); |
3519 | c3d2689d | balrog | } |
3520 | c3d2689d | balrog | |
3521 | fe71e81a | balrog | /* MPU I/O */
|
3522 | fe71e81a | balrog | struct omap_mpuio_s {
|
3523 | fe71e81a | balrog | target_phys_addr_t base; |
3524 | fe71e81a | balrog | qemu_irq irq; |
3525 | fe71e81a | balrog | qemu_irq kbd_irq; |
3526 | fe71e81a | balrog | qemu_irq *in; |
3527 | fe71e81a | balrog | qemu_irq handler[16];
|
3528 | fe71e81a | balrog | qemu_irq wakeup; |
3529 | fe71e81a | balrog | |
3530 | fe71e81a | balrog | uint16_t inputs; |
3531 | fe71e81a | balrog | uint16_t outputs; |
3532 | fe71e81a | balrog | uint16_t dir; |
3533 | fe71e81a | balrog | uint16_t edge; |
3534 | fe71e81a | balrog | uint16_t mask; |
3535 | fe71e81a | balrog | uint16_t ints; |
3536 | fe71e81a | balrog | |
3537 | fe71e81a | balrog | uint16_t debounce; |
3538 | fe71e81a | balrog | uint16_t latch; |
3539 | fe71e81a | balrog | uint8_t event; |
3540 | fe71e81a | balrog | |
3541 | fe71e81a | balrog | uint8_t buttons[5];
|
3542 | fe71e81a | balrog | uint8_t row_latch; |
3543 | fe71e81a | balrog | uint8_t cols; |
3544 | fe71e81a | balrog | int kbd_mask;
|
3545 | fe71e81a | balrog | int clk;
|
3546 | fe71e81a | balrog | }; |
3547 | fe71e81a | balrog | |
3548 | fe71e81a | balrog | static void omap_mpuio_set(void *opaque, int line, int level) |
3549 | fe71e81a | balrog | { |
3550 | fe71e81a | balrog | struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; |
3551 | fe71e81a | balrog | uint16_t prev = s->inputs; |
3552 | fe71e81a | balrog | |
3553 | fe71e81a | balrog | if (level)
|
3554 | fe71e81a | balrog | s->inputs |= 1 << line;
|
3555 | fe71e81a | balrog | else
|
3556 | fe71e81a | balrog | s->inputs &= ~(1 << line);
|
3557 | fe71e81a | balrog | |
3558 | fe71e81a | balrog | if (((1 << line) & s->dir & ~s->mask) && s->clk) { |
3559 | fe71e81a | balrog | if ((s->edge & s->inputs & ~prev) | (~s->edge & ~s->inputs & prev)) {
|
3560 | fe71e81a | balrog | s->ints |= 1 << line;
|
3561 | fe71e81a | balrog | qemu_irq_raise(s->irq); |
3562 | fe71e81a | balrog | /* TODO: wakeup */
|
3563 | fe71e81a | balrog | } |
3564 | fe71e81a | balrog | if ((s->event & (1 << 0)) && /* SET_GPIO_EVENT_MODE */ |
3565 | fe71e81a | balrog | (s->event >> 1) == line) /* PIN_SELECT */ |
3566 | fe71e81a | balrog | s->latch = s->inputs; |
3567 | fe71e81a | balrog | } |
3568 | fe71e81a | balrog | } |
3569 | fe71e81a | balrog | |
3570 | fe71e81a | balrog | static void omap_mpuio_kbd_update(struct omap_mpuio_s *s) |
3571 | fe71e81a | balrog | { |
3572 | fe71e81a | balrog | int i;
|
3573 | fe71e81a | balrog | uint8_t *row, rows = 0, cols = ~s->cols;
|
3574 | fe71e81a | balrog | |
3575 | 38a34e1d | balrog | for (row = s->buttons + 4, i = 1 << 4; i; row --, i >>= 1) |
3576 | fe71e81a | balrog | if (*row & cols)
|
3577 | 38a34e1d | balrog | rows |= i; |
3578 | fe71e81a | balrog | |
3579 | cf6d9118 | balrog | qemu_set_irq(s->kbd_irq, rows && !s->kbd_mask && s->clk); |
3580 | cf6d9118 | balrog | s->row_latch = ~rows; |
3581 | fe71e81a | balrog | } |
3582 | fe71e81a | balrog | |
3583 | fe71e81a | balrog | static uint32_t omap_mpuio_read(void *opaque, target_phys_addr_t addr) |
3584 | fe71e81a | balrog | { |
3585 | fe71e81a | balrog | struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; |
3586 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
3587 | fe71e81a | balrog | uint16_t ret; |
3588 | fe71e81a | balrog | |
3589 | fe71e81a | balrog | switch (offset) {
|
3590 | fe71e81a | balrog | case 0x00: /* INPUT_LATCH */ |
3591 | fe71e81a | balrog | return s->inputs;
|
3592 | fe71e81a | balrog | |
3593 | fe71e81a | balrog | case 0x04: /* OUTPUT_REG */ |
3594 | fe71e81a | balrog | return s->outputs;
|
3595 | fe71e81a | balrog | |
3596 | fe71e81a | balrog | case 0x08: /* IO_CNTL */ |
3597 | fe71e81a | balrog | return s->dir;
|
3598 | fe71e81a | balrog | |
3599 | fe71e81a | balrog | case 0x10: /* KBR_LATCH */ |
3600 | fe71e81a | balrog | return s->row_latch;
|
3601 | fe71e81a | balrog | |
3602 | fe71e81a | balrog | case 0x14: /* KBC_REG */ |
3603 | fe71e81a | balrog | return s->cols;
|
3604 | fe71e81a | balrog | |
3605 | fe71e81a | balrog | case 0x18: /* GPIO_EVENT_MODE_REG */ |
3606 | fe71e81a | balrog | return s->event;
|
3607 | fe71e81a | balrog | |
3608 | fe71e81a | balrog | case 0x1c: /* GPIO_INT_EDGE_REG */ |
3609 | fe71e81a | balrog | return s->edge;
|
3610 | fe71e81a | balrog | |
3611 | fe71e81a | balrog | case 0x20: /* KBD_INT */ |
3612 | cf6d9118 | balrog | return (~s->row_latch & 0x1f) && !s->kbd_mask; |
3613 | fe71e81a | balrog | |
3614 | fe71e81a | balrog | case 0x24: /* GPIO_INT */ |
3615 | fe71e81a | balrog | ret = s->ints; |
3616 | 8e129e07 | balrog | s->ints &= s->mask; |
3617 | 8e129e07 | balrog | if (ret)
|
3618 | 8e129e07 | balrog | qemu_irq_lower(s->irq); |
3619 | fe71e81a | balrog | return ret;
|
3620 | fe71e81a | balrog | |
3621 | fe71e81a | balrog | case 0x28: /* KBD_MASKIT */ |
3622 | fe71e81a | balrog | return s->kbd_mask;
|
3623 | fe71e81a | balrog | |
3624 | fe71e81a | balrog | case 0x2c: /* GPIO_MASKIT */ |
3625 | fe71e81a | balrog | return s->mask;
|
3626 | fe71e81a | balrog | |
3627 | fe71e81a | balrog | case 0x30: /* GPIO_DEBOUNCING_REG */ |
3628 | fe71e81a | balrog | return s->debounce;
|
3629 | fe71e81a | balrog | |
3630 | fe71e81a | balrog | case 0x34: /* GPIO_LATCH_REG */ |
3631 | fe71e81a | balrog | return s->latch;
|
3632 | fe71e81a | balrog | } |
3633 | fe71e81a | balrog | |
3634 | fe71e81a | balrog | OMAP_BAD_REG(addr); |
3635 | fe71e81a | balrog | return 0; |
3636 | fe71e81a | balrog | } |
3637 | fe71e81a | balrog | |
3638 | fe71e81a | balrog | static void omap_mpuio_write(void *opaque, target_phys_addr_t addr, |
3639 | fe71e81a | balrog | uint32_t value) |
3640 | fe71e81a | balrog | { |
3641 | fe71e81a | balrog | struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; |
3642 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
3643 | fe71e81a | balrog | uint16_t diff; |
3644 | fe71e81a | balrog | int ln;
|
3645 | fe71e81a | balrog | |
3646 | fe71e81a | balrog | switch (offset) {
|
3647 | fe71e81a | balrog | case 0x04: /* OUTPUT_REG */ |
3648 | d8f699cb | balrog | diff = (s->outputs ^ value) & ~s->dir; |
3649 | fe71e81a | balrog | s->outputs = value; |
3650 | fe71e81a | balrog | while ((ln = ffs(diff))) {
|
3651 | fe71e81a | balrog | ln --; |
3652 | fe71e81a | balrog | if (s->handler[ln])
|
3653 | fe71e81a | balrog | qemu_set_irq(s->handler[ln], (value >> ln) & 1);
|
3654 | fe71e81a | balrog | diff &= ~(1 << ln);
|
3655 | fe71e81a | balrog | } |
3656 | fe71e81a | balrog | break;
|
3657 | fe71e81a | balrog | |
3658 | fe71e81a | balrog | case 0x08: /* IO_CNTL */ |
3659 | fe71e81a | balrog | diff = s->outputs & (s->dir ^ value); |
3660 | fe71e81a | balrog | s->dir = value; |
3661 | fe71e81a | balrog | |
3662 | fe71e81a | balrog | value = s->outputs & ~s->dir; |
3663 | fe71e81a | balrog | while ((ln = ffs(diff))) {
|
3664 | fe71e81a | balrog | ln --; |
3665 | fe71e81a | balrog | if (s->handler[ln])
|
3666 | fe71e81a | balrog | qemu_set_irq(s->handler[ln], (value >> ln) & 1);
|
3667 | fe71e81a | balrog | diff &= ~(1 << ln);
|
3668 | fe71e81a | balrog | } |
3669 | fe71e81a | balrog | break;
|
3670 | fe71e81a | balrog | |
3671 | fe71e81a | balrog | case 0x14: /* KBC_REG */ |
3672 | fe71e81a | balrog | s->cols = value; |
3673 | fe71e81a | balrog | omap_mpuio_kbd_update(s); |
3674 | fe71e81a | balrog | break;
|
3675 | fe71e81a | balrog | |
3676 | fe71e81a | balrog | case 0x18: /* GPIO_EVENT_MODE_REG */ |
3677 | fe71e81a | balrog | s->event = value & 0x1f;
|
3678 | fe71e81a | balrog | break;
|
3679 | fe71e81a | balrog | |
3680 | fe71e81a | balrog | case 0x1c: /* GPIO_INT_EDGE_REG */ |
3681 | fe71e81a | balrog | s->edge = value; |
3682 | fe71e81a | balrog | break;
|
3683 | fe71e81a | balrog | |
3684 | fe71e81a | balrog | case 0x28: /* KBD_MASKIT */ |
3685 | fe71e81a | balrog | s->kbd_mask = value & 1;
|
3686 | fe71e81a | balrog | omap_mpuio_kbd_update(s); |
3687 | fe71e81a | balrog | break;
|
3688 | fe71e81a | balrog | |
3689 | fe71e81a | balrog | case 0x2c: /* GPIO_MASKIT */ |
3690 | fe71e81a | balrog | s->mask = value; |
3691 | fe71e81a | balrog | break;
|
3692 | fe71e81a | balrog | |
3693 | fe71e81a | balrog | case 0x30: /* GPIO_DEBOUNCING_REG */ |
3694 | fe71e81a | balrog | s->debounce = value & 0x1ff;
|
3695 | fe71e81a | balrog | break;
|
3696 | fe71e81a | balrog | |
3697 | fe71e81a | balrog | case 0x00: /* INPUT_LATCH */ |
3698 | fe71e81a | balrog | case 0x10: /* KBR_LATCH */ |
3699 | fe71e81a | balrog | case 0x20: /* KBD_INT */ |
3700 | fe71e81a | balrog | case 0x24: /* GPIO_INT */ |
3701 | fe71e81a | balrog | case 0x34: /* GPIO_LATCH_REG */ |
3702 | fe71e81a | balrog | OMAP_RO_REG(addr); |
3703 | fe71e81a | balrog | return;
|
3704 | fe71e81a | balrog | |
3705 | fe71e81a | balrog | default:
|
3706 | fe71e81a | balrog | OMAP_BAD_REG(addr); |
3707 | fe71e81a | balrog | return;
|
3708 | fe71e81a | balrog | } |
3709 | fe71e81a | balrog | } |
3710 | fe71e81a | balrog | |
3711 | fe71e81a | balrog | static CPUReadMemoryFunc *omap_mpuio_readfn[] = {
|
3712 | fe71e81a | balrog | omap_badwidth_read16, |
3713 | fe71e81a | balrog | omap_mpuio_read, |
3714 | fe71e81a | balrog | omap_badwidth_read16, |
3715 | fe71e81a | balrog | }; |
3716 | fe71e81a | balrog | |
3717 | fe71e81a | balrog | static CPUWriteMemoryFunc *omap_mpuio_writefn[] = {
|
3718 | fe71e81a | balrog | omap_badwidth_write16, |
3719 | fe71e81a | balrog | omap_mpuio_write, |
3720 | fe71e81a | balrog | omap_badwidth_write16, |
3721 | fe71e81a | balrog | }; |
3722 | fe71e81a | balrog | |
3723 | 9596ebb7 | pbrook | static void omap_mpuio_reset(struct omap_mpuio_s *s) |
3724 | fe71e81a | balrog | { |
3725 | fe71e81a | balrog | s->inputs = 0;
|
3726 | fe71e81a | balrog | s->outputs = 0;
|
3727 | fe71e81a | balrog | s->dir = ~0;
|
3728 | fe71e81a | balrog | s->event = 0;
|
3729 | fe71e81a | balrog | s->edge = 0;
|
3730 | fe71e81a | balrog | s->kbd_mask = 0;
|
3731 | fe71e81a | balrog | s->mask = 0;
|
3732 | fe71e81a | balrog | s->debounce = 0;
|
3733 | fe71e81a | balrog | s->latch = 0;
|
3734 | fe71e81a | balrog | s->ints = 0;
|
3735 | fe71e81a | balrog | s->row_latch = 0x1f;
|
3736 | 38a34e1d | balrog | s->clk = 1;
|
3737 | fe71e81a | balrog | } |
3738 | fe71e81a | balrog | |
3739 | fe71e81a | balrog | static void omap_mpuio_onoff(void *opaque, int line, int on) |
3740 | fe71e81a | balrog | { |
3741 | fe71e81a | balrog | struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; |
3742 | fe71e81a | balrog | |
3743 | fe71e81a | balrog | s->clk = on; |
3744 | fe71e81a | balrog | if (on)
|
3745 | fe71e81a | balrog | omap_mpuio_kbd_update(s); |
3746 | fe71e81a | balrog | } |
3747 | fe71e81a | balrog | |
3748 | fe71e81a | balrog | struct omap_mpuio_s *omap_mpuio_init(target_phys_addr_t base,
|
3749 | fe71e81a | balrog | qemu_irq kbd_int, qemu_irq gpio_int, qemu_irq wakeup, |
3750 | fe71e81a | balrog | omap_clk clk) |
3751 | fe71e81a | balrog | { |
3752 | fe71e81a | balrog | int iomemtype;
|
3753 | fe71e81a | balrog | struct omap_mpuio_s *s = (struct omap_mpuio_s *) |
3754 | fe71e81a | balrog | qemu_mallocz(sizeof(struct omap_mpuio_s)); |
3755 | fe71e81a | balrog | |
3756 | fe71e81a | balrog | s->base = base; |
3757 | fe71e81a | balrog | s->irq = gpio_int; |
3758 | fe71e81a | balrog | s->kbd_irq = kbd_int; |
3759 | fe71e81a | balrog | s->wakeup = wakeup; |
3760 | fe71e81a | balrog | s->in = qemu_allocate_irqs(omap_mpuio_set, s, 16);
|
3761 | fe71e81a | balrog | omap_mpuio_reset(s); |
3762 | fe71e81a | balrog | |
3763 | fe71e81a | balrog | iomemtype = cpu_register_io_memory(0, omap_mpuio_readfn,
|
3764 | fe71e81a | balrog | omap_mpuio_writefn, s); |
3765 | fe71e81a | balrog | cpu_register_physical_memory(s->base, 0x800, iomemtype);
|
3766 | fe71e81a | balrog | |
3767 | fe71e81a | balrog | omap_clk_adduser(clk, qemu_allocate_irqs(omap_mpuio_onoff, s, 1)[0]); |
3768 | fe71e81a | balrog | |
3769 | fe71e81a | balrog | return s;
|
3770 | fe71e81a | balrog | } |
3771 | fe71e81a | balrog | |
3772 | fe71e81a | balrog | qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s)
|
3773 | fe71e81a | balrog | { |
3774 | fe71e81a | balrog | return s->in;
|
3775 | fe71e81a | balrog | } |
3776 | fe71e81a | balrog | |
3777 | fe71e81a | balrog | void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler) |
3778 | fe71e81a | balrog | { |
3779 | fe71e81a | balrog | if (line >= 16 || line < 0) |
3780 | fe71e81a | balrog | cpu_abort(cpu_single_env, "%s: No GPIO line %i\n", __FUNCTION__, line);
|
3781 | fe71e81a | balrog | s->handler[line] = handler; |
3782 | fe71e81a | balrog | } |
3783 | fe71e81a | balrog | |
3784 | fe71e81a | balrog | void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down) |
3785 | fe71e81a | balrog | { |
3786 | fe71e81a | balrog | if (row >= 5 || row < 0) |
3787 | fe71e81a | balrog | cpu_abort(cpu_single_env, "%s: No key %i-%i\n",
|
3788 | fe71e81a | balrog | __FUNCTION__, col, row); |
3789 | fe71e81a | balrog | |
3790 | fe71e81a | balrog | if (down)
|
3791 | 38a34e1d | balrog | s->buttons[row] |= 1 << col;
|
3792 | fe71e81a | balrog | else
|
3793 | 38a34e1d | balrog | s->buttons[row] &= ~(1 << col);
|
3794 | fe71e81a | balrog | |
3795 | fe71e81a | balrog | omap_mpuio_kbd_update(s); |
3796 | fe71e81a | balrog | } |
3797 | fe71e81a | balrog | |
3798 | 64330148 | balrog | /* General-Purpose I/O */
|
3799 | 64330148 | balrog | struct omap_gpio_s {
|
3800 | 64330148 | balrog | target_phys_addr_t base; |
3801 | 64330148 | balrog | qemu_irq irq; |
3802 | 64330148 | balrog | qemu_irq *in; |
3803 | 64330148 | balrog | qemu_irq handler[16];
|
3804 | 64330148 | balrog | |
3805 | 64330148 | balrog | uint16_t inputs; |
3806 | 64330148 | balrog | uint16_t outputs; |
3807 | 64330148 | balrog | uint16_t dir; |
3808 | 64330148 | balrog | uint16_t edge; |
3809 | 64330148 | balrog | uint16_t mask; |
3810 | 64330148 | balrog | uint16_t ints; |
3811 | d8f699cb | balrog | uint16_t pins; |
3812 | 64330148 | balrog | }; |
3813 | 64330148 | balrog | |
3814 | 64330148 | balrog | static void omap_gpio_set(void *opaque, int line, int level) |
3815 | 64330148 | balrog | { |
3816 | 64330148 | balrog | struct omap_gpio_s *s = (struct omap_gpio_s *) opaque; |
3817 | 64330148 | balrog | uint16_t prev = s->inputs; |
3818 | 64330148 | balrog | |
3819 | 64330148 | balrog | if (level)
|
3820 | 64330148 | balrog | s->inputs |= 1 << line;
|
3821 | 64330148 | balrog | else
|
3822 | 64330148 | balrog | s->inputs &= ~(1 << line);
|
3823 | 64330148 | balrog | |
3824 | 64330148 | balrog | if (((s->edge & s->inputs & ~prev) | (~s->edge & ~s->inputs & prev)) &
|
3825 | 64330148 | balrog | (1 << line) & s->dir & ~s->mask) {
|
3826 | 64330148 | balrog | s->ints |= 1 << line;
|
3827 | 64330148 | balrog | qemu_irq_raise(s->irq); |
3828 | 64330148 | balrog | } |
3829 | 64330148 | balrog | } |
3830 | 64330148 | balrog | |
3831 | 64330148 | balrog | static uint32_t omap_gpio_read(void *opaque, target_phys_addr_t addr) |
3832 | 64330148 | balrog | { |
3833 | 64330148 | balrog | struct omap_gpio_s *s = (struct omap_gpio_s *) opaque; |
3834 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
3835 | 64330148 | balrog | |
3836 | 64330148 | balrog | switch (offset) {
|
3837 | 64330148 | balrog | case 0x00: /* DATA_INPUT */ |
3838 | d8f699cb | balrog | return s->inputs & s->pins;
|
3839 | 64330148 | balrog | |
3840 | 64330148 | balrog | case 0x04: /* DATA_OUTPUT */ |
3841 | 64330148 | balrog | return s->outputs;
|
3842 | 64330148 | balrog | |
3843 | 64330148 | balrog | case 0x08: /* DIRECTION_CONTROL */ |
3844 | 64330148 | balrog | return s->dir;
|
3845 | 64330148 | balrog | |
3846 | 64330148 | balrog | case 0x0c: /* INTERRUPT_CONTROL */ |
3847 | 64330148 | balrog | return s->edge;
|
3848 | 64330148 | balrog | |
3849 | 64330148 | balrog | case 0x10: /* INTERRUPT_MASK */ |
3850 | 64330148 | balrog | return s->mask;
|
3851 | 64330148 | balrog | |
3852 | 64330148 | balrog | case 0x14: /* INTERRUPT_STATUS */ |
3853 | 64330148 | balrog | return s->ints;
|
3854 | d8f699cb | balrog | |
3855 | d8f699cb | balrog | case 0x18: /* PIN_CONTROL (not in OMAP310) */ |
3856 | d8f699cb | balrog | OMAP_BAD_REG(addr); |
3857 | d8f699cb | balrog | return s->pins;
|
3858 | 64330148 | balrog | } |
3859 | 64330148 | balrog | |
3860 | 64330148 | balrog | OMAP_BAD_REG(addr); |
3861 | 64330148 | balrog | return 0; |
3862 | 64330148 | balrog | } |
3863 | 64330148 | balrog | |
3864 | 64330148 | balrog | static void omap_gpio_write(void *opaque, target_phys_addr_t addr, |
3865 | 64330148 | balrog | uint32_t value) |
3866 | 64330148 | balrog | { |
3867 | 64330148 | balrog | struct omap_gpio_s *s = (struct omap_gpio_s *) opaque; |
3868 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
3869 | 64330148 | balrog | uint16_t diff; |
3870 | 64330148 | balrog | int ln;
|
3871 | 64330148 | balrog | |
3872 | 64330148 | balrog | switch (offset) {
|
3873 | 64330148 | balrog | case 0x00: /* DATA_INPUT */ |
3874 | 64330148 | balrog | OMAP_RO_REG(addr); |
3875 | 64330148 | balrog | return;
|
3876 | 64330148 | balrog | |
3877 | 64330148 | balrog | case 0x04: /* DATA_OUTPUT */ |
3878 | 66450b15 | balrog | diff = (s->outputs ^ value) & ~s->dir; |
3879 | 64330148 | balrog | s->outputs = value; |
3880 | 64330148 | balrog | while ((ln = ffs(diff))) {
|
3881 | 64330148 | balrog | ln --; |
3882 | 64330148 | balrog | if (s->handler[ln])
|
3883 | 64330148 | balrog | qemu_set_irq(s->handler[ln], (value >> ln) & 1);
|
3884 | 64330148 | balrog | diff &= ~(1 << ln);
|
3885 | 64330148 | balrog | } |
3886 | 64330148 | balrog | break;
|
3887 | 64330148 | balrog | |
3888 | 64330148 | balrog | case 0x08: /* DIRECTION_CONTROL */ |
3889 | 64330148 | balrog | diff = s->outputs & (s->dir ^ value); |
3890 | 64330148 | balrog | s->dir = value; |
3891 | 64330148 | balrog | |
3892 | 64330148 | balrog | value = s->outputs & ~s->dir; |
3893 | 64330148 | balrog | while ((ln = ffs(diff))) {
|
3894 | 64330148 | balrog | ln --; |
3895 | 64330148 | balrog | if (s->handler[ln])
|
3896 | 64330148 | balrog | qemu_set_irq(s->handler[ln], (value >> ln) & 1);
|
3897 | 64330148 | balrog | diff &= ~(1 << ln);
|
3898 | 64330148 | balrog | } |
3899 | 64330148 | balrog | break;
|
3900 | 64330148 | balrog | |
3901 | 64330148 | balrog | case 0x0c: /* INTERRUPT_CONTROL */ |
3902 | 64330148 | balrog | s->edge = value; |
3903 | 64330148 | balrog | break;
|
3904 | 64330148 | balrog | |
3905 | 64330148 | balrog | case 0x10: /* INTERRUPT_MASK */ |
3906 | 64330148 | balrog | s->mask = value; |
3907 | 64330148 | balrog | break;
|
3908 | 64330148 | balrog | |
3909 | 64330148 | balrog | case 0x14: /* INTERRUPT_STATUS */ |
3910 | 64330148 | balrog | s->ints &= ~value; |
3911 | 64330148 | balrog | if (!s->ints)
|
3912 | 64330148 | balrog | qemu_irq_lower(s->irq); |
3913 | 64330148 | balrog | break;
|
3914 | 64330148 | balrog | |
3915 | d8f699cb | balrog | case 0x18: /* PIN_CONTROL (not in OMAP310 TRM) */ |
3916 | d8f699cb | balrog | OMAP_BAD_REG(addr); |
3917 | d8f699cb | balrog | s->pins = value; |
3918 | d8f699cb | balrog | break;
|
3919 | d8f699cb | balrog | |
3920 | 64330148 | balrog | default:
|
3921 | 64330148 | balrog | OMAP_BAD_REG(addr); |
3922 | 64330148 | balrog | return;
|
3923 | 64330148 | balrog | } |
3924 | 64330148 | balrog | } |
3925 | 64330148 | balrog | |
3926 | 3efda49d | balrog | /* *Some* sources say the memory region is 32-bit. */
|
3927 | 64330148 | balrog | static CPUReadMemoryFunc *omap_gpio_readfn[] = {
|
3928 | 3efda49d | balrog | omap_badwidth_read16, |
3929 | 64330148 | balrog | omap_gpio_read, |
3930 | 3efda49d | balrog | omap_badwidth_read16, |
3931 | 64330148 | balrog | }; |
3932 | 64330148 | balrog | |
3933 | 64330148 | balrog | static CPUWriteMemoryFunc *omap_gpio_writefn[] = {
|
3934 | 3efda49d | balrog | omap_badwidth_write16, |
3935 | 64330148 | balrog | omap_gpio_write, |
3936 | 3efda49d | balrog | omap_badwidth_write16, |
3937 | 64330148 | balrog | }; |
3938 | 64330148 | balrog | |
3939 | 9596ebb7 | pbrook | static void omap_gpio_reset(struct omap_gpio_s *s) |
3940 | 64330148 | balrog | { |
3941 | 64330148 | balrog | s->inputs = 0;
|
3942 | 64330148 | balrog | s->outputs = ~0;
|
3943 | 64330148 | balrog | s->dir = ~0;
|
3944 | 64330148 | balrog | s->edge = ~0;
|
3945 | 64330148 | balrog | s->mask = ~0;
|
3946 | 64330148 | balrog | s->ints = 0;
|
3947 | d8f699cb | balrog | s->pins = ~0;
|
3948 | 64330148 | balrog | } |
3949 | 64330148 | balrog | |
3950 | 64330148 | balrog | struct omap_gpio_s *omap_gpio_init(target_phys_addr_t base,
|
3951 | 64330148 | balrog | qemu_irq irq, omap_clk clk) |
3952 | 64330148 | balrog | { |
3953 | 64330148 | balrog | int iomemtype;
|
3954 | 64330148 | balrog | struct omap_gpio_s *s = (struct omap_gpio_s *) |
3955 | 64330148 | balrog | qemu_mallocz(sizeof(struct omap_gpio_s)); |
3956 | 64330148 | balrog | |
3957 | 64330148 | balrog | s->base = base; |
3958 | 64330148 | balrog | s->irq = irq; |
3959 | 64330148 | balrog | s->in = qemu_allocate_irqs(omap_gpio_set, s, 16);
|
3960 | 64330148 | balrog | omap_gpio_reset(s); |
3961 | 64330148 | balrog | |
3962 | 64330148 | balrog | iomemtype = cpu_register_io_memory(0, omap_gpio_readfn,
|
3963 | 64330148 | balrog | omap_gpio_writefn, s); |
3964 | 64330148 | balrog | cpu_register_physical_memory(s->base, 0x1000, iomemtype);
|
3965 | 64330148 | balrog | |
3966 | 64330148 | balrog | return s;
|
3967 | 64330148 | balrog | } |
3968 | 64330148 | balrog | |
3969 | 64330148 | balrog | qemu_irq *omap_gpio_in_get(struct omap_gpio_s *s)
|
3970 | 64330148 | balrog | { |
3971 | 64330148 | balrog | return s->in;
|
3972 | 64330148 | balrog | } |
3973 | 64330148 | balrog | |
3974 | 64330148 | balrog | void omap_gpio_out_set(struct omap_gpio_s *s, int line, qemu_irq handler) |
3975 | 64330148 | balrog | { |
3976 | 64330148 | balrog | if (line >= 16 || line < 0) |
3977 | 64330148 | balrog | cpu_abort(cpu_single_env, "%s: No GPIO line %i\n", __FUNCTION__, line);
|
3978 | 64330148 | balrog | s->handler[line] = handler; |
3979 | 64330148 | balrog | } |
3980 | 64330148 | balrog | |
3981 | d951f6ff | balrog | /* MicroWire Interface */
|
3982 | d951f6ff | balrog | struct omap_uwire_s {
|
3983 | d951f6ff | balrog | target_phys_addr_t base; |
3984 | d951f6ff | balrog | qemu_irq txirq; |
3985 | d951f6ff | balrog | qemu_irq rxirq; |
3986 | d951f6ff | balrog | qemu_irq txdrq; |
3987 | d951f6ff | balrog | |
3988 | d951f6ff | balrog | uint16_t txbuf; |
3989 | d951f6ff | balrog | uint16_t rxbuf; |
3990 | d951f6ff | balrog | uint16_t control; |
3991 | d951f6ff | balrog | uint16_t setup[5];
|
3992 | d951f6ff | balrog | |
3993 | d951f6ff | balrog | struct uwire_slave_s *chip[4]; |
3994 | d951f6ff | balrog | }; |
3995 | d951f6ff | balrog | |
3996 | d951f6ff | balrog | static void omap_uwire_transfer_start(struct omap_uwire_s *s) |
3997 | d951f6ff | balrog | { |
3998 | d951f6ff | balrog | int chipselect = (s->control >> 10) & 3; /* INDEX */ |
3999 | d951f6ff | balrog | struct uwire_slave_s *slave = s->chip[chipselect];
|
4000 | d951f6ff | balrog | |
4001 | d951f6ff | balrog | if ((s->control >> 5) & 0x1f) { /* NB_BITS_WR */ |
4002 | d951f6ff | balrog | if (s->control & (1 << 12)) /* CS_CMD */ |
4003 | d951f6ff | balrog | if (slave && slave->send)
|
4004 | d951f6ff | balrog | slave->send(slave->opaque, |
4005 | d951f6ff | balrog | s->txbuf >> (16 - ((s->control >> 5) & 0x1f))); |
4006 | d951f6ff | balrog | s->control &= ~(1 << 14); /* CSRB */ |
4007 | d951f6ff | balrog | /* TODO: depending on s->setup[4] bits [1:0] assert an IRQ or
|
4008 | d951f6ff | balrog | * a DRQ. When is the level IRQ supposed to be reset? */
|
4009 | d951f6ff | balrog | } |
4010 | d951f6ff | balrog | |
4011 | d951f6ff | balrog | if ((s->control >> 0) & 0x1f) { /* NB_BITS_RD */ |
4012 | d951f6ff | balrog | if (s->control & (1 << 12)) /* CS_CMD */ |
4013 | d951f6ff | balrog | if (slave && slave->receive)
|
4014 | d951f6ff | balrog | s->rxbuf = slave->receive(slave->opaque); |
4015 | d951f6ff | balrog | s->control |= 1 << 15; /* RDRB */ |
4016 | d951f6ff | balrog | /* TODO: depending on s->setup[4] bits [1:0] assert an IRQ or
|
4017 | d951f6ff | balrog | * a DRQ. When is the level IRQ supposed to be reset? */
|
4018 | d951f6ff | balrog | } |
4019 | d951f6ff | balrog | } |
4020 | d951f6ff | balrog | |
4021 | d951f6ff | balrog | static uint32_t omap_uwire_read(void *opaque, target_phys_addr_t addr) |
4022 | d951f6ff | balrog | { |
4023 | d951f6ff | balrog | struct omap_uwire_s *s = (struct omap_uwire_s *) opaque; |
4024 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4025 | d951f6ff | balrog | |
4026 | d951f6ff | balrog | switch (offset) {
|
4027 | d951f6ff | balrog | case 0x00: /* RDR */ |
4028 | d951f6ff | balrog | s->control &= ~(1 << 15); /* RDRB */ |
4029 | d951f6ff | balrog | return s->rxbuf;
|
4030 | d951f6ff | balrog | |
4031 | d951f6ff | balrog | case 0x04: /* CSR */ |
4032 | d951f6ff | balrog | return s->control;
|
4033 | d951f6ff | balrog | |
4034 | d951f6ff | balrog | case 0x08: /* SR1 */ |
4035 | d951f6ff | balrog | return s->setup[0]; |
4036 | d951f6ff | balrog | case 0x0c: /* SR2 */ |
4037 | d951f6ff | balrog | return s->setup[1]; |
4038 | d951f6ff | balrog | case 0x10: /* SR3 */ |
4039 | d951f6ff | balrog | return s->setup[2]; |
4040 | d951f6ff | balrog | case 0x14: /* SR4 */ |
4041 | d951f6ff | balrog | return s->setup[3]; |
4042 | d951f6ff | balrog | case 0x18: /* SR5 */ |
4043 | d951f6ff | balrog | return s->setup[4]; |
4044 | d951f6ff | balrog | } |
4045 | d951f6ff | balrog | |
4046 | d951f6ff | balrog | OMAP_BAD_REG(addr); |
4047 | d951f6ff | balrog | return 0; |
4048 | d951f6ff | balrog | } |
4049 | d951f6ff | balrog | |
4050 | d951f6ff | balrog | static void omap_uwire_write(void *opaque, target_phys_addr_t addr, |
4051 | d951f6ff | balrog | uint32_t value) |
4052 | d951f6ff | balrog | { |
4053 | d951f6ff | balrog | struct omap_uwire_s *s = (struct omap_uwire_s *) opaque; |
4054 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4055 | d951f6ff | balrog | |
4056 | d951f6ff | balrog | switch (offset) {
|
4057 | d951f6ff | balrog | case 0x00: /* TDR */ |
4058 | d951f6ff | balrog | s->txbuf = value; /* TD */
|
4059 | d951f6ff | balrog | if ((s->setup[4] & (1 << 2)) && /* AUTO_TX_EN */ |
4060 | d951f6ff | balrog | ((s->setup[4] & (1 << 3)) || /* CS_TOGGLE_TX_EN */ |
4061 | cf965d24 | balrog | (s->control & (1 << 12)))) { /* CS_CMD */ |
4062 | cf965d24 | balrog | s->control |= 1 << 14; /* CSRB */ |
4063 | d951f6ff | balrog | omap_uwire_transfer_start(s); |
4064 | cf965d24 | balrog | } |
4065 | d951f6ff | balrog | break;
|
4066 | d951f6ff | balrog | |
4067 | d951f6ff | balrog | case 0x04: /* CSR */ |
4068 | d951f6ff | balrog | s->control = value & 0x1fff;
|
4069 | d951f6ff | balrog | if (value & (1 << 13)) /* START */ |
4070 | d951f6ff | balrog | omap_uwire_transfer_start(s); |
4071 | d951f6ff | balrog | break;
|
4072 | d951f6ff | balrog | |
4073 | d951f6ff | balrog | case 0x08: /* SR1 */ |
4074 | d951f6ff | balrog | s->setup[0] = value & 0x003f; |
4075 | d951f6ff | balrog | break;
|
4076 | d951f6ff | balrog | |
4077 | d951f6ff | balrog | case 0x0c: /* SR2 */ |
4078 | d951f6ff | balrog | s->setup[1] = value & 0x0fc0; |
4079 | d951f6ff | balrog | break;
|
4080 | d951f6ff | balrog | |
4081 | d951f6ff | balrog | case 0x10: /* SR3 */ |
4082 | d951f6ff | balrog | s->setup[2] = value & 0x0003; |
4083 | d951f6ff | balrog | break;
|
4084 | d951f6ff | balrog | |
4085 | d951f6ff | balrog | case 0x14: /* SR4 */ |
4086 | d951f6ff | balrog | s->setup[3] = value & 0x0001; |
4087 | d951f6ff | balrog | break;
|
4088 | d951f6ff | balrog | |
4089 | d951f6ff | balrog | case 0x18: /* SR5 */ |
4090 | d951f6ff | balrog | s->setup[4] = value & 0x000f; |
4091 | d951f6ff | balrog | break;
|
4092 | d951f6ff | balrog | |
4093 | d951f6ff | balrog | default:
|
4094 | d951f6ff | balrog | OMAP_BAD_REG(addr); |
4095 | d951f6ff | balrog | return;
|
4096 | d951f6ff | balrog | } |
4097 | d951f6ff | balrog | } |
4098 | d951f6ff | balrog | |
4099 | d951f6ff | balrog | static CPUReadMemoryFunc *omap_uwire_readfn[] = {
|
4100 | d951f6ff | balrog | omap_badwidth_read16, |
4101 | d951f6ff | balrog | omap_uwire_read, |
4102 | d951f6ff | balrog | omap_badwidth_read16, |
4103 | d951f6ff | balrog | }; |
4104 | d951f6ff | balrog | |
4105 | d951f6ff | balrog | static CPUWriteMemoryFunc *omap_uwire_writefn[] = {
|
4106 | d951f6ff | balrog | omap_badwidth_write16, |
4107 | d951f6ff | balrog | omap_uwire_write, |
4108 | d951f6ff | balrog | omap_badwidth_write16, |
4109 | d951f6ff | balrog | }; |
4110 | d951f6ff | balrog | |
4111 | 9596ebb7 | pbrook | static void omap_uwire_reset(struct omap_uwire_s *s) |
4112 | d951f6ff | balrog | { |
4113 | 66450b15 | balrog | s->control = 0;
|
4114 | d951f6ff | balrog | s->setup[0] = 0; |
4115 | d951f6ff | balrog | s->setup[1] = 0; |
4116 | d951f6ff | balrog | s->setup[2] = 0; |
4117 | d951f6ff | balrog | s->setup[3] = 0; |
4118 | d951f6ff | balrog | s->setup[4] = 0; |
4119 | d951f6ff | balrog | } |
4120 | d951f6ff | balrog | |
4121 | d951f6ff | balrog | struct omap_uwire_s *omap_uwire_init(target_phys_addr_t base,
|
4122 | d951f6ff | balrog | qemu_irq *irq, qemu_irq dma, omap_clk clk) |
4123 | d951f6ff | balrog | { |
4124 | d951f6ff | balrog | int iomemtype;
|
4125 | d951f6ff | balrog | struct omap_uwire_s *s = (struct omap_uwire_s *) |
4126 | d951f6ff | balrog | qemu_mallocz(sizeof(struct omap_uwire_s)); |
4127 | d951f6ff | balrog | |
4128 | d951f6ff | balrog | s->base = base; |
4129 | d951f6ff | balrog | s->txirq = irq[0];
|
4130 | d951f6ff | balrog | s->rxirq = irq[1];
|
4131 | d951f6ff | balrog | s->txdrq = dma; |
4132 | d951f6ff | balrog | omap_uwire_reset(s); |
4133 | d951f6ff | balrog | |
4134 | d951f6ff | balrog | iomemtype = cpu_register_io_memory(0, omap_uwire_readfn,
|
4135 | d951f6ff | balrog | omap_uwire_writefn, s); |
4136 | d951f6ff | balrog | cpu_register_physical_memory(s->base, 0x800, iomemtype);
|
4137 | d951f6ff | balrog | |
4138 | d951f6ff | balrog | return s;
|
4139 | d951f6ff | balrog | } |
4140 | d951f6ff | balrog | |
4141 | d951f6ff | balrog | void omap_uwire_attach(struct omap_uwire_s *s, |
4142 | d951f6ff | balrog | struct uwire_slave_s *slave, int chipselect) |
4143 | d951f6ff | balrog | { |
4144 | d951f6ff | balrog | if (chipselect < 0 || chipselect > 3) |
4145 | d951f6ff | balrog | cpu_abort(cpu_single_env, "%s: Bad chipselect %i\n", __FUNCTION__,
|
4146 | d951f6ff | balrog | chipselect); |
4147 | d951f6ff | balrog | |
4148 | d951f6ff | balrog | s->chip[chipselect] = slave; |
4149 | d951f6ff | balrog | } |
4150 | d951f6ff | balrog | |
4151 | 66450b15 | balrog | /* Pseudonoise Pulse-Width Light Modulator */
|
4152 | 9596ebb7 | pbrook | static void omap_pwl_update(struct omap_mpu_state_s *s) |
4153 | 66450b15 | balrog | { |
4154 | 66450b15 | balrog | int output = (s->pwl.clk && s->pwl.enable) ? s->pwl.level : 0; |
4155 | 66450b15 | balrog | |
4156 | 66450b15 | balrog | if (output != s->pwl.output) {
|
4157 | 66450b15 | balrog | s->pwl.output = output; |
4158 | 66450b15 | balrog | printf("%s: Backlight now at %i/256\n", __FUNCTION__, output);
|
4159 | 66450b15 | balrog | } |
4160 | 66450b15 | balrog | } |
4161 | 66450b15 | balrog | |
4162 | 66450b15 | balrog | static uint32_t omap_pwl_read(void *opaque, target_phys_addr_t addr) |
4163 | 66450b15 | balrog | { |
4164 | 66450b15 | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
4165 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4166 | 66450b15 | balrog | |
4167 | 66450b15 | balrog | switch (offset) {
|
4168 | 66450b15 | balrog | case 0x00: /* PWL_LEVEL */ |
4169 | 66450b15 | balrog | return s->pwl.level;
|
4170 | 66450b15 | balrog | case 0x04: /* PWL_CTRL */ |
4171 | 66450b15 | balrog | return s->pwl.enable;
|
4172 | 66450b15 | balrog | } |
4173 | 66450b15 | balrog | OMAP_BAD_REG(addr); |
4174 | 66450b15 | balrog | return 0; |
4175 | 66450b15 | balrog | } |
4176 | 66450b15 | balrog | |
4177 | 66450b15 | balrog | static void omap_pwl_write(void *opaque, target_phys_addr_t addr, |
4178 | 66450b15 | balrog | uint32_t value) |
4179 | 66450b15 | balrog | { |
4180 | 66450b15 | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
4181 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4182 | 66450b15 | balrog | |
4183 | 66450b15 | balrog | switch (offset) {
|
4184 | 66450b15 | balrog | case 0x00: /* PWL_LEVEL */ |
4185 | 66450b15 | balrog | s->pwl.level = value; |
4186 | 66450b15 | balrog | omap_pwl_update(s); |
4187 | 66450b15 | balrog | break;
|
4188 | 66450b15 | balrog | case 0x04: /* PWL_CTRL */ |
4189 | 66450b15 | balrog | s->pwl.enable = value & 1;
|
4190 | 66450b15 | balrog | omap_pwl_update(s); |
4191 | 66450b15 | balrog | break;
|
4192 | 66450b15 | balrog | default:
|
4193 | 66450b15 | balrog | OMAP_BAD_REG(addr); |
4194 | 66450b15 | balrog | return;
|
4195 | 66450b15 | balrog | } |
4196 | 66450b15 | balrog | } |
4197 | 66450b15 | balrog | |
4198 | 66450b15 | balrog | static CPUReadMemoryFunc *omap_pwl_readfn[] = {
|
4199 | 02645926 | balrog | omap_pwl_read, |
4200 | 66450b15 | balrog | omap_badwidth_read8, |
4201 | 66450b15 | balrog | omap_badwidth_read8, |
4202 | 66450b15 | balrog | }; |
4203 | 66450b15 | balrog | |
4204 | 66450b15 | balrog | static CPUWriteMemoryFunc *omap_pwl_writefn[] = {
|
4205 | 02645926 | balrog | omap_pwl_write, |
4206 | 66450b15 | balrog | omap_badwidth_write8, |
4207 | 66450b15 | balrog | omap_badwidth_write8, |
4208 | 66450b15 | balrog | }; |
4209 | 66450b15 | balrog | |
4210 | 9596ebb7 | pbrook | static void omap_pwl_reset(struct omap_mpu_state_s *s) |
4211 | 66450b15 | balrog | { |
4212 | 66450b15 | balrog | s->pwl.output = 0;
|
4213 | 66450b15 | balrog | s->pwl.level = 0;
|
4214 | 66450b15 | balrog | s->pwl.enable = 0;
|
4215 | 66450b15 | balrog | s->pwl.clk = 1;
|
4216 | 66450b15 | balrog | omap_pwl_update(s); |
4217 | 66450b15 | balrog | } |
4218 | 66450b15 | balrog | |
4219 | 66450b15 | balrog | static void omap_pwl_clk_update(void *opaque, int line, int on) |
4220 | 66450b15 | balrog | { |
4221 | 66450b15 | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
4222 | 66450b15 | balrog | |
4223 | 66450b15 | balrog | s->pwl.clk = on; |
4224 | 66450b15 | balrog | omap_pwl_update(s); |
4225 | 66450b15 | balrog | } |
4226 | 66450b15 | balrog | |
4227 | 66450b15 | balrog | static void omap_pwl_init(target_phys_addr_t base, struct omap_mpu_state_s *s, |
4228 | 66450b15 | balrog | omap_clk clk) |
4229 | 66450b15 | balrog | { |
4230 | 66450b15 | balrog | int iomemtype;
|
4231 | 66450b15 | balrog | |
4232 | 66450b15 | balrog | omap_pwl_reset(s); |
4233 | 66450b15 | balrog | |
4234 | 66450b15 | balrog | iomemtype = cpu_register_io_memory(0, omap_pwl_readfn,
|
4235 | 66450b15 | balrog | omap_pwl_writefn, s); |
4236 | b854bc19 | balrog | cpu_register_physical_memory(base, 0x800, iomemtype);
|
4237 | 66450b15 | balrog | |
4238 | 66450b15 | balrog | omap_clk_adduser(clk, qemu_allocate_irqs(omap_pwl_clk_update, s, 1)[0]); |
4239 | 66450b15 | balrog | } |
4240 | 66450b15 | balrog | |
4241 | f34c417b | balrog | /* Pulse-Width Tone module */
|
4242 | f34c417b | balrog | static uint32_t omap_pwt_read(void *opaque, target_phys_addr_t addr) |
4243 | f34c417b | balrog | { |
4244 | f34c417b | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
4245 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4246 | f34c417b | balrog | |
4247 | f34c417b | balrog | switch (offset) {
|
4248 | f34c417b | balrog | case 0x00: /* FRC */ |
4249 | f34c417b | balrog | return s->pwt.frc;
|
4250 | f34c417b | balrog | case 0x04: /* VCR */ |
4251 | f34c417b | balrog | return s->pwt.vrc;
|
4252 | f34c417b | balrog | case 0x08: /* GCR */ |
4253 | f34c417b | balrog | return s->pwt.gcr;
|
4254 | f34c417b | balrog | } |
4255 | f34c417b | balrog | OMAP_BAD_REG(addr); |
4256 | f34c417b | balrog | return 0; |
4257 | f34c417b | balrog | } |
4258 | f34c417b | balrog | |
4259 | f34c417b | balrog | static void omap_pwt_write(void *opaque, target_phys_addr_t addr, |
4260 | f34c417b | balrog | uint32_t value) |
4261 | f34c417b | balrog | { |
4262 | f34c417b | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; |
4263 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4264 | f34c417b | balrog | |
4265 | f34c417b | balrog | switch (offset) {
|
4266 | f34c417b | balrog | case 0x00: /* FRC */ |
4267 | f34c417b | balrog | s->pwt.frc = value & 0x3f;
|
4268 | f34c417b | balrog | break;
|
4269 | f34c417b | balrog | case 0x04: /* VRC */ |
4270 | f34c417b | balrog | if ((value ^ s->pwt.vrc) & 1) { |
4271 | f34c417b | balrog | if (value & 1) |
4272 | f34c417b | balrog | printf("%s: %iHz buzz on\n", __FUNCTION__, (int) |
4273 | f34c417b | balrog | /* 1.5 MHz from a 12-MHz or 13-MHz PWT_CLK */
|
4274 | f34c417b | balrog | ((omap_clk_getrate(s->pwt.clk) >> 3) /
|
4275 | f34c417b | balrog | /* Pre-multiplexer divider */
|
4276 | f34c417b | balrog | ((s->pwt.gcr & 2) ? 1 : 154) / |
4277 | f34c417b | balrog | /* Octave multiplexer */
|
4278 | f34c417b | balrog | (2 << (value & 3)) * |
4279 | f34c417b | balrog | /* 101/107 divider */
|
4280 | f34c417b | balrog | ((value & (1 << 2)) ? 101 : 107) * |
4281 | f34c417b | balrog | /* 49/55 divider */
|
4282 | f34c417b | balrog | ((value & (1 << 3)) ? 49 : 55) * |
4283 | f34c417b | balrog | /* 50/63 divider */
|
4284 | f34c417b | balrog | ((value & (1 << 4)) ? 50 : 63) * |
4285 | f34c417b | balrog | /* 80/127 divider */
|
4286 | f34c417b | balrog | ((value & (1 << 5)) ? 80 : 127) / |
4287 | f34c417b | balrog | (107 * 55 * 63 * 127))); |
4288 | f34c417b | balrog | else
|
4289 | f34c417b | balrog | printf("%s: silence!\n", __FUNCTION__);
|
4290 | f34c417b | balrog | } |
4291 | f34c417b | balrog | s->pwt.vrc = value & 0x7f;
|
4292 | f34c417b | balrog | break;
|
4293 | f34c417b | balrog | case 0x08: /* GCR */ |
4294 | f34c417b | balrog | s->pwt.gcr = value & 3;
|
4295 | f34c417b | balrog | break;
|
4296 | f34c417b | balrog | default:
|
4297 | f34c417b | balrog | OMAP_BAD_REG(addr); |
4298 | f34c417b | balrog | return;
|
4299 | f34c417b | balrog | } |
4300 | f34c417b | balrog | } |
4301 | f34c417b | balrog | |
4302 | f34c417b | balrog | static CPUReadMemoryFunc *omap_pwt_readfn[] = {
|
4303 | 02645926 | balrog | omap_pwt_read, |
4304 | f34c417b | balrog | omap_badwidth_read8, |
4305 | f34c417b | balrog | omap_badwidth_read8, |
4306 | f34c417b | balrog | }; |
4307 | f34c417b | balrog | |
4308 | f34c417b | balrog | static CPUWriteMemoryFunc *omap_pwt_writefn[] = {
|
4309 | 02645926 | balrog | omap_pwt_write, |
4310 | f34c417b | balrog | omap_badwidth_write8, |
4311 | f34c417b | balrog | omap_badwidth_write8, |
4312 | f34c417b | balrog | }; |
4313 | f34c417b | balrog | |
4314 | 9596ebb7 | pbrook | static void omap_pwt_reset(struct omap_mpu_state_s *s) |
4315 | f34c417b | balrog | { |
4316 | f34c417b | balrog | s->pwt.frc = 0;
|
4317 | f34c417b | balrog | s->pwt.vrc = 0;
|
4318 | f34c417b | balrog | s->pwt.gcr = 0;
|
4319 | f34c417b | balrog | } |
4320 | f34c417b | balrog | |
4321 | f34c417b | balrog | static void omap_pwt_init(target_phys_addr_t base, struct omap_mpu_state_s *s, |
4322 | f34c417b | balrog | omap_clk clk) |
4323 | f34c417b | balrog | { |
4324 | f34c417b | balrog | int iomemtype;
|
4325 | f34c417b | balrog | |
4326 | f34c417b | balrog | s->pwt.clk = clk; |
4327 | f34c417b | balrog | omap_pwt_reset(s); |
4328 | f34c417b | balrog | |
4329 | f34c417b | balrog | iomemtype = cpu_register_io_memory(0, omap_pwt_readfn,
|
4330 | f34c417b | balrog | omap_pwt_writefn, s); |
4331 | b854bc19 | balrog | cpu_register_physical_memory(base, 0x800, iomemtype);
|
4332 | f34c417b | balrog | } |
4333 | f34c417b | balrog | |
4334 | 5c1c390f | balrog | /* Real-time Clock module */
|
4335 | 5c1c390f | balrog | struct omap_rtc_s {
|
4336 | 5c1c390f | balrog | target_phys_addr_t base; |
4337 | 5c1c390f | balrog | qemu_irq irq; |
4338 | 5c1c390f | balrog | qemu_irq alarm; |
4339 | 5c1c390f | balrog | QEMUTimer *clk; |
4340 | 5c1c390f | balrog | |
4341 | 5c1c390f | balrog | uint8_t interrupts; |
4342 | 5c1c390f | balrog | uint8_t status; |
4343 | 5c1c390f | balrog | int16_t comp_reg; |
4344 | 5c1c390f | balrog | int running;
|
4345 | 5c1c390f | balrog | int pm_am;
|
4346 | 5c1c390f | balrog | int auto_comp;
|
4347 | 5c1c390f | balrog | int round;
|
4348 | 5c1c390f | balrog | struct tm *(*convert)(const time_t *timep, struct tm *result); |
4349 | 5c1c390f | balrog | struct tm alarm_tm;
|
4350 | 5c1c390f | balrog | time_t alarm_ti; |
4351 | 5c1c390f | balrog | |
4352 | 5c1c390f | balrog | struct tm current_tm;
|
4353 | 5c1c390f | balrog | time_t ti; |
4354 | 5c1c390f | balrog | uint64_t tick; |
4355 | 5c1c390f | balrog | }; |
4356 | 5c1c390f | balrog | |
4357 | 5c1c390f | balrog | static void omap_rtc_interrupts_update(struct omap_rtc_s *s) |
4358 | 5c1c390f | balrog | { |
4359 | 106627d0 | balrog | /* s->alarm is level-triggered */
|
4360 | 5c1c390f | balrog | qemu_set_irq(s->alarm, (s->status >> 6) & 1); |
4361 | 5c1c390f | balrog | } |
4362 | 5c1c390f | balrog | |
4363 | 5c1c390f | balrog | static void omap_rtc_alarm_update(struct omap_rtc_s *s) |
4364 | 5c1c390f | balrog | { |
4365 | 5c1c390f | balrog | s->alarm_ti = mktime(&s->alarm_tm); |
4366 | 5c1c390f | balrog | if (s->alarm_ti == -1) |
4367 | 5c1c390f | balrog | printf("%s: conversion failed\n", __FUNCTION__);
|
4368 | 5c1c390f | balrog | } |
4369 | 5c1c390f | balrog | |
4370 | 5c1c390f | balrog | static inline uint8_t omap_rtc_bcd(int num) |
4371 | 5c1c390f | balrog | { |
4372 | 5c1c390f | balrog | return ((num / 10) << 4) | (num % 10); |
4373 | 5c1c390f | balrog | } |
4374 | 5c1c390f | balrog | |
4375 | 5c1c390f | balrog | static inline int omap_rtc_bin(uint8_t num) |
4376 | 5c1c390f | balrog | { |
4377 | 5c1c390f | balrog | return (num & 15) + 10 * (num >> 4); |
4378 | 5c1c390f | balrog | } |
4379 | 5c1c390f | balrog | |
4380 | 5c1c390f | balrog | static uint32_t omap_rtc_read(void *opaque, target_phys_addr_t addr) |
4381 | 5c1c390f | balrog | { |
4382 | 5c1c390f | balrog | struct omap_rtc_s *s = (struct omap_rtc_s *) opaque; |
4383 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4384 | 5c1c390f | balrog | uint8_t i; |
4385 | 5c1c390f | balrog | |
4386 | 5c1c390f | balrog | switch (offset) {
|
4387 | 5c1c390f | balrog | case 0x00: /* SECONDS_REG */ |
4388 | 5c1c390f | balrog | return omap_rtc_bcd(s->current_tm.tm_sec);
|
4389 | 5c1c390f | balrog | |
4390 | 5c1c390f | balrog | case 0x04: /* MINUTES_REG */ |
4391 | 5c1c390f | balrog | return omap_rtc_bcd(s->current_tm.tm_min);
|
4392 | 5c1c390f | balrog | |
4393 | 5c1c390f | balrog | case 0x08: /* HOURS_REG */ |
4394 | 5c1c390f | balrog | if (s->pm_am)
|
4395 | 5c1c390f | balrog | return ((s->current_tm.tm_hour > 11) << 7) | |
4396 | 5c1c390f | balrog | omap_rtc_bcd(((s->current_tm.tm_hour - 1) % 12) + 1); |
4397 | 5c1c390f | balrog | else
|
4398 | 5c1c390f | balrog | return omap_rtc_bcd(s->current_tm.tm_hour);
|
4399 | 5c1c390f | balrog | |
4400 | 5c1c390f | balrog | case 0x0c: /* DAYS_REG */ |
4401 | 5c1c390f | balrog | return omap_rtc_bcd(s->current_tm.tm_mday);
|
4402 | 5c1c390f | balrog | |
4403 | 5c1c390f | balrog | case 0x10: /* MONTHS_REG */ |
4404 | 5c1c390f | balrog | return omap_rtc_bcd(s->current_tm.tm_mon + 1); |
4405 | 5c1c390f | balrog | |
4406 | 5c1c390f | balrog | case 0x14: /* YEARS_REG */ |
4407 | 5c1c390f | balrog | return omap_rtc_bcd(s->current_tm.tm_year % 100); |
4408 | 5c1c390f | balrog | |
4409 | 5c1c390f | balrog | case 0x18: /* WEEK_REG */ |
4410 | 5c1c390f | balrog | return s->current_tm.tm_wday;
|
4411 | 5c1c390f | balrog | |
4412 | 5c1c390f | balrog | case 0x20: /* ALARM_SECONDS_REG */ |
4413 | 5c1c390f | balrog | return omap_rtc_bcd(s->alarm_tm.tm_sec);
|
4414 | 5c1c390f | balrog | |
4415 | 5c1c390f | balrog | case 0x24: /* ALARM_MINUTES_REG */ |
4416 | 5c1c390f | balrog | return omap_rtc_bcd(s->alarm_tm.tm_min);
|
4417 | 5c1c390f | balrog | |
4418 | 5c1c390f | balrog | case 0x28: /* ALARM_HOURS_REG */ |
4419 | 5c1c390f | balrog | if (s->pm_am)
|
4420 | 5c1c390f | balrog | return ((s->alarm_tm.tm_hour > 11) << 7) | |
4421 | 5c1c390f | balrog | omap_rtc_bcd(((s->alarm_tm.tm_hour - 1) % 12) + 1); |
4422 | 5c1c390f | balrog | else
|
4423 | 5c1c390f | balrog | return omap_rtc_bcd(s->alarm_tm.tm_hour);
|
4424 | 5c1c390f | balrog | |
4425 | 5c1c390f | balrog | case 0x2c: /* ALARM_DAYS_REG */ |
4426 | 5c1c390f | balrog | return omap_rtc_bcd(s->alarm_tm.tm_mday);
|
4427 | 5c1c390f | balrog | |
4428 | 5c1c390f | balrog | case 0x30: /* ALARM_MONTHS_REG */ |
4429 | 5c1c390f | balrog | return omap_rtc_bcd(s->alarm_tm.tm_mon + 1); |
4430 | 5c1c390f | balrog | |
4431 | 5c1c390f | balrog | case 0x34: /* ALARM_YEARS_REG */ |
4432 | 5c1c390f | balrog | return omap_rtc_bcd(s->alarm_tm.tm_year % 100); |
4433 | 5c1c390f | balrog | |
4434 | 5c1c390f | balrog | case 0x40: /* RTC_CTRL_REG */ |
4435 | 5c1c390f | balrog | return (s->pm_am << 3) | (s->auto_comp << 2) | |
4436 | 5c1c390f | balrog | (s->round << 1) | s->running;
|
4437 | 5c1c390f | balrog | |
4438 | 5c1c390f | balrog | case 0x44: /* RTC_STATUS_REG */ |
4439 | 5c1c390f | balrog | i = s->status; |
4440 | 5c1c390f | balrog | s->status &= ~0x3d;
|
4441 | 5c1c390f | balrog | return i;
|
4442 | 5c1c390f | balrog | |
4443 | 5c1c390f | balrog | case 0x48: /* RTC_INTERRUPTS_REG */ |
4444 | 5c1c390f | balrog | return s->interrupts;
|
4445 | 5c1c390f | balrog | |
4446 | 5c1c390f | balrog | case 0x4c: /* RTC_COMP_LSB_REG */ |
4447 | 5c1c390f | balrog | return ((uint16_t) s->comp_reg) & 0xff; |
4448 | 5c1c390f | balrog | |
4449 | 5c1c390f | balrog | case 0x50: /* RTC_COMP_MSB_REG */ |
4450 | 5c1c390f | balrog | return ((uint16_t) s->comp_reg) >> 8; |
4451 | 5c1c390f | balrog | } |
4452 | 5c1c390f | balrog | |
4453 | 5c1c390f | balrog | OMAP_BAD_REG(addr); |
4454 | 5c1c390f | balrog | return 0; |
4455 | 5c1c390f | balrog | } |
4456 | 5c1c390f | balrog | |
4457 | 5c1c390f | balrog | static void omap_rtc_write(void *opaque, target_phys_addr_t addr, |
4458 | 5c1c390f | balrog | uint32_t value) |
4459 | 5c1c390f | balrog | { |
4460 | 5c1c390f | balrog | struct omap_rtc_s *s = (struct omap_rtc_s *) opaque; |
4461 | cf965d24 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4462 | 5c1c390f | balrog | struct tm new_tm;
|
4463 | 5c1c390f | balrog | time_t ti[2];
|
4464 | 5c1c390f | balrog | |
4465 | 5c1c390f | balrog | switch (offset) {
|
4466 | 5c1c390f | balrog | case 0x00: /* SECONDS_REG */ |
4467 | 5c1c390f | balrog | #if ALMDEBUG
|
4468 | 5c1c390f | balrog | printf("RTC SEC_REG <-- %02x\n", value);
|
4469 | 5c1c390f | balrog | #endif
|
4470 | 5c1c390f | balrog | s->ti -= s->current_tm.tm_sec; |
4471 | 5c1c390f | balrog | s->ti += omap_rtc_bin(value); |
4472 | 5c1c390f | balrog | return;
|
4473 | 5c1c390f | balrog | |
4474 | 5c1c390f | balrog | case 0x04: /* MINUTES_REG */ |
4475 | 5c1c390f | balrog | #if ALMDEBUG
|
4476 | 5c1c390f | balrog | printf("RTC MIN_REG <-- %02x\n", value);
|
4477 | 5c1c390f | balrog | #endif
|
4478 | 5c1c390f | balrog | s->ti -= s->current_tm.tm_min * 60;
|
4479 | 5c1c390f | balrog | s->ti += omap_rtc_bin(value) * 60;
|
4480 | 5c1c390f | balrog | return;
|
4481 | 5c1c390f | balrog | |
4482 | 5c1c390f | balrog | case 0x08: /* HOURS_REG */ |
4483 | 5c1c390f | balrog | #if ALMDEBUG
|
4484 | 5c1c390f | balrog | printf("RTC HRS_REG <-- %02x\n", value);
|
4485 | 5c1c390f | balrog | #endif
|
4486 | 5c1c390f | balrog | s->ti -= s->current_tm.tm_hour * 3600;
|
4487 | 5c1c390f | balrog | if (s->pm_am) {
|
4488 | 5c1c390f | balrog | s->ti += (omap_rtc_bin(value & 0x3f) & 12) * 3600; |
4489 | 5c1c390f | balrog | s->ti += ((value >> 7) & 1) * 43200; |
4490 | 5c1c390f | balrog | } else
|
4491 | 5c1c390f | balrog | s->ti += omap_rtc_bin(value & 0x3f) * 3600; |
4492 | 5c1c390f | balrog | return;
|
4493 | 5c1c390f | balrog | |
4494 | 5c1c390f | balrog | case 0x0c: /* DAYS_REG */ |
4495 | 5c1c390f | balrog | #if ALMDEBUG
|
4496 | 5c1c390f | balrog | printf("RTC DAY_REG <-- %02x\n", value);
|
4497 | 5c1c390f | balrog | #endif
|
4498 | 5c1c390f | balrog | s->ti -= s->current_tm.tm_mday * 86400;
|
4499 | 5c1c390f | balrog | s->ti += omap_rtc_bin(value) * 86400;
|
4500 | 5c1c390f | balrog | return;
|
4501 | 5c1c390f | balrog | |
4502 | 5c1c390f | balrog | case 0x10: /* MONTHS_REG */ |
4503 | 5c1c390f | balrog | #if ALMDEBUG
|
4504 | 5c1c390f | balrog | printf("RTC MTH_REG <-- %02x\n", value);
|
4505 | 5c1c390f | balrog | #endif
|
4506 | 5c1c390f | balrog | memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
|
4507 | 5c1c390f | balrog | new_tm.tm_mon = omap_rtc_bin(value); |
4508 | 5c1c390f | balrog | ti[0] = mktime(&s->current_tm);
|
4509 | 5c1c390f | balrog | ti[1] = mktime(&new_tm);
|
4510 | 5c1c390f | balrog | |
4511 | 5c1c390f | balrog | if (ti[0] != -1 && ti[1] != -1) { |
4512 | 5c1c390f | balrog | s->ti -= ti[0];
|
4513 | 5c1c390f | balrog | s->ti += ti[1];
|
4514 | 5c1c390f | balrog | } else {
|
4515 | 5c1c390f | balrog | /* A less accurate version */
|
4516 | 5c1c390f | balrog | s->ti -= s->current_tm.tm_mon * 2592000;
|
4517 | 5c1c390f | balrog | s->ti += omap_rtc_bin(value) * 2592000;
|
4518 | 5c1c390f | balrog | } |
4519 | 5c1c390f | balrog | return;
|
4520 | 5c1c390f | balrog | |
4521 | 5c1c390f | balrog | case 0x14: /* YEARS_REG */ |
4522 | 5c1c390f | balrog | #if ALMDEBUG
|
4523 | 5c1c390f | balrog | printf("RTC YRS_REG <-- %02x\n", value);
|
4524 | 5c1c390f | balrog | #endif
|
4525 | 5c1c390f | balrog | memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
|
4526 | 5c1c390f | balrog | new_tm.tm_year += omap_rtc_bin(value) - (new_tm.tm_year % 100);
|
4527 | 5c1c390f | balrog | ti[0] = mktime(&s->current_tm);
|
4528 | 5c1c390f | balrog | ti[1] = mktime(&new_tm);
|
4529 | 5c1c390f | balrog | |
4530 | 5c1c390f | balrog | if (ti[0] != -1 && ti[1] != -1) { |
4531 | 5c1c390f | balrog | s->ti -= ti[0];
|
4532 | 5c1c390f | balrog | s->ti += ti[1];
|
4533 | 5c1c390f | balrog | } else {
|
4534 | 5c1c390f | balrog | /* A less accurate version */
|
4535 | 5c1c390f | balrog | s->ti -= (s->current_tm.tm_year % 100) * 31536000; |
4536 | 5c1c390f | balrog | s->ti += omap_rtc_bin(value) * 31536000;
|
4537 | 5c1c390f | balrog | } |
4538 | 5c1c390f | balrog | return;
|
4539 | 5c1c390f | balrog | |
4540 | 5c1c390f | balrog | case 0x18: /* WEEK_REG */ |
4541 | 5c1c390f | balrog | return; /* Ignored */ |
4542 | 5c1c390f | balrog | |
4543 | 5c1c390f | balrog | case 0x20: /* ALARM_SECONDS_REG */ |
4544 | 5c1c390f | balrog | #if ALMDEBUG
|
4545 | 5c1c390f | balrog | printf("ALM SEC_REG <-- %02x\n", value);
|
4546 | 5c1c390f | balrog | #endif
|
4547 | 5c1c390f | balrog | s->alarm_tm.tm_sec = omap_rtc_bin(value); |
4548 | 5c1c390f | balrog | omap_rtc_alarm_update(s); |
4549 | 5c1c390f | balrog | return;
|
4550 | 5c1c390f | balrog | |
4551 | 5c1c390f | balrog | case 0x24: /* ALARM_MINUTES_REG */ |
4552 | 5c1c390f | balrog | #if ALMDEBUG
|
4553 | 5c1c390f | balrog | printf("ALM MIN_REG <-- %02x\n", value);
|
4554 | 5c1c390f | balrog | #endif
|
4555 | 5c1c390f | balrog | s->alarm_tm.tm_min = omap_rtc_bin(value); |
4556 | 5c1c390f | balrog | omap_rtc_alarm_update(s); |
4557 | 5c1c390f | balrog | return;
|
4558 | 5c1c390f | balrog | |
4559 | 5c1c390f | balrog | case 0x28: /* ALARM_HOURS_REG */ |
4560 | 5c1c390f | balrog | #if ALMDEBUG
|
4561 | 5c1c390f | balrog | printf("ALM HRS_REG <-- %02x\n", value);
|
4562 | 5c1c390f | balrog | #endif
|
4563 | 5c1c390f | balrog | if (s->pm_am)
|
4564 | 5c1c390f | balrog | s->alarm_tm.tm_hour = |
4565 | 5c1c390f | balrog | ((omap_rtc_bin(value & 0x3f)) % 12) + |
4566 | 5c1c390f | balrog | ((value >> 7) & 1) * 12; |
4567 | 5c1c390f | balrog | else
|
4568 | 5c1c390f | balrog | s->alarm_tm.tm_hour = omap_rtc_bin(value); |
4569 | 5c1c390f | balrog | omap_rtc_alarm_update(s); |
4570 | 5c1c390f | balrog | return;
|
4571 | 5c1c390f | balrog | |
4572 | 5c1c390f | balrog | case 0x2c: /* ALARM_DAYS_REG */ |
4573 | 5c1c390f | balrog | #if ALMDEBUG
|
4574 | 5c1c390f | balrog | printf("ALM DAY_REG <-- %02x\n", value);
|
4575 | 5c1c390f | balrog | #endif
|
4576 | 5c1c390f | balrog | s->alarm_tm.tm_mday = omap_rtc_bin(value); |
4577 | 5c1c390f | balrog | omap_rtc_alarm_update(s); |
4578 | 5c1c390f | balrog | return;
|
4579 | 5c1c390f | balrog | |
4580 | 5c1c390f | balrog | case 0x30: /* ALARM_MONTHS_REG */ |
4581 | 5c1c390f | balrog | #if ALMDEBUG
|
4582 | 5c1c390f | balrog | printf("ALM MON_REG <-- %02x\n", value);
|
4583 | 5c1c390f | balrog | #endif
|
4584 | 5c1c390f | balrog | s->alarm_tm.tm_mon = omap_rtc_bin(value); |
4585 | 5c1c390f | balrog | omap_rtc_alarm_update(s); |
4586 | 5c1c390f | balrog | return;
|
4587 | 5c1c390f | balrog | |
4588 | 5c1c390f | balrog | case 0x34: /* ALARM_YEARS_REG */ |
4589 | 5c1c390f | balrog | #if ALMDEBUG
|
4590 | 5c1c390f | balrog | printf("ALM YRS_REG <-- %02x\n", value);
|
4591 | 5c1c390f | balrog | #endif
|
4592 | 5c1c390f | balrog | s->alarm_tm.tm_year = omap_rtc_bin(value); |
4593 | 5c1c390f | balrog | omap_rtc_alarm_update(s); |
4594 | 5c1c390f | balrog | return;
|
4595 | 5c1c390f | balrog | |
4596 | 5c1c390f | balrog | case 0x40: /* RTC_CTRL_REG */ |
4597 | 5c1c390f | balrog | #if ALMDEBUG
|
4598 | 5c1c390f | balrog | printf("RTC CONTROL <-- %02x\n", value);
|
4599 | 5c1c390f | balrog | #endif
|
4600 | 5c1c390f | balrog | s->pm_am = (value >> 3) & 1; |
4601 | 5c1c390f | balrog | s->auto_comp = (value >> 2) & 1; |
4602 | 5c1c390f | balrog | s->round = (value >> 1) & 1; |
4603 | 5c1c390f | balrog | s->running = value & 1;
|
4604 | 5c1c390f | balrog | s->status &= 0xfd;
|
4605 | 5c1c390f | balrog | s->status |= s->running << 1;
|
4606 | 5c1c390f | balrog | return;
|
4607 | 5c1c390f | balrog | |
4608 | 5c1c390f | balrog | case 0x44: /* RTC_STATUS_REG */ |
4609 | 5c1c390f | balrog | #if ALMDEBUG
|
4610 | 5c1c390f | balrog | printf("RTC STATUSL <-- %02x\n", value);
|
4611 | 5c1c390f | balrog | #endif
|
4612 | 5c1c390f | balrog | s->status &= ~((value & 0xc0) ^ 0x80); |
4613 | 5c1c390f | balrog | omap_rtc_interrupts_update(s); |
4614 | 5c1c390f | balrog | return;
|
4615 | 5c1c390f | balrog | |
4616 | 5c1c390f | balrog | case 0x48: /* RTC_INTERRUPTS_REG */ |
4617 | 5c1c390f | balrog | #if ALMDEBUG
|
4618 | 5c1c390f | balrog | printf("RTC INTRS <-- %02x\n", value);
|
4619 | 5c1c390f | balrog | #endif
|
4620 | 5c1c390f | balrog | s->interrupts = value; |
4621 | 5c1c390f | balrog | return;
|
4622 | 5c1c390f | balrog | |
4623 | 5c1c390f | balrog | case 0x4c: /* RTC_COMP_LSB_REG */ |
4624 | 5c1c390f | balrog | #if ALMDEBUG
|
4625 | 5c1c390f | balrog | printf("RTC COMPLSB <-- %02x\n", value);
|
4626 | 5c1c390f | balrog | #endif
|
4627 | 5c1c390f | balrog | s->comp_reg &= 0xff00;
|
4628 | 5c1c390f | balrog | s->comp_reg |= 0x00ff & value;
|
4629 | 5c1c390f | balrog | return;
|
4630 | 5c1c390f | balrog | |
4631 | 5c1c390f | balrog | case 0x50: /* RTC_COMP_MSB_REG */ |
4632 | 5c1c390f | balrog | #if ALMDEBUG
|
4633 | 5c1c390f | balrog | printf("RTC COMPMSB <-- %02x\n", value);
|
4634 | 5c1c390f | balrog | #endif
|
4635 | 5c1c390f | balrog | s->comp_reg &= 0x00ff;
|
4636 | 5c1c390f | balrog | s->comp_reg |= 0xff00 & (value << 8); |
4637 | 5c1c390f | balrog | return;
|
4638 | 5c1c390f | balrog | |
4639 | 5c1c390f | balrog | default:
|
4640 | 5c1c390f | balrog | OMAP_BAD_REG(addr); |
4641 | 5c1c390f | balrog | return;
|
4642 | 5c1c390f | balrog | } |
4643 | 5c1c390f | balrog | } |
4644 | 5c1c390f | balrog | |
4645 | 5c1c390f | balrog | static CPUReadMemoryFunc *omap_rtc_readfn[] = {
|
4646 | 5c1c390f | balrog | omap_rtc_read, |
4647 | 5c1c390f | balrog | omap_badwidth_read8, |
4648 | 5c1c390f | balrog | omap_badwidth_read8, |
4649 | 5c1c390f | balrog | }; |
4650 | 5c1c390f | balrog | |
4651 | 5c1c390f | balrog | static CPUWriteMemoryFunc *omap_rtc_writefn[] = {
|
4652 | 5c1c390f | balrog | omap_rtc_write, |
4653 | 5c1c390f | balrog | omap_badwidth_write8, |
4654 | 5c1c390f | balrog | omap_badwidth_write8, |
4655 | 5c1c390f | balrog | }; |
4656 | 5c1c390f | balrog | |
4657 | 5c1c390f | balrog | static void omap_rtc_tick(void *opaque) |
4658 | 5c1c390f | balrog | { |
4659 | 5c1c390f | balrog | struct omap_rtc_s *s = opaque;
|
4660 | 5c1c390f | balrog | |
4661 | 5c1c390f | balrog | if (s->round) {
|
4662 | 5c1c390f | balrog | /* Round to nearest full minute. */
|
4663 | 5c1c390f | balrog | if (s->current_tm.tm_sec < 30) |
4664 | 5c1c390f | balrog | s->ti -= s->current_tm.tm_sec; |
4665 | 5c1c390f | balrog | else
|
4666 | 5c1c390f | balrog | s->ti += 60 - s->current_tm.tm_sec;
|
4667 | 5c1c390f | balrog | |
4668 | 5c1c390f | balrog | s->round = 0;
|
4669 | 5c1c390f | balrog | } |
4670 | 5c1c390f | balrog | |
4671 | 5c1c390f | balrog | localtime_r(&s->ti, &s->current_tm); |
4672 | 5c1c390f | balrog | |
4673 | 5c1c390f | balrog | if ((s->interrupts & 0x08) && s->ti == s->alarm_ti) { |
4674 | 5c1c390f | balrog | s->status |= 0x40;
|
4675 | 5c1c390f | balrog | omap_rtc_interrupts_update(s); |
4676 | 5c1c390f | balrog | } |
4677 | 5c1c390f | balrog | |
4678 | 5c1c390f | balrog | if (s->interrupts & 0x04) |
4679 | 5c1c390f | balrog | switch (s->interrupts & 3) { |
4680 | 5c1c390f | balrog | case 0: |
4681 | 5c1c390f | balrog | s->status |= 0x04;
|
4682 | 106627d0 | balrog | qemu_irq_pulse(s->irq); |
4683 | 5c1c390f | balrog | break;
|
4684 | 5c1c390f | balrog | case 1: |
4685 | 5c1c390f | balrog | if (s->current_tm.tm_sec)
|
4686 | 5c1c390f | balrog | break;
|
4687 | 5c1c390f | balrog | s->status |= 0x08;
|
4688 | 106627d0 | balrog | qemu_irq_pulse(s->irq); |
4689 | 5c1c390f | balrog | break;
|
4690 | 5c1c390f | balrog | case 2: |
4691 | 5c1c390f | balrog | if (s->current_tm.tm_sec || s->current_tm.tm_min)
|
4692 | 5c1c390f | balrog | break;
|
4693 | 5c1c390f | balrog | s->status |= 0x10;
|
4694 | 106627d0 | balrog | qemu_irq_pulse(s->irq); |
4695 | 5c1c390f | balrog | break;
|
4696 | 5c1c390f | balrog | case 3: |
4697 | 5c1c390f | balrog | if (s->current_tm.tm_sec ||
|
4698 | 5c1c390f | balrog | s->current_tm.tm_min || s->current_tm.tm_hour) |
4699 | 5c1c390f | balrog | break;
|
4700 | 5c1c390f | balrog | s->status |= 0x20;
|
4701 | 106627d0 | balrog | qemu_irq_pulse(s->irq); |
4702 | 5c1c390f | balrog | break;
|
4703 | 5c1c390f | balrog | } |
4704 | 5c1c390f | balrog | |
4705 | 5c1c390f | balrog | /* Move on */
|
4706 | 5c1c390f | balrog | if (s->running)
|
4707 | 5c1c390f | balrog | s->ti ++; |
4708 | 5c1c390f | balrog | s->tick += 1000;
|
4709 | 5c1c390f | balrog | |
4710 | 5c1c390f | balrog | /*
|
4711 | 5c1c390f | balrog | * Every full hour add a rough approximation of the compensation
|
4712 | 5c1c390f | balrog | * register to the 32kHz Timer (which drives the RTC) value.
|
4713 | 5c1c390f | balrog | */
|
4714 | 5c1c390f | balrog | if (s->auto_comp && !s->current_tm.tm_sec && !s->current_tm.tm_min)
|
4715 | 5c1c390f | balrog | s->tick += s->comp_reg * 1000 / 32768; |
4716 | 5c1c390f | balrog | |
4717 | 5c1c390f | balrog | qemu_mod_timer(s->clk, s->tick); |
4718 | 5c1c390f | balrog | } |
4719 | 5c1c390f | balrog | |
4720 | 9596ebb7 | pbrook | static void omap_rtc_reset(struct omap_rtc_s *s) |
4721 | 5c1c390f | balrog | { |
4722 | 5c1c390f | balrog | s->interrupts = 0;
|
4723 | 5c1c390f | balrog | s->comp_reg = 0;
|
4724 | 5c1c390f | balrog | s->running = 0;
|
4725 | 5c1c390f | balrog | s->pm_am = 0;
|
4726 | 5c1c390f | balrog | s->auto_comp = 0;
|
4727 | 5c1c390f | balrog | s->round = 0;
|
4728 | 5c1c390f | balrog | s->tick = qemu_get_clock(rt_clock); |
4729 | 5c1c390f | balrog | memset(&s->alarm_tm, 0, sizeof(s->alarm_tm)); |
4730 | 5c1c390f | balrog | s->alarm_tm.tm_mday = 0x01;
|
4731 | 5c1c390f | balrog | s->status = 1 << 7; |
4732 | 5c1c390f | balrog | time(&s->ti); |
4733 | 5c1c390f | balrog | s->ti = mktime(s->convert(&s->ti, &s->current_tm)); |
4734 | 5c1c390f | balrog | |
4735 | 5c1c390f | balrog | omap_rtc_alarm_update(s); |
4736 | 5c1c390f | balrog | omap_rtc_tick(s); |
4737 | 5c1c390f | balrog | } |
4738 | 5c1c390f | balrog | |
4739 | 5c1c390f | balrog | struct omap_rtc_s *omap_rtc_init(target_phys_addr_t base,
|
4740 | 5c1c390f | balrog | qemu_irq *irq, omap_clk clk) |
4741 | 5c1c390f | balrog | { |
4742 | 5c1c390f | balrog | int iomemtype;
|
4743 | 5c1c390f | balrog | struct omap_rtc_s *s = (struct omap_rtc_s *) |
4744 | 5c1c390f | balrog | qemu_mallocz(sizeof(struct omap_rtc_s)); |
4745 | 5c1c390f | balrog | |
4746 | 5c1c390f | balrog | s->base = base; |
4747 | 5c1c390f | balrog | s->irq = irq[0];
|
4748 | 5c1c390f | balrog | s->alarm = irq[1];
|
4749 | 5c1c390f | balrog | s->clk = qemu_new_timer(rt_clock, omap_rtc_tick, s); |
4750 | 5c1c390f | balrog | s->convert = rtc_utc ? gmtime_r : localtime_r; |
4751 | 5c1c390f | balrog | |
4752 | 5c1c390f | balrog | omap_rtc_reset(s); |
4753 | 5c1c390f | balrog | |
4754 | 5c1c390f | balrog | iomemtype = cpu_register_io_memory(0, omap_rtc_readfn,
|
4755 | 5c1c390f | balrog | omap_rtc_writefn, s); |
4756 | 5c1c390f | balrog | cpu_register_physical_memory(s->base, 0x800, iomemtype);
|
4757 | 5c1c390f | balrog | |
4758 | 5c1c390f | balrog | return s;
|
4759 | 5c1c390f | balrog | } |
4760 | 5c1c390f | balrog | |
4761 | d8f699cb | balrog | /* Multi-channel Buffered Serial Port interfaces */
|
4762 | d8f699cb | balrog | struct omap_mcbsp_s {
|
4763 | d8f699cb | balrog | target_phys_addr_t base; |
4764 | d8f699cb | balrog | qemu_irq txirq; |
4765 | d8f699cb | balrog | qemu_irq rxirq; |
4766 | d8f699cb | balrog | qemu_irq txdrq; |
4767 | d8f699cb | balrog | qemu_irq rxdrq; |
4768 | d8f699cb | balrog | |
4769 | d8f699cb | balrog | uint16_t spcr[2];
|
4770 | d8f699cb | balrog | uint16_t rcr[2];
|
4771 | d8f699cb | balrog | uint16_t xcr[2];
|
4772 | d8f699cb | balrog | uint16_t srgr[2];
|
4773 | d8f699cb | balrog | uint16_t mcr[2];
|
4774 | d8f699cb | balrog | uint16_t pcr; |
4775 | d8f699cb | balrog | uint16_t rcer[8];
|
4776 | d8f699cb | balrog | uint16_t xcer[8];
|
4777 | d8f699cb | balrog | int tx_rate;
|
4778 | d8f699cb | balrog | int rx_rate;
|
4779 | d8f699cb | balrog | int tx_req;
|
4780 | 73560bc8 | balrog | int rx_req;
|
4781 | d8f699cb | balrog | |
4782 | d8f699cb | balrog | struct i2s_codec_s *codec;
|
4783 | 73560bc8 | balrog | QEMUTimer *source_timer; |
4784 | 73560bc8 | balrog | QEMUTimer *sink_timer; |
4785 | d8f699cb | balrog | }; |
4786 | d8f699cb | balrog | |
4787 | d8f699cb | balrog | static void omap_mcbsp_intr_update(struct omap_mcbsp_s *s) |
4788 | d8f699cb | balrog | { |
4789 | d8f699cb | balrog | int irq;
|
4790 | d8f699cb | balrog | |
4791 | d8f699cb | balrog | switch ((s->spcr[0] >> 4) & 3) { /* RINTM */ |
4792 | d8f699cb | balrog | case 0: |
4793 | d8f699cb | balrog | irq = (s->spcr[0] >> 1) & 1; /* RRDY */ |
4794 | d8f699cb | balrog | break;
|
4795 | d8f699cb | balrog | case 3: |
4796 | d8f699cb | balrog | irq = (s->spcr[0] >> 3) & 1; /* RSYNCERR */ |
4797 | d8f699cb | balrog | break;
|
4798 | d8f699cb | balrog | default:
|
4799 | d8f699cb | balrog | irq = 0;
|
4800 | d8f699cb | balrog | break;
|
4801 | d8f699cb | balrog | } |
4802 | d8f699cb | balrog | |
4803 | 106627d0 | balrog | if (irq)
|
4804 | 106627d0 | balrog | qemu_irq_pulse(s->rxirq); |
4805 | d8f699cb | balrog | |
4806 | d8f699cb | balrog | switch ((s->spcr[1] >> 4) & 3) { /* XINTM */ |
4807 | d8f699cb | balrog | case 0: |
4808 | d8f699cb | balrog | irq = (s->spcr[1] >> 1) & 1; /* XRDY */ |
4809 | d8f699cb | balrog | break;
|
4810 | d8f699cb | balrog | case 3: |
4811 | d8f699cb | balrog | irq = (s->spcr[1] >> 3) & 1; /* XSYNCERR */ |
4812 | d8f699cb | balrog | break;
|
4813 | d8f699cb | balrog | default:
|
4814 | d8f699cb | balrog | irq = 0;
|
4815 | d8f699cb | balrog | break;
|
4816 | d8f699cb | balrog | } |
4817 | d8f699cb | balrog | |
4818 | 106627d0 | balrog | if (irq)
|
4819 | 106627d0 | balrog | qemu_irq_pulse(s->txirq); |
4820 | d8f699cb | balrog | } |
4821 | d8f699cb | balrog | |
4822 | 73560bc8 | balrog | static void omap_mcbsp_rx_newdata(struct omap_mcbsp_s *s) |
4823 | d8f699cb | balrog | { |
4824 | 73560bc8 | balrog | if ((s->spcr[0] >> 1) & 1) /* RRDY */ |
4825 | 73560bc8 | balrog | s->spcr[0] |= 1 << 2; /* RFULL */ |
4826 | 73560bc8 | balrog | s->spcr[0] |= 1 << 1; /* RRDY */ |
4827 | 73560bc8 | balrog | qemu_irq_raise(s->rxdrq); |
4828 | 73560bc8 | balrog | omap_mcbsp_intr_update(s); |
4829 | d8f699cb | balrog | } |
4830 | d8f699cb | balrog | |
4831 | 73560bc8 | balrog | static void omap_mcbsp_source_tick(void *opaque) |
4832 | d8f699cb | balrog | { |
4833 | 73560bc8 | balrog | struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; |
4834 | 73560bc8 | balrog | static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 }; |
4835 | 73560bc8 | balrog | |
4836 | 73560bc8 | balrog | if (!s->rx_rate)
|
4837 | d8f699cb | balrog | return;
|
4838 | 73560bc8 | balrog | if (s->rx_req)
|
4839 | 73560bc8 | balrog | printf("%s: Rx FIFO overrun\n", __FUNCTION__);
|
4840 | d8f699cb | balrog | |
4841 | 73560bc8 | balrog | s->rx_req = s->rx_rate << bps[(s->rcr[0] >> 5) & 7]; |
4842 | d8f699cb | balrog | |
4843 | 73560bc8 | balrog | omap_mcbsp_rx_newdata(s); |
4844 | 73560bc8 | balrog | qemu_mod_timer(s->source_timer, qemu_get_clock(vm_clock) + ticks_per_sec); |
4845 | d8f699cb | balrog | } |
4846 | d8f699cb | balrog | |
4847 | d8f699cb | balrog | static void omap_mcbsp_rx_start(struct omap_mcbsp_s *s) |
4848 | d8f699cb | balrog | { |
4849 | 73560bc8 | balrog | if (!s->codec || !s->codec->rts)
|
4850 | 73560bc8 | balrog | omap_mcbsp_source_tick(s); |
4851 | 73560bc8 | balrog | else if (s->codec->in.len) { |
4852 | 73560bc8 | balrog | s->rx_req = s->codec->in.len; |
4853 | 73560bc8 | balrog | omap_mcbsp_rx_newdata(s); |
4854 | d8f699cb | balrog | } |
4855 | d8f699cb | balrog | } |
4856 | d8f699cb | balrog | |
4857 | d8f699cb | balrog | static void omap_mcbsp_rx_stop(struct omap_mcbsp_s *s) |
4858 | d8f699cb | balrog | { |
4859 | 73560bc8 | balrog | qemu_del_timer(s->source_timer); |
4860 | 73560bc8 | balrog | } |
4861 | 73560bc8 | balrog | |
4862 | 73560bc8 | balrog | static void omap_mcbsp_rx_done(struct omap_mcbsp_s *s) |
4863 | 73560bc8 | balrog | { |
4864 | d8f699cb | balrog | s->spcr[0] &= ~(1 << 1); /* RRDY */ |
4865 | d8f699cb | balrog | qemu_irq_lower(s->rxdrq); |
4866 | d8f699cb | balrog | omap_mcbsp_intr_update(s); |
4867 | d8f699cb | balrog | } |
4868 | d8f699cb | balrog | |
4869 | 73560bc8 | balrog | static void omap_mcbsp_tx_newdata(struct omap_mcbsp_s *s) |
4870 | 73560bc8 | balrog | { |
4871 | 73560bc8 | balrog | s->spcr[1] |= 1 << 1; /* XRDY */ |
4872 | 73560bc8 | balrog | qemu_irq_raise(s->txdrq); |
4873 | 73560bc8 | balrog | omap_mcbsp_intr_update(s); |
4874 | 73560bc8 | balrog | } |
4875 | 73560bc8 | balrog | |
4876 | 73560bc8 | balrog | static void omap_mcbsp_sink_tick(void *opaque) |
4877 | d8f699cb | balrog | { |
4878 | 73560bc8 | balrog | struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; |
4879 | 73560bc8 | balrog | static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 }; |
4880 | 73560bc8 | balrog | |
4881 | 73560bc8 | balrog | if (!s->tx_rate)
|
4882 | d8f699cb | balrog | return;
|
4883 | 73560bc8 | balrog | if (s->tx_req)
|
4884 | 73560bc8 | balrog | printf("%s: Tx FIFO underrun\n", __FUNCTION__);
|
4885 | 73560bc8 | balrog | |
4886 | 73560bc8 | balrog | s->tx_req = s->tx_rate << bps[(s->xcr[0] >> 5) & 7]; |
4887 | 73560bc8 | balrog | |
4888 | 73560bc8 | balrog | omap_mcbsp_tx_newdata(s); |
4889 | 73560bc8 | balrog | qemu_mod_timer(s->sink_timer, qemu_get_clock(vm_clock) + ticks_per_sec); |
4890 | 73560bc8 | balrog | } |
4891 | 73560bc8 | balrog | |
4892 | 73560bc8 | balrog | static void omap_mcbsp_tx_start(struct omap_mcbsp_s *s) |
4893 | 73560bc8 | balrog | { |
4894 | 73560bc8 | balrog | if (!s->codec || !s->codec->cts)
|
4895 | 73560bc8 | balrog | omap_mcbsp_sink_tick(s); |
4896 | 73560bc8 | balrog | else if (s->codec->out.size) { |
4897 | 73560bc8 | balrog | s->tx_req = s->codec->out.size; |
4898 | 73560bc8 | balrog | omap_mcbsp_tx_newdata(s); |
4899 | 73560bc8 | balrog | } |
4900 | 73560bc8 | balrog | } |
4901 | 73560bc8 | balrog | |
4902 | 73560bc8 | balrog | static void omap_mcbsp_tx_done(struct omap_mcbsp_s *s) |
4903 | 73560bc8 | balrog | { |
4904 | 73560bc8 | balrog | s->spcr[1] &= ~(1 << 1); /* XRDY */ |
4905 | 73560bc8 | balrog | qemu_irq_lower(s->txdrq); |
4906 | 73560bc8 | balrog | omap_mcbsp_intr_update(s); |
4907 | 73560bc8 | balrog | if (s->codec && s->codec->cts)
|
4908 | 73560bc8 | balrog | s->codec->tx_swallow(s->codec->opaque); |
4909 | d8f699cb | balrog | } |
4910 | d8f699cb | balrog | |
4911 | d8f699cb | balrog | static void omap_mcbsp_tx_stop(struct omap_mcbsp_s *s) |
4912 | d8f699cb | balrog | { |
4913 | 73560bc8 | balrog | s->tx_req = 0;
|
4914 | 73560bc8 | balrog | omap_mcbsp_tx_done(s); |
4915 | 73560bc8 | balrog | qemu_del_timer(s->sink_timer); |
4916 | 73560bc8 | balrog | } |
4917 | 73560bc8 | balrog | |
4918 | 73560bc8 | balrog | static void omap_mcbsp_req_update(struct omap_mcbsp_s *s) |
4919 | 73560bc8 | balrog | { |
4920 | 73560bc8 | balrog | int prev_rx_rate, prev_tx_rate;
|
4921 | 73560bc8 | balrog | int rx_rate = 0, tx_rate = 0; |
4922 | 73560bc8 | balrog | int cpu_rate = 1500000; /* XXX */ |
4923 | 73560bc8 | balrog | |
4924 | 73560bc8 | balrog | /* TODO: check CLKSTP bit */
|
4925 | 73560bc8 | balrog | if (s->spcr[1] & (1 << 6)) { /* GRST */ |
4926 | 73560bc8 | balrog | if (s->spcr[0] & (1 << 0)) { /* RRST */ |
4927 | 73560bc8 | balrog | if ((s->srgr[1] & (1 << 13)) && /* CLKSM */ |
4928 | 73560bc8 | balrog | (s->pcr & (1 << 8))) { /* CLKRM */ |
4929 | 73560bc8 | balrog | if (~s->pcr & (1 << 7)) /* SCLKME */ |
4930 | 73560bc8 | balrog | rx_rate = cpu_rate / |
4931 | 73560bc8 | balrog | ((s->srgr[0] & 0xff) + 1); /* CLKGDV */ |
4932 | 73560bc8 | balrog | } else
|
4933 | 73560bc8 | balrog | if (s->codec)
|
4934 | 73560bc8 | balrog | rx_rate = s->codec->rx_rate; |
4935 | 73560bc8 | balrog | } |
4936 | 73560bc8 | balrog | |
4937 | 73560bc8 | balrog | if (s->spcr[1] & (1 << 0)) { /* XRST */ |
4938 | 73560bc8 | balrog | if ((s->srgr[1] & (1 << 13)) && /* CLKSM */ |
4939 | 73560bc8 | balrog | (s->pcr & (1 << 9))) { /* CLKXM */ |
4940 | 73560bc8 | balrog | if (~s->pcr & (1 << 7)) /* SCLKME */ |
4941 | 73560bc8 | balrog | tx_rate = cpu_rate / |
4942 | 73560bc8 | balrog | ((s->srgr[0] & 0xff) + 1); /* CLKGDV */ |
4943 | 73560bc8 | balrog | } else
|
4944 | 73560bc8 | balrog | if (s->codec)
|
4945 | 73560bc8 | balrog | tx_rate = s->codec->tx_rate; |
4946 | 73560bc8 | balrog | } |
4947 | 73560bc8 | balrog | } |
4948 | 73560bc8 | balrog | prev_tx_rate = s->tx_rate; |
4949 | 73560bc8 | balrog | prev_rx_rate = s->rx_rate; |
4950 | 73560bc8 | balrog | s->tx_rate = tx_rate; |
4951 | 73560bc8 | balrog | s->rx_rate = rx_rate; |
4952 | 73560bc8 | balrog | |
4953 | 73560bc8 | balrog | if (s->codec)
|
4954 | 73560bc8 | balrog | s->codec->set_rate(s->codec->opaque, rx_rate, tx_rate); |
4955 | 73560bc8 | balrog | |
4956 | 73560bc8 | balrog | if (!prev_tx_rate && tx_rate)
|
4957 | 73560bc8 | balrog | omap_mcbsp_tx_start(s); |
4958 | 73560bc8 | balrog | else if (s->tx_rate && !tx_rate) |
4959 | 73560bc8 | balrog | omap_mcbsp_tx_stop(s); |
4960 | 73560bc8 | balrog | |
4961 | 73560bc8 | balrog | if (!prev_rx_rate && rx_rate)
|
4962 | 73560bc8 | balrog | omap_mcbsp_rx_start(s); |
4963 | 73560bc8 | balrog | else if (prev_tx_rate && !tx_rate) |
4964 | 73560bc8 | balrog | omap_mcbsp_rx_stop(s); |
4965 | d8f699cb | balrog | } |
4966 | d8f699cb | balrog | |
4967 | d8f699cb | balrog | static uint32_t omap_mcbsp_read(void *opaque, target_phys_addr_t addr) |
4968 | d8f699cb | balrog | { |
4969 | d8f699cb | balrog | struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; |
4970 | d8f699cb | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
4971 | d8f699cb | balrog | uint16_t ret; |
4972 | d8f699cb | balrog | |
4973 | d8f699cb | balrog | switch (offset) {
|
4974 | d8f699cb | balrog | case 0x00: /* DRR2 */ |
4975 | d8f699cb | balrog | if (((s->rcr[0] >> 5) & 7) < 3) /* RWDLEN1 */ |
4976 | d8f699cb | balrog | return 0x0000; |
4977 | d8f699cb | balrog | /* Fall through. */
|
4978 | d8f699cb | balrog | case 0x02: /* DRR1 */ |
4979 | 73560bc8 | balrog | if (s->rx_req < 2) { |
4980 | d8f699cb | balrog | printf("%s: Rx FIFO underrun\n", __FUNCTION__);
|
4981 | 73560bc8 | balrog | omap_mcbsp_rx_done(s); |
4982 | d8f699cb | balrog | } else {
|
4983 | 73560bc8 | balrog | s->tx_req -= 2;
|
4984 | 73560bc8 | balrog | if (s->codec && s->codec->in.len >= 2) { |
4985 | 73560bc8 | balrog | ret = s->codec->in.fifo[s->codec->in.start ++] << 8;
|
4986 | 73560bc8 | balrog | ret |= s->codec->in.fifo[s->codec->in.start ++]; |
4987 | 73560bc8 | balrog | s->codec->in.len -= 2;
|
4988 | 73560bc8 | balrog | } else
|
4989 | 73560bc8 | balrog | ret = 0x0000;
|
4990 | 73560bc8 | balrog | if (!s->tx_req)
|
4991 | 73560bc8 | balrog | omap_mcbsp_rx_done(s); |
4992 | d8f699cb | balrog | return ret;
|
4993 | d8f699cb | balrog | } |
4994 | d8f699cb | balrog | return 0x0000; |
4995 | d8f699cb | balrog | |
4996 | d8f699cb | balrog | case 0x04: /* DXR2 */ |
4997 | d8f699cb | balrog | case 0x06: /* DXR1 */ |
4998 | d8f699cb | balrog | return 0x0000; |
4999 | d8f699cb | balrog | |
5000 | d8f699cb | balrog | case 0x08: /* SPCR2 */ |
5001 | d8f699cb | balrog | return s->spcr[1]; |
5002 | d8f699cb | balrog | case 0x0a: /* SPCR1 */ |
5003 | d8f699cb | balrog | return s->spcr[0]; |
5004 | d8f699cb | balrog | case 0x0c: /* RCR2 */ |
5005 | d8f699cb | balrog | return s->rcr[1]; |
5006 | d8f699cb | balrog | case 0x0e: /* RCR1 */ |
5007 | d8f699cb | balrog | return s->rcr[0]; |
5008 | d8f699cb | balrog | case 0x10: /* XCR2 */ |
5009 | d8f699cb | balrog | return s->xcr[1]; |
5010 | d8f699cb | balrog | case 0x12: /* XCR1 */ |
5011 | d8f699cb | balrog | return s->xcr[0]; |
5012 | d8f699cb | balrog | case 0x14: /* SRGR2 */ |
5013 | d8f699cb | balrog | return s->srgr[1]; |
5014 | d8f699cb | balrog | case 0x16: /* SRGR1 */ |
5015 | d8f699cb | balrog | return s->srgr[0]; |
5016 | d8f699cb | balrog | case 0x18: /* MCR2 */ |
5017 | d8f699cb | balrog | return s->mcr[1]; |
5018 | d8f699cb | balrog | case 0x1a: /* MCR1 */ |
5019 | d8f699cb | balrog | return s->mcr[0]; |
5020 | d8f699cb | balrog | case 0x1c: /* RCERA */ |
5021 | d8f699cb | balrog | return s->rcer[0]; |
5022 | d8f699cb | balrog | case 0x1e: /* RCERB */ |
5023 | d8f699cb | balrog | return s->rcer[1]; |
5024 | d8f699cb | balrog | case 0x20: /* XCERA */ |
5025 | d8f699cb | balrog | return s->xcer[0]; |
5026 | d8f699cb | balrog | case 0x22: /* XCERB */ |
5027 | d8f699cb | balrog | return s->xcer[1]; |
5028 | d8f699cb | balrog | case 0x24: /* PCR0 */ |
5029 | d8f699cb | balrog | return s->pcr;
|
5030 | d8f699cb | balrog | case 0x26: /* RCERC */ |
5031 | d8f699cb | balrog | return s->rcer[2]; |
5032 | d8f699cb | balrog | case 0x28: /* RCERD */ |
5033 | d8f699cb | balrog | return s->rcer[3]; |
5034 | d8f699cb | balrog | case 0x2a: /* XCERC */ |
5035 | d8f699cb | balrog | return s->xcer[2]; |
5036 | d8f699cb | balrog | case 0x2c: /* XCERD */ |
5037 | d8f699cb | balrog | return s->xcer[3]; |
5038 | d8f699cb | balrog | case 0x2e: /* RCERE */ |
5039 | d8f699cb | balrog | return s->rcer[4]; |
5040 | d8f699cb | balrog | case 0x30: /* RCERF */ |
5041 | d8f699cb | balrog | return s->rcer[5]; |
5042 | d8f699cb | balrog | case 0x32: /* XCERE */ |
5043 | d8f699cb | balrog | return s->xcer[4]; |
5044 | d8f699cb | balrog | case 0x34: /* XCERF */ |
5045 | d8f699cb | balrog | return s->xcer[5]; |
5046 | d8f699cb | balrog | case 0x36: /* RCERG */ |
5047 | d8f699cb | balrog | return s->rcer[6]; |
5048 | d8f699cb | balrog | case 0x38: /* RCERH */ |
5049 | d8f699cb | balrog | return s->rcer[7]; |
5050 | d8f699cb | balrog | case 0x3a: /* XCERG */ |
5051 | d8f699cb | balrog | return s->xcer[6]; |
5052 | d8f699cb | balrog | case 0x3c: /* XCERH */ |
5053 | d8f699cb | balrog | return s->xcer[7]; |
5054 | d8f699cb | balrog | } |
5055 | d8f699cb | balrog | |
5056 | d8f699cb | balrog | OMAP_BAD_REG(addr); |
5057 | d8f699cb | balrog | return 0; |
5058 | d8f699cb | balrog | } |
5059 | d8f699cb | balrog | |
5060 | 73560bc8 | balrog | static void omap_mcbsp_writeh(void *opaque, target_phys_addr_t addr, |
5061 | d8f699cb | balrog | uint32_t value) |
5062 | d8f699cb | balrog | { |
5063 | d8f699cb | balrog | struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; |
5064 | d8f699cb | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
5065 | d8f699cb | balrog | |
5066 | d8f699cb | balrog | switch (offset) {
|
5067 | d8f699cb | balrog | case 0x00: /* DRR2 */ |
5068 | d8f699cb | balrog | case 0x02: /* DRR1 */ |
5069 | d8f699cb | balrog | OMAP_RO_REG(addr); |
5070 | d8f699cb | balrog | return;
|
5071 | d8f699cb | balrog | |
5072 | d8f699cb | balrog | case 0x04: /* DXR2 */ |
5073 | d8f699cb | balrog | if (((s->xcr[0] >> 5) & 7) < 3) /* XWDLEN1 */ |
5074 | d8f699cb | balrog | return;
|
5075 | d8f699cb | balrog | /* Fall through. */
|
5076 | d8f699cb | balrog | case 0x06: /* DXR1 */ |
5077 | 73560bc8 | balrog | if (s->tx_req > 1) { |
5078 | 73560bc8 | balrog | s->tx_req -= 2;
|
5079 | 73560bc8 | balrog | if (s->codec && s->codec->cts) {
|
5080 | d8f699cb | balrog | s->codec->out.fifo[s->codec->out.len ++] = (value >> 8) & 0xff; |
5081 | d8f699cb | balrog | s->codec->out.fifo[s->codec->out.len ++] = (value >> 0) & 0xff; |
5082 | d8f699cb | balrog | } |
5083 | 73560bc8 | balrog | if (s->tx_req < 2) |
5084 | 73560bc8 | balrog | omap_mcbsp_tx_done(s); |
5085 | d8f699cb | balrog | } else
|
5086 | d8f699cb | balrog | printf("%s: Tx FIFO overrun\n", __FUNCTION__);
|
5087 | d8f699cb | balrog | return;
|
5088 | d8f699cb | balrog | |
5089 | d8f699cb | balrog | case 0x08: /* SPCR2 */ |
5090 | d8f699cb | balrog | s->spcr[1] &= 0x0002; |
5091 | d8f699cb | balrog | s->spcr[1] |= 0x03f9 & value; |
5092 | d8f699cb | balrog | s->spcr[1] |= 0x0004 & (value << 2); /* XEMPTY := XRST */ |
5093 | 73560bc8 | balrog | if (~value & 1) /* XRST */ |
5094 | d8f699cb | balrog | s->spcr[1] &= ~6; |
5095 | d8f699cb | balrog | omap_mcbsp_req_update(s); |
5096 | d8f699cb | balrog | return;
|
5097 | d8f699cb | balrog | case 0x0a: /* SPCR1 */ |
5098 | d8f699cb | balrog | s->spcr[0] &= 0x0006; |
5099 | d8f699cb | balrog | s->spcr[0] |= 0xf8f9 & value; |
5100 | d8f699cb | balrog | if (value & (1 << 15)) /* DLB */ |
5101 | d8f699cb | balrog | printf("%s: Digital Loopback mode enable attempt\n", __FUNCTION__);
|
5102 | d8f699cb | balrog | if (~value & 1) { /* RRST */ |
5103 | d8f699cb | balrog | s->spcr[0] &= ~6; |
5104 | 73560bc8 | balrog | s->rx_req = 0;
|
5105 | 73560bc8 | balrog | omap_mcbsp_rx_done(s); |
5106 | d8f699cb | balrog | } |
5107 | d8f699cb | balrog | omap_mcbsp_req_update(s); |
5108 | d8f699cb | balrog | return;
|
5109 | d8f699cb | balrog | |
5110 | d8f699cb | balrog | case 0x0c: /* RCR2 */ |
5111 | d8f699cb | balrog | s->rcr[1] = value & 0xffff; |
5112 | d8f699cb | balrog | return;
|
5113 | d8f699cb | balrog | case 0x0e: /* RCR1 */ |
5114 | d8f699cb | balrog | s->rcr[0] = value & 0x7fe0; |
5115 | d8f699cb | balrog | return;
|
5116 | d8f699cb | balrog | case 0x10: /* XCR2 */ |
5117 | d8f699cb | balrog | s->xcr[1] = value & 0xffff; |
5118 | d8f699cb | balrog | return;
|
5119 | d8f699cb | balrog | case 0x12: /* XCR1 */ |
5120 | d8f699cb | balrog | s->xcr[0] = value & 0x7fe0; |
5121 | d8f699cb | balrog | return;
|
5122 | d8f699cb | balrog | case 0x14: /* SRGR2 */ |
5123 | d8f699cb | balrog | s->srgr[1] = value & 0xffff; |
5124 | 73560bc8 | balrog | omap_mcbsp_req_update(s); |
5125 | d8f699cb | balrog | return;
|
5126 | d8f699cb | balrog | case 0x16: /* SRGR1 */ |
5127 | d8f699cb | balrog | s->srgr[0] = value & 0xffff; |
5128 | 73560bc8 | balrog | omap_mcbsp_req_update(s); |
5129 | d8f699cb | balrog | return;
|
5130 | d8f699cb | balrog | case 0x18: /* MCR2 */ |
5131 | d8f699cb | balrog | s->mcr[1] = value & 0x03e3; |
5132 | d8f699cb | balrog | if (value & 3) /* XMCM */ |
5133 | d8f699cb | balrog | printf("%s: Tx channel selection mode enable attempt\n",
|
5134 | d8f699cb | balrog | __FUNCTION__); |
5135 | d8f699cb | balrog | return;
|
5136 | d8f699cb | balrog | case 0x1a: /* MCR1 */ |
5137 | d8f699cb | balrog | s->mcr[0] = value & 0x03e1; |
5138 | d8f699cb | balrog | if (value & 1) /* RMCM */ |
5139 | d8f699cb | balrog | printf("%s: Rx channel selection mode enable attempt\n",
|
5140 | d8f699cb | balrog | __FUNCTION__); |
5141 | d8f699cb | balrog | return;
|
5142 | d8f699cb | balrog | case 0x1c: /* RCERA */ |
5143 | d8f699cb | balrog | s->rcer[0] = value & 0xffff; |
5144 | d8f699cb | balrog | return;
|
5145 | d8f699cb | balrog | case 0x1e: /* RCERB */ |
5146 | d8f699cb | balrog | s->rcer[1] = value & 0xffff; |
5147 | d8f699cb | balrog | return;
|
5148 | d8f699cb | balrog | case 0x20: /* XCERA */ |
5149 | d8f699cb | balrog | s->xcer[0] = value & 0xffff; |
5150 | d8f699cb | balrog | return;
|
5151 | d8f699cb | balrog | case 0x22: /* XCERB */ |
5152 | d8f699cb | balrog | s->xcer[1] = value & 0xffff; |
5153 | d8f699cb | balrog | return;
|
5154 | d8f699cb | balrog | case 0x24: /* PCR0 */ |
5155 | d8f699cb | balrog | s->pcr = value & 0x7faf;
|
5156 | d8f699cb | balrog | return;
|
5157 | d8f699cb | balrog | case 0x26: /* RCERC */ |
5158 | d8f699cb | balrog | s->rcer[2] = value & 0xffff; |
5159 | d8f699cb | balrog | return;
|
5160 | d8f699cb | balrog | case 0x28: /* RCERD */ |
5161 | d8f699cb | balrog | s->rcer[3] = value & 0xffff; |
5162 | d8f699cb | balrog | return;
|
5163 | d8f699cb | balrog | case 0x2a: /* XCERC */ |
5164 | d8f699cb | balrog | s->xcer[2] = value & 0xffff; |
5165 | d8f699cb | balrog | return;
|
5166 | d8f699cb | balrog | case 0x2c: /* XCERD */ |
5167 | d8f699cb | balrog | s->xcer[3] = value & 0xffff; |
5168 | d8f699cb | balrog | return;
|
5169 | d8f699cb | balrog | case 0x2e: /* RCERE */ |
5170 | d8f699cb | balrog | s->rcer[4] = value & 0xffff; |
5171 | d8f699cb | balrog | return;
|
5172 | d8f699cb | balrog | case 0x30: /* RCERF */ |
5173 | d8f699cb | balrog | s->rcer[5] = value & 0xffff; |
5174 | d8f699cb | balrog | return;
|
5175 | d8f699cb | balrog | case 0x32: /* XCERE */ |
5176 | d8f699cb | balrog | s->xcer[4] = value & 0xffff; |
5177 | d8f699cb | balrog | return;
|
5178 | d8f699cb | balrog | case 0x34: /* XCERF */ |
5179 | d8f699cb | balrog | s->xcer[5] = value & 0xffff; |
5180 | d8f699cb | balrog | return;
|
5181 | d8f699cb | balrog | case 0x36: /* RCERG */ |
5182 | d8f699cb | balrog | s->rcer[6] = value & 0xffff; |
5183 | d8f699cb | balrog | return;
|
5184 | d8f699cb | balrog | case 0x38: /* RCERH */ |
5185 | d8f699cb | balrog | s->rcer[7] = value & 0xffff; |
5186 | d8f699cb | balrog | return;
|
5187 | d8f699cb | balrog | case 0x3a: /* XCERG */ |
5188 | d8f699cb | balrog | s->xcer[6] = value & 0xffff; |
5189 | d8f699cb | balrog | return;
|
5190 | d8f699cb | balrog | case 0x3c: /* XCERH */ |
5191 | d8f699cb | balrog | s->xcer[7] = value & 0xffff; |
5192 | d8f699cb | balrog | return;
|
5193 | d8f699cb | balrog | } |
5194 | d8f699cb | balrog | |
5195 | d8f699cb | balrog | OMAP_BAD_REG(addr); |
5196 | d8f699cb | balrog | } |
5197 | d8f699cb | balrog | |
5198 | 73560bc8 | balrog | static void omap_mcbsp_writew(void *opaque, target_phys_addr_t addr, |
5199 | 73560bc8 | balrog | uint32_t value) |
5200 | 73560bc8 | balrog | { |
5201 | 73560bc8 | balrog | struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; |
5202 | 73560bc8 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
5203 | 73560bc8 | balrog | |
5204 | 73560bc8 | balrog | if (offset == 0x04) { /* DXR */ |
5205 | 73560bc8 | balrog | if (((s->xcr[0] >> 5) & 7) < 3) /* XWDLEN1 */ |
5206 | 73560bc8 | balrog | return;
|
5207 | 73560bc8 | balrog | if (s->tx_req > 3) { |
5208 | 73560bc8 | balrog | s->tx_req -= 4;
|
5209 | 73560bc8 | balrog | if (s->codec && s->codec->cts) {
|
5210 | 73560bc8 | balrog | s->codec->out.fifo[s->codec->out.len ++] = |
5211 | 73560bc8 | balrog | (value >> 24) & 0xff; |
5212 | 73560bc8 | balrog | s->codec->out.fifo[s->codec->out.len ++] = |
5213 | 73560bc8 | balrog | (value >> 16) & 0xff; |
5214 | 73560bc8 | balrog | s->codec->out.fifo[s->codec->out.len ++] = |
5215 | 73560bc8 | balrog | (value >> 8) & 0xff; |
5216 | 73560bc8 | balrog | s->codec->out.fifo[s->codec->out.len ++] = |
5217 | 73560bc8 | balrog | (value >> 0) & 0xff; |
5218 | 73560bc8 | balrog | } |
5219 | 73560bc8 | balrog | if (s->tx_req < 4) |
5220 | 73560bc8 | balrog | omap_mcbsp_tx_done(s); |
5221 | 73560bc8 | balrog | } else
|
5222 | 73560bc8 | balrog | printf("%s: Tx FIFO overrun\n", __FUNCTION__);
|
5223 | 73560bc8 | balrog | return;
|
5224 | 73560bc8 | balrog | } |
5225 | 73560bc8 | balrog | |
5226 | 73560bc8 | balrog | omap_badwidth_write16(opaque, addr, value); |
5227 | 73560bc8 | balrog | } |
5228 | 73560bc8 | balrog | |
5229 | d8f699cb | balrog | static CPUReadMemoryFunc *omap_mcbsp_readfn[] = {
|
5230 | d8f699cb | balrog | omap_badwidth_read16, |
5231 | d8f699cb | balrog | omap_mcbsp_read, |
5232 | d8f699cb | balrog | omap_badwidth_read16, |
5233 | d8f699cb | balrog | }; |
5234 | d8f699cb | balrog | |
5235 | d8f699cb | balrog | static CPUWriteMemoryFunc *omap_mcbsp_writefn[] = {
|
5236 | d8f699cb | balrog | omap_badwidth_write16, |
5237 | 73560bc8 | balrog | omap_mcbsp_writeh, |
5238 | 73560bc8 | balrog | omap_mcbsp_writew, |
5239 | d8f699cb | balrog | }; |
5240 | d8f699cb | balrog | |
5241 | d8f699cb | balrog | static void omap_mcbsp_reset(struct omap_mcbsp_s *s) |
5242 | d8f699cb | balrog | { |
5243 | d8f699cb | balrog | memset(&s->spcr, 0, sizeof(s->spcr)); |
5244 | d8f699cb | balrog | memset(&s->rcr, 0, sizeof(s->rcr)); |
5245 | d8f699cb | balrog | memset(&s->xcr, 0, sizeof(s->xcr)); |
5246 | d8f699cb | balrog | s->srgr[0] = 0x0001; |
5247 | d8f699cb | balrog | s->srgr[1] = 0x2000; |
5248 | d8f699cb | balrog | memset(&s->mcr, 0, sizeof(s->mcr)); |
5249 | d8f699cb | balrog | memset(&s->pcr, 0, sizeof(s->pcr)); |
5250 | d8f699cb | balrog | memset(&s->rcer, 0, sizeof(s->rcer)); |
5251 | d8f699cb | balrog | memset(&s->xcer, 0, sizeof(s->xcer)); |
5252 | d8f699cb | balrog | s->tx_req = 0;
|
5253 | 73560bc8 | balrog | s->rx_req = 0;
|
5254 | d8f699cb | balrog | s->tx_rate = 0;
|
5255 | d8f699cb | balrog | s->rx_rate = 0;
|
5256 | 73560bc8 | balrog | qemu_del_timer(s->source_timer); |
5257 | 73560bc8 | balrog | qemu_del_timer(s->sink_timer); |
5258 | d8f699cb | balrog | } |
5259 | d8f699cb | balrog | |
5260 | d8f699cb | balrog | struct omap_mcbsp_s *omap_mcbsp_init(target_phys_addr_t base,
|
5261 | d8f699cb | balrog | qemu_irq *irq, qemu_irq *dma, omap_clk clk) |
5262 | d8f699cb | balrog | { |
5263 | d8f699cb | balrog | int iomemtype;
|
5264 | d8f699cb | balrog | struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) |
5265 | d8f699cb | balrog | qemu_mallocz(sizeof(struct omap_mcbsp_s)); |
5266 | d8f699cb | balrog | |
5267 | d8f699cb | balrog | s->base = base; |
5268 | d8f699cb | balrog | s->txirq = irq[0];
|
5269 | d8f699cb | balrog | s->rxirq = irq[1];
|
5270 | d8f699cb | balrog | s->txdrq = dma[0];
|
5271 | d8f699cb | balrog | s->rxdrq = dma[1];
|
5272 | 73560bc8 | balrog | s->sink_timer = qemu_new_timer(vm_clock, omap_mcbsp_sink_tick, s); |
5273 | 73560bc8 | balrog | s->source_timer = qemu_new_timer(vm_clock, omap_mcbsp_source_tick, s); |
5274 | d8f699cb | balrog | omap_mcbsp_reset(s); |
5275 | d8f699cb | balrog | |
5276 | d8f699cb | balrog | iomemtype = cpu_register_io_memory(0, omap_mcbsp_readfn,
|
5277 | d8f699cb | balrog | omap_mcbsp_writefn, s); |
5278 | d8f699cb | balrog | cpu_register_physical_memory(s->base, 0x800, iomemtype);
|
5279 | d8f699cb | balrog | |
5280 | d8f699cb | balrog | return s;
|
5281 | d8f699cb | balrog | } |
5282 | d8f699cb | balrog | |
5283 | 9596ebb7 | pbrook | static void omap_mcbsp_i2s_swallow(void *opaque, int line, int level) |
5284 | d8f699cb | balrog | { |
5285 | d8f699cb | balrog | struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; |
5286 | d8f699cb | balrog | |
5287 | 73560bc8 | balrog | if (s->rx_rate) {
|
5288 | 73560bc8 | balrog | s->rx_req = s->codec->in.len; |
5289 | 73560bc8 | balrog | omap_mcbsp_rx_newdata(s); |
5290 | 73560bc8 | balrog | } |
5291 | d8f699cb | balrog | } |
5292 | d8f699cb | balrog | |
5293 | 9596ebb7 | pbrook | static void omap_mcbsp_i2s_start(void *opaque, int line, int level) |
5294 | d8f699cb | balrog | { |
5295 | d8f699cb | balrog | struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; |
5296 | d8f699cb | balrog | |
5297 | 73560bc8 | balrog | if (s->tx_rate) {
|
5298 | 73560bc8 | balrog | s->tx_req = s->codec->out.size; |
5299 | 73560bc8 | balrog | omap_mcbsp_tx_newdata(s); |
5300 | 73560bc8 | balrog | } |
5301 | d8f699cb | balrog | } |
5302 | d8f699cb | balrog | |
5303 | d8f699cb | balrog | void omap_mcbsp_i2s_attach(struct omap_mcbsp_s *s, struct i2s_codec_s *slave) |
5304 | d8f699cb | balrog | { |
5305 | d8f699cb | balrog | s->codec = slave; |
5306 | d8f699cb | balrog | slave->rx_swallow = qemu_allocate_irqs(omap_mcbsp_i2s_swallow, s, 1)[0]; |
5307 | d8f699cb | balrog | slave->tx_start = qemu_allocate_irqs(omap_mcbsp_i2s_start, s, 1)[0]; |
5308 | d8f699cb | balrog | } |
5309 | d8f699cb | balrog | |
5310 | f9d43072 | balrog | /* LED Pulse Generators */
|
5311 | f9d43072 | balrog | struct omap_lpg_s {
|
5312 | f9d43072 | balrog | target_phys_addr_t base; |
5313 | f9d43072 | balrog | QEMUTimer *tm; |
5314 | f9d43072 | balrog | |
5315 | f9d43072 | balrog | uint8_t control; |
5316 | f9d43072 | balrog | uint8_t power; |
5317 | f9d43072 | balrog | int64_t on; |
5318 | f9d43072 | balrog | int64_t period; |
5319 | f9d43072 | balrog | int clk;
|
5320 | f9d43072 | balrog | int cycle;
|
5321 | f9d43072 | balrog | }; |
5322 | f9d43072 | balrog | |
5323 | f9d43072 | balrog | static void omap_lpg_tick(void *opaque) |
5324 | f9d43072 | balrog | { |
5325 | f9d43072 | balrog | struct omap_lpg_s *s = opaque;
|
5326 | f9d43072 | balrog | |
5327 | f9d43072 | balrog | if (s->cycle)
|
5328 | f9d43072 | balrog | qemu_mod_timer(s->tm, qemu_get_clock(rt_clock) + s->period - s->on); |
5329 | f9d43072 | balrog | else
|
5330 | f9d43072 | balrog | qemu_mod_timer(s->tm, qemu_get_clock(rt_clock) + s->on); |
5331 | f9d43072 | balrog | |
5332 | f9d43072 | balrog | s->cycle = !s->cycle; |
5333 | f9d43072 | balrog | printf("%s: LED is %s\n", __FUNCTION__, s->cycle ? "on" : "off"); |
5334 | f9d43072 | balrog | } |
5335 | f9d43072 | balrog | |
5336 | f9d43072 | balrog | static void omap_lpg_update(struct omap_lpg_s *s) |
5337 | f9d43072 | balrog | { |
5338 | f9d43072 | balrog | int64_t on, period = 1, ticks = 1000; |
5339 | f9d43072 | balrog | static const int per[8] = { 1, 2, 4, 8, 12, 16, 20, 24 }; |
5340 | f9d43072 | balrog | |
5341 | f9d43072 | balrog | if (~s->control & (1 << 6)) /* LPGRES */ |
5342 | f9d43072 | balrog | on = 0;
|
5343 | f9d43072 | balrog | else if (s->control & (1 << 7)) /* PERM_ON */ |
5344 | f9d43072 | balrog | on = period; |
5345 | f9d43072 | balrog | else {
|
5346 | f9d43072 | balrog | period = muldiv64(ticks, per[s->control & 7], /* PERCTRL */ |
5347 | f9d43072 | balrog | 256 / 32); |
5348 | f9d43072 | balrog | on = (s->clk && s->power) ? muldiv64(ticks, |
5349 | f9d43072 | balrog | per[(s->control >> 3) & 7], 256) : 0; /* ONCTRL */ |
5350 | f9d43072 | balrog | } |
5351 | f9d43072 | balrog | |
5352 | f9d43072 | balrog | qemu_del_timer(s->tm); |
5353 | f9d43072 | balrog | if (on == period && s->on < s->period)
|
5354 | f9d43072 | balrog | printf("%s: LED is on\n", __FUNCTION__);
|
5355 | f9d43072 | balrog | else if (on == 0 && s->on) |
5356 | f9d43072 | balrog | printf("%s: LED is off\n", __FUNCTION__);
|
5357 | f9d43072 | balrog | else if (on && (on != s->on || period != s->period)) { |
5358 | f9d43072 | balrog | s->cycle = 0;
|
5359 | f9d43072 | balrog | s->on = on; |
5360 | f9d43072 | balrog | s->period = period; |
5361 | f9d43072 | balrog | omap_lpg_tick(s); |
5362 | f9d43072 | balrog | return;
|
5363 | f9d43072 | balrog | } |
5364 | f9d43072 | balrog | |
5365 | f9d43072 | balrog | s->on = on; |
5366 | f9d43072 | balrog | s->period = period; |
5367 | f9d43072 | balrog | } |
5368 | f9d43072 | balrog | |
5369 | f9d43072 | balrog | static void omap_lpg_reset(struct omap_lpg_s *s) |
5370 | f9d43072 | balrog | { |
5371 | f9d43072 | balrog | s->control = 0x00;
|
5372 | f9d43072 | balrog | s->power = 0x00;
|
5373 | f9d43072 | balrog | s->clk = 1;
|
5374 | f9d43072 | balrog | omap_lpg_update(s); |
5375 | f9d43072 | balrog | } |
5376 | f9d43072 | balrog | |
5377 | f9d43072 | balrog | static uint32_t omap_lpg_read(void *opaque, target_phys_addr_t addr) |
5378 | f9d43072 | balrog | { |
5379 | f9d43072 | balrog | struct omap_lpg_s *s = (struct omap_lpg_s *) opaque; |
5380 | f9d43072 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
5381 | f9d43072 | balrog | |
5382 | f9d43072 | balrog | switch (offset) {
|
5383 | f9d43072 | balrog | case 0x00: /* LCR */ |
5384 | f9d43072 | balrog | return s->control;
|
5385 | f9d43072 | balrog | |
5386 | f9d43072 | balrog | case 0x04: /* PMR */ |
5387 | f9d43072 | balrog | return s->power;
|
5388 | f9d43072 | balrog | } |
5389 | f9d43072 | balrog | |
5390 | f9d43072 | balrog | OMAP_BAD_REG(addr); |
5391 | f9d43072 | balrog | return 0; |
5392 | f9d43072 | balrog | } |
5393 | f9d43072 | balrog | |
5394 | f9d43072 | balrog | static void omap_lpg_write(void *opaque, target_phys_addr_t addr, |
5395 | f9d43072 | balrog | uint32_t value) |
5396 | f9d43072 | balrog | { |
5397 | f9d43072 | balrog | struct omap_lpg_s *s = (struct omap_lpg_s *) opaque; |
5398 | f9d43072 | balrog | int offset = addr & OMAP_MPUI_REG_MASK;
|
5399 | f9d43072 | balrog | |
5400 | f9d43072 | balrog | switch (offset) {
|
5401 | f9d43072 | balrog | case 0x00: /* LCR */ |
5402 | f9d43072 | balrog | if (~value & (1 << 6)) /* LPGRES */ |
5403 | f9d43072 | balrog | omap_lpg_reset(s); |
5404 | f9d43072 | balrog | s->control = value & 0xff;
|
5405 | f9d43072 | balrog | omap_lpg_update(s); |
5406 | f9d43072 | balrog | return;
|
5407 | f9d43072 | balrog | |
5408 | f9d43072 | balrog | case 0x04: /* PMR */ |
5409 | f9d43072 | balrog | s->power = value & 0x01;
|
5410 | f9d43072 | balrog | omap_lpg_update(s); |
5411 | f9d43072 | balrog | return;
|
5412 | f9d43072 | balrog | |
5413 | f9d43072 | balrog | default:
|
5414 | f9d43072 | balrog | OMAP_BAD_REG(addr); |
5415 | f9d43072 | balrog | return;
|
5416 | f9d43072 | balrog | } |
5417 | f9d43072 | balrog | } |
5418 | f9d43072 | balrog | |
5419 | f9d43072 | balrog | static CPUReadMemoryFunc *omap_lpg_readfn[] = {
|
5420 | f9d43072 | balrog | omap_lpg_read, |
5421 | f9d43072 | balrog | omap_badwidth_read8, |
5422 | f9d43072 | balrog | omap_badwidth_read8, |
5423 | f9d43072 | balrog | }; |
5424 | f9d43072 | balrog | |
5425 | f9d43072 | balrog | static CPUWriteMemoryFunc *omap_lpg_writefn[] = {
|
5426 | f9d43072 | balrog | omap_lpg_write, |
5427 | f9d43072 | balrog | omap_badwidth_write8, |
5428 | f9d43072 | balrog | omap_badwidth_write8, |
5429 | f9d43072 | balrog | }; |
5430 | f9d43072 | balrog | |
5431 | f9d43072 | balrog | static void omap_lpg_clk_update(void *opaque, int line, int on) |
5432 | f9d43072 | balrog | { |
5433 | f9d43072 | balrog | struct omap_lpg_s *s = (struct omap_lpg_s *) opaque; |
5434 | f9d43072 | balrog | |
5435 | f9d43072 | balrog | s->clk = on; |
5436 | f9d43072 | balrog | omap_lpg_update(s); |
5437 | f9d43072 | balrog | } |
5438 | f9d43072 | balrog | |
5439 | f9d43072 | balrog | struct omap_lpg_s *omap_lpg_init(target_phys_addr_t base, omap_clk clk)
|
5440 | f9d43072 | balrog | { |
5441 | f9d43072 | balrog | int iomemtype;
|
5442 | f9d43072 | balrog | struct omap_lpg_s *s = (struct omap_lpg_s *) |
5443 | f9d43072 | balrog | qemu_mallocz(sizeof(struct omap_lpg_s)); |
5444 | f9d43072 | balrog | |
5445 | f9d43072 | balrog | s->base = base; |
5446 | f9d43072 | balrog | s->tm = qemu_new_timer(rt_clock, omap_lpg_tick, s); |
5447 | f9d43072 | balrog | |
5448 | f9d43072 | balrog | omap_lpg_reset(s); |
5449 | f9d43072 | balrog | |
5450 | f9d43072 | balrog | iomemtype = cpu_register_io_memory(0, omap_lpg_readfn,
|
5451 | f9d43072 | balrog | omap_lpg_writefn, s); |
5452 | f9d43072 | balrog | cpu_register_physical_memory(s->base, 0x800, iomemtype);
|
5453 | f9d43072 | balrog | |
5454 | f9d43072 | balrog | omap_clk_adduser(clk, qemu_allocate_irqs(omap_lpg_clk_update, s, 1)[0]); |
5455 | f9d43072 | balrog | |
5456 | f9d43072 | balrog | return s;
|
5457 | f9d43072 | balrog | } |
5458 | f9d43072 | balrog | |
5459 | f9d43072 | balrog | /* MPUI Peripheral Bridge configuration */
|
5460 | f9d43072 | balrog | static uint32_t omap_mpui_io_read(void *opaque, target_phys_addr_t addr) |
5461 | f9d43072 | balrog | { |
5462 | f9d43072 | balrog | if (addr == OMAP_MPUI_BASE) /* CMR */ |
5463 | f9d43072 | balrog | return 0xfe4d; |
5464 | f9d43072 | balrog | |
5465 | f9d43072 | balrog | OMAP_BAD_REG(addr); |
5466 | f9d43072 | balrog | return 0; |
5467 | f9d43072 | balrog | } |
5468 | f9d43072 | balrog | |
5469 | f9d43072 | balrog | static CPUReadMemoryFunc *omap_mpui_io_readfn[] = {
|
5470 | f9d43072 | balrog | omap_badwidth_read16, |
5471 | f9d43072 | balrog | omap_mpui_io_read, |
5472 | f9d43072 | balrog | omap_badwidth_read16, |
5473 | f9d43072 | balrog | }; |
5474 | f9d43072 | balrog | |
5475 | f9d43072 | balrog | static CPUWriteMemoryFunc *omap_mpui_io_writefn[] = {
|
5476 | f9d43072 | balrog | omap_badwidth_write16, |
5477 | f9d43072 | balrog | omap_badwidth_write16, |
5478 | f9d43072 | balrog | omap_badwidth_write16, |
5479 | f9d43072 | balrog | }; |
5480 | f9d43072 | balrog | |
5481 | f9d43072 | balrog | static void omap_setup_mpui_io(struct omap_mpu_state_s *mpu) |
5482 | f9d43072 | balrog | { |
5483 | f9d43072 | balrog | int iomemtype = cpu_register_io_memory(0, omap_mpui_io_readfn, |
5484 | f9d43072 | balrog | omap_mpui_io_writefn, mpu); |
5485 | f9d43072 | balrog | cpu_register_physical_memory(OMAP_MPUI_BASE, 0x7fff, iomemtype);
|
5486 | f9d43072 | balrog | } |
5487 | f9d43072 | balrog | |
5488 | c3d2689d | balrog | /* General chip reset */
|
5489 | c3d2689d | balrog | static void omap_mpu_reset(void *opaque) |
5490 | c3d2689d | balrog | { |
5491 | c3d2689d | balrog | struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque; |
5492 | c3d2689d | balrog | |
5493 | c3d2689d | balrog | omap_inth_reset(mpu->ih[0]);
|
5494 | c3d2689d | balrog | omap_inth_reset(mpu->ih[1]);
|
5495 | c3d2689d | balrog | omap_dma_reset(mpu->dma); |
5496 | c3d2689d | balrog | omap_mpu_timer_reset(mpu->timer[0]);
|
5497 | c3d2689d | balrog | omap_mpu_timer_reset(mpu->timer[1]);
|
5498 | c3d2689d | balrog | omap_mpu_timer_reset(mpu->timer[2]);
|
5499 | c3d2689d | balrog | omap_wd_timer_reset(mpu->wdt); |
5500 | c3d2689d | balrog | omap_os_timer_reset(mpu->os_timer); |
5501 | c3d2689d | balrog | omap_lcdc_reset(mpu->lcd); |
5502 | c3d2689d | balrog | omap_ulpd_pm_reset(mpu); |
5503 | c3d2689d | balrog | omap_pin_cfg_reset(mpu); |
5504 | c3d2689d | balrog | omap_mpui_reset(mpu); |
5505 | c3d2689d | balrog | omap_tipb_bridge_reset(mpu->private_tipb); |
5506 | c3d2689d | balrog | omap_tipb_bridge_reset(mpu->public_tipb); |
5507 | c3d2689d | balrog | omap_dpll_reset(&mpu->dpll[0]);
|
5508 | c3d2689d | balrog | omap_dpll_reset(&mpu->dpll[1]);
|
5509 | c3d2689d | balrog | omap_dpll_reset(&mpu->dpll[2]);
|
5510 | d951f6ff | balrog | omap_uart_reset(mpu->uart[0]);
|
5511 | d951f6ff | balrog | omap_uart_reset(mpu->uart[1]);
|
5512 | d951f6ff | balrog | omap_uart_reset(mpu->uart[2]);
|
5513 | b30bb3a2 | balrog | omap_mmc_reset(mpu->mmc); |
5514 | fe71e81a | balrog | omap_mpuio_reset(mpu->mpuio); |
5515 | 64330148 | balrog | omap_gpio_reset(mpu->gpio); |
5516 | d951f6ff | balrog | omap_uwire_reset(mpu->microwire); |
5517 | 66450b15 | balrog | omap_pwl_reset(mpu); |
5518 | 4a2c8ac2 | balrog | omap_pwt_reset(mpu); |
5519 | 4a2c8ac2 | balrog | omap_i2c_reset(mpu->i2c); |
5520 | 5c1c390f | balrog | omap_rtc_reset(mpu->rtc); |
5521 | d8f699cb | balrog | omap_mcbsp_reset(mpu->mcbsp1); |
5522 | d8f699cb | balrog | omap_mcbsp_reset(mpu->mcbsp2); |
5523 | d8f699cb | balrog | omap_mcbsp_reset(mpu->mcbsp3); |
5524 | f9d43072 | balrog | omap_lpg_reset(mpu->led[0]);
|
5525 | f9d43072 | balrog | omap_lpg_reset(mpu->led[1]);
|
5526 | 8ef6367e | balrog | omap_clkm_reset(mpu); |
5527 | c3d2689d | balrog | cpu_reset(mpu->env); |
5528 | c3d2689d | balrog | } |
5529 | c3d2689d | balrog | |
5530 | cf965d24 | balrog | static const struct omap_map_s { |
5531 | cf965d24 | balrog | target_phys_addr_t phys_dsp; |
5532 | cf965d24 | balrog | target_phys_addr_t phys_mpu; |
5533 | cf965d24 | balrog | uint32_t size; |
5534 | cf965d24 | balrog | const char *name; |
5535 | cf965d24 | balrog | } omap15xx_dsp_mm[] = { |
5536 | cf965d24 | balrog | /* Strobe 0 */
|
5537 | cf965d24 | balrog | { 0xe1010000, 0xfffb0000, 0x800, "UART1 BT" }, /* CS0 */ |
5538 | cf965d24 | balrog | { 0xe1010800, 0xfffb0800, 0x800, "UART2 COM" }, /* CS1 */ |
5539 | cf965d24 | balrog | { 0xe1011800, 0xfffb1800, 0x800, "McBSP1 audio" }, /* CS3 */ |
5540 | cf965d24 | balrog | { 0xe1012000, 0xfffb2000, 0x800, "MCSI2 communication" }, /* CS4 */ |
5541 | cf965d24 | balrog | { 0xe1012800, 0xfffb2800, 0x800, "MCSI1 BT u-Law" }, /* CS5 */ |
5542 | cf965d24 | balrog | { 0xe1013000, 0xfffb3000, 0x800, "uWire" }, /* CS6 */ |
5543 | cf965d24 | balrog | { 0xe1013800, 0xfffb3800, 0x800, "I^2C" }, /* CS7 */ |
5544 | cf965d24 | balrog | { 0xe1014000, 0xfffb4000, 0x800, "USB W2FC" }, /* CS8 */ |
5545 | cf965d24 | balrog | { 0xe1014800, 0xfffb4800, 0x800, "RTC" }, /* CS9 */ |
5546 | cf965d24 | balrog | { 0xe1015000, 0xfffb5000, 0x800, "MPUIO" }, /* CS10 */ |
5547 | cf965d24 | balrog | { 0xe1015800, 0xfffb5800, 0x800, "PWL" }, /* CS11 */ |
5548 | cf965d24 | balrog | { 0xe1016000, 0xfffb6000, 0x800, "PWT" }, /* CS12 */ |
5549 | cf965d24 | balrog | { 0xe1017000, 0xfffb7000, 0x800, "McBSP3" }, /* CS14 */ |
5550 | cf965d24 | balrog | { 0xe1017800, 0xfffb7800, 0x800, "MMC" }, /* CS15 */ |
5551 | cf965d24 | balrog | { 0xe1019000, 0xfffb9000, 0x800, "32-kHz timer" }, /* CS18 */ |
5552 | cf965d24 | balrog | { 0xe1019800, 0xfffb9800, 0x800, "UART3" }, /* CS19 */ |
5553 | cf965d24 | balrog | { 0xe101c800, 0xfffbc800, 0x800, "TIPB switches" }, /* CS25 */ |
5554 | cf965d24 | balrog | /* Strobe 1 */
|
5555 | cf965d24 | balrog | { 0xe101e000, 0xfffce000, 0x800, "GPIOs" }, /* CS28 */ |
5556 | cf965d24 | balrog | |
5557 | cf965d24 | balrog | { 0 }
|
5558 | cf965d24 | balrog | }; |
5559 | cf965d24 | balrog | |
5560 | cf965d24 | balrog | static void omap_setup_dsp_mapping(const struct omap_map_s *map) |
5561 | cf965d24 | balrog | { |
5562 | cf965d24 | balrog | int io;
|
5563 | cf965d24 | balrog | |
5564 | cf965d24 | balrog | for (; map->phys_dsp; map ++) {
|
5565 | cf965d24 | balrog | io = cpu_get_physical_page_desc(map->phys_mpu); |
5566 | cf965d24 | balrog | |
5567 | cf965d24 | balrog | cpu_register_physical_memory(map->phys_dsp, map->size, io); |
5568 | cf965d24 | balrog | } |
5569 | cf965d24 | balrog | } |
5570 | cf965d24 | balrog | |
5571 | c3d2689d | balrog | static void omap_mpu_wakeup(void *opaque, int irq, int req) |
5572 | c3d2689d | balrog | { |
5573 | c3d2689d | balrog | struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque; |
5574 | c3d2689d | balrog | |
5575 | fe71e81a | balrog | if (mpu->env->halted)
|
5576 | fe71e81a | balrog | cpu_interrupt(mpu->env, CPU_INTERRUPT_EXITTB); |
5577 | c3d2689d | balrog | } |
5578 | c3d2689d | balrog | |
5579 | 089b7c0a | balrog | struct dma_irq_map {
|
5580 | 089b7c0a | balrog | int ih;
|
5581 | 089b7c0a | balrog | int intr;
|
5582 | 089b7c0a | balrog | }; |
5583 | 089b7c0a | balrog | |
5584 | 089b7c0a | balrog | static const struct dma_irq_map omap_dma_irq_map[] = { |
5585 | 089b7c0a | balrog | { 0, OMAP_INT_DMA_CH0_6 },
|
5586 | 089b7c0a | balrog | { 0, OMAP_INT_DMA_CH1_7 },
|
5587 | 089b7c0a | balrog | { 0, OMAP_INT_DMA_CH2_8 },
|
5588 | 089b7c0a | balrog | { 0, OMAP_INT_DMA_CH3 },
|
5589 | 089b7c0a | balrog | { 0, OMAP_INT_DMA_CH4 },
|
5590 | 089b7c0a | balrog | { 0, OMAP_INT_DMA_CH5 },
|
5591 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH6 },
|
5592 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH7 },
|
5593 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH8 },
|
5594 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH9 },
|
5595 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH10 },
|
5596 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH11 },
|
5597 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH12 },
|
5598 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH13 },
|
5599 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH14 },
|
5600 | 089b7c0a | balrog | { 1, OMAP_INT_1610_DMA_CH15 }
|
5601 | 089b7c0a | balrog | }; |
5602 | 089b7c0a | balrog | |
5603 | c3d2689d | balrog | struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size, |
5604 | c3d2689d | balrog | DisplayState *ds, const char *core) |
5605 | c3d2689d | balrog | { |
5606 | 089b7c0a | balrog | int i;
|
5607 | c3d2689d | balrog | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) |
5608 | c3d2689d | balrog | qemu_mallocz(sizeof(struct omap_mpu_state_s)); |
5609 | c3d2689d | balrog | ram_addr_t imif_base, emiff_base; |
5610 | 106627d0 | balrog | qemu_irq *cpu_irq; |
5611 | 089b7c0a | balrog | qemu_irq dma_irqs[6];
|
5612 | 9d413d1d | balrog | int sdindex;
|
5613 | 106627d0 | balrog | |
5614 | aaed909a | bellard | if (!core)
|
5615 | aaed909a | bellard | core = "ti925t";
|
5616 | c3d2689d | balrog | |
5617 | c3d2689d | balrog | /* Core */
|
5618 | c3d2689d | balrog | s->mpu_model = omap310; |
5619 | aaed909a | bellard | s->env = cpu_init(core); |
5620 | aaed909a | bellard | if (!s->env) {
|
5621 | aaed909a | bellard | fprintf(stderr, "Unable to find CPU definition\n");
|
5622 | aaed909a | bellard | exit(1);
|
5623 | aaed909a | bellard | } |
5624 | c3d2689d | balrog | s->sdram_size = sdram_size; |
5625 | c3d2689d | balrog | s->sram_size = OMAP15XX_SRAM_SIZE; |
5626 | c3d2689d | balrog | |
5627 | fe71e81a | balrog | s->wakeup = qemu_allocate_irqs(omap_mpu_wakeup, s, 1)[0]; |
5628 | fe71e81a | balrog | |
5629 | c3d2689d | balrog | /* Clocks */
|
5630 | c3d2689d | balrog | omap_clk_init(s); |
5631 | c3d2689d | balrog | |
5632 | c3d2689d | balrog | /* Memory-mapped stuff */
|
5633 | c3d2689d | balrog | cpu_register_physical_memory(OMAP_EMIFF_BASE, s->sdram_size, |
5634 | c3d2689d | balrog | (emiff_base = qemu_ram_alloc(s->sdram_size)) | IO_MEM_RAM); |
5635 | c3d2689d | balrog | cpu_register_physical_memory(OMAP_IMIF_BASE, s->sram_size, |
5636 | c3d2689d | balrog | (imif_base = qemu_ram_alloc(s->sram_size)) | IO_MEM_RAM); |
5637 | c3d2689d | balrog | |
5638 | c3d2689d | balrog | omap_clkm_init(0xfffece00, 0xe1008000, s); |
5639 | c3d2689d | balrog | |
5640 | 106627d0 | balrog | cpu_irq = arm_pic_init_cpu(s->env); |
5641 | 106627d0 | balrog | s->ih[0] = omap_inth_init(0xfffecb00, 0x100, 1, |
5642 | 106627d0 | balrog | cpu_irq[ARM_PIC_CPU_IRQ], cpu_irq[ARM_PIC_CPU_FIQ], |
5643 | c3d2689d | balrog | omap_findclk(s, "arminth_ck"));
|
5644 | 106627d0 | balrog | s->ih[1] = omap_inth_init(0xfffe0000, 0x800, 1, |
5645 | 106627d0 | balrog | s->ih[0]->pins[OMAP_INT_15XX_IH2_IRQ], NULL, |
5646 | c3d2689d | balrog | omap_findclk(s, "arminth_ck"));
|
5647 | c3d2689d | balrog | s->irq[0] = s->ih[0]->pins; |
5648 | c3d2689d | balrog | s->irq[1] = s->ih[1]->pins; |
5649 | c3d2689d | balrog | |
5650 | 089b7c0a | balrog | for (i = 0; i < 6; i ++) |
5651 | 089b7c0a | balrog | dma_irqs[i] = s->irq[omap_dma_irq_map[i].ih][omap_dma_irq_map[i].intr]; |
5652 | 089b7c0a | balrog | s->dma = omap_dma_init(0xfffed800, dma_irqs, s->irq[0][OMAP_INT_DMA_LCD], |
5653 | 089b7c0a | balrog | s, omap_findclk(s, "dma_ck"), omap_dma_3_1);
|
5654 | 089b7c0a | balrog | |
5655 | c3d2689d | balrog | s->port[emiff ].addr_valid = omap_validate_emiff_addr; |
5656 | c3d2689d | balrog | s->port[emifs ].addr_valid = omap_validate_emifs_addr; |
5657 | c3d2689d | balrog | s->port[imif ].addr_valid = omap_validate_imif_addr; |
5658 | c3d2689d | balrog | s->port[tipb ].addr_valid = omap_validate_tipb_addr; |
5659 | c3d2689d | balrog | s->port[local ].addr_valid = omap_validate_local_addr; |
5660 | c3d2689d | balrog | s->port[tipb_mpui].addr_valid = omap_validate_tipb_mpui_addr; |
5661 | c3d2689d | balrog | |
5662 | c3d2689d | balrog | s->timer[0] = omap_mpu_timer_init(0xfffec500, |
5663 | c3d2689d | balrog | s->irq[0][OMAP_INT_TIMER1],
|
5664 | c3d2689d | balrog | omap_findclk(s, "mputim_ck"));
|
5665 | c3d2689d | balrog | s->timer[1] = omap_mpu_timer_init(0xfffec600, |
5666 | c3d2689d | balrog | s->irq[0][OMAP_INT_TIMER2],
|
5667 | c3d2689d | balrog | omap_findclk(s, "mputim_ck"));
|
5668 | c3d2689d | balrog | s->timer[2] = omap_mpu_timer_init(0xfffec700, |
5669 | c3d2689d | balrog | s->irq[0][OMAP_INT_TIMER3],
|
5670 | c3d2689d | balrog | omap_findclk(s, "mputim_ck"));
|
5671 | c3d2689d | balrog | |
5672 | c3d2689d | balrog | s->wdt = omap_wd_timer_init(0xfffec800,
|
5673 | c3d2689d | balrog | s->irq[0][OMAP_INT_WD_TIMER],
|
5674 | c3d2689d | balrog | omap_findclk(s, "armwdt_ck"));
|
5675 | c3d2689d | balrog | |
5676 | c3d2689d | balrog | s->os_timer = omap_os_timer_init(0xfffb9000,
|
5677 | c3d2689d | balrog | s->irq[1][OMAP_INT_OS_TIMER],
|
5678 | c3d2689d | balrog | omap_findclk(s, "clk32-kHz"));
|
5679 | c3d2689d | balrog | |
5680 | c3d2689d | balrog | s->lcd = omap_lcdc_init(0xfffec000, s->irq[0][OMAP_INT_LCD_CTRL], |
5681 | c3d2689d | balrog | &s->dma->lcd_ch, ds, imif_base, emiff_base, |
5682 | c3d2689d | balrog | omap_findclk(s, "lcd_ck"));
|
5683 | c3d2689d | balrog | |
5684 | c3d2689d | balrog | omap_ulpd_pm_init(0xfffe0800, s);
|
5685 | c3d2689d | balrog | omap_pin_cfg_init(0xfffe1000, s);
|
5686 | c3d2689d | balrog | omap_id_init(s); |
5687 | c3d2689d | balrog | |
5688 | c3d2689d | balrog | omap_mpui_init(0xfffec900, s);
|
5689 | c3d2689d | balrog | |
5690 | c3d2689d | balrog | s->private_tipb = omap_tipb_bridge_init(0xfffeca00,
|
5691 | c3d2689d | balrog | s->irq[0][OMAP_INT_BRIDGE_PRIV],
|
5692 | c3d2689d | balrog | omap_findclk(s, "tipb_ck"));
|
5693 | c3d2689d | balrog | s->public_tipb = omap_tipb_bridge_init(0xfffed300,
|
5694 | c3d2689d | balrog | s->irq[0][OMAP_INT_BRIDGE_PUB],
|
5695 | c3d2689d | balrog | omap_findclk(s, "tipb_ck"));
|
5696 | c3d2689d | balrog | |
5697 | c3d2689d | balrog | omap_tcmi_init(0xfffecc00, s);
|
5698 | c3d2689d | balrog | |
5699 | d951f6ff | balrog | s->uart[0] = omap_uart_init(0xfffb0000, s->irq[1][OMAP_INT_UART1], |
5700 | c3d2689d | balrog | omap_findclk(s, "uart1_ck"),
|
5701 | c3d2689d | balrog | serial_hds[0]);
|
5702 | d951f6ff | balrog | s->uart[1] = omap_uart_init(0xfffb0800, s->irq[1][OMAP_INT_UART2], |
5703 | c3d2689d | balrog | omap_findclk(s, "uart2_ck"),
|
5704 | c3d2689d | balrog | serial_hds[0] ? serial_hds[1] : 0); |
5705 | d951f6ff | balrog | s->uart[2] = omap_uart_init(0xe1019800, s->irq[0][OMAP_INT_UART3], |
5706 | c3d2689d | balrog | omap_findclk(s, "uart3_ck"),
|
5707 | c3d2689d | balrog | serial_hds[0] && serial_hds[1] ? serial_hds[2] : 0); |
5708 | c3d2689d | balrog | |
5709 | c3d2689d | balrog | omap_dpll_init(&s->dpll[0], 0xfffecf00, omap_findclk(s, "dpll1")); |
5710 | c3d2689d | balrog | omap_dpll_init(&s->dpll[1], 0xfffed000, omap_findclk(s, "dpll2")); |
5711 | c3d2689d | balrog | omap_dpll_init(&s->dpll[2], 0xfffed100, omap_findclk(s, "dpll3")); |
5712 | c3d2689d | balrog | |
5713 | 9d413d1d | balrog | sdindex = drive_get_index(IF_SD, 0, 0); |
5714 | 9d413d1d | balrog | if (sdindex == -1) { |
5715 | e4bcb14c | ths | fprintf(stderr, "qemu: missing SecureDigital device\n");
|
5716 | e4bcb14c | ths | exit(1);
|
5717 | e4bcb14c | ths | } |
5718 | 9d413d1d | balrog | s->mmc = omap_mmc_init(0xfffb7800, drives_table[sdindex].bdrv,
|
5719 | 9d413d1d | balrog | s->irq[1][OMAP_INT_OQN], &s->drq[OMAP_DMA_MMC_TX],
|
5720 | 9d413d1d | balrog | omap_findclk(s, "mmc_ck"));
|
5721 | b30bb3a2 | balrog | |
5722 | fe71e81a | balrog | s->mpuio = omap_mpuio_init(0xfffb5000,
|
5723 | fe71e81a | balrog | s->irq[1][OMAP_INT_KEYBOARD], s->irq[1][OMAP_INT_MPUIO], |
5724 | fe71e81a | balrog | s->wakeup, omap_findclk(s, "clk32-kHz"));
|
5725 | fe71e81a | balrog | |
5726 | 3efda49d | balrog | s->gpio = omap_gpio_init(0xfffce000, s->irq[0][OMAP_INT_GPIO_BANK1], |
5727 | 66450b15 | balrog | omap_findclk(s, "arm_gpio_ck"));
|
5728 | 64330148 | balrog | |
5729 | d951f6ff | balrog | s->microwire = omap_uwire_init(0xfffb3000, &s->irq[1][OMAP_INT_uWireTX], |
5730 | d951f6ff | balrog | s->drq[OMAP_DMA_UWIRE_TX], omap_findclk(s, "mpuper_ck"));
|
5731 | d951f6ff | balrog | |
5732 | d8f699cb | balrog | omap_pwl_init(0xfffb5800, s, omap_findclk(s, "armxor_ck")); |
5733 | d8f699cb | balrog | omap_pwt_init(0xfffb6000, s, omap_findclk(s, "armxor_ck")); |
5734 | 66450b15 | balrog | |
5735 | 4a2c8ac2 | balrog | s->i2c = omap_i2c_init(0xfffb3800, s->irq[1][OMAP_INT_I2C], |
5736 | 4a2c8ac2 | balrog | &s->drq[OMAP_DMA_I2C_RX], omap_findclk(s, "mpuper_ck"));
|
5737 | 4a2c8ac2 | balrog | |
5738 | 5c1c390f | balrog | s->rtc = omap_rtc_init(0xfffb4800, &s->irq[1][OMAP_INT_RTC_TIMER], |
5739 | 5c1c390f | balrog | omap_findclk(s, "clk32-kHz"));
|
5740 | 02645926 | balrog | |
5741 | d8f699cb | balrog | s->mcbsp1 = omap_mcbsp_init(0xfffb1800, &s->irq[1][OMAP_INT_McBSP1TX], |
5742 | d8f699cb | balrog | &s->drq[OMAP_DMA_MCBSP1_TX], omap_findclk(s, "dspxor_ck"));
|
5743 | d8f699cb | balrog | s->mcbsp2 = omap_mcbsp_init(0xfffb1000, &s->irq[0][OMAP_INT_310_McBSP2_TX], |
5744 | d8f699cb | balrog | &s->drq[OMAP_DMA_MCBSP2_TX], omap_findclk(s, "mpuper_ck"));
|
5745 | d8f699cb | balrog | s->mcbsp3 = omap_mcbsp_init(0xfffb7000, &s->irq[1][OMAP_INT_McBSP3TX], |
5746 | d8f699cb | balrog | &s->drq[OMAP_DMA_MCBSP3_TX], omap_findclk(s, "dspxor_ck"));
|
5747 | d8f699cb | balrog | |
5748 | f9d43072 | balrog | s->led[0] = omap_lpg_init(0xfffbd000, omap_findclk(s, "clk32-kHz")); |
5749 | f9d43072 | balrog | s->led[1] = omap_lpg_init(0xfffbd800, omap_findclk(s, "clk32-kHz")); |
5750 | f9d43072 | balrog | |
5751 | 02645926 | balrog | /* Register mappings not currenlty implemented:
|
5752 | 02645926 | balrog | * MCSI2 Comm fffb2000 - fffb27ff (not mapped on OMAP310)
|
5753 | 02645926 | balrog | * MCSI1 Bluetooth fffb2800 - fffb2fff (not mapped on OMAP310)
|
5754 | 02645926 | balrog | * USB W2FC fffb4000 - fffb47ff
|
5755 | 02645926 | balrog | * Camera Interface fffb6800 - fffb6fff
|
5756 | 02645926 | balrog | * USB Host fffba000 - fffba7ff
|
5757 | 02645926 | balrog | * FAC fffba800 - fffbafff
|
5758 | 02645926 | balrog | * HDQ/1-Wire fffbc000 - fffbc7ff
|
5759 | b854bc19 | balrog | * TIPB switches fffbc800 - fffbcfff
|
5760 | 02645926 | balrog | * Mailbox fffcf000 - fffcf7ff
|
5761 | 02645926 | balrog | * Local bus IF fffec100 - fffec1ff
|
5762 | 02645926 | balrog | * Local bus MMU fffec200 - fffec2ff
|
5763 | 02645926 | balrog | * DSP MMU fffed200 - fffed2ff
|
5764 | 02645926 | balrog | */
|
5765 | 02645926 | balrog | |
5766 | cf965d24 | balrog | omap_setup_dsp_mapping(omap15xx_dsp_mm); |
5767 | f9d43072 | balrog | omap_setup_mpui_io(s); |
5768 | cf965d24 | balrog | |
5769 | c3d2689d | balrog | qemu_register_reset(omap_mpu_reset, s); |
5770 | c3d2689d | balrog | |
5771 | c3d2689d | balrog | return s;
|
5772 | c3d2689d | balrog | } |