1098ca2bdSWarner Losh /*- 217d24755SJustin T. Gibbs * Product specific probe and attach routines for: 317d24755SJustin T. Gibbs * aic7901 and aic7902 SCSI controllers 417d24755SJustin T. Gibbs * 517d24755SJustin T. Gibbs * Copyright (c) 1994-2001 Justin T. Gibbs. 61a1fbd0bSJustin T. Gibbs * Copyright (c) 2000-2002 Adaptec Inc. 717d24755SJustin T. Gibbs * All rights reserved. 817d24755SJustin T. Gibbs * 917d24755SJustin T. Gibbs * Redistribution and use in source and binary forms, with or without 1017d24755SJustin T. Gibbs * modification, are permitted provided that the following conditions 1117d24755SJustin T. Gibbs * are met: 1217d24755SJustin T. Gibbs * 1. Redistributions of source code must retain the above copyright 1317d24755SJustin T. Gibbs * notice, this list of conditions, and the following disclaimer, 1417d24755SJustin T. Gibbs * without modification. 1517d24755SJustin T. Gibbs * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1617d24755SJustin T. Gibbs * substantially similar to the "NO WARRANTY" disclaimer below 1717d24755SJustin T. Gibbs * ("Disclaimer") and any redistribution must be conditioned upon 1817d24755SJustin T. Gibbs * including a substantially similar Disclaimer requirement for further 1917d24755SJustin T. Gibbs * binary redistribution. 2017d24755SJustin T. Gibbs * 3. Neither the names of the above-listed copyright holders nor the names 2117d24755SJustin T. Gibbs * of any contributors may be used to endorse or promote products derived 2217d24755SJustin T. Gibbs * from this software without specific prior written permission. 2317d24755SJustin T. Gibbs * 2417d24755SJustin T. Gibbs * Alternatively, this software may be distributed under the terms of the 2517d24755SJustin T. Gibbs * GNU General Public License ("GPL") version 2 as published by the Free 2617d24755SJustin T. Gibbs * Software Foundation. 2717d24755SJustin T. Gibbs * 2817d24755SJustin T. Gibbs * NO WARRANTY 2917d24755SJustin T. Gibbs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3017d24755SJustin T. Gibbs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3117d24755SJustin T. Gibbs * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3217d24755SJustin T. Gibbs * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3317d24755SJustin T. Gibbs * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3417d24755SJustin T. Gibbs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3517d24755SJustin T. Gibbs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3617d24755SJustin T. Gibbs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3717d24755SJustin T. Gibbs * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 3817d24755SJustin T. Gibbs * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3917d24755SJustin T. Gibbs * POSSIBILITY OF SUCH DAMAGES. 4017d24755SJustin T. Gibbs * 4122dbd4c6SJustin T. Gibbs * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#88 $ 4217d24755SJustin T. Gibbs */ 4317d24755SJustin T. Gibbs 4417d24755SJustin T. Gibbs #ifdef __linux__ 4517d24755SJustin T. Gibbs #include "aic79xx_osm.h" 4617d24755SJustin T. Gibbs #include "aic79xx_inline.h" 4717d24755SJustin T. Gibbs #else 48b3b25f2cSJustin T. Gibbs #include <sys/cdefs.h> 49b3b25f2cSJustin T. Gibbs __FBSDID("$FreeBSD$"); 5017d24755SJustin T. Gibbs #include <dev/aic7xxx/aic79xx_osm.h> 5117d24755SJustin T. Gibbs #include <dev/aic7xxx/aic79xx_inline.h> 5217d24755SJustin T. Gibbs #endif 5317d24755SJustin T. Gibbs 5417d24755SJustin T. Gibbs static __inline uint64_t 5517d24755SJustin T. Gibbs ahd_compose_id(u_int device, u_int vendor, u_int subdevice, u_int subvendor) 5617d24755SJustin T. Gibbs { 5717d24755SJustin T. Gibbs uint64_t id; 5817d24755SJustin T. Gibbs 5917d24755SJustin T. Gibbs id = subvendor 6017d24755SJustin T. Gibbs | (subdevice << 16) 6117d24755SJustin T. Gibbs | ((uint64_t)vendor << 32) 6217d24755SJustin T. Gibbs | ((uint64_t)device << 48); 6317d24755SJustin T. Gibbs 6417d24755SJustin T. Gibbs return (id); 6517d24755SJustin T. Gibbs } 6617d24755SJustin T. Gibbs 6717d24755SJustin T. Gibbs #define ID_ALL_MASK 0xFFFFFFFFFFFFFFFFull 684164174aSJustin T. Gibbs #define ID_ALL_IROC_MASK 0xFF7FFFFFFFFFFFFFull 6917d24755SJustin T. Gibbs #define ID_DEV_VENDOR_MASK 0xFFFFFFFF00000000ull 7017d24755SJustin T. Gibbs #define ID_9005_GENERIC_MASK 0xFFF0FFFF00000000ull 714164174aSJustin T. Gibbs #define ID_9005_GENERIC_IROC_MASK 0xFF70FFFF00000000ull 7217d24755SJustin T. Gibbs 7317d24755SJustin T. Gibbs #define ID_AIC7901 0x800F9005FFFF9005ull 741a1fbd0bSJustin T. Gibbs #define ID_AHA_29320A 0x8000900500609005ull 75197696e9SJustin T. Gibbs #define ID_AHA_29320ALP 0x8017900500449005ull 76197696e9SJustin T. Gibbs 77197696e9SJustin T. Gibbs #define ID_AIC7901A 0x801E9005FFFF9005ull 78454bf169SScott Long #define ID_AHA_29320LP 0x8014900500449005ull 7917d24755SJustin T. Gibbs 8017d24755SJustin T. Gibbs #define ID_AIC7902 0x801F9005FFFF9005ull 81454bf169SScott Long #define ID_AIC7902_B 0x801D9005FFFF9005ull 8217d24755SJustin T. Gibbs #define ID_AHA_39320 0x8010900500409005ull 83b3b25f2cSJustin T. Gibbs #define ID_AHA_29320 0x8012900500429005ull 84b3b25f2cSJustin T. Gibbs #define ID_AHA_29320B 0x8013900500439005ull 85197696e9SJustin T. Gibbs #define ID_AHA_39320_B 0x8015900500409005ull 8622dbd4c6SJustin T. Gibbs #define ID_AHA_39320_B_DELL 0x8015900501681028ull 87acae33b0SJustin T. Gibbs #define ID_AHA_39320A 0x8016900500409005ull 8817d24755SJustin T. Gibbs #define ID_AHA_39320D 0x8011900500419005ull 89454bf169SScott Long #define ID_AHA_39320D_B 0x801C900500419005ull 90454bf169SScott Long #define ID_AHA_39320D_HP 0x8011900500AC0E11ull 91454bf169SScott Long #define ID_AHA_39320D_B_HP 0x801C900500AC0E11ull 92a4522488SChristian Brueffer #define ID_AHA_39320LPE 0x8017900500459005ull 9317d24755SJustin T. Gibbs #define ID_AIC7902_PCI_REV_A4 0x3 941a1fbd0bSJustin T. Gibbs #define ID_AIC7902_PCI_REV_B0 0x10 95454bf169SScott Long #define SUBID_HP 0x0E11 9617d24755SJustin T. Gibbs 974164174aSJustin T. Gibbs #define DEVID_9005_HOSTRAID(id) ((id) & 0x80) 984164174aSJustin T. Gibbs 9917d24755SJustin T. Gibbs #define DEVID_9005_TYPE(id) ((id) & 0xF) 10017d24755SJustin T. Gibbs #define DEVID_9005_TYPE_HBA 0x0 /* Standard Card */ 10117d24755SJustin T. Gibbs #define DEVID_9005_TYPE_HBA_2EXT 0x1 /* 2 External Ports */ 10217d24755SJustin T. Gibbs #define DEVID_9005_TYPE_MB 0xF /* On Motherboard */ 10317d24755SJustin T. Gibbs 10417d24755SJustin T. Gibbs #define DEVID_9005_MFUNC(id) ((id) & 0x10) 10517d24755SJustin T. Gibbs 10617d24755SJustin T. Gibbs #define DEVID_9005_PACKETIZED(id) ((id) & 0x8000) 10717d24755SJustin T. Gibbs 10817d24755SJustin T. Gibbs #define SUBID_9005_TYPE(id) ((id) & 0xF) 10917d24755SJustin T. Gibbs #define SUBID_9005_TYPE_HBA 0x0 /* Standard Card */ 11017d24755SJustin T. Gibbs #define SUBID_9005_TYPE_MB 0xF /* On Motherboard */ 11117d24755SJustin T. Gibbs 11217d24755SJustin T. Gibbs #define SUBID_9005_AUTOTERM(id) (((id) & 0x10) == 0) 11317d24755SJustin T. Gibbs 11417d24755SJustin T. Gibbs #define SUBID_9005_LEGACYCONN_FUNC(id) ((id) & 0x20) 11517d24755SJustin T. Gibbs 11617d24755SJustin T. Gibbs #define SUBID_9005_SEEPTYPE(id) ((id) & 0x0C0) >> 6) 11717d24755SJustin T. Gibbs #define SUBID_9005_SEEPTYPE_NONE 0x0 11817d24755SJustin T. Gibbs #define SUBID_9005_SEEPTYPE_4K 0x1 11917d24755SJustin T. Gibbs 120197696e9SJustin T. Gibbs static ahd_device_setup_t ahd_aic7901_setup; 1211a1fbd0bSJustin T. Gibbs static ahd_device_setup_t ahd_aic7901A_setup; 122454bf169SScott Long static ahd_device_setup_t ahd_aic7902_setup; 123c8ee7177SJustin T. Gibbs static ahd_device_setup_t ahd_aic790X_setup; 12417d24755SJustin T. Gibbs 12517d24755SJustin T. Gibbs struct ahd_pci_identity ahd_pci_ident_table [] = 12617d24755SJustin T. Gibbs { 127197696e9SJustin T. Gibbs /* aic7901 based controllers */ 128197696e9SJustin T. Gibbs { 129197696e9SJustin T. Gibbs ID_AHA_29320A, 130197696e9SJustin T. Gibbs ID_ALL_MASK, 131197696e9SJustin T. Gibbs "Adaptec 29320A Ultra320 SCSI adapter", 132197696e9SJustin T. Gibbs ahd_aic7901_setup 133197696e9SJustin T. Gibbs }, 134197696e9SJustin T. Gibbs { 135197696e9SJustin T. Gibbs ID_AHA_29320ALP, 136197696e9SJustin T. Gibbs ID_ALL_MASK, 137197696e9SJustin T. Gibbs "Adaptec 29320ALP Ultra320 SCSI adapter", 138197696e9SJustin T. Gibbs ahd_aic7901_setup 139197696e9SJustin T. Gibbs }, 140454bf169SScott Long /* aic7901A based controllers */ 141454bf169SScott Long { 142454bf169SScott Long ID_AHA_29320LP, 143454bf169SScott Long ID_ALL_MASK, 144454bf169SScott Long "Adaptec 29320LP Ultra320 SCSI adapter", 145454bf169SScott Long ahd_aic7901A_setup 146454bf169SScott Long }, 14717d24755SJustin T. Gibbs /* aic7902 based controllers */ 14817d24755SJustin T. Gibbs { 149b3b25f2cSJustin T. Gibbs ID_AHA_29320, 150b3b25f2cSJustin T. Gibbs ID_ALL_MASK, 151b3b25f2cSJustin T. Gibbs "Adaptec 29320 Ultra320 SCSI adapter", 152b3b25f2cSJustin T. Gibbs ahd_aic7902_setup 153b3b25f2cSJustin T. Gibbs }, 154b3b25f2cSJustin T. Gibbs { 155b3b25f2cSJustin T. Gibbs ID_AHA_29320B, 156b3b25f2cSJustin T. Gibbs ID_ALL_MASK, 157b3b25f2cSJustin T. Gibbs "Adaptec 29320B Ultra320 SCSI adapter", 158b3b25f2cSJustin T. Gibbs ahd_aic7902_setup 159b3b25f2cSJustin T. Gibbs }, 160b3b25f2cSJustin T. Gibbs { 16117d24755SJustin T. Gibbs ID_AHA_39320, 16217d24755SJustin T. Gibbs ID_ALL_MASK, 16317d24755SJustin T. Gibbs "Adaptec 39320 Ultra320 SCSI adapter", 16417d24755SJustin T. Gibbs ahd_aic7902_setup 16517d24755SJustin T. Gibbs }, 16617d24755SJustin T. Gibbs { 167197696e9SJustin T. Gibbs ID_AHA_39320_B, 168197696e9SJustin T. Gibbs ID_ALL_MASK, 169197696e9SJustin T. Gibbs "Adaptec 39320 Ultra320 SCSI adapter", 170197696e9SJustin T. Gibbs ahd_aic7902_setup 171197696e9SJustin T. Gibbs }, 172197696e9SJustin T. Gibbs { 17322dbd4c6SJustin T. Gibbs ID_AHA_39320_B_DELL, 17422dbd4c6SJustin T. Gibbs ID_ALL_MASK, 17522dbd4c6SJustin T. Gibbs "Adaptec (Dell OEM) 39320 Ultra320 SCSI adapter", 17622dbd4c6SJustin T. Gibbs ahd_aic7902_setup 17722dbd4c6SJustin T. Gibbs }, 17822dbd4c6SJustin T. Gibbs { 179acae33b0SJustin T. Gibbs ID_AHA_39320A, 180acae33b0SJustin T. Gibbs ID_ALL_MASK, 181acae33b0SJustin T. Gibbs "Adaptec 39320A Ultra320 SCSI adapter", 182acae33b0SJustin T. Gibbs ahd_aic7902_setup 183acae33b0SJustin T. Gibbs }, 184acae33b0SJustin T. Gibbs { 18517d24755SJustin T. Gibbs ID_AHA_39320D, 18617d24755SJustin T. Gibbs ID_ALL_MASK, 18717d24755SJustin T. Gibbs "Adaptec 39320D Ultra320 SCSI adapter", 18817d24755SJustin T. Gibbs ahd_aic7902_setup 18917d24755SJustin T. Gibbs }, 19017d24755SJustin T. Gibbs { 191454bf169SScott Long ID_AHA_39320D_HP, 19217d24755SJustin T. Gibbs ID_ALL_MASK, 193454bf169SScott Long "Adaptec (HP OEM) 39320D Ultra320 SCSI adapter", 194454bf169SScott Long ahd_aic7902_setup 195454bf169SScott Long }, 196454bf169SScott Long { 197454bf169SScott Long ID_AHA_39320D_B, 198454bf169SScott Long ID_ALL_MASK, 199454bf169SScott Long "Adaptec 39320D Ultra320 SCSI adapter", 200454bf169SScott Long ahd_aic7902_setup 201454bf169SScott Long }, 202454bf169SScott Long { 203454bf169SScott Long ID_AHA_39320D_B_HP, 204454bf169SScott Long ID_ALL_MASK, 205454bf169SScott Long "Adaptec (HP OEM) 39320D Ultra320 SCSI adapter", 20617d24755SJustin T. Gibbs ahd_aic7902_setup 20717d24755SJustin T. Gibbs }, 208a4522488SChristian Brueffer { 209a4522488SChristian Brueffer ID_AHA_39320LPE, 210a4522488SChristian Brueffer ID_ALL_MASK, 211a4522488SChristian Brueffer "Adaptec 39320LPE Ultra320 SCSI adapter", 212a4522488SChristian Brueffer ahd_aic7902_setup 213a4522488SChristian Brueffer }, 21417d24755SJustin T. Gibbs /* Generic chip probes for devices we don't know 'exactly' */ 21517d24755SJustin T. Gibbs { 2164164174aSJustin T. Gibbs ID_AIC7901 & ID_9005_GENERIC_MASK, 21722dbd4c6SJustin T. Gibbs ID_9005_GENERIC_MASK, 218197696e9SJustin T. Gibbs "Adaptec AIC7901 Ultra320 SCSI adapter", 219197696e9SJustin T. Gibbs ahd_aic7901_setup 220197696e9SJustin T. Gibbs }, 221197696e9SJustin T. Gibbs { 22297cae63dSScott Long ID_AIC7901A & ID_DEV_VENDOR_MASK, 22397cae63dSScott Long ID_DEV_VENDOR_MASK, 224454bf169SScott Long "Adaptec AIC7901A Ultra320 SCSI adapter", 225454bf169SScott Long ahd_aic7901A_setup 22617d24755SJustin T. Gibbs }, 22717d24755SJustin T. Gibbs { 22817d24755SJustin T. Gibbs ID_AIC7902 & ID_9005_GENERIC_MASK, 22917d24755SJustin T. Gibbs ID_9005_GENERIC_MASK, 230454bf169SScott Long "Adaptec AIC7902 Ultra320 SCSI adapter", 23117d24755SJustin T. Gibbs ahd_aic7902_setup 23217d24755SJustin T. Gibbs } 23317d24755SJustin T. Gibbs }; 23417d24755SJustin T. Gibbs 23517d24755SJustin T. Gibbs const u_int ahd_num_pci_devs = NUM_ELEMENTS(ahd_pci_ident_table); 23617d24755SJustin T. Gibbs 23717d24755SJustin T. Gibbs #define DEVCONFIG 0x40 23817d24755SJustin T. Gibbs #define PCIXINITPAT 0x0000E000ul 23917d24755SJustin T. Gibbs #define PCIXINIT_PCI33_66 0x0000E000ul 24017d24755SJustin T. Gibbs #define PCIXINIT_PCIX50_66 0x0000C000ul 24117d24755SJustin T. Gibbs #define PCIXINIT_PCIX66_100 0x0000A000ul 24217d24755SJustin T. Gibbs #define PCIXINIT_PCIX100_133 0x00008000ul 24317d24755SJustin T. Gibbs #define PCI_BUS_MODES_INDEX(devconfig) \ 24417d24755SJustin T. Gibbs (((devconfig) & PCIXINITPAT) >> 13) 24517d24755SJustin T. Gibbs static const char *pci_bus_modes[] = 24617d24755SJustin T. Gibbs { 24717d24755SJustin T. Gibbs "PCI bus mode unknown", 24817d24755SJustin T. Gibbs "PCI bus mode unknown", 24917d24755SJustin T. Gibbs "PCI bus mode unknown", 25017d24755SJustin T. Gibbs "PCI bus mode unknown", 25179649302SGavin Atkinson "PCI-X 101-133MHz", 25279649302SGavin Atkinson "PCI-X 67-100MHz", 25379649302SGavin Atkinson "PCI-X 50-66MHz", 25479649302SGavin Atkinson "PCI 33 or 66MHz" 25517d24755SJustin T. Gibbs }; 25617d24755SJustin T. Gibbs 25717d24755SJustin T. Gibbs #define TESTMODE 0x00000800ul 25817d24755SJustin T. Gibbs #define IRDY_RST 0x00000200ul 25917d24755SJustin T. Gibbs #define FRAME_RST 0x00000100ul 26017d24755SJustin T. Gibbs #define PCI64BIT 0x00000080ul 26117d24755SJustin T. Gibbs #define MRDCEN 0x00000040ul 26217d24755SJustin T. Gibbs #define ENDIANSEL 0x00000020ul 26317d24755SJustin T. Gibbs #define MIXQWENDIANEN 0x00000008ul 26417d24755SJustin T. Gibbs #define DACEN 0x00000004ul 26517d24755SJustin T. Gibbs #define STPWLEVEL 0x00000002ul 26617d24755SJustin T. Gibbs #define QWENDIANSEL 0x00000001ul 26717d24755SJustin T. Gibbs 26817d24755SJustin T. Gibbs #define DEVCONFIG1 0x44 26917d24755SJustin T. Gibbs #define PREQDIS 0x01 27017d24755SJustin T. Gibbs 27117d24755SJustin T. Gibbs #define CSIZE_LATTIME 0x0c 27217d24755SJustin T. Gibbs #define CACHESIZE 0x000000fful 27317d24755SJustin T. Gibbs #define LATTIME 0x0000ff00ul 27417d24755SJustin T. Gibbs 27517d24755SJustin T. Gibbs static int ahd_check_extport(struct ahd_softc *ahd); 27617d24755SJustin T. Gibbs static void ahd_configure_termination(struct ahd_softc *ahd, 27717d24755SJustin T. Gibbs u_int adapter_control); 27817d24755SJustin T. Gibbs static void ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat); 27917d24755SJustin T. Gibbs 28017d24755SJustin T. Gibbs struct ahd_pci_identity * 281b3b25f2cSJustin T. Gibbs ahd_find_pci_device(aic_dev_softc_t pci) 28217d24755SJustin T. Gibbs { 28317d24755SJustin T. Gibbs uint64_t full_id; 28417d24755SJustin T. Gibbs uint16_t device; 28517d24755SJustin T. Gibbs uint16_t vendor; 28617d24755SJustin T. Gibbs uint16_t subdevice; 28717d24755SJustin T. Gibbs uint16_t subvendor; 28817d24755SJustin T. Gibbs struct ahd_pci_identity *entry; 28917d24755SJustin T. Gibbs u_int i; 29017d24755SJustin T. Gibbs 291b3b25f2cSJustin T. Gibbs vendor = aic_pci_read_config(pci, PCIR_DEVVENDOR, /*bytes*/2); 292b3b25f2cSJustin T. Gibbs device = aic_pci_read_config(pci, PCIR_DEVICE, /*bytes*/2); 293b3b25f2cSJustin T. Gibbs subvendor = aic_pci_read_config(pci, PCIR_SUBVEND_0, /*bytes*/2); 294b3b25f2cSJustin T. Gibbs subdevice = aic_pci_read_config(pci, PCIR_SUBDEV_0, /*bytes*/2); 29517d24755SJustin T. Gibbs full_id = ahd_compose_id(device, 29617d24755SJustin T. Gibbs vendor, 29717d24755SJustin T. Gibbs subdevice, 29817d24755SJustin T. Gibbs subvendor); 29917d24755SJustin T. Gibbs 3004164174aSJustin T. Gibbs /* 3014164174aSJustin T. Gibbs * If we are configured to attach to HostRAID 3024164174aSJustin T. Gibbs * controllers, mask out the IROC/HostRAID bit 3034164174aSJustin T. Gibbs * in the 3044164174aSJustin T. Gibbs */ 3054164174aSJustin T. Gibbs if (ahd_attach_to_HostRAID_controllers) 3064164174aSJustin T. Gibbs full_id &= ID_ALL_IROC_MASK; 3074164174aSJustin T. Gibbs 30817d24755SJustin T. Gibbs for (i = 0; i < ahd_num_pci_devs; i++) { 30917d24755SJustin T. Gibbs entry = &ahd_pci_ident_table[i]; 31017d24755SJustin T. Gibbs if (entry->full_id == (full_id & entry->id_mask)) { 31117d24755SJustin T. Gibbs /* Honor exclusion entries. */ 31217d24755SJustin T. Gibbs if (entry->name == NULL) 31317d24755SJustin T. Gibbs return (NULL); 31417d24755SJustin T. Gibbs return (entry); 31517d24755SJustin T. Gibbs } 31617d24755SJustin T. Gibbs } 31717d24755SJustin T. Gibbs return (NULL); 31817d24755SJustin T. Gibbs } 31917d24755SJustin T. Gibbs 32017d24755SJustin T. Gibbs int 32117d24755SJustin T. Gibbs ahd_pci_config(struct ahd_softc *ahd, struct ahd_pci_identity *entry) 32217d24755SJustin T. Gibbs { 32317d24755SJustin T. Gibbs struct scb_data *shared_scb_data; 32417d24755SJustin T. Gibbs u_int command; 32517d24755SJustin T. Gibbs uint32_t devconfig; 3264164174aSJustin T. Gibbs uint16_t device; 32717d24755SJustin T. Gibbs uint16_t subvendor; 32817d24755SJustin T. Gibbs int error; 32917d24755SJustin T. Gibbs 33017d24755SJustin T. Gibbs shared_scb_data = NULL; 331454bf169SScott Long ahd->description = entry->name; 332454bf169SScott Long /* 3334164174aSJustin T. Gibbs * Record if this is a HostRAID board. 3344164174aSJustin T. Gibbs */ 3354164174aSJustin T. Gibbs device = aic_pci_read_config(ahd->dev_softc, 3364164174aSJustin T. Gibbs PCIR_DEVICE, /*bytes*/2); 3374164174aSJustin T. Gibbs if (DEVID_9005_HOSTRAID(device)) 3384164174aSJustin T. Gibbs ahd->flags |= AHD_HOSTRAID_BOARD; 3394164174aSJustin T. Gibbs 3404164174aSJustin T. Gibbs /* 341454bf169SScott Long * Record if this is an HP board. 342454bf169SScott Long */ 343b3b25f2cSJustin T. Gibbs subvendor = aic_pci_read_config(ahd->dev_softc, 344454bf169SScott Long PCIR_SUBVEND_0, /*bytes*/2); 345454bf169SScott Long if (subvendor == SUBID_HP) 346454bf169SScott Long ahd->flags |= AHD_HP_BOARD; 347454bf169SScott Long 34817d24755SJustin T. Gibbs error = entry->setup(ahd); 34917d24755SJustin T. Gibbs if (error != 0) 35017d24755SJustin T. Gibbs return (error); 35117d24755SJustin T. Gibbs 3526eb7ebfeSJohn Baldwin /* 3536eb7ebfeSJohn Baldwin * Find the PCI-X cap pointer. If we don't find it, 3546eb7ebfeSJohn Baldwin * pcix_ptr will be 0. 3556eb7ebfeSJohn Baldwin */ 3566eb7ebfeSJohn Baldwin pci_find_extcap(ahd->dev_softc, PCIY_PCIX, &ahd->pcix_ptr); 357b3b25f2cSJustin T. Gibbs devconfig = aic_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4); 35817d24755SJustin T. Gibbs if ((devconfig & PCIXINITPAT) == PCIXINIT_PCI33_66) { 35917d24755SJustin T. Gibbs ahd->chip |= AHD_PCI; 36017d24755SJustin T. Gibbs /* Disable PCIX workarounds when running in PCI mode. */ 36117d24755SJustin T. Gibbs ahd->bugs &= ~AHD_PCIX_BUG_MASK; 36217d24755SJustin T. Gibbs } else { 36317d24755SJustin T. Gibbs ahd->chip |= AHD_PCIX; 3646eb7ebfeSJohn Baldwin if (ahd->pcix_ptr == 0) 3656eb7ebfeSJohn Baldwin return (ENXIO); 36617d24755SJustin T. Gibbs } 36717d24755SJustin T. Gibbs ahd->bus_description = pci_bus_modes[PCI_BUS_MODES_INDEX(devconfig)]; 36817d24755SJustin T. Gibbs 369b3b25f2cSJustin T. Gibbs aic_power_state_change(ahd, AIC_POWER_STATE_D0); 37017d24755SJustin T. Gibbs 37117d24755SJustin T. Gibbs error = ahd_pci_map_registers(ahd); 37217d24755SJustin T. Gibbs if (error != 0) 37317d24755SJustin T. Gibbs return (error); 37417d24755SJustin T. Gibbs 37517d24755SJustin T. Gibbs /* 37617d24755SJustin T. Gibbs * If we need to support high memory, enable dual 37717d24755SJustin T. Gibbs * address cycles. This bit must be set to enable 37817d24755SJustin T. Gibbs * high address bit generation even if we are on a 37917d24755SJustin T. Gibbs * 64bit bus (PCI64BIT set in devconfig). 38017d24755SJustin T. Gibbs */ 38117d24755SJustin T. Gibbs if ((ahd->flags & (AHD_39BIT_ADDRESSING|AHD_64BIT_ADDRESSING)) != 0) { 38217d24755SJustin T. Gibbs uint32_t devconfig; 38317d24755SJustin T. Gibbs 38417d24755SJustin T. Gibbs if (bootverbose) 38517d24755SJustin T. Gibbs printf("%s: Enabling 39Bit Addressing\n", 38617d24755SJustin T. Gibbs ahd_name(ahd)); 387b3b25f2cSJustin T. Gibbs devconfig = aic_pci_read_config(ahd->dev_softc, 38817d24755SJustin T. Gibbs DEVCONFIG, /*bytes*/4); 38917d24755SJustin T. Gibbs devconfig |= DACEN; 390b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, DEVCONFIG, 39117d24755SJustin T. Gibbs devconfig, /*bytes*/4); 39217d24755SJustin T. Gibbs } 39317d24755SJustin T. Gibbs 39417d24755SJustin T. Gibbs /* Ensure busmastering is enabled */ 395b3b25f2cSJustin T. Gibbs command = aic_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2); 39617d24755SJustin T. Gibbs command |= PCIM_CMD_BUSMASTEREN; 397b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_COMMAND, command, /*bytes*/2); 39817d24755SJustin T. Gibbs 39917d24755SJustin T. Gibbs error = ahd_softc_init(ahd); 40017d24755SJustin T. Gibbs if (error != 0) 40117d24755SJustin T. Gibbs return (error); 40217d24755SJustin T. Gibbs 40317d24755SJustin T. Gibbs ahd->bus_intr = ahd_pci_intr; 40417d24755SJustin T. Gibbs 4051d528d67SJustin T. Gibbs error = ahd_reset(ahd, /*reinit*/FALSE); 40617d24755SJustin T. Gibbs if (error != 0) 40717d24755SJustin T. Gibbs return (ENXIO); 40817d24755SJustin T. Gibbs 40917d24755SJustin T. Gibbs ahd->pci_cachesize = 410b3b25f2cSJustin T. Gibbs aic_pci_read_config(ahd->dev_softc, CSIZE_LATTIME, 41117d24755SJustin T. Gibbs /*bytes*/1) & CACHESIZE; 41217d24755SJustin T. Gibbs ahd->pci_cachesize *= 4; 41317d24755SJustin T. Gibbs 41417d24755SJustin T. Gibbs ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 41517d24755SJustin T. Gibbs /* See if we have a SEEPROM and perform auto-term */ 41617d24755SJustin T. Gibbs error = ahd_check_extport(ahd); 41717d24755SJustin T. Gibbs if (error != 0) 41817d24755SJustin T. Gibbs return (error); 41917d24755SJustin T. Gibbs 42017d24755SJustin T. Gibbs /* Core initialization */ 42117d24755SJustin T. Gibbs error = ahd_init(ahd); 42217d24755SJustin T. Gibbs if (error != 0) 42317d24755SJustin T. Gibbs return (error); 42417d24755SJustin T. Gibbs 42517d24755SJustin T. Gibbs /* 42617d24755SJustin T. Gibbs * Allow interrupts now that we are completely setup. 42717d24755SJustin T. Gibbs */ 42817d24755SJustin T. Gibbs error = ahd_pci_map_int(ahd); 42917d24755SJustin T. Gibbs if (error != 0) 43017d24755SJustin T. Gibbs return (error); 43117d24755SJustin T. Gibbs 432032b0a17SScott Long ahd_lock(ahd); 43317d24755SJustin T. Gibbs /* 43417d24755SJustin T. Gibbs * Link this softc in with all other ahd instances. 43517d24755SJustin T. Gibbs */ 43617d24755SJustin T. Gibbs ahd_softc_insert(ahd); 437032b0a17SScott Long ahd_unlock(ahd); 43817d24755SJustin T. Gibbs return (0); 43917d24755SJustin T. Gibbs } 44017d24755SJustin T. Gibbs 44117d24755SJustin T. Gibbs /* 442454bf169SScott Long * Perform some simple tests that should catch situations where 443454bf169SScott Long * our registers are invalidly mapped. 444454bf169SScott Long */ 445454bf169SScott Long int 446454bf169SScott Long ahd_pci_test_register_access(struct ahd_softc *ahd) 447454bf169SScott Long { 4480794987dSJustin T. Gibbs uint32_t cmd; 449176b648eSJustin T. Gibbs u_int targpcistat; 450176b648eSJustin T. Gibbs u_int pci_status1; 45197cae63dSScott Long int error; 4520794987dSJustin T. Gibbs uint8_t hcntrl; 45397cae63dSScott Long 45497cae63dSScott Long error = EIO; 45597cae63dSScott Long 4560794987dSJustin T. Gibbs /* 4570794987dSJustin T. Gibbs * Enable PCI error interrupt status, but suppress NMIs 4580794987dSJustin T. Gibbs * generated by SERR raised due to target aborts. 4590794987dSJustin T. Gibbs */ 460b3b25f2cSJustin T. Gibbs cmd = aic_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2); 461b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_COMMAND, 4620794987dSJustin T. Gibbs cmd & ~PCIM_CMD_SERRESPEN, /*bytes*/2); 463454bf169SScott Long 464454bf169SScott Long /* 465454bf169SScott Long * First a simple test to see if any 466454bf169SScott Long * registers can be read. Reading 467454bf169SScott Long * HCNTRL has no side effects and has 468454bf169SScott Long * at least one bit that is guaranteed to 469454bf169SScott Long * be zero so it is a good register to 470454bf169SScott Long * use for this test. 471454bf169SScott Long */ 4720794987dSJustin T. Gibbs hcntrl = ahd_inb(ahd, HCNTRL); 4730794987dSJustin T. Gibbs if (hcntrl == 0xFF) 47497cae63dSScott Long goto fail; 475454bf169SScott Long 476454bf169SScott Long /* 477454bf169SScott Long * Next create a situation where write combining 478454bf169SScott Long * or read prefetching could be initiated by the 479454bf169SScott Long * CPU or host bridge. Our device does not support 480454bf169SScott Long * either, so look for data corruption and/or flaged 481ba079c0dSScott Long * PCI errors. First pause without causing another 482ba079c0dSScott Long * chip reset. 483454bf169SScott Long */ 484ba079c0dSScott Long hcntrl &= ~CHIPRST; 4850794987dSJustin T. Gibbs ahd_outb(ahd, HCNTRL, hcntrl|PAUSE); 4860794987dSJustin T. Gibbs while (ahd_is_paused(ahd) == 0) 4870794987dSJustin T. Gibbs ; 488176b648eSJustin T. Gibbs 489176b648eSJustin T. Gibbs /* Clear any PCI errors that occurred before our driver attached. */ 490176b648eSJustin T. Gibbs ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); 491176b648eSJustin T. Gibbs targpcistat = ahd_inb(ahd, TARGPCISTAT); 492176b648eSJustin T. Gibbs ahd_outb(ahd, TARGPCISTAT, targpcistat); 493b3b25f2cSJustin T. Gibbs pci_status1 = aic_pci_read_config(ahd->dev_softc, 494176b648eSJustin T. Gibbs PCIR_STATUS + 1, /*bytes*/1); 495b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1, 496176b648eSJustin T. Gibbs pci_status1, /*bytes*/1); 497176b648eSJustin T. Gibbs ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 498176b648eSJustin T. Gibbs ahd_outb(ahd, CLRINT, CLRPCIINT); 499176b648eSJustin T. Gibbs 5000794987dSJustin T. Gibbs ahd_outb(ahd, SEQCTL0, PERRORDIS); 50197cae63dSScott Long ahd_outl(ahd, SRAM_BASE, 0x5aa555aa); 50297cae63dSScott Long if (ahd_inl(ahd, SRAM_BASE) != 0x5aa555aa) 50397cae63dSScott Long goto fail; 504454bf169SScott Long 505454bf169SScott Long if ((ahd_inb(ahd, INTSTAT) & PCIINT) != 0) { 50697cae63dSScott Long u_int targpcistat; 50797cae63dSScott Long 50897cae63dSScott Long ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); 50997cae63dSScott Long targpcistat = ahd_inb(ahd, TARGPCISTAT); 51097cae63dSScott Long if ((targpcistat & STA) != 0) 51197cae63dSScott Long goto fail; 51297cae63dSScott Long } 51397cae63dSScott Long 51497cae63dSScott Long error = 0; 51597cae63dSScott Long 51697cae63dSScott Long fail: 51797cae63dSScott Long if ((ahd_inb(ahd, INTSTAT) & PCIINT) != 0) { 518454bf169SScott Long 519454bf169SScott Long ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); 520454bf169SScott Long targpcistat = ahd_inb(ahd, TARGPCISTAT); 521454bf169SScott Long 522454bf169SScott Long /* Silently clear any latched errors. */ 523454bf169SScott Long ahd_outb(ahd, TARGPCISTAT, targpcistat); 524b3b25f2cSJustin T. Gibbs pci_status1 = aic_pci_read_config(ahd->dev_softc, 525454bf169SScott Long PCIR_STATUS + 1, /*bytes*/1); 526b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1, 527454bf169SScott Long pci_status1, /*bytes*/1); 52897cae63dSScott Long ahd_outb(ahd, CLRINT, CLRPCIINT); 529454bf169SScott Long } 5300794987dSJustin T. Gibbs ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS); 531b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_COMMAND, cmd, /*bytes*/2); 53297cae63dSScott Long return (error); 533454bf169SScott Long } 534454bf169SScott Long 535454bf169SScott Long /* 53617d24755SJustin T. Gibbs * Check the external port logic for a serial eeprom 53717d24755SJustin T. Gibbs * and termination/cable detection contrls. 53817d24755SJustin T. Gibbs */ 53917d24755SJustin T. Gibbs static int 54017d24755SJustin T. Gibbs ahd_check_extport(struct ahd_softc *ahd) 54117d24755SJustin T. Gibbs { 542d7cff4abSJustin T. Gibbs struct vpd_config vpd; 54317d24755SJustin T. Gibbs struct seeprom_config *sc; 54417d24755SJustin T. Gibbs u_int adapter_control; 54517d24755SJustin T. Gibbs int have_seeprom; 54617d24755SJustin T. Gibbs int error; 54717d24755SJustin T. Gibbs 54817d24755SJustin T. Gibbs sc = ahd->seep_config; 54917d24755SJustin T. Gibbs have_seeprom = ahd_acquire_seeprom(ahd); 55017d24755SJustin T. Gibbs if (have_seeprom) { 55117d24755SJustin T. Gibbs u_int start_addr; 55217d24755SJustin T. Gibbs 553d7cff4abSJustin T. Gibbs /* 554d7cff4abSJustin T. Gibbs * Fetch VPD for this function and parse it. 555d7cff4abSJustin T. Gibbs */ 556d7cff4abSJustin T. Gibbs if (bootverbose) 557d7cff4abSJustin T. Gibbs printf("%s: Reading VPD from SEEPROM...", 558d7cff4abSJustin T. Gibbs ahd_name(ahd)); 559d7cff4abSJustin T. Gibbs 560d7cff4abSJustin T. Gibbs /* Address is always in units of 16bit words */ 561d7cff4abSJustin T. Gibbs start_addr = ((2 * sizeof(*sc)) 562d7cff4abSJustin T. Gibbs + (sizeof(vpd) * (ahd->channel - 'A'))) / 2; 563d7cff4abSJustin T. Gibbs 564d7cff4abSJustin T. Gibbs error = ahd_read_seeprom(ahd, (uint16_t *)&vpd, 565d7cff4abSJustin T. Gibbs start_addr, sizeof(vpd)/2, 566d7cff4abSJustin T. Gibbs /*bytestream*/TRUE); 567d7cff4abSJustin T. Gibbs if (error == 0) 568d7cff4abSJustin T. Gibbs error = ahd_parse_vpddata(ahd, &vpd); 569d7cff4abSJustin T. Gibbs if (bootverbose) 570d7cff4abSJustin T. Gibbs printf("%s: VPD parsing %s\n", 571d7cff4abSJustin T. Gibbs ahd_name(ahd), 572d7cff4abSJustin T. Gibbs error == 0 ? "successful" : "failed"); 573d7cff4abSJustin T. Gibbs 57417d24755SJustin T. Gibbs if (bootverbose) 57517d24755SJustin T. Gibbs printf("%s: Reading SEEPROM...", ahd_name(ahd)); 57617d24755SJustin T. Gibbs 57717d24755SJustin T. Gibbs /* Address is always in units of 16bit words */ 57817d24755SJustin T. Gibbs start_addr = (sizeof(*sc) / 2) * (ahd->channel - 'A'); 57917d24755SJustin T. Gibbs 58017d24755SJustin T. Gibbs error = ahd_read_seeprom(ahd, (uint16_t *)sc, 581d7cff4abSJustin T. Gibbs start_addr, sizeof(*sc)/2, 582d7cff4abSJustin T. Gibbs /*bytestream*/FALSE); 58317d24755SJustin T. Gibbs 58417d24755SJustin T. Gibbs if (error != 0) { 58517d24755SJustin T. Gibbs printf("Unable to read SEEPROM\n"); 58617d24755SJustin T. Gibbs have_seeprom = 0; 58717d24755SJustin T. Gibbs } else { 58817d24755SJustin T. Gibbs have_seeprom = ahd_verify_cksum(sc); 58917d24755SJustin T. Gibbs 59017d24755SJustin T. Gibbs if (bootverbose) { 59117d24755SJustin T. Gibbs if (have_seeprom == 0) 59217d24755SJustin T. Gibbs printf ("checksum error\n"); 59317d24755SJustin T. Gibbs else 59417d24755SJustin T. Gibbs printf ("done.\n"); 59517d24755SJustin T. Gibbs } 59617d24755SJustin T. Gibbs } 59717d24755SJustin T. Gibbs ahd_release_seeprom(ahd); 59817d24755SJustin T. Gibbs } 59917d24755SJustin T. Gibbs 60017d24755SJustin T. Gibbs if (!have_seeprom) { 60117d24755SJustin T. Gibbs u_int nvram_scb; 60217d24755SJustin T. Gibbs 60317d24755SJustin T. Gibbs /* 60417d24755SJustin T. Gibbs * Pull scratch ram settings and treat them as 60517d24755SJustin T. Gibbs * if they are the contents of an seeprom if 60617d24755SJustin T. Gibbs * the 'ADPT', 'BIOS', or 'ASPI' signature is found 60717d24755SJustin T. Gibbs * in SCB 0xFF. We manually compose the data as 16bit 60817d24755SJustin T. Gibbs * values to avoid endian issues. 60917d24755SJustin T. Gibbs */ 61017d24755SJustin T. Gibbs ahd_set_scbptr(ahd, 0xFF); 61117d24755SJustin T. Gibbs nvram_scb = ahd_inb_scbram(ahd, SCB_BASE + NVRAM_SCB_OFFSET); 61217d24755SJustin T. Gibbs if (nvram_scb != 0xFF 61317d24755SJustin T. Gibbs && ((ahd_inb_scbram(ahd, SCB_BASE + 0) == 'A' 61417d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'D' 61517d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'P' 61617d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'T') 61717d24755SJustin T. Gibbs || (ahd_inb_scbram(ahd, SCB_BASE + 0) == 'B' 61817d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'I' 61917d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'O' 62017d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'S') 62117d24755SJustin T. Gibbs || (ahd_inb_scbram(ahd, SCB_BASE + 0) == 'A' 62217d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'S' 62317d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'P' 62417d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'I'))) { 62517d24755SJustin T. Gibbs uint16_t *sc_data; 62617d24755SJustin T. Gibbs int i; 62717d24755SJustin T. Gibbs 62817d24755SJustin T. Gibbs ahd_set_scbptr(ahd, nvram_scb); 62917d24755SJustin T. Gibbs sc_data = (uint16_t *)sc; 63017d24755SJustin T. Gibbs for (i = 0; i < 64; i += 2) 63117d24755SJustin T. Gibbs *sc_data++ = ahd_inw_scbram(ahd, SCB_BASE+i); 63217d24755SJustin T. Gibbs have_seeprom = ahd_verify_cksum(sc); 63317d24755SJustin T. Gibbs if (have_seeprom) 63417d24755SJustin T. Gibbs ahd->flags |= AHD_SCB_CONFIG_USED; 63517d24755SJustin T. Gibbs } 63617d24755SJustin T. Gibbs } 63717d24755SJustin T. Gibbs 638f4e98881SRuslan Ermilov #ifdef AHD_DEBUG 63917d24755SJustin T. Gibbs if (have_seeprom != 0 64017d24755SJustin T. Gibbs && (ahd_debug & AHD_DUMP_SEEPROM) != 0) { 641d7cff4abSJustin T. Gibbs uint16_t *sc_data; 64217d24755SJustin T. Gibbs int i; 64317d24755SJustin T. Gibbs 64417d24755SJustin T. Gibbs printf("%s: Seeprom Contents:", ahd_name(ahd)); 645d7cff4abSJustin T. Gibbs sc_data = (uint16_t *)sc; 64617d24755SJustin T. Gibbs for (i = 0; i < (sizeof(*sc)); i += 2) 647d7cff4abSJustin T. Gibbs printf("\n\t0x%.4x", sc_data[i]); 64817d24755SJustin T. Gibbs printf("\n"); 64917d24755SJustin T. Gibbs } 65017d24755SJustin T. Gibbs #endif 65117d24755SJustin T. Gibbs 65217d24755SJustin T. Gibbs if (!have_seeprom) { 65317d24755SJustin T. Gibbs if (bootverbose) 65417d24755SJustin T. Gibbs printf("%s: No SEEPROM available.\n", ahd_name(ahd)); 65517d24755SJustin T. Gibbs ahd->flags |= AHD_USEDEFAULTS; 65617d24755SJustin T. Gibbs error = ahd_default_config(ahd); 65717d24755SJustin T. Gibbs adapter_control = CFAUTOTERM|CFSEAUTOTERM; 65817d24755SJustin T. Gibbs free(ahd->seep_config, M_DEVBUF); 65917d24755SJustin T. Gibbs ahd->seep_config = NULL; 66017d24755SJustin T. Gibbs } else { 66117d24755SJustin T. Gibbs error = ahd_parse_cfgdata(ahd, sc); 66217d24755SJustin T. Gibbs adapter_control = sc->adapter_control; 66317d24755SJustin T. Gibbs } 66417d24755SJustin T. Gibbs if (error != 0) 66517d24755SJustin T. Gibbs return (error); 66617d24755SJustin T. Gibbs 66717d24755SJustin T. Gibbs ahd_configure_termination(ahd, adapter_control); 66817d24755SJustin T. Gibbs 66917d24755SJustin T. Gibbs return (0); 67017d24755SJustin T. Gibbs } 67117d24755SJustin T. Gibbs 67217d24755SJustin T. Gibbs static void 67317d24755SJustin T. Gibbs ahd_configure_termination(struct ahd_softc *ahd, u_int adapter_control) 67417d24755SJustin T. Gibbs { 67517d24755SJustin T. Gibbs int error; 67617d24755SJustin T. Gibbs u_int sxfrctl1; 67717d24755SJustin T. Gibbs uint8_t termctl; 67817d24755SJustin T. Gibbs uint32_t devconfig; 67917d24755SJustin T. Gibbs 680b3b25f2cSJustin T. Gibbs devconfig = aic_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4); 68117d24755SJustin T. Gibbs devconfig &= ~STPWLEVEL; 6821a1fbd0bSJustin T. Gibbs if ((ahd->flags & AHD_STPWLEVEL_A) != 0) 68317d24755SJustin T. Gibbs devconfig |= STPWLEVEL; 6841a1fbd0bSJustin T. Gibbs if (bootverbose) 6851a1fbd0bSJustin T. Gibbs printf("%s: STPWLEVEL is %s\n", 6861a1fbd0bSJustin T. Gibbs ahd_name(ahd), (devconfig & STPWLEVEL) ? "on" : "off"); 687b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, DEVCONFIG, devconfig, /*bytes*/4); 68817d24755SJustin T. Gibbs 68917d24755SJustin T. Gibbs /* Make sure current sensing is off. */ 69017d24755SJustin T. Gibbs if ((ahd->flags & AHD_CURRENT_SENSING) != 0) { 69117d24755SJustin T. Gibbs (void)ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0); 69217d24755SJustin T. Gibbs } 69317d24755SJustin T. Gibbs 69417d24755SJustin T. Gibbs /* 69517d24755SJustin T. Gibbs * Read to sense. Write to set. 69617d24755SJustin T. Gibbs */ 69717d24755SJustin T. Gibbs error = ahd_read_flexport(ahd, FLXADDR_TERMCTL, &termctl); 69817d24755SJustin T. Gibbs if ((adapter_control & CFAUTOTERM) == 0) { 69917d24755SJustin T. Gibbs if (bootverbose) 70017d24755SJustin T. Gibbs printf("%s: Manual Primary Termination\n", 70117d24755SJustin T. Gibbs ahd_name(ahd)); 70217d24755SJustin T. Gibbs termctl &= ~(FLX_TERMCTL_ENPRILOW|FLX_TERMCTL_ENPRIHIGH); 70317d24755SJustin T. Gibbs if ((adapter_control & CFSTERM) != 0) 70417d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENPRILOW; 70517d24755SJustin T. Gibbs if ((adapter_control & CFWSTERM) != 0) 70617d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENPRIHIGH; 70717d24755SJustin T. Gibbs } else if (error != 0) { 70817d24755SJustin T. Gibbs printf("%s: Primary Auto-Term Sensing failed! " 70917d24755SJustin T. Gibbs "Using Defaults.\n", ahd_name(ahd)); 71017d24755SJustin T. Gibbs termctl = FLX_TERMCTL_ENPRILOW|FLX_TERMCTL_ENPRIHIGH; 71117d24755SJustin T. Gibbs } 71217d24755SJustin T. Gibbs 71317d24755SJustin T. Gibbs if ((adapter_control & CFSEAUTOTERM) == 0) { 71417d24755SJustin T. Gibbs if (bootverbose) 71517d24755SJustin T. Gibbs printf("%s: Manual Secondary Termination\n", 71617d24755SJustin T. Gibbs ahd_name(ahd)); 71717d24755SJustin T. Gibbs termctl &= ~(FLX_TERMCTL_ENSECLOW|FLX_TERMCTL_ENSECHIGH); 71817d24755SJustin T. Gibbs if ((adapter_control & CFSELOWTERM) != 0) 71917d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENSECLOW; 72017d24755SJustin T. Gibbs if ((adapter_control & CFSEHIGHTERM) != 0) 72117d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENSECHIGH; 72217d24755SJustin T. Gibbs } else if (error != 0) { 72317d24755SJustin T. Gibbs printf("%s: Secondary Auto-Term Sensing failed! " 72417d24755SJustin T. Gibbs "Using Defaults.\n", ahd_name(ahd)); 72517d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENSECLOW|FLX_TERMCTL_ENSECHIGH; 72617d24755SJustin T. Gibbs } 72717d24755SJustin T. Gibbs 72817d24755SJustin T. Gibbs /* 72917d24755SJustin T. Gibbs * Now set the termination based on what we found. 73017d24755SJustin T. Gibbs */ 73117d24755SJustin T. Gibbs sxfrctl1 = ahd_inb(ahd, SXFRCTL1) & ~STPWEN; 732b3b25f2cSJustin T. Gibbs ahd->flags &= ~AHD_TERM_ENB_A; 73317d24755SJustin T. Gibbs if ((termctl & FLX_TERMCTL_ENPRILOW) != 0) { 73417d24755SJustin T. Gibbs ahd->flags |= AHD_TERM_ENB_A; 73517d24755SJustin T. Gibbs sxfrctl1 |= STPWEN; 73617d24755SJustin T. Gibbs } 73717d24755SJustin T. Gibbs /* Must set the latch once in order to be effective. */ 73817d24755SJustin T. Gibbs ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN); 73917d24755SJustin T. Gibbs ahd_outb(ahd, SXFRCTL1, sxfrctl1); 74017d24755SJustin T. Gibbs 74117d24755SJustin T. Gibbs error = ahd_write_flexport(ahd, FLXADDR_TERMCTL, termctl); 74217d24755SJustin T. Gibbs if (error != 0) { 74317d24755SJustin T. Gibbs printf("%s: Unable to set termination settings!\n", 74417d24755SJustin T. Gibbs ahd_name(ahd)); 74517d24755SJustin T. Gibbs } else if (bootverbose) { 74617d24755SJustin T. Gibbs printf("%s: Primary High byte termination %sabled\n", 74717d24755SJustin T. Gibbs ahd_name(ahd), 74817d24755SJustin T. Gibbs (termctl & FLX_TERMCTL_ENPRIHIGH) ? "En" : "Dis"); 74917d24755SJustin T. Gibbs 75017d24755SJustin T. Gibbs printf("%s: Primary Low byte termination %sabled\n", 75117d24755SJustin T. Gibbs ahd_name(ahd), 75217d24755SJustin T. Gibbs (termctl & FLX_TERMCTL_ENPRILOW) ? "En" : "Dis"); 75317d24755SJustin T. Gibbs 75417d24755SJustin T. Gibbs printf("%s: Secondary High byte termination %sabled\n", 75517d24755SJustin T. Gibbs ahd_name(ahd), 75617d24755SJustin T. Gibbs (termctl & FLX_TERMCTL_ENSECHIGH) ? "En" : "Dis"); 75717d24755SJustin T. Gibbs 75817d24755SJustin T. Gibbs printf("%s: Secondary Low byte termination %sabled\n", 75917d24755SJustin T. Gibbs ahd_name(ahd), 76017d24755SJustin T. Gibbs (termctl & FLX_TERMCTL_ENSECLOW) ? "En" : "Dis"); 76117d24755SJustin T. Gibbs } 76217d24755SJustin T. Gibbs return; 76317d24755SJustin T. Gibbs } 76417d24755SJustin T. Gibbs 76517d24755SJustin T. Gibbs #define DPE 0x80 76617d24755SJustin T. Gibbs #define SSE 0x40 76717d24755SJustin T. Gibbs #define RMA 0x20 76817d24755SJustin T. Gibbs #define RTA 0x10 76917d24755SJustin T. Gibbs #define STA 0x08 77017d24755SJustin T. Gibbs #define DPR 0x01 77117d24755SJustin T. Gibbs 77217d24755SJustin T. Gibbs static const char *split_status_source[] = 77317d24755SJustin T. Gibbs { 77417d24755SJustin T. Gibbs "DFF0", 77517d24755SJustin T. Gibbs "DFF1", 77617d24755SJustin T. Gibbs "OVLY", 77717d24755SJustin T. Gibbs "CMC", 77817d24755SJustin T. Gibbs }; 77917d24755SJustin T. Gibbs 78017d24755SJustin T. Gibbs static const char *pci_status_source[] = 78117d24755SJustin T. Gibbs { 78217d24755SJustin T. Gibbs "DFF0", 78317d24755SJustin T. Gibbs "DFF1", 78417d24755SJustin T. Gibbs "SG", 78517d24755SJustin T. Gibbs "CMC", 78617d24755SJustin T. Gibbs "OVLY", 78717d24755SJustin T. Gibbs "NONE", 78817d24755SJustin T. Gibbs "MSI", 78917d24755SJustin T. Gibbs "TARG" 79017d24755SJustin T. Gibbs }; 79117d24755SJustin T. Gibbs 79217d24755SJustin T. Gibbs static const char *split_status_strings[] = 79317d24755SJustin T. Gibbs { 794acae33b0SJustin T. Gibbs "%s: Received split response in %s.\n", 79517d24755SJustin T. Gibbs "%s: Received split completion error message in %s\n", 79617d24755SJustin T. Gibbs "%s: Receive overrun in %s\n", 79717d24755SJustin T. Gibbs "%s: Count not complete in %s\n", 79817d24755SJustin T. Gibbs "%s: Split completion data bucket in %s\n", 79917d24755SJustin T. Gibbs "%s: Split completion address error in %s\n", 80017d24755SJustin T. Gibbs "%s: Split completion byte count error in %s\n", 801acae33b0SJustin T. Gibbs "%s: Signaled Target-abort to early terminate a split in %s\n" 80217d24755SJustin T. Gibbs }; 80317d24755SJustin T. Gibbs 80417d24755SJustin T. Gibbs static const char *pci_status_strings[] = 80517d24755SJustin T. Gibbs { 80617d24755SJustin T. Gibbs "%s: Data Parity Error has been reported via PERR# in %s\n", 80717d24755SJustin T. Gibbs "%s: Target initial wait state error in %s\n", 80817d24755SJustin T. Gibbs "%s: Split completion read data parity error in %s\n", 80917d24755SJustin T. Gibbs "%s: Split completion address attribute parity error in %s\n", 81017d24755SJustin T. Gibbs "%s: Received a Target Abort in %s\n", 81117d24755SJustin T. Gibbs "%s: Received a Master Abort in %s\n", 81217d24755SJustin T. Gibbs "%s: Signal System Error Detected in %s\n", 81317d24755SJustin T. Gibbs "%s: Address or Write Phase Parity Error Detected in %s.\n" 81417d24755SJustin T. Gibbs }; 81517d24755SJustin T. Gibbs 81617d24755SJustin T. Gibbs void 81717d24755SJustin T. Gibbs ahd_pci_intr(struct ahd_softc *ahd) 81817d24755SJustin T. Gibbs { 81917d24755SJustin T. Gibbs uint8_t pci_status[8]; 82017d24755SJustin T. Gibbs ahd_mode_state saved_modes; 82117d24755SJustin T. Gibbs u_int pci_status1; 82217d24755SJustin T. Gibbs u_int intstat; 82317d24755SJustin T. Gibbs u_int i; 82417d24755SJustin T. Gibbs u_int reg; 82517d24755SJustin T. Gibbs 82617d24755SJustin T. Gibbs intstat = ahd_inb(ahd, INTSTAT); 82717d24755SJustin T. Gibbs 82817d24755SJustin T. Gibbs if ((intstat & SPLTINT) != 0) 82917d24755SJustin T. Gibbs ahd_pci_split_intr(ahd, intstat); 83017d24755SJustin T. Gibbs 83117d24755SJustin T. Gibbs if ((intstat & PCIINT) == 0) 83217d24755SJustin T. Gibbs return; 83317d24755SJustin T. Gibbs 83417d24755SJustin T. Gibbs printf("%s: PCI error Interrupt\n", ahd_name(ahd)); 83517d24755SJustin T. Gibbs saved_modes = ahd_save_modes(ahd); 83617d24755SJustin T. Gibbs ahd_dump_card_state(ahd); 83717d24755SJustin T. Gibbs ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); 83817d24755SJustin T. Gibbs for (i = 0, reg = DF0PCISTAT; i < 8; i++, reg++) { 83917d24755SJustin T. Gibbs 84017d24755SJustin T. Gibbs if (i == 5) 84117d24755SJustin T. Gibbs continue; 84217d24755SJustin T. Gibbs pci_status[i] = ahd_inb(ahd, reg); 843acae33b0SJustin T. Gibbs /* Clear latched errors. So our interrupt deasserts. */ 84417d24755SJustin T. Gibbs ahd_outb(ahd, reg, pci_status[i]); 84517d24755SJustin T. Gibbs } 84617d24755SJustin T. Gibbs 84717d24755SJustin T. Gibbs for (i = 0; i < 8; i++) { 84817d24755SJustin T. Gibbs u_int bit; 84917d24755SJustin T. Gibbs 85017d24755SJustin T. Gibbs if (i == 5) 85117d24755SJustin T. Gibbs continue; 85217d24755SJustin T. Gibbs 85317d24755SJustin T. Gibbs for (bit = 0; bit < 8; bit++) { 85417d24755SJustin T. Gibbs 85517d24755SJustin T. Gibbs if ((pci_status[i] & (0x1 << bit)) != 0) { 85617d24755SJustin T. Gibbs static const char *s; 85717d24755SJustin T. Gibbs 85817d24755SJustin T. Gibbs s = pci_status_strings[bit]; 85917d24755SJustin T. Gibbs if (i == 7/*TARG*/ && bit == 3) 86097cae63dSScott Long s = "%s: Signaled Target Abort\n"; 86117d24755SJustin T. Gibbs printf(s, ahd_name(ahd), pci_status_source[i]); 86217d24755SJustin T. Gibbs } 86317d24755SJustin T. Gibbs } 86417d24755SJustin T. Gibbs } 865b3b25f2cSJustin T. Gibbs pci_status1 = aic_pci_read_config(ahd->dev_softc, 86617d24755SJustin T. Gibbs PCIR_STATUS + 1, /*bytes*/1); 867b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1, 86817d24755SJustin T. Gibbs pci_status1, /*bytes*/1); 86917d24755SJustin T. Gibbs ahd_restore_modes(ahd, saved_modes); 87097cae63dSScott Long ahd_outb(ahd, CLRINT, CLRPCIINT); 87117d24755SJustin T. Gibbs ahd_unpause(ahd); 87217d24755SJustin T. Gibbs } 87317d24755SJustin T. Gibbs 87417d24755SJustin T. Gibbs static void 87517d24755SJustin T. Gibbs ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat) 87617d24755SJustin T. Gibbs { 87717d24755SJustin T. Gibbs uint8_t split_status[4]; 87817d24755SJustin T. Gibbs uint8_t split_status1[4]; 87917d24755SJustin T. Gibbs uint8_t sg_split_status[2]; 88017d24755SJustin T. Gibbs uint8_t sg_split_status1[2]; 88117d24755SJustin T. Gibbs ahd_mode_state saved_modes; 88217d24755SJustin T. Gibbs u_int i; 8836eb7ebfeSJohn Baldwin uint32_t pcix_status; 88417d24755SJustin T. Gibbs 88517d24755SJustin T. Gibbs /* 88617d24755SJustin T. Gibbs * Check for splits in all modes. Modes 0 and 1 88717d24755SJustin T. Gibbs * additionally have SG engine splits to look at. 88817d24755SJustin T. Gibbs */ 8896eb7ebfeSJohn Baldwin pcix_status = aic_pci_read_config(ahd->dev_softc, 8906eb7ebfeSJohn Baldwin ahd->pcix_ptr + PCIXR_STATUS, /*bytes*/ 4); 89117d24755SJustin T. Gibbs printf("%s: PCI Split Interrupt - PCI-X status = 0x%x\n", 8926eb7ebfeSJohn Baldwin ahd_name(ahd), pcix_status >> 16); 89317d24755SJustin T. Gibbs saved_modes = ahd_save_modes(ahd); 89417d24755SJustin T. Gibbs for (i = 0; i < 4; i++) { 89517d24755SJustin T. Gibbs ahd_set_modes(ahd, i, i); 89617d24755SJustin T. Gibbs 89717d24755SJustin T. Gibbs split_status[i] = ahd_inb(ahd, DCHSPLTSTAT0); 89817d24755SJustin T. Gibbs split_status1[i] = ahd_inb(ahd, DCHSPLTSTAT1); 899acae33b0SJustin T. Gibbs /* Clear latched errors. So our interrupt deasserts. */ 90017d24755SJustin T. Gibbs ahd_outb(ahd, DCHSPLTSTAT0, split_status[i]); 90117d24755SJustin T. Gibbs ahd_outb(ahd, DCHSPLTSTAT1, split_status1[i]); 902d7cff4abSJustin T. Gibbs if (i > 1) 90317d24755SJustin T. Gibbs continue; 90417d24755SJustin T. Gibbs sg_split_status[i] = ahd_inb(ahd, SGSPLTSTAT0); 90517d24755SJustin T. Gibbs sg_split_status1[i] = ahd_inb(ahd, SGSPLTSTAT1); 906acae33b0SJustin T. Gibbs /* Clear latched errors. So our interrupt deasserts. */ 90717d24755SJustin T. Gibbs ahd_outb(ahd, SGSPLTSTAT0, sg_split_status[i]); 90817d24755SJustin T. Gibbs ahd_outb(ahd, SGSPLTSTAT1, sg_split_status1[i]); 90917d24755SJustin T. Gibbs } 91017d24755SJustin T. Gibbs 91117d24755SJustin T. Gibbs for (i = 0; i < 4; i++) { 91217d24755SJustin T. Gibbs u_int bit; 91317d24755SJustin T. Gibbs 91417d24755SJustin T. Gibbs for (bit = 0; bit < 8; bit++) { 91517d24755SJustin T. Gibbs 91617d24755SJustin T. Gibbs if ((split_status[i] & (0x1 << bit)) != 0) { 91717d24755SJustin T. Gibbs static const char *s; 91817d24755SJustin T. Gibbs 91917d24755SJustin T. Gibbs s = split_status_strings[bit]; 92017d24755SJustin T. Gibbs printf(s, ahd_name(ahd), 92117d24755SJustin T. Gibbs split_status_source[i]); 92217d24755SJustin T. Gibbs } 92317d24755SJustin T. Gibbs 924d7cff4abSJustin T. Gibbs if (i > 1) 92517d24755SJustin T. Gibbs continue; 92617d24755SJustin T. Gibbs 92717d24755SJustin T. Gibbs if ((sg_split_status[i] & (0x1 << bit)) != 0) { 92817d24755SJustin T. Gibbs static const char *s; 92917d24755SJustin T. Gibbs 93017d24755SJustin T. Gibbs s = split_status_strings[bit]; 93117d24755SJustin T. Gibbs printf(s, ahd_name(ahd), "SG"); 93217d24755SJustin T. Gibbs } 93317d24755SJustin T. Gibbs } 93417d24755SJustin T. Gibbs } 93517d24755SJustin T. Gibbs /* 93617d24755SJustin T. Gibbs * Clear PCI-X status bits. 93717d24755SJustin T. Gibbs */ 9386eb7ebfeSJohn Baldwin aic_pci_write_config(ahd->dev_softc, ahd->pcix_ptr + PCIXR_STATUS, 9396eb7ebfeSJohn Baldwin pcix_status, /*bytes*/4); 94097cae63dSScott Long ahd_outb(ahd, CLRINT, CLRSPLTINT); 94117d24755SJustin T. Gibbs ahd_restore_modes(ahd, saved_modes); 94217d24755SJustin T. Gibbs } 94317d24755SJustin T. Gibbs 94417d24755SJustin T. Gibbs static int 945197696e9SJustin T. Gibbs ahd_aic7901_setup(struct ahd_softc *ahd) 946197696e9SJustin T. Gibbs { 947197696e9SJustin T. Gibbs 948197696e9SJustin T. Gibbs ahd->chip = AHD_AIC7901; 949c8ee7177SJustin T. Gibbs ahd->features = AHD_AIC7901_FE; 950c8ee7177SJustin T. Gibbs return (ahd_aic790X_setup(ahd)); 951197696e9SJustin T. Gibbs } 952197696e9SJustin T. Gibbs 953197696e9SJustin T. Gibbs static int 9541a1fbd0bSJustin T. Gibbs ahd_aic7901A_setup(struct ahd_softc *ahd) 9551a1fbd0bSJustin T. Gibbs { 9561a1fbd0bSJustin T. Gibbs 9571a1fbd0bSJustin T. Gibbs ahd->chip = AHD_AIC7901A; 958c8ee7177SJustin T. Gibbs ahd->features = AHD_AIC7901A_FE; 959c8ee7177SJustin T. Gibbs return (ahd_aic790X_setup(ahd)); 9601a1fbd0bSJustin T. Gibbs } 9611a1fbd0bSJustin T. Gibbs 962454bf169SScott Long static int 963454bf169SScott Long ahd_aic7902_setup(struct ahd_softc *ahd) 964454bf169SScott Long { 965c8ee7177SJustin T. Gibbs ahd->chip = AHD_AIC7902; 966c8ee7177SJustin T. Gibbs ahd->features = AHD_AIC7902_FE; 967c8ee7177SJustin T. Gibbs return (ahd_aic790X_setup(ahd)); 968c8ee7177SJustin T. Gibbs } 969c8ee7177SJustin T. Gibbs 970c8ee7177SJustin T. Gibbs static int 971c8ee7177SJustin T. Gibbs ahd_aic790X_setup(struct ahd_softc *ahd) 972c8ee7177SJustin T. Gibbs { 973b3b25f2cSJustin T. Gibbs aic_dev_softc_t pci; 974454bf169SScott Long u_int rev; 975454bf169SScott Long 976454bf169SScott Long pci = ahd->dev_softc; 977b3b25f2cSJustin T. Gibbs rev = aic_pci_read_config(pci, PCIR_REVID, /*bytes*/1); 978454bf169SScott Long if (rev < ID_AIC7902_PCI_REV_A4) { 979454bf169SScott Long printf("%s: Unable to attach to unsupported chip revision %d\n", 980454bf169SScott Long ahd_name(ahd), rev); 981b3b25f2cSJustin T. Gibbs aic_pci_write_config(pci, PCIR_COMMAND, 0, /*bytes*/2); 982454bf169SScott Long return (ENXIO); 983454bf169SScott Long } 984b3b25f2cSJustin T. Gibbs ahd->channel = aic_get_pci_function(pci) + 'A'; 985454bf169SScott Long if (rev < ID_AIC7902_PCI_REV_B0) { 986454bf169SScott Long /* 987454bf169SScott Long * Enable A series workarounds. 988454bf169SScott Long */ 989454bf169SScott Long ahd->bugs |= AHD_SENT_SCB_UPDATE_BUG|AHD_ABORT_LQI_BUG 990454bf169SScott Long | AHD_PKT_BITBUCKET_BUG|AHD_LONG_SETIMO_BUG 991454bf169SScott Long | AHD_NLQICRC_DELAYED_BUG|AHD_SCSIRST_BUG 992454bf169SScott Long | AHD_LQO_ATNO_BUG|AHD_AUTOFLUSH_BUG 993454bf169SScott Long | AHD_CLRLQO_AUTOCLR_BUG|AHD_PCIX_MMAPIO_BUG 9942cd3cc37SJustin T. Gibbs | AHD_PCIX_CHIPRST_BUG|AHD_PCIX_SCBRAM_RD_BUG 9952cd3cc37SJustin T. Gibbs | AHD_PKTIZED_STATUS_BUG|AHD_PKT_LUN_BUG 9962cd3cc37SJustin T. Gibbs | AHD_MDFF_WSCBPTR_BUG|AHD_REG_SLOW_SETTLE_BUG 9972cd3cc37SJustin T. Gibbs | AHD_SET_MODE_BUG|AHD_BUSFREEREV_BUG 998d7cff4abSJustin T. Gibbs | AHD_NONPACKFIFO_BUG|AHD_PACED_NEGTABLE_BUG 999d7cff4abSJustin T. Gibbs | AHD_FAINT_LED_BUG; 1000454bf169SScott Long 1001454bf169SScott Long /* 1002454bf169SScott Long * IO Cell paramter setup. 1003454bf169SScott Long */ 1004454bf169SScott Long AHD_SET_PRECOMP(ahd, AHD_PRECOMP_CUTBACK_29); 1005454bf169SScott Long 1006454bf169SScott Long if ((ahd->flags & AHD_HP_BOARD) == 0) 1007454bf169SScott Long AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVA); 1008454bf169SScott Long } else { 1009454bf169SScott Long u_int devconfig1; 1010454bf169SScott Long 1011454bf169SScott Long ahd->features |= AHD_RTI|AHD_NEW_IOCELL_OPTS 10124ddea3e2SJustin T. Gibbs | AHD_NEW_DFCNTRL_OPTS|AHD_FAST_CDB_DELIVERY; 101305899a48SJustin T. Gibbs ahd->bugs |= AHD_LQOOVERRUN_BUG|AHD_EARLY_REQ_BUG; 1014c8ee7177SJustin T. Gibbs 1015c8ee7177SJustin T. Gibbs /* 1016c8ee7177SJustin T. Gibbs * Some issues have been resolved in the 7901B. 1017c8ee7177SJustin T. Gibbs */ 1018c8ee7177SJustin T. Gibbs if ((ahd->features & AHD_MULTI_FUNC) != 0) 101905899a48SJustin T. Gibbs ahd->bugs |= AHD_INTCOLLISION_BUG|AHD_ABORT_LQI_BUG 102005899a48SJustin T. Gibbs | AHD_BUSFREEREV_BUG; 1021454bf169SScott Long 1022454bf169SScott Long /* 1023454bf169SScott Long * IO Cell paramter setup. 1024454bf169SScott Long */ 1025454bf169SScott Long AHD_SET_PRECOMP(ahd, AHD_PRECOMP_CUTBACK_29); 1026454bf169SScott Long AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVB); 1027454bf169SScott Long AHD_SET_AMPLITUDE(ahd, AHD_AMPLITUDE_DEF); 1028454bf169SScott Long 1029454bf169SScott Long /* 1030454bf169SScott Long * Set the PREQDIS bit for H2B which disables some workaround 1031454bf169SScott Long * that doesn't work on regular PCI busses. 1032454bf169SScott Long * XXX - Find out exactly what this does from the hardware 1033454bf169SScott Long * folks! 1034454bf169SScott Long */ 1035b3b25f2cSJustin T. Gibbs devconfig1 = aic_pci_read_config(pci, DEVCONFIG1, /*bytes*/1); 1036b3b25f2cSJustin T. Gibbs aic_pci_write_config(pci, DEVCONFIG1, 1037454bf169SScott Long devconfig1|PREQDIS, /*bytes*/1); 1038b3b25f2cSJustin T. Gibbs devconfig1 = aic_pci_read_config(pci, DEVCONFIG1, /*bytes*/1); 1039454bf169SScott Long } 1040454bf169SScott Long 1041454bf169SScott Long return (0); 1042454bf169SScott Long } 1043