Home | History | Annotate | Line # | Download | only in pci
aac_pci.c revision 1.39
      1  1.39       uwe /*	$NetBSD: aac_pci.c,v 1.39 2018/10/15 09:27:30 uwe Exp $	*/
      2   1.1        ad 
      3   1.1        ad /*-
      4   1.1        ad  * Copyright (c) 2002 The NetBSD Foundation, Inc.
      5   1.1        ad  * All rights reserved.
      6   1.1        ad  *
      7   1.1        ad  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1        ad  * by Andrew Doran.
      9   1.1        ad  *
     10   1.1        ad  * Redistribution and use in source and binary forms, with or without
     11   1.1        ad  * modification, are permitted provided that the following conditions
     12   1.1        ad  * are met:
     13   1.1        ad  * 1. Redistributions of source code must retain the above copyright
     14   1.1        ad  *    notice, this list of conditions and the following disclaimer.
     15   1.1        ad  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1        ad  *    notice, this list of conditions and the following disclaimer in the
     17   1.1        ad  *    documentation and/or other materials provided with the distribution.
     18   1.1        ad  *
     19   1.1        ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1        ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1        ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.1        ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.1        ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1        ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1        ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1        ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1        ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1        ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1        ad  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1        ad  */
     31   1.1        ad 
     32   1.1        ad /*-
     33   1.1        ad  * Copyright (c) 2000 Michael Smith
     34   1.1        ad  * Copyright (c) 2000 BSDi
     35   1.1        ad  * Copyright (c) 2000 Niklas Hallqvist
     36   1.1        ad  * All rights reserved.
     37   1.1        ad  *
     38   1.1        ad  * Redistribution and use in source and binary forms, with or without
     39   1.1        ad  * modification, are permitted provided that the following conditions
     40   1.1        ad  * are met:
     41   1.1        ad  * 1. Redistributions of source code must retain the above copyright
     42   1.1        ad  *    notice, this list of conditions and the following disclaimer.
     43   1.1        ad  * 2. Redistributions in binary form must reproduce the above copyright
     44   1.1        ad  *    notice, this list of conditions and the following disclaimer in the
     45   1.1        ad  *    documentation and/or other materials provided with the distribution.
     46   1.1        ad  *
     47   1.1        ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     48   1.1        ad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     49   1.1        ad  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     50   1.1        ad  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     51   1.1        ad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     52   1.1        ad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     53   1.1        ad  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     54   1.1        ad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     55   1.1        ad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     56   1.1        ad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     57   1.1        ad  * SUCH DAMAGE.
     58   1.1        ad  *
     59   1.1        ad  * from FreeBSD: aac_pci.c,v 1.1 2000/09/13 03:20:34 msmith Exp
     60   1.1        ad  * via OpenBSD: aac_pci.c,v 1.7 2002/03/14 01:26:58 millert Exp
     61   1.1        ad  */
     62   1.1        ad 
     63   1.1        ad /*
     64   1.1        ad  * PCI front-end for the `aac' driver.
     65   1.1        ad  */
     66   1.1        ad 
     67   1.1        ad #include <sys/cdefs.h>
     68  1.39       uwe __KERNEL_RCSID(0, "$NetBSD: aac_pci.c,v 1.39 2018/10/15 09:27:30 uwe Exp $");
     69   1.1        ad 
     70   1.1        ad #include <sys/param.h>
     71   1.1        ad #include <sys/systm.h>
     72   1.1        ad #include <sys/device.h>
     73   1.1        ad #include <sys/kernel.h>
     74   1.1        ad #include <sys/malloc.h>
     75   1.1        ad #include <sys/queue.h>
     76   1.1        ad 
     77  1.22        ad #include <sys/bus.h>
     78   1.1        ad #include <machine/endian.h>
     79  1.22        ad #include <sys/intr.h>
     80   1.1        ad 
     81   1.1        ad #include <dev/pci/pcidevs.h>
     82   1.1        ad #include <dev/pci/pcireg.h>
     83   1.1        ad #include <dev/pci/pcivar.h>
     84   1.1        ad 
     85   1.1        ad #include <dev/ic/aacreg.h>
     86   1.1        ad #include <dev/ic/aacvar.h>
     87   1.1        ad 
     88  1.21    briggs struct aac_pci_softc {
     89  1.21    briggs 	struct aac_softc	sc_aac;
     90  1.21    briggs 	pci_chipset_tag_t	sc_pc;
     91  1.21    briggs 	pci_intr_handle_t	sc_ih;
     92  1.21    briggs };
     93  1.21    briggs 
     94  1.11     perry /* i960Rx interface */
     95  1.15   thorpej static int	aac_rx_get_fwstatus(struct aac_softc *);
     96  1.15   thorpej static void	aac_rx_qnotify(struct aac_softc *, int);
     97  1.15   thorpej static int	aac_rx_get_istatus(struct aac_softc *);
     98  1.15   thorpej static void	aac_rx_clear_istatus(struct aac_softc *, int);
     99  1.15   thorpej static void	aac_rx_set_mailbox(struct aac_softc *, u_int32_t, u_int32_t,
    100   1.1        ad 			   u_int32_t, u_int32_t, u_int32_t);
    101  1.15   thorpej static uint32_t aac_rx_get_mailbox(struct aac_softc *, int);
    102  1.15   thorpej static void	aac_rx_set_interrupts(struct aac_softc *, int);
    103  1.21    briggs static int	aac_rx_send_command(struct aac_softc *, struct aac_ccb *);
    104  1.21    briggs static int	aac_rx_get_outb_queue(struct aac_softc *);
    105  1.21    briggs static void	aac_rx_set_outb_queue(struct aac_softc *, int);
    106   1.1        ad 
    107   1.1        ad /* StrongARM interface */
    108  1.15   thorpej static int	aac_sa_get_fwstatus(struct aac_softc *);
    109  1.15   thorpej static void	aac_sa_qnotify(struct aac_softc *, int);
    110  1.15   thorpej static int	aac_sa_get_istatus(struct aac_softc *);
    111  1.15   thorpej static void	aac_sa_clear_istatus(struct aac_softc *, int);
    112  1.15   thorpej static void	aac_sa_set_mailbox(struct aac_softc *, u_int32_t, u_int32_t,
    113   1.1        ad 			   u_int32_t, u_int32_t, u_int32_t);
    114  1.15   thorpej static uint32_t aac_sa_get_mailbox(struct aac_softc *, int);
    115  1.15   thorpej static void	aac_sa_set_interrupts(struct aac_softc *, int);
    116   1.1        ad 
    117  1.21    briggs /* Rocket/MIPS interface */
    118  1.21    briggs static int	aac_rkt_get_fwstatus(struct aac_softc *);
    119  1.21    briggs static void	aac_rkt_qnotify(struct aac_softc *, int);
    120  1.21    briggs static int	aac_rkt_get_istatus(struct aac_softc *);
    121  1.21    briggs static void	aac_rkt_clear_istatus(struct aac_softc *, int);
    122  1.21    briggs static void	aac_rkt_set_mailbox(struct aac_softc *, u_int32_t, u_int32_t,
    123  1.21    briggs 			   u_int32_t, u_int32_t, u_int32_t);
    124  1.21    briggs static uint32_t aac_rkt_get_mailbox(struct aac_softc *, int);
    125  1.21    briggs static void	aac_rkt_set_interrupts(struct aac_softc *, int);
    126  1.21    briggs static int	aac_rkt_send_command(struct aac_softc *, struct aac_ccb *);
    127  1.21    briggs static int	aac_rkt_get_outb_queue(struct aac_softc *);
    128  1.21    briggs static void	aac_rkt_set_outb_queue(struct aac_softc *, int);
    129  1.21    briggs 
    130  1.15   thorpej static const struct aac_interface aac_rx_interface = {
    131   1.1        ad 	aac_rx_get_fwstatus,
    132   1.1        ad 	aac_rx_qnotify,
    133   1.1        ad 	aac_rx_get_istatus,
    134   1.1        ad 	aac_rx_clear_istatus,
    135   1.1        ad 	aac_rx_set_mailbox,
    136  1.12    briggs 	aac_rx_get_mailbox,
    137  1.21    briggs 	aac_rx_set_interrupts,
    138  1.21    briggs 	aac_rx_send_command,
    139  1.21    briggs 	aac_rx_get_outb_queue,
    140  1.21    briggs 	aac_rx_set_outb_queue
    141   1.1        ad };
    142   1.1        ad 
    143  1.15   thorpej static const struct aac_interface aac_sa_interface = {
    144   1.1        ad 	aac_sa_get_fwstatus,
    145   1.1        ad 	aac_sa_qnotify,
    146   1.1        ad 	aac_sa_get_istatus,
    147   1.1        ad 	aac_sa_clear_istatus,
    148   1.1        ad 	aac_sa_set_mailbox,
    149  1.12    briggs 	aac_sa_get_mailbox,
    150  1.21    briggs 	aac_sa_set_interrupts,
    151  1.21    briggs 	NULL, NULL, NULL
    152  1.21    briggs };
    153  1.21    briggs 
    154  1.21    briggs static const struct aac_interface aac_rkt_interface = {
    155  1.21    briggs 	aac_rkt_get_fwstatus,
    156  1.21    briggs 	aac_rkt_qnotify,
    157  1.21    briggs 	aac_rkt_get_istatus,
    158  1.21    briggs 	aac_rkt_clear_istatus,
    159  1.21    briggs 	aac_rkt_set_mailbox,
    160  1.21    briggs 	aac_rkt_get_mailbox,
    161  1.21    briggs 	aac_rkt_set_interrupts,
    162  1.21    briggs 	aac_rkt_send_command,
    163  1.21    briggs 	aac_rkt_get_outb_queue,
    164  1.21    briggs 	aac_rkt_set_outb_queue
    165   1.1        ad };
    166   1.1        ad 
    167  1.17  christos static struct aac_ident {
    168   1.1        ad 	u_short	vendor;
    169   1.1        ad 	u_short	device;
    170   1.1        ad 	u_short	subvendor;
    171   1.1        ad 	u_short	subdevice;
    172   1.1        ad 	u_short	hwif;
    173   1.1        ad 	u_short	quirks;
    174   1.1        ad 	const char	*prodstr;
    175  1.17  christos } const aac_ident[] = {
    176   1.1        ad 	{
    177   1.1        ad 		PCI_VENDOR_DELL,
    178   1.1        ad 		PCI_PRODUCT_DELL_PERC_2SI,
    179   1.1        ad 		PCI_VENDOR_DELL,
    180   1.1        ad 		PCI_PRODUCT_DELL_PERC_2SI,
    181   1.1        ad 		AAC_HWIF_I960RX,
    182   1.1        ad 		0,
    183   1.1        ad 		"Dell PERC 2/Si"
    184   1.1        ad 	},
    185   1.1        ad 	{
    186   1.1        ad 		PCI_VENDOR_DELL,
    187   1.1        ad 		PCI_PRODUCT_DELL_PERC_3DI,
    188   1.1        ad 		PCI_VENDOR_DELL,
    189   1.1        ad 		PCI_PRODUCT_DELL_PERC_3DI,
    190   1.1        ad 		AAC_HWIF_I960RX,
    191   1.1        ad 		0,
    192   1.1        ad 		"Dell PERC 3/Di"
    193   1.1        ad 	},
    194   1.1        ad 	{
    195   1.1        ad 		PCI_VENDOR_DELL,
    196   1.1        ad 		PCI_PRODUCT_DELL_PERC_3DI,
    197   1.1        ad 		PCI_VENDOR_DELL,
    198   1.1        ad 		PCI_PRODUCT_DELL_PERC_3DI_SUB2,
    199   1.1        ad 		AAC_HWIF_I960RX,
    200   1.1        ad 		0,
    201   1.1        ad 		"Dell PERC 3/Di"
    202   1.1        ad 	},
    203   1.1        ad 	{
    204   1.1        ad 		PCI_VENDOR_DELL,
    205   1.1        ad 		PCI_PRODUCT_DELL_PERC_3DI,
    206   1.1        ad 		PCI_VENDOR_DELL,
    207   1.1        ad 		PCI_PRODUCT_DELL_PERC_3DI_SUB3,
    208   1.1        ad 		AAC_HWIF_I960RX,
    209   1.1        ad 		0,
    210   1.1        ad 		"Dell PERC 3/Di"
    211   1.1        ad 	},
    212   1.1        ad 	{
    213   1.1        ad 		PCI_VENDOR_DELL,
    214   1.1        ad 		PCI_PRODUCT_DELL_PERC_3DI_2,
    215   1.1        ad 		PCI_VENDOR_DELL,
    216   1.1        ad 		PCI_PRODUCT_DELL_PERC_3DI_2_SUB,
    217   1.3        ad 		AAC_HWIF_I960RX,
    218   1.3        ad 		0,
    219   1.3        ad 		"Dell PERC 3/Di"
    220   1.3        ad 	},
    221   1.3        ad         {
    222   1.3        ad 		PCI_VENDOR_DELL,
    223   1.3        ad 		PCI_PRODUCT_DELL_PERC_3DI_3,
    224   1.3        ad 		PCI_VENDOR_DELL,
    225   1.3        ad 		PCI_PRODUCT_DELL_PERC_3DI_3_SUB,
    226   1.3        ad 		AAC_HWIF_I960RX,
    227   1.3        ad 		0,
    228   1.3        ad 		"Dell PERC 3/Di"
    229   1.3        ad 	},
    230   1.3        ad 	{
    231   1.3        ad 		PCI_VENDOR_DELL,
    232   1.3        ad 		PCI_PRODUCT_DELL_PERC_3DI_3,
    233   1.3        ad 		PCI_VENDOR_DELL,
    234   1.3        ad 		PCI_PRODUCT_DELL_PERC_3DI_3_SUB2,
    235   1.3        ad 		AAC_HWIF_I960RX,
    236   1.3        ad 		0,
    237   1.3        ad 		"Dell PERC 3/Di"
    238   1.3        ad 	},
    239   1.3        ad 	{
    240   1.3        ad 		PCI_VENDOR_DELL,
    241   1.3        ad 		PCI_PRODUCT_DELL_PERC_3DI_3,
    242   1.3        ad 		PCI_VENDOR_DELL,
    243   1.3        ad 		PCI_PRODUCT_DELL_PERC_3DI_3_SUB3,
    244   1.1        ad 		AAC_HWIF_I960RX,
    245   1.1        ad 		0,
    246   1.1        ad 		"Dell PERC 3/Di"
    247   1.1        ad 	},
    248   1.1        ad 	{
    249   1.1        ad 		PCI_VENDOR_DELL,
    250   1.1        ad 		PCI_PRODUCT_DELL_PERC_3SI,
    251   1.1        ad 		PCI_VENDOR_DELL,
    252   1.1        ad 		PCI_PRODUCT_DELL_PERC_3SI,
    253   1.1        ad 		AAC_HWIF_I960RX,
    254   1.1        ad 		0,
    255   1.1        ad 		"Dell PERC 3/Si"
    256   1.1        ad 	},
    257   1.1        ad 	{
    258   1.1        ad 		PCI_VENDOR_DELL,
    259   1.1        ad 		PCI_PRODUCT_DELL_PERC_3SI_2,
    260   1.1        ad 		PCI_VENDOR_DELL,
    261   1.1        ad 		PCI_PRODUCT_DELL_PERC_3SI_2_SUB,
    262   1.1        ad 		AAC_HWIF_I960RX,
    263   1.1        ad 		0,
    264   1.1        ad 		"Dell PERC 3/Si"
    265   1.1        ad 	},
    266   1.1        ad 	{
    267   1.1        ad 		PCI_VENDOR_ADP2,
    268  1.14    martti 		PCI_PRODUCT_ADP2_ASR2200S,
    269  1.14    martti 		PCI_VENDOR_DELL,
    270  1.14    martti 		PCI_PRODUCT_DELL_CERC_1_5,
    271  1.14    martti 		AAC_HWIF_I960RX,
    272  1.14    martti 		AAC_QUIRK_NO4GB,
    273  1.14    martti 		"Dell CERC SATA RAID 1.5/6ch"
    274  1.14    martti 	},
    275  1.14    martti 	{
    276  1.14    martti 		PCI_VENDOR_ADP2,
    277   1.1        ad 		PCI_PRODUCT_ADP2_AAC2622,
    278   1.1        ad 		PCI_VENDOR_ADP2,
    279   1.1        ad 		PCI_PRODUCT_ADP2_AAC2622,
    280   1.1        ad 		AAC_HWIF_I960RX,
    281   1.1        ad 		0,
    282   1.1        ad 		"Adaptec ADP-2622"
    283   1.1        ad 	},
    284   1.1        ad 	{
    285   1.1        ad 		PCI_VENDOR_ADP2,
    286   1.1        ad 		PCI_PRODUCT_ADP2_ASR2200S,
    287   1.1        ad 		PCI_VENDOR_ADP2,
    288   1.8  gendalia 		PCI_PRODUCT_ADP2_ASR2200S_SUB2M,
    289   1.8  gendalia 		AAC_HWIF_I960RX,
    290  1.21    briggs 		AAC_QUIRK_NO4GB | AAC_QUIRK_256FIBS,
    291   1.8  gendalia 		"Adaptec ASR-2200S"
    292   1.8  gendalia 	},
    293   1.8  gendalia 	{
    294   1.8  gendalia 		PCI_VENDOR_ADP2,
    295   1.8  gendalia 		PCI_PRODUCT_ADP2_ASR2200S,
    296   1.8  gendalia 		PCI_VENDOR_DELL,
    297   1.8  gendalia 		PCI_PRODUCT_ADP2_ASR2200S_SUB2M,
    298   1.8  gendalia 		AAC_HWIF_I960RX,
    299  1.21    briggs 		AAC_QUIRK_NO4GB | AAC_QUIRK_256FIBS,
    300   1.8  gendalia 		"Dell PERC 320/DC"
    301   1.8  gendalia 	},
    302   1.8  gendalia 	{
    303   1.8  gendalia 		PCI_VENDOR_ADP2,
    304   1.8  gendalia 		PCI_PRODUCT_ADP2_ASR2200S,
    305   1.8  gendalia 		PCI_VENDOR_ADP2,
    306   1.1        ad 		PCI_PRODUCT_ADP2_ASR2200S,
    307   1.1        ad 		AAC_HWIF_I960RX,
    308  1.21    briggs 		AAC_QUIRK_NO4GB | AAC_QUIRK_256FIBS,
    309   1.1        ad 		"Adaptec ASR-2200S"
    310   1.1        ad 	},
    311   1.1        ad 	{
    312   1.1        ad 		PCI_VENDOR_ADP2,
    313   1.1        ad 		PCI_PRODUCT_ADP2_ASR2200S,
    314   1.1        ad 		PCI_VENDOR_ADP2,
    315  1.10  gendalia 		PCI_PRODUCT_ADP2_AAR2810SA,
    316  1.10  gendalia 		AAC_HWIF_I960RX,
    317  1.21    briggs 		AAC_QUIRK_NO4GB,
    318  1.10  gendalia 		"Adaptec AAR-2810SA"
    319  1.10  gendalia 	},
    320  1.10  gendalia 	{
    321  1.10  gendalia 		PCI_VENDOR_ADP2,
    322  1.10  gendalia 		PCI_PRODUCT_ADP2_ASR2200S,
    323  1.10  gendalia 		PCI_VENDOR_ADP2,
    324   1.1        ad 		PCI_PRODUCT_ADP2_ASR2120S,
    325   1.1        ad 		AAC_HWIF_I960RX,
    326  1.21    briggs 		AAC_QUIRK_NO4GB | AAC_QUIRK_256FIBS,
    327   1.1        ad 		"Adaptec ASR-2120S"
    328   1.1        ad 	},
    329   1.1        ad 	{
    330   1.9  jdolecek 		PCI_VENDOR_ADP2,
    331   1.9  jdolecek 		PCI_PRODUCT_ADP2_ASR2200S,
    332   1.9  jdolecek 		PCI_VENDOR_ADP2,
    333  1.13      tron 		PCI_PRODUCT_ADP2_ASR2410SA,
    334   1.9  jdolecek 		AAC_HWIF_I960RX,
    335  1.21    briggs 		AAC_QUIRK_NO4GB,
    336   1.9  jdolecek 		"Adaptec ASR-2410SA"
    337   1.9  jdolecek 	},
    338   1.9  jdolecek 	{
    339  1.20  christos 		PCI_VENDOR_ADP2,
    340  1.20  christos 		PCI_PRODUCT_ADP2_ASR2200S,
    341  1.20  christos 		PCI_VENDOR_HP,
    342  1.20  christos 		PCI_PRODUCT_ADP2_HP_M110_G2,
    343  1.20  christos 		AAC_HWIF_I960RX,
    344  1.21    briggs 		AAC_QUIRK_NO4GB,
    345  1.20  christos 		"HP ML110 G2 (Adaptec ASR-2610SA)"
    346  1.20  christos 	},
    347  1.20  christos 	{
    348  1.25  sborrill 		PCI_VENDOR_ADP2,
    349  1.25  sborrill 		PCI_PRODUCT_ADP2_ASR2120S,
    350  1.25  sborrill 		PCI_VENDOR_IBM,
    351  1.25  sborrill 		PCI_PRODUCT_IBM_SERVERAID8K,
    352  1.25  sborrill 		AAC_HWIF_RKT,
    353  1.25  sborrill 		0,
    354  1.25  sborrill 		"IBM ServeRAID 8k"
    355  1.25  sborrill 	},
    356  1.32  jmcneill 	{	PCI_VENDOR_ADP2,
    357  1.32  jmcneill 		PCI_PRODUCT_ADP2_ASR2200S,
    358  1.32  jmcneill 		PCI_VENDOR_ADP2,
    359  1.34       chs 		PCI_PRODUCT_ADP2_2405,
    360  1.34       chs 		AAC_HWIF_I960RX,
    361  1.34       chs 		0,
    362  1.34       chs 		"Adaptec RAID 2405"
    363  1.34       chs 	},
    364  1.34       chs 	{	PCI_VENDOR_ADP2,
    365  1.34       chs 		PCI_PRODUCT_ADP2_ASR2200S,
    366  1.34       chs 		PCI_VENDOR_ADP2,
    367  1.39       uwe 		PCI_PRODUCT_ADP2_2445,
    368  1.39       uwe 		AAC_HWIF_I960RX,
    369  1.39       uwe 		0,
    370  1.39       uwe 		"Adaptec RAID 2445"
    371  1.39       uwe 	},
    372  1.39       uwe 	{	PCI_VENDOR_ADP2,
    373  1.39       uwe 		PCI_PRODUCT_ADP2_ASR2200S,
    374  1.39       uwe 		PCI_VENDOR_ADP2,
    375  1.39       uwe 		PCI_PRODUCT_ADP2_2805,
    376  1.39       uwe 		AAC_HWIF_I960RX,
    377  1.39       uwe 		0,
    378  1.39       uwe 		"Adaptec RAID 2805"
    379  1.39       uwe 	},
    380  1.39       uwe 	{	PCI_VENDOR_ADP2,
    381  1.39       uwe 		PCI_PRODUCT_ADP2_ASR2200S,
    382  1.39       uwe 		PCI_VENDOR_ADP2,
    383  1.32  jmcneill 		PCI_PRODUCT_ADP2_3405,
    384  1.32  jmcneill 		AAC_HWIF_I960RX,
    385  1.32  jmcneill 		0,
    386  1.32  jmcneill 		"Adaptec RAID 3405"
    387  1.32  jmcneill 	},
    388  1.34       chs 	{	PCI_VENDOR_ADP2,
    389  1.34       chs 		PCI_PRODUCT_ADP2_ASR2200S,
    390  1.34       chs 		PCI_VENDOR_ADP2,
    391  1.34       chs 		PCI_PRODUCT_ADP2_3805,
    392  1.34       chs 		AAC_HWIF_I960RX,
    393  1.34       chs 		0,
    394  1.34       chs 		"Adaptec RAID 3805"
    395  1.34       chs 	},
    396  1.25  sborrill 	{
    397   1.1        ad 		PCI_VENDOR_DEC,
    398   1.2  augustss 		PCI_PRODUCT_DEC_21554,
    399   1.1        ad 		PCI_VENDOR_ADP2,
    400   1.1        ad 		PCI_PRODUCT_ADP2_AAC364,
    401   1.1        ad 		AAC_HWIF_STRONGARM,
    402   1.1        ad 		0,
    403   1.1        ad 		"Adaptec AAC-364"
    404   1.1        ad 	},
    405   1.1        ad 	{
    406   1.1        ad 		PCI_VENDOR_DEC,
    407   1.2  augustss 		PCI_PRODUCT_DEC_21554,
    408   1.1        ad 		PCI_VENDOR_ADP2,
    409   1.1        ad 		PCI_PRODUCT_ADP2_ASR5400S,
    410   1.1        ad 		AAC_HWIF_STRONGARM,
    411  1.21    briggs 		AAC_QUIRK_BROKEN_MMAP,
    412   1.1        ad 		"Adaptec ASR-5400S"
    413   1.1        ad 	},
    414   1.1        ad 	{
    415   1.1        ad 		PCI_VENDOR_DEC,
    416   1.2  augustss 		PCI_PRODUCT_DEC_21554,
    417   1.1        ad 		PCI_VENDOR_ADP2,
    418   1.1        ad 		PCI_PRODUCT_ADP2_PERC_2QC,
    419   1.1        ad 		AAC_HWIF_STRONGARM,
    420   1.1        ad 		AAC_QUIRK_PERC2QC,
    421   1.1        ad 		"Dell PERC 2/QC"
    422   1.1        ad 	},
    423   1.1        ad 	{
    424   1.1        ad 		PCI_VENDOR_DEC,
    425   1.2  augustss 		PCI_PRODUCT_DEC_21554,
    426   1.1        ad 		PCI_VENDOR_ADP2,
    427   1.1        ad 		PCI_PRODUCT_ADP2_PERC_3QC,
    428   1.1        ad 		AAC_HWIF_STRONGARM,
    429   1.1        ad 		0,
    430   1.1        ad 		"Dell PERC 3/QC"
    431   1.1        ad 	},
    432   1.1        ad 	{
    433   1.1        ad 		PCI_VENDOR_DEC,
    434   1.2  augustss 		PCI_PRODUCT_DEC_21554,
    435   1.1        ad 		PCI_VENDOR_HP,
    436   1.1        ad 		PCI_PRODUCT_HP_NETRAID_4M,
    437   1.1        ad 		AAC_HWIF_STRONGARM,
    438   1.1        ad 		0,
    439   1.1        ad 		"HP NetRAID-4M"
    440   1.1        ad 	},
    441  1.33        is 	{
    442  1.33        is 		PCI_VENDOR_ADP2,
    443  1.33        is 		PCI_PRODUCT_ADP2_ASR2200S,
    444  1.33        is 		PCI_VENDOR_SUN,
    445  1.33        is 		PCI_PRODUCT_ADP2_ASR2120S,
    446  1.31        is 		AAC_HWIF_I960RX,
    447  1.31        is 		0,
    448  1.31        is 		"SG-XPCIESAS-R-IN"
    449  1.31        is 	},
    450   1.1        ad };
    451   1.1        ad 
    452  1.15   thorpej static const struct aac_ident *
    453   1.1        ad aac_find_ident(struct pci_attach_args *pa)
    454   1.1        ad {
    455   1.1        ad 	const struct aac_ident *m, *mm;
    456   1.1        ad 	u_int32_t subsysid;
    457   1.1        ad 
    458   1.1        ad 	m = aac_ident;
    459   1.1        ad 	mm = aac_ident + (sizeof(aac_ident) / sizeof(aac_ident[0]));
    460   1.1        ad 
    461   1.1        ad 	while (m < mm) {
    462   1.1        ad 		if (m->vendor == PCI_VENDOR(pa->pa_id) &&
    463   1.1        ad 		    m->device == PCI_PRODUCT(pa->pa_id)) {
    464   1.1        ad 			subsysid = pci_conf_read(pa->pa_pc, pa->pa_tag,
    465   1.1        ad 			    PCI_SUBSYS_ID_REG);
    466   1.1        ad 			if (m->subvendor == PCI_VENDOR(subsysid) &&
    467   1.1        ad 			    m->subdevice == PCI_PRODUCT(subsysid))
    468   1.1        ad 				return (m);
    469   1.1        ad 		}
    470   1.1        ad 		m++;
    471   1.1        ad 	}
    472   1.1        ad 
    473   1.1        ad 	return (NULL);
    474   1.1        ad }
    475   1.1        ad 
    476  1.15   thorpej static int
    477  1.21    briggs aac_pci_intr_set(struct aac_softc *sc, int (*hand)(void*), void *arg)
    478  1.21    briggs {
    479  1.21    briggs 	struct aac_pci_softc	*pcisc;
    480  1.21    briggs 
    481  1.21    briggs 	pcisc = (struct aac_pci_softc *) sc;
    482  1.21    briggs 
    483  1.21    briggs 	pci_intr_disestablish(pcisc->sc_pc, sc->sc_ih);
    484  1.21    briggs 	sc->sc_ih = pci_intr_establish(pcisc->sc_pc, pcisc->sc_ih,
    485  1.21    briggs 				       IPL_BIO, hand, arg);
    486  1.21    briggs 	if (sc->sc_ih == NULL) {
    487  1.21    briggs 		return ENXIO;
    488  1.21    briggs 	}
    489  1.21    briggs 	return 0;
    490  1.21    briggs }
    491  1.21    briggs 
    492  1.21    briggs static int
    493  1.28    cegger aac_pci_match(device_t parent, cfdata_t match, void *aux)
    494   1.1        ad {
    495   1.1        ad 	struct pci_attach_args *pa;
    496   1.1        ad 
    497   1.1        ad 	pa = aux;
    498   1.1        ad 
    499   1.1        ad 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_I2O)
    500   1.1        ad 		return (0);
    501   1.1        ad 
    502   1.1        ad 	return (aac_find_ident(pa) != NULL);
    503   1.1        ad }
    504   1.1        ad 
    505  1.15   thorpej static void
    506  1.28    cegger aac_pci_attach(device_t parent, device_t self, void *aux)
    507   1.1        ad {
    508   1.1        ad 	struct pci_attach_args *pa;
    509   1.1        ad 	pci_chipset_tag_t pc;
    510  1.21    briggs 	struct aac_pci_softc *pcisc;
    511   1.1        ad 	struct aac_softc *sc;
    512   1.1        ad 	u_int16_t command;
    513   1.1        ad 	bus_addr_t membase;
    514   1.1        ad 	bus_size_t memsize;
    515   1.1        ad 	const char *intrstr;
    516   1.1        ad 	int state;
    517   1.1        ad 	const struct aac_ident *m;
    518  1.36  christos 	char intrbuf[PCI_INTRSTR_LEN];
    519   1.1        ad 
    520   1.1        ad 	pa = aux;
    521   1.1        ad 	pc = pa->pa_pc;
    522  1.29    cegger 	pcisc = device_private(self);
    523  1.21    briggs 	pcisc->sc_pc = pc;
    524  1.21    briggs 	sc = &pcisc->sc_aac;
    525  1.35       chs 	sc->sc_dv = self;
    526   1.1        ad 	state = 0;
    527   1.1        ad 
    528   1.7   thorpej 	aprint_naive(": RAID controller\n");
    529   1.7   thorpej 	aprint_normal(": ");
    530   1.1        ad 
    531   1.1        ad 	/*
    532   1.1        ad 	 * Verify that the adapter is correctly set up in PCI space.
    533   1.1        ad 	 */
    534   1.1        ad 	command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
    535   1.1        ad 	command |= PCI_COMMAND_MASTER_ENABLE;
    536   1.1        ad 	pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, command);
    537   1.1        ad 	command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
    538   1.1        ad 	AAC_DPRINTF(AAC_D_MISC, ("pci command status reg 0x08x "));
    539   1.1        ad 
    540   1.1        ad 	if ((command & PCI_COMMAND_MASTER_ENABLE) == 0) {
    541   1.7   thorpej 		aprint_error("can't enable bus-master feature\n");
    542   1.1        ad 		goto bail_out;
    543   1.1        ad 	}
    544   1.1        ad 
    545   1.1        ad 	if ((command & PCI_COMMAND_MEM_ENABLE) == 0) {
    546   1.7   thorpej 		aprint_error("memory window not available\n");
    547   1.1        ad 		goto bail_out;
    548   1.1        ad 	}
    549   1.1        ad 
    550   1.1        ad 	/*
    551   1.1        ad 	 * Map control/status registers.
    552   1.1        ad 	 */
    553   1.1        ad 	if (pci_mapreg_map(pa, PCI_MAPREG_START,
    554   1.1        ad 	    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_memt,
    555   1.1        ad 	    &sc->sc_memh, &membase, &memsize)) {
    556   1.7   thorpej 		aprint_error("can't find mem space\n");
    557   1.1        ad 		goto bail_out;
    558   1.1        ad 	}
    559   1.1        ad 	state++;
    560   1.1        ad 
    561  1.21    briggs 	if (pci_intr_map(pa, &pcisc->sc_ih)) {
    562   1.7   thorpej 		aprint_error("couldn't map interrupt\n");
    563   1.1        ad 		goto bail_out;
    564   1.1        ad 	}
    565  1.36  christos 	intrstr = pci_intr_string(pc, pcisc->sc_ih, intrbuf, sizeof(intrbuf));
    566  1.21    briggs 	sc->sc_ih = pci_intr_establish(pc, pcisc->sc_ih, IPL_BIO, aac_intr, sc);
    567   1.1        ad 	if (sc->sc_ih == NULL) {
    568   1.7   thorpej 		aprint_error("couldn't establish interrupt");
    569   1.1        ad 		if (intrstr != NULL)
    570  1.30     njoly 			aprint_error(" at %s", intrstr);
    571  1.30     njoly 		aprint_error("\n");
    572   1.1        ad 		goto bail_out;
    573   1.1        ad 	}
    574   1.1        ad 	state++;
    575   1.1        ad 
    576   1.1        ad 	sc->sc_dmat = pa->pa_dmat;
    577   1.1        ad 
    578   1.1        ad 	m = aac_find_ident(pa);
    579   1.7   thorpej 	aprint_normal("%s\n", m->prodstr);
    580   1.1        ad 	if (intrstr != NULL)
    581  1.37   msaitoh 		aprint_normal_dev(self, "interrupting at %s\n", intrstr);
    582   1.1        ad 
    583   1.1        ad 	sc->sc_hwif = m->hwif;
    584   1.1        ad 	sc->sc_quirks = m->quirks;
    585   1.1        ad 	switch (sc->sc_hwif) {
    586   1.1        ad 		case AAC_HWIF_I960RX:
    587   1.1        ad 			AAC_DPRINTF(AAC_D_MISC,
    588   1.1        ad 			    ("set hardware up for i960Rx"));
    589   1.1        ad 			sc->sc_if = aac_rx_interface;
    590   1.1        ad 			break;
    591   1.1        ad 
    592   1.1        ad 		case AAC_HWIF_STRONGARM:
    593   1.1        ad 			AAC_DPRINTF(AAC_D_MISC,
    594   1.1        ad 			    ("set hardware up for StrongARM"));
    595   1.1        ad 			sc->sc_if = aac_sa_interface;
    596   1.1        ad 			break;
    597  1.21    briggs 
    598  1.21    briggs 		case AAC_HWIF_RKT:
    599  1.21    briggs 			AAC_DPRINTF(AAC_D_MISC,
    600  1.21    briggs 			    ("set hardware up for MIPS/Rocket"));
    601  1.21    briggs 			sc->sc_if = aac_rkt_interface;
    602  1.21    briggs 			break;
    603   1.1        ad 	}
    604  1.21    briggs 	sc->sc_regsize = memsize;
    605  1.21    briggs 	sc->sc_intr_set = aac_pci_intr_set;
    606   1.1        ad 
    607   1.1        ad 	if (!aac_attach(sc))
    608   1.1        ad 		return;
    609   1.1        ad 
    610   1.1        ad  bail_out:
    611   1.1        ad 	if (state > 1)
    612   1.1        ad 		pci_intr_disestablish(pc, sc->sc_ih);
    613   1.1        ad 	if (state > 0)
    614   1.1        ad 		bus_space_unmap(sc->sc_memt, sc->sc_memh, memsize);
    615   1.1        ad }
    616   1.1        ad 
    617  1.38  pgoyette /* ARGSUSED */
    618  1.38  pgoyette static int
    619  1.38  pgoyette aac_pci_rescan(device_t self, const char *attr, const int *flags)
    620  1.38  pgoyette {
    621  1.38  pgoyette 
    622  1.38  pgoyette 	return aac_devscan(device_private(self));
    623  1.38  pgoyette }
    624  1.38  pgoyette 
    625  1.38  pgoyette CFATTACH_DECL3_NEW(aac_pci, sizeof(struct aac_pci_softc),
    626  1.38  pgoyette     aac_pci_match, aac_pci_attach, NULL, NULL, aac_pci_rescan, NULL, 0);
    627  1.15   thorpej 
    628   1.1        ad /*
    629   1.1        ad  * Read the current firmware status word.
    630   1.1        ad  */
    631  1.15   thorpej static int
    632   1.1        ad aac_sa_get_fwstatus(struct aac_softc *sc)
    633   1.1        ad {
    634   1.1        ad 
    635   1.1        ad 	return (AAC_GETREG4(sc, AAC_SA_FWSTATUS));
    636   1.1        ad }
    637   1.1        ad 
    638  1.15   thorpej static int
    639   1.1        ad aac_rx_get_fwstatus(struct aac_softc *sc)
    640   1.1        ad {
    641   1.1        ad 
    642   1.1        ad 	return (AAC_GETREG4(sc, AAC_RX_FWSTATUS));
    643   1.1        ad }
    644   1.1        ad 
    645  1.21    briggs static int
    646  1.21    briggs aac_rkt_get_fwstatus(struct aac_softc *sc)
    647  1.21    briggs {
    648  1.21    briggs 
    649  1.21    briggs 	return (AAC_GETREG4(sc, AAC_RKT_FWSTATUS));
    650  1.21    briggs }
    651  1.21    briggs 
    652   1.1        ad /*
    653   1.1        ad  * Notify the controller of a change in a given queue
    654   1.1        ad  */
    655   1.1        ad 
    656  1.15   thorpej static void
    657   1.1        ad aac_sa_qnotify(struct aac_softc *sc, int qbit)
    658   1.1        ad {
    659   1.1        ad 
    660   1.1        ad 	AAC_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit);
    661   1.1        ad }
    662   1.1        ad 
    663  1.15   thorpej static void
    664   1.1        ad aac_rx_qnotify(struct aac_softc *sc, int qbit)
    665   1.1        ad {
    666   1.1        ad 
    667   1.1        ad 	AAC_SETREG4(sc, AAC_RX_IDBR, qbit);
    668   1.1        ad }
    669   1.1        ad 
    670  1.21    briggs static void
    671  1.21    briggs aac_rkt_qnotify(struct aac_softc *sc, int qbit)
    672  1.21    briggs {
    673  1.21    briggs 
    674  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_IDBR, qbit);
    675  1.21    briggs }
    676  1.21    briggs 
    677   1.1        ad /*
    678   1.1        ad  * Get the interrupt reason bits
    679   1.1        ad  */
    680  1.15   thorpej static int
    681   1.1        ad aac_sa_get_istatus(struct aac_softc *sc)
    682   1.1        ad {
    683   1.1        ad 
    684   1.1        ad 	return (AAC_GETREG2(sc, AAC_SA_DOORBELL0));
    685   1.1        ad }
    686   1.1        ad 
    687  1.15   thorpej static int
    688   1.1        ad aac_rx_get_istatus(struct aac_softc *sc)
    689   1.1        ad {
    690   1.1        ad 
    691   1.1        ad 	return (AAC_GETREG4(sc, AAC_RX_ODBR));
    692   1.1        ad }
    693   1.1        ad 
    694  1.21    briggs static int
    695  1.21    briggs aac_rkt_get_istatus(struct aac_softc *sc)
    696  1.21    briggs {
    697  1.21    briggs 
    698  1.21    briggs 	return (AAC_GETREG4(sc, AAC_RKT_ODBR));
    699  1.21    briggs }
    700  1.21    briggs 
    701   1.1        ad /*
    702   1.1        ad  * Clear some interrupt reason bits
    703   1.1        ad  */
    704  1.15   thorpej static void
    705   1.1        ad aac_sa_clear_istatus(struct aac_softc *sc, int mask)
    706   1.1        ad {
    707   1.1        ad 
    708   1.1        ad 	AAC_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask);
    709   1.1        ad }
    710   1.1        ad 
    711  1.15   thorpej static void
    712   1.1        ad aac_rx_clear_istatus(struct aac_softc *sc, int mask)
    713   1.1        ad {
    714   1.1        ad 
    715   1.1        ad 	AAC_SETREG4(sc, AAC_RX_ODBR, mask);
    716   1.1        ad }
    717   1.1        ad 
    718  1.21    briggs static void
    719  1.21    briggs aac_rkt_clear_istatus(struct aac_softc *sc, int mask)
    720  1.21    briggs {
    721  1.21    briggs 
    722  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_ODBR, mask);
    723  1.21    briggs }
    724  1.21    briggs 
    725   1.1        ad /*
    726   1.1        ad  * Populate the mailbox and set the command word
    727   1.1        ad  */
    728  1.15   thorpej static void
    729   1.1        ad aac_sa_set_mailbox(struct aac_softc *sc, u_int32_t command,
    730   1.1        ad 		   u_int32_t arg0, u_int32_t arg1, u_int32_t arg2,
    731   1.1        ad 		   u_int32_t arg3)
    732   1.1        ad {
    733   1.1        ad 
    734   1.1        ad 	AAC_SETREG4(sc, AAC_SA_MAILBOX, command);
    735   1.1        ad 	AAC_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0);
    736   1.1        ad 	AAC_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1);
    737   1.1        ad 	AAC_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2);
    738   1.1        ad 	AAC_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3);
    739   1.1        ad }
    740   1.1        ad 
    741  1.15   thorpej static void
    742   1.1        ad aac_rx_set_mailbox(struct aac_softc *sc, u_int32_t command,
    743   1.1        ad 		   u_int32_t arg0, u_int32_t arg1, u_int32_t arg2,
    744   1.1        ad 		   u_int32_t arg3)
    745   1.1        ad {
    746   1.1        ad 
    747   1.1        ad 	AAC_SETREG4(sc, AAC_RX_MAILBOX, command);
    748   1.1        ad 	AAC_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0);
    749   1.1        ad 	AAC_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1);
    750   1.1        ad 	AAC_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2);
    751   1.1        ad 	AAC_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3);
    752   1.1        ad }
    753   1.1        ad 
    754  1.21    briggs static void
    755  1.21    briggs aac_rkt_set_mailbox(struct aac_softc *sc, u_int32_t command,
    756  1.21    briggs 		    u_int32_t arg0, u_int32_t arg1, u_int32_t arg2,
    757  1.21    briggs 		    u_int32_t arg3)
    758  1.21    briggs {
    759  1.21    briggs 
    760  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_MAILBOX, command);
    761  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_MAILBOX + 4, arg0);
    762  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_MAILBOX + 8, arg1);
    763  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_MAILBOX + 12, arg2);
    764  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_MAILBOX + 16, arg3);
    765  1.21    briggs }
    766  1.21    briggs 
    767   1.1        ad /*
    768  1.12    briggs  * Fetch the specified mailbox
    769   1.1        ad  */
    770  1.15   thorpej static uint32_t
    771  1.12    briggs aac_sa_get_mailbox(struct aac_softc *sc, int mb)
    772   1.1        ad {
    773   1.1        ad 
    774  1.12    briggs 	return (AAC_GETREG4(sc, AAC_SA_MAILBOX + (mb * 4)));
    775   1.1        ad }
    776   1.1        ad 
    777  1.15   thorpej static uint32_t
    778  1.12    briggs aac_rx_get_mailbox(struct aac_softc *sc, int mb)
    779   1.1        ad {
    780   1.1        ad 
    781  1.12    briggs 	return (AAC_GETREG4(sc, AAC_RX_MAILBOX + (mb * 4)));
    782   1.1        ad }
    783   1.1        ad 
    784  1.21    briggs static uint32_t
    785  1.21    briggs aac_rkt_get_mailbox(struct aac_softc *sc, int mb)
    786  1.21    briggs {
    787  1.21    briggs 
    788  1.21    briggs 	return (AAC_GETREG4(sc, AAC_RKT_MAILBOX + (mb * 4)));
    789  1.21    briggs }
    790  1.21    briggs 
    791   1.1        ad /*
    792   1.1        ad  * Set/clear interrupt masks
    793   1.1        ad  */
    794  1.15   thorpej static void
    795   1.1        ad aac_sa_set_interrupts(struct aac_softc *sc, int enable)
    796   1.1        ad {
    797   1.1        ad 
    798   1.1        ad 	if (enable)
    799   1.1        ad 		AAC_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS);
    800   1.1        ad 	else
    801   1.1        ad 		AAC_SETREG2((sc), AAC_SA_MASK0_SET, ~0);
    802   1.1        ad }
    803   1.1        ad 
    804  1.15   thorpej static void
    805   1.1        ad aac_rx_set_interrupts(struct aac_softc *sc, int enable)
    806   1.1        ad {
    807   1.1        ad 
    808  1.21    briggs 	if (enable) {
    809  1.21    briggs 		if (sc->sc_quirks & AAC_QUIRK_NEW_COMM)
    810  1.21    briggs 			AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INT_NEW_COMM);
    811  1.21    briggs 		else
    812  1.21    briggs 			AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS);
    813  1.21    briggs 	} else {
    814   1.1        ad 		AAC_SETREG4(sc, AAC_RX_OIMR, ~0);
    815  1.21    briggs 	}
    816  1.21    briggs }
    817  1.21    briggs 
    818  1.21    briggs static void
    819  1.21    briggs aac_rkt_set_interrupts(struct aac_softc *sc, int enable)
    820  1.21    briggs {
    821  1.21    briggs 
    822  1.21    briggs 	if (enable) {
    823  1.21    briggs 		if (sc->sc_quirks & AAC_QUIRK_NEW_COMM)
    824  1.21    briggs 			AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INT_NEW_COMM);
    825  1.21    briggs 		else
    826  1.21    briggs 			AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS);
    827  1.21    briggs 	} else {
    828  1.21    briggs 		AAC_SETREG4(sc, AAC_RKT_OIMR, ~0);
    829  1.21    briggs 	}
    830  1.21    briggs }
    831  1.21    briggs 
    832  1.21    briggs /*
    833  1.21    briggs  * New comm. interface: Send command functions
    834  1.21    briggs  */
    835  1.21    briggs static int
    836  1.21    briggs aac_rx_send_command(struct aac_softc *sc, struct aac_ccb *ac)
    837  1.21    briggs {
    838  1.21    briggs 	u_int32_t	index, device;
    839  1.21    briggs 
    840  1.21    briggs 	index = AAC_GETREG4(sc, AAC_RX_IQUE);
    841  1.21    briggs 	if (index == 0xffffffffL)
    842  1.21    briggs 		index = AAC_GETREG4(sc, AAC_RX_IQUE);
    843  1.21    briggs 	if (index == 0xffffffffL)
    844  1.21    briggs 		return index;
    845  1.21    briggs #ifdef notyet
    846  1.21    briggs 	aac_enqueue_busy(ac);
    847  1.21    briggs #endif
    848  1.21    briggs 	device = index;
    849  1.21    briggs 	AAC_SETREG4(sc, device,
    850  1.21    briggs 	    htole32((u_int32_t)(ac->ac_fibphys & 0xffffffffUL)));
    851  1.21    briggs 	device += 4;
    852  1.21    briggs 	if (sizeof(bus_addr_t) > 4) {
    853  1.21    briggs 		AAC_SETREG4(sc, device,
    854  1.21    briggs 		    htole32((u_int32_t)((u_int64_t)ac->ac_fibphys >> 32)));
    855  1.21    briggs 	} else {
    856  1.21    briggs 		AAC_SETREG4(sc, device, 0);
    857  1.21    briggs 	}
    858  1.21    briggs 	device += 4;
    859  1.21    briggs 	AAC_SETREG4(sc, device, ac->ac_fib->Header.Size);
    860  1.21    briggs 	AAC_SETREG4(sc, AAC_RX_IQUE, index);
    861  1.21    briggs 	return 0;
    862  1.21    briggs }
    863  1.21    briggs 
    864  1.21    briggs static int
    865  1.21    briggs aac_rkt_send_command(struct aac_softc *sc, struct aac_ccb *ac)
    866  1.21    briggs {
    867  1.21    briggs 	u_int32_t	index, device;
    868  1.21    briggs 
    869  1.21    briggs 	index = AAC_GETREG4(sc, AAC_RKT_IQUE);
    870  1.21    briggs 	if (index == 0xffffffffL)
    871  1.21    briggs 		index = AAC_GETREG4(sc, AAC_RKT_IQUE);
    872  1.21    briggs 	if (index == 0xffffffffL)
    873  1.21    briggs 		return index;
    874  1.21    briggs #ifdef notyet
    875  1.21    briggs 	aac_enqueue_busy(ac);
    876  1.21    briggs #endif
    877  1.21    briggs 	device = index;
    878  1.21    briggs 	AAC_SETREG4(sc, device,
    879  1.21    briggs 	    htole32((u_int32_t)(ac->ac_fibphys & 0xffffffffUL)));
    880  1.21    briggs 	device += 4;
    881  1.21    briggs 	if (sizeof(bus_addr_t) > 4) {
    882  1.21    briggs 		AAC_SETREG4(sc, device,
    883  1.21    briggs 		    htole32((u_int32_t)((u_int64_t)ac->ac_fibphys >> 32)));
    884  1.21    briggs 	} else {
    885  1.21    briggs 		AAC_SETREG4(sc, device, 0);
    886  1.21    briggs 	}
    887  1.21    briggs 	device += 4;
    888  1.21    briggs 	AAC_SETREG4(sc, device, ac->ac_fib->Header.Size);
    889  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_IQUE, index);
    890  1.21    briggs 	return 0;
    891  1.21    briggs }
    892  1.21    briggs 
    893  1.21    briggs /*
    894  1.21    briggs  * New comm. interface: get, set outbound queue index
    895  1.21    briggs  */
    896  1.21    briggs static int
    897  1.21    briggs aac_rx_get_outb_queue(struct aac_softc *sc)
    898  1.21    briggs {
    899  1.21    briggs 
    900  1.21    briggs 	return AAC_GETREG4(sc, AAC_RX_OQUE);
    901  1.21    briggs }
    902  1.21    briggs 
    903  1.21    briggs static int
    904  1.21    briggs aac_rkt_get_outb_queue(struct aac_softc *sc)
    905  1.21    briggs {
    906  1.21    briggs 
    907  1.21    briggs 	return AAC_GETREG4(sc, AAC_RKT_OQUE);
    908  1.21    briggs }
    909  1.21    briggs 
    910  1.21    briggs static void
    911  1.21    briggs aac_rx_set_outb_queue(struct aac_softc *sc, int index)
    912  1.21    briggs {
    913  1.21    briggs 
    914  1.21    briggs 	AAC_SETREG4(sc, AAC_RX_OQUE, index);
    915  1.21    briggs }
    916  1.21    briggs 
    917  1.21    briggs static void
    918  1.21    briggs aac_rkt_set_outb_queue(struct aac_softc *sc, int index)
    919  1.21    briggs {
    920  1.21    briggs 
    921  1.21    briggs 	AAC_SETREG4(sc, AAC_RKT_OQUE, index);
    922   1.1        ad }
    923