mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
8f214efc9a
ahc_eisa.c: ahc_pci.c: Conform to new aic7xxx IRQ API. Adapt to aic7xxx_freebsd -> aic7xxx_osm changes. aic7770.c: Disable card generated interrupt early in our probe for "extra safety" Commonize some seeprom code with the PCI side of the driver. aic7xxx.c: Correctly initialize a few scratch ram locations during a sequencer restart. This avoids spurious sequencer ram parity errors in some configurations. Include the softc in ahc_update_residual calls. We need it for some diagnostics in this code path. Flag a data overrun on an auto-request sense failure as a CAM_AUTOSENSE_FAIL rather than a CAM_DATA_RUN_ERR. Force a renegotiation after noticing a parity error. This covers targets that lose our negotiation settings but don't bother to give us a unit attention condition. This can happen if a target fails during a reselection of us during a cable pull. Convert some code to using constants. Fix some typos. Correct target mode message loop handling. ahc_clear_msg_state was not clearing the "need to go to message out phase" bit once our loop was over. Simplify some abort handling code. Include tag information in target mode immediate notify events. When shutting down EISA controllers, don't EISA BIOS settings in the high portions of scratch ram. This fixes warm boot issues on some systems. Save a bit of space by only allocating the SCBs that we can use. Avoid some code paths in ahc_abort_scbs() if we are currently acting as a target. Correctly cleanup stranded SCBs in the card's SCB array. These are SCBs who's mapping has already been torn down by code that aborted the SCB by seeing it in another list first. Add a comment about some potential bus reset issues for target mode on Twin (EISA only) controllers. aic7xxx.h: Cleanup the hardware scb definitions a bit. Allocate a ful 256 byte scb mapping index. This simplifies the lookup code since the table covers all possible (and potentially bogus) values. Make AHC_DEBUG work again. aic7xxx.reg: Updates to hardware SCB definition. New definitions for target mode fixes. aic7xxx.seq: In target mode, initialize SAVED_LUN just after we receive the identify message. It may be required in the error recovery path when a normal cdb packet (includes lun) is not sent up to the host for processing. Respond to irregular messages during a selection in target mode. Defer looking for space for a cdb packet until we are about to enter command phase. We want to be able to handle irregular messages even if we would otherwise return QUEUE_FULL or BUSY. Add support for sending Ignore Wide Residue messages as a target. In the disable disconnect case in target mode, set our transfer rate correctly once data are availble. aic7xxx_93cx6.c: aic7xxx_93cx6.h: Add the ability to write and erase the seeprom. aic7xxx_inline.h: Correct Big Endian handling of large cdb sizes (> 12 bytes). Adaptec to changes in the calc_residual API. Correct a target mode bug where we always attempted to service the input queue even if no progress could be made due to lack of ATIOs. aic7xxx_osm.c: Adaptec to new IRQ mapping API. The new API allows the core to only enable our IRQ mapping once it is safe (sufficient initialization) to do so. Slap bootverbose protection around some diagnostics. Only attempt DT phases if we are wide. aic7xxx_osm.h: Enable big endian support. Adjust for IRQ API change. aic7xxx_pci.c: Be more careful about relying on subvendor 9005 information. We now only trust it for HBAs. This should allow the driver to attach to some MBs where the subvendor/device information does not follow the Adaptec spec. Only enable interrupts on the card once we are fully setup. Disable external SCB ram usage on the aic7895. I have not been able to make it 100% reliable. Adjust to seeprom routines being properly prefixed with "ahc". Fix a few bugs in the external SCB ram probing routine. We need to clear any parity errors we've triggered during the probe to avoid future, fatal, interrupts. If we detect an invalid cable combination, pretent there are no cable at all. This will enable all of the terminators which is probably the safest configuration we can "guess". MFC after: 4 days
216 lines
5.6 KiB
C
216 lines
5.6 KiB
C
/*
|
|
* FreeBSD, EISA product support functions
|
|
*
|
|
*
|
|
* Copyright (c) 1994-1998, 2000, 2001 Justin T. Gibbs.
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice immediately at the beginning of the file, without modification,
|
|
* this list of conditions, and the following disclaimer.
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
* derived from this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* $Id$
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
#include <dev/aic7xxx/aic7xxx_osm.h>
|
|
|
|
#include <dev/eisa/eisaconf.h>
|
|
|
|
static int
|
|
aic7770_probe(device_t dev)
|
|
{
|
|
struct aic7770_identity *entry;
|
|
struct resource *regs;
|
|
uint32_t iobase;
|
|
bus_space_handle_t bsh;
|
|
bus_space_tag_t tag;
|
|
u_int irq;
|
|
u_int intdef;
|
|
u_int hcntrl;
|
|
int shared;
|
|
int rid;
|
|
int error;
|
|
|
|
entry = aic7770_find_device(eisa_get_id(dev));
|
|
if (entry == NULL)
|
|
return (ENXIO);
|
|
device_set_desc(dev, entry->name);
|
|
|
|
iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + AHC_EISA_SLOT_OFFSET;
|
|
|
|
eisa_add_iospace(dev, iobase, AHC_EISA_IOSIZE, RESVADDR_NONE);
|
|
|
|
rid = 0;
|
|
regs = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
|
|
0, ~0, 1, RF_ACTIVE);
|
|
if (regs == NULL) {
|
|
device_printf(dev, "Unable to map I/O space?!\n");
|
|
return ENOMEM;
|
|
}
|
|
|
|
tag = rman_get_bustag(regs);
|
|
bsh = rman_get_bushandle(regs);
|
|
error = 0;
|
|
|
|
/* Pause the card preseving the IRQ type */
|
|
hcntrl = bus_space_read_1(tag, bsh, HCNTRL) & IRQMS;
|
|
bus_space_write_1(tag, bsh, HCNTRL, hcntrl | PAUSE);
|
|
while ((bus_space_read_1(tag, bsh, HCNTRL) & PAUSE) == 0)
|
|
;
|
|
|
|
/* Make sure we have a valid interrupt vector */
|
|
intdef = bus_space_read_1(tag, bsh, INTDEF);
|
|
shared = (intdef & EDGE_TRIG) ? EISA_TRIGGER_EDGE : EISA_TRIGGER_LEVEL;
|
|
irq = intdef & VECTOR;
|
|
switch (irq) {
|
|
case 9:
|
|
case 10:
|
|
case 11:
|
|
case 12:
|
|
case 14:
|
|
case 15:
|
|
break;
|
|
default:
|
|
printf("aic7770 at slot %d: illegal irq setting %d\n",
|
|
eisa_get_slot(dev), intdef);
|
|
error = ENXIO;
|
|
}
|
|
|
|
if (error == 0)
|
|
eisa_add_intr(dev, irq, shared);
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, rid, regs);
|
|
return (error);
|
|
}
|
|
|
|
static int
|
|
aic7770_attach(device_t dev)
|
|
{
|
|
struct aic7770_identity *entry;
|
|
struct ahc_softc *ahc;
|
|
char *name;
|
|
int error;
|
|
|
|
entry = aic7770_find_device(eisa_get_id(dev));
|
|
if (entry == NULL)
|
|
return (ENXIO);
|
|
|
|
/*
|
|
* Allocate a softc for this card and
|
|
* set it up for attachment by our
|
|
* common detect routine.
|
|
*/
|
|
name = malloc(strlen(device_get_nameunit(dev)) + 1, M_DEVBUF, M_NOWAIT);
|
|
if (name == NULL)
|
|
return (ENOMEM);
|
|
strcpy(name, device_get_nameunit(dev));
|
|
ahc = ahc_alloc(dev, name);
|
|
if (ahc == NULL)
|
|
return (ENOMEM);
|
|
|
|
ahc_set_unit(ahc, device_get_unit(dev));
|
|
|
|
/* Allocate a dmatag for our SCB DMA maps */
|
|
/* XXX Should be a child of the PCI bus dma tag */
|
|
error = bus_dma_tag_create(/*parent*/NULL, /*alignment*/1,
|
|
/*boundary*/0,
|
|
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
|
|
/*highaddr*/BUS_SPACE_MAXADDR,
|
|
/*filter*/NULL, /*filterarg*/NULL,
|
|
/*maxsize*/MAXBSIZE, /*nsegments*/AHC_NSEG,
|
|
/*maxsegsz*/AHC_MAXTRANSFER_SIZE,
|
|
/*flags*/BUS_DMA_ALLOCNOW,
|
|
&ahc->parent_dmat);
|
|
|
|
if (error != 0) {
|
|
printf("ahc_eisa_attach: Could not allocate DMA tag "
|
|
"- error %d\n", error);
|
|
ahc_free(ahc);
|
|
return (ENOMEM);
|
|
}
|
|
ahc->dev_softc = dev;
|
|
error = aic7770_config(ahc, entry, /*unused ioport arg*/0);
|
|
if (error != 0) {
|
|
ahc_free(ahc);
|
|
return (error);
|
|
}
|
|
|
|
ahc_attach(ahc);
|
|
return (0);
|
|
}
|
|
|
|
int
|
|
aic7770_map_registers(struct ahc_softc *ahc, u_int unused_ioport_arg)
|
|
{
|
|
struct resource *regs;
|
|
int rid;
|
|
|
|
rid = 0;
|
|
regs = bus_alloc_resource(ahc->dev_softc, SYS_RES_IOPORT,
|
|
&rid, 0, ~0, 1, RF_ACTIVE);
|
|
if (regs == NULL) {
|
|
device_printf(ahc->dev_softc, "Unable to map I/O space?!\n");
|
|
return ENOMEM;
|
|
}
|
|
ahc->platform_data->regs_res_type = SYS_RES_IOPORT;
|
|
ahc->platform_data->regs_res_id = rid,
|
|
ahc->platform_data->regs = regs;
|
|
ahc->tag = rman_get_bustag(regs);
|
|
ahc->bsh = rman_get_bushandle(regs);
|
|
return (0);
|
|
}
|
|
|
|
int
|
|
aic7770_map_int(struct ahc_softc *ahc, int irq)
|
|
{
|
|
int zero;
|
|
|
|
zero = 0;
|
|
ahc->platform_data->irq =
|
|
bus_alloc_resource(ahc->dev_softc, SYS_RES_IRQ, &zero,
|
|
0, ~0, 1, RF_ACTIVE);
|
|
if (ahc->platform_data->irq == NULL)
|
|
return (ENOMEM);
|
|
ahc->platform_data->irq_res_type = SYS_RES_IRQ;
|
|
return (ahc_map_int(ahc));
|
|
}
|
|
|
|
static device_method_t ahc_eisa_device_methods[] = {
|
|
/* Device interface */
|
|
DEVMETHOD(device_probe, aic7770_probe),
|
|
DEVMETHOD(device_attach, aic7770_attach),
|
|
DEVMETHOD(device_detach, ahc_detach),
|
|
{ 0, 0 }
|
|
};
|
|
|
|
static driver_t ahc_eisa_driver = {
|
|
"ahc",
|
|
ahc_eisa_device_methods,
|
|
sizeof(struct ahc_softc)
|
|
};
|
|
|
|
static devclass_t ahc_devclass;
|
|
|
|
DRIVER_MODULE(ahc, eisa, ahc_eisa_driver, ahc_devclass, 0, 0);
|
|
MODULE_DEPEND(ahc_eisa, ahc, 1, 1, 1);
|
|
MODULE_VERSION(ahc_eisa, 1);
|