2 * FreeBSD, EISA product support functions
5 * Copyright (c) 1994-1998, 2000, 2001 Justin T. Gibbs.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice immediately at the beginning of the file, without modification,
13 * this list of conditions, and the following disclaimer.
14 * 2. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_eisa.c#11 $
31 * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15.2.11 2003/06/10 03:26:07 gibbs Exp $
34 #include <dev/aic7xxx/aic7xxx_osm.h>
36 #include <dev/eisa/eisaconf.h>
39 aic7770_probe(device_t dev)
41 struct aic7770_identity *entry;
42 struct resource *regs;
44 bus_space_handle_t bsh;
53 entry = aic7770_find_device(eisa_get_id(dev));
56 device_set_desc(dev, entry->name);
58 iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + AHC_EISA_SLOT_OFFSET;
60 eisa_add_iospace(dev, iobase, AHC_EISA_IOSIZE, RESVADDR_NONE);
63 regs = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
66 device_printf(dev, "Unable to map I/O space?!\n");
70 tag = rman_get_bustag(regs);
71 bsh = rman_get_bushandle(regs);
74 /* Pause the card preseving the IRQ type */
75 hcntrl = bus_space_read_1(tag, bsh, HCNTRL) & IRQMS;
76 bus_space_write_1(tag, bsh, HCNTRL, hcntrl | PAUSE);
77 while ((bus_space_read_1(tag, bsh, HCNTRL) & PAUSE) == 0)
80 /* Make sure we have a valid interrupt vector */
81 intdef = bus_space_read_1(tag, bsh, INTDEF);
82 shared = (intdef & EDGE_TRIG) ? EISA_TRIGGER_EDGE : EISA_TRIGGER_LEVEL;
83 irq = intdef & VECTOR;
93 printf("aic7770 at slot %d: illegal irq setting %d\n",
94 eisa_get_slot(dev), intdef);
99 eisa_add_intr(dev, irq, shared);
101 bus_release_resource(dev, SYS_RES_IOPORT, rid, regs);
106 aic7770_attach(device_t dev)
108 struct aic7770_identity *entry;
109 struct ahc_softc *ahc;
113 entry = aic7770_find_device(eisa_get_id(dev));
118 * Allocate a softc for this card and
119 * set it up for attachment by our
120 * common detect routine.
122 name = malloc(strlen(device_get_nameunit(dev)) + 1, M_DEVBUF, M_NOWAIT);
125 strcpy(name, device_get_nameunit(dev));
126 ahc = ahc_alloc(dev, name);
130 ahc_set_unit(ahc, device_get_unit(dev));
132 /* Allocate a dmatag for our SCB DMA maps */
133 /* XXX Should be a child of the PCI bus dma tag */
134 error = bus_dma_tag_create(/*parent*/NULL, /*alignment*/1,
136 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
137 /*highaddr*/BUS_SPACE_MAXADDR,
138 /*filter*/NULL, /*filterarg*/NULL,
139 /*maxsize*/BUS_SPACE_MAXSIZE_32BIT,
140 /*nsegments*/AHC_NSEG,
141 /*maxsegsz*/AHC_MAXTRANSFER_SIZE,
146 printf("ahc_eisa_attach: Could not allocate DMA tag "
147 "- error %d\n", error);
151 ahc->dev_softc = dev;
152 error = aic7770_config(ahc, entry, /*unused ioport arg*/0);
163 aic7770_map_registers(struct ahc_softc *ahc, u_int unused_ioport_arg)
165 struct resource *regs;
169 regs = bus_alloc_resource(ahc->dev_softc, SYS_RES_IOPORT,
170 &rid, 0, ~0, 1, RF_ACTIVE);
172 device_printf(ahc->dev_softc, "Unable to map I/O space?!\n");
175 ahc->platform_data->regs_res_type = SYS_RES_IOPORT;
176 ahc->platform_data->regs_res_id = rid,
177 ahc->platform_data->regs = regs;
178 ahc->tag = rman_get_bustag(regs);
179 ahc->bsh = rman_get_bushandle(regs);
184 aic7770_map_int(struct ahc_softc *ahc, int irq)
189 ahc->platform_data->irq =
190 bus_alloc_resource(ahc->dev_softc, SYS_RES_IRQ, &zero,
191 0, ~0, 1, RF_ACTIVE);
192 if (ahc->platform_data->irq == NULL)
194 ahc->platform_data->irq_res_type = SYS_RES_IRQ;
195 return (ahc_map_int(ahc));
198 static device_method_t ahc_eisa_device_methods[] = {
199 /* Device interface */
200 DEVMETHOD(device_probe, aic7770_probe),
201 DEVMETHOD(device_attach, aic7770_attach),
202 DEVMETHOD(device_detach, ahc_detach),
206 static driver_t ahc_eisa_driver = {
208 ahc_eisa_device_methods,
209 sizeof(struct ahc_softc)
212 DRIVER_MODULE(ahc_eisa, eisa, ahc_eisa_driver, ahc_devclass, 0, 0);
213 MODULE_DEPEND(ahc_eisa, ahc, 1, 1, 1);
214 MODULE_VERSION(ahc_eisa, 1);