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.
20 * $FreeBSD: src/sys/dev/si/si_pci.c,v 1.2 2000/01/24 08:11:10 peter Exp $
21 * $DragonFly: src/sys/dev/serial/si/si_pci.c,v 1.3 2003/08/07 21:17:11 dillon Exp $
24 #include <sys/param.h>
25 #include <sys/systm.h>
26 #include <sys/kernel.h>
28 #include <machine/bus.h>
30 #include <machine/resource.h>
35 #include <bus/pci/pcivar.h>
38 si_pci_probe(device_t dev)
40 const char *desc = NULL;
42 switch (pci_get_devid(dev)) {
44 desc = "Specialix SI/XIO PCI host card";
47 if (pci_read_config(dev, SIJETSSIDREG, 4) == 0x020011cb)
48 desc = "Specialix SX PCI host card";
52 device_set_desc(dev, desc);
59 si_pci_attach(device_t dev)
67 sc = device_get_softc(dev);
69 switch (pci_get_devid(dev)) {
72 sc->sc_mem_rid = SIPCIBADR;
75 sc->sc_type = SIJETPCI;
76 sc->sc_mem_rid = SIJETBADR;
80 sc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY,
83 if (!sc->sc_mem_res) {
84 device_printf(dev, "couldn't map memory\n");
87 sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res);
88 sc->sc_maddr = rman_get_virtual(sc->sc_mem_res);
91 sc->sc_irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->sc_irq_rid,
92 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
93 if (!sc->sc_irq_res) {
94 device_printf(dev, "couldn't map interrupt\n");
97 sc->sc_irq = rman_get_start(sc->sc_irq_res);
98 error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY,
101 device_printf(dev, "could not activate interrupt\n");
105 error = siattach(dev);
108 return (0); /* success */
113 if (sc->sc_irq_res) {
115 bus_teardown_intr(dev, sc->sc_irq_res, ih);
116 bus_release_resource(dev, SYS_RES_IRQ,
117 sc->sc_irq_rid, sc->sc_irq_res);
120 if (sc->sc_mem_res) {
121 bus_release_resource(dev, SYS_RES_MEMORY,
122 sc->sc_mem_rid, sc->sc_mem_res);
128 static device_method_t si_pci_methods[] = {
129 /* Device interface */
130 DEVMETHOD(device_probe, si_pci_probe),
131 DEVMETHOD(device_attach, si_pci_attach),
136 static driver_t si_pci_driver = {
139 sizeof(struct si_softc),
142 DRIVER_MODULE(si, pci, si_pci_driver, si_devclass, 0, 0);