2 * TI OMAP processors emulation.
4 * Copyright (C) 2007-2008 Nokia Corporation
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
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include "qemu-timer.h"
27 #include "qemu-char.h"
31 struct omap_gp_timer_s {
37 target_phys_addr_t base;
40 struct omap_target_agent_s *ta;
46 int64_t ticks_per_sec;
57 gpt_trigger_none, gpt_trigger_overflow, gpt_trigger_both
60 gpt_capture_none, gpt_capture_rising,
61 gpt_capture_falling, gpt_capture_both
72 uint32_t capture_val[2];
76 uint16_t writeh; /* LSB */
77 uint16_t readh; /* MSB */
80 #define GPT_TCAR_IT (1 << 2)
81 #define GPT_OVF_IT (1 << 1)
82 #define GPT_MAT_IT (1 << 0)
84 static inline void omap_gp_timer_intr(struct omap_gp_timer_s *timer, int it)
86 if (timer->it_ena & it) {
88 qemu_irq_raise(timer->irq);
91 /* Or are the status bits set even when masked?
92 * i.e. is masking applied before or after the status register? */
95 if (timer->wu_ena & it)
96 qemu_irq_pulse(timer->wkup);
99 static inline void omap_gp_timer_out(struct omap_gp_timer_s *timer, int level)
101 if (!timer->inout && timer->out_val != level) {
102 timer->out_val = level;
103 qemu_set_irq(timer->out, level);
107 static inline uint32_t omap_gp_timer_read(struct omap_gp_timer_s *timer)
111 if (timer->st && timer->rate) {
112 distance = qemu_get_clock(vm_clock) - timer->time;
113 distance = muldiv64(distance, timer->rate, timer->ticks_per_sec);
115 if (distance >= 0xffffffff - timer->val)
118 return timer->val + distance;
123 static inline void omap_gp_timer_sync(struct omap_gp_timer_s *timer)
126 timer->val = omap_gp_timer_read(timer);
127 timer->time = qemu_get_clock(vm_clock);
131 static inline void omap_gp_timer_update(struct omap_gp_timer_s *timer)
133 int64_t expires, matches;
135 if (timer->st && timer->rate) {
136 expires = muldiv64(0x100000000ll - timer->val,
137 timer->ticks_per_sec, timer->rate);
138 qemu_mod_timer(timer->timer, timer->time + expires);
140 if (timer->ce && timer->match_val >= timer->val) {
141 matches = muldiv64(timer->match_val - timer->val,
142 timer->ticks_per_sec, timer->rate);
143 qemu_mod_timer(timer->match, timer->time + matches);
145 qemu_del_timer(timer->match);
147 qemu_del_timer(timer->timer);
148 qemu_del_timer(timer->match);
149 omap_gp_timer_out(timer, timer->scpwm);
153 static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer)
156 /* TODO in overflow-and-match mode if the first event to
157 * occurs is the match, don't toggle. */
158 omap_gp_timer_out(timer, !timer->out_val);
160 /* TODO inverted pulse on timer->out_val == 1? */
161 qemu_irq_pulse(timer->out);
164 static void omap_gp_timer_tick(void *opaque)
166 struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
172 timer->val = timer->load_val;
173 timer->time = qemu_get_clock(vm_clock);
176 if (timer->trigger == gpt_trigger_overflow ||
177 timer->trigger == gpt_trigger_both)
178 omap_gp_timer_trigger(timer);
180 omap_gp_timer_intr(timer, GPT_OVF_IT);
181 omap_gp_timer_update(timer);
184 static void omap_gp_timer_match(void *opaque)
186 struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
188 if (timer->trigger == gpt_trigger_both)
189 omap_gp_timer_trigger(timer);
191 omap_gp_timer_intr(timer, GPT_MAT_IT);
194 static void omap_gp_timer_input(void *opaque, int line, int on)
196 struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
199 switch (s->capture) {
201 case gpt_capture_none:
204 case gpt_capture_rising:
205 trigger = !s->in_val && on;
207 case gpt_capture_falling:
208 trigger = s->in_val && !on;
210 case gpt_capture_both:
211 trigger = (s->in_val == !on);
216 if (s->inout && trigger && s->capt_num < 2) {
217 s->capture_val[s->capt_num] = omap_gp_timer_read(s);
219 if (s->capt2 == s->capt_num ++)
220 omap_gp_timer_intr(s, GPT_TCAR_IT);
224 static void omap_gp_timer_clk_update(void *opaque, int line, int on)
226 struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
228 omap_gp_timer_sync(timer);
229 timer->rate = on ? omap_clk_getrate(timer->clk) : 0;
230 omap_gp_timer_update(timer);
233 static void omap_gp_timer_clk_setup(struct omap_gp_timer_s *timer)
235 omap_clk_adduser(timer->clk,
236 qemu_allocate_irqs(omap_gp_timer_clk_update, timer, 1)[0]);
237 timer->rate = omap_clk_getrate(timer->clk);
240 static void omap_gp_timer_reset(struct omap_gp_timer_s *s)
250 s->trigger = gpt_trigger_none;
251 s->capture = gpt_capture_none;
260 s->load_val = 0x00000000;
261 s->capture_val[0] = 0x00000000;
262 s->capture_val[1] = 0x00000000;
263 s->match_val = 0x00000000;
264 omap_gp_timer_update(s);
267 static uint32_t omap_gp_timer_readw(void *opaque, target_phys_addr_t addr)
269 struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
270 int offset = addr - s->base;
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 *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;
358 int offset = addr - s->base;
361 case 0x00: /* TIDR */
362 case 0x14: /* TISTAT */
363 case 0x34: /* TWPS */
364 case 0x3c: /* TCAR1 */
365 case 0x44: /* TCAR2 */
369 case 0x10: /* TIOCP_CFG */
370 s->config = value & 0x33d;
371 if (((value >> 3) & 3) == 3) /* IDLEMODE */
372 fprintf(stderr, "%s: illegal IDLEMODE value in TIOCP_CFG\n",
374 if (value & 2) /* SOFTRESET */
375 omap_gp_timer_reset(s);
378 case 0x18: /* TISR */
379 if (value & GPT_TCAR_IT)
381 if (s->status && !(s->status &= ~value))
382 qemu_irq_lower(s->irq);
385 case 0x1c: /* TIER */
386 s->it_ena = value & 7;
389 case 0x20: /* TWER */
390 s->wu_ena = value & 7;
393 case 0x24: /* TCLR */
394 omap_gp_timer_sync(s);
395 s->inout = (value >> 14) & 1;
396 s->capt2 = (value >> 13) & 1;
397 s->pt = (value >> 12) & 1;
398 s->trigger = (value >> 10) & 3;
399 if (s->capture == gpt_capture_none &&
400 ((value >> 8) & 3) != gpt_capture_none)
402 s->capture = (value >> 8) & 3;
403 s->scpwm = (value >> 7) & 1;
404 s->ce = (value >> 6) & 1;
405 s->pre = (value >> 5) & 1;
406 s->ptv = (value >> 2) & 7;
407 s->ar = (value >> 1) & 1;
408 s->st = (value >> 0) & 1;
409 if (s->inout && s->trigger != gpt_trigger_none)
410 fprintf(stderr, "%s: GP timer pin must be an output "
411 "for this trigger mode\n", __FUNCTION__);
412 if (!s->inout && s->capture != gpt_capture_none)
413 fprintf(stderr, "%s: GP timer pin must be an input "
414 "for this capture mode\n", __FUNCTION__);
415 if (s->trigger == gpt_trigger_none)
416 omap_gp_timer_out(s, s->scpwm);
417 /* TODO: make sure this doesn't overflow 32-bits */
418 s->ticks_per_sec = ticks_per_sec << (s->pre ? s->ptv + 1 : 0);
419 omap_gp_timer_update(s);
422 case 0x28: /* TCRR */
423 s->time = qemu_get_clock(vm_clock);
425 omap_gp_timer_update(s);
428 case 0x2c: /* TLDR */
432 case 0x30: /* TTGR */
433 s->time = qemu_get_clock(vm_clock);
434 s->val = s->load_val;
435 omap_gp_timer_update(s);
438 case 0x38: /* TMAR */
439 omap_gp_timer_sync(s);
440 s->match_val = value;
441 omap_gp_timer_update(s);
444 case 0x40: /* TSICR */
445 s->posted = (value >> 2) & 1;
446 if (value & 2) /* How much exactly are we supposed to reset? */
447 omap_gp_timer_reset(s);
455 static void omap_gp_timer_writeh(void *opaque, target_phys_addr_t addr,
458 struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
461 return omap_gp_timer_write(opaque, addr, (value << 16) | s->writeh);
463 s->writeh = (uint16_t) value;
466 static CPUWriteMemoryFunc *omap_gp_timer_writefn[] = {
467 omap_badwidth_write32,
468 omap_gp_timer_writeh,
472 struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta,
473 qemu_irq irq, omap_clk fclk, omap_clk iclk)
476 struct omap_gp_timer_s *s = (struct omap_gp_timer_s *)
477 qemu_mallocz(sizeof(struct omap_gp_timer_s));
482 s->timer = qemu_new_timer(vm_clock, omap_gp_timer_tick, s);
483 s->match = qemu_new_timer(vm_clock, omap_gp_timer_match, s);
484 s->in = qemu_allocate_irqs(omap_gp_timer_input, s, 1)[0];
485 omap_gp_timer_reset(s);
486 omap_gp_timer_clk_setup(s);
488 iomemtype = l4_register_io_memory(0, omap_gp_timer_readfn,
489 omap_gp_timer_writefn, s);
490 s->base = omap_l4_attach(ta, 0, iomemtype);
495 /* 32-kHz Sync Timer of the OMAP2 */
496 static uint32_t omap_synctimer_read(struct omap_synctimer_s *s) {
497 return muldiv64(qemu_get_clock(vm_clock), 0x8000, ticks_per_sec);
500 static void omap_synctimer_reset(struct omap_synctimer_s *s)
502 s->val = omap_synctimer_read(s);
505 static uint32_t omap_synctimer_readw(void *opaque, target_phys_addr_t addr)
507 struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
508 int offset = addr - s->base;
511 case 0x00: /* 32KSYNCNT_REV */
515 return omap_synctimer_read(s) - s->val;
522 static uint32_t omap_synctimer_readh(void *opaque, target_phys_addr_t addr)
524 struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
530 ret = omap_synctimer_readw(opaque, addr);
531 s->readh = ret >> 16;
536 static CPUReadMemoryFunc *omap_synctimer_readfn[] = {
537 omap_badwidth_read32,
538 omap_synctimer_readh,
539 omap_synctimer_readw,
542 static void omap_synctimer_write(void *opaque, target_phys_addr_t addr,
548 static CPUWriteMemoryFunc *omap_synctimer_writefn[] = {
549 omap_badwidth_write32,
550 omap_synctimer_write,
551 omap_synctimer_write,
554 void omap_synctimer_init(struct omap_target_agent_s *ta,
555 struct omap_mpu_state_s *mpu, omap_clk fclk, omap_clk iclk)
557 struct omap_synctimer_s *s = &mpu->synctimer;
559 omap_synctimer_reset(s);
560 s->base = omap_l4_attach(ta, 0, l4_register_io_memory(0,
561 omap_synctimer_readfn, omap_synctimer_writefn, s));
564 /* General-Purpose Interface of OMAP2 */
565 struct omap2_gpio_s {
566 target_phys_addr_t base;
570 qemu_irq handler[32];
585 static inline void omap_gpio_module_int_update(struct omap2_gpio_s *s,
588 qemu_set_irq(s->irq[line], s->ints[line] & s->mask[line]);
591 static void omap_gpio_module_wake(struct omap2_gpio_s *s, int line)
593 if (!(s->config[0] & (1 << 2))) /* ENAWAKEUP */
595 if (!(s->config[0] & (3 << 3))) /* Force Idle */
597 if (!(s->wumask & (1 << line)))
600 qemu_irq_raise(s->wkup);
603 static inline void omap_gpio_module_out_update(struct omap2_gpio_s *s,
610 while ((ln = ffs(diff))) {
612 qemu_set_irq(s->handler[ln], (s->outputs >> ln) & 1);
617 static void omap_gpio_module_level_update(struct omap2_gpio_s *s, int line)
619 s->ints[line] |= s->dir &
620 ((s->inputs & s->level[1]) | (~s->inputs & s->level[0]));
621 omap_gpio_module_int_update(s, line);
624 static inline void omap_gpio_module_int(struct omap2_gpio_s *s, int line)
626 s->ints[0] |= 1 << line;
627 omap_gpio_module_int_update(s, 0);
628 s->ints[1] |= 1 << line;
629 omap_gpio_module_int_update(s, 1);
630 omap_gpio_module_wake(s, line);
633 static void omap_gpio_module_set(void *opaque, int line, int level)
635 struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
638 if (s->dir & (1 << line) & ((~s->inputs & s->edge[0]) | s->level[1]))
639 omap_gpio_module_int(s, line);
640 s->inputs |= 1 << line;
642 if (s->dir & (1 << line) & ((s->inputs & s->edge[1]) | s->level[0]))
643 omap_gpio_module_int(s, line);
644 s->inputs &= ~(1 << line);
648 static void omap_gpio_module_reset(struct omap2_gpio_s *s)
666 static uint32_t omap_gpio_module_read(void *opaque, target_phys_addr_t addr)
668 struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
669 int offset = addr - s->base;
672 case 0x00: /* GPIO_REVISION */
675 case 0x10: /* GPIO_SYSCONFIG */
678 case 0x14: /* GPIO_SYSSTATUS */
681 case 0x18: /* GPIO_IRQSTATUS1 */
684 case 0x1c: /* GPIO_IRQENABLE1 */
685 case 0x60: /* GPIO_CLEARIRQENABLE1 */
686 case 0x64: /* GPIO_SETIRQENABLE1 */
689 case 0x20: /* GPIO_WAKEUPENABLE */
690 case 0x80: /* GPIO_CLEARWKUENA */
691 case 0x84: /* GPIO_SETWKUENA */
694 case 0x28: /* GPIO_IRQSTATUS2 */
697 case 0x2c: /* GPIO_IRQENABLE2 */
698 case 0x70: /* GPIO_CLEARIRQENABLE2 */
699 case 0x74: /* GPIO_SETIREQNEABLE2 */
702 case 0x30: /* GPIO_CTRL */
705 case 0x34: /* GPIO_OE */
708 case 0x38: /* GPIO_DATAIN */
711 case 0x3c: /* GPIO_DATAOUT */
712 case 0x90: /* GPIO_CLEARDATAOUT */
713 case 0x94: /* GPIO_SETDATAOUT */
716 case 0x40: /* GPIO_LEVELDETECT0 */
719 case 0x44: /* GPIO_LEVELDETECT1 */
722 case 0x48: /* GPIO_RISINGDETECT */
725 case 0x4c: /* GPIO_FALLINGDETECT */
728 case 0x50: /* GPIO_DEBOUNCENABLE */
731 case 0x54: /* GPIO_DEBOUNCINGTIME */
739 static void omap_gpio_module_write(void *opaque, target_phys_addr_t addr,
742 struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
743 int offset = addr - s->base;
748 case 0x00: /* GPIO_REVISION */
749 case 0x14: /* GPIO_SYSSTATUS */
750 case 0x38: /* GPIO_DATAIN */
754 case 0x10: /* GPIO_SYSCONFIG */
755 if (((value >> 3) & 3) == 3)
756 fprintf(stderr, "%s: bad IDLEMODE value\n", __FUNCTION__);
758 omap_gpio_module_reset(s);
759 s->config[0] = value & 0x1d;
762 case 0x18: /* GPIO_IRQSTATUS1 */
763 if (s->ints[0] & value) {
764 s->ints[0] &= ~value;
765 omap_gpio_module_level_update(s, 0);
769 case 0x1c: /* GPIO_IRQENABLE1 */
771 omap_gpio_module_int_update(s, 0);
774 case 0x20: /* GPIO_WAKEUPENABLE */
778 case 0x28: /* GPIO_IRQSTATUS2 */
779 if (s->ints[1] & value) {
780 s->ints[1] &= ~value;
781 omap_gpio_module_level_update(s, 1);
785 case 0x2c: /* GPIO_IRQENABLE2 */
787 omap_gpio_module_int_update(s, 1);
790 case 0x30: /* GPIO_CTRL */
791 s->config[1] = value & 7;
794 case 0x34: /* GPIO_OE */
795 diff = s->outputs & (s->dir ^ value);
798 value = s->outputs & ~s->dir;
799 while ((ln = ffs(diff))) {
800 diff &= ~(1 <<-- ln);
801 qemu_set_irq(s->handler[ln], (value >> ln) & 1);
804 omap_gpio_module_level_update(s, 0);
805 omap_gpio_module_level_update(s, 1);
808 case 0x3c: /* GPIO_DATAOUT */
809 omap_gpio_module_out_update(s, s->outputs ^ value);
812 case 0x40: /* GPIO_LEVELDETECT0 */
814 omap_gpio_module_level_update(s, 0);
815 omap_gpio_module_level_update(s, 1);
818 case 0x44: /* GPIO_LEVELDETECT1 */
820 omap_gpio_module_level_update(s, 0);
821 omap_gpio_module_level_update(s, 1);
824 case 0x48: /* GPIO_RISINGDETECT */
828 case 0x4c: /* GPIO_FALLINGDETECT */
832 case 0x50: /* GPIO_DEBOUNCENABLE */
836 case 0x54: /* GPIO_DEBOUNCINGTIME */
840 case 0x60: /* GPIO_CLEARIRQENABLE1 */
841 s->mask[0] &= ~value;
842 omap_gpio_module_int_update(s, 0);
845 case 0x64: /* GPIO_SETIRQENABLE1 */
847 omap_gpio_module_int_update(s, 0);
850 case 0x70: /* GPIO_CLEARIRQENABLE2 */
851 s->mask[1] &= ~value;
852 omap_gpio_module_int_update(s, 1);
855 case 0x74: /* GPIO_SETIREQNEABLE2 */
857 omap_gpio_module_int_update(s, 1);
860 case 0x80: /* GPIO_CLEARWKUENA */
864 case 0x84: /* GPIO_SETWKUENA */
868 case 0x90: /* GPIO_CLEARDATAOUT */
869 omap_gpio_module_out_update(s, s->outputs & value);
872 case 0x94: /* GPIO_SETDATAOUT */
873 omap_gpio_module_out_update(s, ~s->outputs & value);
882 static uint32_t omap_gpio_module_readp(void *opaque, target_phys_addr_t addr)
884 return omap_gpio_module_readp(opaque, addr) >> ((addr & 3) << 3);
887 static void omap_gpio_module_writep(void *opaque, target_phys_addr_t addr,
890 struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
891 int offset = addr - s->base;
893 uint32_t mask = 0xffff;
895 switch (offset & ~3) {
896 case 0x00: /* GPIO_REVISION */
897 case 0x14: /* GPIO_SYSSTATUS */
898 case 0x38: /* GPIO_DATAIN */
902 case 0x10: /* GPIO_SYSCONFIG */
903 case 0x1c: /* GPIO_IRQENABLE1 */
904 case 0x20: /* GPIO_WAKEUPENABLE */
905 case 0x2c: /* GPIO_IRQENABLE2 */
906 case 0x30: /* GPIO_CTRL */
907 case 0x34: /* GPIO_OE */
908 case 0x3c: /* GPIO_DATAOUT */
909 case 0x40: /* GPIO_LEVELDETECT0 */
910 case 0x44: /* GPIO_LEVELDETECT1 */
911 case 0x48: /* GPIO_RISINGDETECT */
912 case 0x4c: /* GPIO_FALLINGDETECT */
913 case 0x50: /* GPIO_DEBOUNCENABLE */
914 case 0x54: /* GPIO_DEBOUNCINGTIME */
915 cur = omap_gpio_module_read(opaque, addr & ~3) &
916 ~(mask << ((addr & 3) << 3));
919 case 0x18: /* GPIO_IRQSTATUS1 */
920 case 0x28: /* GPIO_IRQSTATUS2 */
921 case 0x60: /* GPIO_CLEARIRQENABLE1 */
922 case 0x64: /* GPIO_SETIRQENABLE1 */
923 case 0x70: /* GPIO_CLEARIRQENABLE2 */
924 case 0x74: /* GPIO_SETIREQNEABLE2 */
925 case 0x80: /* GPIO_CLEARWKUENA */
926 case 0x84: /* GPIO_SETWKUENA */
927 case 0x90: /* GPIO_CLEARDATAOUT */
928 case 0x94: /* GPIO_SETDATAOUT */
929 value <<= (addr & 3) << 3;
930 omap_gpio_module_write(opaque, addr, cur | value);
939 static CPUReadMemoryFunc *omap_gpio_module_readfn[] = {
940 omap_gpio_module_readp,
941 omap_gpio_module_readp,
942 omap_gpio_module_read,
945 static CPUWriteMemoryFunc *omap_gpio_module_writefn[] = {
946 omap_gpio_module_writep,
947 omap_gpio_module_writep,
948 omap_gpio_module_write,
951 static void omap_gpio_module_init(struct omap2_gpio_s *s,
952 struct omap_target_agent_s *ta, int region,
953 qemu_irq mpu, qemu_irq dsp, qemu_irq wkup,
954 omap_clk fclk, omap_clk iclk)
961 s->in = qemu_allocate_irqs(omap_gpio_module_set, s, 32);
963 iomemtype = l4_register_io_memory(0, omap_gpio_module_readfn,
964 omap_gpio_module_writefn, s);
965 s->base = omap_l4_attach(ta, region, iomemtype);
969 struct omap2_gpio_s module[5];
972 target_phys_addr_t topbase;
977 static void omap_gpif_reset(struct omap_gpif_s *s)
981 for (i = 0; i < s->modules; i ++)
982 omap_gpio_module_reset(s->module + i);
988 static uint32_t omap_gpif_top_read(void *opaque, target_phys_addr_t addr)
990 struct omap_gpif_s *s = (struct omap_gpif_s *) opaque;
991 int offset = addr - s->topbase;
994 case 0x00: /* IPGENERICOCPSPL_REVISION */
997 case 0x10: /* IPGENERICOCPSPL_SYSCONFIG */
1000 case 0x14: /* IPGENERICOCPSPL_SYSSTATUS */
1003 case 0x18: /* IPGENERICOCPSPL_IRQSTATUS */
1006 case 0x40: /* IPGENERICOCPSPL_GPO */
1009 case 0x50: /* IPGENERICOCPSPL_GPI */
1017 static void omap_gpif_top_write(void *opaque, target_phys_addr_t addr,
1020 struct omap_gpif_s *s = (struct omap_gpif_s *) opaque;
1021 int offset = addr - s->topbase;
1024 case 0x00: /* IPGENERICOCPSPL_REVISION */
1025 case 0x14: /* IPGENERICOCPSPL_SYSSTATUS */
1026 case 0x18: /* IPGENERICOCPSPL_IRQSTATUS */
1027 case 0x50: /* IPGENERICOCPSPL_GPI */
1031 case 0x10: /* IPGENERICOCPSPL_SYSCONFIG */
1032 if (value & (1 << 1)) /* SOFTRESET */
1034 s->autoidle = value & 1;
1037 case 0x40: /* IPGENERICOCPSPL_GPO */
1047 static CPUReadMemoryFunc *omap_gpif_top_readfn[] = {
1053 static CPUWriteMemoryFunc *omap_gpif_top_writefn[] = {
1054 omap_gpif_top_write,
1055 omap_gpif_top_write,
1056 omap_gpif_top_write,
1059 struct omap_gpif_s *omap2_gpio_init(struct omap_target_agent_s *ta,
1060 qemu_irq *irq, omap_clk *fclk, omap_clk iclk, int modules)
1063 struct omap_gpif_s *s = (struct omap_gpif_s *)
1064 qemu_mallocz(sizeof(struct omap_gpif_s));
1065 int region[4] = { 0, 2, 4, 5 };
1067 s->modules = modules;
1068 for (i = 0; i < modules; i ++)
1069 omap_gpio_module_init(s->module + i, ta, region[i],
1070 irq[i], 0, 0, fclk[i], iclk);
1074 iomemtype = l4_register_io_memory(0, omap_gpif_top_readfn,
1075 omap_gpif_top_writefn, s);
1076 s->topbase = omap_l4_attach(ta, 1, iomemtype);
1081 qemu_irq *omap2_gpio_in_get(struct omap_gpif_s *s, int start)
1083 if (start >= s->modules * 32 || start < 0)
1084 cpu_abort(cpu_single_env, "%s: No GPIO line %i\n",
1085 __FUNCTION__, start);
1086 return s->module[start >> 5].in + (start & 31);
1089 void omap2_gpio_out_set(struct omap_gpif_s *s, int line, qemu_irq handler)
1091 if (line >= s->modules * 32 || line < 0)
1092 cpu_abort(cpu_single_env, "%s: No GPIO line %i\n", __FUNCTION__, line);
1093 s->module[line >> 5].handler[line & 31] = handler;
1096 /* Multichannel SPI */
1097 struct omap_mcspi_s {
1098 target_phys_addr_t base;
1109 struct omap_mcspi_ch_s {
1112 uint32_t (*txrx)(void *opaque, uint32_t, int);
1124 static inline void omap_mcspi_interrupt_update(struct omap_mcspi_s *s)
1126 qemu_set_irq(s->irq, s->irqst & s->irqen);
1129 static inline void omap_mcspi_dmarequest_update(struct omap_mcspi_ch_s *ch)
1131 qemu_set_irq(ch->txdrq,
1132 (ch->control & 1) && /* EN */
1133 (ch->config & (1 << 14)) && /* DMAW */
1134 (ch->status & (1 << 1)) && /* TXS */
1135 ((ch->config >> 12) & 3) != 1); /* TRM */
1136 qemu_set_irq(ch->rxdrq,
1137 (ch->control & 1) && /* EN */
1138 (ch->config & (1 << 15)) && /* DMAW */
1139 (ch->status & (1 << 0)) && /* RXS */
1140 ((ch->config >> 12) & 3) != 2); /* TRM */
1143 static void omap_mcspi_transfer_run(struct omap_mcspi_s *s, int chnum)
1145 struct omap_mcspi_ch_s *ch = s->ch + chnum;
1147 if (!(ch->control & 1)) /* EN */
1149 if ((ch->status & (1 << 0)) && /* RXS */
1150 ((ch->config >> 12) & 3) != 2 && /* TRM */
1151 !(ch->config & (1 << 19))) /* TURBO */
1153 if ((ch->status & (1 << 1)) && /* TXS */
1154 ((ch->config >> 12) & 3) != 1) /* TRM */
1157 if (!(s->control & 1) || /* SINGLE */
1158 (ch->config & (1 << 20))) { /* FORCE */
1160 ch->rx = ch->txrx(ch->opaque, ch->tx, /* WL */
1161 1 + (0x1f & (ch->config >> 7)));
1165 ch->status |= 1 << 2; /* EOT */
1166 ch->status |= 1 << 1; /* TXS */
1167 if (((ch->config >> 12) & 3) != 2) /* TRM */
1168 ch->status |= 1 << 0; /* RXS */
1171 if ((ch->status & (1 << 0)) && /* RXS */
1172 ((ch->config >> 12) & 3) != 2 && /* TRM */
1173 !(ch->config & (1 << 19))) /* TURBO */
1174 s->irqst |= 1 << (2 + 4 * chnum); /* RX_FULL */
1175 if ((ch->status & (1 << 1)) && /* TXS */
1176 ((ch->config >> 12) & 3) != 1) /* TRM */
1177 s->irqst |= 1 << (0 + 4 * chnum); /* TX_EMPTY */
1178 omap_mcspi_interrupt_update(s);
1179 omap_mcspi_dmarequest_update(ch);
1182 static void omap_mcspi_reset(struct omap_mcspi_s *s)
1193 for (ch = 0; ch < 4; ch ++) {
1194 s->ch[ch].config = 0x060000;
1195 s->ch[ch].status = 2; /* TXS */
1196 s->ch[ch].control = 0;
1198 omap_mcspi_dmarequest_update(s->ch + ch);
1201 omap_mcspi_interrupt_update(s);
1204 static uint32_t omap_mcspi_read(void *opaque, target_phys_addr_t addr)
1206 struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque;
1207 int offset = addr - s->base;
1212 case 0x00: /* MCSPI_REVISION */
1215 case 0x10: /* MCSPI_SYSCONFIG */
1216 return s->sysconfig;
1218 case 0x14: /* MCSPI_SYSSTATUS */
1219 return 1; /* RESETDONE */
1221 case 0x18: /* MCSPI_IRQSTATUS */
1224 case 0x1c: /* MCSPI_IRQENABLE */
1227 case 0x20: /* MCSPI_WAKEUPENABLE */
1230 case 0x24: /* MCSPI_SYST */
1233 case 0x28: /* MCSPI_MODULCTRL */
1239 case 0x2c: /* MCSPI_CHCONF */
1240 return s->ch[ch].config;
1245 case 0x30: /* MCSPI_CHSTAT */
1246 return s->ch[ch].status;
1251 case 0x34: /* MCSPI_CHCTRL */
1252 return s->ch[ch].control;
1257 case 0x38: /* MCSPI_TX */
1258 return s->ch[ch].tx;
1263 case 0x3c: /* MCSPI_RX */
1264 s->ch[ch].status &= ~(1 << 0); /* RXS */
1266 omap_mcspi_transfer_run(s, ch);
1274 static void omap_mcspi_write(void *opaque, target_phys_addr_t addr,
1277 struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque;
1278 int offset = addr - s->base;
1282 case 0x00: /* MCSPI_REVISION */
1283 case 0x14: /* MCSPI_SYSSTATUS */
1284 case 0x30: /* MCSPI_CHSTAT0 */
1285 case 0x3c: /* MCSPI_RX0 */
1286 case 0x44: /* MCSPI_CHSTAT1 */
1287 case 0x50: /* MCSPI_RX1 */
1288 case 0x58: /* MCSPI_CHSTAT2 */
1289 case 0x64: /* MCSPI_RX2 */
1290 case 0x6c: /* MCSPI_CHSTAT3 */
1291 case 0x78: /* MCSPI_RX3 */
1295 case 0x10: /* MCSPI_SYSCONFIG */
1296 if (value & (1 << 1)) /* SOFTRESET */
1297 omap_mcspi_reset(s);
1298 s->sysconfig = value & 0x31d;
1301 case 0x18: /* MCSPI_IRQSTATUS */
1302 if (!((s->control & (1 << 3)) && (s->systest & (1 << 11)))) {
1304 omap_mcspi_interrupt_update(s);
1308 case 0x1c: /* MCSPI_IRQENABLE */
1309 s->irqen = value & 0x1777f;
1310 omap_mcspi_interrupt_update(s);
1313 case 0x20: /* MCSPI_WAKEUPENABLE */
1314 s->wken = value & 1;
1317 case 0x24: /* MCSPI_SYST */
1318 if (s->control & (1 << 3)) /* SYSTEM_TEST */
1319 if (value & (1 << 11)) { /* SSB */
1320 s->irqst |= 0x1777f;
1321 omap_mcspi_interrupt_update(s);
1323 s->systest = value & 0xfff;
1326 case 0x28: /* MCSPI_MODULCTRL */
1327 if (value & (1 << 3)) /* SYSTEM_TEST */
1328 if (s->systest & (1 << 11)) { /* SSB */
1329 s->irqst |= 0x1777f;
1330 omap_mcspi_interrupt_update(s);
1332 s->control = value & 0xf;
1338 case 0x2c: /* MCSPI_CHCONF */
1339 if ((value ^ s->ch[ch].config) & (3 << 14)) /* DMAR | DMAW */
1340 omap_mcspi_dmarequest_update(s->ch + ch);
1341 if (((value >> 12) & 3) == 3) /* TRM */
1342 fprintf(stderr, "%s: invalid TRM value (3)\n", __FUNCTION__);
1343 if (((value >> 7) & 0x1f) < 3) /* WL */
1344 fprintf(stderr, "%s: invalid WL value (%i)\n",
1345 __FUNCTION__, (value >> 7) & 0x1f);
1346 s->ch[ch].config = value & 0x7fffff;
1352 case 0x34: /* MCSPI_CHCTRL */
1353 if (value & ~s->ch[ch].control & 1) { /* EN */
1354 s->ch[ch].control |= 1;
1355 omap_mcspi_transfer_run(s, ch);
1357 s->ch[ch].control = value & 1;
1363 case 0x38: /* MCSPI_TX */
1364 s->ch[ch].tx = value;
1365 s->ch[ch].status &= ~(1 << 1); /* TXS */
1366 omap_mcspi_transfer_run(s, ch);
1375 static CPUReadMemoryFunc *omap_mcspi_readfn[] = {
1376 omap_badwidth_read32,
1377 omap_badwidth_read32,
1381 static CPUWriteMemoryFunc *omap_mcspi_writefn[] = {
1382 omap_badwidth_write32,
1383 omap_badwidth_write32,
1387 struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum,
1388 qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk)
1391 struct omap_mcspi_s *s = (struct omap_mcspi_s *)
1392 qemu_mallocz(sizeof(struct omap_mcspi_s));
1393 struct omap_mcspi_ch_s *ch = s->ch;
1398 ch->txdrq = *drq ++;
1399 ch->rxdrq = *drq ++;
1402 omap_mcspi_reset(s);
1404 iomemtype = l4_register_io_memory(0, omap_mcspi_readfn,
1405 omap_mcspi_writefn, s);
1406 s->base = omap_l4_attach(ta, 0, iomemtype);
1411 void omap_mcspi_attach(struct omap_mcspi_s *s,
1412 uint32_t (*txrx)(void *opaque, uint32_t, int), void *opaque,
1415 if (chipselect < 0 || chipselect >= s->chnum)
1416 cpu_abort(cpu_single_env, "%s: Bad chipselect %i\n",
1417 __FUNCTION__, chipselect);
1419 s->ch[chipselect].txrx = txrx;
1420 s->ch[chipselect].opaque = opaque;
1423 /* STI/XTI (emulation interface) console - reverse engineered only */
1425 target_phys_addr_t base;
1426 target_phys_addr_t channel_base;
1428 CharDriverState *chr;
1434 uint32_t clkcontrol;
1435 uint32_t serial_config;
1438 #define STI_TRACE_CONSOLE_CHANNEL 239
1439 #define STI_TRACE_CONTROL_CHANNEL 253
1441 static inline void omap_sti_interrupt_update(struct omap_sti_s *s)
1443 qemu_set_irq(s->irq, s->irqst & s->irqen);
1446 static void omap_sti_reset(struct omap_sti_s *s)
1452 s->serial_config = 0;
1454 omap_sti_interrupt_update(s);
1457 static uint32_t omap_sti_read(void *opaque, target_phys_addr_t addr)
1459 struct omap_sti_s *s = (struct omap_sti_s *) opaque;
1460 int offset = addr - s->base;
1463 case 0x00: /* STI_REVISION */
1466 case 0x10: /* STI_SYSCONFIG */
1467 return s->sysconfig;
1469 case 0x14: /* STI_SYSSTATUS / STI_RX_STATUS / XTI_SYSSTATUS */
1472 case 0x18: /* STI_IRQSTATUS */
1475 case 0x1c: /* STI_IRQSETEN / STI_IRQCLREN */
1478 case 0x24: /* STI_ER / STI_DR / XTI_TRACESELECT */
1479 case 0x28: /* STI_RX_DR / XTI_RXDATA */
1483 case 0x2c: /* STI_CLK_CTRL / XTI_SCLKCRTL */
1484 return s->clkcontrol;
1486 case 0x30: /* STI_SERIAL_CFG / XTI_SCONFIG */
1487 return s->serial_config;
1494 static void omap_sti_write(void *opaque, target_phys_addr_t addr,
1497 struct omap_sti_s *s = (struct omap_sti_s *) opaque;
1498 int offset = addr - s->base;
1501 case 0x00: /* STI_REVISION */
1502 case 0x14: /* STI_SYSSTATUS / STI_RX_STATUS / XTI_SYSSTATUS */
1506 case 0x10: /* STI_SYSCONFIG */
1507 if (value & (1 << 1)) /* SOFTRESET */
1509 s->sysconfig = value & 0xfe;
1512 case 0x18: /* STI_IRQSTATUS */
1514 omap_sti_interrupt_update(s);
1517 case 0x1c: /* STI_IRQSETEN / STI_IRQCLREN */
1518 s->irqen = value & 0xffff;
1519 omap_sti_interrupt_update(s);
1522 case 0x2c: /* STI_CLK_CTRL / XTI_SCLKCRTL */
1523 s->clkcontrol = value & 0xff;
1526 case 0x30: /* STI_SERIAL_CFG / XTI_SCONFIG */
1527 s->serial_config = value & 0xff;
1530 case 0x24: /* STI_ER / STI_DR / XTI_TRACESELECT */
1531 case 0x28: /* STI_RX_DR / XTI_RXDATA */
1541 static CPUReadMemoryFunc *omap_sti_readfn[] = {
1542 omap_badwidth_read32,
1543 omap_badwidth_read32,
1547 static CPUWriteMemoryFunc *omap_sti_writefn[] = {
1548 omap_badwidth_write32,
1549 omap_badwidth_write32,
1553 static uint32_t omap_sti_fifo_read(void *opaque, target_phys_addr_t addr)
1559 static void omap_sti_fifo_write(void *opaque, target_phys_addr_t addr,
1562 struct omap_sti_s *s = (struct omap_sti_s *) opaque;
1563 int offset = addr - s->channel_base;
1564 int ch = offset >> 6;
1565 uint8_t byte = value;
1567 if (ch == STI_TRACE_CONTROL_CHANNEL) {
1568 /* Flush channel <i>value</i>. */
1569 qemu_chr_write(s->chr, "\r", 1);
1570 } else if (ch == STI_TRACE_CONSOLE_CHANNEL || 1) {
1571 if (value == 0xc0 || value == 0xc3) {
1572 /* Open channel <i>ch</i>. */
1573 } else if (value == 0x00)
1574 qemu_chr_write(s->chr, "\n", 1);
1576 qemu_chr_write(s->chr, &byte, 1);
1580 static CPUReadMemoryFunc *omap_sti_fifo_readfn[] = {
1582 omap_badwidth_read8,
1583 omap_badwidth_read8,
1586 static CPUWriteMemoryFunc *omap_sti_fifo_writefn[] = {
1587 omap_sti_fifo_write,
1588 omap_badwidth_write8,
1589 omap_badwidth_write8,
1592 struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta,
1593 target_phys_addr_t channel_base, qemu_irq irq, omap_clk clk,
1594 CharDriverState *chr)
1597 struct omap_sti_s *s = (struct omap_sti_s *)
1598 qemu_mallocz(sizeof(struct omap_sti_s));
1603 s->chr = chr ?: qemu_chr_open("null");
1605 iomemtype = l4_register_io_memory(0, omap_sti_readfn,
1606 omap_sti_writefn, s);
1607 s->base = omap_l4_attach(ta, 0, iomemtype);
1609 iomemtype = cpu_register_io_memory(0, omap_sti_fifo_readfn,
1610 omap_sti_fifo_writefn, s);
1611 s->channel_base = channel_base;
1612 cpu_register_physical_memory(s->channel_base, 0x10000, iomemtype);
1617 /* L4 Interconnect */
1618 struct omap_target_agent_s {
1619 struct omap_l4_s *bus;
1621 struct omap_l4_region_s *start;
1622 target_phys_addr_t base;
1629 target_phys_addr_t base;
1631 struct omap_target_agent_s ta[0];
1635 static int omap_l4_io_entries;
1636 static int omap_cpu_io_entry;
1637 static struct omap_l4_entry {
1638 CPUReadMemoryFunc **mem_read;
1639 CPUWriteMemoryFunc **mem_write;
1641 } *omap_l4_io_entry;
1642 static CPUReadMemoryFunc **omap_l4_io_readb_fn;
1643 static CPUReadMemoryFunc **omap_l4_io_readh_fn;
1644 static CPUReadMemoryFunc **omap_l4_io_readw_fn;
1645 static CPUWriteMemoryFunc **omap_l4_io_writeb_fn;
1646 static CPUWriteMemoryFunc **omap_l4_io_writeh_fn;
1647 static CPUWriteMemoryFunc **omap_l4_io_writew_fn;
1648 static void **omap_l4_io_opaque;
1650 int l4_register_io_memory(int io_index, CPUReadMemoryFunc **mem_read,
1651 CPUWriteMemoryFunc **mem_write, void *opaque)
1653 omap_l4_io_entry[omap_l4_io_entries].mem_read = mem_read;
1654 omap_l4_io_entry[omap_l4_io_entries].mem_write = mem_write;
1655 omap_l4_io_entry[omap_l4_io_entries].opaque = opaque;
1657 return omap_l4_io_entries ++;
1660 static uint32_t omap_l4_io_readb(void *opaque, target_phys_addr_t addr)
1662 unsigned int i = (addr - OMAP2_L4_BASE) >> TARGET_PAGE_BITS;
1664 return omap_l4_io_readb_fn[i](omap_l4_io_opaque[i], addr);
1667 static uint32_t omap_l4_io_readh(void *opaque, target_phys_addr_t addr)
1669 unsigned int i = (addr - OMAP2_L4_BASE) >> TARGET_PAGE_BITS;
1671 return omap_l4_io_readh_fn[i](omap_l4_io_opaque[i], addr);
1674 static uint32_t omap_l4_io_readw(void *opaque, target_phys_addr_t addr)
1676 unsigned int i = (addr - OMAP2_L4_BASE) >> TARGET_PAGE_BITS;
1678 return omap_l4_io_readw_fn[i](omap_l4_io_opaque[i], addr);
1681 static void omap_l4_io_writeb(void *opaque, target_phys_addr_t addr,
1684 unsigned int i = (addr - OMAP2_L4_BASE) >> TARGET_PAGE_BITS;
1686 return omap_l4_io_writeb_fn[i](omap_l4_io_opaque[i], addr, value);
1689 static void omap_l4_io_writeh(void *opaque, target_phys_addr_t addr,
1692 unsigned int i = (addr - OMAP2_L4_BASE) >> TARGET_PAGE_BITS;
1694 return omap_l4_io_writeh_fn[i](omap_l4_io_opaque[i], addr, value);
1697 static void omap_l4_io_writew(void *opaque, target_phys_addr_t addr,
1700 unsigned int i = (addr - OMAP2_L4_BASE) >> TARGET_PAGE_BITS;
1702 return omap_l4_io_writew_fn[i](omap_l4_io_opaque[i], addr, value);
1705 static CPUReadMemoryFunc *omap_l4_io_readfn[] = {
1711 static CPUWriteMemoryFunc *omap_l4_io_writefn[] = {
1718 struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num)
1720 struct omap_l4_s *bus = qemu_mallocz(
1721 sizeof(*bus) + ta_num * sizeof(*bus->ta));
1723 bus->ta_num = ta_num;
1727 omap_l4_io_entries = 1;
1728 omap_l4_io_entry = qemu_mallocz(125 * sizeof(*omap_l4_io_entry));
1731 cpu_register_io_memory(0, omap_l4_io_readfn,
1732 omap_l4_io_writefn, bus);
1733 # define L4_PAGES (0xb4000 / TARGET_PAGE_SIZE)
1734 omap_l4_io_readb_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
1735 omap_l4_io_readh_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
1736 omap_l4_io_readw_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
1737 omap_l4_io_writeb_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
1738 omap_l4_io_writeh_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
1739 omap_l4_io_writew_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
1740 omap_l4_io_opaque = qemu_mallocz(sizeof(void *) * L4_PAGES);
1746 static uint32_t omap_l4ta_read(void *opaque, target_phys_addr_t addr)
1748 struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque;
1749 target_phys_addr_t reg = addr - s->base;
1752 case 0x00: /* COMPONENT */
1753 return s->component;
1755 case 0x20: /* AGENT_CONTROL */
1758 case 0x28: /* AGENT_STATUS */
1766 static void omap_l4ta_write(void *opaque, target_phys_addr_t addr,
1769 struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque;
1770 target_phys_addr_t reg = addr - s->base;
1773 case 0x00: /* COMPONENT */
1774 case 0x28: /* AGENT_STATUS */
1778 case 0x20: /* AGENT_CONTROL */
1779 s->control = value & 0x01000700;
1780 if (value & 1) /* OCP_RESET */
1781 s->status &= ~1; /* REQ_TIMEOUT */
1789 static CPUReadMemoryFunc *omap_l4ta_readfn[] = {
1790 omap_badwidth_read16,
1792 omap_badwidth_read16,
1795 static CPUWriteMemoryFunc *omap_l4ta_writefn[] = {
1796 omap_badwidth_write32,
1797 omap_badwidth_write32,
1802 #define L4TAO(n) ((n) + 39)
1804 static struct omap_l4_region_s {
1805 target_phys_addr_t offset;
1808 } omap_l4_region[125] = {
1809 [ 1] = { 0x40800, 0x800, 32 }, /* Initiator agent */
1810 [ 2] = { 0x41000, 0x1000, 32 }, /* Link agent */
1811 [ 0] = { 0x40000, 0x800, 32 }, /* Address and protection */
1812 [ 3] = { 0x00000, 0x1000, 32 | 16 | 8 }, /* System Control and Pinout */
1813 [ 4] = { 0x01000, 0x1000, 32 | 16 | 8 }, /* L4TAO1 */
1814 [ 5] = { 0x04000, 0x1000, 32 | 16 }, /* 32K Timer */
1815 [ 6] = { 0x05000, 0x1000, 32 | 16 | 8 }, /* L4TAO2 */
1816 [ 7] = { 0x08000, 0x800, 32 }, /* PRCM Region A */
1817 [ 8] = { 0x08800, 0x800, 32 }, /* PRCM Region B */
1818 [ 9] = { 0x09000, 0x1000, 32 | 16 | 8 }, /* L4TAO */
1819 [ 10] = { 0x12000, 0x1000, 32 | 16 | 8 }, /* Test (BCM) */
1820 [ 11] = { 0x13000, 0x1000, 32 | 16 | 8 }, /* L4TA1 */
1821 [ 12] = { 0x14000, 0x1000, 32 }, /* Test/emulation (TAP) */
1822 [ 13] = { 0x15000, 0x1000, 32 | 16 | 8 }, /* L4TA2 */
1823 [ 14] = { 0x18000, 0x1000, 32 | 16 | 8 }, /* GPIO1 */
1824 [ 16] = { 0x1a000, 0x1000, 32 | 16 | 8 }, /* GPIO2 */
1825 [ 18] = { 0x1c000, 0x1000, 32 | 16 | 8 }, /* GPIO3 */
1826 [ 19] = { 0x1e000, 0x1000, 32 | 16 | 8 }, /* GPIO4 */
1827 [ 15] = { 0x19000, 0x1000, 32 | 16 | 8 }, /* Quad GPIO TOP */
1828 [ 17] = { 0x1b000, 0x1000, 32 | 16 | 8 }, /* L4TA3 */
1829 [ 20] = { 0x20000, 0x1000, 32 | 16 | 8 }, /* WD Timer 1 (Secure) */
1830 [ 22] = { 0x22000, 0x1000, 32 | 16 | 8 }, /* WD Timer 2 (OMAP) */
1831 [ 21] = { 0x21000, 0x1000, 32 | 16 | 8 }, /* Dual WD timer TOP */
1832 [ 23] = { 0x23000, 0x1000, 32 | 16 | 8 }, /* L4TA4 */
1833 [ 24] = { 0x28000, 0x1000, 32 | 16 | 8 }, /* GP Timer 1 */
1834 [ 25] = { 0x29000, 0x1000, 32 | 16 | 8 }, /* L4TA7 */
1835 [ 26] = { 0x48000, 0x2000, 32 | 16 | 8 }, /* Emulation (ARM11ETB) */
1836 [ 27] = { 0x4a000, 0x1000, 32 | 16 | 8 }, /* L4TA9 */
1837 [ 28] = { 0x50000, 0x400, 32 | 16 | 8 }, /* Display top */
1838 [ 29] = { 0x50400, 0x400, 32 | 16 | 8 }, /* Display control */
1839 [ 30] = { 0x50800, 0x400, 32 | 16 | 8 }, /* Display RFBI */
1840 [ 31] = { 0x50c00, 0x400, 32 | 16 | 8 }, /* Display encoder */
1841 [ 32] = { 0x51000, 0x1000, 32 | 16 | 8 }, /* L4TA10 */
1842 [ 33] = { 0x52000, 0x400, 32 | 16 | 8 }, /* Camera top */
1843 [ 34] = { 0x52400, 0x400, 32 | 16 | 8 }, /* Camera core */
1844 [ 35] = { 0x52800, 0x400, 32 | 16 | 8 }, /* Camera DMA */
1845 [ 36] = { 0x52c00, 0x400, 32 | 16 | 8 }, /* Camera MMU */
1846 [ 37] = { 0x53000, 0x1000, 32 | 16 | 8 }, /* L4TA11 */
1847 [ 38] = { 0x56000, 0x1000, 32 | 16 | 8 }, /* sDMA */
1848 [ 39] = { 0x57000, 0x1000, 32 | 16 | 8 }, /* L4TA12 */
1849 [ 40] = { 0x58000, 0x1000, 32 | 16 | 8 }, /* SSI top */
1850 [ 41] = { 0x59000, 0x1000, 32 | 16 | 8 }, /* SSI GDD */
1851 [ 42] = { 0x5a000, 0x1000, 32 | 16 | 8 }, /* SSI Port1 */
1852 [ 43] = { 0x5b000, 0x1000, 32 | 16 | 8 }, /* SSI Port2 */
1853 [ 44] = { 0x5c000, 0x1000, 32 | 16 | 8 }, /* L4TA13 */
1854 [ 45] = { 0x5e000, 0x1000, 32 | 16 | 8 }, /* USB OTG */
1855 [ 46] = { 0x5f000, 0x1000, 32 | 16 | 8 }, /* L4TAO4 */
1856 [ 47] = { 0x60000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER1SDRC) */
1857 [ 48] = { 0x61000, 0x1000, 32 | 16 | 8 }, /* L4TA14 */
1858 [ 49] = { 0x62000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER2GPMC) */
1859 [ 50] = { 0x63000, 0x1000, 32 | 16 | 8 }, /* L4TA15 */
1860 [ 51] = { 0x64000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER3OCM) */
1861 [ 52] = { 0x65000, 0x1000, 32 | 16 | 8 }, /* L4TA16 */
1862 [ 53] = { 0x66000, 0x300, 32 | 16 | 8 }, /* Emulation (WIN_TRACER4L4) */
1863 [ 54] = { 0x67000, 0x1000, 32 | 16 | 8 }, /* L4TA17 */
1864 [ 55] = { 0x68000, 0x1000, 32 | 16 | 8 }, /* Emulation (XTI) */
1865 [ 56] = { 0x69000, 0x1000, 32 | 16 | 8 }, /* L4TA18 */
1866 [ 57] = { 0x6a000, 0x1000, 16 | 8 }, /* UART1 */
1867 [ 58] = { 0x6b000, 0x1000, 32 | 16 | 8 }, /* L4TA19 */
1868 [ 59] = { 0x6c000, 0x1000, 16 | 8 }, /* UART2 */
1869 [ 60] = { 0x6d000, 0x1000, 32 | 16 | 8 }, /* L4TA20 */
1870 [ 61] = { 0x6e000, 0x1000, 16 | 8 }, /* UART3 */
1871 [ 62] = { 0x6f000, 0x1000, 32 | 16 | 8 }, /* L4TA21 */
1872 [ 63] = { 0x70000, 0x1000, 16 }, /* I2C1 */
1873 [ 64] = { 0x71000, 0x1000, 32 | 16 | 8 }, /* L4TAO5 */
1874 [ 65] = { 0x72000, 0x1000, 16 }, /* I2C2 */
1875 [ 66] = { 0x73000, 0x1000, 32 | 16 | 8 }, /* L4TAO6 */
1876 [ 67] = { 0x74000, 0x1000, 16 }, /* McBSP1 */
1877 [ 68] = { 0x75000, 0x1000, 32 | 16 | 8 }, /* L4TAO7 */
1878 [ 69] = { 0x76000, 0x1000, 16 }, /* McBSP2 */
1879 [ 70] = { 0x77000, 0x1000, 32 | 16 | 8 }, /* L4TAO8 */
1880 [ 71] = { 0x24000, 0x1000, 32 | 16 | 8 }, /* WD Timer 3 (DSP) */
1881 [ 72] = { 0x25000, 0x1000, 32 | 16 | 8 }, /* L4TA5 */
1882 [ 73] = { 0x26000, 0x1000, 32 | 16 | 8 }, /* WD Timer 4 (IVA) */
1883 [ 74] = { 0x27000, 0x1000, 32 | 16 | 8 }, /* L4TA6 */
1884 [ 75] = { 0x2a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 2 */
1885 [ 76] = { 0x2b000, 0x1000, 32 | 16 | 8 }, /* L4TA8 */
1886 [ 77] = { 0x78000, 0x1000, 32 | 16 | 8 }, /* GP Timer 3 */
1887 [ 78] = { 0x79000, 0x1000, 32 | 16 | 8 }, /* L4TA22 */
1888 [ 79] = { 0x7a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 4 */
1889 [ 80] = { 0x7b000, 0x1000, 32 | 16 | 8 }, /* L4TA23 */
1890 [ 81] = { 0x7c000, 0x1000, 32 | 16 | 8 }, /* GP Timer 5 */
1891 [ 82] = { 0x7d000, 0x1000, 32 | 16 | 8 }, /* L4TA24 */
1892 [ 83] = { 0x7e000, 0x1000, 32 | 16 | 8 }, /* GP Timer 6 */
1893 [ 84] = { 0x7f000, 0x1000, 32 | 16 | 8 }, /* L4TA25 */
1894 [ 85] = { 0x80000, 0x1000, 32 | 16 | 8 }, /* GP Timer 7 */
1895 [ 86] = { 0x81000, 0x1000, 32 | 16 | 8 }, /* L4TA26 */
1896 [ 87] = { 0x82000, 0x1000, 32 | 16 | 8 }, /* GP Timer 8 */
1897 [ 88] = { 0x83000, 0x1000, 32 | 16 | 8 }, /* L4TA27 */
1898 [ 89] = { 0x84000, 0x1000, 32 | 16 | 8 }, /* GP Timer 9 */
1899 [ 90] = { 0x85000, 0x1000, 32 | 16 | 8 }, /* L4TA28 */
1900 [ 91] = { 0x86000, 0x1000, 32 | 16 | 8 }, /* GP Timer 10 */
1901 [ 92] = { 0x87000, 0x1000, 32 | 16 | 8 }, /* L4TA29 */
1902 [ 93] = { 0x88000, 0x1000, 32 | 16 | 8 }, /* GP Timer 11 */
1903 [ 94] = { 0x89000, 0x1000, 32 | 16 | 8 }, /* L4TA30 */
1904 [ 95] = { 0x8a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 12 */
1905 [ 96] = { 0x8b000, 0x1000, 32 | 16 | 8 }, /* L4TA31 */
1906 [ 97] = { 0x90000, 0x1000, 16 }, /* EAC */
1907 [ 98] = { 0x91000, 0x1000, 32 | 16 | 8 }, /* L4TA32 */
1908 [ 99] = { 0x92000, 0x1000, 16 }, /* FAC */
1909 [100] = { 0x93000, 0x1000, 32 | 16 | 8 }, /* L4TA33 */
1910 [101] = { 0x94000, 0x1000, 32 | 16 | 8 }, /* IPC (MAILBOX) */
1911 [102] = { 0x95000, 0x1000, 32 | 16 | 8 }, /* L4TA34 */
1912 [103] = { 0x98000, 0x1000, 32 | 16 | 8 }, /* SPI1 */
1913 [104] = { 0x99000, 0x1000, 32 | 16 | 8 }, /* L4TA35 */
1914 [105] = { 0x9a000, 0x1000, 32 | 16 | 8 }, /* SPI2 */
1915 [106] = { 0x9b000, 0x1000, 32 | 16 | 8 }, /* L4TA36 */
1916 [107] = { 0x9c000, 0x1000, 16 | 8 }, /* MMC SDIO */
1917 [108] = { 0x9d000, 0x1000, 32 | 16 | 8 }, /* L4TAO9 */
1918 [109] = { 0x9e000, 0x1000, 32 | 16 | 8 }, /* MS_PRO */
1919 [110] = { 0x9f000, 0x1000, 32 | 16 | 8 }, /* L4TAO10 */
1920 [111] = { 0xa0000, 0x1000, 32 }, /* RNG */
1921 [112] = { 0xa1000, 0x1000, 32 | 16 | 8 }, /* L4TAO11 */
1922 [113] = { 0xa2000, 0x1000, 32 }, /* DES3DES */
1923 [114] = { 0xa3000, 0x1000, 32 | 16 | 8 }, /* L4TAO12 */
1924 [115] = { 0xa4000, 0x1000, 32 }, /* SHA1MD5 */
1925 [116] = { 0xa5000, 0x1000, 32 | 16 | 8 }, /* L4TAO13 */
1926 [117] = { 0xa6000, 0x1000, 32 }, /* AES */
1927 [118] = { 0xa7000, 0x1000, 32 | 16 | 8 }, /* L4TA37 */
1928 [119] = { 0xa8000, 0x2000, 32 }, /* PKA */
1929 [120] = { 0xaa000, 0x1000, 32 | 16 | 8 }, /* L4TA38 */
1930 [121] = { 0xb0000, 0x1000, 32 }, /* MG */
1931 [122] = { 0xb1000, 0x1000, 32 | 16 | 8 },
1932 [123] = { 0xb2000, 0x1000, 32 }, /* HDQ/1-Wire */
1933 [124] = { 0xb3000, 0x1000, 32 | 16 | 8 }, /* L4TA39 */
1936 static struct omap_l4_agent_info_s {
1941 } omap_l4_agent_info[54] = {
1942 { 0, 0, 3, 2 }, /* L4IA initiatior agent */
1943 { L4TAO(1), 3, 2, 1 }, /* Control and pinout module */
1944 { L4TAO(2), 5, 2, 1 }, /* 32K timer */
1945 { L4TAO(3), 7, 3, 2 }, /* PRCM */
1946 { L4TA(1), 10, 2, 1 }, /* BCM */
1947 { L4TA(2), 12, 2, 1 }, /* Test JTAG */
1948 { L4TA(3), 14, 6, 3 }, /* Quad GPIO */
1949 { L4TA(4), 20, 4, 3 }, /* WD timer 1/2 */
1950 { L4TA(7), 24, 2, 1 }, /* GP timer 1 */
1951 { L4TA(9), 26, 2, 1 }, /* ATM11 ETB */
1952 { L4TA(10), 28, 5, 4 }, /* Display subsystem */
1953 { L4TA(11), 33, 5, 4 }, /* Camera subsystem */
1954 { L4TA(12), 38, 2, 1 }, /* sDMA */
1955 { L4TA(13), 40, 5, 4 }, /* SSI */
1956 { L4TAO(4), 45, 2, 1 }, /* USB */
1957 { L4TA(14), 47, 2, 1 }, /* Win Tracer1 */
1958 { L4TA(15), 49, 2, 1 }, /* Win Tracer2 */
1959 { L4TA(16), 51, 2, 1 }, /* Win Tracer3 */
1960 { L4TA(17), 53, 2, 1 }, /* Win Tracer4 */
1961 { L4TA(18), 55, 2, 1 }, /* XTI */
1962 { L4TA(19), 57, 2, 1 }, /* UART1 */
1963 { L4TA(20), 59, 2, 1 }, /* UART2 */
1964 { L4TA(21), 61, 2, 1 }, /* UART3 */
1965 { L4TAO(5), 63, 2, 1 }, /* I2C1 */
1966 { L4TAO(6), 65, 2, 1 }, /* I2C2 */
1967 { L4TAO(7), 67, 2, 1 }, /* McBSP1 */
1968 { L4TAO(8), 69, 2, 1 }, /* McBSP2 */
1969 { L4TA(5), 71, 2, 1 }, /* WD Timer 3 (DSP) */
1970 { L4TA(6), 73, 2, 1 }, /* WD Timer 4 (IVA) */
1971 { L4TA(8), 75, 2, 1 }, /* GP Timer 2 */
1972 { L4TA(22), 77, 2, 1 }, /* GP Timer 3 */
1973 { L4TA(23), 79, 2, 1 }, /* GP Timer 4 */
1974 { L4TA(24), 81, 2, 1 }, /* GP Timer 5 */
1975 { L4TA(25), 83, 2, 1 }, /* GP Timer 6 */
1976 { L4TA(26), 85, 2, 1 }, /* GP Timer 7 */
1977 { L4TA(27), 87, 2, 1 }, /* GP Timer 8 */
1978 { L4TA(28), 89, 2, 1 }, /* GP Timer 9 */
1979 { L4TA(29), 91, 2, 1 }, /* GP Timer 10 */
1980 { L4TA(30), 93, 2, 1 }, /* GP Timer 11 */
1981 { L4TA(31), 95, 2, 1 }, /* GP Timer 12 */
1982 { L4TA(32), 97, 2, 1 }, /* EAC */
1983 { L4TA(33), 99, 2, 1 }, /* FAC */
1984 { L4TA(34), 101, 2, 1 }, /* IPC */
1985 { L4TA(35), 103, 2, 1 }, /* SPI1 */
1986 { L4TA(36), 105, 2, 1 }, /* SPI2 */
1987 { L4TAO(9), 107, 2, 1 }, /* MMC SDIO */
1988 { L4TAO(10), 109, 2, 1 },
1989 { L4TAO(11), 111, 2, 1 }, /* RNG */
1990 { L4TAO(12), 113, 2, 1 }, /* DES3DES */
1991 { L4TAO(13), 115, 2, 1 }, /* SHA1MD5 */
1992 { L4TA(37), 117, 2, 1 }, /* AES */
1993 { L4TA(38), 119, 2, 1 }, /* PKA */
1995 { L4TA(39), 123, 2, 1 }, /* HDQ/1-Wire */
1998 #define omap_l4ta(bus, cs) omap_l4ta_get(bus, L4TA(cs))
1999 #define omap_l4tao(bus, cs) omap_l4ta_get(bus, L4TAO(cs))
2001 struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus, int cs)
2004 struct omap_target_agent_s *ta = 0;
2005 struct omap_l4_agent_info_s *info = 0;
2007 for (i = 0; i < bus->ta_num; i ++)
2008 if (omap_l4_agent_info[i].ta == cs) {
2010 info = &omap_l4_agent_info[i];
2014 fprintf(stderr, "%s: bad target agent (%i)\n", __FUNCTION__, cs);
2019 ta->start = &omap_l4_region[info->region];
2020 ta->regions = info->regions;
2022 ta->component = ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
2023 ta->status = 0x00000000;
2024 ta->control = 0x00000200; /* XXX 01000200 for L4TAO */
2026 iomemtype = l4_register_io_memory(0, omap_l4ta_readfn,
2027 omap_l4ta_writefn, ta);
2028 ta->base = omap_l4_attach(ta, info->ta_region, iomemtype);
2033 target_phys_addr_t omap_l4_attach(struct omap_target_agent_s *ta, int region,
2036 target_phys_addr_t base;
2042 if (region < 0 || region >= ta->regions) {
2043 fprintf(stderr, "%s: bad io region (%i)\n", __FUNCTION__, region);
2047 base = ta->bus->base + ta->start[region].offset;
2048 size = ta->start[region].size;
2051 cpu_register_physical_memory(base, size, iotype);
2053 cpu_register_physical_memory(base, size, omap_cpu_io_entry);
2054 i = (base - ta->bus->base) / TARGET_PAGE_SIZE;
2055 for (; size > 0; size -= TARGET_PAGE_SIZE, i ++) {
2056 omap_l4_io_readb_fn[i] = omap_l4_io_entry[iotype].mem_read[0];
2057 omap_l4_io_readh_fn[i] = omap_l4_io_entry[iotype].mem_read[1];
2058 omap_l4_io_readw_fn[i] = omap_l4_io_entry[iotype].mem_read[2];
2059 omap_l4_io_writeb_fn[i] = omap_l4_io_entry[iotype].mem_write[0];
2060 omap_l4_io_writeh_fn[i] = omap_l4_io_entry[iotype].mem_write[1];
2061 omap_l4_io_writew_fn[i] = omap_l4_io_entry[iotype].mem_write[2];
2062 omap_l4_io_opaque[i] = omap_l4_io_entry[iotype].opaque;
2070 /* TEST-Chip-level TAP */
2071 static uint32_t omap_tap_read(void *opaque, target_phys_addr_t addr)
2073 struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
2074 target_phys_addr_t reg = addr - s->tap_base;
2077 case 0x204: /* IDCODE_reg */
2078 switch (s->mpu_model) {
2082 return 0x5b5d902f; /* ES 2.2 */
2084 return 0x5b68a02f; /* ES 2.2 */
2086 return 0x1b7ae02f; /* ES 2 */
2088 cpu_abort(cpu_single_env, "%s: Bad mpu model\n", __FUNCTION__);
2091 case 0x208: /* PRODUCTION_ID_reg for OMAP2 */
2092 case 0x210: /* PRODUCTION_ID_reg for OMAP3 */
2093 switch (s->mpu_model) {
2095 return 0x000254f0; /* POP ESHS2.1.1 in N91/93/95, ES2 in N800 */
2105 cpu_abort(cpu_single_env, "%s: Bad mpu model\n", __FUNCTION__);
2109 switch (s->mpu_model) {
2113 return 0xcafeb5d9; /* ES 2.2 */
2115 return 0xcafeb68a; /* ES 2.2 */
2117 return 0xcafeb7ae; /* ES 2 */
2119 cpu_abort(cpu_single_env, "%s: Bad mpu model\n", __FUNCTION__);
2122 case 0x218: /* DIE_ID_reg */
2123 return ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
2124 case 0x21c: /* DIE_ID_reg */
2126 case 0x220: /* DIE_ID_reg */
2127 return ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
2128 case 0x224: /* DIE_ID_reg */
2129 return ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
2136 static void omap_tap_write(void *opaque, target_phys_addr_t addr,
2142 static CPUReadMemoryFunc *omap_tap_readfn[] = {
2143 omap_badwidth_read32,
2144 omap_badwidth_read32,
2148 static CPUWriteMemoryFunc *omap_tap_writefn[] = {
2149 omap_badwidth_write32,
2150 omap_badwidth_write32,
2154 void omap_tap_init(struct omap_target_agent_s *ta,
2155 struct omap_mpu_state_s *mpu)
2157 mpu->tap_base = omap_l4_attach(ta, 0, l4_register_io_memory(0,
2158 omap_tap_readfn, omap_tap_writefn, mpu));
2161 /* Power, Reset, and Clock Management */
2162 struct omap_prcm_s {
2163 target_phys_addr_t base;
2165 struct omap_mpu_state_s *mpu;
2172 uint32_t scratch[20];
2176 uint32_t clkemul[1];
2180 uint32_t clkctrl[4];
2181 uint32_t clkidle[7];
2182 uint32_t setuptime[2];
2188 uint32_t rstctrl[1];
2190 uint32_t rsttime_wkup;
2196 static void omap_prcm_int_update(struct omap_prcm_s *s, int dom)
2198 qemu_set_irq(s->irq[dom], s->irqst[dom] & s->irqen[dom]);
2199 /* XXX or is the mask applied before PRCM_IRQSTATUS_* ? */
2202 static uint32_t omap_prcm_read(void *opaque, target_phys_addr_t addr)
2204 struct omap_prcm_s *s = (struct omap_prcm_s *) opaque;
2205 int offset = addr - s->base;
2208 case 0x000: /* PRCM_REVISION */
2211 case 0x010: /* PRCM_SYSCONFIG */
2212 return s->sysconfig;
2214 case 0x018: /* PRCM_IRQSTATUS_MPU */
2217 case 0x01c: /* PRCM_IRQENABLE_MPU */
2220 case 0x050: /* PRCM_VOLTCTRL */
2222 case 0x054: /* PRCM_VOLTST */
2223 return s->voltctrl & 3;
2225 case 0x060: /* PRCM_CLKSRC_CTRL */
2226 return s->clksrc[0];
2227 case 0x070: /* PRCM_CLKOUT_CTRL */
2228 return s->clkout[0];
2229 case 0x078: /* PRCM_CLKEMUL_CTRL */
2230 return s->clkemul[0];
2231 case 0x080: /* PRCM_CLKCFG_CTRL */
2232 case 0x084: /* PRCM_CLKCFG_STATUS */
2235 case 0x090: /* PRCM_VOLTSETUP */
2236 return s->setuptime[0];
2238 case 0x094: /* PRCM_CLKSSETUP */
2239 return s->setuptime[1];
2241 case 0x098: /* PRCM_POLCTRL */
2242 return s->clkpol[0];
2244 case 0x0b0: /* GENERAL_PURPOSE1 */
2245 case 0x0b4: /* GENERAL_PURPOSE2 */
2246 case 0x0b8: /* GENERAL_PURPOSE3 */
2247 case 0x0bc: /* GENERAL_PURPOSE4 */
2248 case 0x0c0: /* GENERAL_PURPOSE5 */
2249 case 0x0c4: /* GENERAL_PURPOSE6 */
2250 case 0x0c8: /* GENERAL_PURPOSE7 */
2251 case 0x0cc: /* GENERAL_PURPOSE8 */
2252 case 0x0d0: /* GENERAL_PURPOSE9 */
2253 case 0x0d4: /* GENERAL_PURPOSE10 */
2254 case 0x0d8: /* GENERAL_PURPOSE11 */
2255 case 0x0dc: /* GENERAL_PURPOSE12 */
2256 case 0x0e0: /* GENERAL_PURPOSE13 */
2257 case 0x0e4: /* GENERAL_PURPOSE14 */
2258 case 0x0e8: /* GENERAL_PURPOSE15 */
2259 case 0x0ec: /* GENERAL_PURPOSE16 */
2260 case 0x0f0: /* GENERAL_PURPOSE17 */
2261 case 0x0f4: /* GENERAL_PURPOSE18 */
2262 case 0x0f8: /* GENERAL_PURPOSE19 */
2263 case 0x0fc: /* GENERAL_PURPOSE20 */
2264 return s->scratch[(offset - 0xb0) >> 2];
2266 case 0x140: /* CM_CLKSEL_MPU */
2267 return s->clksel[0];
2268 case 0x148: /* CM_CLKSTCTRL_MPU */
2269 return s->clkctrl[0];
2271 case 0x158: /* RM_RSTST_MPU */
2273 case 0x1c8: /* PM_WKDEP_MPU */
2275 case 0x1d4: /* PM_EVGENCTRL_MPU */
2277 case 0x1d8: /* PM_EVEGENONTIM_MPU */
2278 return s->evtime[0];
2279 case 0x1dc: /* PM_EVEGENOFFTIM_MPU */
2280 return s->evtime[1];
2281 case 0x1e0: /* PM_PWSTCTRL_MPU */
2283 case 0x1e4: /* PM_PWSTST_MPU */
2286 case 0x200: /* CM_FCLKEN1_CORE */
2288 case 0x204: /* CM_FCLKEN2_CORE */
2290 case 0x210: /* CM_ICLKEN1_CORE */
2292 case 0x214: /* CM_ICLKEN2_CORE */
2294 case 0x21c: /* CM_ICLKEN4_CORE */
2297 case 0x220: /* CM_IDLEST1_CORE */
2298 /* TODO: check the actual iclk status */
2300 case 0x224: /* CM_IDLEST2_CORE */
2301 /* TODO: check the actual iclk status */
2303 case 0x22c: /* CM_IDLEST4_CORE */
2304 /* TODO: check the actual iclk status */
2307 case 0x230: /* CM_AUTOIDLE1_CORE */
2308 return s->clkidle[0];
2309 case 0x234: /* CM_AUTOIDLE2_CORE */
2310 return s->clkidle[1];
2311 case 0x238: /* CM_AUTOIDLE3_CORE */
2312 return s->clkidle[2];
2313 case 0x23c: /* CM_AUTOIDLE4_CORE */
2314 return s->clkidle[3];
2316 case 0x240: /* CM_CLKSEL1_CORE */
2317 return s->clksel[1];
2318 case 0x244: /* CM_CLKSEL2_CORE */
2319 return s->clksel[2];
2321 case 0x248: /* CM_CLKSTCTRL_CORE */
2322 return s->clkctrl[1];
2324 case 0x2a0: /* PM_WKEN1_CORE */
2326 case 0x2a4: /* PM_WKEN2_CORE */
2329 case 0x2b0: /* PM_WKST1_CORE */
2331 case 0x2b4: /* PM_WKST2_CORE */
2333 case 0x2c8: /* PM_WKDEP_CORE */
2336 case 0x2e0: /* PM_PWSTCTRL_CORE */
2338 case 0x2e4: /* PM_PWSTST_CORE */
2339 return 0x000030 | (s->power[1] & 0xfc00);
2341 case 0x300: /* CM_FCLKEN_GFX */
2343 case 0x310: /* CM_ICLKEN_GFX */
2345 case 0x320: /* CM_IDLEST_GFX */
2346 /* TODO: check the actual iclk status */
2348 case 0x340: /* CM_CLKSEL_GFX */
2349 return s->clksel[3];
2350 case 0x348: /* CM_CLKSTCTRL_GFX */
2351 return s->clkctrl[2];
2352 case 0x350: /* RM_RSTCTRL_GFX */
2353 return s->rstctrl[0];
2354 case 0x358: /* RM_RSTST_GFX */
2356 case 0x3c8: /* PM_WKDEP_GFX */
2359 case 0x3e0: /* PM_PWSTCTRL_GFX */
2361 case 0x3e4: /* PM_PWSTST_GFX */
2362 return s->power[2] & 3;
2364 case 0x400: /* CM_FCLKEN_WKUP */
2366 case 0x410: /* CM_ICLKEN_WKUP */
2368 case 0x420: /* CM_IDLEST_WKUP */
2369 /* TODO: check the actual iclk status */
2371 case 0x430: /* CM_AUTOIDLE_WKUP */
2372 return s->clkidle[4];
2373 case 0x440: /* CM_CLKSEL_WKUP */
2374 return s->clksel[4];
2375 case 0x450: /* RM_RSTCTRL_WKUP */
2377 case 0x454: /* RM_RSTTIME_WKUP */
2378 return s->rsttime_wkup;
2379 case 0x458: /* RM_RSTST_WKUP */
2381 case 0x4a0: /* PM_WKEN_WKUP */
2383 case 0x4b0: /* PM_WKST_WKUP */
2386 case 0x500: /* CM_CLKEN_PLL */
2388 case 0x520: /* CM_IDLEST_CKGEN */
2389 /* Core uses 32-kHz clock */
2390 if (!(s->clksel[6] & 3))
2392 /* DPLL not in lock mode, core uses ref_clk */
2393 if ((s->clken[9] & 3) != 3)
2395 /* Core uses DPLL */
2397 case 0x530: /* CM_AUTOIDLE_PLL */
2398 return s->clkidle[5];
2399 case 0x540: /* CM_CLKSEL1_PLL */
2400 return s->clksel[5];
2401 case 0x544: /* CM_CLKSEL2_PLL */
2402 return s->clksel[6];
2404 case 0x800: /* CM_FCLKEN_DSP */
2405 return s->clken[10];
2406 case 0x810: /* CM_ICLKEN_DSP */
2407 return s->clken[11];
2408 case 0x820: /* CM_IDLEST_DSP */
2409 /* TODO: check the actual iclk status */
2411 case 0x830: /* CM_AUTOIDLE_DSP */
2412 return s->clkidle[6];
2413 case 0x840: /* CM_CLKSEL_DSP */
2414 return s->clksel[7];
2415 case 0x848: /* CM_CLKSTCTRL_DSP */
2416 return s->clkctrl[3];
2417 case 0x850: /* RM_RSTCTRL_DSP */
2419 case 0x858: /* RM_RSTST_DSP */
2421 case 0x8c8: /* PM_WKDEP_DSP */
2423 case 0x8e0: /* PM_PWSTCTRL_DSP */
2425 case 0x8e4: /* PM_PWSTST_DSP */
2426 return 0x008030 | (s->power[3] & 0x3003);
2428 case 0x8f0: /* PRCM_IRQSTATUS_DSP */
2430 case 0x8f4: /* PRCM_IRQENABLE_DSP */
2433 case 0x8f8: /* PRCM_IRQSTATUS_IVA */
2435 case 0x8fc: /* PRCM_IRQENABLE_IVA */
2443 static void omap_prcm_write(void *opaque, target_phys_addr_t addr,
2446 struct omap_prcm_s *s = (struct omap_prcm_s *) opaque;
2447 int offset = addr - s->base;
2450 case 0x000: /* PRCM_REVISION */
2451 case 0x054: /* PRCM_VOLTST */
2452 case 0x084: /* PRCM_CLKCFG_STATUS */
2453 case 0x1e4: /* PM_PWSTST_MPU */
2454 case 0x220: /* CM_IDLEST1_CORE */
2455 case 0x224: /* CM_IDLEST2_CORE */
2456 case 0x22c: /* CM_IDLEST4_CORE */
2457 case 0x2c8: /* PM_WKDEP_CORE */
2458 case 0x2e4: /* PM_PWSTST_CORE */
2459 case 0x320: /* CM_IDLEST_GFX */
2460 case 0x3e4: /* PM_PWSTST_GFX */
2461 case 0x420: /* CM_IDLEST_WKUP */
2462 case 0x520: /* CM_IDLEST_CKGEN */
2463 case 0x820: /* CM_IDLEST_DSP */
2464 case 0x8e4: /* PM_PWSTST_DSP */
2468 case 0x010: /* PRCM_SYSCONFIG */
2469 s->sysconfig = value & 1;
2472 case 0x018: /* PRCM_IRQSTATUS_MPU */
2473 s->irqst[0] &= ~value;
2474 omap_prcm_int_update(s, 0);
2476 case 0x01c: /* PRCM_IRQENABLE_MPU */
2477 s->irqen[0] = value & 0x3f;
2478 omap_prcm_int_update(s, 0);
2481 case 0x050: /* PRCM_VOLTCTRL */
2482 s->voltctrl = value & 0xf1c3;
2485 case 0x060: /* PRCM_CLKSRC_CTRL */
2486 s->clksrc[0] = value & 0xdb;
2487 /* TODO update clocks */
2490 case 0x070: /* PRCM_CLKOUT_CTRL */
2491 s->clkout[0] = value & 0xbbbb;
2492 /* TODO update clocks */
2495 case 0x078: /* PRCM_CLKEMUL_CTRL */
2496 s->clkemul[0] = value & 1;
2497 /* TODO update clocks */
2500 case 0x080: /* PRCM_CLKCFG_CTRL */
2503 case 0x090: /* PRCM_VOLTSETUP */
2504 s->setuptime[0] = value & 0xffff;
2506 case 0x094: /* PRCM_CLKSSETUP */
2507 s->setuptime[1] = value & 0xffff;
2510 case 0x098: /* PRCM_POLCTRL */
2511 s->clkpol[0] = value & 0x701;
2514 case 0x0b0: /* GENERAL_PURPOSE1 */
2515 case 0x0b4: /* GENERAL_PURPOSE2 */
2516 case 0x0b8: /* GENERAL_PURPOSE3 */
2517 case 0x0bc: /* GENERAL_PURPOSE4 */
2518 case 0x0c0: /* GENERAL_PURPOSE5 */
2519 case 0x0c4: /* GENERAL_PURPOSE6 */
2520 case 0x0c8: /* GENERAL_PURPOSE7 */
2521 case 0x0cc: /* GENERAL_PURPOSE8 */
2522 case 0x0d0: /* GENERAL_PURPOSE9 */
2523 case 0x0d4: /* GENERAL_PURPOSE10 */
2524 case 0x0d8: /* GENERAL_PURPOSE11 */
2525 case 0x0dc: /* GENERAL_PURPOSE12 */
2526 case 0x0e0: /* GENERAL_PURPOSE13 */
2527 case 0x0e4: /* GENERAL_PURPOSE14 */
2528 case 0x0e8: /* GENERAL_PURPOSE15 */
2529 case 0x0ec: /* GENERAL_PURPOSE16 */
2530 case 0x0f0: /* GENERAL_PURPOSE17 */
2531 case 0x0f4: /* GENERAL_PURPOSE18 */
2532 case 0x0f8: /* GENERAL_PURPOSE19 */
2533 case 0x0fc: /* GENERAL_PURPOSE20 */
2534 s->scratch[(offset - 0xb0) >> 2] = value;
2537 case 0x140: /* CM_CLKSEL_MPU */
2538 s->clksel[0] = value & 0x1f;
2539 /* TODO update clocks */
2541 case 0x148: /* CM_CLKSTCTRL_MPU */
2542 s->clkctrl[0] = value & 0x1f;
2545 case 0x158: /* RM_RSTST_MPU */
2546 s->rst[0] &= ~value;
2548 case 0x1c8: /* PM_WKDEP_MPU */
2549 s->wkup[0] = value & 0x15;
2552 case 0x1d4: /* PM_EVGENCTRL_MPU */
2553 s->ev = value & 0x1f;
2555 case 0x1d8: /* PM_EVEGENONTIM_MPU */
2556 s->evtime[0] = value;
2558 case 0x1dc: /* PM_EVEGENOFFTIM_MPU */
2559 s->evtime[1] = value;
2562 case 0x1e0: /* PM_PWSTCTRL_MPU */
2563 s->power[0] = value & 0xc0f;
2566 case 0x200: /* CM_FCLKEN1_CORE */
2567 s->clken[0] = value & 0xbfffffff;
2568 /* TODO update clocks */
2570 case 0x204: /* CM_FCLKEN2_CORE */
2571 s->clken[1] = value & 0x00000007;
2572 /* TODO update clocks */
2574 case 0x210: /* CM_ICLKEN1_CORE */
2575 s->clken[2] = value & 0xfffffff9;
2576 /* TODO update clocks */
2578 case 0x214: /* CM_ICLKEN2_CORE */
2579 s->clken[3] = value & 0x00000007;
2580 /* TODO update clocks */
2582 case 0x21c: /* CM_ICLKEN4_CORE */
2583 s->clken[4] = value & 0x0000001f;
2584 /* TODO update clocks */
2587 case 0x230: /* CM_AUTOIDLE1_CORE */
2588 s->clkidle[0] = value & 0xfffffff9;
2589 /* TODO update clocks */
2591 case 0x234: /* CM_AUTOIDLE2_CORE */
2592 s->clkidle[1] = value & 0x00000007;
2593 /* TODO update clocks */
2595 case 0x238: /* CM_AUTOIDLE3_CORE */
2596 s->clkidle[2] = value & 0x00000007;
2597 /* TODO update clocks */
2599 case 0x23c: /* CM_AUTOIDLE4_CORE */
2600 s->clkidle[3] = value & 0x0000001f;
2601 /* TODO update clocks */
2604 case 0x240: /* CM_CLKSEL1_CORE */
2605 s->clksel[1] = value & 0x0fffbf7f;
2606 /* TODO update clocks */
2609 case 0x244: /* CM_CLKSEL2_CORE */
2610 s->clksel[2] = value & 0x00fffffc;
2611 /* TODO update clocks */
2614 case 0x248: /* CM_CLKSTCTRL_CORE */
2615 s->clkctrl[1] = value & 0x7;
2618 case 0x2a0: /* PM_WKEN1_CORE */
2619 s->wken[0] = value & 0x04667ff8;
2621 case 0x2a4: /* PM_WKEN2_CORE */
2622 s->wken[1] = value & 0x00000005;
2625 case 0x2b0: /* PM_WKST1_CORE */
2626 s->wkst[0] &= ~value;
2628 case 0x2b4: /* PM_WKST2_CORE */
2629 s->wkst[1] &= ~value;
2632 case 0x2e0: /* PM_PWSTCTRL_CORE */
2633 s->power[1] = (value & 0x00fc3f) | (1 << 2);
2636 case 0x300: /* CM_FCLKEN_GFX */
2637 s->clken[5] = value & 6;
2638 /* TODO update clocks */
2640 case 0x310: /* CM_ICLKEN_GFX */
2641 s->clken[6] = value & 1;
2642 /* TODO update clocks */
2644 case 0x340: /* CM_CLKSEL_GFX */
2645 s->clksel[3] = value & 7;
2646 /* TODO update clocks */
2648 case 0x348: /* CM_CLKSTCTRL_GFX */
2649 s->clkctrl[2] = value & 1;
2651 case 0x350: /* RM_RSTCTRL_GFX */
2652 s->rstctrl[0] = value & 1;
2655 case 0x358: /* RM_RSTST_GFX */
2656 s->rst[1] &= ~value;
2658 case 0x3c8: /* PM_WKDEP_GFX */
2659 s->wkup[1] = value & 0x13;
2661 case 0x3e0: /* PM_PWSTCTRL_GFX */
2662 s->power[2] = (value & 0x00c0f) | (3 << 2);
2665 case 0x400: /* CM_FCLKEN_WKUP */
2666 s->clken[7] = value & 0xd;
2667 /* TODO update clocks */
2669 case 0x410: /* CM_ICLKEN_WKUP */
2670 s->clken[8] = value & 0x3f;
2671 /* TODO update clocks */
2673 case 0x430: /* CM_AUTOIDLE_WKUP */
2674 s->clkidle[4] = value & 0x0000003f;
2675 /* TODO update clocks */
2677 case 0x440: /* CM_CLKSEL_WKUP */
2678 s->clksel[4] = value & 3;
2679 /* TODO update clocks */
2681 case 0x450: /* RM_RSTCTRL_WKUP */
2684 qemu_system_reset_request();
2686 case 0x454: /* RM_RSTTIME_WKUP */
2687 s->rsttime_wkup = value & 0x1fff;
2689 case 0x458: /* RM_RSTST_WKUP */
2690 s->rst[2] &= ~value;
2692 case 0x4a0: /* PM_WKEN_WKUP */
2693 s->wken[2] = value & 0x00000005;
2695 case 0x4b0: /* PM_WKST_WKUP */
2696 s->wkst[2] &= ~value;
2699 case 0x500: /* CM_CLKEN_PLL */
2700 s->clken[9] = value & 0xcf;
2701 /* TODO update clocks */
2703 case 0x530: /* CM_AUTOIDLE_PLL */
2704 s->clkidle[5] = value & 0x000000cf;
2705 /* TODO update clocks */
2707 case 0x540: /* CM_CLKSEL1_PLL */
2708 s->clksel[5] = value & 0x03bfff28;
2709 /* TODO update clocks */
2711 case 0x544: /* CM_CLKSEL2_PLL */
2712 s->clksel[6] = value & 3;
2713 /* TODO update clocks */
2716 case 0x800: /* CM_FCLKEN_DSP */
2717 s->clken[10] = value & 0x501;
2718 /* TODO update clocks */
2720 case 0x810: /* CM_ICLKEN_DSP */
2721 s->clken[11] = value & 0x2;
2722 /* TODO update clocks */
2724 case 0x830: /* CM_AUTOIDLE_DSP */
2725 s->clkidle[6] = value & 0x2;
2726 /* TODO update clocks */
2728 case 0x840: /* CM_CLKSEL_DSP */
2729 s->clksel[7] = value & 0x3fff;
2730 /* TODO update clocks */
2732 case 0x848: /* CM_CLKSTCTRL_DSP */
2733 s->clkctrl[3] = value & 0x101;
2735 case 0x850: /* RM_RSTCTRL_DSP */
2738 case 0x858: /* RM_RSTST_DSP */
2739 s->rst[3] &= ~value;
2741 case 0x8c8: /* PM_WKDEP_DSP */
2742 s->wkup[2] = value & 0x13;
2744 case 0x8e0: /* PM_PWSTCTRL_DSP */
2745 s->power[3] = (value & 0x03017) | (3 << 2);
2748 case 0x8f0: /* PRCM_IRQSTATUS_DSP */
2749 s->irqst[1] &= ~value;
2750 omap_prcm_int_update(s, 1);
2752 case 0x8f4: /* PRCM_IRQENABLE_DSP */
2753 s->irqen[1] = value & 0x7;
2754 omap_prcm_int_update(s, 1);
2757 case 0x8f8: /* PRCM_IRQSTATUS_IVA */
2758 s->irqst[2] &= ~value;
2759 omap_prcm_int_update(s, 2);
2761 case 0x8fc: /* PRCM_IRQENABLE_IVA */
2762 s->irqen[2] = value & 0x7;
2763 omap_prcm_int_update(s, 2);
2772 static CPUReadMemoryFunc *omap_prcm_readfn[] = {
2773 omap_badwidth_read32,
2774 omap_badwidth_read32,
2778 static CPUWriteMemoryFunc *omap_prcm_writefn[] = {
2779 omap_badwidth_write32,
2780 omap_badwidth_write32,
2784 static void omap_prcm_reset(struct omap_prcm_s *s)
2793 s->voltctrl = 0x1040;
2815 s->clkidle[5] = 0x0c;
2817 s->clksel[0] = 0x01;
2818 s->clksel[1] = 0x02100121;
2819 s->clksel[2] = 0x00000000;
2820 s->clksel[3] = 0x01;
2822 s->clksel[7] = 0x0121;
2826 s->wken[0] = 0x04667ff8;
2827 s->wken[1] = 0x00000005;
2832 s->power[0] = 0x00c;
2834 s->power[2] = 0x0000c;
2840 static void omap_prcm_coldreset(struct omap_prcm_s *s)
2842 s->setuptime[0] = 0;
2843 s->setuptime[1] = 0;
2844 memset(&s->scratch, 0, sizeof(s->scratch));
2853 s->clksrc[0] = 0x43;
2854 s->clkout[0] = 0x0303;
2856 s->clkpol[0] = 0x100;
2857 s->rsttime_wkup = 0x1002;
2862 struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta,
2863 qemu_irq mpu_int, qemu_irq dsp_int, qemu_irq iva_int,
2864 struct omap_mpu_state_s *mpu)
2867 struct omap_prcm_s *s = (struct omap_prcm_s *)
2868 qemu_mallocz(sizeof(struct omap_prcm_s));
2870 s->irq[0] = mpu_int;
2871 s->irq[1] = dsp_int;
2872 s->irq[2] = iva_int;
2874 omap_prcm_coldreset(s);
2876 iomemtype = l4_register_io_memory(0, omap_prcm_readfn,
2877 omap_prcm_writefn, s);
2878 s->base = omap_l4_attach(ta, 0, iomemtype);
2879 omap_l4_attach(ta, 1, iomemtype);
2884 /* System and Pinout control */
2885 struct omap_sysctl_s {
2886 target_phys_addr_t base;
2887 struct omap_mpu_state_s *mpu;
2892 uint32_t padconf[0x45];
2894 uint32_t msuspendmux[5];
2897 static uint32_t omap_sysctl_read(void *opaque, target_phys_addr_t addr)
2899 struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
2900 int offset = addr - s->base;
2903 case 0x000: /* CONTROL_REVISION */
2906 case 0x010: /* CONTROL_SYSCONFIG */
2907 return s->sysconfig;
2909 case 0x030 ... 0x140: /* CONTROL_PADCONF - only used in the POP */
2910 return s->padconf[(offset - 0x30) >> 2];
2912 case 0x270: /* CONTROL_DEBOBS */
2915 case 0x274: /* CONTROL_DEVCONF */
2916 return s->devconfig;
2918 case 0x28c: /* CONTROL_EMU_SUPPORT */
2921 case 0x290: /* CONTROL_MSUSPENDMUX_0 */
2922 return s->msuspendmux[0];
2923 case 0x294: /* CONTROL_MSUSPENDMUX_1 */
2924 return s->msuspendmux[1];
2925 case 0x298: /* CONTROL_MSUSPENDMUX_2 */
2926 return s->msuspendmux[2];
2927 case 0x29c: /* CONTROL_MSUSPENDMUX_3 */
2928 return s->msuspendmux[3];
2929 case 0x2a0: /* CONTROL_MSUSPENDMUX_4 */
2930 return s->msuspendmux[4];
2931 case 0x2a4: /* CONTROL_MSUSPENDMUX_5 */
2934 case 0x2b8: /* CONTROL_PSA_CTRL */
2935 return s->psaconfig;
2936 case 0x2bc: /* CONTROL_PSA_CMD */
2937 case 0x2c0: /* CONTROL_PSA_VALUE */
2940 case 0x2b0: /* CONTROL_SEC_CTRL */
2942 case 0x2d0: /* CONTROL_SEC_EMU */
2944 case 0x2d4: /* CONTROL_SEC_TAP */
2946 case 0x2b4: /* CONTROL_SEC_TEST */
2947 case 0x2f0: /* CONTROL_SEC_STATUS */
2948 case 0x2f4: /* CONTROL_SEC_ERR_STATUS */
2949 /* Secure mode is not present on general-pusrpose device. Outside
2950 * secure mode these values cannot be read or written. */
2953 case 0x2d8: /* CONTROL_OCM_RAM_PERM */
2955 case 0x2dc: /* CONTROL_OCM_PUB_RAM_ADD */
2956 case 0x2e0: /* CONTROL_EXT_SEC_RAM_START_ADD */
2957 case 0x2e4: /* CONTROL_EXT_SEC_RAM_STOP_ADD */
2958 /* No secure mode so no Extended Secure RAM present. */
2961 case 0x2f8: /* CONTROL_STATUS */
2962 /* Device Type => General-purpose */
2964 case 0x2fc: /* CONTROL_GENERAL_PURPOSE_STATUS */
2966 case 0x300: /* CONTROL_RPUB_KEY_H_0 */
2967 case 0x304: /* CONTROL_RPUB_KEY_H_1 */
2968 case 0x308: /* CONTROL_RPUB_KEY_H_2 */
2969 case 0x30c: /* CONTROL_RPUB_KEY_H_3 */
2972 case 0x310: /* CONTROL_RAND_KEY_0 */
2973 case 0x314: /* CONTROL_RAND_KEY_1 */
2974 case 0x318: /* CONTROL_RAND_KEY_2 */
2975 case 0x31c: /* CONTROL_RAND_KEY_3 */
2976 case 0x320: /* CONTROL_CUST_KEY_0 */
2977 case 0x324: /* CONTROL_CUST_KEY_1 */
2978 case 0x330: /* CONTROL_TEST_KEY_0 */
2979 case 0x334: /* CONTROL_TEST_KEY_1 */
2980 case 0x338: /* CONTROL_TEST_KEY_2 */
2981 case 0x33c: /* CONTROL_TEST_KEY_3 */
2982 case 0x340: /* CONTROL_TEST_KEY_4 */
2983 case 0x344: /* CONTROL_TEST_KEY_5 */
2984 case 0x348: /* CONTROL_TEST_KEY_6 */
2985 case 0x34c: /* CONTROL_TEST_KEY_7 */
2986 case 0x350: /* CONTROL_TEST_KEY_8 */
2987 case 0x354: /* CONTROL_TEST_KEY_9 */
2988 /* Can only be accessed in secure mode and when C_FieldAccEnable
2989 * bit is set in CONTROL_SEC_CTRL.
2990 * TODO: otherwise an interconnect access error is generated. */
2998 static void omap_sysctl_write(void *opaque, target_phys_addr_t addr,
3001 struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
3002 int offset = addr - s->base;
3005 case 0x000: /* CONTROL_REVISION */
3006 case 0x2a4: /* CONTROL_MSUSPENDMUX_5 */
3007 case 0x2c0: /* CONTROL_PSA_VALUE */
3008 case 0x2f8: /* CONTROL_STATUS */
3009 case 0x2fc: /* CONTROL_GENERAL_PURPOSE_STATUS */
3010 case 0x300: /* CONTROL_RPUB_KEY_H_0 */
3011 case 0x304: /* CONTROL_RPUB_KEY_H_1 */
3012 case 0x308: /* CONTROL_RPUB_KEY_H_2 */
3013 case 0x30c: /* CONTROL_RPUB_KEY_H_3 */
3014 case 0x310: /* CONTROL_RAND_KEY_0 */
3015 case 0x314: /* CONTROL_RAND_KEY_1 */
3016 case 0x318: /* CONTROL_RAND_KEY_2 */
3017 case 0x31c: /* CONTROL_RAND_KEY_3 */
3018 case 0x320: /* CONTROL_CUST_KEY_0 */
3019 case 0x324: /* CONTROL_CUST_KEY_1 */
3020 case 0x330: /* CONTROL_TEST_KEY_0 */
3021 case 0x334: /* CONTROL_TEST_KEY_1 */
3022 case 0x338: /* CONTROL_TEST_KEY_2 */
3023 case 0x33c: /* CONTROL_TEST_KEY_3 */
3024 case 0x340: /* CONTROL_TEST_KEY_4 */
3025 case 0x344: /* CONTROL_TEST_KEY_5 */
3026 case 0x348: /* CONTROL_TEST_KEY_6 */
3027 case 0x34c: /* CONTROL_TEST_KEY_7 */
3028 case 0x350: /* CONTROL_TEST_KEY_8 */
3029 case 0x354: /* CONTROL_TEST_KEY_9 */
3033 case 0x010: /* CONTROL_SYSCONFIG */
3034 s->sysconfig = value & 0x1e;
3037 case 0x030 ... 0x140: /* CONTROL_PADCONF - only used in the POP */
3038 /* XXX: should check constant bits */
3039 s->padconf[(offset - 0x30) >> 2] = value & 0x1f1f1f1f;
3042 case 0x270: /* CONTROL_DEBOBS */
3043 s->obs = value & 0xff;
3046 case 0x274: /* CONTROL_DEVCONF */
3047 s->devconfig = value & 0xffffc7ff;
3050 case 0x28c: /* CONTROL_EMU_SUPPORT */
3053 case 0x290: /* CONTROL_MSUSPENDMUX_0 */
3054 s->msuspendmux[0] = value & 0x3fffffff;
3056 case 0x294: /* CONTROL_MSUSPENDMUX_1 */
3057 s->msuspendmux[1] = value & 0x3fffffff;
3059 case 0x298: /* CONTROL_MSUSPENDMUX_2 */
3060 s->msuspendmux[2] = value & 0x3fffffff;
3062 case 0x29c: /* CONTROL_MSUSPENDMUX_3 */
3063 s->msuspendmux[3] = value & 0x3fffffff;
3065 case 0x2a0: /* CONTROL_MSUSPENDMUX_4 */
3066 s->msuspendmux[4] = value & 0x3fffffff;
3069 case 0x2b8: /* CONTROL_PSA_CTRL */
3070 s->psaconfig = value & 0x1c;
3071 s->psaconfig |= (value & 0x20) ? 2 : 1;
3073 case 0x2bc: /* CONTROL_PSA_CMD */
3076 case 0x2b0: /* CONTROL_SEC_CTRL */
3077 case 0x2b4: /* CONTROL_SEC_TEST */
3078 case 0x2d0: /* CONTROL_SEC_EMU */
3079 case 0x2d4: /* CONTROL_SEC_TAP */
3080 case 0x2d8: /* CONTROL_OCM_RAM_PERM */
3081 case 0x2dc: /* CONTROL_OCM_PUB_RAM_ADD */
3082 case 0x2e0: /* CONTROL_EXT_SEC_RAM_START_ADD */
3083 case 0x2e4: /* CONTROL_EXT_SEC_RAM_STOP_ADD */
3084 case 0x2f0: /* CONTROL_SEC_STATUS */
3085 case 0x2f4: /* CONTROL_SEC_ERR_STATUS */
3094 static CPUReadMemoryFunc *omap_sysctl_readfn[] = {
3095 omap_badwidth_read32, /* TODO */
3096 omap_badwidth_read32, /* TODO */
3100 static CPUWriteMemoryFunc *omap_sysctl_writefn[] = {
3101 omap_badwidth_write32, /* TODO */
3102 omap_badwidth_write32, /* TODO */
3106 static void omap_sysctl_reset(struct omap_sysctl_s *s)
3108 /* (power-on reset) */
3111 s->devconfig = 0x0c000000;
3112 s->msuspendmux[0] = 0x00000000;
3113 s->msuspendmux[1] = 0x00000000;
3114 s->msuspendmux[2] = 0x00000000;
3115 s->msuspendmux[3] = 0x00000000;
3116 s->msuspendmux[4] = 0x00000000;
3119 s->padconf[0x00] = 0x000f0f0f;
3120 s->padconf[0x01] = 0x00000000;
3121 s->padconf[0x02] = 0x00000000;
3122 s->padconf[0x03] = 0x00000000;
3123 s->padconf[0x04] = 0x00000000;
3124 s->padconf[0x05] = 0x00000000;
3125 s->padconf[0x06] = 0x00000000;
3126 s->padconf[0x07] = 0x00000000;
3127 s->padconf[0x08] = 0x08080800;
3128 s->padconf[0x09] = 0x08080808;
3129 s->padconf[0x0a] = 0x08080808;
3130 s->padconf[0x0b] = 0x08080808;
3131 s->padconf[0x0c] = 0x08080808;
3132 s->padconf[0x0d] = 0x08080800;
3133 s->padconf[0x0e] = 0x08080808;
3134 s->padconf[0x0f] = 0x08080808;
3135 s->padconf[0x10] = 0x18181808; /* | 0x07070700 if SBoot3 */
3136 s->padconf[0x11] = 0x18181818; /* | 0x07070707 if SBoot3 */
3137 s->padconf[0x12] = 0x18181818; /* | 0x07070707 if SBoot3 */
3138 s->padconf[0x13] = 0x18181818; /* | 0x07070707 if SBoot3 */
3139 s->padconf[0x14] = 0x18181818; /* | 0x00070707 if SBoot3 */
3140 s->padconf[0x15] = 0x18181818;
3141 s->padconf[0x16] = 0x18181818; /* | 0x07000000 if SBoot3 */
3142 s->padconf[0x17] = 0x1f001f00;
3143 s->padconf[0x18] = 0x1f1f1f1f;
3144 s->padconf[0x19] = 0x00000000;
3145 s->padconf[0x1a] = 0x1f180000;
3146 s->padconf[0x1b] = 0x00001f1f;
3147 s->padconf[0x1c] = 0x1f001f00;
3148 s->padconf[0x1d] = 0x00000000;
3149 s->padconf[0x1e] = 0x00000000;
3150 s->padconf[0x1f] = 0x08000000;
3151 s->padconf[0x20] = 0x08080808;
3152 s->padconf[0x21] = 0x08080808;
3153 s->padconf[0x22] = 0x0f080808;
3154 s->padconf[0x23] = 0x0f0f0f0f;
3155 s->padconf[0x24] = 0x000f0f0f;
3156 s->padconf[0x25] = 0x1f1f1f0f;
3157 s->padconf[0x26] = 0x080f0f1f;
3158 s->padconf[0x27] = 0x070f1808;
3159 s->padconf[0x28] = 0x0f070707;
3160 s->padconf[0x29] = 0x000f0f1f;
3161 s->padconf[0x2a] = 0x0f0f0f1f;
3162 s->padconf[0x2b] = 0x08000000;
3163 s->padconf[0x2c] = 0x0000001f;
3164 s->padconf[0x2d] = 0x0f0f1f00;
3165 s->padconf[0x2e] = 0x1f1f0f0f;
3166 s->padconf[0x2f] = 0x0f1f1f1f;
3167 s->padconf[0x30] = 0x0f0f0f0f;
3168 s->padconf[0x31] = 0x0f1f0f1f;
3169 s->padconf[0x32] = 0x0f0f0f0f;
3170 s->padconf[0x33] = 0x0f1f0f1f;
3171 s->padconf[0x34] = 0x1f1f0f0f;
3172 s->padconf[0x35] = 0x0f0f1f1f;
3173 s->padconf[0x36] = 0x0f0f1f0f;
3174 s->padconf[0x37] = 0x0f0f0f0f;
3175 s->padconf[0x38] = 0x1f18180f;
3176 s->padconf[0x39] = 0x1f1f1f1f;
3177 s->padconf[0x3a] = 0x00001f1f;
3178 s->padconf[0x3b] = 0x00000000;
3179 s->padconf[0x3c] = 0x00000000;
3180 s->padconf[0x3d] = 0x0f0f0f0f;
3181 s->padconf[0x3e] = 0x18000f0f;
3182 s->padconf[0x3f] = 0x00070000;
3183 s->padconf[0x40] = 0x00000707;
3184 s->padconf[0x41] = 0x0f1f0700;
3185 s->padconf[0x42] = 0x1f1f070f;
3186 s->padconf[0x43] = 0x0008081f;
3187 s->padconf[0x44] = 0x00000800;
3190 struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
3191 omap_clk iclk, struct omap_mpu_state_s *mpu)
3194 struct omap_sysctl_s *s = (struct omap_sysctl_s *)
3195 qemu_mallocz(sizeof(struct omap_sysctl_s));
3198 omap_sysctl_reset(s);
3200 iomemtype = l4_register_io_memory(0, omap_sysctl_readfn,
3201 omap_sysctl_writefn, s);
3202 s->base = omap_l4_attach(ta, 0, iomemtype);
3203 omap_l4_attach(ta, 0, iomemtype);
3208 /* SDRAM Controller Subsystem */
3209 struct omap_sdrc_s {
3210 target_phys_addr_t base;
3215 static void omap_sdrc_reset(struct omap_sdrc_s *s)
3220 static uint32_t omap_sdrc_read(void *opaque, target_phys_addr_t addr)
3222 struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque;
3223 int offset = addr - s->base;
3226 case 0x00: /* SDRC_REVISION */
3229 case 0x10: /* SDRC_SYSCONFIG */
3232 case 0x14: /* SDRC_SYSSTATUS */
3233 return 1; /* RESETDONE */
3235 case 0x40: /* SDRC_CS_CFG */
3236 case 0x44: /* SDRC_SHARING */
3237 case 0x48: /* SDRC_ERR_ADDR */
3238 case 0x4c: /* SDRC_ERR_TYPE */
3239 case 0x60: /* SDRC_DLLA_SCTRL */
3240 case 0x64: /* SDRC_DLLA_STATUS */
3241 case 0x68: /* SDRC_DLLB_CTRL */
3242 case 0x6c: /* SDRC_DLLB_STATUS */
3243 case 0x70: /* SDRC_POWER */
3244 case 0x80: /* SDRC_MCFG_0 */
3245 case 0x84: /* SDRC_MR_0 */
3246 case 0x88: /* SDRC_EMR1_0 */
3247 case 0x8c: /* SDRC_EMR2_0 */
3248 case 0x90: /* SDRC_EMR3_0 */
3249 case 0x94: /* SDRC_DCDL1_CTRL */
3250 case 0x98: /* SDRC_DCDL2_CTRL */
3251 case 0x9c: /* SDRC_ACTIM_CTRLA_0 */
3252 case 0xa0: /* SDRC_ACTIM_CTRLB_0 */
3253 case 0xa4: /* SDRC_RFR_CTRL_0 */
3254 case 0xa8: /* SDRC_MANUAL_0 */
3255 case 0xb0: /* SDRC_MCFG_1 */
3256 case 0xb4: /* SDRC_MR_1 */
3257 case 0xb8: /* SDRC_EMR1_1 */
3258 case 0xbc: /* SDRC_EMR2_1 */
3259 case 0xc0: /* SDRC_EMR3_1 */
3260 case 0xc4: /* SDRC_ACTIM_CTRLA_1 */
3261 case 0xc8: /* SDRC_ACTIM_CTRLB_1 */
3262 case 0xd4: /* SDRC_RFR_CTRL_1 */
3263 case 0xd8: /* SDRC_MANUAL_1 */
3271 static void omap_sdrc_write(void *opaque, target_phys_addr_t addr,
3274 struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque;
3275 int offset = addr - s->base;
3278 case 0x00: /* SDRC_REVISION */
3279 case 0x14: /* SDRC_SYSSTATUS */
3280 case 0x48: /* SDRC_ERR_ADDR */
3281 case 0x64: /* SDRC_DLLA_STATUS */
3282 case 0x6c: /* SDRC_DLLB_STATUS */
3286 case 0x10: /* SDRC_SYSCONFIG */
3287 if ((value >> 3) != 0x2)
3288 fprintf(stderr, "%s: bad SDRAM idle mode %i\n",
3289 __FUNCTION__, value >> 3);
3292 s->config = value & 0x18;
3295 case 0x40: /* SDRC_CS_CFG */
3296 case 0x44: /* SDRC_SHARING */
3297 case 0x4c: /* SDRC_ERR_TYPE */
3298 case 0x60: /* SDRC_DLLA_SCTRL */
3299 case 0x68: /* SDRC_DLLB_CTRL */
3300 case 0x70: /* SDRC_POWER */
3301 case 0x80: /* SDRC_MCFG_0 */
3302 case 0x84: /* SDRC_MR_0 */
3303 case 0x88: /* SDRC_EMR1_0 */
3304 case 0x8c: /* SDRC_EMR2_0 */
3305 case 0x90: /* SDRC_EMR3_0 */
3306 case 0x94: /* SDRC_DCDL1_CTRL */
3307 case 0x98: /* SDRC_DCDL2_CTRL */
3308 case 0x9c: /* SDRC_ACTIM_CTRLA_0 */
3309 case 0xa0: /* SDRC_ACTIM_CTRLB_0 */
3310 case 0xa4: /* SDRC_RFR_CTRL_0 */
3311 case 0xa8: /* SDRC_MANUAL_0 */
3312 case 0xb0: /* SDRC_MCFG_1 */
3313 case 0xb4: /* SDRC_MR_1 */
3314 case 0xb8: /* SDRC_EMR1_1 */
3315 case 0xbc: /* SDRC_EMR2_1 */
3316 case 0xc0: /* SDRC_EMR3_1 */
3317 case 0xc4: /* SDRC_ACTIM_CTRLA_1 */
3318 case 0xc8: /* SDRC_ACTIM_CTRLB_1 */
3319 case 0xd4: /* SDRC_RFR_CTRL_1 */
3320 case 0xd8: /* SDRC_MANUAL_1 */
3329 static CPUReadMemoryFunc *omap_sdrc_readfn[] = {
3330 omap_badwidth_read32,
3331 omap_badwidth_read32,
3335 static CPUWriteMemoryFunc *omap_sdrc_writefn[] = {
3336 omap_badwidth_write32,
3337 omap_badwidth_write32,
3341 struct omap_sdrc_s *omap_sdrc_init(target_phys_addr_t base)
3344 struct omap_sdrc_s *s = (struct omap_sdrc_s *)
3345 qemu_mallocz(sizeof(struct omap_sdrc_s));
3350 iomemtype = cpu_register_io_memory(0, omap_sdrc_readfn,
3351 omap_sdrc_writefn, s);
3352 cpu_register_physical_memory(s->base, 0x1000, iomemtype);
3357 /* General-Purpose Memory Controller */
3358 struct omap_gpmc_s {
3359 target_phys_addr_t base;
3367 uint32_t prefconfig[2];
3371 struct omap_gpmc_cs_file_s {
3373 target_phys_addr_t base;
3376 void (*base_update)(void *opaque, target_phys_addr_t new);
3377 void (*unmap)(void *opaque);
3383 struct ecc_state_s ecc[9];
3386 static void omap_gpmc_int_update(struct omap_gpmc_s *s)
3388 qemu_set_irq(s->irq, s->irqen & s->irqst);
3391 static void omap_gpmc_cs_map(struct omap_gpmc_cs_file_s *f, int base, int mask)
3393 /* TODO: check for overlapping regions and report access errors */
3394 if ((mask != 0x8 && mask != 0xc && mask != 0xe && mask != 0xf) ||
3395 (base < 0 || base >= 0x40) ||
3396 (base & 0x0f & ~mask)) {
3397 fprintf(stderr, "%s: wrong cs address mapping/decoding!\n",
3405 f->base = base << 24;
3406 f->size = (0x0fffffff & ~(mask << 24)) + 1;
3407 /* TODO: rather than setting the size of the mapping (which should be
3408 * constant), the mask should cause wrapping of the address space, so
3409 * that the same memory becomes accessible at every <i>size</i> bytes
3410 * starting from <i>base</i>. */
3412 cpu_register_physical_memory(f->base, f->size, f->iomemtype);
3415 f->base_update(f->opaque, f->base);
3418 static void omap_gpmc_cs_unmap(struct omap_gpmc_cs_file_s *f)
3422 f->unmap(f->opaque);
3424 cpu_register_physical_memory(f->base, f->size, IO_MEM_UNASSIGNED);
3430 static void omap_gpmc_reset(struct omap_gpmc_s *s)
3437 omap_gpmc_int_update(s);
3440 s->prefconfig[0] = 0x00004000;
3441 s->prefconfig[1] = 0x00000000;
3445 for (i = 0; i < 8; i ++) {
3446 if (s->cs_file[i].config[6] & (1 << 6)) /* CSVALID */
3447 omap_gpmc_cs_unmap(s->cs_file + i);
3448 s->cs_file[i].config[0] = i ? 1 << 12 : 0;
3449 s->cs_file[i].config[1] = 0x101001;
3450 s->cs_file[i].config[2] = 0x020201;
3451 s->cs_file[i].config[3] = 0x10031003;
3452 s->cs_file[i].config[4] = 0x10f1111;
3453 s->cs_file[i].config[5] = 0;
3454 s->cs_file[i].config[6] = 0xf00 | (i ? 0 : 1 << 6);
3455 if (s->cs_file[i].config[6] & (1 << 6)) /* CSVALID */
3456 omap_gpmc_cs_map(&s->cs_file[i],
3457 s->cs_file[i].config[6] & 0x1f, /* MASKADDR */
3458 (s->cs_file[i].config[6] >> 8 & 0xf)); /* BASEADDR */
3460 omap_gpmc_cs_map(s->cs_file, 0, 0xf);
3463 s->ecc_cfg = 0x3fcff000;
3464 for (i = 0; i < 9; i ++)
3465 ecc_reset(&s->ecc[i]);
3468 static uint32_t omap_gpmc_read(void *opaque, target_phys_addr_t addr)
3470 struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
3471 int offset = addr - s->base;
3473 struct omap_gpmc_cs_file_s *f;
3476 case 0x000: /* GPMC_REVISION */
3479 case 0x010: /* GPMC_SYSCONFIG */
3480 return s->sysconfig;
3482 case 0x014: /* GPMC_SYSSTATUS */
3483 return 1; /* RESETDONE */
3485 case 0x018: /* GPMC_IRQSTATUS */
3488 case 0x01c: /* GPMC_IRQENABLE */
3491 case 0x040: /* GPMC_TIMEOUT_CONTROL */
3494 case 0x044: /* GPMC_ERR_ADDRESS */
3495 case 0x048: /* GPMC_ERR_TYPE */
3498 case 0x050: /* GPMC_CONFIG */
3501 case 0x054: /* GPMC_STATUS */
3504 case 0x060 ... 0x1d4:
3505 cs = (offset - 0x060) / 0x30;
3506 offset -= cs * 0x30;
3507 f = s->cs_file + cs;
3508 switch (offset - cs * 0x30) {
3509 case 0x60: /* GPMC_CONFIG1 */
3510 return f->config[0];
3511 case 0x64: /* GPMC_CONFIG2 */
3512 return f->config[1];
3513 case 0x68: /* GPMC_CONFIG3 */
3514 return f->config[2];
3515 case 0x6c: /* GPMC_CONFIG4 */
3516 return f->config[3];
3517 case 0x70: /* GPMC_CONFIG5 */
3518 return f->config[4];
3519 case 0x74: /* GPMC_CONFIG6 */
3520 return f->config[5];
3521 case 0x78: /* GPMC_CONFIG7 */
3522 return f->config[6];
3523 case 0x84: /* GPMC_NAND_DATA */
3528 case 0x1e0: /* GPMC_PREFETCH_CONFIG1 */
3529 return s->prefconfig[0];
3530 case 0x1e4: /* GPMC_PREFETCH_CONFIG2 */
3531 return s->prefconfig[1];
3532 case 0x1ec: /* GPMC_PREFETCH_CONTROL */
3533 return s->prefcontrol;
3534 case 0x1f0: /* GPMC_PREFETCH_STATUS */
3535 return (s->preffifo << 24) |
3537 ((s->prefconfig[0] >> 8) & 0x7f) ? 1 : 0) << 16) |
3540 case 0x1f4: /* GPMC_ECC_CONFIG */
3542 case 0x1f8: /* GPMC_ECC_CONTROL */
3544 case 0x1fc: /* GPMC_ECC_SIZE_CONFIG */
3546 case 0x200 ... 0x220: /* GPMC_ECC_RESULT */
3547 cs = (offset & 0x1f) >> 2;
3548 /* TODO: check correctness */
3550 ((s->ecc[cs].cp & 0x07) << 0) |
3551 ((s->ecc[cs].cp & 0x38) << 13) |
3552 ((s->ecc[cs].lp[0] & 0x1ff) << 3) |
3553 ((s->ecc[cs].lp[1] & 0x1ff) << 19);
3555 case 0x230: /* GPMC_TESTMODE_CTRL */
3557 case 0x234: /* GPMC_PSA_LSB */
3558 case 0x238: /* GPMC_PSA_MSB */
3566 static void omap_gpmc_write(void *opaque, target_phys_addr_t addr,
3569 struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
3570 int offset = addr - s->base;
3572 struct omap_gpmc_cs_file_s *f;
3575 case 0x000: /* GPMC_REVISION */
3576 case 0x014: /* GPMC_SYSSTATUS */
3577 case 0x054: /* GPMC_STATUS */
3578 case 0x1f0: /* GPMC_PREFETCH_STATUS */
3579 case 0x200 ... 0x220: /* GPMC_ECC_RESULT */
3580 case 0x234: /* GPMC_PSA_LSB */
3581 case 0x238: /* GPMC_PSA_MSB */
3585 case 0x010: /* GPMC_SYSCONFIG */
3586 if ((value >> 3) == 0x3)
3587 fprintf(stderr, "%s: bad SDRAM idle mode %i\n",
3588 __FUNCTION__, value >> 3);
3591 s->sysconfig = value & 0x19;
3594 case 0x018: /* GPMC_IRQSTATUS */
3596 omap_gpmc_int_update(s);
3599 case 0x01c: /* GPMC_IRQENABLE */
3600 s->irqen = value & 0xf03;
3601 omap_gpmc_int_update(s);
3604 case 0x040: /* GPMC_TIMEOUT_CONTROL */
3605 s->timeout = value & 0x1ff1;
3608 case 0x044: /* GPMC_ERR_ADDRESS */
3609 case 0x048: /* GPMC_ERR_TYPE */
3612 case 0x050: /* GPMC_CONFIG */
3613 s->config = value & 0xf13;
3616 case 0x060 ... 0x1d4:
3617 cs = (offset - 0x060) / 0x30;
3618 offset -= cs * 0x30;
3619 f = s->cs_file + cs;
3621 case 0x60: /* GPMC_CONFIG1 */
3622 f->config[0] = value & 0xffef3e13;
3624 case 0x64: /* GPMC_CONFIG2 */
3625 f->config[1] = value & 0x001f1f8f;
3627 case 0x68: /* GPMC_CONFIG3 */
3628 f->config[2] = value & 0x001f1f8f;
3630 case 0x6c: /* GPMC_CONFIG4 */
3631 f->config[3] = value & 0x1f8f1f8f;
3633 case 0x70: /* GPMC_CONFIG5 */
3634 f->config[4] = value & 0x0f1f1f1f;
3636 case 0x74: /* GPMC_CONFIG6 */
3637 f->config[5] = value & 0x00000fcf;
3639 case 0x78: /* GPMC_CONFIG7 */
3640 if ((f->config[6] ^ value) & 0xf7f) {
3641 if (f->config[6] & (1 << 6)) /* CSVALID */
3642 omap_gpmc_cs_unmap(f);
3643 if (value & (1 << 6)) /* CSVALID */
3644 omap_gpmc_cs_map(f, value & 0x1f, /* MASKADDR */
3645 (value >> 8 & 0xf)); /* BASEADDR */
3647 f->config[6] = value & 0x00000f7f;
3649 case 0x7c: /* GPMC_NAND_COMMAND */
3650 case 0x80: /* GPMC_NAND_ADDRESS */
3651 case 0x84: /* GPMC_NAND_DATA */
3659 case 0x1e0: /* GPMC_PREFETCH_CONFIG1 */
3660 s->prefconfig[0] = value & 0x7f8f7fbf;
3661 /* TODO: update interrupts, fifos, dmas */
3664 case 0x1e4: /* GPMC_PREFETCH_CONFIG2 */
3665 s->prefconfig[1] = value & 0x3fff;
3668 case 0x1ec: /* GPMC_PREFETCH_CONTROL */
3669 s->prefcontrol = value & 1;
3670 if (s->prefcontrol) {
3671 if (s->prefconfig[0] & 1)
3679 case 0x1f4: /* GPMC_ECC_CONFIG */
3682 case 0x1f8: /* GPMC_ECC_CONTROL */
3683 if (value & (1 << 8))
3684 for (cs = 0; cs < 9; cs ++)
3685 ecc_reset(&s->ecc[cs]);
3686 s->ecc_ptr = value & 0xf;
3687 if (s->ecc_ptr == 0 || s->ecc_ptr > 9) {
3692 case 0x1fc: /* GPMC_ECC_SIZE_CONFIG */
3693 s->ecc_cfg = value & 0x3fcff1ff;
3695 case 0x230: /* GPMC_TESTMODE_CTRL */
3697 fprintf(stderr, "%s: test mode enable attempt\n", __FUNCTION__);
3707 static CPUReadMemoryFunc *omap_gpmc_readfn[] = {
3708 omap_badwidth_read32, /* TODO */
3709 omap_badwidth_read32, /* TODO */
3713 static CPUWriteMemoryFunc *omap_gpmc_writefn[] = {
3714 omap_badwidth_write32, /* TODO */
3715 omap_badwidth_write32, /* TODO */
3719 struct omap_gpmc_s *omap_gpmc_init(target_phys_addr_t base, qemu_irq irq)
3722 struct omap_gpmc_s *s = (struct omap_gpmc_s *)
3723 qemu_mallocz(sizeof(struct omap_gpmc_s));
3728 iomemtype = cpu_register_io_memory(0, omap_gpmc_readfn,
3729 omap_gpmc_writefn, s);
3730 cpu_register_physical_memory(s->base, 0x1000, iomemtype);
3735 void omap_gpmc_attach(struct omap_gpmc_s *s, int cs, int iomemtype,
3736 void (*base_upd)(void *opaque, target_phys_addr_t new),
3737 void (*unmap)(void *opaque), void *opaque)
3739 struct omap_gpmc_cs_file_s *f;
3741 if (cs < 0 || cs >= 8) {
3742 fprintf(stderr, "%s: bad chip-select %i\n", __FUNCTION__, cs);
3745 f = &s->cs_file[cs];
3747 f->iomemtype = iomemtype;
3748 f->base_update = base_upd;
3752 if (f->config[6] & (1 << 6)) /* CSVALID */
3753 omap_gpmc_cs_map(f, f->config[6] & 0x1f, /* MASKADDR */
3754 (f->config[6] >> 8 & 0xf)); /* BASEADDR */
3757 /* General chip reset */
3758 static void omap2_mpu_reset(void *opaque)
3760 struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
3762 omap_inth_reset(mpu->ih[0]);
3763 omap_dma_reset(mpu->dma);
3764 omap_prcm_reset(mpu->prcm);
3765 omap_sysctl_reset(mpu->sysc);
3766 omap_gp_timer_reset(mpu->gptimer[0]);
3767 omap_gp_timer_reset(mpu->gptimer[1]);
3768 omap_gp_timer_reset(mpu->gptimer[2]);
3769 omap_gp_timer_reset(mpu->gptimer[3]);
3770 omap_gp_timer_reset(mpu->gptimer[4]);
3771 omap_gp_timer_reset(mpu->gptimer[5]);
3772 omap_gp_timer_reset(mpu->gptimer[6]);
3773 omap_gp_timer_reset(mpu->gptimer[7]);
3774 omap_gp_timer_reset(mpu->gptimer[8]);
3775 omap_gp_timer_reset(mpu->gptimer[9]);
3776 omap_gp_timer_reset(mpu->gptimer[10]);
3777 omap_gp_timer_reset(mpu->gptimer[11]);
3778 omap_synctimer_reset(&mpu->synctimer);
3779 omap_sdrc_reset(mpu->sdrc);
3780 omap_gpmc_reset(mpu->gpmc);
3781 omap_dss_reset(mpu->dss);
3782 omap_uart_reset(mpu->uart[0]);
3783 omap_uart_reset(mpu->uart[1]);
3784 omap_uart_reset(mpu->uart[2]);
3785 omap_mmc_reset(mpu->mmc);
3786 omap_gpif_reset(mpu->gpif);
3787 omap_mcspi_reset(mpu->mcspi[0]);
3788 omap_mcspi_reset(mpu->mcspi[1]);
3789 omap_i2c_reset(mpu->i2c[0]);
3790 omap_i2c_reset(mpu->i2c[1]);
3791 cpu_reset(mpu->env);
3794 static int omap2_validate_addr(struct omap_mpu_state_s *s,
3795 target_phys_addr_t addr)
3800 static const struct dma_irq_map omap2_dma_irq_map[] = {
3801 { 0, OMAP_INT_24XX_SDMA_IRQ0 },
3802 { 0, OMAP_INT_24XX_SDMA_IRQ1 },
3803 { 0, OMAP_INT_24XX_SDMA_IRQ2 },
3804 { 0, OMAP_INT_24XX_SDMA_IRQ3 },
3807 struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,
3808 DisplayState *ds, const char *core)
3810 struct omap_mpu_state_s *s = (struct omap_mpu_state_s *)
3811 qemu_mallocz(sizeof(struct omap_mpu_state_s));
3812 ram_addr_t sram_base, q2_base;
3814 qemu_irq dma_irqs[4];
3815 omap_clk gpio_clks[4];
3820 s->mpu_model = omap2420;
3821 s->env = cpu_init(core ?: "arm1136-r2");
3823 fprintf(stderr, "Unable to find CPU definition\n");
3826 s->sdram_size = sdram_size;
3827 s->sram_size = OMAP242X_SRAM_SIZE;
3829 s->wakeup = qemu_allocate_irqs(omap_mpu_wakeup, s, 1)[0];
3834 /* Memory-mapped stuff */
3835 cpu_register_physical_memory(OMAP2_Q2_BASE, s->sdram_size,
3836 (q2_base = qemu_ram_alloc(s->sdram_size)) | IO_MEM_RAM);
3837 cpu_register_physical_memory(OMAP2_SRAM_BASE, s->sram_size,
3838 (sram_base = qemu_ram_alloc(s->sram_size)) | IO_MEM_RAM);
3840 s->l4 = omap_l4_init(OMAP2_L4_BASE, 54);
3842 /* Actually mapped at any 2K boundary in the ARM11 private-peripheral if */
3843 cpu_irq = arm_pic_init_cpu(s->env);
3844 s->ih[0] = omap2_inth_init(0x480fe000, 0x1000, 3, &s->irq[0],
3845 cpu_irq[ARM_PIC_CPU_IRQ], cpu_irq[ARM_PIC_CPU_FIQ],
3846 omap_findclk(s, "mpu_intc_fclk"),
3847 omap_findclk(s, "mpu_intc_iclk"));
3849 s->prcm = omap_prcm_init(omap_l4tao(s->l4, 3),
3850 s->irq[0][OMAP_INT_24XX_PRCM_MPU_IRQ], NULL, NULL, s);
3852 s->sysc = omap_sysctl_init(omap_l4tao(s->l4, 1),
3853 omap_findclk(s, "omapctrl_iclk"), s);
3855 for (i = 0; i < 4; i ++)
3857 s->irq[omap2_dma_irq_map[i].ih][omap2_dma_irq_map[i].intr];
3858 s->dma = omap_dma4_init(0x48056000, dma_irqs, s, 256, 32,
3859 omap_findclk(s, "sdma_iclk"),
3860 omap_findclk(s, "sdma_fclk"));
3861 s->port->addr_valid = omap2_validate_addr;
3863 s->uart[0] = omap2_uart_init(omap_l4ta(s->l4, 19),
3864 s->irq[0][OMAP_INT_24XX_UART1_IRQ],
3865 omap_findclk(s, "uart1_fclk"),
3866 omap_findclk(s, "uart1_iclk"),
3867 s->drq[OMAP24XX_DMA_UART1_TX],
3868 s->drq[OMAP24XX_DMA_UART1_RX], serial_hds[0]);
3869 s->uart[1] = omap2_uart_init(omap_l4ta(s->l4, 20),
3870 s->irq[0][OMAP_INT_24XX_UART2_IRQ],
3871 omap_findclk(s, "uart2_fclk"),
3872 omap_findclk(s, "uart2_iclk"),
3873 s->drq[OMAP24XX_DMA_UART2_TX],
3874 s->drq[OMAP24XX_DMA_UART2_RX],
3875 serial_hds[0] ? serial_hds[1] : 0);
3876 s->uart[2] = omap2_uart_init(omap_l4ta(s->l4, 21),
3877 s->irq[0][OMAP_INT_24XX_UART3_IRQ],
3878 omap_findclk(s, "uart3_fclk"),
3879 omap_findclk(s, "uart3_iclk"),
3880 s->drq[OMAP24XX_DMA_UART3_TX],
3881 s->drq[OMAP24XX_DMA_UART3_RX],
3882 serial_hds[0] && serial_hds[1] ? serial_hds[2] : 0);
3884 s->gptimer[0] = omap_gp_timer_init(omap_l4ta(s->l4, 7),
3885 s->irq[0][OMAP_INT_24XX_GPTIMER1],
3886 omap_findclk(s, "wu_gpt1_clk"),
3887 omap_findclk(s, "wu_l4_iclk"));
3888 s->gptimer[1] = omap_gp_timer_init(omap_l4ta(s->l4, 8),
3889 s->irq[0][OMAP_INT_24XX_GPTIMER2],
3890 omap_findclk(s, "core_gpt2_clk"),
3891 omap_findclk(s, "core_l4_iclk"));
3892 s->gptimer[2] = omap_gp_timer_init(omap_l4ta(s->l4, 22),
3893 s->irq[0][OMAP_INT_24XX_GPTIMER3],
3894 omap_findclk(s, "core_gpt3_clk"),
3895 omap_findclk(s, "core_l4_iclk"));
3896 s->gptimer[3] = omap_gp_timer_init(omap_l4ta(s->l4, 23),
3897 s->irq[0][OMAP_INT_24XX_GPTIMER4],
3898 omap_findclk(s, "core_gpt4_clk"),
3899 omap_findclk(s, "core_l4_iclk"));
3900 s->gptimer[4] = omap_gp_timer_init(omap_l4ta(s->l4, 24),
3901 s->irq[0][OMAP_INT_24XX_GPTIMER5],
3902 omap_findclk(s, "core_gpt5_clk"),
3903 omap_findclk(s, "core_l4_iclk"));
3904 s->gptimer[5] = omap_gp_timer_init(omap_l4ta(s->l4, 25),
3905 s->irq[0][OMAP_INT_24XX_GPTIMER6],
3906 omap_findclk(s, "core_gpt6_clk"),
3907 omap_findclk(s, "core_l4_iclk"));
3908 s->gptimer[6] = omap_gp_timer_init(omap_l4ta(s->l4, 26),
3909 s->irq[0][OMAP_INT_24XX_GPTIMER7],
3910 omap_findclk(s, "core_gpt7_clk"),
3911 omap_findclk(s, "core_l4_iclk"));
3912 s->gptimer[7] = omap_gp_timer_init(omap_l4ta(s->l4, 27),
3913 s->irq[0][OMAP_INT_24XX_GPTIMER8],
3914 omap_findclk(s, "core_gpt8_clk"),
3915 omap_findclk(s, "core_l4_iclk"));
3916 s->gptimer[8] = omap_gp_timer_init(omap_l4ta(s->l4, 28),
3917 s->irq[0][OMAP_INT_24XX_GPTIMER9],
3918 omap_findclk(s, "core_gpt9_clk"),
3919 omap_findclk(s, "core_l4_iclk"));
3920 s->gptimer[9] = omap_gp_timer_init(omap_l4ta(s->l4, 29),
3921 s->irq[0][OMAP_INT_24XX_GPTIMER10],
3922 omap_findclk(s, "core_gpt10_clk"),
3923 omap_findclk(s, "core_l4_iclk"));
3924 s->gptimer[10] = omap_gp_timer_init(omap_l4ta(s->l4, 30),
3925 s->irq[0][OMAP_INT_24XX_GPTIMER11],
3926 omap_findclk(s, "core_gpt11_clk"),
3927 omap_findclk(s, "core_l4_iclk"));
3928 s->gptimer[11] = omap_gp_timer_init(omap_l4ta(s->l4, 31),
3929 s->irq[0][OMAP_INT_24XX_GPTIMER12],
3930 omap_findclk(s, "core_gpt12_clk"),
3931 omap_findclk(s, "core_l4_iclk"));
3933 omap_tap_init(omap_l4ta(s->l4, 2), s);
3935 omap_synctimer_init(omap_l4tao(s->l4, 2), s,
3936 omap_findclk(s, "clk32-kHz"),
3937 omap_findclk(s, "core_l4_iclk"));
3939 s->i2c[0] = omap2_i2c_init(omap_l4tao(s->l4, 5),
3940 s->irq[0][OMAP_INT_24XX_I2C1_IRQ],
3941 &s->drq[OMAP24XX_DMA_I2C1_TX],
3942 omap_findclk(s, "i2c1.fclk"),
3943 omap_findclk(s, "i2c1.iclk"));
3944 s->i2c[1] = omap2_i2c_init(omap_l4tao(s->l4, 6),
3945 s->irq[0][OMAP_INT_24XX_I2C2_IRQ],
3946 &s->drq[OMAP24XX_DMA_I2C2_TX],
3947 omap_findclk(s, "i2c2.fclk"),
3948 omap_findclk(s, "i2c2.iclk"));
3950 gpio_clks[0] = omap_findclk(s, "gpio1_dbclk");
3951 gpio_clks[1] = omap_findclk(s, "gpio2_dbclk");
3952 gpio_clks[2] = omap_findclk(s, "gpio3_dbclk");
3953 gpio_clks[3] = omap_findclk(s, "gpio4_dbclk");
3954 s->gpif = omap2_gpio_init(omap_l4ta(s->l4, 3),
3955 &s->irq[0][OMAP_INT_24XX_GPIO_BANK1],
3956 gpio_clks, omap_findclk(s, "gpio_iclk"), 4);
3958 s->sdrc = omap_sdrc_init(0x68009000);
3959 s->gpmc = omap_gpmc_init(0x6800a000, s->irq[0][OMAP_INT_24XX_GPMC_IRQ]);
3961 sdindex = drive_get_index(IF_SD, 0, 0);
3962 if (sdindex == -1) {
3963 fprintf(stderr, "qemu: missing SecureDigital device\n");
3966 s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9), drives_table[sdindex].bdrv,
3967 s->irq[0][OMAP_INT_24XX_MMC_IRQ],
3968 &s->drq[OMAP24XX_DMA_MMC1_TX],
3969 omap_findclk(s, "mmc_fclk"), omap_findclk(s, "mmc_iclk"));
3971 s->mcspi[0] = omap_mcspi_init(omap_l4ta(s->l4, 35), 4,
3972 s->irq[0][OMAP_INT_24XX_MCSPI1_IRQ],
3973 &s->drq[OMAP24XX_DMA_SPI1_TX0],
3974 omap_findclk(s, "spi1_fclk"),
3975 omap_findclk(s, "spi1_iclk"));
3976 s->mcspi[1] = omap_mcspi_init(omap_l4ta(s->l4, 36), 2,
3977 s->irq[0][OMAP_INT_24XX_MCSPI2_IRQ],
3978 &s->drq[OMAP24XX_DMA_SPI2_TX0],
3979 omap_findclk(s, "spi2_fclk"),
3980 omap_findclk(s, "spi2_iclk"));
3982 s->dss = omap_dss_init(omap_l4ta(s->l4, 10), 0x68000800, ds,
3983 /* XXX wire M_IRQ_25, D_L2_IRQ_30 and I_IRQ_13 together */
3984 s->irq[0][OMAP_INT_24XX_DSS_IRQ], s->drq[OMAP24XX_DMA_DSS],
3985 omap_findclk(s, "dss_clk1"), omap_findclk(s, "dss_clk2"),
3986 omap_findclk(s, "dss_54m_clk"),
3987 omap_findclk(s, "dss_l3_iclk"),
3988 omap_findclk(s, "dss_l4_iclk"));
3990 omap_sti_init(omap_l4ta(s->l4, 18), 0x54000000,
3991 s->irq[0][OMAP_INT_24XX_STI], omap_findclk(s, "emul_ck"),
3992 serial_hds[0] && serial_hds[1] && serial_hds[2] ?
3995 /* All register mappings (includin those not currenlty implemented):
3996 * SystemControlMod 48000000 - 48000fff
3997 * SystemControlL4 48001000 - 48001fff
3998 * 32kHz Timer Mod 48004000 - 48004fff
3999 * 32kHz Timer L4 48005000 - 48005fff
4000 * PRCM ModA 48008000 - 480087ff
4001 * PRCM ModB 48008800 - 48008fff
4002 * PRCM L4 48009000 - 48009fff
4003 * TEST-BCM Mod 48012000 - 48012fff
4004 * TEST-BCM L4 48013000 - 48013fff
4005 * TEST-TAP Mod 48014000 - 48014fff
4006 * TEST-TAP L4 48015000 - 48015fff
4007 * GPIO1 Mod 48018000 - 48018fff
4008 * GPIO Top 48019000 - 48019fff
4009 * GPIO2 Mod 4801a000 - 4801afff
4010 * GPIO L4 4801b000 - 4801bfff
4011 * GPIO3 Mod 4801c000 - 4801cfff
4012 * GPIO4 Mod 4801e000 - 4801efff
4013 * WDTIMER1 Mod 48020000 - 48010fff
4014 * WDTIMER Top 48021000 - 48011fff
4015 * WDTIMER2 Mod 48022000 - 48012fff
4016 * WDTIMER L4 48023000 - 48013fff
4017 * WDTIMER3 Mod 48024000 - 48014fff
4018 * WDTIMER3 L4 48025000 - 48015fff
4019 * WDTIMER4 Mod 48026000 - 48016fff
4020 * WDTIMER4 L4 48027000 - 48017fff
4021 * GPTIMER1 Mod 48028000 - 48018fff
4022 * GPTIMER1 L4 48029000 - 48019fff
4023 * GPTIMER2 Mod 4802a000 - 4801afff
4024 * GPTIMER2 L4 4802b000 - 4801bfff
4025 * L4-Config AP 48040000 - 480407ff
4026 * L4-Config IP 48040800 - 48040fff
4027 * L4-Config LA 48041000 - 48041fff
4028 * ARM11ETB Mod 48048000 - 48049fff
4029 * ARM11ETB L4 4804a000 - 4804afff
4030 * DISPLAY Top 48050000 - 480503ff
4031 * DISPLAY DISPC 48050400 - 480507ff
4032 * DISPLAY RFBI 48050800 - 48050bff
4033 * DISPLAY VENC 48050c00 - 48050fff
4034 * DISPLAY L4 48051000 - 48051fff
4035 * CAMERA Top 48052000 - 480523ff
4036 * CAMERA core 48052400 - 480527ff
4037 * CAMERA DMA 48052800 - 48052bff
4038 * CAMERA MMU 48052c00 - 48052fff
4039 * CAMERA L4 48053000 - 48053fff
4040 * SDMA Mod 48056000 - 48056fff
4041 * SDMA L4 48057000 - 48057fff
4042 * SSI Top 48058000 - 48058fff
4043 * SSI GDD 48059000 - 48059fff
4044 * SSI Port1 4805a000 - 4805afff
4045 * SSI Port2 4805b000 - 4805bfff
4046 * SSI L4 4805c000 - 4805cfff
4047 * USB Mod 4805e000 - 480fefff
4048 * USB L4 4805f000 - 480fffff
4049 * WIN_TRACER1 Mod 48060000 - 48060fff
4050 * WIN_TRACER1 L4 48061000 - 48061fff
4051 * WIN_TRACER2 Mod 48062000 - 48062fff
4052 * WIN_TRACER2 L4 48063000 - 48063fff
4053 * WIN_TRACER3 Mod 48064000 - 48064fff
4054 * WIN_TRACER3 L4 48065000 - 48065fff
4055 * WIN_TRACER4 Top 48066000 - 480660ff
4056 * WIN_TRACER4 ETT 48066100 - 480661ff
4057 * WIN_TRACER4 WT 48066200 - 480662ff
4058 * WIN_TRACER4 L4 48067000 - 48067fff
4059 * XTI Mod 48068000 - 48068fff
4060 * XTI L4 48069000 - 48069fff
4061 * UART1 Mod 4806a000 - 4806afff
4062 * UART1 L4 4806b000 - 4806bfff
4063 * UART2 Mod 4806c000 - 4806cfff
4064 * UART2 L4 4806d000 - 4806dfff
4065 * UART3 Mod 4806e000 - 4806efff
4066 * UART3 L4 4806f000 - 4806ffff
4067 * I2C1 Mod 48070000 - 48070fff
4068 * I2C1 L4 48071000 - 48071fff
4069 * I2C2 Mod 48072000 - 48072fff
4070 * I2C2 L4 48073000 - 48073fff
4071 * McBSP1 Mod 48074000 - 48074fff
4072 * McBSP1 L4 48075000 - 48075fff
4073 * McBSP2 Mod 48076000 - 48076fff
4074 * McBSP2 L4 48077000 - 48077fff
4075 * GPTIMER3 Mod 48078000 - 48078fff
4076 * GPTIMER3 L4 48079000 - 48079fff
4077 * GPTIMER4 Mod 4807a000 - 4807afff
4078 * GPTIMER4 L4 4807b000 - 4807bfff
4079 * GPTIMER5 Mod 4807c000 - 4807cfff
4080 * GPTIMER5 L4 4807d000 - 4807dfff
4081 * GPTIMER6 Mod 4807e000 - 4807efff
4082 * GPTIMER6 L4 4807f000 - 4807ffff
4083 * GPTIMER7 Mod 48080000 - 48080fff
4084 * GPTIMER7 L4 48081000 - 48081fff
4085 * GPTIMER8 Mod 48082000 - 48082fff
4086 * GPTIMER8 L4 48083000 - 48083fff
4087 * GPTIMER9 Mod 48084000 - 48084fff
4088 * GPTIMER9 L4 48085000 - 48085fff
4089 * GPTIMER10 Mod 48086000 - 48086fff
4090 * GPTIMER10 L4 48087000 - 48087fff
4091 * GPTIMER11 Mod 48088000 - 48088fff
4092 * GPTIMER11 L4 48089000 - 48089fff
4093 * GPTIMER12 Mod 4808a000 - 4808afff
4094 * GPTIMER12 L4 4808b000 - 4808bfff
4095 * EAC Mod 48090000 - 48090fff
4096 * EAC L4 48091000 - 48091fff
4097 * FAC Mod 48092000 - 48092fff
4098 * FAC L4 48093000 - 48093fff
4099 * MAILBOX Mod 48094000 - 48094fff
4100 * MAILBOX L4 48095000 - 48095fff
4101 * SPI1 Mod 48098000 - 48098fff
4102 * SPI1 L4 48099000 - 48099fff
4103 * SPI2 Mod 4809a000 - 4809afff
4104 * SPI2 L4 4809b000 - 4809bfff
4105 * MMC/SDIO Mod 4809c000 - 4809cfff
4106 * MMC/SDIO L4 4809d000 - 4809dfff
4107 * MS_PRO Mod 4809e000 - 4809efff
4108 * MS_PRO L4 4809f000 - 4809ffff
4109 * RNG Mod 480a0000 - 480a0fff
4110 * RNG L4 480a1000 - 480a1fff
4111 * DES3DES Mod 480a2000 - 480a2fff
4112 * DES3DES L4 480a3000 - 480a3fff
4113 * SHA1MD5 Mod 480a4000 - 480a4fff
4114 * SHA1MD5 L4 480a5000 - 480a5fff
4115 * AES Mod 480a6000 - 480a6fff
4116 * AES L4 480a7000 - 480a7fff
4117 * PKA Mod 480a8000 - 480a9fff
4118 * PKA L4 480aa000 - 480aafff
4119 * MG Mod 480b0000 - 480b0fff
4120 * MG L4 480b1000 - 480b1fff
4121 * HDQ/1-wire Mod 480b2000 - 480b2fff
4122 * HDQ/1-wire L4 480b3000 - 480b3fff
4123 * MPU interrupt 480fe000 - 480fefff
4124 * STI channel base 54000000 - 5400ffff
4125 * IVA RAM 5c000000 - 5c01ffff
4126 * IVA ROM 5c020000 - 5c027fff
4127 * IMG_BUF_A 5c040000 - 5c040fff
4128 * IMG_BUF_B 5c042000 - 5c042fff
4129 * VLCDS 5c048000 - 5c0487ff
4130 * IMX_COEF 5c049000 - 5c04afff
4131 * IMX_CMD 5c051000 - 5c051fff
4132 * VLCDQ 5c053000 - 5c0533ff
4133 * VLCDH 5c054000 - 5c054fff
4134 * SEQ_CMD 5c055000 - 5c055fff
4135 * IMX_REG 5c056000 - 5c0560ff
4136 * VLCD_REG 5c056100 - 5c0561ff
4137 * SEQ_REG 5c056200 - 5c0562ff
4138 * IMG_BUF_REG 5c056300 - 5c0563ff
4139 * SEQIRQ_REG 5c056400 - 5c0564ff
4140 * OCP_REG 5c060000 - 5c060fff
4141 * SYSC_REG 5c070000 - 5c070fff
4142 * MMU_REG 5d000000 - 5d000fff
4143 * sDMA R 68000400 - 680005ff
4144 * sDMA W 68000600 - 680007ff
4145 * Display Control 68000800 - 680009ff
4146 * DSP subsystem 68000a00 - 68000bff
4147 * MPU subsystem 68000c00 - 68000dff
4148 * IVA subsystem 68001000 - 680011ff
4149 * USB 68001200 - 680013ff
4150 * Camera 68001400 - 680015ff
4151 * VLYNQ (firewall) 68001800 - 68001bff
4152 * VLYNQ 68001e00 - 68001fff
4153 * SSI 68002000 - 680021ff
4154 * L4 68002400 - 680025ff
4155 * DSP (firewall) 68002800 - 68002bff
4156 * DSP subsystem 68002e00 - 68002fff
4157 * IVA (firewall) 68003000 - 680033ff
4158 * IVA 68003600 - 680037ff
4159 * GFX 68003a00 - 68003bff
4160 * CMDWR emulation 68003c00 - 68003dff
4161 * SMS 68004000 - 680041ff
4162 * OCM 68004200 - 680043ff
4163 * GPMC 68004400 - 680045ff
4164 * RAM (firewall) 68005000 - 680053ff
4165 * RAM (err login) 68005400 - 680057ff
4166 * ROM (firewall) 68005800 - 68005bff
4167 * ROM (err login) 68005c00 - 68005fff
4168 * GPMC (firewall) 68006000 - 680063ff
4169 * GPMC (err login) 68006400 - 680067ff
4170 * SMS (err login) 68006c00 - 68006fff
4171 * SMS registers 68008000 - 68008fff
4172 * SDRC registers 68009000 - 68009fff
4173 * GPMC registers 6800a000 6800afff
4176 qemu_register_reset(omap2_mpu_reset, s);