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.
21 #include <sys/cdefs.h>
22 __FBSDID("$FreeBSD$");
24 #include <sys/param.h>
25 #include <sys/systm.h>
26 #include <sys/kernel.h>
27 #include <sys/module.h>
29 #include <machine/bus.h>
31 #include <machine/resource.h>
33 #include <dev/si/sireg.h>
34 #include <dev/si/sivar.h>
36 #include <dev/pci/pcireg.h>
37 #include <dev/pci/pcivar.h>
40 si_pci_probe(device_t dev)
42 const char *desc = NULL;
44 switch (pci_get_devid(dev)) {
46 desc = "Specialix SI/XIO PCI host card";
49 if (pci_read_config(dev, SIJETSSIDREG, 4) == 0x020011cb)
50 desc = "Specialix SX PCI host card";
54 device_set_desc(dev, desc);
55 return BUS_PROBE_DEFAULT;
61 si_pci_attach(device_t dev)
69 sc = device_get_softc(dev);
71 switch (pci_get_devid(dev)) {
74 sc->sc_mem_rid = SIPCIBADR;
77 sc->sc_type = SIJETPCI;
78 sc->sc_mem_rid = SIJETBADR;
82 sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
85 if (!sc->sc_mem_res) {
86 device_printf(dev, "couldn't map memory\n");
89 sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res);
90 sc->sc_maddr = rman_get_virtual(sc->sc_mem_res);
93 sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
95 RF_ACTIVE | RF_SHAREABLE);
96 if (!sc->sc_irq_res) {
97 device_printf(dev, "couldn't map interrupt\n");
100 sc->sc_irq = rman_get_start(sc->sc_irq_res);
101 error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY,
102 NULL, si_intr, sc, &ih);
104 device_printf(dev, "could not activate interrupt\n");
108 if (pci_get_devid(dev) == 0x200011cb) {
110 struct resource *plx_res;
114 /* Perform a PLX control register fixup */
116 plx_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
118 if (plx_res == NULL) {
119 device_printf(dev, "couldn't map plx registers\n");
121 addr = rman_get_virtual(plx_res);
122 oldvalue = addr[0x50 / 4];
123 if (oldvalue != 0x18260000) {
124 device_printf(dev, "PLX register 0x50: 0x%08x changed to 0x%08x\n", oldvalue, 0x18260000);
125 addr[0x50 / 4] = 0x18260000;
127 bus_release_resource(dev, SYS_RES_MEMORY, rid, plx_res);
131 error = siattach(dev);
134 return (0); /* success */
139 if (sc->sc_irq_res) {
141 bus_teardown_intr(dev, sc->sc_irq_res, ih);
142 bus_release_resource(dev, SYS_RES_IRQ,
143 sc->sc_irq_rid, sc->sc_irq_res);
146 if (sc->sc_mem_res) {
147 bus_release_resource(dev, SYS_RES_MEMORY,
148 sc->sc_mem_rid, sc->sc_mem_res);
154 static device_method_t si_pci_methods[] = {
155 /* Device interface */
156 DEVMETHOD(device_probe, si_pci_probe),
157 DEVMETHOD(device_attach, si_pci_attach),
162 static driver_t si_pci_driver = {
165 sizeof(struct si_softc),
168 DRIVER_MODULE(si, pci, si_pci_driver, si_devclass, 0, 0);