2 * Device driver for Specialix range (SI/XIO) of serial line multiplexors.
4 * Copyright (C) 2000, Peter Wemm <peter@netplex.com.au>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notices, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notices, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHORS BE LIABLE.
22 #include <sys/cdefs.h>
23 __FBSDID("$FreeBSD$");
25 #include <sys/param.h>
26 #include <sys/systm.h>
27 #include <sys/kernel.h>
28 #include <sys/module.h>
30 #include <machine/bus.h>
32 #include <machine/resource.h>
34 #include <dev/si/sireg.h>
35 #include <dev/si/sivar.h>
37 #include <dev/eisa/eisaconf.h>
40 si_eisa_probe(device_t dev)
46 if (eisa_get_id(dev) != SIEISADEVID)
49 device_set_desc(dev, "Specialix SI/XIO EISA host card");
51 iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + SIEISABASE;
52 eisa_add_iospace(dev, iobase, SIEISAIOSIZE, RESVADDR_NONE);
54 maddr = (inb(iobase+1) << 24) | (inb(iobase) << 16);
55 eisa_add_mspace(dev, maddr, SIEISA_MEMSIZE, RESVADDR_NONE);
57 irq = ((inb(iobase+2) >> 4) & 0xf);
58 eisa_add_intr(dev, irq, EISA_TRIGGER_LEVEL); /* XXX shared? */
64 si_eisa_attach(device_t dev)
72 sc = device_get_softc(dev);
77 sc->sc_port_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
78 &sc->sc_port_rid, RF_ACTIVE);
79 if (!sc->sc_port_res) {
80 device_printf(dev, "couldn't allocate ioports\n");
83 sc->sc_iobase = rman_get_start(sc->sc_port_res);
86 sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
87 &sc->sc_mem_rid, RF_ACTIVE);
88 if (!sc->sc_mem_res) {
89 device_printf(dev, "couldn't allocate iomemory");
92 sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res);
93 sc->sc_maddr = rman_get_virtual(sc->sc_mem_res);
96 sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
98 RF_ACTIVE | RF_SHAREABLE);
99 if (!sc->sc_irq_res) {
100 device_printf(dev, "couldn't allocate interrupt");
103 sc->sc_irq = rman_get_start(sc->sc_irq_res);
104 error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY,
105 NULL, si_intr, sc,&ih);
107 device_printf(dev, "couldn't activate interrupt");
111 error = siattach(dev);
114 return (0); /* success */
119 if (sc->sc_irq_res) {
121 bus_teardown_intr(dev, sc->sc_irq_res, ih);
122 bus_release_resource(dev, SYS_RES_IRQ,
123 sc->sc_irq_rid, sc->sc_irq_res);
126 if (sc->sc_mem_res) {
127 bus_release_resource(dev, SYS_RES_MEMORY,
128 sc->sc_mem_rid, sc->sc_mem_res);
131 if (sc->sc_port_res) {
132 bus_release_resource(dev, SYS_RES_IOPORT,
133 sc->sc_port_rid, sc->sc_port_res);
139 static device_method_t si_eisa_methods[] = {
140 /* Device interface */
141 DEVMETHOD(device_probe, si_eisa_probe),
142 DEVMETHOD(device_attach, si_eisa_attach),
147 static driver_t si_eisa_driver = {
150 sizeof(struct si_softc),
153 DRIVER_MODULE(si, eisa, si_eisa_driver, si_devclass, 0, 0);