1999-06-24 03:33:30 +00:00
|
|
|
/*-
|
2017-11-27 14:52:40 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2000-03-08 16:16:31 +00:00
|
|
|
* Copyright (c) 1999,2000 Jonathan Lemon
|
1999-06-24 03:33:30 +00:00
|
|
|
* 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, 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1999-06-24 03:33:30 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2004-05-30 20:08:47 +00:00
|
|
|
#include <sys/module.h>
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1999-06-24 03:33:30 +00:00
|
|
|
#include <sys/bus.h>
|
2003-02-23 18:45:50 +00:00
|
|
|
#include <sys/conf.h>
|
Extract eventfilter declarations to sys/_eventfilter.h
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.
EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).
As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions. The remainder of the patch addresses
adding appropriate includes to fix those files.
LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).
No functional change (intended). Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped.
2019-05-20 00:38:23 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
1999-06-24 03:33:30 +00:00
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
2003-08-22 06:00:27 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2003-04-01 15:06:26 +00:00
|
|
|
#include <geom/geom_disk.h>
|
|
|
|
|
1999-06-24 03:33:30 +00:00
|
|
|
#include <dev/ida/idavar.h>
|
2000-03-08 16:16:31 +00:00
|
|
|
#include <dev/ida/idareg.h>
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2004-01-13 11:28:21 +00:00
|
|
|
#define IDA_PCI_MAX_DMA_ADDR 0xFFFFFFFF
|
|
|
|
#define IDA_PCI_MAX_DMA_COUNT 0xFFFFFFFF
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2004-01-13 11:28:21 +00:00
|
|
|
#define IDA_PCI_MEMADDR PCIR_BAR(1) /* Mem I/O Address */
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2004-01-13 11:28:21 +00:00
|
|
|
#define IDA_DEVICEID_SMART 0xAE100E11
|
|
|
|
#define IDA_DEVICEID_DEC_SMART 0x00461011
|
|
|
|
#define IDA_DEVICEID_NCR_53C1510 0x00101000
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2000-03-08 16:16:31 +00:00
|
|
|
static int
|
|
|
|
ida_v3_fifo_full(struct ida_softc *ida)
|
|
|
|
{
|
|
|
|
return (ida_inl(ida, R_CMD_FIFO) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ida_v3_submit(struct ida_softc *ida, struct ida_qcb *qcb)
|
|
|
|
{
|
|
|
|
ida_outl(ida, R_CMD_FIFO, qcb->hwqcb_busaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bus_addr_t
|
|
|
|
ida_v3_done(struct ida_softc *ida)
|
|
|
|
{
|
2004-12-14 17:41:51 +00:00
|
|
|
bus_addr_t completed;
|
|
|
|
|
|
|
|
completed = ida_inl(ida, R_DONE_FIFO);
|
|
|
|
if (completed == -1) {
|
|
|
|
return (0); /* fifo is empty */
|
|
|
|
}
|
|
|
|
return (completed);
|
2000-03-08 16:16:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ida_v3_int_pending(struct ida_softc *ida)
|
|
|
|
{
|
|
|
|
return (ida_inl(ida, R_INT_PENDING));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ida_v3_int_enable(struct ida_softc *ida, int enable)
|
|
|
|
{
|
2001-02-26 22:25:30 +00:00
|
|
|
if (enable)
|
|
|
|
ida->flags |= IDA_INTERRUPTS;
|
|
|
|
else
|
|
|
|
ida->flags &= ~IDA_INTERRUPTS;
|
2000-03-08 16:16:31 +00:00
|
|
|
ida_outl(ida, R_INT_MASK, enable ? INT_ENABLE : INT_DISABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ida_v4_fifo_full(struct ida_softc *ida)
|
|
|
|
{
|
|
|
|
return (ida_inl(ida, R_42XX_REQUEST) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ida_v4_submit(struct ida_softc *ida, struct ida_qcb *qcb)
|
|
|
|
{
|
|
|
|
ida_outl(ida, R_42XX_REQUEST, qcb->hwqcb_busaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bus_addr_t
|
|
|
|
ida_v4_done(struct ida_softc *ida)
|
|
|
|
{
|
|
|
|
bus_addr_t completed;
|
|
|
|
|
|
|
|
completed = ida_inl(ida, R_42XX_REPLY);
|
|
|
|
if (completed == -1)
|
|
|
|
return (0); /* fifo is empty */
|
|
|
|
ida_outl(ida, R_42XX_REPLY, 0); /* confirm read */
|
|
|
|
return (completed);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ida_v4_int_pending(struct ida_softc *ida)
|
|
|
|
{
|
|
|
|
return (ida_inl(ida, R_42XX_STATUS) & STATUS_42XX_INT_PENDING);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ida_v4_int_enable(struct ida_softc *ida, int enable)
|
|
|
|
{
|
2001-02-26 22:25:30 +00:00
|
|
|
if (enable)
|
|
|
|
ida->flags |= IDA_INTERRUPTS;
|
|
|
|
else
|
|
|
|
ida->flags &= ~IDA_INTERRUPTS;
|
2000-03-08 16:16:31 +00:00
|
|
|
ida_outl(ida, R_42XX_INT_MASK,
|
|
|
|
enable ? INT_ENABLE_42XX : INT_DISABLE_42XX);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ida_access ida_v3_access = {
|
|
|
|
ida_v3_fifo_full,
|
|
|
|
ida_v3_submit,
|
|
|
|
ida_v3_done,
|
|
|
|
ida_v3_int_pending,
|
|
|
|
ida_v3_int_enable,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ida_access ida_v4_access = {
|
|
|
|
ida_v4_fifo_full,
|
|
|
|
ida_v4_submit,
|
|
|
|
ida_v4_done,
|
|
|
|
ida_v4_int_pending,
|
|
|
|
ida_v4_int_enable,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ida_board board_id[] = {
|
2001-01-09 14:49:41 +00:00
|
|
|
{ 0x40300E11, "Compaq SMART-2/P array controller",
|
|
|
|
&ida_v3_access, 0 },
|
|
|
|
{ 0x40310E11, "Compaq SMART-2SL array controller",
|
|
|
|
&ida_v3_access, 0 },
|
|
|
|
{ 0x40320E11, "Compaq Smart Array 3200 controller",
|
|
|
|
&ida_v3_access, 0 },
|
|
|
|
{ 0x40330E11, "Compaq Smart Array 3100ES controller",
|
|
|
|
&ida_v3_access, 0 },
|
|
|
|
{ 0x40340E11, "Compaq Smart Array 221 controller",
|
|
|
|
&ida_v3_access, 0 },
|
|
|
|
|
|
|
|
{ 0x40400E11, "Compaq Integrated Array controller",
|
|
|
|
&ida_v4_access, IDA_FIRMWARE },
|
|
|
|
{ 0x40480E11, "Compaq RAID LC2 controller",
|
|
|
|
&ida_v4_access, IDA_FIRMWARE },
|
|
|
|
{ 0x40500E11, "Compaq Smart Array 4200 controller",
|
|
|
|
&ida_v4_access, 0 },
|
|
|
|
{ 0x40510E11, "Compaq Smart Array 4250ES controller",
|
|
|
|
&ida_v4_access, 0 },
|
|
|
|
{ 0x40580E11, "Compaq Smart Array 431 controller",
|
|
|
|
&ida_v4_access, 0 },
|
|
|
|
|
|
|
|
{ 0, "", 0, 0 },
|
1999-06-24 03:33:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int ida_pci_probe(device_t dev);
|
|
|
|
static int ida_pci_attach(device_t dev);
|
|
|
|
|
|
|
|
static device_method_t ida_pci_methods[] = {
|
|
|
|
DEVMETHOD(device_probe, ida_pci_probe),
|
|
|
|
DEVMETHOD(device_attach, ida_pci_attach),
|
2000-03-08 16:16:31 +00:00
|
|
|
DEVMETHOD(device_detach, ida_detach),
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2011-11-22 21:28:20 +00:00
|
|
|
DEVMETHOD_END
|
1999-06-24 03:33:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ida_pci_driver = {
|
|
|
|
"ida",
|
|
|
|
ida_pci_methods,
|
|
|
|
sizeof(struct ida_softc)
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t ida_devclass;
|
|
|
|
|
2000-03-08 16:16:31 +00:00
|
|
|
static struct ida_board *
|
2000-10-13 23:34:47 +00:00
|
|
|
ida_pci_match(device_t dev)
|
2000-03-08 16:16:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
2000-10-13 23:34:47 +00:00
|
|
|
u_int32_t id, sub_id;
|
|
|
|
|
|
|
|
id = pci_get_devid(dev);
|
|
|
|
sub_id = pci_get_subdevice(dev) << 16 | pci_get_subvendor(dev);
|
2000-03-08 16:16:31 +00:00
|
|
|
|
2000-10-13 23:34:47 +00:00
|
|
|
if (id == IDA_DEVICEID_SMART ||
|
|
|
|
id == IDA_DEVICEID_DEC_SMART ||
|
|
|
|
id == IDA_DEVICEID_NCR_53C1510) {
|
|
|
|
for (i = 0; board_id[i].board; i++)
|
|
|
|
if (board_id[i].board == sub_id)
|
|
|
|
return (&board_id[i]);
|
|
|
|
}
|
2000-03-08 16:16:31 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
1999-06-24 03:33:30 +00:00
|
|
|
static int
|
|
|
|
ida_pci_probe(device_t dev)
|
|
|
|
{
|
2000-10-13 23:34:47 +00:00
|
|
|
struct ida_board *board = ida_pci_match(dev);
|
|
|
|
|
2000-05-04 20:23:56 +00:00
|
|
|
if (board != NULL) {
|
|
|
|
device_set_desc(dev, board->desc);
|
2005-03-05 18:17:35 +00:00
|
|
|
return (BUS_PROBE_DEFAULT);
|
1999-06-24 03:33:30 +00:00
|
|
|
}
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ida_pci_attach(device_t dev)
|
|
|
|
{
|
2000-10-13 23:34:47 +00:00
|
|
|
struct ida_board *board = ida_pci_match(dev);
|
2000-12-01 15:26:11 +00:00
|
|
|
u_int32_t id = pci_get_devid(dev);
|
1999-06-24 03:33:30 +00:00
|
|
|
struct ida_softc *ida;
|
|
|
|
int error, rid;
|
|
|
|
|
|
|
|
ida = (struct ida_softc *)device_get_softc(dev);
|
|
|
|
ida->dev = dev;
|
2000-03-08 16:16:31 +00:00
|
|
|
ida->cmd = *board->accessor;
|
2001-01-09 14:49:41 +00:00
|
|
|
ida->flags = board->flags;
|
2012-08-27 17:24:07 +00:00
|
|
|
mtx_init(&ida->lock, "ida", NULL, MTX_DEF);
|
|
|
|
callout_init_mtx(&ida->ch, &ida->lock, 0);
|
2000-03-08 16:16:31 +00:00
|
|
|
|
1999-06-24 03:33:30 +00:00
|
|
|
ida->regs_res_type = SYS_RES_MEMORY;
|
|
|
|
ida->regs_res_id = IDA_PCI_MEMADDR;
|
2000-12-01 15:26:11 +00:00
|
|
|
if (id == IDA_DEVICEID_DEC_SMART)
|
2003-09-02 17:30:40 +00:00
|
|
|
ida->regs_res_id = PCIR_BAR(0);
|
2000-07-27 22:24:44 +00:00
|
|
|
|
2004-03-17 17:50:55 +00:00
|
|
|
ida->regs = bus_alloc_resource_any(dev, ida->regs_res_type,
|
|
|
|
&ida->regs_res_id, RF_ACTIVE);
|
1999-06-24 03:33:30 +00:00
|
|
|
if (ida->regs == NULL) {
|
2000-07-27 22:24:44 +00:00
|
|
|
device_printf(dev, "can't allocate memory resources\n");
|
1999-06-24 03:33:30 +00:00
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
|
2004-12-14 17:23:01 +00:00
|
|
|
error = bus_dma_tag_create(
|
2012-03-12 08:03:51 +00:00
|
|
|
/* parent */ bus_get_dma_tag(dev),
|
2004-12-14 17:23:01 +00:00
|
|
|
/* alignment */ 1,
|
|
|
|
/* boundary */ 0,
|
|
|
|
/* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
|
|
|
|
/* highaddr */ BUS_SPACE_MAXADDR,
|
|
|
|
/* filter */ NULL,
|
|
|
|
/* filterarg */ NULL,
|
2015-03-22 16:10:28 +00:00
|
|
|
/* maxsize */ BUS_SPACE_MAXSIZE_32BIT,
|
|
|
|
/* nsegments */ BUS_SPACE_UNRESTRICTED,
|
2004-12-14 17:23:01 +00:00
|
|
|
/* maxsegsize */ BUS_SPACE_MAXSIZE_32BIT,
|
|
|
|
/* flags */ BUS_DMA_ALLOCNOW,
|
|
|
|
/* lockfunc */ NULL,
|
|
|
|
/* lockarg */ NULL,
|
|
|
|
&ida->parent_dmat);
|
1999-06-24 03:33:30 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(dev, "can't allocate DMA tag\n");
|
|
|
|
ida_free(ida);
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
rid = 0;
|
2005-04-13 05:06:57 +00:00
|
|
|
ida->irq_res_type = SYS_RES_IRQ;
|
2004-03-17 17:50:55 +00:00
|
|
|
ida->irq = bus_alloc_resource_any(dev, ida->irq_res_type, &rid,
|
|
|
|
RF_ACTIVE | RF_SHAREABLE);
|
2005-04-13 05:06:57 +00:00
|
|
|
if (ida->irq == NULL) {
|
|
|
|
ida_free(ida);
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
2012-08-27 17:24:07 +00:00
|
|
|
error = bus_setup_intr(dev, ida->irq, INTR_TYPE_BIO | INTR_ENTROPY | INTR_MPSAFE,
|
2007-02-23 12:19:07 +00:00
|
|
|
NULL, ida_intr, ida, &ida->ih);
|
1999-06-24 03:33:30 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "can't setup interrupt\n");
|
|
|
|
ida_free(ida);
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
|
2016-05-11 17:38:09 +00:00
|
|
|
error = ida_setup(ida);
|
1999-06-24 03:33:30 +00:00
|
|
|
if (error) {
|
2005-04-13 05:06:57 +00:00
|
|
|
ida_free(ida);
|
|
|
|
return (error);
|
|
|
|
}
|
1999-06-24 03:33:30 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
DRIVER_MODULE(ida, pci, ida_pci_driver, ida_devclass, 0, 0);
|
Add PNP info to PCI attachments of cbb, cxgb, ida, iwn, ixl, ixlv,
mfi, mps, mpr, mvs, my, oce, pcn, ral, rl. This only labels existing
pci device tables, and has no probe / attach code changes.
Reviewed by: imp, chuck
Submitted by: Lakhan Shiva Kamireddy <lakhanshiva@gmail.com>
Sponsored by: Google, Inc. (GSoC 2018)
Approved by: re (glen)
2018-09-26 17:12:30 +00:00
|
|
|
MODULE_PNP_INFO("W32:vendor/device;D:#", pci, ida, board_id,
|
|
|
|
nitems(board_id) - 1);
|