1139749Simp/*-
253790Sobrien *  Device driver optimized for the Symbios/LSI 53C896/53C895A/53C1010
353790Sobrien *  PCI-SCSI controllers.
453790Sobrien *
586266Sgroudier *  Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
653790Sobrien *
753790Sobrien *  This driver also supports the following Symbios/LSI PCI-SCSI chips:
859743Sgroudier *	53C810A, 53C825A, 53C860, 53C875, 53C876, 53C885, 53C895,
959743Sgroudier *	53C810,  53C815,  53C825 and the 53C1510D is 53C8XX mode.
1053790Sobrien *
1153790Sobrien *
1253790Sobrien *  This driver for FreeBSD-CAM is derived from the Linux sym53c8xx driver.
1353790Sobrien *  Copyright (C) 1998-1999  Gerard Roudier
1453790Sobrien *
1553790Sobrien *  The sym53c8xx driver is derived from the ncr53c8xx driver that had been
1653790Sobrien *  a port of the FreeBSD ncr driver to Linux-1.2.13.
1753790Sobrien *
1853790Sobrien *  The original ncr driver has been written for 386bsd and FreeBSD by
1953790Sobrien *          Wolfgang Stanglmeier        <wolf@cologne.de>
2053790Sobrien *          Stefan Esser                <se@mi.Uni-Koeln.de>
2153790Sobrien *  Copyright (C) 1994  Wolfgang Stanglmeier
2253790Sobrien *
2353790Sobrien *  The initialisation code, and part of the code that addresses
2453790Sobrien *  FreeBSD-CAM services is based on the aic7xxx driver for FreeBSD-CAM
2553790Sobrien *  written by Justin T. Gibbs.
2653790Sobrien *
2753790Sobrien *  Other major contributions:
2853790Sobrien *
2953790Sobrien *  NVRAM detection and reading.
3053790Sobrien *  Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
3153790Sobrien *
3253790Sobrien *-----------------------------------------------------------------------------
3353790Sobrien *
3453790Sobrien * Redistribution and use in source and binary forms, with or without
3553790Sobrien * modification, are permitted provided that the following conditions
3653790Sobrien * are met:
3753790Sobrien * 1. Redistributions of source code must retain the above copyright
3853790Sobrien *    notice, this list of conditions and the following disclaimer.
3953790Sobrien * 2. Redistributions in binary form must reproduce the above copyright
4053790Sobrien *    notice, this list of conditions and the following disclaimer in the
4153790Sobrien *    documentation and/or other materials provided with the distribution.
4253790Sobrien * 3. The name of the author may not be used to endorse or promote products
4353790Sobrien *    derived from this software without specific prior written permission.
4453790Sobrien *
4553790Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
4653790Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4753790Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4853790Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
4953790Sobrien * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5053790Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5153790Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5253790Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5353790Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5453790Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5553790Sobrien * SUCH DAMAGE.
5653790Sobrien */
5755258Sobrien
5855258Sobrien/* $FreeBSD$ */
5955258Sobrien
6053790Sobrien#ifndef SYM_CONF_H
6153790Sobrien#define SYM_CONF_H
6253790Sobrien
6353790Sobrien/*-------------------------------------------------------------------
6453790Sobrien *  Static configuration.
6553790Sobrien *-------------------------------------------------------------------
6653790Sobrien */
6753790Sobrien
6853790Sobrien/*
6959743Sgroudier *  Also support early NCR 810, 815 and 825 chips.
7059743Sgroudier */
7159743Sgroudier#define SYM_CONF_GENERIC_SUPPORT
7259743Sgroudier
7359743Sgroudier/*
7453790Sobrien *  Use Normal IO instead of MMIO.
7553790Sobrien */
7654690Sobrien/* #define SYM_CONF_IOMAPPED */
7753790Sobrien
7853790Sobrien/*
7953790Sobrien *  Max tags for a device (logical unit)
8053790Sobrien * 	We use a power of 2, (7) means 2<<7=128
8153790Sobrien *  Maximum is 8 -> 256 tags
8253790Sobrien */
8354690Sobrien#define SYM_CONF_MAX_TAG_ORDER	(6)
8453790Sobrien
8553790Sobrien/*
86236061Smarius *  DMA boundary
87236061Smarius *  We need to ensure 16 MB boundaries not to be crossed during DMA of
88236061Smarius *  each segment, due to some chips being flawed.
89236061Smarius */
90236061Smarius#define SYM_CONF_DMA_BOUNDARY	(1UL << 24)
91236061Smarius
92236061Smarius/*
93237101Smarius *  Max number of scatter/gather entries for an I/O.
9453790Sobrien *  Each entry costs 8 bytes in the internal CCB data structure.
95237101Smarius *  We use at most 33 segments but also no more than required for handling
96237101Smarius *  MAXPHYS.
9753790Sobrien */
98237101Smarius#define	SYM_CONF_MAX_SG		(MIN(33, (MAXPHYS / PAGE_SIZE) + 1))
9953790Sobrien
10053790Sobrien/*
10153790Sobrien *  Max number of targets.
10253790Sobrien *  Maximum is 16 and you are advised not to change this value.
10353790Sobrien */
10454690Sobrien#define SYM_CONF_MAX_TARGET	(16)
10553790Sobrien
10653790Sobrien/*
10753790Sobrien *  Max number of logical units.
10853790Sobrien *  SPI-2 allows up to 64 logical units, but in real life, target
10953790Sobrien *  that implements more that 7 logical units are pretty rare.
11053790Sobrien *  Anyway, the cost of accepting up to 64 logical unit is low in
11153790Sobrien *  this driver, thus going with the maximum is acceptable.
11253790Sobrien */
11354690Sobrien#define SYM_CONF_MAX_LUN		(64)
11453790Sobrien
11553790Sobrien/*
11653790Sobrien *  Max number of IO control blocks queued to the controller.
11753790Sobrien *  Each entry needs 8 bytes and the queues are allocated contiguously.
11853790Sobrien *  Since we donnot want to allocate more than a page, the theorical
11953790Sobrien *  maximum is PAGE_SIZE/8. For safety, we announce a bit less to the
12053790Sobrien *  access method. :)
12153790Sobrien *  When not supplied, as it is suggested, the driver compute some
12253790Sobrien *  good value for this parameter.
12353790Sobrien */
12454690Sobrien/* #define SYM_CONF_MAX_START	(PAGE_SIZE/8 - 16) */
12553790Sobrien
12653790Sobrien/*
12753790Sobrien *  Support for NVRAM.
12853790Sobrien */
12954690Sobrien#define SYM_CONF_NVRAM_SUPPORT
13059743Sgroudier/* #define SYM_CONF_NVRAM_SUPPORT */
13153790Sobrien
13253790Sobrien/*
13353790Sobrien *  Support for Immediate Arbitration.
13453790Sobrien *  Not advised.
13553790Sobrien */
13654690Sobrien/* #define SYM_CONF_IARB_SUPPORT */
13753790Sobrien
13853790Sobrien/*-------------------------------------------------------------------
13953790Sobrien *  Configuration that could be dynamic if it was possible
14053790Sobrien *  to pass arguments to the driver.
14153790Sobrien *-------------------------------------------------------------------
14253790Sobrien */
14353790Sobrien
14453790Sobrien/*
14553790Sobrien *  HOST default scsi id.
14653790Sobrien */
14754690Sobrien#define SYM_SETUP_HOST_ID	7
14853790Sobrien
14953790Sobrien/*
15053790Sobrien *  Max synchronous transfers.
15153790Sobrien */
15254690Sobrien#define SYM_SETUP_MIN_SYNC	(9)
15353790Sobrien
15453790Sobrien/*
15553790Sobrien *  Max wide order.
15653790Sobrien */
15754690Sobrien#define SYM_SETUP_MAX_WIDE	(1)
15853790Sobrien
15953790Sobrien/*
16053790Sobrien *  Max SCSI offset.
16153790Sobrien */
16255628Sgroudier#define SYM_SETUP_MAX_OFFS	(63)
16354690Sobrien
16453790Sobrien/*
16553790Sobrien *  Default number of tags.
16653790Sobrien */
16754690Sobrien#define SYM_SETUP_MAX_TAG	(1<<SYM_CONF_MAX_TAG_ORDER)
16853790Sobrien
16953790Sobrien/*
17053790Sobrien *  SYMBIOS NVRAM format support.
17153790Sobrien */
17254690Sobrien#define SYM_SETUP_SYMBIOS_NVRAM	(1)
17353790Sobrien
17453790Sobrien/*
17553790Sobrien *  TEKRAM NVRAM format support.
17653790Sobrien */
17754690Sobrien#define SYM_SETUP_TEKRAM_NVRAM	(1)
17853790Sobrien
17953790Sobrien/*
18053790Sobrien *  PCI parity checking.
18154690Sobrien *  It should not be an option, but some poor or broken
18254690Sobrien *  PCI-HOST bridges have been reported to make problems
18354690Sobrien *  when this feature is enabled.
18454690Sobrien *  Setting this option to 0 tells the driver not to
18554690Sobrien *  enable the checking against PCI parity.
18653790Sobrien */
18754690Sobrien#ifndef SYM_SETUP_PCI_PARITY
18854690Sobrien#define SYM_SETUP_PCI_PARITY	(1)
18954690Sobrien#endif
19053790Sobrien
19153790Sobrien/*
19253790Sobrien *  SCSI parity checking.
19353790Sobrien */
19454690Sobrien#define SYM_SETUP_SCSI_PARITY	(1)
19553790Sobrien
19653790Sobrien/*
19753790Sobrien *  SCSI activity LED.
19853790Sobrien */
19954690Sobrien#define SYM_SETUP_SCSI_LED	(0)
20053790Sobrien
20153790Sobrien/*
20254690Sobrien *  SCSI High Voltage Differential support.
20354690Sobrien *
20454690Sobrien *  HVD/LVD/SE capable controllers (895, 895A, 896, 1010)
20554690Sobrien *  report the actual SCSI BUS mode from the STEST4 IO
20654690Sobrien *  register.
20754690Sobrien *
20854690Sobrien *  But for HVD/SE only capable chips (825a, 875, 885),
20954690Sobrien *  the driver uses some heuristic to probe against HVD.
21054690Sobrien *  Normally, the chip senses the DIFFSENS signal and
21154690Sobrien *  should switch its BUS tranceivers to high impedance
21254690Sobrien *  in situation of the driver having been wrong about
21354690Sobrien *  the actual BUS mode. May-be, the BUS mode probing of
21454690Sobrien *  the driver is safe, but, given that it may be partially
21554690Sobrien *  based on some previous IO register settings, it
21654690Sobrien *  cannot be stated so. Thus, decision has been taken
21754690Sobrien *  to require a user option to be set for the DIFF probing
21854690Sobrien *  to be applied for the 825a, 875 and 885 chips.
21954690Sobrien *
22054690Sobrien *  This setup option works as follows:
22154690Sobrien *
22254690Sobrien *    0  ->  HVD only supported for 895, 895A, 896, 1010.
22354690Sobrien *    1  ->  HVD probed  for 825A, 875, 885.
22454690Sobrien *    2  ->  HVD assumed for 825A, 875, 885 (not advised).
22553790Sobrien */
22654690Sobrien#ifndef SYM_SETUP_SCSI_DIFF
22754690Sobrien#define SYM_SETUP_SCSI_DIFF	(0)
22854690Sobrien#endif
22953790Sobrien
23053790Sobrien/*
23153790Sobrien *  IRQ mode.
23253790Sobrien */
23354690Sobrien#define SYM_SETUP_IRQ_MODE	(0)
23453790Sobrien
23553790Sobrien/*
23653790Sobrien *  Check SCSI BUS signal on reset.
23753790Sobrien */
23854690Sobrien#define SYM_SETUP_SCSI_BUS_CHECK	(1)
23953790Sobrien
24053790Sobrien/*
24153790Sobrien *  Max burst for PCI (1<<value)
24253790Sobrien *  7 means: (1<<7) = 128 DWORDS.
24353790Sobrien */
24454690Sobrien#define SYM_SETUP_BURST_ORDER	(7)
24553790Sobrien
24653790Sobrien/*
24753790Sobrien *  Only relevant if IARB support configured.
24853790Sobrien *  - Max number of successive settings of IARB hints.
24953790Sobrien *  - Set IARB on arbitration lost.
25053790Sobrien */
25154690Sobrien#define SYM_CONF_IARB_MAX 3
25254690Sobrien#define SYM_CONF_SET_IARB_ON_ARB_LOST 1
25353790Sobrien
25453790Sobrien/*
25553790Sobrien *  Returning wrong residuals may make problems.
25653790Sobrien *  When zero, this define tells the driver to
25753790Sobrien *  always return 0 as transfer residual.
25853790Sobrien *  Btw, all my testings of residuals have succeeded.
25953790Sobrien */
26054690Sobrien#define SYM_CONF_RESIDUAL_SUPPORT 1
26153790Sobrien
26254690Sobrien/*
26354690Sobrien *  Supported maximum number of LUNs to announce to
26454690Sobrien *  the access method.
26554690Sobrien *  The driver supports up to 64 LUNs per target as
26654690Sobrien *  required by SPI-2/SPI-3. However some SCSI devices
26754690Sobrien *  designed prior to these specifications or not being
26854690Sobrien *  conformant may be highly confused when they are
26954690Sobrien *  asked about a LUN > 7.
27054690Sobrien */
27154690Sobrien#ifndef SYM_SETUP_MAX_LUN
27254690Sobrien#define SYM_SETUP_MAX_LUN	(8)
27354690Sobrien#endif
27454690Sobrien
27554690Sobrien/*
27654690Sobrien *  Low priority probe map.
27754690Sobrien *
27854690Sobrien *  This option is used as a bitmap to tell the driver
27954690Sobrien *  about chips that are to be claimed with a low priority
28054690Sobrien *  (-2000) by the probe method. This allows any other driver
28154690Sobrien *  that may return some higher priority value for the same
28254690Sobrien *  chips to take precedence over this driver (sym).
28354690Sobrien *  This option may be used when both the ncr driver and this
28454690Sobrien *  driver are configured.
28554690Sobrien *
28654690Sobrien *  Bits are to be coded as follows:
28759743Sgroudier *    0x01  ->  810a, 860
28859743Sgroudier *    0x02  ->  825a, 875, 885, 895
28959743Sgroudier *    0x04  ->  895a, 896, 1510d
29059743Sgroudier *    0x08  ->  1010
29159743Sgroudier *    0x40  ->  810, 815, 825
29254690Sobrien *
29354690Sobrien *  For example, value 5 tells the driver to claim support
29454690Sobrien *  for 810a, 860, 895a, 896 and 1510d with low priority,
29554690Sobrien *  allowing the ncr driver to take precedence if configured.
29654690Sobrien */
29754690Sobrien#ifndef SYM_SETUP_LP_PROBE_MAP
29854690Sobrien#define SYM_SETUP_LP_PROBE_MAP 0
29954690Sobrien#endif
30054690Sobrien
30153790Sobrien#endif /* SYM_CONF_H */
302