4 * Copyright (c) 2007 Magnus Damm
5 * Copyright (c) 2005 Samuel Tardieu
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 #include "sh7750_regs.h"
30 #include "sh7750_regnames.h"
37 typedef struct SH7750State
{
40 /* Peripheral frequency in Hz */
42 /* SDRAM controller */
48 /* PCMCIA controller */
54 uint16_t portdira
; /* Cached */
55 uint16_t portpullupa
; /* Cached */
56 uint16_t portdirb
; /* Cached */
57 uint16_t portpullupb
; /* Cached */
60 uint16_t periph_pdtra
; /* Imposed by the peripherals */
61 uint16_t periph_portdira
; /* Direction seen from the peripherals */
62 uint16_t periph_pdtrb
; /* Imposed by the peripherals */
63 uint16_t periph_portdirb
; /* Direction seen from the peripherals */
64 sh7750_io_device
*devices
[NB_DEVICES
]; /* External peripherals */
69 struct intc_desc intc
;
72 static inline int has_bcr3_and_bcr4(SH7750State
* s
)
74 return (s
->cpu
->features
& SH_FEATURE_BCR3_AND_BCR4
);
76 /**********************************************************************
78 **********************************************************************/
80 int sh7750_register_io_device(SH7750State
* s
, sh7750_io_device
* device
)
84 for (i
= 0; i
< NB_DEVICES
; i
++) {
85 if (s
->devices
[i
] == NULL
) {
86 s
->devices
[i
] = device
;
93 static uint16_t portdir(uint32_t v
)
95 #define EVENPORTMASK(n) ((v & (1<<((n)<<1))) >> (n))
97 EVENPORTMASK(15) | EVENPORTMASK(14) | EVENPORTMASK(13) |
98 EVENPORTMASK(12) | EVENPORTMASK(11) | EVENPORTMASK(10) |
99 EVENPORTMASK(9) | EVENPORTMASK(8) | EVENPORTMASK(7) |
100 EVENPORTMASK(6) | EVENPORTMASK(5) | EVENPORTMASK(4) |
101 EVENPORTMASK(3) | EVENPORTMASK(2) | EVENPORTMASK(1) |
105 static uint16_t portpullup(uint32_t v
)
107 #define ODDPORTMASK(n) ((v & (1<<(((n)<<1)+1))) >> (n))
109 ODDPORTMASK(15) | ODDPORTMASK(14) | ODDPORTMASK(13) |
110 ODDPORTMASK(12) | ODDPORTMASK(11) | ODDPORTMASK(10) |
111 ODDPORTMASK(9) | ODDPORTMASK(8) | ODDPORTMASK(7) | ODDPORTMASK(6) |
112 ODDPORTMASK(5) | ODDPORTMASK(4) | ODDPORTMASK(3) | ODDPORTMASK(2) |
113 ODDPORTMASK(1) | ODDPORTMASK(0);
116 static uint16_t porta_lines(SH7750State
* s
)
118 return (s
->portdira
& s
->pdtra
) | /* CPU */
119 (s
->periph_portdira
& s
->periph_pdtra
) | /* Peripherals */
120 (~(s
->portdira
| s
->periph_portdira
) & s
->portpullupa
); /* Pullups */
123 static uint16_t portb_lines(SH7750State
* s
)
125 return (s
->portdirb
& s
->pdtrb
) | /* CPU */
126 (s
->periph_portdirb
& s
->periph_pdtrb
) | /* Peripherals */
127 (~(s
->portdirb
| s
->periph_portdirb
) & s
->portpullupb
); /* Pullups */
130 static void gen_port_interrupts(SH7750State
* s
)
132 /* XXXXX interrupts not generated */
135 static void porta_changed(SH7750State
* s
, uint16_t prev
)
137 uint16_t currenta
, changes
;
141 fprintf(stderr
, "porta changed from 0x%04x to 0x%04x\n",
142 prev
, porta_lines(s
));
143 fprintf(stderr
, "pdtra=0x%04x, pctra=0x%08x\n", s
->pdtra
, s
->pctra
);
145 currenta
= porta_lines(s
);
146 if (currenta
== prev
)
148 changes
= currenta
^ prev
;
150 for (i
= 0; i
< NB_DEVICES
; i
++) {
151 if (s
->devices
[i
] && (s
->devices
[i
]->portamask_trigger
& changes
)) {
152 r
|= s
->devices
[i
]->port_change_cb(currenta
, portb_lines(s
),
156 &s
->periph_portdirb
);
161 gen_port_interrupts(s
);
164 static void portb_changed(SH7750State
* s
, uint16_t prev
)
166 uint16_t currentb
, changes
;
169 currentb
= portb_lines(s
);
170 if (currentb
== prev
)
172 changes
= currentb
^ prev
;
174 for (i
= 0; i
< NB_DEVICES
; i
++) {
175 if (s
->devices
[i
] && (s
->devices
[i
]->portbmask_trigger
& changes
)) {
176 r
|= s
->devices
[i
]->port_change_cb(portb_lines(s
), currentb
,
180 &s
->periph_portdirb
);
185 gen_port_interrupts(s
);
188 /**********************************************************************
190 **********************************************************************/
192 static void error_access(const char *kind
, target_phys_addr_t addr
)
194 fprintf(stderr
, "%s to %s (0x" TARGET_FMT_plx
") not supported\n",
195 kind
, regname(addr
), addr
);
198 static void ignore_access(const char *kind
, target_phys_addr_t addr
)
200 fprintf(stderr
, "%s to %s (0x" TARGET_FMT_plx
") ignored\n",
201 kind
, regname(addr
), addr
);
204 static uint32_t sh7750_mem_readb(void *opaque
, target_phys_addr_t addr
)
208 error_access("byte read", addr
);
213 static uint32_t sh7750_mem_readw(void *opaque
, target_phys_addr_t addr
)
215 SH7750State
*s
= opaque
;
221 if(!has_bcr3_and_bcr4(s
))
222 error_access("word read", addr
);
224 case SH7750_FRQCR_A7
:
230 "Read access to refresh count register, incrementing\n");
232 case SH7750_PDTRA_A7
:
233 return porta_lines(s
);
234 case SH7750_PDTRB_A7
:
235 return portb_lines(s
);
236 case SH7750_RTCOR_A7
:
237 case SH7750_RTCNT_A7
:
238 case SH7750_RTCSR_A7
:
239 ignore_access("word read", addr
);
242 error_access("word read", addr
);
247 static uint32_t sh7750_mem_readl(void *opaque
, target_phys_addr_t addr
)
249 SH7750State
*s
= opaque
;
255 if(!has_bcr3_and_bcr4(s
))
256 error_access("long read", addr
);
262 ignore_access("long read", addr
);
264 case SH7750_MMUCR_A7
:
265 return s
->cpu
->mmucr
;
276 case SH7750_EXPEVT_A7
:
277 return s
->cpu
->expevt
;
278 case SH7750_INTEVT_A7
:
279 return s
->cpu
->intevt
;
282 case 0x1f000030: /* Processor version */
284 case 0x1f000040: /* Cache version */
286 case 0x1f000044: /* Processor revision */
289 error_access("long read", addr
);
294 #define is_in_sdrmx(a, x) (a >= SH7750_SDMR ## x ## _A7 \
295 && a <= (SH7750_SDMR ## x ## _A7 + SH7750_SDMR ## x ## _REGNB))
296 static void sh7750_mem_writeb(void *opaque
, target_phys_addr_t addr
,
300 if (is_in_sdrmx(addr
, 2) || is_in_sdrmx(addr
, 3)) {
301 ignore_access("byte write", addr
);
305 error_access("byte write", addr
);
309 static void sh7750_mem_writew(void *opaque
, target_phys_addr_t addr
,
312 SH7750State
*s
= opaque
;
316 /* SDRAM controller */
321 if(!has_bcr3_and_bcr4(s
))
322 error_access("word write", addr
);
328 case SH7750_RTCNT_A7
:
329 case SH7750_RTCOR_A7
:
330 case SH7750_RTCSR_A7
:
331 ignore_access("word write", addr
);
334 case SH7750_PDTRA_A7
:
335 temp
= porta_lines(s
);
336 s
->pdtra
= mem_value
;
337 porta_changed(s
, temp
);
339 case SH7750_PDTRB_A7
:
340 temp
= portb_lines(s
);
341 s
->pdtrb
= mem_value
;
342 portb_changed(s
, temp
);
345 fprintf(stderr
, "Write access to refresh count register\n");
348 case SH7750_GPIOIC_A7
:
349 s
->gpioic
= mem_value
;
350 if (mem_value
!= 0) {
351 fprintf(stderr
, "I/O interrupts not implemented\n");
356 error_access("word write", addr
);
361 static void sh7750_mem_writel(void *opaque
, target_phys_addr_t addr
,
364 SH7750State
*s
= opaque
;
368 /* SDRAM controller */
373 if(!has_bcr3_and_bcr4(s
))
374 error_access("long write", addr
);
381 ignore_access("long write", addr
);
384 case SH7750_PCTRA_A7
:
385 temp
= porta_lines(s
);
386 s
->pctra
= mem_value
;
387 s
->portdira
= portdir(mem_value
);
388 s
->portpullupa
= portpullup(mem_value
);
389 porta_changed(s
, temp
);
391 case SH7750_PCTRB_A7
:
392 temp
= portb_lines(s
);
393 s
->pctrb
= mem_value
;
394 s
->portdirb
= portdir(mem_value
);
395 s
->portpullupb
= portpullup(mem_value
);
396 portb_changed(s
, temp
);
398 case SH7750_MMUCR_A7
:
399 if (mem_value
& MMUCR_TI
) {
400 cpu_sh4_invalidate_tlb(s
->cpu
);
402 s
->cpu
->mmucr
= mem_value
& ~MMUCR_TI
;
405 /* If asid changes, clear all registered tlb entries. */
406 if ((s
->cpu
->pteh
& 0xff) != (mem_value
& 0xff))
407 tlb_flush(s
->cpu
, 1);
408 s
->cpu
->pteh
= mem_value
;
411 s
->cpu
->ptel
= mem_value
;
414 s
->cpu
->ptea
= mem_value
& 0x0000000f;
417 s
->cpu
->ttb
= mem_value
;
420 s
->cpu
->tea
= mem_value
;
423 s
->cpu
->tra
= mem_value
& 0x000007ff;
425 case SH7750_EXPEVT_A7
:
426 s
->cpu
->expevt
= mem_value
& 0x000007ff;
428 case SH7750_INTEVT_A7
:
429 s
->cpu
->intevt
= mem_value
& 0x000007ff;
435 error_access("long write", addr
);
440 static CPUReadMemoryFunc
* const sh7750_mem_read
[] = {
446 static CPUWriteMemoryFunc
* const sh7750_mem_write
[] = {
452 /* sh775x interrupt controller tables for sh_intc.c
453 * stolen from linux/arch/sh/kernel/cpu/sh4/setup-sh7750.c
459 /* interrupt sources */
460 IRL_0
, IRL_1
, IRL_2
, IRL_3
, IRL_4
, IRL_5
, IRL_6
, IRL_7
,
461 IRL_8
, IRL_9
, IRL_A
, IRL_B
, IRL_C
, IRL_D
, IRL_E
,
462 IRL0
, IRL1
, IRL2
, IRL3
,
464 DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
, DMAC_DMTE3
,
465 DMAC_DMTE4
, DMAC_DMTE5
, DMAC_DMTE6
, DMAC_DMTE7
,
467 PCIC0_PCISERR
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
468 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
,
469 TMU3
, TMU4
, TMU0
, TMU1
, TMU2_TUNI
, TMU2_TICPI
,
470 RTC_ATI
, RTC_PRI
, RTC_CUI
,
471 SCI1_ERI
, SCI1_RXI
, SCI1_TXI
, SCI1_TEI
,
472 SCIF_ERI
, SCIF_RXI
, SCIF_BRI
, SCIF_TXI
,
476 /* interrupt groups */
477 DMAC
, PCIC1
, TMU2
, RTC
, SCI1
, SCIF
, REF
,
484 static struct intc_vect vectors
[] = {
485 INTC_VECT(HUDI
, 0x600), INTC_VECT(GPIOI
, 0x620),
486 INTC_VECT(TMU0
, 0x400), INTC_VECT(TMU1
, 0x420),
487 INTC_VECT(TMU2_TUNI
, 0x440), INTC_VECT(TMU2_TICPI
, 0x460),
488 INTC_VECT(RTC_ATI
, 0x480), INTC_VECT(RTC_PRI
, 0x4a0),
489 INTC_VECT(RTC_CUI
, 0x4c0),
490 INTC_VECT(SCI1_ERI
, 0x4e0), INTC_VECT(SCI1_RXI
, 0x500),
491 INTC_VECT(SCI1_TXI
, 0x520), INTC_VECT(SCI1_TEI
, 0x540),
492 INTC_VECT(SCIF_ERI
, 0x700), INTC_VECT(SCIF_RXI
, 0x720),
493 INTC_VECT(SCIF_BRI
, 0x740), INTC_VECT(SCIF_TXI
, 0x760),
494 INTC_VECT(WDT
, 0x560),
495 INTC_VECT(REF_RCMI
, 0x580), INTC_VECT(REF_ROVI
, 0x5a0),
498 static struct intc_group groups
[] = {
499 INTC_GROUP(TMU2
, TMU2_TUNI
, TMU2_TICPI
),
500 INTC_GROUP(RTC
, RTC_ATI
, RTC_PRI
, RTC_CUI
),
501 INTC_GROUP(SCI1
, SCI1_ERI
, SCI1_RXI
, SCI1_TXI
, SCI1_TEI
),
502 INTC_GROUP(SCIF
, SCIF_ERI
, SCIF_RXI
, SCIF_BRI
, SCIF_TXI
),
503 INTC_GROUP(REF
, REF_RCMI
, REF_ROVI
),
506 static struct intc_prio_reg prio_registers
[] = {
507 { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0
, TMU1
, TMU2
, RTC
} },
508 { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT
, REF
, SCI1
, 0 } },
509 { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI
, DMAC
, SCIF
, HUDI
} },
510 { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0
, IRL1
, IRL2
, IRL3
} },
511 { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
513 PCIC1
, PCIC0_PCISERR
} },
516 /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
518 static struct intc_vect vectors_dma4
[] = {
519 INTC_VECT(DMAC_DMTE0
, 0x640), INTC_VECT(DMAC_DMTE1
, 0x660),
520 INTC_VECT(DMAC_DMTE2
, 0x680), INTC_VECT(DMAC_DMTE3
, 0x6a0),
521 INTC_VECT(DMAC_DMAE
, 0x6c0),
524 static struct intc_group groups_dma4
[] = {
525 INTC_GROUP(DMAC
, DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
,
526 DMAC_DMTE3
, DMAC_DMAE
),
529 /* SH7750R and SH7751R both have 8-channel DMA controllers */
531 static struct intc_vect vectors_dma8
[] = {
532 INTC_VECT(DMAC_DMTE0
, 0x640), INTC_VECT(DMAC_DMTE1
, 0x660),
533 INTC_VECT(DMAC_DMTE2
, 0x680), INTC_VECT(DMAC_DMTE3
, 0x6a0),
534 INTC_VECT(DMAC_DMTE4
, 0x780), INTC_VECT(DMAC_DMTE5
, 0x7a0),
535 INTC_VECT(DMAC_DMTE6
, 0x7c0), INTC_VECT(DMAC_DMTE7
, 0x7e0),
536 INTC_VECT(DMAC_DMAE
, 0x6c0),
539 static struct intc_group groups_dma8
[] = {
540 INTC_GROUP(DMAC
, DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
,
541 DMAC_DMTE3
, DMAC_DMTE4
, DMAC_DMTE5
,
542 DMAC_DMTE6
, DMAC_DMTE7
, DMAC_DMAE
),
545 /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
547 static struct intc_vect vectors_tmu34
[] = {
548 INTC_VECT(TMU3
, 0xb00), INTC_VECT(TMU4
, 0xb80),
551 static struct intc_mask_reg mask_registers
[] = {
552 { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
553 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
554 0, 0, 0, 0, 0, 0, TMU4
, TMU3
,
555 PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
556 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
,
557 PCIC1_PCIDMA3
, PCIC0_PCISERR
} },
560 /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
562 static struct intc_vect vectors_irlm
[] = {
563 INTC_VECT(IRL0
, 0x240), INTC_VECT(IRL1
, 0x2a0),
564 INTC_VECT(IRL2
, 0x300), INTC_VECT(IRL3
, 0x360),
567 /* SH7751 and SH7751R both have PCI */
569 static struct intc_vect vectors_pci
[] = {
570 INTC_VECT(PCIC0_PCISERR
, 0xa00), INTC_VECT(PCIC1_PCIERR
, 0xae0),
571 INTC_VECT(PCIC1_PCIPWDWN
, 0xac0), INTC_VECT(PCIC1_PCIPWON
, 0xaa0),
572 INTC_VECT(PCIC1_PCIDMA0
, 0xa80), INTC_VECT(PCIC1_PCIDMA1
, 0xa60),
573 INTC_VECT(PCIC1_PCIDMA2
, 0xa40), INTC_VECT(PCIC1_PCIDMA3
, 0xa20),
576 static struct intc_group groups_pci
[] = {
577 INTC_GROUP(PCIC1
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
578 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
),
581 static struct intc_vect vectors_irl
[] = {
582 INTC_VECT(IRL_0
, 0x200),
583 INTC_VECT(IRL_1
, 0x220),
584 INTC_VECT(IRL_2
, 0x240),
585 INTC_VECT(IRL_3
, 0x260),
586 INTC_VECT(IRL_4
, 0x280),
587 INTC_VECT(IRL_5
, 0x2a0),
588 INTC_VECT(IRL_6
, 0x2c0),
589 INTC_VECT(IRL_7
, 0x2e0),
590 INTC_VECT(IRL_8
, 0x300),
591 INTC_VECT(IRL_9
, 0x320),
592 INTC_VECT(IRL_A
, 0x340),
593 INTC_VECT(IRL_B
, 0x360),
594 INTC_VECT(IRL_C
, 0x380),
595 INTC_VECT(IRL_D
, 0x3a0),
596 INTC_VECT(IRL_E
, 0x3c0),
599 static struct intc_group groups_irl
[] = {
600 INTC_GROUP(IRL
, IRL_0
, IRL_1
, IRL_2
, IRL_3
, IRL_4
, IRL_5
, IRL_6
,
601 IRL_7
, IRL_8
, IRL_9
, IRL_A
, IRL_B
, IRL_C
, IRL_D
, IRL_E
),
604 /**********************************************************************
605 Memory mapped cache and TLB
606 **********************************************************************/
608 #define MM_REGION_MASK 0x07000000
609 #define MM_ICACHE_ADDR (0)
610 #define MM_ICACHE_DATA (1)
611 #define MM_ITLB_ADDR (2)
612 #define MM_ITLB_DATA (3)
613 #define MM_OCACHE_ADDR (4)
614 #define MM_OCACHE_DATA (5)
615 #define MM_UTLB_ADDR (6)
616 #define MM_UTLB_DATA (7)
617 #define MM_REGION_TYPE(addr) ((addr & MM_REGION_MASK) >> 24)
619 static uint32_t invalid_read(void *opaque
, target_phys_addr_t addr
)
626 static uint32_t sh7750_mmct_readl(void *opaque
, target_phys_addr_t addr
)
630 switch (MM_REGION_TYPE(addr
)) {
656 static void invalid_write(void *opaque
, target_phys_addr_t addr
,
662 static void sh7750_mmct_writel(void *opaque
, target_phys_addr_t addr
,
665 SH7750State
*s
= opaque
;
667 switch (MM_REGION_TYPE(addr
)) {
673 cpu_sh4_write_mmaped_itlb_addr(s
->cpu
, addr
, mem_value
);
684 cpu_sh4_write_mmaped_utlb_addr(s
->cpu
, addr
, mem_value
);
696 static CPUReadMemoryFunc
* const sh7750_mmct_read
[] = {
702 static CPUWriteMemoryFunc
* const sh7750_mmct_write
[] = {
708 SH7750State
*sh7750_init(CPUSH4State
* cpu
)
711 int sh7750_io_memory
;
712 int sh7750_mm_cache_and_tlb
; /* memory mapped cache and tlb */
714 s
= qemu_mallocz(sizeof(SH7750State
));
716 s
->periph_freq
= 60000000; /* 60MHz */
717 sh7750_io_memory
= cpu_register_io_memory(sh7750_mem_read
,
719 DEVICE_NATIVE_ENDIAN
);
720 cpu_register_physical_memory_offset(0x1f000000, 0x1000,
721 sh7750_io_memory
, 0x1f000000);
722 cpu_register_physical_memory_offset(0xff000000, 0x1000,
723 sh7750_io_memory
, 0x1f000000);
724 cpu_register_physical_memory_offset(0x1f800000, 0x1000,
725 sh7750_io_memory
, 0x1f800000);
726 cpu_register_physical_memory_offset(0xff800000, 0x1000,
727 sh7750_io_memory
, 0x1f800000);
728 cpu_register_physical_memory_offset(0x1fc00000, 0x1000,
729 sh7750_io_memory
, 0x1fc00000);
730 cpu_register_physical_memory_offset(0xffc00000, 0x1000,
731 sh7750_io_memory
, 0x1fc00000);
733 sh7750_mm_cache_and_tlb
= cpu_register_io_memory(sh7750_mmct_read
,
734 sh7750_mmct_write
, s
,
735 DEVICE_NATIVE_ENDIAN
);
736 cpu_register_physical_memory(0xf0000000, 0x08000000,
737 sh7750_mm_cache_and_tlb
);
739 sh_intc_init(&s
->intc
, NR_SOURCES
,
740 _INTC_ARRAY(mask_registers
),
741 _INTC_ARRAY(prio_registers
));
743 sh_intc_register_sources(&s
->intc
,
744 _INTC_ARRAY(vectors
),
745 _INTC_ARRAY(groups
));
747 cpu
->intc_handle
= &s
->intc
;
749 sh_serial_init(0x1fe00000, 0, s
->periph_freq
, serial_hds
[0],
750 s
->intc
.irqs
[SCI1_ERI
],
751 s
->intc
.irqs
[SCI1_RXI
],
752 s
->intc
.irqs
[SCI1_TXI
],
753 s
->intc
.irqs
[SCI1_TEI
],
755 sh_serial_init(0x1fe80000, SH_SERIAL_FEAT_SCIF
,
756 s
->periph_freq
, serial_hds
[1],
757 s
->intc
.irqs
[SCIF_ERI
],
758 s
->intc
.irqs
[SCIF_RXI
],
759 s
->intc
.irqs
[SCIF_TXI
],
761 s
->intc
.irqs
[SCIF_BRI
]);
763 tmu012_init(0x1fd80000,
764 TMU012_FEAT_TOCR
| TMU012_FEAT_3CHAN
| TMU012_FEAT_EXTCLK
,
768 s
->intc
.irqs
[TMU2_TUNI
],
769 s
->intc
.irqs
[TMU2_TICPI
]);
771 if (cpu
->id
& (SH_CPU_SH7750
| SH_CPU_SH7750S
| SH_CPU_SH7751
)) {
772 sh_intc_register_sources(&s
->intc
,
773 _INTC_ARRAY(vectors_dma4
),
774 _INTC_ARRAY(groups_dma4
));
777 if (cpu
->id
& (SH_CPU_SH7750R
| SH_CPU_SH7751R
)) {
778 sh_intc_register_sources(&s
->intc
,
779 _INTC_ARRAY(vectors_dma8
),
780 _INTC_ARRAY(groups_dma8
));
783 if (cpu
->id
& (SH_CPU_SH7750R
| SH_CPU_SH7751
| SH_CPU_SH7751R
)) {
784 sh_intc_register_sources(&s
->intc
,
785 _INTC_ARRAY(vectors_tmu34
),
787 tmu012_init(0x1e100000, 0, s
->periph_freq
,
793 if (cpu
->id
& (SH_CPU_SH7751_ALL
)) {
794 sh_intc_register_sources(&s
->intc
,
795 _INTC_ARRAY(vectors_pci
),
796 _INTC_ARRAY(groups_pci
));
799 if (cpu
->id
& (SH_CPU_SH7750S
| SH_CPU_SH7750R
| SH_CPU_SH7751_ALL
)) {
800 sh_intc_register_sources(&s
->intc
,
801 _INTC_ARRAY(vectors_irlm
),
805 sh_intc_register_sources(&s
->intc
,
806 _INTC_ARRAY(vectors_irl
),
807 _INTC_ARRAY(groups_irl
));
811 qemu_irq
sh7750_irl(SH7750State
*s
)
813 sh_intc_toggle_source(sh_intc_source(&s
->intc
, IRL
), 1, 0); /* enable */
814 return qemu_allocate_irqs(sh_intc_set_irl
, sh_intc_source(&s
->intc
, IRL
),