18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Core definitions and data structures shareable across OS platforms. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 1994-2001 Justin T. Gibbs. 58c2ecf20Sopenharmony_ci * Copyright (c) 2000-2001 Adaptec Inc. 68c2ecf20Sopenharmony_ci * All rights reserved. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 98c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 108c2ecf20Sopenharmony_ci * are met: 118c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 128c2ecf20Sopenharmony_ci * notice, this list of conditions, and the following disclaimer, 138c2ecf20Sopenharmony_ci * without modification. 148c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer 158c2ecf20Sopenharmony_ci * substantially similar to the "NO WARRANTY" disclaimer below 168c2ecf20Sopenharmony_ci * ("Disclaimer") and any redistribution must be conditioned upon 178c2ecf20Sopenharmony_ci * including a substantially similar Disclaimer requirement for further 188c2ecf20Sopenharmony_ci * binary redistribution. 198c2ecf20Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names 208c2ecf20Sopenharmony_ci * of any contributors may be used to endorse or promote products derived 218c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 248c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 258c2ecf20Sopenharmony_ci * Software Foundation. 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * NO WARRANTY 288c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 298c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 308c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 318c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 328c2ecf20Sopenharmony_ci * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 338c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 348c2ecf20Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 358c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 368c2ecf20Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 378c2ecf20Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 388c2ecf20Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGES. 398c2ecf20Sopenharmony_ci * 408c2ecf20Sopenharmony_ci * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#85 $ 418c2ecf20Sopenharmony_ci * 428c2ecf20Sopenharmony_ci * $FreeBSD$ 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#ifndef _AIC7XXX_H_ 468c2ecf20Sopenharmony_ci#define _AIC7XXX_H_ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* Register Definitions */ 498c2ecf20Sopenharmony_ci#include "aic7xxx_reg.h" 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/************************* Forward Declarations *******************************/ 528c2ecf20Sopenharmony_cistruct ahc_platform_data; 538c2ecf20Sopenharmony_cistruct scb_platform_data; 548c2ecf20Sopenharmony_cistruct seeprom_descriptor; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/****************************** Useful Macros *********************************/ 578c2ecf20Sopenharmony_ci#ifndef TRUE 588c2ecf20Sopenharmony_ci#define TRUE 1 598c2ecf20Sopenharmony_ci#endif 608c2ecf20Sopenharmony_ci#ifndef FALSE 618c2ecf20Sopenharmony_ci#define FALSE 0 628c2ecf20Sopenharmony_ci#endif 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define ALL_CHANNELS '\0' 658c2ecf20Sopenharmony_ci#define ALL_TARGETS_MASK 0xFFFF 668c2ecf20Sopenharmony_ci#define INITIATOR_WILDCARD (~0) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define SCSIID_TARGET(ahc, scsiid) \ 698c2ecf20Sopenharmony_ci (((scsiid) & ((((ahc)->features & AHC_TWIN) != 0) ? TWIN_TID : TID)) \ 708c2ecf20Sopenharmony_ci >> TID_SHIFT) 718c2ecf20Sopenharmony_ci#define SCSIID_OUR_ID(scsiid) \ 728c2ecf20Sopenharmony_ci ((scsiid) & OID) 738c2ecf20Sopenharmony_ci#define SCSIID_CHANNEL(ahc, scsiid) \ 748c2ecf20Sopenharmony_ci ((((ahc)->features & AHC_TWIN) != 0) \ 758c2ecf20Sopenharmony_ci ? ((((scsiid) & TWIN_CHNLB) != 0) ? 'B' : 'A') \ 768c2ecf20Sopenharmony_ci : 'A') 778c2ecf20Sopenharmony_ci#define SCB_IS_SCSIBUS_B(ahc, scb) \ 788c2ecf20Sopenharmony_ci (SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid) == 'B') 798c2ecf20Sopenharmony_ci#define SCB_GET_OUR_ID(scb) \ 808c2ecf20Sopenharmony_ci SCSIID_OUR_ID((scb)->hscb->scsiid) 818c2ecf20Sopenharmony_ci#define SCB_GET_TARGET(ahc, scb) \ 828c2ecf20Sopenharmony_ci SCSIID_TARGET((ahc), (scb)->hscb->scsiid) 838c2ecf20Sopenharmony_ci#define SCB_GET_CHANNEL(ahc, scb) \ 848c2ecf20Sopenharmony_ci SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid) 858c2ecf20Sopenharmony_ci#define SCB_GET_LUN(scb) \ 868c2ecf20Sopenharmony_ci ((scb)->hscb->lun & LID) 878c2ecf20Sopenharmony_ci#define SCB_GET_TARGET_OFFSET(ahc, scb) \ 888c2ecf20Sopenharmony_ci (SCB_GET_TARGET(ahc, scb) + (SCB_IS_SCSIBUS_B(ahc, scb) ? 8 : 0)) 898c2ecf20Sopenharmony_ci#define SCB_GET_TARGET_MASK(ahc, scb) \ 908c2ecf20Sopenharmony_ci (0x01 << (SCB_GET_TARGET_OFFSET(ahc, scb))) 918c2ecf20Sopenharmony_ci#ifdef AHC_DEBUG 928c2ecf20Sopenharmony_ci#define SCB_IS_SILENT(scb) \ 938c2ecf20Sopenharmony_ci ((ahc_debug & AHC_SHOW_MASKED_ERRORS) == 0 \ 948c2ecf20Sopenharmony_ci && (((scb)->flags & SCB_SILENT) != 0)) 958c2ecf20Sopenharmony_ci#else 968c2ecf20Sopenharmony_ci#define SCB_IS_SILENT(scb) \ 978c2ecf20Sopenharmony_ci (((scb)->flags & SCB_SILENT) != 0) 988c2ecf20Sopenharmony_ci#endif 998c2ecf20Sopenharmony_ci#define TCL_TARGET_OFFSET(tcl) \ 1008c2ecf20Sopenharmony_ci ((((tcl) >> 4) & TID) >> 4) 1018c2ecf20Sopenharmony_ci#define TCL_LUN(tcl) \ 1028c2ecf20Sopenharmony_ci (tcl & (AHC_NUM_LUNS - 1)) 1038c2ecf20Sopenharmony_ci#define BUILD_TCL(scsiid, lun) \ 1048c2ecf20Sopenharmony_ci ((lun) | (((scsiid) & TID) << 4)) 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#ifndef AHC_TARGET_MODE 1078c2ecf20Sopenharmony_ci#undef AHC_TMODE_ENABLE 1088c2ecf20Sopenharmony_ci#define AHC_TMODE_ENABLE 0 1098c2ecf20Sopenharmony_ci#endif 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/**************************** Driver Constants ********************************/ 1128c2ecf20Sopenharmony_ci/* 1138c2ecf20Sopenharmony_ci * The maximum number of supported targets. 1148c2ecf20Sopenharmony_ci */ 1158c2ecf20Sopenharmony_ci#define AHC_NUM_TARGETS 16 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* 1188c2ecf20Sopenharmony_ci * The maximum number of supported luns. 1198c2ecf20Sopenharmony_ci * The identify message only supports 64 luns in SPI3. 1208c2ecf20Sopenharmony_ci * You can have 2^64 luns when information unit transfers are enabled, 1218c2ecf20Sopenharmony_ci * but it is doubtful this driver will ever support IUTs. 1228c2ecf20Sopenharmony_ci */ 1238c2ecf20Sopenharmony_ci#define AHC_NUM_LUNS 64 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/* 1268c2ecf20Sopenharmony_ci * The maximum transfer per S/G segment. 1278c2ecf20Sopenharmony_ci */ 1288c2ecf20Sopenharmony_ci#define AHC_MAXTRANSFER_SIZE 0x00ffffff /* limited by 24bit counter */ 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci/* 1318c2ecf20Sopenharmony_ci * The maximum amount of SCB storage in hardware on a controller. 1328c2ecf20Sopenharmony_ci * This value represents an upper bound. Controllers vary in the number 1338c2ecf20Sopenharmony_ci * they actually support. 1348c2ecf20Sopenharmony_ci */ 1358c2ecf20Sopenharmony_ci#define AHC_SCB_MAX 255 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* 1388c2ecf20Sopenharmony_ci * The maximum number of concurrent transactions supported per driver instance. 1398c2ecf20Sopenharmony_ci * Sequencer Control Blocks (SCBs) store per-transaction information. Although 1408c2ecf20Sopenharmony_ci * the space for SCBs on the host adapter varies by model, the driver will 1418c2ecf20Sopenharmony_ci * page the SCBs between host and controller memory as needed. We are limited 1428c2ecf20Sopenharmony_ci * to 253 because: 1438c2ecf20Sopenharmony_ci * 1) The 8bit nature of the RISC engine holds us to an 8bit value. 1448c2ecf20Sopenharmony_ci * 2) We reserve one value, 255, to represent the invalid element. 1458c2ecf20Sopenharmony_ci * 3) Our input queue scheme requires one SCB to always be reserved 1468c2ecf20Sopenharmony_ci * in advance of queuing any SCBs. This takes us down to 254. 1478c2ecf20Sopenharmony_ci * 4) To handle our output queue correctly on machines that only 1488c2ecf20Sopenharmony_ci * support 32bit stores, we must clear the array 4 bytes at a 1498c2ecf20Sopenharmony_ci * time. To avoid colliding with a DMA write from the sequencer, 1508c2ecf20Sopenharmony_ci * we must be sure that 4 slots are empty when we write to clear 1518c2ecf20Sopenharmony_ci * the queue. This reduces us to 253 SCBs: 1 that just completed 1528c2ecf20Sopenharmony_ci * and the known three additional empty slots in the queue that 1538c2ecf20Sopenharmony_ci * precede it. 1548c2ecf20Sopenharmony_ci */ 1558c2ecf20Sopenharmony_ci#define AHC_MAX_QUEUE 253 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci/* 1588c2ecf20Sopenharmony_ci * The maximum amount of SCB storage we allocate in host memory. This 1598c2ecf20Sopenharmony_ci * number should reflect the 1 additional SCB we require to handle our 1608c2ecf20Sopenharmony_ci * qinfifo mechanism. 1618c2ecf20Sopenharmony_ci */ 1628c2ecf20Sopenharmony_ci#define AHC_SCB_MAX_ALLOC (AHC_MAX_QUEUE+1) 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci/* 1658c2ecf20Sopenharmony_ci * Ring Buffer of incoming target commands. 1668c2ecf20Sopenharmony_ci * We allocate 256 to simplify the logic in the sequencer 1678c2ecf20Sopenharmony_ci * by using the natural wrap point of an 8bit counter. 1688c2ecf20Sopenharmony_ci */ 1698c2ecf20Sopenharmony_ci#define AHC_TMODE_CMDS 256 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci/* Reset line assertion time in us */ 1728c2ecf20Sopenharmony_ci#define AHC_BUSRESET_DELAY 25 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/******************* Chip Characteristics/Operating Settings *****************/ 1758c2ecf20Sopenharmony_ci/* 1768c2ecf20Sopenharmony_ci * Chip Type 1778c2ecf20Sopenharmony_ci * The chip order is from least sophisticated to most sophisticated. 1788c2ecf20Sopenharmony_ci */ 1798c2ecf20Sopenharmony_citypedef enum { 1808c2ecf20Sopenharmony_ci AHC_NONE = 0x0000, 1818c2ecf20Sopenharmony_ci AHC_CHIPID_MASK = 0x00FF, 1828c2ecf20Sopenharmony_ci AHC_AIC7770 = 0x0001, 1838c2ecf20Sopenharmony_ci AHC_AIC7850 = 0x0002, 1848c2ecf20Sopenharmony_ci AHC_AIC7855 = 0x0003, 1858c2ecf20Sopenharmony_ci AHC_AIC7859 = 0x0004, 1868c2ecf20Sopenharmony_ci AHC_AIC7860 = 0x0005, 1878c2ecf20Sopenharmony_ci AHC_AIC7870 = 0x0006, 1888c2ecf20Sopenharmony_ci AHC_AIC7880 = 0x0007, 1898c2ecf20Sopenharmony_ci AHC_AIC7895 = 0x0008, 1908c2ecf20Sopenharmony_ci AHC_AIC7895C = 0x0009, 1918c2ecf20Sopenharmony_ci AHC_AIC7890 = 0x000a, 1928c2ecf20Sopenharmony_ci AHC_AIC7896 = 0x000b, 1938c2ecf20Sopenharmony_ci AHC_AIC7892 = 0x000c, 1948c2ecf20Sopenharmony_ci AHC_AIC7899 = 0x000d, 1958c2ecf20Sopenharmony_ci AHC_VL = 0x0100, /* Bus type VL */ 1968c2ecf20Sopenharmony_ci AHC_EISA = 0x0200, /* Bus type EISA */ 1978c2ecf20Sopenharmony_ci AHC_PCI = 0x0400, /* Bus type PCI */ 1988c2ecf20Sopenharmony_ci AHC_BUS_MASK = 0x0F00 1998c2ecf20Sopenharmony_ci} ahc_chip; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* 2028c2ecf20Sopenharmony_ci * Features available in each chip type. 2038c2ecf20Sopenharmony_ci */ 2048c2ecf20Sopenharmony_citypedef enum { 2058c2ecf20Sopenharmony_ci AHC_FENONE = 0x00000, 2068c2ecf20Sopenharmony_ci AHC_ULTRA = 0x00001, /* Supports 20MHz Transfers */ 2078c2ecf20Sopenharmony_ci AHC_ULTRA2 = 0x00002, /* Supports 40MHz Transfers */ 2088c2ecf20Sopenharmony_ci AHC_WIDE = 0x00004, /* Wide Channel */ 2098c2ecf20Sopenharmony_ci AHC_TWIN = 0x00008, /* Twin Channel */ 2108c2ecf20Sopenharmony_ci AHC_MORE_SRAM = 0x00010, /* 80 bytes instead of 64 */ 2118c2ecf20Sopenharmony_ci AHC_CMD_CHAN = 0x00020, /* Has a Command DMA Channel */ 2128c2ecf20Sopenharmony_ci AHC_QUEUE_REGS = 0x00040, /* Has Queue management registers */ 2138c2ecf20Sopenharmony_ci AHC_SG_PRELOAD = 0x00080, /* Can perform auto-SG preload */ 2148c2ecf20Sopenharmony_ci AHC_SPIOCAP = 0x00100, /* Has a Serial Port I/O Cap Register */ 2158c2ecf20Sopenharmony_ci AHC_MULTI_TID = 0x00200, /* Has bitmask of TIDs for select-in */ 2168c2ecf20Sopenharmony_ci AHC_HS_MAILBOX = 0x00400, /* Has HS_MAILBOX register */ 2178c2ecf20Sopenharmony_ci AHC_DT = 0x00800, /* Double Transition transfers */ 2188c2ecf20Sopenharmony_ci AHC_NEW_TERMCTL = 0x01000, /* Newer termination scheme */ 2198c2ecf20Sopenharmony_ci AHC_MULTI_FUNC = 0x02000, /* Multi-Function Twin Channel Device */ 2208c2ecf20Sopenharmony_ci AHC_LARGE_SCBS = 0x04000, /* 64byte SCBs */ 2218c2ecf20Sopenharmony_ci AHC_AUTORATE = 0x08000, /* Automatic update of SCSIRATE/OFFSET*/ 2228c2ecf20Sopenharmony_ci AHC_AUTOPAUSE = 0x10000, /* Automatic pause on register access */ 2238c2ecf20Sopenharmony_ci AHC_TARGETMODE = 0x20000, /* Has tested target mode support */ 2248c2ecf20Sopenharmony_ci AHC_MULTIROLE = 0x40000, /* Space for two roles at a time */ 2258c2ecf20Sopenharmony_ci AHC_REMOVABLE = 0x80000, /* Hot-Swap supported */ 2268c2ecf20Sopenharmony_ci AHC_HVD = 0x100000, /* HVD rather than SE */ 2278c2ecf20Sopenharmony_ci AHC_AIC7770_FE = AHC_FENONE, 2288c2ecf20Sopenharmony_ci /* 2298c2ecf20Sopenharmony_ci * The real 7850 does not support Ultra modes, but there are 2308c2ecf20Sopenharmony_ci * several cards that use the generic 7850 PCI ID even though 2318c2ecf20Sopenharmony_ci * they are using an Ultra capable chip (7859/7860). We start 2328c2ecf20Sopenharmony_ci * out with the AHC_ULTRA feature set and then check the DEVSTATUS 2338c2ecf20Sopenharmony_ci * register to determine if the capability is really present. 2348c2ecf20Sopenharmony_ci */ 2358c2ecf20Sopenharmony_ci AHC_AIC7850_FE = AHC_SPIOCAP|AHC_AUTOPAUSE|AHC_TARGETMODE|AHC_ULTRA, 2368c2ecf20Sopenharmony_ci AHC_AIC7860_FE = AHC_AIC7850_FE, 2378c2ecf20Sopenharmony_ci AHC_AIC7870_FE = AHC_TARGETMODE|AHC_AUTOPAUSE, 2388c2ecf20Sopenharmony_ci AHC_AIC7880_FE = AHC_AIC7870_FE|AHC_ULTRA, 2398c2ecf20Sopenharmony_ci /* 2408c2ecf20Sopenharmony_ci * Although we have space for both the initiator and 2418c2ecf20Sopenharmony_ci * target roles on ULTRA2 chips, we currently disable 2428c2ecf20Sopenharmony_ci * the initiator role to allow multi-scsi-id target mode 2438c2ecf20Sopenharmony_ci * configurations. We can only respond on the same SCSI 2448c2ecf20Sopenharmony_ci * ID as our initiator role if we allow initiator operation. 2458c2ecf20Sopenharmony_ci * At some point, we should add a configuration knob to 2468c2ecf20Sopenharmony_ci * allow both roles to be loaded. 2478c2ecf20Sopenharmony_ci */ 2488c2ecf20Sopenharmony_ci AHC_AIC7890_FE = AHC_MORE_SRAM|AHC_CMD_CHAN|AHC_ULTRA2 2498c2ecf20Sopenharmony_ci |AHC_QUEUE_REGS|AHC_SG_PRELOAD|AHC_MULTI_TID 2508c2ecf20Sopenharmony_ci |AHC_HS_MAILBOX|AHC_NEW_TERMCTL|AHC_LARGE_SCBS 2518c2ecf20Sopenharmony_ci |AHC_TARGETMODE, 2528c2ecf20Sopenharmony_ci AHC_AIC7892_FE = AHC_AIC7890_FE|AHC_DT|AHC_AUTORATE|AHC_AUTOPAUSE, 2538c2ecf20Sopenharmony_ci AHC_AIC7895_FE = AHC_AIC7880_FE|AHC_MORE_SRAM|AHC_AUTOPAUSE 2548c2ecf20Sopenharmony_ci |AHC_CMD_CHAN|AHC_MULTI_FUNC|AHC_LARGE_SCBS, 2558c2ecf20Sopenharmony_ci AHC_AIC7895C_FE = AHC_AIC7895_FE|AHC_MULTI_TID, 2568c2ecf20Sopenharmony_ci AHC_AIC7896_FE = AHC_AIC7890_FE|AHC_MULTI_FUNC, 2578c2ecf20Sopenharmony_ci AHC_AIC7899_FE = AHC_AIC7892_FE|AHC_MULTI_FUNC 2588c2ecf20Sopenharmony_ci} ahc_feature; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci/* 2618c2ecf20Sopenharmony_ci * Bugs in the silicon that we work around in software. 2628c2ecf20Sopenharmony_ci */ 2638c2ecf20Sopenharmony_citypedef enum { 2648c2ecf20Sopenharmony_ci AHC_BUGNONE = 0x00, 2658c2ecf20Sopenharmony_ci /* 2668c2ecf20Sopenharmony_ci * On all chips prior to the U2 product line, 2678c2ecf20Sopenharmony_ci * the WIDEODD S/G segment feature does not 2688c2ecf20Sopenharmony_ci * work during scsi->HostBus transfers. 2698c2ecf20Sopenharmony_ci */ 2708c2ecf20Sopenharmony_ci AHC_TMODE_WIDEODD_BUG = 0x01, 2718c2ecf20Sopenharmony_ci /* 2728c2ecf20Sopenharmony_ci * On the aic7890/91 Rev 0 chips, the autoflush 2738c2ecf20Sopenharmony_ci * feature does not work. A manual flush of 2748c2ecf20Sopenharmony_ci * the DMA FIFO is required. 2758c2ecf20Sopenharmony_ci */ 2768c2ecf20Sopenharmony_ci AHC_AUTOFLUSH_BUG = 0x02, 2778c2ecf20Sopenharmony_ci /* 2788c2ecf20Sopenharmony_ci * On many chips, cacheline streaming does not work. 2798c2ecf20Sopenharmony_ci */ 2808c2ecf20Sopenharmony_ci AHC_CACHETHEN_BUG = 0x04, 2818c2ecf20Sopenharmony_ci /* 2828c2ecf20Sopenharmony_ci * On the aic7896/97 chips, cacheline 2838c2ecf20Sopenharmony_ci * streaming must be enabled. 2848c2ecf20Sopenharmony_ci */ 2858c2ecf20Sopenharmony_ci AHC_CACHETHEN_DIS_BUG = 0x08, 2868c2ecf20Sopenharmony_ci /* 2878c2ecf20Sopenharmony_ci * PCI 2.1 Retry failure on non-empty data fifo. 2888c2ecf20Sopenharmony_ci */ 2898c2ecf20Sopenharmony_ci AHC_PCI_2_1_RETRY_BUG = 0x10, 2908c2ecf20Sopenharmony_ci /* 2918c2ecf20Sopenharmony_ci * Controller does not handle cacheline residuals 2928c2ecf20Sopenharmony_ci * properly on S/G segments if PCI MWI instructions 2938c2ecf20Sopenharmony_ci * are allowed. 2948c2ecf20Sopenharmony_ci */ 2958c2ecf20Sopenharmony_ci AHC_PCI_MWI_BUG = 0x20, 2968c2ecf20Sopenharmony_ci /* 2978c2ecf20Sopenharmony_ci * An SCB upload using the SCB channel's 2988c2ecf20Sopenharmony_ci * auto array entry copy feature may 2998c2ecf20Sopenharmony_ci * corrupt data. This appears to only 3008c2ecf20Sopenharmony_ci * occur on 66MHz systems. 3018c2ecf20Sopenharmony_ci */ 3028c2ecf20Sopenharmony_ci AHC_SCBCHAN_UPLOAD_BUG = 0x40 3038c2ecf20Sopenharmony_ci} ahc_bug; 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci/* 3068c2ecf20Sopenharmony_ci * Configuration specific settings. 3078c2ecf20Sopenharmony_ci * The driver determines these settings by probing the 3088c2ecf20Sopenharmony_ci * chip/controller's configuration. 3098c2ecf20Sopenharmony_ci */ 3108c2ecf20Sopenharmony_citypedef enum { 3118c2ecf20Sopenharmony_ci AHC_FNONE = 0x000, 3128c2ecf20Sopenharmony_ci AHC_PRIMARY_CHANNEL = 0x003, /* 3138c2ecf20Sopenharmony_ci * The channel that should 3148c2ecf20Sopenharmony_ci * be probed first. 3158c2ecf20Sopenharmony_ci */ 3168c2ecf20Sopenharmony_ci AHC_USEDEFAULTS = 0x004, /* 3178c2ecf20Sopenharmony_ci * For cards without an seeprom 3188c2ecf20Sopenharmony_ci * or a BIOS to initialize the chip's 3198c2ecf20Sopenharmony_ci * SRAM, we use the default target 3208c2ecf20Sopenharmony_ci * settings. 3218c2ecf20Sopenharmony_ci */ 3228c2ecf20Sopenharmony_ci AHC_SEQUENCER_DEBUG = 0x008, 3238c2ecf20Sopenharmony_ci AHC_SHARED_SRAM = 0x010, 3248c2ecf20Sopenharmony_ci AHC_LARGE_SEEPROM = 0x020, /* Uses C56_66 not C46 */ 3258c2ecf20Sopenharmony_ci AHC_RESET_BUS_A = 0x040, 3268c2ecf20Sopenharmony_ci AHC_RESET_BUS_B = 0x080, 3278c2ecf20Sopenharmony_ci AHC_EXTENDED_TRANS_A = 0x100, 3288c2ecf20Sopenharmony_ci AHC_EXTENDED_TRANS_B = 0x200, 3298c2ecf20Sopenharmony_ci AHC_TERM_ENB_A = 0x400, 3308c2ecf20Sopenharmony_ci AHC_TERM_ENB_B = 0x800, 3318c2ecf20Sopenharmony_ci AHC_INITIATORROLE = 0x1000, /* 3328c2ecf20Sopenharmony_ci * Allow initiator operations on 3338c2ecf20Sopenharmony_ci * this controller. 3348c2ecf20Sopenharmony_ci */ 3358c2ecf20Sopenharmony_ci AHC_TARGETROLE = 0x2000, /* 3368c2ecf20Sopenharmony_ci * Allow target operations on this 3378c2ecf20Sopenharmony_ci * controller. 3388c2ecf20Sopenharmony_ci */ 3398c2ecf20Sopenharmony_ci AHC_NEWEEPROM_FMT = 0x4000, 3408c2ecf20Sopenharmony_ci AHC_TQINFIFO_BLOCKED = 0x10000, /* Blocked waiting for ATIOs */ 3418c2ecf20Sopenharmony_ci AHC_INT50_SPEEDFLEX = 0x20000, /* 3428c2ecf20Sopenharmony_ci * Internal 50pin connector 3438c2ecf20Sopenharmony_ci * sits behind an aic3860 3448c2ecf20Sopenharmony_ci */ 3458c2ecf20Sopenharmony_ci AHC_SCB_BTT = 0x40000, /* 3468c2ecf20Sopenharmony_ci * The busy targets table is 3478c2ecf20Sopenharmony_ci * stored in SCB space rather 3488c2ecf20Sopenharmony_ci * than SRAM. 3498c2ecf20Sopenharmony_ci */ 3508c2ecf20Sopenharmony_ci AHC_BIOS_ENABLED = 0x80000, 3518c2ecf20Sopenharmony_ci AHC_ALL_INTERRUPTS = 0x100000, 3528c2ecf20Sopenharmony_ci AHC_PAGESCBS = 0x400000, /* Enable SCB paging */ 3538c2ecf20Sopenharmony_ci AHC_EDGE_INTERRUPT = 0x800000, /* Device uses edge triggered ints */ 3548c2ecf20Sopenharmony_ci AHC_39BIT_ADDRESSING = 0x1000000, /* Use 39 bit addressing scheme. */ 3558c2ecf20Sopenharmony_ci AHC_LSCBS_ENABLED = 0x2000000, /* 64Byte SCBs enabled */ 3568c2ecf20Sopenharmony_ci AHC_SCB_CONFIG_USED = 0x4000000, /* No SEEPROM but SCB2 had info. */ 3578c2ecf20Sopenharmony_ci AHC_NO_BIOS_INIT = 0x8000000, /* No BIOS left over settings. */ 3588c2ecf20Sopenharmony_ci AHC_DISABLE_PCI_PERR = 0x10000000, 3598c2ecf20Sopenharmony_ci AHC_HAS_TERM_LOGIC = 0x20000000 3608c2ecf20Sopenharmony_ci} ahc_flag; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_ci/************************* Hardware SCB Definition ***************************/ 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci/* 3658c2ecf20Sopenharmony_ci * The driver keeps up to MAX_SCB scb structures per card in memory. The SCB 3668c2ecf20Sopenharmony_ci * consists of a "hardware SCB" mirroring the fields available on the card 3678c2ecf20Sopenharmony_ci * and additional information the kernel stores for each transaction. 3688c2ecf20Sopenharmony_ci * 3698c2ecf20Sopenharmony_ci * To minimize space utilization, a portion of the hardware scb stores 3708c2ecf20Sopenharmony_ci * different data during different portions of a SCSI transaction. 3718c2ecf20Sopenharmony_ci * As initialized by the host driver for the initiator role, this area 3728c2ecf20Sopenharmony_ci * contains the SCSI cdb (or a pointer to the cdb) to be executed. After 3738c2ecf20Sopenharmony_ci * the cdb has been presented to the target, this area serves to store 3748c2ecf20Sopenharmony_ci * residual transfer information and the SCSI status byte. 3758c2ecf20Sopenharmony_ci * For the target role, the contents of this area do not change, but 3768c2ecf20Sopenharmony_ci * still serve a different purpose than for the initiator role. See 3778c2ecf20Sopenharmony_ci * struct target_data for details. 3788c2ecf20Sopenharmony_ci */ 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci/* 3818c2ecf20Sopenharmony_ci * Status information embedded in the shared poriton of 3828c2ecf20Sopenharmony_ci * an SCB after passing the cdb to the target. The kernel 3838c2ecf20Sopenharmony_ci * driver will only read this data for transactions that 3848c2ecf20Sopenharmony_ci * complete abnormally (non-zero status byte). 3858c2ecf20Sopenharmony_ci */ 3868c2ecf20Sopenharmony_cistruct status_pkt { 3878c2ecf20Sopenharmony_ci uint32_t residual_datacnt; /* Residual in the current S/G seg */ 3888c2ecf20Sopenharmony_ci uint32_t residual_sg_ptr; /* The next S/G for this transfer */ 3898c2ecf20Sopenharmony_ci uint8_t scsi_status; /* Standard SCSI status byte */ 3908c2ecf20Sopenharmony_ci}; 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ci/* 3938c2ecf20Sopenharmony_ci * Target mode version of the shared data SCB segment. 3948c2ecf20Sopenharmony_ci */ 3958c2ecf20Sopenharmony_cistruct target_data { 3968c2ecf20Sopenharmony_ci uint32_t residual_datacnt; /* Residual in the current S/G seg */ 3978c2ecf20Sopenharmony_ci uint32_t residual_sg_ptr; /* The next S/G for this transfer */ 3988c2ecf20Sopenharmony_ci uint8_t scsi_status; /* SCSI status to give to initiator */ 3998c2ecf20Sopenharmony_ci uint8_t target_phases; /* Bitmap of phases to execute */ 4008c2ecf20Sopenharmony_ci uint8_t data_phase; /* Data-In or Data-Out */ 4018c2ecf20Sopenharmony_ci uint8_t initiator_tag; /* Initiator's transaction tag */ 4028c2ecf20Sopenharmony_ci}; 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_cistruct hardware_scb { 4058c2ecf20Sopenharmony_ci/*0*/ union { 4068c2ecf20Sopenharmony_ci /* 4078c2ecf20Sopenharmony_ci * If the cdb is 12 bytes or less, we embed it directly 4088c2ecf20Sopenharmony_ci * in the SCB. For longer cdbs, we embed the address 4098c2ecf20Sopenharmony_ci * of the cdb payload as seen by the chip and a DMA 4108c2ecf20Sopenharmony_ci * is used to pull it in. 4118c2ecf20Sopenharmony_ci */ 4128c2ecf20Sopenharmony_ci uint8_t cdb[12]; 4138c2ecf20Sopenharmony_ci uint32_t cdb_ptr; 4148c2ecf20Sopenharmony_ci struct status_pkt status; 4158c2ecf20Sopenharmony_ci struct target_data tdata; 4168c2ecf20Sopenharmony_ci } shared_data; 4178c2ecf20Sopenharmony_ci/* 4188c2ecf20Sopenharmony_ci * A word about residuals. 4198c2ecf20Sopenharmony_ci * The scb is presented to the sequencer with the dataptr and datacnt 4208c2ecf20Sopenharmony_ci * fields initialized to the contents of the first S/G element to 4218c2ecf20Sopenharmony_ci * transfer. The sgptr field is initialized to the bus address for 4228c2ecf20Sopenharmony_ci * the S/G element that follows the first in the in core S/G array 4238c2ecf20Sopenharmony_ci * or'ed with the SG_FULL_RESID flag. Sgptr may point to an invalid 4248c2ecf20Sopenharmony_ci * S/G entry for this transfer (single S/G element transfer with the 4258c2ecf20Sopenharmony_ci * first elements address and length preloaded in the dataptr/datacnt 4268c2ecf20Sopenharmony_ci * fields). If no transfer is to occur, sgptr is set to SG_LIST_NULL. 4278c2ecf20Sopenharmony_ci * The SG_FULL_RESID flag ensures that the residual will be correctly 4288c2ecf20Sopenharmony_ci * noted even if no data transfers occur. Once the data phase is entered, 4298c2ecf20Sopenharmony_ci * the residual sgptr and datacnt are loaded from the sgptr and the 4308c2ecf20Sopenharmony_ci * datacnt fields. After each S/G element's dataptr and length are 4318c2ecf20Sopenharmony_ci * loaded into the hardware, the residual sgptr is advanced. After 4328c2ecf20Sopenharmony_ci * each S/G element is expired, its datacnt field is checked to see 4338c2ecf20Sopenharmony_ci * if the LAST_SEG flag is set. If so, SG_LIST_NULL is set in the 4348c2ecf20Sopenharmony_ci * residual sg ptr and the transfer is considered complete. If the 4358c2ecf20Sopenharmony_ci * sequencer determines that there is a residual in the tranfer, it 4368c2ecf20Sopenharmony_ci * will set the SG_RESID_VALID flag in sgptr and dma the scb back into 4378c2ecf20Sopenharmony_ci * host memory. To sumarize: 4388c2ecf20Sopenharmony_ci * 4398c2ecf20Sopenharmony_ci * Sequencer: 4408c2ecf20Sopenharmony_ci * o A residual has occurred if SG_FULL_RESID is set in sgptr, 4418c2ecf20Sopenharmony_ci * or residual_sgptr does not have SG_LIST_NULL set. 4428c2ecf20Sopenharmony_ci * 4438c2ecf20Sopenharmony_ci * o We are transferring the last segment if residual_datacnt has 4448c2ecf20Sopenharmony_ci * the SG_LAST_SEG flag set. 4458c2ecf20Sopenharmony_ci * 4468c2ecf20Sopenharmony_ci * Host: 4478c2ecf20Sopenharmony_ci * o A residual has occurred if a completed scb has the 4488c2ecf20Sopenharmony_ci * SG_RESID_VALID flag set. 4498c2ecf20Sopenharmony_ci * 4508c2ecf20Sopenharmony_ci * o residual_sgptr and sgptr refer to the "next" sg entry 4518c2ecf20Sopenharmony_ci * and so may point beyond the last valid sg entry for the 4528c2ecf20Sopenharmony_ci * transfer. 4538c2ecf20Sopenharmony_ci */ 4548c2ecf20Sopenharmony_ci/*12*/ uint32_t dataptr; 4558c2ecf20Sopenharmony_ci/*16*/ uint32_t datacnt; /* 4568c2ecf20Sopenharmony_ci * Byte 3 (numbered from 0) of 4578c2ecf20Sopenharmony_ci * the datacnt is really the 4588c2ecf20Sopenharmony_ci * 4th byte in that data address. 4598c2ecf20Sopenharmony_ci */ 4608c2ecf20Sopenharmony_ci/*20*/ uint32_t sgptr; 4618c2ecf20Sopenharmony_ci#define SG_PTR_MASK 0xFFFFFFF8 4628c2ecf20Sopenharmony_ci/*24*/ uint8_t control; /* See SCB_CONTROL in aic7xxx.reg for details */ 4638c2ecf20Sopenharmony_ci/*25*/ uint8_t scsiid; /* what to load in the SCSIID register */ 4648c2ecf20Sopenharmony_ci/*26*/ uint8_t lun; 4658c2ecf20Sopenharmony_ci/*27*/ uint8_t tag; /* 4668c2ecf20Sopenharmony_ci * Index into our kernel SCB array. 4678c2ecf20Sopenharmony_ci * Also used as the tag for tagged I/O 4688c2ecf20Sopenharmony_ci */ 4698c2ecf20Sopenharmony_ci/*28*/ uint8_t cdb_len; 4708c2ecf20Sopenharmony_ci/*29*/ uint8_t scsirate; /* Value for SCSIRATE register */ 4718c2ecf20Sopenharmony_ci/*30*/ uint8_t scsioffset; /* Value for SCSIOFFSET register */ 4728c2ecf20Sopenharmony_ci/*31*/ uint8_t next; /* 4738c2ecf20Sopenharmony_ci * Used for threading SCBs in the 4748c2ecf20Sopenharmony_ci * "Waiting for Selection" and 4758c2ecf20Sopenharmony_ci * "Disconnected SCB" lists down 4768c2ecf20Sopenharmony_ci * in the sequencer. 4778c2ecf20Sopenharmony_ci */ 4788c2ecf20Sopenharmony_ci/*32*/ uint8_t cdb32[32]; /* 4798c2ecf20Sopenharmony_ci * CDB storage for cdbs of size 4808c2ecf20Sopenharmony_ci * 13->32. We store them here 4818c2ecf20Sopenharmony_ci * because hardware scbs are 4828c2ecf20Sopenharmony_ci * allocated from DMA safe 4838c2ecf20Sopenharmony_ci * memory so we are guaranteed 4848c2ecf20Sopenharmony_ci * the controller can access 4858c2ecf20Sopenharmony_ci * this data. 4868c2ecf20Sopenharmony_ci */ 4878c2ecf20Sopenharmony_ci}; 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci/************************ Kernel SCB Definitions ******************************/ 4908c2ecf20Sopenharmony_ci/* 4918c2ecf20Sopenharmony_ci * Some fields of the SCB are OS dependent. Here we collect the 4928c2ecf20Sopenharmony_ci * definitions for elements that all OS platforms need to include 4938c2ecf20Sopenharmony_ci * in there SCB definition. 4948c2ecf20Sopenharmony_ci */ 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci/* 4978c2ecf20Sopenharmony_ci * Definition of a scatter/gather element as transferred to the controller. 4988c2ecf20Sopenharmony_ci * The aic7xxx chips only support a 24bit length. We use the top byte of 4998c2ecf20Sopenharmony_ci * the length to store additional address bits and a flag to indicate 5008c2ecf20Sopenharmony_ci * that a given segment terminates the transfer. This gives us an 5018c2ecf20Sopenharmony_ci * addressable range of 512GB on machines with 64bit PCI or with chips 5028c2ecf20Sopenharmony_ci * that can support dual address cycles on 32bit PCI busses. 5038c2ecf20Sopenharmony_ci */ 5048c2ecf20Sopenharmony_cistruct ahc_dma_seg { 5058c2ecf20Sopenharmony_ci uint32_t addr; 5068c2ecf20Sopenharmony_ci uint32_t len; 5078c2ecf20Sopenharmony_ci#define AHC_DMA_LAST_SEG 0x80000000 5088c2ecf20Sopenharmony_ci#define AHC_SG_HIGH_ADDR_MASK 0x7F000000 5098c2ecf20Sopenharmony_ci#define AHC_SG_LEN_MASK 0x00FFFFFF 5108c2ecf20Sopenharmony_ci}; 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_cistruct sg_map_node { 5138c2ecf20Sopenharmony_ci bus_dmamap_t sg_dmamap; 5148c2ecf20Sopenharmony_ci dma_addr_t sg_physaddr; 5158c2ecf20Sopenharmony_ci struct ahc_dma_seg* sg_vaddr; 5168c2ecf20Sopenharmony_ci SLIST_ENTRY(sg_map_node) links; 5178c2ecf20Sopenharmony_ci}; 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_ci/* 5208c2ecf20Sopenharmony_ci * The current state of this SCB. 5218c2ecf20Sopenharmony_ci */ 5228c2ecf20Sopenharmony_citypedef enum { 5238c2ecf20Sopenharmony_ci SCB_FREE = 0x0000, 5248c2ecf20Sopenharmony_ci SCB_OTHERTCL_TIMEOUT = 0x0002,/* 5258c2ecf20Sopenharmony_ci * Another device was active 5268c2ecf20Sopenharmony_ci * during the first timeout for 5278c2ecf20Sopenharmony_ci * this SCB so we gave ourselves 5288c2ecf20Sopenharmony_ci * an additional timeout period 5298c2ecf20Sopenharmony_ci * in case it was hogging the 5308c2ecf20Sopenharmony_ci * bus. 5318c2ecf20Sopenharmony_ci */ 5328c2ecf20Sopenharmony_ci SCB_DEVICE_RESET = 0x0004, 5338c2ecf20Sopenharmony_ci SCB_SENSE = 0x0008, 5348c2ecf20Sopenharmony_ci SCB_CDB32_PTR = 0x0010, 5358c2ecf20Sopenharmony_ci SCB_RECOVERY_SCB = 0x0020, 5368c2ecf20Sopenharmony_ci SCB_AUTO_NEGOTIATE = 0x0040,/* Negotiate to achieve goal. */ 5378c2ecf20Sopenharmony_ci SCB_NEGOTIATE = 0x0080,/* Negotiation forced for command. */ 5388c2ecf20Sopenharmony_ci SCB_ABORT = 0x0100, 5398c2ecf20Sopenharmony_ci SCB_UNTAGGEDQ = 0x0200, 5408c2ecf20Sopenharmony_ci SCB_ACTIVE = 0x0400, 5418c2ecf20Sopenharmony_ci SCB_TARGET_IMMEDIATE = 0x0800, 5428c2ecf20Sopenharmony_ci SCB_TRANSMISSION_ERROR = 0x1000,/* 5438c2ecf20Sopenharmony_ci * We detected a parity or CRC 5448c2ecf20Sopenharmony_ci * error that has effected the 5458c2ecf20Sopenharmony_ci * payload of the command. This 5468c2ecf20Sopenharmony_ci * flag is checked when normal 5478c2ecf20Sopenharmony_ci * status is returned to catch 5488c2ecf20Sopenharmony_ci * the case of a target not 5498c2ecf20Sopenharmony_ci * responding to our attempt 5508c2ecf20Sopenharmony_ci * to report the error. 5518c2ecf20Sopenharmony_ci */ 5528c2ecf20Sopenharmony_ci SCB_TARGET_SCB = 0x2000, 5538c2ecf20Sopenharmony_ci SCB_SILENT = 0x4000 /* 5548c2ecf20Sopenharmony_ci * Be quiet about transmission type 5558c2ecf20Sopenharmony_ci * errors. They are expected and we 5568c2ecf20Sopenharmony_ci * don't want to upset the user. This 5578c2ecf20Sopenharmony_ci * flag is typically used during DV. 5588c2ecf20Sopenharmony_ci */ 5598c2ecf20Sopenharmony_ci} scb_flag; 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_cistruct scb { 5628c2ecf20Sopenharmony_ci struct hardware_scb *hscb; 5638c2ecf20Sopenharmony_ci union { 5648c2ecf20Sopenharmony_ci SLIST_ENTRY(scb) sle; 5658c2ecf20Sopenharmony_ci TAILQ_ENTRY(scb) tqe; 5668c2ecf20Sopenharmony_ci } links; 5678c2ecf20Sopenharmony_ci LIST_ENTRY(scb) pending_links; 5688c2ecf20Sopenharmony_ci ahc_io_ctx_t io_ctx; 5698c2ecf20Sopenharmony_ci struct ahc_softc *ahc_softc; 5708c2ecf20Sopenharmony_ci scb_flag flags; 5718c2ecf20Sopenharmony_ci struct scb_platform_data *platform_data; 5728c2ecf20Sopenharmony_ci struct sg_map_node *sg_map; 5738c2ecf20Sopenharmony_ci struct ahc_dma_seg *sg_list; 5748c2ecf20Sopenharmony_ci dma_addr_t sg_list_phys; 5758c2ecf20Sopenharmony_ci u_int sg_count;/* How full ahc_dma_seg is */ 5768c2ecf20Sopenharmony_ci}; 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_cistruct scb_data { 5798c2ecf20Sopenharmony_ci SLIST_HEAD(, scb) free_scbs; /* 5808c2ecf20Sopenharmony_ci * Pool of SCBs ready to be assigned 5818c2ecf20Sopenharmony_ci * commands to execute. 5828c2ecf20Sopenharmony_ci */ 5838c2ecf20Sopenharmony_ci struct scb *scbindex[256]; /* 5848c2ecf20Sopenharmony_ci * Mapping from tag to SCB. 5858c2ecf20Sopenharmony_ci * As tag identifiers are an 5868c2ecf20Sopenharmony_ci * 8bit value, we provide space 5878c2ecf20Sopenharmony_ci * for all possible tag values. 5888c2ecf20Sopenharmony_ci * Any lookups to entries at or 5898c2ecf20Sopenharmony_ci * above AHC_SCB_MAX_ALLOC will 5908c2ecf20Sopenharmony_ci * always fail. 5918c2ecf20Sopenharmony_ci */ 5928c2ecf20Sopenharmony_ci struct hardware_scb *hscbs; /* Array of hardware SCBs */ 5938c2ecf20Sopenharmony_ci struct scb *scbarray; /* Array of kernel SCBs */ 5948c2ecf20Sopenharmony_ci struct scsi_sense_data *sense; /* Per SCB sense data */ 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci /* 5978c2ecf20Sopenharmony_ci * "Bus" addresses of our data structures. 5988c2ecf20Sopenharmony_ci */ 5998c2ecf20Sopenharmony_ci bus_dma_tag_t hscb_dmat; /* dmat for our hardware SCB array */ 6008c2ecf20Sopenharmony_ci bus_dmamap_t hscb_dmamap; 6018c2ecf20Sopenharmony_ci dma_addr_t hscb_busaddr; 6028c2ecf20Sopenharmony_ci bus_dma_tag_t sense_dmat; 6038c2ecf20Sopenharmony_ci bus_dmamap_t sense_dmamap; 6048c2ecf20Sopenharmony_ci dma_addr_t sense_busaddr; 6058c2ecf20Sopenharmony_ci bus_dma_tag_t sg_dmat; /* dmat for our sg segments */ 6068c2ecf20Sopenharmony_ci SLIST_HEAD(, sg_map_node) sg_maps; 6078c2ecf20Sopenharmony_ci uint8_t numscbs; 6088c2ecf20Sopenharmony_ci uint8_t maxhscbs; /* Number of SCBs on the card */ 6098c2ecf20Sopenharmony_ci uint8_t init_level; /* 6108c2ecf20Sopenharmony_ci * How far we've initialized 6118c2ecf20Sopenharmony_ci * this structure. 6128c2ecf20Sopenharmony_ci */ 6138c2ecf20Sopenharmony_ci}; 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci/************************ Target Mode Definitions *****************************/ 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci/* 6188c2ecf20Sopenharmony_ci * Connection descriptor for select-in requests in target mode. 6198c2ecf20Sopenharmony_ci */ 6208c2ecf20Sopenharmony_cistruct target_cmd { 6218c2ecf20Sopenharmony_ci uint8_t scsiid; /* Our ID and the initiator's ID */ 6228c2ecf20Sopenharmony_ci uint8_t identify; /* Identify message */ 6238c2ecf20Sopenharmony_ci uint8_t bytes[22]; /* 6248c2ecf20Sopenharmony_ci * Bytes contains any additional message 6258c2ecf20Sopenharmony_ci * bytes terminated by 0xFF. The remainder 6268c2ecf20Sopenharmony_ci * is the cdb to execute. 6278c2ecf20Sopenharmony_ci */ 6288c2ecf20Sopenharmony_ci uint8_t cmd_valid; /* 6298c2ecf20Sopenharmony_ci * When a command is complete, the firmware 6308c2ecf20Sopenharmony_ci * will set cmd_valid to all bits set. 6318c2ecf20Sopenharmony_ci * After the host has seen the command, 6328c2ecf20Sopenharmony_ci * the bits are cleared. This allows us 6338c2ecf20Sopenharmony_ci * to just peek at host memory to determine 6348c2ecf20Sopenharmony_ci * if more work is complete. cmd_valid is on 6358c2ecf20Sopenharmony_ci * an 8 byte boundary to simplify setting 6368c2ecf20Sopenharmony_ci * it on aic7880 hardware which only has 6378c2ecf20Sopenharmony_ci * limited direct access to the DMA FIFO. 6388c2ecf20Sopenharmony_ci */ 6398c2ecf20Sopenharmony_ci uint8_t pad[7]; 6408c2ecf20Sopenharmony_ci}; 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ci/* 6438c2ecf20Sopenharmony_ci * Number of events we can buffer up if we run out 6448c2ecf20Sopenharmony_ci * of immediate notify ccbs. 6458c2ecf20Sopenharmony_ci */ 6468c2ecf20Sopenharmony_ci#define AHC_TMODE_EVENT_BUFFER_SIZE 8 6478c2ecf20Sopenharmony_cistruct ahc_tmode_event { 6488c2ecf20Sopenharmony_ci uint8_t initiator_id; 6498c2ecf20Sopenharmony_ci uint8_t event_type; /* MSG type or EVENT_TYPE_BUS_RESET */ 6508c2ecf20Sopenharmony_ci#define EVENT_TYPE_BUS_RESET 0xFF 6518c2ecf20Sopenharmony_ci uint8_t event_arg; 6528c2ecf20Sopenharmony_ci}; 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci/* 6558c2ecf20Sopenharmony_ci * Per enabled lun target mode state. 6568c2ecf20Sopenharmony_ci * As this state is directly influenced by the host OS'es target mode 6578c2ecf20Sopenharmony_ci * environment, we let the OS module define it. Forward declare the 6588c2ecf20Sopenharmony_ci * structure here so we can store arrays of them, etc. in OS neutral 6598c2ecf20Sopenharmony_ci * data structures. 6608c2ecf20Sopenharmony_ci */ 6618c2ecf20Sopenharmony_ci#ifdef AHC_TARGET_MODE 6628c2ecf20Sopenharmony_cistruct ahc_tmode_lstate { 6638c2ecf20Sopenharmony_ci struct cam_path *path; 6648c2ecf20Sopenharmony_ci struct ccb_hdr_slist accept_tios; 6658c2ecf20Sopenharmony_ci struct ccb_hdr_slist immed_notifies; 6668c2ecf20Sopenharmony_ci struct ahc_tmode_event event_buffer[AHC_TMODE_EVENT_BUFFER_SIZE]; 6678c2ecf20Sopenharmony_ci uint8_t event_r_idx; 6688c2ecf20Sopenharmony_ci uint8_t event_w_idx; 6698c2ecf20Sopenharmony_ci}; 6708c2ecf20Sopenharmony_ci#else 6718c2ecf20Sopenharmony_cistruct ahc_tmode_lstate; 6728c2ecf20Sopenharmony_ci#endif 6738c2ecf20Sopenharmony_ci 6748c2ecf20Sopenharmony_ci/******************** Transfer Negotiation Datastructures *********************/ 6758c2ecf20Sopenharmony_ci#define AHC_TRANS_CUR 0x01 /* Modify current neogtiation status */ 6768c2ecf20Sopenharmony_ci#define AHC_TRANS_ACTIVE 0x03 /* Assume this target is on the bus */ 6778c2ecf20Sopenharmony_ci#define AHC_TRANS_GOAL 0x04 /* Modify negotiation goal */ 6788c2ecf20Sopenharmony_ci#define AHC_TRANS_USER 0x08 /* Modify user negotiation settings */ 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ci#define AHC_WIDTH_UNKNOWN 0xFF 6818c2ecf20Sopenharmony_ci#define AHC_PERIOD_UNKNOWN 0xFF 6828c2ecf20Sopenharmony_ci#define AHC_OFFSET_UNKNOWN 0xFF 6838c2ecf20Sopenharmony_ci#define AHC_PPR_OPTS_UNKNOWN 0xFF 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci/* 6868c2ecf20Sopenharmony_ci * Transfer Negotiation Information. 6878c2ecf20Sopenharmony_ci */ 6888c2ecf20Sopenharmony_cistruct ahc_transinfo { 6898c2ecf20Sopenharmony_ci uint8_t protocol_version; /* SCSI Revision level */ 6908c2ecf20Sopenharmony_ci uint8_t transport_version; /* SPI Revision level */ 6918c2ecf20Sopenharmony_ci uint8_t width; /* Bus width */ 6928c2ecf20Sopenharmony_ci uint8_t period; /* Sync rate factor */ 6938c2ecf20Sopenharmony_ci uint8_t offset; /* Sync offset */ 6948c2ecf20Sopenharmony_ci uint8_t ppr_options; /* Parallel Protocol Request options */ 6958c2ecf20Sopenharmony_ci}; 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_ci/* 6988c2ecf20Sopenharmony_ci * Per-initiator current, goal and user transfer negotiation information. */ 6998c2ecf20Sopenharmony_cistruct ahc_initiator_tinfo { 7008c2ecf20Sopenharmony_ci uint8_t scsirate; /* Computed value for SCSIRATE reg */ 7018c2ecf20Sopenharmony_ci struct ahc_transinfo curr; 7028c2ecf20Sopenharmony_ci struct ahc_transinfo goal; 7038c2ecf20Sopenharmony_ci struct ahc_transinfo user; 7048c2ecf20Sopenharmony_ci}; 7058c2ecf20Sopenharmony_ci 7068c2ecf20Sopenharmony_ci/* 7078c2ecf20Sopenharmony_ci * Per enabled target ID state. 7088c2ecf20Sopenharmony_ci * Pointers to lun target state as well as sync/wide negotiation information 7098c2ecf20Sopenharmony_ci * for each initiator<->target mapping. For the initiator role we pretend 7108c2ecf20Sopenharmony_ci * that we are the target and the targets are the initiators since the 7118c2ecf20Sopenharmony_ci * negotiation is the same regardless of role. 7128c2ecf20Sopenharmony_ci */ 7138c2ecf20Sopenharmony_cistruct ahc_tmode_tstate { 7148c2ecf20Sopenharmony_ci struct ahc_tmode_lstate* enabled_luns[AHC_NUM_LUNS]; 7158c2ecf20Sopenharmony_ci struct ahc_initiator_tinfo transinfo[AHC_NUM_TARGETS]; 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ci /* 7188c2ecf20Sopenharmony_ci * Per initiator state bitmasks. 7198c2ecf20Sopenharmony_ci */ 7208c2ecf20Sopenharmony_ci uint16_t auto_negotiate;/* Auto Negotiation Required */ 7218c2ecf20Sopenharmony_ci uint16_t ultraenb; /* Using ultra sync rate */ 7228c2ecf20Sopenharmony_ci uint16_t discenable; /* Disconnection allowed */ 7238c2ecf20Sopenharmony_ci uint16_t tagenable; /* Tagged Queuing allowed */ 7248c2ecf20Sopenharmony_ci}; 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ci/* 7278c2ecf20Sopenharmony_ci * Data structure for our table of allowed synchronous transfer rates. 7288c2ecf20Sopenharmony_ci */ 7298c2ecf20Sopenharmony_cistruct ahc_syncrate { 7308c2ecf20Sopenharmony_ci u_int sxfr_u2; /* Value of the SXFR parameter for Ultra2+ Chips */ 7318c2ecf20Sopenharmony_ci u_int sxfr; /* Value of the SXFR parameter for <= Ultra Chips */ 7328c2ecf20Sopenharmony_ci#define ULTRA_SXFR 0x100 /* Rate Requires Ultra Mode set */ 7338c2ecf20Sopenharmony_ci#define ST_SXFR 0x010 /* Rate Single Transition Only */ 7348c2ecf20Sopenharmony_ci#define DT_SXFR 0x040 /* Rate Double Transition Only */ 7358c2ecf20Sopenharmony_ci uint8_t period; /* Period to send to SCSI target */ 7368c2ecf20Sopenharmony_ci const char *rate; 7378c2ecf20Sopenharmony_ci}; 7388c2ecf20Sopenharmony_ci 7398c2ecf20Sopenharmony_ci/* Safe and valid period for async negotiations. */ 7408c2ecf20Sopenharmony_ci#define AHC_ASYNC_XFER_PERIOD 0x45 7418c2ecf20Sopenharmony_ci#define AHC_ULTRA2_XFER_PERIOD 0x0a 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci/* 7448c2ecf20Sopenharmony_ci * Indexes into our table of syncronous transfer rates. 7458c2ecf20Sopenharmony_ci */ 7468c2ecf20Sopenharmony_ci#define AHC_SYNCRATE_DT 0 7478c2ecf20Sopenharmony_ci#define AHC_SYNCRATE_ULTRA2 1 7488c2ecf20Sopenharmony_ci#define AHC_SYNCRATE_ULTRA 3 7498c2ecf20Sopenharmony_ci#define AHC_SYNCRATE_FAST 6 7508c2ecf20Sopenharmony_ci#define AHC_SYNCRATE_MAX AHC_SYNCRATE_DT 7518c2ecf20Sopenharmony_ci#define AHC_SYNCRATE_MIN 13 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_ci/***************************** Lookup Tables **********************************/ 7548c2ecf20Sopenharmony_ci/* 7558c2ecf20Sopenharmony_ci * Phase -> name and message out response 7568c2ecf20Sopenharmony_ci * to parity errors in each phase table. 7578c2ecf20Sopenharmony_ci */ 7588c2ecf20Sopenharmony_cistruct ahc_phase_table_entry { 7598c2ecf20Sopenharmony_ci uint8_t phase; 7608c2ecf20Sopenharmony_ci uint8_t mesg_out; /* Message response to parity errors */ 7618c2ecf20Sopenharmony_ci char *phasemsg; 7628c2ecf20Sopenharmony_ci}; 7638c2ecf20Sopenharmony_ci 7648c2ecf20Sopenharmony_ci/************************** Serial EEPROM Format ******************************/ 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_cistruct seeprom_config { 7678c2ecf20Sopenharmony_ci/* 7688c2ecf20Sopenharmony_ci * Per SCSI ID Configuration Flags 7698c2ecf20Sopenharmony_ci */ 7708c2ecf20Sopenharmony_ci uint16_t device_flags[16]; /* words 0-15 */ 7718c2ecf20Sopenharmony_ci#define CFXFER 0x0007 /* synchronous transfer rate */ 7728c2ecf20Sopenharmony_ci#define CFSYNCH 0x0008 /* enable synchronous transfer */ 7738c2ecf20Sopenharmony_ci#define CFDISC 0x0010 /* enable disconnection */ 7748c2ecf20Sopenharmony_ci#define CFWIDEB 0x0020 /* wide bus device */ 7758c2ecf20Sopenharmony_ci#define CFSYNCHISULTRA 0x0040 /* CFSYNCH is an ultra offset (2940AU)*/ 7768c2ecf20Sopenharmony_ci#define CFSYNCSINGLE 0x0080 /* Single-Transition signalling */ 7778c2ecf20Sopenharmony_ci#define CFSTART 0x0100 /* send start unit SCSI command */ 7788c2ecf20Sopenharmony_ci#define CFINCBIOS 0x0200 /* include in BIOS scan */ 7798c2ecf20Sopenharmony_ci#define CFRNFOUND 0x0400 /* report even if not found */ 7808c2ecf20Sopenharmony_ci#define CFMULTILUNDEV 0x0800 /* Probe multiple luns in BIOS scan */ 7818c2ecf20Sopenharmony_ci#define CFWBCACHEENB 0x4000 /* Enable W-Behind Cache on disks */ 7828c2ecf20Sopenharmony_ci#define CFWBCACHENOP 0xc000 /* Don't touch W-Behind Cache */ 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci/* 7858c2ecf20Sopenharmony_ci * BIOS Control Bits 7868c2ecf20Sopenharmony_ci */ 7878c2ecf20Sopenharmony_ci uint16_t bios_control; /* word 16 */ 7888c2ecf20Sopenharmony_ci#define CFSUPREM 0x0001 /* support all removeable drives */ 7898c2ecf20Sopenharmony_ci#define CFSUPREMB 0x0002 /* support removeable boot drives */ 7908c2ecf20Sopenharmony_ci#define CFBIOSEN 0x0004 /* BIOS enabled */ 7918c2ecf20Sopenharmony_ci#define CFBIOS_BUSSCAN 0x0008 /* Have the BIOS Scan the Bus */ 7928c2ecf20Sopenharmony_ci#define CFSM2DRV 0x0010 /* support more than two drives */ 7938c2ecf20Sopenharmony_ci#define CFSTPWLEVEL 0x0010 /* Termination level control */ 7948c2ecf20Sopenharmony_ci#define CF284XEXTEND 0x0020 /* extended translation (284x cards) */ 7958c2ecf20Sopenharmony_ci#define CFCTRL_A 0x0020 /* BIOS displays Ctrl-A message */ 7968c2ecf20Sopenharmony_ci#define CFTERM_MENU 0x0040 /* BIOS displays termination menu */ 7978c2ecf20Sopenharmony_ci#define CFEXTEND 0x0080 /* extended translation enabled */ 7988c2ecf20Sopenharmony_ci#define CFSCAMEN 0x0100 /* SCAM enable */ 7998c2ecf20Sopenharmony_ci#define CFMSG_LEVEL 0x0600 /* BIOS Message Level */ 8008c2ecf20Sopenharmony_ci#define CFMSG_VERBOSE 0x0000 8018c2ecf20Sopenharmony_ci#define CFMSG_SILENT 0x0200 8028c2ecf20Sopenharmony_ci#define CFMSG_DIAG 0x0400 8038c2ecf20Sopenharmony_ci#define CFBOOTCD 0x0800 /* Support Bootable CD-ROM */ 8048c2ecf20Sopenharmony_ci/* UNUSED 0xff00 */ 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ci/* 8078c2ecf20Sopenharmony_ci * Host Adapter Control Bits 8088c2ecf20Sopenharmony_ci */ 8098c2ecf20Sopenharmony_ci uint16_t adapter_control; /* word 17 */ 8108c2ecf20Sopenharmony_ci#define CFAUTOTERM 0x0001 /* Perform Auto termination */ 8118c2ecf20Sopenharmony_ci#define CFULTRAEN 0x0002 /* Ultra SCSI speed enable */ 8128c2ecf20Sopenharmony_ci#define CF284XSELTO 0x0003 /* Selection timeout (284x cards) */ 8138c2ecf20Sopenharmony_ci#define CF284XFIFO 0x000C /* FIFO Threshold (284x cards) */ 8148c2ecf20Sopenharmony_ci#define CFSTERM 0x0004 /* SCSI low byte termination */ 8158c2ecf20Sopenharmony_ci#define CFWSTERM 0x0008 /* SCSI high byte termination */ 8168c2ecf20Sopenharmony_ci#define CFSPARITY 0x0010 /* SCSI parity */ 8178c2ecf20Sopenharmony_ci#define CF284XSTERM 0x0020 /* SCSI low byte term (284x cards) */ 8188c2ecf20Sopenharmony_ci#define CFMULTILUN 0x0020 8198c2ecf20Sopenharmony_ci#define CFRESETB 0x0040 /* reset SCSI bus at boot */ 8208c2ecf20Sopenharmony_ci#define CFCLUSTERENB 0x0080 /* Cluster Enable */ 8218c2ecf20Sopenharmony_ci#define CFBOOTCHAN 0x0300 /* probe this channel first */ 8228c2ecf20Sopenharmony_ci#define CFBOOTCHANSHIFT 8 8238c2ecf20Sopenharmony_ci#define CFSEAUTOTERM 0x0400 /* Ultra2 Perform secondary Auto Term*/ 8248c2ecf20Sopenharmony_ci#define CFSELOWTERM 0x0800 /* Ultra2 secondary low term */ 8258c2ecf20Sopenharmony_ci#define CFSEHIGHTERM 0x1000 /* Ultra2 secondary high term */ 8268c2ecf20Sopenharmony_ci#define CFENABLEDV 0x4000 /* Perform Domain Validation*/ 8278c2ecf20Sopenharmony_ci 8288c2ecf20Sopenharmony_ci/* 8298c2ecf20Sopenharmony_ci * Bus Release Time, Host Adapter ID 8308c2ecf20Sopenharmony_ci */ 8318c2ecf20Sopenharmony_ci uint16_t brtime_id; /* word 18 */ 8328c2ecf20Sopenharmony_ci#define CFSCSIID 0x000f /* host adapter SCSI ID */ 8338c2ecf20Sopenharmony_ci/* UNUSED 0x00f0 */ 8348c2ecf20Sopenharmony_ci#define CFBRTIME 0xff00 /* bus release time */ 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci/* 8378c2ecf20Sopenharmony_ci * Maximum targets 8388c2ecf20Sopenharmony_ci */ 8398c2ecf20Sopenharmony_ci uint16_t max_targets; /* word 19 */ 8408c2ecf20Sopenharmony_ci#define CFMAXTARG 0x00ff /* maximum targets */ 8418c2ecf20Sopenharmony_ci#define CFBOOTLUN 0x0f00 /* Lun to boot from */ 8428c2ecf20Sopenharmony_ci#define CFBOOTID 0xf000 /* Target to boot from */ 8438c2ecf20Sopenharmony_ci uint16_t res_1[10]; /* words 20-29 */ 8448c2ecf20Sopenharmony_ci uint16_t signature; /* Signature == 0x250 */ 8458c2ecf20Sopenharmony_ci#define CFSIGNATURE 0x250 8468c2ecf20Sopenharmony_ci#define CFSIGNATURE2 0x300 8478c2ecf20Sopenharmony_ci uint16_t checksum; /* word 31 */ 8488c2ecf20Sopenharmony_ci}; 8498c2ecf20Sopenharmony_ci 8508c2ecf20Sopenharmony_ci/**************************** Message Buffer *********************************/ 8518c2ecf20Sopenharmony_citypedef enum { 8528c2ecf20Sopenharmony_ci MSG_TYPE_NONE = 0x00, 8538c2ecf20Sopenharmony_ci MSG_TYPE_INITIATOR_MSGOUT = 0x01, 8548c2ecf20Sopenharmony_ci MSG_TYPE_INITIATOR_MSGIN = 0x02, 8558c2ecf20Sopenharmony_ci MSG_TYPE_TARGET_MSGOUT = 0x03, 8568c2ecf20Sopenharmony_ci MSG_TYPE_TARGET_MSGIN = 0x04 8578c2ecf20Sopenharmony_ci} ahc_msg_type; 8588c2ecf20Sopenharmony_ci 8598c2ecf20Sopenharmony_citypedef enum { 8608c2ecf20Sopenharmony_ci MSGLOOP_IN_PROG, 8618c2ecf20Sopenharmony_ci MSGLOOP_MSGCOMPLETE, 8628c2ecf20Sopenharmony_ci MSGLOOP_TERMINATED 8638c2ecf20Sopenharmony_ci} msg_loop_stat; 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_ci/*********************** Software Configuration Structure *********************/ 8668c2ecf20Sopenharmony_ciTAILQ_HEAD(scb_tailq, scb); 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_cistruct ahc_aic7770_softc { 8698c2ecf20Sopenharmony_ci /* 8708c2ecf20Sopenharmony_ci * Saved register state used for chip_init(). 8718c2ecf20Sopenharmony_ci */ 8728c2ecf20Sopenharmony_ci uint8_t busspd; 8738c2ecf20Sopenharmony_ci uint8_t bustime; 8748c2ecf20Sopenharmony_ci}; 8758c2ecf20Sopenharmony_ci 8768c2ecf20Sopenharmony_cistruct ahc_pci_softc { 8778c2ecf20Sopenharmony_ci /* 8788c2ecf20Sopenharmony_ci * Saved register state used for chip_init(). 8798c2ecf20Sopenharmony_ci */ 8808c2ecf20Sopenharmony_ci uint32_t devconfig; 8818c2ecf20Sopenharmony_ci uint16_t targcrccnt; 8828c2ecf20Sopenharmony_ci uint8_t command; 8838c2ecf20Sopenharmony_ci uint8_t csize_lattime; 8848c2ecf20Sopenharmony_ci uint8_t optionmode; 8858c2ecf20Sopenharmony_ci uint8_t crccontrol1; 8868c2ecf20Sopenharmony_ci uint8_t dscommand0; 8878c2ecf20Sopenharmony_ci uint8_t dspcistatus; 8888c2ecf20Sopenharmony_ci uint8_t scbbaddr; 8898c2ecf20Sopenharmony_ci uint8_t dff_thrsh; 8908c2ecf20Sopenharmony_ci}; 8918c2ecf20Sopenharmony_ci 8928c2ecf20Sopenharmony_ciunion ahc_bus_softc { 8938c2ecf20Sopenharmony_ci struct ahc_aic7770_softc aic7770_softc; 8948c2ecf20Sopenharmony_ci struct ahc_pci_softc pci_softc; 8958c2ecf20Sopenharmony_ci}; 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_citypedef void (*ahc_bus_intr_t)(struct ahc_softc *); 8988c2ecf20Sopenharmony_citypedef int (*ahc_bus_chip_init_t)(struct ahc_softc *); 8998c2ecf20Sopenharmony_citypedef int (*ahc_bus_suspend_t)(struct ahc_softc *); 9008c2ecf20Sopenharmony_citypedef int (*ahc_bus_resume_t)(struct ahc_softc *); 9018c2ecf20Sopenharmony_citypedef void ahc_callback_t (void *); 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_cistruct ahc_softc { 9048c2ecf20Sopenharmony_ci bus_space_tag_t tag; 9058c2ecf20Sopenharmony_ci bus_space_handle_t bsh; 9068c2ecf20Sopenharmony_ci struct scb_data *scb_data; 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_ci struct scb *next_queued_scb; 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci /* 9118c2ecf20Sopenharmony_ci * SCBs that have been sent to the controller 9128c2ecf20Sopenharmony_ci */ 9138c2ecf20Sopenharmony_ci BSD_LIST_HEAD(, scb) pending_scbs; 9148c2ecf20Sopenharmony_ci 9158c2ecf20Sopenharmony_ci /* 9168c2ecf20Sopenharmony_ci * Counting lock for deferring the release of additional 9178c2ecf20Sopenharmony_ci * untagged transactions from the untagged_queues. When 9188c2ecf20Sopenharmony_ci * the lock is decremented to 0, all queues in the 9198c2ecf20Sopenharmony_ci * untagged_queues array are run. 9208c2ecf20Sopenharmony_ci */ 9218c2ecf20Sopenharmony_ci u_int untagged_queue_lock; 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_ci /* 9248c2ecf20Sopenharmony_ci * Per-target queue of untagged-transactions. The 9258c2ecf20Sopenharmony_ci * transaction at the head of the queue is the 9268c2ecf20Sopenharmony_ci * currently pending untagged transaction for the 9278c2ecf20Sopenharmony_ci * target. The driver only allows a single untagged 9288c2ecf20Sopenharmony_ci * transaction per target. 9298c2ecf20Sopenharmony_ci */ 9308c2ecf20Sopenharmony_ci struct scb_tailq untagged_queues[AHC_NUM_TARGETS]; 9318c2ecf20Sopenharmony_ci 9328c2ecf20Sopenharmony_ci /* 9338c2ecf20Sopenharmony_ci * Bus attachment specific data. 9348c2ecf20Sopenharmony_ci */ 9358c2ecf20Sopenharmony_ci union ahc_bus_softc bus_softc; 9368c2ecf20Sopenharmony_ci 9378c2ecf20Sopenharmony_ci /* 9388c2ecf20Sopenharmony_ci * Platform specific data. 9398c2ecf20Sopenharmony_ci */ 9408c2ecf20Sopenharmony_ci struct ahc_platform_data *platform_data; 9418c2ecf20Sopenharmony_ci 9428c2ecf20Sopenharmony_ci /* 9438c2ecf20Sopenharmony_ci * Platform specific device information. 9448c2ecf20Sopenharmony_ci */ 9458c2ecf20Sopenharmony_ci ahc_dev_softc_t dev_softc; 9468c2ecf20Sopenharmony_ci struct device *dev; 9478c2ecf20Sopenharmony_ci 9488c2ecf20Sopenharmony_ci /* 9498c2ecf20Sopenharmony_ci * Bus specific device information. 9508c2ecf20Sopenharmony_ci */ 9518c2ecf20Sopenharmony_ci ahc_bus_intr_t bus_intr; 9528c2ecf20Sopenharmony_ci 9538c2ecf20Sopenharmony_ci /* 9548c2ecf20Sopenharmony_ci * Bus specific initialization required 9558c2ecf20Sopenharmony_ci * after a chip reset. 9568c2ecf20Sopenharmony_ci */ 9578c2ecf20Sopenharmony_ci ahc_bus_chip_init_t bus_chip_init; 9588c2ecf20Sopenharmony_ci 9598c2ecf20Sopenharmony_ci /* 9608c2ecf20Sopenharmony_ci * Target mode related state kept on a per enabled lun basis. 9618c2ecf20Sopenharmony_ci * Targets that are not enabled will have null entries. 9628c2ecf20Sopenharmony_ci * As an initiator, we keep one target entry for our initiator 9638c2ecf20Sopenharmony_ci * ID to store our sync/wide transfer settings. 9648c2ecf20Sopenharmony_ci */ 9658c2ecf20Sopenharmony_ci struct ahc_tmode_tstate *enabled_targets[AHC_NUM_TARGETS]; 9668c2ecf20Sopenharmony_ci 9678c2ecf20Sopenharmony_ci /* 9688c2ecf20Sopenharmony_ci * The black hole device responsible for handling requests for 9698c2ecf20Sopenharmony_ci * disabled luns on enabled targets. 9708c2ecf20Sopenharmony_ci */ 9718c2ecf20Sopenharmony_ci struct ahc_tmode_lstate *black_hole; 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_ci /* 9748c2ecf20Sopenharmony_ci * Device instance currently on the bus awaiting a continue TIO 9758c2ecf20Sopenharmony_ci * for a command that was not given the disconnect priveledge. 9768c2ecf20Sopenharmony_ci */ 9778c2ecf20Sopenharmony_ci struct ahc_tmode_lstate *pending_device; 9788c2ecf20Sopenharmony_ci 9798c2ecf20Sopenharmony_ci /* 9808c2ecf20Sopenharmony_ci * Card characteristics 9818c2ecf20Sopenharmony_ci */ 9828c2ecf20Sopenharmony_ci ahc_chip chip; 9838c2ecf20Sopenharmony_ci ahc_feature features; 9848c2ecf20Sopenharmony_ci ahc_bug bugs; 9858c2ecf20Sopenharmony_ci ahc_flag flags; 9868c2ecf20Sopenharmony_ci struct seeprom_config *seep_config; 9878c2ecf20Sopenharmony_ci 9888c2ecf20Sopenharmony_ci /* Values to store in the SEQCTL register for pause and unpause */ 9898c2ecf20Sopenharmony_ci uint8_t unpause; 9908c2ecf20Sopenharmony_ci uint8_t pause; 9918c2ecf20Sopenharmony_ci 9928c2ecf20Sopenharmony_ci /* Command Queues */ 9938c2ecf20Sopenharmony_ci uint8_t qoutfifonext; 9948c2ecf20Sopenharmony_ci uint8_t qinfifonext; 9958c2ecf20Sopenharmony_ci uint8_t *qoutfifo; 9968c2ecf20Sopenharmony_ci uint8_t *qinfifo; 9978c2ecf20Sopenharmony_ci 9988c2ecf20Sopenharmony_ci /* Critical Section Data */ 9998c2ecf20Sopenharmony_ci struct cs *critical_sections; 10008c2ecf20Sopenharmony_ci u_int num_critical_sections; 10018c2ecf20Sopenharmony_ci 10028c2ecf20Sopenharmony_ci /* Channel Names ('A', 'B', etc.) */ 10038c2ecf20Sopenharmony_ci char channel; 10048c2ecf20Sopenharmony_ci char channel_b; 10058c2ecf20Sopenharmony_ci 10068c2ecf20Sopenharmony_ci /* Initiator Bus ID */ 10078c2ecf20Sopenharmony_ci uint8_t our_id; 10088c2ecf20Sopenharmony_ci uint8_t our_id_b; 10098c2ecf20Sopenharmony_ci 10108c2ecf20Sopenharmony_ci /* 10118c2ecf20Sopenharmony_ci * PCI error detection. 10128c2ecf20Sopenharmony_ci */ 10138c2ecf20Sopenharmony_ci int unsolicited_ints; 10148c2ecf20Sopenharmony_ci 10158c2ecf20Sopenharmony_ci /* 10168c2ecf20Sopenharmony_ci * Target incoming command FIFO. 10178c2ecf20Sopenharmony_ci */ 10188c2ecf20Sopenharmony_ci struct target_cmd *targetcmds; 10198c2ecf20Sopenharmony_ci uint8_t tqinfifonext; 10208c2ecf20Sopenharmony_ci 10218c2ecf20Sopenharmony_ci /* 10228c2ecf20Sopenharmony_ci * Cached copy of the sequencer control register. 10238c2ecf20Sopenharmony_ci */ 10248c2ecf20Sopenharmony_ci uint8_t seqctl; 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_ci /* 10278c2ecf20Sopenharmony_ci * Incoming and outgoing message handling. 10288c2ecf20Sopenharmony_ci */ 10298c2ecf20Sopenharmony_ci uint8_t send_msg_perror; 10308c2ecf20Sopenharmony_ci ahc_msg_type msg_type; 10318c2ecf20Sopenharmony_ci uint8_t msgout_buf[12];/* Message we are sending */ 10328c2ecf20Sopenharmony_ci uint8_t msgin_buf[12];/* Message we are receiving */ 10338c2ecf20Sopenharmony_ci u_int msgout_len; /* Length of message to send */ 10348c2ecf20Sopenharmony_ci u_int msgout_index; /* Current index in msgout */ 10358c2ecf20Sopenharmony_ci u_int msgin_index; /* Current index in msgin */ 10368c2ecf20Sopenharmony_ci 10378c2ecf20Sopenharmony_ci /* 10388c2ecf20Sopenharmony_ci * Mapping information for data structures shared 10398c2ecf20Sopenharmony_ci * between the sequencer and kernel. 10408c2ecf20Sopenharmony_ci */ 10418c2ecf20Sopenharmony_ci bus_dma_tag_t parent_dmat; 10428c2ecf20Sopenharmony_ci bus_dma_tag_t shared_data_dmat; 10438c2ecf20Sopenharmony_ci bus_dmamap_t shared_data_dmamap; 10448c2ecf20Sopenharmony_ci dma_addr_t shared_data_busaddr; 10458c2ecf20Sopenharmony_ci 10468c2ecf20Sopenharmony_ci /* 10478c2ecf20Sopenharmony_ci * Bus address of the one byte buffer used to 10488c2ecf20Sopenharmony_ci * work-around a DMA bug for chips <= aic7880 10498c2ecf20Sopenharmony_ci * in target mode. 10508c2ecf20Sopenharmony_ci */ 10518c2ecf20Sopenharmony_ci dma_addr_t dma_bug_buf; 10528c2ecf20Sopenharmony_ci 10538c2ecf20Sopenharmony_ci /* Number of enabled target mode device on this card */ 10548c2ecf20Sopenharmony_ci u_int enabled_luns; 10558c2ecf20Sopenharmony_ci 10568c2ecf20Sopenharmony_ci /* Initialization level of this data structure */ 10578c2ecf20Sopenharmony_ci u_int init_level; 10588c2ecf20Sopenharmony_ci 10598c2ecf20Sopenharmony_ci /* PCI cacheline size. */ 10608c2ecf20Sopenharmony_ci u_int pci_cachesize; 10618c2ecf20Sopenharmony_ci 10628c2ecf20Sopenharmony_ci /* 10638c2ecf20Sopenharmony_ci * Count of parity errors we have seen as a target. 10648c2ecf20Sopenharmony_ci * We auto-disable parity error checking after seeing 10658c2ecf20Sopenharmony_ci * AHC_PCI_TARGET_PERR_THRESH number of errors. 10668c2ecf20Sopenharmony_ci */ 10678c2ecf20Sopenharmony_ci u_int pci_target_perr_count; 10688c2ecf20Sopenharmony_ci#define AHC_PCI_TARGET_PERR_THRESH 10 10698c2ecf20Sopenharmony_ci 10708c2ecf20Sopenharmony_ci /* Maximum number of sequencer instructions supported. */ 10718c2ecf20Sopenharmony_ci u_int instruction_ram_size; 10728c2ecf20Sopenharmony_ci 10738c2ecf20Sopenharmony_ci /* Per-Unit descriptive information */ 10748c2ecf20Sopenharmony_ci const char *description; 10758c2ecf20Sopenharmony_ci char *name; 10768c2ecf20Sopenharmony_ci int unit; 10778c2ecf20Sopenharmony_ci 10788c2ecf20Sopenharmony_ci /* Selection Timer settings */ 10798c2ecf20Sopenharmony_ci int seltime; 10808c2ecf20Sopenharmony_ci int seltime_b; 10818c2ecf20Sopenharmony_ci 10828c2ecf20Sopenharmony_ci uint16_t user_discenable;/* Disconnection allowed */ 10838c2ecf20Sopenharmony_ci uint16_t user_tagenable;/* Tagged Queuing allowed */ 10848c2ecf20Sopenharmony_ci}; 10858c2ecf20Sopenharmony_ci 10868c2ecf20Sopenharmony_ci/************************ Active Device Information ***************************/ 10878c2ecf20Sopenharmony_citypedef enum { 10888c2ecf20Sopenharmony_ci ROLE_UNKNOWN, 10898c2ecf20Sopenharmony_ci ROLE_INITIATOR, 10908c2ecf20Sopenharmony_ci ROLE_TARGET 10918c2ecf20Sopenharmony_ci} role_t; 10928c2ecf20Sopenharmony_ci 10938c2ecf20Sopenharmony_cistruct ahc_devinfo { 10948c2ecf20Sopenharmony_ci int our_scsiid; 10958c2ecf20Sopenharmony_ci int target_offset; 10968c2ecf20Sopenharmony_ci uint16_t target_mask; 10978c2ecf20Sopenharmony_ci u_int target; 10988c2ecf20Sopenharmony_ci u_int lun; 10998c2ecf20Sopenharmony_ci char channel; 11008c2ecf20Sopenharmony_ci role_t role; /* 11018c2ecf20Sopenharmony_ci * Only guaranteed to be correct if not 11028c2ecf20Sopenharmony_ci * in the busfree state. 11038c2ecf20Sopenharmony_ci */ 11048c2ecf20Sopenharmony_ci}; 11058c2ecf20Sopenharmony_ci 11068c2ecf20Sopenharmony_ci/****************************** PCI Structures ********************************/ 11078c2ecf20Sopenharmony_citypedef int (ahc_device_setup_t)(struct ahc_softc *); 11088c2ecf20Sopenharmony_ci 11098c2ecf20Sopenharmony_cistruct ahc_pci_identity { 11108c2ecf20Sopenharmony_ci uint64_t full_id; 11118c2ecf20Sopenharmony_ci uint64_t id_mask; 11128c2ecf20Sopenharmony_ci const char *name; 11138c2ecf20Sopenharmony_ci ahc_device_setup_t *setup; 11148c2ecf20Sopenharmony_ci}; 11158c2ecf20Sopenharmony_ci 11168c2ecf20Sopenharmony_ci/***************************** VL/EISA Declarations ***************************/ 11178c2ecf20Sopenharmony_cistruct aic7770_identity { 11188c2ecf20Sopenharmony_ci uint32_t full_id; 11198c2ecf20Sopenharmony_ci uint32_t id_mask; 11208c2ecf20Sopenharmony_ci const char *name; 11218c2ecf20Sopenharmony_ci ahc_device_setup_t *setup; 11228c2ecf20Sopenharmony_ci}; 11238c2ecf20Sopenharmony_ciextern struct aic7770_identity aic7770_ident_table[]; 11248c2ecf20Sopenharmony_ciextern const int ahc_num_aic7770_devs; 11258c2ecf20Sopenharmony_ci 11268c2ecf20Sopenharmony_ci#define AHC_EISA_SLOT_OFFSET 0xc00 11278c2ecf20Sopenharmony_ci#define AHC_EISA_IOSIZE 0x100 11288c2ecf20Sopenharmony_ci 11298c2ecf20Sopenharmony_ci/*************************** Function Declarations ****************************/ 11308c2ecf20Sopenharmony_ci/******************************************************************************/ 11318c2ecf20Sopenharmony_ci 11328c2ecf20Sopenharmony_ci/***************************** PCI Front End *********************************/ 11338c2ecf20Sopenharmony_ciconst struct ahc_pci_identity *ahc_find_pci_device(ahc_dev_softc_t); 11348c2ecf20Sopenharmony_ciint ahc_pci_config(struct ahc_softc *, 11358c2ecf20Sopenharmony_ci const struct ahc_pci_identity *); 11368c2ecf20Sopenharmony_ciint ahc_pci_test_register_access(struct ahc_softc *); 11378c2ecf20Sopenharmony_ci#ifdef CONFIG_PM 11388c2ecf20Sopenharmony_civoid ahc_pci_resume(struct ahc_softc *ahc); 11398c2ecf20Sopenharmony_ci#endif 11408c2ecf20Sopenharmony_ci 11418c2ecf20Sopenharmony_ci/*************************** EISA/VL Front End ********************************/ 11428c2ecf20Sopenharmony_cistruct aic7770_identity *aic7770_find_device(uint32_t); 11438c2ecf20Sopenharmony_ciint aic7770_config(struct ahc_softc *ahc, 11448c2ecf20Sopenharmony_ci struct aic7770_identity *, 11458c2ecf20Sopenharmony_ci u_int port); 11468c2ecf20Sopenharmony_ci 11478c2ecf20Sopenharmony_ci/************************** SCB and SCB queue management **********************/ 11488c2ecf20Sopenharmony_ciint ahc_probe_scbs(struct ahc_softc *); 11498c2ecf20Sopenharmony_civoid ahc_qinfifo_requeue_tail(struct ahc_softc *ahc, 11508c2ecf20Sopenharmony_ci struct scb *scb); 11518c2ecf20Sopenharmony_ciint ahc_match_scb(struct ahc_softc *ahc, struct scb *scb, 11528c2ecf20Sopenharmony_ci int target, char channel, int lun, 11538c2ecf20Sopenharmony_ci u_int tag, role_t role); 11548c2ecf20Sopenharmony_ci 11558c2ecf20Sopenharmony_ci/****************************** Initialization ********************************/ 11568c2ecf20Sopenharmony_cistruct ahc_softc *ahc_alloc(void *platform_arg, char *name); 11578c2ecf20Sopenharmony_ciint ahc_softc_init(struct ahc_softc *); 11588c2ecf20Sopenharmony_civoid ahc_controller_info(struct ahc_softc *ahc, char *buf); 11598c2ecf20Sopenharmony_ciint ahc_chip_init(struct ahc_softc *ahc); 11608c2ecf20Sopenharmony_ciint ahc_init(struct ahc_softc *ahc); 11618c2ecf20Sopenharmony_civoid ahc_intr_enable(struct ahc_softc *ahc, int enable); 11628c2ecf20Sopenharmony_civoid ahc_pause_and_flushwork(struct ahc_softc *ahc); 11638c2ecf20Sopenharmony_ci#ifdef CONFIG_PM 11648c2ecf20Sopenharmony_ciint ahc_suspend(struct ahc_softc *ahc); 11658c2ecf20Sopenharmony_ciint ahc_resume(struct ahc_softc *ahc); 11668c2ecf20Sopenharmony_ci#endif 11678c2ecf20Sopenharmony_civoid ahc_set_unit(struct ahc_softc *, int); 11688c2ecf20Sopenharmony_civoid ahc_set_name(struct ahc_softc *, char *); 11698c2ecf20Sopenharmony_civoid ahc_free(struct ahc_softc *ahc); 11708c2ecf20Sopenharmony_ciint ahc_reset(struct ahc_softc *ahc, int reinit); 11718c2ecf20Sopenharmony_ci 11728c2ecf20Sopenharmony_ci/***************************** Error Recovery *********************************/ 11738c2ecf20Sopenharmony_citypedef enum { 11748c2ecf20Sopenharmony_ci SEARCH_COMPLETE, 11758c2ecf20Sopenharmony_ci SEARCH_COUNT, 11768c2ecf20Sopenharmony_ci SEARCH_REMOVE 11778c2ecf20Sopenharmony_ci} ahc_search_action; 11788c2ecf20Sopenharmony_ciint ahc_search_qinfifo(struct ahc_softc *ahc, int target, 11798c2ecf20Sopenharmony_ci char channel, int lun, u_int tag, 11808c2ecf20Sopenharmony_ci role_t role, uint32_t status, 11818c2ecf20Sopenharmony_ci ahc_search_action action); 11828c2ecf20Sopenharmony_ciint ahc_search_untagged_queues(struct ahc_softc *ahc, 11838c2ecf20Sopenharmony_ci ahc_io_ctx_t ctx, 11848c2ecf20Sopenharmony_ci int target, char channel, 11858c2ecf20Sopenharmony_ci int lun, uint32_t status, 11868c2ecf20Sopenharmony_ci ahc_search_action action); 11878c2ecf20Sopenharmony_ciint ahc_search_disc_list(struct ahc_softc *ahc, int target, 11888c2ecf20Sopenharmony_ci char channel, int lun, u_int tag, 11898c2ecf20Sopenharmony_ci int stop_on_first, int remove, 11908c2ecf20Sopenharmony_ci int save_state); 11918c2ecf20Sopenharmony_ciint ahc_reset_channel(struct ahc_softc *ahc, char channel, 11928c2ecf20Sopenharmony_ci int initiate_reset); 11938c2ecf20Sopenharmony_ci 11948c2ecf20Sopenharmony_ci/*************************** Utility Functions ********************************/ 11958c2ecf20Sopenharmony_civoid ahc_compile_devinfo(struct ahc_devinfo *devinfo, 11968c2ecf20Sopenharmony_ci u_int our_id, u_int target, 11978c2ecf20Sopenharmony_ci u_int lun, char channel, 11988c2ecf20Sopenharmony_ci role_t role); 11998c2ecf20Sopenharmony_ci/************************** Transfer Negotiation ******************************/ 12008c2ecf20Sopenharmony_ciconst struct ahc_syncrate* ahc_find_syncrate(struct ahc_softc *ahc, u_int *period, 12018c2ecf20Sopenharmony_ci u_int *ppr_options, u_int maxsync); 12028c2ecf20Sopenharmony_ciu_int ahc_find_period(struct ahc_softc *ahc, 12038c2ecf20Sopenharmony_ci u_int scsirate, u_int maxsync); 12048c2ecf20Sopenharmony_ci/* 12058c2ecf20Sopenharmony_ci * Negotiation types. These are used to qualify if we should renegotiate 12068c2ecf20Sopenharmony_ci * even if our goal and current transport parameters are identical. 12078c2ecf20Sopenharmony_ci */ 12088c2ecf20Sopenharmony_citypedef enum { 12098c2ecf20Sopenharmony_ci AHC_NEG_TO_GOAL, /* Renegotiate only if goal and curr differ. */ 12108c2ecf20Sopenharmony_ci AHC_NEG_IF_NON_ASYNC, /* Renegotiate so long as goal is non-async. */ 12118c2ecf20Sopenharmony_ci AHC_NEG_ALWAYS /* Renegotiat even if goal is async. */ 12128c2ecf20Sopenharmony_ci} ahc_neg_type; 12138c2ecf20Sopenharmony_ciint ahc_update_neg_request(struct ahc_softc*, 12148c2ecf20Sopenharmony_ci struct ahc_devinfo*, 12158c2ecf20Sopenharmony_ci struct ahc_tmode_tstate*, 12168c2ecf20Sopenharmony_ci struct ahc_initiator_tinfo*, 12178c2ecf20Sopenharmony_ci ahc_neg_type); 12188c2ecf20Sopenharmony_civoid ahc_set_width(struct ahc_softc *ahc, 12198c2ecf20Sopenharmony_ci struct ahc_devinfo *devinfo, 12208c2ecf20Sopenharmony_ci u_int width, u_int type, int paused); 12218c2ecf20Sopenharmony_civoid ahc_set_syncrate(struct ahc_softc *ahc, 12228c2ecf20Sopenharmony_ci struct ahc_devinfo *devinfo, 12238c2ecf20Sopenharmony_ci const struct ahc_syncrate *syncrate, 12248c2ecf20Sopenharmony_ci u_int period, u_int offset, 12258c2ecf20Sopenharmony_ci u_int ppr_options, 12268c2ecf20Sopenharmony_ci u_int type, int paused); 12278c2ecf20Sopenharmony_citypedef enum { 12288c2ecf20Sopenharmony_ci AHC_QUEUE_NONE, 12298c2ecf20Sopenharmony_ci AHC_QUEUE_BASIC, 12308c2ecf20Sopenharmony_ci AHC_QUEUE_TAGGED 12318c2ecf20Sopenharmony_ci} ahc_queue_alg; 12328c2ecf20Sopenharmony_ci 12338c2ecf20Sopenharmony_ci/**************************** Target Mode *************************************/ 12348c2ecf20Sopenharmony_ci#ifdef AHC_TARGET_MODE 12358c2ecf20Sopenharmony_civoid ahc_send_lstate_events(struct ahc_softc *, 12368c2ecf20Sopenharmony_ci struct ahc_tmode_lstate *); 12378c2ecf20Sopenharmony_civoid ahc_handle_en_lun(struct ahc_softc *ahc, 12388c2ecf20Sopenharmony_ci struct cam_sim *sim, union ccb *ccb); 12398c2ecf20Sopenharmony_cicam_status ahc_find_tmode_devs(struct ahc_softc *ahc, 12408c2ecf20Sopenharmony_ci struct cam_sim *sim, union ccb *ccb, 12418c2ecf20Sopenharmony_ci struct ahc_tmode_tstate **tstate, 12428c2ecf20Sopenharmony_ci struct ahc_tmode_lstate **lstate, 12438c2ecf20Sopenharmony_ci int notfound_failure); 12448c2ecf20Sopenharmony_ci#ifndef AHC_TMODE_ENABLE 12458c2ecf20Sopenharmony_ci#define AHC_TMODE_ENABLE 0 12468c2ecf20Sopenharmony_ci#endif 12478c2ecf20Sopenharmony_ci#endif 12488c2ecf20Sopenharmony_ci/******************************* Debug ***************************************/ 12498c2ecf20Sopenharmony_ci#ifdef AHC_DEBUG 12508c2ecf20Sopenharmony_ciextern uint32_t ahc_debug; 12518c2ecf20Sopenharmony_ci#define AHC_SHOW_MISC 0x0001 12528c2ecf20Sopenharmony_ci#define AHC_SHOW_SENSE 0x0002 12538c2ecf20Sopenharmony_ci#define AHC_DUMP_SEEPROM 0x0004 12548c2ecf20Sopenharmony_ci#define AHC_SHOW_TERMCTL 0x0008 12558c2ecf20Sopenharmony_ci#define AHC_SHOW_MEMORY 0x0010 12568c2ecf20Sopenharmony_ci#define AHC_SHOW_MESSAGES 0x0020 12578c2ecf20Sopenharmony_ci#define AHC_SHOW_DV 0x0040 12588c2ecf20Sopenharmony_ci#define AHC_SHOW_SELTO 0x0080 12598c2ecf20Sopenharmony_ci#define AHC_SHOW_QFULL 0x0200 12608c2ecf20Sopenharmony_ci#define AHC_SHOW_QUEUE 0x0400 12618c2ecf20Sopenharmony_ci#define AHC_SHOW_TQIN 0x0800 12628c2ecf20Sopenharmony_ci#define AHC_SHOW_MASKED_ERRORS 0x1000 12638c2ecf20Sopenharmony_ci#define AHC_DEBUG_SEQUENCER 0x2000 12648c2ecf20Sopenharmony_ci#endif 12658c2ecf20Sopenharmony_civoid ahc_print_devinfo(struct ahc_softc *ahc, 12668c2ecf20Sopenharmony_ci struct ahc_devinfo *dev); 12678c2ecf20Sopenharmony_civoid ahc_dump_card_state(struct ahc_softc *ahc); 12688c2ecf20Sopenharmony_ciint ahc_print_register(const ahc_reg_parse_entry_t *table, 12698c2ecf20Sopenharmony_ci u_int num_entries, 12708c2ecf20Sopenharmony_ci const char *name, 12718c2ecf20Sopenharmony_ci u_int address, 12728c2ecf20Sopenharmony_ci u_int value, 12738c2ecf20Sopenharmony_ci u_int *cur_column, 12748c2ecf20Sopenharmony_ci u_int wrap_point); 12758c2ecf20Sopenharmony_ci/******************************* SEEPROM *************************************/ 12768c2ecf20Sopenharmony_ciint ahc_acquire_seeprom(struct ahc_softc *ahc, 12778c2ecf20Sopenharmony_ci struct seeprom_descriptor *sd); 12788c2ecf20Sopenharmony_civoid ahc_release_seeprom(struct seeprom_descriptor *sd); 12798c2ecf20Sopenharmony_ci#endif /* _AIC7XXX_H_ */ 1280