Commit e0029ad1 authored by Russell King's avatar Russell King

[ARM] Finally kill old ecard device discovery interfaces.

This cset kills the old racy ecard device discovery interfaces,
converting the remaining drivers to use the new LDM-based
interface.
parent 8d2c59fd
...@@ -989,42 +989,6 @@ ecard_probe(int slot, card_type_t type) ...@@ -989,42 +989,6 @@ ecard_probe(int slot, card_type_t type)
return rc; return rc;
} }
static ecard_t *finding_pos;
void ecard_startfind(void)
{
finding_pos = NULL;
}
ecard_t *ecard_find(int cid, const card_ids *cids)
{
if (!finding_pos)
finding_pos = cards;
else
finding_pos = finding_pos->next;
for (; finding_pos; finding_pos = finding_pos->next) {
if (finding_pos->claimed)
continue;
if (finding_pos->dev.driver)
continue;
if (!cids) {
if ((finding_pos->cid.id ^ cid) == 0)
break;
} else {
const struct ecard_id *id;
id = ecard_match_device(cids, finding_pos);
if (id)
break;
}
}
return finding_pos;
}
/* /*
* Initialise the expansion card system. * Initialise the expansion card system.
* Locate all hardware - interrupt management and * Locate all hardware - interrupt management and
...@@ -1087,10 +1051,15 @@ static int ecard_drv_probe(struct device *dev) ...@@ -1087,10 +1051,15 @@ static int ecard_drv_probe(struct device *dev)
struct expansion_card *ec = ECARD_DEV(dev); struct expansion_card *ec = ECARD_DEV(dev);
struct ecard_driver *drv = ECARD_DRV(dev->driver); struct ecard_driver *drv = ECARD_DRV(dev->driver);
const struct ecard_id *id; const struct ecard_id *id;
int ret;
id = ecard_match_device(drv->id_table, ec); id = ecard_match_device(drv->id_table, ec);
return drv->probe(ec, id); ecard_claim(ec);
ret = drv->probe(ec, id);
if (ret)
ecard_release(ec);
return ret;
} }
static int ecard_drv_remove(struct device *dev) static int ecard_drv_remove(struct device *dev)
...@@ -1099,6 +1068,7 @@ static int ecard_drv_remove(struct device *dev) ...@@ -1099,6 +1068,7 @@ static int ecard_drv_remove(struct device *dev)
struct ecard_driver *drv = ECARD_DRV(dev->driver); struct ecard_driver *drv = ECARD_DRV(dev->driver);
drv->remove(ec); drv->remove(ec);
ecard_release(ec);
return 0; return 0;
} }
...@@ -1144,12 +1114,8 @@ static int ecard_bus_init(void) ...@@ -1144,12 +1114,8 @@ static int ecard_bus_init(void)
postcore_initcall(ecard_bus_init); postcore_initcall(ecard_bus_init);
EXPORT_SYMBOL(ecard_startfind);
EXPORT_SYMBOL(ecard_find);
EXPORT_SYMBOL(ecard_readchunk); EXPORT_SYMBOL(ecard_readchunk);
EXPORT_SYMBOL(ecard_address); EXPORT_SYMBOL(ecard_address);
EXPORT_SYMBOL(ecard_register_driver); EXPORT_SYMBOL(ecard_register_driver);
EXPORT_SYMBOL(ecard_remove_driver); EXPORT_SYMBOL(ecard_remove_driver);
EXPORT_SYMBOL(ecard_bus_type); EXPORT_SYMBOL(ecard_bus_type);
...@@ -160,13 +160,6 @@ struct hd_geometry { ...@@ -160,13 +160,6 @@ struct hd_geometry {
#ifndef DEBUG #ifndef DEBUG
/*#define DEBUG */ /*#define DEBUG */
#endif #endif
/*
* List of card types that we recognise
*/
static const card_ids mfm_cids[] = {
{ MANU_ACORN, PROD_ACORN_MFM },
{ 0xffff, 0xffff }
};
/* /*
* End of configuration * End of configuration
*/ */
...@@ -1230,8 +1223,6 @@ static struct block_device_operations mfm_fops = ...@@ -1230,8 +1223,6 @@ static struct block_device_operations mfm_fops =
.ioctl = mfm_ioctl, .ioctl = mfm_ioctl,
}; };
static struct expansion_card *ecs;
/* /*
* See if there is a controller at the address presently at mfm_addr * See if there is a controller at the address presently at mfm_addr
* *
...@@ -1266,44 +1257,18 @@ static int mfm_probecontroller (unsigned int mfm_addr) ...@@ -1266,44 +1257,18 @@ static int mfm_probecontroller (unsigned int mfm_addr)
return 1; return 1;
} }
/* static int mfm_do_init(unsigned char irqmask)
* Look for a MFM controller - first check the motherboard, then the podules
* The podules have an extra interrupt enable that needs to be played with
*
* The HDC is accessed at MEDIUM IOC speeds.
*/
static int __init mfm_init (void)
{ {
unsigned char irqmask; int i, ret;
int i;
if (mfm_probecontroller(ONBOARD_MFM_ADDRESS)) {
mfm_addr = ONBOARD_MFM_ADDRESS;
mfm_IRQPollLoc = IOC_IRQSTATB;
mfm_irqenable = 0;
mfm_irq = IRQ_HARDDISK;
irqmask = 0x08; /* IL3 pin */
} else {
ecs = ecard_find(0, mfm_cids);
if (!ecs) {
mfm_addr = 0;
return -1;
}
mfm_addr = ecard_address(ecs, ECARD_IOC, ECARD_MEDIUM) + 0x800;
mfm_IRQPollLoc = ioaddr(mfm_addr + 0x400);
mfm_irqenable = mfm_IRQPollLoc;
mfm_irq = ecs->irq;
irqmask = 0x08;
ecard_claim(ecs);
}
printk("mfm: found at address %08X, interrupt %d\n", mfm_addr, mfm_irq); printk("mfm: found at address %08X, interrupt %d\n", mfm_addr, mfm_irq);
ret = -EBUSY;
if (!request_region (mfm_addr, 10, "mfm")) if (!request_region (mfm_addr, 10, "mfm"))
goto out1; goto out1;
if (register_blkdev(MAJOR_NR, "mfm", &mfm_fops)) { ret = register_blkdev(MAJOR_NR, "mfm", &mfm_fops);
if (ret) {
printk("mfm_init: unable to get major number %d\n", MAJOR_NR); printk("mfm_init: unable to get major number %d\n", MAJOR_NR);
goto out2; goto out2;
} }
...@@ -1319,8 +1284,10 @@ static int __init mfm_init (void) ...@@ -1319,8 +1284,10 @@ static int __init mfm_init (void)
lastspecifieddrive = -1; lastspecifieddrive = -1;
mfm_drives = mfm_initdrives(); mfm_drives = mfm_initdrives();
if (!mfm_drives) if (!mfm_drives) {
ret = -ENODEV;
goto out3; goto out3;
}
for (i = 0; i < mfm_drives; i++) { for (i = 0; i < mfm_drives; i++) {
struct gendisk *disk = alloc_disk(64); struct gendisk *disk = alloc_disk(64);
...@@ -1335,7 +1302,8 @@ static int __init mfm_init (void) ...@@ -1335,7 +1302,8 @@ static int __init mfm_init (void)
printk("mfm: detected %d hard drive%s\n", mfm_drives, printk("mfm: detected %d hard drive%s\n", mfm_drives,
mfm_drives == 1 ? "" : "s"); mfm_drives == 1 ? "" : "s");
if (request_irq(mfm_irq, mfm_interrupt_handler, SA_INTERRUPT, "MFM harddisk", NULL)) { ret = request_irq(mfm_irq, mfm_interrupt_handler, SA_INTERRUPT, "MFM harddisk", NULL);
if (ret) {
printk("mfm: unable to get IRQ%d\n", mfm_irq); printk("mfm: unable to get IRQ%d\n", mfm_irq);
goto out4; goto out4;
} }
...@@ -1359,19 +1327,17 @@ static int __init mfm_init (void) ...@@ -1359,19 +1327,17 @@ static int __init mfm_init (void)
out2: out2:
release_region(mfm_addr, 10); release_region(mfm_addr, 10);
out1: out1:
ecard_release(ecs); return ret;
return -1;
Enomem: Enomem:
while (i--) while (i--)
put_disk(mfm_gendisk[i]); put_disk(mfm_gendisk[i]);
goto out3; goto out3;
} }
static void __exit mfm_exit(void) static void mfm_do_exit(void)
{ {
int i; int i;
if (ecs && mfm_irqenable)
outw (0, mfm_irqenable); /* Required to enable IRQs from MFM podule */
free_irq(mfm_irq, NULL); free_irq(mfm_irq, NULL);
for (i = 0; i < mfm_drives; i++) { for (i = 0; i < mfm_drives; i++) {
del_gendisk(mfm_gendisk[i]); del_gendisk(mfm_gendisk[i]);
...@@ -1379,12 +1345,72 @@ static void __exit mfm_exit(void) ...@@ -1379,12 +1345,72 @@ static void __exit mfm_exit(void)
} }
blk_cleanup_queue(&mfm_queue); blk_cleanup_queue(&mfm_queue);
unregister_blkdev(MAJOR_NR, "mfm"); unregister_blkdev(MAJOR_NR, "mfm");
if (ecs)
ecard_release(ecs);
if (mfm_addr) if (mfm_addr)
release_region(mfm_addr, 10); release_region(mfm_addr, 10);
} }
static int __devinit mfm_probe(struct expansion_card *ec, struct ecard_id *id)
{
if (mfm_addr)
return -EBUSY;
mfm_addr = ecard_address(ec, ECARD_IOC, ECARD_MEDIUM) + 0x800;
mfm_IRQPollLoc = ioaddr(mfm_addr + 0x400);
mfm_irqenable = mfm_IRQPollLoc;
mfm_irq = ec->irq;
return mfm_do_init(0x08);
}
static void __devexit mfm_remove(struct expansion_card *ec)
{
outw (0, mfm_irqenable); /* Required to enable IRQs from MFM podule */
mfm_do_exit();
}
static const struct ecard_id mfm_cids[] = {
{ MANU_ACORN, PROD_ACORN_MFM },
{ 0xffff, 0xffff },
};
static struct ecard_driver mfm_driver = {
.probe = mfm_probe,
.remove = __devexit(mfm_remove),
.id_table = mfm_cids,
.drv = {
.name = "mfm",
},
};
/*
* Look for a MFM controller - first check the motherboard, then the podules
* The podules have an extra interrupt enable that needs to be played with
*
* The HDC is accessed at MEDIUM IOC speeds.
*/
static int __init mfm_init (void)
{
unsigned char irqmask;
if (mfm_probecontroller(ONBOARD_MFM_ADDRESS)) {
mfm_addr = ONBOARD_MFM_ADDRESS;
mfm_IRQPollLoc = IOC_IRQSTATB;
mfm_irqenable = 0;
mfm_irq = IRQ_HARDDISK;
return mfm_do_init(0x08); /* IL3 pin */
} else {
return ecard_register_driver(&mfm_driver);
}
}
static void __exit mfm_exit(void)
{
if (mfm_addr == ONBOARD_MFM_ADDRESS)
mfm_do_exit();
else
ecard_unregister_driver(&mfm_driver);
}
module_init(mfm_init) module_init(mfm_init)
module_exit(mfm_exit) module_exit(mfm_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -1021,8 +1021,6 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1021,8 +1021,6 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
ether1_banner(); ether1_banner();
ecard_claim(ec);
dev = init_etherdev(NULL, sizeof(struct ether1_priv)); dev = init_etherdev(NULL, sizeof(struct ether1_priv));
if (!dev) { if (!dev) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -1077,7 +1075,6 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1077,7 +1075,6 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
unregister_netdev(dev); unregister_netdev(dev);
kfree(dev); kfree(dev);
out: out:
ecard_release(ec);
return ret; return ret;
} }
...@@ -1092,8 +1089,6 @@ static void __devexit ether1_remove(struct expansion_card *ec) ...@@ -1092,8 +1089,6 @@ static void __devexit ether1_remove(struct expansion_card *ec)
release_region(dev->base_addr, 16); release_region(dev->base_addr, 16);
release_region(dev->base_addr + 0x800, 4096); release_region(dev->base_addr + 0x800, 4096);
kfree(dev); kfree(dev);
ecard_release(ec);
} }
static const struct ecard_id ether1_ids[] = { static const struct ecard_id ether1_ids[] = {
......
...@@ -830,8 +830,6 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -830,8 +830,6 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
ether3_banner(); ether3_banner();
ecard_claim(ec);
dev = init_etherdev(NULL, sizeof(struct dev_priv)); dev = init_etherdev(NULL, sizeof(struct dev_priv));
if (!dev) { if (!dev) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -917,7 +915,6 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -917,7 +915,6 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
unregister_netdev(dev); unregister_netdev(dev);
kfree(dev); kfree(dev);
out: out:
ecard_release(ec);
return ret; return ret;
} }
...@@ -930,8 +927,6 @@ static void __devexit ether3_remove(struct expansion_card *ec) ...@@ -930,8 +927,6 @@ static void __devexit ether3_remove(struct expansion_card *ec)
unregister_netdev(dev); unregister_netdev(dev);
release_region(dev->base_addr, 128); release_region(dev->base_addr, 128);
kfree(dev); kfree(dev);
ecard_release(ec);
} }
static const struct ecard_id ether3_ids[] = { static const struct ecard_id ether3_ids[] = {
......
...@@ -568,8 +568,6 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -568,8 +568,6 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
etherh_banner(); etherh_banner();
ecard_claim(ec);
dev = init_etherdev(NULL, sizeof(struct etherh_priv)); dev = init_etherdev(NULL, sizeof(struct etherh_priv));
if (!dev) { if (!dev) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -725,7 +723,6 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -725,7 +723,6 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
kfree(dev->priv); kfree(dev->priv);
kfree(dev); kfree(dev);
out: out:
ecard_release(ec);
return ret; return ret;
} }
...@@ -744,7 +741,6 @@ static void __devexit etherh_remove(struct expansion_card *ec) ...@@ -744,7 +741,6 @@ static void __devexit etherh_remove(struct expansion_card *ec)
ec->ops = NULL; ec->ops = NULL;
kfree(ec->irq_data); kfree(ec->irq_data);
ecard_release(ec);
} }
static const struct ecard_id etherh_ids[] = { static const struct ecard_id etherh_ids[] = {
......
...@@ -109,10 +109,7 @@ ...@@ -109,10 +109,7 @@
* If not set, then use PIO mode (not currently supported). * If not set, then use PIO mode (not currently supported).
*/ */
#define USE_DMAC #define USE_DMAC
/*
* List of devices that the driver will recognise
*/
#define ACORNSCSI_LIST { MANU_ACORN, PROD_ACORN_SCSI }
/* /*
* ==================================================================================== * ====================================================================================
*/ */
...@@ -2832,148 +2829,6 @@ int acornscsi_reset(Scsi_Cmnd *SCpnt, unsigned int reset_flags) ...@@ -2832,148 +2829,6 @@ int acornscsi_reset(Scsi_Cmnd *SCpnt, unsigned int reset_flags)
/*============================================================================================== /*==============================================================================================
* initialisation & miscellaneous support * initialisation & miscellaneous support
*/ */
static struct expansion_card *ecs[MAX_ECARDS];
/*
* Prototype: void acornscsi_init(AS_Host *host)
* Purpose : initialise the AS_Host structure for one interface & setup hardware
* Params : host - host to setup
*/
static
void acornscsi_host_init(AS_Host *host)
{
memset(&host->stats, 0, sizeof (host->stats));
queue_initialise(&host->queues.issue);
queue_initialise(&host->queues.disconnected);
msgqueue_initialise(&host->scsi.msgs);
acornscsi_resetcard(host);
}
int acornscsi_detect(Scsi_Host_Template * tpnt)
{
static const card_ids acornscsi_cids[] = { ACORNSCSI_LIST, { 0xffff, 0xffff } };
int i, count = 0;
struct Scsi_Host *instance;
AS_Host *host;
tpnt->proc_name = "acornscsi";
for (i = 0; i < MAX_ECARDS; i++)
ecs[i] = NULL;
ecard_startfind();
while(1) {
ecs[count] = ecard_find(0, acornscsi_cids);
if (!ecs[count])
break;
if (ecs[count]->irq == 0xff) {
printk("scsi: WD33C93 does not have IRQ enabled - ignoring\n");
continue;
}
ecard_claim(ecs[count]); /* Must claim here - card produces irq on reset */
instance = scsi_register(tpnt, sizeof(AS_Host));
if (!instance) {
ecard_release(ecs[count]);
break;
}
host = (AS_Host *)instance->hostdata;
instance->io_port = ecard_address(ecs[count], ECARD_MEMC, 0);
instance->irq = ecs[count]->irq;
host->host = instance;
host->scsi.io_port = ioaddr(instance->io_port + 0x800);
host->scsi.irq = instance->irq;
host->card.io_intr = POD_SPACE(instance->io_port) + 0x800;
host->card.io_page = POD_SPACE(instance->io_port) + 0xc00;
host->card.io_ram = ioaddr(instance->io_port);
host->dma.io_port = instance->io_port + 0xc00;
host->dma.io_intr_clear = POD_SPACE(instance->io_port) + 0x800;
ecs[count]->irqaddr = (char *)ioaddr(host->card.io_intr);
ecs[count]->irqmask = 0x0a;
if (!request_region(instance->io_port + 0x800, 2, "acornscsi(sbic)"))
goto err_1;
if (!request_region(host->card.io_intr, 1, "acornscsi(intr)"))
goto err_2;
if (!request_region(host->card.io_page, 1, "acornscsi(page)"))
goto err_3;
#ifdef USE_DMAC
if (!request_region(host->dma.io_port, 256, "acornscsi(dmac)"))
goto err_4;
#endif
if (!request_region(instance->io_port, 2048, "acornscsi(ram)"))
goto err_5;
if (request_irq(host->scsi.irq, acornscsi_intr, SA_INTERRUPT, "acornscsi", host)) {
printk(KERN_CRIT "scsi%d: IRQ%d not free, interrupts disabled\n",
instance->host_no, host->scsi.irq);
host->scsi.irq = NO_IRQ;
}
acornscsi_host_init(host);
++count;
}
return count;
err_5:
#ifdef USE_DMAC
release_region(host->dma.io_port, 256);
#endif
err_4:
release_region(host->card.io_page, 1);
err_3:
release_region(host->card.io_intr, 1);
err_2:
release_region(instance->io_port + 0x800, 2);
err_1:
scsi_unregister(instance);
return 0;
}
/*
* Function: int acornscsi_release(struct Scsi_Host *host)
* Purpose : release all resources used by this adapter
* Params : host - driver structure to release
* Returns : nothing of any consequence
*/
int acornscsi_release(struct Scsi_Host *instance)
{
AS_Host *host = (AS_Host *)instance->hostdata;
int i;
/*
* Put card into RESET state
*/
outb(0x80, host->card.io_page);
if (host->scsi.irq != NO_IRQ)
free_irq(host->scsi.irq, host);
release_region(instance->io_port + 0x800, 2);
release_region(host->card.io_intr, 1);
release_region(host->card.io_page, 1);
release_region(host->dma.io_port, 256);
release_region(instance->io_port, 2048);
for (i = 0; i < MAX_ECARDS; i++)
if (ecs[i] && instance->io_port == ecard_address(ecs[i], ECARD_MEMC, 0))
ecard_release(ecs[i]);
msgqueue_free(&host->scsi.msgs);
queue_free(&host->queues.disconnected);
queue_free(&host->queues.issue);
return 0;
}
/* /*
* Function: char *acornscsi_info(struct Scsi_Host *host) * Function: char *acornscsi_info(struct Scsi_Host *host)
...@@ -3126,10 +2981,9 @@ static Scsi_Host_Template acornscsi_template = { ...@@ -3126,10 +2981,9 @@ static Scsi_Host_Template acornscsi_template = {
.module = THIS_MODULE, .module = THIS_MODULE,
.proc_info = acornscsi_proc_info, .proc_info = acornscsi_proc_info,
.name = "AcornSCSI", .name = "AcornSCSI",
.detect = acornscsi_detect,
.release = acornscsi_release,
.info = acornscsi_info, .info = acornscsi_info,
.queuecommand = acornscsi_queuecmd, .queuecommand = acornscsi_queuecmd,
#warning fixme
.abort = acornscsi_abort, .abort = acornscsi_abort,
.reset = acornscsi_reset, .reset = acornscsi_reset,
.can_queue = 16, .can_queue = 16,
...@@ -3137,22 +2991,137 @@ static Scsi_Host_Template acornscsi_template = { ...@@ -3137,22 +2991,137 @@ static Scsi_Host_Template acornscsi_template = {
.sg_tablesize = SG_ALL, .sg_tablesize = SG_ALL,
.cmd_per_lun = 2, .cmd_per_lun = 2,
.unchecked_isa_dma = 0, .unchecked_isa_dma = 0,
.use_clustering = DISABLE_CLUSTERING .use_clustering = DISABLE_CLUSTERING,
.proc_name = "acornscsi",
}; };
static int __init acornscsi_init(void) static int __devinit
acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
{ {
scsi_register_host(&acornscsi_template); struct Scsi_Host *host;
if (acornscsi_template.present) AS_Host *ashost;
return 0; int ret = -ENOMEM;
host = scsi_register(&acornscsi_template, sizeof(AS_Host));
if (!host)
goto out;
ashost = (AS_Host *)host->hostdata;
host->io_port = ecard_address(ec, ECARD_MEMC, 0);
host->irq = ec->irq;
ashost->host = host;
ashost->scsi.io_port = ioaddr(host->io_port + 0x800);
ashost->scsi.irq = host->irq;
ashost->card.io_intr = POD_SPACE(host->io_port) + 0x800;
ashost->card.io_page = POD_SPACE(host->io_port) + 0xc00;
ashost->card.io_ram = ioaddr(host->io_port);
ashost->dma.io_port = host->io_port + 0xc00;
ashost->dma.io_intr_clear = POD_SPACE(host->io_port) + 0x800;
ec->irqaddr = (char *)ioaddr(ashost->card.io_intr);
ec->irqmask = 0x0a;
ret = -EBUSY;
if (!request_region(host->io_port + 0x800, 2, "acornscsi(sbic)"))
goto err_1;
if (!request_region(ashost->card.io_intr, 1, "acornscsi(intr)"))
goto err_2;
if (!request_region(ashost->card.io_page, 1, "acornscsi(page)"))
goto err_3;
#ifdef USE_DMAC
if (!request_region(ashost->dma.io_port, 256, "acornscsi(dmac)"))
goto err_4;
#endif
if (!request_region(host->io_port, 2048, "acornscsi(ram)"))
goto err_5;
scsi_unregister_host(&acornscsi_template); ret = request_irq(host->irq, acornscsi_intr, SA_INTERRUPT, "acornscsi", ashost);
return -ENODEV; if (ret) {
printk(KERN_CRIT "scsi%d: IRQ%d not free: %d\n",
host->host_no, ashost->scsi.irq, ret);
goto err_6;
}
memset(&ashost->stats, 0, sizeof (ashost->stats));
queue_initialise(&ashost->queues.issue);
queue_initialise(&ashost->queues.disconnected);
msgqueue_initialise(&ashost->scsi.msgs);
acornscsi_resetcard(ashost);
ret = scsi_add_host(host);
if (ret == 0)
goto out;
free_irq(host->irq, ashost);
err_6:
release_region(host->io_port, 2048);
err_5:
#ifdef USE_DMAC
release_region(ashost->dma.io_port, 256);
#endif
err_4:
release_region(ashost->card.io_page, 1);
err_3:
release_region(ashost->card.io_intr, 1);
err_2:
release_region(host->io_port + 0x800, 2);
err_1:
scsi_unregister(host);
out:
return ret;
}
static void __devexit acornscsi_remove(struct expansion_card *ec)
{
struct Scsi_Host *host = ecard_get_drvdata(ec);
AS_Host *ashost = (AS_Host *)host->hostdata;
ecard_set_drvdata(ec, NULL);
scsi_remove_host(host);
/*
* Put card into RESET state
*/
outb(0x80, ashost->card.io_page);
free_irq(host->irq, ashost);
release_region(host->io_port + 0x800, 2);
release_region(ashost->card.io_intr, 1);
release_region(ashost->card.io_page, 1);
release_region(ashost->dma.io_port, 256);
release_region(host->io_port, 2048);
msgqueue_free(&ashost->scsi.msgs);
queue_free(&ashost->queues.disconnected);
queue_free(&ashost->queues.issue);
}
static const struct ecard_id acornscsi_cids[] = {
{ MANU_ACORN, PROD_ACORN_SCSI },
{ 0xffff, 0xffff },
};
static struct ecard_driver acornscsi_driver = {
.probe = acornscsi_probe,
.remove = __devexit_p(acornscsi_remove),
.id_table = acornscsi_cids,
.drv = {
.name = "acornscsi",
},
};
static int __init acornscsi_init(void)
{
return ecard_register_driver(&acornscsi_driver);
} }
static void __exit acornscsi_exit(void) static void __exit acornscsi_exit(void)
{ {
scsi_unregister_host(&acornscsi_template); ecard_remove_driver(&acornscsi_driver);
} }
module_init(acornscsi_init); module_init(acornscsi_init);
...@@ -3161,4 +3130,3 @@ module_exit(acornscsi_exit); ...@@ -3161,4 +3130,3 @@ module_exit(acornscsi_exit);
MODULE_AUTHOR("Russell King"); MODULE_AUTHOR("Russell King");
MODULE_DESCRIPTION("AcornSCSI driver"); MODULE_DESCRIPTION("AcornSCSI driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -37,21 +37,29 @@ ...@@ -37,21 +37,29 @@
#include "../../scsi/scsi.h" #include "../../scsi/scsi.h"
#include "../../scsi/hosts.h" #include "../../scsi/hosts.h"
#include "arxescsi.h"
#include "fas216.h" #include "fas216.h"
/* Hmm - this should go somewhere else */ struct arxescsi_info {
#define BUS_ADDR(x) ((((unsigned long)(x)) << 2) + IO_BASE) FAS216_Info info;
/* Configuration */ /* other info... */
#define ARXESCSI_XTALFREQ 24 unsigned int cstatus; /* card status register */
#define ARXESCSI_ASYNC_PERIOD 200 unsigned int dmaarea; /* Pseudo DMA area */
#define ARXESCSI_SYNC_DEPTH 0 };
/* #define CSTATUS_IRQ (1 << 0)
* List of devices that the driver will recognise #define CSTATUS_DRQ (1 << 0)
*/
#define ARXESCSI_LIST { MANU_ARXE, PROD_ARXE_SCSI } #ifndef CAN_QUEUE
#define CAN_QUEUE 1
#endif
#ifndef CMD_PER_LUN
#define CMD_PER_LUN 1
#endif
/* Hmm - this should go somewhere else */
#define BUS_ADDR(x) ((((unsigned long)(x)) << 2) + IO_BASE)
/* /*
* Version * Version
...@@ -60,8 +68,6 @@ ...@@ -60,8 +68,6 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_PATCH 1 #define VER_PATCH 1
static struct expansion_card *ecs[MAX_ECARDS];
/* /*
* Function: int arxescsi_dma_setup(host, SCpnt, direction, min_type) * Function: int arxescsi_dma_setup(host, SCpnt, direction, min_type)
* Purpose : initialises DMA/PIO * Purpose : initialises DMA/PIO
...@@ -85,7 +91,7 @@ arxescsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp, ...@@ -85,7 +91,7 @@ arxescsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,
/* Faster transfer routines, written by SH to speed up the loops */ /* Faster transfer routines, written by SH to speed up the loops */
static __inline__ unsigned char getb(unsigned int address, unsigned int reg) static inline unsigned char getb(unsigned int address, unsigned int reg)
{ {
unsigned char value; unsigned char value;
...@@ -96,7 +102,7 @@ static __inline__ unsigned char getb(unsigned int address, unsigned int reg) ...@@ -96,7 +102,7 @@ static __inline__ unsigned char getb(unsigned int address, unsigned int reg)
return value; return value;
} }
static __inline__ unsigned int getw(unsigned int address, unsigned int reg) static inline unsigned int getw(unsigned int address, unsigned int reg)
{ {
unsigned int value; unsigned int value;
...@@ -109,7 +115,7 @@ static __inline__ unsigned int getw(unsigned int address, unsigned int reg) ...@@ -109,7 +115,7 @@ static __inline__ unsigned int getw(unsigned int address, unsigned int reg)
return value; return value;
} }
static __inline__ void putw(unsigned int address, unsigned int reg, unsigned long value) static inline void putw(unsigned int address, unsigned int reg, unsigned long value)
{ {
__asm__ __volatile__( __asm__ __volatile__(
"mov %0, %0, lsl #16\n\t" "mov %0, %0, lsl #16\n\t"
...@@ -157,7 +163,7 @@ void arxescsi_pseudo_dma_write(unsigned char *addr, unsigned int io) ...@@ -157,7 +163,7 @@ void arxescsi_pseudo_dma_write(unsigned char *addr, unsigned int io)
void arxescsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp, void arxescsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
fasdmadir_t direction, int transfer) fasdmadir_t direction, int transfer)
{ {
ARXEScsi_Info *info = (ARXEScsi_Info *)host->hostdata; struct arxescsi_info *info = (struct arxescsi_info *)host->hostdata;
unsigned int length, io, error=0; unsigned int length, io, error=0;
unsigned char *addr; unsigned char *addr;
...@@ -247,106 +253,6 @@ static void arxescsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp) ...@@ -247,106 +253,6 @@ static void arxescsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp)
*/ */
} }
/*
* Function: int arxescsi_detect(Scsi_Host_Template * tpnt)
* Purpose : initialises ARXE SCSI driver
* Params : tpnt - template for this SCSI adapter
* Returns : >0 if host found, 0 otherwise.
*/
int arxescsi_detect(Scsi_Host_Template *tpnt)
{
static const card_ids arxescsi_cids[] = { ARXESCSI_LIST, { 0xffff, 0xffff} };
int count = 0;
struct Scsi_Host *host;
tpnt->proc_name = "arxescsi";
memset(ecs, 0, sizeof (ecs));
ecard_startfind();
while (1) {
ARXEScsi_Info *info;
ecs[count] = ecard_find(0, arxescsi_cids);
if (!ecs[count])
break;
ecard_claim(ecs[count]);
host = scsi_register(tpnt, sizeof (ARXEScsi_Info));
if (!host) {
ecard_release(ecs[count]);
break;
}
host->io_port = ecard_address(ecs[count], ECARD_MEMC, 0) + 0x0800;
host->irq = NO_IRQ;
host->dma_channel = NO_DMA;
host->can_queue = 0; /* no command queueing */
info = (ARXEScsi_Info *)host->hostdata;
info->info.scsi.io_port = host->io_port;
info->info.scsi.irq = host->irq;
info->info.scsi.io_shift = 3;
info->info.ifcfg.clockrate = ARXESCSI_XTALFREQ;
info->info.ifcfg.select_timeout = 255;
info->info.ifcfg.asyncperiod = ARXESCSI_ASYNC_PERIOD;
info->info.ifcfg.sync_max_depth = ARXESCSI_SYNC_DEPTH;
info->info.ifcfg.cntl3 = CNTL3_FASTSCSI | CNTL3_FASTCLK;
info->info.ifcfg.disconnect_ok = 0;
info->info.ifcfg.wide_max_size = 0;
info->info.dma.setup = arxescsi_dma_setup;
info->info.dma.pseudo = arxescsi_dma_pseudo;
info->info.dma.stop = arxescsi_dma_stop;
info->dmaarea = host->io_port + 128;
info->cstatus = host->io_port + 384;
ecs[count]->irqaddr = (unsigned char *)BUS_ADDR(host->io_port);
ecs[count]->irqmask = CSTATUS_IRQ;
if (!request_region(host->io_port, 120, "arxescsi-fas")) {
ecard_release(ecs[count]);
scsi_unregister(host);
break;
}
if (!request_region(host->io_port + 128, 384, "arxescsi-dma")) {
ecard_release(ecs[count]);
release_region(host->io_port, 120);
scsi_unregister(host);
break;
}
printk("scsi%d: Has no interrupts - using polling mode\n",
host->host_no);
fas216_init(host);
++count;
}
return count;
}
/*
* Function: int arxescsi_release(struct Scsi_Host * host)
* Purpose : releases all resources used by this adapter
* Params : host - driver host structure to return info for.
* Returns : nothing
*/
int arxescsi_release(struct Scsi_Host *host)
{
int i;
fas216_release(host);
release_region(host->io_port, 120);
release_region(host->io_port + 128, 384);
for (i = 0; i < MAX_ECARDS; i++)
if (ecs[i] && host->io_port == (ecard_address(ecs[i], ECARD_MEMC, 0) + 0x0800))
ecard_release(ecs[i]);
return 0;
}
/* /*
* Function: const char *arxescsi_info(struct Scsi_Host * host) * Function: const char *arxescsi_info(struct Scsi_Host * host)
* Purpose : returns a descriptive string about this interface, * Purpose : returns a descriptive string about this interface,
...@@ -355,7 +261,7 @@ int arxescsi_release(struct Scsi_Host *host) ...@@ -355,7 +261,7 @@ int arxescsi_release(struct Scsi_Host *host)
*/ */
const char *arxescsi_info(struct Scsi_Host *host) const char *arxescsi_info(struct Scsi_Host *host)
{ {
ARXEScsi_Info *info = (ARXEScsi_Info *)host->hostdata; struct arxescsi_info *info = (struct arxescsi_info *)host->hostdata;
static char string[100], *p; static char string[100], *p;
p = string; p = string;
...@@ -385,14 +291,14 @@ int arxescsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -385,14 +291,14 @@ int arxescsi_proc_info(char *buffer, char **start, off_t offset,
{ {
int pos, begin; int pos, begin;
struct Scsi_Host *host; struct Scsi_Host *host;
ARXEScsi_Info *info; struct arxescsi_info *info;
Scsi_Device *scd; Scsi_Device *scd;
host = scsi_host_hn_get(host_no); host = scsi_host_hn_get(host_no);
if (!host) if (!host)
return 0; return 0;
info = (ARXEScsi_Info *)host->hostdata; info = (struct arxescsi_info *)host->hostdata;
if (inout == 1) if (inout == 1)
return -EINVAL; return -EINVAL;
...@@ -424,22 +330,122 @@ int arxescsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -424,22 +330,122 @@ int arxescsi_proc_info(char *buffer, char **start, off_t offset,
return pos; return pos;
} }
static Scsi_Host_Template arxescsi_template = ARXEScsi; static Scsi_Host_Template arxescsi_template = {
.proc_info = arxescsi_proc_info,
.name = "ARXE SCSI card",
.info = arxescsi_info,
.command = fas216_command,
.queuecommand = fas216_queue_command,
.eh_host_reset_handler = fas216_eh_host_reset,
.eh_bus_reset_handler = fas216_eh_bus_reset,
.eh_device_reset_handler = fas216_eh_device_reset,
.eh_abort_handler = fas216_eh_abort,
.can_queue = 0,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = CMD_PER_LUN,
.use_clustering = DISABLE_CLUSTERING,
.proc_name = "arxescsi",
};
static int __devinit
arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id)
{
struct Scsi_Host *host;
struct arxescsi_info *info;
int ret = -ENOMEM;
host = scsi_register(&arxescsi_template, sizeof(struct arxescsi_info));
if (!host)
goto out;
static int __init init_arxe_scsi_driver(void) host->io_port = ecard_address(ec, ECARD_MEMC, 0) + 0x0800;
host->irq = NO_IRQ;
host->dma_channel = NO_DMA;
info = (struct arxescsi_info *)host->hostdata;
info->info.scsi.io_port = host->io_port;
info->info.scsi.irq = host->irq;
info->info.scsi.io_shift = 3;
info->info.ifcfg.clockrate = 24; /* MHz */
info->info.ifcfg.select_timeout = 255;
info->info.ifcfg.asyncperiod = 200; /* ns */
info->info.ifcfg.sync_max_depth = 0;
info->info.ifcfg.cntl3 = CNTL3_FASTSCSI | CNTL3_FASTCLK;
info->info.ifcfg.disconnect_ok = 0;
info->info.ifcfg.wide_max_size = 0;
info->info.dma.setup = arxescsi_dma_setup;
info->info.dma.pseudo = arxescsi_dma_pseudo;
info->info.dma.stop = arxescsi_dma_stop;
info->dmaarea = host->io_port + 128;
info->cstatus = host->io_port + 384;
ec->irqaddr = (unsigned char *)BUS_ADDR(host->io_port);
ec->irqmask = CSTATUS_IRQ;
if (!request_region(host->io_port, 120, "arxescsi-fas")) {
ret = -EBUSY;
goto out_free;
}
if (!request_region(host->io_port + 128, 384, "arxescsi-dma")) {
ret = -EBUSY;
goto out_release;
}
printk("scsi%d: Has no interrupts - using polling mode\n",
host->host_no);
fas216_init(host);
ret = scsi_add_host(host);
if (ret == 0)
goto out;
release_region(host->io_port + 128, 384);
out_release:
release_region(host->io_port, 120);
out_free:
scsi_unregister(host);
out:
return ret;
}
static void __devexit arxescsi_release(struct expansion_card *ec)
{ {
arxescsi_template.module = THIS_MODULE; struct Scsi_Host *host = ecard_get_drvdata(ec);
scsi_register_host(&arxescsi_template);
if (arxescsi_template.present)
return 0;
scsi_unregister_host(&arxescsi_template); ecard_set_drvdata(ec, NULL);
return -ENODEV; scsi_remove_host(host);
fas216_release(host);
release_region(host->io_port + 128, 384);
release_region(host->io_port, 120);
scsi_unregister(host);
}
static const struct ecard_id arxescsi_cids[] = {
{ MANU_ARXE, PROD_ARXE_SCSI },
{ 0xffff, 0xffff },
};
static struct ecard_driver arxescsi_driver = {
.probe = arxescsi_probe,
.remove = __devexit_p(arxescsi_remove),
.id_table = arxescsi_cids,
.drv = {
.name = "arxescsi",
},
};
static int __init init_arxe_scsi_driver(void)
{
return ecard_register_driver(&arxescsi_driver);
} }
static void __exit exit_arxe_scsi_driver(void) static void __exit exit_arxe_scsi_driver(void)
{ {
scsi_unregister_host(&arxescsi_template); ecard_remove_driver(&arxescsi_driver);
} }
module_init(init_arxe_scsi_driver); module_init(init_arxe_scsi_driver);
......
#define AUTOSENSE
#define PSEUDO_DMA
/* /*
* Generic Generic NCR5380 driver * Generic Generic NCR5380 driver
* *
* Copyright 1995, Russell King * Copyright 1995-2002, Russell King
*
* ALPHA RELEASE 1.
*
* For more information, please consult
*
* NCR 5380 Family
* SCSI Protocol Controller
* Databook
*
* NCR Microelectronics
* 1635 Aeroplaza Drive
* Colorado Springs, CO 80916
* 1+ (719) 578-3400
* 1+ (800) 334-5454
*/
/*
* Options :
*
* PARITY - enable parity checking. Not supported.
*
* SCSI2 - enable support for SCSI-II tagged queueing. Untested.
*
* USLEEP - enable support for devices that don't disconnect. Untested.
*/
/*
* $Log: cumana_1.c,v $
* Revision 1.3 1998/05/03 20:45:32 alan
* ARM SCSI update. This adds the eesox driver and massively updates the
* Cumana driver. The folks who bought cumana arent anal retentive all
* docs are secret weenies so now there are docs ..
*
* Revision 1.2 1998/03/08 05:49:46 davem
* Merge to 2.1.89
*
* Revision 1.1 1998/02/23 02:45:22 davem
* Merge to 2.1.88
*
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -64,25 +21,16 @@ ...@@ -64,25 +21,16 @@
#include <scsi/scsicam.h> #include <scsi/scsicam.h>
#define CUMANASCSI_PUBLIC_RELEASE 1 #define AUTOSENSE
#define PSEUDO_DMA
static const card_ids cumanascsi_cids[] = {
{ MANU_CUMANA, PROD_CUMANA_SCSI_1 },
{ 0xffff, 0xffff }
};
#define NCR5380_implementation_fields \
int port, ctrl
#define NCR5380_local_declare() \
struct Scsi_Host *_instance
#define NCR5380_setup(instance) \ #define CUMANASCSI_PUBLIC_RELEASE 1
_instance = instance
#define NCR5380_implementation_fields int port, ctrl
#define NCR5380_local_declare() struct Scsi_Host *_instance
#define NCR5380_setup(instance) _instance = instance
#define NCR5380_read(reg) cumanascsi_read(_instance, reg) #define NCR5380_read(reg) cumanascsi_read(_instance, reg)
#define NCR5380_write(reg, value) cumanascsi_write(_instance, reg, value) #define NCR5380_write(reg, value) cumanascsi_write(_instance, reg, value)
#define NCR5380_intr cumanascsi_intr #define NCR5380_intr cumanascsi_intr
#define NCR5380_queue_command cumanascsi_queue_command #define NCR5380_queue_command cumanascsi_queue_command
#define NCR5380_proc_info cumanascsi_proc_info #define NCR5380_proc_info cumanascsi_proc_info
...@@ -95,111 +43,12 @@ int NCR5380_proc_info(char *buffer, char **start, off_t offset, ...@@ -95,111 +43,12 @@ int NCR5380_proc_info(char *buffer, char **start, off_t offset,
#include "../../scsi/NCR5380.h" #include "../../scsi/NCR5380.h"
/*
* Function : cumanascsi_setup(char *str, int *ints)
*
* Purpose : LILO command line initialization of the overrides array,
*
* Inputs : str - unused, ints - array of integer parameters with ints[0]
* equal to the number of ints.
*
*/
void cumanascsi_setup(char *str, int *ints) void cumanascsi_setup(char *str, int *ints)
{ {
} }
#define CUMANA_ADDRESS(card) (ecard_address((card), ECARD_IOC, ECARD_SLOW) + 0x800) const char *cumanascsi_info(struct Scsi_Host *spnt)
#define CUMANA_IRQ(card) ((card)->irq)
/*
* Function : int cumanascsi_detect(Scsi_Host_Template * tpnt)
*
* Purpose : initializes cumana NCR5380 driver based on the
* command line / compile time port and irq definitions.
*
* Inputs : tpnt - template for this SCSI adapter.
*
* Returns : 1 if a host adapter was found, 0 if not.
*
*/
static struct expansion_card *ecs[4];
int cumanascsi_detect(Scsi_Host_Template * tpnt)
{
int count = 0;
struct Scsi_Host *instance;
tpnt->proc_name = "CumanaSCSI-1";
memset (ecs, 0, sizeof (ecs));
while(1) {
if((ecs[count] = ecard_find(0, cumanascsi_cids)) == NULL)
break;
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!instance)
break;
instance->io_port = CUMANA_ADDRESS(ecs[count]);
instance->irq = CUMANA_IRQ(ecs[count]);
NCR5380_init(instance, 0);
ecard_claim(ecs[count]);
instance->n_io_port = 255;
if ( !(request_region (instance->io_port, instance->n_io_port, "CumanaSCSI-1")) ) {
ecard_release(ecs[count]);
scsi_unregister(instance);
break;
}
((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
outb(0x00, instance->io_port - 577);
if (instance->irq != IRQ_NONE)
if (request_irq(instance->irq, cumanascsi_intr, SA_INTERRUPT, "CumanaSCSI-1", NULL)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
instance->host_no, instance->irq);
instance->irq = IRQ_NONE;
}
if (instance->irq == IRQ_NONE) {
printk("scsi%d: interrupts not enabled. for better interactive performance,\n", instance->host_no);
printk("scsi%d: please jumper the board for a free IRQ.\n", instance->host_no);
}
printk("scsi%d: at port %lX irq", instance->host_no, instance->io_port);
if (instance->irq == IRQ_NONE)
printk ("s disabled");
else
printk (" %d", instance->irq);
printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
tpnt->can_queue, tpnt->cmd_per_lun, CUMANASCSI_PUBLIC_RELEASE);
printk("\nscsi%d:", instance->host_no);
NCR5380_print_options(instance);
printk("\n");
++count;
}
return count;
}
int cumanascsi_release (struct Scsi_Host *shpnt)
{ {
int i;
if (shpnt->irq != IRQ_NONE)
free_irq (shpnt->irq, NULL);
if (shpnt->io_port)
release_region (shpnt->io_port, shpnt->n_io_port);
for (i = 0; i < 4; i++)
if (shpnt->io_port == CUMANA_ADDRESS(ecs[i]))
ecard_release (ecs[i]);
return 0;
}
const char * cumanascsi_info (struct Scsi_Host *spnt) {
return ""; return "";
} }
...@@ -219,8 +68,8 @@ const char * cumanascsi_info (struct Scsi_Host *spnt) { ...@@ -219,8 +68,8 @@ const char * cumanascsi_info (struct Scsi_Host *spnt) {
#define L(v) (((v)<<16)|((v) & 0x0000ffff)) #define L(v) (((v)<<16)|((v) & 0x0000ffff))
#define H(v) (((v)>>16)|((v) & 0xffff0000)) #define H(v) (((v)>>16)|((v) & 0xffff0000))
static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, static inline int
int len) NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, int len)
{ {
int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
int oldctrl = *ctrl; int oldctrl = *ctrl;
...@@ -289,8 +138,8 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr ...@@ -289,8 +138,8 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr
return len; return len;
} }
static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, static inline int
int len) NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, int len)
{ {
int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
int oldctrl = *ctrl; int oldctrl = *ctrl;
...@@ -367,7 +216,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, ...@@ -367,7 +216,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr,
static char cumanascsi_read(struct Scsi_Host *instance, int reg) static char cumanascsi_read(struct Scsi_Host *instance, int reg)
{ {
int iobase = instance->io_port; unsigned int iobase = instance->io_port;
int i; int i;
int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
...@@ -395,8 +244,6 @@ static void cumanascsi_write(struct Scsi_Host *instance, int reg, int value) ...@@ -395,8 +244,6 @@ static void cumanascsi_write(struct Scsi_Host *instance, int reg, int value)
static Scsi_Host_Template cumanascsi_template = { static Scsi_Host_Template cumanascsi_template = {
.module = THIS_MODULE, .module = THIS_MODULE,
.name = "Cumana 16-bit SCSI", .name = "Cumana 16-bit SCSI",
.detect = cumanascsi_detect,
.release = cumanascsi_release,
.info = cumanascsi_info, .info = cumanascsi_info,
.queuecommand = cumanascsi_queue_command, .queuecommand = cumanascsi_queue_command,
.eh_abort_handler = NCR5380_abort, .eh_abort_handler = NCR5380_abort,
...@@ -408,26 +255,101 @@ static Scsi_Host_Template cumanascsi_template = { ...@@ -408,26 +255,101 @@ static Scsi_Host_Template cumanascsi_template = {
.sg_tablesize = SG_ALL, .sg_tablesize = SG_ALL,
.cmd_per_lun = 2, .cmd_per_lun = 2,
.unchecked_isa_dma = 0, .unchecked_isa_dma = 0,
.use_clustering = DISABLE_CLUSTERING .use_clustering = DISABLE_CLUSTERING,
.proc_name = "CumanaSCSI-1",
}; };
static int __init cumanascsi_init(void) static int __devinit
cumanascsi1_probe(struct expansion_card *ec, struct ecard_ids *id)
{
struct Scsi_Host *host;
int ret = -ENOMEM;
host = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!host)
goto out;
host->io_port = ecard_address(ec, ECARD_IOC, ECARD_SLOW) + 0x800;
host->irq = ec->irq;
NCR5380_init(host, 0);
host->n_io_port = 255;
if (!(request_region(host->io_port, host->n_io_port, "CumanaSCSI-1"))) {
ret = -EBUSY;
goto out_free;
}
((struct NCR5380_hostdata *)host->hostdata)->ctrl = 0;
outb(0x00, host->io_port - 577);
ret = request_irq(host->irq, cumanascsi_intr, SA_INTERRUPT,
"CumanaSCSI-1", host);
if (ret) {
printk("scsi%d: IRQ%d not free: %d\n",
host->host_no, host->irq, ret);
goto out_release;
}
printk("scsi%d: at port 0x%08lx irq %d",
host->host_no, host->io_port, host->irq);
printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
tpnt->can_queue, tpnt->cmd_per_lun, CUMANASCSI_PUBLIC_RELEASE);
printk("\nscsi%d:", host->host_no);
NCR5380_print_options(host);
printk("\n");
ret = scsi_add_host(host);
if (ret == 0)
goto out;
free_irq(host->irq, host);
out_release:
release_region(host->io_port, host->n_io_port);
out_free:
scsi_unregister(host);
out:
return ret;
}
static void __devexit cumanascsi1_remove(struct expansion_card *ec)
{ {
scsi_register_host(&cumanascsi_template); struct Scsi_Host *host = ecard_get_drvdata(ec);
if (cumanascsi_template.present)
return 0; ecard_set_drvdata(ec, NULL);
scsi_unregister_host(&cumanascsi_template); scsi_remove_host(host);
return -ENODEV; free_irq(host->irq, host);
release_region(host->io_port, host->n_io_port);
scsi_remove(host);
}
static const struct ecard_ids cumanascsi1_cids[] = {
{ MANU_CUMANA, PROD_CUMANA_SCSI_1 },
{ 0xffff, 0xffff }
};
static struct ecard_driver cumanascsi1_driver = {
.probe = cumanascsi1_probe,
.remove = __devexit_p(cumanascsi1_remove),
.id_table = cumanascsi1_cids,
.drv = {
.name = "cumanascsi1",
},
};
static int __init cumanascsi_init(void)
{
return ecard_register_driver(&cumanascsi1_driver);
} }
static void __exit cumanascsi_exit(void) static void __exit cumanascsi_exit(void)
{ {
scsi_unregister_host(&cumanascsi_template); ecard_remove_driver(&cumanascsi1_driver);
} }
module_init(cumanascsi_init); module_init(cumanascsi_init);
module_exit(cumanascsi_exit); module_exit(cumanascsi_exit);
MODULE_DESCRIPTION("Cumana SCSI-1 driver for Acorn machines");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
/* /*
* linux/drivers/acorn/scsi/cumana_2.c * linux/drivers/acorn/scsi/cumana_2.c
* *
* Copyright (C) 1997-2000 Russell King * Copyright (C) 1997-2002 Russell King
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -42,16 +42,6 @@ ...@@ -42,16 +42,6 @@
#include <scsi/scsicam.h> #include <scsi/scsicam.h>
/* Configuration */
#define CUMANASCSI2_XTALFREQ 40
#define CUMANASCSI2_ASYNC_PERIOD 200
#define CUMANASCSI2_SYNC_DEPTH 7
/*
* List of devices that the driver will recognise
*/
#define CUMANASCSI2_LIST { MANU_CUMANA, PROD_CUMANA_SCSI_2 }
#define CUMANASCSI2_STATUS (0) #define CUMANASCSI2_STATUS (0)
#define STATUS_INT (1 << 0) #define STATUS_INT (1 << 0)
#define STATUS_DRQ (1 << 1) #define STATUS_DRQ (1 << 1)
...@@ -73,15 +63,12 @@ ...@@ -73,15 +63,12 @@
#define CUMANASCSI2_FAS216_OFFSET (0xc0) #define CUMANASCSI2_FAS216_OFFSET (0xc0)
#define CUMANASCSI2_FAS216_SHIFT 0 #define CUMANASCSI2_FAS216_SHIFT 0
#define CUMANASCSI2_FAS216_SIZE (16)
/* /*
* Version * Version
*/ */
#define VER_MAJOR 0 #define VERSION "1.00 (13/11/2002 2.5.47)"
#define VER_MINOR 0
#define VER_PATCH 4
static struct expansion_card *ecs[MAX_ECARDS];
/* /*
* Use term=0,1,0,0,0 to turn terminators on/off * Use term=0,1,0,0,0 to turn terminators on/off
...@@ -90,16 +77,15 @@ static int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 }; ...@@ -90,16 +77,15 @@ static int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 };
#define NR_SG 256 #define NR_SG 256
typedef struct { struct cumanascsi2_info {
FAS216_Info info; FAS216_Info info;
/* other info... */
unsigned int status; /* card status register */ unsigned int status; /* card status register */
unsigned int alatch; /* Control register */ unsigned int alatch; /* Control register */
unsigned int terms; /* Terminator state */ unsigned int terms; /* Terminator state */
unsigned int dmaarea; /* Pseudo DMA area */ unsigned int dmaarea; /* Pseudo DMA area */
struct scatterlist sg[NR_SG]; /* Scatter DMA list */ struct scatterlist sg[NR_SG]; /* Scatter DMA list */
} CumanaScsi2_Info; };
#define CSTATUS_IRQ (1 << 0) #define CSTATUS_IRQ (1 << 0)
#define CSTATUS_DRQ (1 << 1) #define CSTATUS_DRQ (1 << 1)
...@@ -129,12 +115,8 @@ cumanascsi_2_irqdisable(struct expansion_card *ec, int irqnr) ...@@ -129,12 +115,8 @@ cumanascsi_2_irqdisable(struct expansion_card *ec, int irqnr)
} }
static const expansioncard_ops_t cumanascsi_2_ops = { static const expansioncard_ops_t cumanascsi_2_ops = {
cumanascsi_2_irqenable, .irqenable = cumanascsi_2_irqenable,
cumanascsi_2_irqdisable, .irqdisable = cumanascsi_2_irqdisable,
NULL,
NULL,
NULL,
NULL
}; };
/* Prototype: void cumanascsi_2_terminator_ctl(host, on_off) /* Prototype: void cumanascsi_2_terminator_ctl(host, on_off)
...@@ -145,7 +127,7 @@ static const expansioncard_ops_t cumanascsi_2_ops = { ...@@ -145,7 +127,7 @@ static const expansioncard_ops_t cumanascsi_2_ops = {
static void static void
cumanascsi_2_terminator_ctl(struct Scsi_Host *host, int on_off) cumanascsi_2_terminator_ctl(struct Scsi_Host *host, int on_off)
{ {
CumanaScsi2_Info *info = (CumanaScsi2_Info *)host->hostdata; struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
if (on_off) { if (on_off) {
info->terms = 1; info->terms = 1;
...@@ -182,7 +164,7 @@ static fasdmatype_t ...@@ -182,7 +164,7 @@ static fasdmatype_t
cumanascsi_2_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp, cumanascsi_2_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,
fasdmadir_t direction, fasdmatype_t min_type) fasdmadir_t direction, fasdmatype_t min_type)
{ {
CumanaScsi2_Info *info = (CumanaScsi2_Info *)host->hostdata; struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
int dmach = host->dma_channel; int dmach = host->dma_channel;
outb(ALATCH_DIS_DMA, info->alatch); outb(ALATCH_DIS_DMA, info->alatch);
...@@ -233,7 +215,7 @@ static void ...@@ -233,7 +215,7 @@ static void
cumanascsi_2_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp, cumanascsi_2_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
fasdmadir_t direction, int transfer) fasdmadir_t direction, int transfer)
{ {
CumanaScsi2_Info *info = (CumanaScsi2_Info *)host->hostdata; struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
unsigned int length; unsigned int length;
unsigned char *addr; unsigned char *addr;
...@@ -307,129 +289,13 @@ cumanascsi_2_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp, ...@@ -307,129 +289,13 @@ cumanascsi_2_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
static void static void
cumanascsi_2_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp) cumanascsi_2_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp)
{ {
CumanaScsi2_Info *info = (CumanaScsi2_Info *)host->hostdata; struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
if (host->dma_channel != NO_DMA) { if (host->dma_channel != NO_DMA) {
outb(ALATCH_DIS_DMA, info->alatch); outb(ALATCH_DIS_DMA, info->alatch);
disable_dma(host->dma_channel); disable_dma(host->dma_channel);
} }
} }
/* Prototype: int cumanascsi_2_detect(Scsi_Host_Template * tpnt)
* Purpose : initialises Cumana SCSI 2 driver
* Params : tpnt - template for this SCSI adapter
* Returns : >0 if host found, 0 otherwise.
*/
int
cumanascsi_2_detect(Scsi_Host_Template *tpnt)
{
static const card_ids cumanascsi_2_cids[] =
{ CUMANASCSI2_LIST, { 0xffff, 0xffff} };
int count = 0;
struct Scsi_Host *host;
tpnt->proc_name = "cumanascs2";
memset(ecs, 0, sizeof (ecs));
ecard_startfind();
while (1) {
CumanaScsi2_Info *info;
ecs[count] = ecard_find(0, cumanascsi_2_cids);
if (!ecs[count])
break;
ecard_claim(ecs[count]);
host = scsi_register(tpnt, sizeof (CumanaScsi2_Info));
if (!host) {
ecard_release(ecs[count]);
break;
}
host->io_port = ecard_address(ecs[count], ECARD_MEMC, 0);
host->irq = ecs[count]->irq;
host->dma_channel = ecs[count]->dma;
info = (CumanaScsi2_Info *)host->hostdata;
info->terms = term[count] ? 1 : 0;
cumanascsi_2_terminator_ctl(host, info->terms);
info->info.scsi.io_port = host->io_port + CUMANASCSI2_FAS216_OFFSET;
info->info.scsi.io_shift = CUMANASCSI2_FAS216_SHIFT;
info->info.scsi.irq = host->irq;
info->info.ifcfg.clockrate = CUMANASCSI2_XTALFREQ;
info->info.ifcfg.select_timeout = 255;
info->info.ifcfg.asyncperiod = CUMANASCSI2_ASYNC_PERIOD;
info->info.ifcfg.sync_max_depth = CUMANASCSI2_SYNC_DEPTH;
info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
info->info.ifcfg.disconnect_ok = 1;
info->info.ifcfg.wide_max_size = 0;
info->info.dma.setup = cumanascsi_2_dma_setup;
info->info.dma.pseudo = cumanascsi_2_dma_pseudo;
info->info.dma.stop = cumanascsi_2_dma_stop;
info->dmaarea = host->io_port + CUMANASCSI2_PSEUDODMA;
info->status = host->io_port + CUMANASCSI2_STATUS;
info->alatch = host->io_port + CUMANASCSI2_ALATCH;
ecs[count]->irqaddr = (unsigned char *)ioaddr(info->status);
ecs[count]->irqmask = STATUS_INT;
ecs[count]->irq_data = (void *)info->alatch;
ecs[count]->ops = (expansioncard_ops_t *)&cumanascsi_2_ops;
if (!request_region(host->io_port + CUMANASCSI2_FAS216_OFFSET,
16 << CUMANASCSI2_FAS216_SHIFT, "cumanascsi2-fas")) {
scsi_unregister(host);
ecard_release(ecs[count]);
break;
}
if (host->irq != NO_IRQ &&
request_irq(host->irq, cumanascsi_2_intr,
SA_INTERRUPT, "cumanascsi2", host)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
host->host_no, host->irq);
host->irq = NO_IRQ;
info->info.scsi.irq = NO_IRQ;
}
if (host->dma_channel != NO_DMA &&
request_dma(host->dma_channel, "cumanascsi2")) {
printk("scsi%d: DMA%d not free, DMA disabled\n",
host->host_no, host->dma_channel);
host->dma_channel = NO_DMA;
}
fas216_init(host);
++count;
}
return count;
}
/* Prototype: int cumanascsi_2_release(struct Scsi_Host * host)
* Purpose : releases all resources used by this adapter
* Params : host - driver host structure to return info for.
*/
int cumanascsi_2_release(struct Scsi_Host *host)
{
int i;
fas216_release(host);
if (host->irq != NO_IRQ)
free_irq(host->irq, host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
release_region(host->io_port + CUMANASCSI2_FAS216_OFFSET,
16 << CUMANASCSI2_FAS216_SHIFT);
for (i = 0; i < MAX_ECARDS; i++)
if (ecs[i] && host->io_port == ecard_address (ecs[i], ECARD_MEMC, 0))
ecard_release (ecs[i]);
return 0;
}
/* Prototype: const char *cumanascsi_2_info(struct Scsi_Host * host) /* Prototype: const char *cumanascsi_2_info(struct Scsi_Host * host)
* Purpose : returns a descriptive string about this interface, * Purpose : returns a descriptive string about this interface,
* Params : host - driver host structure to return info for. * Params : host - driver host structure to return info for.
...@@ -437,15 +303,14 @@ int cumanascsi_2_release(struct Scsi_Host *host) ...@@ -437,15 +303,14 @@ int cumanascsi_2_release(struct Scsi_Host *host)
*/ */
const char *cumanascsi_2_info(struct Scsi_Host *host) const char *cumanascsi_2_info(struct Scsi_Host *host)
{ {
CumanaScsi2_Info *info = (CumanaScsi2_Info *)host->hostdata; struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
static char string[100], *p; static char string[100], *p;
p = string; p = string;
p += sprintf(p, "%s ", host->hostt->name); p += sprintf(p, "%s ", host->hostt->name);
p += fas216_info(&info->info, p); p += fas216_info(&info->info, p);
p += sprintf(p, "v%d.%d.%d terminators o%s", p += sprintf(p, "v%s terminators o%s",
VER_MAJOR, VER_MINOR, VER_PATCH, VERSION, info->terms ? "n" : "ff");
info->terms ? "n" : "ff");
return string; return string;
} }
...@@ -499,7 +364,7 @@ int cumanascsi_2_proc_info (char *buffer, char **start, off_t offset, ...@@ -499,7 +364,7 @@ int cumanascsi_2_proc_info (char *buffer, char **start, off_t offset,
{ {
int pos, begin; int pos, begin;
struct Scsi_Host *host; struct Scsi_Host *host;
CumanaScsi2_Info *info; struct cumanascsi2_info *info;
Scsi_Device *scd; Scsi_Device *scd;
host = scsi_host_hn_get(host_no); host = scsi_host_hn_get(host_no);
...@@ -509,12 +374,12 @@ int cumanascsi_2_proc_info (char *buffer, char **start, off_t offset, ...@@ -509,12 +374,12 @@ int cumanascsi_2_proc_info (char *buffer, char **start, off_t offset,
if (inout == 1) if (inout == 1)
return cumanascsi_2_set_proc_info(host, buffer, length); return cumanascsi_2_set_proc_info(host, buffer, length);
info = (CumanaScsi2_Info *)host->hostdata; info = (struct cumanascsi2_info *)host->hostdata;
begin = 0; begin = 0;
pos = sprintf(buffer, pos = sprintf(buffer,
"Cumana SCSI II driver version %d.%d.%d\n", "Cumana SCSI II driver version v%s\n",
VER_MAJOR, VER_MINOR, VER_PATCH); VERSION);
pos += fas216_print_host(&info->info, buffer + pos); pos += fas216_print_host(&info->info, buffer + pos);
pos += sprintf(buffer + pos, "Term : o%s\n", pos += sprintf(buffer + pos, "Term : o%s\n",
...@@ -556,35 +421,148 @@ static Scsi_Host_Template cumanascsi2_template = { ...@@ -556,35 +421,148 @@ static Scsi_Host_Template cumanascsi2_template = {
.module = THIS_MODULE, .module = THIS_MODULE,
.proc_info = cumanascsi_2_proc_info, .proc_info = cumanascsi_2_proc_info,
.name = "Cumana SCSI II", .name = "Cumana SCSI II",
.detect = cumanascsi_2_detect,
.release = cumanascsi_2_release,
.info = cumanascsi_2_info, .info = cumanascsi_2_info,
.can_queue = 1,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = 1,
.use_clustering = DISABLE_CLUSTERING,
.command = fas216_command, .command = fas216_command,
.queuecommand = fas216_queue_command, .queuecommand = fas216_queue_command,
.eh_host_reset_handler = fas216_eh_host_reset, .eh_host_reset_handler = fas216_eh_host_reset,
.eh_bus_reset_handler = fas216_eh_bus_reset, .eh_bus_reset_handler = fas216_eh_bus_reset,
.eh_device_reset_handler = fas216_eh_device_reset, .eh_device_reset_handler = fas216_eh_device_reset,
.eh_abort_handler = fas216_eh_abort, .eh_abort_handler = fas216_eh_abort,
.can_queue = 1,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = 1,
.use_clustering = DISABLE_CLUSTERING,
.proc_name = "cumanascsi2",
}; };
static int __init cumanascsi2_init(void) static int __devinit
cumanascsi2_probe(struct expansion_card *ec, const struct ecard_id *id)
{ {
scsi_register_host(&cumanascsi2_template); struct Scsi_Host *host;
if (cumanascsi2_template.present) struct cumanascsi2_info *info;
return 0; int ret = -ENOMEM;
host = scsi_register(&cumanascsi2_template, sizeof (struct cumanascsi2_info));
if (!host)
goto out;
host->io_port = ecard_address(ec, ECARD_MEMC, 0);
host->irq = ec->irq;
host->dma_channel = ec->dma;
if (!request_region(host->io_port + CUMANASCSI2_FAS216_OFFSET,
CUMANASCSI2_FAS216_SIZE, "cumanascsi2-fas")) {
ret = -EBUSY;
goto out_free;
}
ecard_set_drvdata(ec, host);
info = (struct cumanascsi2_info *)host->hostdata;
info->dmaarea = host->io_port + CUMANASCSI2_PSEUDODMA;
info->status = host->io_port + CUMANASCSI2_STATUS;
info->alatch = host->io_port + CUMANASCSI2_ALATCH;
ec->irqaddr = (unsigned char *)ioaddr(info->status);
ec->irqmask = STATUS_INT;
ec->irq_data = (void *)info->alatch;
ec->ops = (expansioncard_ops_t *)&cumanascsi_2_ops;
scsi_unregister_host(&cumanascsi2_template); cumanascsi_2_terminator_ctl(host, term[ec->slot_no]);
return -ENODEV;
info->info.scsi.io_port = host->io_port + CUMANASCSI2_FAS216_OFFSET;
info->info.scsi.io_shift = CUMANASCSI2_FAS216_SHIFT;
info->info.scsi.irq = host->irq;
info->info.ifcfg.clockrate = 40; /* MHz */
info->info.ifcfg.select_timeout = 255;
info->info.ifcfg.asyncperiod = 200; /* ns */
info->info.ifcfg.sync_max_depth = 7;
info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
info->info.ifcfg.disconnect_ok = 1;
info->info.ifcfg.wide_max_size = 0;
info->info.dma.setup = cumanascsi_2_dma_setup;
info->info.dma.pseudo = cumanascsi_2_dma_pseudo;
info->info.dma.stop = cumanascsi_2_dma_stop;
ret = request_irq(host->irq, cumanascsi_2_intr,
SA_INTERRUPT, "cumanascsi2", host);
if (ret) {
printk("scsi%d: IRQ%d not free: %d\n",
host->host_no, host->irq, ret);
goto out_region;
}
if (host->dma_channel != NO_DMA) {
if (request_dma(host->dma_channel, "cumanascsi2")) {
printk("scsi%d: DMA%d not free, using PIO\n",
host->host_no, host->dma_channel);
host->dma_channel = NO_DMA;
} else {
set_dma_speed(host->dma_channel, 180);
}
}
fas216_init(host);
ret = scsi_add_host(host);
if (ret == 0)
goto out;
fas216_release(host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
free_irq(host->irq, host);
out_region:
release_region(host->io_port + CUMANASCSI2_FAS216_OFFSET,
CUMANASCSI2_FAS216_SIZE);
out_free:
scsi_unregister(host);
out:
return ret;
}
static void __devexit cumanascsi2_remove(struct expansion_card *ec)
{
struct Scsi_Host *host = ecard_get_drvdata(ec);
ecard_set_drvdata(ec, NULL);
scsi_remove_host(host);
fas216_release(host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
free_irq(host->irq, host);
release_region(host->io_port + CUMANASCSI2_FAS216_OFFSET,
CUMANASCSI2_FAS216_SIZE);
scsi_unregister(host);
}
static const struct ecard_id cumanascsi2_cids[] = {
{ MANU_CUMANA, PROD_CUMANA_SCSI_2 },
{ 0xffff, 0xffff },
};
static struct ecard_driver cumanascsi2_driver = {
.probe = cumanascsi2_probe,
.remove = __devexit_p(cumanascsi2_remove),
.id_table = cumanascsi2_cids,
.drv = {
.name = "cumanascsi2",
},
};
static int __init cumanascsi2_init(void)
{
return ecard_register_driver(&cumanascsi2_driver);
} }
static void __exit cumanascsi2_exit(void) static void __exit cumanascsi2_exit(void)
{ {
scsi_unregister_host(&cumanascsi2_template); ecard_remove_driver(&cumanascsi2_driver);
} }
module_init(cumanascsi2_init); module_init(cumanascsi2_init);
...@@ -595,4 +573,3 @@ MODULE_DESCRIPTION("Cumana SCSI-2 driver for Acorn machines"); ...@@ -595,4 +573,3 @@ MODULE_DESCRIPTION("Cumana SCSI-2 driver for Acorn machines");
MODULE_PARM(term, "1-8i"); MODULE_PARM(term, "1-8i");
MODULE_PARM_DESC(term, "SCSI bus termination"); MODULE_PARM_DESC(term, "SCSI bus termination");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/blk.h> #include <linux/blk.h>
......
/* /*
* linux/drivers/acorn/scsi/eesox.c * linux/drivers/acorn/scsi/eesox.c
* *
* Copyright (C) 1997-2000 Russell King * Copyright (C) 1997-2002 Russell King
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -48,18 +48,9 @@ ...@@ -48,18 +48,9 @@
#include <scsi/scsicam.h> #include <scsi/scsicam.h>
/* Configuration */
#define EESOX_XTALFREQ 40
#define EESOX_ASYNC_PERIOD 200
#define EESOX_SYNC_DEPTH 7
/*
* List of devices that the driver will recognise
*/
#define EESOXSCSI_LIST { MANU_EESOX, PROD_EESOX_SCSI2 }
#define EESOX_FAS216_OFFSET 0xc00 #define EESOX_FAS216_OFFSET 0xc00
#define EESOX_FAS216_SHIFT 3 #define EESOX_FAS216_SHIFT 3
#define EESOX_FAS216_SIZE (16 << EESOX_FAS216_SHIFT)
#define EESOX_STATUS 0xa00 #define EESOX_STATUS 0xa00
#define EESOX_STAT_INTR 0x01 #define EESOX_STAT_INTR 0x01
...@@ -75,11 +66,7 @@ ...@@ -75,11 +66,7 @@
/* /*
* Version * Version
*/ */
#define VER_MAJOR 0 #define VERSION "1.00 (13/11/2002 2.5.47)"
#define VER_MINOR 0
#define VER_PATCH 3
static struct expansion_card *ecs[MAX_ECARDS];
/* /*
* Use term=0,1,0,0,0 to turn terminators on/off * Use term=0,1,0,0,0 to turn terminators on/off
...@@ -88,19 +75,14 @@ static int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 }; ...@@ -88,19 +75,14 @@ static int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 };
#define NR_SG 256 #define NR_SG 256
struct control { struct eesoxscsi_info {
unsigned int io_port;
unsigned int control;
};
typedef struct {
FAS216_Info info; FAS216_Info info;
struct control control; unsigned int ctl_port;
unsigned int control;
unsigned int dmaarea; /* Pseudo DMA area */ unsigned int dmaarea; /* Pseudo DMA area */
struct scatterlist sg[NR_SG]; /* Scatter DMA list */ struct scatterlist sg[NR_SG]; /* Scatter DMA list */
} EESOXScsi_Info; };
/* Prototype: void eesoxscsi_irqenable(ec, irqnr) /* Prototype: void eesoxscsi_irqenable(ec, irqnr)
* Purpose : Enable interrupts on EESOX SCSI card * Purpose : Enable interrupts on EESOX SCSI card
...@@ -110,11 +92,11 @@ typedef struct { ...@@ -110,11 +92,11 @@ typedef struct {
static void static void
eesoxscsi_irqenable(struct expansion_card *ec, int irqnr) eesoxscsi_irqenable(struct expansion_card *ec, int irqnr)
{ {
struct control *control = (struct control *)ec->irq_data; struct eesoxscsi_info *info = (struct eesoxscsi_info *)ec->irq_data;
control->control |= EESOX_INTR_ENABLE; info->control |= EESOX_INTR_ENABLE;
outb(control->control, control->io_port); outb(info->control, info->ctl_port);
} }
/* Prototype: void eesoxscsi_irqdisable(ec, irqnr) /* Prototype: void eesoxscsi_irqdisable(ec, irqnr)
...@@ -125,20 +107,16 @@ eesoxscsi_irqenable(struct expansion_card *ec, int irqnr) ...@@ -125,20 +107,16 @@ eesoxscsi_irqenable(struct expansion_card *ec, int irqnr)
static void static void
eesoxscsi_irqdisable(struct expansion_card *ec, int irqnr) eesoxscsi_irqdisable(struct expansion_card *ec, int irqnr)
{ {
struct control *control = (struct control *)ec->irq_data; struct eesoxscsi_info *info = (struct eesoxscsi_info *)ec->irq_data;
control->control &= ~EESOX_INTR_ENABLE; info->control &= ~EESOX_INTR_ENABLE;
outb(control->control, control->io_port); outb(info->control, info->ctl_port);
} }
static const expansioncard_ops_t eesoxscsi_ops = { static const expansioncard_ops_t eesoxscsi_ops = {
eesoxscsi_irqenable, .irqenable = eesoxscsi_irqenable,
eesoxscsi_irqdisable, .irqdisable = eesoxscsi_irqdisable,
NULL,
NULL,
NULL,
NULL
}; };
/* Prototype: void eesoxscsi_terminator_ctl(*host, on_off) /* Prototype: void eesoxscsi_terminator_ctl(*host, on_off)
...@@ -149,16 +127,16 @@ static const expansioncard_ops_t eesoxscsi_ops = { ...@@ -149,16 +127,16 @@ static const expansioncard_ops_t eesoxscsi_ops = {
static void static void
eesoxscsi_terminator_ctl(struct Scsi_Host *host, int on_off) eesoxscsi_terminator_ctl(struct Scsi_Host *host, int on_off)
{ {
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata; struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(host->host_lock, flags); spin_lock_irqsave(host->host_lock, flags);
if (on_off) if (on_off)
info->control.control |= EESOX_TERM_ENABLE; info->control |= EESOX_TERM_ENABLE;
else else
info->control.control &= ~EESOX_TERM_ENABLE; info->control &= ~EESOX_TERM_ENABLE;
outb(info->control.control, info->control.io_port); outb(info->control, info->ctl_port);
spin_unlock_irqrestore(host->host_lock, flags); spin_unlock_irqrestore(host->host_lock, flags);
} }
...@@ -188,7 +166,7 @@ static fasdmatype_t ...@@ -188,7 +166,7 @@ static fasdmatype_t
eesoxscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp, eesoxscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,
fasdmadir_t direction, fasdmatype_t min_type) fasdmadir_t direction, fasdmatype_t min_type)
{ {
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata; struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata;
int dmach = host->dma_channel; int dmach = host->dma_channel;
if (dmach != NO_DMA && if (dmach != NO_DMA &&
...@@ -224,7 +202,7 @@ static void ...@@ -224,7 +202,7 @@ static void
eesoxscsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp, eesoxscsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
fasdmadir_t dir, int transfer_size) fasdmadir_t dir, int transfer_size)
{ {
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata; struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata;
unsigned int status; unsigned int status;
unsigned int length = SCp->this_residual; unsigned int length = SCp->this_residual;
union { union {
...@@ -321,116 +299,6 @@ eesoxscsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp) ...@@ -321,116 +299,6 @@ eesoxscsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp)
disable_dma(host->dma_channel); disable_dma(host->dma_channel);
} }
/* Prototype: int eesoxscsi_detect(Scsi_Host_Template * tpnt)
* Purpose : initialises EESOX SCSI driver
* Params : tpnt - template for this SCSI adapter
* Returns : >0 if host found, 0 otherwise.
*/
int
eesoxscsi_detect(Scsi_Host_Template *tpnt)
{
static const card_ids eesoxscsi_cids[] =
{ EESOXSCSI_LIST, { 0xffff, 0xffff} };
int count = 0;
struct Scsi_Host *host;
tpnt->proc_name = "eesox";
memset(ecs, 0, sizeof (ecs));
ecard_startfind();
while(1) {
EESOXScsi_Info *info;
ecs[count] = ecard_find(0, eesoxscsi_cids);
if (!ecs[count])
break;
ecard_claim(ecs[count]);
host = scsi_register(tpnt, sizeof (EESOXScsi_Info));
if (!host) {
ecard_release(ecs[count]);
break;
}
host->io_port = ecard_address(ecs[count], ECARD_IOC, ECARD_FAST);
host->irq = ecs[count]->irq;
host->dma_channel = ecs[count]->dma;
info = (EESOXScsi_Info *)host->hostdata;
info->control.io_port = host->io_port + EESOX_CONTROL;
info->control.control = term[count] ? EESOX_TERM_ENABLE : 0;
outb(info->control.control, info->control.io_port);
ecs[count]->irqaddr = (unsigned char *)
ioaddr(host->io_port + EESOX_STATUS);
ecs[count]->irqmask = EESOX_STAT_INTR;
ecs[count]->irq_data = &info->control;
ecs[count]->ops = (expansioncard_ops_t *)&eesoxscsi_ops;
info->info.scsi.io_port = host->io_port + EESOX_FAS216_OFFSET;
info->info.scsi.io_shift = EESOX_FAS216_SHIFT;
info->info.scsi.irq = host->irq;
info->info.ifcfg.clockrate = EESOX_XTALFREQ;
info->info.ifcfg.select_timeout = 255;
info->info.ifcfg.asyncperiod = EESOX_ASYNC_PERIOD;
info->info.ifcfg.sync_max_depth = EESOX_SYNC_DEPTH;
info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
info->info.ifcfg.disconnect_ok = 1;
info->info.ifcfg.wide_max_size = 0;
info->info.dma.setup = eesoxscsi_dma_setup;
info->info.dma.pseudo = eesoxscsi_dma_pseudo;
info->info.dma.stop = eesoxscsi_dma_stop;
info->dmaarea = host->io_port + EESOX_DMA_OFFSET;
request_region(host->io_port + EESOX_FAS216_OFFSET,
16 << EESOX_FAS216_SHIFT, "eesox2-fas");
if (host->irq != NO_IRQ &&
request_irq(host->irq, eesoxscsi_intr,
SA_INTERRUPT, "eesox", host)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
host->host_no, host->irq);
host->irq = NO_IRQ;
}
if (host->dma_channel != NO_DMA &&
request_dma(host->dma_channel, "eesox")) {
printk("scsi%d: DMA%d not free, DMA disabled\n",
host->host_no, host->dma_channel);
host->dma_channel = NO_DMA;
}
fas216_init(host);
++count;
}
return count;
}
/* Prototype: int eesoxscsi_release(struct Scsi_Host * host)
* Purpose : releases all resources used by this adapter
* Params : host - driver host structure to return info for.
*/
int eesoxscsi_release(struct Scsi_Host *host)
{
int i;
fas216_release(host);
if (host->irq != NO_IRQ)
free_irq(host->irq, host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
release_region(host->io_port + EESOX_FAS216_OFFSET, 16 << EESOX_FAS216_SHIFT);
for (i = 0; i < MAX_ECARDS; i++)
if (ecs[i] &&
host->io_port == ecard_address(ecs[i], ECARD_IOC, ECARD_FAST))
ecard_release(ecs[i]);
return 0;
}
/* Prototype: const char *eesoxscsi_info(struct Scsi_Host * host) /* Prototype: const char *eesoxscsi_info(struct Scsi_Host * host)
* Purpose : returns a descriptive string about this interface, * Purpose : returns a descriptive string about this interface,
* Params : host - driver host structure to return info for. * Params : host - driver host structure to return info for.
...@@ -438,15 +306,15 @@ int eesoxscsi_release(struct Scsi_Host *host) ...@@ -438,15 +306,15 @@ int eesoxscsi_release(struct Scsi_Host *host)
*/ */
const char *eesoxscsi_info(struct Scsi_Host *host) const char *eesoxscsi_info(struct Scsi_Host *host)
{ {
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata; struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata;
static char string[100], *p; static char string[100], *p;
p = string; p = string;
p += sprintf(p, "%s ", host->hostt->name); p += sprintf(p, "%s ", host->hostt->name);
p += fas216_info(&info->info, p); p += fas216_info(&info->info, p);
p += sprintf(p, "v%d.%d.%d terminators o%s", p += sprintf(p, "v%s terminators o%s",
VER_MAJOR, VER_MINOR, VER_PATCH, VERSION,
info->control.control & EESOX_TERM_ENABLE ? "n" : "ff"); info->control & EESOX_TERM_ENABLE ? "n" : "ff");
return string; return string;
} }
...@@ -500,7 +368,7 @@ int eesoxscsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -500,7 +368,7 @@ int eesoxscsi_proc_info(char *buffer, char **start, off_t offset,
{ {
int pos, begin; int pos, begin;
struct Scsi_Host *host; struct Scsi_Host *host;
EESOXScsi_Info *info; struct eesoxscsi_info *info;
Scsi_Device *scd; Scsi_Device *scd;
host = scsi_host_hn_get(host_no); host = scsi_host_hn_get(host_no);
...@@ -510,28 +378,28 @@ int eesoxscsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -510,28 +378,28 @@ int eesoxscsi_proc_info(char *buffer, char **start, off_t offset,
if (inout == 1) if (inout == 1)
return eesoxscsi_set_proc_info(host, buffer, length); return eesoxscsi_set_proc_info(host, buffer, length);
info = (EESOXScsi_Info *)host->hostdata; info = (struct eesoxscsi_info *)host->hostdata;
begin = 0; begin = 0;
pos = sprintf(buffer, pos = sprintf(buffer,
"EESOX SCSI driver version %d.%d.%d\n", "EESOX SCSI driver version v%s\n",
VER_MAJOR, VER_MINOR, VER_PATCH); VERSION);
pos += fas216_print_host(&info->info, buffer + pos); pos += fas216_print_host(&info->info, buffer + pos);
pos += sprintf(buffer + pos, "Term : o%s\n", pos += sprintf(buffer + pos, "Term : o%s\n",
info->control.control & EESOX_TERM_ENABLE ? "n" : "ff"); info->control & EESOX_TERM_ENABLE ? "n" : "ff");
pos += fas216_print_stats(&info->info, buffer + pos); pos += fas216_print_stats(&info->info, buffer + pos);
pos += sprintf (buffer+pos, "\nAttached devices:\n"); pos += sprintf(buffer+pos, "\nAttached devices:\n");
for (scd = host->host_queue; scd; scd = scd->next) { for (scd = host->host_queue; scd; scd = scd->next) {
int len; int len;
proc_print_scsidevice (scd, buffer, &len, pos); proc_print_scsidevice(scd, buffer, &len, pos);
pos += len; pos += len;
pos += sprintf (buffer+pos, "Extensions: "); pos += sprintf(buffer+pos, "Extensions: ");
if (scd->tagged_supported) if (scd->tagged_supported)
pos += sprintf (buffer+pos, "TAG %sabled [%d] ", pos += sprintf(buffer+pos, "TAG %sabled [%d] ",
scd->tagged_queue ? "en" : "dis", scd->tagged_queue ? "en" : "dis",
scd->current_tag); scd->current_tag);
pos += sprintf (buffer+pos, "\n"); pos += sprintf (buffer+pos, "\n");
...@@ -553,35 +421,144 @@ static Scsi_Host_Template eesox_template = { ...@@ -553,35 +421,144 @@ static Scsi_Host_Template eesox_template = {
.module = THIS_MODULE, .module = THIS_MODULE,
.proc_info = eesoxscsi_proc_info, .proc_info = eesoxscsi_proc_info,
.name = "EESOX SCSI", .name = "EESOX SCSI",
.detect = eesoxscsi_detect,
.release = eesoxscsi_release,
.info = eesoxscsi_info, .info = eesoxscsi_info,
.can_queue = 1,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = 1,
.use_clustering = DISABLE_CLUSTERING,
.command = fas216_command, .command = fas216_command,
.queuecommand = fas216_queue_command, .queuecommand = fas216_queue_command,
.eh_host_reset_handler = fas216_eh_host_reset, .eh_host_reset_handler = fas216_eh_host_reset,
.eh_bus_reset_handler = fas216_eh_bus_reset, .eh_bus_reset_handler = fas216_eh_bus_reset,
.eh_device_reset_handler = fas216_eh_device_reset, .eh_device_reset_handler = fas216_eh_device_reset,
.eh_abort_handler = fas216_eh_abort, .eh_abort_handler = fas216_eh_abort,
.can_queue = 1,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = 1,
.use_clustering = DISABLE_CLUSTERING,
.proc_name = "eesox",
}; };
static int __init eesox_init(void) static int __devinit
eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
{ {
scsi_register_host(&eesox_template); struct Scsi_Host *host;
if (eesox_template.present) struct eesoxscsi_info *info;
return 0; int ret = -ENOMEM;
host = scsi_register(&eesox_template,
sizeof(struct eesoxscsi_info));
if (!host)
goto out;
host->io_port = ecard_address(ec, ECARD_IOC, ECARD_FAST);
host->irq = ec->irq;
host->dma_channel = ec->dma;
if (!request_region(host->io_port + EESOX_FAS216_OFFSET,
EESOX_FAS216_SIZE, "eesox2-fas")) {
ret = -EBUSY;
goto out_free;
}
ecard_set_drvdata(ec, host);
info = (struct eesoxscsi_info *)host->hostdata;
info->ctl_port = host->io_port + EESOX_CONTROL;
info->control = term[ec->slot_no] ? EESOX_TERM_ENABLE : 0;
outb(info->control, info->ctl_port);
ec->irqaddr = (unsigned char *)ioaddr(host->io_port + EESOX_STATUS);
ec->irqmask = EESOX_STAT_INTR;
ec->irq_data = info;
ec->ops = (expansioncard_ops_t *)&eesoxscsi_ops;
info->info.scsi.io_port = host->io_port + EESOX_FAS216_OFFSET;
info->info.scsi.io_shift = EESOX_FAS216_SHIFT;
info->info.scsi.irq = host->irq;
info->info.ifcfg.clockrate = 40; /* MHz */
info->info.ifcfg.select_timeout = 255;
info->info.ifcfg.asyncperiod = 200; /* ns */
info->info.ifcfg.sync_max_depth = 7;
info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
info->info.ifcfg.disconnect_ok = 1;
info->info.ifcfg.wide_max_size = 0;
info->info.dma.setup = eesoxscsi_dma_setup;
info->info.dma.pseudo = eesoxscsi_dma_pseudo;
info->info.dma.stop = eesoxscsi_dma_stop;
info->dmaarea = host->io_port + EESOX_DMA_OFFSET;
ret = request_irq(host->irq, eesoxscsi_intr,
SA_INTERRUPT, "eesox", host);
if (ret) {
printk("scsi%d: IRQ%d not free: %d\n",
host->host_no, host->irq, ret);
goto out_region;
}
scsi_unregister_host(&eesox_template); if (host->dma_channel != NO_DMA) {
return -ENODEV; if (request_dma(host->dma_channel, "eesox")) {
printk("scsi%d: DMA%d not free, DMA disabled\n",
host->host_no, host->dma_channel);
host->dma_channel = NO_DMA;
} else {
set_dma_speed(host->dma_channel, 180);
}
}
fas216_init(host);
ret = scsi_add_host(host);
if (ret == 0)
goto out;
fas216_release(host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
free_irq(host->irq, host);
out_region:
release_region(host->io_port + EESOX_FAS216_OFFSET,
EESOX_FAS216_SIZE);
out_free:
scsi_unregister(host);
out:
return ret;
}
static void __devexit eesoxscsi_remove(struct expansion_card *ec)
{
struct Scsi_Host *host = ecard_get_drvdata(ec);
ecard_set_drvdata(ec, NULL);
scsi_remove_host(host);
fas216_release(host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
free_irq(host->irq, host);
release_region(host->io_port + EESOX_FAS216_OFFSET, EESOX_FAS216_SIZE);
scsi_unregister(host);
}
static const struct ecard_id eesoxscsi_cids[] = {
{ MANU_EESOX, PROD_EESOX_SCSI2 },
{ 0xffff, 0xffff },
};
static struct ecard_driver eesoxscsi_driver = {
.probe = eesoxscsi_probe,
.remove = __devexit_p(eesoxscsi_remove),
.id_table = eesoxscsi_cids,
.drv = {
.name = "eesoxscsi",
},
};
static int __init eesox_init(void)
{
return ecard_register_driver(&eesoxscsi_driver);
} }
static void __exit eesox_exit(void) static void __exit eesox_exit(void)
{ {
scsi_unregister_host(&eesox_template); ecard_remove_driver(&eesoxscsi_driver);
} }
module_init(eesox_init); module_init(eesox_init);
......
...@@ -93,14 +93,18 @@ ...@@ -93,14 +93,18 @@
#undef SCSI2_TAG #undef SCSI2_TAG
#undef DEBUG_CONNECT #undef DEBUG_CONNECT
#undef DEBUG_BUSSERVICE
#undef DEBUG_FUNCTIONDONE
#undef DEBUG_MESSAGES #undef DEBUG_MESSAGES
#undef CHECK_STRUCTURE #undef CHECK_STRUCTURE
static struct { int stat, ssr, isr, ph; } list[8]; #define LOG_CONNECT (1 << 0)
static int ptr; #define LOG_BUSSERVICE (1 << 1)
#define LOG_FUNCTIONDONE (1 << 2)
#define LOG_MESSAGES (1 << 3)
#define LOG_BUFFER (1 << 4)
#define LOG_ERROR (1 << 8)
static int level_mask = LOG_ERROR;
static void fas216_dumpstate(FAS216_Info *info) static void fas216_dumpstate(FAS216_Info *info)
{ {
...@@ -120,6 +124,13 @@ static void fas216_dumpstate(FAS216_Info *info) ...@@ -120,6 +124,13 @@ static void fas216_dumpstate(FAS216_Info *info)
inb(REG_CNTL3(info)), inb(REG_CTCH(info))); inb(REG_CNTL3(info)), inb(REG_CTCH(info)));
} }
static void print_SCp(Scsi_Pointer *SCp, const char *prefix, const char *suffix)
{
printk("%sptr %p this_residual 0x%x buffer %p buffers_residual 0x%x%s",
prefix, SCp->ptr, SCp->this_residual, SCp->buffer,
SCp->buffers_residual, suffix);
}
static void fas216_dumpinfo(FAS216_Info *info) static void fas216_dumpinfo(FAS216_Info *info)
{ {
static int used = 0; static int used = 0;
...@@ -140,9 +151,7 @@ static void fas216_dumpinfo(FAS216_Info *info) ...@@ -140,9 +151,7 @@ static void fas216_dumpinfo(FAS216_Info *info)
info->scsi.type, info->scsi.phase, info->scsi.type, info->scsi.phase,
info->scsi.reconnected.target, info->scsi.reconnected.target,
info->scsi.reconnected.lun, info->scsi.reconnected.tag); info->scsi.reconnected.lun, info->scsi.reconnected.tag);
printk(" SCp={ ptr=%p this_residual=%X buffer=%p buffers_residual=%X }\n", print_SCp(&info->scsi.SCp, " SCp={ ", " }\n");
info->scsi.SCp.ptr, info->scsi.SCp.this_residual,
info->scsi.SCp.buffer, info->scsi.SCp.buffers_residual);
printk(" msgs async_stp=%X disconnectable=%d aborting=%d }\n", printk(" msgs async_stp=%X disconnectable=%d aborting=%d }\n",
info->scsi.async_stp, info->scsi.async_stp,
info->scsi.disconnectable, info->scsi.aborting); info->scsi.disconnectable, info->scsi.aborting);
...@@ -156,7 +165,7 @@ static void fas216_dumpinfo(FAS216_Info *info) ...@@ -156,7 +165,7 @@ static void fas216_dumpinfo(FAS216_Info *info)
info->ifcfg.clockrate, info->ifcfg.select_timeout, info->ifcfg.clockrate, info->ifcfg.select_timeout,
info->ifcfg.asyncperiod, info->ifcfg.sync_max_depth); info->ifcfg.asyncperiod, info->ifcfg.sync_max_depth);
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
printk(" busyluns[%d]=%X dev[%d]={ disconnect_ok=%d stp=%X sof=%X sync_state=%X }\n", printk(" busyluns[%d]=%08lx dev[%d]={ disconnect_ok=%d stp=%X sof=%X sync_state=%X }\n",
i, info->busyluns[i], i, i, info->busyluns[i], i,
info->device[i].disconnect_ok, info->device[i].stp, info->device[i].disconnect_ok, info->device[i].stp,
info->device[i].sof, info->device[i].sync_state); info->device[i].sof, info->device[i].sync_state);
...@@ -229,29 +238,73 @@ static char fas216_target(FAS216_Info *info) ...@@ -229,29 +238,73 @@ static char fas216_target(FAS216_Info *info)
return 'H'; return 'H';
} }
static void fas216_log(FAS216_Info *info, int level, char *fmt, ...)
{
va_list args;
static char buf[1024];
if (level != 0 && !(level & level_mask))
return;
va_start(args, fmt);
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
printk("scsi%d.%c: %s\n", info->host->host_no, fas216_target(info), buf);
}
#define PH_SIZE 32
static struct { int stat, ssr, isr, ph; } ph_list[PH_SIZE];
static int ph_ptr;
static void add_debug_list(int stat, int ssr, int isr, int ph) static void add_debug_list(int stat, int ssr, int isr, int ph)
{ {
list[ptr].stat = stat; ph_list[ph_ptr].stat = stat;
list[ptr].ssr = ssr; ph_list[ph_ptr].ssr = ssr;
list[ptr].isr = isr; ph_list[ph_ptr].isr = isr;
list[ptr].ph = ph; ph_list[ph_ptr].ph = ph;
ph_ptr = (ph_ptr + 1) & (PH_SIZE-1);
}
static struct { int command; void *from; } cmd_list[8];
static int cmd_ptr;
static void fas216_cmd(FAS216_Info *info, unsigned int command)
{
cmd_list[cmd_ptr].command = command;
cmd_list[cmd_ptr].from = __builtin_return_address(0);
cmd_ptr = (cmd_ptr + 1) & 7;
ptr = (ptr + 1) & 7; outb(command, REG_CMD(info));
} }
static void print_debug_list(void) static void print_debug_list(void)
{ {
int i; int i;
i = ptr; i = ph_ptr;
printk(KERN_ERR "SCSI IRQ trail\n");
do {
printk(" %02x:%02x:%02x:%1x",
ph_list[i].stat, ph_list[i].ssr,
ph_list[i].isr, ph_list[i].ph);
i = (i + 1) & (PH_SIZE - 1);
if (((i ^ ph_ptr) & 7) == 0)
printk("\n");
} while (i != ph_ptr);
if ((i ^ ph_ptr) & 7)
printk("\n");
printk(KERN_ERR "SCSI IRQ trail: "); i = cmd_ptr;
printk(KERN_ERR "FAS216 commands: ");
do { do {
printk("%02X:%02X:%02X:%1X ", printk("%02x:%p ", cmd_list[i].command, cmd_list[i].from);
list[i].stat, list[i].ssr,
list[i].isr, list[i].ph);
i = (i + 1) & 7; i = (i + 1) & 7;
} while (i != ptr); } while (i != cmd_ptr);
printk("\n"); printk("\n");
} }
...@@ -299,10 +352,9 @@ fas216_get_last_msg(FAS216_Info *info, int pos) ...@@ -299,10 +352,9 @@ fas216_get_last_msg(FAS216_Info *info, int pos)
packed_msg = msg->msg[0]; packed_msg = msg->msg[0];
} }
#ifdef DEBUG_MESSAGES fas216_log(info, LOG_MESSAGES,
printk("Message: %04X found at position %02X\n", "Message: %04x found at position %02x\n", packed_msg, pos);
packed_msg, pos);
#endif
return packed_msg; return packed_msg;
} }
...@@ -313,8 +365,7 @@ fas216_get_last_msg(FAS216_Info *info, int pos) ...@@ -313,8 +365,7 @@ fas216_get_last_msg(FAS216_Info *info, int pos)
* : ns - period in ns (between subsequent bytes) * : ns - period in ns (between subsequent bytes)
* Returns : Value suitable for REG_STP * Returns : Value suitable for REG_STP
*/ */
static int static int fas216_syncperiod(FAS216_Info *info, int ns)
fas216_syncperiod(FAS216_Info *info, int ns)
{ {
int value = (info->ifcfg.clockrate * ns) / 1000; int value = (info->ifcfg.clockrate * ns) / 1000;
...@@ -336,8 +387,7 @@ fas216_syncperiod(FAS216_Info *info, int ns) ...@@ -336,8 +387,7 @@ fas216_syncperiod(FAS216_Info *info, int ns)
* a transfer period >= 200ns - otherwise the chip will violate * a transfer period >= 200ns - otherwise the chip will violate
* the SCSI timings. * the SCSI timings.
*/ */
static void static void fas216_set_sync(FAS216_Info *info, int target)
fas216_set_sync(FAS216_Info *info, int target)
{ {
outb(info->device[target].sof, REG_SOF(info)); outb(info->device[target].sof, REG_SOF(info));
outb(info->device[target].stp, REG_STP(info)); outb(info->device[target].stp, REG_STP(info));
...@@ -365,9 +415,9 @@ fas216_set_sync(FAS216_Info *info, int target) ...@@ -365,9 +415,9 @@ fas216_set_sync(FAS216_Info *info, int target)
* Using the correct method assures compatibility with wide data * Using the correct method assures compatibility with wide data
* transfers and future enhancements. * transfers and future enhancements.
* *
* We will always initiate a synchronous transfer negociation request on * We will always initiate a synchronous transfer negotiation request on
* every INQUIRY or REQUEST SENSE message, unless the target itself has * every INQUIRY or REQUEST SENSE message, unless the target itself has
* at some point performed a synchronous transfer negociation request, or * at some point performed a synchronous transfer negotiation request, or
* we have synchronous transfers disabled for this device. * we have synchronous transfers disabled for this device.
*/ */
...@@ -376,8 +426,7 @@ fas216_set_sync(FAS216_Info *info, int target) ...@@ -376,8 +426,7 @@ fas216_set_sync(FAS216_Info *info, int target)
* Params : info - state structure for interface * Params : info - state structure for interface
* : msg - message from target * : msg - message from target
*/ */
static void static void fas216_handlesync(FAS216_Info *info, char *msg)
fas216_handlesync(FAS216_Info *info, char *msg)
{ {
struct fas216_device *dev = &info->device[info->SCpnt->target]; struct fas216_device *dev = &info->device[info->SCpnt->target];
enum { sync, async, none, reject } res = none; enum { sync, async, none, reject } res = none;
...@@ -393,7 +442,7 @@ fas216_handlesync(FAS216_Info *info, char *msg) ...@@ -393,7 +442,7 @@ fas216_handlesync(FAS216_Info *info, char *msg)
* message with a MESSAGE REJECT message. * message with a MESSAGE REJECT message.
* *
* Hence, if we get this condition, we disable * Hence, if we get this condition, we disable
* negociation for this device. * negotiation for this device.
*/ */
if (dev->sync_state == neg_inprogress) { if (dev->sync_state == neg_inprogress) {
dev->sync_state = neg_invalid; dev->sync_state = neg_invalid;
...@@ -411,14 +460,14 @@ fas216_handlesync(FAS216_Info *info, char *msg) ...@@ -411,14 +460,14 @@ fas216_handlesync(FAS216_Info *info, char *msg)
res = reject; res = reject;
break; break;
/* We were not negociating a synchronous transfer, /* We were not negotiating a synchronous transfer,
* but the device sent us a negociation request. * but the device sent us a negotiation request.
* Honour the request by sending back a SDTR * Honour the request by sending back a SDTR
* message containing our capability, limited by * message containing our capability, limited by
* the targets capability. * the targets capability.
*/ */
default: default:
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
if (msg[4] > info->ifcfg.sync_max_depth) if (msg[4] > info->ifcfg.sync_max_depth)
msg[4] = info->ifcfg.sync_max_depth; msg[4] = info->ifcfg.sync_max_depth;
if (msg[3] < 1000 / info->ifcfg.clockrate) if (msg[3] < 1000 / info->ifcfg.clockrate)
...@@ -437,7 +486,7 @@ fas216_handlesync(FAS216_Info *info, char *msg) ...@@ -437,7 +486,7 @@ fas216_handlesync(FAS216_Info *info, char *msg)
res = sync; res = sync;
break; break;
/* We initiated the synchronous transfer negociation, /* We initiated the synchronous transfer negotiation,
* and have successfully received a response from the * and have successfully received a response from the
* target. The synchronous transfer agreement has been * target. The synchronous transfer agreement has been
* reached. Note: if the values returned are out of our * reached. Note: if the values returned are out of our
...@@ -466,7 +515,7 @@ fas216_handlesync(FAS216_Info *info, char *msg) ...@@ -466,7 +515,7 @@ fas216_handlesync(FAS216_Info *info, char *msg)
break; break;
case reject: case reject:
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT); msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
...@@ -488,8 +537,7 @@ fas216_handlesync(FAS216_Info *info, char *msg) ...@@ -488,8 +537,7 @@ fas216_handlesync(FAS216_Info *info, char *msg)
* Params : info - state structure for interface * Params : info - state structure for interface
* : msg - message from target * : msg - message from target
*/ */
static void static void fas216_handlewide(FAS216_Info *info, char *msg)
fas216_handlewide(FAS216_Info *info, char *msg)
{ {
struct fas216_device *dev = &info->device[info->SCpnt->target]; struct fas216_device *dev = &info->device[info->SCpnt->target];
enum { wide, bit8, none, reject } res = none; enum { wide, bit8, none, reject } res = none;
...@@ -505,7 +553,7 @@ fas216_handlewide(FAS216_Info *info, char *msg) ...@@ -505,7 +553,7 @@ fas216_handlewide(FAS216_Info *info, char *msg)
* WDTR message with a MESSAGE REJECT message. * WDTR message with a MESSAGE REJECT message.
* *
* Hence, if we get this condition, we never * Hence, if we get this condition, we never
* reattempt negociation for this device. * reattempt negotiation for this device.
*/ */
if (dev->wide_state == neg_inprogress) { if (dev->wide_state == neg_inprogress) {
dev->wide_state = neg_invalid; dev->wide_state = neg_invalid;
...@@ -523,14 +571,14 @@ fas216_handlewide(FAS216_Info *info, char *msg) ...@@ -523,14 +571,14 @@ fas216_handlewide(FAS216_Info *info, char *msg)
res = reject; res = reject;
break; break;
/* We were not negociating a wide data transfer, /* We were not negotiating a wide data transfer,
* but the device sent is a negociation request. * but the device sent is a negotiation request.
* Honour the request by sending back a WDTR * Honour the request by sending back a WDTR
* message containing our capability, limited by * message containing our capability, limited by
* the targets capability. * the targets capability.
*/ */
default: default:
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
if (msg[3] > info->ifcfg.wide_max_size) if (msg[3] > info->ifcfg.wide_max_size)
msg[3] = info->ifcfg.wide_max_size; msg[3] = info->ifcfg.wide_max_size;
...@@ -542,7 +590,7 @@ fas216_handlewide(FAS216_Info *info, char *msg) ...@@ -542,7 +590,7 @@ fas216_handlewide(FAS216_Info *info, char *msg)
res = wide; res = wide;
break; break;
/* We initiated the wide data transfer negociation, /* We initiated the wide data transfer negotiation,
* and have successfully received a response from the * and have successfully received a response from the
* target. The synchronous transfer agreement has been * target. The synchronous transfer agreement has been
* reached. Note: if the values returned are out of our * reached. Note: if the values returned are out of our
...@@ -567,7 +615,7 @@ fas216_handlewide(FAS216_Info *info, char *msg) ...@@ -567,7 +615,7 @@ fas216_handlewide(FAS216_Info *info, char *msg)
break; break;
case reject: case reject:
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT); msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
...@@ -586,13 +634,14 @@ fas216_handlewide(FAS216_Info *info, char *msg) ...@@ -586,13 +634,14 @@ fas216_handlewide(FAS216_Info *info, char *msg)
* Params : info - interface's local pointer to update * Params : info - interface's local pointer to update
* bytes_transferred - number of bytes transferred * bytes_transferred - number of bytes transferred
*/ */
static void static void fas216_updateptrs(FAS216_Info *info, int bytes_transferred)
fas216_updateptrs(FAS216_Info *info, int bytes_transferred)
{ {
Scsi_Pointer *SCp = &info->scsi.SCp; Scsi_Pointer *SCp = &info->scsi.SCp;
fas216_checkmagic(info); fas216_checkmagic(info);
BUG_ON(bytes_transferred < 0);
info->SCpnt->request_bufflen -= bytes_transferred; info->SCpnt->request_bufflen -= bytes_transferred;
while (bytes_transferred != 0) { while (bytes_transferred != 0) {
...@@ -623,8 +672,7 @@ fas216_updateptrs(FAS216_Info *info, int bytes_transferred) ...@@ -623,8 +672,7 @@ fas216_updateptrs(FAS216_Info *info, int bytes_transferred)
* direction - direction to transfer data (DMA_OUT/DMA_IN) * direction - direction to transfer data (DMA_OUT/DMA_IN)
* Notes : this is incredibly slow * Notes : this is incredibly slow
*/ */
static void static void fas216_pio(FAS216_Info *info, fasdmadir_t direction)
fas216_pio(FAS216_Info *info, fasdmadir_t direction)
{ {
fas216_checkmagic(info); fas216_checkmagic(info);
...@@ -634,53 +682,94 @@ fas216_pio(FAS216_Info *info, fasdmadir_t direction) ...@@ -634,53 +682,94 @@ fas216_pio(FAS216_Info *info, fasdmadir_t direction)
put_next_SCp_byte(&info->scsi.SCp, inb(REG_FF(info))); put_next_SCp_byte(&info->scsi.SCp, inb(REG_FF(info)));
} }
static void fas216_cleanuptransfer(FAS216_Info *info)
{
unsigned long total, residual, fifo;
if (info->dma.transfer_type == fasdma_real_all)
total = info->SCpnt->request_bufflen;
else
total = info->scsi.SCp.this_residual;
residual = inb(REG_CTCL(info)) + (inb(REG_CTCM(info)) << 8) +
(inb(REG_CTCH(info)) << 16);
fifo = inb(REG_CFIS(info)) & CFIS_CF;
fas216_log(info, LOG_BUFFER, "cleaning up from previous "
"transfer: length 0x%06x, residual 0x%x, fifo %d",
total, residual, fifo);
/*
* If we were performing Data-Out, the transfer counter
* counts down each time a byte is transferred by the
* host to the FIFO. This means we must include the
* bytes left in the FIFO from the transfer counter.
*/
if (info->scsi.phase == PHASE_DATAOUT) {
residual += fifo;
fifo = 0;
}
if (info->dma.transfer_type != fasdma_none &&
info->dma.transfer_type != fasdma_pio) {
fas216_updateptrs(info, total - residual);
}
/*
* If we were performing Data-In, then the FIFO counter
* contains the number of bytes not transferred via DMA
* from the on-board FIFO. Read them manually.
*/
if (info->scsi.phase == PHASE_DATAIN) {
while (fifo && info->scsi.SCp.ptr) {
*info->scsi.SCp.ptr = inb(REG_FF(info));
fas216_updateptrs(info, 1);
fifo--;
}
}
info->dma.transfer_type = fasdma_none;
}
/* Function: void fas216_starttransfer(FAS216_Info *info, /* Function: void fas216_starttransfer(FAS216_Info *info,
* fasdmadir_t direction) * fasdmadir_t direction)
* Purpose : Start a DMA/PIO transfer off of/on to card * Purpose : Start a DMA/PIO transfer off of/on to card
* Params : info - interface from which device disconnected from * Params : info - interface from which device disconnected from
* direction - transfer direction (DMA_OUT/DMA_IN) * direction - transfer direction (DMA_OUT/DMA_IN)
*/ */
static void static void fas216_starttransfer(FAS216_Info *info, fasdmadir_t direction)
fas216_starttransfer(FAS216_Info *info, fasdmadir_t direction, int flush_fifo)
{ {
fasdmatype_t dmatype; fasdmatype_t dmatype;
int phase = (direction == DMA_OUT) ? PHASE_DATAOUT : PHASE_DATAIN;
fas216_checkmagic(info); fas216_checkmagic(info);
info->scsi.phase = (direction == DMA_OUT) ? if (phase != info->scsi.phase) {
PHASE_DATAOUT : PHASE_DATAIN; info->scsi.phase = phase;
if (info->dma.transfer_type != fasdma_none &&
info->dma.transfer_type != fasdma_pio) {
unsigned long total, residual;
if (info->dma.transfer_type == fasdma_real_all)
total = info->SCpnt->request_bufflen;
else
total = info->scsi.SCp.this_residual;
residual = (inb(REG_CFIS(info)) & CFIS_CF) + if (direction == DMA_OUT)
inb(REG_CTCL(info)) + fas216_cmd(info, CMD_FLUSHFIFO);
(inb(REG_CTCM(info)) << 8) + } else {
(inb(REG_CTCH(info)) << 16); fas216_cleanuptransfer(info);
fas216_updateptrs(info, total - residual);
} }
info->dma.transfer_type = fasdma_none;
fas216_log(info, LOG_BUFFER,
"starttransfer: buffer %p length 0x%06x reqlen 0x%06x",
info->scsi.SCp.ptr, info->scsi.SCp.this_residual,
info->SCpnt->request_bufflen);
if (!info->scsi.SCp.ptr) { if (!info->scsi.SCp.ptr) {
printk("scsi%d.%c: null buffer passed to " fas216_log(info, LOG_ERROR, "null buffer passed to "
"fas216_starttransfer\n", info->host->host_no, "fas216_starttransfer");
fas216_target(info)); print_SCp(&info->scsi.SCp, "SCp: ", "\n");
print_SCp(&info->SCpnt->SCp, "Cmnd SCp: ", "\n");
return; return;
} }
/* flush FIFO */
if (flush_fifo)
outb(CMD_FLUSHFIFO, REG_CMD(info));
/* /*
* Default to PIO mode or DMA mode if we have a synchronous * Default to PIO mode or DMA mode if we have
* transfer agreement. * a synchronous transfer agreement.
*/ */
if (info->device[info->SCpnt->target].sof && info->dma.setup) if (info->device[info->SCpnt->target].sof && info->dma.setup)
dmatype = fasdma_real_all; dmatype = fasdma_real_all;
...@@ -694,41 +783,45 @@ fas216_starttransfer(FAS216_Info *info, fasdmadir_t direction, int flush_fifo) ...@@ -694,41 +783,45 @@ fas216_starttransfer(FAS216_Info *info, fasdmadir_t direction, int flush_fifo)
switch (dmatype) { switch (dmatype) {
case fasdma_pio: case fasdma_pio:
fas216_log(info, LOG_BUFFER, "PIO transfer");
outb(0, REG_SOF(info)); outb(0, REG_SOF(info));
outb(info->scsi.async_stp, REG_STP(info)); outb(info->scsi.async_stp, REG_STP(info));
outb(info->scsi.SCp.this_residual, REG_STCL(info)); outb(info->scsi.SCp.this_residual, REG_STCL(info));
outb(info->scsi.SCp.this_residual >> 8, REG_STCM(info)); outb(info->scsi.SCp.this_residual >> 8, REG_STCM(info));
outb(info->scsi.SCp.this_residual >> 16, REG_STCH(info)); outb(info->scsi.SCp.this_residual >> 16, REG_STCH(info));
outb(CMD_TRANSFERINFO, REG_CMD(info)); fas216_cmd(info, CMD_TRANSFERINFO);
fas216_pio(info, direction); fas216_pio(info, direction);
break; break;
case fasdma_pseudo: case fasdma_pseudo:
fas216_log(info, LOG_BUFFER, "pseudo transfer");
outb(info->scsi.SCp.this_residual, REG_STCL(info)); outb(info->scsi.SCp.this_residual, REG_STCL(info));
outb(info->scsi.SCp.this_residual >> 8, REG_STCM(info)); outb(info->scsi.SCp.this_residual >> 8, REG_STCM(info));
outb(info->scsi.SCp.this_residual >> 16, REG_STCH(info)); outb(info->scsi.SCp.this_residual >> 16, REG_STCH(info));
outb(CMD_TRANSFERINFO | CMD_WITHDMA, REG_CMD(info)); fas216_cmd(info, CMD_TRANSFERINFO | CMD_WITHDMA);
info->dma.pseudo(info->host, &info->scsi.SCp, info->dma.pseudo(info->host, &info->scsi.SCp,
direction, info->SCpnt->transfersize); direction, info->SCpnt->transfersize);
break; break;
case fasdma_real_block: case fasdma_real_block:
fas216_log(info, LOG_BUFFER, "block dma transfer");
outb(info->scsi.SCp.this_residual, REG_STCL(info)); outb(info->scsi.SCp.this_residual, REG_STCL(info));
outb(info->scsi.SCp.this_residual >> 8, REG_STCM(info)); outb(info->scsi.SCp.this_residual >> 8, REG_STCM(info));
outb(info->scsi.SCp.this_residual >> 16, REG_STCH(info)); outb(info->scsi.SCp.this_residual >> 16, REG_STCH(info));
outb(CMD_TRANSFERINFO | CMD_WITHDMA, REG_CMD(info)); fas216_cmd(info, CMD_TRANSFERINFO | CMD_WITHDMA);
break; break;
case fasdma_real_all: case fasdma_real_all:
fas216_log(info, LOG_BUFFER, "total dma transfer");
outb(info->SCpnt->request_bufflen, REG_STCL(info)); outb(info->SCpnt->request_bufflen, REG_STCL(info));
outb(info->SCpnt->request_bufflen >> 8, REG_STCM(info)); outb(info->SCpnt->request_bufflen >> 8, REG_STCM(info));
outb(info->SCpnt->request_bufflen >> 16, REG_STCH(info)); outb(info->SCpnt->request_bufflen >> 16, REG_STCH(info));
outb(CMD_TRANSFERINFO | CMD_WITHDMA, REG_CMD(info)); fas216_cmd(info, CMD_TRANSFERINFO | CMD_WITHDMA);
break; break;
default: default:
printk(KERN_ERR "scsi%d.%d: invalid FAS216 DMA type\n", fas216_log(info, LOG_BUFFER | LOG_ERROR,
info->host->host_no, fas216_target(info)); "invalid FAS216 DMA type");
break; break;
} }
} }
...@@ -737,51 +830,49 @@ fas216_starttransfer(FAS216_Info *info, fasdmadir_t direction, int flush_fifo) ...@@ -737,51 +830,49 @@ fas216_starttransfer(FAS216_Info *info, fasdmadir_t direction, int flush_fifo)
* Purpose : Stop a DMA transfer onto / off of the card * Purpose : Stop a DMA transfer onto / off of the card
* Params : info - interface from which device disconnected from * Params : info - interface from which device disconnected from
*/ */
static void static void fas216_stoptransfer(FAS216_Info *info)
fas216_stoptransfer(FAS216_Info *info)
{ {
fas216_checkmagic(info); fas216_checkmagic(info);
if (info->dma.transfer_type != fasdma_none &&
info->dma.transfer_type != fasdma_pio) {
unsigned long total, residual;
if ((info->dma.transfer_type == fasdma_real_all || if ((info->dma.transfer_type == fasdma_real_all ||
info->dma.transfer_type == fasdma_real_block) && info->dma.transfer_type == fasdma_real_block) &&
info->dma.stop) info->dma.stop)
info->dma.stop(info->host, &info->scsi.SCp); info->dma.stop(info->host, &info->scsi.SCp);
if (info->dma.transfer_type == fasdma_real_all) fas216_cleanuptransfer(info);
total = info->SCpnt->request_bufflen;
else
total = info->scsi.SCp.this_residual;
residual = (inb(REG_CFIS(info)) & CFIS_CF) +
inb(REG_CTCL(info)) +
(inb(REG_CTCM(info)) << 8) +
(inb(REG_CTCH(info)) << 16);
fas216_updateptrs(info, total - residual);
info->dma.transfer_type = fasdma_none;
}
if (info->scsi.phase == PHASE_DATAOUT) if (info->scsi.phase == PHASE_DATAOUT)
outb(CMD_FLUSHFIFO, REG_CMD(info)); fas216_cmd(info, CMD_FLUSHFIFO);
}
static void fas216_aborttransfer(FAS216_Info *info)
{
fas216_checkmagic(info);
if ((info->dma.transfer_type == fasdma_real_all ||
info->dma.transfer_type == fasdma_real_block) &&
info->dma.stop)
info->dma.stop(info->host, &info->scsi.SCp);
info->dma.transfer_type = fasdma_none;
fas216_cmd(info, CMD_FLUSHFIFO);
} }
/* Function: void fas216_disconnected_intr(FAS216_Info *info) /* Function: void fas216_disconnected_intr(FAS216_Info *info)
* Purpose : handle device disconnection * Purpose : handle device disconnection
* Params : info - interface from which device disconnected from * Params : info - interface from which device disconnected from
*/ */
static void static void fas216_disconnect_intr(FAS216_Info *info)
fas216_disconnect_intr(FAS216_Info *info)
{ {
fas216_checkmagic(info); fas216_checkmagic(info);
#ifdef DEBUG_CONNECT fas216_log(info, LOG_CONNECT, "disconnect phase=%02x",
printk("scsi%d.%c: disconnect phase=%02X\n", info->host->host_no, info->scsi.phase);
fas216_target(info), info->scsi.phase);
#endif
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
fas216_cmd(info, CMD_ENABLESEL);
switch (info->scsi.phase) { switch (info->scsi.phase) {
case PHASE_SELECTION: /* while selecting - no target */ case PHASE_SELECTION: /* while selecting - no target */
case PHASE_SELSTEPS: case PHASE_SELSTEPS:
...@@ -789,7 +880,6 @@ fas216_disconnect_intr(FAS216_Info *info) ...@@ -789,7 +880,6 @@ fas216_disconnect_intr(FAS216_Info *info)
break; break;
case PHASE_MSGIN_DISCONNECT: /* message in - disconnecting */ case PHASE_MSGIN_DISCONNECT: /* message in - disconnecting */
outb(CMD_ENABLESEL, REG_CMD(info));
info->scsi.disconnectable = 1; info->scsi.disconnectable = 1;
info->scsi.reconnected.tag = 0; info->scsi.reconnected.tag = 0;
info->scsi.phase = PHASE_IDLE; info->scsi.phase = PHASE_IDLE;
...@@ -841,19 +931,16 @@ fas216_reselected_intr(FAS216_Info *info) ...@@ -841,19 +931,16 @@ fas216_reselected_intr(FAS216_Info *info)
info->device[SCpnt->target].sync_state = neg_wait; info->device[SCpnt->target].sync_state = neg_wait;
} }
#ifdef DEBUG_CONNECT fas216_log(info, LOG_CONNECT, "reconnect phase=%02X", info->scsi.phase);
printk("scsi%d.%c: reconnect phase=%02X\n", info->host->host_no,
fas216_target(info), info->scsi.phase);
#endif
if ((inb(REG_CFIS(info)) & CFIS_CF) != 2) { if ((inb(REG_CFIS(info)) & CFIS_CF) != 2) {
printk(KERN_ERR "scsi%d.H: incorrect number of bytes after reselect\n", printk(KERN_ERR "scsi%d.H: incorrect number of bytes after reselect\n",
info->host->host_no); info->host->host_no);
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
outb(CMD_MSGACCEPTED, REG_CMD(info));
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR); msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
fas216_cmd(info, CMD_MSGACCEPTED);
return; return;
} }
...@@ -877,11 +964,11 @@ fas216_reselected_intr(FAS216_Info *info) ...@@ -877,11 +964,11 @@ fas216_reselected_intr(FAS216_Info *info)
* Something went wrong - send an initiator error to * Something went wrong - send an initiator error to
* the target. * the target.
*/ */
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
outb(CMD_MSGACCEPTED, REG_CMD(info));
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR); msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
fas216_cmd(info, CMD_MSGACCEPTED);
return; return;
} }
...@@ -903,6 +990,9 @@ fas216_reselected_intr(FAS216_Info *info) ...@@ -903,6 +990,9 @@ fas216_reselected_intr(FAS216_Info *info)
info->scsi.reconnected.lun = identify_msg; info->scsi.reconnected.lun = identify_msg;
info->scsi.reconnected.tag = 0; info->scsi.reconnected.tag = 0;
/* set up for synchronous transfers */
fas216_set_sync(info, target);
ok = 0; ok = 0;
if (info->scsi.disconnectable && info->SCpnt && if (info->scsi.disconnectable && info->SCpnt &&
info->SCpnt->target == target && info->SCpnt->lun == identify_msg) info->SCpnt->target == target && info->SCpnt->lun == identify_msg)
...@@ -922,12 +1012,12 @@ fas216_reselected_intr(FAS216_Info *info) ...@@ -922,12 +1012,12 @@ fas216_reselected_intr(FAS216_Info *info)
* record of this command, we can't send * record of this command, we can't send
* an INITIATOR DETECTED ERROR message. * an INITIATOR DETECTED ERROR message.
*/ */
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
msgqueue_addmsg(&info->scsi.msgs, 1, ABORT); msgqueue_addmsg(&info->scsi.msgs, 1, ABORT);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
} }
outb(CMD_MSGACCEPTED, REG_CMD(info)); fas216_cmd(info, CMD_MSGACCEPTED);
} }
/* Function: void fas216_finish_reconnect(FAS216_Info *info) /* Function: void fas216_finish_reconnect(FAS216_Info *info)
...@@ -939,28 +1029,20 @@ fas216_finish_reconnect(FAS216_Info *info) ...@@ -939,28 +1029,20 @@ fas216_finish_reconnect(FAS216_Info *info)
{ {
fas216_checkmagic(info); fas216_checkmagic(info);
#ifdef DEBUG_CONNECT fas216_log(info, LOG_CONNECT, "Connected: %1x %1x %02x, reconnected: %1x %1x %02x",
printk("Connected: %1X %1X %02X, reconnected: %1X %1X %02X\n",
info->SCpnt->target, info->SCpnt->lun, info->SCpnt->tag, info->SCpnt->target, info->SCpnt->lun, info->SCpnt->tag,
info->scsi.reconnected.target, info->scsi.reconnected.lun, info->scsi.reconnected.target, info->scsi.reconnected.lun,
info->scsi.reconnected.tag); info->scsi.reconnected.tag);
#endif
if (info->scsi.disconnectable && info->SCpnt) { if (info->scsi.disconnectable && info->SCpnt) {
info->scsi.disconnectable = 0; info->scsi.disconnectable = 0;
if (info->SCpnt->target == info->scsi.reconnected.target && if (info->SCpnt->target == info->scsi.reconnected.target &&
info->SCpnt->lun == info->scsi.reconnected.lun && info->SCpnt->lun == info->scsi.reconnected.lun &&
info->SCpnt->tag == info->scsi.reconnected.tag) { info->SCpnt->tag == info->scsi.reconnected.tag) {
#ifdef DEBUG_CONNECT fas216_log(info, LOG_CONNECT, "reconnected");
printk("scsi%d.%c: reconnected",
info->host->host_no, fas216_target(info));
#endif
} else { } else {
queue_add_cmd_tail(&info->queues.disconnected, info->SCpnt); queue_add_cmd_tail(&info->queues.disconnected, info->SCpnt);
#ifdef DEBUG_CONNECT fas216_log(info, LOG_CONNECT, "had to move command to disconnected queue");
printk("scsi%d.%c: had to move command to disconnected queue\n",
info->host->host_no, fas216_target(info));
#endif
info->SCpnt = NULL; info->SCpnt = NULL;
} }
} }
...@@ -969,20 +1051,19 @@ fas216_finish_reconnect(FAS216_Info *info) ...@@ -969,20 +1051,19 @@ fas216_finish_reconnect(FAS216_Info *info)
info->scsi.reconnected.target, info->scsi.reconnected.target,
info->scsi.reconnected.lun, info->scsi.reconnected.lun,
info->scsi.reconnected.tag); info->scsi.reconnected.tag);
#ifdef DEBUG_CONNECT fas216_log(info, LOG_CONNECT, "had to get command");
printk("scsi%d.%c: had to get command",
info->host->host_no, fas216_target(info));
#endif
} }
if (!info->SCpnt) { if (!info->SCpnt) {
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
#if 0 #if 0
if (info->scsi.reconnected.tag) if (info->scsi.reconnected.tag)
msgqueue_addmsg(&info->scsi.msgs, 2, ABORT_TAG, info->scsi.reconnected.tag); msgqueue_addmsg(&info->scsi.msgs, 2, ABORT_TAG, info->scsi.reconnected.tag);
else else
#endif #endif
msgqueue_addmsg(&info->scsi.msgs, 1, ABORT); msgqueue_addmsg(&info->scsi.msgs, 1, ABORT);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
info->scsi.aborting = 1; info->scsi.aborting = 1;
} else { } else {
...@@ -990,123 +1071,15 @@ fas216_finish_reconnect(FAS216_Info *info) ...@@ -990,123 +1071,15 @@ fas216_finish_reconnect(FAS216_Info *info)
* Restore data pointer from SAVED data pointer * Restore data pointer from SAVED data pointer
*/ */
info->scsi.SCp = info->SCpnt->SCp; info->scsi.SCp = info->SCpnt->SCp;
#ifdef DEBUG_CONNECT fas216_log(info, LOG_CONNECT, "data pointers: [%p, %X]",
printk(", data pointers: [%p, %X]",
info->scsi.SCp.ptr, info->scsi.SCp.this_residual); info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
#endif
}
#ifdef DEBUG_CONNECT
printk("\n");
#endif
}
static int fas216_wait_cmd(FAS216_Info *info, int cmd)
{
int tout;
int stat;
outb(cmd, REG_CMD(info));
for (tout = 1000; tout; tout -= 1) {
stat = inb(REG_STAT(info));
if (stat & STAT_INT)
break;
udelay(1);
} }
return stat;
}
static int fas216_get_msg_byte(FAS216_Info *info)
{
int stat;
stat = fas216_wait_cmd(info, CMD_MSGACCEPTED);
if ((stat & STAT_INT) == 0)
goto timedout;
if ((stat & STAT_BUSMASK) != STAT_MESGIN)
goto unexpected_phase_change;
inb(REG_INST(info));
stat = fas216_wait_cmd(info, CMD_TRANSFERINFO);
if ((stat & STAT_INT) == 0)
goto timedout;
if ((stat & STAT_BUSMASK) != STAT_MESGIN)
goto unexpected_phase_change;
inb(REG_INST(info));
return inb(REG_FF(info));
timedout:
printk("scsi%d.%c: timed out waiting for message byte\n",
info->host->host_no, fas216_target(info));
return -1;
unexpected_phase_change:
printk("scsi%d.%c: unexpected phase change: status = %02X\n",
info->host->host_no, fas216_target(info), stat);
return -2;
} }
/* Function: void fas216_message(FAS216_Info *info) static void fas216_parse_message(FAS216_Info *info, unsigned char *message, int msglen)
* Purpose : handle a function done interrupt from FAS216 chip
* Params : info - interface which caused function done interrupt
*/
static void fas216_message(FAS216_Info *info)
{ {
unsigned char *message = info->scsi.message;
unsigned int msglen = 1, i;
int msgbyte = 0;
fas216_checkmagic(info);
message[0] = inb(REG_FF(info));
if (message[0] == EXTENDED_MESSAGE) {
msgbyte = fas216_get_msg_byte(info);
if (msgbyte >= 0) {
message[1] = msgbyte;
for (msglen = 2; msglen < message[1] + 2; msglen++) {
msgbyte = fas216_get_msg_byte(info);
if (msgbyte >= 0)
message[msglen] = msgbyte;
else
break;
}
}
}
info->scsi.msglen = msglen;
#ifdef DEBUG_MESSAGES
{
int i; int i;
printk("scsi%d.%c: message in: ",
info->host->host_no, fas216_target(info));
for (i = 0; i < msglen; i++)
printk("%02X ", message[i]);
printk("\n");
}
#endif
if (info->scsi.phase == PHASE_RECONNECTED) {
if (message[0] == SIMPLE_QUEUE_TAG)
info->scsi.reconnected.tag = message[1];
fas216_finish_reconnect(info);
info->scsi.phase = PHASE_MSGIN;
}
switch (message[0]) { switch (message[0]) {
case COMMAND_COMPLETE: case COMMAND_COMPLETE:
if (msglen != 1) if (msglen != 1)
...@@ -1131,11 +1104,9 @@ static void fas216_message(FAS216_Info *info) ...@@ -1131,11 +1104,9 @@ static void fas216_message(FAS216_Info *info)
*/ */
info->SCpnt->SCp = info->scsi.SCp; info->SCpnt->SCp = info->scsi.SCp;
info->SCpnt->SCp.sent_command = 0; info->SCpnt->SCp.sent_command = 0;
#if defined (DEBUG_MESSAGES) || defined (DEBUG_CONNECT) fas216_log(info, LOG_CONNECT | LOG_MESSAGES | LOG_BUFFER,
printk("scsi%d.%c: save data pointers: [%p, %X]\n", "save data pointers: [%p, %X]",
info->host->host_no, fas216_target(info),
info->scsi.SCp.ptr, info->scsi.SCp.this_residual); info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
#endif
break; break;
case RESTORE_POINTERS: case RESTORE_POINTERS:
...@@ -1146,11 +1117,9 @@ static void fas216_message(FAS216_Info *info) ...@@ -1146,11 +1117,9 @@ static void fas216_message(FAS216_Info *info)
* Restore current data pointer from SAVED data pointer * Restore current data pointer from SAVED data pointer
*/ */
info->scsi.SCp = info->SCpnt->SCp; info->scsi.SCp = info->SCpnt->SCp;
#if defined (DEBUG_MESSAGES) || defined (DEBUG_CONNECT) fas216_log(info, LOG_CONNECT | LOG_MESSAGES | LOG_BUFFER,
printk("scsi%d.%c: restore data pointers: [%p, %X]\n", "restore data pointers: [%p, 0x%x]",
info->host->host_no, fas216_target(info),
info->scsi.SCp.ptr, info->scsi.SCp.this_residual); info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
#endif
break; break;
case DISCONNECT: case DISCONNECT:
...@@ -1174,8 +1143,7 @@ static void fas216_message(FAS216_Info *info) ...@@ -1174,8 +1143,7 @@ static void fas216_message(FAS216_Info *info)
break; break;
default: default:
printk("scsi%d.%c: reject, last message %04X\n", fas216_log(info, 0, "reject, last message 0x%04x",
info->host->host_no, fas216_target(info),
fas216_get_last_msg(info, info->scsi.msgin_fifo)); fas216_get_last_msg(info, info->scsi.msgin_fifo));
} }
break; break;
...@@ -1188,9 +1156,7 @@ static void fas216_message(FAS216_Info *info) ...@@ -1188,9 +1156,7 @@ static void fas216_message(FAS216_Info *info)
goto unrecognised; goto unrecognised;
/* handled above - print a warning since this is untested */ /* handled above - print a warning since this is untested */
printk("scsi%d.%c: reconnect queue tag %02X\n", fas216_log(info, 0, "reconnect queue tag 0x%02x", message[1]);
info->host->host_no, fas216_target(info),
message[1]);
break; break;
case EXTENDED_MESSAGE: case EXTENDED_MESSAGE:
...@@ -1198,11 +1164,11 @@ static void fas216_message(FAS216_Info *info) ...@@ -1198,11 +1164,11 @@ static void fas216_message(FAS216_Info *info)
goto unrecognised; goto unrecognised;
switch (message[2]) { switch (message[2]) {
case EXTENDED_SDTR: /* Sync transfer negociation request/reply */ case EXTENDED_SDTR: /* Sync transfer negotiation request/reply */
fas216_handlesync(info, message); fas216_handlesync(info, message);
break; break;
case EXTENDED_WDTR: /* Wide transfer negociation request/reply */ case EXTENDED_WDTR: /* Wide transfer negotiation request/reply */
fas216_handlewide(info, message); fas216_handlewide(info, message);
break; break;
...@@ -1214,12 +1180,10 @@ static void fas216_message(FAS216_Info *info) ...@@ -1214,12 +1180,10 @@ static void fas216_message(FAS216_Info *info)
default: default:
goto unrecognised; goto unrecognised;
} }
outb(CMD_MSGACCEPTED, REG_CMD(info));
return; return;
unrecognised: unrecognised:
printk("scsi%d.%c: unrecognised message, rejecting\n", fas216_log(info, 0, "unrecognised message, rejecting");
info->host->host_no, fas216_target(info));
printk("scsi%d.%c: message was", info->host->host_no, fas216_target(info)); printk("scsi%d.%c: message was", info->host->host_no, fas216_target(info));
for (i = 0; i < msglen; i++) for (i = 0; i < msglen; i++)
printk("%s%02X", i & 31 ? " " : "\n ", message[i]); printk("%s%02X", i & 31 ? " " : "\n ", message[i]);
...@@ -1230,39 +1194,163 @@ static void fas216_message(FAS216_Info *info) ...@@ -1230,39 +1194,163 @@ static void fas216_message(FAS216_Info *info)
* I can't use SETATN since the chip gives me an * I can't use SETATN since the chip gives me an
* invalid command interrupt when I do. Weird. * invalid command interrupt when I do. Weird.
*/ */
outb(CMD_NOP, REG_CMD(info)); fas216_cmd(info, CMD_NOP);
fas216_dumpstate(info); fas216_dumpstate(info);
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT); msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
fas216_dumpstate(info); fas216_dumpstate(info);
outb(CMD_MSGACCEPTED, REG_CMD(info));
} }
/* Function: void fas216_send_command(FAS216_Info *info) static int fas216_wait_cmd(FAS216_Info *info, int cmd)
* Purpose : send a command to a target after all message bytes have been sent
* Params : info - interface which caused bus service
*/
static void fas216_send_command(FAS216_Info *info)
{ {
int i; int tout;
int stat;
fas216_checkmagic(info);
outb(CMD_NOP|CMD_WITHDMA, REG_CMD(info));
outb(CMD_FLUSHFIFO, REG_CMD(info));
/* load command */ fas216_cmd(info, cmd);
for (i = info->scsi.SCp.sent_command; i < info->SCpnt->cmd_len; i++)
outb(info->SCpnt->cmnd[i], REG_FF(info));
outb(CMD_TRANSFERINFO, REG_CMD(info)); for (tout = 1000; tout; tout -= 1) {
stat = inb(REG_STAT(info));
if (stat & (STAT_INT|STAT_PARITYERROR))
break;
udelay(1);
}
info->scsi.phase = PHASE_COMMAND; return stat;
} }
/* Function: void fas216_send_messageout(FAS216_Info *info, int start) static int fas216_get_msg_byte(FAS216_Info *info)
{
unsigned int stat = fas216_wait_cmd(info, CMD_MSGACCEPTED);
if ((stat & STAT_INT) == 0)
goto timedout;
if ((stat & STAT_BUSMASK) != STAT_MESGIN)
goto unexpected_phase_change;
inb(REG_INST(info));
stat = fas216_wait_cmd(info, CMD_TRANSFERINFO);
if ((stat & STAT_INT) == 0)
goto timedout;
if (stat & STAT_PARITYERROR)
goto parity_error;
if ((stat & STAT_BUSMASK) != STAT_MESGIN)
goto unexpected_phase_change;
inb(REG_INST(info));
return inb(REG_FF(info));
timedout:
fas216_log(info, LOG_ERROR, "timed out waiting for message byte");
return -1;
unexpected_phase_change:
fas216_log(info, LOG_ERROR, "unexpected phase change: status = %02x", stat);
return -2;
parity_error:
fas216_log(info, LOG_ERROR, "parity error during message in phase");
return -3;
}
/* Function: void fas216_message(FAS216_Info *info)
* Purpose : handle a function done interrupt from FAS216 chip
* Params : info - interface which caused function done interrupt
*/
static void fas216_message(FAS216_Info *info)
{
unsigned char *message = info->scsi.message;
unsigned int msglen = 1;
int msgbyte = 0;
fas216_checkmagic(info);
message[0] = inb(REG_FF(info));
if (message[0] == EXTENDED_MESSAGE) {
msgbyte = fas216_get_msg_byte(info);
if (msgbyte >= 0) {
message[1] = msgbyte;
for (msglen = 2; msglen < message[1] + 2; msglen++) {
msgbyte = fas216_get_msg_byte(info);
if (msgbyte >= 0)
message[msglen] = msgbyte;
else
break;
}
}
}
if (msgbyte == -3)
goto parity_error;
info->scsi.msglen = msglen;
#ifdef DEBUG_MESSAGES
{
int i;
printk("scsi%d.%c: message in: ",
info->host->host_no, fas216_target(info));
for (i = 0; i < msglen; i++)
printk("%02X ", message[i]);
printk("\n");
}
#endif
if (info->scsi.phase == PHASE_RECONNECTED) {
if (message[0] == SIMPLE_QUEUE_TAG)
info->scsi.reconnected.tag = message[1];
fas216_finish_reconnect(info);
info->scsi.phase = PHASE_MSGIN;
}
fas216_parse_message(info, message, msglen);
fas216_cmd(info, CMD_MSGACCEPTED);
return;
parity_error:
fas216_cmd(info, CMD_SETATN);
msgqueue_flush(&info->scsi.msgs);
msgqueue_addmsg(&info->scsi.msgs, 1, MSG_PARITY_ERROR);
info->scsi.phase = PHASE_MSGOUT_EXPECT;
fas216_cmd(info, CMD_MSGACCEPTED);
return;
}
/* Function: void fas216_send_command(FAS216_Info *info)
* Purpose : send a command to a target after all message bytes have been sent
* Params : info - interface which caused bus service
*/
static void fas216_send_command(FAS216_Info *info)
{
int i;
fas216_checkmagic(info);
fas216_cmd(info, CMD_NOP|CMD_WITHDMA);
fas216_cmd(info, CMD_FLUSHFIFO);
/* load command */
for (i = info->scsi.SCp.sent_command; i < info->SCpnt->cmd_len; i++)
outb(info->SCpnt->cmnd[i], REG_FF(info));
fas216_cmd(info, CMD_TRANSFERINFO);
info->scsi.phase = PHASE_COMMAND;
}
/* Function: void fas216_send_messageout(FAS216_Info *info, int start)
* Purpose : handle bus service to send a message * Purpose : handle bus service to send a message
* Params : info - interface which caused bus service * Params : info - interface which caused bus service
* Note : We do not allow the device to change the data direction! * Note : We do not allow the device to change the data direction!
...@@ -1273,7 +1361,7 @@ static void fas216_send_messageout(FAS216_Info *info, int start) ...@@ -1273,7 +1361,7 @@ static void fas216_send_messageout(FAS216_Info *info, int start)
fas216_checkmagic(info); fas216_checkmagic(info);
outb(CMD_FLUSHFIFO, REG_CMD(info)); fas216_cmd(info, CMD_FLUSHFIFO);
if (tot_msglen) { if (tot_msglen) {
struct message *msg; struct message *msg;
...@@ -1291,7 +1379,7 @@ static void fas216_send_messageout(FAS216_Info *info, int start) ...@@ -1291,7 +1379,7 @@ static void fas216_send_messageout(FAS216_Info *info, int start)
} else } else
outb(NOP, REG_FF(info)); outb(NOP, REG_FF(info));
outb(CMD_TRANSFERINFO, REG_CMD(info)); fas216_cmd(info, CMD_TRANSFERINFO);
info->scsi.phase = PHASE_MSGOUT; info->scsi.phase = PHASE_MSGOUT;
} }
...@@ -1306,10 +1394,9 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1306,10 +1394,9 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
{ {
fas216_checkmagic(info); fas216_checkmagic(info);
#ifdef DEBUG_BUSSERVICE fas216_log(info, LOG_BUSSERVICE,
printk("scsi%d.%c: bus service: stat=%02X ssr=%02X phase=%02X\n", "bus service: stat=%02x ssr=%02x phase=%02x",
info->host->host_no, fas216_target(info), stat, ssr, info->scsi.phase); stat, ssr, info->scsi.phase);
#endif
switch (info->scsi.phase) { switch (info->scsi.phase) {
case PHASE_SELECTION: case PHASE_SELECTION:
...@@ -1337,7 +1424,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1337,7 +1424,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
break; break;
} }
outb(CMD_NOP, REG_CMD(info)); fas216_cmd(info, CMD_NOP);
#define STATE(st,ph) ((ph) << 3 | (st)) #define STATE(st,ph) ((ph) << 3 | (st))
/* This table describes the legal SCSI state transitions, /* This table describes the legal SCSI state transitions,
...@@ -1352,11 +1439,11 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1352,11 +1439,11 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
case STATE(STAT_DATAIN, PHASE_MSGOUT): /* Message Out -> Data In */ case STATE(STAT_DATAIN, PHASE_MSGOUT): /* Message Out -> Data In */
case STATE(STAT_DATAIN, PHASE_COMMAND): /* Command -> Data In */ case STATE(STAT_DATAIN, PHASE_COMMAND): /* Command -> Data In */
case STATE(STAT_DATAIN, PHASE_MSGIN): /* Message In -> Data In */ case STATE(STAT_DATAIN, PHASE_MSGIN): /* Message In -> Data In */
fas216_starttransfer(info, DMA_IN, 0); fas216_starttransfer(info, DMA_IN);
return; return;
case STATE(STAT_DATAOUT, PHASE_DATAOUT):/* Data Out -> Data Out */ case STATE(STAT_DATAOUT, PHASE_DATAOUT):/* Data Out -> Data Out */
fas216_starttransfer(info, DMA_OUT, 0); fas216_starttransfer(info, DMA_OUT);
return; return;
/* Reselmsgin -> Data Out */ /* Reselmsgin -> Data Out */
...@@ -1366,7 +1453,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1366,7 +1453,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
case STATE(STAT_DATAOUT, PHASE_MSGOUT): /* Message Out -> Data Out */ case STATE(STAT_DATAOUT, PHASE_MSGOUT): /* Message Out -> Data Out */
case STATE(STAT_DATAOUT, PHASE_COMMAND):/* Command -> Data Out */ case STATE(STAT_DATAOUT, PHASE_COMMAND):/* Command -> Data Out */
case STATE(STAT_DATAOUT, PHASE_MSGIN): /* Message In -> Data Out */ case STATE(STAT_DATAOUT, PHASE_MSGIN): /* Message In -> Data Out */
fas216_starttransfer(info, DMA_OUT, 1); fas216_starttransfer(info, DMA_OUT);
return; return;
/* Reselmsgin -> Status */ /* Reselmsgin -> Status */
...@@ -1381,7 +1468,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1381,7 +1468,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
case STATE(STAT_STATUS, PHASE_COMMAND): /* Command -> Status */ case STATE(STAT_STATUS, PHASE_COMMAND): /* Command -> Status */
case STATE(STAT_STATUS, PHASE_MSGIN): /* Message In -> Status */ case STATE(STAT_STATUS, PHASE_MSGIN): /* Message In -> Status */
status: status:
outb(CMD_INITCMDCOMPLETE, REG_CMD(info)); fas216_cmd(info, CMD_INITCMDCOMPLETE);
info->scsi.phase = PHASE_STATUS; info->scsi.phase = PHASE_STATUS;
return; return;
...@@ -1392,8 +1479,8 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1392,8 +1479,8 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
case STATE(STAT_MESGIN, PHASE_SELSTEPS):/* Sel w/ steps -> Message In */ case STATE(STAT_MESGIN, PHASE_SELSTEPS):/* Sel w/ steps -> Message In */
case STATE(STAT_MESGIN, PHASE_MSGOUT): /* Message Out -> Message In */ case STATE(STAT_MESGIN, PHASE_MSGOUT): /* Message Out -> Message In */
info->scsi.msgin_fifo = inb(REG_CFIS(info)) & CFIS_CF; info->scsi.msgin_fifo = inb(REG_CFIS(info)) & CFIS_CF;
outb(CMD_FLUSHFIFO, REG_CMD(info)); fas216_cmd(info, CMD_FLUSHFIFO);
outb(CMD_TRANSFERINFO, REG_CMD(info)); fas216_cmd(info, CMD_TRANSFERINFO);
info->scsi.phase = PHASE_MSGIN; info->scsi.phase = PHASE_MSGIN;
return; return;
...@@ -1401,7 +1488,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1401,7 +1488,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
case STATE(STAT_MESGIN, PHASE_RECONNECTED): case STATE(STAT_MESGIN, PHASE_RECONNECTED):
case STATE(STAT_MESGIN, PHASE_MSGIN): case STATE(STAT_MESGIN, PHASE_MSGIN):
info->scsi.msgin_fifo = inb(REG_CFIS(info)) & CFIS_CF; info->scsi.msgin_fifo = inb(REG_CFIS(info)) & CFIS_CF;
outb(CMD_TRANSFERINFO, REG_CMD(info)); fas216_cmd(info, CMD_TRANSFERINFO);
return; return;
/* Reselmsgin -> Command */ /* Reselmsgin -> Command */
...@@ -1412,11 +1499,43 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1412,11 +1499,43 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
fas216_send_command(info); fas216_send_command(info);
info->scsi.phase = PHASE_COMMAND; info->scsi.phase = PHASE_COMMAND;
return; return;
/* Selection -> Message Out */
/*
* Selection -> Message Out
*/
case STATE(STAT_MESGOUT, PHASE_SELECTION): case STATE(STAT_MESGOUT, PHASE_SELECTION):
fas216_send_messageout(info, 1); fas216_send_messageout(info, 1);
return; return;
/* Any -> Message Out */
/*
* Message Out -> Message Out
*/
case STATE(STAT_MESGOUT, PHASE_SELSTEPS):
case STATE(STAT_MESGOUT, PHASE_MSGOUT):
/*
* If we get another message out phase, this usually
* means some parity error occurred. Resend complete
* set of messages. If we have more than one byte to
* send, we need to assert ATN again.
*/
if (info->device[info->SCpnt->target].parity_check) {
/*
* We were testing... good, the device
* supports parity checking.
*/
info->device[info->SCpnt->target].parity_check = 0;
info->device[info->SCpnt->target].parity_enabled = 1;
outb(info->scsi.cfg[0], REG_CNTL1(info));
}
if (msgqueue_msglength(&info->scsi.msgs) > 1)
fas216_cmd(info, CMD_SETATN);
/*FALLTHROUGH*/
/*
* Any -> Message Out
*/
case STATE(STAT_MESGOUT, PHASE_MSGOUT_EXPECT): case STATE(STAT_MESGOUT, PHASE_MSGOUT_EXPECT):
fas216_send_messageout(info, 0); fas216_send_messageout(info, 0);
return; return;
...@@ -1435,29 +1554,14 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1435,29 +1554,14 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
printk(KERN_ERR "scsi%d.%c: " printk(KERN_ERR "scsi%d.%c: "
"target trying to receive more command bytes\n", "target trying to receive more command bytes\n",
info->host->host_no, fas216_target(info)); info->host->host_no, fas216_target(info));
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
outb(15, REG_STCL(info)); outb(15, REG_STCL(info));
outb(0, REG_STCM(info)); outb(0, REG_STCM(info));
outb(0, REG_STCH(info)); outb(0, REG_STCH(info));
outb(CMD_PADBYTES | CMD_WITHDMA, REG_CMD(info)); fas216_cmd(info, CMD_PADBYTES | CMD_WITHDMA);
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR); msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
return;
/* Selection -> Message Out */
case STATE(STAT_MESGOUT, PHASE_SELSTEPS):
case STATE(STAT_MESGOUT, PHASE_MSGOUT): /* Message Out -> Message Out */
/* If we get another message out phase, this
* usually means some parity error occurred.
* Resend complete set of messages. If we have
* more than 1 byte to send, we need to assert
* ATN again.
*/
if (msgqueue_msglength(&info->scsi.msgs) > 1)
outb(CMD_SETATN, REG_CMD(info));
fas216_send_messageout(info, 0);
return; return;
} }
...@@ -1466,11 +1570,11 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1466,11 +1570,11 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
info->host->host_no, fas216_target(info), info->host->host_no, fas216_target(info),
fas216_bus_phase(stat)); fas216_bus_phase(stat));
msgqueue_flush(&info->scsi.msgs); msgqueue_flush(&info->scsi.msgs);
outb(CMD_SETATN, REG_CMD(info)); fas216_cmd(info, CMD_SETATN);
msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR); msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR);
info->scsi.phase = PHASE_MSGOUT_EXPECT; info->scsi.phase = PHASE_MSGOUT_EXPECT;
info->scsi.aborting = 1; info->scsi.aborting = 1;
outb(CMD_TRANSFERINFO, REG_CMD(info)); fas216_cmd(info, CMD_TRANSFERINFO);
return; return;
} }
printk(KERN_ERR "scsi%d.%c: bus phase %s after %s?\n", printk(KERN_ERR "scsi%d.%c: bus phase %s after %s?\n",
...@@ -1481,9 +1585,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1481,9 +1585,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
return; return;
bad_is: bad_is:
printk("scsi%d.%c: bus service at step %d?\n", fas216_log(info, 0, "bus service at step %d?", ssr & IS_BITS);
info->host->host_no, fas216_target(info),
ssr & IS_BITS);
print_debug_list(); print_debug_list();
fas216_done(info, DID_ERROR); fas216_done(info, DID_ERROR);
...@@ -1497,39 +1599,88 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne ...@@ -1497,39 +1599,88 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
*/ */
static void fas216_funcdone_intr(FAS216_Info *info, unsigned int stat, unsigned int ssr) static void fas216_funcdone_intr(FAS216_Info *info, unsigned int stat, unsigned int ssr)
{ {
int status, message; unsigned int fifo_len = inb(REG_CFIS(info)) & CFIS_CF;
unsigned int status, message;
fas216_checkmagic(info); fas216_checkmagic(info);
#ifdef DEBUG_FUNCTIONDONE fas216_log(info, LOG_FUNCTIONDONE,
printk("scsi%d.%c: function done: stat=%X ssr=%X phase=%02X\n", "function done: stat=%02x ssr=%02x phase=%02x",
info->host->host_no, fas216_target(info), stat, ssr, info->scsi.phase); stat, ssr, info->scsi.phase);
#endif
switch (info->scsi.phase) { switch (info->scsi.phase) {
case PHASE_STATUS: /* status phase - read status and msg */ case PHASE_STATUS: /* status phase - read status and msg */
if (fifo_len != 2) {
fas216_log(info, 0, "odd number of bytes in FIFO: %d", fifo_len);
}
status = inb(REG_FF(info)); status = inb(REG_FF(info));
message = inb(REG_FF(info)); message = inb(REG_FF(info));
info->scsi.SCp.Message = message; info->scsi.SCp.Message = message;
info->scsi.SCp.Status = status; info->scsi.SCp.Status = status;
info->scsi.phase = PHASE_DONE; info->scsi.phase = PHASE_DONE;
outb(CMD_MSGACCEPTED, REG_CMD(info)); fas216_cmd(info, CMD_MSGACCEPTED);
break; break;
case PHASE_IDLE: /* reselected? */ case PHASE_IDLE: /* reselected? */
case PHASE_MSGIN: /* message in phase */ case PHASE_MSGIN: /* message in phase */
case PHASE_RECONNECTED: /* reconnected command */ case PHASE_RECONNECTED: /* reconnected command */
if ((stat & STAT_BUSMASK) == STAT_MESGIN) { if ((stat & STAT_BUSMASK) == STAT_MESGIN) {
info->scsi.msgin_fifo = inb(REG_CFIS(info)) & CFIS_CF; info->scsi.msgin_fifo = fifo_len;
fas216_message(info); fas216_message(info);
break; break;
} }
default: default:
printk("scsi%d.%c: internal phase %s for function done?" fas216_log(info, 0, "internal phase %s for function done?"
" What do I do with this?\n", " What do I do with this?",
info->host->host_no, fas216_target(info), fas216_target(info), fas216_drv_phase(info));
fas216_drv_phase(info)); }
}
static void fas216_bus_reset(FAS216_Info *info)
{
neg_t sync_state, wide_state;
int i;
msgqueue_flush(&info->scsi.msgs);
info->scsi.reconnected.target = 0;
info->scsi.reconnected.lun = 0;
info->scsi.reconnected.tag = 0;
if (info->ifcfg.wide_max_size == 0)
wide_state = neg_invalid;
else
#ifdef SCSI2_WIDE
wide_state = neg_wait;
#else
wide_state = neg_invalid;
#endif
if (info->host->dma_channel == NO_DMA || !info->dma.setup)
sync_state = neg_invalid;
else
#ifdef SCSI2_SYNC
sync_state = neg_wait;
#else
sync_state = neg_invalid;
#endif
info->scsi.phase = PHASE_IDLE;
info->SCpnt = NULL; /* bug! */
for (i = 0; i < 8; i++) {
info->device[i].disconnect_ok = info->ifcfg.disconnect_ok;
info->device[i].sync_state = sync_state;
info->device[i].wide_state = wide_state;
info->device[i].period = info->ifcfg.asyncperiod / 4;
info->device[i].stp = info->scsi.async_stp;
info->device[i].sof = 0;
info->device[i].wide_xfer = 0;
} }
info->rst_bus_status = 1;
wake_up(&info->eh_wait);
} }
/* Function: void fas216_intr(struct Scsi_Host *instance) /* Function: void fas216_intr(struct Scsi_Host *instance)
...@@ -1551,11 +1702,13 @@ void fas216_intr(struct Scsi_Host *instance) ...@@ -1551,11 +1702,13 @@ void fas216_intr(struct Scsi_Host *instance)
if (stat & STAT_INT) { if (stat & STAT_INT) {
if (isr & INST_BUSRESET) { if (isr & INST_BUSRESET) {
printk(KERN_DEBUG "scsi%d.H: bus reset detected\n", instance->host_no); fas216_log(info, 0, "bus reset detected");
scsi_report_bus_reset(instance, 0); fas216_bus_reset(info);
scsi_report_bus_reset(info->host, 0);
} else if (isr & INST_ILLEGALCMD) { } else if (isr & INST_ILLEGALCMD) {
printk(KERN_CRIT "scsi%d.H: illegal command given\n", instance->host_no); fas216_log(info, LOG_ERROR, "illegal command given\n");
fas216_dumpstate(info); fas216_dumpstate(info);
print_debug_list();
} else if (isr & INST_DISCONNECT) } else if (isr & INST_DISCONNECT)
fas216_disconnect_intr(info); fas216_disconnect_intr(info);
else if (isr & INST_RESELECTED) /* reselected */ else if (isr & INST_RESELECTED) /* reselected */
...@@ -1565,108 +1718,123 @@ void fas216_intr(struct Scsi_Host *instance) ...@@ -1565,108 +1718,123 @@ void fas216_intr(struct Scsi_Host *instance)
else if (isr & INST_FUNCDONE) /* function done */ else if (isr & INST_FUNCDONE) /* function done */
fas216_funcdone_intr(info, stat, ssr); fas216_funcdone_intr(info, stat, ssr);
else else
printk("scsi%d.%c: unknown interrupt received:" fas216_log(info, 0, "unknown interrupt received:"
" phase %s isr %02X ssr %02X stat %02X\n", " phase %s isr %02X ssr %02X stat %02X",
instance->host_no, fas216_target(info),
fas216_drv_phase(info), isr, ssr, stat); fas216_drv_phase(info), isr, ssr, stat);
} }
} }
/* Function: void fas216_kick(FAS216_Info *info) static void __fas216_start_command(FAS216_Info *info, Scsi_Cmnd *SCpnt)
* Purpose : kick a command to the interface - interface should be idle
* Params : info - our host interface to kick
* Notes : Interrupts are always disabled!
*/
static void fas216_kick(FAS216_Info *info)
{ {
Scsi_Cmnd *SCpnt = NULL; int tot_msglen;
int tot_msglen, from_queue = 0, disconnect_ok;
fas216_checkmagic(info); /* following what the ESP driver says */
outb(0, REG_STCL(info));
outb(0, REG_STCM(info));
outb(0, REG_STCH(info));
fas216_cmd(info, CMD_NOP | CMD_WITHDMA);
/* flush FIFO */
fas216_cmd(info, CMD_FLUSHFIFO);
/* load bus-id and timeout */
outb(BUSID(SCpnt->target), REG_SDID(info));
outb(info->ifcfg.select_timeout, REG_STIM(info));
/* synchronous transfers */
fas216_set_sync(info, SCpnt->target);
tot_msglen = msgqueue_msglength(&info->scsi.msgs);
#ifdef DEBUG_MESSAGES
{
struct message *msg;
int msgnr = 0, i;
printk("scsi%d.%c: message out: ",
info->host->host_no, '0' + SCpnt->target);
while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) {
printk("{ ");
for (i = 0; i < msg->length; i++)
printk("%02x ", msg->msg[i]);
printk("} ");
}
printk("\n");
}
#endif
if (tot_msglen == 1 || tot_msglen == 3) {
/* /*
* Obtain the next command to process. * We have an easy message length to send...
*/ */
do { struct message *msg;
if (info->reqSCpnt) { int msgnr = 0, i;
SCpnt = info->reqSCpnt;
info->reqSCpnt = NULL; info->scsi.phase = PHASE_SELSTEPS;
break;
/* load message bytes */
while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) {
for (i = 0; i < msg->length; i++)
outb(msg->msg[i], REG_FF(info));
msg->fifo = tot_msglen - (inb(REG_CFIS(info)) & CFIS_CF);
} }
if (info->origSCpnt) { /* load command */
SCpnt = info->origSCpnt; for (i = 0; i < SCpnt->cmd_len; i++)
info->origSCpnt = NULL; outb(SCpnt->cmnd[i], REG_FF(info));
break;
if (tot_msglen == 1)
fas216_cmd(info, CMD_SELECTATN);
else
fas216_cmd(info, CMD_SELECTATN3);
} else {
/*
* We have an unusual number of message bytes to send.
* Load first byte into fifo, and issue SELECT with ATN and
* stop steps.
*/
struct message *msg = msgqueue_getmsg(&info->scsi.msgs, 0);
outb(msg->msg[0], REG_FF(info));
msg->fifo = 1;
fas216_cmd(info, CMD_SELECTATNSTOP);
} }
}
/* retrieve next command */ /*
if (!SCpnt) { * Decide whether we need to perform a parity test on this device.
SCpnt = queue_remove_exclude(&info->queues.issue, * Can also be used to force parity error conditions during initial
info->busyluns); * information transfer phase (message out) for test purposes.
from_queue = 1; */
break; static int parity_test(FAS216_Info *info, int target)
{
#if 0
if (target == 3) {
info->device[3].parity_check = 0;
return 1;
} }
} while (0); #endif
return info->device[target].parity_check;
}
if (!SCpnt) /* no command pending - just exit */ static void fas216_start_command(FAS216_Info *info, Scsi_Cmnd *SCpnt)
return; {
int disconnect_ok;
if (info->scsi.disconnectable && info->SCpnt) { if (parity_test(info, SCpnt->target))
queue_add_cmd_tail(&info->queues.disconnected, info->SCpnt); outb(info->scsi.cfg[0] | CNTL1_PTE, REG_CNTL1(info));
info->scsi.disconnectable = 0; else
info->SCpnt = NULL; outb(info->scsi.cfg[0], REG_CNTL1(info));
printk("scsi%d.%c: moved command to disconnected queue\n",
info->host->host_no, fas216_target(info));
}
/* /*
* claim host busy * claim host busy
*/ */
info->scsi.phase = PHASE_SELECTION; info->scsi.phase = PHASE_SELECTION;
info->SCpnt = SCpnt;
info->scsi.SCp = SCpnt->SCp; info->scsi.SCp = SCpnt->SCp;
info->SCpnt = SCpnt;
info->dma.transfer_type = fasdma_none; info->dma.transfer_type = fasdma_none;
#ifdef DEBUG_CONNECT
printk("scsi%d.%c: starting cmd %02X",
info->host->host_no, '0' + SCpnt->target,
SCpnt->cmnd[0]);
#endif
if (from_queue) {
#ifdef SCSI2_TAG
/*
* tagged queuing - allocate a new tag to this command
*/
if (SCpnt->device->tagged_queue && SCpnt->cmnd[0] != REQUEST_SENSE &&
SCpnt->cmnd[0] != INQUIRY) {
SCpnt->device->current_tag += 1;
if (SCpnt->device->current_tag == 0)
SCpnt->device->current_tag = 1;
SCpnt->tag = SCpnt->device->current_tag;
} else
#endif
set_bit(SCpnt->target * 8 + SCpnt->lun, info->busyluns);
info->stats.removes += 1;
switch (SCpnt->cmnd[0]) {
case WRITE_6:
case WRITE_10:
case WRITE_12:
info->stats.writes += 1;
break;
case READ_6:
case READ_10:
case READ_12:
info->stats.reads += 1;
break;
default:
info->stats.miscs += 1;
break;
}
}
/* /*
* Don't allow request sense commands to disconnect. * Don't allow request sense commands to disconnect.
*/ */
...@@ -1710,84 +1878,180 @@ static void fas216_kick(FAS216_Info *info) ...@@ -1710,84 +1878,180 @@ static void fas216_kick(FAS216_Info *info)
#endif #endif
} while (0); } while (0);
__fas216_start_command(info, SCpnt);
}
static void fas216_allocate_tag(FAS216_Info *info, Scsi_Cmnd *SCpnt)
{
#ifdef SCSI2_TAG
/*
* tagged queuing - allocate a new tag to this command
*/
if (SCpnt->device->tagged_queue && SCpnt->cmnd[0] != REQUEST_SENSE &&
SCpnt->cmnd[0] != INQUIRY) {
SCpnt->device->current_tag += 1;
if (SCpnt->device->current_tag == 0)
SCpnt->device->current_tag = 1;
SCpnt->tag = SCpnt->device->current_tag;
} else
#endif
set_bit(SCpnt->target * 8 + SCpnt->lun, info->busyluns);
info->stats.removes += 1;
switch (SCpnt->cmnd[0]) {
case WRITE_6:
case WRITE_10:
case WRITE_12:
info->stats.writes += 1;
break;
case READ_6:
case READ_10:
case READ_12:
info->stats.reads += 1;
break;
default:
info->stats.miscs += 1;
break;
}
}
static void fas216_do_bus_device_reset(FAS216_Info *info, Scsi_Cmnd *SCpnt)
{
struct message *msg;
/*
* claim host busy
*/
info->scsi.phase = PHASE_SELECTION;
info->scsi.SCp = SCpnt->SCp;
info->SCpnt = SCpnt;
info->dma.transfer_type = fasdma_none;
fas216_log(info, LOG_ERROR, "sending bus device reset");
msgqueue_flush(&info->scsi.msgs);
msgqueue_addmsg(&info->scsi.msgs, 1, BUS_DEVICE_RESET);
/* following what the ESP driver says */ /* following what the ESP driver says */
outb(0, REG_STCL(info)); outb(0, REG_STCL(info));
outb(0, REG_STCM(info)); outb(0, REG_STCM(info));
outb(0, REG_STCH(info)); outb(0, REG_STCH(info));
outb(CMD_NOP | CMD_WITHDMA, REG_CMD(info)); fas216_cmd(info, CMD_NOP | CMD_WITHDMA);
/* flush FIFO */ /* flush FIFO */
outb(CMD_FLUSHFIFO, REG_CMD(info)); fas216_cmd(info, CMD_FLUSHFIFO);
/* load bus-id and timeout */ /* load bus-id and timeout */
outb(BUSID(SCpnt->target), REG_SDID(info)); outb(BUSID(SCpnt->target), REG_SDID(info));
outb(info->ifcfg.select_timeout, REG_STIM(info)); outb(info->ifcfg.select_timeout, REG_STIM(info));
/* synchronous transfers */ /* synchronous transfers */
fas216_set_sync(info, SCpnt->target); fas216_set_sync(info, SCpnt->target);
msg = msgqueue_getmsg(&info->scsi.msgs, 0);
outb(BUS_DEVICE_RESET, REG_FF(info));
msg->fifo = 1;
fas216_cmd(info, CMD_SELECTATNSTOP);
}
/* Function: void fas216_kick(FAS216_Info *info)
* Purpose : kick a command to the interface - interface should be idle
* Params : info - our host interface to kick
* Notes : Interrupts are always disabled!
*/
static void fas216_kick(FAS216_Info *info)
{
Scsi_Cmnd *SCpnt = NULL;
#define TYPE_OTHER 0
#define TYPE_RESET 1
#define TYPE_QUEUE 2
int where_from = TYPE_OTHER;
fas216_checkmagic(info);
/*
* Obtain the next command to process.
*/
do {
if (info->rstSCpnt) {
SCpnt = info->rstSCpnt;
/* don't remove it */
where_from = TYPE_RESET;
break;
}
if (info->reqSCpnt) {
SCpnt = info->reqSCpnt;
info->reqSCpnt = NULL;
break;
}
if (info->origSCpnt) {
SCpnt = info->origSCpnt;
info->origSCpnt = NULL;
break;
}
/* retrieve next command */
if (!SCpnt) {
SCpnt = queue_remove_exclude(&info->queues.issue,
info->busyluns);
where_from = TYPE_QUEUE;
break;
}
} while (0);
tot_msglen = msgqueue_msglength(&info->scsi.msgs); if (!SCpnt) /* no command pending - just exit */
return;
#ifdef DEBUG_MESSAGES if (info->scsi.disconnectable && info->SCpnt) {
{ fas216_log(info, LOG_CONNECT,
struct message *msg; "moved command for %d to disconnected queue",
int msgnr = 0, i; info->SCpnt->target);
queue_add_cmd_tail(&info->queues.disconnected, info->SCpnt);
info->scsi.disconnectable = 0;
info->SCpnt = NULL;
}
printk("scsi%d.%c: message out: ", #if defined(DEBUG_CONNECT) || defined(DEBUG_MESSAGES)
printk("scsi%d.%c: starting ",
info->host->host_no, '0' + SCpnt->target); info->host->host_no, '0' + SCpnt->target);
while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { print_command(SCpnt->cmnd);
printk("{ ");
for (i = 0; i < msg->length; i++)
printk("%02x ", msg->msg[i]);
printk("} ");
}
printk("\n");
}
#endif #endif
if (tot_msglen == 1 || tot_msglen == 3) { switch (where_from) {
/* case TYPE_QUEUE:
* We have an easy message length to send... fas216_allocate_tag(info, SCpnt);
*/ case TYPE_OTHER:
struct message *msg; fas216_start_command(info, SCpnt);
int msgnr = 0, i; break;
case TYPE_RESET:
info->scsi.phase = PHASE_SELSTEPS; fas216_do_bus_device_reset(info, SCpnt);
break;
/* load message bytes */
while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) {
for (i = 0; i < msg->length; i++)
outb(msg->msg[i], REG_FF(info));
msg->fifo = tot_msglen - (inb(REG_CFIS(info)) & CFIS_CF);
} }
/* load command */ fas216_log(info, LOG_CONNECT, "select: data pointers [%p, %X]",
for (i = 0; i < SCpnt->cmd_len; i++) info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
outb(SCpnt->cmnd[i], REG_FF(info));
if (tot_msglen == 1)
outb(CMD_SELECTATN, REG_CMD(info));
else
outb(CMD_SELECTATN3, REG_CMD(info));
} else {
/* /*
* We have an unusual number of message bytes to send. * should now get either DISCONNECT or
* Load first byte into fifo, and issue SELECT with ATN and * (FUNCTION DONE with BUS SERVICE) interrupt
* stop steps.
*/ */
struct message *msg = msgqueue_getmsg(&info->scsi.msgs, 0); }
outb(msg->msg[0], REG_FF(info));
msg->fifo = 1;
outb(CMD_SELECTATNSTOP, REG_CMD(info)); /*
} * Clean up from issuing a BUS DEVICE RESET message to a device.
*/
static void
fas216_devicereset_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result)
{
fas216_log(info, LOG_ERROR, "fas216 device reset complete");
#ifdef DEBUG_CONNECT info->rstSCpnt = NULL;
printk(", data pointers [%p, %X]\n", info->rst_dev_status = 1;
info->scsi.SCp.ptr, info->scsi.SCp.this_residual); wake_up(&info->eh_wait);
#endif
/* should now get either DISCONNECT or (FUNCTION DONE with BUS SERVICE) intr */
} }
/* Function: void fas216_rq_sns_done(info, SCpnt, result) /* Function: void fas216_rq_sns_done(info, SCpnt, result)
...@@ -1799,11 +2063,9 @@ static void fas216_kick(FAS216_Info *info) ...@@ -1799,11 +2063,9 @@ static void fas216_kick(FAS216_Info *info)
static void static void
fas216_rq_sns_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result) fas216_rq_sns_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result)
{ {
#ifdef DEBUG_CONNECT fas216_log(info, LOG_CONNECT,
printk("scsi%d.%c: request sense complete, result=%04X%02X%02X\n", "request sense complete, result=0x%04x%02x%02x",
info->host->host_no, '0' + SCpnt->target, result, result, SCpnt->SCp.Message, SCpnt->SCp.Status);
SCpnt->SCp.Message, SCpnt->SCp.Status);
#endif
if (result != DID_OK || SCpnt->SCp.Status != GOOD) if (result != DID_OK || SCpnt->SCp.Status != GOOD)
/* /*
...@@ -1812,7 +2074,8 @@ fas216_rq_sns_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result) ...@@ -1812,7 +2074,8 @@ fas216_rq_sns_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result)
* confuse the higher levels. * confuse the higher levels.
*/ */
memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer)); memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
//printk("scsi%d.%c: sense buffer: ", info->host->host_no, '0' + SCpnt->target);
//{ int i; for (i = 0; i < 32; i++) printk("%02x ", SCpnt->sense_buffer[i]); printk("\n"); }
/* /*
* Note that we don't set SCpnt->result, since that should * Note that we don't set SCpnt->result, since that should
* reflect the status of the command that we were asked by * reflect the status of the command that we were asked by
...@@ -1850,10 +2113,11 @@ fas216_std_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result) ...@@ -1850,10 +2113,11 @@ fas216_std_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result)
goto done; goto done;
/* /*
* If the command returned CHECK_CONDITION status, * If the command returned CHECK_CONDITION or COMMAND_TERMINATED
* request the sense information. * status, request the sense information.
*/ */
if (info->scsi.SCp.Status == CHECK_CONDITION) if (status_byte(SCpnt->result) == CHECK_CONDITION ||
status_byte(SCpnt->result) == COMMAND_TERMINATED)
goto request_sense; goto request_sense;
/* /*
...@@ -1888,8 +2152,15 @@ fas216_std_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result) ...@@ -1888,8 +2152,15 @@ fas216_std_done(FAS216_Info *info, Scsi_Cmnd *SCpnt, unsigned int result)
} }
} }
done: SCpnt->scsi_done(SCpnt); done:
if (SCpnt->scsi_done) {
SCpnt->scsi_done(SCpnt);
return; return;
}
panic("scsi%d.H: null scsi_done function in fas216_done",
info->host->host_no);
request_sense: request_sense:
memset(SCpnt->cmnd, 0, sizeof (SCpnt->cmnd)); memset(SCpnt->cmnd, 0, sizeof (SCpnt->cmnd));
...@@ -1928,6 +2199,7 @@ static void fas216_done(FAS216_Info *info, unsigned int result) ...@@ -1928,6 +2199,7 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
{ {
void (*fn)(FAS216_Info *, Scsi_Cmnd *, unsigned int); void (*fn)(FAS216_Info *, Scsi_Cmnd *, unsigned int);
Scsi_Cmnd *SCpnt; Scsi_Cmnd *SCpnt;
unsigned long flags;
fas216_checkmagic(info); fas216_checkmagic(info);
...@@ -1938,12 +2210,8 @@ static void fas216_done(FAS216_Info *info, unsigned int result) ...@@ -1938,12 +2210,8 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
info->SCpnt = NULL; info->SCpnt = NULL;
info->scsi.phase = PHASE_IDLE; info->scsi.phase = PHASE_IDLE;
if (!SCpnt->scsi_done)
goto no_done;
if (info->scsi.aborting) { if (info->scsi.aborting) {
printk("scsi%d.%c: uncaught abort - returning DID_ABORT\n", fas216_log(info, 0, "uncaught abort - returning DID_ABORT");
info->host->host_no, fas216_target(info));
result = DID_ABORT; result = DID_ABORT;
info->scsi.aborting = 0; info->scsi.aborting = 0;
} }
...@@ -1966,21 +2234,23 @@ static void fas216_done(FAS216_Info *info, unsigned int result) ...@@ -1966,21 +2234,23 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
* the sense information, fas216_kick will re-assert the busy * the sense information, fas216_kick will re-assert the busy
* status. * status.
*/ */
info->device[SCpnt->target].parity_check = 0;
clear_bit(SCpnt->target * 8 + SCpnt->lun, info->busyluns); clear_bit(SCpnt->target * 8 + SCpnt->lun, info->busyluns);
fn = (void (*)(FAS216_Info *, Scsi_Cmnd *, unsigned int))SCpnt->host_scribble; fn = (void (*)(FAS216_Info *, Scsi_Cmnd *, unsigned int))SCpnt->host_scribble;
fn(info, SCpnt, result); fn(info, SCpnt, result);
if (info->scsi.irq != NO_IRQ) if (info->scsi.irq != NO_IRQ) {
spin_lock_irqsave(&info->host_lock, flags);
if (info->scsi.phase == PHASE_IDLE)
fas216_kick(info); fas216_kick(info);
spin_unlock_irqrestore(&info->host_lock, flags);
}
return; return;
no_command: no_command:
panic("scsi%d.H: null command in fas216_done", panic("scsi%d.H: null command in fas216_done",
info->host->host_no); info->host->host_no);
no_done:
panic("scsi%d.H: null scsi_done function in fas216_done",
info->host->host_no);
} }
/* Function: int fas216_queue_command(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) /* Function: int fas216_queue_command(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
...@@ -1998,9 +2268,9 @@ int fas216_queue_command(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) ...@@ -1998,9 +2268,9 @@ int fas216_queue_command(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
fas216_checkmagic(info); fas216_checkmagic(info);
#ifdef DEBUG_CONNECT #ifdef DEBUG_CONNECT
printk("scsi%d.%c: received queuable command (%p) %02X\n", printk("scsi%d.H: received command for id %d (%p) ",
SCpnt->host->host_no, '0' + SCpnt->target, SCpnt->host->host_no, SCpnt->target, SCpnt);
SCpnt, SCpnt->cmnd[0]); print_command(SCpnt->cmnd);
#endif #endif
SCpnt->scsi_done = done; SCpnt->scsi_done = done;
...@@ -2012,6 +2282,8 @@ int fas216_queue_command(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) ...@@ -2012,6 +2282,8 @@ int fas216_queue_command(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
info->stats.queues += 1; info->stats.queues += 1;
SCpnt->tag = 0; SCpnt->tag = 0;
spin_lock(&info->host_lock);
/* /*
* Add command into execute queue and let it complete under * Add command into execute queue and let it complete under
* whatever scheme we're using. * whatever scheme we're using.
...@@ -2022,8 +2294,14 @@ int fas216_queue_command(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) ...@@ -2022,8 +2294,14 @@ int fas216_queue_command(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
* If we successfully added the command, * If we successfully added the command,
* kick the interface to get it moving. * kick the interface to get it moving.
*/ */
if (result == 0 && (!info->SCpnt || info->scsi.disconnectable)) if (result == 0 && info->scsi.phase == PHASE_IDLE)
fas216_kick(info); fas216_kick(info);
spin_unlock(&info->host_lock);
#ifdef DEBUG_CONNECT
printk("scsi%d.H: queue %s\n", info->host->host_no,
result ? "failure" : "success");
#endif
return result; return result;
} }
...@@ -2092,23 +2370,41 @@ int fas216_command(Scsi_Cmnd *SCpnt) ...@@ -2092,23 +2370,41 @@ int fas216_command(Scsi_Cmnd *SCpnt)
return SCpnt->result; return SCpnt->result;
} }
enum res_abort { /*
res_failed, /* unable to abort */ * Error handler timeout function. Indicate that we timed out,
* and wake up any error handler process so it can continue.
*/
static void fas216_eh_timer(unsigned long data)
{
FAS216_Info *info = (FAS216_Info *)data;
fas216_log(info, LOG_ERROR, "error handling timed out\n");
del_timer(&info->eh_timer);
if (info->rst_bus_status == 0)
info->rst_bus_status = -1;
if (info->rst_dev_status == 0)
info->rst_dev_status = -1;
wake_up(&info->eh_wait);
}
enum res_find {
res_failed, /* not found */
res_success, /* command on issue queue */ res_success, /* command on issue queue */
res_success_clear, /* command marked tgt/lun busy */
res_hw_abort /* command on disconnected dev */ res_hw_abort /* command on disconnected dev */
}; };
/* /*
* Prototype: enum res_abort fas216_do_abort(FAS216_Info *info, Scsi_Cmnd *SCpnt) * Prototype: enum res_find fas216_do_abort(FAS216_Info *info, Scsi_Cmnd *SCpnt)
* Purpose : decide how to abort a command * Purpose : decide how to abort a command
* Params : SCpnt - command to abort * Params : SCpnt - command to abort
* Returns : abort status * Returns : abort status
*/ */
static enum res_abort static enum res_find fas216_find_command(FAS216_Info *info, Scsi_Cmnd *SCpnt)
fas216_do_abort(FAS216_Info *info, Scsi_Cmnd *SCpnt)
{ {
enum res_abort res = res_failed; enum res_find res = res_failed;
if (queue_remove_cmd(&info->queues.issue, SCpnt)) { if (queue_remove_cmd(&info->queues.issue, SCpnt)) {
/* /*
...@@ -2156,8 +2452,9 @@ fas216_do_abort(FAS216_Info *info, Scsi_Cmnd *SCpnt) ...@@ -2156,8 +2452,9 @@ fas216_do_abort(FAS216_Info *info, Scsi_Cmnd *SCpnt)
* been set. * been set.
*/ */
info->origSCpnt = NULL; info->origSCpnt = NULL;
clear_bit(SCpnt->target * 8 + SCpnt->lun, info->busyluns);
printk("waiting for execution "); printk("waiting for execution ");
res = res_success_clear; res = res_success;
} else } else
printk("unknown "); printk("unknown ");
...@@ -2179,22 +2476,15 @@ int fas216_eh_abort(Scsi_Cmnd *SCpnt) ...@@ -2179,22 +2476,15 @@ int fas216_eh_abort(Scsi_Cmnd *SCpnt)
info->stats.aborts += 1; info->stats.aborts += 1;
printk(KERN_WARNING "scsi%d: abort command ", info->host->host_no);
print_command(SCpnt->data_cmnd);
print_debug_list(); print_debug_list();
fas216_dumpstate(info); fas216_dumpstate(info);
fas216_dumpinfo(info);
printk(KERN_WARNING "scsi%d: abort ", info->host->host_no); printk(KERN_WARNING "scsi%d: abort %p ", info->host->host_no, SCpnt);
switch (fas216_do_abort(info, SCpnt)) {
/*
* We managed to find the command and cleared it out.
* We do not expect the command to be executing on the
* target, but we have set the busylun bit.
*/
case res_success_clear:
printk("clear ");
clear_bit(SCpnt->target * 8 + SCpnt->lun, info->busyluns);
switch (fas216_find_command(info, SCpnt)) {
/* /*
* We found the command, and cleared it out. Either * We found the command, and cleared it out. Either
* the command is still known to be executing on the * the command is still known to be executing on the
...@@ -2225,132 +2515,161 @@ int fas216_eh_abort(Scsi_Cmnd *SCpnt) ...@@ -2225,132 +2515,161 @@ int fas216_eh_abort(Scsi_Cmnd *SCpnt)
return result; return result;
} }
/* Function: void fas216_reset_state(FAS216_Info *info) /* Function: int fas216_eh_device_reset(Scsi_Cmnd *SCpnt)
* Purpose : Initialise driver internal state * Purpose : Reset the device associated with this command
* Params : info - state to initialise * Params : SCpnt - command specifing device to reset
* Returns : FAILED if unable to reset
* Notes : We won't be re-entered, so we'll only have one device
* reset on the go at one time.
*/ */
static void fas216_reset_state(FAS216_Info *info) int fas216_eh_device_reset(Scsi_Cmnd *SCpnt)
{ {
neg_t sync_state, wide_state; FAS216_Info *info = (FAS216_Info *)SCpnt->host->hostdata;
int i; unsigned long flags;
int i, res = FAILED, target = SCpnt->target;
fas216_checkmagic(info); fas216_log(info, LOG_ERROR, "device reset for target %d", target);
spin_lock_irqsave(&info->host_lock, flags);
do {
/* /*
* Clear out all stale info in our state structure * If we are currently connected to a device, and
* it is the device we want to reset, there is
* nothing we can do here. Chances are it is stuck,
* and we need a bus reset.
*/ */
memset(info->busyluns, 0, sizeof(info->busyluns)); if (info->SCpnt && !info->scsi.disconnectable &&
msgqueue_flush(&info->scsi.msgs); info->SCpnt->target == SCpnt->target)
info->scsi.reconnected.target = 0; break;
info->scsi.reconnected.lun = 0;
info->scsi.reconnected.tag = 0;
info->scsi.disconnectable = 0;
info->scsi.aborting = 0;
info->scsi.phase = PHASE_IDLE;
info->scsi.async_stp =
fas216_syncperiod(info, info->ifcfg.asyncperiod);
if (info->ifcfg.wide_max_size == 0)
wide_state = neg_invalid;
else
#ifdef SCSI2_WIDE
wide_state = neg_wait;
#else
wide_state = neg_invalid;
#endif
if (info->host->dma_channel == NO_DMA || !info->dma.setup)
sync_state = neg_invalid;
else
#ifdef SCSI2_SYNC
sync_state = neg_wait;
#else
sync_state = neg_invalid;
#endif
for (i = 0; i < 8; i++) { /*
info->device[i].disconnect_ok = info->ifcfg.disconnect_ok; * We're going to be resetting this device. Remove
info->device[i].sync_state = sync_state; * all pending commands from the driver. By doing
info->device[i].wide_state = wide_state; * so, we guarantee that we won't touch the command
info->device[i].period = info->ifcfg.asyncperiod / 4; * structures except to process the reset request.
info->device[i].stp = info->scsi.async_stp; */
info->device[i].sof = 0; queue_remove_all_target(&info->queues.issue, target);
info->device[i].wide_xfer = 0; queue_remove_all_target(&info->queues.disconnected, target);
} if (info->origSCpnt && info->origSCpnt->target == target)
info->origSCpnt = NULL;
if (info->reqSCpnt && info->reqSCpnt->target == target)
info->reqSCpnt = NULL;
for (i = 0; i < 8; i++)
clear_bit(target * 8 + i, info->busyluns);
/* /*
* Drain all commands on disconnected queue * Hijack this SCSI command structure to send
* a bus device reset message to this device.
*/ */
while (queue_remove(&info->queues.disconnected) != NULL); SCpnt->host_scribble = (void *)fas216_devicereset_done;
info->rst_dev_status = 0;
info->rstSCpnt = SCpnt;
if (info->scsi.phase == PHASE_IDLE)
fas216_kick(info);
mod_timer(&info->eh_timer, 30 * HZ);
spin_unlock_irqrestore(&info->host_lock, flags);
/* /*
* Remove executing commands. * Wait up to 30 seconds for the reset to complete.
*/ */
info->SCpnt = NULL; wait_event(info->eh_wait, info->rst_dev_status);
info->reqSCpnt = NULL;
info->origSCpnt = NULL;
}
/* Function: int fas216_eh_device_reset(Scsi_Cmnd *SCpnt) del_timer_sync(&info->eh_timer);
* Purpose : Reset the device associated with this command spin_lock_irqsave(&info->host_lock, flags);
* Params : SCpnt - command specifing device to reset info->rstSCpnt = NULL;
* Returns : FAILED if unable to reset
*/
int fas216_eh_device_reset(Scsi_Cmnd *SCpnt)
{
FAS216_Info *info = (FAS216_Info *)SCpnt->host->hostdata;
printk("scsi%d.%c: %s: called\n", if (info->rst_dev_status == 1)
info->host->host_no, '0' + SCpnt->target, __FUNCTION__); res = SUCCESS;
return FAILED; } while (0);
SCpnt->host_scribble = NULL;
spin_unlock_irqrestore(&info->host_lock, flags);
fas216_log(info, LOG_ERROR, "device reset complete: %s\n",
res == SUCCESS ? "success" : "failed");
return res;
} }
/* Function: int fas216_eh_bus_reset(Scsi_Cmnd *SCpnt) /* Function: int fas216_eh_bus_reset(Scsi_Cmnd *SCpnt)
* Purpose : Reset the bus associated with the command * Purpose : Reset the bus associated with the command
* Params : SCpnt - command specifing bus to reset * Params : SCpnt - command specifing bus to reset
* Returns : FAILED if unable to reset * Returns : FAILED if unable to reset
* Notes : io_request_lock is taken, and irqs are disabled * Notes : Further commands are blocked.
*/ */
int fas216_eh_bus_reset(Scsi_Cmnd *SCpnt) int fas216_eh_bus_reset(Scsi_Cmnd *SCpnt)
{ {
FAS216_Info *info = (FAS216_Info *)SCpnt->host->hostdata; FAS216_Info *info = (FAS216_Info *)SCpnt->host->hostdata;
int result = FAILED; unsigned long flags;
Scsi_Device *SDpnt;
fas216_checkmagic(info); fas216_checkmagic(info);
fas216_log(info, LOG_ERROR, "resetting bus");
info->stats.bus_resets += 1; info->stats.bus_resets += 1;
printk("scsi%d.%c: %s: resetting bus\n", spin_lock_irqsave(&info->host_lock, flags);
info->host->host_no, '0' + SCpnt->target, __FUNCTION__);
/* /*
* Attempt to stop all activity on this interface. * Stop all activity on this interface.
*/ */
fas216_aborttransfer(info);
outb(info->scsi.cfg[2], REG_CNTL3(info)); outb(info->scsi.cfg[2], REG_CNTL3(info));
fas216_stoptransfer(info);
/* /*
* Clear any pending interrupts * Clear any pending interrupts.
*/ */
while (inb(REG_STAT(info)) & STAT_INT) while (inb(REG_STAT(info)) & STAT_INT)
inb(REG_INST(info)); inb(REG_INST(info));
info->rst_bus_status = 0;
/* /*
* Reset the SCSI bus * For each attached hard-reset device, clear out
* all command structures. Leave the running
* command in place.
*/ */
outb(CMD_RESETSCSI, REG_CMD(info)); for (SDpnt = info->host->host_queue; SDpnt; SDpnt = SDpnt->next) {
udelay(5); int i;
if (SDpnt->soft_reset)
continue;
queue_remove_all_target(&info->queues.issue, SDpnt->id);
queue_remove_all_target(&info->queues.disconnected, SDpnt->id);
if (info->origSCpnt && info->origSCpnt->target == SDpnt->id)
info->origSCpnt = NULL;
if (info->reqSCpnt && info->reqSCpnt->target == SDpnt->id)
info->reqSCpnt = NULL;
info->SCpnt = NULL;
for (i = 0; i < 8; i++)
clear_bit(SDpnt->id * 8 + i, info->busyluns);
}
/* /*
* Clear reset interrupt * Reset the SCSI bus. Device cleanup happens in
* the interrupt handler.
*/ */
if (inb(REG_STAT(info)) & STAT_INT && fas216_cmd(info, CMD_RESETSCSI);
inb(REG_INST(info)) & INST_BUSRESET)
result = SUCCESS;
fas216_reset_state(info); mod_timer(&info->eh_timer, jiffies + HZ);
spin_unlock_irqrestore(&info->host_lock, flags);
return result; /*
* Wait one second for the interrupt.
*/
wait_event(info->eh_wait, info->rst_bus_status);
del_timer_sync(&info->eh_timer);
fas216_log(info, LOG_ERROR, "bus reset complete: %s\n",
info->rst_bus_status == 1 ? "success" : "failed");
return info->rst_bus_status == 1 ? SUCCESS : FAILED;
} }
/* Function: void fas216_init_chip(FAS216_Info *info) /* Function: void fas216_init_chip(FAS216_Info *info)
...@@ -2387,7 +2706,7 @@ int fas216_eh_host_reset(Scsi_Cmnd *SCpnt) ...@@ -2387,7 +2706,7 @@ int fas216_eh_host_reset(Scsi_Cmnd *SCpnt)
/* /*
* Reset the SCSI chip. * Reset the SCSI chip.
*/ */
outb(CMD_RESETCHIP, REG_CMD(info)); fas216_cmd(info, CMD_RESETCHIP);
/* /*
* Ugly ugly ugly! * Ugly ugly ugly!
...@@ -2396,13 +2715,13 @@ int fas216_eh_host_reset(Scsi_Cmnd *SCpnt) ...@@ -2396,13 +2715,13 @@ int fas216_eh_host_reset(Scsi_Cmnd *SCpnt)
* IRQs after the sleep. * IRQs after the sleep.
*/ */
spin_unlock_irq(info->host->host_lock); spin_unlock_irq(info->host->host_lock);
scsi_sleep(25*HZ/100); scsi_sleep(50 * HZ/100);
spin_lock_irq(info->host->host_lock); spin_lock_irq(info->host->host_lock);
/* /*
* Release the SCSI reset. * Release the SCSI reset.
*/ */
outb(CMD_NOP, REG_CMD(info)); fas216_cmd(info, CMD_NOP);
fas216_init_chip(info); fas216_init_chip(info);
...@@ -2509,6 +2828,44 @@ static int fas216_detect_type(FAS216_Info *info) ...@@ -2509,6 +2828,44 @@ static int fas216_detect_type(FAS216_Info *info)
return TYPE_NCR53C9x; return TYPE_NCR53C9x;
} }
/* Function: void fas216_reset_state(FAS216_Info *info)
* Purpose : Initialise driver internal state
* Params : info - state to initialise
*/
static void fas216_reset_state(FAS216_Info *info)
{
int i;
fas216_checkmagic(info);
fas216_bus_reset(info);
/*
* Clear out all stale info in our state structure
*/
memset(info->busyluns, 0, sizeof(info->busyluns));
info->scsi.disconnectable = 0;
info->scsi.aborting = 0;
for (i = 0; i < 8; i++) {
info->device[i].parity_enabled = 0;
info->device[i].parity_check = 1;
}
/*
* Drain all commands on disconnected queue
*/
while (queue_remove(&info->queues.disconnected) != NULL);
/*
* Remove executing commands.
*/
info->SCpnt = NULL;
info->reqSCpnt = NULL;
info->rstSCpnt = NULL;
info->origSCpnt = NULL;
}
/* Function: int fas216_init(struct Scsi_Host *instance) /* Function: int fas216_init(struct Scsi_Host *instance)
* Purpose : initialise FAS/NCR/AMD SCSI ic. * Purpose : initialise FAS/NCR/AMD SCSI ic.
* Params : instance - a driver-specific filled-out structure * Params : instance - a driver-specific filled-out structure
...@@ -2522,9 +2879,19 @@ int fas216_init(struct Scsi_Host *instance) ...@@ -2522,9 +2879,19 @@ int fas216_init(struct Scsi_Host *instance)
info->magic_start = MAGIC; info->magic_start = MAGIC;
info->magic_end = MAGIC; info->magic_end = MAGIC;
info->host = instance; info->host = instance;
info->scsi.cfg[0] = instance->this_id; info->scsi.cfg[0] = instance->this_id | CNTL1_PERE;
info->scsi.cfg[1] = CNTL2_ENF | CNTL2_S2FE; info->scsi.cfg[1] = CNTL2_ENF | CNTL2_S2FE;
info->scsi.cfg[2] = info->ifcfg.cntl3 | CNTL3_ADIDCHK | CNTL3_G2CB; info->scsi.cfg[2] = info->ifcfg.cntl3 | CNTL3_ADIDCHK | CNTL3_G2CB;
info->scsi.async_stp = fas216_syncperiod(info, info->ifcfg.asyncperiod);
info->rst_dev_status = -1;
info->rst_bus_status = -1;
init_waitqueue_head(&info->eh_wait);
init_timer(&info->eh_timer);
info->eh_timer.data = (unsigned long)info;
info->eh_timer.function = fas216_eh_timer;
spin_lock_init(&info->host_lock);
memset(&info->stats, 0, sizeof(info->stats)); memset(&info->stats, 0, sizeof(info->stats));
...@@ -2561,7 +2928,7 @@ int fas216_init(struct Scsi_Host *instance) ...@@ -2561,7 +2928,7 @@ int fas216_init(struct Scsi_Host *instance)
* scsi standard says wait 250ms * scsi standard says wait 250ms
*/ */
spin_unlock_irq(info->host->host_lock); spin_unlock_irq(info->host->host_lock);
scsi_sleep(25*HZ/100); scsi_sleep(100*HZ/100);
spin_lock_irq(info->host->host_lock); spin_lock_irq(info->host->host_lock);
outb(info->scsi.cfg[0], REG_CNTL1(info)); outb(info->scsi.cfg[0], REG_CNTL1(info));
...@@ -2621,7 +2988,6 @@ int fas216_info(FAS216_Info *info, char *buffer) ...@@ -2621,7 +2988,6 @@ int fas216_info(FAS216_Info *info, char *buffer)
int fas216_print_host(FAS216_Info *info, char *buffer) int fas216_print_host(FAS216_Info *info, char *buffer)
{ {
return sprintf(buffer, return sprintf(buffer,
"\n" "\n"
"Chip : %s\n" "Chip : %s\n"
...@@ -2634,8 +3000,9 @@ int fas216_print_host(FAS216_Info *info, char *buffer) ...@@ -2634,8 +3000,9 @@ int fas216_print_host(FAS216_Info *info, char *buffer)
int fas216_print_stats(FAS216_Info *info, char *buffer) int fas216_print_stats(FAS216_Info *info, char *buffer)
{ {
return sprintf(buffer, char *p = buffer;
"\n"
p += sprintf(p, "\n"
"Command Statistics:\n" "Command Statistics:\n"
" Queued : %u\n" " Queued : %u\n"
" Issued : %u\n" " Issued : %u\n"
...@@ -2652,6 +3019,8 @@ int fas216_print_stats(FAS216_Info *info, char *buffer) ...@@ -2652,6 +3019,8 @@ int fas216_print_stats(FAS216_Info *info, char *buffer)
info->stats.writes, info->stats.miscs, info->stats.writes, info->stats.miscs,
info->stats.disconnects, info->stats.aborts, info->stats.disconnects, info->stats.aborts,
info->stats.bus_resets, info->stats.host_resets); info->stats.bus_resets, info->stats.host_resets);
return p - buffer;
} }
int fas216_print_device(FAS216_Info *info, Scsi_Device *scd, char *buffer) int fas216_print_device(FAS216_Info *info, Scsi_Device *scd, char *buffer)
...@@ -2670,7 +3039,9 @@ int fas216_print_device(FAS216_Info *info, Scsi_Device *scd, char *buffer) ...@@ -2670,7 +3039,9 @@ int fas216_print_device(FAS216_Info *info, Scsi_Device *scd, char *buffer)
scd->tagged_queue ? "en" : "dis", scd->tagged_queue ? "en" : "dis",
scd->current_tag); scd->current_tag);
p += sprintf(p, "\n Transfers : %d-bit ", p += sprintf(p, "%s\n", dev->parity_enabled ? "parity" : "");
p += sprintf(p, " Transfers : %d-bit ",
8 << dev->wide_xfer); 8 << dev->wide_xfer);
if (dev->sof) if (dev->sof)
......
...@@ -214,10 +214,22 @@ typedef enum { ...@@ -214,10 +214,22 @@ typedef enum {
typedef struct { typedef struct {
unsigned long magic_start; unsigned long magic_start;
spinlock_t host_lock;
struct Scsi_Host *host; /* host */ struct Scsi_Host *host; /* host */
Scsi_Cmnd *SCpnt; /* currently processing command */ Scsi_Cmnd *SCpnt; /* currently processing command */
Scsi_Cmnd *origSCpnt; /* original connecting command */ Scsi_Cmnd *origSCpnt; /* original connecting command */
Scsi_Cmnd *reqSCpnt; /* request sense command */ Scsi_Cmnd *reqSCpnt; /* request sense command */
Scsi_Cmnd *rstSCpnt; /* reset command */
Scsi_Cmnd *pending_SCpnt[8]; /* per-device pending commands */
int next_pending; /* next pending device */
/*
* Error recovery
*/
wait_queue_head_t eh_wait;
struct timer_list eh_timer;
unsigned int rst_dev_status;
unsigned int rst_bus_status;
/* driver information */ /* driver information */
struct { struct {
...@@ -281,6 +293,8 @@ typedef struct { ...@@ -281,6 +293,8 @@ typedef struct {
/* per-device info */ /* per-device info */
struct fas216_device { struct fas216_device {
unsigned char disconnect_ok:1; /* device can disconnect */ unsigned char disconnect_ok:1; /* device can disconnect */
unsigned char parity_enabled:1; /* parity checking enabled */
unsigned char parity_check:1; /* need to check parity checking */
unsigned char period; /* sync xfer period in (*4ns) */ unsigned char period; /* sync xfer period in (*4ns) */
unsigned char stp; /* synchronous transfer period */ unsigned char stp; /* synchronous transfer period */
unsigned char sof; /* synchronous offset register */ unsigned char sof; /* synchronous offset register */
......
#define AUTOSENSE
/*#define PSEUDO_DMA*/
/* /*
* Oak Generic NCR5380 driver * Oak Generic NCR5380 driver
* *
* Copyright 1995, Russell King * Copyright 1995-2002, Russell King
*
* ALPHA RELEASE 1.
*
* For more information, please consult
*
* NCR 5380 Family
* SCSI Protocol Controller
* Databook
*
* NCR Microelectronics
* 1635 Aeroplaza Drive
* Colorado Springs, CO 80916
* 1+ (719) 578-3400
* 1+ (800) 334-5454
*/
/*
* Options :
*
* PARITY - enable parity checking. Not supported.
*
* SCSI2 - enable support for SCSI-II tagged queueing. Untested.
*
* USLEEP - enable support for devices that don't disconnect. Untested.
*/
/*
* $Log: oak.c,v $
* Revision 1.3 1998/05/03 20:45:37 alan
* ARM SCSI update. This adds the eesox driver and massively updates the
* Cumana driver. The folks who bought cumana arent anal retentive all
* docs are secret weenies so now there are docs ..
*
* Revision 1.2 1998/03/08 05:49:48 davem
* Merge to 2.1.89
*
* Revision 1.1 1998/02/23 02:45:27 davem
* Merge to 2.1.88
*
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -60,6 +19,9 @@ ...@@ -60,6 +19,9 @@
#include "../../scsi/scsi.h" #include "../../scsi/scsi.h"
#include "../../scsi/hosts.h" #include "../../scsi/hosts.h"
#define AUTOSENSE
/*#define PSEUDO_DMA*/
#define OAKSCSI_PUBLIC_RELEASE 1 #define OAKSCSI_PUBLIC_RELEASE 1
#define NCR5380_read(reg) oakscsi_read(_instance, reg) #define NCR5380_read(reg) oakscsi_read(_instance, reg)
...@@ -71,14 +33,9 @@ ...@@ -71,14 +33,9 @@
int NCR5380_proc_info(char *buffer, char **start, off_t offset, int NCR5380_proc_info(char *buffer, char **start, off_t offset,
int length, int hostno, int inout); int length, int hostno, int inout);
#define NCR5380_implementation_fields \ #define NCR5380_implementation_fields int port, ctrl
int port, ctrl #define NCR5380_local_declare() struct Scsi_Host *_instance
#define NCR5380_setup(instance) _instance = instance
#define NCR5380_local_declare() \
struct Scsi_Host *_instance
#define NCR5380_setup(instance) \
_instance = instance
#define BOARD_NORMAL 0 #define BOARD_NORMAL 0
#define BOARD_NCR53C400 1 #define BOARD_NCR53C400 1
...@@ -88,105 +45,8 @@ int NCR5380_proc_info(char *buffer, char **start, off_t offset, ...@@ -88,105 +45,8 @@ int NCR5380_proc_info(char *buffer, char **start, off_t offset,
#undef START_DMA_INITIATOR_RECEIVE_REG #undef START_DMA_INITIATOR_RECEIVE_REG
#define START_DMA_INITIATOR_RECEIVE_REG (7 + 128) #define START_DMA_INITIATOR_RECEIVE_REG (7 + 128)
static const card_ids oakscsi_cids[] = { const char * oakscsi_info (struct Scsi_Host *spnt)
{ MANU_OAK, PROD_OAK_SCSI },
{ 0xffff, 0xffff }
};
#define OAK_ADDRESS(card) (ecard_address((card), ECARD_MEMC, 0))
#define OAK_IRQ(card) (IRQ_NONE)
/*
* Function : int oakscsi_detect(Scsi_Host_Template * tpnt)
*
* Purpose : initializes oak NCR5380 driver based on the
* command line / compile time port and irq definitions.
*
* Inputs : tpnt - template for this SCSI adapter.
*
* Returns : 1 if a host adapter was found, 0 if not.
*
*/
static struct expansion_card *ecs[4];
int oakscsi_detect(Scsi_Host_Template * tpnt)
{
int count = 0;
struct Scsi_Host *instance;
tpnt->proc_name = "oakscsi";
memset (ecs, 0, sizeof (ecs));
ecard_startfind ();
while(1) {
if ((ecs[count] = ecard_find(0, oakscsi_cids)) == NULL)
break;
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!instance)
break;
instance->io_port = OAK_ADDRESS(ecs[count]);
instance->irq = OAK_IRQ(ecs[count]);
NCR5380_init(instance, 0);
ecard_claim(ecs[count]);
instance->n_io_port = 255;
if (!request_region (instance->io_port, instance->n_io_port, "Oak SCSI")) {
ecard_release(ecs[count]);
scsi_unregister(instance);
break;
}
if (instance->irq != IRQ_NONE)
if (request_irq(instance->irq, oakscsi_intr, SA_INTERRUPT, "Oak SCSI", NULL)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
instance->host_no, instance->irq);
instance->irq = IRQ_NONE;
}
if (instance->irq != IRQ_NONE) {
printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no);
printk("scsi%d: that the board had an interrupt!\n", instance->host_no);
}
printk("scsi%d: at port %lX irq", instance->host_no, instance->io_port);
if (instance->irq == IRQ_NONE)
printk ("s disabled");
else
printk (" %d", instance->irq);
printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
tpnt->can_queue, tpnt->cmd_per_lun, OAKSCSI_PUBLIC_RELEASE);
printk("\nscsi%d:", instance->host_no);
NCR5380_print_options(instance);
printk("\n");
++count;
}
#ifdef MODULE
if(count == 0)
printk("No oak scsi devices found\n");
#endif
return count;
}
int oakscsi_release (struct Scsi_Host *shpnt)
{ {
int i;
if (shpnt->irq != IRQ_NONE)
free_irq (shpnt->irq, NULL);
if (shpnt->io_port)
release_region (shpnt->io_port, shpnt->n_io_port);
for (i = 0; i < 4; i++)
if (shpnt->io_port == OAK_ADDRESS(ecs[i]))
ecard_release (ecs[i]);
return 0;
}
const char * oakscsi_info (struct Scsi_Host *spnt) {
return ""; return "";
} }
...@@ -258,8 +118,6 @@ static Scsi_Host_Template oakscsi_template = { ...@@ -258,8 +118,6 @@ static Scsi_Host_Template oakscsi_template = {
.module = THIS_MODULE, .module = THIS_MODULE,
.proc_info = oakscsi_proc_info, .proc_info = oakscsi_proc_info,
.name = "Oak 16-bit SCSI", .name = "Oak 16-bit SCSI",
.detect = oakscsi_detect,
.release = oakscsi_release,
.info = oakscsi_info, .info = oakscsi_info,
.queuecommand = oakscsi_queue_command, .queuecommand = oakscsi_queue_command,
.eh_abort_handler = NCR5380_abort, .eh_abort_handler = NCR5380_abort,
...@@ -270,22 +128,82 @@ static Scsi_Host_Template oakscsi_template = { ...@@ -270,22 +128,82 @@ static Scsi_Host_Template oakscsi_template = {
.this_id = 7, .this_id = 7,
.sg_tablesize = SG_ALL, .sg_tablesize = SG_ALL,
.cmd_per_lun = 2, .cmd_per_lun = 2,
.use_clustering = DISABLE_CLUSTERING .use_clustering = DISABLE_CLUSTERING,
.proc_name = "oakscsi",
}; };
static int __init oakscsi_init(void) static int __devinit
oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
{ {
scsi_register_host(&oakscsi_template); struct Scsi_Host *host;
if (oakscsi_template.present) int ret = -ENOMEM;
return 0;
host = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!host)
goto out;
host->io_port = ecard_address(ec, ECARD_MEMC, 0)
host->irq = IRQ_NONE;
host->n_io_port = 255;
scsi_unregister_host(&oakscsi_template); ret = -EBUSY;
return -ENODEV; if (!request_region (host->io_port, host->n_io_port, "Oak SCSI"))
goto unreg;
NCR5380_init(host, 0);
printk("scsi%d: at port 0x%08lx irqs disabled",
host->host_no, host->io_port);
printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
tpnt->can_queue, tpnt->cmd_per_lun, OAKSCSI_PUBLIC_RELEASE);
printk("\nscsi%d:", host->host_no);
NCR5380_print_options(host);
printk("\n");
ret = scsi_add_host(host);
if (ret == 0)
goto out;
release_region(host->io_port, host->n_io_port);
unreg:
scsi_unregister(host);
out:
return ret;
}
static void __devexit oakscsi_remove(struct expansion_card *ec)
{
struct Scsi_Host *host = ecard_get_drvdata(ec);
ecard_set_drvdata(ec, NULL);
scsi_remove_host(host);
release_region(host->io_port, host->n_io_port);
scsi_unregister(host);
}
static const struct ecard_id oakscsi_cids[] = {
{ MANU_OAK, PROD_OAK_SCSI },
{ 0xffff, 0xffff }
};
static struct ecard_driver oakscsi_driver = {
.probe = oakscsi_probe,
.remove = __devexit_p(oakscsi_remove),
.id_table = oakscsi_cids,
.drv = {
.name = "oakscsi",
},
};
static int __init oakscsi_init(void)
{
return ecard_register_driver(&oakscsi_driver);
} }
static void __exit oakscsi_exit(void) static void __exit oakscsi_exit(void)
{ {
scsi_unregister_host(&oakscsi_template); ecard_remove_driver(&oakscsi_driver);
} }
module_init(oakscsi_init); module_init(oakscsi_init);
......
/* /*
* linux/drivers/acorn/scsi/powertec.c * linux/drivers/acorn/scsi/powertec.c
* *
* Copyright (C) 1997-2000 Russell King * Copyright (C) 1997-2002 Russell King
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
*
* This driver is based on experimentation. Hence, it may have made
* assumptions about the particular card that I have available, and
* may not be reliable!
*
* Changelog:
* 01-10-1997 RMK Created, READONLY version.
* 15-02-1998 RMK Added DMA support and hardware definitions.
* 15-04-1998 RMK Only do PIO if FAS216 will allow it.
* 02-05-1998 RMK Moved DMA sg list into per-interface structure.
* 27-06-1998 RMK Changed asm/delay.h to linux/delay.h
* 02-04-2000 RMK Updated for new error handling code.
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/blk.h> #include <linux/blk.h>
...@@ -45,18 +33,9 @@ ...@@ -45,18 +33,9 @@
#include <scsi/scsicam.h> #include <scsi/scsicam.h>
/* Configuration */
#define POWERTEC_XTALFREQ 40
#define POWERTEC_ASYNC_PERIOD 200
#define POWERTEC_SYNC_DEPTH 7
/*
* List of devices that the driver will recognise
*/
#define POWERTECSCSI_LIST { MANU_ALSYSTEMS, PROD_ALSYS_SCSIATAPI }
#define POWERTEC_FAS216_OFFSET 0xc00 #define POWERTEC_FAS216_OFFSET 0xc00
#define POWERTEC_FAS216_SHIFT 4 #define POWERTEC_FAS216_SHIFT 4
#define POWERTEC_FAS216_SIZE (16 << POWERTEC_FAS216_SHIFT)
#define POWERTEC_INTR_STATUS 0x800 #define POWERTEC_INTR_STATUS 0x800
#define POWERTEC_INTR_BIT 0x80 #define POWERTEC_INTR_BIT 0x80
...@@ -71,33 +50,22 @@ ...@@ -71,33 +50,22 @@
#define POWERTEC_INTR_ENABLE 1 #define POWERTEC_INTR_ENABLE 1
#define POWERTEC_INTR_DISABLE 0 #define POWERTEC_INTR_DISABLE 0
/* #define VERSION "1.00 (13/11/2002 2.5.47)"
* Version
*/
#define VER_MAJOR 0
#define VER_MINOR 0
#define VER_PATCH 5
static struct expansion_card *ecs[MAX_ECARDS];
/* /*
* Use term=0,1,0,0,0 to turn terminators on/off * Use term=0,1,0,0,0 to turn terminators on/off.
* One entry per slot.
*/ */
static int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 }; static int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 };
#define NR_SG 256 #define NR_SG 256
typedef struct { struct powertec_info {
FAS216_Info info; FAS216_Info info;
struct {
unsigned int term_port; unsigned int term_port;
unsigned int terms; unsigned int term_ctl;
} control; struct scatterlist sg[NR_SG];
};
/* other info... */
struct scatterlist sg[NR_SG]; /* Scatter DMA list */
} PowerTecScsi_Info;
/* Prototype: void powertecscsi_irqenable(ec, irqnr) /* Prototype: void powertecscsi_irqenable(ec, irqnr)
* Purpose : Enable interrupts on Powertec SCSI card * Purpose : Enable interrupts on Powertec SCSI card
...@@ -124,12 +92,8 @@ powertecscsi_irqdisable(struct expansion_card *ec, int irqnr) ...@@ -124,12 +92,8 @@ powertecscsi_irqdisable(struct expansion_card *ec, int irqnr)
} }
static const expansioncard_ops_t powertecscsi_ops = { static const expansioncard_ops_t powertecscsi_ops = {
powertecscsi_irqenable, .irqenable = powertecscsi_irqenable,
powertecscsi_irqdisable, .irqdisable = powertecscsi_irqdisable,
NULL,
NULL,
NULL,
NULL
}; };
/* Prototype: void powertecscsi_terminator_ctl(host, on_off) /* Prototype: void powertecscsi_terminator_ctl(host, on_off)
...@@ -140,14 +104,10 @@ static const expansioncard_ops_t powertecscsi_ops = { ...@@ -140,14 +104,10 @@ static const expansioncard_ops_t powertecscsi_ops = {
static void static void
powertecscsi_terminator_ctl(struct Scsi_Host *host, int on_off) powertecscsi_terminator_ctl(struct Scsi_Host *host, int on_off)
{ {
PowerTecScsi_Info *info = (PowerTecScsi_Info *)host->hostdata; struct powertec_info *info = (struct powertec_info *)host->hostdata;
if (on_off)
info->control.terms = POWERTEC_TERM_ENABLE;
else
info->control.terms = 0;
outb(info->control.terms, info->control.term_port); info->term_ctl = on_off ? POWERTEC_TERM_ENABLE : 0;
outb(info->term_ctl, info->term_port);
} }
/* Prototype: void powertecscsi_intr(irq, *dev_id, *regs) /* Prototype: void powertecscsi_intr(irq, *dev_id, *regs)
...@@ -176,7 +136,7 @@ static fasdmatype_t ...@@ -176,7 +136,7 @@ static fasdmatype_t
powertecscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp, powertecscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,
fasdmadir_t direction, fasdmatype_t min_type) fasdmadir_t direction, fasdmatype_t min_type)
{ {
PowerTecScsi_Info *info = (PowerTecScsi_Info *)host->hostdata; struct powertec_info *info = (struct powertec_info *)host->hostdata;
int dmach = host->dma_channel; int dmach = host->dma_channel;
if (dmach != NO_DMA && if (dmach != NO_DMA &&
...@@ -220,122 +180,6 @@ powertecscsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp) ...@@ -220,122 +180,6 @@ powertecscsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp)
disable_dma(host->dma_channel); disable_dma(host->dma_channel);
} }
/* Prototype: int powertecscsi_detect(Scsi_Host_Template * tpnt)
* Purpose : initialises PowerTec SCSI driver
* Params : tpnt - template for this SCSI adapter
* Returns : >0 if host found, 0 otherwise.
*/
int
powertecscsi_detect(Scsi_Host_Template *tpnt)
{
static const card_ids powertecscsi_cids[] =
{ POWERTECSCSI_LIST, { 0xffff, 0xffff} };
int count = 0;
struct Scsi_Host *host;
tpnt->proc_name = "powertec";
memset(ecs, 0, sizeof (ecs));
ecard_startfind();
while (1) {
PowerTecScsi_Info *info;
ecs[count] = ecard_find(0, powertecscsi_cids);
if (!ecs[count])
break;
ecard_claim(ecs[count]);
host = scsi_register(tpnt, sizeof (PowerTecScsi_Info));
if (!host) {
ecard_release(ecs[count]);
break;
}
host->io_port = ecard_address(ecs[count], ECARD_IOC, ECARD_FAST);
host->irq = ecs[count]->irq;
host->dma_channel = ecs[count]->dma;
info = (PowerTecScsi_Info *)host->hostdata;
if (host->dma_channel != NO_DMA)
set_dma_speed(host->dma_channel, 180);
info->control.term_port = host->io_port + POWERTEC_TERM_CONTROL;
info->control.terms = term[count] ? POWERTEC_TERM_ENABLE : 0;
powertecscsi_terminator_ctl(host, info->control.terms);
info->info.scsi.io_port =
host->io_port + POWERTEC_FAS216_OFFSET;
info->info.scsi.io_shift= POWERTEC_FAS216_SHIFT;
info->info.scsi.irq = host->irq;
info->info.ifcfg.clockrate = POWERTEC_XTALFREQ;
info->info.ifcfg.select_timeout = 255;
info->info.ifcfg.asyncperiod = POWERTEC_ASYNC_PERIOD;
info->info.ifcfg.sync_max_depth = POWERTEC_SYNC_DEPTH;
info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
info->info.ifcfg.disconnect_ok = 1;
info->info.ifcfg.wide_max_size = 0;
info->info.dma.setup = powertecscsi_dma_setup;
info->info.dma.pseudo = NULL;
info->info.dma.stop = powertecscsi_dma_stop;
ecs[count]->irqaddr = (unsigned char *)
ioaddr(host->io_port + POWERTEC_INTR_STATUS);
ecs[count]->irqmask = POWERTEC_INTR_BIT;
ecs[count]->irq_data = (void *)
(host->io_port + POWERTEC_INTR_CONTROL);
ecs[count]->ops = (expansioncard_ops_t *)&powertecscsi_ops;
request_region(host->io_port + POWERTEC_FAS216_OFFSET,
16 << POWERTEC_FAS216_SHIFT, "powertec2-fas");
if (host->irq != NO_IRQ &&
request_irq(host->irq, powertecscsi_intr,
SA_INTERRUPT, "powertec", host)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
host->host_no, host->irq);
host->irq = NO_IRQ;
info->info.scsi.irq = NO_IRQ;
}
if (host->dma_channel != NO_DMA &&
request_dma(host->dma_channel, "powertec")) {
printk("scsi%d: DMA%d not free, DMA disabled\n",
host->host_no, host->dma_channel);
host->dma_channel = NO_DMA;
}
fas216_init(host);
++count;
}
return count;
}
/* Prototype: int powertecscsi_release(struct Scsi_Host * host)
* Purpose : releases all resources used by this adapter
* Params : host - driver host structure to return info for.
*/
int powertecscsi_release(struct Scsi_Host *host)
{
int i;
fas216_release(host);
if (host->irq != NO_IRQ)
free_irq(host->irq, host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
release_region(host->io_port + POWERTEC_FAS216_OFFSET,
16 << POWERTEC_FAS216_SHIFT);
for (i = 0; i < MAX_ECARDS; i++)
if (ecs[i] &&
host->io_port == ecard_address(ecs[i], ECARD_IOC, ECARD_FAST))
ecard_release(ecs[i]);
return 0;
}
/* Prototype: const char *powertecscsi_info(struct Scsi_Host * host) /* Prototype: const char *powertecscsi_info(struct Scsi_Host * host)
* Purpose : returns a descriptive string about this interface, * Purpose : returns a descriptive string about this interface,
* Params : host - driver host structure to return info for. * Params : host - driver host structure to return info for.
...@@ -343,15 +187,14 @@ int powertecscsi_release(struct Scsi_Host *host) ...@@ -343,15 +187,14 @@ int powertecscsi_release(struct Scsi_Host *host)
*/ */
const char *powertecscsi_info(struct Scsi_Host *host) const char *powertecscsi_info(struct Scsi_Host *host)
{ {
PowerTecScsi_Info *info = (PowerTecScsi_Info *)host->hostdata; struct powertec_info *info = (struct powertec_info *)host->hostdata;
static char string[100], *p; static char string[100], *p;
p = string; p = string;
p += sprintf(p, "%s ", host->hostt->name); p += sprintf(p, "%s ", host->hostt->name);
p += fas216_info(&info->info, p); p += fas216_info(&info->info, p);
p += sprintf(p, "v%d.%d.%d terminators o%s", p += sprintf(p, "v%s terminators o%s",
VER_MAJOR, VER_MINOR, VER_PATCH, VERSION, info->term_ctl ? "n" : "ff");
info->control.terms ? "n" : "ff");
return string; return string;
} }
...@@ -405,7 +248,7 @@ int powertecscsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -405,7 +248,7 @@ int powertecscsi_proc_info(char *buffer, char **start, off_t offset,
{ {
int pos, begin; int pos, begin;
struct Scsi_Host *host; struct Scsi_Host *host;
PowerTecScsi_Info *info; struct powertec_info *info;
Scsi_Device *scd; Scsi_Device *scd;
host = scsi_host_hn_get(host_no); host = scsi_host_hn_get(host_no);
...@@ -415,16 +258,14 @@ int powertecscsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -415,16 +258,14 @@ int powertecscsi_proc_info(char *buffer, char **start, off_t offset,
if (inout == 1) if (inout == 1)
return powertecscsi_set_proc_info(host, buffer, length); return powertecscsi_set_proc_info(host, buffer, length);
info = (PowerTecScsi_Info *)host->hostdata; info = (struct powertec_info *)host->hostdata;
begin = 0; begin = 0;
pos = sprintf(buffer, pos = sprintf(buffer, "PowerTec SCSI driver v%s\n", VERSION);
"PowerTec SCSI driver version %d.%d.%d\n",
VER_MAJOR, VER_MINOR, VER_PATCH);
pos += fas216_print_host(&info->info, buffer + pos); pos += fas216_print_host(&info->info, buffer + pos);
pos += sprintf(buffer + pos, "Term : o%s\n", pos += sprintf(buffer + pos, "Term : o%s\n",
info->control.terms ? "n" : "ff"); info->term_ctl ? "n" : "ff");
pos += fas216_print_stats(&info->info, buffer + pos); pos += fas216_print_stats(&info->info, buffer + pos);
...@@ -453,35 +294,147 @@ static Scsi_Host_Template powertecscsi_template = { ...@@ -453,35 +294,147 @@ static Scsi_Host_Template powertecscsi_template = {
.module = THIS_MODULE, .module = THIS_MODULE,
.proc_info = powertecscsi_proc_info, .proc_info = powertecscsi_proc_info,
.name = "PowerTec SCSI", .name = "PowerTec SCSI",
.detect = powertecscsi_detect,
.release = powertecscsi_release,
.info = powertecscsi_info, .info = powertecscsi_info,
.can_queue = 1,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = 1,
.use_clustering = ENABLE_CLUSTERING,
.command = fas216_command, .command = fas216_command,
.queuecommand = fas216_queue_command, .queuecommand = fas216_queue_command,
.eh_host_reset_handler = fas216_eh_host_reset, .eh_host_reset_handler = fas216_eh_host_reset,
.eh_bus_reset_handler = fas216_eh_bus_reset, .eh_bus_reset_handler = fas216_eh_bus_reset,
.eh_device_reset_handler = fas216_eh_device_reset, .eh_device_reset_handler = fas216_eh_device_reset,
.eh_abort_handler = fas216_eh_abort, .eh_abort_handler = fas216_eh_abort,
.can_queue = 1,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = 1,
.use_clustering = ENABLE_CLUSTERING,
.proc_name = "powertec",
}; };
static int __init powertecscsi_init(void) static int __devinit
powertecscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
{ {
scsi_register_host(&powertecscsi_template); struct Scsi_Host *host;
if (powertecscsi_template.present) struct powertec_info *info;
return 0; int ret = -ENOMEM;
host = scsi_register(&powertecscsi_template,
sizeof (struct powertec_info));
if (!host)
goto out;
host->io_port = ecard_address(ec, ECARD_IOC, ECARD_FAST);
host->irq = ec->irq;
host->dma_channel = ec->dma;
if (!request_region(host->io_port + POWERTEC_FAS216_OFFSET,
POWERTEC_FAS216_SIZE, "powertec2-fas")) {
ret = -EBUSY;
goto out_free;
}
ec->irqaddr = (unsigned char *)
ioaddr(host->io_port + POWERTEC_INTR_STATUS);
ec->irqmask = POWERTEC_INTR_BIT;
ec->irq_data = (void *)(host->io_port + POWERTEC_INTR_CONTROL);
ec->ops = (expansioncard_ops_t *)&powertecscsi_ops;
ecard_set_drvdata(ec, host);
info = (struct powertec_info *)host->hostdata;
info->term_port = host->io_port + POWERTEC_TERM_CONTROL;
powertecscsi_terminator_ctl(host, term[ec->slot_no]);
info->info.scsi.io_port = host->io_port + POWERTEC_FAS216_OFFSET;
info->info.scsi.io_shift = POWERTEC_FAS216_SHIFT;
info->info.scsi.irq = host->irq;
info->info.ifcfg.clockrate = 40; /* MHz */
info->info.ifcfg.select_timeout = 255;
info->info.ifcfg.asyncperiod = 200; /* ns */
info->info.ifcfg.sync_max_depth = 7;
info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
info->info.ifcfg.disconnect_ok = 1;
info->info.ifcfg.wide_max_size = 0;
info->info.dma.setup = powertecscsi_dma_setup;
info->info.dma.pseudo = NULL;
info->info.dma.stop = powertecscsi_dma_stop;
ret = request_irq(host->irq, powertecscsi_intr,
SA_INTERRUPT, "powertec", host);
if (ret) {
printk("scsi%d: IRQ%d not free: %d\n",
host->host_no, host->irq, ret);
goto out_region;
}
if (host->dma_channel != NO_DMA) {
if (request_dma(host->dma_channel, "powertec")) {
printk("scsi%d: DMA%d not free, using PIO\n",
host->host_no, host->dma_channel);
host->dma_channel = NO_DMA;
} else {
set_dma_speed(host->dma_channel, 180);
}
}
fas216_init(host);
ret = scsi_add_host(host);
if (ret == 0)
goto out;
fas216_release(host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
free_irq(host->irq, host);
out_region:
release_region(host->io_port + POWERTEC_FAS216_OFFSET,
POWERTEC_FAS216_SIZE);
out_free:
scsi_unregister(host);
out:
return ret;
}
scsi_unregister_host(&powertecscsi_template); static void __devexit powertecscsi_remove(struct expansion_card *ec)
return -ENODEV; {
struct Scsi_Host *host = ecard_get_drvdata(ec);
ecard_set_drvdata(ec, NULL);
scsi_remove_host(host);
fas216_release(host);
if (host->dma_channel != NO_DMA)
free_dma(host->dma_channel);
free_irq(host->irq, host);
release_region(host->io_port + POWERTEC_FAS216_OFFSET,
POWERTEC_FAS216_SIZE);
scsi_unregister(host);
}
static const struct ecard_id powertecscsi_cids[] = {
{ MANU_ALSYSTEMS, PROD_ALSYS_SCSIATAPI },
{ 0xffff, 0xffff },
};
static struct ecard_driver powertecscsi_driver = {
.probe = powertecscsi_probe,
.remove = __devexit_p(powertecscsi_remove),
.id_table = powertecscsi_cids,
.drv = {
.name = "powertecscsi",
},
};
static int __init powertecscsi_init(void)
{
return ecard_register_driver(&powertecscsi_driver);
} }
static void __exit powertecscsi_exit(void) static void __exit powertecscsi_exit(void)
{ {
scsi_unregister_host(&powertecscsi_template); ecard_remove_driver(&powertecscsi_driver);
} }
module_init(powertecscsi_init); module_init(powertecscsi_init);
...@@ -492,4 +445,3 @@ MODULE_DESCRIPTION("Powertec SCSI driver"); ...@@ -492,4 +445,3 @@ MODULE_DESCRIPTION("Powertec SCSI driver");
MODULE_PARM(term, "1-8i"); MODULE_PARM(term, "1-8i");
MODULE_PARM_DESC(term, "SCSI bus termination"); MODULE_PARM_DESC(term, "SCSI bus termination");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -228,6 +228,27 @@ Scsi_Cmnd *queue_remove_tgtluntag (Queue_t *queue, int target, int lun, int tag) ...@@ -228,6 +228,27 @@ Scsi_Cmnd *queue_remove_tgtluntag (Queue_t *queue, int target, int lun, int tag)
return SCpnt; return SCpnt;
} }
/*
* Function: queue_remove_all_target(queue, target)
* Purpose : remove all SCSI commands from the queue for a specified target
* Params : queue - queue to remove command from
* target - target device id
* Returns : nothing
*/
void queue_remove_all_target(Queue_t *queue, int target)
{
unsigned long flags;
struct list_head *l;
spin_lock_irqsave(&queue->queue_lock, flags);
list_for_each(l, &queue->head) {
QE_t *q = list_entry(l, QE_t, list);
if (q->SCpnt->target == target)
__queue_remove(queue, l);
}
spin_unlock_irqrestore(&queue->queue_lock, flags);
}
/* /*
* Function: int queue_probetgtlun (queue, target, lun) * Function: int queue_probetgtlun (queue, target, lun)
* Purpose : check to see if we have a command in the queue for the specified * Purpose : check to see if we have a command in the queue for the specified
...@@ -290,6 +311,7 @@ EXPORT_SYMBOL(queue_remove); ...@@ -290,6 +311,7 @@ EXPORT_SYMBOL(queue_remove);
EXPORT_SYMBOL(queue_remove_exclude); EXPORT_SYMBOL(queue_remove_exclude);
EXPORT_SYMBOL(queue_remove_tgtluntag); EXPORT_SYMBOL(queue_remove_tgtluntag);
EXPORT_SYMBOL(queue_remove_cmd); EXPORT_SYMBOL(queue_remove_cmd);
EXPORT_SYMBOL(queue_remove_all_target);
EXPORT_SYMBOL(queue_probetgtlun); EXPORT_SYMBOL(queue_probetgtlun);
MODULE_AUTHOR("Russell King"); MODULE_AUTHOR("Russell King");
......
...@@ -73,6 +73,15 @@ extern int __queue_add(Queue_t *queue, Scsi_Cmnd *SCpnt, int head); ...@@ -73,6 +73,15 @@ extern int __queue_add(Queue_t *queue, Scsi_Cmnd *SCpnt, int head);
*/ */
extern Scsi_Cmnd *queue_remove_tgtluntag (Queue_t *queue, int target, int lun, int tag); extern Scsi_Cmnd *queue_remove_tgtluntag (Queue_t *queue, int target, int lun, int tag);
/*
* Function: queue_remove_all_target(queue, target)
* Purpose : remove all SCSI commands from the queue for a specified target
* Params : queue - queue to remove command from
* target - target device id
* Returns : nothing
*/
extern void queue_remove_all_target(Queue_t *queue, int target);
/* /*
* Function: int queue_probetgtlun (queue, target, lun) * Function: int queue_probetgtlun (queue, target, lun)
* Purpose : check to see if we have a command in the queue for the specified * Purpose : check to see if we have a command in the queue for the specified
......
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
#define MANU_SERPORT 0x003f #define MANU_SERPORT 0x003f
#define PROD_SERPORT_DSPORT 0x00b9 #define PROD_SERPORT_DSPORT 0x00b9
#define MANU_ARXE 0x0041
#define PROD_ARXE_SCSI 0x00be
#define MANU_I3 0x0046 #define MANU_I3 0x0046
#define PROD_I3_ETHERLAN500 0x00d4 #define PROD_I3_ETHERLAN500 0x00d4
#define PROD_I3_ETHERLAN600 0x00ec #define PROD_I3_ETHERLAN600 0x00ec
...@@ -95,11 +98,11 @@ typedef enum { /* Speed for ECARD_IOC space */ ...@@ -95,11 +98,11 @@ typedef enum { /* Speed for ECARD_IOC space */
ECARD_SYNC = 3 ECARD_SYNC = 3
} card_speed_t; } card_speed_t;
typedef struct ecard_id { /* Card ID structure */ struct ecard_id { /* Card ID structure */
unsigned short manufacturer; unsigned short manufacturer;
unsigned short product; unsigned short product;
void *data; void *data;
} card_ids; };
struct in_ecid { /* Packed card ID information */ struct in_ecid { /* Packed card ID information */
unsigned short product; /* Product code */ unsigned short product; /* Product code */
...@@ -177,16 +180,6 @@ struct in_chunk_dir { ...@@ -177,16 +180,6 @@ struct in_chunk_dir {
*/ */
#define ecard_release(ec) ((ec)->claimed = 0) #define ecard_release(ec) ((ec)->claimed = 0)
/*
* Start finding cards from the top of the list
*/
extern void ecard_startfind (void);
/*
* Find an expansion card with the correct cid, product and manufacturer code
*/
extern struct expansion_card *ecard_find (int cid, const card_ids *ids);
/* /*
* Read a chunk from an expansion card * Read a chunk from an expansion card
* cd : where to put read data * cd : where to put read data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment