| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: jensenio_intr.c,v 1.17 2021/07/04 22:42:35 thorpej Exp $ */ | | 1 | /* $NetBSD: jensenio_intr.c,v 1.18 2021/07/15 01:43:54 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe. | | 8 | * by Jason R. Thorpe. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -21,39 +21,41 @@ | | | @@ -21,39 +21,41 @@ |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 32 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
33 | | | 33 | |
34 | __KERNEL_RCSID(0, "$NetBSD: jensenio_intr.c,v 1.17 2021/07/04 22:42:35 thorpej Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: jensenio_intr.c,v 1.18 2021/07/15 01:43:54 thorpej Exp $"); |
35 | | | 35 | |
36 | #include <sys/types.h> | | 36 | #include <sys/types.h> |
37 | #include <sys/param.h> | | 37 | #include <sys/param.h> |
38 | #include <sys/time.h> | | 38 | #include <sys/time.h> |
39 | #include <sys/systm.h> | | 39 | #include <sys/systm.h> |
40 | #include <sys/errno.h> | | 40 | #include <sys/errno.h> |
41 | #include <sys/device.h> | | 41 | #include <sys/device.h> |
42 | #include <sys/cpu.h> | | 42 | #include <sys/cpu.h> |
43 | #include <sys/syslog.h> | | 43 | #include <sys/syslog.h> |
44 | | | 44 | |
45 | #include <machine/autoconf.h> | | 45 | #include <machine/autoconf.h> |
46 | | | 46 | |
| | | 47 | #include <dev/ic/i8259reg.h> |
| | | 48 | |
47 | #include <dev/eisa/eisavar.h> | | 49 | #include <dev/eisa/eisavar.h> |
48 | | | 50 | |
49 | #include <dev/isa/isareg.h> | | 51 | #include <dev/isa/isareg.h> |
50 | #include <dev/isa/isavar.h> | | 52 | #include <dev/isa/isavar.h> |
51 | | | 53 | |
52 | #include <alpha/jensenio/jenseniovar.h> | | 54 | #include <alpha/jensenio/jenseniovar.h> |
53 | | | 55 | |
54 | static bus_space_tag_t pic_iot; | | 56 | static bus_space_tag_t pic_iot; |
55 | static bus_space_handle_t pic_ioh[2]; | | 57 | static bus_space_handle_t pic_ioh[2]; |
56 | static bus_space_handle_t pic_elcr_ioh; | | 58 | static bus_space_handle_t pic_elcr_ioh; |
57 | | | 59 | |
58 | static int jensenio_eisa_intr_map(void *, u_int, | | 60 | static int jensenio_eisa_intr_map(void *, u_int, |
59 | eisa_intr_handle_t *); | | 61 | eisa_intr_handle_t *); |
| @@ -87,31 +89,32 @@ static const int jensenio_intr_deftype[J | | | @@ -87,31 +89,32 @@ static const int jensenio_intr_deftype[J |
87 | IST_NONE, /* 9: EISA pin B04 */ | | 89 | IST_NONE, /* 9: EISA pin B04 */ |
88 | IST_NONE, /* 10: EISA pin D03 */ | | 90 | IST_NONE, /* 10: EISA pin D03 */ |
89 | IST_NONE, /* 11: EISA pin D04 */ | | 91 | IST_NONE, /* 11: EISA pin D04 */ |
90 | IST_NONE, /* 12: EISA pin D05 */ | | 92 | IST_NONE, /* 12: EISA pin D05 */ |
91 | IST_UNUSABLE, /* 13: not connected */ | | 93 | IST_UNUSABLE, /* 13: not connected */ |
92 | IST_NONE, /* 14: EISA pin D07 (SCSI) */ | | 94 | IST_NONE, /* 14: EISA pin D07 (SCSI) */ |
93 | IST_NONE, /* 15: EISA pin D06 */ | | 95 | IST_NONE, /* 15: EISA pin D06 */ |
94 | }; | | 96 | }; |
95 | | | 97 | |
96 | static inline void | | 98 | static inline void |
97 | jensenio_specific_eoi(int irq) | | 99 | jensenio_specific_eoi(int irq) |
98 | { | | 100 | { |
99 | | | 101 | |
100 | if (irq > 7) | | 102 | if (irq > 7) { |
101 | bus_space_write_1(pic_iot, pic_ioh[1], | | 103 | bus_space_write_1(pic_iot, pic_ioh[1], PIC_OCW2, |
102 | 0, 0x20 | (irq & 0x07)); | | 104 | OCW2_EOI | OCW2_SL | (irq & 0x07)); |
103 | bus_space_write_1(pic_iot, pic_ioh[0], | | 105 | } |
104 | 0, 0x20 | (irq > 7 ? 2 : irq)); | | 106 | bus_space_write_1(pic_iot, pic_ioh[0], PIC_OCW2, |
| | | 107 | OCW2_EOI | OCW2_SL | (irq > 7 ? 2 : irq)); |
105 | } | | 108 | } |
106 | | | 109 | |
107 | void | | 110 | void |
108 | jensenio_intr_init(struct jensenio_config *jcp) | | 111 | jensenio_intr_init(struct jensenio_config *jcp) |
109 | { | | 112 | { |
110 | eisa_chipset_tag_t ec = &jcp->jc_ec; | | 113 | eisa_chipset_tag_t ec = &jcp->jc_ec; |
111 | isa_chipset_tag_t ic = &jcp->jc_ic; | | 114 | isa_chipset_tag_t ic = &jcp->jc_ic; |
112 | struct evcnt *ev; | | 115 | struct evcnt *ev; |
113 | const char *cp; | | 116 | const char *cp; |
114 | int i; | | 117 | int i; |
115 | | | 118 | |
116 | pic_iot = &jcp->jc_eisa_iot; | | 119 | pic_iot = &jcp->jc_eisa_iot; |
117 | | | 120 | |
| @@ -331,32 +334,32 @@ jensenio_iointr(void *framep, u_long vec | | | @@ -331,32 +334,32 @@ jensenio_iointr(void *framep, u_long vec |
331 | | | 334 | |
332 | jensenio_specific_eoi(irq); | | 335 | jensenio_specific_eoi(irq); |
333 | } | | 336 | } |
334 | | | 337 | |
335 | static void | | 338 | static void |
336 | jensenio_enable_intr(int irq, int onoff) | | 339 | jensenio_enable_intr(int irq, int onoff) |
337 | { | | 340 | { |
338 | int pic; | | 341 | int pic; |
339 | uint8_t bit, mask; | | 342 | uint8_t bit, mask; |
340 | | | 343 | |
341 | pic = irq >> 3; | | 344 | pic = irq >> 3; |
342 | bit = 1 << (irq & 0x7); | | 345 | bit = 1 << (irq & 0x7); |
343 | | | 346 | |
344 | mask = bus_space_read_1(pic_iot, pic_ioh[pic], 1); | | 347 | mask = bus_space_read_1(pic_iot, pic_ioh[pic], PIC_OCW1); |
345 | if (onoff) | | 348 | if (onoff) |
346 | mask &= ~bit; | | 349 | mask &= ~bit; |
347 | else | | 350 | else |
348 | mask |= bit; | | 351 | mask |= bit; |
349 | bus_space_write_1(pic_iot, pic_ioh[pic], 1, mask); | | 352 | bus_space_write_1(pic_iot, pic_ioh[pic], PIC_OCW1, mask); |
350 | } | | 353 | } |
351 | | | 354 | |
352 | void | | 355 | void |
353 | jensenio_setlevel(int irq, int level) | | 356 | jensenio_setlevel(int irq, int level) |
354 | { | | 357 | { |
355 | int elcr; | | 358 | int elcr; |
356 | uint8_t bit, mask; | | 359 | uint8_t bit, mask; |
357 | | | 360 | |
358 | elcr = irq >> 3; | | 361 | elcr = irq >> 3; |
359 | bit = 1 << (irq & 0x7); | | 362 | bit = 1 << (irq & 0x7); |
360 | | | 363 | |
361 | mask = bus_space_read_1(pic_iot, pic_elcr_ioh, elcr); | | 364 | mask = bus_space_read_1(pic_iot, pic_elcr_ioh, elcr); |
362 | if (level) | | 365 | if (level) |
| @@ -368,22 +371,25 @@ jensenio_setlevel(int irq, int level) | | | @@ -368,22 +371,25 @@ jensenio_setlevel(int irq, int level) |
368 | | | 371 | |
369 | static void | | 372 | static void |
370 | jensenio_pic_init(void) | | 373 | jensenio_pic_init(void) |
371 | { | | 374 | { |
372 | static const int picaddr[2] = { IO_ICU1, IO_ICU2 }; | | 375 | static const int picaddr[2] = { IO_ICU1, IO_ICU2 }; |
373 | int pic; | | 376 | int pic; |
374 | | | 377 | |
375 | /* | | 378 | /* |
376 | * Map the PICs and mask off the interrupts on them. | | 379 | * Map the PICs and mask off the interrupts on them. |
377 | */ | | 380 | */ |
378 | for (pic = 0; pic < 2; pic++) { | | 381 | for (pic = 0; pic < 2; pic++) { |
379 | if (bus_space_map(pic_iot, picaddr[pic], 2, 0, &pic_ioh[pic])) | | 382 | if (bus_space_map(pic_iot, picaddr[pic], 2, 0, &pic_ioh[pic])) |
380 | panic("jensenio_init_intr: unable to map PIC %d", pic); | | 383 | panic("jensenio_init_intr: unable to map PIC %d", pic); |
381 | bus_space_write_1(pic_iot, pic_ioh[pic], 1, 0xff); | | 384 | bus_space_write_1(pic_iot, pic_ioh[pic], PIC_OCW1, 0xff); |
382 | } | | 385 | } |
383 | | | 386 | |
384 | /* | | 387 | /* |
385 | * Map the ELCR registers. | | 388 | * Map the ELCR registers and initialize all interrupts to EDGE |
| | | 389 | * trigger. |
386 | */ | | 390 | */ |
387 | if (bus_space_map(pic_iot, 0x4d0, 2, 0, &pic_elcr_ioh)) | | 391 | if (bus_space_map(pic_iot, 0x4d0, 2, 0, &pic_elcr_ioh)) |
388 | panic("jensenio_init_intr: unable to map ELCR registers"); | | 392 | panic("jensenio_init_intr: unable to map ELCR registers"); |
| | | 393 | bus_space_write_1(pic_iot, pic_elcr_ioh, 0, 0); |
| | | 394 | bus_space_write_1(pic_iot, pic_elcr_ioh, 1, 0); |
389 | } | | 395 | } |