2009-09-22 17:22:53 +04:00
|
|
|
/* $NetBSD: aha_mca.c,v 1.22 2009/09/22 13:22:53 tsutsui Exp $ */
|
2000-05-11 19:42:00 +04:00
|
|
|
|
|
|
|
/*
|
2002-03-24 21:46:49 +03:00
|
|
|
* Copyright (c) 2000-2002 The NetBSD Foundation, Inc.
|
2000-05-11 19:42:00 +04:00
|
|
|
* Copyright (c) 1996-1999 Scott D. Telford.
|
|
|
|
* Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
|
|
|
|
* Portions:
|
|
|
|
*
|
|
|
|
* 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, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Charles M. Hannum.
|
|
|
|
* 4. 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 ``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 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Originally written by Julian Elischer (julian@tfs.com)
|
|
|
|
* for TRW Financial Systems for use under the MACH(2.5) operating system.
|
|
|
|
*
|
|
|
|
* TRW Financial Systems, in accordance with their agreement with Carnegie
|
|
|
|
* Mellon University, makes this software available to CMU to distribute
|
|
|
|
* or use in any manner that they see fit as long as this message is kept with
|
|
|
|
* the software. For this reason TFS also grants any other persons or
|
|
|
|
* organisations permission to use or modify this software.
|
|
|
|
*
|
|
|
|
* TFS supplies this software to be publicly redistributed
|
|
|
|
* on the understanding that TFS is not responsible for the correct
|
|
|
|
* functioning of this software in any circumstances.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AHA-1640 MCA bus code by Scott Telford
|
|
|
|
*/
|
|
|
|
|
2001-11-13 10:38:28 +03:00
|
|
|
#include <sys/cdefs.h>
|
2009-09-22 17:22:53 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: aha_mca.c,v 1.22 2009/09/22 13:22:53 tsutsui Exp $");
|
2001-11-13 10:38:28 +03:00
|
|
|
|
2000-05-11 19:42:00 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/intr.h>
|
2000-05-11 19:42:00 +04:00
|
|
|
|
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
|
|
|
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/isa/isadmavar.h>
|
|
|
|
|
|
|
|
#include <dev/ic/ahareg.h>
|
|
|
|
#include <dev/ic/ahavar.h>
|
|
|
|
|
|
|
|
#include <dev/mca/mcareg.h>
|
|
|
|
#include <dev/mca/mcavar.h>
|
|
|
|
#include <dev/mca/mcadevs.h>
|
|
|
|
|
|
|
|
#define AHA_ISA_IOSIZE 4
|
|
|
|
|
2009-09-22 17:22:53 +04:00
|
|
|
static int aha_mca_probe(device_t, cfdata_t, void *);
|
|
|
|
static void aha_mca_attach(device_t, device_t, void *);
|
2000-05-11 19:42:00 +04:00
|
|
|
|
2009-09-21 12:12:47 +04:00
|
|
|
CFATTACH_DECL_NEW(aha_mca, sizeof(struct aha_softc),
|
2002-10-02 20:33:28 +04:00
|
|
|
aha_mca_probe, aha_mca_attach, NULL, NULL);
|
2000-05-11 19:42:00 +04:00
|
|
|
|
|
|
|
int
|
2009-09-21 12:12:47 +04:00
|
|
|
aha_mca_probe(device_t parent, cfdata_t match, void *aux)
|
2000-05-11 19:42:00 +04:00
|
|
|
{
|
|
|
|
register struct mca_attach_args *ma = aux;
|
|
|
|
|
2002-03-24 21:46:49 +03:00
|
|
|
if (ma->ma_id == MCA_PRODUCT_AHA1640)
|
|
|
|
return (1);
|
2000-05-11 19:42:00 +04:00
|
|
|
|
2002-03-24 21:46:49 +03:00
|
|
|
return (0);
|
2000-05-11 19:42:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2009-05-12 18:28:22 +04:00
|
|
|
aha_mca_attach(device_t parent, device_t self, void *aux)
|
2000-05-11 19:42:00 +04:00
|
|
|
{
|
|
|
|
struct mca_attach_args *ma = aux;
|
2006-03-29 10:51:47 +04:00
|
|
|
struct aha_softc *sc = device_private(self);
|
2000-05-11 19:42:00 +04:00
|
|
|
bus_space_tag_t iot = ma->ma_iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
struct aha_probe_data apd;
|
|
|
|
mca_chipset_tag_t mc = ma->ma_mc;
|
|
|
|
bus_addr_t iobase;
|
|
|
|
|
2009-09-21 12:12:47 +04:00
|
|
|
sc->sc_dev =self;
|
|
|
|
|
2002-03-24 21:46:49 +03:00
|
|
|
/*
|
|
|
|
* POS registers differ much between 8003 and 8013, so they are
|
|
|
|
* divided to two sections.
|
2005-02-27 03:26:58 +03:00
|
|
|
*
|
2002-03-24 21:46:49 +03:00
|
|
|
* POS register 2: (adf pos0)
|
|
|
|
* 7 6 5 4 3 2 1 0
|
|
|
|
* | 0 0 0 0 0 0 \__ enable: 0=adapter disabled, 1=adapter enabled
|
|
|
|
* \_______________ Adapter BIOS location
|
|
|
|
*
|
|
|
|
* POS register 3: (adf pos1)
|
|
|
|
* 7 6 5 4 3 2 1 0
|
|
|
|
* \_/ \___/ \___/
|
2005-02-27 03:26:58 +03:00
|
|
|
* | | \__ I/O Port Address (upper part)
|
2002-03-24 21:46:49 +03:00
|
|
|
* | |__________ Adapter BIOS location
|
|
|
|
* |_______________ I/O Port Address (lower part)
|
|
|
|
*
|
|
|
|
* POS register 4: (adf pos2)
|
|
|
|
* 7 6 5 4 3 2 1 0
|
|
|
|
* \___/ | | \___/
|
|
|
|
* | | | \__ IRQ: XXX+8
|
|
|
|
* | | |________ Sync xfer started by AHA-1640: 1=YES 2=NO
|
|
|
|
* | |__________ SCSI Parity Checking On/Off
|
|
|
|
* |______________ SCSI Address
|
2005-02-27 03:26:58 +03:00
|
|
|
*
|
2002-03-24 21:46:49 +03:00
|
|
|
* POS register 3: (adf pos3)
|
|
|
|
* 7 6 5 4 3 2 1 0
|
|
|
|
* | \_____/
|
|
|
|
* | \__ Arbitration lvl (DMA channel)
|
|
|
|
* |__________ Fairness On/Off
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-11-22 23:25:58 +03:00
|
|
|
apd.sc_irq = (ma->ma_pos[4] & 0x7) + 8;
|
|
|
|
apd.sc_drq = ma->ma_pos[5] & 0xf;
|
|
|
|
apd.sc_scsi_dev = (ma->ma_pos[4] & 0xe0) >> 5;
|
2001-04-23 10:10:08 +04:00
|
|
|
|
2001-11-22 23:25:58 +03:00
|
|
|
printf(" slot %d irq %d drq %d: Adaptec AHA-1640 SCSI Adapter\n",
|
2001-04-23 10:10:08 +04:00
|
|
|
ma->ma_slot + 1,
|
2001-11-22 23:25:58 +03:00
|
|
|
apd.sc_irq, apd.sc_drq);
|
2000-05-11 19:42:00 +04:00
|
|
|
|
2001-11-22 23:25:58 +03:00
|
|
|
iobase = ((ma->ma_pos[3] & 0x03) << 8) + 0x30 +
|
|
|
|
((ma->ma_pos[3] & 0x40) >> 4);
|
2000-05-11 19:42:00 +04:00
|
|
|
|
|
|
|
if (bus_space_map(iot, iobase, AHA_ISA_IOSIZE, 0, &ioh)) {
|
2009-09-21 12:12:47 +04:00
|
|
|
aprint_error_dev(self, "can't map i/o space\n");
|
2000-05-11 19:42:00 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_iot = iot;
|
|
|
|
sc->sc_ioh = ioh;
|
|
|
|
sc->sc_dmat = ma->ma_dmat;
|
|
|
|
|
2001-11-22 23:25:58 +03:00
|
|
|
/*
|
2002-03-24 21:46:49 +03:00
|
|
|
* AHA1640 is bus-mastering card, does not need any assistance
|
|
|
|
* with DMA transfers by MCA DMA controller.
|
2001-11-22 23:25:58 +03:00
|
|
|
*/
|
2000-05-11 19:42:00 +04:00
|
|
|
|
|
|
|
sc->sc_ih = mca_intr_establish(mc, apd.sc_irq, IPL_BIO, aha_intr, sc);
|
|
|
|
if (sc->sc_ih == NULL) {
|
2009-09-21 12:12:47 +04:00
|
|
|
aprint_error_dev(self, "couldn't establish interrupt\n");
|
2000-05-11 19:42:00 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aha_attach(sc, &apd);
|
|
|
|
}
|