ncr53c8xx.h

来自「linux 内核源代码」· C头文件 代码 · 共 1,330 行 · 第 1/3 页

H
1,330
字号
/********************************************************************************  Device driver for the PCI-SCSI NCR538XX controller family.****  Copyright (C) 1994  Wolfgang Stanglmeier**  Copyright (C) 1998-2001  Gerard Roudier <groudier@free.fr>****  This program is free software; you can redistribute it and/or modify**  it under the terms of the GNU General Public License as published by**  the Free Software Foundation; either version 2 of the License, or**  (at your option) any later version.****  This program is distributed in the hope that it will be useful,**  but WITHOUT ANY WARRANTY; without even the implied warranty of**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the**  GNU General Public License for more details.****  You should have received a copy of the GNU General Public License**  along with this program; if not, write to the Free Software**  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.****-----------------------------------------------------------------------------****  This driver has been ported to Linux from the FreeBSD NCR53C8XX driver**  and is currently maintained by****          Gerard Roudier              <groudier@free.fr>****  Being given that this driver originates from the FreeBSD version, and**  in order to keep synergy on both, any suggested enhancements and corrections**  received on Linux are automatically a potential candidate for the FreeBSD **  version.****  The original driver has been written for 386bsd and FreeBSD by**          Wolfgang Stanglmeier        <wolf@cologne.de>**          Stefan Esser                <se@mi.Uni-Koeln.de>****  And has been ported to NetBSD by**          Charles M. Hannum           <mycroft@gnu.ai.mit.edu>****  NVRAM detection and reading.**    Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>****  Added support for MIPS big endian systems.**    Carsten Langgaard, carstenl@mips.com**    Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.****  Added support for HP PARISC big endian systems.**    Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.**********************************************************************************/#ifndef NCR53C8XX_H#define NCR53C8XX_H#include <scsi/scsi_host.h>/***	If you want a driver as small as possible, donnot define the **	following options.*/#define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT#define SCSI_NCR_DEBUG_INFO_SUPPORT/***	To disable integrity checking, do not define the **	following option.*/#ifdef	CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK#	define SCSI_NCR_ENABLE_INTEGRITY_CHECK#endif/* ---------------------------------------------------------------------** Take into account kernel configured parameters.** Most of these options can be overridden at startup by a command line.** ---------------------------------------------------------------------*//* * For Ultra2 and Ultra3 SCSI support option, use special features.  * * Value (default) means: *	bit 0 : all features enabled, except: *		bit 1 : PCI Write And Invalidate. *		bit 2 : Data Phase Mismatch handling from SCRIPTS. * * Use boot options ncr53c8xx=specf:1 if you want all chip features to be  * enabled by the driver. */#define	SCSI_NCR_SETUP_SPECIAL_FEATURES		(3)#define SCSI_NCR_MAX_SYNC			(80)/* * Allow tags from 2 to 256, default 8 */#ifdef	CONFIG_SCSI_NCR53C8XX_MAX_TAGS#if	CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2#define SCSI_NCR_MAX_TAGS	(2)#elif	CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256#define SCSI_NCR_MAX_TAGS	(256)#else#define	SCSI_NCR_MAX_TAGS	CONFIG_SCSI_NCR53C8XX_MAX_TAGS#endif#else#define SCSI_NCR_MAX_TAGS	(8)#endif/* * Allow tagged command queuing support if configured with default number  * of tags set to max (see above). */#ifdef	CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS#define	SCSI_NCR_SETUP_DEFAULT_TAGS	CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS#elif	defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE#define	SCSI_NCR_SETUP_DEFAULT_TAGS	SCSI_NCR_MAX_TAGS#else#define	SCSI_NCR_SETUP_DEFAULT_TAGS	(0)#endif/* * Immediate arbitration */#if defined(CONFIG_SCSI_NCR53C8XX_IARB)#define SCSI_NCR_IARB_SUPPORT#endif/* * Sync transfer frequency at startup. * Allow from 5Mhz to 80Mhz default 20 Mhz. */#ifndef	CONFIG_SCSI_NCR53C8XX_SYNC#define	CONFIG_SCSI_NCR53C8XX_SYNC	(20)#elif	CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC#undef	CONFIG_SCSI_NCR53C8XX_SYNC#define	CONFIG_SCSI_NCR53C8XX_SYNC	SCSI_NCR_MAX_SYNC#endif#if	CONFIG_SCSI_NCR53C8XX_SYNC == 0#define	SCSI_NCR_SETUP_DEFAULT_SYNC	(255)#elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 5#define	SCSI_NCR_SETUP_DEFAULT_SYNC	(50)#elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 20#define	SCSI_NCR_SETUP_DEFAULT_SYNC	(250/(CONFIG_SCSI_NCR53C8XX_SYNC))#elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 33#define	SCSI_NCR_SETUP_DEFAULT_SYNC	(11)#elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 40#define	SCSI_NCR_SETUP_DEFAULT_SYNC	(10)#else#define	SCSI_NCR_SETUP_DEFAULT_SYNC 	(9)#endif/* * Disallow disconnections at boot-up */#ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT#define SCSI_NCR_SETUP_DISCONNECTION	(0)#else#define SCSI_NCR_SETUP_DISCONNECTION	(1)#endif/* * Force synchronous negotiation for all targets */#ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO	(1)#else#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO	(0)#endif/* * Disable master parity checking (flawed hardwares need that) */#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK#define SCSI_NCR_SETUP_MASTER_PARITY	(0)#else#define SCSI_NCR_SETUP_MASTER_PARITY	(1)#endif/* * Disable scsi parity checking (flawed devices may need that) */#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK#define SCSI_NCR_SETUP_SCSI_PARITY	(0)#else#define SCSI_NCR_SETUP_SCSI_PARITY	(1)#endif/* * Settle time after reset at boot-up */#define SCSI_NCR_SETUP_SETTLE_TIME	(2)/***	Bridge quirks work-around option defaulted to 1.*/#ifndef	SCSI_NCR_PCIQ_WORK_AROUND_OPT#define	SCSI_NCR_PCIQ_WORK_AROUND_OPT	1#endif/***	Work-around common bridge misbehaviour.****	- Do not flush posted writes in the opposite **	  direction on read.**	- May reorder DMA writes to memory.****	This option should not affect performances **	significantly, so it is the default.*/#if	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1#define	SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM#define	SCSI_NCR_PCIQ_MAY_REORDER_WRITES#define	SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS/***	Same as option 1, but also deal with **	misconfigured interrupts.****	- Edge triggered instead of level sensitive.**	- No interrupt line connected.**	- IRQ number misconfigured.**	**	If no interrupt is delivered, the driver will **	catch the interrupt conditions 10 times per **	second. No need to say that this option is **	not recommended.*/#elif	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2#define	SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM#define	SCSI_NCR_PCIQ_MAY_REORDER_WRITES#define	SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS#define	SCSI_NCR_PCIQ_BROKEN_INTR/***	Some bridge designers decided to flush **	everything prior to deliver the interrupt.**	This option tries to deal with such a **	behaviour.*/#elif	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3#define	SCSI_NCR_PCIQ_SYNC_ON_INTR#endif/***	Other parameters not configurable with "make config"**	Avoid to change these constants, unless you know what you are doing.*/#define SCSI_NCR_ALWAYS_SIMPLE_TAG#define SCSI_NCR_MAX_SCATTER	(127)#define SCSI_NCR_MAX_TARGET	(16)/***   Compute some desirable value for CAN_QUEUE **   and CMD_PER_LUN.**   The driver will use lower values if these **   ones appear to be too large.*/#define SCSI_NCR_CAN_QUEUE	(8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET)#define SCSI_NCR_CMD_PER_LUN	(SCSI_NCR_MAX_TAGS)#define SCSI_NCR_SG_TABLESIZE	(SCSI_NCR_MAX_SCATTER)#define SCSI_NCR_TIMER_INTERVAL	(HZ)#if 1 /* defined CONFIG_SCSI_MULTI_LUN */#define SCSI_NCR_MAX_LUN	(16)#else#define SCSI_NCR_MAX_LUN	(1)#endif/* *  IO functions definition for big/little endian CPU support. *  For now, the NCR is only supported in little endian addressing mode,  */#ifdef	__BIG_ENDIAN#define	inw_l2b		inw#define	inl_l2b		inl#define	outw_b2l	outw#define	outl_b2l	outl#define	readb_raw	readb#define	writeb_raw	writeb#if defined(SCSI_NCR_BIG_ENDIAN)#define	readw_l2b	__raw_readw#define	readl_l2b	__raw_readl#define	writew_b2l	__raw_writew#define	writel_b2l	__raw_writel#define	readw_raw	__raw_readw#define	readl_raw	__raw_readl#define	writew_raw	__raw_writew#define	writel_raw	__raw_writel#else	/* Other big-endian */#define	readw_l2b	readw#define	readl_l2b	readl#define	writew_b2l	writew#define	writel_b2l	writel#define	readw_raw	readw#define	readl_raw	readl#define	writew_raw	writew#define	writel_raw	writel#endif#else	/* little endian */#define	inw_raw		inw#define	inl_raw		inl#define	outw_raw	outw#define	outl_raw	outl#define	readb_raw	readb#define	readw_raw	readw#define	readl_raw	readl#define	writeb_raw	writeb#define	writew_raw	writew#define	writel_raw	writel#endif#if !defined(__hppa__) && !defined(__mips__)#ifdef	SCSI_NCR_BIG_ENDIAN#error	"The NCR in BIG ENDIAN addressing mode is not (yet) supported"#endif#endif#define MEMORY_BARRIER()	mb()/* *  If the NCR uses big endian addressing mode over the  *  PCI, actual io register addresses for byte and word  *  accesses must be changed according to lane routing. *  Btw, ncr_offb() and ncr_offw() macros only apply to  *  constants and so donnot generate bloated code. */#if	defined(SCSI_NCR_BIG_ENDIAN)#define ncr_offb(o)	(((o)&~3)+((~((o)&3))&3))#define ncr_offw(o)	(((o)&~3)+((~((o)&3))&2))#else#define ncr_offb(o)	(o)#define ncr_offw(o)	(o)#endif/* *  If the CPU and the NCR use same endian-ness addressing, *  no byte reordering is needed for script patching. *  Macro cpu_to_scr() is to be used for script patching. *  Macro scr_to_cpu() is to be used for getting a DWORD  *  from the script. */#if	defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)#define cpu_to_scr(dw)	cpu_to_le32(dw)#define scr_to_cpu(dw)	le32_to_cpu(dw)#elif	defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)#define cpu_to_scr(dw)	cpu_to_be32(dw)#define scr_to_cpu(dw)	be32_to_cpu(dw)#else#define cpu_to_scr(dw)	(dw)#define scr_to_cpu(dw)	(dw)#endif/* *  Access to the controller chip. * *  If the CPU and the NCR use same endian-ness addressing, *  no byte reordering is needed for accessing chip io  *  registers. Functions suffixed by '_raw' are assumed  *  to access the chip over the PCI without doing byte  *  reordering. Functions suffixed by '_l2b' are  *  assumed to perform little-endian to big-endian byte  *  reordering, those suffixed by '_b2l' blah, blah, *  blah, ... *//* *  MEMORY mapped IO input / output */#define INB_OFF(o)		readb_raw((char __iomem *)np->reg + ncr_offb(o))#define OUTB_OFF(o, val)	writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o))#if	defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)#define INW_OFF(o)		readw_l2b((char __iomem *)np->reg + ncr_offw(o))#define INL_OFF(o)		readl_l2b((char __iomem *)np->reg + (o))#define OUTW_OFF(o, val)	writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o))#define OUTL_OFF(o, val)	writel_b2l((val), (char __iomem *)np->reg + (o))#elif	defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)#define INW_OFF(o)		readw_b2l((char __iomem *)np->reg + ncr_offw(o))#define INL_OFF(o)		readl_b2l((char __iomem *)np->reg + (o))#define OUTW_OFF(o, val)	writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o))#define OUTL_OFF(o, val)	writel_l2b((val), (char __iomem *)np->reg + (o))#else#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS/* Only 8 or 32 bit transfers allowed */#define INW_OFF(o)		(readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1))#else#define INW_OFF(o)		readw_raw((char __iomem *)np->reg + ncr_offw(o))#endif#define INL_OFF(o)		readl_raw((char __iomem *)np->reg + (o))#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS/* Only 8 or 32 bit transfers allowed */#define OUTW_OFF(o, val)	do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0)#else#define OUTW_OFF(o, val)	writew_raw((val), (char __iomem *)np->reg + ncr_offw(o))#endif#define OUTL_OFF(o, val)	writel_raw((val), (char __iomem *)np->reg + (o))#endif#define INB(r)		INB_OFF (offsetof(struct ncr_reg,r))#define INW(r)		INW_OFF (offsetof(struct ncr_reg,r))#define INL(r)		INL_OFF (offsetof(struct ncr_reg,r))#define OUTB(r, val)	OUTB_OFF (offsetof(struct ncr_reg,r), (val))#define OUTW(r, val)	OUTW_OFF (offsetof(struct ncr_reg,r), (val))#define OUTL(r, val)	OUTL_OFF (offsetof(struct ncr_reg,r), (val))/* *  Set bit field ON, OFF  */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?