xref: /netbsd-src/sys/arch/hppa/dev/ssio.c (revision c7fb772b85b2b5d4cfb282f868f454b4701534fd)
1*c7fb772bSthorpej /*	$NetBSD: ssio.c,v 1.5 2021/08/07 16:18:55 thorpej Exp $	*/
26d3ceb1dSskrll 
36d3ceb1dSskrll /*	$OpenBSD: ssio.c,v 1.7 2009/03/08 22:19:04 miod Exp $	*/
46d3ceb1dSskrll 
56d3ceb1dSskrll /*
66d3ceb1dSskrll  * Copyright (c) 2007 Mark Kettenis
76d3ceb1dSskrll  *
86d3ceb1dSskrll  * Permission to use, copy, modify, and distribute this software for any
96d3ceb1dSskrll  * purpose with or without fee is hereby granted, provided that the above
106d3ceb1dSskrll  * copyright notice and this permission notice appear in all copies.
116d3ceb1dSskrll  *
126d3ceb1dSskrll  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
136d3ceb1dSskrll  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
146d3ceb1dSskrll  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
156d3ceb1dSskrll  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
166d3ceb1dSskrll  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
176d3ceb1dSskrll  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
186d3ceb1dSskrll  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
196d3ceb1dSskrll  */
206d3ceb1dSskrll 
216d3ceb1dSskrll /*
226d3ceb1dSskrll  * Driver for the National Semiconductor PC87560 Legacy I/O chip.
236d3ceb1dSskrll  */
246d3ceb1dSskrll 
256d3ceb1dSskrll #include <sys/param.h>
266d3ceb1dSskrll #include <sys/systm.h>
276d3ceb1dSskrll #include <sys/device.h>
286d3ceb1dSskrll 
296d3ceb1dSskrll #include <sys/bus.h>
306d3ceb1dSskrll #include <machine/iomod.h>
316d3ceb1dSskrll 
326d3ceb1dSskrll #include <dev/pci/pcireg.h>
336d3ceb1dSskrll #include <dev/pci/pcivar.h>
346d3ceb1dSskrll #include <dev/pci/pcidevs.h>
356d3ceb1dSskrll #include <dev/pci/pciidereg.h>
366d3ceb1dSskrll 
376d3ceb1dSskrll #include <hppa/hppa/machdep.h>
386d3ceb1dSskrll #include <hppa/dev/ssiovar.h>
396d3ceb1dSskrll 
406d3ceb1dSskrll #include "ukbd.h"
416d3ceb1dSskrll #if NUKBD > 0
426d3ceb1dSskrll #include <dev/usb/ohcireg.h>
436d3ceb1dSskrll #include <dev/usb/ukbdvar.h>
446d3ceb1dSskrll #endif
456d3ceb1dSskrll 
466d3ceb1dSskrll /* PCI config space. */
476d3ceb1dSskrll #define SSIO_PCI_DMA_RC2	0x64
486d3ceb1dSskrll #define SSIO_PCI_INT_TC1	0x67
496d3ceb1dSskrll #define SSIO_PCI_INT_TC2	0x68
506d3ceb1dSskrll #define SSIO_PCI_INT_RC1	0x69
516d3ceb1dSskrll #define SSIO_PCI_INT_RC2	0x6a
526d3ceb1dSskrll #define SSIO_PCI_INT_RC3	0x6b
536d3ceb1dSskrll #define SSIO_PCI_INT_RC4	0x6c
546d3ceb1dSskrll #define SSIO_PCI_INT_RC5	0x6d
556d3ceb1dSskrll #define SSIO_PCI_INT_RC6	0x6e
566d3ceb1dSskrll #define SSIO_PCI_INT_RC7	0x6f
576d3ceb1dSskrll #define SSIO_PCI_INT_RC8	0x70
586d3ceb1dSskrll #define SSIO_PCI_INT_RC9	0x71
596d3ceb1dSskrll #define SSIO_PCI_SP1BAR		0x94
606d3ceb1dSskrll #define SSIO_PCI_SP2BAR		0x98
616d3ceb1dSskrll #define SSIO_PCI_PPBAR		0x9c
626d3ceb1dSskrll 
636d3ceb1dSskrll #define SSIO_PCI_INT_TC1_MASK	0xff
646d3ceb1dSskrll #define SSIO_PCI_INT_TC1_SHIFT	24
656d3ceb1dSskrll 
666d3ceb1dSskrll #define SSIO_PCI_INT_TC2_MASK	0xff
676d3ceb1dSskrll #define SSIO_PCI_INT_TC2_SHIFT	0
686d3ceb1dSskrll 
696d3ceb1dSskrll #define SSIO_PCI_INT_RC1_MASK	0xff
706d3ceb1dSskrll #define SSIO_PCI_INT_RC1_SHIFT	8
716d3ceb1dSskrll 
726d3ceb1dSskrll #define SSIO_PCI_INT_RC2_MASK	0xff
736d3ceb1dSskrll #define SSIO_PCI_INT_RC2_SHIFT	16
746d3ceb1dSskrll 
756d3ceb1dSskrll #define SSIO_PCI_INT_RC3_MASK	0xff
766d3ceb1dSskrll #define SSIO_PCI_INT_RC3_SHIFT	24
776d3ceb1dSskrll 
786d3ceb1dSskrll #define SSIO_PCI_INT_RC4_MASK	0xff
796d3ceb1dSskrll #define SSIO_PCI_INT_RC4_SHIFT	0
806d3ceb1dSskrll 
816d3ceb1dSskrll #define SSIO_PCI_INT_RC5_MASK	0xff
826d3ceb1dSskrll #define SSIO_PCI_INT_RC5_SHIFT	8
836d3ceb1dSskrll 
846d3ceb1dSskrll #define SSIO_PCI_INT_RC6_MASK	0xff
856d3ceb1dSskrll #define SSIO_PCI_INT_RC6_SHIFT	16
866d3ceb1dSskrll 
876d3ceb1dSskrll #define SSIO_PCI_INT_RC7_MASK	0xff
886d3ceb1dSskrll #define SSIO_PCI_INT_RC7_SHIFT	24
896d3ceb1dSskrll 
906d3ceb1dSskrll #define SSIO_PCI_INT_RC8_MASK	0xff
916d3ceb1dSskrll #define SSIO_PCI_INT_RC8_SHIFT	0
926d3ceb1dSskrll 
936d3ceb1dSskrll #define SSIO_PCI_INT_RC9_MASK	0xff
946d3ceb1dSskrll #define SSIO_PCI_INT_RC9_SHIFT	8
956d3ceb1dSskrll 
966d3ceb1dSskrll /* Cascaded i8259-compatible PICs. */
976d3ceb1dSskrll #define SSIO_PIC1	0x20
986d3ceb1dSskrll #define SSIO_PIC2	0xa0
996d3ceb1dSskrll #define SSIO_NINTS	16
1006d3ceb1dSskrll 
1016d3ceb1dSskrll struct ssio_iv {
1026d3ceb1dSskrll 	int (*handler)(void *);
1036d3ceb1dSskrll 	void *arg;
1046d3ceb1dSskrll };
1056d3ceb1dSskrll 
1066d3ceb1dSskrll struct ssio_iv ssio_intr_table[SSIO_NINTS];
1076d3ceb1dSskrll 
1086d3ceb1dSskrll struct ssio_softc {
1096d3ceb1dSskrll 	bus_space_tag_t sc_iot;
1106d3ceb1dSskrll 	bus_space_handle_t sc_ic1h;
1116d3ceb1dSskrll 	bus_space_handle_t sc_ic2h;
1126d3ceb1dSskrll 	void *sc_ih;
1136d3ceb1dSskrll };
1146d3ceb1dSskrll 
1156d3ceb1dSskrll int	ssio_match(device_t, cfdata_t, void *);
1166d3ceb1dSskrll void	ssio_attach(device_t, device_t, void *);
1176d3ceb1dSskrll 
1186d3ceb1dSskrll CFATTACH_DECL_NEW(ssio, sizeof(struct ssio_softc), ssio_match, ssio_attach, NULL,
1196d3ceb1dSskrll     NULL);
1206d3ceb1dSskrll 
1216d3ceb1dSskrll extern struct cfdriver ssio_cd;
1226d3ceb1dSskrll 
1236d3ceb1dSskrll int	ssio_intr(void *);
1246d3ceb1dSskrll int	ssio_print(void *, const char *);
1256d3ceb1dSskrll 
1266d3ceb1dSskrll int
ssio_match(device_t parent,cfdata_t match,void * aux)1276d3ceb1dSskrll ssio_match(device_t parent, cfdata_t match, void *aux)
1286d3ceb1dSskrll {
1296d3ceb1dSskrll 	struct pci_attach_args *pa = aux;
1306d3ceb1dSskrll 	pcireg_t bhlc, id;
1316d3ceb1dSskrll 	pcitag_t tag;
1326d3ceb1dSskrll 
1336d3ceb1dSskrll 	/*
1346d3ceb1dSskrll 	 * The firmware doesn't always switch the IDE function into native
1356d3ceb1dSskrll 	 * mode.  So we do that ourselves since it makes life much simpler.
1366d3ceb1dSskrll 	 * Note that we have to do this in the match function since the
1376d3ceb1dSskrll 	 * Legacy I/O function attaches after the IDE function.
1386d3ceb1dSskrll 	 */
1396d3ceb1dSskrll 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NS &&
1406d3ceb1dSskrll 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NS_PC87415) {
1416d3ceb1dSskrll 		bhlc = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
1426d3ceb1dSskrll 		if (!PCI_HDRTYPE_MULTIFN(bhlc))
1436d3ceb1dSskrll 			return (0);
1446d3ceb1dSskrll 
1456d3ceb1dSskrll 		tag = pci_make_tag(pa->pa_pc, pa->pa_bus, pa->pa_device, 1);
1466d3ceb1dSskrll 		id = pci_conf_read(pa->pa_pc, tag, PCI_ID_REG);
1476d3ceb1dSskrll 		if (PCI_VENDOR(id) != PCI_VENDOR_NS ||
1486d3ceb1dSskrll 		    PCI_PRODUCT(id) != PCI_PRODUCT_NS_PC87560)
1496d3ceb1dSskrll 			return (0);
1506d3ceb1dSskrll 
1516d3ceb1dSskrll 		pa->pa_class |= PCIIDE_INTERFACE_PCI(0) << PCI_INTERFACE_SHIFT;
1526d3ceb1dSskrll 		pa->pa_class |= PCIIDE_INTERFACE_PCI(1) << PCI_INTERFACE_SHIFT;
1536d3ceb1dSskrll 		pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG,
1546d3ceb1dSskrll 		    pa->pa_class);
1556d3ceb1dSskrll 		return (0);
1566d3ceb1dSskrll 	}
1576d3ceb1dSskrll 
1586d3ceb1dSskrll 	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_NS)
1596d3ceb1dSskrll 		return 0;
1606d3ceb1dSskrll 
1616d3ceb1dSskrll 	if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NS_PC87560)
1626d3ceb1dSskrll 		return 1;
1636d3ceb1dSskrll 
1646d3ceb1dSskrll 	return 0;
1656d3ceb1dSskrll }
1666d3ceb1dSskrll 
1676d3ceb1dSskrll void
ssio_attach(device_t parent,device_t self,void * aux)1686d3ceb1dSskrll ssio_attach(device_t parent, device_t self, void *aux)
1696d3ceb1dSskrll {
1706d3ceb1dSskrll 	struct ssio_softc *sc = device_private(self);
1716d3ceb1dSskrll 	struct pci_attach_args *pa = aux;
1726d3ceb1dSskrll 	struct ssio_attach_args saa;
1736d3ceb1dSskrll 	pci_intr_handle_t ih;
1746d3ceb1dSskrll 	char devinfo[256];
1756d3ceb1dSskrll 	const char *intrstr;
1766d3ceb1dSskrll 	pcireg_t reg;
1776d3ceb1dSskrll 	int revision;
1786d3ceb1dSskrll #if NUKBD > 0
1796d3ceb1dSskrll 	pcitag_t tag;
1806d3ceb1dSskrll 	int pagezero_cookie;
1816d3ceb1dSskrll #endif
182e58a356cSchristos 	char buf[PCI_INTRSTR_LEN];
1836d3ceb1dSskrll 
1846d3ceb1dSskrll 	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof devinfo);
1856d3ceb1dSskrll 	revision = PCI_REVISION(pa->pa_class);
1866d3ceb1dSskrll 	aprint_normal(": %s (rev. 0x%02x)\n", devinfo, revision);
1876d3ceb1dSskrll 
1886d3ceb1dSskrll 	sc->sc_iot = pa->pa_iot;
1896d3ceb1dSskrll 	if (bus_space_map(sc->sc_iot, SSIO_PIC1, 2, 0, &sc->sc_ic1h)) {
1906d3ceb1dSskrll 		aprint_error_dev(self, "unable to map PIC1 registers\n");
1916d3ceb1dSskrll 		return;
1926d3ceb1dSskrll 	}
1936d3ceb1dSskrll 	if (bus_space_map(sc->sc_iot, SSIO_PIC2, 2, 0, &sc->sc_ic2h)) {
1946d3ceb1dSskrll 		aprint_error_dev(self, "unable to map PIC2 registers\n");
1956d3ceb1dSskrll 		goto unmap_ic1;
1966d3ceb1dSskrll 	}
1976d3ceb1dSskrll 
1986d3ceb1dSskrll 	if (pci_intr_map(pa, &ih)) {
1996d3ceb1dSskrll 		aprint_error_dev(self, "unable to map interrupt\n");
2006d3ceb1dSskrll 		goto unmap_ic2;
2016d3ceb1dSskrll 	}
202e58a356cSchristos 	intrstr = pci_intr_string(pa->pa_pc, ih, buf, sizeof(buf));
2036d3ceb1dSskrll 	sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_TTY, ssio_intr,
2046d3ceb1dSskrll 	    sc);
2056d3ceb1dSskrll 	if (sc->sc_ih == NULL) {
2066d3ceb1dSskrll 		aprint_error_dev(self, "could not establish interrupt");
2076d3ceb1dSskrll 		if (intrstr != NULL)
2086d3ceb1dSskrll 			aprint_error(" at %s", intrstr);
2096d3ceb1dSskrll 		aprint_error("\n");
2106d3ceb1dSskrll 		goto unmap_ic2;
2116d3ceb1dSskrll 	}
2126d3ceb1dSskrll 	aprint_normal_dev(self, "interrupting at %s\n", intrstr);
2136d3ceb1dSskrll 
2146d3ceb1dSskrll 	/*
2156d3ceb1dSskrll 	 * We use the following interrupt mapping:
2166d3ceb1dSskrll 	 *
2176d3ceb1dSskrll 	 * USB (INTD#)		IRQ 1
2186d3ceb1dSskrll 	 * IDE Channel 1	IRQ 5
2196d3ceb1dSskrll 	 * Serial Port 1	IRQ 4
2206d3ceb1dSskrll 	 * Serial Port 2	IRQ 3
2216d3ceb1dSskrll 	 * Parallel Port	IRQ 7
2226d3ceb1dSskrll 	 *
2236d3ceb1dSskrll 	 * USB and IDE are set to level triggered, all others to edge
2246d3ceb1dSskrll 	 * triggered.
2256d3ceb1dSskrll 	 *
2266d3ceb1dSskrll 	 * We disable all other interrupts since we don't need them.
2276d3ceb1dSskrll 	 */
2286d3ceb1dSskrll 	reg = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_DMA_RC2);
2296d3ceb1dSskrll 	reg &= ~(SSIO_PCI_INT_TC1_MASK << SSIO_PCI_INT_TC1_SHIFT);
2306d3ceb1dSskrll 	reg |= 0x22 << SSIO_PCI_INT_TC1_SHIFT;
2316d3ceb1dSskrll 	pci_conf_write(pa->pa_pc, pa->pa_tag, SSIO_PCI_DMA_RC2, reg);
2326d3ceb1dSskrll 
2336d3ceb1dSskrll 	reg = 0;
2346d3ceb1dSskrll 	reg |= 0x34 << SSIO_PCI_INT_RC1_SHIFT;	/* SP1, SP2 */
2356d3ceb1dSskrll 	reg |= 0x07 << SSIO_PCI_INT_RC2_SHIFT;	/* PP */
2366d3ceb1dSskrll 	reg |= 0x05 << SSIO_PCI_INT_RC3_SHIFT;	/* IDE1 */
2376d3ceb1dSskrll 	pci_conf_write(pa->pa_pc, pa->pa_tag, SSIO_PCI_INT_TC2, reg);
2386d3ceb1dSskrll 
2396d3ceb1dSskrll 	reg = 0;
2406d3ceb1dSskrll 	reg |= 0x10 << SSIO_PCI_INT_RC5_SHIFT;	/* INTD# (USB) */
2416d3ceb1dSskrll 	pci_conf_write(pa->pa_pc, pa->pa_tag, SSIO_PCI_INT_RC4, reg);
2426d3ceb1dSskrll 
2436d3ceb1dSskrll 	/* Program PIC1. */
2446d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x11);
2456d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x00);
2466d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x04);
2476d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x01);
2486d3ceb1dSskrll 
2496d3ceb1dSskrll 	/* Priority (3-7,0-2). */
2506d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0xc2);
2516d3ceb1dSskrll 
2526d3ceb1dSskrll 	/* Program PIC2. */
2536d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 0, 0x11);
2546d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x00);
2556d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x02);
2566d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x01);
2576d3ceb1dSskrll 
2586d3ceb1dSskrll 	/* Unmask all interrupts. */
2596d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x00);
2606d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x00);
2616d3ceb1dSskrll 
2626d3ceb1dSskrll 	/* Serial Port 1. */
2636d3ceb1dSskrll 	saa.saa_name = "com";
2646d3ceb1dSskrll 	saa.saa_iot = sc->sc_iot;
2656d3ceb1dSskrll 	saa.saa_iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_SP1BAR);
2666d3ceb1dSskrll 	saa.saa_iobase &= 0xfffffffe;
2676d3ceb1dSskrll 	saa.saa_irq = 4;
268*c7fb772bSthorpej 	config_found(self, &saa, ssio_print, CFARGS_NONE);
2696d3ceb1dSskrll 
2706d3ceb1dSskrll 	/* Serial Port 2. */
2716d3ceb1dSskrll 	saa.saa_name = "com";
2726d3ceb1dSskrll 	saa.saa_iot = sc->sc_iot;
2736d3ceb1dSskrll 	saa.saa_iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_SP2BAR);
2746d3ceb1dSskrll 	saa.saa_iobase &= 0xfffffffe;
2756d3ceb1dSskrll 	saa.saa_irq = 3;
276*c7fb772bSthorpej 	config_found(self, &saa, ssio_print, CFARGS_NONE);
2776d3ceb1dSskrll 
2786d3ceb1dSskrll 	/* Parallel Port. */
2796d3ceb1dSskrll 	saa.saa_name = "lpt";
2806d3ceb1dSskrll 	saa.saa_iot = sc->sc_iot;
2816d3ceb1dSskrll 	saa.saa_iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_PPBAR);
2826d3ceb1dSskrll 	saa.saa_iobase &= 0xfffffffe;
2836d3ceb1dSskrll 	saa.saa_irq = 7;
284*c7fb772bSthorpej 	config_found(self, &saa, ssio_print, CFARGS_NONE);
2856d3ceb1dSskrll 
2866d3ceb1dSskrll #if NUKBD > 0
2876d3ceb1dSskrll 	/*
2887991f5a7Sandvar 	 * If a USB keyboard is used for console input, the firmware passes
2896d3ceb1dSskrll 	 * the mmio address of the USB controller the keyboard is attached
2906d3ceb1dSskrll 	 * to.  Since we know the USB controller is function 2 on the same
2916d3ceb1dSskrll 	 * device and comes right after us (we're function 1 remember),
2926d3ceb1dSskrll 	 * this is a convenient spot to mark the USB keyboard as console
2936d3ceb1dSskrll 	 * if the address matches.
2946d3ceb1dSskrll 	 */
2956d3ceb1dSskrll 	tag = pci_make_tag(pa->pa_pc, pa->pa_bus, pa->pa_device, 2);
2966d3ceb1dSskrll 	reg = pci_conf_read(pa->pa_pc, tag, PCI_CBMEM);
2976d3ceb1dSskrll 
2986d3ceb1dSskrll 	pagezero_cookie = hppa_pagezero_map();
2996d3ceb1dSskrll 	if (PAGE0->mem_kbd.pz_class == PCL_KEYBD &&
3006d3ceb1dSskrll 	    PAGE0->mem_kbd.pz_hpa == (struct iomod *)reg)
3016d3ceb1dSskrll 		ukbd_cnattach();
3026d3ceb1dSskrll 	hppa_pagezero_unmap(pagezero_cookie);
3036d3ceb1dSskrll #endif
3046d3ceb1dSskrll 
3056d3ceb1dSskrll 	return;
3066d3ceb1dSskrll 
3076d3ceb1dSskrll unmap_ic2:
3086d3ceb1dSskrll 	bus_space_unmap(sc->sc_iot, sc->sc_ic2h, 2);
3096d3ceb1dSskrll unmap_ic1:
3106d3ceb1dSskrll 	bus_space_unmap(sc->sc_iot, sc->sc_ic1h, 2);
3116d3ceb1dSskrll }
3126d3ceb1dSskrll 
3136d3ceb1dSskrll int
ssio_intr(void * v)3146d3ceb1dSskrll ssio_intr(void *v)
3156d3ceb1dSskrll {
3166d3ceb1dSskrll 	struct ssio_softc *sc = v;
3176d3ceb1dSskrll 	struct ssio_iv *iv;
3186d3ceb1dSskrll 	int claimed = 0;
3196d3ceb1dSskrll 	int irq, isr;
3206d3ceb1dSskrll 
3216d3ceb1dSskrll 	/* Poll for interrupt. */
3226d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x0c);
3236d3ceb1dSskrll 	irq = bus_space_read_1(sc->sc_iot, sc->sc_ic1h, 0);
3246d3ceb1dSskrll 	irq &= 0x07;
3256d3ceb1dSskrll 
3266d3ceb1dSskrll 	if (irq == 7) {
3276d3ceb1dSskrll 		bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x0b);
3286d3ceb1dSskrll 		isr = bus_space_read_1(sc->sc_iot, sc->sc_ic1h, 0);
3296d3ceb1dSskrll 		if ((isr & 0x80) == 0)
3306d3ceb1dSskrll 			/* Spurious interrupt. */
3316d3ceb1dSskrll 			return (0);
3326d3ceb1dSskrll 	}
3336d3ceb1dSskrll 
3346d3ceb1dSskrll 	iv = &ssio_intr_table[irq];
3356d3ceb1dSskrll 	if (iv->handler)
3366d3ceb1dSskrll 		claimed = iv->handler(iv->arg);
3376d3ceb1dSskrll 
3386d3ceb1dSskrll 	/* Signal EOI. */
3396d3ceb1dSskrll 	bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x60 | (irq & 0x0f));
3406d3ceb1dSskrll 
3416d3ceb1dSskrll 	return (claimed);
3426d3ceb1dSskrll }
3436d3ceb1dSskrll 
3446d3ceb1dSskrll void *
ssio_intr_establish(int pri,int irq,int (* handler)(void *),void * arg,const char * name)3456d3ceb1dSskrll ssio_intr_establish(int pri, int irq, int (*handler)(void *), void *arg,
3466d3ceb1dSskrll     const char *name)
3476d3ceb1dSskrll {
3486d3ceb1dSskrll 	struct ssio_iv *iv;
3496d3ceb1dSskrll 
3506d3ceb1dSskrll 	if (irq < 0 || irq >= SSIO_NINTS || ssio_intr_table[irq].handler)
3516d3ceb1dSskrll 		return (NULL);
3526d3ceb1dSskrll 
3536d3ceb1dSskrll 	iv = &ssio_intr_table[irq];
3546d3ceb1dSskrll 	iv->handler = handler;
3556d3ceb1dSskrll 	iv->arg = arg;
3566d3ceb1dSskrll 
3576d3ceb1dSskrll 	return (iv);
3586d3ceb1dSskrll }
3596d3ceb1dSskrll 
3606d3ceb1dSskrll int
ssio_print(void * aux,const char * pnp)3616d3ceb1dSskrll ssio_print(void *aux, const char *pnp)
3626d3ceb1dSskrll {
3636d3ceb1dSskrll 	struct ssio_attach_args *saa = aux;
3646d3ceb1dSskrll 
3656d3ceb1dSskrll 	if (pnp)
3666d3ceb1dSskrll 		printf("%s at %s", saa->saa_name, pnp);
3676d3ceb1dSskrll 	if (saa->saa_iobase) {
3686d3ceb1dSskrll 		printf(" offset %lx", saa->saa_iobase);
3696d3ceb1dSskrll 		if (!pnp && saa->saa_irq >= 0)
3706d3ceb1dSskrll 			printf(" irq %d", saa->saa_irq);
3716d3ceb1dSskrll 	}
3726d3ceb1dSskrll 
3736d3ceb1dSskrll 	return (UNCONF);
3746d3ceb1dSskrll }
375