/*
* Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
* of PCI-SCSI IO processors.
*
* Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
*
* This driver is derived from the Linux sym53c8xx driver.
* Copyright (C) 1998-2000 Gerard Roudier
*
* The sym53c8xx driver is derived from the ncr53c8xx driver that had been
* a port of the FreeBSD ncr driver to Linux-1.2.13.
*
* The original ncr driver has been written for 386bsd and FreeBSD by
* Wolfgang Stanglmeier <wolf@cologne.de>
* Stefan Esser <se@mi.Uni-Koeln.de>
* Copyright (C) 1994 Wolfgang Stanglmeier
*
* Other major contributions:
*
* NVRAM detection and reading.
* Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
*
*-----------------------------------------------------------------------------
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SYM_HIPD_H
#define SYM_HIPD_H
/*
* Generic driver options.
*
* They may be defined in platform specific headers, if they
* are useful.
*
* SYM_OPT_HANDLE_DIR_UNKNOWN
* When this option is set, the SCRIPTS used by the driver
* are able to handle SCSI transfers with direction not
* supplied by user.
* (set for Linux-2.0.X)
*
* SYM_OPT_HANDLE_DEVICE_QUEUEING
* When this option is set, the driver will use a queue per
* device and handle QUEUE FULL status requeuing internally.
*
* SYM_OPT_LIMIT_COMMAND_REORDERING
* When this option is set, the driver tries to limit tagged
* command reordering to some reasonnable value.
* (set for Linux)
*/
#if 0
#define SYM_OPT_HANDLE_DIR_UNKNOWN
#define SYM_OPT_HANDLE_DEVICE_QUEUEING
#define SYM_OPT_LIMIT_COMMAND_REORDERING
#endif
/*
* Active debugging tags and verbosity.
* Both DEBUG_FLAGS and sym_verbose can be redefined
* by the platform specific code to something else.
*/
#define DEBUG_ALLOC (0x0001)
#define DEBUG_PHASE (0x0002)
#define DEBUG_POLL (0x0004)
#define DEBUG_QUEUE (0x0008)
#define DEBUG_RESULT (0x0010)
#define DEBUG_SCATTER (0x0020)
#define DEBUG_SCRIPT (0x0040)
#define DEBUG_TINY (0x0080)
#define DEBUG_TIMING (0x0100)
#define DEBUG_NEGO (0x0200)
#define DEBUG_TAGS (0x0400)
#define DEBUG_POINTER (0x0800)
#ifndef DEBUG_FLAGS
#define DEBUG_FLAGS (0x0000)
#endif
#ifndef sym_verbose
#define sym_verbose (np->verbose)
#endif
/*
* These ones should have been already defined.
*/
#ifndef assert
#define assert(expression) { \
if (!(expression)) { \
(void)panic( \
"assertion \"%s\" failed: file \"%s\", line %d\n", \
#expression, \
__FILE__, __LINE__); \
} \
}
#endif
/*
* Number of tasks per device we want to handle.
*/
#if SYM_CONF_MAX_TAG_ORDER > 8
#error "more than 256 tags per logical unit not allowed."
#endif
#define SYM_CONF_MAX_TASK (1<<SYM_CONF_MAX_TAG_ORDER)
/*
* Donnot use more tasks that we can handle.
*/
#ifndef SYM_CONF_MAX_TAG
#define SYM_CONF_MAX_TAG SYM_CONF_MAX_TASK
#endif
#if SYM_CONF_MAX_TAG > SYM_CONF_MAX_TASK
#undef SYM_CONF_MAX_TAG
#define SYM_CONF_MAX_TAG SYM_CONF_MAX_TASK
#endif
/*
* This one means 'NO TAG for this job'
*/
#define NO_TAG (256)
/*
* Number of SCSI targets.
*/
#if SYM_CONF_MAX_TARGET > 16
#error "more than 16 targets not allowed."
#endif
/*
* Number of logical units per target.
*/
#if SYM_CONF_MAX_LUN > 64
#error "more than 64 logical units per target not allowed."
#endif
/*
* Asynchronous pre-scaler (ns). Shall be 40 for
* the SCSI timings to be compliant.
*/
#define SYM_CONF_MIN_ASYNC (40)
/*
* Shortest memory chunk is (1<<SYM_MEM_SHIFT), currently 16.
* Actual allocations happen as SYM_MEM_CLUSTER_SIZE sized.
* (1 PAGE at a time is just fine).
*/
#define SYM_MEM_SHIFT 4
#define SYM_MEM_CLUSTER_SIZE (1UL << SYM_MEM_CLUSTER_SHIFT)
#define SYM_MEM_CLUSTER_MASK (SYM_MEM_CLUSTER_SIZE-1)
/*
* Number of entries in the START and DONE queues.
*
* We limit to 1 PAGE in order to succeed allocation of
* these queues. Each entry is 8 bytes long (2 DWORDS).
*/
#ifdef SYM_CONF_MAX_START
#define SYM_CONF_MAX_QUEUE (SYM_CONF_MAX_START+2)
#else
#define SYM_CONF_MAX_QUEUE (7*SYM_CONF_MAX_TASK+2)
#define SYM_CONF_MAX_START (SYM_CONF_MAX_QUEUE-2)
#endif
#if SYM_CONF_MAX_QUEUE > SYM_MEM_CLUSTER_SIZE/8
#undef SYM_CONF_MAX_QUEUE
#define SYM_CONF_MAX_QUEUE (SYM_MEM_CLUSTER_SIZE/8)
#undef SYM_CONF_MAX_START
#define SYM_CONF_MAX_START (SYM_CONF_MAX_QUEUE-2)
#endif
/*
* For this one, we want a short name :-)
*/
#define MAX_QUEUE SYM_CONF_MAX_QUEUE
/*
* Common definitions for both bus space based and legacy IO methods.
*/
#define INB_OFF(np, o) ioread8(np->s.ioaddr + (o))
#define INW_OFF(np, o) ioread16(np->s.ioaddr + (o))
#define INL_OFF(np, o) ioread32(np->s.ioaddr + (o))
#define OUTB_OFF(np, o, val) iowrite8((val), np->s.ioaddr + (o))
#define OUTW_OFF(np, o, val) iowrite16((val), np->s.ioaddr + (o))
#define OUTL_OFF(np, o, val) iowrite32((val), np->s.ioaddr + (o))
#define INB(np, r) INB_OFF(np, offsetof(struct sym_reg, r))
#define INW(np, r) INW_OFF(np, offsetof(struct sym_reg, r))
#define INL(np, r) INL_OFF(np, offsetof(struct sym_reg, r))
#define OUTB(np, r, v) OUTB_OFF(np, offsetof(struct sym_reg, r), (v))
#define OUTW(np, r, v) OUTW_OFF(np, offsetof(struct sym_reg, r), (v))
#define OUTL(np, r, v) OUTL_OFF(np, offsetof(struct sym_reg, r), (v))
#define OUTONB(np, r, m) OUTB(np, r, INB(np, r) | (m))
#define OUTOFFB(np, r, m) OUTB(np, r, INB(np, r) & ~(m))
#define OUTONW(np, r, m) OUTW(np, r, INW(np, r) | (m))
#define OUTOFFW(np, r, m) OUTW(np, r, INW(np, r) & ~(m))
#define OUTONL(np, r, m) OUTL(np, r, INL(np, r) | (m))
#define OUTOFFL(np, r, m) OUTL(np, r, INL(np, r) & ~(m))
/*
* We normally want the chip to have a consistent view
* of driver internal data structures when we restart it.
* Thus these macros.
*/
#define OUTL_DSP(np, v) \
do { \
MEMORY_WRITE_BARRIER(); \
OUTL(np, nc_dsp, (v)); \
} while (0)
#define OUTONB_STD() \
do { \
MEMORY_WRITE_BARRIER(); \
OUTONB(np, nc_dcntl, (ST