1098ca2bdSWarner Losh /*- 217d24755SJustin T. Gibbs * Product specific probe and attach routines for: 317d24755SJustin T. Gibbs * aic7901 and aic7902 SCSI controllers 417d24755SJustin T. Gibbs * 5718cf2ccSPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 6718cf2ccSPedro F. Giffuni * 717d24755SJustin T. Gibbs * Copyright (c) 1994-2001 Justin T. Gibbs. 81a1fbd0bSJustin T. Gibbs * Copyright (c) 2000-2002 Adaptec Inc. 917d24755SJustin T. Gibbs * All rights reserved. 1017d24755SJustin T. Gibbs * 1117d24755SJustin T. Gibbs * Redistribution and use in source and binary forms, with or without 1217d24755SJustin T. Gibbs * modification, are permitted provided that the following conditions 1317d24755SJustin T. Gibbs * are met: 1417d24755SJustin T. Gibbs * 1. Redistributions of source code must retain the above copyright 1517d24755SJustin T. Gibbs * notice, this list of conditions, and the following disclaimer, 1617d24755SJustin T. Gibbs * without modification. 1717d24755SJustin T. Gibbs * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1817d24755SJustin T. Gibbs * substantially similar to the "NO WARRANTY" disclaimer below 1917d24755SJustin T. Gibbs * ("Disclaimer") and any redistribution must be conditioned upon 2017d24755SJustin T. Gibbs * including a substantially similar Disclaimer requirement for further 2117d24755SJustin T. Gibbs * binary redistribution. 2217d24755SJustin T. Gibbs * 3. Neither the names of the above-listed copyright holders nor the names 2317d24755SJustin T. Gibbs * of any contributors may be used to endorse or promote products derived 2417d24755SJustin T. Gibbs * from this software without specific prior written permission. 2517d24755SJustin T. Gibbs * 2617d24755SJustin T. Gibbs * Alternatively, this software may be distributed under the terms of the 2717d24755SJustin T. Gibbs * GNU General Public License ("GPL") version 2 as published by the Free 2817d24755SJustin T. Gibbs * Software Foundation. 2917d24755SJustin T. Gibbs * 3017d24755SJustin T. Gibbs * NO WARRANTY 3117d24755SJustin T. Gibbs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3217d24755SJustin T. Gibbs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3317d24755SJustin T. Gibbs * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3417d24755SJustin T. Gibbs * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3517d24755SJustin T. Gibbs * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3617d24755SJustin T. Gibbs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3717d24755SJustin T. Gibbs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3817d24755SJustin T. Gibbs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3917d24755SJustin T. Gibbs * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4017d24755SJustin T. Gibbs * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4117d24755SJustin T. Gibbs * POSSIBILITY OF SUCH DAMAGES. 4217d24755SJustin T. Gibbs * 4322dbd4c6SJustin T. Gibbs * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#88 $ 4417d24755SJustin T. Gibbs */ 4517d24755SJustin T. Gibbs 4617d24755SJustin T. Gibbs #include <dev/aic7xxx/aic79xx_osm.h> 4717d24755SJustin T. Gibbs #include <dev/aic7xxx/aic79xx_inline.h> 4817d24755SJustin T. Gibbs 4917d24755SJustin T. Gibbs static __inline uint64_t 5017d24755SJustin T. Gibbs ahd_compose_id(u_int device, u_int vendor, u_int subdevice, u_int subvendor) 5117d24755SJustin T. Gibbs { 5217d24755SJustin T. Gibbs uint64_t id; 5317d24755SJustin T. Gibbs 5417d24755SJustin T. Gibbs id = subvendor 5517d24755SJustin T. Gibbs | (subdevice << 16) 5617d24755SJustin T. Gibbs | ((uint64_t)vendor << 32) 5717d24755SJustin T. Gibbs | ((uint64_t)device << 48); 5817d24755SJustin T. Gibbs 5917d24755SJustin T. Gibbs return (id); 6017d24755SJustin T. Gibbs } 6117d24755SJustin T. Gibbs 6217d24755SJustin T. Gibbs #define ID_ALL_MASK 0xFFFFFFFFFFFFFFFFull 634164174aSJustin T. Gibbs #define ID_ALL_IROC_MASK 0xFF7FFFFFFFFFFFFFull 6417d24755SJustin T. Gibbs #define ID_DEV_VENDOR_MASK 0xFFFFFFFF00000000ull 6517d24755SJustin T. Gibbs #define ID_9005_GENERIC_MASK 0xFFF0FFFF00000000ull 664164174aSJustin T. Gibbs #define ID_9005_GENERIC_IROC_MASK 0xFF70FFFF00000000ull 6717d24755SJustin T. Gibbs 6817d24755SJustin T. Gibbs #define ID_AIC7901 0x800F9005FFFF9005ull 691a1fbd0bSJustin T. Gibbs #define ID_AHA_29320A 0x8000900500609005ull 70197696e9SJustin T. Gibbs #define ID_AHA_29320ALP 0x8017900500449005ull 71*b25765b4SOleksandr Tymoshenko #define ID_AHA_29320LPE 0x8017900500459005ull 72197696e9SJustin T. Gibbs 73197696e9SJustin T. Gibbs #define ID_AIC7901A 0x801E9005FFFF9005ull 74454bf169SScott Long #define ID_AHA_29320LP 0x8014900500449005ull 7517d24755SJustin T. Gibbs 7617d24755SJustin T. Gibbs #define ID_AIC7902 0x801F9005FFFF9005ull 77454bf169SScott Long #define ID_AIC7902_B 0x801D9005FFFF9005ull 7817d24755SJustin T. Gibbs #define ID_AHA_39320 0x8010900500409005ull 79b3b25f2cSJustin T. Gibbs #define ID_AHA_29320 0x8012900500429005ull 80b3b25f2cSJustin T. Gibbs #define ID_AHA_29320B 0x8013900500439005ull 81197696e9SJustin T. Gibbs #define ID_AHA_39320_B 0x8015900500409005ull 8222dbd4c6SJustin T. Gibbs #define ID_AHA_39320_B_DELL 0x8015900501681028ull 83acae33b0SJustin T. Gibbs #define ID_AHA_39320A 0x8016900500409005ull 8417d24755SJustin T. Gibbs #define ID_AHA_39320D 0x8011900500419005ull 85454bf169SScott Long #define ID_AHA_39320D_B 0x801C900500419005ull 86454bf169SScott Long #define ID_AHA_39320D_HP 0x8011900500AC0E11ull 87454bf169SScott Long #define ID_AHA_39320D_B_HP 0x801C900500AC0E11ull 8817d24755SJustin T. Gibbs #define ID_AIC7902_PCI_REV_A4 0x3 891a1fbd0bSJustin T. Gibbs #define ID_AIC7902_PCI_REV_B0 0x10 90454bf169SScott Long #define SUBID_HP 0x0E11 917cfc62d8SAchim Leubner #define DEVICE8081 0x8081 927cfc62d8SAchim Leubner #define DEVICE8088 0x8088 937cfc62d8SAchim Leubner #define DEVICE8089 0x8089 947cfc62d8SAchim Leubner #define ADAPTECVENDORID 0x9005 957cfc62d8SAchim Leubner #define SUBVENDOR9005 0x9005 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 }, 140*b25765b4SOleksandr Tymoshenko { 141*b25765b4SOleksandr Tymoshenko ID_AHA_29320LPE, 142*b25765b4SOleksandr Tymoshenko ID_ALL_MASK, 143*b25765b4SOleksandr Tymoshenko "Adaptec 29320LPE Ultra320 SCSI adapter", 144*b25765b4SOleksandr Tymoshenko ahd_aic7901_setup 145*b25765b4SOleksandr Tymoshenko }, 146454bf169SScott Long /* aic7901A based controllers */ 147454bf169SScott Long { 148454bf169SScott Long ID_AHA_29320LP, 149454bf169SScott Long ID_ALL_MASK, 150454bf169SScott Long "Adaptec 29320LP Ultra320 SCSI adapter", 151454bf169SScott Long ahd_aic7901A_setup 152454bf169SScott Long }, 15317d24755SJustin T. Gibbs /* aic7902 based controllers */ 15417d24755SJustin T. Gibbs { 155b3b25f2cSJustin T. Gibbs ID_AHA_29320, 156b3b25f2cSJustin T. Gibbs ID_ALL_MASK, 157b3b25f2cSJustin T. Gibbs "Adaptec 29320 Ultra320 SCSI adapter", 158b3b25f2cSJustin T. Gibbs ahd_aic7902_setup 159b3b25f2cSJustin T. Gibbs }, 160b3b25f2cSJustin T. Gibbs { 161b3b25f2cSJustin T. Gibbs ID_AHA_29320B, 162b3b25f2cSJustin T. Gibbs ID_ALL_MASK, 163b3b25f2cSJustin T. Gibbs "Adaptec 29320B Ultra320 SCSI adapter", 164b3b25f2cSJustin T. Gibbs ahd_aic7902_setup 165b3b25f2cSJustin T. Gibbs }, 166b3b25f2cSJustin T. Gibbs { 16717d24755SJustin T. Gibbs ID_AHA_39320, 16817d24755SJustin T. Gibbs ID_ALL_MASK, 16917d24755SJustin T. Gibbs "Adaptec 39320 Ultra320 SCSI adapter", 17017d24755SJustin T. Gibbs ahd_aic7902_setup 17117d24755SJustin T. Gibbs }, 17217d24755SJustin T. Gibbs { 173197696e9SJustin T. Gibbs ID_AHA_39320_B, 174197696e9SJustin T. Gibbs ID_ALL_MASK, 175197696e9SJustin T. Gibbs "Adaptec 39320 Ultra320 SCSI adapter", 176197696e9SJustin T. Gibbs ahd_aic7902_setup 177197696e9SJustin T. Gibbs }, 178197696e9SJustin T. Gibbs { 17922dbd4c6SJustin T. Gibbs ID_AHA_39320_B_DELL, 18022dbd4c6SJustin T. Gibbs ID_ALL_MASK, 18122dbd4c6SJustin T. Gibbs "Adaptec (Dell OEM) 39320 Ultra320 SCSI adapter", 18222dbd4c6SJustin T. Gibbs ahd_aic7902_setup 18322dbd4c6SJustin T. Gibbs }, 18422dbd4c6SJustin T. Gibbs { 185acae33b0SJustin T. Gibbs ID_AHA_39320A, 186acae33b0SJustin T. Gibbs ID_ALL_MASK, 187acae33b0SJustin T. Gibbs "Adaptec 39320A Ultra320 SCSI adapter", 188acae33b0SJustin T. Gibbs ahd_aic7902_setup 189acae33b0SJustin T. Gibbs }, 190acae33b0SJustin T. Gibbs { 19117d24755SJustin T. Gibbs ID_AHA_39320D, 19217d24755SJustin T. Gibbs ID_ALL_MASK, 19317d24755SJustin T. Gibbs "Adaptec 39320D Ultra320 SCSI adapter", 19417d24755SJustin T. Gibbs ahd_aic7902_setup 19517d24755SJustin T. Gibbs }, 19617d24755SJustin T. Gibbs { 197454bf169SScott Long ID_AHA_39320D_HP, 19817d24755SJustin T. Gibbs ID_ALL_MASK, 199454bf169SScott Long "Adaptec (HP OEM) 39320D Ultra320 SCSI adapter", 200454bf169SScott Long ahd_aic7902_setup 201454bf169SScott Long }, 202454bf169SScott Long { 203454bf169SScott Long ID_AHA_39320D_B, 204454bf169SScott Long ID_ALL_MASK, 205454bf169SScott Long "Adaptec 39320D Ultra320 SCSI adapter", 206454bf169SScott Long ahd_aic7902_setup 207454bf169SScott Long }, 208454bf169SScott Long { 209454bf169SScott Long ID_AHA_39320D_B_HP, 210454bf169SScott Long ID_ALL_MASK, 211454bf169SScott Long "Adaptec (HP OEM) 39320D Ultra320 SCSI adapter", 21217d24755SJustin T. Gibbs ahd_aic7902_setup 21317d24755SJustin T. Gibbs }, 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); 2957cfc62d8SAchim Leubner 2967cfc62d8SAchim Leubner if ((vendor == ADAPTECVENDORID) && (subvendor == SUBVENDOR9005)) { 2977cfc62d8SAchim Leubner if ((device == DEVICE8081) || (device == DEVICE8088) || 2987cfc62d8SAchim Leubner (device == DEVICE8089)) { 2997cfc62d8SAchim Leubner printf("Controller device ID conflict with PMC Adaptec HBA\n"); 3007cfc62d8SAchim Leubner return (NULL); 3017cfc62d8SAchim Leubner } 3027cfc62d8SAchim Leubner } 3037cfc62d8SAchim Leubner 30417d24755SJustin T. Gibbs full_id = ahd_compose_id(device, 30517d24755SJustin T. Gibbs vendor, 30617d24755SJustin T. Gibbs subdevice, 30717d24755SJustin T. Gibbs subvendor); 30817d24755SJustin T. Gibbs 3094164174aSJustin T. Gibbs /* 3104164174aSJustin T. Gibbs * If we are configured to attach to HostRAID 3114164174aSJustin T. Gibbs * controllers, mask out the IROC/HostRAID bit 3124164174aSJustin T. Gibbs * in the 3134164174aSJustin T. Gibbs */ 3144164174aSJustin T. Gibbs if (ahd_attach_to_HostRAID_controllers) 3154164174aSJustin T. Gibbs full_id &= ID_ALL_IROC_MASK; 3164164174aSJustin T. Gibbs 31717d24755SJustin T. Gibbs for (i = 0; i < ahd_num_pci_devs; i++) { 31817d24755SJustin T. Gibbs entry = &ahd_pci_ident_table[i]; 31917d24755SJustin T. Gibbs if (entry->full_id == (full_id & entry->id_mask)) { 32017d24755SJustin T. Gibbs /* Honor exclusion entries. */ 32117d24755SJustin T. Gibbs if (entry->name == NULL) 32217d24755SJustin T. Gibbs return (NULL); 32317d24755SJustin T. Gibbs return (entry); 32417d24755SJustin T. Gibbs } 32517d24755SJustin T. Gibbs } 32617d24755SJustin T. Gibbs return (NULL); 32717d24755SJustin T. Gibbs } 32817d24755SJustin T. Gibbs 32917d24755SJustin T. Gibbs int 33017d24755SJustin T. Gibbs ahd_pci_config(struct ahd_softc *ahd, struct ahd_pci_identity *entry) 33117d24755SJustin T. Gibbs { 33217d24755SJustin T. Gibbs u_int command; 33317d24755SJustin T. Gibbs uint32_t devconfig; 3344164174aSJustin T. Gibbs uint16_t device; 33517d24755SJustin T. Gibbs uint16_t subvendor; 33617d24755SJustin T. Gibbs int error; 33717d24755SJustin T. Gibbs 338454bf169SScott Long ahd->description = entry->name; 339454bf169SScott Long /* 3404164174aSJustin T. Gibbs * Record if this is a HostRAID board. 3414164174aSJustin T. Gibbs */ 3424164174aSJustin T. Gibbs device = aic_pci_read_config(ahd->dev_softc, 3434164174aSJustin T. Gibbs PCIR_DEVICE, /*bytes*/2); 3444164174aSJustin T. Gibbs if (DEVID_9005_HOSTRAID(device)) 3454164174aSJustin T. Gibbs ahd->flags |= AHD_HOSTRAID_BOARD; 3464164174aSJustin T. Gibbs 3474164174aSJustin T. Gibbs /* 348454bf169SScott Long * Record if this is an HP board. 349454bf169SScott Long */ 350b3b25f2cSJustin T. Gibbs subvendor = aic_pci_read_config(ahd->dev_softc, 351454bf169SScott Long PCIR_SUBVEND_0, /*bytes*/2); 352454bf169SScott Long if (subvendor == SUBID_HP) 353454bf169SScott Long ahd->flags |= AHD_HP_BOARD; 354454bf169SScott Long 35517d24755SJustin T. Gibbs error = entry->setup(ahd); 35617d24755SJustin T. Gibbs if (error != 0) 35717d24755SJustin T. Gibbs return (error); 35817d24755SJustin T. Gibbs 3596eb7ebfeSJohn Baldwin /* 3606eb7ebfeSJohn Baldwin * Find the PCI-X cap pointer. If we don't find it, 3616eb7ebfeSJohn Baldwin * pcix_ptr will be 0. 3626eb7ebfeSJohn Baldwin */ 3633b0a4aefSJohn Baldwin pci_find_cap(ahd->dev_softc, PCIY_PCIX, &ahd->pcix_ptr); 364b3b25f2cSJustin T. Gibbs devconfig = aic_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4); 36517d24755SJustin T. Gibbs if ((devconfig & PCIXINITPAT) == PCIXINIT_PCI33_66) { 36617d24755SJustin T. Gibbs ahd->chip |= AHD_PCI; 36717d24755SJustin T. Gibbs /* Disable PCIX workarounds when running in PCI mode. */ 36817d24755SJustin T. Gibbs ahd->bugs &= ~AHD_PCIX_BUG_MASK; 36917d24755SJustin T. Gibbs } else { 37017d24755SJustin T. Gibbs ahd->chip |= AHD_PCIX; 3716eb7ebfeSJohn Baldwin if (ahd->pcix_ptr == 0) 3726eb7ebfeSJohn Baldwin return (ENXIO); 37317d24755SJustin T. Gibbs } 37417d24755SJustin T. Gibbs ahd->bus_description = pci_bus_modes[PCI_BUS_MODES_INDEX(devconfig)]; 37517d24755SJustin T. Gibbs 376b3b25f2cSJustin T. Gibbs aic_power_state_change(ahd, AIC_POWER_STATE_D0); 37717d24755SJustin T. Gibbs 37817d24755SJustin T. Gibbs error = ahd_pci_map_registers(ahd); 37917d24755SJustin T. Gibbs if (error != 0) 38017d24755SJustin T. Gibbs return (error); 38117d24755SJustin T. Gibbs 38217d24755SJustin T. Gibbs /* 38317d24755SJustin T. Gibbs * If we need to support high memory, enable dual 38417d24755SJustin T. Gibbs * address cycles. This bit must be set to enable 38517d24755SJustin T. Gibbs * high address bit generation even if we are on a 38617d24755SJustin T. Gibbs * 64bit bus (PCI64BIT set in devconfig). 38717d24755SJustin T. Gibbs */ 38817d24755SJustin T. Gibbs if ((ahd->flags & (AHD_39BIT_ADDRESSING|AHD_64BIT_ADDRESSING)) != 0) { 38917d24755SJustin T. Gibbs uint32_t devconfig; 39017d24755SJustin T. Gibbs 39117d24755SJustin T. Gibbs if (bootverbose) 39217d24755SJustin T. Gibbs printf("%s: Enabling 39Bit Addressing\n", 39317d24755SJustin T. Gibbs ahd_name(ahd)); 394b3b25f2cSJustin T. Gibbs devconfig = aic_pci_read_config(ahd->dev_softc, 39517d24755SJustin T. Gibbs DEVCONFIG, /*bytes*/4); 39617d24755SJustin T. Gibbs devconfig |= DACEN; 397b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, DEVCONFIG, 39817d24755SJustin T. Gibbs devconfig, /*bytes*/4); 39917d24755SJustin T. Gibbs } 40017d24755SJustin T. Gibbs 40117d24755SJustin T. Gibbs /* Ensure busmastering is enabled */ 402b3b25f2cSJustin T. Gibbs command = aic_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2); 40317d24755SJustin T. Gibbs command |= PCIM_CMD_BUSMASTEREN; 404b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_COMMAND, command, /*bytes*/2); 40517d24755SJustin T. Gibbs 40617d24755SJustin T. Gibbs error = ahd_softc_init(ahd); 40717d24755SJustin T. Gibbs if (error != 0) 40817d24755SJustin T. Gibbs return (error); 40917d24755SJustin T. Gibbs 41017d24755SJustin T. Gibbs ahd->bus_intr = ahd_pci_intr; 41117d24755SJustin T. Gibbs 4121d528d67SJustin T. Gibbs error = ahd_reset(ahd, /*reinit*/FALSE); 41317d24755SJustin T. Gibbs if (error != 0) 41417d24755SJustin T. Gibbs return (ENXIO); 41517d24755SJustin T. Gibbs 41617d24755SJustin T. Gibbs ahd->pci_cachesize = 417b3b25f2cSJustin T. Gibbs aic_pci_read_config(ahd->dev_softc, CSIZE_LATTIME, 41817d24755SJustin T. Gibbs /*bytes*/1) & CACHESIZE; 41917d24755SJustin T. Gibbs ahd->pci_cachesize *= 4; 42017d24755SJustin T. Gibbs 42117d24755SJustin T. Gibbs ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 42217d24755SJustin T. Gibbs /* See if we have a SEEPROM and perform auto-term */ 42317d24755SJustin T. Gibbs error = ahd_check_extport(ahd); 42417d24755SJustin T. Gibbs if (error != 0) 42517d24755SJustin T. Gibbs return (error); 42617d24755SJustin T. Gibbs 42717d24755SJustin T. Gibbs /* Core initialization */ 42817d24755SJustin T. Gibbs error = ahd_init(ahd); 42917d24755SJustin T. Gibbs if (error != 0) 43017d24755SJustin T. Gibbs return (error); 43117d24755SJustin T. Gibbs 43217d24755SJustin T. Gibbs /* 43317d24755SJustin T. Gibbs * Allow interrupts now that we are completely setup. 43417d24755SJustin T. Gibbs */ 43517d24755SJustin T. Gibbs error = ahd_pci_map_int(ahd); 43617d24755SJustin T. Gibbs if (error != 0) 43717d24755SJustin T. Gibbs return (error); 43817d24755SJustin T. Gibbs 439032b0a17SScott Long ahd_lock(ahd); 44017d24755SJustin T. Gibbs /* 44117d24755SJustin T. Gibbs * Link this softc in with all other ahd instances. 44217d24755SJustin T. Gibbs */ 44317d24755SJustin T. Gibbs ahd_softc_insert(ahd); 444032b0a17SScott Long ahd_unlock(ahd); 44517d24755SJustin T. Gibbs return (0); 44617d24755SJustin T. Gibbs } 44717d24755SJustin T. Gibbs 44817d24755SJustin T. Gibbs /* 449454bf169SScott Long * Perform some simple tests that should catch situations where 450454bf169SScott Long * our registers are invalidly mapped. 451454bf169SScott Long */ 452454bf169SScott Long int 453454bf169SScott Long ahd_pci_test_register_access(struct ahd_softc *ahd) 454454bf169SScott Long { 4550794987dSJustin T. Gibbs uint32_t cmd; 456176b648eSJustin T. Gibbs u_int targpcistat; 457176b648eSJustin T. Gibbs u_int pci_status1; 45897cae63dSScott Long int error; 4590794987dSJustin T. Gibbs uint8_t hcntrl; 46097cae63dSScott Long 46197cae63dSScott Long error = EIO; 46297cae63dSScott Long 4630794987dSJustin T. Gibbs /* 4640794987dSJustin T. Gibbs * Enable PCI error interrupt status, but suppress NMIs 4650794987dSJustin T. Gibbs * generated by SERR raised due to target aborts. 4660794987dSJustin T. Gibbs */ 467b3b25f2cSJustin T. Gibbs cmd = aic_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2); 468b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_COMMAND, 4690794987dSJustin T. Gibbs cmd & ~PCIM_CMD_SERRESPEN, /*bytes*/2); 470454bf169SScott Long 471454bf169SScott Long /* 472454bf169SScott Long * First a simple test to see if any 473454bf169SScott Long * registers can be read. Reading 474454bf169SScott Long * HCNTRL has no side effects and has 475454bf169SScott Long * at least one bit that is guaranteed to 476454bf169SScott Long * be zero so it is a good register to 477454bf169SScott Long * use for this test. 478454bf169SScott Long */ 4790794987dSJustin T. Gibbs hcntrl = ahd_inb(ahd, HCNTRL); 4800794987dSJustin T. Gibbs if (hcntrl == 0xFF) 48197cae63dSScott Long goto fail; 482454bf169SScott Long 483454bf169SScott Long /* 484454bf169SScott Long * Next create a situation where write combining 485454bf169SScott Long * or read prefetching could be initiated by the 486454bf169SScott Long * CPU or host bridge. Our device does not support 487594c945aSPedro F. Giffuni * either, so look for data corruption and/or flagged 488ba079c0dSScott Long * PCI errors. First pause without causing another 489ba079c0dSScott Long * chip reset. 490454bf169SScott Long */ 491ba079c0dSScott Long hcntrl &= ~CHIPRST; 4920794987dSJustin T. Gibbs ahd_outb(ahd, HCNTRL, hcntrl|PAUSE); 4930794987dSJustin T. Gibbs while (ahd_is_paused(ahd) == 0) 4940794987dSJustin T. Gibbs ; 495176b648eSJustin T. Gibbs 496176b648eSJustin T. Gibbs /* Clear any PCI errors that occurred before our driver attached. */ 497176b648eSJustin T. Gibbs ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); 498176b648eSJustin T. Gibbs targpcistat = ahd_inb(ahd, TARGPCISTAT); 499176b648eSJustin T. Gibbs ahd_outb(ahd, TARGPCISTAT, targpcistat); 500b3b25f2cSJustin T. Gibbs pci_status1 = aic_pci_read_config(ahd->dev_softc, 501176b648eSJustin T. Gibbs PCIR_STATUS + 1, /*bytes*/1); 502b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1, 503176b648eSJustin T. Gibbs pci_status1, /*bytes*/1); 504176b648eSJustin T. Gibbs ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 505176b648eSJustin T. Gibbs ahd_outb(ahd, CLRINT, CLRPCIINT); 506176b648eSJustin T. Gibbs 5070794987dSJustin T. Gibbs ahd_outb(ahd, SEQCTL0, PERRORDIS); 50897cae63dSScott Long ahd_outl(ahd, SRAM_BASE, 0x5aa555aa); 50997cae63dSScott Long if (ahd_inl(ahd, SRAM_BASE) != 0x5aa555aa) 51097cae63dSScott Long goto fail; 511454bf169SScott Long 512454bf169SScott Long if ((ahd_inb(ahd, INTSTAT) & PCIINT) != 0) { 51397cae63dSScott Long u_int targpcistat; 51497cae63dSScott Long 51597cae63dSScott Long ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); 51697cae63dSScott Long targpcistat = ahd_inb(ahd, TARGPCISTAT); 51797cae63dSScott Long if ((targpcistat & STA) != 0) 51897cae63dSScott Long goto fail; 51997cae63dSScott Long } 52097cae63dSScott Long 52197cae63dSScott Long error = 0; 52297cae63dSScott Long 52397cae63dSScott Long fail: 52497cae63dSScott Long if ((ahd_inb(ahd, INTSTAT) & PCIINT) != 0) { 525454bf169SScott Long ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); 526454bf169SScott Long targpcistat = ahd_inb(ahd, TARGPCISTAT); 527454bf169SScott Long 528454bf169SScott Long /* Silently clear any latched errors. */ 529454bf169SScott Long ahd_outb(ahd, TARGPCISTAT, targpcistat); 530b3b25f2cSJustin T. Gibbs pci_status1 = aic_pci_read_config(ahd->dev_softc, 531454bf169SScott Long PCIR_STATUS + 1, /*bytes*/1); 532b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1, 533454bf169SScott Long pci_status1, /*bytes*/1); 53497cae63dSScott Long ahd_outb(ahd, CLRINT, CLRPCIINT); 535454bf169SScott Long } 5360794987dSJustin T. Gibbs ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS); 537b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_COMMAND, cmd, /*bytes*/2); 53897cae63dSScott Long return (error); 539454bf169SScott Long } 540454bf169SScott Long 541454bf169SScott Long /* 54217d24755SJustin T. Gibbs * Check the external port logic for a serial eeprom 54317d24755SJustin T. Gibbs * and termination/cable detection contrls. 54417d24755SJustin T. Gibbs */ 54517d24755SJustin T. Gibbs static int 54617d24755SJustin T. Gibbs ahd_check_extport(struct ahd_softc *ahd) 54717d24755SJustin T. Gibbs { 548d7cff4abSJustin T. Gibbs struct vpd_config vpd; 54917d24755SJustin T. Gibbs struct seeprom_config *sc; 55017d24755SJustin T. Gibbs u_int adapter_control; 55117d24755SJustin T. Gibbs int have_seeprom; 55217d24755SJustin T. Gibbs int error; 55317d24755SJustin T. Gibbs 55417d24755SJustin T. Gibbs sc = ahd->seep_config; 55517d24755SJustin T. Gibbs have_seeprom = ahd_acquire_seeprom(ahd); 55617d24755SJustin T. Gibbs if (have_seeprom) { 55717d24755SJustin T. Gibbs u_int start_addr; 55817d24755SJustin T. Gibbs 559d7cff4abSJustin T. Gibbs /* 560d7cff4abSJustin T. Gibbs * Fetch VPD for this function and parse it. 561d7cff4abSJustin T. Gibbs */ 562d7cff4abSJustin T. Gibbs if (bootverbose) 563d7cff4abSJustin T. Gibbs printf("%s: Reading VPD from SEEPROM...", 564d7cff4abSJustin T. Gibbs ahd_name(ahd)); 565d7cff4abSJustin T. Gibbs 566d7cff4abSJustin T. Gibbs /* Address is always in units of 16bit words */ 567d7cff4abSJustin T. Gibbs start_addr = ((2 * sizeof(*sc)) 568d7cff4abSJustin T. Gibbs + (sizeof(vpd) * (ahd->channel - 'A'))) / 2; 569d7cff4abSJustin T. Gibbs 570d7cff4abSJustin T. Gibbs error = ahd_read_seeprom(ahd, (uint16_t *)&vpd, 571d7cff4abSJustin T. Gibbs start_addr, sizeof(vpd)/2, 572d7cff4abSJustin T. Gibbs /*bytestream*/TRUE); 573d7cff4abSJustin T. Gibbs if (error == 0) 574d7cff4abSJustin T. Gibbs error = ahd_parse_vpddata(ahd, &vpd); 575d7cff4abSJustin T. Gibbs if (bootverbose) 576d7cff4abSJustin T. Gibbs printf("%s: VPD parsing %s\n", 577d7cff4abSJustin T. Gibbs ahd_name(ahd), 578d7cff4abSJustin T. Gibbs error == 0 ? "successful" : "failed"); 579d7cff4abSJustin T. Gibbs 58017d24755SJustin T. Gibbs if (bootverbose) 58117d24755SJustin T. Gibbs printf("%s: Reading SEEPROM...", ahd_name(ahd)); 58217d24755SJustin T. Gibbs 58317d24755SJustin T. Gibbs /* Address is always in units of 16bit words */ 58417d24755SJustin T. Gibbs start_addr = (sizeof(*sc) / 2) * (ahd->channel - 'A'); 58517d24755SJustin T. Gibbs 58617d24755SJustin T. Gibbs error = ahd_read_seeprom(ahd, (uint16_t *)sc, 587d7cff4abSJustin T. Gibbs start_addr, sizeof(*sc)/2, 588d7cff4abSJustin T. Gibbs /*bytestream*/FALSE); 58917d24755SJustin T. Gibbs 59017d24755SJustin T. Gibbs if (error != 0) { 59117d24755SJustin T. Gibbs printf("Unable to read SEEPROM\n"); 59217d24755SJustin T. Gibbs have_seeprom = 0; 59317d24755SJustin T. Gibbs } else { 59417d24755SJustin T. Gibbs have_seeprom = ahd_verify_cksum(sc); 59517d24755SJustin T. Gibbs 59617d24755SJustin T. Gibbs if (bootverbose) { 59717d24755SJustin T. Gibbs if (have_seeprom == 0) 59817d24755SJustin T. Gibbs printf ("checksum error\n"); 59917d24755SJustin T. Gibbs else 60017d24755SJustin T. Gibbs printf ("done.\n"); 60117d24755SJustin T. Gibbs } 60217d24755SJustin T. Gibbs } 60317d24755SJustin T. Gibbs ahd_release_seeprom(ahd); 60417d24755SJustin T. Gibbs } 60517d24755SJustin T. Gibbs 60617d24755SJustin T. Gibbs if (!have_seeprom) { 60717d24755SJustin T. Gibbs u_int nvram_scb; 60817d24755SJustin T. Gibbs 60917d24755SJustin T. Gibbs /* 61017d24755SJustin T. Gibbs * Pull scratch ram settings and treat them as 61117d24755SJustin T. Gibbs * if they are the contents of an seeprom if 61217d24755SJustin T. Gibbs * the 'ADPT', 'BIOS', or 'ASPI' signature is found 61317d24755SJustin T. Gibbs * in SCB 0xFF. We manually compose the data as 16bit 61417d24755SJustin T. Gibbs * values to avoid endian issues. 61517d24755SJustin T. Gibbs */ 61617d24755SJustin T. Gibbs ahd_set_scbptr(ahd, 0xFF); 61717d24755SJustin T. Gibbs nvram_scb = ahd_inb_scbram(ahd, SCB_BASE + NVRAM_SCB_OFFSET); 61817d24755SJustin T. Gibbs if (nvram_scb != 0xFF 61917d24755SJustin T. Gibbs && ((ahd_inb_scbram(ahd, SCB_BASE + 0) == 'A' 62017d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'D' 62117d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'P' 62217d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'T') 62317d24755SJustin T. Gibbs || (ahd_inb_scbram(ahd, SCB_BASE + 0) == 'B' 62417d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'I' 62517d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'O' 62617d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'S') 62717d24755SJustin T. Gibbs || (ahd_inb_scbram(ahd, SCB_BASE + 0) == 'A' 62817d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 1) == 'S' 62917d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 2) == 'P' 63017d24755SJustin T. Gibbs && ahd_inb_scbram(ahd, SCB_BASE + 3) == 'I'))) { 63117d24755SJustin T. Gibbs uint16_t *sc_data; 63217d24755SJustin T. Gibbs int i; 63317d24755SJustin T. Gibbs 63417d24755SJustin T. Gibbs ahd_set_scbptr(ahd, nvram_scb); 63517d24755SJustin T. Gibbs sc_data = (uint16_t *)sc; 63617d24755SJustin T. Gibbs for (i = 0; i < 64; i += 2) 63717d24755SJustin T. Gibbs *sc_data++ = ahd_inw_scbram(ahd, SCB_BASE+i); 63817d24755SJustin T. Gibbs have_seeprom = ahd_verify_cksum(sc); 63917d24755SJustin T. Gibbs if (have_seeprom) 64017d24755SJustin T. Gibbs ahd->flags |= AHD_SCB_CONFIG_USED; 64117d24755SJustin T. Gibbs } 64217d24755SJustin T. Gibbs } 64317d24755SJustin T. Gibbs 644f4e98881SRuslan Ermilov #ifdef AHD_DEBUG 64517d24755SJustin T. Gibbs if (have_seeprom != 0 64617d24755SJustin T. Gibbs && (ahd_debug & AHD_DUMP_SEEPROM) != 0) { 647d7cff4abSJustin T. Gibbs uint16_t *sc_data; 64817d24755SJustin T. Gibbs int i; 64917d24755SJustin T. Gibbs 65017d24755SJustin T. Gibbs printf("%s: Seeprom Contents:", ahd_name(ahd)); 651d7cff4abSJustin T. Gibbs sc_data = (uint16_t *)sc; 65217d24755SJustin T. Gibbs for (i = 0; i < (sizeof(*sc)); i += 2) 653d7cff4abSJustin T. Gibbs printf("\n\t0x%.4x", sc_data[i]); 65417d24755SJustin T. Gibbs printf("\n"); 65517d24755SJustin T. Gibbs } 65617d24755SJustin T. Gibbs #endif 65717d24755SJustin T. Gibbs 65817d24755SJustin T. Gibbs if (!have_seeprom) { 65917d24755SJustin T. Gibbs if (bootverbose) 66017d24755SJustin T. Gibbs printf("%s: No SEEPROM available.\n", ahd_name(ahd)); 66117d24755SJustin T. Gibbs ahd->flags |= AHD_USEDEFAULTS; 66217d24755SJustin T. Gibbs error = ahd_default_config(ahd); 66317d24755SJustin T. Gibbs adapter_control = CFAUTOTERM|CFSEAUTOTERM; 66417d24755SJustin T. Gibbs free(ahd->seep_config, M_DEVBUF); 66517d24755SJustin T. Gibbs ahd->seep_config = NULL; 66617d24755SJustin T. Gibbs } else { 66717d24755SJustin T. Gibbs error = ahd_parse_cfgdata(ahd, sc); 66817d24755SJustin T. Gibbs adapter_control = sc->adapter_control; 66917d24755SJustin T. Gibbs } 67017d24755SJustin T. Gibbs if (error != 0) 67117d24755SJustin T. Gibbs return (error); 67217d24755SJustin T. Gibbs 67317d24755SJustin T. Gibbs ahd_configure_termination(ahd, adapter_control); 67417d24755SJustin T. Gibbs 67517d24755SJustin T. Gibbs return (0); 67617d24755SJustin T. Gibbs } 67717d24755SJustin T. Gibbs 67817d24755SJustin T. Gibbs static void 67917d24755SJustin T. Gibbs ahd_configure_termination(struct ahd_softc *ahd, u_int adapter_control) 68017d24755SJustin T. Gibbs { 68117d24755SJustin T. Gibbs int error; 68217d24755SJustin T. Gibbs u_int sxfrctl1; 68317d24755SJustin T. Gibbs uint8_t termctl; 68417d24755SJustin T. Gibbs uint32_t devconfig; 68517d24755SJustin T. Gibbs 686b3b25f2cSJustin T. Gibbs devconfig = aic_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4); 68717d24755SJustin T. Gibbs devconfig &= ~STPWLEVEL; 6881a1fbd0bSJustin T. Gibbs if ((ahd->flags & AHD_STPWLEVEL_A) != 0) 68917d24755SJustin T. Gibbs devconfig |= STPWLEVEL; 6901a1fbd0bSJustin T. Gibbs if (bootverbose) 6911a1fbd0bSJustin T. Gibbs printf("%s: STPWLEVEL is %s\n", 6921a1fbd0bSJustin T. Gibbs ahd_name(ahd), (devconfig & STPWLEVEL) ? "on" : "off"); 693b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, DEVCONFIG, devconfig, /*bytes*/4); 69417d24755SJustin T. Gibbs 69517d24755SJustin T. Gibbs /* Make sure current sensing is off. */ 69617d24755SJustin T. Gibbs if ((ahd->flags & AHD_CURRENT_SENSING) != 0) { 69717d24755SJustin T. Gibbs (void)ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0); 69817d24755SJustin T. Gibbs } 69917d24755SJustin T. Gibbs 70017d24755SJustin T. Gibbs /* 70117d24755SJustin T. Gibbs * Read to sense. Write to set. 70217d24755SJustin T. Gibbs */ 70317d24755SJustin T. Gibbs error = ahd_read_flexport(ahd, FLXADDR_TERMCTL, &termctl); 70417d24755SJustin T. Gibbs if ((adapter_control & CFAUTOTERM) == 0) { 70517d24755SJustin T. Gibbs if (bootverbose) 70617d24755SJustin T. Gibbs printf("%s: Manual Primary Termination\n", 70717d24755SJustin T. Gibbs ahd_name(ahd)); 70817d24755SJustin T. Gibbs termctl &= ~(FLX_TERMCTL_ENPRILOW|FLX_TERMCTL_ENPRIHIGH); 70917d24755SJustin T. Gibbs if ((adapter_control & CFSTERM) != 0) 71017d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENPRILOW; 71117d24755SJustin T. Gibbs if ((adapter_control & CFWSTERM) != 0) 71217d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENPRIHIGH; 71317d24755SJustin T. Gibbs } else if (error != 0) { 71417d24755SJustin T. Gibbs printf("%s: Primary Auto-Term Sensing failed! " 71517d24755SJustin T. Gibbs "Using Defaults.\n", ahd_name(ahd)); 71617d24755SJustin T. Gibbs termctl = FLX_TERMCTL_ENPRILOW|FLX_TERMCTL_ENPRIHIGH; 71717d24755SJustin T. Gibbs } 71817d24755SJustin T. Gibbs 71917d24755SJustin T. Gibbs if ((adapter_control & CFSEAUTOTERM) == 0) { 72017d24755SJustin T. Gibbs if (bootverbose) 72117d24755SJustin T. Gibbs printf("%s: Manual Secondary Termination\n", 72217d24755SJustin T. Gibbs ahd_name(ahd)); 72317d24755SJustin T. Gibbs termctl &= ~(FLX_TERMCTL_ENSECLOW|FLX_TERMCTL_ENSECHIGH); 72417d24755SJustin T. Gibbs if ((adapter_control & CFSELOWTERM) != 0) 72517d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENSECLOW; 72617d24755SJustin T. Gibbs if ((adapter_control & CFSEHIGHTERM) != 0) 72717d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENSECHIGH; 72817d24755SJustin T. Gibbs } else if (error != 0) { 72917d24755SJustin T. Gibbs printf("%s: Secondary Auto-Term Sensing failed! " 73017d24755SJustin T. Gibbs "Using Defaults.\n", ahd_name(ahd)); 73117d24755SJustin T. Gibbs termctl |= FLX_TERMCTL_ENSECLOW|FLX_TERMCTL_ENSECHIGH; 73217d24755SJustin T. Gibbs } 73317d24755SJustin T. Gibbs 73417d24755SJustin T. Gibbs /* 73517d24755SJustin T. Gibbs * Now set the termination based on what we found. 73617d24755SJustin T. Gibbs */ 73717d24755SJustin T. Gibbs sxfrctl1 = ahd_inb(ahd, SXFRCTL1) & ~STPWEN; 738b3b25f2cSJustin T. Gibbs ahd->flags &= ~AHD_TERM_ENB_A; 73917d24755SJustin T. Gibbs if ((termctl & FLX_TERMCTL_ENPRILOW) != 0) { 74017d24755SJustin T. Gibbs ahd->flags |= AHD_TERM_ENB_A; 74117d24755SJustin T. Gibbs sxfrctl1 |= STPWEN; 74217d24755SJustin T. Gibbs } 74317d24755SJustin T. Gibbs /* Must set the latch once in order to be effective. */ 74417d24755SJustin T. Gibbs ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN); 74517d24755SJustin T. Gibbs ahd_outb(ahd, SXFRCTL1, sxfrctl1); 74617d24755SJustin T. Gibbs 74717d24755SJustin T. Gibbs error = ahd_write_flexport(ahd, FLXADDR_TERMCTL, termctl); 74817d24755SJustin T. Gibbs if (error != 0) { 74917d24755SJustin T. Gibbs printf("%s: Unable to set termination settings!\n", 75017d24755SJustin T. Gibbs ahd_name(ahd)); 75117d24755SJustin T. Gibbs } else if (bootverbose) { 75217d24755SJustin T. Gibbs printf("%s: Primary High byte termination %sabled\n", 75317d24755SJustin T. Gibbs ahd_name(ahd), 75417d24755SJustin T. Gibbs (termctl & FLX_TERMCTL_ENPRIHIGH) ? "En" : "Dis"); 75517d24755SJustin T. Gibbs 75617d24755SJustin T. Gibbs printf("%s: Primary Low byte termination %sabled\n", 75717d24755SJustin T. Gibbs ahd_name(ahd), 75817d24755SJustin T. Gibbs (termctl & FLX_TERMCTL_ENPRILOW) ? "En" : "Dis"); 75917d24755SJustin T. Gibbs 76017d24755SJustin T. Gibbs printf("%s: Secondary High byte termination %sabled\n", 76117d24755SJustin T. Gibbs ahd_name(ahd), 76217d24755SJustin T. Gibbs (termctl & FLX_TERMCTL_ENSECHIGH) ? "En" : "Dis"); 76317d24755SJustin T. Gibbs 76417d24755SJustin T. Gibbs printf("%s: Secondary Low byte termination %sabled\n", 76517d24755SJustin T. Gibbs ahd_name(ahd), 76617d24755SJustin T. Gibbs (termctl & FLX_TERMCTL_ENSECLOW) ? "En" : "Dis"); 76717d24755SJustin T. Gibbs } 76817d24755SJustin T. Gibbs return; 76917d24755SJustin T. Gibbs } 77017d24755SJustin T. Gibbs 77117d24755SJustin T. Gibbs #define DPE 0x80 77217d24755SJustin T. Gibbs #define SSE 0x40 77317d24755SJustin T. Gibbs #define RMA 0x20 77417d24755SJustin T. Gibbs #define RTA 0x10 77517d24755SJustin T. Gibbs #define STA 0x08 77617d24755SJustin T. Gibbs #define DPR 0x01 77717d24755SJustin T. Gibbs 77817d24755SJustin T. Gibbs static const char *split_status_source[] = 77917d24755SJustin T. Gibbs { 78017d24755SJustin T. Gibbs "DFF0", 78117d24755SJustin T. Gibbs "DFF1", 78217d24755SJustin T. Gibbs "OVLY", 78317d24755SJustin T. Gibbs "CMC", 78417d24755SJustin T. Gibbs }; 78517d24755SJustin T. Gibbs 78617d24755SJustin T. Gibbs static const char *pci_status_source[] = 78717d24755SJustin T. Gibbs { 78817d24755SJustin T. Gibbs "DFF0", 78917d24755SJustin T. Gibbs "DFF1", 79017d24755SJustin T. Gibbs "SG", 79117d24755SJustin T. Gibbs "CMC", 79217d24755SJustin T. Gibbs "OVLY", 79317d24755SJustin T. Gibbs "NONE", 79417d24755SJustin T. Gibbs "MSI", 79517d24755SJustin T. Gibbs "TARG" 79617d24755SJustin T. Gibbs }; 79717d24755SJustin T. Gibbs 79817d24755SJustin T. Gibbs static const char *split_status_strings[] = 79917d24755SJustin T. Gibbs { 800acae33b0SJustin T. Gibbs "%s: Received split response in %s.\n", 80117d24755SJustin T. Gibbs "%s: Received split completion error message in %s\n", 80217d24755SJustin T. Gibbs "%s: Receive overrun in %s\n", 80317d24755SJustin T. Gibbs "%s: Count not complete in %s\n", 80417d24755SJustin T. Gibbs "%s: Split completion data bucket in %s\n", 80517d24755SJustin T. Gibbs "%s: Split completion address error in %s\n", 80617d24755SJustin T. Gibbs "%s: Split completion byte count error in %s\n", 807acae33b0SJustin T. Gibbs "%s: Signaled Target-abort to early terminate a split in %s\n" 80817d24755SJustin T. Gibbs }; 80917d24755SJustin T. Gibbs 81017d24755SJustin T. Gibbs static const char *pci_status_strings[] = 81117d24755SJustin T. Gibbs { 81217d24755SJustin T. Gibbs "%s: Data Parity Error has been reported via PERR# in %s\n", 81317d24755SJustin T. Gibbs "%s: Target initial wait state error in %s\n", 81417d24755SJustin T. Gibbs "%s: Split completion read data parity error in %s\n", 81517d24755SJustin T. Gibbs "%s: Split completion address attribute parity error in %s\n", 81617d24755SJustin T. Gibbs "%s: Received a Target Abort in %s\n", 81717d24755SJustin T. Gibbs "%s: Received a Master Abort in %s\n", 81817d24755SJustin T. Gibbs "%s: Signal System Error Detected in %s\n", 81917d24755SJustin T. Gibbs "%s: Address or Write Phase Parity Error Detected in %s.\n" 82017d24755SJustin T. Gibbs }; 82117d24755SJustin T. Gibbs 82217d24755SJustin T. Gibbs void 82317d24755SJustin T. Gibbs ahd_pci_intr(struct ahd_softc *ahd) 82417d24755SJustin T. Gibbs { 82517d24755SJustin T. Gibbs uint8_t pci_status[8]; 82617d24755SJustin T. Gibbs ahd_mode_state saved_modes; 82717d24755SJustin T. Gibbs u_int pci_status1; 82817d24755SJustin T. Gibbs u_int intstat; 82917d24755SJustin T. Gibbs u_int i; 83017d24755SJustin T. Gibbs u_int reg; 83117d24755SJustin T. Gibbs 83217d24755SJustin T. Gibbs intstat = ahd_inb(ahd, INTSTAT); 83317d24755SJustin T. Gibbs 83417d24755SJustin T. Gibbs if ((intstat & SPLTINT) != 0) 83517d24755SJustin T. Gibbs ahd_pci_split_intr(ahd, intstat); 83617d24755SJustin T. Gibbs 83717d24755SJustin T. Gibbs if ((intstat & PCIINT) == 0) 83817d24755SJustin T. Gibbs return; 83917d24755SJustin T. Gibbs 84017d24755SJustin T. Gibbs printf("%s: PCI error Interrupt\n", ahd_name(ahd)); 84117d24755SJustin T. Gibbs saved_modes = ahd_save_modes(ahd); 84217d24755SJustin T. Gibbs ahd_dump_card_state(ahd); 84317d24755SJustin T. Gibbs ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); 84417d24755SJustin T. Gibbs for (i = 0, reg = DF0PCISTAT; i < 8; i++, reg++) { 84517d24755SJustin T. Gibbs if (i == 5) 84617d24755SJustin T. Gibbs continue; 84717d24755SJustin T. Gibbs pci_status[i] = ahd_inb(ahd, reg); 848acae33b0SJustin T. Gibbs /* Clear latched errors. So our interrupt deasserts. */ 84917d24755SJustin T. Gibbs ahd_outb(ahd, reg, pci_status[i]); 85017d24755SJustin T. Gibbs } 85117d24755SJustin T. Gibbs 85217d24755SJustin T. Gibbs for (i = 0; i < 8; i++) { 85317d24755SJustin T. Gibbs u_int bit; 85417d24755SJustin T. Gibbs 85517d24755SJustin T. Gibbs if (i == 5) 85617d24755SJustin T. Gibbs continue; 85717d24755SJustin T. Gibbs 85817d24755SJustin T. Gibbs for (bit = 0; bit < 8; bit++) { 85917d24755SJustin T. Gibbs if ((pci_status[i] & (0x1 << bit)) != 0) { 86017d24755SJustin T. Gibbs static const char *s; 86117d24755SJustin T. Gibbs 86217d24755SJustin T. Gibbs s = pci_status_strings[bit]; 86317d24755SJustin T. Gibbs if (i == 7/*TARG*/ && bit == 3) 86497cae63dSScott Long s = "%s: Signaled Target Abort\n"; 86517d24755SJustin T. Gibbs printf(s, ahd_name(ahd), pci_status_source[i]); 86617d24755SJustin T. Gibbs } 86717d24755SJustin T. Gibbs } 86817d24755SJustin T. Gibbs } 869b3b25f2cSJustin T. Gibbs pci_status1 = aic_pci_read_config(ahd->dev_softc, 87017d24755SJustin T. Gibbs PCIR_STATUS + 1, /*bytes*/1); 871b3b25f2cSJustin T. Gibbs aic_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1, 87217d24755SJustin T. Gibbs pci_status1, /*bytes*/1); 87317d24755SJustin T. Gibbs ahd_restore_modes(ahd, saved_modes); 87497cae63dSScott Long ahd_outb(ahd, CLRINT, CLRPCIINT); 87517d24755SJustin T. Gibbs ahd_unpause(ahd); 87617d24755SJustin T. Gibbs } 87717d24755SJustin T. Gibbs 87817d24755SJustin T. Gibbs static void 87917d24755SJustin T. Gibbs ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat) 88017d24755SJustin T. Gibbs { 88117d24755SJustin T. Gibbs uint8_t split_status[4]; 88217d24755SJustin T. Gibbs uint8_t split_status1[4]; 88317d24755SJustin T. Gibbs uint8_t sg_split_status[2]; 88417d24755SJustin T. Gibbs uint8_t sg_split_status1[2]; 88517d24755SJustin T. Gibbs ahd_mode_state saved_modes; 88617d24755SJustin T. Gibbs u_int i; 8876eb7ebfeSJohn Baldwin uint32_t pcix_status; 88817d24755SJustin T. Gibbs 88917d24755SJustin T. Gibbs /* 89017d24755SJustin T. Gibbs * Check for splits in all modes. Modes 0 and 1 89117d24755SJustin T. Gibbs * additionally have SG engine splits to look at. 89217d24755SJustin T. Gibbs */ 8936eb7ebfeSJohn Baldwin pcix_status = aic_pci_read_config(ahd->dev_softc, 8946eb7ebfeSJohn Baldwin ahd->pcix_ptr + PCIXR_STATUS, /*bytes*/ 4); 89517d24755SJustin T. Gibbs printf("%s: PCI Split Interrupt - PCI-X status = 0x%x\n", 8966eb7ebfeSJohn Baldwin ahd_name(ahd), pcix_status >> 16); 89717d24755SJustin T. Gibbs saved_modes = ahd_save_modes(ahd); 89817d24755SJustin T. Gibbs for (i = 0; i < 4; i++) { 89917d24755SJustin T. Gibbs ahd_set_modes(ahd, i, i); 90017d24755SJustin T. Gibbs 90117d24755SJustin T. Gibbs split_status[i] = ahd_inb(ahd, DCHSPLTSTAT0); 90217d24755SJustin T. Gibbs split_status1[i] = ahd_inb(ahd, DCHSPLTSTAT1); 903acae33b0SJustin T. Gibbs /* Clear latched errors. So our interrupt deasserts. */ 90417d24755SJustin T. Gibbs ahd_outb(ahd, DCHSPLTSTAT0, split_status[i]); 90517d24755SJustin T. Gibbs ahd_outb(ahd, DCHSPLTSTAT1, split_status1[i]); 906d7cff4abSJustin T. Gibbs if (i > 1) 90717d24755SJustin T. Gibbs continue; 90817d24755SJustin T. Gibbs sg_split_status[i] = ahd_inb(ahd, SGSPLTSTAT0); 90917d24755SJustin T. Gibbs sg_split_status1[i] = ahd_inb(ahd, SGSPLTSTAT1); 910acae33b0SJustin T. Gibbs /* Clear latched errors. So our interrupt deasserts. */ 91117d24755SJustin T. Gibbs ahd_outb(ahd, SGSPLTSTAT0, sg_split_status[i]); 91217d24755SJustin T. Gibbs ahd_outb(ahd, SGSPLTSTAT1, sg_split_status1[i]); 91317d24755SJustin T. Gibbs } 91417d24755SJustin T. Gibbs 91517d24755SJustin T. Gibbs for (i = 0; i < 4; i++) { 91617d24755SJustin T. Gibbs u_int bit; 91717d24755SJustin T. Gibbs 91817d24755SJustin T. Gibbs for (bit = 0; bit < 8; bit++) { 91917d24755SJustin T. Gibbs if ((split_status[i] & (0x1 << bit)) != 0) { 92017d24755SJustin T. Gibbs static const char *s; 92117d24755SJustin T. Gibbs 92217d24755SJustin T. Gibbs s = split_status_strings[bit]; 92317d24755SJustin T. Gibbs printf(s, ahd_name(ahd), 92417d24755SJustin T. Gibbs split_status_source[i]); 92517d24755SJustin T. Gibbs } 92617d24755SJustin T. Gibbs 927d7cff4abSJustin T. Gibbs if (i > 1) 92817d24755SJustin T. Gibbs continue; 92917d24755SJustin T. Gibbs 93017d24755SJustin T. Gibbs if ((sg_split_status[i] & (0x1 << bit)) != 0) { 93117d24755SJustin T. Gibbs static const char *s; 93217d24755SJustin T. Gibbs 93317d24755SJustin T. Gibbs s = split_status_strings[bit]; 93417d24755SJustin T. Gibbs printf(s, ahd_name(ahd), "SG"); 93517d24755SJustin T. Gibbs } 93617d24755SJustin T. Gibbs } 93717d24755SJustin T. Gibbs } 93817d24755SJustin T. Gibbs /* 93917d24755SJustin T. Gibbs * Clear PCI-X status bits. 94017d24755SJustin T. Gibbs */ 9416eb7ebfeSJohn Baldwin aic_pci_write_config(ahd->dev_softc, ahd->pcix_ptr + PCIXR_STATUS, 9426eb7ebfeSJohn Baldwin pcix_status, /*bytes*/4); 94397cae63dSScott Long ahd_outb(ahd, CLRINT, CLRSPLTINT); 94417d24755SJustin T. Gibbs ahd_restore_modes(ahd, saved_modes); 94517d24755SJustin T. Gibbs } 94617d24755SJustin T. Gibbs 94717d24755SJustin T. Gibbs static int 948197696e9SJustin T. Gibbs ahd_aic7901_setup(struct ahd_softc *ahd) 949197696e9SJustin T. Gibbs { 950197696e9SJustin T. Gibbs 951197696e9SJustin T. Gibbs ahd->chip = AHD_AIC7901; 952c8ee7177SJustin T. Gibbs ahd->features = AHD_AIC7901_FE; 953c8ee7177SJustin T. Gibbs return (ahd_aic790X_setup(ahd)); 954197696e9SJustin T. Gibbs } 955197696e9SJustin T. Gibbs 956197696e9SJustin T. Gibbs static int 9571a1fbd0bSJustin T. Gibbs ahd_aic7901A_setup(struct ahd_softc *ahd) 9581a1fbd0bSJustin T. Gibbs { 9591a1fbd0bSJustin T. Gibbs 9601a1fbd0bSJustin T. Gibbs ahd->chip = AHD_AIC7901A; 961c8ee7177SJustin T. Gibbs ahd->features = AHD_AIC7901A_FE; 962c8ee7177SJustin T. Gibbs return (ahd_aic790X_setup(ahd)); 9631a1fbd0bSJustin T. Gibbs } 9641a1fbd0bSJustin T. Gibbs 965454bf169SScott Long static int 966454bf169SScott Long ahd_aic7902_setup(struct ahd_softc *ahd) 967454bf169SScott Long { 968c8ee7177SJustin T. Gibbs ahd->chip = AHD_AIC7902; 969c8ee7177SJustin T. Gibbs ahd->features = AHD_AIC7902_FE; 970c8ee7177SJustin T. Gibbs return (ahd_aic790X_setup(ahd)); 971c8ee7177SJustin T. Gibbs } 972c8ee7177SJustin T. Gibbs 973c8ee7177SJustin T. Gibbs static int 974c8ee7177SJustin T. Gibbs ahd_aic790X_setup(struct ahd_softc *ahd) 975c8ee7177SJustin T. Gibbs { 976b3b25f2cSJustin T. Gibbs aic_dev_softc_t pci; 977454bf169SScott Long u_int rev; 978454bf169SScott Long 979454bf169SScott Long pci = ahd->dev_softc; 980b3b25f2cSJustin T. Gibbs rev = aic_pci_read_config(pci, PCIR_REVID, /*bytes*/1); 981454bf169SScott Long if (rev < ID_AIC7902_PCI_REV_A4) { 982454bf169SScott Long printf("%s: Unable to attach to unsupported chip revision %d\n", 983454bf169SScott Long ahd_name(ahd), rev); 984b3b25f2cSJustin T. Gibbs aic_pci_write_config(pci, PCIR_COMMAND, 0, /*bytes*/2); 985454bf169SScott Long return (ENXIO); 986454bf169SScott Long } 987b3b25f2cSJustin T. Gibbs ahd->channel = aic_get_pci_function(pci) + 'A'; 988454bf169SScott Long if (rev < ID_AIC7902_PCI_REV_B0) { 989454bf169SScott Long /* 990454bf169SScott Long * Enable A series workarounds. 991454bf169SScott Long */ 992454bf169SScott Long ahd->bugs |= AHD_SENT_SCB_UPDATE_BUG|AHD_ABORT_LQI_BUG 993454bf169SScott Long | AHD_PKT_BITBUCKET_BUG|AHD_LONG_SETIMO_BUG 994454bf169SScott Long | AHD_NLQICRC_DELAYED_BUG|AHD_SCSIRST_BUG 995454bf169SScott Long | AHD_LQO_ATNO_BUG|AHD_AUTOFLUSH_BUG 996454bf169SScott Long | AHD_CLRLQO_AUTOCLR_BUG|AHD_PCIX_MMAPIO_BUG 9972cd3cc37SJustin T. Gibbs | AHD_PCIX_CHIPRST_BUG|AHD_PCIX_SCBRAM_RD_BUG 9982cd3cc37SJustin T. Gibbs | AHD_PKTIZED_STATUS_BUG|AHD_PKT_LUN_BUG 9992cd3cc37SJustin T. Gibbs | AHD_MDFF_WSCBPTR_BUG|AHD_REG_SLOW_SETTLE_BUG 10002cd3cc37SJustin T. Gibbs | AHD_SET_MODE_BUG|AHD_BUSFREEREV_BUG 1001d7cff4abSJustin T. Gibbs | AHD_NONPACKFIFO_BUG|AHD_PACED_NEGTABLE_BUG 1002d7cff4abSJustin T. Gibbs | AHD_FAINT_LED_BUG; 1003454bf169SScott Long 1004454bf169SScott Long /* 1005594c945aSPedro F. Giffuni * IO Cell parameter setup. 1006454bf169SScott Long */ 1007454bf169SScott Long AHD_SET_PRECOMP(ahd, AHD_PRECOMP_CUTBACK_29); 1008454bf169SScott Long 1009454bf169SScott Long if ((ahd->flags & AHD_HP_BOARD) == 0) 1010454bf169SScott Long AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVA); 1011454bf169SScott Long } else { 1012454bf169SScott Long u_int devconfig1; 1013454bf169SScott Long 1014454bf169SScott Long ahd->features |= AHD_RTI|AHD_NEW_IOCELL_OPTS 10154ddea3e2SJustin T. Gibbs | AHD_NEW_DFCNTRL_OPTS|AHD_FAST_CDB_DELIVERY; 101605899a48SJustin T. Gibbs ahd->bugs |= AHD_LQOOVERRUN_BUG|AHD_EARLY_REQ_BUG; 1017c8ee7177SJustin T. Gibbs 1018c8ee7177SJustin T. Gibbs /* 1019c8ee7177SJustin T. Gibbs * Some issues have been resolved in the 7901B. 1020c8ee7177SJustin T. Gibbs */ 1021c8ee7177SJustin T. Gibbs if ((ahd->features & AHD_MULTI_FUNC) != 0) 102205899a48SJustin T. Gibbs ahd->bugs |= AHD_INTCOLLISION_BUG|AHD_ABORT_LQI_BUG 102305899a48SJustin T. Gibbs | AHD_BUSFREEREV_BUG; 1024454bf169SScott Long 1025454bf169SScott Long /* 1026594c945aSPedro F. Giffuni * IO Cell parameter setup. 1027454bf169SScott Long */ 1028454bf169SScott Long AHD_SET_PRECOMP(ahd, AHD_PRECOMP_CUTBACK_29); 1029454bf169SScott Long AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVB); 1030454bf169SScott Long AHD_SET_AMPLITUDE(ahd, AHD_AMPLITUDE_DEF); 1031454bf169SScott Long 1032454bf169SScott Long /* 1033454bf169SScott Long * Set the PREQDIS bit for H2B which disables some workaround 1034454bf169SScott Long * that doesn't work on regular PCI busses. 1035454bf169SScott Long * XXX - Find out exactly what this does from the hardware 1036454bf169SScott Long * folks! 1037454bf169SScott Long */ 1038b3b25f2cSJustin T. Gibbs devconfig1 = aic_pci_read_config(pci, DEVCONFIG1, /*bytes*/1); 1039b3b25f2cSJustin T. Gibbs aic_pci_write_config(pci, DEVCONFIG1, 1040454bf169SScott Long devconfig1|PREQDIS, /*bytes*/1); 1041b3b25f2cSJustin T. Gibbs devconfig1 = aic_pci_read_config(pci, DEVCONFIG1, /*bytes*/1); 1042454bf169SScott Long } 1043454bf169SScott Long 1044454bf169SScott Long return (0); 1045454bf169SScott Long } 1046