Commit 151eb016 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] atp870u scsi update

Rediffed with the 2.5.28 biosparm change included
parent cd2e72b7
......@@ -3,6 +3,7 @@
*
* Copyright (C) 1997 Wu Ching Chen
* 2.1.x update (C) 1998 Krzysztof G. Baranowski
* 2.5.x update (C) 2002 Red Hat <alan@redhat.com>
*
* Marcelo Tosatti <marcelo@conectiva.com.br> : SMP fixes
*
......@@ -11,11 +12,10 @@
* enable 32 bit fifo transfer
* support cdrom & remove device run ultra speed
* fix disconnect bug 2000/12/21
* support atp880 chip lvd u160 2001/05/15 (7.1)
* support atp880 chip lvd u160 2001/05/15
* fix prd table bug 2001/09/12 (7.1)
*/
#error Please convert me to Documentation/DMA-mapping.txt
#include <linux/module.h>
#include <linux/kernel.h>
......@@ -38,19 +38,15 @@
#include<linux/stat.h>
void mydlyu(unsigned int);
/*
* static const char RCSid[] = "$Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/atp870u.c,v 1.0 1997/05/07 15:22:00 root Exp root $";
*/
static unsigned char admaxu = 1;
static unsigned short int sync_idu;
static unsigned int irqnumu[2] = {0, 0};
#define MAX_ATP 16
struct atp_unit
{
struct atp_unit {
unsigned long ioport;
unsigned long irq;
unsigned long pciport;
......@@ -72,8 +68,7 @@ struct atp_unit
unsigned char ata_cdbu[16];
unsigned char sp[16];
Scsi_Cmnd *querequ[qcnt];
struct atp_id
{
struct atp_id {
unsigned char dirctu;
unsigned char devspu;
unsigned char devtypeu;
......@@ -82,58 +77,50 @@ struct atp_unit
unsigned long last_lenu;
unsigned char *prd_posu;
unsigned char *prd_tableu;
dma_addr_t prd_phys;
Scsi_Cmnd *curr_req;
} id[16];
struct Scsi_Host *host;
struct pci_dev *pdev;
};
static struct Scsi_Host *atp_host[2] = {NULL, NULL};
static struct atp_unit atp_unit[2];
static struct Scsi_Host *atp_host[MAX_ATP];
static void send_s870(struct Scsi_Host *);
static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
{
unsigned long flags;
unsigned short int tmpcip, id;
unsigned char i, j, h, target_id, lun;
unsigned char i, j, target_id, lun;
unsigned char *prd;
Scsi_Cmnd *workrequ;
unsigned int workportu, tmport;
unsigned long adrcntu, k;
int errstus;
struct atp_unit *dev = dev_id;
struct Scsi_Host *host = dev_id;
struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
for (h = 0; h < 2; h++) {
if (irq == irqnumu[h]) {
goto irq_numok;
}
}
return;
irq_numok:
dev->in_int = 1;
workportu = dev->ioport;
tmport = workportu;
if (dev->working != 0)
{
if (dev->working != 0) {
tmport += 0x1f;
j = inb(tmport);
if ((j & 0x80) == 0)
{
if ((j & 0x80) == 0) {
dev->in_int = 0;
return;
}
tmpcip = dev->pciport;
if ((inb(tmpcip) & 0x08) != 0)
{
if ((inb(tmpcip) & 0x08) != 0) {
tmpcip += 0x2;
for (k=0; k < 1000; k++)
{
if ((inb(tmpcip) & 0x08) == 0)
{
for (k = 0; k < 1000; k++) {
if ((inb(tmpcip) & 0x08) == 0) {
goto stop_dma;
}
if ((inb(tmpcip) & 0x01) == 0)
{
if ((inb(tmpcip) & 0x01) == 0) {
goto stop_dma;
}
}
......@@ -159,40 +146,32 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
target_id &= 0x07;
}
if ((j & 0x40) != 0)
{
if (dev->last_cmd == 0xff)
{
if ((j & 0x40) != 0) {
if (dev->last_cmd == 0xff) {
dev->last_cmd = target_id;
}
dev->last_cmd |= 0x40;
}
if (i == 0x85)
{
if ((dev->last_cmd & 0xf0) != 0x40)
{
if (i == 0x85) {
if ((dev->last_cmd & 0xf0) != 0x40) {
dev->last_cmd = 0xff;
}
/*
* Flip wide
*/
if (dev->wide_idu != 0)
{
if (dev->wide_idu != 0) {
tmport = workportu + 0x1b;
outb(0x01,tmport);
while ((inb(tmport) & 0x01) != 0x01)
{
outb(0x01,tmport);
outb(0x01, tmport);
while ((inb(tmport) & 0x01) != 0x01) {
outb(0x01, tmport);
}
}
/*
* Issue more commands
*/
if (((dev->quhdu != dev->quendu) || (dev->last_cmd != 0xff)) &&
(dev->in_snd == 0))
{
send_s870(h);
if (((dev->quhdu != dev->quendu) || (dev->last_cmd != 0xff)) && (dev->in_snd == 0)) {
send_s870(host);
}
/*
* Done
......@@ -201,17 +180,14 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
return;
}
if (i == 0x40)
{
if (i == 0x40) {
dev->last_cmd |= 0x40;
dev->in_int = 0;
return;
}
if (i == 0x21)
{
if ((dev->last_cmd & 0xf0) != 0x40)
{
if (i == 0x21) {
if ((dev->last_cmd & 0xf0) != 0x40) {
dev->last_cmd = 0xff;
}
tmport -= 0x05;
......@@ -230,21 +206,18 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
dev->in_int = 0;
return;
}
if ((i == 0x80) || (i == 0x8f))
{
if ((i == 0x80) || (i == 0x8f)) {
lun = 0;
tmport -= 0x07;
j = inb(tmport);
if (j == 0x44 || i==0x80) {
if (j == 0x44 || i == 0x80) {
tmport += 0x0d;
lun = inb(tmport) & 0x07;
} else {
if ((dev->last_cmd & 0xf0) != 0x40)
{
if ((dev->last_cmd & 0xf0) != 0x40) {
dev->last_cmd = 0xff;
}
if (j == 0x41)
{
if (j == 0x41) {
tmport += 0x02;
adrcntu = 0;
((unsigned char *) &adrcntu)[2] = inb(tmport++);
......@@ -258,9 +231,7 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
outb(0x08, tmport);
dev->in_int = 0;
return;
}
else
{
} else {
outb(0x46, tmport);
dev->id[target_id].dirctu = 0x00;
tmport += 0x02;
......@@ -273,8 +244,7 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
return;
}
}
if (dev->last_cmd != 0xff)
{
if (dev->last_cmd != 0xff) {
dev->last_cmd |= 0x40;
}
tmport = workportu + 0x10;
......@@ -284,8 +254,7 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
/*
* Remap wide identifiers
*/
if ((target_id & 0x10) != 0)
{
if ((target_id & 0x10) != 0) {
target_id = (target_id & 0x07) | 0x08;
} else {
target_id &= 0x07;
......@@ -311,30 +280,19 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
outb(0x80, tmport);
/* enable 32 bit fifo transfer */
if (dev->deviceid != 0x8081)
{
if (dev->deviceid != 0x8081) {
tmport = workportu + 0x3a;
if ((dev->ata_cdbu[0] == 0x08) || (dev->ata_cdbu[0] == 0x28) ||
(dev->ata_cdbu[0] == 0x0a) || (dev->ata_cdbu[0] == 0x2a))
{
outb((unsigned char)((inb(tmport) & 0xf3) | 0x08),tmport);
}
else
{
outb((unsigned char)(inb(tmport) & 0xf3),tmport);
}
if ((dev->ata_cdbu[0] == 0x08) || (dev->ata_cdbu[0] == 0x28) || (dev->ata_cdbu[0] == 0x0a) || (dev->ata_cdbu[0] == 0x2a)) {
outb((unsigned char) ((inb(tmport) & 0xf3) | 0x08), tmport);
} else {
outb((unsigned char) (inb(tmport) & 0xf3), tmport);
}
else
{
} else {
tmport = workportu - 0x05;
if ((dev->ata_cdbu[0] == 0x08) || (dev->ata_cdbu[0] == 0x28) ||
(dev->ata_cdbu[0] == 0x0a) || (dev->ata_cdbu[0] == 0x2a))
{
outb((unsigned char)((inb(tmport) & 0x3f) | 0xc0),tmport);
}
else
{
outb((unsigned char)(inb(tmport) & 0x3f),tmport);
if ((dev->ata_cdbu[0] == 0x08) || (dev->ata_cdbu[0] == 0x28) || (dev->ata_cdbu[0] == 0x0a) || (dev->ata_cdbu[0] == 0x2a)) {
outb((unsigned char) ((inb(tmport) & 0x3f) | 0xc0), tmport);
} else {
outb((unsigned char) (inb(tmport) & 0x3f), tmport);
}
}
......@@ -349,9 +307,8 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
j |= 0x01;
}
outb(j, tmport);
while ((inb(tmport) & 0x01) != j)
{
outb(j,tmport);
while ((inb(tmport) & 0x01) != j) {
outb(j, tmport);
}
if (dev->id[target_id].last_lenu == 0) {
......@@ -361,8 +318,7 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
return;
}
prd = dev->id[target_id].prd_posu;
while (adrcntu != 0)
{
while (adrcntu != 0) {
id = ((unsigned short int *) (prd))[2];
if (id == 0) {
k = 0x10000;
......@@ -413,18 +369,15 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
workrequ = dev->id[target_id].curr_req;
if (i == 0x42) {
if ((dev->last_cmd & 0xf0) != 0x40)
{
if ((dev->last_cmd & 0xf0) != 0x40) {
dev->last_cmd = 0xff;
}
errstus = 0x02;
workrequ->result = errstus;
goto go_42;
}
if (i == 0x16)
{
if ((dev->last_cmd & 0xf0) != 0x40)
{
if (i == 0x16) {
if ((dev->last_cmd & 0xf0) != 0x40) {
dev->last_cmd = 0xff;
}
errstus = 0;
......@@ -435,7 +388,12 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
/*
* Complete the command
*/
spin_lock_irqsave(workrequ->host->host_lock, flags);
if(workrequ->use_sg)
pci_unmap_sg(dev->pdev, (struct scatterlist *)workrequ->buffer, workrequ->use_sg, scsi_to_pci_dma_dir(workrequ->sc_data_direction));
else if(workrequ->request_bufflen && workrequ->sc_data_direction != SCSI_DATA_NONE)
pci_unmap_single(dev->pdev, workrequ->SCp.dma_handle, workrequ->request_bufflen, scsi_to_pci_dma_dir(workrequ->sc_data_direction));
spin_lock_irqsave(dev->host->host_lock, flags);
(*workrequ->scsi_done) (workrequ);
/*
......@@ -443,31 +401,27 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
*/
dev->id[target_id].curr_req = 0;
dev->working--;
spin_unlock_irqrestore(workrequ->host->host_lock, flags);
spin_unlock_irqrestore(dev->host->host_lock, flags);
/*
* Take it back wide
*/
if (dev->wide_idu != 0) {
tmport = workportu + 0x1b;
outb(0x01,tmport);
while ((inb(tmport) & 0x01) != 0x01)
{
outb(0x01,tmport);
outb(0x01, tmport);
while ((inb(tmport) & 0x01) != 0x01) {
outb(0x01, tmport);
}
}
/*
* If there is stuff to send and nothing going then send it
*/
if (((dev->last_cmd != 0xff) || (dev->quhdu != dev->quendu)) &&
(dev->in_snd == 0))
{
send_s870(h);
if (((dev->last_cmd != 0xff) || (dev->quhdu != dev->quendu)) && (dev->in_snd == 0)) {
send_s870(host);
}
dev->in_int = 0;
return;
}
if ((dev->last_cmd & 0xf0) != 0x40)
{
if ((dev->last_cmd & 0xf0) != 0x40) {
dev->last_cmd = 0xff;
}
if (i == 0x4f) {
......@@ -532,27 +486,23 @@ static void atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
}
}
int atp870u_queuecommand(Scsi_Cmnd * req_p, void (*done) (Scsi_Cmnd *))
static int atp870u_queuecommand(Scsi_Cmnd * req_p, void (*done) (Scsi_Cmnd *))
{
unsigned char h;
unsigned long flags;
unsigned short int m;
unsigned int tmport;
struct Scsi_Host *host;
struct atp_unit *dev;
for (h = 0; h <= admaxu; h++) {
if (req_p->host == atp_host[h]) {
goto host_ok;
}
}
return 0;
host_ok:
if (req_p->channel != 0) {
req_p->result = 0x00040000;
done(req_p);
return 0;
}
dev = &atp_unit[h];
};
host = req_p->host;
dev = (struct atp_unit *)&host->hostdata;
m = 1;
m = m << req_p->target;
......@@ -576,8 +526,8 @@ int atp870u_queuecommand(Scsi_Cmnd * req_p, void (*done) (Scsi_Cmnd *))
/*
* Count new command
*/
save_flags(flags);
cli();
spin_lock_irqsave(host->host_lock, flags);
dev->quendu++;
if (dev->quendu >= qcnt) {
dev->quendu = 0;
......@@ -591,28 +541,20 @@ int atp870u_queuecommand(Scsi_Cmnd * req_p, void (*done) (Scsi_Cmnd *))
}
dev->quendu--;
req_p->result = 0x00020000;
spin_unlock_irqrestore(host->host_lock, flags);
done(req_p);
restore_flags(flags);
return 0;
}
dev->querequ[dev->quendu] = req_p;
tmport = dev->ioport + 0x1c;
restore_flags(flags);
spin_unlock_irqrestore(host->host_lock, flags);
if ((inb(tmport) == 0) && (dev->in_int == 0) && (dev->in_snd == 0)) {
send_s870(h);
send_s870(host);
}
return 0;
}
void mydlyu(unsigned int dlycnt)
{
unsigned int i;
for (i = 0; i < dlycnt; i++) {
inb(0x80);
}
}
void send_s870(unsigned char h)
static void send_s870(struct Scsi_Host *host)
{
unsigned int tmport;
Scsi_Cmnd *workrequ;
......@@ -621,38 +563,37 @@ void send_s870(unsigned char h)
unsigned char j, target_id;
unsigned char *prd;
unsigned short int tmpcip, w;
unsigned long l, bttl;
unsigned long l;
dma_addr_t bttl;
unsigned int workportu;
struct scatterlist *sgpnt;
struct atp_unit *dev = &atp_unit[h];
struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
int sg_count;
spin_lock_irqsave(host->host_lock, flags);
save_flags(flags);
cli();
if (dev->in_snd != 0) {
restore_flags(flags);
spin_unlock_irqrestore(host->host_lock, flags);
return;
}
dev->in_snd = 1;
if ((dev->last_cmd != 0xff) && ((dev->last_cmd & 0x40) != 0)) {
dev->last_cmd &= 0x0f;
workrequ = dev->id[dev->last_cmd].curr_req;
if (workrequ != NULL) /* check NULL pointer */
{
if (workrequ != NULL) { /* check NULL pointer */
goto cmd_subp;
}
dev->last_cmd = 0xff;
if (dev->quhdu == dev->quendu)
{
if (dev->quhdu == dev->quendu) {
dev->in_snd = 0;
restore_flags(flags);
return ;
spin_unlock_irqrestore(dev->host->host_lock, flags);
return;
}
}
if ((dev->last_cmd != 0xff) && (dev->working != 0))
{
if ((dev->last_cmd != 0xff) && (dev->working != 0)) {
dev->in_snd = 0;
restore_flags(flags);
return ;
spin_unlock_irqrestore(dev->host->host_lock, flags);
return;
}
dev->working++;
j = dev->quhdu;
......@@ -669,7 +610,7 @@ void send_s870(unsigned char h)
dev->quhdu = j;
dev->working--;
dev->in_snd = 0;
restore_flags(flags);
spin_unlock_irqrestore(host->host_lock, flags);
return;
cmd_subp:
workportu = dev->ioport;
......@@ -684,7 +625,7 @@ void send_s870(unsigned char h)
abortsnd:
dev->last_cmd |= 0x40;
dev->in_snd = 0;
restore_flags(flags);
spin_unlock_irqrestore(dev->host->host_lock, flags);
return;
oktosend:
memcpy(&dev->ata_cdbu[0], &workrequ->cmnd[0], workrequ->cmd_len);
......@@ -710,9 +651,8 @@ void send_s870(unsigned char h)
j |= 0x01;
}
outb(j, tmport);
while ((inb(tmport) & 0x01) != j)
{
outb(j,tmport);
while ((inb(tmport) & 0x01) != j) {
outb(j, tmport);
}
/*
......@@ -737,21 +677,21 @@ void send_s870(unsigned char h)
/*
* Figure out the transfer size
*/
if (workrequ->use_sg)
{
if (workrequ->use_sg) {
l = 0;
sgpnt = (struct scatterlist *) workrequ->request_buffer;
for (i = 0; i < workrequ->use_sg; i++)
{
if (sgpnt[i].length == 0 || workrequ->use_sg > ATP870U_SCATTER)
{
sg_count = pci_map_sg(dev->pdev, sgpnt, workrequ->use_sg, scsi_to_pci_dma_dir(workrequ->sc_data_direction));
for (i = 0; i < workrequ->use_sg; i++) {
if (sgpnt[i].length == 0 || workrequ->use_sg > ATP870U_SCATTER) {
panic("Foooooooood fight!");
}
l += sgpnt[i].length;
}
} else {
} else if(workrequ->request_bufflen && workrequ->sc_data_direction != PCI_DMA_NONE) {
workrequ->SCp.dma_handle = pci_map_single(dev->pdev, workrequ->request_buffer, workrequ->request_bufflen, scsi_to_pci_dma_dir(workrequ->sc_data_direction));
l = workrequ->request_bufflen;
}
else l = 0;
/*
* Write transfer size
*/
......@@ -770,13 +710,12 @@ void send_s870(unsigned char h)
/*
* Check transfer direction
*/
if ((dev->ata_cdbu[0] == WRITE_6) || (dev->ata_cdbu[0] == WRITE_10) ||
(dev->ata_cdbu[0] == WRITE_12) || (dev->ata_cdbu[0] == MODE_SELECT)) {
if (workrequ->sc_data_direction == SCSI_DATA_WRITE) {
outb((unsigned char) (j | 0x20), tmport++);
} else {
outb(j, tmport++);
}
outb((unsigned char)(inb(tmport) | 0x80),tmport);
outb((unsigned char) (inb(tmport) | 0x80), tmport);
outb(0x80, tmport);
tmport = workportu + 0x1c;
dev->id[target_id].dirctu = 0;
......@@ -788,7 +727,7 @@ void send_s870(unsigned char h)
dev->last_cmd |= 0x40;
}
dev->in_snd = 0;
restore_flags(flags);
spin_unlock_irqrestore(host->host_lock, flags);
return;
}
tmpcip = dev->pciport;
......@@ -800,75 +739,71 @@ void send_s870(unsigned char h)
* a linear chain.
*/
if (workrequ->use_sg)
{
if (workrequ->use_sg) {
sgpnt = (struct scatterlist *) workrequ->request_buffer;
i = 0;
for (j = 0; j < workrequ->use_sg; j++) {
(unsigned long) (((unsigned long *) (prd))[i >> 1]) = virt_to_bus(sgpnt[j].address);
(unsigned short int) (((unsigned short int *) (prd))[i + 2]) = sgpnt[j].length;
(unsigned short int) (((unsigned short int *) (prd))[i + 3]) = 0;
bttl = sg_dma_address(&sgpnt[j]);
l = sg_dma_len(&sgpnt[j]);
while (l > 0x10000) {
(u16) (((u16 *) (prd))[i + 3]) = 0x0000;
(u16) (((u16 *) (prd))[i + 2]) = 0x0000;
(u32) (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
l -= 0x10000;
bttl += 0x10000;
i += 0x04;
}
(u32) (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
(u16) (((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
(u16) (((u16 *) (prd))[i + 3]) = 0;
i += 0x04;
}
(unsigned short int) (((unsigned short int *) (prd))[i - 1]) = 0x8000;
(u16) (((u16 *) (prd))[i - 1]) = cpu_to_le16(0x8000);
} else {
/*
* For a linear request write a chain of blocks
*/
bttl = virt_to_bus(workrequ->request_buffer);
bttl = workrequ->SCp.dma_handle;
l = workrequ->request_bufflen;
i = 0;
while (l > 0x10000) {
(unsigned short int) (((unsigned short int *) (prd))[i + 3]) = 0x0000;
(unsigned short int) (((unsigned short int *) (prd))[i + 2]) = 0x0000;
(unsigned long) (((unsigned long *) (prd))[i >> 1]) = bttl;
(u16) (((u16 *) (prd))[i + 3]) = 0x0000;
(u16) (((u16 *) (prd))[i + 2]) = 0x0000;
(u32) (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
l -= 0x10000;
bttl += 0x10000;
i += 0x04;
}
(unsigned short int) (((unsigned short int *) (prd))[i + 3]) = 0x8000;
(unsigned short int) (((unsigned short int *) (prd))[i + 2]) = l;
(unsigned long) (((unsigned long *) (prd))[i >> 1]) = bttl;
(u16) (((u16 *) (prd))[i + 3]) = cpu_to_le16(0x8000);
(u16) (((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
(u32) (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
}
tmpcip = tmpcip + 4;
dev->id[target_id].prdaddru = virt_to_bus(dev->id[target_id].prd_tableu);
outl(dev->id[target_id].prdaddru, tmpcip);
dev->id[target_id].prdaddru = dev->id[target_id].prd_phys;
outl(dev->id[target_id].prd_phys, tmpcip);
tmpcip = tmpcip - 2;
outb(0x06, tmpcip);
outb(0x00, tmpcip);
tmpcip = tmpcip - 2;
if (dev->deviceid != 0x8081)
{
if (dev->deviceid != 0x8081) {
tmport = workportu + 0x3a;
if ((dev->ata_cdbu[0] == 0x08) || (dev->ata_cdbu[0] == 0x28) ||
(dev->ata_cdbu[0] == 0x0a) || (dev->ata_cdbu[0] == 0x2a))
{
outb((unsigned char)((inb(tmport) & 0xf3) | 0x08),tmport);
}
else
{
outb((unsigned char)(inb(tmport) & 0xf3),tmport);
}
if ((dev->ata_cdbu[0] == 0x08) || (dev->ata_cdbu[0] == 0x28) || (dev->ata_cdbu[0] == 0x0a) || (dev->ata_cdbu[0] == 0x2a)) {
outb((inb(tmport) & 0xf3) | 0x08, tmport);
} else {
outb(inb(tmport) & 0xf3, tmport);
}
else
{
} else {
tmport = workportu - 0x05;
if ((dev->ata_cdbu[0] == 0x08) || (dev->ata_cdbu[0] == 0x28) ||
(dev->ata_cdbu[0] == 0x0a) || (dev->ata_cdbu[0] == 0x2a))
{
outb((unsigned char)((inb(tmport) & 0x3f) | 0xc0),tmport);
}
else
{
outb((unsigned char)(inb(tmport) & 0x3f),tmport);
if ((dev->ata_cdbu[0] == 0x08) || (dev->ata_cdbu[0] == 0x28) || (dev->ata_cdbu[0] == 0x0a) || (dev->ata_cdbu[0] == 0x2a)) {
outb((unsigned char) ((inb(tmport) & 0x3f) | 0xc0), tmport);
} else {
outb((unsigned char) (inb(tmport) & 0x3f), tmport);
}
}
tmport = workportu + 0x1c;
if ((dev->ata_cdbu[0] == WRITE_6) || (dev->ata_cdbu[0] == WRITE_10) ||
(dev->ata_cdbu[0] == WRITE_12) || (dev->ata_cdbu[0] == MODE_SELECT))
{
if (workrequ->sc_data_direction == SCSI_DATA_WRITE) {
dev->id[target_id].dirctu = 0x20;
if (inb(tmport) == 0) {
tmport = workportu + 0x18;
......@@ -878,11 +813,10 @@ void send_s870(unsigned char h)
dev->last_cmd |= 0x40;
}
dev->in_snd = 0;
restore_flags(flags);
spin_unlock_irqrestore(host->host_lock, flags);
return;
}
if (inb(tmport) == 0)
{
if (inb(tmport) == 0) {
tmport = workportu + 0x18;
outb(0x08, tmport);
outb(0x09, tmpcip);
......@@ -890,7 +824,7 @@ void send_s870(unsigned char h)
dev->last_cmd |= 0x40;
}
dev->in_snd = 0;
restore_flags(flags);
spin_unlock_irqrestore(host->host_lock, flags);
return;
}
......@@ -900,18 +834,21 @@ static void internal_done(Scsi_Cmnd * SCpnt)
SCpnt->SCp.Status++;
}
int atp870u_command(Scsi_Cmnd * SCpnt)
static int atp870u_command(Scsi_Cmnd * SCpnt)
{
atp870u_queuecommand(SCpnt, internal_done);
SCpnt->SCp.Status = 0;
while (!SCpnt->SCp.Status)
{
cpu_relax();
barrier();
}
return SCpnt->result;
}
unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)
static unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)
{
unsigned int tmport;
unsigned short int i, k;
......@@ -942,7 +879,7 @@ unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)
outw(*val, tmport);
*val &= 0xbfff; /* release DB6 */
outw(*val, tmport);
FUN_D6:
FUN_D6:
for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */
if ((inw(tmport) & 0x4000) != 0) { /* DB6 all release? */
goto FUN_D6;
......@@ -952,7 +889,7 @@ unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)
return j;
}
void tscam(unsigned char host)
static void tscam(struct Scsi_Host *host)
{
unsigned int tmport;
......@@ -960,14 +897,14 @@ void tscam(unsigned char host)
unsigned long n;
unsigned short int m, assignid_map, val;
unsigned char mbuf[33], quintet[2];
struct atp_unit *dev = &atp_unit[host];
struct atp_unit *dev = (struct atp_unit *)host->hostdata;
static unsigned char g2q_tab[8] = {
0x38, 0x31, 0x32, 0x2b, 0x34, 0x2d, 0x2e, 0x27
};
for (i = 0; i < 0x10; i++) {
mydlyu(0xffff);
udelay(0xffff);
}
tmport = dev->ioport + 1;
......@@ -1056,8 +993,8 @@ void tscam(unsigned char host)
inb(0x80); /* 2 deskew delay(45ns*2=90ns) */
val &= 0x007f; /* no bsy */
outw(val, tmport);
mydlyu(0xffff); /* recommanded SCAM selection response time */
mydlyu(0xffff);
udelay(0xffff); /* recommanded SCAM selection response time */
udelay(0xffff);
val &= 0x00fb; /* after 1ms no msg */
outw(val, tmport);
wait_nomsg:
......@@ -1065,7 +1002,7 @@ void tscam(unsigned char host)
goto wait_nomsg;
}
outb(1, 0x80);
mydlyu(100);
udelay(100);
for (n = 0; n < 0x30000; n++) {
if ((inb(tmport) & 0x80) != 0) { /* bsy ? */
goto wait_io;
......@@ -1088,7 +1025,7 @@ void tscam(unsigned char host)
outw(val, tmport);
outb(2, 0x80);
TCM_SYNC:
mydlyu(0x800);
udelay(0x800);
if ((inb(tmport) & 0x80) == 0x00) { /* bsy ? */
outw(0, tmport--);
outb(0, tmport);
......@@ -1193,19 +1130,19 @@ void tscam(unsigned char host)
}
void is870(unsigned long host, unsigned int wkport)
void is870(struct Scsi_Host *host, unsigned int wkport)
{
unsigned int tmport;
unsigned char i, j, k, rmb, n;
unsigned short int m;
static unsigned char mbuf[512];
static unsigned char satn[9] = {0, 0, 0, 0, 0, 0, 0, 6, 6};
static unsigned char inqd[9] = {0x12, 0, 0, 0, 0x24, 0, 0, 0x24, 6};
static unsigned char synn[6] = {0x80, 1, 3, 1, 0x19, 0x0e};
static unsigned char synu[6] = {0x80, 1, 3, 1, 0x0c, 0x0e};
static unsigned char synw[6] = {0x80, 1, 3, 1, 0x0c, 0x07};
static unsigned char wide[6] = {0x80, 1, 2, 3, 1, 0};
struct atp_unit *dev = &atp_unit[host];
static unsigned char satn[9] = { 0, 0, 0, 0, 0, 0, 0, 6, 6 };
static unsigned char inqd[9] = { 0x12, 0, 0, 0, 0x24, 0, 0, 0x24, 6 };
static unsigned char synn[6] = { 0x80, 1, 3, 1, 0x19, 0x0e };
static unsigned char synu[6] = { 0x80, 1, 3, 1, 0x0c, 0x0e };
static unsigned char synw[6] = { 0x80, 1, 3, 1, 0x0c, 0x07 };
static unsigned char wide[6] = { 0x80, 1, 2, 3, 1, 0 };
struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
sync_idu = 0;
tmport = wkport + 0x3a;
......@@ -1227,9 +1164,7 @@ void is870(unsigned long host, unsigned int wkport)
tmport = wkport + 0x1b;
if (dev->chip_veru == 4) {
outb(0x01, tmport);
}
else
{
} else {
outb(0x00, tmport);
}
tmport = wkport + 1;
......@@ -1499,9 +1434,7 @@ void is870(unsigned long host, unsigned int wkport)
m = m << i;
dev->wide_idu |= m;
not_wide:
if ((dev->id[i].devtypeu == 0x00) || (dev->id[i].devtypeu == 0x07) ||
((dev->id[i].devtypeu == 0x05) && ((n & 0x10) != 0)))
{
if ((dev->id[i].devtypeu == 0x00) || (dev->id[i].devtypeu == 0x07) || ((dev->id[i].devtypeu == 0x05) && ((n & 0x10) != 0))) {
goto set_sync;
}
continue;
......@@ -1682,31 +1615,31 @@ void is870(unsigned long host, unsigned int wkport)
goto set_syn_ok;
}
j = 0x60;
set_syn_ok:
set_syn_ok:
dev->id[i].devspu = (dev->id[i].devspu & 0x0f) | j;
}
tmport = wkport + 0x3a;
outb((unsigned char) (inb(tmport) & 0xef), tmport);
}
void is880(unsigned long host, unsigned int wkport)
static void is880(struct Scsi_Host *host, unsigned int wkport)
{
unsigned int tmport;
unsigned char i, j, k, rmb, n, lvdmode;
unsigned short int m;
static unsigned char mbuf[512];
static unsigned char satn[9] = {0, 0, 0, 0, 0, 0, 0, 6, 6};
static unsigned char inqd[9] = {0x12, 0, 0, 0, 0x24, 0, 0, 0x24, 6};
static unsigned char synn[6] = {0x80, 1, 3, 1, 0x19, 0x0e};
unsigned char synu[6] = {0x80, 1, 3, 1, 0x0a, 0x0e};
static unsigned char synw[6] = {0x80, 1, 3, 1, 0x19, 0x0e};
unsigned char synuw[6] = {0x80, 1, 3, 1, 0x0a, 0x0e};
static unsigned char wide[6] = {0x80, 1, 2, 3, 1, 0};
static unsigned char u3[9] = { 0x80,1,6,4,0x09,00,0x0e,0x01,0x02 };
struct atp_unit *dev = &atp_unit[host];
static unsigned char satn[9] = { 0, 0, 0, 0, 0, 0, 0, 6, 6 };
static unsigned char inqd[9] = { 0x12, 0, 0, 0, 0x24, 0, 0, 0x24, 6 };
static unsigned char synn[6] = { 0x80, 1, 3, 1, 0x19, 0x0e };
unsigned char synu[6] = { 0x80, 1, 3, 1, 0x0a, 0x0e };
static unsigned char synw[6] = { 0x80, 1, 3, 1, 0x19, 0x0e };
unsigned char synuw[6] = { 0x80, 1, 3, 1, 0x0a, 0x0e };
static unsigned char wide[6] = { 0x80, 1, 2, 3, 1, 0 };
static unsigned char u3[9] = { 0x80, 1, 6, 4, 0x09, 00, 0x0e, 0x01, 0x02 };
struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
sync_idu = 0;
lvdmode=inb(wkport + 0x3f) & 0x40;
lvdmode = inb(wkport + 0x3f) & 0x40;
for (i = 0; i < 16; i++) {
m = 1;
......@@ -1842,8 +1775,7 @@ void is880(unsigned long host, unsigned int wkport)
if ((i < 8) && ((dev->global_map & 0x20) == 0)) {
goto not_wide;
}
if (lvdmode == 0)
{
if (lvdmode == 0) {
goto chg_wide;
}
if (dev->sp[i] != 0x04) // force u2
......@@ -2132,29 +2064,22 @@ void is880(unsigned long host, unsigned int wkport)
m = m << i;
dev->wide_idu |= m;
not_wide:
if ((dev->id[i].devtypeu == 0x00) || (dev->id[i].devtypeu == 0x07) ||
((dev->id[i].devtypeu == 0x05) && ((n & 0x10) != 0)))
{
if ((dev->id[i].devtypeu == 0x00) || (dev->id[i].devtypeu == 0x07) || ((dev->id[i].devtypeu == 0x05) && ((n & 0x10) != 0))) {
m = 1;
m = m << i;
if ((dev->async & m) != 0)
{
if ((dev->async & m) != 0) {
goto set_sync;
}
}
continue;
set_sync:
if (dev->sp[i] == 0x02)
{
synu[4]=0x0c;
synuw[4]=0x0c;
}
else
{
if (dev->sp[i] >= 0x03)
{
synu[4]=0x0a;
synuw[4]=0x0a;
if (dev->sp[i] == 0x02) {
synu[4] = 0x0c;
synuw[4] = 0x0c;
} else {
if (dev->sp[i] >= 0x03) {
synu[4] = 0x0a;
synuw[4] = 0x0a;
}
}
tmport = wkport + 0x5b;
......@@ -2320,7 +2245,7 @@ void is880(unsigned long host, unsigned int wkport)
mbuf[4] = 0x0e;
}
dev->id[i].devspu = mbuf[4];
if (mbuf[3] < 0x0c){
if (mbuf[3] < 0x0c) {
j = 0xb0;
goto set_syn_ok;
}
......@@ -2341,42 +2266,21 @@ void is880(unsigned long host, unsigned int wkport)
goto set_syn_ok;
}
j = 0x60;
set_syn_ok:
set_syn_ok:
dev->id[i].devspu = (dev->id[i].devspu & 0x0f) | j;
}
}
/* return non-zero on detection */
int atp870u_detect(Scsi_Host_Template * tpnt)
{
unsigned char irq, h, k, m;
unsigned long flags;
unsigned int base_io, error, tmport;
unsigned short index = 0;
struct pci_dev *pdev[3];
unsigned char chip_ver[3], host_id;
unsigned short dev_id[3], n;
struct Scsi_Host *shpnt = NULL;
int tmpcnt = 0;
int count = 0;
static unsigned short devid[9] = {
0x8081, 0x8002, 0x8010, 0x8020, 0x8030, 0x8040, 0x8050, 0x8060, 0
};
printk(KERN_INFO "aec671x_detect: \n");
if (!pci_present()) {
printk(KERN_INFO" NO PCI SUPPORT.\n");
return count;
}
tpnt->proc_name = "atp870u";
static void atp870u_init_tables(struct Scsi_Host *host)
{
struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
int k;
for (h = 0; h < 2; h++) {
struct atp_unit *dev = &atp_unit[h];
for(k=0;k<16;k++)
{
dev->id[k].prd_tableu = kmalloc(1024, GFP_KERNEL);
dev->id[k].devspu=0x20;
for (k = 0; k < 16; k++) {
/* FIXME */
dev->id[k].prd_tableu = pci_alloc_consistent(dev->pdev, 1024, &dev->id[k].prd_phys);
dev->id[k].devspu = 0x20;
dev->id[k].devtypeu = 0;
dev->id[k].curr_req = NULL;
}
......@@ -2385,8 +2289,6 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
dev->host_idu = 0x07;
dev->quhdu = 0;
dev->quendu = 0;
pdev[h]=NULL;
pdev[2]=NULL;
dev->chip_veru = 0;
dev->last_cmd = 0xff;
dev->in_snd = 0;
......@@ -2398,44 +2300,68 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
dev->id[k].curr_req = 0;
dev->sp[k] = 0x04;
}
}
/* return non-zero on detection */
static int atp870u_detect(Scsi_Host_Template * tpnt)
{
unsigned char irq, h, k, m;
unsigned long flags;
unsigned int base_io, error, tmport;
struct pci_dev *pdev[MAX_ATP];
unsigned char chip_ver[MAX_ATP], host_id;
unsigned short dev_id[MAX_ATP], n;
struct Scsi_Host *shpnt = NULL;
int card = 0;
int count = 0;
static unsigned short devid[9] = {
0x8081, 0x8002, 0x8010, 0x8020, 0x8030, 0x8040, 0x8050, 0x8060, 0
};
printk(KERN_INFO "aec671x_detect: \n");
if (!pci_present()) {
printk(KERN_INFO " NO PCI SUPPORT.\n");
return count;
}
tpnt->proc_name = "atp870u";
h = 0;
while (devid[h] != 0) {
pdev[2] = pci_find_device(0x1191, devid[h], pdev[2]);
if (pdev[2] == NULL || pci_enable_device(pdev[2])) {
h++;
index = 0;
while (devid[h] != 0)
{
struct pci_dev *dev = NULL;
while((dev = pci_find_device(0x1191, devid[h], dev))!=NULL)
{
if(pci_enable_device(dev))
continue;
if(pci_set_dma_mask(dev, 0xFFFFFFFFUL))
{
printk(KERN_ERR "atp870u: 32bit DMA mask required but not available.\n");
continue;
}
chip_ver[2] = 0;
dev_id[2] = devid[h];
chip_ver[card] = 0;
dev_id[card] = devid[h];
if (devid[h] == 0x8002) {
error = pci_read_config_byte(pdev[2], 0x08, &chip_ver[2]);
if (chip_ver[2] < 2) {
goto nxt_devfn;
error = pci_read_config_byte(dev, 0x08, &chip_ver[card]);
if (chip_ver[card] < 2) {
continue;
}
}
if (devid[h] == 0x8010 || devid[h] == 0x8081 || devid[h] == 0x8050)
{
chip_ver[2] = 0x04;
}
pdev[tmpcnt] = pdev[2];
chip_ver[tmpcnt] = chip_ver[2];
dev_id[tmpcnt] = dev_id[2];
tmpcnt++;
nxt_devfn:
index++;
if (index > 3) {
index = 0;
h++;
}
if(tmpcnt>1)
if (devid[h] == 0x8010 || devid[h] == 0x8081 || devid[h] == 0x8050) {
chip_ver[card] = 0x04;
}
pdev[card] = dev;
card++;
if (card == MAX_ATP)
break;
}
for (h = 0; h < 2; h++) {
struct atp_unit *dev=&atp_unit[h];
if (pdev[h]==NULL) {
}
for (h = 0; h < MAX_ATP; h++) {
struct atp_unit tmp, *dev;
if (pdev[h] == NULL) {
return count;
}
......@@ -2443,49 +2369,49 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
base_io = pci_resource_start(pdev[h], 0);
irq = pdev[h]->irq;
if (dev_id[h] != 0x8081)
{
error = pci_read_config_byte(pdev[h],0x49,&host_id);
if (dev_id[h] != 0x8081) {
error = pci_read_config_byte(pdev[h], 0x49, &host_id);
base_io &= 0xfffffff8;
if (check_region(base_io,0x40) != 0)
{
if (check_region(base_io, 0x40) != 0) {
return 0;
}
printk(KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-3 Host Adapter: %d IO:%x, IRQ:%d.\n"
,h, base_io, irq);
dev->ioport = base_io;
dev->pciport = base_io + 0x20;
dev->deviceid = dev_id[h];
irqnumu[h] = irq;
printk(KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-3 Host Adapter: %d IO:%x, IRQ:%d.\n", h, base_io, irq);
tmp.ioport = base_io;
tmp.pciport = base_io + 0x20;
tmp.deviceid = dev_id[h];
host_id &= 0x07;
dev->host_idu = host_id;
dev->chip_veru = chip_ver[h];
tmp.host_idu = host_id;
tmp.chip_veru = chip_ver[h];
tmport = base_io + 0x22;
dev->scam_on = inb(tmport);
tmp.scam_on = inb(tmport);
tmport += 0x0b;
dev->global_map = inb(tmport++);
dev->ultra_map = inw(tmport);
if (dev->ultra_map == 0) {
dev->scam_on = 0x00;
dev->global_map = 0x20;
dev->ultra_map = 0xffff;
}
shpnt = scsi_register(tpnt, 4);
if(shpnt==NULL)
tmp.global_map = inb(tmport++);
tmp.ultra_map = inw(tmport);
if (tmp.ultra_map == 0) {
tmp.scam_on = 0x00;
tmp.global_map = 0x20;
tmp.ultra_map = 0xffff;
}
shpnt = scsi_register(tpnt, sizeof(struct atp_unit));
if (shpnt == NULL)
return count;
save_flags(flags);
cli();
if (request_irq(irq, atp870u_intr_handle, SA_SHIRQ, "atp870u", dev)) {
tmp.host = shpnt;
tmp.pdev = pdev[h];
/* Save the atp_unit data */
memcpy(&shpnt->hostdata, &tmp, sizeof(tmp));
atp870u_init_tables(shpnt);
spin_lock_irqsave(shpnt->host_lock, flags);
if (request_irq(irq, atp870u_intr_handle, SA_SHIRQ, "atp870u", shpnt)) {
printk(KERN_ERR "Unable to allocate IRQ for Acard controller.\n");
goto unregister;
}
if (chip_ver[h] > 0x07) /* check if atp876 chip */
{ /* then enable terminator */
if (chip_ver[h] > 0x07) { /* check if atp876 chip *//* then enable terminator */
tmport = base_io + 0x3e;
outb(0x00, tmport);
}
......@@ -2494,9 +2420,9 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
k = (inb(tmport) & 0xf3) | 0x10;
outb(k, tmport);
outb((k & 0xdf), tmport);
mydlyu(0x8000);
udelay(0x8000);
outb(k, tmport);
mydlyu(0x8000);
udelay(0x8000);
tmport = base_io;
outb((host_id | 0x08), tmport);
tmport += 0x18;
......@@ -2511,107 +2437,99 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
tmport = base_io + 0x11;
outb(0x20, tmport);
tscam(h);
is870(h, base_io);
tscam(shpnt);
is870(shpnt, base_io);
tmport = base_io + 0x3a;
outb((inb(tmport) & 0xef), tmport);
tmport++;
outb((inb(tmport) | 0x20),tmport);
}
else
{
outb((inb(tmport) | 0x20), tmport);
} else {
base_io &= 0xfffffff8;
if (check_region(base_io,0x60) != 0)
{
if (check_region(base_io, 0x60) != 0) {
return 0;
}
host_id = inb(base_io + 0x39);
host_id >>= 0x04;
printk(KERN_INFO " ACARD AEC-67160 PCI Ultra160 LVD/SE SCSI Adapter: %d IO:%x, IRQ:%d.\n"
,h, base_io, irq);
dev->ioport = base_io + 0x40;
dev->pciport = base_io + 0x28;
dev->deviceid = dev_id[h];
irqnumu[h] = irq;
dev->host_idu = host_id;
dev->chip_veru = chip_ver[h];
printk(KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: %d IO:%x, IRQ:%d.\n", h, base_io, irq);
tmp.ioport = base_io + 0x40;
tmp.pciport = base_io + 0x28;
tmp.deviceid = dev_id[h];
tmp.host_idu = host_id;
tmp.chip_veru = chip_ver[h];
tmport = base_io + 0x22;
dev->scam_on = inb(tmport);
tmp.scam_on = inb(tmport);
tmport += 0x13;
dev->global_map = inb(tmport);
tmp.global_map = inb(tmport);
tmport += 0x07;
dev->ultra_map = inw(tmport);
tmp.ultra_map = inw(tmport);
n=0x3f09;
n = 0x3f09;
next_fblk:
if (n >= 0x4000)
{
if (n >= 0x4000) {
goto flash_ok;
}
m=0;
outw(n,base_io + 0x34);
m = 0;
outw(n, base_io + 0x34);
n += 0x0002;
if (inb(base_io + 0x30) == 0xff)
{
if (inb(base_io + 0x30) == 0xff) {
goto flash_ok;
}
dev->sp[m++]=inb(base_io + 0x30);
dev->sp[m++]=inb(base_io + 0x31);
dev->sp[m++]=inb(base_io + 0x32);
dev->sp[m++]=inb(base_io + 0x33);
outw(n,base_io + 0x34);
tmp.sp[m++] = inb(base_io + 0x30);
tmp.sp[m++] = inb(base_io + 0x31);
tmp.sp[m++] = inb(base_io + 0x32);
tmp.sp[m++] = inb(base_io + 0x33);
outw(n, base_io + 0x34);
n += 0x0002;
dev->sp[m++]=inb(base_io + 0x30);
dev->sp[m++]=inb(base_io + 0x31);
dev->sp[m++]=inb(base_io + 0x32);
dev->sp[m++]=inb(base_io + 0x33);
outw(n,base_io + 0x34);
tmp.sp[m++] = inb(base_io + 0x30);
tmp.sp[m++] = inb(base_io + 0x31);
tmp.sp[m++] = inb(base_io + 0x32);
tmp.sp[m++] = inb(base_io + 0x33);
outw(n, base_io + 0x34);
n += 0x0002;
dev->sp[m++]=inb(base_io + 0x30);
dev->sp[m++]=inb(base_io + 0x31);
dev->sp[m++]=inb(base_io + 0x32);
dev->sp[m++]=inb(base_io + 0x33);
outw(n,base_io + 0x34);
tmp.sp[m++] = inb(base_io + 0x30);
tmp.sp[m++] = inb(base_io + 0x31);
tmp.sp[m++] = inb(base_io + 0x32);
tmp.sp[m++] = inb(base_io + 0x33);
outw(n, base_io + 0x34);
n += 0x0002;
dev->sp[m++]=inb(base_io + 0x30);
dev->sp[m++]=inb(base_io + 0x31);
dev->sp[m++]=inb(base_io + 0x32);
dev->sp[m++]=inb(base_io + 0x33);
tmp.sp[m++] = inb(base_io + 0x30);
tmp.sp[m++] = inb(base_io + 0x31);
tmp.sp[m++] = inb(base_io + 0x32);
tmp.sp[m++] = inb(base_io + 0x33);
n += 0x0018;
goto next_fblk;
flash_ok:
outw(0,base_io + 0x34);
dev->ultra_map=0;
dev->async = 0;
for (k=0; k < 16; k++)
{
n=1;
outw(0, base_io + 0x34);
tmp.ultra_map = 0;
tmp.async = 0;
for (k = 0; k < 16; k++) {
n = 1;
n = n << k;
if (dev->sp[k] > 1)
{
dev->ultra_map |= n;
}
else
{
if (dev->sp[k] == 0)
{
dev->async |= n;
if (tmp.sp[k] > 1) {
tmp.ultra_map |= n;
} else {
if (tmp.sp[k] == 0) {
tmp.async |= n;
}
}
}
dev->async = ~(dev->async);
outb(dev->global_map,base_io + 0x35);
tmp.async = ~(tmp.async);
outb(tmp.global_map, base_io + 0x35);
shpnt = scsi_register(tpnt, 4);
if(shpnt==NULL)
shpnt = scsi_register(tpnt, sizeof(struct atp_unit));
if (shpnt == NULL)
return count;
save_flags(flags);
cli();
if (request_irq(irq, atp870u_intr_handle, SA_SHIRQ, "atp870u", dev)) {
tmp.pdev = pdev[h];
memcpy(&shpnt->hostdata, &tmp, sizeof(tmp));
atp870u_init_tables(shpnt);
spin_lock_irqsave(shpnt->host_lock, flags);
if (request_irq(irq, atp870u_intr_handle, SA_SHIRQ, "atp870u", shpnt)) {
printk(KERN_ERR "Unable to allocate IRQ for Acard controller.\n");
goto unregister;
}
......@@ -2621,9 +2539,9 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
outb(k, tmport);
tmport += 0x03;
outb(0x20, tmport);
mydlyu(0x8000);
udelay(0x8000);
outb(0, tmport);
mydlyu(0x8000);
udelay(0x8000);
tmport = base_io + 0x5b;
inb(tmport);
tmport -= 0x04;
......@@ -2642,12 +2560,14 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
tmport = base_io + 0x51;
outb(0x20, tmport);
tscam(h);
is880(h, base_io);
tscam(shpnt);
is880(shpnt, base_io);
tmport = base_io + 0x38;
outb(0xb0, tmport);
}
dev = (struct atp_unit *)&shpnt->hostdata;
atp_host[h] = shpnt;
if (dev->chip_veru == 4) {
shpnt->max_id = 16;
......@@ -2655,31 +2575,23 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
shpnt->this_id = host_id;
shpnt->unique_id = base_io;
shpnt->io_port = base_io;
if (dev_id[h] == 0x8081)
{
if (dev_id[h] == 0x8081) {
shpnt->n_io_port = 0x60; /* Number of bytes of I/O space used */
}
else
{
} else {
shpnt->n_io_port = 0x40; /* Number of bytes of I/O space used */
}
shpnt->irq = irq;
restore_flags(flags);
if (dev_id[h] == 0x8081)
{
if (dev_id[h] == 0x8081) {
request_region(base_io, 0x60, "atp870u"); /* Register the IO ports that we use */
}
else
{
} else {
request_region(base_io, 0x40, "atp870u"); /* Register the IO ports that we use */
}
count++;
index++;
continue;
unregister:
scsi_unregister(shpnt);
restore_flags(flags);
index++;
spin_unlock_irqrestore(shpnt->host_lock, flags);
continue;
}
......@@ -2692,18 +2604,11 @@ int atp870u_detect(Scsi_Host_Template * tpnt)
int atp870u_abort(Scsi_Cmnd * SCpnt)
{
unsigned char h, j, k;
unsigned char j, k;
Scsi_Cmnd *workrequ;
unsigned int tmport;
struct atp_unit *dev;
for (h = 0; h <= admaxu; h++) {
if (SCpnt->host == atp_host[h]) {
goto find_adp;
}
}
panic("Abort host not found !");
find_adp:
dev=&atp_unit[h];
struct atp_unit *dev = (struct atp_unit *)&SCpnt->host->hostdata;
printk(KERN_DEBUG "working=%x last_cmd=%x ", dev->working, dev->last_cmd);
printk(" quhdu=%x quendu=%x ", dev->quhdu, dev->quendu);
tmport = dev->ioport;
......@@ -2714,59 +2619,33 @@ int atp870u_abort(Scsi_Cmnd * SCpnt)
printk(" r1c=%2x", inb(tmport));
tmport += 0x03;
printk(" r1f=%2x in_snd=%2x ", inb(tmport), dev->in_snd);
tmport= dev->pciport;
tmport = dev->pciport;
printk(" r20=%2x", inb(tmport));
tmport += 0x02;
printk(" r22=%2x", inb(tmport));
tmport = dev->ioport + 0x3a;
printk(" r3a=%2x \n",inb(tmport));
printk(" r3a=%2x \n", inb(tmport));
tmport = dev->ioport + 0x3b;
printk(" r3b=%2x \n",inb(tmport));
for(j=0;j<16;j++)
{
if (dev->id[j].curr_req != NULL)
{
printk(" r3b=%2x \n", inb(tmport));
for (j = 0; j < 16; j++) {
if (dev->id[j].curr_req != NULL) {
workrequ = dev->id[j].curr_req;
printk("\n que cdb= ");
for (k=0; k < workrequ->cmd_len; k++)
{
printk(" %2x ",workrequ->cmnd[k]);
for (k = 0; k < workrequ->cmd_len; k++) {
printk(" %2x ", workrequ->cmnd[k]);
}
printk(" last_lenu= %lx ",dev->id[j].last_lenu);
printk(" last_lenu= %lx ", dev->id[j].last_lenu);
}
}
return (SCSI_ABORT_SNOOZE);
}
int atp870u_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags)
{
unsigned char h;
struct atp_unit *dev;
/*
* See if a bus reset was suggested.
*/
for (h = 0; h <= admaxu; h++) {
if (SCpnt->host == atp_host[h]) {
goto find_host;
}
}
panic("Reset bus host not found !");
find_host:
dev=&atp_unit[h];
/* SCpnt->result = 0x00080000;
SCpnt->scsi_done(SCpnt);
dev->working=0;
dev->quhdu=0;
dev->quendu=0;
return (SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET); */
return (SCSI_RESET_SNOOZE);
/* Sort of - the thing handles itself */
return SUCCESS;
}
const char *atp870u_info(struct Scsi_Host *notused)
{
static char buffer[128];
strcpy(buffer, "ACARD AEC-6710/6712/67160 PCI Ultra/W/LVD SCSI-3 Adapter Driver V2.5+ac ");
strcpy(buffer, "ACARD AEC-6710/6712/67160 PCI Ultra/W/LVD SCSI-3 Adapter Driver V2.6+ac ");
return buffer;
}
......@@ -2777,8 +2656,7 @@ int atp870u_set_info(char *buffer, int length, struct Scsi_Host *HBAptr)
}
#define BLS buffer + len + size
int atp870u_proc_info(char *buffer, char **start, off_t offset, int length,
int hostno, int inout)
int atp870u_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout)
{
struct Scsi_Host *HBAptr;
static u8 buff[512];
......@@ -2789,7 +2667,7 @@ int atp870u_proc_info(char *buffer, char **start, off_t offset, int length,
off_t pos = 0;
HBAptr = NULL;
for (i = 0; i < 2; i++) {
for (i = 0; i < MAX_ATP; i++) {
if ((HBAptr = atp_host[i]) != NULL) {
if (HBAptr->host_no == hostno) {
break;
......@@ -2811,7 +2689,7 @@ int atp870u_proc_info(char *buffer, char **start, off_t offset, int length,
if (offset == 0) {
memset(buff, 0, sizeof(buff));
}
size += sprintf(BLS, "ACARD AEC-671X Driver Version: 2.5+ac\n");
size += sprintf(BLS, "ACARD AEC-671X Driver Version: 2.6+ac\n");
len += size;
pos = begin + len;
size = 0;
......@@ -2835,7 +2713,7 @@ int atp870u_proc_info(char *buffer, char **start, off_t offset, int length,
#include "sd.h"
int atp870u_biosparam(Scsi_Disk * disk, struct block_device *dev, int *ip)
static int atp870u_biosparam(Scsi_Disk * disk, struct block_device *dev, int *ip)
{
int heads, sectors, cylinders;
......@@ -2856,24 +2734,18 @@ int atp870u_biosparam(Scsi_Disk * disk, struct block_device *dev, int *ip)
}
int atp870u_release (struct Scsi_Host *pshost)
static int atp870u_release(struct Scsi_Host *pshost)
{
int h;
for (h = 0; h <= admaxu; h++)
{
if (pshost == atp_host[h]) {
struct atp_unit *dev = (struct atp_unit *)&pshost->hostdata;
int k;
free_irq (pshost->irq, &atp_unit[h]);
release_region (pshost->io_port, pshost->n_io_port);
free_irq(pshost->irq, pshost);
release_region(pshost->io_port, pshost->n_io_port);
scsi_unregister(pshost);
for(k=0;k<16;k++)
kfree(atp_unit[h].id[k].prd_tableu);
for (k = 0; k < 16; k++)
pci_free_consistent(dev->pdev, 1024, dev->id[k].prd_tableu, dev->id[k].prd_phys);
return 0;
}
}
panic("atp870u: bad scsi host passed.\n");
}
MODULE_LICENSE("GPL");
static Scsi_Host_Template driver_template = ATP870U;
......
......@@ -17,14 +17,12 @@
#define MAX_CDB 12
#define MAX_SENSE 14
int atp870u_detect(Scsi_Host_Template *);
int atp870u_command(Scsi_Cmnd *);
int atp870u_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
int atp870u_abort(Scsi_Cmnd *);
int atp870u_reset(Scsi_Cmnd *, unsigned int);
int atp870u_biosparam(Disk *, struct block_device *, int *);
int atp870u_release(struct Scsi_Host *);
void send_s870(unsigned char);
static int atp870u_detect(Scsi_Host_Template *);
static int atp870u_command(Scsi_Cmnd *);
static int atp870u_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
static int atp870u_abort(Scsi_Cmnd *);
static int atp870u_biosparam(Disk *, struct block_device *, int *);
static int atp870u_release(struct Scsi_Host *);
#define qcnt 32
#define ATP870U_SCATTER 128
......@@ -49,12 +47,7 @@ extern int atp870u_proc_info(char *, char **, off_t, int, int, int);
command: atp870u_command, \
queuecommand: atp870u_queuecommand, \
eh_strategy_handler: NULL, \
eh_abort_handler: NULL, \
eh_device_reset_handler: NULL, \
eh_bus_reset_handler: NULL, \
eh_host_reset_handler: NULL, \
abort: atp870u_abort, \
reset: atp870u_reset, \
eh_abort_handler: atp870u_abort, \
slave_attach: NULL, \
bios_param: atp870u_biosparam, \
can_queue: qcnt, /* max simultaneous cmds */\
......
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