18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Adaptec AIC7xxx device driver for Linux. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 1994 John Aycock 58c2ecf20Sopenharmony_ci * The University of Calgary Department of Computer Science. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 88c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by 98c2ecf20Sopenharmony_ci * the Free Software Foundation; either version 2, or (at your option) 108c2ecf20Sopenharmony_ci * any later version. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, 138c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 148c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 158c2ecf20Sopenharmony_ci * GNU General Public License for more details. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License 188c2ecf20Sopenharmony_ci * along with this program; see the file COPYING. If not, write to 198c2ecf20Sopenharmony_ci * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * Copyright (c) 2000-2003 Adaptec Inc. 228c2ecf20Sopenharmony_ci * All rights reserved. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 258c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 268c2ecf20Sopenharmony_ci * are met: 278c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 288c2ecf20Sopenharmony_ci * notice, this list of conditions, and the following disclaimer, 298c2ecf20Sopenharmony_ci * without modification. 308c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer 318c2ecf20Sopenharmony_ci * substantially similar to the "NO WARRANTY" disclaimer below 328c2ecf20Sopenharmony_ci * ("Disclaimer") and any redistribution must be conditioned upon 338c2ecf20Sopenharmony_ci * including a substantially similar Disclaimer requirement for further 348c2ecf20Sopenharmony_ci * binary redistribution. 358c2ecf20Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names 368c2ecf20Sopenharmony_ci * of any contributors may be used to endorse or promote products derived 378c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 388c2ecf20Sopenharmony_ci * 398c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 408c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 418c2ecf20Sopenharmony_ci * Software Foundation. 428c2ecf20Sopenharmony_ci * 438c2ecf20Sopenharmony_ci * NO WARRANTY 448c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 458c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 468c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 478c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 488c2ecf20Sopenharmony_ci * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 498c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 508c2ecf20Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 518c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 528c2ecf20Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 538c2ecf20Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 548c2ecf20Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGES. 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#151 $ 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_ci#ifndef _AIC7XXX_LINUX_H_ 608c2ecf20Sopenharmony_ci#define _AIC7XXX_LINUX_H_ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#include <linux/types.h> 638c2ecf20Sopenharmony_ci#include <linux/blkdev.h> 648c2ecf20Sopenharmony_ci#include <linux/delay.h> 658c2ecf20Sopenharmony_ci#include <linux/ioport.h> 668c2ecf20Sopenharmony_ci#include <linux/pci.h> 678c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 688c2ecf20Sopenharmony_ci#include <linux/module.h> 698c2ecf20Sopenharmony_ci#include <linux/slab.h> 708c2ecf20Sopenharmony_ci#include <asm/byteorder.h> 718c2ecf20Sopenharmony_ci#include <asm/io.h> 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#include <scsi/scsi.h> 748c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h> 758c2ecf20Sopenharmony_ci#include <scsi/scsi_eh.h> 768c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h> 778c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h> 788c2ecf20Sopenharmony_ci#include <scsi/scsi_tcq.h> 798c2ecf20Sopenharmony_ci#include <scsi/scsi_transport.h> 808c2ecf20Sopenharmony_ci#include <scsi/scsi_transport_spi.h> 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* Core SCSI definitions */ 838c2ecf20Sopenharmony_ci#define AIC_LIB_PREFIX ahc 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#include "cam.h" 868c2ecf20Sopenharmony_ci#include "queue.h" 878c2ecf20Sopenharmony_ci#include "scsi_message.h" 888c2ecf20Sopenharmony_ci#include "aiclib.h" 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/*********************************** Debugging ********************************/ 918c2ecf20Sopenharmony_ci#ifdef CONFIG_AIC7XXX_DEBUG_ENABLE 928c2ecf20Sopenharmony_ci#ifdef CONFIG_AIC7XXX_DEBUG_MASK 938c2ecf20Sopenharmony_ci#define AHC_DEBUG 1 948c2ecf20Sopenharmony_ci#define AHC_DEBUG_OPTS CONFIG_AIC7XXX_DEBUG_MASK 958c2ecf20Sopenharmony_ci#else 968c2ecf20Sopenharmony_ci/* 978c2ecf20Sopenharmony_ci * Compile in debugging code, but do not enable any printfs. 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_ci#define AHC_DEBUG 1 1008c2ecf20Sopenharmony_ci#endif 1018c2ecf20Sopenharmony_ci/* No debugging code. */ 1028c2ecf20Sopenharmony_ci#endif 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/************************* Forward Declarations *******************************/ 1058c2ecf20Sopenharmony_cistruct ahc_softc; 1068c2ecf20Sopenharmony_citypedef struct pci_dev *ahc_dev_softc_t; 1078c2ecf20Sopenharmony_citypedef struct scsi_cmnd *ahc_io_ctx_t; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/******************************* Byte Order ***********************************/ 1108c2ecf20Sopenharmony_ci#define ahc_htobe16(x) cpu_to_be16(x) 1118c2ecf20Sopenharmony_ci#define ahc_htobe32(x) cpu_to_be32(x) 1128c2ecf20Sopenharmony_ci#define ahc_htobe64(x) cpu_to_be64(x) 1138c2ecf20Sopenharmony_ci#define ahc_htole16(x) cpu_to_le16(x) 1148c2ecf20Sopenharmony_ci#define ahc_htole32(x) cpu_to_le32(x) 1158c2ecf20Sopenharmony_ci#define ahc_htole64(x) cpu_to_le64(x) 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci#define ahc_be16toh(x) be16_to_cpu(x) 1188c2ecf20Sopenharmony_ci#define ahc_be32toh(x) be32_to_cpu(x) 1198c2ecf20Sopenharmony_ci#define ahc_be64toh(x) be64_to_cpu(x) 1208c2ecf20Sopenharmony_ci#define ahc_le16toh(x) le16_to_cpu(x) 1218c2ecf20Sopenharmony_ci#define ahc_le32toh(x) le32_to_cpu(x) 1228c2ecf20Sopenharmony_ci#define ahc_le64toh(x) le64_to_cpu(x) 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci/************************* Configuration Data *********************************/ 1258c2ecf20Sopenharmony_ciextern u_int aic7xxx_no_probe; 1268c2ecf20Sopenharmony_ciextern u_int aic7xxx_allow_memio; 1278c2ecf20Sopenharmony_ciextern struct scsi_host_template aic7xxx_driver_template; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci/***************************** Bus Space/DMA **********************************/ 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_citypedef uint32_t bus_size_t; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_citypedef enum { 1348c2ecf20Sopenharmony_ci BUS_SPACE_MEMIO, 1358c2ecf20Sopenharmony_ci BUS_SPACE_PIO 1368c2ecf20Sopenharmony_ci} bus_space_tag_t; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_citypedef union { 1398c2ecf20Sopenharmony_ci u_long ioport; 1408c2ecf20Sopenharmony_ci volatile uint8_t __iomem *maddr; 1418c2ecf20Sopenharmony_ci} bus_space_handle_t; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_citypedef struct bus_dma_segment 1448c2ecf20Sopenharmony_ci{ 1458c2ecf20Sopenharmony_ci dma_addr_t ds_addr; 1468c2ecf20Sopenharmony_ci bus_size_t ds_len; 1478c2ecf20Sopenharmony_ci} bus_dma_segment_t; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistruct ahc_linux_dma_tag 1508c2ecf20Sopenharmony_ci{ 1518c2ecf20Sopenharmony_ci bus_size_t alignment; 1528c2ecf20Sopenharmony_ci bus_size_t boundary; 1538c2ecf20Sopenharmony_ci bus_size_t maxsize; 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_citypedef struct ahc_linux_dma_tag* bus_dma_tag_t; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_citypedef dma_addr_t bus_dmamap_t; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_citypedef int bus_dma_filter_t(void*, dma_addr_t); 1608c2ecf20Sopenharmony_citypedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#define BUS_DMA_WAITOK 0x0 1638c2ecf20Sopenharmony_ci#define BUS_DMA_NOWAIT 0x1 1648c2ecf20Sopenharmony_ci#define BUS_DMA_ALLOCNOW 0x2 1658c2ecf20Sopenharmony_ci#define BUS_DMA_LOAD_SEGS 0x4 /* 1668c2ecf20Sopenharmony_ci * Argument is an S/G list not 1678c2ecf20Sopenharmony_ci * a single buffer. 1688c2ecf20Sopenharmony_ci */ 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define BUS_SPACE_MAXADDR 0xFFFFFFFF 1718c2ecf20Sopenharmony_ci#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF 1728c2ecf20Sopenharmony_ci#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ciint ahc_dma_tag_create(struct ahc_softc *, bus_dma_tag_t /*parent*/, 1758c2ecf20Sopenharmony_ci bus_size_t /*alignment*/, bus_size_t /*boundary*/, 1768c2ecf20Sopenharmony_ci dma_addr_t /*lowaddr*/, dma_addr_t /*highaddr*/, 1778c2ecf20Sopenharmony_ci bus_dma_filter_t*/*filter*/, void */*filterarg*/, 1788c2ecf20Sopenharmony_ci bus_size_t /*maxsize*/, int /*nsegments*/, 1798c2ecf20Sopenharmony_ci bus_size_t /*maxsegsz*/, int /*flags*/, 1808c2ecf20Sopenharmony_ci bus_dma_tag_t */*dma_tagp*/); 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_civoid ahc_dma_tag_destroy(struct ahc_softc *, bus_dma_tag_t /*tag*/); 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ciint ahc_dmamem_alloc(struct ahc_softc *, bus_dma_tag_t /*dmat*/, 1858c2ecf20Sopenharmony_ci void** /*vaddr*/, int /*flags*/, 1868c2ecf20Sopenharmony_ci bus_dmamap_t* /*mapp*/); 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_civoid ahc_dmamem_free(struct ahc_softc *, bus_dma_tag_t /*dmat*/, 1898c2ecf20Sopenharmony_ci void* /*vaddr*/, bus_dmamap_t /*map*/); 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_civoid ahc_dmamap_destroy(struct ahc_softc *, bus_dma_tag_t /*tag*/, 1928c2ecf20Sopenharmony_ci bus_dmamap_t /*map*/); 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ciint ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t /*dmat*/, 1958c2ecf20Sopenharmony_ci bus_dmamap_t /*map*/, void * /*buf*/, 1968c2ecf20Sopenharmony_ci bus_size_t /*buflen*/, bus_dmamap_callback_t *, 1978c2ecf20Sopenharmony_ci void */*callback_arg*/, int /*flags*/); 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ciint ahc_dmamap_unload(struct ahc_softc *, bus_dma_tag_t, bus_dmamap_t); 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* 2028c2ecf20Sopenharmony_ci * Operations performed by ahc_dmamap_sync(). 2038c2ecf20Sopenharmony_ci */ 2048c2ecf20Sopenharmony_ci#define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */ 2058c2ecf20Sopenharmony_ci#define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */ 2068c2ecf20Sopenharmony_ci#define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */ 2078c2ecf20Sopenharmony_ci#define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */ 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci/* 2108c2ecf20Sopenharmony_ci * XXX 2118c2ecf20Sopenharmony_ci * ahc_dmamap_sync is only used on buffers allocated with 2128c2ecf20Sopenharmony_ci * the pci_alloc_consistent() API. Although I'm not sure how 2138c2ecf20Sopenharmony_ci * this works on architectures with a write buffer, Linux does 2148c2ecf20Sopenharmony_ci * not have an API to sync "coherent" memory. Perhaps we need 2158c2ecf20Sopenharmony_ci * to do an mb()? 2168c2ecf20Sopenharmony_ci */ 2178c2ecf20Sopenharmony_ci#define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op) 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci/********************************** Includes **********************************/ 2208c2ecf20Sopenharmony_ci#ifdef CONFIG_AIC7XXX_REG_PRETTY_PRINT 2218c2ecf20Sopenharmony_ci#define AIC_DEBUG_REGISTERS 1 2228c2ecf20Sopenharmony_ci#else 2238c2ecf20Sopenharmony_ci#define AIC_DEBUG_REGISTERS 0 2248c2ecf20Sopenharmony_ci#endif 2258c2ecf20Sopenharmony_ci#include "aic7xxx.h" 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci/***************************** Timer Facilities *******************************/ 2288c2ecf20Sopenharmony_cistatic inline void 2298c2ecf20Sopenharmony_ciahc_scb_timer_reset(struct scb *scb, u_int usec) 2308c2ecf20Sopenharmony_ci{ 2318c2ecf20Sopenharmony_ci} 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci/***************************** SMP support ************************************/ 2348c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci#define AIC7XXX_DRIVER_VERSION "7.0" 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci/*************************** Device Data Structures ***************************/ 2398c2ecf20Sopenharmony_ci/* 2408c2ecf20Sopenharmony_ci * A per probed device structure used to deal with some error recovery 2418c2ecf20Sopenharmony_ci * scenarios that the Linux mid-layer code just doesn't know how to 2428c2ecf20Sopenharmony_ci * handle. The structure allocated for a device only becomes persistent 2438c2ecf20Sopenharmony_ci * after a successfully completed inquiry command to the target when 2448c2ecf20Sopenharmony_ci * that inquiry data indicates a lun is present. 2458c2ecf20Sopenharmony_ci */ 2468c2ecf20Sopenharmony_citypedef enum { 2478c2ecf20Sopenharmony_ci AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */ 2488c2ecf20Sopenharmony_ci AHC_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */ 2498c2ecf20Sopenharmony_ci AHC_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */ 2508c2ecf20Sopenharmony_ci AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 2518c2ecf20Sopenharmony_ci} ahc_linux_dev_flags; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_cistruct ahc_linux_device { 2548c2ecf20Sopenharmony_ci /* 2558c2ecf20Sopenharmony_ci * The number of transactions currently 2568c2ecf20Sopenharmony_ci * queued to the device. 2578c2ecf20Sopenharmony_ci */ 2588c2ecf20Sopenharmony_ci int active; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci /* 2618c2ecf20Sopenharmony_ci * The currently allowed number of 2628c2ecf20Sopenharmony_ci * transactions that can be queued to 2638c2ecf20Sopenharmony_ci * the device. Must be signed for 2648c2ecf20Sopenharmony_ci * conversion from tagged to untagged 2658c2ecf20Sopenharmony_ci * mode where the device may have more 2668c2ecf20Sopenharmony_ci * than one outstanding active transaction. 2678c2ecf20Sopenharmony_ci */ 2688c2ecf20Sopenharmony_ci int openings; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci /* 2718c2ecf20Sopenharmony_ci * A positive count indicates that this 2728c2ecf20Sopenharmony_ci * device's queue is halted. 2738c2ecf20Sopenharmony_ci */ 2748c2ecf20Sopenharmony_ci u_int qfrozen; 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci /* 2778c2ecf20Sopenharmony_ci * Cumulative command counter. 2788c2ecf20Sopenharmony_ci */ 2798c2ecf20Sopenharmony_ci u_long commands_issued; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci /* 2828c2ecf20Sopenharmony_ci * The number of tagged transactions when 2838c2ecf20Sopenharmony_ci * running at our current opening level 2848c2ecf20Sopenharmony_ci * that have been successfully received by 2858c2ecf20Sopenharmony_ci * this device since the last QUEUE FULL. 2868c2ecf20Sopenharmony_ci */ 2878c2ecf20Sopenharmony_ci u_int tag_success_count; 2888c2ecf20Sopenharmony_ci#define AHC_TAG_SUCCESS_INTERVAL 50 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci ahc_linux_dev_flags flags; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci /* 2938c2ecf20Sopenharmony_ci * The high limit for the tags variable. 2948c2ecf20Sopenharmony_ci */ 2958c2ecf20Sopenharmony_ci u_int maxtags; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci /* 2988c2ecf20Sopenharmony_ci * The computed number of tags outstanding 2998c2ecf20Sopenharmony_ci * at the time of the last QUEUE FULL event. 3008c2ecf20Sopenharmony_ci */ 3018c2ecf20Sopenharmony_ci u_int tags_on_last_queuefull; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci /* 3048c2ecf20Sopenharmony_ci * How many times we have seen a queue full 3058c2ecf20Sopenharmony_ci * with the same number of tags. This is used 3068c2ecf20Sopenharmony_ci * to stop our adaptive queue depth algorithm 3078c2ecf20Sopenharmony_ci * on devices with a fixed number of tags. 3088c2ecf20Sopenharmony_ci */ 3098c2ecf20Sopenharmony_ci u_int last_queuefull_same_count; 3108c2ecf20Sopenharmony_ci#define AHC_LOCK_TAGS_COUNT 50 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci /* 3138c2ecf20Sopenharmony_ci * How many transactions have been queued 3148c2ecf20Sopenharmony_ci * without the device going idle. We use 3158c2ecf20Sopenharmony_ci * this statistic to determine when to issue 3168c2ecf20Sopenharmony_ci * an ordered tag to prevent transaction 3178c2ecf20Sopenharmony_ci * starvation. This statistic is only updated 3188c2ecf20Sopenharmony_ci * if the AHC_DEV_PERIODIC_OTAG flag is set 3198c2ecf20Sopenharmony_ci * on this device. 3208c2ecf20Sopenharmony_ci */ 3218c2ecf20Sopenharmony_ci u_int commands_since_idle_or_otag; 3228c2ecf20Sopenharmony_ci#define AHC_OTAG_THRESH 500 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci/********************* Definitions Required by the Core ***********************/ 3268c2ecf20Sopenharmony_ci/* 3278c2ecf20Sopenharmony_ci * Number of SG segments we require. So long as the S/G segments for 3288c2ecf20Sopenharmony_ci * a particular transaction are allocated in a physically contiguous 3298c2ecf20Sopenharmony_ci * manner and are allocated below 4GB, the number of S/G segments is 3308c2ecf20Sopenharmony_ci * unrestricted. 3318c2ecf20Sopenharmony_ci */ 3328c2ecf20Sopenharmony_ci#define AHC_NSEG 128 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci/* 3358c2ecf20Sopenharmony_ci * Per-SCB OSM storage. 3368c2ecf20Sopenharmony_ci */ 3378c2ecf20Sopenharmony_cistruct scb_platform_data { 3388c2ecf20Sopenharmony_ci struct ahc_linux_device *dev; 3398c2ecf20Sopenharmony_ci dma_addr_t buf_busaddr; 3408c2ecf20Sopenharmony_ci uint32_t xfer_len; 3418c2ecf20Sopenharmony_ci uint32_t sense_resid; /* Auto-Sense residual */ 3428c2ecf20Sopenharmony_ci}; 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci/* 3458c2ecf20Sopenharmony_ci * Define a structure used for each host adapter. All members are 3468c2ecf20Sopenharmony_ci * aligned on a boundary >= the size of the member to honor the 3478c2ecf20Sopenharmony_ci * alignment restrictions of the various platforms supported by 3488c2ecf20Sopenharmony_ci * this driver. 3498c2ecf20Sopenharmony_ci */ 3508c2ecf20Sopenharmony_cistruct ahc_platform_data { 3518c2ecf20Sopenharmony_ci /* 3528c2ecf20Sopenharmony_ci * Fields accessed from interrupt context. 3538c2ecf20Sopenharmony_ci */ 3548c2ecf20Sopenharmony_ci struct scsi_target *starget[AHC_NUM_TARGETS]; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci spinlock_t spin_lock; 3578c2ecf20Sopenharmony_ci u_int qfrozen; 3588c2ecf20Sopenharmony_ci struct completion *eh_done; 3598c2ecf20Sopenharmony_ci struct Scsi_Host *host; /* pointer to scsi host */ 3608c2ecf20Sopenharmony_ci#define AHC_LINUX_NOIRQ ((uint32_t)~0) 3618c2ecf20Sopenharmony_ci uint32_t irq; /* IRQ for this adapter */ 3628c2ecf20Sopenharmony_ci uint32_t bios_address; 3638c2ecf20Sopenharmony_ci resource_size_t mem_busaddr; /* Mem Base Addr */ 3648c2ecf20Sopenharmony_ci}; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_civoid ahc_delay(long); 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci/***************************** Low Level I/O **********************************/ 3708c2ecf20Sopenharmony_ciuint8_t ahc_inb(struct ahc_softc * ahc, long port); 3718c2ecf20Sopenharmony_civoid ahc_outb(struct ahc_softc * ahc, long port, uint8_t val); 3728c2ecf20Sopenharmony_civoid ahc_outsb(struct ahc_softc * ahc, long port, 3738c2ecf20Sopenharmony_ci uint8_t *, int count); 3748c2ecf20Sopenharmony_civoid ahc_insb(struct ahc_softc * ahc, long port, 3758c2ecf20Sopenharmony_ci uint8_t *, int count); 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci/**************************** Initialization **********************************/ 3788c2ecf20Sopenharmony_ciint ahc_linux_register_host(struct ahc_softc *, 3798c2ecf20Sopenharmony_ci struct scsi_host_template *); 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci/******************************** Locking *************************************/ 3828c2ecf20Sopenharmony_ci/* Lock protecting internal data structures */ 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_cistatic inline void 3858c2ecf20Sopenharmony_ciahc_lockinit(struct ahc_softc *ahc) 3868c2ecf20Sopenharmony_ci{ 3878c2ecf20Sopenharmony_ci spin_lock_init(&ahc->platform_data->spin_lock); 3888c2ecf20Sopenharmony_ci} 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cistatic inline void 3918c2ecf20Sopenharmony_ciahc_lock(struct ahc_softc *ahc, unsigned long *flags) 3928c2ecf20Sopenharmony_ci{ 3938c2ecf20Sopenharmony_ci spin_lock_irqsave(&ahc->platform_data->spin_lock, *flags); 3948c2ecf20Sopenharmony_ci} 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_cistatic inline void 3978c2ecf20Sopenharmony_ciahc_unlock(struct ahc_softc *ahc, unsigned long *flags) 3988c2ecf20Sopenharmony_ci{ 3998c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&ahc->platform_data->spin_lock, *flags); 4008c2ecf20Sopenharmony_ci} 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci/******************************* PCI Definitions ******************************/ 4038c2ecf20Sopenharmony_ci/* 4048c2ecf20Sopenharmony_ci * PCIM_xxx: mask to locate subfield in register 4058c2ecf20Sopenharmony_ci * PCIR_xxx: config register offset 4068c2ecf20Sopenharmony_ci * PCIC_xxx: device class 4078c2ecf20Sopenharmony_ci * PCIS_xxx: device subclass 4088c2ecf20Sopenharmony_ci * PCIP_xxx: device programming interface 4098c2ecf20Sopenharmony_ci * PCIV_xxx: PCI vendor ID (only required to fixup ancient devices) 4108c2ecf20Sopenharmony_ci * PCID_xxx: device ID 4118c2ecf20Sopenharmony_ci */ 4128c2ecf20Sopenharmony_ci#define PCIR_DEVVENDOR 0x00 4138c2ecf20Sopenharmony_ci#define PCIR_VENDOR 0x00 4148c2ecf20Sopenharmony_ci#define PCIR_DEVICE 0x02 4158c2ecf20Sopenharmony_ci#define PCIR_COMMAND 0x04 4168c2ecf20Sopenharmony_ci#define PCIM_CMD_PORTEN 0x0001 4178c2ecf20Sopenharmony_ci#define PCIM_CMD_MEMEN 0x0002 4188c2ecf20Sopenharmony_ci#define PCIM_CMD_BUSMASTEREN 0x0004 4198c2ecf20Sopenharmony_ci#define PCIM_CMD_MWRICEN 0x0010 4208c2ecf20Sopenharmony_ci#define PCIM_CMD_PERRESPEN 0x0040 4218c2ecf20Sopenharmony_ci#define PCIM_CMD_SERRESPEN 0x0100 4228c2ecf20Sopenharmony_ci#define PCIR_STATUS 0x06 4238c2ecf20Sopenharmony_ci#define PCIR_REVID 0x08 4248c2ecf20Sopenharmony_ci#define PCIR_PROGIF 0x09 4258c2ecf20Sopenharmony_ci#define PCIR_SUBCLASS 0x0a 4268c2ecf20Sopenharmony_ci#define PCIR_CLASS 0x0b 4278c2ecf20Sopenharmony_ci#define PCIR_CACHELNSZ 0x0c 4288c2ecf20Sopenharmony_ci#define PCIR_LATTIMER 0x0d 4298c2ecf20Sopenharmony_ci#define PCIR_HEADERTYPE 0x0e 4308c2ecf20Sopenharmony_ci#define PCIM_MFDEV 0x80 4318c2ecf20Sopenharmony_ci#define PCIR_BIST 0x0f 4328c2ecf20Sopenharmony_ci#define PCIR_CAP_PTR 0x34 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci/* config registers for header type 0 devices */ 4358c2ecf20Sopenharmony_ci#define PCIR_MAPS 0x10 4368c2ecf20Sopenharmony_ci#define PCIR_SUBVEND_0 0x2c 4378c2ecf20Sopenharmony_ci#define PCIR_SUBDEV_0 0x2e 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_citypedef enum 4408c2ecf20Sopenharmony_ci{ 4418c2ecf20Sopenharmony_ci AHC_POWER_STATE_D0, 4428c2ecf20Sopenharmony_ci AHC_POWER_STATE_D1, 4438c2ecf20Sopenharmony_ci AHC_POWER_STATE_D2, 4448c2ecf20Sopenharmony_ci AHC_POWER_STATE_D3 4458c2ecf20Sopenharmony_ci} ahc_power_state; 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci/**************************** VL/EISA Routines ********************************/ 4488c2ecf20Sopenharmony_ci#ifdef CONFIG_EISA 4498c2ecf20Sopenharmony_ciint ahc_linux_eisa_init(void); 4508c2ecf20Sopenharmony_civoid ahc_linux_eisa_exit(void); 4518c2ecf20Sopenharmony_ciint aic7770_map_registers(struct ahc_softc *ahc, 4528c2ecf20Sopenharmony_ci u_int port); 4538c2ecf20Sopenharmony_ciint aic7770_map_int(struct ahc_softc *ahc, u_int irq); 4548c2ecf20Sopenharmony_ci#else 4558c2ecf20Sopenharmony_cistatic inline int ahc_linux_eisa_init(void) { 4568c2ecf20Sopenharmony_ci return -ENODEV; 4578c2ecf20Sopenharmony_ci} 4588c2ecf20Sopenharmony_cistatic inline void ahc_linux_eisa_exit(void) { 4598c2ecf20Sopenharmony_ci} 4608c2ecf20Sopenharmony_ci#endif 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci/******************************* PCI Routines *********************************/ 4638c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI 4648c2ecf20Sopenharmony_ciint ahc_linux_pci_init(void); 4658c2ecf20Sopenharmony_civoid ahc_linux_pci_exit(void); 4668c2ecf20Sopenharmony_ciint ahc_pci_map_registers(struct ahc_softc *ahc); 4678c2ecf20Sopenharmony_ciint ahc_pci_map_int(struct ahc_softc *ahc); 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ciuint32_t ahc_pci_read_config(ahc_dev_softc_t pci, 4708c2ecf20Sopenharmony_ci int reg, int width); 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_civoid ahc_pci_write_config(ahc_dev_softc_t pci, 4738c2ecf20Sopenharmony_ci int reg, uint32_t value, 4748c2ecf20Sopenharmony_ci int width); 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_cistatic inline int ahc_get_pci_function(ahc_dev_softc_t); 4778c2ecf20Sopenharmony_cistatic inline int 4788c2ecf20Sopenharmony_ciahc_get_pci_function(ahc_dev_softc_t pci) 4798c2ecf20Sopenharmony_ci{ 4808c2ecf20Sopenharmony_ci return (PCI_FUNC(pci->devfn)); 4818c2ecf20Sopenharmony_ci} 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_cistatic inline int ahc_get_pci_slot(ahc_dev_softc_t); 4848c2ecf20Sopenharmony_cistatic inline int 4858c2ecf20Sopenharmony_ciahc_get_pci_slot(ahc_dev_softc_t pci) 4868c2ecf20Sopenharmony_ci{ 4878c2ecf20Sopenharmony_ci return (PCI_SLOT(pci->devfn)); 4888c2ecf20Sopenharmony_ci} 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_cistatic inline int ahc_get_pci_bus(ahc_dev_softc_t); 4918c2ecf20Sopenharmony_cistatic inline int 4928c2ecf20Sopenharmony_ciahc_get_pci_bus(ahc_dev_softc_t pci) 4938c2ecf20Sopenharmony_ci{ 4948c2ecf20Sopenharmony_ci return (pci->bus->number); 4958c2ecf20Sopenharmony_ci} 4968c2ecf20Sopenharmony_ci#else 4978c2ecf20Sopenharmony_cistatic inline int ahc_linux_pci_init(void) { 4988c2ecf20Sopenharmony_ci return 0; 4998c2ecf20Sopenharmony_ci} 5008c2ecf20Sopenharmony_cistatic inline void ahc_linux_pci_exit(void) { 5018c2ecf20Sopenharmony_ci} 5028c2ecf20Sopenharmony_ci#endif 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_cistatic inline void ahc_flush_device_writes(struct ahc_softc *); 5058c2ecf20Sopenharmony_cistatic inline void 5068c2ecf20Sopenharmony_ciahc_flush_device_writes(struct ahc_softc *ahc) 5078c2ecf20Sopenharmony_ci{ 5088c2ecf20Sopenharmony_ci /* XXX Is this sufficient for all architectures??? */ 5098c2ecf20Sopenharmony_ci ahc_inb(ahc, INTSTAT); 5108c2ecf20Sopenharmony_ci} 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci/**************************** Proc FS Support *********************************/ 5138c2ecf20Sopenharmony_ciint ahc_proc_write_seeprom(struct Scsi_Host *, char *, int); 5148c2ecf20Sopenharmony_ciint ahc_linux_show_info(struct seq_file *, struct Scsi_Host *); 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci/*************************** Domain Validation ********************************/ 5178c2ecf20Sopenharmony_ci/*********************** Transaction Access Wrappers *************************/ 5188c2ecf20Sopenharmony_cistatic inline void ahc_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t); 5198c2ecf20Sopenharmony_cistatic inline void ahc_set_transaction_status(struct scb *, uint32_t); 5208c2ecf20Sopenharmony_cistatic inline void ahc_cmd_set_scsi_status(struct scsi_cmnd *, uint32_t); 5218c2ecf20Sopenharmony_cistatic inline void ahc_set_scsi_status(struct scb *, uint32_t); 5228c2ecf20Sopenharmony_cistatic inline uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd); 5238c2ecf20Sopenharmony_cistatic inline uint32_t ahc_get_transaction_status(struct scb *); 5248c2ecf20Sopenharmony_cistatic inline uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd); 5258c2ecf20Sopenharmony_cistatic inline uint32_t ahc_get_scsi_status(struct scb *); 5268c2ecf20Sopenharmony_cistatic inline void ahc_set_transaction_tag(struct scb *, int, u_int); 5278c2ecf20Sopenharmony_cistatic inline u_long ahc_get_transfer_length(struct scb *); 5288c2ecf20Sopenharmony_cistatic inline int ahc_get_transfer_dir(struct scb *); 5298c2ecf20Sopenharmony_cistatic inline void ahc_set_residual(struct scb *, u_long); 5308c2ecf20Sopenharmony_cistatic inline void ahc_set_sense_residual(struct scb *scb, u_long resid); 5318c2ecf20Sopenharmony_cistatic inline u_long ahc_get_residual(struct scb *); 5328c2ecf20Sopenharmony_cistatic inline u_long ahc_get_sense_residual(struct scb *); 5338c2ecf20Sopenharmony_cistatic inline int ahc_perform_autosense(struct scb *); 5348c2ecf20Sopenharmony_cistatic inline uint32_t ahc_get_sense_bufsize(struct ahc_softc *, 5358c2ecf20Sopenharmony_ci struct scb *); 5368c2ecf20Sopenharmony_cistatic inline void ahc_notify_xfer_settings_change(struct ahc_softc *, 5378c2ecf20Sopenharmony_ci struct ahc_devinfo *); 5388c2ecf20Sopenharmony_cistatic inline void ahc_platform_scb_free(struct ahc_softc *ahc, 5398c2ecf20Sopenharmony_ci struct scb *scb); 5408c2ecf20Sopenharmony_cistatic inline void ahc_freeze_scb(struct scb *scb); 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_cistatic inline 5438c2ecf20Sopenharmony_civoid ahc_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status) 5448c2ecf20Sopenharmony_ci{ 5458c2ecf20Sopenharmony_ci cmd->result &= ~(CAM_STATUS_MASK << 16); 5468c2ecf20Sopenharmony_ci cmd->result |= status << 16; 5478c2ecf20Sopenharmony_ci} 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_cistatic inline 5508c2ecf20Sopenharmony_civoid ahc_set_transaction_status(struct scb *scb, uint32_t status) 5518c2ecf20Sopenharmony_ci{ 5528c2ecf20Sopenharmony_ci ahc_cmd_set_transaction_status(scb->io_ctx,status); 5538c2ecf20Sopenharmony_ci} 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_cistatic inline 5568c2ecf20Sopenharmony_civoid ahc_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status) 5578c2ecf20Sopenharmony_ci{ 5588c2ecf20Sopenharmony_ci cmd->result &= ~0xFFFF; 5598c2ecf20Sopenharmony_ci cmd->result |= status; 5608c2ecf20Sopenharmony_ci} 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_cistatic inline 5638c2ecf20Sopenharmony_civoid ahc_set_scsi_status(struct scb *scb, uint32_t status) 5648c2ecf20Sopenharmony_ci{ 5658c2ecf20Sopenharmony_ci ahc_cmd_set_scsi_status(scb->io_ctx, status); 5668c2ecf20Sopenharmony_ci} 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_cistatic inline 5698c2ecf20Sopenharmony_ciuint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd) 5708c2ecf20Sopenharmony_ci{ 5718c2ecf20Sopenharmony_ci return ((cmd->result >> 16) & CAM_STATUS_MASK); 5728c2ecf20Sopenharmony_ci} 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_cistatic inline 5758c2ecf20Sopenharmony_ciuint32_t ahc_get_transaction_status(struct scb *scb) 5768c2ecf20Sopenharmony_ci{ 5778c2ecf20Sopenharmony_ci return (ahc_cmd_get_transaction_status(scb->io_ctx)); 5788c2ecf20Sopenharmony_ci} 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_cistatic inline 5818c2ecf20Sopenharmony_ciuint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd) 5828c2ecf20Sopenharmony_ci{ 5838c2ecf20Sopenharmony_ci return (cmd->result & 0xFFFF); 5848c2ecf20Sopenharmony_ci} 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_cistatic inline 5878c2ecf20Sopenharmony_ciuint32_t ahc_get_scsi_status(struct scb *scb) 5888c2ecf20Sopenharmony_ci{ 5898c2ecf20Sopenharmony_ci return (ahc_cmd_get_scsi_status(scb->io_ctx)); 5908c2ecf20Sopenharmony_ci} 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_cistatic inline 5938c2ecf20Sopenharmony_civoid ahc_set_transaction_tag(struct scb *scb, int enabled, u_int type) 5948c2ecf20Sopenharmony_ci{ 5958c2ecf20Sopenharmony_ci /* 5968c2ecf20Sopenharmony_ci * Nothing to do for linux as the incoming transaction 5978c2ecf20Sopenharmony_ci * has no concept of tag/non tagged, etc. 5988c2ecf20Sopenharmony_ci */ 5998c2ecf20Sopenharmony_ci} 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_cistatic inline 6028c2ecf20Sopenharmony_ciu_long ahc_get_transfer_length(struct scb *scb) 6038c2ecf20Sopenharmony_ci{ 6048c2ecf20Sopenharmony_ci return (scb->platform_data->xfer_len); 6058c2ecf20Sopenharmony_ci} 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_cistatic inline 6088c2ecf20Sopenharmony_ciint ahc_get_transfer_dir(struct scb *scb) 6098c2ecf20Sopenharmony_ci{ 6108c2ecf20Sopenharmony_ci return (scb->io_ctx->sc_data_direction); 6118c2ecf20Sopenharmony_ci} 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_cistatic inline 6148c2ecf20Sopenharmony_civoid ahc_set_residual(struct scb *scb, u_long resid) 6158c2ecf20Sopenharmony_ci{ 6168c2ecf20Sopenharmony_ci scsi_set_resid(scb->io_ctx, resid); 6178c2ecf20Sopenharmony_ci} 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_cistatic inline 6208c2ecf20Sopenharmony_civoid ahc_set_sense_residual(struct scb *scb, u_long resid) 6218c2ecf20Sopenharmony_ci{ 6228c2ecf20Sopenharmony_ci scb->platform_data->sense_resid = resid; 6238c2ecf20Sopenharmony_ci} 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_cistatic inline 6268c2ecf20Sopenharmony_ciu_long ahc_get_residual(struct scb *scb) 6278c2ecf20Sopenharmony_ci{ 6288c2ecf20Sopenharmony_ci return scsi_get_resid(scb->io_ctx); 6298c2ecf20Sopenharmony_ci} 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_cistatic inline 6328c2ecf20Sopenharmony_ciu_long ahc_get_sense_residual(struct scb *scb) 6338c2ecf20Sopenharmony_ci{ 6348c2ecf20Sopenharmony_ci return (scb->platform_data->sense_resid); 6358c2ecf20Sopenharmony_ci} 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_cistatic inline 6388c2ecf20Sopenharmony_ciint ahc_perform_autosense(struct scb *scb) 6398c2ecf20Sopenharmony_ci{ 6408c2ecf20Sopenharmony_ci /* 6418c2ecf20Sopenharmony_ci * We always perform autosense in Linux. 6428c2ecf20Sopenharmony_ci * On other platforms this is set on a 6438c2ecf20Sopenharmony_ci * per-transaction basis. 6448c2ecf20Sopenharmony_ci */ 6458c2ecf20Sopenharmony_ci return (1); 6468c2ecf20Sopenharmony_ci} 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_cistatic inline uint32_t 6498c2ecf20Sopenharmony_ciahc_get_sense_bufsize(struct ahc_softc *ahc, struct scb *scb) 6508c2ecf20Sopenharmony_ci{ 6518c2ecf20Sopenharmony_ci return (sizeof(struct scsi_sense_data)); 6528c2ecf20Sopenharmony_ci} 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_cistatic inline void 6558c2ecf20Sopenharmony_ciahc_notify_xfer_settings_change(struct ahc_softc *ahc, 6568c2ecf20Sopenharmony_ci struct ahc_devinfo *devinfo) 6578c2ecf20Sopenharmony_ci{ 6588c2ecf20Sopenharmony_ci /* Nothing to do here for linux */ 6598c2ecf20Sopenharmony_ci} 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_cistatic inline void 6628c2ecf20Sopenharmony_ciahc_platform_scb_free(struct ahc_softc *ahc, struct scb *scb) 6638c2ecf20Sopenharmony_ci{ 6648c2ecf20Sopenharmony_ci} 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_ciint ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg); 6678c2ecf20Sopenharmony_civoid ahc_platform_free(struct ahc_softc *ahc); 6688c2ecf20Sopenharmony_civoid ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb); 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_cistatic inline void 6718c2ecf20Sopenharmony_ciahc_freeze_scb(struct scb *scb) 6728c2ecf20Sopenharmony_ci{ 6738c2ecf20Sopenharmony_ci if ((scb->io_ctx->result & (CAM_DEV_QFRZN << 16)) == 0) { 6748c2ecf20Sopenharmony_ci scb->io_ctx->result |= CAM_DEV_QFRZN << 16; 6758c2ecf20Sopenharmony_ci scb->platform_data->dev->qfrozen++; 6768c2ecf20Sopenharmony_ci } 6778c2ecf20Sopenharmony_ci} 6788c2ecf20Sopenharmony_ci 6798c2ecf20Sopenharmony_civoid ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev, 6808c2ecf20Sopenharmony_ci struct ahc_devinfo *devinfo, ahc_queue_alg); 6818c2ecf20Sopenharmony_ciint ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, 6828c2ecf20Sopenharmony_ci char channel, int lun, u_int tag, 6838c2ecf20Sopenharmony_ci role_t role, uint32_t status); 6848c2ecf20Sopenharmony_ciirqreturn_t 6858c2ecf20Sopenharmony_ci ahc_linux_isr(int irq, void *dev_id); 6868c2ecf20Sopenharmony_civoid ahc_platform_flushwork(struct ahc_softc *ahc); 6878c2ecf20Sopenharmony_civoid ahc_done(struct ahc_softc*, struct scb*); 6888c2ecf20Sopenharmony_civoid ahc_send_async(struct ahc_softc *, char channel, 6898c2ecf20Sopenharmony_ci u_int target, u_int lun, ac_code); 6908c2ecf20Sopenharmony_civoid ahc_print_path(struct ahc_softc *, struct scb *); 6918c2ecf20Sopenharmony_ci 6928c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI 6938c2ecf20Sopenharmony_ci#define AHC_PCI_CONFIG 1 6948c2ecf20Sopenharmony_ci#else 6958c2ecf20Sopenharmony_ci#define AHC_PCI_CONFIG 0 6968c2ecf20Sopenharmony_ci#endif 6978c2ecf20Sopenharmony_ci#define bootverbose aic7xxx_verbose 6988c2ecf20Sopenharmony_ciextern u_int aic7xxx_verbose; 6998c2ecf20Sopenharmony_ci#endif /* _AIC7XXX_LINUX_H_ */ 700