2 * TI OMAP processors emulation.
4 * Copyright (C) 2007-2008 Nokia Corporation
5 * Written by Andrzej Zaborowski <andrew@openedhand.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 or
10 * (at your option) version 3 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, see <http://www.gnu.org/licenses/>.
26 #include "qemu-timer.h"
27 #include "qemu-char.h"
30 #include "audio/audio.h"
33 struct omap_gp_timer_s
{
41 struct omap_target_agent_s
*ta
;
47 int64_t ticks_per_sec
;
58 gpt_trigger_none
, gpt_trigger_overflow
, gpt_trigger_both
61 gpt_capture_none
, gpt_capture_rising
,
62 gpt_capture_falling
, gpt_capture_both
73 uint32_t capture_val
[2];
77 uint16_t writeh
; /* LSB */
78 uint16_t readh
; /* MSB */
81 #define GPT_TCAR_IT (1 << 2)
82 #define GPT_OVF_IT (1 << 1)
83 #define GPT_MAT_IT (1 << 0)
85 static inline void omap_gp_timer_intr(struct omap_gp_timer_s
*timer
, int it
)
87 if (timer
->it_ena
& it
) {
89 qemu_irq_raise(timer
->irq
);
92 /* Or are the status bits set even when masked?
93 * i.e. is masking applied before or after the status register? */
96 if (timer
->wu_ena
& it
)
97 qemu_irq_pulse(timer
->wkup
);
100 static inline void omap_gp_timer_out(struct omap_gp_timer_s
*timer
, int level
)
102 if (!timer
->inout
&& timer
->out_val
!= level
) {
103 timer
->out_val
= level
;
104 qemu_set_irq(timer
->out
, level
);
108 static inline uint32_t omap_gp_timer_read(struct omap_gp_timer_s
*timer
)
112 if (timer
->st
&& timer
->rate
) {
113 distance
= qemu_get_clock(vm_clock
) - timer
->time
;
114 distance
= muldiv64(distance
, timer
->rate
, timer
->ticks_per_sec
);
116 if (distance
>= 0xffffffff - timer
->val
)
119 return timer
->val
+ distance
;
124 static inline void omap_gp_timer_sync(struct omap_gp_timer_s
*timer
)
127 timer
->val
= omap_gp_timer_read(timer
);
128 timer
->time
= qemu_get_clock(vm_clock
);
132 static inline void omap_gp_timer_update(struct omap_gp_timer_s
*timer
)
134 int64_t expires
, matches
;
136 if (timer
->st
&& timer
->rate
) {
137 expires
= muldiv64(0x100000000ll
- timer
->val
,
138 timer
->ticks_per_sec
, timer
->rate
);
139 qemu_mod_timer(timer
->timer
, timer
->time
+ expires
);
141 if (timer
->ce
&& timer
->match_val
>= timer
->val
) {
142 matches
= muldiv64(timer
->match_val
- timer
->val
,
143 timer
->ticks_per_sec
, timer
->rate
);
144 qemu_mod_timer(timer
->match
, timer
->time
+ matches
);
146 qemu_del_timer(timer
->match
);
148 qemu_del_timer(timer
->timer
);
149 qemu_del_timer(timer
->match
);
150 omap_gp_timer_out(timer
, timer
->scpwm
);
154 static inline void omap_gp_timer_trigger(struct omap_gp_timer_s
*timer
)
157 /* TODO in overflow-and-match mode if the first event to
158 * occur is the match, don't toggle. */
159 omap_gp_timer_out(timer
, !timer
->out_val
);
161 /* TODO inverted pulse on timer->out_val == 1? */
162 qemu_irq_pulse(timer
->out
);
165 static void omap_gp_timer_tick(void *opaque
)
167 struct omap_gp_timer_s
*timer
= (struct omap_gp_timer_s
*) opaque
;
173 timer
->val
= timer
->load_val
;
174 timer
->time
= qemu_get_clock(vm_clock
);
177 if (timer
->trigger
== gpt_trigger_overflow
||
178 timer
->trigger
== gpt_trigger_both
)
179 omap_gp_timer_trigger(timer
);
181 omap_gp_timer_intr(timer
, GPT_OVF_IT
);
182 omap_gp_timer_update(timer
);
185 static void omap_gp_timer_match(void *opaque
)
187 struct omap_gp_timer_s
*timer
= (struct omap_gp_timer_s
*) opaque
;
189 if (timer
->trigger
== gpt_trigger_both
)
190 omap_gp_timer_trigger(timer
);
192 omap_gp_timer_intr(timer
, GPT_MAT_IT
);
195 static void omap_gp_timer_input(void *opaque
, int line
, int on
)
197 struct omap_gp_timer_s
*s
= (struct omap_gp_timer_s
*) opaque
;
200 switch (s
->capture
) {
202 case gpt_capture_none
:
205 case gpt_capture_rising
:
206 trigger
= !s
->in_val
&& on
;
208 case gpt_capture_falling
:
209 trigger
= s
->in_val
&& !on
;
211 case gpt_capture_both
:
212 trigger
= (s
->in_val
== !on
);
217 if (s
->inout
&& trigger
&& s
->capt_num
< 2) {
218 s
->capture_val
[s
->capt_num
] = omap_gp_timer_read(s
);
220 if (s
->capt2
== s
->capt_num
++)
221 omap_gp_timer_intr(s
, GPT_TCAR_IT
);
225 static void omap_gp_timer_clk_update(void *opaque
, int line
, int on
)
227 struct omap_gp_timer_s
*timer
= (struct omap_gp_timer_s
*) opaque
;
229 omap_gp_timer_sync(timer
);
230 timer
->rate
= on
? omap_clk_getrate(timer
->clk
) : 0;
231 omap_gp_timer_update(timer
);
234 static void omap_gp_timer_clk_setup(struct omap_gp_timer_s
*timer
)
236 omap_clk_adduser(timer
->clk
,
237 qemu_allocate_irqs(omap_gp_timer_clk_update
, timer
, 1)[0]);
238 timer
->rate
= omap_clk_getrate(timer
->clk
);
241 static void omap_gp_timer_reset(struct omap_gp_timer_s
*s
)
251 s
->trigger
= gpt_trigger_none
;
252 s
->capture
= gpt_capture_none
;
261 s
->load_val
= 0x00000000;
262 s
->capture_val
[0] = 0x00000000;
263 s
->capture_val
[1] = 0x00000000;
264 s
->match_val
= 0x00000000;
265 omap_gp_timer_update(s
);
268 static uint32_t omap_gp_timer_readw(void *opaque
, target_phys_addr_t addr
)
270 struct omap_gp_timer_s
*s
= (struct omap_gp_timer_s
*) opaque
;
273 case 0x00: /* TIDR */
276 case 0x10: /* TIOCP_CFG */
279 case 0x14: /* TISTAT */
280 /* ??? When's this bit reset? */
281 return 1; /* RESETDONE */
283 case 0x18: /* TISR */
286 case 0x1c: /* TIER */
289 case 0x20: /* TWER */
292 case 0x24: /* TCLR */
293 return (s
->inout
<< 14) |
305 case 0x28: /* TCRR */
306 return omap_gp_timer_read(s
);
308 case 0x2c: /* TLDR */
311 case 0x30: /* TTGR */
314 case 0x34: /* TWPS */
315 return 0x00000000; /* No posted writes pending. */
317 case 0x38: /* TMAR */
320 case 0x3c: /* TCAR1 */
321 return s
->capture_val
[0];
323 case 0x40: /* TSICR */
324 return s
->posted
<< 2;
326 case 0x44: /* TCAR2 */
327 return s
->capture_val
[1];
334 static uint32_t omap_gp_timer_readh(void *opaque
, target_phys_addr_t addr
)
336 struct omap_gp_timer_s
*s
= (struct omap_gp_timer_s
*) opaque
;
342 ret
= omap_gp_timer_readw(opaque
, addr
);
343 s
->readh
= ret
>> 16;
348 static CPUReadMemoryFunc
* const omap_gp_timer_readfn
[] = {
349 omap_badwidth_read32
,
354 static void omap_gp_timer_write(void *opaque
, target_phys_addr_t addr
,
357 struct omap_gp_timer_s
*s
= (struct omap_gp_timer_s
*) opaque
;
360 case 0x00: /* TIDR */
361 case 0x14: /* TISTAT */
362 case 0x34: /* TWPS */
363 case 0x3c: /* TCAR1 */
364 case 0x44: /* TCAR2 */
368 case 0x10: /* TIOCP_CFG */
369 s
->config
= value
& 0x33d;
370 if (((value
>> 3) & 3) == 3) /* IDLEMODE */
371 fprintf(stderr
, "%s: illegal IDLEMODE value in TIOCP_CFG\n",
373 if (value
& 2) /* SOFTRESET */
374 omap_gp_timer_reset(s
);
377 case 0x18: /* TISR */
378 if (value
& GPT_TCAR_IT
)
380 if (s
->status
&& !(s
->status
&= ~value
))
381 qemu_irq_lower(s
->irq
);
384 case 0x1c: /* TIER */
385 s
->it_ena
= value
& 7;
388 case 0x20: /* TWER */
389 s
->wu_ena
= value
& 7;
392 case 0x24: /* TCLR */
393 omap_gp_timer_sync(s
);
394 s
->inout
= (value
>> 14) & 1;
395 s
->capt2
= (value
>> 13) & 1;
396 s
->pt
= (value
>> 12) & 1;
397 s
->trigger
= (value
>> 10) & 3;
398 if (s
->capture
== gpt_capture_none
&&
399 ((value
>> 8) & 3) != gpt_capture_none
)
401 s
->capture
= (value
>> 8) & 3;
402 s
->scpwm
= (value
>> 7) & 1;
403 s
->ce
= (value
>> 6) & 1;
404 s
->pre
= (value
>> 5) & 1;
405 s
->ptv
= (value
>> 2) & 7;
406 s
->ar
= (value
>> 1) & 1;
407 s
->st
= (value
>> 0) & 1;
408 if (s
->inout
&& s
->trigger
!= gpt_trigger_none
)
409 fprintf(stderr
, "%s: GP timer pin must be an output "
410 "for this trigger mode\n", __FUNCTION__
);
411 if (!s
->inout
&& s
->capture
!= gpt_capture_none
)
412 fprintf(stderr
, "%s: GP timer pin must be an input "
413 "for this capture mode\n", __FUNCTION__
);
414 if (s
->trigger
== gpt_trigger_none
)
415 omap_gp_timer_out(s
, s
->scpwm
);
416 /* TODO: make sure this doesn't overflow 32-bits */
417 s
->ticks_per_sec
= get_ticks_per_sec() << (s
->pre
? s
->ptv
+ 1 : 0);
418 omap_gp_timer_update(s
);
421 case 0x28: /* TCRR */
422 s
->time
= qemu_get_clock(vm_clock
);
424 omap_gp_timer_update(s
);
427 case 0x2c: /* TLDR */
431 case 0x30: /* TTGR */
432 s
->time
= qemu_get_clock(vm_clock
);
433 s
->val
= s
->load_val
;
434 omap_gp_timer_update(s
);
437 case 0x38: /* TMAR */
438 omap_gp_timer_sync(s
);
439 s
->match_val
= value
;
440 omap_gp_timer_update(s
);
443 case 0x40: /* TSICR */
444 s
->posted
= (value
>> 2) & 1;
445 if (value
& 2) /* How much exactly are we supposed to reset? */
446 omap_gp_timer_reset(s
);
454 static void omap_gp_timer_writeh(void *opaque
, target_phys_addr_t addr
,
457 struct omap_gp_timer_s
*s
= (struct omap_gp_timer_s
*) opaque
;
460 return omap_gp_timer_write(opaque
, addr
, (value
<< 16) | s
->writeh
);
462 s
->writeh
= (uint16_t) value
;
465 static CPUWriteMemoryFunc
* const omap_gp_timer_writefn
[] = {
466 omap_badwidth_write32
,
467 omap_gp_timer_writeh
,
471 struct omap_gp_timer_s
*omap_gp_timer_init(struct omap_target_agent_s
*ta
,
472 qemu_irq irq
, omap_clk fclk
, omap_clk iclk
)
475 struct omap_gp_timer_s
*s
= (struct omap_gp_timer_s
*)
476 qemu_mallocz(sizeof(struct omap_gp_timer_s
));
481 s
->timer
= qemu_new_timer(vm_clock
, omap_gp_timer_tick
, s
);
482 s
->match
= qemu_new_timer(vm_clock
, omap_gp_timer_match
, s
);
483 s
->in
= qemu_allocate_irqs(omap_gp_timer_input
, s
, 1)[0];
484 omap_gp_timer_reset(s
);
485 omap_gp_timer_clk_setup(s
);
487 iomemtype
= l4_register_io_memory(omap_gp_timer_readfn
,
488 omap_gp_timer_writefn
, s
);
489 omap_l4_attach(ta
, 0, iomemtype
);
494 /* 32-kHz Sync Timer of the OMAP2 */
495 static uint32_t omap_synctimer_read(struct omap_synctimer_s
*s
) {
496 return muldiv64(qemu_get_clock(vm_clock
), 0x8000, get_ticks_per_sec());
499 static void omap_synctimer_reset(struct omap_synctimer_s
*s
)
501 s
->val
= omap_synctimer_read(s
);
504 static uint32_t omap_synctimer_readw(void *opaque
, target_phys_addr_t addr
)
506 struct omap_synctimer_s
*s
= (struct omap_synctimer_s
*) opaque
;
509 case 0x00: /* 32KSYNCNT_REV */
513 return omap_synctimer_read(s
) - s
->val
;
520 static uint32_t omap_synctimer_readh(void *opaque
, target_phys_addr_t addr
)
522 struct omap_synctimer_s
*s
= (struct omap_synctimer_s
*) opaque
;
528 ret
= omap_synctimer_readw(opaque
, addr
);
529 s
->readh
= ret
>> 16;
534 static CPUReadMemoryFunc
* const omap_synctimer_readfn
[] = {
535 omap_badwidth_read32
,
536 omap_synctimer_readh
,
537 omap_synctimer_readw
,
540 static void omap_synctimer_write(void *opaque
, target_phys_addr_t addr
,
546 static CPUWriteMemoryFunc
* const omap_synctimer_writefn
[] = {
547 omap_badwidth_write32
,
548 omap_synctimer_write
,
549 omap_synctimer_write
,
552 void omap_synctimer_init(struct omap_target_agent_s
*ta
,
553 struct omap_mpu_state_s
*mpu
, omap_clk fclk
, omap_clk iclk
)
555 struct omap_synctimer_s
*s
= &mpu
->synctimer
;
557 omap_synctimer_reset(s
);
558 omap_l4_attach(ta
, 0, l4_register_io_memory(
559 omap_synctimer_readfn
, omap_synctimer_writefn
, s
));
562 /* General-Purpose Interface of OMAP2 */
563 struct omap2_gpio_s
{
567 qemu_irq handler
[32];
582 static inline void omap_gpio_module_int_update(struct omap2_gpio_s
*s
,
585 qemu_set_irq(s
->irq
[line
], s
->ints
[line
] & s
->mask
[line
]);
588 static void omap_gpio_module_wake(struct omap2_gpio_s
*s
, int line
)
590 if (!(s
->config
[0] & (1 << 2))) /* ENAWAKEUP */
592 if (!(s
->config
[0] & (3 << 3))) /* Force Idle */
594 if (!(s
->wumask
& (1 << line
)))
597 qemu_irq_raise(s
->wkup
);
600 static inline void omap_gpio_module_out_update(struct omap2_gpio_s
*s
,
607 while ((ln
= ffs(diff
))) {
609 qemu_set_irq(s
->handler
[ln
], (s
->outputs
>> ln
) & 1);
614 static void omap_gpio_module_level_update(struct omap2_gpio_s
*s
, int line
)
616 s
->ints
[line
] |= s
->dir
&
617 ((s
->inputs
& s
->level
[1]) | (~s
->inputs
& s
->level
[0]));
618 omap_gpio_module_int_update(s
, line
);
621 static inline void omap_gpio_module_int(struct omap2_gpio_s
*s
, int line
)
623 s
->ints
[0] |= 1 << line
;
624 omap_gpio_module_int_update(s
, 0);
625 s
->ints
[1] |= 1 << line
;
626 omap_gpio_module_int_update(s
, 1);
627 omap_gpio_module_wake(s
, line
);
630 static void omap_gpio_module_set(void *opaque
, int line
, int level
)
632 struct omap2_gpio_s
*s
= (struct omap2_gpio_s
*) opaque
;
635 if (s
->dir
& (1 << line
) & ((~s
->inputs
& s
->edge
[0]) | s
->level
[1]))
636 omap_gpio_module_int(s
, line
);
637 s
->inputs
|= 1 << line
;
639 if (s
->dir
& (1 << line
) & ((s
->inputs
& s
->edge
[1]) | s
->level
[0]))
640 omap_gpio_module_int(s
, line
);
641 s
->inputs
&= ~(1 << line
);
645 static void omap_gpio_module_reset(struct omap2_gpio_s
*s
)
663 static uint32_t omap_gpio_module_read(void *opaque
, target_phys_addr_t addr
)
665 struct omap2_gpio_s
*s
= (struct omap2_gpio_s
*) opaque
;
668 case 0x00: /* GPIO_REVISION */
671 case 0x10: /* GPIO_SYSCONFIG */
674 case 0x14: /* GPIO_SYSSTATUS */
677 case 0x18: /* GPIO_IRQSTATUS1 */
680 case 0x1c: /* GPIO_IRQENABLE1 */
681 case 0x60: /* GPIO_CLEARIRQENABLE1 */
682 case 0x64: /* GPIO_SETIRQENABLE1 */
685 case 0x20: /* GPIO_WAKEUPENABLE */
686 case 0x80: /* GPIO_CLEARWKUENA */
687 case 0x84: /* GPIO_SETWKUENA */
690 case 0x28: /* GPIO_IRQSTATUS2 */
693 case 0x2c: /* GPIO_IRQENABLE2 */
694 case 0x70: /* GPIO_CLEARIRQENABLE2 */
695 case 0x74: /* GPIO_SETIREQNEABLE2 */
698 case 0x30: /* GPIO_CTRL */
701 case 0x34: /* GPIO_OE */
704 case 0x38: /* GPIO_DATAIN */
707 case 0x3c: /* GPIO_DATAOUT */
708 case 0x90: /* GPIO_CLEARDATAOUT */
709 case 0x94: /* GPIO_SETDATAOUT */
712 case 0x40: /* GPIO_LEVELDETECT0 */
715 case 0x44: /* GPIO_LEVELDETECT1 */
718 case 0x48: /* GPIO_RISINGDETECT */
721 case 0x4c: /* GPIO_FALLINGDETECT */
724 case 0x50: /* GPIO_DEBOUNCENABLE */
727 case 0x54: /* GPIO_DEBOUNCINGTIME */
735 static void omap_gpio_module_write(void *opaque
, target_phys_addr_t addr
,
738 struct omap2_gpio_s
*s
= (struct omap2_gpio_s
*) opaque
;
743 case 0x00: /* GPIO_REVISION */
744 case 0x14: /* GPIO_SYSSTATUS */
745 case 0x38: /* GPIO_DATAIN */
749 case 0x10: /* GPIO_SYSCONFIG */
750 if (((value
>> 3) & 3) == 3)
751 fprintf(stderr
, "%s: bad IDLEMODE value\n", __FUNCTION__
);
753 omap_gpio_module_reset(s
);
754 s
->config
[0] = value
& 0x1d;
757 case 0x18: /* GPIO_IRQSTATUS1 */
758 if (s
->ints
[0] & value
) {
759 s
->ints
[0] &= ~value
;
760 omap_gpio_module_level_update(s
, 0);
764 case 0x1c: /* GPIO_IRQENABLE1 */
766 omap_gpio_module_int_update(s
, 0);
769 case 0x20: /* GPIO_WAKEUPENABLE */
773 case 0x28: /* GPIO_IRQSTATUS2 */
774 if (s
->ints
[1] & value
) {
775 s
->ints
[1] &= ~value
;
776 omap_gpio_module_level_update(s
, 1);
780 case 0x2c: /* GPIO_IRQENABLE2 */
782 omap_gpio_module_int_update(s
, 1);
785 case 0x30: /* GPIO_CTRL */
786 s
->config
[1] = value
& 7;
789 case 0x34: /* GPIO_OE */
790 diff
= s
->outputs
& (s
->dir
^ value
);
793 value
= s
->outputs
& ~s
->dir
;
794 while ((ln
= ffs(diff
))) {
795 diff
&= ~(1 <<-- ln
);
796 qemu_set_irq(s
->handler
[ln
], (value
>> ln
) & 1);
799 omap_gpio_module_level_update(s
, 0);
800 omap_gpio_module_level_update(s
, 1);
803 case 0x3c: /* GPIO_DATAOUT */
804 omap_gpio_module_out_update(s
, s
->outputs
^ value
);
807 case 0x40: /* GPIO_LEVELDETECT0 */
809 omap_gpio_module_level_update(s
, 0);
810 omap_gpio_module_level_update(s
, 1);
813 case 0x44: /* GPIO_LEVELDETECT1 */
815 omap_gpio_module_level_update(s
, 0);
816 omap_gpio_module_level_update(s
, 1);
819 case 0x48: /* GPIO_RISINGDETECT */
823 case 0x4c: /* GPIO_FALLINGDETECT */
827 case 0x50: /* GPIO_DEBOUNCENABLE */
831 case 0x54: /* GPIO_DEBOUNCINGTIME */
835 case 0x60: /* GPIO_CLEARIRQENABLE1 */
836 s
->mask
[0] &= ~value
;
837 omap_gpio_module_int_update(s
, 0);
840 case 0x64: /* GPIO_SETIRQENABLE1 */
842 omap_gpio_module_int_update(s
, 0);
845 case 0x70: /* GPIO_CLEARIRQENABLE2 */
846 s
->mask
[1] &= ~value
;
847 omap_gpio_module_int_update(s
, 1);
850 case 0x74: /* GPIO_SETIREQNEABLE2 */
852 omap_gpio_module_int_update(s
, 1);
855 case 0x80: /* GPIO_CLEARWKUENA */
859 case 0x84: /* GPIO_SETWKUENA */
863 case 0x90: /* GPIO_CLEARDATAOUT */
864 omap_gpio_module_out_update(s
, s
->outputs
& value
);
867 case 0x94: /* GPIO_SETDATAOUT */
868 omap_gpio_module_out_update(s
, ~s
->outputs
& value
);
877 static uint32_t omap_gpio_module_readp(void *opaque
, target_phys_addr_t addr
)
879 return omap_gpio_module_readp(opaque
, addr
) >> ((addr
& 3) << 3);
882 static void omap_gpio_module_writep(void *opaque
, target_phys_addr_t addr
,
886 uint32_t mask
= 0xffff;
889 case 0x00: /* GPIO_REVISION */
890 case 0x14: /* GPIO_SYSSTATUS */
891 case 0x38: /* GPIO_DATAIN */
895 case 0x10: /* GPIO_SYSCONFIG */
896 case 0x1c: /* GPIO_IRQENABLE1 */
897 case 0x20: /* GPIO_WAKEUPENABLE */
898 case 0x2c: /* GPIO_IRQENABLE2 */
899 case 0x30: /* GPIO_CTRL */
900 case 0x34: /* GPIO_OE */
901 case 0x3c: /* GPIO_DATAOUT */
902 case 0x40: /* GPIO_LEVELDETECT0 */
903 case 0x44: /* GPIO_LEVELDETECT1 */
904 case 0x48: /* GPIO_RISINGDETECT */
905 case 0x4c: /* GPIO_FALLINGDETECT */
906 case 0x50: /* GPIO_DEBOUNCENABLE */
907 case 0x54: /* GPIO_DEBOUNCINGTIME */
908 cur
= omap_gpio_module_read(opaque
, addr
& ~3) &
909 ~(mask
<< ((addr
& 3) << 3));
912 case 0x18: /* GPIO_IRQSTATUS1 */
913 case 0x28: /* GPIO_IRQSTATUS2 */
914 case 0x60: /* GPIO_CLEARIRQENABLE1 */
915 case 0x64: /* GPIO_SETIRQENABLE1 */
916 case 0x70: /* GPIO_CLEARIRQENABLE2 */
917 case 0x74: /* GPIO_SETIREQNEABLE2 */
918 case 0x80: /* GPIO_CLEARWKUENA */
919 case 0x84: /* GPIO_SETWKUENA */
920 case 0x90: /* GPIO_CLEARDATAOUT */
921 case 0x94: /* GPIO_SETDATAOUT */
922 value
<<= (addr
& 3) << 3;
923 omap_gpio_module_write(opaque
, addr
, cur
| value
);
932 static CPUReadMemoryFunc
* const omap_gpio_module_readfn
[] = {
933 omap_gpio_module_readp
,
934 omap_gpio_module_readp
,
935 omap_gpio_module_read
,
938 static CPUWriteMemoryFunc
* const omap_gpio_module_writefn
[] = {
939 omap_gpio_module_writep
,
940 omap_gpio_module_writep
,
941 omap_gpio_module_write
,
944 static void omap_gpio_module_init(struct omap2_gpio_s
*s
,
945 struct omap_target_agent_s
*ta
, int region
,
946 qemu_irq mpu
, qemu_irq dsp
, qemu_irq wkup
,
947 omap_clk fclk
, omap_clk iclk
)
954 s
->in
= qemu_allocate_irqs(omap_gpio_module_set
, s
, 32);
956 iomemtype
= l4_register_io_memory(omap_gpio_module_readfn
,
957 omap_gpio_module_writefn
, s
);
958 omap_l4_attach(ta
, region
, iomemtype
);
962 struct omap2_gpio_s module
[5];
969 static void omap_gpif_reset(struct omap_gpif_s
*s
)
973 for (i
= 0; i
< s
->modules
; i
++)
974 omap_gpio_module_reset(s
->module
+ i
);
980 static uint32_t omap_gpif_top_read(void *opaque
, target_phys_addr_t addr
)
982 struct omap_gpif_s
*s
= (struct omap_gpif_s
*) opaque
;
985 case 0x00: /* IPGENERICOCPSPL_REVISION */
988 case 0x10: /* IPGENERICOCPSPL_SYSCONFIG */
991 case 0x14: /* IPGENERICOCPSPL_SYSSTATUS */
994 case 0x18: /* IPGENERICOCPSPL_IRQSTATUS */
997 case 0x40: /* IPGENERICOCPSPL_GPO */
1000 case 0x50: /* IPGENERICOCPSPL_GPI */
1008 static void omap_gpif_top_write(void *opaque
, target_phys_addr_t addr
,
1011 struct omap_gpif_s
*s
= (struct omap_gpif_s
*) opaque
;
1014 case 0x00: /* IPGENERICOCPSPL_REVISION */
1015 case 0x14: /* IPGENERICOCPSPL_SYSSTATUS */
1016 case 0x18: /* IPGENERICOCPSPL_IRQSTATUS */
1017 case 0x50: /* IPGENERICOCPSPL_GPI */
1021 case 0x10: /* IPGENERICOCPSPL_SYSCONFIG */
1022 if (value
& (1 << 1)) /* SOFTRESET */
1024 s
->autoidle
= value
& 1;
1027 case 0x40: /* IPGENERICOCPSPL_GPO */
1037 static CPUReadMemoryFunc
* const omap_gpif_top_readfn
[] = {
1043 static CPUWriteMemoryFunc
* const omap_gpif_top_writefn
[] = {
1044 omap_gpif_top_write
,
1045 omap_gpif_top_write
,
1046 omap_gpif_top_write
,
1049 struct omap_gpif_s
*omap2_gpio_init(struct omap_target_agent_s
*ta
,
1050 qemu_irq
*irq
, omap_clk
*fclk
, omap_clk iclk
, int modules
)
1053 struct omap_gpif_s
*s
= (struct omap_gpif_s
*)
1054 qemu_mallocz(sizeof(struct omap_gpif_s
));
1055 int region
[4] = { 0, 2, 4, 5 };
1057 s
->modules
= modules
;
1058 for (i
= 0; i
< modules
; i
++)
1059 omap_gpio_module_init(s
->module
+ i
, ta
, region
[i
],
1060 irq
[i
], NULL
, NULL
, fclk
[i
], iclk
);
1064 iomemtype
= l4_register_io_memory(omap_gpif_top_readfn
,
1065 omap_gpif_top_writefn
, s
);
1066 omap_l4_attach(ta
, 1, iomemtype
);
1071 qemu_irq
*omap2_gpio_in_get(struct omap_gpif_s
*s
, int start
)
1073 if (start
>= s
->modules
* 32 || start
< 0)
1074 hw_error("%s: No GPIO line %i\n", __FUNCTION__
, start
);
1075 return s
->module
[start
>> 5].in
+ (start
& 31);
1078 void omap2_gpio_out_set(struct omap_gpif_s
*s
, int line
, qemu_irq handler
)
1080 if (line
>= s
->modules
* 32 || line
< 0)
1081 hw_error("%s: No GPIO line %i\n", __FUNCTION__
, line
);
1082 s
->module
[line
>> 5].handler
[line
& 31] = handler
;
1085 /* Multichannel SPI */
1086 struct omap_mcspi_s
{
1097 struct omap_mcspi_ch_s
{
1100 uint32_t (*txrx
)(void *opaque
, uint32_t, int);
1112 static inline void omap_mcspi_interrupt_update(struct omap_mcspi_s
*s
)
1114 qemu_set_irq(s
->irq
, s
->irqst
& s
->irqen
);
1117 static inline void omap_mcspi_dmarequest_update(struct omap_mcspi_ch_s
*ch
)
1119 qemu_set_irq(ch
->txdrq
,
1120 (ch
->control
& 1) && /* EN */
1121 (ch
->config
& (1 << 14)) && /* DMAW */
1122 (ch
->status
& (1 << 1)) && /* TXS */
1123 ((ch
->config
>> 12) & 3) != 1); /* TRM */
1124 qemu_set_irq(ch
->rxdrq
,
1125 (ch
->control
& 1) && /* EN */
1126 (ch
->config
& (1 << 15)) && /* DMAW */
1127 (ch
->status
& (1 << 0)) && /* RXS */
1128 ((ch
->config
>> 12) & 3) != 2); /* TRM */
1131 static void omap_mcspi_transfer_run(struct omap_mcspi_s
*s
, int chnum
)
1133 struct omap_mcspi_ch_s
*ch
= s
->ch
+ chnum
;
1135 if (!(ch
->control
& 1)) /* EN */
1137 if ((ch
->status
& (1 << 0)) && /* RXS */
1138 ((ch
->config
>> 12) & 3) != 2 && /* TRM */
1139 !(ch
->config
& (1 << 19))) /* TURBO */
1141 if ((ch
->status
& (1 << 1)) && /* TXS */
1142 ((ch
->config
>> 12) & 3) != 1) /* TRM */
1145 if (!(s
->control
& 1) || /* SINGLE */
1146 (ch
->config
& (1 << 20))) { /* FORCE */
1148 ch
->rx
= ch
->txrx(ch
->opaque
, ch
->tx
, /* WL */
1149 1 + (0x1f & (ch
->config
>> 7)));
1153 ch
->status
|= 1 << 2; /* EOT */
1154 ch
->status
|= 1 << 1; /* TXS */
1155 if (((ch
->config
>> 12) & 3) != 2) /* TRM */
1156 ch
->status
|= 1 << 0; /* RXS */
1159 if ((ch
->status
& (1 << 0)) && /* RXS */
1160 ((ch
->config
>> 12) & 3) != 2 && /* TRM */
1161 !(ch
->config
& (1 << 19))) /* TURBO */
1162 s
->irqst
|= 1 << (2 + 4 * chnum
); /* RX_FULL */
1163 if ((ch
->status
& (1 << 1)) && /* TXS */
1164 ((ch
->config
>> 12) & 3) != 1) /* TRM */
1165 s
->irqst
|= 1 << (0 + 4 * chnum
); /* TX_EMPTY */
1166 omap_mcspi_interrupt_update(s
);
1167 omap_mcspi_dmarequest_update(ch
);
1170 static void omap_mcspi_reset(struct omap_mcspi_s
*s
)
1181 for (ch
= 0; ch
< 4; ch
++) {
1182 s
->ch
[ch
].config
= 0x060000;
1183 s
->ch
[ch
].status
= 2; /* TXS */
1184 s
->ch
[ch
].control
= 0;
1186 omap_mcspi_dmarequest_update(s
->ch
+ ch
);
1189 omap_mcspi_interrupt_update(s
);
1192 static uint32_t omap_mcspi_read(void *opaque
, target_phys_addr_t addr
)
1194 struct omap_mcspi_s
*s
= (struct omap_mcspi_s
*) opaque
;
1199 case 0x00: /* MCSPI_REVISION */
1202 case 0x10: /* MCSPI_SYSCONFIG */
1203 return s
->sysconfig
;
1205 case 0x14: /* MCSPI_SYSSTATUS */
1206 return 1; /* RESETDONE */
1208 case 0x18: /* MCSPI_IRQSTATUS */
1211 case 0x1c: /* MCSPI_IRQENABLE */
1214 case 0x20: /* MCSPI_WAKEUPENABLE */
1217 case 0x24: /* MCSPI_SYST */
1220 case 0x28: /* MCSPI_MODULCTRL */
1226 case 0x2c: /* MCSPI_CHCONF */
1227 return s
->ch
[ch
].config
;
1232 case 0x30: /* MCSPI_CHSTAT */
1233 return s
->ch
[ch
].status
;
1238 case 0x34: /* MCSPI_CHCTRL */
1239 return s
->ch
[ch
].control
;
1244 case 0x38: /* MCSPI_TX */
1245 return s
->ch
[ch
].tx
;
1250 case 0x3c: /* MCSPI_RX */
1251 s
->ch
[ch
].status
&= ~(1 << 0); /* RXS */
1253 omap_mcspi_transfer_run(s
, ch
);
1261 static void omap_mcspi_write(void *opaque
, target_phys_addr_t addr
,
1264 struct omap_mcspi_s
*s
= (struct omap_mcspi_s
*) opaque
;
1268 case 0x00: /* MCSPI_REVISION */
1269 case 0x14: /* MCSPI_SYSSTATUS */
1270 case 0x30: /* MCSPI_CHSTAT0 */
1271 case 0x3c: /* MCSPI_RX0 */
1272 case 0x44: /* MCSPI_CHSTAT1 */
1273 case 0x50: /* MCSPI_RX1 */
1274 case 0x58: /* MCSPI_CHSTAT2 */
1275 case 0x64: /* MCSPI_RX2 */
1276 case 0x6c: /* MCSPI_CHSTAT3 */
1277 case 0x78: /* MCSPI_RX3 */
1281 case 0x10: /* MCSPI_SYSCONFIG */
1282 if (value
& (1 << 1)) /* SOFTRESET */
1283 omap_mcspi_reset(s
);
1284 s
->sysconfig
= value
& 0x31d;
1287 case 0x18: /* MCSPI_IRQSTATUS */
1288 if (!((s
->control
& (1 << 3)) && (s
->systest
& (1 << 11)))) {
1290 omap_mcspi_interrupt_update(s
);
1294 case 0x1c: /* MCSPI_IRQENABLE */
1295 s
->irqen
= value
& 0x1777f;
1296 omap_mcspi_interrupt_update(s
);
1299 case 0x20: /* MCSPI_WAKEUPENABLE */
1300 s
->wken
= value
& 1;
1303 case 0x24: /* MCSPI_SYST */
1304 if (s
->control
& (1 << 3)) /* SYSTEM_TEST */
1305 if (value
& (1 << 11)) { /* SSB */
1306 s
->irqst
|= 0x1777f;
1307 omap_mcspi_interrupt_update(s
);
1309 s
->systest
= value
& 0xfff;
1312 case 0x28: /* MCSPI_MODULCTRL */
1313 if (value
& (1 << 3)) /* SYSTEM_TEST */
1314 if (s
->systest
& (1 << 11)) { /* SSB */
1315 s
->irqst
|= 0x1777f;
1316 omap_mcspi_interrupt_update(s
);
1318 s
->control
= value
& 0xf;
1324 case 0x2c: /* MCSPI_CHCONF */
1325 if ((value
^ s
->ch
[ch
].config
) & (3 << 14)) /* DMAR | DMAW */
1326 omap_mcspi_dmarequest_update(s
->ch
+ ch
);
1327 if (((value
>> 12) & 3) == 3) /* TRM */
1328 fprintf(stderr
, "%s: invalid TRM value (3)\n", __FUNCTION__
);
1329 if (((value
>> 7) & 0x1f) < 3) /* WL */
1330 fprintf(stderr
, "%s: invalid WL value (%i)\n",
1331 __FUNCTION__
, (value
>> 7) & 0x1f);
1332 s
->ch
[ch
].config
= value
& 0x7fffff;
1338 case 0x34: /* MCSPI_CHCTRL */
1339 if (value
& ~s
->ch
[ch
].control
& 1) { /* EN */
1340 s
->ch
[ch
].control
|= 1;
1341 omap_mcspi_transfer_run(s
, ch
);
1343 s
->ch
[ch
].control
= value
& 1;
1349 case 0x38: /* MCSPI_TX */
1350 s
->ch
[ch
].tx
= value
;
1351 s
->ch
[ch
].status
&= ~(1 << 1); /* TXS */
1352 omap_mcspi_transfer_run(s
, ch
);
1361 static CPUReadMemoryFunc
* const omap_mcspi_readfn
[] = {
1362 omap_badwidth_read32
,
1363 omap_badwidth_read32
,
1367 static CPUWriteMemoryFunc
* const omap_mcspi_writefn
[] = {
1368 omap_badwidth_write32
,
1369 omap_badwidth_write32
,
1373 struct omap_mcspi_s
*omap_mcspi_init(struct omap_target_agent_s
*ta
, int chnum
,
1374 qemu_irq irq
, qemu_irq
*drq
, omap_clk fclk
, omap_clk iclk
)
1377 struct omap_mcspi_s
*s
= (struct omap_mcspi_s
*)
1378 qemu_mallocz(sizeof(struct omap_mcspi_s
));
1379 struct omap_mcspi_ch_s
*ch
= s
->ch
;
1384 ch
->txdrq
= *drq
++;
1385 ch
->rxdrq
= *drq
++;
1388 omap_mcspi_reset(s
);
1390 iomemtype
= l4_register_io_memory(omap_mcspi_readfn
,
1391 omap_mcspi_writefn
, s
);
1392 omap_l4_attach(ta
, 0, iomemtype
);
1397 void omap_mcspi_attach(struct omap_mcspi_s
*s
,
1398 uint32_t (*txrx
)(void *opaque
, uint32_t, int), void *opaque
,
1401 if (chipselect
< 0 || chipselect
>= s
->chnum
)
1402 hw_error("%s: Bad chipselect %i\n", __FUNCTION__
, chipselect
);
1404 s
->ch
[chipselect
].txrx
= txrx
;
1405 s
->ch
[chipselect
].opaque
= opaque
;
1408 /* Enhanced Audio Controller (CODEC only) */
1427 uint32_t (*txrx
)(void *opaque
, uint32_t, int);
1430 #define EAC_BUF_LEN 1024
1431 uint32_t rxbuf
[EAC_BUF_LEN
];
1435 uint32_t txbuf
[EAC_BUF_LEN
];
1444 /* These need to be moved to the actual codec */
1446 SWVoiceIn
*in_voice
;
1447 SWVoiceOut
*out_voice
;
1457 static inline void omap_eac_interrupt_update(struct omap_eac_s
*s
)
1459 qemu_set_irq(s
->irq
, (s
->codec
.config
[1] >> 14) & 1); /* AURDI */
1462 static inline void omap_eac_in_dmarequest_update(struct omap_eac_s
*s
)
1464 qemu_set_irq(s
->codec
.rxdrq
, (s
->codec
.rxavail
|| s
->codec
.rxlen
) &&
1465 ((s
->codec
.config
[1] >> 12) & 1)); /* DMAREN */
1468 static inline void omap_eac_out_dmarequest_update(struct omap_eac_s
*s
)
1470 qemu_set_irq(s
->codec
.txdrq
, s
->codec
.txlen
< s
->codec
.txavail
&&
1471 ((s
->codec
.config
[1] >> 11) & 1)); /* DMAWEN */
1474 static inline void omap_eac_in_refill(struct omap_eac_s
*s
)
1476 int left
= MIN(EAC_BUF_LEN
- s
->codec
.rxlen
, s
->codec
.rxavail
) << 2;
1477 int start
= ((s
->codec
.rxoff
+ s
->codec
.rxlen
) & (EAC_BUF_LEN
- 1)) << 2;
1478 int leftwrap
= MIN(left
, (EAC_BUF_LEN
<< 2) - start
);
1480 uint8_t *buf
= (uint8_t *) s
->codec
.rxbuf
+ start
;
1484 while (leftwrap
&& (recv
= AUD_read(s
->codec
.in_voice
, buf
+ start
,
1485 leftwrap
)) > 0) { /* Be defensive */
1490 s
->codec
.rxavail
= 0;
1492 s
->codec
.rxavail
-= start
>> 2;
1493 s
->codec
.rxlen
+= start
>> 2;
1495 if (recv
> 0 && left
> 0) {
1497 while (left
&& (recv
= AUD_read(s
->codec
.in_voice
,
1498 (uint8_t *) s
->codec
.rxbuf
+ start
,
1499 left
)) > 0) { /* Be defensive */
1504 s
->codec
.rxavail
= 0;
1506 s
->codec
.rxavail
-= start
>> 2;
1507 s
->codec
.rxlen
+= start
>> 2;
1511 static inline void omap_eac_out_empty(struct omap_eac_s
*s
)
1513 int left
= s
->codec
.txlen
<< 2;
1517 while (left
&& (sent
= AUD_write(s
->codec
.out_voice
,
1518 (uint8_t *) s
->codec
.txbuf
+ start
,
1519 left
)) > 0) { /* Be defensive */
1525 s
->codec
.txavail
= 0;
1526 omap_eac_out_dmarequest_update(s
);
1533 static void omap_eac_in_cb(void *opaque
, int avail_b
)
1535 struct omap_eac_s
*s
= (struct omap_eac_s
*) opaque
;
1537 s
->codec
.rxavail
= avail_b
>> 2;
1538 omap_eac_in_refill(s
);
1539 /* TODO: possibly discard current buffer if overrun */
1540 omap_eac_in_dmarequest_update(s
);
1543 static void omap_eac_out_cb(void *opaque
, int free_b
)
1545 struct omap_eac_s
*s
= (struct omap_eac_s
*) opaque
;
1547 s
->codec
.txavail
= free_b
>> 2;
1549 omap_eac_out_empty(s
);
1551 omap_eac_out_dmarequest_update(s
);
1554 static void omap_eac_enable_update(struct omap_eac_s
*s
)
1556 s
->codec
.enable
= !(s
->codec
.config
[1] & 1) && /* EACPWD */
1557 (s
->codec
.config
[1] & 2) && /* AUDEN */
1561 static const int omap_eac_fsint
[4] = {
1568 static const int omap_eac_fsint2
[8] = {
1577 static const int omap_eac_fsint3
[16] = {
1586 0, 0, 0, 0, 0, 0, 0, 0,
1589 static void omap_eac_rate_update(struct omap_eac_s
*s
)
1593 fsint
[2] = (s
->codec
.config
[3] >> 9) & 0xf;
1594 fsint
[1] = (s
->codec
.config
[2] >> 0) & 0x7;
1595 fsint
[0] = (s
->codec
.config
[0] >> 6) & 0x3;
1597 s
->codec
.rate
= omap_eac_fsint3
[fsint
[2]];
1598 else if (fsint
[1] < 0x7)
1599 s
->codec
.rate
= omap_eac_fsint2
[fsint
[1]];
1601 s
->codec
.rate
= omap_eac_fsint
[fsint
[0]];
1604 static void omap_eac_volume_update(struct omap_eac_s
*s
)
1609 static void omap_eac_format_update(struct omap_eac_s
*s
)
1611 struct audsettings fmt
;
1613 /* The hardware buffers at most one sample */
1617 if (s
->codec
.in_voice
) {
1618 AUD_set_active_in(s
->codec
.in_voice
, 0);
1619 AUD_close_in(&s
->codec
.card
, s
->codec
.in_voice
);
1620 s
->codec
.in_voice
= NULL
;
1622 if (s
->codec
.out_voice
) {
1623 omap_eac_out_empty(s
);
1624 AUD_set_active_out(s
->codec
.out_voice
, 0);
1625 AUD_close_out(&s
->codec
.card
, s
->codec
.out_voice
);
1626 s
->codec
.out_voice
= NULL
;
1627 s
->codec
.txavail
= 0;
1629 /* Discard what couldn't be written */
1632 omap_eac_enable_update(s
);
1633 if (!s
->codec
.enable
)
1636 omap_eac_rate_update(s
);
1637 fmt
.endianness
= ((s
->codec
.config
[0] >> 8) & 1); /* LI_BI */
1638 fmt
.nchannels
= ((s
->codec
.config
[0] >> 10) & 1) ? 2 : 1; /* MN_ST */
1639 fmt
.freq
= s
->codec
.rate
;
1640 /* TODO: signedness possibly depends on the CODEC hardware - or
1641 * does I2S specify it? */
1642 /* All register writes are 16 bits so we we store 16-bit samples
1643 * in the buffers regardless of AGCFR[B8_16] value. */
1644 fmt
.fmt
= AUD_FMT_U16
;
1646 s
->codec
.in_voice
= AUD_open_in(&s
->codec
.card
, s
->codec
.in_voice
,
1647 "eac.codec.in", s
, omap_eac_in_cb
, &fmt
);
1648 s
->codec
.out_voice
= AUD_open_out(&s
->codec
.card
, s
->codec
.out_voice
,
1649 "eac.codec.out", s
, omap_eac_out_cb
, &fmt
);
1651 omap_eac_volume_update(s
);
1653 AUD_set_active_in(s
->codec
.in_voice
, 1);
1654 AUD_set_active_out(s
->codec
.out_voice
, 1);
1657 static void omap_eac_reset(struct omap_eac_s
*s
)
1660 s
->config
[0] = 0x0c;
1661 s
->config
[1] = 0x09;
1662 s
->config
[2] = 0xab;
1663 s
->config
[3] = 0x03;
1670 s
->gain
[0] = 0xe7e7;
1671 s
->gain
[1] = 0x6767;
1672 s
->gain
[2] = 0x6767;
1673 s
->gain
[3] = 0x6767;
1683 s
->modem
.control
= 0x00;
1684 s
->modem
.config
= 0x0000;
1685 s
->bt
.control
= 0x00;
1686 s
->bt
.config
= 0x0000;
1687 s
->codec
.config
[0] = 0x0649;
1688 s
->codec
.config
[1] = 0x0000;
1689 s
->codec
.config
[2] = 0x0007;
1690 s
->codec
.config
[3] = 0x1ffc;
1694 s
->codec
.rxavail
= 0;
1695 s
->codec
.txavail
= 0;
1697 omap_eac_format_update(s
);
1698 omap_eac_interrupt_update(s
);
1701 static uint32_t omap_eac_read(void *opaque
, target_phys_addr_t addr
)
1703 struct omap_eac_s
*s
= (struct omap_eac_s
*) opaque
;
1707 case 0x000: /* CPCFR1 */
1708 return s
->config
[0];
1709 case 0x004: /* CPCFR2 */
1710 return s
->config
[1];
1711 case 0x008: /* CPCFR3 */
1712 return s
->config
[2];
1713 case 0x00c: /* CPCFR4 */
1714 return s
->config
[3];
1716 case 0x010: /* CPTCTL */
1717 return s
->control
| ((s
->codec
.rxavail
+ s
->codec
.rxlen
> 0) << 7) |
1718 ((s
->codec
.txlen
< s
->codec
.txavail
) << 5);
1720 case 0x014: /* CPTTADR */
1722 case 0x018: /* CPTDATL */
1723 return s
->data
& 0xff;
1724 case 0x01c: /* CPTDATH */
1725 return s
->data
>> 8;
1726 case 0x020: /* CPTVSLL */
1728 case 0x024: /* CPTVSLH */
1729 return s
->vtsl
| (3 << 5); /* CRDY1 | CRDY2 */
1730 case 0x040: /* MPCTR */
1731 return s
->modem
.control
;
1732 case 0x044: /* MPMCCFR */
1733 return s
->modem
.config
;
1734 case 0x060: /* BPCTR */
1735 return s
->bt
.control
;
1736 case 0x064: /* BPMCCFR */
1737 return s
->bt
.config
;
1738 case 0x080: /* AMSCFR */
1740 case 0x084: /* AMVCTR */
1742 case 0x088: /* AM1VCTR */
1744 case 0x08c: /* AM2VCTR */
1746 case 0x090: /* AM3VCTR */
1748 case 0x094: /* ASTCTR */
1750 case 0x098: /* APD1LCR */
1752 case 0x09c: /* APD1RCR */
1754 case 0x0a0: /* APD2LCR */
1756 case 0x0a4: /* APD2RCR */
1758 case 0x0a8: /* APD3LCR */
1760 case 0x0ac: /* APD3RCR */
1762 case 0x0b0: /* APD4R */
1764 case 0x0b4: /* ADWR */
1765 /* This should be write-only? Docs list it as read-only. */
1767 case 0x0b8: /* ADRDR */
1768 if (likely(s
->codec
.rxlen
> 1)) {
1769 ret
= s
->codec
.rxbuf
[s
->codec
.rxoff
++];
1771 s
->codec
.rxoff
&= EAC_BUF_LEN
- 1;
1773 } else if (s
->codec
.rxlen
) {
1774 ret
= s
->codec
.rxbuf
[s
->codec
.rxoff
++];
1776 s
->codec
.rxoff
&= EAC_BUF_LEN
- 1;
1777 if (s
->codec
.rxavail
)
1778 omap_eac_in_refill(s
);
1779 omap_eac_in_dmarequest_update(s
);
1783 case 0x0bc: /* AGCFR */
1784 return s
->codec
.config
[0];
1785 case 0x0c0: /* AGCTR */
1786 return s
->codec
.config
[1] | ((s
->codec
.config
[1] & 2) << 14);
1787 case 0x0c4: /* AGCFR2 */
1788 return s
->codec
.config
[2];
1789 case 0x0c8: /* AGCFR3 */
1790 return s
->codec
.config
[3];
1791 case 0x0cc: /* MBPDMACTR */
1792 case 0x0d0: /* MPDDMARR */
1793 case 0x0d8: /* MPUDMARR */
1794 case 0x0e4: /* BPDDMARR */
1795 case 0x0ec: /* BPUDMARR */
1798 case 0x100: /* VERSION_NUMBER */
1801 case 0x104: /* SYSCONFIG */
1802 return s
->sysconfig
;
1804 case 0x108: /* SYSSTATUS */
1805 return 1 | 0xe; /* RESETDONE | stuff */
1812 static void omap_eac_write(void *opaque
, target_phys_addr_t addr
,
1815 struct omap_eac_s
*s
= (struct omap_eac_s
*) opaque
;
1818 case 0x098: /* APD1LCR */
1819 case 0x09c: /* APD1RCR */
1820 case 0x0a0: /* APD2LCR */
1821 case 0x0a4: /* APD2RCR */
1822 case 0x0a8: /* APD3LCR */
1823 case 0x0ac: /* APD3RCR */
1824 case 0x0b0: /* APD4R */
1825 case 0x0b8: /* ADRDR */
1826 case 0x0d0: /* MPDDMARR */
1827 case 0x0d8: /* MPUDMARR */
1828 case 0x0e4: /* BPDDMARR */
1829 case 0x0ec: /* BPUDMARR */
1830 case 0x100: /* VERSION_NUMBER */
1831 case 0x108: /* SYSSTATUS */
1835 case 0x000: /* CPCFR1 */
1836 s
->config
[0] = value
& 0xff;
1837 omap_eac_format_update(s
);
1839 case 0x004: /* CPCFR2 */
1840 s
->config
[1] = value
& 0xff;
1841 omap_eac_format_update(s
);
1843 case 0x008: /* CPCFR3 */
1844 s
->config
[2] = value
& 0xff;
1845 omap_eac_format_update(s
);
1847 case 0x00c: /* CPCFR4 */
1848 s
->config
[3] = value
& 0xff;
1849 omap_eac_format_update(s
);
1852 case 0x010: /* CPTCTL */
1853 /* Assuming TXF and TXE bits are read-only... */
1854 s
->control
= value
& 0x5f;
1855 omap_eac_interrupt_update(s
);
1858 case 0x014: /* CPTTADR */
1859 s
->address
= value
& 0xff;
1861 case 0x018: /* CPTDATL */
1863 s
->data
|= value
& 0xff;
1865 case 0x01c: /* CPTDATH */
1867 s
->data
|= value
<< 8;
1869 case 0x020: /* CPTVSLL */
1870 s
->vtol
= value
& 0xf8;
1872 case 0x024: /* CPTVSLH */
1873 s
->vtsl
= value
& 0x9f;
1875 case 0x040: /* MPCTR */
1876 s
->modem
.control
= value
& 0x8f;
1878 case 0x044: /* MPMCCFR */
1879 s
->modem
.config
= value
& 0x7fff;
1881 case 0x060: /* BPCTR */
1882 s
->bt
.control
= value
& 0x8f;
1884 case 0x064: /* BPMCCFR */
1885 s
->bt
.config
= value
& 0x7fff;
1887 case 0x080: /* AMSCFR */
1888 s
->mixer
= value
& 0x0fff;
1890 case 0x084: /* AMVCTR */
1891 s
->gain
[0] = value
& 0xffff;
1893 case 0x088: /* AM1VCTR */
1894 s
->gain
[1] = value
& 0xff7f;
1896 case 0x08c: /* AM2VCTR */
1897 s
->gain
[2] = value
& 0xff7f;
1899 case 0x090: /* AM3VCTR */
1900 s
->gain
[3] = value
& 0xff7f;
1902 case 0x094: /* ASTCTR */
1903 s
->att
= value
& 0xff;
1906 case 0x0b4: /* ADWR */
1907 s
->codec
.txbuf
[s
->codec
.txlen
++] = value
;
1908 if (unlikely(s
->codec
.txlen
== EAC_BUF_LEN
||
1909 s
->codec
.txlen
== s
->codec
.txavail
)) {
1910 if (s
->codec
.txavail
)
1911 omap_eac_out_empty(s
);
1912 /* Discard what couldn't be written */
1917 case 0x0bc: /* AGCFR */
1918 s
->codec
.config
[0] = value
& 0x07ff;
1919 omap_eac_format_update(s
);
1921 case 0x0c0: /* AGCTR */
1922 s
->codec
.config
[1] = value
& 0x780f;
1923 omap_eac_format_update(s
);
1925 case 0x0c4: /* AGCFR2 */
1926 s
->codec
.config
[2] = value
& 0x003f;
1927 omap_eac_format_update(s
);
1929 case 0x0c8: /* AGCFR3 */
1930 s
->codec
.config
[3] = value
& 0xffff;
1931 omap_eac_format_update(s
);
1933 case 0x0cc: /* MBPDMACTR */
1934 case 0x0d4: /* MPDDMAWR */
1935 case 0x0e0: /* MPUDMAWR */
1936 case 0x0e8: /* BPDDMAWR */
1937 case 0x0f0: /* BPUDMAWR */
1940 case 0x104: /* SYSCONFIG */
1941 if (value
& (1 << 1)) /* SOFTRESET */
1943 s
->sysconfig
= value
& 0x31d;
1952 static CPUReadMemoryFunc
* const omap_eac_readfn
[] = {
1953 omap_badwidth_read16
,
1955 omap_badwidth_read16
,
1958 static CPUWriteMemoryFunc
* const omap_eac_writefn
[] = {
1959 omap_badwidth_write16
,
1961 omap_badwidth_write16
,
1964 struct omap_eac_s
*omap_eac_init(struct omap_target_agent_s
*ta
,
1965 qemu_irq irq
, qemu_irq
*drq
, omap_clk fclk
, omap_clk iclk
)
1968 struct omap_eac_s
*s
= (struct omap_eac_s
*)
1969 qemu_mallocz(sizeof(struct omap_eac_s
));
1972 s
->codec
.rxdrq
= *drq
++;
1973 s
->codec
.txdrq
= *drq
;
1977 AUD_register_card("OMAP EAC", &s
->codec
.card
);
1979 iomemtype
= cpu_register_io_memory(omap_eac_readfn
,
1980 omap_eac_writefn
, s
);
1981 omap_l4_attach(ta
, 0, iomemtype
);
1987 /* STI/XTI (emulation interface) console - reverse engineered only */
1990 CharDriverState
*chr
;
1996 uint32_t clkcontrol
;
1997 uint32_t serial_config
;
2000 #define STI_TRACE_CONSOLE_CHANNEL 239
2001 #define STI_TRACE_CONTROL_CHANNEL 253
2003 static inline void omap_sti_interrupt_update(struct omap_sti_s
*s
)
2005 qemu_set_irq(s
->irq
, s
->irqst
& s
->irqen
);
2008 static void omap_sti_reset(struct omap_sti_s
*s
)
2014 s
->serial_config
= 0;
2016 omap_sti_interrupt_update(s
);
2019 static uint32_t omap_sti_read(void *opaque
, target_phys_addr_t addr
)
2021 struct omap_sti_s
*s
= (struct omap_sti_s
*) opaque
;
2024 case 0x00: /* STI_REVISION */
2027 case 0x10: /* STI_SYSCONFIG */
2028 return s
->sysconfig
;
2030 case 0x14: /* STI_SYSSTATUS / STI_RX_STATUS / XTI_SYSSTATUS */
2033 case 0x18: /* STI_IRQSTATUS */
2036 case 0x1c: /* STI_IRQSETEN / STI_IRQCLREN */
2039 case 0x24: /* STI_ER / STI_DR / XTI_TRACESELECT */
2040 case 0x28: /* STI_RX_DR / XTI_RXDATA */
2044 case 0x2c: /* STI_CLK_CTRL / XTI_SCLKCRTL */
2045 return s
->clkcontrol
;
2047 case 0x30: /* STI_SERIAL_CFG / XTI_SCONFIG */
2048 return s
->serial_config
;
2055 static void omap_sti_write(void *opaque
, target_phys_addr_t addr
,
2058 struct omap_sti_s
*s
= (struct omap_sti_s
*) opaque
;
2061 case 0x00: /* STI_REVISION */
2062 case 0x14: /* STI_SYSSTATUS / STI_RX_STATUS / XTI_SYSSTATUS */
2066 case 0x10: /* STI_SYSCONFIG */
2067 if (value
& (1 << 1)) /* SOFTRESET */
2069 s
->sysconfig
= value
& 0xfe;
2072 case 0x18: /* STI_IRQSTATUS */
2074 omap_sti_interrupt_update(s
);
2077 case 0x1c: /* STI_IRQSETEN / STI_IRQCLREN */
2078 s
->irqen
= value
& 0xffff;
2079 omap_sti_interrupt_update(s
);
2082 case 0x2c: /* STI_CLK_CTRL / XTI_SCLKCRTL */
2083 s
->clkcontrol
= value
& 0xff;
2086 case 0x30: /* STI_SERIAL_CFG / XTI_SCONFIG */
2087 s
->serial_config
= value
& 0xff;
2090 case 0x24: /* STI_ER / STI_DR / XTI_TRACESELECT */
2091 case 0x28: /* STI_RX_DR / XTI_RXDATA */
2101 static CPUReadMemoryFunc
* const omap_sti_readfn
[] = {
2102 omap_badwidth_read32
,
2103 omap_badwidth_read32
,
2107 static CPUWriteMemoryFunc
* const omap_sti_writefn
[] = {
2108 omap_badwidth_write32
,
2109 omap_badwidth_write32
,
2113 static uint32_t omap_sti_fifo_read(void *opaque
, target_phys_addr_t addr
)
2119 static void omap_sti_fifo_write(void *opaque
, target_phys_addr_t addr
,
2122 struct omap_sti_s
*s
= (struct omap_sti_s
*) opaque
;
2124 uint8_t byte
= value
;
2126 if (ch
== STI_TRACE_CONTROL_CHANNEL
) {
2127 /* Flush channel <i>value</i>. */
2128 qemu_chr_write(s
->chr
, (const uint8_t *) "\r", 1);
2129 } else if (ch
== STI_TRACE_CONSOLE_CHANNEL
|| 1) {
2130 if (value
== 0xc0 || value
== 0xc3) {
2131 /* Open channel <i>ch</i>. */
2132 } else if (value
== 0x00)
2133 qemu_chr_write(s
->chr
, (const uint8_t *) "\n", 1);
2135 qemu_chr_write(s
->chr
, &byte
, 1);
2139 static CPUReadMemoryFunc
* const omap_sti_fifo_readfn
[] = {
2141 omap_badwidth_read8
,
2142 omap_badwidth_read8
,
2145 static CPUWriteMemoryFunc
* const omap_sti_fifo_writefn
[] = {
2146 omap_sti_fifo_write
,
2147 omap_badwidth_write8
,
2148 omap_badwidth_write8
,
2151 static struct omap_sti_s
*omap_sti_init(struct omap_target_agent_s
*ta
,
2152 target_phys_addr_t channel_base
, qemu_irq irq
, omap_clk clk
,
2153 CharDriverState
*chr
)
2156 struct omap_sti_s
*s
= (struct omap_sti_s
*)
2157 qemu_mallocz(sizeof(struct omap_sti_s
));
2162 s
->chr
= chr
?: qemu_chr_open("null", "null", NULL
);
2164 iomemtype
= l4_register_io_memory(omap_sti_readfn
,
2165 omap_sti_writefn
, s
);
2166 omap_l4_attach(ta
, 0, iomemtype
);
2168 iomemtype
= cpu_register_io_memory(omap_sti_fifo_readfn
,
2169 omap_sti_fifo_writefn
, s
);
2170 cpu_register_physical_memory(channel_base
, 0x10000, iomemtype
);
2175 /* L4 Interconnect */
2176 struct omap_target_agent_s
{
2177 struct omap_l4_s
*bus
;
2179 struct omap_l4_region_s
*start
;
2180 target_phys_addr_t base
;
2187 target_phys_addr_t base
;
2189 struct omap_target_agent_s ta
[0];
2193 static int omap_l4_io_entries
;
2194 static int omap_cpu_io_entry
;
2195 static struct omap_l4_entry
{
2196 CPUReadMemoryFunc
* const *mem_read
;
2197 CPUWriteMemoryFunc
* const *mem_write
;
2199 } *omap_l4_io_entry
;
2200 static CPUReadMemoryFunc
* const *omap_l4_io_readb_fn
;
2201 static CPUReadMemoryFunc
* const *omap_l4_io_readh_fn
;
2202 static CPUReadMemoryFunc
* const *omap_l4_io_readw_fn
;
2203 static CPUWriteMemoryFunc
* const *omap_l4_io_writeb_fn
;
2204 static CPUWriteMemoryFunc
* const *omap_l4_io_writeh_fn
;
2205 static CPUWriteMemoryFunc
* const *omap_l4_io_writew_fn
;
2206 static void **omap_l4_io_opaque
;
2208 int l4_register_io_memory(CPUReadMemoryFunc
* const *mem_read
,
2209 CPUWriteMemoryFunc
* const *mem_write
, void *opaque
)
2211 omap_l4_io_entry
[omap_l4_io_entries
].mem_read
= mem_read
;
2212 omap_l4_io_entry
[omap_l4_io_entries
].mem_write
= mem_write
;
2213 omap_l4_io_entry
[omap_l4_io_entries
].opaque
= opaque
;
2215 return omap_l4_io_entries
++;
2218 static uint32_t omap_l4_io_readb(void *opaque
, target_phys_addr_t addr
)
2220 unsigned int i
= (addr
- OMAP2_L4_BASE
) >> TARGET_PAGE_BITS
;
2222 return omap_l4_io_readb_fn
[i
](omap_l4_io_opaque
[i
], addr
);
2225 static uint32_t omap_l4_io_readh(void *opaque
, target_phys_addr_t addr
)
2227 unsigned int i
= (addr
- OMAP2_L4_BASE
) >> TARGET_PAGE_BITS
;
2229 return omap_l4_io_readh_fn
[i
](omap_l4_io_opaque
[i
], addr
);
2232 static uint32_t omap_l4_io_readw(void *opaque
, target_phys_addr_t addr
)
2234 unsigned int i
= (addr
- OMAP2_L4_BASE
) >> TARGET_PAGE_BITS
;
2236 return omap_l4_io_readw_fn
[i
](omap_l4_io_opaque
[i
], addr
);
2239 static void omap_l4_io_writeb(void *opaque
, target_phys_addr_t addr
,
2242 unsigned int i
= (addr
- OMAP2_L4_BASE
) >> TARGET_PAGE_BITS
;
2244 return omap_l4_io_writeb_fn
[i
](omap_l4_io_opaque
[i
], addr
, value
);
2247 static void omap_l4_io_writeh(void *opaque
, target_phys_addr_t addr
,
2250 unsigned int i
= (addr
- OMAP2_L4_BASE
) >> TARGET_PAGE_BITS
;
2252 return omap_l4_io_writeh_fn
[i
](omap_l4_io_opaque
[i
], addr
, value
);
2255 static void omap_l4_io_writew(void *opaque
, target_phys_addr_t addr
,
2258 unsigned int i
= (addr
- OMAP2_L4_BASE
) >> TARGET_PAGE_BITS
;
2260 return omap_l4_io_writew_fn
[i
](omap_l4_io_opaque
[i
], addr
, value
);
2263 static CPUReadMemoryFunc
* const omap_l4_io_readfn
[] = {
2269 static CPUWriteMemoryFunc
* const omap_l4_io_writefn
[] = {
2276 struct omap_l4_s
*omap_l4_init(target_phys_addr_t base
, int ta_num
)
2278 struct omap_l4_s
*bus
= qemu_mallocz(
2279 sizeof(*bus
) + ta_num
* sizeof(*bus
->ta
));
2281 bus
->ta_num
= ta_num
;
2285 omap_l4_io_entries
= 1;
2286 omap_l4_io_entry
= qemu_mallocz(125 * sizeof(*omap_l4_io_entry
));
2289 cpu_register_io_memory(omap_l4_io_readfn
,
2290 omap_l4_io_writefn
, bus
);
2291 # define L4_PAGES (0xb4000 / TARGET_PAGE_SIZE)
2292 omap_l4_io_readb_fn
= qemu_mallocz(sizeof(void *) * L4_PAGES
);
2293 omap_l4_io_readh_fn
= qemu_mallocz(sizeof(void *) * L4_PAGES
);
2294 omap_l4_io_readw_fn
= qemu_mallocz(sizeof(void *) * L4_PAGES
);
2295 omap_l4_io_writeb_fn
= qemu_mallocz(sizeof(void *) * L4_PAGES
);
2296 omap_l4_io_writeh_fn
= qemu_mallocz(sizeof(void *) * L4_PAGES
);
2297 omap_l4_io_writew_fn
= qemu_mallocz(sizeof(void *) * L4_PAGES
);
2298 omap_l4_io_opaque
= qemu_mallocz(sizeof(void *) * L4_PAGES
);
2304 static uint32_t omap_l4ta_read(void *opaque
, target_phys_addr_t addr
)
2306 struct omap_target_agent_s
*s
= (struct omap_target_agent_s
*) opaque
;
2309 case 0x00: /* COMPONENT */
2310 return s
->component
;
2312 case 0x20: /* AGENT_CONTROL */
2315 case 0x28: /* AGENT_STATUS */
2323 static void omap_l4ta_write(void *opaque
, target_phys_addr_t addr
,
2326 struct omap_target_agent_s
*s
= (struct omap_target_agent_s
*) opaque
;
2329 case 0x00: /* COMPONENT */
2330 case 0x28: /* AGENT_STATUS */
2334 case 0x20: /* AGENT_CONTROL */
2335 s
->control
= value
& 0x01000700;
2336 if (value
& 1) /* OCP_RESET */
2337 s
->status
&= ~1; /* REQ_TIMEOUT */
2345 static CPUReadMemoryFunc
* const omap_l4ta_readfn
[] = {
2346 omap_badwidth_read16
,
2348 omap_badwidth_read16
,
2351 static CPUWriteMemoryFunc
* const omap_l4ta_writefn
[] = {
2352 omap_badwidth_write32
,
2353 omap_badwidth_write32
,
2358 #define L4TAO(n) ((n) + 39)
2360 static struct omap_l4_region_s
{
2361 target_phys_addr_t offset
;
2364 } omap_l4_region
[125] = {
2365 [ 1] = { 0x40800, 0x800, 32 }, /* Initiator agent */
2366 [ 2] = { 0x41000, 0x1000, 32 }, /* Link agent */
2367 [ 0] = { 0x40000, 0x800, 32 }, /* Address and protection */
2368 [ 3] = { 0x00000, 0x1000, 32 | 16 | 8 }, /* System Control and Pinout */
2369 [ 4] = { 0x01000, 0x1000, 32 | 16 | 8 }, /* L4TAO1 */
2370 [ 5] = { 0x04000, 0x1000, 32 | 16 }, /* 32K Timer */
2371 [ 6] = { 0x05000, 0x1000, 32 | 16 | 8 }, /* L4TAO2 */
2372 [ 7] = { 0x08000, 0x800, 32 }, /* PRCM Region A */
2373 [ 8] = { 0x08800, 0x800, 32 }, /* PRCM Region B */
2374 [ 9] = { 0x09000, 0x1000, 32 | 16 | 8 }, /* L4TAO */
2375 [ 10] = { 0x12000, 0x1000, 32 | 16 | 8 }, /* Test (BCM) */
2376 [ 11] = { 0x13000, 0x1000, 32 | 16 | 8 }, /* L4TA1 */
2377 [ 12] = { 0x14000, 0x1000, 32 }, /* Test/emulation (TAP) */
2378 [ 13] = { 0x15000, 0x1000, 32 | 16 | 8 }, /* L4TA2 */
2379 [ 14] = { 0x18000, 0x1000, 32 | 16 | 8 }, /* GPIO1 */
2380 [ 16] = { 0x1a000, 0x1000, 32 | 16 | 8 }, /* GPIO2 */
2381 [ 18] = { 0x1c000, 0x1000, 32 | 16 | 8 }, /* GPIO3 */
2382 [ 19] = { 0x1e000, 0x1000, 32 | 16 | 8 }, /* GPIO4 */
2383 [ 15] = { 0x19000, 0x1000, 32 | 16 | 8 }, /* Quad GPIO TOP */
2384 [ 17] = { 0x1b000, 0x1000, 32 | 16 | 8 }, /* L4TA3 */
2385 [ 20] = { 0x20000, 0x1000, 32 | 16 | 8 }, /* WD Timer 1 (Secure) */
2386 [ 22] = { 0x22000, 0x1000, 32 | 16 | 8 }, /* WD Timer 2 (OMAP) */
2387 [ 21] = { 0x21000, 0x1000, 32 | 16 | 8 }, /* Dual WD timer TOP */
2388 [ 23] = { 0x23000, 0x1000, 32 | 16 | 8 }, /* L4TA4 */
2389 [ 24] = { 0x28000, 0x1000, 32 | 16 | 8 }, /* GP Timer 1 */
2390 [ 25] = { 0x29000, 0x1000, 32 | 16 | 8 }, /* L4TA7 */
2391 [ 26] = { 0x48000, 0x2000, 32 | 16 | 8 }, /* Emulation (ARM11ETB) */
2392 [ 27] = { 0x4a000, 0x1000, 32 | 16 | 8 }, /* L4TA9 */
2393 [ 28] = { 0x50000, 0x400, 32 | 16 | 8 }, /* Display top */
2394 [ 29] = { 0x50400, 0x400, 32 | 16 | 8 }, /* Display control */
2395 [ 30] = { 0x50800, 0x400, 32 | 16 | 8 }, /* Display RFBI */
2396 [ 31] = { 0x50c00, 0x400, 32 | 16 | 8 }, /* Display encoder */
2397 [ 32] = { 0x51000, 0x1000, 32 | 16 | 8 }, /* L4TA10 */
2398 [ 33] = { 0x52000, 0x400, 32 | 16 | 8 }, /* Camera top */
2399 [ 34] = { 0x52400, 0x400, 32 | 16 | 8 }, /* Camera core */
2400 [ 35] = { 0x52800, 0x400, 32 | 16 | 8 }, /* Camera DMA */
2401 [ 36] = { 0x52c00, 0x400, 32 | 16 | 8 }, /* Camera MMU */
2402 [ 37] = { 0x53000, 0x1000, 32 | 16 | 8 }, /* L4TA11 */
2403 [ 38] = { 0x56000, 0x1000, 32 | 16 | 8 }, /* sDMA */
2404 [ 39] = { 0x57000, 0x1000, 32 | 16 | 8 }, /* L4TA12 */
2405 [ 40] = { 0x58000, 0x1000, 32 | 16 | 8 }, /* SSI top */
2406 [ 41] = { 0x59000, 0x1000, 32 | 16 | 8 }, /* SSI GDD */
2407 [ 42] = { 0x5a000, 0x1000, 32 | 16 | 8 }, /* SSI Port1 */
2408 [ 43] = { 0x5b000, 0x1000, 32 | 16 | 8 }, /* SSI Port2 */
2409 [ 44] = { 0x5c000, 0x1000, 32 | 16 | 8 }, /* L4TA13 */
2410 [ 45] = { 0x5e000, 0x1000, 32 | 16 | 8 }, /* USB OTG */
2411 [ 46] = { 0x5f000, 0x1000, 32 | 16 | 8 }, /* L4TAO4 */
2412 [ 47] = { 0x60000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER1SDRC) */
2413 [ 48] = { 0x61000, 0x1000, 32 | 16 | 8 }, /* L4TA14 */
2414 [ 49] = { 0x62000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER2GPMC) */
2415 [ 50] = { 0x63000, 0x1000, 32 | 16 | 8 }, /* L4TA15 */
2416 [ 51] = { 0x64000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER3OCM) */
2417 [ 52] = { 0x65000, 0x1000, 32 | 16 | 8 }, /* L4TA16 */
2418 [ 53] = { 0x66000, 0x300, 32 | 16 | 8 }, /* Emulation (WIN_TRACER4L4) */
2419 [ 54] = { 0x67000, 0x1000, 32 | 16 | 8 }, /* L4TA17 */
2420 [ 55] = { 0x68000, 0x1000, 32 | 16 | 8 }, /* Emulation (XTI) */
2421 [ 56] = { 0x69000, 0x1000, 32 | 16 | 8 }, /* L4TA18 */
2422 [ 57] = { 0x6a000, 0x1000, 16 | 8 }, /* UART1 */
2423 [ 58] = { 0x6b000, 0x1000, 32 | 16 | 8 }, /* L4TA19 */
2424 [ 59] = { 0x6c000, 0x1000, 16 | 8 }, /* UART2 */
2425 [ 60] = { 0x6d000, 0x1000, 32 | 16 | 8 }, /* L4TA20 */
2426 [ 61] = { 0x6e000, 0x1000, 16 | 8 }, /* UART3 */
2427 [ 62] = { 0x6f000, 0x1000, 32 | 16 | 8 }, /* L4TA21 */
2428 [ 63] = { 0x70000, 0x1000, 16 }, /* I2C1 */
2429 [ 64] = { 0x71000, 0x1000, 32 | 16 | 8 }, /* L4TAO5 */
2430 [ 65] = { 0x72000, 0x1000, 16 }, /* I2C2 */
2431 [ 66] = { 0x73000, 0x1000, 32 | 16 | 8 }, /* L4TAO6 */
2432 [ 67] = { 0x74000, 0x1000, 16 }, /* McBSP1 */
2433 [ 68] = { 0x75000, 0x1000, 32 | 16 | 8 }, /* L4TAO7 */
2434 [ 69] = { 0x76000, 0x1000, 16 }, /* McBSP2 */
2435 [ 70] = { 0x77000, 0x1000, 32 | 16 | 8 }, /* L4TAO8 */
2436 [ 71] = { 0x24000, 0x1000, 32 | 16 | 8 }, /* WD Timer 3 (DSP) */
2437 [ 72] = { 0x25000, 0x1000, 32 | 16 | 8 }, /* L4TA5 */
2438 [ 73] = { 0x26000, 0x1000, 32 | 16 | 8 }, /* WD Timer 4 (IVA) */
2439 [ 74] = { 0x27000, 0x1000, 32 | 16 | 8 }, /* L4TA6 */
2440 [ 75] = { 0x2a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 2 */
2441 [ 76] = { 0x2b000, 0x1000, 32 | 16 | 8 }, /* L4TA8 */
2442 [ 77] = { 0x78000, 0x1000, 32 | 16 | 8 }, /* GP Timer 3 */
2443 [ 78] = { 0x79000, 0x1000, 32 | 16 | 8 }, /* L4TA22 */
2444 [ 79] = { 0x7a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 4 */
2445 [ 80] = { 0x7b000, 0x1000, 32 | 16 | 8 }, /* L4TA23 */
2446 [ 81] = { 0x7c000, 0x1000, 32 | 16 | 8 }, /* GP Timer 5 */
2447 [ 82] = { 0x7d000, 0x1000, 32 | 16 | 8 }, /* L4TA24 */
2448 [ 83] = { 0x7e000, 0x1000, 32 | 16 | 8 }, /* GP Timer 6 */
2449 [ 84] = { 0x7f000, 0x1000, 32 | 16 | 8 }, /* L4TA25 */
2450 [ 85] = { 0x80000, 0x1000, 32 | 16 | 8 }, /* GP Timer 7 */
2451 [ 86] = { 0x81000, 0x1000, 32 | 16 | 8 }, /* L4TA26 */
2452 [ 87] = { 0x82000, 0x1000, 32 | 16 | 8 }, /* GP Timer 8 */
2453 [ 88] = { 0x83000, 0x1000, 32 | 16 | 8 }, /* L4TA27 */
2454 [ 89] = { 0x84000, 0x1000, 32 | 16 | 8 }, /* GP Timer 9 */
2455 [ 90] = { 0x85000, 0x1000, 32 | 16 | 8 }, /* L4TA28 */
2456 [ 91] = { 0x86000, 0x1000, 32 | 16 | 8 }, /* GP Timer 10 */
2457 [ 92] = { 0x87000, 0x1000, 32 | 16 | 8 }, /* L4TA29 */
2458 [ 93] = { 0x88000, 0x1000, 32 | 16 | 8 }, /* GP Timer 11 */
2459 [ 94] = { 0x89000, 0x1000, 32 | 16 | 8 }, /* L4TA30 */
2460 [ 95] = { 0x8a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 12 */
2461 [ 96] = { 0x8b000, 0x1000, 32 | 16 | 8 }, /* L4TA31 */
2462 [ 97] = { 0x90000, 0x1000, 16 }, /* EAC */
2463 [ 98] = { 0x91000, 0x1000, 32 | 16 | 8 }, /* L4TA32 */
2464 [ 99] = { 0x92000, 0x1000, 16 }, /* FAC */
2465 [100] = { 0x93000, 0x1000, 32 | 16 | 8 }, /* L4TA33 */
2466 [101] = { 0x94000, 0x1000, 32 | 16 | 8 }, /* IPC (MAILBOX) */
2467 [102] = { 0x95000, 0x1000, 32 | 16 | 8 }, /* L4TA34 */
2468 [103] = { 0x98000, 0x1000, 32 | 16 | 8 }, /* SPI1 */
2469 [104] = { 0x99000, 0x1000, 32 | 16 | 8 }, /* L4TA35 */
2470 [105] = { 0x9a000, 0x1000, 32 | 16 | 8 }, /* SPI2 */
2471 [106] = { 0x9b000, 0x1000, 32 | 16 | 8 }, /* L4TA36 */
2472 [107] = { 0x9c000, 0x1000, 16 | 8 }, /* MMC SDIO */
2473 [108] = { 0x9d000, 0x1000, 32 | 16 | 8 }, /* L4TAO9 */
2474 [109] = { 0x9e000, 0x1000, 32 | 16 | 8 }, /* MS_PRO */
2475 [110] = { 0x9f000, 0x1000, 32 | 16 | 8 }, /* L4TAO10 */
2476 [111] = { 0xa0000, 0x1000, 32 }, /* RNG */
2477 [112] = { 0xa1000, 0x1000, 32 | 16 | 8 }, /* L4TAO11 */
2478 [113] = { 0xa2000, 0x1000, 32 }, /* DES3DES */
2479 [114] = { 0xa3000, 0x1000, 32 | 16 | 8 }, /* L4TAO12 */
2480 [115] = { 0xa4000, 0x1000, 32 }, /* SHA1MD5 */
2481 [116] = { 0xa5000, 0x1000, 32 | 16 | 8 }, /* L4TAO13 */
2482 [117] = { 0xa6000, 0x1000, 32 }, /* AES */
2483 [118] = { 0xa7000, 0x1000, 32 | 16 | 8 }, /* L4TA37 */
2484 [119] = { 0xa8000, 0x2000, 32 }, /* PKA */
2485 [120] = { 0xaa000, 0x1000, 32 | 16 | 8 }, /* L4TA38 */
2486 [121] = { 0xb0000, 0x1000, 32 }, /* MG */
2487 [122] = { 0xb1000, 0x1000, 32 | 16 | 8 },
2488 [123] = { 0xb2000, 0x1000, 32 }, /* HDQ/1-Wire */
2489 [124] = { 0xb3000, 0x1000, 32 | 16 | 8 }, /* L4TA39 */
2492 static struct omap_l4_agent_info_s
{
2497 } omap_l4_agent_info
[54] = {
2498 { 0, 0, 3, 2 }, /* L4IA initiatior agent */
2499 { L4TAO(1), 3, 2, 1 }, /* Control and pinout module */
2500 { L4TAO(2), 5, 2, 1 }, /* 32K timer */
2501 { L4TAO(3), 7, 3, 2 }, /* PRCM */
2502 { L4TA(1), 10, 2, 1 }, /* BCM */
2503 { L4TA(2), 12, 2, 1 }, /* Test JTAG */
2504 { L4TA(3), 14, 6, 3 }, /* Quad GPIO */
2505 { L4TA(4), 20, 4, 3 }, /* WD timer 1/2 */
2506 { L4TA(7), 24, 2, 1 }, /* GP timer 1 */
2507 { L4TA(9), 26, 2, 1 }, /* ATM11 ETB */
2508 { L4TA(10), 28, 5, 4 }, /* Display subsystem */
2509 { L4TA(11), 33, 5, 4 }, /* Camera subsystem */
2510 { L4TA(12), 38, 2, 1 }, /* sDMA */
2511 { L4TA(13), 40, 5, 4 }, /* SSI */
2512 { L4TAO(4), 45, 2, 1 }, /* USB */
2513 { L4TA(14), 47, 2, 1 }, /* Win Tracer1 */
2514 { L4TA(15), 49, 2, 1 }, /* Win Tracer2 */
2515 { L4TA(16), 51, 2, 1 }, /* Win Tracer3 */
2516 { L4TA(17), 53, 2, 1 }, /* Win Tracer4 */
2517 { L4TA(18), 55, 2, 1 }, /* XTI */
2518 { L4TA(19), 57, 2, 1 }, /* UART1 */
2519 { L4TA(20), 59, 2, 1 }, /* UART2 */
2520 { L4TA(21), 61, 2, 1 }, /* UART3 */
2521 { L4TAO(5), 63, 2, 1 }, /* I2C1 */
2522 { L4TAO(6), 65, 2, 1 }, /* I2C2 */
2523 { L4TAO(7), 67, 2, 1 }, /* McBSP1 */
2524 { L4TAO(8), 69, 2, 1 }, /* McBSP2 */
2525 { L4TA(5), 71, 2, 1 }, /* WD Timer 3 (DSP) */
2526 { L4TA(6), 73, 2, 1 }, /* WD Timer 4 (IVA) */
2527 { L4TA(8), 75, 2, 1 }, /* GP Timer 2 */
2528 { L4TA(22), 77, 2, 1 }, /* GP Timer 3 */
2529 { L4TA(23), 79, 2, 1 }, /* GP Timer 4 */
2530 { L4TA(24), 81, 2, 1 }, /* GP Timer 5 */
2531 { L4TA(25), 83, 2, 1 }, /* GP Timer 6 */
2532 { L4TA(26), 85, 2, 1 }, /* GP Timer 7 */
2533 { L4TA(27), 87, 2, 1 }, /* GP Timer 8 */
2534 { L4TA(28), 89, 2, 1 }, /* GP Timer 9 */
2535 { L4TA(29), 91, 2, 1 }, /* GP Timer 10 */
2536 { L4TA(30), 93, 2, 1 }, /* GP Timer 11 */
2537 { L4TA(31), 95, 2, 1 }, /* GP Timer 12 */
2538 { L4TA(32), 97, 2, 1 }, /* EAC */
2539 { L4TA(33), 99, 2, 1 }, /* FAC */
2540 { L4TA(34), 101, 2, 1 }, /* IPC */
2541 { L4TA(35), 103, 2, 1 }, /* SPI1 */
2542 { L4TA(36), 105, 2, 1 }, /* SPI2 */
2543 { L4TAO(9), 107, 2, 1 }, /* MMC SDIO */
2544 { L4TAO(10), 109, 2, 1 },
2545 { L4TAO(11), 111, 2, 1 }, /* RNG */
2546 { L4TAO(12), 113, 2, 1 }, /* DES3DES */
2547 { L4TAO(13), 115, 2, 1 }, /* SHA1MD5 */
2548 { L4TA(37), 117, 2, 1 }, /* AES */
2549 { L4TA(38), 119, 2, 1 }, /* PKA */
2551 { L4TA(39), 123, 2, 1 }, /* HDQ/1-Wire */
2554 #define omap_l4ta(bus, cs) omap_l4ta_get(bus, L4TA(cs))
2555 #define omap_l4tao(bus, cs) omap_l4ta_get(bus, L4TAO(cs))
2557 struct omap_target_agent_s
*omap_l4ta_get(struct omap_l4_s
*bus
, int cs
)
2560 struct omap_target_agent_s
*ta
= NULL
;
2561 struct omap_l4_agent_info_s
*info
= NULL
;
2563 for (i
= 0; i
< bus
->ta_num
; i
++)
2564 if (omap_l4_agent_info
[i
].ta
== cs
) {
2566 info
= &omap_l4_agent_info
[i
];
2570 fprintf(stderr
, "%s: bad target agent (%i)\n", __FUNCTION__
, cs
);
2575 ta
->start
= &omap_l4_region
[info
->region
];
2576 ta
->regions
= info
->regions
;
2578 ta
->component
= ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
2579 ta
->status
= 0x00000000;
2580 ta
->control
= 0x00000200; /* XXX 01000200 for L4TAO */
2582 iomemtype
= l4_register_io_memory(omap_l4ta_readfn
,
2583 omap_l4ta_writefn
, ta
);
2584 ta
->base
= omap_l4_attach(ta
, info
->ta_region
, iomemtype
);
2589 target_phys_addr_t
omap_l4_attach(struct omap_target_agent_s
*ta
, int region
,
2592 target_phys_addr_t base
;
2598 if (region
< 0 || region
>= ta
->regions
) {
2599 fprintf(stderr
, "%s: bad io region (%i)\n", __FUNCTION__
, region
);
2603 base
= ta
->bus
->base
+ ta
->start
[region
].offset
;
2604 size
= ta
->start
[region
].size
;
2607 cpu_register_physical_memory(base
, size
, iotype
);
2609 cpu_register_physical_memory(base
, size
, omap_cpu_io_entry
);
2610 i
= (base
- ta
->bus
->base
) / TARGET_PAGE_SIZE
;
2611 for (; size
> 0; size
-= TARGET_PAGE_SIZE
, i
++) {
2612 omap_l4_io_readb_fn
[i
] = omap_l4_io_entry
[iotype
].mem_read
[0];
2613 omap_l4_io_readh_fn
[i
] = omap_l4_io_entry
[iotype
].mem_read
[1];
2614 omap_l4_io_readw_fn
[i
] = omap_l4_io_entry
[iotype
].mem_read
[2];
2615 omap_l4_io_writeb_fn
[i
] = omap_l4_io_entry
[iotype
].mem_write
[0];
2616 omap_l4_io_writeh_fn
[i
] = omap_l4_io_entry
[iotype
].mem_write
[1];
2617 omap_l4_io_writew_fn
[i
] = omap_l4_io_entry
[iotype
].mem_write
[2];
2618 omap_l4_io_opaque
[i
] = omap_l4_io_entry
[iotype
].opaque
;
2626 /* TEST-Chip-level TAP */
2627 static uint32_t omap_tap_read(void *opaque
, target_phys_addr_t addr
)
2629 struct omap_mpu_state_s
*s
= (struct omap_mpu_state_s
*) opaque
;
2632 case 0x204: /* IDCODE_reg */
2633 switch (s
->mpu_model
) {
2637 return 0x5b5d902f; /* ES 2.2 */
2639 return 0x5b68a02f; /* ES 2.2 */
2641 return 0x1b7ae02f; /* ES 2 */
2643 hw_error("%s: Bad mpu model\n", __FUNCTION__
);
2646 case 0x208: /* PRODUCTION_ID_reg for OMAP2 */
2647 case 0x210: /* PRODUCTION_ID_reg for OMAP3 */
2648 switch (s
->mpu_model
) {
2650 return 0x000254f0; /* POP ESHS2.1.1 in N91/93/95, ES2 in N800 */
2660 hw_error("%s: Bad mpu model\n", __FUNCTION__
);
2664 switch (s
->mpu_model
) {
2668 return 0xcafeb5d9; /* ES 2.2 */
2670 return 0xcafeb68a; /* ES 2.2 */
2672 return 0xcafeb7ae; /* ES 2 */
2674 hw_error("%s: Bad mpu model\n", __FUNCTION__
);
2677 case 0x218: /* DIE_ID_reg */
2678 return ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
2679 case 0x21c: /* DIE_ID_reg */
2681 case 0x220: /* DIE_ID_reg */
2682 return ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
2683 case 0x224: /* DIE_ID_reg */
2684 return ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
2691 static void omap_tap_write(void *opaque
, target_phys_addr_t addr
,
2697 static CPUReadMemoryFunc
* const omap_tap_readfn
[] = {
2698 omap_badwidth_read32
,
2699 omap_badwidth_read32
,
2703 static CPUWriteMemoryFunc
* const omap_tap_writefn
[] = {
2704 omap_badwidth_write32
,
2705 omap_badwidth_write32
,
2709 void omap_tap_init(struct omap_target_agent_s
*ta
,
2710 struct omap_mpu_state_s
*mpu
)
2712 omap_l4_attach(ta
, 0, l4_register_io_memory(
2713 omap_tap_readfn
, omap_tap_writefn
, mpu
));
2716 /* Power, Reset, and Clock Management */
2717 struct omap_prcm_s
{
2719 struct omap_mpu_state_s
*mpu
;
2726 uint32_t scratch
[20];
2730 uint32_t clkemul
[1];
2734 uint32_t clkctrl
[4];
2735 uint32_t clkidle
[7];
2736 uint32_t setuptime
[2];
2742 uint32_t rstctrl
[1];
2744 uint32_t rsttime_wkup
;
2749 int dpll_lock
, apll_lock
[2];
2752 static void omap_prcm_int_update(struct omap_prcm_s
*s
, int dom
)
2754 qemu_set_irq(s
->irq
[dom
], s
->irqst
[dom
] & s
->irqen
[dom
]);
2755 /* XXX or is the mask applied before PRCM_IRQSTATUS_* ? */
2758 static uint32_t omap_prcm_read(void *opaque
, target_phys_addr_t addr
)
2760 struct omap_prcm_s
*s
= (struct omap_prcm_s
*) opaque
;
2764 case 0x000: /* PRCM_REVISION */
2767 case 0x010: /* PRCM_SYSCONFIG */
2768 return s
->sysconfig
;
2770 case 0x018: /* PRCM_IRQSTATUS_MPU */
2773 case 0x01c: /* PRCM_IRQENABLE_MPU */
2776 case 0x050: /* PRCM_VOLTCTRL */
2778 case 0x054: /* PRCM_VOLTST */
2779 return s
->voltctrl
& 3;
2781 case 0x060: /* PRCM_CLKSRC_CTRL */
2782 return s
->clksrc
[0];
2783 case 0x070: /* PRCM_CLKOUT_CTRL */
2784 return s
->clkout
[0];
2785 case 0x078: /* PRCM_CLKEMUL_CTRL */
2786 return s
->clkemul
[0];
2787 case 0x080: /* PRCM_CLKCFG_CTRL */
2788 case 0x084: /* PRCM_CLKCFG_STATUS */
2791 case 0x090: /* PRCM_VOLTSETUP */
2792 return s
->setuptime
[0];
2794 case 0x094: /* PRCM_CLKSSETUP */
2795 return s
->setuptime
[1];
2797 case 0x098: /* PRCM_POLCTRL */
2798 return s
->clkpol
[0];
2800 case 0x0b0: /* GENERAL_PURPOSE1 */
2801 case 0x0b4: /* GENERAL_PURPOSE2 */
2802 case 0x0b8: /* GENERAL_PURPOSE3 */
2803 case 0x0bc: /* GENERAL_PURPOSE4 */
2804 case 0x0c0: /* GENERAL_PURPOSE5 */
2805 case 0x0c4: /* GENERAL_PURPOSE6 */
2806 case 0x0c8: /* GENERAL_PURPOSE7 */
2807 case 0x0cc: /* GENERAL_PURPOSE8 */
2808 case 0x0d0: /* GENERAL_PURPOSE9 */
2809 case 0x0d4: /* GENERAL_PURPOSE10 */
2810 case 0x0d8: /* GENERAL_PURPOSE11 */
2811 case 0x0dc: /* GENERAL_PURPOSE12 */
2812 case 0x0e0: /* GENERAL_PURPOSE13 */
2813 case 0x0e4: /* GENERAL_PURPOSE14 */
2814 case 0x0e8: /* GENERAL_PURPOSE15 */
2815 case 0x0ec: /* GENERAL_PURPOSE16 */
2816 case 0x0f0: /* GENERAL_PURPOSE17 */
2817 case 0x0f4: /* GENERAL_PURPOSE18 */
2818 case 0x0f8: /* GENERAL_PURPOSE19 */
2819 case 0x0fc: /* GENERAL_PURPOSE20 */
2820 return s
->scratch
[(addr
- 0xb0) >> 2];
2822 case 0x140: /* CM_CLKSEL_MPU */
2823 return s
->clksel
[0];
2824 case 0x148: /* CM_CLKSTCTRL_MPU */
2825 return s
->clkctrl
[0];
2827 case 0x158: /* RM_RSTST_MPU */
2829 case 0x1c8: /* PM_WKDEP_MPU */
2831 case 0x1d4: /* PM_EVGENCTRL_MPU */
2833 case 0x1d8: /* PM_EVEGENONTIM_MPU */
2834 return s
->evtime
[0];
2835 case 0x1dc: /* PM_EVEGENOFFTIM_MPU */
2836 return s
->evtime
[1];
2837 case 0x1e0: /* PM_PWSTCTRL_MPU */
2839 case 0x1e4: /* PM_PWSTST_MPU */
2842 case 0x200: /* CM_FCLKEN1_CORE */
2844 case 0x204: /* CM_FCLKEN2_CORE */
2846 case 0x210: /* CM_ICLKEN1_CORE */
2848 case 0x214: /* CM_ICLKEN2_CORE */
2850 case 0x21c: /* CM_ICLKEN4_CORE */
2853 case 0x220: /* CM_IDLEST1_CORE */
2854 /* TODO: check the actual iclk status */
2856 case 0x224: /* CM_IDLEST2_CORE */
2857 /* TODO: check the actual iclk status */
2859 case 0x22c: /* CM_IDLEST4_CORE */
2860 /* TODO: check the actual iclk status */
2863 case 0x230: /* CM_AUTOIDLE1_CORE */
2864 return s
->clkidle
[0];
2865 case 0x234: /* CM_AUTOIDLE2_CORE */
2866 return s
->clkidle
[1];
2867 case 0x238: /* CM_AUTOIDLE3_CORE */
2868 return s
->clkidle
[2];
2869 case 0x23c: /* CM_AUTOIDLE4_CORE */
2870 return s
->clkidle
[3];
2872 case 0x240: /* CM_CLKSEL1_CORE */
2873 return s
->clksel
[1];
2874 case 0x244: /* CM_CLKSEL2_CORE */
2875 return s
->clksel
[2];
2877 case 0x248: /* CM_CLKSTCTRL_CORE */
2878 return s
->clkctrl
[1];
2880 case 0x2a0: /* PM_WKEN1_CORE */
2882 case 0x2a4: /* PM_WKEN2_CORE */
2885 case 0x2b0: /* PM_WKST1_CORE */
2887 case 0x2b4: /* PM_WKST2_CORE */
2889 case 0x2c8: /* PM_WKDEP_CORE */
2892 case 0x2e0: /* PM_PWSTCTRL_CORE */
2894 case 0x2e4: /* PM_PWSTST_CORE */
2895 return 0x000030 | (s
->power
[1] & 0xfc00);
2897 case 0x300: /* CM_FCLKEN_GFX */
2899 case 0x310: /* CM_ICLKEN_GFX */
2901 case 0x320: /* CM_IDLEST_GFX */
2902 /* TODO: check the actual iclk status */
2904 case 0x340: /* CM_CLKSEL_GFX */
2905 return s
->clksel
[3];
2906 case 0x348: /* CM_CLKSTCTRL_GFX */
2907 return s
->clkctrl
[2];
2908 case 0x350: /* RM_RSTCTRL_GFX */
2909 return s
->rstctrl
[0];
2910 case 0x358: /* RM_RSTST_GFX */
2912 case 0x3c8: /* PM_WKDEP_GFX */
2915 case 0x3e0: /* PM_PWSTCTRL_GFX */
2917 case 0x3e4: /* PM_PWSTST_GFX */
2918 return s
->power
[2] & 3;
2920 case 0x400: /* CM_FCLKEN_WKUP */
2922 case 0x410: /* CM_ICLKEN_WKUP */
2924 case 0x420: /* CM_IDLEST_WKUP */
2925 /* TODO: check the actual iclk status */
2927 case 0x430: /* CM_AUTOIDLE_WKUP */
2928 return s
->clkidle
[4];
2929 case 0x440: /* CM_CLKSEL_WKUP */
2930 return s
->clksel
[4];
2931 case 0x450: /* RM_RSTCTRL_WKUP */
2933 case 0x454: /* RM_RSTTIME_WKUP */
2934 return s
->rsttime_wkup
;
2935 case 0x458: /* RM_RSTST_WKUP */
2937 case 0x4a0: /* PM_WKEN_WKUP */
2939 case 0x4b0: /* PM_WKST_WKUP */
2942 case 0x500: /* CM_CLKEN_PLL */
2944 case 0x520: /* CM_IDLEST_CKGEN */
2945 ret
= 0x0000070 | (s
->apll_lock
[0] << 9) | (s
->apll_lock
[1] << 8);
2946 if (!(s
->clksel
[6] & 3))
2947 /* Core uses 32-kHz clock */
2949 else if (!s
->dpll_lock
)
2950 /* DPLL not locked, core uses ref_clk */
2953 /* Core uses DPLL */
2956 case 0x530: /* CM_AUTOIDLE_PLL */
2957 return s
->clkidle
[5];
2958 case 0x540: /* CM_CLKSEL1_PLL */
2959 return s
->clksel
[5];
2960 case 0x544: /* CM_CLKSEL2_PLL */
2961 return s
->clksel
[6];
2963 case 0x800: /* CM_FCLKEN_DSP */
2964 return s
->clken
[10];
2965 case 0x810: /* CM_ICLKEN_DSP */
2966 return s
->clken
[11];
2967 case 0x820: /* CM_IDLEST_DSP */
2968 /* TODO: check the actual iclk status */
2970 case 0x830: /* CM_AUTOIDLE_DSP */
2971 return s
->clkidle
[6];
2972 case 0x840: /* CM_CLKSEL_DSP */
2973 return s
->clksel
[7];
2974 case 0x848: /* CM_CLKSTCTRL_DSP */
2975 return s
->clkctrl
[3];
2976 case 0x850: /* RM_RSTCTRL_DSP */
2978 case 0x858: /* RM_RSTST_DSP */
2980 case 0x8c8: /* PM_WKDEP_DSP */
2982 case 0x8e0: /* PM_PWSTCTRL_DSP */
2984 case 0x8e4: /* PM_PWSTST_DSP */
2985 return 0x008030 | (s
->power
[3] & 0x3003);
2987 case 0x8f0: /* PRCM_IRQSTATUS_DSP */
2989 case 0x8f4: /* PRCM_IRQENABLE_DSP */
2992 case 0x8f8: /* PRCM_IRQSTATUS_IVA */
2994 case 0x8fc: /* PRCM_IRQENABLE_IVA */
3002 static void omap_prcm_apll_update(struct omap_prcm_s
*s
)
3006 mode
[0] = (s
->clken
[9] >> 6) & 3;
3007 s
->apll_lock
[0] = (mode
[0] == 3);
3008 mode
[1] = (s
->clken
[9] >> 2) & 3;
3009 s
->apll_lock
[1] = (mode
[1] == 3);
3010 /* TODO: update clocks */
3012 if (mode
[0] == 1 || mode
[0] == 2 || mode
[1] == 1 || mode
[1] == 2)
3013 fprintf(stderr
, "%s: bad EN_54M_PLL or bad EN_96M_PLL\n",
3017 static void omap_prcm_dpll_update(struct omap_prcm_s
*s
)
3019 omap_clk dpll
= omap_findclk(s
->mpu
, "dpll");
3020 omap_clk dpll_x2
= omap_findclk(s
->mpu
, "dpll");
3021 omap_clk core
= omap_findclk(s
->mpu
, "core_clk");
3022 int mode
= (s
->clken
[9] >> 0) & 3;
3025 mult
= (s
->clksel
[5] >> 12) & 0x3ff;
3026 div
= (s
->clksel
[5] >> 8) & 0xf;
3027 if (mult
== 0 || mult
== 1)
3028 mode
= 1; /* Bypass */
3033 fprintf(stderr
, "%s: bad EN_DPLL\n", __FUNCTION__
);
3035 case 1: /* Low-power bypass mode (Default) */
3036 case 2: /* Fast-relock bypass mode */
3037 omap_clk_setrate(dpll
, 1, 1);
3038 omap_clk_setrate(dpll_x2
, 1, 1);
3040 case 3: /* Lock mode */
3041 s
->dpll_lock
= 1; /* After 20 FINT cycles (ref_clk / (div + 1)). */
3043 omap_clk_setrate(dpll
, div
+ 1, mult
);
3044 omap_clk_setrate(dpll_x2
, div
+ 1, mult
* 2);
3048 switch ((s
->clksel
[6] >> 0) & 3) {
3050 omap_clk_reparent(core
, omap_findclk(s
->mpu
, "clk32-kHz"));
3053 omap_clk_reparent(core
, dpll
);
3057 omap_clk_reparent(core
, dpll_x2
);
3060 fprintf(stderr
, "%s: bad CORE_CLK_SRC\n", __FUNCTION__
);
3065 static void omap_prcm_write(void *opaque
, target_phys_addr_t addr
,
3068 struct omap_prcm_s
*s
= (struct omap_prcm_s
*) opaque
;
3071 case 0x000: /* PRCM_REVISION */
3072 case 0x054: /* PRCM_VOLTST */
3073 case 0x084: /* PRCM_CLKCFG_STATUS */
3074 case 0x1e4: /* PM_PWSTST_MPU */
3075 case 0x220: /* CM_IDLEST1_CORE */
3076 case 0x224: /* CM_IDLEST2_CORE */
3077 case 0x22c: /* CM_IDLEST4_CORE */
3078 case 0x2c8: /* PM_WKDEP_CORE */
3079 case 0x2e4: /* PM_PWSTST_CORE */
3080 case 0x320: /* CM_IDLEST_GFX */
3081 case 0x3e4: /* PM_PWSTST_GFX */
3082 case 0x420: /* CM_IDLEST_WKUP */
3083 case 0x520: /* CM_IDLEST_CKGEN */
3084 case 0x820: /* CM_IDLEST_DSP */
3085 case 0x8e4: /* PM_PWSTST_DSP */
3089 case 0x010: /* PRCM_SYSCONFIG */
3090 s
->sysconfig
= value
& 1;
3093 case 0x018: /* PRCM_IRQSTATUS_MPU */
3094 s
->irqst
[0] &= ~value
;
3095 omap_prcm_int_update(s
, 0);
3097 case 0x01c: /* PRCM_IRQENABLE_MPU */
3098 s
->irqen
[0] = value
& 0x3f;
3099 omap_prcm_int_update(s
, 0);
3102 case 0x050: /* PRCM_VOLTCTRL */
3103 s
->voltctrl
= value
& 0xf1c3;
3106 case 0x060: /* PRCM_CLKSRC_CTRL */
3107 s
->clksrc
[0] = value
& 0xdb;
3108 /* TODO update clocks */
3111 case 0x070: /* PRCM_CLKOUT_CTRL */
3112 s
->clkout
[0] = value
& 0xbbbb;
3113 /* TODO update clocks */
3116 case 0x078: /* PRCM_CLKEMUL_CTRL */
3117 s
->clkemul
[0] = value
& 1;
3118 /* TODO update clocks */
3121 case 0x080: /* PRCM_CLKCFG_CTRL */
3124 case 0x090: /* PRCM_VOLTSETUP */
3125 s
->setuptime
[0] = value
& 0xffff;
3127 case 0x094: /* PRCM_CLKSSETUP */
3128 s
->setuptime
[1] = value
& 0xffff;
3131 case 0x098: /* PRCM_POLCTRL */
3132 s
->clkpol
[0] = value
& 0x701;
3135 case 0x0b0: /* GENERAL_PURPOSE1 */
3136 case 0x0b4: /* GENERAL_PURPOSE2 */
3137 case 0x0b8: /* GENERAL_PURPOSE3 */
3138 case 0x0bc: /* GENERAL_PURPOSE4 */
3139 case 0x0c0: /* GENERAL_PURPOSE5 */
3140 case 0x0c4: /* GENERAL_PURPOSE6 */
3141 case 0x0c8: /* GENERAL_PURPOSE7 */
3142 case 0x0cc: /* GENERAL_PURPOSE8 */
3143 case 0x0d0: /* GENERAL_PURPOSE9 */
3144 case 0x0d4: /* GENERAL_PURPOSE10 */
3145 case 0x0d8: /* GENERAL_PURPOSE11 */
3146 case 0x0dc: /* GENERAL_PURPOSE12 */
3147 case 0x0e0: /* GENERAL_PURPOSE13 */
3148 case 0x0e4: /* GENERAL_PURPOSE14 */
3149 case 0x0e8: /* GENERAL_PURPOSE15 */
3150 case 0x0ec: /* GENERAL_PURPOSE16 */
3151 case 0x0f0: /* GENERAL_PURPOSE17 */
3152 case 0x0f4: /* GENERAL_PURPOSE18 */
3153 case 0x0f8: /* GENERAL_PURPOSE19 */
3154 case 0x0fc: /* GENERAL_PURPOSE20 */
3155 s
->scratch
[(addr
- 0xb0) >> 2] = value
;
3158 case 0x140: /* CM_CLKSEL_MPU */
3159 s
->clksel
[0] = value
& 0x1f;
3160 /* TODO update clocks */
3162 case 0x148: /* CM_CLKSTCTRL_MPU */
3163 s
->clkctrl
[0] = value
& 0x1f;
3166 case 0x158: /* RM_RSTST_MPU */
3167 s
->rst
[0] &= ~value
;
3169 case 0x1c8: /* PM_WKDEP_MPU */
3170 s
->wkup
[0] = value
& 0x15;
3173 case 0x1d4: /* PM_EVGENCTRL_MPU */
3174 s
->ev
= value
& 0x1f;
3176 case 0x1d8: /* PM_EVEGENONTIM_MPU */
3177 s
->evtime
[0] = value
;
3179 case 0x1dc: /* PM_EVEGENOFFTIM_MPU */
3180 s
->evtime
[1] = value
;
3183 case 0x1e0: /* PM_PWSTCTRL_MPU */
3184 s
->power
[0] = value
& 0xc0f;
3187 case 0x200: /* CM_FCLKEN1_CORE */
3188 s
->clken
[0] = value
& 0xbfffffff;
3189 /* TODO update clocks */
3190 /* The EN_EAC bit only gets/puts func_96m_clk. */
3192 case 0x204: /* CM_FCLKEN2_CORE */
3193 s
->clken
[1] = value
& 0x00000007;
3194 /* TODO update clocks */
3196 case 0x210: /* CM_ICLKEN1_CORE */
3197 s
->clken
[2] = value
& 0xfffffff9;
3198 /* TODO update clocks */
3199 /* The EN_EAC bit only gets/puts core_l4_iclk. */
3201 case 0x214: /* CM_ICLKEN2_CORE */
3202 s
->clken
[3] = value
& 0x00000007;
3203 /* TODO update clocks */
3205 case 0x21c: /* CM_ICLKEN4_CORE */
3206 s
->clken
[4] = value
& 0x0000001f;
3207 /* TODO update clocks */
3210 case 0x230: /* CM_AUTOIDLE1_CORE */
3211 s
->clkidle
[0] = value
& 0xfffffff9;
3212 /* TODO update clocks */
3214 case 0x234: /* CM_AUTOIDLE2_CORE */
3215 s
->clkidle
[1] = value
& 0x00000007;
3216 /* TODO update clocks */
3218 case 0x238: /* CM_AUTOIDLE3_CORE */
3219 s
->clkidle
[2] = value
& 0x00000007;
3220 /* TODO update clocks */
3222 case 0x23c: /* CM_AUTOIDLE4_CORE */
3223 s
->clkidle
[3] = value
& 0x0000001f;
3224 /* TODO update clocks */
3227 case 0x240: /* CM_CLKSEL1_CORE */
3228 s
->clksel
[1] = value
& 0x0fffbf7f;
3229 /* TODO update clocks */
3232 case 0x244: /* CM_CLKSEL2_CORE */
3233 s
->clksel
[2] = value
& 0x00fffffc;
3234 /* TODO update clocks */
3237 case 0x248: /* CM_CLKSTCTRL_CORE */
3238 s
->clkctrl
[1] = value
& 0x7;
3241 case 0x2a0: /* PM_WKEN1_CORE */
3242 s
->wken
[0] = value
& 0x04667ff8;
3244 case 0x2a4: /* PM_WKEN2_CORE */
3245 s
->wken
[1] = value
& 0x00000005;
3248 case 0x2b0: /* PM_WKST1_CORE */
3249 s
->wkst
[0] &= ~value
;
3251 case 0x2b4: /* PM_WKST2_CORE */
3252 s
->wkst
[1] &= ~value
;
3255 case 0x2e0: /* PM_PWSTCTRL_CORE */
3256 s
->power
[1] = (value
& 0x00fc3f) | (1 << 2);
3259 case 0x300: /* CM_FCLKEN_GFX */
3260 s
->clken
[5] = value
& 6;
3261 /* TODO update clocks */
3263 case 0x310: /* CM_ICLKEN_GFX */
3264 s
->clken
[6] = value
& 1;
3265 /* TODO update clocks */
3267 case 0x340: /* CM_CLKSEL_GFX */
3268 s
->clksel
[3] = value
& 7;
3269 /* TODO update clocks */
3271 case 0x348: /* CM_CLKSTCTRL_GFX */
3272 s
->clkctrl
[2] = value
& 1;
3274 case 0x350: /* RM_RSTCTRL_GFX */
3275 s
->rstctrl
[0] = value
& 1;
3278 case 0x358: /* RM_RSTST_GFX */
3279 s
->rst
[1] &= ~value
;
3281 case 0x3c8: /* PM_WKDEP_GFX */
3282 s
->wkup
[1] = value
& 0x13;
3284 case 0x3e0: /* PM_PWSTCTRL_GFX */
3285 s
->power
[2] = (value
& 0x00c0f) | (3 << 2);
3288 case 0x400: /* CM_FCLKEN_WKUP */
3289 s
->clken
[7] = value
& 0xd;
3290 /* TODO update clocks */
3292 case 0x410: /* CM_ICLKEN_WKUP */
3293 s
->clken
[8] = value
& 0x3f;
3294 /* TODO update clocks */
3296 case 0x430: /* CM_AUTOIDLE_WKUP */
3297 s
->clkidle
[4] = value
& 0x0000003f;
3298 /* TODO update clocks */
3300 case 0x440: /* CM_CLKSEL_WKUP */
3301 s
->clksel
[4] = value
& 3;
3302 /* TODO update clocks */
3304 case 0x450: /* RM_RSTCTRL_WKUP */
3307 qemu_system_reset_request();
3309 case 0x454: /* RM_RSTTIME_WKUP */
3310 s
->rsttime_wkup
= value
& 0x1fff;
3312 case 0x458: /* RM_RSTST_WKUP */
3313 s
->rst
[2] &= ~value
;
3315 case 0x4a0: /* PM_WKEN_WKUP */
3316 s
->wken
[2] = value
& 0x00000005;
3318 case 0x4b0: /* PM_WKST_WKUP */
3319 s
->wkst
[2] &= ~value
;
3322 case 0x500: /* CM_CLKEN_PLL */
3323 if (value
& 0xffffff30)
3324 fprintf(stderr
, "%s: write 0s in CM_CLKEN_PLL for "
3325 "future compatiblity\n", __FUNCTION__
);
3326 if ((s
->clken
[9] ^ value
) & 0xcc) {
3327 s
->clken
[9] &= ~0xcc;
3328 s
->clken
[9] |= value
& 0xcc;
3329 omap_prcm_apll_update(s
);
3331 if ((s
->clken
[9] ^ value
) & 3) {
3333 s
->clken
[9] |= value
& 3;
3334 omap_prcm_dpll_update(s
);
3337 case 0x530: /* CM_AUTOIDLE_PLL */
3338 s
->clkidle
[5] = value
& 0x000000cf;
3339 /* TODO update clocks */
3341 case 0x540: /* CM_CLKSEL1_PLL */
3342 if (value
& 0xfc4000d7)
3343 fprintf(stderr
, "%s: write 0s in CM_CLKSEL1_PLL for "
3344 "future compatiblity\n", __FUNCTION__
);
3345 if ((s
->clksel
[5] ^ value
) & 0x003fff00) {
3346 s
->clksel
[5] = value
& 0x03bfff28;
3347 omap_prcm_dpll_update(s
);
3349 /* TODO update the other clocks */
3351 s
->clksel
[5] = value
& 0x03bfff28;
3353 case 0x544: /* CM_CLKSEL2_PLL */
3355 fprintf(stderr
, "%s: write 0s in CM_CLKSEL2_PLL[31:2] for "
3356 "future compatiblity\n", __FUNCTION__
);
3357 if (s
->clksel
[6] != (value
& 3)) {
3358 s
->clksel
[6] = value
& 3;
3359 omap_prcm_dpll_update(s
);
3363 case 0x800: /* CM_FCLKEN_DSP */
3364 s
->clken
[10] = value
& 0x501;
3365 /* TODO update clocks */
3367 case 0x810: /* CM_ICLKEN_DSP */
3368 s
->clken
[11] = value
& 0x2;
3369 /* TODO update clocks */
3371 case 0x830: /* CM_AUTOIDLE_DSP */
3372 s
->clkidle
[6] = value
& 0x2;
3373 /* TODO update clocks */
3375 case 0x840: /* CM_CLKSEL_DSP */
3376 s
->clksel
[7] = value
& 0x3fff;
3377 /* TODO update clocks */
3379 case 0x848: /* CM_CLKSTCTRL_DSP */
3380 s
->clkctrl
[3] = value
& 0x101;
3382 case 0x850: /* RM_RSTCTRL_DSP */
3385 case 0x858: /* RM_RSTST_DSP */
3386 s
->rst
[3] &= ~value
;
3388 case 0x8c8: /* PM_WKDEP_DSP */
3389 s
->wkup
[2] = value
& 0x13;
3391 case 0x8e0: /* PM_PWSTCTRL_DSP */
3392 s
->power
[3] = (value
& 0x03017) | (3 << 2);
3395 case 0x8f0: /* PRCM_IRQSTATUS_DSP */
3396 s
->irqst
[1] &= ~value
;
3397 omap_prcm_int_update(s
, 1);
3399 case 0x8f4: /* PRCM_IRQENABLE_DSP */
3400 s
->irqen
[1] = value
& 0x7;
3401 omap_prcm_int_update(s
, 1);
3404 case 0x8f8: /* PRCM_IRQSTATUS_IVA */
3405 s
->irqst
[2] &= ~value
;
3406 omap_prcm_int_update(s
, 2);
3408 case 0x8fc: /* PRCM_IRQENABLE_IVA */
3409 s
->irqen
[2] = value
& 0x7;
3410 omap_prcm_int_update(s
, 2);
3419 static CPUReadMemoryFunc
* const omap_prcm_readfn
[] = {
3420 omap_badwidth_read32
,
3421 omap_badwidth_read32
,
3425 static CPUWriteMemoryFunc
* const omap_prcm_writefn
[] = {
3426 omap_badwidth_write32
,
3427 omap_badwidth_write32
,
3431 static void omap_prcm_reset(struct omap_prcm_s
*s
)
3440 s
->voltctrl
= 0x1040;
3462 s
->clkidle
[5] = 0x0c;
3464 s
->clksel
[0] = 0x01;
3465 s
->clksel
[1] = 0x02100121;
3466 s
->clksel
[2] = 0x00000000;
3467 s
->clksel
[3] = 0x01;
3469 s
->clksel
[7] = 0x0121;
3473 s
->wken
[0] = 0x04667ff8;
3474 s
->wken
[1] = 0x00000005;
3479 s
->power
[0] = 0x00c;
3481 s
->power
[2] = 0x0000c;
3485 omap_prcm_apll_update(s
);
3486 omap_prcm_dpll_update(s
);
3489 static void omap_prcm_coldreset(struct omap_prcm_s
*s
)
3491 s
->setuptime
[0] = 0;
3492 s
->setuptime
[1] = 0;
3493 memset(&s
->scratch
, 0, sizeof(s
->scratch
));
3502 s
->clksrc
[0] = 0x43;
3503 s
->clkout
[0] = 0x0303;
3505 s
->clkpol
[0] = 0x100;
3506 s
->rsttime_wkup
= 0x1002;
3511 struct omap_prcm_s
*omap_prcm_init(struct omap_target_agent_s
*ta
,
3512 qemu_irq mpu_int
, qemu_irq dsp_int
, qemu_irq iva_int
,
3513 struct omap_mpu_state_s
*mpu
)
3516 struct omap_prcm_s
*s
= (struct omap_prcm_s
*)
3517 qemu_mallocz(sizeof(struct omap_prcm_s
));
3519 s
->irq
[0] = mpu_int
;
3520 s
->irq
[1] = dsp_int
;
3521 s
->irq
[2] = iva_int
;
3523 omap_prcm_coldreset(s
);
3525 iomemtype
= l4_register_io_memory(omap_prcm_readfn
,
3526 omap_prcm_writefn
, s
);
3527 omap_l4_attach(ta
, 0, iomemtype
);
3528 omap_l4_attach(ta
, 1, iomemtype
);
3533 /* System and Pinout control */
3534 struct omap_sysctl_s
{
3535 struct omap_mpu_state_s
*mpu
;
3540 uint32_t padconf
[0x45];
3542 uint32_t msuspendmux
[5];
3545 static uint32_t omap_sysctl_read8(void *opaque
, target_phys_addr_t addr
)
3548 struct omap_sysctl_s
*s
= (struct omap_sysctl_s
*) opaque
;
3549 int pad_offset
, byte_offset
;
3553 case 0x030 ... 0x140: /* CONTROL_PADCONF - only used in the POP */
3554 pad_offset
= (addr
- 0x30) >> 2;
3555 byte_offset
= (addr
- 0x30) & (4 - 1);
3557 value
= s
->padconf
[pad_offset
];
3558 value
= (value
>> (byte_offset
* 8)) & 0xff;
3570 static uint32_t omap_sysctl_read(void *opaque
, target_phys_addr_t addr
)
3572 struct omap_sysctl_s
*s
= (struct omap_sysctl_s
*) opaque
;
3575 case 0x000: /* CONTROL_REVISION */
3578 case 0x010: /* CONTROL_SYSCONFIG */
3579 return s
->sysconfig
;
3581 case 0x030 ... 0x140: /* CONTROL_PADCONF - only used in the POP */
3582 return s
->padconf
[(addr
- 0x30) >> 2];
3584 case 0x270: /* CONTROL_DEBOBS */
3587 case 0x274: /* CONTROL_DEVCONF */
3588 return s
->devconfig
;
3590 case 0x28c: /* CONTROL_EMU_SUPPORT */
3593 case 0x290: /* CONTROL_MSUSPENDMUX_0 */
3594 return s
->msuspendmux
[0];
3595 case 0x294: /* CONTROL_MSUSPENDMUX_1 */
3596 return s
->msuspendmux
[1];
3597 case 0x298: /* CONTROL_MSUSPENDMUX_2 */
3598 return s
->msuspendmux
[2];
3599 case 0x29c: /* CONTROL_MSUSPENDMUX_3 */
3600 return s
->msuspendmux
[3];
3601 case 0x2a0: /* CONTROL_MSUSPENDMUX_4 */
3602 return s
->msuspendmux
[4];
3603 case 0x2a4: /* CONTROL_MSUSPENDMUX_5 */
3606 case 0x2b8: /* CONTROL_PSA_CTRL */
3607 return s
->psaconfig
;
3608 case 0x2bc: /* CONTROL_PSA_CMD */
3609 case 0x2c0: /* CONTROL_PSA_VALUE */
3612 case 0x2b0: /* CONTROL_SEC_CTRL */
3614 case 0x2d0: /* CONTROL_SEC_EMU */
3616 case 0x2d4: /* CONTROL_SEC_TAP */
3618 case 0x2b4: /* CONTROL_SEC_TEST */
3619 case 0x2f0: /* CONTROL_SEC_STATUS */
3620 case 0x2f4: /* CONTROL_SEC_ERR_STATUS */
3621 /* Secure mode is not present on general-pusrpose device. Outside
3622 * secure mode these values cannot be read or written. */
3625 case 0x2d8: /* CONTROL_OCM_RAM_PERM */
3627 case 0x2dc: /* CONTROL_OCM_PUB_RAM_ADD */
3628 case 0x2e0: /* CONTROL_EXT_SEC_RAM_START_ADD */
3629 case 0x2e4: /* CONTROL_EXT_SEC_RAM_STOP_ADD */
3630 /* No secure mode so no Extended Secure RAM present. */
3633 case 0x2f8: /* CONTROL_STATUS */
3634 /* Device Type => General-purpose */
3636 case 0x2fc: /* CONTROL_GENERAL_PURPOSE_STATUS */
3638 case 0x300: /* CONTROL_RPUB_KEY_H_0 */
3639 case 0x304: /* CONTROL_RPUB_KEY_H_1 */
3640 case 0x308: /* CONTROL_RPUB_KEY_H_2 */
3641 case 0x30c: /* CONTROL_RPUB_KEY_H_3 */
3644 case 0x310: /* CONTROL_RAND_KEY_0 */
3645 case 0x314: /* CONTROL_RAND_KEY_1 */
3646 case 0x318: /* CONTROL_RAND_KEY_2 */
3647 case 0x31c: /* CONTROL_RAND_KEY_3 */
3648 case 0x320: /* CONTROL_CUST_KEY_0 */
3649 case 0x324: /* CONTROL_CUST_KEY_1 */
3650 case 0x330: /* CONTROL_TEST_KEY_0 */
3651 case 0x334: /* CONTROL_TEST_KEY_1 */
3652 case 0x338: /* CONTROL_TEST_KEY_2 */
3653 case 0x33c: /* CONTROL_TEST_KEY_3 */
3654 case 0x340: /* CONTROL_TEST_KEY_4 */
3655 case 0x344: /* CONTROL_TEST_KEY_5 */
3656 case 0x348: /* CONTROL_TEST_KEY_6 */
3657 case 0x34c: /* CONTROL_TEST_KEY_7 */
3658 case 0x350: /* CONTROL_TEST_KEY_8 */
3659 case 0x354: /* CONTROL_TEST_KEY_9 */
3660 /* Can only be accessed in secure mode and when C_FieldAccEnable
3661 * bit is set in CONTROL_SEC_CTRL.
3662 * TODO: otherwise an interconnect access error is generated. */
3670 static void omap_sysctl_write8(void *opaque
, target_phys_addr_t addr
,
3673 struct omap_sysctl_s
*s
= (struct omap_sysctl_s
*) opaque
;
3674 int pad_offset
, byte_offset
;
3678 case 0x030 ... 0x140: /* CONTROL_PADCONF - only used in the POP */
3679 pad_offset
= (addr
- 0x30) >> 2;
3680 byte_offset
= (addr
- 0x30) & (4 - 1);
3682 prev_value
= s
->padconf
[pad_offset
];
3683 prev_value
&= ~(0xff << (byte_offset
* 8));
3684 prev_value
|= ((value
& 0x1f1f1f1f) << (byte_offset
* 8)) & 0x1f1f1f1f;
3685 s
->padconf
[pad_offset
] = prev_value
;
3694 static void omap_sysctl_write(void *opaque
, target_phys_addr_t addr
,
3697 struct omap_sysctl_s
*s
= (struct omap_sysctl_s
*) opaque
;
3700 case 0x000: /* CONTROL_REVISION */
3701 case 0x2a4: /* CONTROL_MSUSPENDMUX_5 */
3702 case 0x2c0: /* CONTROL_PSA_VALUE */
3703 case 0x2f8: /* CONTROL_STATUS */
3704 case 0x2fc: /* CONTROL_GENERAL_PURPOSE_STATUS */
3705 case 0x300: /* CONTROL_RPUB_KEY_H_0 */
3706 case 0x304: /* CONTROL_RPUB_KEY_H_1 */
3707 case 0x308: /* CONTROL_RPUB_KEY_H_2 */
3708 case 0x30c: /* CONTROL_RPUB_KEY_H_3 */
3709 case 0x310: /* CONTROL_RAND_KEY_0 */
3710 case 0x314: /* CONTROL_RAND_KEY_1 */
3711 case 0x318: /* CONTROL_RAND_KEY_2 */
3712 case 0x31c: /* CONTROL_RAND_KEY_3 */
3713 case 0x320: /* CONTROL_CUST_KEY_0 */
3714 case 0x324: /* CONTROL_CUST_KEY_1 */
3715 case 0x330: /* CONTROL_TEST_KEY_0 */
3716 case 0x334: /* CONTROL_TEST_KEY_1 */
3717 case 0x338: /* CONTROL_TEST_KEY_2 */
3718 case 0x33c: /* CONTROL_TEST_KEY_3 */
3719 case 0x340: /* CONTROL_TEST_KEY_4 */
3720 case 0x344: /* CONTROL_TEST_KEY_5 */
3721 case 0x348: /* CONTROL_TEST_KEY_6 */
3722 case 0x34c: /* CONTROL_TEST_KEY_7 */
3723 case 0x350: /* CONTROL_TEST_KEY_8 */
3724 case 0x354: /* CONTROL_TEST_KEY_9 */
3728 case 0x010: /* CONTROL_SYSCONFIG */
3729 s
->sysconfig
= value
& 0x1e;
3732 case 0x030 ... 0x140: /* CONTROL_PADCONF - only used in the POP */
3733 /* XXX: should check constant bits */
3734 s
->padconf
[(addr
- 0x30) >> 2] = value
& 0x1f1f1f1f;
3737 case 0x270: /* CONTROL_DEBOBS */
3738 s
->obs
= value
& 0xff;
3741 case 0x274: /* CONTROL_DEVCONF */
3742 s
->devconfig
= value
& 0xffffc7ff;
3745 case 0x28c: /* CONTROL_EMU_SUPPORT */
3748 case 0x290: /* CONTROL_MSUSPENDMUX_0 */
3749 s
->msuspendmux
[0] = value
& 0x3fffffff;
3751 case 0x294: /* CONTROL_MSUSPENDMUX_1 */
3752 s
->msuspendmux
[1] = value
& 0x3fffffff;
3754 case 0x298: /* CONTROL_MSUSPENDMUX_2 */
3755 s
->msuspendmux
[2] = value
& 0x3fffffff;
3757 case 0x29c: /* CONTROL_MSUSPENDMUX_3 */
3758 s
->msuspendmux
[3] = value
& 0x3fffffff;
3760 case 0x2a0: /* CONTROL_MSUSPENDMUX_4 */
3761 s
->msuspendmux
[4] = value
& 0x3fffffff;
3764 case 0x2b8: /* CONTROL_PSA_CTRL */
3765 s
->psaconfig
= value
& 0x1c;
3766 s
->psaconfig
|= (value
& 0x20) ? 2 : 1;
3768 case 0x2bc: /* CONTROL_PSA_CMD */
3771 case 0x2b0: /* CONTROL_SEC_CTRL */
3772 case 0x2b4: /* CONTROL_SEC_TEST */
3773 case 0x2d0: /* CONTROL_SEC_EMU */
3774 case 0x2d4: /* CONTROL_SEC_TAP */
3775 case 0x2d8: /* CONTROL_OCM_RAM_PERM */
3776 case 0x2dc: /* CONTROL_OCM_PUB_RAM_ADD */
3777 case 0x2e0: /* CONTROL_EXT_SEC_RAM_START_ADD */
3778 case 0x2e4: /* CONTROL_EXT_SEC_RAM_STOP_ADD */
3779 case 0x2f0: /* CONTROL_SEC_STATUS */
3780 case 0x2f4: /* CONTROL_SEC_ERR_STATUS */
3789 static CPUReadMemoryFunc
* const omap_sysctl_readfn
[] = {
3791 omap_badwidth_read32
, /* TODO */
3795 static CPUWriteMemoryFunc
* const omap_sysctl_writefn
[] = {
3797 omap_badwidth_write32
, /* TODO */
3801 static void omap_sysctl_reset(struct omap_sysctl_s
*s
)
3803 /* (power-on reset) */
3806 s
->devconfig
= 0x0c000000;
3807 s
->msuspendmux
[0] = 0x00000000;
3808 s
->msuspendmux
[1] = 0x00000000;
3809 s
->msuspendmux
[2] = 0x00000000;
3810 s
->msuspendmux
[3] = 0x00000000;
3811 s
->msuspendmux
[4] = 0x00000000;
3814 s
->padconf
[0x00] = 0x000f0f0f;
3815 s
->padconf
[0x01] = 0x00000000;
3816 s
->padconf
[0x02] = 0x00000000;
3817 s
->padconf
[0x03] = 0x00000000;
3818 s
->padconf
[0x04] = 0x00000000;
3819 s
->padconf
[0x05] = 0x00000000;
3820 s
->padconf
[0x06] = 0x00000000;
3821 s
->padconf
[0x07] = 0x00000000;
3822 s
->padconf
[0x08] = 0x08080800;
3823 s
->padconf
[0x09] = 0x08080808;
3824 s
->padconf
[0x0a] = 0x08080808;
3825 s
->padconf
[0x0b] = 0x08080808;
3826 s
->padconf
[0x0c] = 0x08080808;
3827 s
->padconf
[0x0d] = 0x08080800;
3828 s
->padconf
[0x0e] = 0x08080808;
3829 s
->padconf
[0x0f] = 0x08080808;
3830 s
->padconf
[0x10] = 0x18181808; /* | 0x07070700 if SBoot3 */
3831 s
->padconf
[0x11] = 0x18181818; /* | 0x07070707 if SBoot3 */
3832 s
->padconf
[0x12] = 0x18181818; /* | 0x07070707 if SBoot3 */
3833 s
->padconf
[0x13] = 0x18181818; /* | 0x07070707 if SBoot3 */
3834 s
->padconf
[0x14] = 0x18181818; /* | 0x00070707 if SBoot3 */
3835 s
->padconf
[0x15] = 0x18181818;
3836 s
->padconf
[0x16] = 0x18181818; /* | 0x07000000 if SBoot3 */
3837 s
->padconf
[0x17] = 0x1f001f00;
3838 s
->padconf
[0x18] = 0x1f1f1f1f;
3839 s
->padconf
[0x19] = 0x00000000;
3840 s
->padconf
[0x1a] = 0x1f180000;
3841 s
->padconf
[0x1b] = 0x00001f1f;
3842 s
->padconf
[0x1c] = 0x1f001f00;
3843 s
->padconf
[0x1d] = 0x00000000;
3844 s
->padconf
[0x1e] = 0x00000000;
3845 s
->padconf
[0x1f] = 0x08000000;
3846 s
->padconf
[0x20] = 0x08080808;
3847 s
->padconf
[0x21] = 0x08080808;
3848 s
->padconf
[0x22] = 0x0f080808;
3849 s
->padconf
[0x23] = 0x0f0f0f0f;
3850 s
->padconf
[0x24] = 0x000f0f0f;
3851 s
->padconf
[0x25] = 0x1f1f1f0f;
3852 s
->padconf
[0x26] = 0x080f0f1f;
3853 s
->padconf
[0x27] = 0x070f1808;
3854 s
->padconf
[0x28] = 0x0f070707;
3855 s
->padconf
[0x29] = 0x000f0f1f;
3856 s
->padconf
[0x2a] = 0x0f0f0f1f;
3857 s
->padconf
[0x2b] = 0x08000000;
3858 s
->padconf
[0x2c] = 0x0000001f;
3859 s
->padconf
[0x2d] = 0x0f0f1f00;
3860 s
->padconf
[0x2e] = 0x1f1f0f0f;
3861 s
->padconf
[0x2f] = 0x0f1f1f1f;
3862 s
->padconf
[0x30] = 0x0f0f0f0f;
3863 s
->padconf
[0x31] = 0x0f1f0f1f;
3864 s
->padconf
[0x32] = 0x0f0f0f0f;
3865 s
->padconf
[0x33] = 0x0f1f0f1f;
3866 s
->padconf
[0x34] = 0x1f1f0f0f;
3867 s
->padconf
[0x35] = 0x0f0f1f1f;
3868 s
->padconf
[0x36] = 0x0f0f1f0f;
3869 s
->padconf
[0x37] = 0x0f0f0f0f;
3870 s
->padconf
[0x38] = 0x1f18180f;
3871 s
->padconf
[0x39] = 0x1f1f1f1f;
3872 s
->padconf
[0x3a] = 0x00001f1f;
3873 s
->padconf
[0x3b] = 0x00000000;
3874 s
->padconf
[0x3c] = 0x00000000;
3875 s
->padconf
[0x3d] = 0x0f0f0f0f;
3876 s
->padconf
[0x3e] = 0x18000f0f;
3877 s
->padconf
[0x3f] = 0x00070000;
3878 s
->padconf
[0x40] = 0x00000707;
3879 s
->padconf
[0x41] = 0x0f1f0700;
3880 s
->padconf
[0x42] = 0x1f1f070f;
3881 s
->padconf
[0x43] = 0x0008081f;
3882 s
->padconf
[0x44] = 0x00000800;
3885 struct omap_sysctl_s
*omap_sysctl_init(struct omap_target_agent_s
*ta
,
3886 omap_clk iclk
, struct omap_mpu_state_s
*mpu
)
3889 struct omap_sysctl_s
*s
= (struct omap_sysctl_s
*)
3890 qemu_mallocz(sizeof(struct omap_sysctl_s
));
3893 omap_sysctl_reset(s
);
3895 iomemtype
= l4_register_io_memory(omap_sysctl_readfn
,
3896 omap_sysctl_writefn
, s
);
3897 omap_l4_attach(ta
, 0, iomemtype
);
3902 /* SDRAM Controller Subsystem */
3903 struct omap_sdrc_s
{
3907 static void omap_sdrc_reset(struct omap_sdrc_s
*s
)
3912 static uint32_t omap_sdrc_read(void *opaque
, target_phys_addr_t addr
)
3914 struct omap_sdrc_s
*s
= (struct omap_sdrc_s
*) opaque
;
3917 case 0x00: /* SDRC_REVISION */
3920 case 0x10: /* SDRC_SYSCONFIG */
3923 case 0x14: /* SDRC_SYSSTATUS */
3924 return 1; /* RESETDONE */
3926 case 0x40: /* SDRC_CS_CFG */
3927 case 0x44: /* SDRC_SHARING */
3928 case 0x48: /* SDRC_ERR_ADDR */
3929 case 0x4c: /* SDRC_ERR_TYPE */
3930 case 0x60: /* SDRC_DLLA_SCTRL */
3931 case 0x64: /* SDRC_DLLA_STATUS */
3932 case 0x68: /* SDRC_DLLB_CTRL */
3933 case 0x6c: /* SDRC_DLLB_STATUS */
3934 case 0x70: /* SDRC_POWER */
3935 case 0x80: /* SDRC_MCFG_0 */
3936 case 0x84: /* SDRC_MR_0 */
3937 case 0x88: /* SDRC_EMR1_0 */
3938 case 0x8c: /* SDRC_EMR2_0 */
3939 case 0x90: /* SDRC_EMR3_0 */
3940 case 0x94: /* SDRC_DCDL1_CTRL */
3941 case 0x98: /* SDRC_DCDL2_CTRL */
3942 case 0x9c: /* SDRC_ACTIM_CTRLA_0 */
3943 case 0xa0: /* SDRC_ACTIM_CTRLB_0 */
3944 case 0xa4: /* SDRC_RFR_CTRL_0 */
3945 case 0xa8: /* SDRC_MANUAL_0 */
3946 case 0xb0: /* SDRC_MCFG_1 */
3947 case 0xb4: /* SDRC_MR_1 */
3948 case 0xb8: /* SDRC_EMR1_1 */
3949 case 0xbc: /* SDRC_EMR2_1 */
3950 case 0xc0: /* SDRC_EMR3_1 */
3951 case 0xc4: /* SDRC_ACTIM_CTRLA_1 */
3952 case 0xc8: /* SDRC_ACTIM_CTRLB_1 */
3953 case 0xd4: /* SDRC_RFR_CTRL_1 */
3954 case 0xd8: /* SDRC_MANUAL_1 */
3962 static void omap_sdrc_write(void *opaque
, target_phys_addr_t addr
,
3965 struct omap_sdrc_s
*s
= (struct omap_sdrc_s
*) opaque
;
3968 case 0x00: /* SDRC_REVISION */
3969 case 0x14: /* SDRC_SYSSTATUS */
3970 case 0x48: /* SDRC_ERR_ADDR */
3971 case 0x64: /* SDRC_DLLA_STATUS */
3972 case 0x6c: /* SDRC_DLLB_STATUS */
3976 case 0x10: /* SDRC_SYSCONFIG */
3977 if ((value
>> 3) != 0x2)
3978 fprintf(stderr
, "%s: bad SDRAM idle mode %i\n",
3979 __FUNCTION__
, value
>> 3);
3982 s
->config
= value
& 0x18;
3985 case 0x40: /* SDRC_CS_CFG */
3986 case 0x44: /* SDRC_SHARING */
3987 case 0x4c: /* SDRC_ERR_TYPE */
3988 case 0x60: /* SDRC_DLLA_SCTRL */
3989 case 0x68: /* SDRC_DLLB_CTRL */
3990 case 0x70: /* SDRC_POWER */
3991 case 0x80: /* SDRC_MCFG_0 */
3992 case 0x84: /* SDRC_MR_0 */
3993 case 0x88: /* SDRC_EMR1_0 */
3994 case 0x8c: /* SDRC_EMR2_0 */
3995 case 0x90: /* SDRC_EMR3_0 */
3996 case 0x94: /* SDRC_DCDL1_CTRL */
3997 case 0x98: /* SDRC_DCDL2_CTRL */
3998 case 0x9c: /* SDRC_ACTIM_CTRLA_0 */
3999 case 0xa0: /* SDRC_ACTIM_CTRLB_0 */
4000 case 0xa4: /* SDRC_RFR_CTRL_0 */
4001 case 0xa8: /* SDRC_MANUAL_0 */
4002 case 0xb0: /* SDRC_MCFG_1 */
4003 case 0xb4: /* SDRC_MR_1 */
4004 case 0xb8: /* SDRC_EMR1_1 */
4005 case 0xbc: /* SDRC_EMR2_1 */
4006 case 0xc0: /* SDRC_EMR3_1 */
4007 case 0xc4: /* SDRC_ACTIM_CTRLA_1 */
4008 case 0xc8: /* SDRC_ACTIM_CTRLB_1 */
4009 case 0xd4: /* SDRC_RFR_CTRL_1 */
4010 case 0xd8: /* SDRC_MANUAL_1 */
4019 static CPUReadMemoryFunc
* const omap_sdrc_readfn
[] = {
4020 omap_badwidth_read32
,
4021 omap_badwidth_read32
,
4025 static CPUWriteMemoryFunc
* const omap_sdrc_writefn
[] = {
4026 omap_badwidth_write32
,
4027 omap_badwidth_write32
,
4031 struct omap_sdrc_s
*omap_sdrc_init(target_phys_addr_t base
)
4034 struct omap_sdrc_s
*s
= (struct omap_sdrc_s
*)
4035 qemu_mallocz(sizeof(struct omap_sdrc_s
));
4039 iomemtype
= cpu_register_io_memory(omap_sdrc_readfn
,
4040 omap_sdrc_writefn
, s
);
4041 cpu_register_physical_memory(base
, 0x1000, iomemtype
);
4046 /* General-Purpose Memory Controller */
4047 struct omap_gpmc_s
{
4055 uint32_t prefconfig
[2];
4059 struct omap_gpmc_cs_file_s
{
4061 target_phys_addr_t base
;
4064 void (*base_update
)(void *opaque
, target_phys_addr_t
new);
4065 void (*unmap
)(void *opaque
);
4074 static void omap_gpmc_int_update(struct omap_gpmc_s
*s
)
4076 qemu_set_irq(s
->irq
, s
->irqen
& s
->irqst
);
4079 static void omap_gpmc_cs_map(struct omap_gpmc_cs_file_s
*f
, int base
, int mask
)
4081 /* TODO: check for overlapping regions and report access errors */
4082 if ((mask
!= 0x8 && mask
!= 0xc && mask
!= 0xe && mask
!= 0xf) ||
4083 (base
< 0 || base
>= 0x40) ||
4084 (base
& 0x0f & ~mask
)) {
4085 fprintf(stderr
, "%s: wrong cs address mapping/decoding!\n",
4093 f
->base
= base
<< 24;
4094 f
->size
= (0x0fffffff & ~(mask
<< 24)) + 1;
4095 /* TODO: rather than setting the size of the mapping (which should be
4096 * constant), the mask should cause wrapping of the address space, so
4097 * that the same memory becomes accessible at every <i>size</i> bytes
4098 * starting from <i>base</i>. */
4100 cpu_register_physical_memory(f
->base
, f
->size
, f
->iomemtype
);
4103 f
->base_update(f
->opaque
, f
->base
);
4106 static void omap_gpmc_cs_unmap(struct omap_gpmc_cs_file_s
*f
)
4110 f
->unmap(f
->opaque
);
4112 cpu_register_physical_memory(f
->base
, f
->size
, IO_MEM_UNASSIGNED
);
4118 static void omap_gpmc_reset(struct omap_gpmc_s
*s
)
4125 omap_gpmc_int_update(s
);
4128 s
->prefconfig
[0] = 0x00004000;
4129 s
->prefconfig
[1] = 0x00000000;
4133 for (i
= 0; i
< 8; i
++) {
4134 if (s
->cs_file
[i
].config
[6] & (1 << 6)) /* CSVALID */
4135 omap_gpmc_cs_unmap(s
->cs_file
+ i
);
4136 s
->cs_file
[i
].config
[0] = i
? 1 << 12 : 0;
4137 s
->cs_file
[i
].config
[1] = 0x101001;
4138 s
->cs_file
[i
].config
[2] = 0x020201;
4139 s
->cs_file
[i
].config
[3] = 0x10031003;
4140 s
->cs_file
[i
].config
[4] = 0x10f1111;
4141 s
->cs_file
[i
].config
[5] = 0;
4142 s
->cs_file
[i
].config
[6] = 0xf00 | (i
? 0 : 1 << 6);
4143 if (s
->cs_file
[i
].config
[6] & (1 << 6)) /* CSVALID */
4144 omap_gpmc_cs_map(&s
->cs_file
[i
],
4145 s
->cs_file
[i
].config
[6] & 0x1f, /* MASKADDR */
4146 (s
->cs_file
[i
].config
[6] >> 8 & 0xf)); /* BASEADDR */
4148 omap_gpmc_cs_map(s
->cs_file
, 0, 0xf);
4151 s
->ecc_cfg
= 0x3fcff000;
4152 for (i
= 0; i
< 9; i
++)
4153 ecc_reset(&s
->ecc
[i
]);
4156 static uint32_t omap_gpmc_read(void *opaque
, target_phys_addr_t addr
)
4158 struct omap_gpmc_s
*s
= (struct omap_gpmc_s
*) opaque
;
4160 struct omap_gpmc_cs_file_s
*f
;
4163 case 0x000: /* GPMC_REVISION */
4166 case 0x010: /* GPMC_SYSCONFIG */
4167 return s
->sysconfig
;
4169 case 0x014: /* GPMC_SYSSTATUS */
4170 return 1; /* RESETDONE */
4172 case 0x018: /* GPMC_IRQSTATUS */
4175 case 0x01c: /* GPMC_IRQENABLE */
4178 case 0x040: /* GPMC_TIMEOUT_CONTROL */
4181 case 0x044: /* GPMC_ERR_ADDRESS */
4182 case 0x048: /* GPMC_ERR_TYPE */
4185 case 0x050: /* GPMC_CONFIG */
4188 case 0x054: /* GPMC_STATUS */
4191 case 0x060 ... 0x1d4:
4192 cs
= (addr
- 0x060) / 0x30;
4194 f
= s
->cs_file
+ cs
;
4196 case 0x60: /* GPMC_CONFIG1 */
4197 return f
->config
[0];
4198 case 0x64: /* GPMC_CONFIG2 */
4199 return f
->config
[1];
4200 case 0x68: /* GPMC_CONFIG3 */
4201 return f
->config
[2];
4202 case 0x6c: /* GPMC_CONFIG4 */
4203 return f
->config
[3];
4204 case 0x70: /* GPMC_CONFIG5 */
4205 return f
->config
[4];
4206 case 0x74: /* GPMC_CONFIG6 */
4207 return f
->config
[5];
4208 case 0x78: /* GPMC_CONFIG7 */
4209 return f
->config
[6];
4210 case 0x84: /* GPMC_NAND_DATA */
4215 case 0x1e0: /* GPMC_PREFETCH_CONFIG1 */
4216 return s
->prefconfig
[0];
4217 case 0x1e4: /* GPMC_PREFETCH_CONFIG2 */
4218 return s
->prefconfig
[1];
4219 case 0x1ec: /* GPMC_PREFETCH_CONTROL */
4220 return s
->prefcontrol
;
4221 case 0x1f0: /* GPMC_PREFETCH_STATUS */
4222 return (s
->preffifo
<< 24) |
4224 ((s
->prefconfig
[0] >> 8) & 0x7f) ? 1 : 0) << 16) |
4227 case 0x1f4: /* GPMC_ECC_CONFIG */
4229 case 0x1f8: /* GPMC_ECC_CONTROL */
4231 case 0x1fc: /* GPMC_ECC_SIZE_CONFIG */
4233 case 0x200 ... 0x220: /* GPMC_ECC_RESULT */
4234 cs
= (addr
& 0x1f) >> 2;
4235 /* TODO: check correctness */
4237 ((s
->ecc
[cs
].cp
& 0x07) << 0) |
4238 ((s
->ecc
[cs
].cp
& 0x38) << 13) |
4239 ((s
->ecc
[cs
].lp
[0] & 0x1ff) << 3) |
4240 ((s
->ecc
[cs
].lp
[1] & 0x1ff) << 19);
4242 case 0x230: /* GPMC_TESTMODE_CTRL */
4244 case 0x234: /* GPMC_PSA_LSB */
4245 case 0x238: /* GPMC_PSA_MSB */
4253 static void omap_gpmc_write(void *opaque
, target_phys_addr_t addr
,
4256 struct omap_gpmc_s
*s
= (struct omap_gpmc_s
*) opaque
;
4258 struct omap_gpmc_cs_file_s
*f
;
4261 case 0x000: /* GPMC_REVISION */
4262 case 0x014: /* GPMC_SYSSTATUS */
4263 case 0x054: /* GPMC_STATUS */
4264 case 0x1f0: /* GPMC_PREFETCH_STATUS */
4265 case 0x200 ... 0x220: /* GPMC_ECC_RESULT */
4266 case 0x234: /* GPMC_PSA_LSB */
4267 case 0x238: /* GPMC_PSA_MSB */
4271 case 0x010: /* GPMC_SYSCONFIG */
4272 if ((value
>> 3) == 0x3)
4273 fprintf(stderr
, "%s: bad SDRAM idle mode %i\n",
4274 __FUNCTION__
, value
>> 3);
4277 s
->sysconfig
= value
& 0x19;
4280 case 0x018: /* GPMC_IRQSTATUS */
4282 omap_gpmc_int_update(s
);
4285 case 0x01c: /* GPMC_IRQENABLE */
4286 s
->irqen
= value
& 0xf03;
4287 omap_gpmc_int_update(s
);
4290 case 0x040: /* GPMC_TIMEOUT_CONTROL */
4291 s
->timeout
= value
& 0x1ff1;
4294 case 0x044: /* GPMC_ERR_ADDRESS */
4295 case 0x048: /* GPMC_ERR_TYPE */
4298 case 0x050: /* GPMC_CONFIG */
4299 s
->config
= value
& 0xf13;
4302 case 0x060 ... 0x1d4:
4303 cs
= (addr
- 0x060) / 0x30;
4305 f
= s
->cs_file
+ cs
;
4307 case 0x60: /* GPMC_CONFIG1 */
4308 f
->config
[0] = value
& 0xffef3e13;
4310 case 0x64: /* GPMC_CONFIG2 */
4311 f
->config
[1] = value
& 0x001f1f8f;
4313 case 0x68: /* GPMC_CONFIG3 */
4314 f
->config
[2] = value
& 0x001f1f8f;
4316 case 0x6c: /* GPMC_CONFIG4 */
4317 f
->config
[3] = value
& 0x1f8f1f8f;
4319 case 0x70: /* GPMC_CONFIG5 */
4320 f
->config
[4] = value
& 0x0f1f1f1f;
4322 case 0x74: /* GPMC_CONFIG6 */
4323 f
->config
[5] = value
& 0x00000fcf;
4325 case 0x78: /* GPMC_CONFIG7 */
4326 if ((f
->config
[6] ^ value
) & 0xf7f) {
4327 if (f
->config
[6] & (1 << 6)) /* CSVALID */
4328 omap_gpmc_cs_unmap(f
);
4329 if (value
& (1 << 6)) /* CSVALID */
4330 omap_gpmc_cs_map(f
, value
& 0x1f, /* MASKADDR */
4331 (value
>> 8 & 0xf)); /* BASEADDR */
4333 f
->config
[6] = value
& 0x00000f7f;
4335 case 0x7c: /* GPMC_NAND_COMMAND */
4336 case 0x80: /* GPMC_NAND_ADDRESS */
4337 case 0x84: /* GPMC_NAND_DATA */
4345 case 0x1e0: /* GPMC_PREFETCH_CONFIG1 */
4346 s
->prefconfig
[0] = value
& 0x7f8f7fbf;
4347 /* TODO: update interrupts, fifos, dmas */
4350 case 0x1e4: /* GPMC_PREFETCH_CONFIG2 */
4351 s
->prefconfig
[1] = value
& 0x3fff;
4354 case 0x1ec: /* GPMC_PREFETCH_CONTROL */
4355 s
->prefcontrol
= value
& 1;
4356 if (s
->prefcontrol
) {
4357 if (s
->prefconfig
[0] & 1)
4365 case 0x1f4: /* GPMC_ECC_CONFIG */
4368 case 0x1f8: /* GPMC_ECC_CONTROL */
4369 if (value
& (1 << 8))
4370 for (cs
= 0; cs
< 9; cs
++)
4371 ecc_reset(&s
->ecc
[cs
]);
4372 s
->ecc_ptr
= value
& 0xf;
4373 if (s
->ecc_ptr
== 0 || s
->ecc_ptr
> 9) {
4378 case 0x1fc: /* GPMC_ECC_SIZE_CONFIG */
4379 s
->ecc_cfg
= value
& 0x3fcff1ff;
4381 case 0x230: /* GPMC_TESTMODE_CTRL */
4383 fprintf(stderr
, "%s: test mode enable attempt\n", __FUNCTION__
);
4393 static CPUReadMemoryFunc
* const omap_gpmc_readfn
[] = {
4394 omap_badwidth_read32
, /* TODO */
4395 omap_badwidth_read32
, /* TODO */
4399 static CPUWriteMemoryFunc
* const omap_gpmc_writefn
[] = {
4400 omap_badwidth_write32
, /* TODO */
4401 omap_badwidth_write32
, /* TODO */
4405 struct omap_gpmc_s
*omap_gpmc_init(target_phys_addr_t base
, qemu_irq irq
)
4408 struct omap_gpmc_s
*s
= (struct omap_gpmc_s
*)
4409 qemu_mallocz(sizeof(struct omap_gpmc_s
));
4413 iomemtype
= cpu_register_io_memory(omap_gpmc_readfn
,
4414 omap_gpmc_writefn
, s
);
4415 cpu_register_physical_memory(base
, 0x1000, iomemtype
);
4420 void omap_gpmc_attach(struct omap_gpmc_s
*s
, int cs
, int iomemtype
,
4421 void (*base_upd
)(void *opaque
, target_phys_addr_t
new),
4422 void (*unmap
)(void *opaque
), void *opaque
)
4424 struct omap_gpmc_cs_file_s
*f
;
4426 if (cs
< 0 || cs
>= 8) {
4427 fprintf(stderr
, "%s: bad chip-select %i\n", __FUNCTION__
, cs
);
4430 f
= &s
->cs_file
[cs
];
4432 f
->iomemtype
= iomemtype
;
4433 f
->base_update
= base_upd
;
4437 if (f
->config
[6] & (1 << 6)) /* CSVALID */
4438 omap_gpmc_cs_map(f
, f
->config
[6] & 0x1f, /* MASKADDR */
4439 (f
->config
[6] >> 8 & 0xf)); /* BASEADDR */
4442 /* General chip reset */
4443 static void omap2_mpu_reset(void *opaque
)
4445 struct omap_mpu_state_s
*mpu
= (struct omap_mpu_state_s
*) opaque
;
4447 omap_inth_reset(mpu
->ih
[0]);
4448 omap_dma_reset(mpu
->dma
);
4449 omap_prcm_reset(mpu
->prcm
);
4450 omap_sysctl_reset(mpu
->sysc
);
4451 omap_gp_timer_reset(mpu
->gptimer
[0]);
4452 omap_gp_timer_reset(mpu
->gptimer
[1]);
4453 omap_gp_timer_reset(mpu
->gptimer
[2]);
4454 omap_gp_timer_reset(mpu
->gptimer
[3]);
4455 omap_gp_timer_reset(mpu
->gptimer
[4]);
4456 omap_gp_timer_reset(mpu
->gptimer
[5]);
4457 omap_gp_timer_reset(mpu
->gptimer
[6]);
4458 omap_gp_timer_reset(mpu
->gptimer
[7]);
4459 omap_gp_timer_reset(mpu
->gptimer
[8]);
4460 omap_gp_timer_reset(mpu
->gptimer
[9]);
4461 omap_gp_timer_reset(mpu
->gptimer
[10]);
4462 omap_gp_timer_reset(mpu
->gptimer
[11]);
4463 omap_synctimer_reset(&mpu
->synctimer
);
4464 omap_sdrc_reset(mpu
->sdrc
);
4465 omap_gpmc_reset(mpu
->gpmc
);
4466 omap_dss_reset(mpu
->dss
);
4467 omap_uart_reset(mpu
->uart
[0]);
4468 omap_uart_reset(mpu
->uart
[1]);
4469 omap_uart_reset(mpu
->uart
[2]);
4470 omap_mmc_reset(mpu
->mmc
);
4471 omap_gpif_reset(mpu
->gpif
);
4472 omap_mcspi_reset(mpu
->mcspi
[0]);
4473 omap_mcspi_reset(mpu
->mcspi
[1]);
4474 omap_i2c_reset(mpu
->i2c
[0]);
4475 omap_i2c_reset(mpu
->i2c
[1]);
4476 cpu_reset(mpu
->env
);
4479 static int omap2_validate_addr(struct omap_mpu_state_s
*s
,
4480 target_phys_addr_t addr
)
4485 static const struct dma_irq_map omap2_dma_irq_map
[] = {
4486 { 0, OMAP_INT_24XX_SDMA_IRQ0
},
4487 { 0, OMAP_INT_24XX_SDMA_IRQ1
},
4488 { 0, OMAP_INT_24XX_SDMA_IRQ2
},
4489 { 0, OMAP_INT_24XX_SDMA_IRQ3
},
4492 struct omap_mpu_state_s
*omap2420_mpu_init(unsigned long sdram_size
,
4495 struct omap_mpu_state_s
*s
= (struct omap_mpu_state_s
*)
4496 qemu_mallocz(sizeof(struct omap_mpu_state_s
));
4497 ram_addr_t sram_base
, q2_base
;
4499 qemu_irq dma_irqs
[4];
4500 omap_clk gpio_clks
[4];
4505 s
->mpu_model
= omap2420
;
4506 s
->env
= cpu_init(core
?: "arm1136-r2");
4508 fprintf(stderr
, "Unable to find CPU definition\n");
4511 s
->sdram_size
= sdram_size
;
4512 s
->sram_size
= OMAP242X_SRAM_SIZE
;
4514 s
->wakeup
= qemu_allocate_irqs(omap_mpu_wakeup
, s
, 1)[0];
4519 /* Memory-mapped stuff */
4520 cpu_register_physical_memory(OMAP2_Q2_BASE
, s
->sdram_size
,
4521 (q2_base
= qemu_ram_alloc(s
->sdram_size
)) | IO_MEM_RAM
);
4522 cpu_register_physical_memory(OMAP2_SRAM_BASE
, s
->sram_size
,
4523 (sram_base
= qemu_ram_alloc(s
->sram_size
)) | IO_MEM_RAM
);
4525 s
->l4
= omap_l4_init(OMAP2_L4_BASE
, 54);
4527 /* Actually mapped at any 2K boundary in the ARM11 private-peripheral if */
4528 cpu_irq
= arm_pic_init_cpu(s
->env
);
4529 s
->ih
[0] = omap2_inth_init(0x480fe000, 0x1000, 3, &s
->irq
[0],
4530 cpu_irq
[ARM_PIC_CPU_IRQ
], cpu_irq
[ARM_PIC_CPU_FIQ
],
4531 omap_findclk(s
, "mpu_intc_fclk"),
4532 omap_findclk(s
, "mpu_intc_iclk"));
4534 s
->prcm
= omap_prcm_init(omap_l4tao(s
->l4
, 3),
4535 s
->irq
[0][OMAP_INT_24XX_PRCM_MPU_IRQ
], NULL
, NULL
, s
);
4537 s
->sysc
= omap_sysctl_init(omap_l4tao(s
->l4
, 1),
4538 omap_findclk(s
, "omapctrl_iclk"), s
);
4540 for (i
= 0; i
< 4; i
++)
4542 s
->irq
[omap2_dma_irq_map
[i
].ih
][omap2_dma_irq_map
[i
].intr
];
4543 s
->dma
= omap_dma4_init(0x48056000, dma_irqs
, s
, 256, 32,
4544 omap_findclk(s
, "sdma_iclk"),
4545 omap_findclk(s
, "sdma_fclk"));
4546 s
->port
->addr_valid
= omap2_validate_addr
;
4548 /* Register SDRAM and SRAM ports for fast DMA transfers. */
4549 soc_dma_port_add_mem_ram(s
->dma
, q2_base
, OMAP2_Q2_BASE
, s
->sdram_size
);
4550 soc_dma_port_add_mem_ram(s
->dma
, sram_base
, OMAP2_SRAM_BASE
, s
->sram_size
);
4552 s
->uart
[0] = omap2_uart_init(omap_l4ta(s
->l4
, 19),
4553 s
->irq
[0][OMAP_INT_24XX_UART1_IRQ
],
4554 omap_findclk(s
, "uart1_fclk"),
4555 omap_findclk(s
, "uart1_iclk"),
4556 s
->drq
[OMAP24XX_DMA_UART1_TX
],
4557 s
->drq
[OMAP24XX_DMA_UART1_RX
], serial_hds
[0]);
4558 s
->uart
[1] = omap2_uart_init(omap_l4ta(s
->l4
, 20),
4559 s
->irq
[0][OMAP_INT_24XX_UART2_IRQ
],
4560 omap_findclk(s
, "uart2_fclk"),
4561 omap_findclk(s
, "uart2_iclk"),
4562 s
->drq
[OMAP24XX_DMA_UART2_TX
],
4563 s
->drq
[OMAP24XX_DMA_UART2_RX
],
4564 serial_hds
[0] ? serial_hds
[1] : NULL
);
4565 s
->uart
[2] = omap2_uart_init(omap_l4ta(s
->l4
, 21),
4566 s
->irq
[0][OMAP_INT_24XX_UART3_IRQ
],
4567 omap_findclk(s
, "uart3_fclk"),
4568 omap_findclk(s
, "uart3_iclk"),
4569 s
->drq
[OMAP24XX_DMA_UART3_TX
],
4570 s
->drq
[OMAP24XX_DMA_UART3_RX
],
4571 serial_hds
[0] && serial_hds
[1] ? serial_hds
[2] : NULL
);
4573 s
->gptimer
[0] = omap_gp_timer_init(omap_l4ta(s
->l4
, 7),
4574 s
->irq
[0][OMAP_INT_24XX_GPTIMER1
],
4575 omap_findclk(s
, "wu_gpt1_clk"),
4576 omap_findclk(s
, "wu_l4_iclk"));
4577 s
->gptimer
[1] = omap_gp_timer_init(omap_l4ta(s
->l4
, 8),
4578 s
->irq
[0][OMAP_INT_24XX_GPTIMER2
],
4579 omap_findclk(s
, "core_gpt2_clk"),
4580 omap_findclk(s
, "core_l4_iclk"));
4581 s
->gptimer
[2] = omap_gp_timer_init(omap_l4ta(s
->l4
, 22),
4582 s
->irq
[0][OMAP_INT_24XX_GPTIMER3
],
4583 omap_findclk(s
, "core_gpt3_clk"),
4584 omap_findclk(s
, "core_l4_iclk"));
4585 s
->gptimer
[3] = omap_gp_timer_init(omap_l4ta(s
->l4
, 23),
4586 s
->irq
[0][OMAP_INT_24XX_GPTIMER4
],
4587 omap_findclk(s
, "core_gpt4_clk"),
4588 omap_findclk(s
, "core_l4_iclk"));
4589 s
->gptimer
[4] = omap_gp_timer_init(omap_l4ta(s
->l4
, 24),
4590 s
->irq
[0][OMAP_INT_24XX_GPTIMER5
],
4591 omap_findclk(s
, "core_gpt5_clk"),
4592 omap_findclk(s
, "core_l4_iclk"));
4593 s
->gptimer
[5] = omap_gp_timer_init(omap_l4ta(s
->l4
, 25),
4594 s
->irq
[0][OMAP_INT_24XX_GPTIMER6
],
4595 omap_findclk(s
, "core_gpt6_clk"),
4596 omap_findclk(s
, "core_l4_iclk"));
4597 s
->gptimer
[6] = omap_gp_timer_init(omap_l4ta(s
->l4
, 26),
4598 s
->irq
[0][OMAP_INT_24XX_GPTIMER7
],
4599 omap_findclk(s
, "core_gpt7_clk"),
4600 omap_findclk(s
, "core_l4_iclk"));
4601 s
->gptimer
[7] = omap_gp_timer_init(omap_l4ta(s
->l4
, 27),
4602 s
->irq
[0][OMAP_INT_24XX_GPTIMER8
],
4603 omap_findclk(s
, "core_gpt8_clk"),
4604 omap_findclk(s
, "core_l4_iclk"));
4605 s
->gptimer
[8] = omap_gp_timer_init(omap_l4ta(s
->l4
, 28),
4606 s
->irq
[0][OMAP_INT_24XX_GPTIMER9
],
4607 omap_findclk(s
, "core_gpt9_clk"),
4608 omap_findclk(s
, "core_l4_iclk"));
4609 s
->gptimer
[9] = omap_gp_timer_init(omap_l4ta(s
->l4
, 29),
4610 s
->irq
[0][OMAP_INT_24XX_GPTIMER10
],
4611 omap_findclk(s
, "core_gpt10_clk"),
4612 omap_findclk(s
, "core_l4_iclk"));
4613 s
->gptimer
[10] = omap_gp_timer_init(omap_l4ta(s
->l4
, 30),
4614 s
->irq
[0][OMAP_INT_24XX_GPTIMER11
],
4615 omap_findclk(s
, "core_gpt11_clk"),
4616 omap_findclk(s
, "core_l4_iclk"));
4617 s
->gptimer
[11] = omap_gp_timer_init(omap_l4ta(s
->l4
, 31),
4618 s
->irq
[0][OMAP_INT_24XX_GPTIMER12
],
4619 omap_findclk(s
, "core_gpt12_clk"),
4620 omap_findclk(s
, "core_l4_iclk"));
4622 omap_tap_init(omap_l4ta(s
->l4
, 2), s
);
4624 omap_synctimer_init(omap_l4tao(s
->l4
, 2), s
,
4625 omap_findclk(s
, "clk32-kHz"),
4626 omap_findclk(s
, "core_l4_iclk"));
4628 s
->i2c
[0] = omap2_i2c_init(omap_l4tao(s
->l4
, 5),
4629 s
->irq
[0][OMAP_INT_24XX_I2C1_IRQ
],
4630 &s
->drq
[OMAP24XX_DMA_I2C1_TX
],
4631 omap_findclk(s
, "i2c1.fclk"),
4632 omap_findclk(s
, "i2c1.iclk"));
4633 s
->i2c
[1] = omap2_i2c_init(omap_l4tao(s
->l4
, 6),
4634 s
->irq
[0][OMAP_INT_24XX_I2C2_IRQ
],
4635 &s
->drq
[OMAP24XX_DMA_I2C2_TX
],
4636 omap_findclk(s
, "i2c2.fclk"),
4637 omap_findclk(s
, "i2c2.iclk"));
4639 gpio_clks
[0] = omap_findclk(s
, "gpio1_dbclk");
4640 gpio_clks
[1] = omap_findclk(s
, "gpio2_dbclk");
4641 gpio_clks
[2] = omap_findclk(s
, "gpio3_dbclk");
4642 gpio_clks
[3] = omap_findclk(s
, "gpio4_dbclk");
4643 s
->gpif
= omap2_gpio_init(omap_l4ta(s
->l4
, 3),
4644 &s
->irq
[0][OMAP_INT_24XX_GPIO_BANK1
],
4645 gpio_clks
, omap_findclk(s
, "gpio_iclk"), 4);
4647 s
->sdrc
= omap_sdrc_init(0x68009000);
4648 s
->gpmc
= omap_gpmc_init(0x6800a000, s
->irq
[0][OMAP_INT_24XX_GPMC_IRQ
]);
4650 dinfo
= drive_get(IF_SD
, 0, 0);
4652 fprintf(stderr
, "qemu: missing SecureDigital device\n");
4655 s
->mmc
= omap2_mmc_init(omap_l4tao(s
->l4
, 9), dinfo
->bdrv
,
4656 s
->irq
[0][OMAP_INT_24XX_MMC_IRQ
],
4657 &s
->drq
[OMAP24XX_DMA_MMC1_TX
],
4658 omap_findclk(s
, "mmc_fclk"), omap_findclk(s
, "mmc_iclk"));
4660 s
->mcspi
[0] = omap_mcspi_init(omap_l4ta(s
->l4
, 35), 4,
4661 s
->irq
[0][OMAP_INT_24XX_MCSPI1_IRQ
],
4662 &s
->drq
[OMAP24XX_DMA_SPI1_TX0
],
4663 omap_findclk(s
, "spi1_fclk"),
4664 omap_findclk(s
, "spi1_iclk"));
4665 s
->mcspi
[1] = omap_mcspi_init(omap_l4ta(s
->l4
, 36), 2,
4666 s
->irq
[0][OMAP_INT_24XX_MCSPI2_IRQ
],
4667 &s
->drq
[OMAP24XX_DMA_SPI2_TX0
],
4668 omap_findclk(s
, "spi2_fclk"),
4669 omap_findclk(s
, "spi2_iclk"));
4671 s
->dss
= omap_dss_init(omap_l4ta(s
->l4
, 10), 0x68000800,
4672 /* XXX wire M_IRQ_25, D_L2_IRQ_30 and I_IRQ_13 together */
4673 s
->irq
[0][OMAP_INT_24XX_DSS_IRQ
], s
->drq
[OMAP24XX_DMA_DSS
],
4674 omap_findclk(s
, "dss_clk1"), omap_findclk(s
, "dss_clk2"),
4675 omap_findclk(s
, "dss_54m_clk"),
4676 omap_findclk(s
, "dss_l3_iclk"),
4677 omap_findclk(s
, "dss_l4_iclk"));
4679 omap_sti_init(omap_l4ta(s
->l4
, 18), 0x54000000,
4680 s
->irq
[0][OMAP_INT_24XX_STI
], omap_findclk(s
, "emul_ck"),
4681 serial_hds
[0] && serial_hds
[1] && serial_hds
[2] ?
4682 serial_hds
[3] : NULL
);
4684 s
->eac
= omap_eac_init(omap_l4ta(s
->l4
, 32),
4685 s
->irq
[0][OMAP_INT_24XX_EAC_IRQ
],
4686 /* Ten consecutive lines */
4687 &s
->drq
[OMAP24XX_DMA_EAC_AC_RD
],
4688 omap_findclk(s
, "func_96m_clk"),
4689 omap_findclk(s
, "core_l4_iclk"));
4691 /* All register mappings (includin those not currenlty implemented):
4692 * SystemControlMod 48000000 - 48000fff
4693 * SystemControlL4 48001000 - 48001fff
4694 * 32kHz Timer Mod 48004000 - 48004fff
4695 * 32kHz Timer L4 48005000 - 48005fff
4696 * PRCM ModA 48008000 - 480087ff
4697 * PRCM ModB 48008800 - 48008fff
4698 * PRCM L4 48009000 - 48009fff
4699 * TEST-BCM Mod 48012000 - 48012fff
4700 * TEST-BCM L4 48013000 - 48013fff
4701 * TEST-TAP Mod 48014000 - 48014fff
4702 * TEST-TAP L4 48015000 - 48015fff
4703 * GPIO1 Mod 48018000 - 48018fff
4704 * GPIO Top 48019000 - 48019fff
4705 * GPIO2 Mod 4801a000 - 4801afff
4706 * GPIO L4 4801b000 - 4801bfff
4707 * GPIO3 Mod 4801c000 - 4801cfff
4708 * GPIO4 Mod 4801e000 - 4801efff
4709 * WDTIMER1 Mod 48020000 - 48010fff
4710 * WDTIMER Top 48021000 - 48011fff
4711 * WDTIMER2 Mod 48022000 - 48012fff
4712 * WDTIMER L4 48023000 - 48013fff
4713 * WDTIMER3 Mod 48024000 - 48014fff
4714 * WDTIMER3 L4 48025000 - 48015fff
4715 * WDTIMER4 Mod 48026000 - 48016fff
4716 * WDTIMER4 L4 48027000 - 48017fff
4717 * GPTIMER1 Mod 48028000 - 48018fff
4718 * GPTIMER1 L4 48029000 - 48019fff
4719 * GPTIMER2 Mod 4802a000 - 4801afff
4720 * GPTIMER2 L4 4802b000 - 4801bfff
4721 * L4-Config AP 48040000 - 480407ff
4722 * L4-Config IP 48040800 - 48040fff
4723 * L4-Config LA 48041000 - 48041fff
4724 * ARM11ETB Mod 48048000 - 48049fff
4725 * ARM11ETB L4 4804a000 - 4804afff
4726 * DISPLAY Top 48050000 - 480503ff
4727 * DISPLAY DISPC 48050400 - 480507ff
4728 * DISPLAY RFBI 48050800 - 48050bff
4729 * DISPLAY VENC 48050c00 - 48050fff
4730 * DISPLAY L4 48051000 - 48051fff
4731 * CAMERA Top 48052000 - 480523ff
4732 * CAMERA core 48052400 - 480527ff
4733 * CAMERA DMA 48052800 - 48052bff
4734 * CAMERA MMU 48052c00 - 48052fff
4735 * CAMERA L4 48053000 - 48053fff
4736 * SDMA Mod 48056000 - 48056fff
4737 * SDMA L4 48057000 - 48057fff
4738 * SSI Top 48058000 - 48058fff
4739 * SSI GDD 48059000 - 48059fff
4740 * SSI Port1 4805a000 - 4805afff
4741 * SSI Port2 4805b000 - 4805bfff
4742 * SSI L4 4805c000 - 4805cfff
4743 * USB Mod 4805e000 - 480fefff
4744 * USB L4 4805f000 - 480fffff
4745 * WIN_TRACER1 Mod 48060000 - 48060fff
4746 * WIN_TRACER1 L4 48061000 - 48061fff
4747 * WIN_TRACER2 Mod 48062000 - 48062fff
4748 * WIN_TRACER2 L4 48063000 - 48063fff
4749 * WIN_TRACER3 Mod 48064000 - 48064fff
4750 * WIN_TRACER3 L4 48065000 - 48065fff
4751 * WIN_TRACER4 Top 48066000 - 480660ff
4752 * WIN_TRACER4 ETT 48066100 - 480661ff
4753 * WIN_TRACER4 WT 48066200 - 480662ff
4754 * WIN_TRACER4 L4 48067000 - 48067fff
4755 * XTI Mod 48068000 - 48068fff
4756 * XTI L4 48069000 - 48069fff
4757 * UART1 Mod 4806a000 - 4806afff
4758 * UART1 L4 4806b000 - 4806bfff
4759 * UART2 Mod 4806c000 - 4806cfff
4760 * UART2 L4 4806d000 - 4806dfff
4761 * UART3 Mod 4806e000 - 4806efff
4762 * UART3 L4 4806f000 - 4806ffff
4763 * I2C1 Mod 48070000 - 48070fff
4764 * I2C1 L4 48071000 - 48071fff
4765 * I2C2 Mod 48072000 - 48072fff
4766 * I2C2 L4 48073000 - 48073fff
4767 * McBSP1 Mod 48074000 - 48074fff
4768 * McBSP1 L4 48075000 - 48075fff
4769 * McBSP2 Mod 48076000 - 48076fff
4770 * McBSP2 L4 48077000 - 48077fff
4771 * GPTIMER3 Mod 48078000 - 48078fff
4772 * GPTIMER3 L4 48079000 - 48079fff
4773 * GPTIMER4 Mod 4807a000 - 4807afff
4774 * GPTIMER4 L4 4807b000 - 4807bfff
4775 * GPTIMER5 Mod 4807c000 - 4807cfff
4776 * GPTIMER5 L4 4807d000 - 4807dfff
4777 * GPTIMER6 Mod 4807e000 - 4807efff
4778 * GPTIMER6 L4 4807f000 - 4807ffff
4779 * GPTIMER7 Mod 48080000 - 48080fff
4780 * GPTIMER7 L4 48081000 - 48081fff
4781 * GPTIMER8 Mod 48082000 - 48082fff
4782 * GPTIMER8 L4 48083000 - 48083fff
4783 * GPTIMER9 Mod 48084000 - 48084fff
4784 * GPTIMER9 L4 48085000 - 48085fff
4785 * GPTIMER10 Mod 48086000 - 48086fff
4786 * GPTIMER10 L4 48087000 - 48087fff
4787 * GPTIMER11 Mod 48088000 - 48088fff
4788 * GPTIMER11 L4 48089000 - 48089fff
4789 * GPTIMER12 Mod 4808a000 - 4808afff
4790 * GPTIMER12 L4 4808b000 - 4808bfff
4791 * EAC Mod 48090000 - 48090fff
4792 * EAC L4 48091000 - 48091fff
4793 * FAC Mod 48092000 - 48092fff
4794 * FAC L4 48093000 - 48093fff
4795 * MAILBOX Mod 48094000 - 48094fff
4796 * MAILBOX L4 48095000 - 48095fff
4797 * SPI1 Mod 48098000 - 48098fff
4798 * SPI1 L4 48099000 - 48099fff
4799 * SPI2 Mod 4809a000 - 4809afff
4800 * SPI2 L4 4809b000 - 4809bfff
4801 * MMC/SDIO Mod 4809c000 - 4809cfff
4802 * MMC/SDIO L4 4809d000 - 4809dfff
4803 * MS_PRO Mod 4809e000 - 4809efff
4804 * MS_PRO L4 4809f000 - 4809ffff
4805 * RNG Mod 480a0000 - 480a0fff
4806 * RNG L4 480a1000 - 480a1fff
4807 * DES3DES Mod 480a2000 - 480a2fff
4808 * DES3DES L4 480a3000 - 480a3fff
4809 * SHA1MD5 Mod 480a4000 - 480a4fff
4810 * SHA1MD5 L4 480a5000 - 480a5fff
4811 * AES Mod 480a6000 - 480a6fff
4812 * AES L4 480a7000 - 480a7fff
4813 * PKA Mod 480a8000 - 480a9fff
4814 * PKA L4 480aa000 - 480aafff
4815 * MG Mod 480b0000 - 480b0fff
4816 * MG L4 480b1000 - 480b1fff
4817 * HDQ/1-wire Mod 480b2000 - 480b2fff
4818 * HDQ/1-wire L4 480b3000 - 480b3fff
4819 * MPU interrupt 480fe000 - 480fefff
4820 * STI channel base 54000000 - 5400ffff
4821 * IVA RAM 5c000000 - 5c01ffff
4822 * IVA ROM 5c020000 - 5c027fff
4823 * IMG_BUF_A 5c040000 - 5c040fff
4824 * IMG_BUF_B 5c042000 - 5c042fff
4825 * VLCDS 5c048000 - 5c0487ff
4826 * IMX_COEF 5c049000 - 5c04afff
4827 * IMX_CMD 5c051000 - 5c051fff
4828 * VLCDQ 5c053000 - 5c0533ff
4829 * VLCDH 5c054000 - 5c054fff
4830 * SEQ_CMD 5c055000 - 5c055fff
4831 * IMX_REG 5c056000 - 5c0560ff
4832 * VLCD_REG 5c056100 - 5c0561ff
4833 * SEQ_REG 5c056200 - 5c0562ff
4834 * IMG_BUF_REG 5c056300 - 5c0563ff
4835 * SEQIRQ_REG 5c056400 - 5c0564ff
4836 * OCP_REG 5c060000 - 5c060fff
4837 * SYSC_REG 5c070000 - 5c070fff
4838 * MMU_REG 5d000000 - 5d000fff
4839 * sDMA R 68000400 - 680005ff
4840 * sDMA W 68000600 - 680007ff
4841 * Display Control 68000800 - 680009ff
4842 * DSP subsystem 68000a00 - 68000bff
4843 * MPU subsystem 68000c00 - 68000dff
4844 * IVA subsystem 68001000 - 680011ff
4845 * USB 68001200 - 680013ff
4846 * Camera 68001400 - 680015ff
4847 * VLYNQ (firewall) 68001800 - 68001bff
4848 * VLYNQ 68001e00 - 68001fff
4849 * SSI 68002000 - 680021ff
4850 * L4 68002400 - 680025ff
4851 * DSP (firewall) 68002800 - 68002bff
4852 * DSP subsystem 68002e00 - 68002fff
4853 * IVA (firewall) 68003000 - 680033ff
4854 * IVA 68003600 - 680037ff
4855 * GFX 68003a00 - 68003bff
4856 * CMDWR emulation 68003c00 - 68003dff
4857 * SMS 68004000 - 680041ff
4858 * OCM 68004200 - 680043ff
4859 * GPMC 68004400 - 680045ff
4860 * RAM (firewall) 68005000 - 680053ff
4861 * RAM (err login) 68005400 - 680057ff
4862 * ROM (firewall) 68005800 - 68005bff
4863 * ROM (err login) 68005c00 - 68005fff
4864 * GPMC (firewall) 68006000 - 680063ff
4865 * GPMC (err login) 68006400 - 680067ff
4866 * SMS (err login) 68006c00 - 68006fff
4867 * SMS registers 68008000 - 68008fff
4868 * SDRC registers 68009000 - 68009fff
4869 * GPMC registers 6800a000 6800afff
4872 qemu_register_reset(omap2_mpu_reset
, s
);