add idl4k kernel firmware version 1.13.0.105

This commit is contained in:
Jaroslav Kysela
2015-03-26 17:22:37 +01:00
parent 5194d2792e
commit e9070cdc77
31064 changed files with 12769984 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
#
# PCMCIA SCSI adapter configuration
#
menuconfig SCSI_LOWLEVEL_PCMCIA
bool "PCMCIA SCSI adapter support"
depends on SCSI!=n && PCMCIA!=n
# drivers have problems when build in, so require modules
if SCSI_LOWLEVEL_PCMCIA && SCSI && PCMCIA && m
config PCMCIA_AHA152X
tristate "Adaptec AHA152X PCMCIA support"
depends on !64BIT
select SCSI_SPI_ATTRS
help
Say Y here if you intend to attach this type of PCMCIA SCSI host
adapter to your computer.
To compile this driver as a module, choose M here: the
module will be called aha152x_cs.
config PCMCIA_FDOMAIN
tristate "Future Domain PCMCIA support"
help
Say Y here if you intend to attach this type of PCMCIA SCSI host
adapter to your computer.
To compile this driver as a module, choose M here: the
module will be called fdomain_cs.
config PCMCIA_NINJA_SCSI
tristate "NinjaSCSI-3 / NinjaSCSI-32Bi (16bit) PCMCIA support"
depends on !64BIT
help
If you intend to attach this type of PCMCIA SCSI host adapter to
your computer, say Y here and read
<file:Documentation/scsi/NinjaSCSI.txt>.
Supported cards:
NinjaSCSI-3: (version string: "WBT","NinjaSCSI-3","R1.0")
IO-DATA PCSC-FP
ALPHA DATA AD-PCS201
CyQ've SFC-201
LOGITECH LPM-SCSI2E
Pioneer PCR-PR24's card
I-O DATA CDPS-PX24's card (PCSC-F)
Panasonic KXL-RW10AN CD-RW's card
etc.
NinjaSCSI-32Bit (in 16bit mode):
[Workbit (version string: "WORKBIT","UltraNinja-16","1")]
Jazz SCP050
[I-O DATA (OEM) (version string: "IO DATA","CBSC16 ","1")]
I-O DATA CBSC-II
[Kyusyu Matsushita Kotobuki (OEM)
(version string: "KME ","SCSI-CARD-001","1")]
KME KXL-820AN's card
HP M820e CDRW's card
etc.
To compile this driver as a module, choose M here: the
module will be called nsp_cs.
config PCMCIA_QLOGIC
tristate "Qlogic PCMCIA support"
help
Say Y here if you intend to attach this type of PCMCIA SCSI host
adapter to your computer.
To compile this driver as a module, choose M here: the
module will be called qlogic_cs.
config PCMCIA_SYM53C500
tristate "Symbios 53c500 PCMCIA support"
help
Say Y here if you have a New Media Bus Toaster or other PCMCIA
SCSI adapter based on the Symbios 53c500 controller.
To compile this driver as a module, choose M here: the
module will be called sym53c500_cs.
endif # SCSI_LOWLEVEL_PCMCIA

View File

@@ -0,0 +1,13 @@
EXTRA_CFLAGS += -Idrivers/scsi
# 16-bit client drivers
obj-$(CONFIG_PCMCIA_QLOGIC) += qlogic_cs.o
obj-$(CONFIG_PCMCIA_FDOMAIN) += fdomain_cs.o
obj-$(CONFIG_PCMCIA_AHA152X) += aha152x_cs.o
obj-$(CONFIG_PCMCIA_NINJA_SCSI) += nsp_cs.o
obj-$(CONFIG_PCMCIA_SYM53C500) += sym53c500_cs.o
aha152x_cs-objs := aha152x_stub.o aha152x_core.o
fdomain_cs-objs := fdomain_stub.o fdomain_core.o
qlogic_cs-objs := qlogic_stub.o

View File

@@ -0,0 +1,3 @@
#define PCMCIA 1
#define AHA152X_STAT 1
#include "aha152x.c"

View File

@@ -0,0 +1,263 @@
/*======================================================================
A driver for Adaptec AHA152X-compatible PCMCIA SCSI cards.
This driver supports the Adaptec AHA-1460, the New Media Bus
Toaster, and the New Media Toast & Jam.
aha152x_cs.c 1.54 2000/06/12 21:27:25
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The initial developer of the original code is David A. Hinds
<dahinds@users.sourceforge.net>. Portions created by David A. Hinds
are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
Alternatively, the contents of this file may be used under the
terms of the GNU General Public License version 2 (the "GPL"), in which
case the provisions of the GPL are applicable instead of the
above. If you wish to allow the use of your version of this file
only under the terms of the GPL and not to allow others to use
your version of this file under the MPL, indicate your decision
by deleting the provisions above and replace them with the notice
and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this
file under either the MPL or the GPL.
======================================================================*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/ioport.h>
#include <scsi/scsi.h>
#include <linux/major.h>
#include <linux/blkdev.h>
#include <scsi/scsi_ioctl.h>
#include "scsi.h"
#include <scsi/scsi_host.h>
#include "aha152x.h"
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0644);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version =
"aha152x_cs.c 1.54 2000/06/12 21:27:25 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
/*====================================================================*/
/* Parameters that can be set with 'insmod' */
/* SCSI bus setup options */
static int host_id = 7;
static int reconnect = 1;
static int parity = 1;
static int synchronous = 1;
static int reset_delay = 100;
static int ext_trans = 0;
module_param(host_id, int, 0);
module_param(reconnect, int, 0);
module_param(parity, int, 0);
module_param(synchronous, int, 0);
module_param(reset_delay, int, 0);
module_param(ext_trans, int, 0);
MODULE_LICENSE("Dual MPL/GPL");
/*====================================================================*/
typedef struct scsi_info_t {
struct pcmcia_device *p_dev;
dev_node_t node;
struct Scsi_Host *host;
} scsi_info_t;
static void aha152x_release_cs(struct pcmcia_device *link);
static void aha152x_detach(struct pcmcia_device *p_dev);
static int aha152x_config_cs(struct pcmcia_device *link);
static struct pcmcia_device *dev_list;
static int aha152x_probe(struct pcmcia_device *link)
{
scsi_info_t *info;
DEBUG(0, "aha152x_attach()\n");
/* Create new SCSI device */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) return -ENOMEM;
info->p_dev = link;
link->priv = info;
link->io.NumPorts1 = 0x20;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
link->io.IOAddrLines = 10;
link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
link->irq.IRQInfo1 = IRQ_LEVEL_ID;
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;
link->conf.Present = PRESENT_OPTION;
return aha152x_config_cs(link);
} /* aha152x_attach */
/*====================================================================*/
static void aha152x_detach(struct pcmcia_device *link)
{
DEBUG(0, "aha152x_detach(0x%p)\n", link);
aha152x_release_cs(link);
/* Unlink device structure, free bits */
kfree(link->priv);
} /* aha152x_detach */
/*====================================================================*/
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
static int aha152x_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
/* For New Media T&J, look for a SCSI window */
if (cfg->io.win[0].len >= 0x20)
p_dev->io.BasePort1 = cfg->io.win[0].base;
else if ((cfg->io.nwin > 1) &&
(cfg->io.win[1].len >= 0x20))
p_dev->io.BasePort1 = cfg->io.win[1].base;
if ((cfg->io.nwin > 0) &&
(p_dev->io.BasePort1 < 0xffff)) {
if (!pcmcia_request_io(p_dev, &p_dev->io))
return 0;
}
return -EINVAL;
}
static int aha152x_config_cs(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
struct aha152x_setup s;
int last_ret, last_fn;
struct Scsi_Host *host;
DEBUG(0, "aha152x_config(0x%p)\n", link);
last_ret = pcmcia_loop_config(link, aha152x_config_check, NULL);
if (last_ret) {
cs_error(link, RequestIO, last_ret);
goto failed;
}
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
/* Set configuration options for the aha152x driver */
memset(&s, 0, sizeof(s));
s.conf = "PCMCIA setup";
s.io_port = link->io.BasePort1;
s.irq = link->irq.AssignedIRQ;
s.scsiid = host_id;
s.reconnect = reconnect;
s.parity = parity;
s.synchronous = synchronous;
s.delay = reset_delay;
if (ext_trans)
s.ext_trans = ext_trans;
host = aha152x_probe_one(&s);
if (host == NULL) {
printk(KERN_INFO "aha152x_cs: no SCSI devices found\n");
goto cs_failed;
}
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev_node = &info->node;
info->host = host;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
aha152x_release_cs(link);
return -ENODEV;
}
static void aha152x_release_cs(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
aha152x_release(info->host);
pcmcia_disable_device(link);
}
static int aha152x_resume(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
aha152x_host_reset_host(info->host);
return 0;
}
static struct pcmcia_device_id aha152x_ids[] = {
PCMCIA_DEVICE_PROD_ID123("New Media", "SCSI", "Bus Toaster", 0xcdf7e4cc, 0x35f26476, 0xa8851d6e),
PCMCIA_DEVICE_PROD_ID123("NOTEWORTHY", "SCSI", "Bus Toaster", 0xad89c6e8, 0x35f26476, 0xa8851d6e),
PCMCIA_DEVICE_PROD_ID12("Adaptec, Inc.", "APA-1460 SCSI Host Adapter", 0x24ba9738, 0x3a3c3d20),
PCMCIA_DEVICE_PROD_ID12("New Media Corporation", "Multimedia Sound/SCSI", 0x085a850b, 0x80a6535c),
PCMCIA_DEVICE_PROD_ID12("NOTEWORTHY", "NWCOMB02 SCSI/AUDIO COMBO CARD", 0xad89c6e8, 0x5f9a615b),
PCMCIA_DEVICE_NULL,
};
MODULE_DEVICE_TABLE(pcmcia, aha152x_ids);
static struct pcmcia_driver aha152x_cs_driver = {
.owner = THIS_MODULE,
.drv = {
.name = "aha152x_cs",
},
.probe = aha152x_probe,
.remove = aha152x_detach,
.id_table = aha152x_ids,
.resume = aha152x_resume,
};
static int __init init_aha152x_cs(void)
{
return pcmcia_register_driver(&aha152x_cs_driver);
}
static void __exit exit_aha152x_cs(void)
{
pcmcia_unregister_driver(&aha152x_cs_driver);
BUG_ON(dev_list != NULL);
}
module_init(init_aha152x_cs);
module_exit(exit_aha152x_cs);

View File

@@ -0,0 +1,2 @@
#define PCMCIA 1
#include "fdomain.c"

View File

@@ -0,0 +1,237 @@
/*======================================================================
A driver for Future Domain-compatible PCMCIA SCSI cards
fdomain_cs.c 1.47 2001/10/13 00:08:52
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The initial developer of the original code is David A. Hinds
<dahinds@users.sourceforge.net>. Portions created by David A. Hinds
are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
Alternatively, the contents of this file may be used under the
terms of the GNU General Public License version 2 (the "GPL"), in
which case the provisions of the GPL are applicable instead of the
above. If you wish to allow the use of your version of this file
only under the terms of the GPL and not to allow others to use
your version of this file under the MPL, indicate your decision
by deleting the provisions above and replace them with the notice
and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this
file under either the MPL or the GPL.
======================================================================*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/ioport.h>
#include <scsi/scsi.h>
#include <linux/major.h>
#include <linux/blkdev.h>
#include <scsi/scsi_ioctl.h>
#include "scsi.h"
#include <scsi/scsi_host.h>
#include "fdomain.h"
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
/*====================================================================*/
/* Module parameters */
MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
MODULE_DESCRIPTION("Future Domain PCMCIA SCSI driver");
MODULE_LICENSE("Dual MPL/GPL");
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version =
"fdomain_cs.c 1.47 2001/10/13 00:08:52 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
/*====================================================================*/
typedef struct scsi_info_t {
struct pcmcia_device *p_dev;
dev_node_t node;
struct Scsi_Host *host;
} scsi_info_t;
static void fdomain_release(struct pcmcia_device *link);
static void fdomain_detach(struct pcmcia_device *p_dev);
static int fdomain_config(struct pcmcia_device *link);
static int fdomain_probe(struct pcmcia_device *link)
{
scsi_info_t *info;
DEBUG(0, "fdomain_attach()\n");
/* Create new SCSI device */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
info->p_dev = link;
link->priv = info;
link->io.NumPorts1 = 0x10;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
link->io.IOAddrLines = 10;
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
link->irq.IRQInfo1 = IRQ_LEVEL_ID;
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;
link->conf.Present = PRESENT_OPTION;
return fdomain_config(link);
} /* fdomain_attach */
/*====================================================================*/
static void fdomain_detach(struct pcmcia_device *link)
{
DEBUG(0, "fdomain_detach(0x%p)\n", link);
fdomain_release(link);
kfree(link->priv);
} /* fdomain_detach */
/*====================================================================*/
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
static int fdomain_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
p_dev->io.BasePort1 = cfg->io.win[0].base;
return pcmcia_request_io(p_dev, &p_dev->io);
}
static int fdomain_config(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
int last_ret, last_fn;
char str[22];
struct Scsi_Host *host;
DEBUG(0, "fdomain_config(0x%p)\n", link);
last_ret = pcmcia_loop_config(link, fdomain_config_check, NULL);
if (last_ret) {
cs_error(link, RequestIO, last_ret);
goto failed;
}
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
/* A bad hack... */
release_region(link->io.BasePort1, link->io.NumPorts1);
/* Set configuration options for the fdomain driver */
sprintf(str, "%d,%d", link->io.BasePort1, link->irq.AssignedIRQ);
fdomain_setup(str);
host = __fdomain_16x0_detect(&fdomain_driver_template);
if (!host) {
printk(KERN_INFO "fdomain_cs: no SCSI devices found\n");
goto cs_failed;
}
if (scsi_add_host(host, NULL))
goto cs_failed;
scsi_scan_host(host);
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev_node = &info->node;
info->host = host;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
fdomain_release(link);
return -ENODEV;
} /* fdomain_config */
/*====================================================================*/
static void fdomain_release(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
DEBUG(0, "fdomain_release(0x%p)\n", link);
scsi_remove_host(info->host);
pcmcia_disable_device(link);
scsi_unregister(info->host);
}
/*====================================================================*/
static int fdomain_resume(struct pcmcia_device *link)
{
fdomain_16x0_bus_reset(NULL);
return 0;
}
static struct pcmcia_device_id fdomain_ids[] = {
PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20),
PCMCIA_DEVICE_PROD_ID1("SCSI PCMCIA Adapter Card", 0x8dacb57e),
PCMCIA_DEVICE_PROD_ID12(" SIMPLE TECHNOLOGY Corporation", "SCSI PCMCIA Credit Card Controller", 0x182bdafe, 0xc80d106f),
PCMCIA_DEVICE_NULL,
};
MODULE_DEVICE_TABLE(pcmcia, fdomain_ids);
static struct pcmcia_driver fdomain_cs_driver = {
.owner = THIS_MODULE,
.drv = {
.name = "fdomain_cs",
},
.probe = fdomain_probe,
.remove = fdomain_detach,
.id_table = fdomain_ids,
.resume = fdomain_resume,
};
static int __init init_fdomain_cs(void)
{
return pcmcia_register_driver(&fdomain_cs_driver);
}
static void __exit exit_fdomain_cs(void)
{
pcmcia_unregister_driver(&fdomain_cs_driver);
}
module_init(init_fdomain_cs);
module_exit(exit_fdomain_cs);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,399 @@
/*=======================================================/
Header file for nsp_cs.c
By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
Ver.1.0 : Cut unused lines.
Ver 0.1 : Initial version.
This software may be used and distributed according to the terms of
the GNU General Public License.
=========================================================*/
#ifndef __nsp_cs__
#define __nsp_cs__
/* for debugging */
//#define NSP_DEBUG 9
/*
#define static
#define inline
*/
/************************************
* Some useful macros...
*/
/* SCSI initiator must be ID 7 */
#define NSP_INITIATOR_ID 7
#define NSP_SELTIMEOUT 200
/***************************************************************************
* register definitions
***************************************************************************/
/*========================================================================
* base register
========================================================================*/
#define IRQCONTROL 0x00 /* R */
# define IRQCONTROL_RESELECT_CLEAR BIT(0)
# define IRQCONTROL_PHASE_CHANGE_CLEAR BIT(1)
# define IRQCONTROL_TIMER_CLEAR BIT(2)
# define IRQCONTROL_FIFO_CLEAR BIT(3)
# define IRQCONTROL_ALLMASK 0xff
# define IRQCONTROL_ALLCLEAR (IRQCONTROL_RESELECT_CLEAR | \
IRQCONTROL_PHASE_CHANGE_CLEAR | \
IRQCONTROL_TIMER_CLEAR | \
IRQCONTROL_FIFO_CLEAR )
# define IRQCONTROL_IRQDISABLE 0xf0
#define IRQSTATUS 0x00 /* W */
# define IRQSTATUS_SCSI BIT(0)
# define IRQSTATUS_TIMER BIT(2)
# define IRQSTATUS_FIFO BIT(3)
# define IRQSTATUS_MASK 0x0f
#define IFSELECT 0x01 /* W */
# define IF_IFSEL BIT(0)
# define IF_REGSEL BIT(2)
#define FIFOSTATUS 0x01 /* R */
# define FIFOSTATUS_CHIP_REVISION_MASK 0x0f
# define FIFOSTATUS_CHIP_ID_MASK 0x70
# define FIFOSTATUS_FULL_EMPTY BIT(7)
#define INDEXREG 0x02 /* R/W */
#define DATAREG 0x03 /* R/W */
#define FIFODATA 0x04 /* R/W */
#define FIFODATA1 0x05 /* R/W */
#define FIFODATA2 0x06 /* R/W */
#define FIFODATA3 0x07 /* R/W */
/*====================================================================
* indexed register
====================================================================*/
#define EXTBUSCTRL 0x10 /* R/W,deleted */
#define CLOCKDIV 0x11 /* R/W */
# define CLOCK_40M 0x02
# define CLOCK_20M 0x01
# define FAST_20 BIT(2)
#define TERMPWRCTRL 0x13 /* R/W */
# define POWER_ON BIT(0)
#define SCSIIRQMODE 0x15 /* R/W */
# define SCSI_PHASE_CHANGE_EI BIT(0)
# define RESELECT_EI BIT(4)
# define FIFO_IRQ_EI BIT(5)
# define SCSI_RESET_IRQ_EI BIT(6)
#define IRQPHASESENCE 0x16 /* R */
# define LATCHED_MSG BIT(0)
# define LATCHED_IO BIT(1)
# define LATCHED_CD BIT(2)
# define LATCHED_BUS_FREE BIT(3)
# define PHASE_CHANGE_IRQ BIT(4)
# define RESELECT_IRQ BIT(5)
# define FIFO_IRQ BIT(6)
# define SCSI_RESET_IRQ BIT(7)
#define TIMERCOUNT 0x17 /* R/W */
#define SCSIBUSCTRL 0x18 /* R/W */
# define SCSI_SEL BIT(0)
# define SCSI_RST BIT(1)
# define SCSI_DATAOUT_ENB BIT(2)
# define SCSI_ATN BIT(3)
# define SCSI_ACK BIT(4)
# define SCSI_BSY BIT(5)
# define AUTODIRECTION BIT(6)
# define ACKENB BIT(7)
#define SCSIBUSMON 0x19 /* R */
#define SETARBIT 0x1A /* W */
# define ARBIT_GO BIT(0)
# define ARBIT_FLAG_CLEAR BIT(1)
#define ARBITSTATUS 0x1A /* R */
/*# define ARBIT_GO BIT(0)*/
# define ARBIT_WIN BIT(1)
# define ARBIT_FAIL BIT(2)
# define RESELECT_FLAG BIT(3)
#define PARITYCTRL 0x1B /* W */
#define PARITYSTATUS 0x1B /* R */
#define COMMANDCTRL 0x1C /* W */
# define CLEAR_COMMAND_POINTER BIT(0)
# define AUTO_COMMAND_GO BIT(1)
#define RESELECTID 0x1C /* R */
#define COMMANDDATA 0x1D /* R/W */
#define POINTERCLR 0x1E /* W */
# define POINTER_CLEAR BIT(0)
# define ACK_COUNTER_CLEAR BIT(1)
# define REQ_COUNTER_CLEAR BIT(2)
# define HOST_COUNTER_CLEAR BIT(3)
# define READ_SOURCE (BIT(4) | BIT(5))
# define ACK_COUNTER (0)
# define REQ_COUNTER (BIT(4))
# define HOST_COUNTER (BIT(5))
#define TRANSFERCOUNT 0x1E /* R */
#define TRANSFERMODE 0x20 /* R/W */
# define MODE_MEM8 BIT(0)
# define MODE_MEM32 BIT(1)
# define MODE_ADR24 BIT(2)
# define MODE_ADR32 BIT(3)
# define MODE_IO8 BIT(4)
# define MODE_IO32 BIT(5)
# define TRANSFER_GO BIT(6)
# define BRAIND BIT(7)
#define SYNCREG 0x21 /* R/W */
# define SYNCREG_OFFSET_MASK 0x0f
# define SYNCREG_PERIOD_MASK 0xf0
# define SYNCREG_PERIOD_SHIFT 4
#define SCSIDATALATCH 0x22 /* W */
#define SCSIDATAIN 0x22 /* R */
#define SCSIDATAWITHACK 0x23 /* R/W */
#define SCAMCONTROL 0x24 /* W */
#define SCAMSTATUS 0x24 /* R */
#define SCAMDATA 0x25 /* R/W */
#define OTHERCONTROL 0x26 /* R/W */
# define TPL_ROM_WRITE_EN BIT(0)
# define TPWR_OUT BIT(1)
# define TPWR_SENSE BIT(2)
# define RA8_CONTROL BIT(3)
#define ACKWIDTH 0x27 /* R/W */
#define CLRTESTPNT 0x28 /* W */
#define ACKCNTLD 0x29 /* W */
#define REQCNTLD 0x2A /* W */
#define HSTCNTLD 0x2B /* W */
#define CHECKSUM 0x2C /* R/W */
/************************************************************************
* Input status bit definitions.
************************************************************************/
#define S_MESSAGE BIT(0) /* Message line from SCSI bus */
#define S_IO BIT(1) /* Input/Output line from SCSI bus */
#define S_CD BIT(2) /* Command/Data line from SCSI bus */
#define S_BUSY BIT(3) /* Busy line from SCSI bus */
#define S_ACK BIT(4) /* Acknowlege line from SCSI bus */
#define S_REQUEST BIT(5) /* Request line from SCSI bus */
#define S_SELECT BIT(6) /* */
#define S_ATN BIT(7) /* */
/***********************************************************************
* Useful Bus Monitor status combinations.
***********************************************************************/
#define BUSMON_SEL S_SELECT
#define BUSMON_BSY S_BUSY
#define BUSMON_REQ S_REQUEST
#define BUSMON_IO S_IO
#define BUSMON_ACK S_ACK
#define BUSMON_BUS_FREE 0
#define BUSMON_COMMAND ( S_BUSY | S_CD | S_REQUEST )
#define BUSMON_MESSAGE_IN ( S_BUSY | S_CD | S_IO | S_MESSAGE | S_REQUEST )
#define BUSMON_MESSAGE_OUT ( S_BUSY | S_CD | S_MESSAGE | S_REQUEST )
#define BUSMON_DATA_IN ( S_BUSY | S_IO | S_REQUEST )
#define BUSMON_DATA_OUT ( S_BUSY | S_REQUEST )
#define BUSMON_STATUS ( S_BUSY | S_CD | S_IO | S_REQUEST )
#define BUSMON_SELECT ( S_IO | S_SELECT )
#define BUSMON_RESELECT ( S_IO | S_SELECT )
#define BUSMON_PHASE_MASK ( S_CD | S_IO | S_MESSAGE | S_SELECT )
#define BUSPHASE_SELECT ( BUSMON_SELECT & BUSMON_PHASE_MASK )
#define BUSPHASE_COMMAND ( BUSMON_COMMAND & BUSMON_PHASE_MASK )
#define BUSPHASE_MESSAGE_IN ( BUSMON_MESSAGE_IN & BUSMON_PHASE_MASK )
#define BUSPHASE_MESSAGE_OUT ( BUSMON_MESSAGE_OUT & BUSMON_PHASE_MASK )
#define BUSPHASE_DATA_IN ( BUSMON_DATA_IN & BUSMON_PHASE_MASK )
#define BUSPHASE_DATA_OUT ( BUSMON_DATA_OUT & BUSMON_PHASE_MASK )
#define BUSPHASE_STATUS ( BUSMON_STATUS & BUSMON_PHASE_MASK )
/*====================================================================*/
typedef struct scsi_info_t {
struct pcmcia_device *p_dev;
struct Scsi_Host *host;
dev_node_t node;
int stop;
} scsi_info_t;
/* synchronous transfer negotiation data */
typedef struct _sync_data {
unsigned int SyncNegotiation;
#define SYNC_NOT_YET 0
#define SYNC_OK 1
#define SYNC_NG 2
unsigned int SyncPeriod;
unsigned int SyncOffset;
unsigned char SyncRegister;
unsigned char AckWidth;
} sync_data;
typedef struct _nsp_hw_data {
unsigned int BaseAddress;
unsigned int NumAddress;
unsigned int IrqNumber;
unsigned long MmioAddress;
#define NSP_MMIO_OFFSET 0x0800
unsigned long MmioLength;
unsigned char ScsiClockDiv;
unsigned char TransferMode;
int TimerCount;
int SelectionTimeOut;
struct scsi_cmnd *CurrentSC;
//int CurrnetTarget;
int FifoCount;
#define MSGBUF_SIZE 20
unsigned char MsgBuffer[MSGBUF_SIZE];
int MsgLen;
#define N_TARGET 8
sync_data Sync[N_TARGET];
char nspinfo[110]; /* description */
spinlock_t Lock;
scsi_info_t *ScsiInfo; /* attach <-> detect glue */
#ifdef NSP_DEBUG
int CmdId; /* Accepted command serial number.
Used for debugging. */
#endif
} nsp_hw_data;
/****************************************************************************
*
*/
/* Card service functions */
static void nsp_cs_detach (struct pcmcia_device *p_dev);
static void nsp_cs_release(struct pcmcia_device *link);
static int nsp_cs_config (struct pcmcia_device *link);
/* Linux SCSI subsystem specific functions */
static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht);
static const char *nsp_info (struct Scsi_Host *shpnt);
static int nsp_proc_info (
struct Scsi_Host *host,
char *buffer,
char **start,
off_t offset,
int length,
int inout);
static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
void (* done)(struct scsi_cmnd *SCpnt));
/* Error handler */
/*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/
/*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
static int nsp_eh_bus_reset (struct scsi_cmnd *SCpnt);
static int nsp_eh_host_reset (struct scsi_cmnd *SCpnt);
static int nsp_bus_reset (nsp_hw_data *data);
/* */
static int nsphw_init (nsp_hw_data *data);
static int nsphw_start_selection(struct scsi_cmnd *SCpnt);
static void nsp_start_timer (struct scsi_cmnd *SCpnt, int time);
static int nsp_fifo_count (struct scsi_cmnd *SCpnt);
static void nsp_pio_read (struct scsi_cmnd *SCpnt);
static void nsp_pio_write (struct scsi_cmnd *SCpnt);
static int nsp_nexus (struct scsi_cmnd *SCpnt);
static void nsp_scsi_done (struct scsi_cmnd *SCpnt);
static int nsp_analyze_sdtr (struct scsi_cmnd *SCpnt);
static int nsp_negate_signal (struct scsi_cmnd *SCpnt,
unsigned char mask, char *str);
static int nsp_expect_signal (struct scsi_cmnd *SCpnt,
unsigned char current_phase,
unsigned char mask);
static int nsp_xfer (struct scsi_cmnd *SCpnt, int phase);
static int nsp_dataphase_bypass (struct scsi_cmnd *SCpnt);
static int nsp_reselected (struct scsi_cmnd *SCpnt);
static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht);
/* Interrupt handler */
//static irqreturn_t nspintr(int irq, void *dev_id);
/* Module entry point*/
static int __init nsp_cs_init(void);
static void __exit nsp_cs_exit(void);
/* Debug */
#ifdef NSP_DEBUG
static void show_command (struct scsi_cmnd *SCpnt);
static void show_phase (struct scsi_cmnd *SCpnt);
static void show_busphase(unsigned char stat);
static void show_message (nsp_hw_data *data);
#else
# define show_command(ptr) /* */
# define show_phase(SCpnt) /* */
# define show_busphase(stat) /* */
# define show_message(data) /* */
#endif
/*
* SCSI phase
*/
enum _scsi_phase {
PH_UNDETERMINED ,
PH_ARBSTART ,
PH_SELSTART ,
PH_SELECTED ,
PH_COMMAND ,
PH_DATA ,
PH_STATUS ,
PH_MSG_IN ,
PH_MSG_OUT ,
PH_DISCONNECT ,
PH_RESELECT ,
PH_ABORT ,
PH_RESET
};
enum _data_in_out {
IO_UNKNOWN,
IO_IN,
IO_OUT
};
enum _burst_mode {
BURST_IO8 = 0,
BURST_IO32 = 1,
BURST_MEM32 = 2,
};
/**************************************************************************
* SCSI messaage
*/
#define MSG_COMMAND_COMPLETE 0x00
#define MSG_EXTENDED 0x01
#define MSG_ABORT 0x06
#define MSG_NO_OPERATION 0x08
#define MSG_BUS_DEVICE_RESET 0x0c
#define MSG_EXT_SDTR 0x01
/* scatter-gather table */
# define BUFFER_ADDR ((char *)((sg_virt(SCpnt->SCp.buffer))))
#endif /*__nsp_cs__*/
/* end */

View File

@@ -0,0 +1,215 @@
/*========================================================================
Debug routines for nsp_cs
By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
This software may be used and distributed according to the terms of
the GNU General Public License.
=========================================================================*/
/* $Id: nsp_debug.c,v 1.3 2003/07/26 14:21:09 elca Exp $ */
/*
* Show the command data of a command
*/
static const char unknown[] = "UNKNOWN";
static const char * group_0_commands[] = {
/* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
/* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",
/* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
/* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
/* 13-16 */ unknown, "Recover Buffered Data", "Mode Select", "Reserve",
/* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
/* 1c-1d */ "Receive Diagnostic", "Send Diagnostic",
/* 1e-1f */ "Prevent/Allow Medium Removal", unknown,
};
static const char *group_1_commands[] = {
/* 20-22 */ unknown, unknown, unknown,
/* 23-28 */ unknown, unknown, "Read Capacity", unknown, unknown, "Read (10)",
/* 29-2d */ unknown, "Write (10)", "Seek (10)", unknown, unknown,
/* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal",
/* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position",
/* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data",
/* 38-3c */ "Medium Scan", "Compare","Copy Verify", "Write Buffer", "Read Buffer",
/* 3d-3f */ "Update Block", "Read Long", "Write Long",
};
static const char *group_2_commands[] = {
/* 40-41 */ "Change Definition", "Write Same",
/* 42-48 */ "Read Sub-Ch(cd)", "Read TOC", "Read Header(cd)", "Play Audio(cd)", unknown, "Play Audio MSF(cd)", "Play Audio Track/Index(cd)",
/* 49-4f */ "Play Track Relative(10)(cd)", unknown, "Pause/Resume(cd)", "Log Select", "Log Sense", unknown, unknown,
/* 50-55 */ unknown, unknown, unknown, unknown, unknown, "Mode Select (10)",
/* 56-5b */ unknown, unknown, unknown, unknown, "Mode Sense (10)", unknown,
/* 5c-5f */ unknown, unknown, unknown,
};
#define group(opcode) (((opcode) >> 5) & 7)
#define RESERVED_GROUP 0
#define VENDOR_GROUP 1
#define NOTEXT_GROUP 2
static const char **commands[] = {
group_0_commands, group_1_commands, group_2_commands,
(const char **) RESERVED_GROUP, (const char **) RESERVED_GROUP,
(const char **) NOTEXT_GROUP, (const char **) VENDOR_GROUP,
(const char **) VENDOR_GROUP
};
static const char reserved[] = "RESERVED";
static const char vendor[] = "VENDOR SPECIFIC";
static void print_opcodek(unsigned char opcode)
{
const char **table = commands[ group(opcode) ];
switch ((unsigned long) table) {
case RESERVED_GROUP:
printk("%s[%02x] ", reserved, opcode);
break;
case NOTEXT_GROUP:
printk("%s(notext)[%02x] ", unknown, opcode);
break;
case VENDOR_GROUP:
printk("%s[%02x] ", vendor, opcode);
break;
default:
if (table[opcode & 0x1f] != unknown)
printk("%s[%02x] ", table[opcode & 0x1f], opcode);
else
printk("%s[%02x] ", unknown, opcode);
break;
}
}
static void print_commandk (unsigned char *command)
{
int i, s;
printk(KERN_DEBUG);
print_opcodek(command[0]);
/*printk(KERN_DEBUG "%s ", __func__);*/
if ((command[0] >> 5) == 6 ||
(command[0] >> 5) == 7 ) {
s = 12; /* vender specific */
} else {
s = COMMAND_SIZE(command[0]);
}
for ( i = 1; i < s; ++i) {
printk("%02x ", command[i]);
}
switch (s) {
case 6:
printk("LBA=%d len=%d",
(((unsigned int)command[1] & 0x0f) << 16) |
( (unsigned int)command[2] << 8) |
( (unsigned int)command[3] ),
(unsigned int)command[4]
);
break;
case 10:
printk("LBA=%d len=%d",
((unsigned int)command[2] << 24) |
((unsigned int)command[3] << 16) |
((unsigned int)command[4] << 8) |
((unsigned int)command[5] ),
((unsigned int)command[7] << 8) |
((unsigned int)command[8] )
);
break;
case 12:
printk("LBA=%d len=%d",
((unsigned int)command[2] << 24) |
((unsigned int)command[3] << 16) |
((unsigned int)command[4] << 8) |
((unsigned int)command[5] ),
((unsigned int)command[6] << 24) |
((unsigned int)command[7] << 16) |
((unsigned int)command[8] << 8) |
((unsigned int)command[9] )
);
break;
default:
break;
}
printk("\n");
}
static void show_command(struct scsi_cmnd *SCpnt)
{
print_commandk(SCpnt->cmnd);
}
static void show_phase(struct scsi_cmnd *SCpnt)
{
int i = SCpnt->SCp.phase;
char *ph[] = {
"PH_UNDETERMINED",
"PH_ARBSTART",
"PH_SELSTART",
"PH_SELECTED",
"PH_COMMAND",
"PH_DATA",
"PH_STATUS",
"PH_MSG_IN",
"PH_MSG_OUT",
"PH_DISCONNECT",
"PH_RESELECT"
};
if ( i < PH_UNDETERMINED || i > PH_RESELECT ) {
printk(KERN_DEBUG "scsi phase: unknown(%d)\n", i);
return;
}
printk(KERN_DEBUG "scsi phase: %s\n", ph[i]);
return;
}
static void show_busphase(unsigned char stat)
{
switch(stat) {
case BUSPHASE_COMMAND:
printk(KERN_DEBUG "BUSPHASE_COMMAND\n");
break;
case BUSPHASE_MESSAGE_IN:
printk(KERN_DEBUG "BUSPHASE_MESSAGE_IN\n");
break;
case BUSPHASE_MESSAGE_OUT:
printk(KERN_DEBUG "BUSPHASE_MESSAGE_OUT\n");
break;
case BUSPHASE_DATA_IN:
printk(KERN_DEBUG "BUSPHASE_DATA_IN\n");
break;
case BUSPHASE_DATA_OUT:
printk(KERN_DEBUG "BUSPHASE_DATA_OUT\n");
break;
case BUSPHASE_STATUS:
printk(KERN_DEBUG "BUSPHASE_STATUS\n");
break;
case BUSPHASE_SELECT:
printk(KERN_DEBUG "BUSPHASE_SELECT\n");
break;
default:
printk(KERN_DEBUG "BUSPHASE_other\n");
break;
}
}
static void show_message(nsp_hw_data *data)
{
int i;
printk(KERN_DEBUG "msg:");
for(i=0; i < data->MsgLen; i++) {
printk(" %02x", data->MsgBuffer[i]);
}
printk("\n");
}
/* end */

View File

@@ -0,0 +1,274 @@
/*
NinjaSCSI I/O funtions
By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
This software may be used and distributed according to the terms of
the GNU General Public License.
*/
/* $Id: nsp_io.h,v 1.3 2003/08/04 21:15:26 elca Exp $ */
#ifndef __NSP_IO_H__
#define __NSP_IO_H__
static inline void nsp_write(unsigned int base,
unsigned int index,
unsigned char val);
static inline unsigned char nsp_read(unsigned int base,
unsigned int index);
static inline void nsp_index_write(unsigned int BaseAddr,
unsigned int Register,
unsigned char Value);
static inline unsigned char nsp_index_read(unsigned int BaseAddr,
unsigned int Register);
/*******************************************************************
* Basic IO
*/
static inline void nsp_write(unsigned int base,
unsigned int index,
unsigned char val)
{
outb(val, (base + index));
}
static inline unsigned char nsp_read(unsigned int base,
unsigned int index)
{
return inb(base + index);
}
/**********************************************************************
* Indexed IO
*/
static inline unsigned char nsp_index_read(unsigned int BaseAddr,
unsigned int Register)
{
outb(Register, BaseAddr + INDEXREG);
return inb(BaseAddr + DATAREG);
}
static inline void nsp_index_write(unsigned int BaseAddr,
unsigned int Register,
unsigned char Value)
{
outb(Register, BaseAddr + INDEXREG);
outb(Value, BaseAddr + DATAREG);
}
/*********************************************************************
* fifo func
*/
/* read 8 bit FIFO */
static inline void nsp_multi_read_1(unsigned int BaseAddr,
unsigned int Register,
void *buf,
unsigned long count)
{
insb(BaseAddr + Register, buf, count);
}
static inline void nsp_fifo8_read(unsigned int base,
void *buf,
unsigned long count)
{
/*nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx", buf, count);*/
nsp_multi_read_1(base, FIFODATA, buf, count);
}
/*--------------------------------------------------------------*/
/* read 16 bit FIFO */
static inline void nsp_multi_read_2(unsigned int BaseAddr,
unsigned int Register,
void *buf,
unsigned long count)
{
insw(BaseAddr + Register, buf, count);
}
static inline void nsp_fifo16_read(unsigned int base,
void *buf,
unsigned long count)
{
//nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx*2", buf, count);
nsp_multi_read_2(base, FIFODATA, buf, count);
}
/*--------------------------------------------------------------*/
/* read 32bit FIFO */
static inline void nsp_multi_read_4(unsigned int BaseAddr,
unsigned int Register,
void *buf,
unsigned long count)
{
insl(BaseAddr + Register, buf, count);
}
static inline void nsp_fifo32_read(unsigned int base,
void *buf,
unsigned long count)
{
//nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx*4", buf, count);
nsp_multi_read_4(base, FIFODATA, buf, count);
}
/*----------------------------------------------------------*/
/* write 8bit FIFO */
static inline void nsp_multi_write_1(unsigned int BaseAddr,
unsigned int Register,
void *buf,
unsigned long count)
{
outsb(BaseAddr + Register, buf, count);
}
static inline void nsp_fifo8_write(unsigned int base,
void *buf,
unsigned long count)
{
nsp_multi_write_1(base, FIFODATA, buf, count);
}
/*---------------------------------------------------------*/
/* write 16bit FIFO */
static inline void nsp_multi_write_2(unsigned int BaseAddr,
unsigned int Register,
void *buf,
unsigned long count)
{
outsw(BaseAddr + Register, buf, count);
}
static inline void nsp_fifo16_write(unsigned int base,
void *buf,
unsigned long count)
{
nsp_multi_write_2(base, FIFODATA, buf, count);
}
/*---------------------------------------------------------*/
/* write 32bit FIFO */
static inline void nsp_multi_write_4(unsigned int BaseAddr,
unsigned int Register,
void *buf,
unsigned long count)
{
outsl(BaseAddr + Register, buf, count);
}
static inline void nsp_fifo32_write(unsigned int base,
void *buf,
unsigned long count)
{
nsp_multi_write_4(base, FIFODATA, buf, count);
}
/*====================================================================*/
static inline void nsp_mmio_write(unsigned long base,
unsigned int index,
unsigned char val)
{
unsigned char *ptr = (unsigned char *)(base + NSP_MMIO_OFFSET + index);
writeb(val, ptr);
}
static inline unsigned char nsp_mmio_read(unsigned long base,
unsigned int index)
{
unsigned char *ptr = (unsigned char *)(base + NSP_MMIO_OFFSET + index);
return readb(ptr);
}
/*-----------*/
static inline unsigned char nsp_mmio_index_read(unsigned long base,
unsigned int reg)
{
unsigned char *index_ptr = (unsigned char *)(base + NSP_MMIO_OFFSET + INDEXREG);
unsigned char *data_ptr = (unsigned char *)(base + NSP_MMIO_OFFSET + DATAREG);
writeb((unsigned char)reg, index_ptr);
return readb(data_ptr);
}
static inline void nsp_mmio_index_write(unsigned long base,
unsigned int reg,
unsigned char val)
{
unsigned char *index_ptr = (unsigned char *)(base + NSP_MMIO_OFFSET + INDEXREG);
unsigned char *data_ptr = (unsigned char *)(base + NSP_MMIO_OFFSET + DATAREG);
writeb((unsigned char)reg, index_ptr);
writeb(val, data_ptr);
}
/* read 32bit FIFO */
static inline void nsp_mmio_multi_read_4(unsigned long base,
unsigned int Register,
void *buf,
unsigned long count)
{
unsigned long *ptr = (unsigned long *)(base + Register);
unsigned long *tmp = (unsigned long *)buf;
int i;
//nsp_dbg(NSP_DEBUG_DATA_IO, "base 0x%0lx ptr 0x%p",base,ptr);
for (i = 0; i < count; i++) {
*tmp = readl(ptr);
//nsp_dbg(NSP_DEBUG_DATA_IO, "<%d,%p,%p,%lx>", i, ptr, tmp, *tmp);
tmp++;
}
}
static inline void nsp_mmio_fifo32_read(unsigned int base,
void *buf,
unsigned long count)
{
//nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx*4", buf, count);
nsp_mmio_multi_read_4(base, FIFODATA, buf, count);
}
static inline void nsp_mmio_multi_write_4(unsigned long base,
unsigned int Register,
void *buf,
unsigned long count)
{
unsigned long *ptr = (unsigned long *)(base + Register);
unsigned long *tmp = (unsigned long *)buf;
int i;
//nsp_dbg(NSP_DEBUG_DATA_IO, "base 0x%0lx ptr 0x%p",base,ptr);
for (i = 0; i < count; i++) {
writel(*tmp, ptr);
//nsp_dbg(NSP_DEBUG_DATA_IO, "<%d,%p,%p,%lx>", i, ptr, tmp, *tmp);
tmp++;
}
}
static inline void nsp_mmio_fifo32_write(unsigned int base,
void *buf,
unsigned long count)
{
//nsp_dbg(NSP_DEBUG_DATA_IO, "buf=0x%p, count=0x%lx*4", buf, count);
nsp_mmio_multi_write_4(base, FIFODATA, buf, count);
}
#endif
/* end */

View File

@@ -0,0 +1,78 @@
/*==========================================================================
NinjaSCSI-3 message handler
By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
This software may be used and distributed according to the terms of
the GNU General Public License.
*/
/* $Id: nsp_message.c,v 1.6 2003/07/26 14:21:09 elca Exp $ */
static void nsp_message_in(struct scsi_cmnd *SCpnt)
{
unsigned int base = SCpnt->device->host->io_port;
nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
unsigned char data_reg, control_reg;
int ret, len;
/*
* XXX: NSP QUIRK
* NSP invoke interrupts only in the case of scsi phase changes,
* therefore we should poll the scsi phase here to catch
* the next "msg in" if exists (no scsi phase changes).
*/
ret = 16;
len = 0;
nsp_dbg(NSP_DEBUG_MSGINOCCUR, "msgin loop");
do {
/* read data */
data_reg = nsp_index_read(base, SCSIDATAIN);
/* assert ACK */
control_reg = nsp_index_read(base, SCSIBUSCTRL);
control_reg |= SCSI_ACK;
nsp_index_write(base, SCSIBUSCTRL, control_reg);
nsp_negate_signal(SCpnt, BUSMON_REQ, "msgin<REQ>");
data->MsgBuffer[len] = data_reg; len++;
/* deassert ACK */
control_reg = nsp_index_read(base, SCSIBUSCTRL);
control_reg &= ~SCSI_ACK;
nsp_index_write(base, SCSIBUSCTRL, control_reg);
/* catch a next signal */
ret = nsp_expect_signal(SCpnt, BUSPHASE_MESSAGE_IN, BUSMON_REQ);
} while (ret > 0 && MSGBUF_SIZE > len);
data->MsgLen = len;
}
static void nsp_message_out(struct scsi_cmnd *SCpnt)
{
nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
int ret = 1;
int len = data->MsgLen;
/*
* XXX: NSP QUIRK
* NSP invoke interrupts only in the case of scsi phase changes,
* therefore we should poll the scsi phase here to catch
* the next "msg out" if exists (no scsi phase changes).
*/
nsp_dbg(NSP_DEBUG_MSGOUTOCCUR, "msgout loop");
do {
if (nsp_xfer(SCpnt, BUSPHASE_MESSAGE_OUT)) {
nsp_msg(KERN_DEBUG, "msgout: xfer short");
}
/* catch a next signal */
ret = nsp_expect_signal(SCpnt, BUSPHASE_MESSAGE_OUT, BUSMON_REQ);
} while (ret > 0 && len-- > 0);
}
/* end */

View File

@@ -0,0 +1,347 @@
/*======================================================================
A driver for the Qlogic SCSI card
qlogic_cs.c 1.79 2000/06/12 21:27:26
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The initial developer of the original code is David A. Hinds
<dahinds@users.sourceforge.net>. Portions created by David A. Hinds
are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
Alternatively, the contents of this file may be used under the
terms of the GNU General Public License version 2 (the "GPL"), in which
case the provisions of the GPL are applicable instead of the
above. If you wish to allow the use of your version of this file
only under the terms of the GPL and not to allow others to use
your version of this file under the MPL, indicate your decision
by deleting the provisions above and replace them with the notice
and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this
file under either the MPL or the GPL.
======================================================================*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/ioport.h>
#include <asm/io.h>
#include <scsi/scsi.h>
#include <linux/major.h>
#include <linux/blkdev.h>
#include <scsi/scsi_ioctl.h>
#include <linux/interrupt.h>
#include "scsi.h"
#include <scsi/scsi_host.h>
#include "../qlogicfas408.h"
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
#include <pcmcia/ciscode.h>
/* Set the following to 2 to use normal interrupt (active high/totempole-
* tristate), otherwise use 0 (REQUIRED FOR PCMCIA) for active low, open
* drain
*/
#define INT_TYPE 0
static char qlogic_name[] = "qlogic_cs";
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0644);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version = "qlogic_cs.c 1.79-ac 2002/10/26 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
static struct scsi_host_template qlogicfas_driver_template = {
.module = THIS_MODULE,
.name = qlogic_name,
.proc_name = qlogic_name,
.info = qlogicfas408_info,
.queuecommand = qlogicfas408_queuecommand,
.eh_abort_handler = qlogicfas408_abort,
.eh_bus_reset_handler = qlogicfas408_bus_reset,
.bios_param = qlogicfas408_biosparam,
.can_queue = 1,
.this_id = -1,
.sg_tablesize = SG_ALL,
.cmd_per_lun = 1,
.use_clustering = DISABLE_CLUSTERING,
};
/*====================================================================*/
typedef struct scsi_info_t {
struct pcmcia_device *p_dev;
dev_node_t node;
struct Scsi_Host *host;
unsigned short manf_id;
} scsi_info_t;
static void qlogic_release(struct pcmcia_device *link);
static void qlogic_detach(struct pcmcia_device *p_dev);
static int qlogic_config(struct pcmcia_device * link);
static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host,
struct pcmcia_device *link, int qbase, int qlirq)
{
int qltyp; /* type of chip */
int qinitid;
struct Scsi_Host *shost; /* registered host structure */
struct qlogicfas408_priv *priv;
qltyp = qlogicfas408_get_chip_type(qbase, INT_TYPE);
qinitid = host->this_id;
if (qinitid < 0)
qinitid = 7; /* if no ID, use 7 */
qlogicfas408_setup(qbase, qinitid, INT_TYPE);
host->name = qlogic_name;
shost = scsi_host_alloc(host, sizeof(struct qlogicfas408_priv));
if (!shost)
goto err;
shost->io_port = qbase;
shost->n_io_port = 16;
shost->dma_channel = -1;
if (qlirq != -1)
shost->irq = qlirq;
priv = get_priv_by_host(shost);
priv->qlirq = qlirq;
priv->qbase = qbase;
priv->qinitid = qinitid;
priv->shost = shost;
priv->int_type = INT_TYPE;
if (request_irq(qlirq, qlogicfas408_ihandl, 0, qlogic_name, shost))
goto free_scsi_host;
sprintf(priv->qinfo,
"Qlogicfas Driver version 0.46, chip %02X at %03X, IRQ %d, TPdma:%d",
qltyp, qbase, qlirq, QL_TURBO_PDMA);
if (scsi_add_host(shost, NULL))
goto free_interrupt;
scsi_scan_host(shost);
return shost;
free_interrupt:
free_irq(qlirq, shost);
free_scsi_host:
scsi_host_put(shost);
err:
return NULL;
}
static int qlogic_probe(struct pcmcia_device *link)
{
scsi_info_t *info;
DEBUG(0, "qlogic_attach()\n");
/* Create new SCSI device */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
info->p_dev = link;
link->priv = info;
link->io.NumPorts1 = 16;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
link->io.IOAddrLines = 10;
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
link->irq.IRQInfo1 = IRQ_LEVEL_ID;
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;
link->conf.Present = PRESENT_OPTION;
return qlogic_config(link);
} /* qlogic_attach */
/*====================================================================*/
static void qlogic_detach(struct pcmcia_device *link)
{
DEBUG(0, "qlogic_detach(0x%p)\n", link);
qlogic_release(link);
kfree(link->priv);
} /* qlogic_detach */
/*====================================================================*/
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
static int qlogic_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
p_dev->io.BasePort1 = cfg->io.win[0].base;
p_dev->io.NumPorts1 = cfg->io.win[0].len;
if (p_dev->io.BasePort1 == 0)
return -ENODEV;
return pcmcia_request_io(p_dev, &p_dev->io);
}
static int qlogic_config(struct pcmcia_device * link)
{
scsi_info_t *info = link->priv;
int last_ret, last_fn;
struct Scsi_Host *host;
DEBUG(0, "qlogic_config(0x%p)\n", link);
last_ret = pcmcia_loop_config(link, qlogic_config_check, NULL);
if (last_ret) {
cs_error(link, RequestIO, last_ret);
goto failed;
}
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
if ((info->manf_id == MANFID_MACNICA) || (info->manf_id == MANFID_PIONEER) || (info->manf_id == 0x0098)) {
/* set ATAcmd */
outb(0xb4, link->io.BasePort1 + 0xd);
outb(0x24, link->io.BasePort1 + 0x9);
outb(0x04, link->io.BasePort1 + 0xd);
}
/* The KXL-810AN has a bigger IO port window */
if (link->io.NumPorts1 == 32)
host = qlogic_detect(&qlogicfas_driver_template, link,
link->io.BasePort1 + 16, link->irq.AssignedIRQ);
else
host = qlogic_detect(&qlogicfas_driver_template, link,
link->io.BasePort1, link->irq.AssignedIRQ);
if (!host) {
printk(KERN_INFO "%s: no SCSI devices found\n", qlogic_name);
goto cs_failed;
}
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev_node = &info->node;
info->host = host;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
pcmcia_disable_device(link);
failed:
return -ENODEV;
} /* qlogic_config */
/*====================================================================*/
static void qlogic_release(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
DEBUG(0, "qlogic_release(0x%p)\n", link);
scsi_remove_host(info->host);
free_irq(link->irq.AssignedIRQ, info->host);
pcmcia_disable_device(link);
scsi_host_put(info->host);
}
/*====================================================================*/
static int qlogic_resume(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
pcmcia_request_configuration(link, &link->conf);
if ((info->manf_id == MANFID_MACNICA) ||
(info->manf_id == MANFID_PIONEER) ||
(info->manf_id == 0x0098)) {
outb(0x80, link->io.BasePort1 + 0xd);
outb(0x24, link->io.BasePort1 + 0x9);
outb(0x04, link->io.BasePort1 + 0xd);
}
/* Ugggglllyyyy!!! */
qlogicfas408_bus_reset(NULL);
return 0;
}
static struct pcmcia_device_id qlogic_ids[] = {
PCMCIA_DEVICE_PROD_ID12("EIger Labs", "PCMCIA-to-SCSI Adapter", 0x88395fa7, 0x33b7a5e6),
PCMCIA_DEVICE_PROD_ID12("EPSON", "SCSI-2 PC Card SC200", 0xd361772f, 0x299d1751),
PCMCIA_DEVICE_PROD_ID12("MACNICA", "MIRACLE SCSI-II mPS110", 0x20841b68, 0xab3c3b6d),
PCMCIA_DEVICE_PROD_ID12("MIDORI ELECTRONICS ", "CN-SC43", 0x6534382a, 0xd67eee79),
PCMCIA_DEVICE_PROD_ID12("NEC", "PC-9801N-J03R", 0x18df0ba0, 0x24662e8a),
PCMCIA_DEVICE_PROD_ID12("KME ", "KXLC003", 0x82375a27, 0xf68e5bf7),
PCMCIA_DEVICE_PROD_ID12("KME ", "KXLC004", 0x82375a27, 0x68eace54),
PCMCIA_DEVICE_PROD_ID12("KME", "KXLC101", 0x3faee676, 0x194250ec),
PCMCIA_DEVICE_PROD_ID12("QLOGIC CORPORATION", "pc05", 0xd77b2930, 0xa85b2735),
PCMCIA_DEVICE_PROD_ID12("QLOGIC CORPORATION", "pc05 rev 1.10", 0xd77b2930, 0x70f8b5f8),
PCMCIA_DEVICE_PROD_ID123("KME", "KXLC002", "00", 0x3faee676, 0x81896b61, 0xf99f065f),
PCMCIA_DEVICE_PROD_ID12("RATOC System Inc.", "SCSI2 CARD 37", 0x85c10e17, 0x1a2640c1),
PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "SCSC200A PC CARD SCSI", 0xb4585a1a, 0xa6f06ebe),
PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "SCSC200B PC CARD SCSI-10", 0xb4585a1a, 0x0a88dea0),
/* these conflict with other cards! */
/* PCMCIA_DEVICE_PROD_ID123("MACNICA", "MIRACLE SCSI", "mPS100", 0x20841b68, 0xf8dedaeb, 0x89f7fafb), */
/* PCMCIA_DEVICE_PROD_ID123("MACNICA", "MIRACLE SCSI", "mPS100", 0x20841b68, 0xf8dedaeb, 0x89f7fafb), */
PCMCIA_DEVICE_NULL,
};
MODULE_DEVICE_TABLE(pcmcia, qlogic_ids);
static struct pcmcia_driver qlogic_cs_driver = {
.owner = THIS_MODULE,
.drv = {
.name = "qlogic_cs",
},
.probe = qlogic_probe,
.remove = qlogic_detach,
.id_table = qlogic_ids,
.resume = qlogic_resume,
};
static int __init init_qlogic_cs(void)
{
return pcmcia_register_driver(&qlogic_cs_driver);
}
static void __exit exit_qlogic_cs(void)
{
pcmcia_unregister_driver(&qlogic_cs_driver);
}
MODULE_AUTHOR("Tom Zerucha, Michael Griffith");
MODULE_DESCRIPTION("Driver for the PCMCIA Qlogic FAS SCSI controllers");
MODULE_LICENSE("GPL");
module_init(init_qlogic_cs);
module_exit(exit_qlogic_cs);

View File

@@ -0,0 +1,926 @@
/*
* sym53c500_cs.c Bob Tracy (rct@frus.com)
*
* A rewrite of the pcmcia-cs add-on driver for newer (circa 1997)
* New Media Bus Toaster PCMCIA SCSI cards using the Symbios Logic
* 53c500 controller: intended for use with 2.6 and later kernels.
* The pcmcia-cs add-on version of this driver is not supported
* beyond 2.4. It consisted of three files with history/copyright
* information as follows:
*
* SYM53C500.h
* Bob Tracy (rct@frus.com)
* Original by Tom Corner (tcorner@via.at).
* Adapted from NCR53c406a.h which is Copyrighted (C) 1994
* Normunds Saumanis (normunds@rx.tech.swh.lv)
*
* SYM53C500.c
* Bob Tracy (rct@frus.com)
* Original driver by Tom Corner (tcorner@via.at) was adapted
* from NCR53c406a.c which is Copyrighted (C) 1994, 1995, 1996
* Normunds Saumanis (normunds@fi.ibm.com)
*
* sym53c500.c
* Bob Tracy (rct@frus.com)
* Original by Tom Corner (tcorner@via.at) was adapted from a
* driver for the Qlogic SCSI card written by
* David Hinds (dhinds@allegro.stanford.edu).
*
* 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, 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.
*/
#define SYM53C500_DEBUG 0
#define VERBOSE_SYM53C500_DEBUG 0
/*
* Set this to 0 if you encounter kernel lockups while transferring
* data in PIO mode. Note this can be changed via "sysfs".
*/
#define USE_FAST_PIO 1
/* =============== End of user configurable parameters ============== */
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/ioport.h>
#include <linux/blkdev.h>
#include <linux/spinlock.h>
#include <linux/bitops.h>
#include <asm/io.h>
#include <asm/dma.h>
#include <asm/irq.h>
#include <scsi/scsi_ioctl.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
#include <pcmcia/ciscode.h>
/* ================================================================== */
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version =
"sym53c500_cs.c 0.9c 2004/10/27 (Bob Tracy)";
#else
#define DEBUG(n, args...)
#endif
/* ================================================================== */
#define SYNC_MODE 0 /* Synchronous transfer mode */
/* Default configuration */
#define C1_IMG 0x07 /* ID=7 */
#define C2_IMG 0x48 /* FE SCSI2 */
#define C3_IMG 0x20 /* CDB */
#define C4_IMG 0x04 /* ANE */
#define C5_IMG 0xa4 /* ? changed from b6= AA PI SIE POL */
#define C7_IMG 0x80 /* added for SYM53C500 t. corner */
/* Hardware Registers: offsets from io_port (base) */
/* Control Register Set 0 */
#define TC_LSB 0x00 /* transfer counter lsb */
#define TC_MSB 0x01 /* transfer counter msb */
#define SCSI_FIFO 0x02 /* scsi fifo register */
#define CMD_REG 0x03 /* command register */
#define STAT_REG 0x04 /* status register */
#define DEST_ID 0x04 /* selection/reselection bus id */
#define INT_REG 0x05 /* interrupt status register */
#define SRTIMOUT 0x05 /* select/reselect timeout reg */
#define SEQ_REG 0x06 /* sequence step register */
#define SYNCPRD 0x06 /* synchronous transfer period */
#define FIFO_FLAGS 0x07 /* indicates # of bytes in fifo */
#define SYNCOFF 0x07 /* synchronous offset register */
#define CONFIG1 0x08 /* configuration register */
#define CLKCONV 0x09 /* clock conversion register */
/* #define TESTREG 0x0A */ /* test mode register */
#define CONFIG2 0x0B /* configuration 2 register */
#define CONFIG3 0x0C /* configuration 3 register */
#define CONFIG4 0x0D /* configuration 4 register */
#define TC_HIGH 0x0E /* transfer counter high */
/* #define FIFO_BOTTOM 0x0F */ /* reserve FIFO byte register */
/* Control Register Set 1 */
/* #define JUMPER_SENSE 0x00 */ /* jumper sense port reg (r/w) */
/* #define SRAM_PTR 0x01 */ /* SRAM address pointer reg (r/w) */
/* #define SRAM_DATA 0x02 */ /* SRAM data register (r/w) */
#define PIO_FIFO 0x04 /* PIO FIFO registers (r/w) */
/* #define PIO_FIFO1 0x05 */ /* */
/* #define PIO_FIFO2 0x06 */ /* */
/* #define PIO_FIFO3 0x07 */ /* */
#define PIO_STATUS 0x08 /* PIO status (r/w) */
/* #define ATA_CMD 0x09 */ /* ATA command/status reg (r/w) */
/* #define ATA_ERR 0x0A */ /* ATA features/error reg (r/w) */
#define PIO_FLAG 0x0B /* PIO flag interrupt enable (r/w) */
#define CONFIG5 0x09 /* configuration 5 register */
/* #define SIGNATURE 0x0E */ /* signature register (r) */
/* #define CONFIG6 0x0F */ /* configuration 6 register (r) */
#define CONFIG7 0x0d
/* select register set 0 */
#define REG0(x) (outb(C4_IMG, (x) + CONFIG4))
/* select register set 1 */
#define REG1(x) outb(C7_IMG, (x) + CONFIG7); outb(C5_IMG, (x) + CONFIG5)
#if SYM53C500_DEBUG
#define DEB(x) x
#else
#define DEB(x)
#endif
#if VERBOSE_SYM53C500_DEBUG
#define VDEB(x) x
#else
#define VDEB(x)
#endif
#define LOAD_DMA_COUNT(x, count) \
outb(count & 0xff, (x) + TC_LSB); \
outb((count >> 8) & 0xff, (x) + TC_MSB); \
outb((count >> 16) & 0xff, (x) + TC_HIGH);
/* Chip commands */
#define DMA_OP 0x80
#define SCSI_NOP 0x00
#define FLUSH_FIFO 0x01
#define CHIP_RESET 0x02
#define SCSI_RESET 0x03
#define RESELECT 0x40
#define SELECT_NO_ATN 0x41
#define SELECT_ATN 0x42
#define SELECT_ATN_STOP 0x43
#define ENABLE_SEL 0x44
#define DISABLE_SEL 0x45
#define SELECT_ATN3 0x46
#define RESELECT3 0x47
#define TRANSFER_INFO 0x10
#define INIT_CMD_COMPLETE 0x11
#define MSG_ACCEPT 0x12
#define TRANSFER_PAD 0x18
#define SET_ATN 0x1a
#define RESET_ATN 0x1b
#define SEND_MSG 0x20
#define SEND_STATUS 0x21
#define SEND_DATA 0x22
#define DISCONN_SEQ 0x23
#define TERMINATE_SEQ 0x24
#define TARG_CMD_COMPLETE 0x25
#define DISCONN 0x27
#define RECV_MSG 0x28
#define RECV_CMD 0x29
#define RECV_DATA 0x2a
#define RECV_CMD_SEQ 0x2b
#define TARGET_ABORT_DMA 0x04
/* ================================================================== */
struct scsi_info_t {
struct pcmcia_device *p_dev;
dev_node_t node;
struct Scsi_Host *host;
unsigned short manf_id;
};
/*
* Repository for per-instance host data.
*/
struct sym53c500_data {
struct scsi_cmnd *current_SC;
int fast_pio;
};
enum Phase {
idle,
data_out,
data_in,
command_ph,
status_ph,
message_out,
message_in
};
/* ================================================================== */
static void
chip_init(int io_port)
{
REG1(io_port);
outb(0x01, io_port + PIO_STATUS);
outb(0x00, io_port + PIO_FLAG);
outb(C4_IMG, io_port + CONFIG4); /* REG0(io_port); */
outb(C3_IMG, io_port + CONFIG3);
outb(C2_IMG, io_port + CONFIG2);
outb(C1_IMG, io_port + CONFIG1);
outb(0x05, io_port + CLKCONV); /* clock conversion factor */
outb(0x9C, io_port + SRTIMOUT); /* Selection timeout */
outb(0x05, io_port + SYNCPRD); /* Synchronous transfer period */
outb(SYNC_MODE, io_port + SYNCOFF); /* synchronous mode */
}
static void
SYM53C500_int_host_reset(int io_port)
{
outb(C4_IMG, io_port + CONFIG4); /* REG0(io_port); */
outb(CHIP_RESET, io_port + CMD_REG);
outb(SCSI_NOP, io_port + CMD_REG); /* required after reset */
outb(SCSI_RESET, io_port + CMD_REG);
chip_init(io_port);
}
static __inline__ int
SYM53C500_pio_read(int fast_pio, int base, unsigned char *request, unsigned int reqlen)
{
int i;
int len; /* current scsi fifo size */
REG1(base);
while (reqlen) {
i = inb(base + PIO_STATUS);
/* VDEB(printk("pio_status=%x\n", i)); */
if (i & 0x80)
return 0;
switch (i & 0x1e) {
default:
case 0x10: /* fifo empty */
len = 0;
break;
case 0x0:
len = 1;
break;
case 0x8: /* fifo 1/3 full */
len = 42;
break;
case 0xc: /* fifo 2/3 full */
len = 84;
break;
case 0xe: /* fifo full */
len = 128;
break;
}
if ((i & 0x40) && len == 0) { /* fifo empty and interrupt occurred */
return 0;
}
if (len) {
if (len > reqlen)
len = reqlen;
if (fast_pio && len > 3) {
insl(base + PIO_FIFO, request, len >> 2);
request += len & 0xfc;
reqlen -= len & 0xfc;
} else {
while (len--) {
*request++ = inb(base + PIO_FIFO);
reqlen--;
}
}
}
}
return 0;
}
static __inline__ int
SYM53C500_pio_write(int fast_pio, int base, unsigned char *request, unsigned int reqlen)
{
int i = 0;
int len; /* current scsi fifo size */
REG1(base);
while (reqlen && !(i & 0x40)) {
i = inb(base + PIO_STATUS);
/* VDEB(printk("pio_status=%x\n", i)); */
if (i & 0x80) /* error */
return 0;
switch (i & 0x1e) {
case 0x10:
len = 128;
break;
case 0x0:
len = 84;
break;
case 0x8:
len = 42;
break;
case 0xc:
len = 1;
break;
default:
case 0xe:
len = 0;
break;
}
if (len) {
if (len > reqlen)
len = reqlen;
if (fast_pio && len > 3) {
outsl(base + PIO_FIFO, request, len >> 2);
request += len & 0xfc;
reqlen -= len & 0xfc;
} else {
while (len--) {
outb(*request++, base + PIO_FIFO);
reqlen--;
}
}
}
}
return 0;
}
static irqreturn_t
SYM53C500_intr(int irq, void *dev_id)
{
unsigned long flags;
struct Scsi_Host *dev = dev_id;
DEB(unsigned char fifo_size;)
DEB(unsigned char seq_reg;)
unsigned char status, int_reg;
unsigned char pio_status;
int port_base = dev->io_port;
struct sym53c500_data *data =
(struct sym53c500_data *)dev->hostdata;
struct scsi_cmnd *curSC = data->current_SC;
int fast_pio = data->fast_pio;
spin_lock_irqsave(dev->host_lock, flags);
VDEB(printk("SYM53C500_intr called\n"));
REG1(port_base);
pio_status = inb(port_base + PIO_STATUS);
REG0(port_base);
status = inb(port_base + STAT_REG);
DEB(seq_reg = inb(port_base + SEQ_REG));
int_reg = inb(port_base + INT_REG);
DEB(fifo_size = inb(port_base + FIFO_FLAGS) & 0x1f);
#if SYM53C500_DEBUG
printk("status=%02x, seq_reg=%02x, int_reg=%02x, fifo_size=%02x",
status, seq_reg, int_reg, fifo_size);
printk(", pio=%02x\n", pio_status);
#endif /* SYM53C500_DEBUG */
if (int_reg & 0x80) { /* SCSI reset intr */
DEB(printk("SYM53C500: reset intr received\n"));
curSC->result = DID_RESET << 16;
goto idle_out;
}
if (pio_status & 0x80) {
printk("SYM53C500: Warning: PIO error!\n");
curSC->result = DID_ERROR << 16;
goto idle_out;
}
if (status & 0x20) { /* Parity error */
printk("SYM53C500: Warning: parity error!\n");
curSC->result = DID_PARITY << 16;
goto idle_out;
}
if (status & 0x40) { /* Gross error */
printk("SYM53C500: Warning: gross error!\n");
curSC->result = DID_ERROR << 16;
goto idle_out;
}
if (int_reg & 0x20) { /* Disconnect */
DEB(printk("SYM53C500: disconnect intr received\n"));
if (curSC->SCp.phase != message_in) { /* Unexpected disconnect */
curSC->result = DID_NO_CONNECT << 16;
} else { /* Command complete, return status and message */
curSC->result = (curSC->SCp.Status & 0xff)
| ((curSC->SCp.Message & 0xff) << 8) | (DID_OK << 16);
}
goto idle_out;
}
switch (status & 0x07) { /* scsi phase */
case 0x00: /* DATA-OUT */
if (int_reg & 0x10) { /* Target requesting info transfer */
struct scatterlist *sg;
int i;
curSC->SCp.phase = data_out;
VDEB(printk("SYM53C500: Data-Out phase\n"));
outb(FLUSH_FIFO, port_base + CMD_REG);
LOAD_DMA_COUNT(port_base, scsi_bufflen(curSC)); /* Max transfer size */
outb(TRANSFER_INFO | DMA_OP, port_base + CMD_REG);
scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) {
SYM53C500_pio_write(fast_pio, port_base,
sg_virt(sg), sg->length);
}
REG0(port_base);
}
break;
case 0x01: /* DATA-IN */
if (int_reg & 0x10) { /* Target requesting info transfer */
struct scatterlist *sg;
int i;
curSC->SCp.phase = data_in;
VDEB(printk("SYM53C500: Data-In phase\n"));
outb(FLUSH_FIFO, port_base + CMD_REG);
LOAD_DMA_COUNT(port_base, scsi_bufflen(curSC)); /* Max transfer size */
outb(TRANSFER_INFO | DMA_OP, port_base + CMD_REG);
scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) {
SYM53C500_pio_read(fast_pio, port_base,
sg_virt(sg), sg->length);
}
REG0(port_base);
}
break;
case 0x02: /* COMMAND */
curSC->SCp.phase = command_ph;
printk("SYM53C500: Warning: Unknown interrupt occurred in command phase!\n");
break;
case 0x03: /* STATUS */
curSC->SCp.phase = status_ph;
VDEB(printk("SYM53C500: Status phase\n"));
outb(FLUSH_FIFO, port_base + CMD_REG);
outb(INIT_CMD_COMPLETE, port_base + CMD_REG);
break;
case 0x04: /* Reserved */
case 0x05: /* Reserved */
printk("SYM53C500: WARNING: Reserved phase!!!\n");
break;
case 0x06: /* MESSAGE-OUT */
DEB(printk("SYM53C500: Message-Out phase\n"));
curSC->SCp.phase = message_out;
outb(SET_ATN, port_base + CMD_REG); /* Reject the message */
outb(MSG_ACCEPT, port_base + CMD_REG);
break;
case 0x07: /* MESSAGE-IN */
VDEB(printk("SYM53C500: Message-In phase\n"));
curSC->SCp.phase = message_in;
curSC->SCp.Status = inb(port_base + SCSI_FIFO);
curSC->SCp.Message = inb(port_base + SCSI_FIFO);
VDEB(printk("SCSI FIFO size=%d\n", inb(port_base + FIFO_FLAGS) & 0x1f));
DEB(printk("Status = %02x Message = %02x\n", curSC->SCp.Status, curSC->SCp.Message));
if (curSC->SCp.Message == SAVE_POINTERS || curSC->SCp.Message == DISCONNECT) {
outb(SET_ATN, port_base + CMD_REG); /* Reject message */
DEB(printk("Discarding SAVE_POINTERS message\n"));
}
outb(MSG_ACCEPT, port_base + CMD_REG);
break;
}
out:
spin_unlock_irqrestore(dev->host_lock, flags);
return IRQ_HANDLED;
idle_out:
curSC->SCp.phase = idle;
curSC->scsi_done(curSC);
goto out;
}
static void
SYM53C500_release(struct pcmcia_device *link)
{
struct scsi_info_t *info = link->priv;
struct Scsi_Host *shost = info->host;
DEBUG(0, "SYM53C500_release(0x%p)\n", link);
/*
* Do this before releasing/freeing resources.
*/
scsi_remove_host(shost);
/*
* Interrupts getting hosed on card removal. Try
* the following code, mostly from qlogicfas.c.
*/
if (shost->irq)
free_irq(shost->irq, shost);
if (shost->io_port && shost->n_io_port)
release_region(shost->io_port, shost->n_io_port);
pcmcia_disable_device(link);
scsi_host_put(shost);
} /* SYM53C500_release */
static const char*
SYM53C500_info(struct Scsi_Host *SChost)
{
static char info_msg[256];
struct sym53c500_data *data =
(struct sym53c500_data *)SChost->hostdata;
DEB(printk("SYM53C500_info called\n"));
(void)snprintf(info_msg, sizeof(info_msg),
"SYM53C500 at 0x%lx, IRQ %d, %s PIO mode.",
SChost->io_port, SChost->irq, data->fast_pio ? "fast" : "slow");
return (info_msg);
}
static int
SYM53C500_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
{
int i;
int port_base = SCpnt->device->host->io_port;
struct sym53c500_data *data =
(struct sym53c500_data *)SCpnt->device->host->hostdata;
VDEB(printk("SYM53C500_queue called\n"));
DEB(printk("cmd=%02x, cmd_len=%02x, target=%02x, lun=%02x, bufflen=%d\n",
SCpnt->cmnd[0], SCpnt->cmd_len, SCpnt->device->id,
SCpnt->device->lun, scsi_bufflen(SCpnt)));
VDEB(for (i = 0; i < SCpnt->cmd_len; i++)
printk("cmd[%d]=%02x ", i, SCpnt->cmnd[i]));
VDEB(printk("\n"));
data->current_SC = SCpnt;
data->current_SC->scsi_done = done;
data->current_SC->SCp.phase = command_ph;
data->current_SC->SCp.Status = 0;
data->current_SC->SCp.Message = 0;
/* We are locked here already by the mid layer */
REG0(port_base);
outb(scmd_id(SCpnt), port_base + DEST_ID); /* set destination */
outb(FLUSH_FIFO, port_base + CMD_REG); /* reset the fifos */
for (i = 0; i < SCpnt->cmd_len; i++) {
outb(SCpnt->cmnd[i], port_base + SCSI_FIFO);
}
outb(SELECT_NO_ATN, port_base + CMD_REG);
return 0;
}
static int
SYM53C500_host_reset(struct scsi_cmnd *SCpnt)
{
int port_base = SCpnt->device->host->io_port;
DEB(printk("SYM53C500_host_reset called\n"));
spin_lock_irq(SCpnt->device->host->host_lock);
SYM53C500_int_host_reset(port_base);
spin_unlock_irq(SCpnt->device->host->host_lock);
return SUCCESS;
}
static int
SYM53C500_biosparm(struct scsi_device *disk,
struct block_device *dev,
sector_t capacity, int *info_array)
{
int size;
DEB(printk("SYM53C500_biosparm called\n"));
size = capacity;
info_array[0] = 64; /* heads */
info_array[1] = 32; /* sectors */
info_array[2] = size >> 11; /* cylinders */
if (info_array[2] > 1024) { /* big disk */
info_array[0] = 255;
info_array[1] = 63;
info_array[2] = size / (255 * 63);
}
return 0;
}
static ssize_t
SYM53C500_show_pio(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *SHp = class_to_shost(dev);
struct sym53c500_data *data =
(struct sym53c500_data *)SHp->hostdata;
return snprintf(buf, 4, "%d\n", data->fast_pio);
}
static ssize_t
SYM53C500_store_pio(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int pio;
struct Scsi_Host *SHp = class_to_shost(dev);
struct sym53c500_data *data =
(struct sym53c500_data *)SHp->hostdata;
pio = simple_strtoul(buf, NULL, 0);
if (pio == 0 || pio == 1) {
data->fast_pio = pio;
return count;
}
else
return -EINVAL;
}
/*
* SCSI HBA device attributes we want to
* make available via sysfs.
*/
static struct device_attribute SYM53C500_pio_attr = {
.attr = {
.name = "fast_pio",
.mode = (S_IRUGO | S_IWUSR),
},
.show = SYM53C500_show_pio,
.store = SYM53C500_store_pio,
};
static struct device_attribute *SYM53C500_shost_attrs[] = {
&SYM53C500_pio_attr,
NULL,
};
/*
* scsi_host_template initializer
*/
static struct scsi_host_template sym53c500_driver_template = {
.module = THIS_MODULE,
.name = "SYM53C500",
.info = SYM53C500_info,
.queuecommand = SYM53C500_queue,
.eh_host_reset_handler = SYM53C500_host_reset,
.bios_param = SYM53C500_biosparm,
.proc_name = "SYM53C500",
.can_queue = 1,
.this_id = 7,
.sg_tablesize = 32,
.cmd_per_lun = 1,
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = SYM53C500_shost_attrs
};
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
static int SYM53C500_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
p_dev->io.BasePort1 = cfg->io.win[0].base;
p_dev->io.NumPorts1 = cfg->io.win[0].len;
if (p_dev->io.BasePort1 == 0)
return -ENODEV;
return pcmcia_request_io(p_dev, &p_dev->io);
}
static int
SYM53C500_config(struct pcmcia_device *link)
{
struct scsi_info_t *info = link->priv;
int last_ret, last_fn;
int irq_level, port_base;
struct Scsi_Host *host;
struct scsi_host_template *tpnt = &sym53c500_driver_template;
struct sym53c500_data *data;
DEBUG(0, "SYM53C500_config(0x%p)\n", link);
info->manf_id = link->manf_id;
last_ret = pcmcia_loop_config(link, SYM53C500_config_check, NULL);
if (last_ret) {
cs_error(link, RequestIO, last_ret);
goto failed;
}
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
/*
* That's the trouble with copying liberally from another driver.
* Some things probably aren't relevant, and I suspect this entire
* section dealing with manufacturer IDs can be scrapped. --rct
*/
if ((info->manf_id == MANFID_MACNICA) ||
(info->manf_id == MANFID_PIONEER) ||
(info->manf_id == 0x0098)) {
/* set ATAcmd */
outb(0xb4, link->io.BasePort1 + 0xd);
outb(0x24, link->io.BasePort1 + 0x9);
outb(0x04, link->io.BasePort1 + 0xd);
}
/*
* irq_level == 0 implies tpnt->can_queue == 0, which
* is not supported in 2.6. Thus, only irq_level > 0
* will be allowed.
*
* Possible port_base values are as follows:
*
* 0x130, 0x230, 0x280, 0x290,
* 0x320, 0x330, 0x340, 0x350
*/
port_base = link->io.BasePort1;
irq_level = link->irq.AssignedIRQ;
DEB(printk("SYM53C500: port_base=0x%x, irq=%d, fast_pio=%d\n",
port_base, irq_level, USE_FAST_PIO);)
chip_init(port_base);
host = scsi_host_alloc(tpnt, sizeof(struct sym53c500_data));
if (!host) {
printk("SYM53C500: Unable to register host, giving up.\n");
goto err_release;
}
data = (struct sym53c500_data *)host->hostdata;
if (irq_level > 0) {
if (request_irq(irq_level, SYM53C500_intr, IRQF_SHARED, "SYM53C500", host)) {
printk("SYM53C500: unable to allocate IRQ %d\n", irq_level);
goto err_free_scsi;
}
DEB(printk("SYM53C500: allocated IRQ %d\n", irq_level));
} else if (irq_level == 0) {
DEB(printk("SYM53C500: No interrupts detected\n"));
goto err_free_scsi;
} else {
DEB(printk("SYM53C500: Shouldn't get here!\n"));
goto err_free_scsi;
}
host->unique_id = port_base;
host->irq = irq_level;
host->io_port = port_base;
host->n_io_port = 0x10;
host->dma_channel = -1;
/*
* Note fast_pio is set to USE_FAST_PIO by
* default, but can be changed via "sysfs".
*/
data->fast_pio = USE_FAST_PIO;
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev_node = &info->node;
info->host = host;
if (scsi_add_host(host, NULL))
goto err_free_irq;
scsi_scan_host(host);
return 0;
err_free_irq:
free_irq(irq_level, host);
err_free_scsi:
scsi_host_put(host);
err_release:
release_region(port_base, 0x10);
printk(KERN_INFO "sym53c500_cs: no SCSI devices found\n");
return -ENODEV;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
SYM53C500_release(link);
return -ENODEV;
} /* SYM53C500_config */
static int sym53c500_resume(struct pcmcia_device *link)
{
struct scsi_info_t *info = link->priv;
/* See earlier comment about manufacturer IDs. */
if ((info->manf_id == MANFID_MACNICA) ||
(info->manf_id == MANFID_PIONEER) ||
(info->manf_id == 0x0098)) {
outb(0x80, link->io.BasePort1 + 0xd);
outb(0x24, link->io.BasePort1 + 0x9);
outb(0x04, link->io.BasePort1 + 0xd);
}
/*
* If things don't work after a "resume",
* this is a good place to start looking.
*/
SYM53C500_int_host_reset(link->io.BasePort1);
return 0;
}
static void
SYM53C500_detach(struct pcmcia_device *link)
{
DEBUG(0, "SYM53C500_detach(0x%p)\n", link);
SYM53C500_release(link);
kfree(link->priv);
link->priv = NULL;
} /* SYM53C500_detach */
static int
SYM53C500_probe(struct pcmcia_device *link)
{
struct scsi_info_t *info;
DEBUG(0, "SYM53C500_attach()\n");
/* Create new SCSI device */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
info->p_dev = link;
link->priv = info;
link->io.NumPorts1 = 16;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
link->io.IOAddrLines = 10;
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
link->irq.IRQInfo1 = IRQ_LEVEL_ID;
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;
return SYM53C500_config(link);
} /* SYM53C500_attach */
MODULE_AUTHOR("Bob Tracy <rct@frus.com>");
MODULE_DESCRIPTION("SYM53C500 PCMCIA SCSI driver");
MODULE_LICENSE("GPL");
static struct pcmcia_device_id sym53c500_ids[] = {
PCMCIA_DEVICE_PROD_ID12("BASICS by New Media Corporation", "SCSI Sym53C500", 0x23c78a9d, 0x0099e7f7),
PCMCIA_DEVICE_PROD_ID12("New Media Corporation", "SCSI Bus Toaster Sym53C500", 0x085a850b, 0x45432eb8),
PCMCIA_DEVICE_PROD_ID2("SCSI9000", 0x21648f44),
PCMCIA_DEVICE_NULL,
};
MODULE_DEVICE_TABLE(pcmcia, sym53c500_ids);
static struct pcmcia_driver sym53c500_cs_driver = {
.owner = THIS_MODULE,
.drv = {
.name = "sym53c500_cs",
},
.probe = SYM53C500_probe,
.remove = SYM53C500_detach,
.id_table = sym53c500_ids,
.resume = sym53c500_resume,
};
static int __init
init_sym53c500_cs(void)
{
return pcmcia_register_driver(&sym53c500_cs_driver);
}
static void __exit
exit_sym53c500_cs(void)
{
pcmcia_unregister_driver(&sym53c500_cs_driver);
}
module_init(init_sym53c500_cs);
module_exit(exit_sym53c500_cs);