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
30 #include "sh7750_regs.h"
31 #include "sh7750_regnames.h"
38 typedef struct SH7750State
{
41 /* Peripheral frequency in Hz */
43 /* SDRAM controller */
49 /* PCMCIA controller */
55 uint16_t portdira
; /* Cached */
56 uint16_t portpullupa
; /* Cached */
57 uint16_t portdirb
; /* Cached */
58 uint16_t portpullupb
; /* Cached */
61 uint16_t periph_pdtra
; /* Imposed by the peripherals */
62 uint16_t periph_portdira
; /* Direction seen from the peripherals */
63 uint16_t periph_pdtrb
; /* Imposed by the peripherals */
64 uint16_t periph_portdirb
; /* Direction seen from the peripherals */
65 sh7750_io_device
*devices
[NB_DEVICES
]; /* External peripherals */
70 struct intc_desc intc
;
73 static int inline has_bcr3_and_bcr4(SH7750State
* s
)
75 return (s
->cpu
->features
& SH_FEATURE_BCR3_AND_BCR4
);
77 /**********************************************************************
79 **********************************************************************/
81 int sh7750_register_io_device(SH7750State
* s
, sh7750_io_device
* device
)
85 for (i
= 0; i
< NB_DEVICES
; i
++) {
86 if (s
->devices
[i
] == NULL
) {
87 s
->devices
[i
] = device
;
94 static uint16_t portdir(uint32_t v
)
96 #define EVENPORTMASK(n) ((v & (1<<((n)<<1))) >> (n))
98 EVENPORTMASK(15) | EVENPORTMASK(14) | EVENPORTMASK(13) |
99 EVENPORTMASK(12) | EVENPORTMASK(11) | EVENPORTMASK(10) |
100 EVENPORTMASK(9) | EVENPORTMASK(8) | EVENPORTMASK(7) |
101 EVENPORTMASK(6) | EVENPORTMASK(5) | EVENPORTMASK(4) |
102 EVENPORTMASK(3) | EVENPORTMASK(2) | EVENPORTMASK(1) |
106 static uint16_t portpullup(uint32_t v
)
108 #define ODDPORTMASK(n) ((v & (1<<(((n)<<1)+1))) >> (n))
110 ODDPORTMASK(15) | ODDPORTMASK(14) | ODDPORTMASK(13) |
111 ODDPORTMASK(12) | ODDPORTMASK(11) | ODDPORTMASK(10) |
112 ODDPORTMASK(9) | ODDPORTMASK(8) | ODDPORTMASK(7) | ODDPORTMASK(6) |
113 ODDPORTMASK(5) | ODDPORTMASK(4) | ODDPORTMASK(3) | ODDPORTMASK(2) |
114 ODDPORTMASK(1) | ODDPORTMASK(0);
117 static uint16_t porta_lines(SH7750State
* s
)
119 return (s
->portdira
& s
->pdtra
) | /* CPU */
120 (s
->periph_portdira
& s
->periph_pdtra
) | /* Peripherals */
121 (~(s
->portdira
| s
->periph_portdira
) & s
->portpullupa
); /* Pullups */
124 static uint16_t portb_lines(SH7750State
* s
)
126 return (s
->portdirb
& s
->pdtrb
) | /* CPU */
127 (s
->periph_portdirb
& s
->periph_pdtrb
) | /* Peripherals */
128 (~(s
->portdirb
| s
->periph_portdirb
) & s
->portpullupb
); /* Pullups */
131 static void gen_port_interrupts(SH7750State
* s
)
133 /* XXXXX interrupts not generated */
136 static void porta_changed(SH7750State
* s
, uint16_t prev
)
138 uint16_t currenta
, changes
;
142 fprintf(stderr
, "porta changed from 0x%04x to 0x%04x\n",
143 prev
, porta_lines(s
));
144 fprintf(stderr
, "pdtra=0x%04x, pctra=0x%08x\n", s
->pdtra
, s
->pctra
);
146 currenta
= porta_lines(s
);
147 if (currenta
== prev
)
149 changes
= currenta
^ prev
;
151 for (i
= 0; i
< NB_DEVICES
; i
++) {
152 if (s
->devices
[i
] && (s
->devices
[i
]->portamask_trigger
& changes
)) {
153 r
|= s
->devices
[i
]->port_change_cb(currenta
, portb_lines(s
),
157 &s
->periph_portdirb
);
162 gen_port_interrupts(s
);
165 static void portb_changed(SH7750State
* s
, uint16_t prev
)
167 uint16_t currentb
, changes
;
170 currentb
= portb_lines(s
);
171 if (currentb
== prev
)
173 changes
= currentb
^ prev
;
175 for (i
= 0; i
< NB_DEVICES
; i
++) {
176 if (s
->devices
[i
] && (s
->devices
[i
]->portbmask_trigger
& changes
)) {
177 r
|= s
->devices
[i
]->port_change_cb(portb_lines(s
), currentb
,
181 &s
->periph_portdirb
);
186 gen_port_interrupts(s
);
189 /**********************************************************************
191 **********************************************************************/
193 static void error_access(const char *kind
, target_phys_addr_t addr
)
195 fprintf(stderr
, "%s to %s (0x" TARGET_FMT_plx
") not supported\n",
196 kind
, regname(addr
), addr
);
199 static void ignore_access(const char *kind
, target_phys_addr_t addr
)
201 fprintf(stderr
, "%s to %s (0x" TARGET_FMT_plx
") ignored\n",
202 kind
, regname(addr
), addr
);
205 static uint32_t sh7750_mem_readb(void *opaque
, target_phys_addr_t addr
)
209 error_access("byte read", addr
);
214 static uint32_t sh7750_mem_readw(void *opaque
, target_phys_addr_t addr
)
216 SH7750State
*s
= opaque
;
222 if(!has_bcr3_and_bcr4(s
))
223 error_access("word read", addr
);
225 case SH7750_FRQCR_A7
:
231 "Read access to refresh count register, incrementing\n");
233 case SH7750_PDTRA_A7
:
234 return porta_lines(s
);
235 case SH7750_PDTRB_A7
:
236 return portb_lines(s
);
237 case SH7750_RTCOR_A7
:
238 case SH7750_RTCNT_A7
:
239 case SH7750_RTCSR_A7
:
240 ignore_access("word read", addr
);
243 error_access("word read", addr
);
248 static uint32_t sh7750_mem_readl(void *opaque
, target_phys_addr_t addr
)
250 SH7750State
*s
= opaque
;
256 if(!has_bcr3_and_bcr4(s
))
257 error_access("long read", addr
);
263 ignore_access("long read", addr
);
265 case SH7750_MMUCR_A7
:
266 return s
->cpu
->mmucr
;
277 case SH7750_EXPEVT_A7
:
278 return s
->cpu
->expevt
;
279 case SH7750_INTEVT_A7
:
280 return s
->cpu
->intevt
;
283 case 0x1f000030: /* Processor version */
285 case 0x1f000040: /* Cache version */
287 case 0x1f000044: /* Processor revision */
290 error_access("long read", addr
);
295 #define is_in_sdrmx(a, x) (a >= SH7750_SDMR ## x ## _A7 \
296 && a <= (SH7750_SDMR ## x ## _A7 + SH7750_SDMR ## x ## _REGNB))
297 static void sh7750_mem_writeb(void *opaque
, target_phys_addr_t addr
,
301 if (is_in_sdrmx(addr
, 2) || is_in_sdrmx(addr
, 3)) {
302 ignore_access("byte write", addr
);
306 error_access("byte write", addr
);
310 static void sh7750_mem_writew(void *opaque
, target_phys_addr_t addr
,
313 SH7750State
*s
= opaque
;
317 /* SDRAM controller */
322 if(!has_bcr3_and_bcr4(s
))
323 error_access("word write", addr
);
329 case SH7750_RTCNT_A7
:
330 case SH7750_RTCOR_A7
:
331 case SH7750_RTCSR_A7
:
332 ignore_access("word write", addr
);
335 case SH7750_PDTRA_A7
:
336 temp
= porta_lines(s
);
337 s
->pdtra
= mem_value
;
338 porta_changed(s
, temp
);
340 case SH7750_PDTRB_A7
:
341 temp
= portb_lines(s
);
342 s
->pdtrb
= mem_value
;
343 portb_changed(s
, temp
);
346 fprintf(stderr
, "Write access to refresh count register\n");
349 case SH7750_GPIOIC_A7
:
350 s
->gpioic
= mem_value
;
351 if (mem_value
!= 0) {
352 fprintf(stderr
, "I/O interrupts not implemented\n");
357 error_access("word write", addr
);
362 static void sh7750_mem_writel(void *opaque
, target_phys_addr_t addr
,
365 SH7750State
*s
= opaque
;
369 /* SDRAM controller */
374 if(!has_bcr3_and_bcr4(s
))
375 error_access("long write", addr
);
382 ignore_access("long write", addr
);
385 case SH7750_PCTRA_A7
:
386 temp
= porta_lines(s
);
387 s
->pctra
= mem_value
;
388 s
->portdira
= portdir(mem_value
);
389 s
->portpullupa
= portpullup(mem_value
);
390 porta_changed(s
, temp
);
392 case SH7750_PCTRB_A7
:
393 temp
= portb_lines(s
);
394 s
->pctrb
= mem_value
;
395 s
->portdirb
= portdir(mem_value
);
396 s
->portpullupb
= portpullup(mem_value
);
397 portb_changed(s
, temp
);
399 case SH7750_MMUCR_A7
:
400 s
->cpu
->mmucr
= mem_value
;
403 /* If asid changes, clear all registered tlb entries. */
404 if ((s
->cpu
->pteh
& 0xff) != (mem_value
& 0xff))
405 tlb_flush(s
->cpu
, 1);
406 s
->cpu
->pteh
= mem_value
;
409 s
->cpu
->ptel
= mem_value
;
412 s
->cpu
->ptea
= mem_value
& 0x0000000f;
415 s
->cpu
->ttb
= mem_value
;
418 s
->cpu
->tea
= mem_value
;
421 s
->cpu
->tra
= mem_value
& 0x000007ff;
423 case SH7750_EXPEVT_A7
:
424 s
->cpu
->expevt
= mem_value
& 0x000007ff;
426 case SH7750_INTEVT_A7
:
427 s
->cpu
->intevt
= mem_value
& 0x000007ff;
433 error_access("long write", addr
);
438 static CPUReadMemoryFunc
*sh7750_mem_read
[] = {
444 static CPUWriteMemoryFunc
*sh7750_mem_write
[] = {
450 /* sh775x interrupt controller tables for sh_intc.c
451 * stolen from linux/arch/sh/kernel/cpu/sh4/setup-sh7750.c
457 /* interrupt sources */
458 IRL_0
, IRL_1
, IRL_2
, IRL_3
, IRL_4
, IRL_5
, IRL_6
, IRL_7
,
459 IRL_8
, IRL_9
, IRL_A
, IRL_B
, IRL_C
, IRL_D
, IRL_E
,
460 IRL0
, IRL1
, IRL2
, IRL3
,
462 DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
, DMAC_DMTE3
,
463 DMAC_DMTE4
, DMAC_DMTE5
, DMAC_DMTE6
, DMAC_DMTE7
,
465 PCIC0_PCISERR
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
466 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
,
467 TMU3
, TMU4
, TMU0
, TMU1
, TMU2_TUNI
, TMU2_TICPI
,
468 RTC_ATI
, RTC_PRI
, RTC_CUI
,
469 SCI1_ERI
, SCI1_RXI
, SCI1_TXI
, SCI1_TEI
,
470 SCIF_ERI
, SCIF_RXI
, SCIF_BRI
, SCIF_TXI
,
474 /* interrupt groups */
475 DMAC
, PCIC1
, TMU2
, RTC
, SCI1
, SCIF
, REF
,
482 static struct intc_vect vectors
[] = {
483 INTC_VECT(HUDI
, 0x600), INTC_VECT(GPIOI
, 0x620),
484 INTC_VECT(TMU0
, 0x400), INTC_VECT(TMU1
, 0x420),
485 INTC_VECT(TMU2_TUNI
, 0x440), INTC_VECT(TMU2_TICPI
, 0x460),
486 INTC_VECT(RTC_ATI
, 0x480), INTC_VECT(RTC_PRI
, 0x4a0),
487 INTC_VECT(RTC_CUI
, 0x4c0),
488 INTC_VECT(SCI1_ERI
, 0x4e0), INTC_VECT(SCI1_RXI
, 0x500),
489 INTC_VECT(SCI1_TXI
, 0x520), INTC_VECT(SCI1_TEI
, 0x540),
490 INTC_VECT(SCIF_ERI
, 0x700), INTC_VECT(SCIF_RXI
, 0x720),
491 INTC_VECT(SCIF_BRI
, 0x740), INTC_VECT(SCIF_TXI
, 0x760),
492 INTC_VECT(WDT
, 0x560),
493 INTC_VECT(REF_RCMI
, 0x580), INTC_VECT(REF_ROVI
, 0x5a0),
496 static struct intc_group groups
[] = {
497 INTC_GROUP(TMU2
, TMU2_TUNI
, TMU2_TICPI
),
498 INTC_GROUP(RTC
, RTC_ATI
, RTC_PRI
, RTC_CUI
),
499 INTC_GROUP(SCI1
, SCI1_ERI
, SCI1_RXI
, SCI1_TXI
, SCI1_TEI
),
500 INTC_GROUP(SCIF
, SCIF_ERI
, SCIF_RXI
, SCIF_BRI
, SCIF_TXI
),
501 INTC_GROUP(REF
, REF_RCMI
, REF_ROVI
),
504 static struct intc_prio_reg prio_registers
[] = {
505 { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0
, TMU1
, TMU2
, RTC
} },
506 { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT
, REF
, SCI1
, 0 } },
507 { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI
, DMAC
, SCIF
, HUDI
} },
508 { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0
, IRL1
, IRL2
, IRL3
} },
509 { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
511 PCIC1
, PCIC0_PCISERR
} },
514 /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
516 static struct intc_vect vectors_dma4
[] = {
517 INTC_VECT(DMAC_DMTE0
, 0x640), INTC_VECT(DMAC_DMTE1
, 0x660),
518 INTC_VECT(DMAC_DMTE2
, 0x680), INTC_VECT(DMAC_DMTE3
, 0x6a0),
519 INTC_VECT(DMAC_DMAE
, 0x6c0),
522 static struct intc_group groups_dma4
[] = {
523 INTC_GROUP(DMAC
, DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
,
524 DMAC_DMTE3
, DMAC_DMAE
),
527 /* SH7750R and SH7751R both have 8-channel DMA controllers */
529 static struct intc_vect vectors_dma8
[] = {
530 INTC_VECT(DMAC_DMTE0
, 0x640), INTC_VECT(DMAC_DMTE1
, 0x660),
531 INTC_VECT(DMAC_DMTE2
, 0x680), INTC_VECT(DMAC_DMTE3
, 0x6a0),
532 INTC_VECT(DMAC_DMTE4
, 0x780), INTC_VECT(DMAC_DMTE5
, 0x7a0),
533 INTC_VECT(DMAC_DMTE6
, 0x7c0), INTC_VECT(DMAC_DMTE7
, 0x7e0),
534 INTC_VECT(DMAC_DMAE
, 0x6c0),
537 static struct intc_group groups_dma8
[] = {
538 INTC_GROUP(DMAC
, DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
,
539 DMAC_DMTE3
, DMAC_DMTE4
, DMAC_DMTE5
,
540 DMAC_DMTE6
, DMAC_DMTE7
, DMAC_DMAE
),
543 /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
545 static struct intc_vect vectors_tmu34
[] = {
546 INTC_VECT(TMU3
, 0xb00), INTC_VECT(TMU4
, 0xb80),
549 static struct intc_mask_reg mask_registers
[] = {
550 { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
551 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
552 0, 0, 0, 0, 0, 0, TMU4
, TMU3
,
553 PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
554 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
,
555 PCIC1_PCIDMA3
, PCIC0_PCISERR
} },
558 /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
560 static struct intc_vect vectors_irlm
[] = {
561 INTC_VECT(IRL0
, 0x240), INTC_VECT(IRL1
, 0x2a0),
562 INTC_VECT(IRL2
, 0x300), INTC_VECT(IRL3
, 0x360),
565 /* SH7751 and SH7751R both have PCI */
567 static struct intc_vect vectors_pci
[] = {
568 INTC_VECT(PCIC0_PCISERR
, 0xa00), INTC_VECT(PCIC1_PCIERR
, 0xae0),
569 INTC_VECT(PCIC1_PCIPWDWN
, 0xac0), INTC_VECT(PCIC1_PCIPWON
, 0xaa0),
570 INTC_VECT(PCIC1_PCIDMA0
, 0xa80), INTC_VECT(PCIC1_PCIDMA1
, 0xa60),
571 INTC_VECT(PCIC1_PCIDMA2
, 0xa40), INTC_VECT(PCIC1_PCIDMA3
, 0xa20),
574 static struct intc_group groups_pci
[] = {
575 INTC_GROUP(PCIC1
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
576 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
),
579 static struct intc_vect vectors_irl
[] = {
580 INTC_VECT(IRL_0
, 0x200),
581 INTC_VECT(IRL_1
, 0x220),
582 INTC_VECT(IRL_2
, 0x240),
583 INTC_VECT(IRL_3
, 0x260),
584 INTC_VECT(IRL_4
, 0x280),
585 INTC_VECT(IRL_5
, 0x2a0),
586 INTC_VECT(IRL_6
, 0x2c0),
587 INTC_VECT(IRL_7
, 0x2e0),
588 INTC_VECT(IRL_8
, 0x300),
589 INTC_VECT(IRL_9
, 0x320),
590 INTC_VECT(IRL_A
, 0x340),
591 INTC_VECT(IRL_B
, 0x360),
592 INTC_VECT(IRL_C
, 0x380),
593 INTC_VECT(IRL_D
, 0x3a0),
594 INTC_VECT(IRL_E
, 0x3c0),
597 static struct intc_group groups_irl
[] = {
598 INTC_GROUP(IRL
, IRL_0
, IRL_1
, IRL_2
, IRL_3
, IRL_4
, IRL_5
, IRL_6
,
599 IRL_7
, IRL_8
, IRL_9
, IRL_A
, IRL_B
, IRL_C
, IRL_D
, IRL_E
),
602 /**********************************************************************
603 Memory mapped cache and TLB
604 **********************************************************************/
606 #define MM_REGION_MASK 0x07000000
607 #define MM_ICACHE_ADDR (0)
608 #define MM_ICACHE_DATA (1)
609 #define MM_ITLB_ADDR (2)
610 #define MM_ITLB_DATA (3)
611 #define MM_OCACHE_ADDR (4)
612 #define MM_OCACHE_DATA (5)
613 #define MM_UTLB_ADDR (6)
614 #define MM_UTLB_DATA (7)
615 #define MM_REGION_TYPE(addr) ((addr & MM_REGION_MASK) >> 24)
617 static uint32_t invalid_read(void *opaque
, target_phys_addr_t addr
)
624 static uint32_t sh7750_mmct_readl(void *opaque
, target_phys_addr_t addr
)
628 switch (MM_REGION_TYPE(addr
)) {
654 static void invalid_write(void *opaque
, target_phys_addr_t addr
,
660 static void sh7750_mmct_writel(void *opaque
, target_phys_addr_t addr
,
663 SH7750State
*s
= opaque
;
665 switch (MM_REGION_TYPE(addr
)) {
680 cpu_sh4_write_mmaped_utlb_addr(s
->cpu
, addr
, mem_value
);
692 static CPUReadMemoryFunc
*sh7750_mmct_read
[] = {
698 static CPUWriteMemoryFunc
*sh7750_mmct_write
[] = {
704 SH7750State
*sh7750_init(CPUSH4State
* cpu
)
707 int sh7750_io_memory
;
708 int sh7750_mm_cache_and_tlb
; /* memory mapped cache and tlb */
710 s
= qemu_mallocz(sizeof(SH7750State
));
712 s
->periph_freq
= 60000000; /* 60MHz */
713 sh7750_io_memory
= cpu_register_io_memory(0,
715 sh7750_mem_write
, s
);
716 cpu_register_physical_memory_offset(0x1f000000, 0x1000,
717 sh7750_io_memory
, 0x1f000000);
718 cpu_register_physical_memory_offset(0xff000000, 0x1000,
719 sh7750_io_memory
, 0x1f000000);
720 cpu_register_physical_memory_offset(0x1f800000, 0x1000,
721 sh7750_io_memory
, 0x1f800000);
722 cpu_register_physical_memory_offset(0xff800000, 0x1000,
723 sh7750_io_memory
, 0x1f800000);
724 cpu_register_physical_memory_offset(0x1fc00000, 0x1000,
725 sh7750_io_memory
, 0x1fc00000);
726 cpu_register_physical_memory_offset(0xffc00000, 0x1000,
727 sh7750_io_memory
, 0x1fc00000);
729 sh7750_mm_cache_and_tlb
= cpu_register_io_memory(0,
731 sh7750_mmct_write
, s
);
732 cpu_register_physical_memory(0xf0000000, 0x08000000,
733 sh7750_mm_cache_and_tlb
);
735 sh_intc_init(&s
->intc
, NR_SOURCES
,
736 _INTC_ARRAY(mask_registers
),
737 _INTC_ARRAY(prio_registers
));
739 sh_intc_register_sources(&s
->intc
,
740 _INTC_ARRAY(vectors
),
741 _INTC_ARRAY(groups
));
743 cpu
->intc_handle
= &s
->intc
;
745 sh_serial_init(0x1fe00000, 0, s
->periph_freq
, serial_hds
[0],
746 s
->intc
.irqs
[SCI1_ERI
],
747 s
->intc
.irqs
[SCI1_RXI
],
748 s
->intc
.irqs
[SCI1_TXI
],
749 s
->intc
.irqs
[SCI1_TEI
],
751 sh_serial_init(0x1fe80000, SH_SERIAL_FEAT_SCIF
,
752 s
->periph_freq
, serial_hds
[1],
753 s
->intc
.irqs
[SCIF_ERI
],
754 s
->intc
.irqs
[SCIF_RXI
],
755 s
->intc
.irqs
[SCIF_TXI
],
757 s
->intc
.irqs
[SCIF_BRI
]);
759 tmu012_init(0x1fd80000,
760 TMU012_FEAT_TOCR
| TMU012_FEAT_3CHAN
| TMU012_FEAT_EXTCLK
,
764 s
->intc
.irqs
[TMU2_TUNI
],
765 s
->intc
.irqs
[TMU2_TICPI
]);
767 if (cpu
->id
& (SH_CPU_SH7750
| SH_CPU_SH7750S
| SH_CPU_SH7751
)) {
768 sh_intc_register_sources(&s
->intc
,
769 _INTC_ARRAY(vectors_dma4
),
770 _INTC_ARRAY(groups_dma4
));
773 if (cpu
->id
& (SH_CPU_SH7750R
| SH_CPU_SH7751R
)) {
774 sh_intc_register_sources(&s
->intc
,
775 _INTC_ARRAY(vectors_dma8
),
776 _INTC_ARRAY(groups_dma8
));
779 if (cpu
->id
& (SH_CPU_SH7750R
| SH_CPU_SH7751
| SH_CPU_SH7751R
)) {
780 sh_intc_register_sources(&s
->intc
,
781 _INTC_ARRAY(vectors_tmu34
),
783 tmu012_init(0x1e100000, 0, s
->periph_freq
,
789 if (cpu
->id
& (SH_CPU_SH7751_ALL
)) {
790 sh_intc_register_sources(&s
->intc
,
791 _INTC_ARRAY(vectors_pci
),
792 _INTC_ARRAY(groups_pci
));
795 if (cpu
->id
& (SH_CPU_SH7750S
| SH_CPU_SH7750R
| SH_CPU_SH7751_ALL
)) {
796 sh_intc_register_sources(&s
->intc
,
797 _INTC_ARRAY(vectors_irlm
),
801 sh_intc_register_sources(&s
->intc
,
802 _INTC_ARRAY(vectors_irl
),
803 _INTC_ARRAY(groups_irl
));
807 qemu_irq
sh7750_irl(SH7750State
*s
)
809 sh_intc_toggle_source(sh_intc_source(&s
->intc
, IRL
), 1, 0); /* enable */
810 return qemu_allocate_irqs(sh_intc_set_irl
, sh_intc_source(&s
->intc
, IRL
),