1 /* Blackfin System Interrupt Controller (SIC) model.
3 Copyright (C) 2010-2024 Free Software Foundation, Inc.
4 Contributed by Analog Devices, Inc.
6 This file is part of simulators.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* This must come before any other includes. */
26 #include "dv-bfin_sic.h"
27 #include "dv-bfin_cec.h"
31 /* We assume first element is the base. */
34 /* Order after here is important -- matches hardware MMR layout. */
35 bu16
BFIN_MMR_16(swrst
);
36 bu16
BFIN_MMR_16(syscr
);
37 bu16
BFIN_MMR_16(rvect
); /* XXX: BF59x has a 32bit AUX_REVID here. */
41 bu32 iar0
, iar1
, iar2
, iar3
;
45 bu32 iar4
, iar5
, iar6
, iar7
;
50 bu32 iar0
, iar1
, iar2
, iar3
;
54 bu32 imask0
, imask1
, imask2
;
55 bu32 isr0
, isr1
, isr2
;
56 bu32 iwr0
, iwr1
, iwr2
;
57 bu32 iar0
, iar1
, iar2
, iar3
;
58 bu32 iar4
, iar5
, iar6
, iar7
;
59 bu32 iar8
, iar9
, iar10
, iar11
;
63 bu32 iar0
, iar1
, iar2
, iar3
;
64 bu32 iar4
, iar5
, iar6
, iar7
;
70 #define mmr_base() offsetof(struct bfin_sic, swrst)
71 #define mmr_offset(mmr) (offsetof(struct bfin_sic, mmr) - mmr_base())
72 #define mmr_idx(mmr) (mmr_offset (mmr) / 4)
74 static const char * const bf52x_mmr_names
[] =
76 "SWRST", "SYSCR", "SIC_RVECT", "SIC_IMASK0", "SIC_IAR0", "SIC_IAR1",
77 "SIC_IAR2", "SIC_IAR3", "SIC_ISR0", "SIC_IWR0",
78 [mmr_idx (bf52x
.imask1
)] = "SIC_IMASK1", "SIC_IAR4", "SIC_IAR5",
79 "SIC_IAR6", "SIC_IAR7", "SIC_ISR1", "SIC_IWR1",
81 static const char * const bf537_mmr_names
[] =
83 "SWRST", "SYSCR", "SIC_RVECT", "SIC_IMASK", "SIC_IAR0", "SIC_IAR1",
84 "SIC_IAR2", "SIC_IAR3", "SIC_ISR", "SIC_IWR",
86 static const char * const bf54x_mmr_names
[] =
88 "SWRST", "SYSCR", "SIC_RVECT", "SIC_IMASK0", "SIC_IMASK1", "SIC_IMASK2",
89 "SIC_ISR0", "SIC_ISR1", "SIC_ISR2", "SIC_IWR0", "SIC_IWR1", "SIC_IWR2",
90 "SIC_IAR0", "SIC_IAR1", "SIC_IAR2", "SIC_IAR3",
91 "SIC_IAR4", "SIC_IAR5", "SIC_IAR6", "SIC_IAR7",
92 "SIC_IAR8", "SIC_IAR9", "SIC_IAR10", "SIC_IAR11",
94 static const char * const bf561_mmr_names
[] =
96 "SWRST", "SYSCR", "SIC_RVECT", "SIC_IMASK0", "SIC_IMASK1",
97 "SIC_IAR0", "SIC_IAR1", "SIC_IAR2", "SIC_IAR3",
98 "SIC_IAR4", "SIC_IAR5", "SIC_IAR6", "SIC_IAR7",
99 "SIC_ISR0", "SIC_ISR1", "SIC_IWR0", "SIC_IWR1",
101 static const char * const *mmr_names
;
102 #define mmr_name(off) (mmr_names[(off) / 4] ? : "<INV>")
105 bfin_sic_forward_interrupts (struct hw
*me
, bu32
*isr
, bu32
*imask
, bu32
*iar
)
110 /* Process pending and unmasked interrupts. */
111 ipend
= *isr
& *imask
;
113 /* Usually none are pending unmasked, so avoid bit twiddling. */
117 for (my_port
= 0; my_port
< 32; ++my_port
)
119 bu32 iar_idx
, iar_off
, iar_val
;
120 bu32 bit
= (1 << my_port
);
122 /* This bit isn't pending, so check next one. */
126 /* The IAR registers map the System input to the Core output.
127 Every 4 bits in the IAR are used to map to IVG{7..15}. */
128 iar_idx
= my_port
/ 8;
129 iar_off
= (my_port
% 8) * 4;
130 iar_val
= (iar
[iar_idx
] & (0xf << iar_off
)) >> iar_off
;
131 HW_TRACE ((me
, "forwarding int %i to CEC", IVG7
+ iar_val
));
132 hw_port_event (me
, IVG7
+ iar_val
, 1);
137 bfin_sic_52x_forward_interrupts (struct hw
*me
, struct bfin_sic
*sic
)
139 bfin_sic_forward_interrupts (me
, &sic
->bf52x
.isr0
, &sic
->bf52x
.imask0
, &sic
->bf52x
.iar0
);
140 bfin_sic_forward_interrupts (me
, &sic
->bf52x
.isr1
, &sic
->bf52x
.imask1
, &sic
->bf52x
.iar4
);
144 bfin_sic_52x_io_write_buffer (struct hw
*me
, const void *source
, int space
,
145 address_word addr
, unsigned nr_bytes
)
147 struct bfin_sic
*sic
= hw_data (me
);
153 /* Invalid access mode is higher priority than missing register. */
154 if (!dv_bfin_mmr_require_16_32 (me
, addr
, nr_bytes
, true))
158 value
= dv_load_4 (source
);
160 value
= dv_load_2 (source
);
162 mmr_off
= addr
- sic
->base
;
163 valuep
= (void *)((uintptr_t)sic
+ mmr_base() + mmr_off
);
168 /* XXX: Discard all SIC writes for now. */
171 case mmr_offset(swrst
):
172 /* XXX: This should trigger a software reset ... */
174 case mmr_offset(syscr
):
175 /* XXX: what to do ... */
177 case mmr_offset(bf52x
.imask0
):
178 case mmr_offset(bf52x
.imask1
):
179 bfin_sic_52x_forward_interrupts (me
, sic
);
182 case mmr_offset(bf52x
.iar0
) ... mmr_offset(bf52x
.iar3
):
183 case mmr_offset(bf52x
.iar4
) ... mmr_offset(bf52x
.iar7
):
184 case mmr_offset(bf52x
.iwr0
):
185 case mmr_offset(bf52x
.iwr1
):
188 case mmr_offset(bf52x
.isr0
):
189 case mmr_offset(bf52x
.isr1
):
190 /* ISR is read-only. */
193 /* XXX: Should discard other writes. */
201 bfin_sic_52x_io_read_buffer (struct hw
*me
, void *dest
, int space
,
202 address_word addr
, unsigned nr_bytes
)
204 struct bfin_sic
*sic
= hw_data (me
);
210 /* Invalid access mode is higher priority than missing register. */
211 if (!dv_bfin_mmr_require_16_32 (me
, addr
, nr_bytes
, false))
214 mmr_off
= addr
- sic
->base
;
215 valuep
= (void *)((uintptr_t)sic
+ mmr_base() + mmr_off
);
223 case mmr_offset(swrst
):
224 case mmr_offset(syscr
):
225 case mmr_offset(rvect
):
226 dv_store_2 (dest
, *value16p
);
228 case mmr_offset(bf52x
.imask0
):
229 case mmr_offset(bf52x
.imask1
):
230 case mmr_offset(bf52x
.iar0
) ... mmr_offset(bf52x
.iar3
):
231 case mmr_offset(bf52x
.iar4
) ... mmr_offset(bf52x
.iar7
):
232 case mmr_offset(bf52x
.iwr0
):
233 case mmr_offset(bf52x
.iwr1
):
234 case mmr_offset(bf52x
.isr0
):
235 case mmr_offset(bf52x
.isr1
):
236 dv_store_4 (dest
, *value32p
);
240 dv_store_2 (dest
, 0);
242 dv_store_4 (dest
, 0);
250 bfin_sic_537_forward_interrupts (struct hw
*me
, struct bfin_sic
*sic
)
252 bfin_sic_forward_interrupts (me
, &sic
->bf537
.isr
, &sic
->bf537
.imask
, &sic
->bf537
.iar0
);
256 bfin_sic_537_io_write_buffer (struct hw
*me
, const void *source
, int space
,
257 address_word addr
, unsigned nr_bytes
)
259 struct bfin_sic
*sic
= hw_data (me
);
265 /* Invalid access mode is higher priority than missing register. */
266 if (!dv_bfin_mmr_require_16_32 (me
, addr
, nr_bytes
, true))
270 value
= dv_load_4 (source
);
272 value
= dv_load_2 (source
);
274 mmr_off
= addr
- sic
->base
;
275 valuep
= (void *)((uintptr_t)sic
+ mmr_base() + mmr_off
);
280 /* XXX: Discard all SIC writes for now. */
283 case mmr_offset(swrst
):
284 /* XXX: This should trigger a software reset ... */
286 case mmr_offset(syscr
):
287 /* XXX: what to do ... */
289 case mmr_offset(bf537
.imask
):
290 bfin_sic_537_forward_interrupts (me
, sic
);
293 case mmr_offset(bf537
.iar0
):
294 case mmr_offset(bf537
.iar1
):
295 case mmr_offset(bf537
.iar2
):
296 case mmr_offset(bf537
.iar3
):
297 case mmr_offset(bf537
.iwr
):
300 case mmr_offset(bf537
.isr
):
301 /* ISR is read-only. */
304 /* XXX: Should discard other writes. */
312 bfin_sic_537_io_read_buffer (struct hw
*me
, void *dest
, int space
,
313 address_word addr
, unsigned nr_bytes
)
315 struct bfin_sic
*sic
= hw_data (me
);
321 /* Invalid access mode is higher priority than missing register. */
322 if (!dv_bfin_mmr_require_16_32 (me
, addr
, nr_bytes
, false))
325 mmr_off
= addr
- sic
->base
;
326 valuep
= (void *)((uintptr_t)sic
+ mmr_base() + mmr_off
);
334 case mmr_offset(swrst
):
335 case mmr_offset(syscr
):
336 case mmr_offset(rvect
):
337 dv_store_2 (dest
, *value16p
);
339 case mmr_offset(bf537
.imask
):
340 case mmr_offset(bf537
.iar0
):
341 case mmr_offset(bf537
.iar1
):
342 case mmr_offset(bf537
.iar2
):
343 case mmr_offset(bf537
.iar3
):
344 case mmr_offset(bf537
.isr
):
345 case mmr_offset(bf537
.iwr
):
346 dv_store_4 (dest
, *value32p
);
350 dv_store_2 (dest
, 0);
352 dv_store_4 (dest
, 0);
360 bfin_sic_54x_forward_interrupts (struct hw
*me
, struct bfin_sic
*sic
)
362 bfin_sic_forward_interrupts (me
, &sic
->bf54x
.isr0
, &sic
->bf54x
.imask0
, &sic
->bf54x
.iar0
);
363 bfin_sic_forward_interrupts (me
, &sic
->bf54x
.isr1
, &sic
->bf54x
.imask1
, &sic
->bf54x
.iar4
);
364 bfin_sic_forward_interrupts (me
, &sic
->bf54x
.isr2
, &sic
->bf54x
.imask2
, &sic
->bf54x
.iar8
);
368 bfin_sic_54x_io_write_buffer (struct hw
*me
, const void *source
, int space
,
369 address_word addr
, unsigned nr_bytes
)
371 struct bfin_sic
*sic
= hw_data (me
);
377 /* Invalid access mode is higher priority than missing register. */
378 if (!dv_bfin_mmr_require_16_32 (me
, addr
, nr_bytes
, true))
382 value
= dv_load_4 (source
);
384 value
= dv_load_2 (source
);
386 mmr_off
= addr
- sic
->base
;
387 valuep
= (void *)((uintptr_t)sic
+ mmr_base() + mmr_off
);
392 /* XXX: Discard all SIC writes for now. */
395 case mmr_offset(swrst
):
396 /* XXX: This should trigger a software reset ... */
398 case mmr_offset(syscr
):
399 /* XXX: what to do ... */
401 case mmr_offset(bf54x
.imask0
) ... mmr_offset(bf54x
.imask2
):
402 bfin_sic_54x_forward_interrupts (me
, sic
);
405 case mmr_offset(bf54x
.iar0
) ... mmr_offset(bf54x
.iar11
):
406 case mmr_offset(bf54x
.iwr0
) ... mmr_offset(bf54x
.iwr2
):
409 case mmr_offset(bf54x
.isr0
) ... mmr_offset(bf54x
.isr2
):
410 /* ISR is read-only. */
413 /* XXX: Should discard other writes. */
421 bfin_sic_54x_io_read_buffer (struct hw
*me
, void *dest
, int space
,
422 address_word addr
, unsigned nr_bytes
)
424 struct bfin_sic
*sic
= hw_data (me
);
430 /* Invalid access mode is higher priority than missing register. */
431 if (!dv_bfin_mmr_require_16_32 (me
, addr
, nr_bytes
, false))
434 mmr_off
= addr
- sic
->base
;
435 valuep
= (void *)((uintptr_t)sic
+ mmr_base() + mmr_off
);
443 case mmr_offset(swrst
):
444 case mmr_offset(syscr
):
445 case mmr_offset(rvect
):
446 dv_store_2 (dest
, *value16p
);
448 case mmr_offset(bf54x
.imask0
) ... mmr_offset(bf54x
.imask2
):
449 case mmr_offset(bf54x
.iar0
) ... mmr_offset(bf54x
.iar11
):
450 case mmr_offset(bf54x
.iwr0
) ... mmr_offset(bf54x
.iwr2
):
451 case mmr_offset(bf54x
.isr0
) ... mmr_offset(bf54x
.isr2
):
452 dv_store_4 (dest
, *value32p
);
456 dv_store_2 (dest
, 0);
458 dv_store_4 (dest
, 0);
466 bfin_sic_561_forward_interrupts (struct hw
*me
, struct bfin_sic
*sic
)
468 bfin_sic_forward_interrupts (me
, &sic
->bf561
.isr0
, &sic
->bf561
.imask0
, &sic
->bf561
.iar0
);
469 bfin_sic_forward_interrupts (me
, &sic
->bf561
.isr1
, &sic
->bf561
.imask1
, &sic
->bf561
.iar4
);
473 bfin_sic_561_io_write_buffer (struct hw
*me
, const void *source
, int space
,
474 address_word addr
, unsigned nr_bytes
)
476 struct bfin_sic
*sic
= hw_data (me
);
482 /* Invalid access mode is higher priority than missing register. */
483 if (!dv_bfin_mmr_require_16_32 (me
, addr
, nr_bytes
, true))
487 value
= dv_load_4 (source
);
489 value
= dv_load_2 (source
);
491 mmr_off
= addr
- sic
->base
;
492 valuep
= (void *)((uintptr_t)sic
+ mmr_base() + mmr_off
);
497 /* XXX: Discard all SIC writes for now. */
500 case mmr_offset(swrst
):
501 /* XXX: This should trigger a software reset ... */
503 case mmr_offset(syscr
):
504 /* XXX: what to do ... */
506 case mmr_offset(bf561
.imask0
):
507 case mmr_offset(bf561
.imask1
):
508 bfin_sic_561_forward_interrupts (me
, sic
);
511 case mmr_offset(bf561
.iar0
) ... mmr_offset(bf561
.iar3
):
512 case mmr_offset(bf561
.iar4
) ... mmr_offset(bf561
.iar7
):
513 case mmr_offset(bf561
.iwr0
):
514 case mmr_offset(bf561
.iwr1
):
517 case mmr_offset(bf561
.isr0
):
518 case mmr_offset(bf561
.isr1
):
519 /* ISR is read-only. */
522 /* XXX: Should discard other writes. */
530 bfin_sic_561_io_read_buffer (struct hw
*me
, void *dest
, int space
,
531 address_word addr
, unsigned nr_bytes
)
533 struct bfin_sic
*sic
= hw_data (me
);
539 /* Invalid access mode is higher priority than missing register. */
540 if (!dv_bfin_mmr_require_16_32 (me
, addr
, nr_bytes
, false))
543 mmr_off
= addr
- sic
->base
;
544 valuep
= (void *)((uintptr_t)sic
+ mmr_base() + mmr_off
);
552 case mmr_offset(swrst
):
553 case mmr_offset(syscr
):
554 case mmr_offset(rvect
):
555 dv_store_2 (dest
, *value16p
);
557 case mmr_offset(bf561
.imask0
):
558 case mmr_offset(bf561
.imask1
):
559 case mmr_offset(bf561
.iar0
) ... mmr_offset(bf561
.iar3
):
560 case mmr_offset(bf561
.iar4
) ... mmr_offset(bf561
.iar7
):
561 case mmr_offset(bf561
.iwr0
):
562 case mmr_offset(bf561
.iwr1
):
563 case mmr_offset(bf561
.isr0
):
564 case mmr_offset(bf561
.isr1
):
565 dv_store_4 (dest
, *value32p
);
569 dv_store_2 (dest
, 0);
571 dv_store_4 (dest
, 0);
578 /* Give each SIC its own base to make it easier to extract the pin at
579 runtime. The pin is used as its bit position in the SIC MMRs. */
580 #define ENC(sic, pin) (((sic) << 8) + (pin))
581 #define DEC_PIN(pin) ((pin) % 0x100)
582 #define DEC_SIC(pin) ((pin) >> 8)
584 /* It would be nice to declare just one set of input_ports, and then
585 have the device tree instantiate multiple SICs, but the MMR layout
586 on the BF54x/BF561 makes this pretty hard to pull off since their
587 regs are interwoven in the address space. */
589 #define BFIN_SIC_TO_CEC_PORTS \
590 { "ivg7", IVG7, 0, output_port, }, \
591 { "ivg8", IVG8, 0, output_port, }, \
592 { "ivg9", IVG9, 0, output_port, }, \
593 { "ivg10", IVG10, 0, output_port, }, \
594 { "ivg11", IVG11, 0, output_port, }, \
595 { "ivg12", IVG12, 0, output_port, }, \
596 { "ivg13", IVG13, 0, output_port, }, \
597 { "ivg14", IVG14, 0, output_port, }, \
598 { "ivg15", IVG15, 0, output_port, },
600 #define SIC_PORTS(n) \
601 { "int0@"#n, ENC(n, 0), 0, input_port, }, \
602 { "int1@"#n, ENC(n, 1), 0, input_port, }, \
603 { "int2@"#n, ENC(n, 2), 0, input_port, }, \
604 { "int3@"#n, ENC(n, 3), 0, input_port, }, \
605 { "int4@"#n, ENC(n, 4), 0, input_port, }, \
606 { "int5@"#n, ENC(n, 5), 0, input_port, }, \
607 { "int6@"#n, ENC(n, 6), 0, input_port, }, \
608 { "int7@"#n, ENC(n, 7), 0, input_port, }, \
609 { "int8@"#n, ENC(n, 8), 0, input_port, }, \
610 { "int9@"#n, ENC(n, 9), 0, input_port, }, \
611 { "int10@"#n, ENC(n, 10), 0, input_port, }, \
612 { "int11@"#n, ENC(n, 11), 0, input_port, }, \
613 { "int12@"#n, ENC(n, 12), 0, input_port, }, \
614 { "int13@"#n, ENC(n, 13), 0, input_port, }, \
615 { "int14@"#n, ENC(n, 14), 0, input_port, }, \
616 { "int15@"#n, ENC(n, 15), 0, input_port, }, \
617 { "int16@"#n, ENC(n, 16), 0, input_port, }, \
618 { "int17@"#n, ENC(n, 17), 0, input_port, }, \
619 { "int18@"#n, ENC(n, 18), 0, input_port, }, \
620 { "int19@"#n, ENC(n, 19), 0, input_port, }, \
621 { "int20@"#n, ENC(n, 20), 0, input_port, }, \
622 { "int21@"#n, ENC(n, 21), 0, input_port, }, \
623 { "int22@"#n, ENC(n, 22), 0, input_port, }, \
624 { "int23@"#n, ENC(n, 23), 0, input_port, }, \
625 { "int24@"#n, ENC(n, 24), 0, input_port, }, \
626 { "int25@"#n, ENC(n, 25), 0, input_port, }, \
627 { "int26@"#n, ENC(n, 26), 0, input_port, }, \
628 { "int27@"#n, ENC(n, 27), 0, input_port, }, \
629 { "int28@"#n, ENC(n, 28), 0, input_port, }, \
630 { "int29@"#n, ENC(n, 29), 0, input_port, }, \
631 { "int30@"#n, ENC(n, 30), 0, input_port, }, \
632 { "int31@"#n, ENC(n, 31), 0, input_port, },
634 static const struct hw_port_descriptor bfin_sic1_ports
[] =
636 BFIN_SIC_TO_CEC_PORTS
641 static const struct hw_port_descriptor bfin_sic2_ports
[] =
643 BFIN_SIC_TO_CEC_PORTS
649 static const struct hw_port_descriptor bfin_sic3_ports
[] =
651 BFIN_SIC_TO_CEC_PORTS
658 static const struct hw_port_descriptor bfin_sic_561_ports
[] =
660 { "sup_irq@0", 0, 0, output_port
, },
661 { "sup_irq@1", 1, 0, output_port
, },
662 BFIN_SIC_TO_CEC_PORTS
669 bfin_sic_port_event (struct hw
*me
, bu32
*isr
, bu32 bit
, int level
)
678 bfin_sic_52x_port_event (struct hw
*me
, int my_port
, struct hw
*source
,
679 int source_port
, int level
)
681 struct bfin_sic
*sic
= hw_data (me
);
682 bu32 idx
= DEC_SIC (my_port
);
683 bu32 pin
= DEC_PIN (my_port
);
686 HW_TRACE ((me
, "processing level %i from port %i (SIC %u pin %u)",
687 level
, my_port
, idx
, pin
));
689 /* SIC only exists to forward interrupts from the system to the CEC. */
692 case 0: bfin_sic_port_event (me
, &sic
->bf52x
.isr0
, bit
, level
); break;
693 case 1: bfin_sic_port_event (me
, &sic
->bf52x
.isr1
, bit
, level
); break;
696 /* XXX: Handle SIC wakeup source ?
697 if (sic->bf52x.iwr0 & bit)
699 if (sic->bf52x.iwr1 & bit)
703 bfin_sic_52x_forward_interrupts (me
, sic
);
707 bfin_sic_537_port_event (struct hw
*me
, int my_port
, struct hw
*source
,
708 int source_port
, int level
)
710 struct bfin_sic
*sic
= hw_data (me
);
711 bu32 idx
= DEC_SIC (my_port
);
712 bu32 pin
= DEC_PIN (my_port
);
715 HW_TRACE ((me
, "processing level %i from port %i (SIC %u pin %u)",
716 level
, my_port
, idx
, pin
));
718 /* SIC only exists to forward interrupts from the system to the CEC. */
719 bfin_sic_port_event (me
, &sic
->bf537
.isr
, bit
, level
);
721 /* XXX: Handle SIC wakeup source ?
722 if (sic->bf537.iwr & bit)
726 bfin_sic_537_forward_interrupts (me
, sic
);
730 bfin_sic_54x_port_event (struct hw
*me
, int my_port
, struct hw
*source
,
731 int source_port
, int level
)
733 struct bfin_sic
*sic
= hw_data (me
);
734 bu32 idx
= DEC_SIC (my_port
);
735 bu32 pin
= DEC_PIN (my_port
);
738 HW_TRACE ((me
, "processing level %i from port %i (SIC %u pin %u)",
739 level
, my_port
, idx
, pin
));
741 /* SIC only exists to forward interrupts from the system to the CEC. */
744 case 0: bfin_sic_port_event (me
, &sic
->bf54x
.isr0
, bit
, level
); break;
745 case 1: bfin_sic_port_event (me
, &sic
->bf54x
.isr0
, bit
, level
); break;
746 case 2: bfin_sic_port_event (me
, &sic
->bf54x
.isr0
, bit
, level
); break;
749 /* XXX: Handle SIC wakeup source ?
750 if (sic->bf54x.iwr0 & bit)
752 if (sic->bf54x.iwr1 & bit)
754 if (sic->bf54x.iwr2 & bit)
758 bfin_sic_54x_forward_interrupts (me
, sic
);
762 bfin_sic_561_port_event (struct hw
*me
, int my_port
, struct hw
*source
,
763 int source_port
, int level
)
765 struct bfin_sic
*sic
= hw_data (me
);
766 bu32 idx
= DEC_SIC (my_port
);
767 bu32 pin
= DEC_PIN (my_port
);
770 HW_TRACE ((me
, "processing level %i from port %i (SIC %u pin %u)",
771 level
, my_port
, idx
, pin
));
773 /* SIC only exists to forward interrupts from the system to the CEC. */
776 case 0: bfin_sic_port_event (me
, &sic
->bf561
.isr0
, bit
, level
); break;
777 case 1: bfin_sic_port_event (me
, &sic
->bf561
.isr1
, bit
, level
); break;
780 /* XXX: Handle SIC wakeup source ?
781 if (sic->bf561.iwr0 & bit)
783 if (sic->bf561.iwr1 & bit)
787 bfin_sic_561_forward_interrupts (me
, sic
);
791 attach_bfin_sic_regs (struct hw
*me
, struct bfin_sic
*sic
)
793 address_word attach_address
;
795 unsigned attach_size
;
796 reg_property_spec reg
;
798 if (hw_find_property (me
, "reg") == NULL
)
799 hw_abort (me
, "Missing \"reg\" property");
801 if (!hw_find_reg_array_property (me
, "reg", 0, ®
))
802 hw_abort (me
, "\"reg\" property must contain three addr/size entries");
804 hw_unit_address_to_attach_address (hw_parent (me
),
806 &attach_space
, &attach_address
, me
);
807 hw_unit_size_to_attach_size (hw_parent (me
), ®
.size
, &attach_size
, me
);
809 if (attach_size
!= BFIN_MMR_SIC_SIZE
)
810 hw_abort (me
, "\"reg\" size must be %#x", BFIN_MMR_SIC_SIZE
);
812 hw_attach_address (hw_parent (me
),
813 0, attach_space
, attach_address
, attach_size
, me
);
815 sic
->base
= attach_address
;
819 bfin_sic_finish (struct hw
*me
)
821 struct bfin_sic
*sic
;
823 sic
= HW_ZALLOC (me
, struct bfin_sic
);
825 set_hw_data (me
, sic
);
826 attach_bfin_sic_regs (me
, sic
);
828 switch (hw_find_integer_property (me
, "type"))
831 set_hw_io_read_buffer (me
, bfin_sic_52x_io_read_buffer
);
832 set_hw_io_write_buffer (me
, bfin_sic_52x_io_write_buffer
);
833 set_hw_ports (me
, bfin_sic2_ports
);
834 set_hw_port_event (me
, bfin_sic_52x_port_event
);
835 mmr_names
= bf52x_mmr_names
;
837 /* Initialize the SIC. */
838 sic
->bf52x
.imask0
= sic
->bf52x
.imask1
= 0;
839 sic
->bf52x
.isr0
= sic
->bf52x
.isr1
= 0;
840 sic
->bf52x
.iwr0
= sic
->bf52x
.iwr1
= 0xFFFFFFFF;
841 sic
->bf52x
.iar0
= 0x00000000;
842 sic
->bf52x
.iar1
= 0x22111000;
843 sic
->bf52x
.iar2
= 0x33332222;
844 sic
->bf52x
.iar3
= 0x44444433;
845 sic
->bf52x
.iar4
= 0x55555555;
846 sic
->bf52x
.iar5
= 0x06666655;
847 sic
->bf52x
.iar6
= 0x33333003;
848 sic
->bf52x
.iar7
= 0x00000000; /* XXX: Find and fix */
851 set_hw_io_read_buffer (me
, bfin_sic_52x_io_read_buffer
);
852 set_hw_io_write_buffer (me
, bfin_sic_52x_io_write_buffer
);
853 set_hw_ports (me
, bfin_sic2_ports
);
854 set_hw_port_event (me
, bfin_sic_52x_port_event
);
855 mmr_names
= bf52x_mmr_names
;
857 /* Initialize the SIC. */
858 sic
->bf52x
.imask0
= sic
->bf52x
.imask1
= 0;
859 sic
->bf52x
.isr0
= sic
->bf52x
.isr1
= 0;
860 sic
->bf52x
.iwr0
= sic
->bf52x
.iwr1
= 0xFFFFFFFF;
861 sic
->bf52x
.iar0
= 0x00000000;
862 sic
->bf52x
.iar1
= 0x11000000;
863 sic
->bf52x
.iar2
= 0x33332222;
864 sic
->bf52x
.iar3
= 0x44444433;
865 sic
->bf52x
.iar4
= 0x55555555;
866 sic
->bf52x
.iar5
= 0x06666655;
867 sic
->bf52x
.iar6
= 0x33333000;
868 sic
->bf52x
.iar7
= 0x00000000; /* XXX: Find and fix */
871 set_hw_io_read_buffer (me
, bfin_sic_52x_io_read_buffer
);
872 set_hw_io_write_buffer (me
, bfin_sic_52x_io_write_buffer
);
873 set_hw_ports (me
, bfin_sic2_ports
);
874 set_hw_port_event (me
, bfin_sic_52x_port_event
);
875 mmr_names
= bf52x_mmr_names
;
877 /* Initialize the SIC. */
878 sic
->bf52x
.imask0
= sic
->bf52x
.imask1
= 0;
879 sic
->bf52x
.isr0
= sic
->bf52x
.isr1
= 0;
880 sic
->bf52x
.iwr0
= sic
->bf52x
.iwr1
= 0xFFFFFFFF;
881 sic
->bf52x
.iar0
= 0x00000000;
882 sic
->bf52x
.iar1
= 0x11000000;
883 sic
->bf52x
.iar2
= 0x33332222;
884 sic
->bf52x
.iar3
= 0x44444433;
885 sic
->bf52x
.iar4
= 0x55555555;
886 sic
->bf52x
.iar5
= 0x06666655;
887 sic
->bf52x
.iar6
= 0x33333000;
888 sic
->bf52x
.iar7
= 0x00000000; /* XXX: Find and fix */
891 set_hw_io_read_buffer (me
, bfin_sic_537_io_read_buffer
);
892 set_hw_io_write_buffer (me
, bfin_sic_537_io_write_buffer
);
893 set_hw_ports (me
, bfin_sic1_ports
);
894 set_hw_port_event (me
, bfin_sic_537_port_event
);
895 mmr_names
= bf537_mmr_names
;
897 /* Initialize the SIC. */
898 sic
->bf537
.imask
= 0;
900 sic
->bf537
.iwr
= 0xFFFFFFFF;
901 sic
->bf537
.iar0
= 0x10000000;
902 sic
->bf537
.iar1
= 0x33322221;
903 sic
->bf537
.iar2
= 0x66655444;
904 sic
->bf537
.iar3
= 0; /* XXX: fix this */
909 set_hw_io_read_buffer (me
, bfin_sic_537_io_read_buffer
);
910 set_hw_io_write_buffer (me
, bfin_sic_537_io_write_buffer
);
911 set_hw_ports (me
, bfin_sic1_ports
);
912 set_hw_port_event (me
, bfin_sic_537_port_event
);
913 mmr_names
= bf537_mmr_names
;
915 /* Initialize the SIC. */
916 sic
->bf537
.imask
= 0;
918 sic
->bf537
.iwr
= 0xFFFFFFFF;
919 sic
->bf537
.iar0
= 0x22211000;
920 sic
->bf537
.iar1
= 0x43333332;
921 sic
->bf537
.iar2
= 0x55555444;
922 sic
->bf537
.iar3
= 0x66655555;
925 set_hw_io_read_buffer (me
, bfin_sic_52x_io_read_buffer
);
926 set_hw_io_write_buffer (me
, bfin_sic_52x_io_write_buffer
);
927 set_hw_ports (me
, bfin_sic2_ports
);
928 set_hw_port_event (me
, bfin_sic_52x_port_event
);
929 mmr_names
= bf52x_mmr_names
;
931 /* Initialize the SIC. */
932 sic
->bf52x
.imask0
= sic
->bf52x
.imask1
= 0;
933 sic
->bf52x
.isr0
= sic
->bf52x
.isr1
= 0;
934 sic
->bf52x
.iwr0
= sic
->bf52x
.iwr1
= 0xFFFFFFFF;
935 sic
->bf52x
.iar0
= 0x10000000;
936 sic
->bf52x
.iar1
= 0x33322221;
937 sic
->bf52x
.iar2
= 0x66655444;
938 sic
->bf52x
.iar3
= 0x00000000;
939 sic
->bf52x
.iar4
= 0x32222220;
940 sic
->bf52x
.iar5
= 0x44433333;
941 sic
->bf52x
.iar6
= 0x00444664;
942 sic
->bf52x
.iar7
= 0x00000000; /* XXX: Find and fix */
945 set_hw_io_read_buffer (me
, bfin_sic_54x_io_read_buffer
);
946 set_hw_io_write_buffer (me
, bfin_sic_54x_io_write_buffer
);
947 set_hw_ports (me
, bfin_sic3_ports
);
948 set_hw_port_event (me
, bfin_sic_54x_port_event
);
949 mmr_names
= bf54x_mmr_names
;
951 /* Initialize the SIC. */
952 sic
->bf54x
.imask0
= sic
->bf54x
.imask1
= sic
->bf54x
.imask2
= 0;
953 sic
->bf54x
.isr0
= sic
->bf54x
.isr1
= sic
->bf54x
.isr2
= 0;
954 sic
->bf54x
.iwr0
= sic
->bf54x
.iwr1
= sic
->bf54x
.iwr2
= 0xFFFFFFFF;
955 sic
->bf54x
.iar0
= 0x10000000;
956 sic
->bf54x
.iar1
= 0x33322221;
957 sic
->bf54x
.iar2
= 0x66655444;
958 sic
->bf54x
.iar3
= 0x00000000;
959 sic
->bf54x
.iar4
= 0x32222220;
960 sic
->bf54x
.iar5
= 0x44433333;
961 sic
->bf54x
.iar6
= 0x00444664;
962 sic
->bf54x
.iar7
= 0x00000000;
963 sic
->bf54x
.iar8
= 0x44111111;
964 sic
->bf54x
.iar9
= 0x44444444;
965 sic
->bf54x
.iar10
= 0x44444444;
966 sic
->bf54x
.iar11
= 0x55444444;
969 set_hw_io_read_buffer (me
, bfin_sic_561_io_read_buffer
);
970 set_hw_io_write_buffer (me
, bfin_sic_561_io_write_buffer
);
971 set_hw_ports (me
, bfin_sic_561_ports
);
972 set_hw_port_event (me
, bfin_sic_561_port_event
);
973 mmr_names
= bf561_mmr_names
;
975 /* Initialize the SIC. */
976 sic
->bf561
.imask0
= sic
->bf561
.imask1
= 0;
977 sic
->bf561
.isr0
= sic
->bf561
.isr1
= 0;
978 sic
->bf561
.iwr0
= sic
->bf561
.iwr1
= 0xFFFFFFFF;
979 sic
->bf561
.iar0
= 0x00000000;
980 sic
->bf561
.iar1
= 0x11111000;
981 sic
->bf561
.iar2
= 0x21111111;
982 sic
->bf561
.iar3
= 0x22222222;
983 sic
->bf561
.iar4
= 0x33333222;
984 sic
->bf561
.iar5
= 0x43333333;
985 sic
->bf561
.iar6
= 0x21144444;
986 sic
->bf561
.iar7
= 0x00006552;
989 set_hw_io_read_buffer (me
, bfin_sic_537_io_read_buffer
);
990 set_hw_io_write_buffer (me
, bfin_sic_537_io_write_buffer
);
991 set_hw_ports (me
, bfin_sic1_ports
);
992 set_hw_port_event (me
, bfin_sic_537_port_event
);
993 mmr_names
= bf537_mmr_names
;
995 /* Initialize the SIC. */
996 sic
->bf537
.imask
= 0;
998 sic
->bf537
.iwr
= 0xFFFFFFFF;
999 sic
->bf537
.iar0
= 0x00000000;
1000 sic
->bf537
.iar1
= 0x33322221;
1001 sic
->bf537
.iar2
= 0x55444443;
1002 sic
->bf537
.iar3
= 0x66600005;
1005 hw_abort (me
, "no support for SIC on this Blackfin model yet");
1009 const struct hw_descriptor dv_bfin_sic_descriptor
[] =
1011 {"bfin_sic", bfin_sic_finish
,},