Commit 6a3cebb6 authored by Ondrej Zary's avatar Ondrej Zary Committed by Martin K. Petersen

atp870u: Introduce HW access wrappers

Introduce *_read? and *_write? wrappers to improve code readability.
Also make sure that baseport is always initialized, not only for ATP880.
Signed-off-by: default avatarOndrej Zary <linux@rainbow-software.org>
Reviewed-by: default avatarHannes Reinicke <hare@suse.de>
Acked-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c7fcc089
...@@ -44,6 +44,51 @@ static void send_s870(struct atp_unit *dev,unsigned char c); ...@@ -44,6 +44,51 @@ static void send_s870(struct atp_unit *dev,unsigned char c);
static void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c); static void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c);
static void tscam_885(void); static void tscam_885(void);
static inline void atp_writeb_base(struct atp_unit *atp, u8 reg, u8 val)
{
outb(val, atp->baseport + reg);
}
static inline void atp_writeb_io(struct atp_unit *atp, u8 channel, u8 reg, u8 val)
{
outb(val, atp->ioport[channel] + reg);
}
static inline void atp_writew_io(struct atp_unit *atp, u8 channel, u8 reg, u16 val)
{
outw(val, atp->ioport[channel] + reg);
}
static inline void atp_writeb_pci(struct atp_unit *atp, u8 channel, u8 reg, u8 val)
{
outb(val, atp->pciport[channel] + reg);
}
static inline void atp_writel_pci(struct atp_unit *atp, u8 channel, u8 reg, u32 val)
{
outl(val, atp->pciport[channel] + reg);
}
static inline u8 atp_readb_base(struct atp_unit *atp, u8 reg)
{
return inb(atp->baseport + reg);
}
static inline u8 atp_readb_io(struct atp_unit *atp, u8 channel, u8 reg)
{
return inb(atp->ioport[channel] + reg);
}
static inline u16 atp_readw_io(struct atp_unit *atp, u8 channel, u8 reg)
{
return inw(atp->ioport[channel] + reg);
}
static inline u8 atp_readb_pci(struct atp_unit *atp, u8 channel, u8 reg)
{
return inb(atp->pciport[channel] + reg);
}
static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
{ {
unsigned long flags; unsigned long flags;
...@@ -59,7 +104,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -59,7 +104,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
struct atp_unit *dev = (struct atp_unit *)&host->hostdata; struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
for (c = 0; c < 2; c++) { for (c = 0; c < 2; c++) {
j = inb(dev->ioport[c] + 0x1f); j = atp_readb_io(dev, c, 0x1f);
if ((j & 0x80) != 0) if ((j & 0x80) != 0)
break; break;
dev->in_int[c] = 0; dev->in_int[c] = 0;
...@@ -70,29 +115,29 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -70,29 +115,29 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
printk("atp870u_intr_handle enter\n"); printk("atp870u_intr_handle enter\n");
#endif #endif
dev->in_int[c] = 1; dev->in_int[c] = 1;
cmdp = inb(dev->ioport[c] + 0x10); cmdp = atp_readb_io(dev, c, 0x10);
if (dev->working[c] != 0) { if (dev->working[c] != 0) {
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
if ((inb(dev->ioport[c] + 0x16) & 0x80) == 0) if ((atp_readb_io(dev, c, 0x16) & 0x80) == 0)
outb((inb(dev->ioport[c] + 0x16) | 0x80), dev->ioport[c] + 0x16); atp_writeb_io(dev, c, 0x16, (atp_readb_io(dev, c, 0x16) | 0x80));
} }
if ((inb(dev->pciport[c]) & 0x08) != 0) if ((atp_readb_pci(dev, c, 0x00) & 0x08) != 0)
{ {
for (k=0; k < 1000; k++) { for (k=0; k < 1000; k++) {
if ((inb(dev->pciport[c] + 2) & 0x08) == 0) if ((atp_readb_pci(dev, c, 2) & 0x08) == 0)
break; break;
if ((inb(dev->pciport[c] + 2) & 0x01) == 0) if ((atp_readb_pci(dev, c, 2) & 0x01) == 0)
break; break;
} }
} }
outb(0x00, dev->pciport[c]); atp_writeb_pci(dev, c, 0, 0x00);
i = inb(dev->ioport[c] + 0x17); i = atp_readb_io(dev, c, 0x17);
if (dev->dev_id == ATP885_DEVID) if (dev->dev_id == ATP885_DEVID)
outb(0x06, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x06);
target_id = inb(dev->ioport[c] + 0x15); target_id = atp_readb_io(dev, c, 0x15);
/* /*
* Remap wide devices onto id numbers * Remap wide devices onto id numbers
...@@ -121,9 +166,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -121,9 +166,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
} }
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
adrcnt = 0; adrcnt = 0;
((unsigned char *) &adrcnt)[2] = inb(dev->ioport[c] + 0x12); ((unsigned char *) &adrcnt)[2] = atp_readb_io(dev, c, 0x12);
((unsigned char *) &adrcnt)[1] = inb(dev->ioport[c] + 0x13); ((unsigned char *) &adrcnt)[1] = atp_readb_io(dev, c, 0x13);
((unsigned char *) &adrcnt)[0] = inb(dev->ioport[c] + 0x14); ((unsigned char *) &adrcnt)[0] = atp_readb_io(dev, c, 0x14);
if (dev->id[c][target_id].last_len != adrcnt) if (dev->id[c][target_id].last_len != adrcnt)
{ {
k = dev->id[c][target_id].last_len; k = dev->id[c][target_id].last_len;
...@@ -140,10 +185,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -140,10 +185,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
* Flip wide * Flip wide
*/ */
if (dev->wide_id[c] != 0) { if (dev->wide_id[c] != 0) {
outb(0x01, dev->ioport[c] + 0x1b); atp_writeb_io(dev, c, 0x1b, 0x01);
while ((inb(dev->ioport[c] + 0x1b) & 0x01) != 0x01) { while ((atp_readb_io(dev, c, 0x1b) & 0x01) != 0x01)
outb(0x01, dev->ioport[c] + 0x1b); atp_writeb_io(dev, c, 0x1b, 0x01);
}
} }
/* /*
* Issue more commands * Issue more commands
...@@ -178,15 +222,15 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -178,15 +222,15 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
dev->last_cmd[c] = 0xff; dev->last_cmd[c] = 0xff;
} }
adrcnt = 0; adrcnt = 0;
((unsigned char *) &adrcnt)[2] = inb(dev->ioport[c] + 0x12); ((unsigned char *) &adrcnt)[2] = atp_readb_io(dev, c, 0x12);
((unsigned char *) &adrcnt)[1] = inb(dev->ioport[c] + 0x13); ((unsigned char *) &adrcnt)[1] = atp_readb_io(dev, c, 0x13);
((unsigned char *) &adrcnt)[0] = inb(dev->ioport[c] + 0x14); ((unsigned char *) &adrcnt)[0] = atp_readb_io(dev, c, 0x14);
k = dev->id[c][target_id].last_len; k = dev->id[c][target_id].last_len;
k -= adrcnt; k -= adrcnt;
dev->id[c][target_id].tran_len = k; dev->id[c][target_id].tran_len = k;
dev->id[c][target_id].last_len = adrcnt; dev->id[c][target_id].last_len = adrcnt;
outb(0x41, dev->ioport[c] + 0x10); atp_writeb_io(dev, c, 0x10, 0x41);
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
dev->in_int[c] = 0; dev->in_int[c] = 0;
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -205,9 +249,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -205,9 +249,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
printk(KERN_DEBUG "Device reselect\n"); printk(KERN_DEBUG "Device reselect\n");
#endif #endif
lun = 0; lun = 0;
if (cmdp == 0x44 || i==0x80) { if (cmdp == 0x44 || i == 0x80)
lun = inb(dev->ioport[c] + 0x1d) & 0x07; lun = atp_readb_io(dev, c, 0x1d) & 0x07;
} else { else {
if ((dev->last_cmd[c] & 0xf0) != 0x40) { if ((dev->last_cmd[c] & 0xf0) != 0x40) {
dev->last_cmd[c] = 0xff; dev->last_cmd[c] = 0xff;
} }
...@@ -216,26 +260,26 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -216,26 +260,26 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
printk("cmdp = 0x41\n"); printk("cmdp = 0x41\n");
#endif #endif
adrcnt = 0; adrcnt = 0;
((unsigned char *) &adrcnt)[2] = inb(dev->ioport[c] + 0x12); ((unsigned char *) &adrcnt)[2] = atp_readb_io(dev, c, 0x12);
((unsigned char *) &adrcnt)[1] = inb(dev->ioport[c] + 0x13); ((unsigned char *) &adrcnt)[1] = atp_readb_io(dev, c, 0x13);
((unsigned char *) &adrcnt)[0] = inb(dev->ioport[c] + 0x14); ((unsigned char *) &adrcnt)[0] = atp_readb_io(dev, c, 0x14);
k = dev->id[c][target_id].last_len; k = dev->id[c][target_id].last_len;
k -= adrcnt; k -= adrcnt;
dev->id[c][target_id].tran_len = k; dev->id[c][target_id].tran_len = k;
dev->id[c][target_id].last_len = adrcnt; dev->id[c][target_id].last_len = adrcnt;
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
dev->in_int[c] = 0; dev->in_int[c] = 0;
return IRQ_HANDLED; return IRQ_HANDLED;
} else { } else {
#ifdef ED_DBGP #ifdef ED_DBGP
printk("cmdp != 0x41\n"); printk("cmdp != 0x41\n");
#endif #endif
outb(0x46, dev->ioport[c] + 0x10); atp_writeb_io(dev, c, 0x10, 0x46);
dev->id[c][target_id].dirct = 0x00; dev->id[c][target_id].dirct = 0x00;
outb(0x00, dev->ioport[c] + 0x12); atp_writeb_io(dev, c, 0x12, 0x00);
outb(0x00, dev->ioport[c] + 0x13); atp_writeb_io(dev, c, 0x13, 0x00);
outb(0x00, dev->ioport[c] + 0x14); atp_writeb_io(dev, c, 0x14, 0x00);
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
dev->in_int[c] = 0; dev->in_int[c] = 0;
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -244,12 +288,12 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -244,12 +288,12 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
dev->last_cmd[c] |= 0x40; dev->last_cmd[c] |= 0x40;
} }
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
j = inb(dev->baseport + 0x29) & 0xfe; j = atp_readb_base(dev, 0x29) & 0xfe;
outb(j, dev->baseport + 0x29); atp_writeb_base(dev, 0x29, j);
} else } else
outb(0x45, dev->ioport[c] + 0x10); atp_writeb_io(dev, c, 0x10, 0x45);
target_id = inb(dev->ioport[c] + 0x16); target_id = atp_readb_io(dev, c, 0x16);
/* /*
* Remap wide identifiers * Remap wide identifiers
*/ */
...@@ -259,7 +303,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -259,7 +303,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
target_id &= 0x07; target_id &= 0x07;
} }
if (dev->dev_id == ATP885_DEVID) if (dev->dev_id == ATP885_DEVID)
outb(0x45, dev->ioport[c] + 0x10); atp_writeb_io(dev, c, 0x10, 0x45);
workreq = dev->id[c][target_id].curr_req; workreq = dev->id[c][target_id].curr_req;
#ifdef ED_DBGP #ifdef ED_DBGP
scmd_printk(KERN_DEBUG, workreq, "CDB"); scmd_printk(KERN_DEBUG, workreq, "CDB");
...@@ -268,16 +312,16 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -268,16 +312,16 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
printk("\n"); printk("\n");
#endif #endif
outb(lun, dev->ioport[c] + 0x0f); atp_writeb_io(dev, c, 0x0f, lun);
outb(dev->id[c][target_id].devsp, dev->ioport[c] + 0x11); atp_writeb_io(dev, c, 0x11, dev->id[c][target_id].devsp);
adrcnt = dev->id[c][target_id].tran_len; adrcnt = dev->id[c][target_id].tran_len;
k = dev->id[c][target_id].last_len; k = dev->id[c][target_id].last_len;
outb(((unsigned char *) &k)[2], dev->ioport[c] + 0x12); atp_writeb_io(dev, c, 0x12, ((unsigned char *) &k)[2]);
outb(((unsigned char *) &k)[1], dev->ioport[c] + 0x13); atp_writeb_io(dev, c, 0x13, ((unsigned char *) &k)[1]);
outb(((unsigned char *) &k)[0], dev->ioport[c] + 0x14); atp_writeb_io(dev, c, 0x14, ((unsigned char *) &k)[0]);
#ifdef ED_DBGP #ifdef ED_DBGP
printk("k %x, k[0] 0x%x k[1] 0x%x k[2] 0x%x\n", k, inb(dev->ioport[c] + 0x14), inb(dev->ioport[c] + 0x13), inb(dev->ioport[c] + 0x12)); printk("k %x, k[0] 0x%x k[1] 0x%x k[2] 0x%x\n", k, atp_readb_io(dev, c, 0x14), atp_readb_io(dev, c, 0x13), atp_readb_io(dev, c, 0x12));
#endif #endif
/* Remap wide */ /* Remap wide */
j = target_id; j = target_id;
...@@ -286,30 +330,28 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -286,30 +330,28 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
} }
/* Add direction */ /* Add direction */
j |= dev->id[c][target_id].dirct; j |= dev->id[c][target_id].dirct;
outb(j, dev->ioport[c] + 0x15); atp_writeb_io(dev, c, 0x15, j);
outb(0x80, dev->ioport[c] + 0x16); atp_writeb_io(dev, c, 0x16, 0x80);
/* enable 32 bit fifo transfer */ /* enable 32 bit fifo transfer */
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
i=inb(dev->pciport[c] + 1) & 0xf3; i = atp_readb_pci(dev, c, 1) & 0xf3;
//j=workreq->cmnd[0]; //j=workreq->cmnd[0];
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) { if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) {
i |= 0x0c; i |= 0x0c;
} }
outb(i, dev->pciport[c] + 1); atp_writeb_pci(dev, c, 1, i);
} else if ((dev->dev_id == ATP880_DEVID1) || } else if ((dev->dev_id == ATP880_DEVID1) ||
(dev->dev_id == ATP880_DEVID2) ) { (dev->dev_id == ATP880_DEVID2) ) {
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) { if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
outb((unsigned char) ((inb(dev->ioport[c] - 0x05) & 0x3f) | 0xc0), dev->ioport[c] - 0x05);///minus 0x05??? atp_writeb_base(dev, 0x3b, (atp_readb_base(dev, 0x3b) & 0x3f) | 0xc0);
} else { else
outb((unsigned char) (inb(dev->ioport[c] - 0x05) & 0x3f), dev->ioport[c] - 0x05);///minus 0x05??? atp_writeb_base(dev, 0x3b, atp_readb_base(dev, 0x3b) & 0x3f);
}
} else { } else {
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) { if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
outb((unsigned char) ((inb(dev->ioport[c] + 0x3a) & 0xf3) | 0x08), dev->ioport[c] + 0x3a); atp_writeb_io(dev, c, 0x3a, (atp_readb_io(dev, c, 0x3a) & 0xf3) | 0x08);
} else { else
outb((unsigned char) (inb(dev->ioport[c] + 0x3a) & 0xf3), dev->ioport[c] + 0x3a); atp_writeb_io(dev, c, 0x3a, atp_readb_io(dev, c, 0x3a) & 0xf3);
}
} }
j = 0; j = 0;
id = 1; id = 1;
...@@ -320,12 +362,11 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -320,12 +362,11 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
if ((id & dev->wide_id[c]) != 0) { if ((id & dev->wide_id[c]) != 0) {
j |= 0x01; j |= 0x01;
} }
outb(j, dev->ioport[c] + 0x1b); atp_writeb_io(dev, c, 0x1b, j);
while ((inb(dev->ioport[c] + 0x1b) & 0x01) != j) { while ((atp_readb_io(dev, c, 0x1b) & 0x01) != j)
outb(j,dev->ioport[c] + 0x1b); atp_writeb_io(dev, c, 0x1b, j);
}
if (dev->id[c][target_id].last_len == 0) { if (dev->id[c][target_id].last_len == 0) {
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
dev->in_int[c] = 0; dev->in_int[c] = 0;
#ifdef ED_DBGP #ifdef ED_DBGP
printk("dev->id[c][target_id].last_len = 0\n"); printk("dev->id[c][target_id].last_len = 0\n");
...@@ -358,28 +399,28 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -358,28 +399,28 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
} }
} }
} }
outl(dev->id[c][target_id].prdaddr, dev->pciport[c] + 0x04); atp_writel_pci(dev, c, 0x04, dev->id[c][target_id].prdaddr);
#ifdef ED_DBGP #ifdef ED_DBGP
printk("dev->id[%d][%d].prdaddr 0x%8x\n", c, target_id, dev->id[c][target_id].prdaddr); printk("dev->id[%d][%d].prdaddr 0x%8x\n", c, target_id, dev->id[c][target_id].prdaddr);
#endif #endif
if (dev->dev_id != ATP885_DEVID) { if (dev->dev_id != ATP885_DEVID) {
outb(0x06, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x06);
outb(0x00, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x00);
} }
/* /*
* Check transfer direction * Check transfer direction
*/ */
if (dev->id[c][target_id].dirct != 0) { if (dev->id[c][target_id].dirct != 0) {
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
outb(0x01, dev->pciport[c]); atp_writeb_pci(dev, c, 0, 0x01);
dev->in_int[c] = 0; dev->in_int[c] = 0;
#ifdef ED_DBGP #ifdef ED_DBGP
printk("status 0x80 return dirct != 0\n"); printk("status 0x80 return dirct != 0\n");
#endif #endif
return IRQ_HANDLED; return IRQ_HANDLED;
} }
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
outb(0x09, dev->pciport[c]); atp_writeb_pci(dev, c, 0, 0x09);
dev->in_int[c] = 0; dev->in_int[c] = 0;
#ifdef ED_DBGP #ifdef ED_DBGP
printk("status 0x80 return dirct = 0\n"); printk("status 0x80 return dirct = 0\n");
...@@ -398,7 +439,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -398,7 +439,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
dev->last_cmd[c] = 0xff; dev->last_cmd[c] = 0xff;
} }
if (i == 0x16) { if (i == 0x16) {
workreq->result = inb(dev->ioport[c] + 0x0f); workreq->result = atp_readb_io(dev, c, 0x0f);
if (((dev->r1f[c][target_id] & 0x10) != 0)&&(dev->dev_id==ATP885_DEVID)) { if (((dev->r1f[c][target_id] & 0x10) != 0)&&(dev->dev_id==ATP885_DEVID)) {
printk(KERN_WARNING "AEC67162 CRC ERROR !\n"); printk(KERN_WARNING "AEC67162 CRC ERROR !\n");
workreq->result = 0x02; workreq->result = 0x02;
...@@ -407,8 +448,8 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -407,8 +448,8 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
workreq->result = 0x02; workreq->result = 0x02;
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
j = inb(dev->baseport + 0x29) | 0x01; j = atp_readb_base(dev, 0x29) | 0x01;
outb(j, dev->baseport + 0x29); atp_writeb_base(dev, 0x29, j);
} }
/* /*
* Complete the command * Complete the command
...@@ -430,10 +471,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -430,10 +471,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
* Take it back wide * Take it back wide
*/ */
if (dev->wide_id[c] != 0) { if (dev->wide_id[c] != 0) {
outb(0x01, dev->ioport[c] + 0x1b); atp_writeb_io(dev, c, 0x1b, 0x01);
while ((inb(dev->ioport[c] + 0x1b) & 0x01) != 0x01) { while ((atp_readb_io(dev, c, 0x1b) & 0x01) != 0x01)
outb(0x01, dev->ioport[c] + 0x1b); atp_writeb_io(dev, c, 0x1b, 0x01);
}
} }
/* /*
* If there is stuff to send and nothing going then send it * If there is stuff to send and nothing going then send it
...@@ -458,52 +498,51 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) ...@@ -458,52 +498,51 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
} }
i &= 0x0f; i &= 0x0f;
if (i == 0x09) { if (i == 0x09) {
outl(dev->id[c][target_id].prdaddr, dev->pciport[c] + 4); atp_writel_pci(dev, c, 4, dev->id[c][target_id].prdaddr);
outb(0x06, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x06);
outb(0x00, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x00);
outb(0x41, dev->ioport[c] + 0x10); atp_writeb_io(dev, c, 0x10, 0x41);
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
k = dev->id[c][target_id].last_len; k = dev->id[c][target_id].last_len;
outb((unsigned char) (((unsigned char *) (&k))[2]), dev->ioport[c] + 0x12); atp_writeb_io(dev, c, 0x12, ((unsigned char *) (&k))[2]);
outb((unsigned char) (((unsigned char *) (&k))[1]), dev->ioport[c] + 0x13); atp_writeb_io(dev, c, 0x13, ((unsigned char *) (&k))[1]);
outb((unsigned char) (((unsigned char *) (&k))[0]), dev->ioport[c] + 0x14); atp_writeb_io(dev, c, 0x14, ((unsigned char *) (&k))[0]);
dev->id[c][target_id].dirct = 0x00; dev->id[c][target_id].dirct = 0x00;
} else { } else {
dev->id[c][target_id].dirct = 0x00; dev->id[c][target_id].dirct = 0x00;
} }
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
outb(0x09, dev->pciport[c]); atp_writeb_pci(dev, c, 0, 0x09);
dev->in_int[c] = 0; dev->in_int[c] = 0;
return IRQ_HANDLED; return IRQ_HANDLED;
} }
if (i == 0x08) { if (i == 0x08) {
outl(dev->id[c][target_id].prdaddr, dev->pciport[c] + 4); atp_writel_pci(dev, c, 4, dev->id[c][target_id].prdaddr);
outb(0x06, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x06);
outb(0x00, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x00);
outb(0x41, dev->ioport[c] + 0x10); atp_writeb_io(dev, c, 0x10, 0x41);
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
k = dev->id[c][target_id].last_len; k = dev->id[c][target_id].last_len;
outb((unsigned char) (((unsigned char *) (&k))[2]), dev->ioport[c] + 0x12); atp_writeb_io(dev, c, 0x12, ((unsigned char *) (&k))[2]);
outb((unsigned char) (((unsigned char *) (&k))[1]), dev->ioport[c] + 0x13); atp_writeb_io(dev, c, 0x13, ((unsigned char *) (&k))[1]);
outb((unsigned char) (((unsigned char *) (&k))[0]), dev->ioport[c] + 0x14); atp_writeb_io(dev, c, 0x14, ((unsigned char *) (&k))[0]);
} }
outb((unsigned char) (inb(dev->ioport[c] + 0x15) | 0x20), dev->ioport[c] + 0x15); atp_writeb_io(dev, c, 0x15, atp_readb_io(dev, c, 0x15) | 0x20);
dev->id[c][target_id].dirct = 0x20; dev->id[c][target_id].dirct = 0x20;
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
outb(0x01, dev->pciport[c]); atp_writeb_pci(dev, c, 0, 0x01);
dev->in_int[c] = 0; dev->in_int[c] = 0;
return IRQ_HANDLED; return IRQ_HANDLED;
} }
if (i == 0x0a) { if (i == 0x0a)
outb(0x30, dev->ioport[c] + 0x10); atp_writeb_io(dev, c, 0x10, 0x30);
} else { else
outb(0x46, dev->ioport[c] + 0x10); atp_writeb_io(dev, c, 0x10, 0x46);
}
dev->id[c][target_id].dirct = 0x00; dev->id[c][target_id].dirct = 0x00;
outb(0x00, dev->ioport[c] + 0x12); atp_writeb_io(dev, c, 0x12, 0x00);
outb(0x00, dev->ioport[c] + 0x13); atp_writeb_io(dev, c, 0x13, 0x00);
outb(0x00, dev->ioport[c] + 0x14); atp_writeb_io(dev, c, 0x14, 0x00);
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
} }
dev->in_int[c] = 0; dev->in_int[c] = 0;
...@@ -590,9 +629,9 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p, ...@@ -590,9 +629,9 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,
} }
dev->quereq[c][dev->quend[c]] = req_p; dev->quereq[c][dev->quend[c]] = req_p;
#ifdef ED_DBGP #ifdef ED_DBGP
printk("dev->ioport[c] = %x inb(dev->ioport[c] + 0x1c) = %x dev->in_int[%d] = %d dev->in_snd[%d] = %d\n",dev->ioport[c],inb(dev->ioport[c] + 0x1c),c,dev->in_int[c],c,dev->in_snd[c]); printk("dev->ioport[c] = %x atp_readb_io(dev, c, 0x1c) = %x dev->in_int[%d] = %d dev->in_snd[%d] = %d\n",dev->ioport[c],atp_readb_io(dev, c, 0x1c),c,dev->in_int[c],c,dev->in_snd[c]);
#endif #endif
if ((inb(dev->ioport[c] + 0x1c) == 0) && (dev->in_int[c] == 0) && (dev->in_snd[c] == 0)) { if ((atp_readb_io(dev, c, 0x1c) == 0) && (dev->in_int[c] == 0) && (dev->in_snd[c] == 0)) {
#ifdef ED_DBGP #ifdef ED_DBGP
printk("Call sent_s870(atp870u_queuecommand)\n"); printk("Call sent_s870(atp870u_queuecommand)\n");
#endif #endif
...@@ -666,7 +705,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c) ...@@ -666,7 +705,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
dev->id[c][scmd_id(workreq)].curr_req = workreq; dev->id[c][scmd_id(workreq)].curr_req = workreq;
dev->last_cmd[c] = scmd_id(workreq); dev->last_cmd[c] = scmd_id(workreq);
} }
if ((inb(dev->ioport[c] + 0x1f) & 0xb0) != 0 || inb(dev->ioport[c] + 0x1c) != 0) { if ((atp_readb_io(dev, c, 0x1f) & 0xb0) != 0 || atp_readb_io(dev, c, 0x1c) != 0) {
#ifdef ED_DBGP #ifdef ED_DBGP
printk("Abort to Send\n"); printk("Abort to Send\n");
#endif #endif
...@@ -685,8 +724,8 @@ static void send_s870(struct atp_unit *dev,unsigned char c) ...@@ -685,8 +724,8 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
l = scsi_bufflen(workreq); l = scsi_bufflen(workreq);
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
j = inb(dev->baseport + 0x29) & 0xfe; j = atp_readb_base(dev, 0x29) & 0xfe;
outb(j, dev->baseport + 0x29); atp_writeb_base(dev, 0x29, j);
dev->r1f[c][scmd_id(workreq)] = 0; dev->r1f[c][scmd_id(workreq)] = 0;
} }
...@@ -709,9 +748,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c) ...@@ -709,9 +748,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
if ((w & dev->wide_id[c]) != 0) { if ((w & dev->wide_id[c]) != 0) {
j |= 0x01; j |= 0x01;
} }
outb(j, dev->ioport[c] + 0x1b); atp_writeb_io(dev, c, 0x1b, j);
while ((inb(dev->ioport[c] + 0x1b) & 0x01) != j) { while ((atp_readb_io(dev, c, 0x1b) & 0x01) != j) {
outb(j,dev->ioport[c] + 0x1b); atp_writeb_pci(dev, c, 0x1b, j);
#ifdef ED_DBGP #ifdef ED_DBGP
printk("send_s870 while loop 1\n"); printk("send_s870 while loop 1\n");
#endif #endif
...@@ -720,21 +759,19 @@ static void send_s870(struct atp_unit *dev,unsigned char c) ...@@ -720,21 +759,19 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
* Write the command * Write the command
*/ */
outb(workreq->cmd_len, dev->ioport[c] + 0x00); atp_writeb_io(dev, c, 0x00, workreq->cmd_len);
outb(0x2c, dev->ioport[c] + 0x01); atp_writeb_io(dev, c, 0x01, 0x2c);
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID)
outb(0x7f, dev->ioport[c] + 0x02); atp_writeb_io(dev, c, 0x02, 0x7f);
} else { else
outb(0xcf, dev->ioport[c] + 0x02); atp_writeb_io(dev, c, 0x02, 0xcf);
} for (i = 0; i < workreq->cmd_len; i++)
for (i = 0; i < workreq->cmd_len; i++) { atp_writeb_io(dev, c, 0x03 + i, workreq->cmnd[i]);
outb(workreq->cmnd[i], dev->ioport[c] + 0x03 + i); atp_writeb_io(dev, c, 0x0f, workreq->device->lun);
}
outb(workreq->device->lun, dev->ioport[c] + 0x0f);
/* /*
* Write the target * Write the target
*/ */
outb(dev->id[c][target_id].devsp, dev->ioport[c] + 0x11); atp_writeb_io(dev, c, 0x11, dev->id[c][target_id].devsp);
#ifdef ED_DBGP #ifdef ED_DBGP
printk("dev->id[%d][%d].devsp = %2x\n",c,target_id,dev->id[c][target_id].devsp); printk("dev->id[%d][%d].devsp = %2x\n",c,target_id,dev->id[c][target_id].devsp);
#endif #endif
...@@ -743,9 +780,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c) ...@@ -743,9 +780,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
/* /*
* Write transfer size * Write transfer size
*/ */
outb((unsigned char) (((unsigned char *) (&l))[2]), dev->ioport[c] + 0x12); atp_writeb_io(dev, c, 0x12, ((unsigned char *) (&l))[2]);
outb((unsigned char) (((unsigned char *) (&l))[1]), dev->ioport[c] + 0x13); atp_writeb_io(dev, c, 0x13, ((unsigned char *) (&l))[1]);
outb((unsigned char) (((unsigned char *) (&l))[0]), dev->ioport[c] + 0x14); atp_writeb_io(dev, c, 0x14, ((unsigned char *) (&l))[0]);
j = target_id; j = target_id;
dev->id[c][j].last_len = l; dev->id[c][j].last_len = l;
dev->id[c][j].tran_len = 0; dev->id[c][j].tran_len = 0;
...@@ -761,23 +798,21 @@ static void send_s870(struct atp_unit *dev,unsigned char c) ...@@ -761,23 +798,21 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
/* /*
* Check transfer direction * Check transfer direction
*/ */
if (workreq->sc_data_direction == DMA_TO_DEVICE) { if (workreq->sc_data_direction == DMA_TO_DEVICE)
outb((unsigned char) (j | 0x20), dev->ioport[c] + 0x15); atp_writeb_io(dev, c, 0x15, j | 0x20);
} else { else
outb(j, dev->ioport[c] + 0x15); atp_writeb_io(dev, c, 0x15, j);
} atp_writeb_io(dev, c, 0x16, atp_readb_io(dev, c, 0x16) | 0x80);
outb((unsigned char) (inb(dev->ioport[c] + 0x16) | 0x80), dev->ioport[c] + 0x16); atp_writeb_io(dev, c, 0x16, 0x80);
outb(0x80, dev->ioport[c] + 0x16);
dev->id[c][target_id].dirct = 0; dev->id[c][target_id].dirct = 0;
if (l == 0) { if (l == 0) {
if (inb(dev->ioport[c] + 0x1c) == 0) { if (atp_readb_io(dev, c, 0x1c) == 0) {
#ifdef ED_DBGP #ifdef ED_DBGP
printk("change SCSI_CMD_REG 0x08\n"); printk("change SCSI_CMD_REG 0x08\n");
#endif #endif
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
} else { } else
dev->last_cmd[c] |= 0x40; dev->last_cmd[c] |= 0x40;
}
dev->in_snd[c] = 0; dev->in_snd[c] = 0;
return; return;
} }
...@@ -821,36 +856,34 @@ static void send_s870(struct atp_unit *dev,unsigned char c) ...@@ -821,36 +856,34 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
printk("send_s870: prdaddr_2 0x%8x target_id %d\n", dev->id[c][target_id].prdaddr,target_id); printk("send_s870: prdaddr_2 0x%8x target_id %d\n", dev->id[c][target_id].prdaddr,target_id);
#endif #endif
dev->id[c][target_id].prdaddr = dev->id[c][target_id].prd_bus; dev->id[c][target_id].prdaddr = dev->id[c][target_id].prd_bus;
outl(dev->id[c][target_id].prdaddr, dev->pciport[c] + 4); atp_writel_pci(dev, c, 4, dev->id[c][target_id].prdaddr);
outb(0x06, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x06);
outb(0x00, dev->pciport[c] + 2); atp_writeb_pci(dev, c, 2, 0x00);
if (dev->dev_id == ATP885_DEVID) { if (dev->dev_id == ATP885_DEVID) {
j = inb(dev->pciport[c] + 1) & 0xf3; j = atp_readb_pci(dev, c, 1) & 0xf3;
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) ||
(workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) { (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) {
j |= 0x0c; j |= 0x0c;
} }
outb(j, dev->pciport[c] + 1); atp_writeb_pci(dev, c, 1, j);
} else if ((dev->dev_id == ATP880_DEVID1) || } else if ((dev->dev_id == ATP880_DEVID1) ||
(dev->dev_id == ATP880_DEVID2)) { (dev->dev_id == ATP880_DEVID2)) {
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) { if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
outb((unsigned char) ((inb(dev->ioport[c] - 0x05) & 0x3f) | 0xc0), dev->ioport[c] - 0x05); atp_writeb_base(dev, 0x3b, (atp_readb_base(dev, 0x3b) & 0x3f) | 0xc0);
} else { else
outb((unsigned char) (inb(dev->ioport[c] - 0x05) & 0x3f), dev->ioport[c] - 0x05); atp_writeb_base(dev, 0x3b, atp_readb_base(dev, 0x3b) & 0x3f);
}
} else { } else {
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) { if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
outb((inb(dev->ioport[c] + 0x3a) & 0xf3) | 0x08, dev->ioport[c] + 0x3a); atp_writeb_io(dev, c, 0x3a, (atp_readb_io(dev, c, 0x3a) & 0xf3) | 0x08);
} else { else
outb(inb(dev->ioport[c] + 0x3a) & 0xf3, dev->ioport[c] + 0x3a); atp_writeb_io(dev, c, 0x3a, atp_readb_io(dev, c, 0x3a) & 0xf3);
}
} }
if(workreq->sc_data_direction == DMA_TO_DEVICE) { if(workreq->sc_data_direction == DMA_TO_DEVICE) {
dev->id[c][target_id].dirct = 0x20; dev->id[c][target_id].dirct = 0x20;
if (inb(dev->ioport[c] + 0x1c) == 0) { if (atp_readb_io(dev, c, 0x1c) == 0) {
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
outb(0x01, dev->pciport[c]); atp_writeb_pci(dev, c, 0, 0x01);
#ifdef ED_DBGP #ifdef ED_DBGP
printk( "start DMA(to target)\n"); printk( "start DMA(to target)\n");
#endif #endif
...@@ -860,9 +893,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c) ...@@ -860,9 +893,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
dev->in_snd[c] = 0; dev->in_snd[c] = 0;
return; return;
} }
if (inb(dev->ioport[c] + 0x1c) == 0) { if (atp_readb_io(dev, c, 0x1c) == 0) {
outb(0x08, dev->ioport[c] + 0x18); atp_writeb_io(dev, c, 0x18, 0x08);
outb(0x09, dev->pciport[c]); atp_writeb_pci(dev, c, 0, 0x09);
#ifdef ED_DBGP #ifdef ED_DBGP
printk( "start DMA(to host)\n"); printk( "start DMA(to host)\n");
#endif #endif
...@@ -879,28 +912,28 @@ static unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val) ...@@ -879,28 +912,28 @@ static unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)
unsigned short int i, k; unsigned short int i, k;
unsigned char j; unsigned char j;
outw(*val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, *val);
for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */ for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */
k = inw(dev->ioport[0] + 0x1c); k = atp_readw_io(dev, 0, 0x1c);
j = (unsigned char) (k >> 8); j = (unsigned char) (k >> 8);
if ((k & 0x8000) != 0) /* DB7 all release? */ if ((k & 0x8000) != 0) /* DB7 all release? */
i = 0; i = 0;
} }
*val |= 0x4000; /* assert DB6 */ *val |= 0x4000; /* assert DB6 */
outw(*val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, *val);
*val &= 0xdfff; /* assert DB5 */ *val &= 0xdfff; /* assert DB5 */
outw(*val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, *val);
for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */ for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */
if ((inw(dev->ioport[0] + 0x1c) & 0x2000) != 0) /* DB5 all release? */ if ((atp_readw_io(dev, 0, 0x1c) & 0x2000) != 0) /* DB5 all release? */
i = 0; i = 0;
} }
*val |= 0x8000; /* no DB4-0, assert DB7 */ *val |= 0x8000; /* no DB4-0, assert DB7 */
*val &= 0xe0ff; *val &= 0xe0ff;
outw(*val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, *val);
*val &= 0xbfff; /* release DB6 */ *val &= 0xbfff; /* release DB6 */
outw(*val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, *val);
for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */ for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */
if ((inw(dev->ioport[0] + 0x1c) & 0x4000) != 0) /* DB6 all release? */ if ((atp_readw_io(dev, 0, 0x1c) & 0x4000) != 0) /* DB6 all release? */
i = 0; i = 0;
} }
...@@ -926,9 +959,9 @@ static void tscam(struct Scsi_Host *host) ...@@ -926,9 +959,9 @@ static void tscam(struct Scsi_Host *host)
} }
*/ */
outb(0x08, dev->ioport[0] + 1); atp_writeb_io(dev, 0, 1, 0x08);
outb(0x7f, dev->ioport[0] + 2); atp_writeb_io(dev, 0, 2, 0x7f);
outb(0x20, dev->ioport[0] + 0x11); atp_writeb_io(dev, 0, 0x11, 0x20);
if ((dev->scam_on & 0x40) == 0) { if ((dev->scam_on & 0x40) == 0) {
return; return;
...@@ -941,13 +974,13 @@ static void tscam(struct Scsi_Host *host) ...@@ -941,13 +974,13 @@ static void tscam(struct Scsi_Host *host)
j = 8; j = 8;
} }
assignid_map = m; assignid_map = m;
outb(0x02, dev->ioport[0] + 0x02); /* 2*2=4ms,3EH 2/32*3E=3.9ms */ atp_writeb_io(dev, 0, 0x02, 0x02); /* 2*2=4ms,3EH 2/32*3E=3.9ms */
outb(0, dev->ioport[0] + 0x03); atp_writeb_io(dev, 0, 0x03, 0);
outb(0, dev->ioport[0] + 0x04); atp_writeb_io(dev, 0, 0x04, 0);
outb(0, dev->ioport[0] + 0x05); atp_writeb_io(dev, 0, 0x05, 0);
outb(0, dev->ioport[0] + 0x06); atp_writeb_io(dev, 0, 0x06, 0);
outb(0, dev->ioport[0] + 0x07); atp_writeb_io(dev, 0, 0x07, 0);
outb(0, dev->ioport[0] + 0x08); atp_writeb_io(dev, 0, 0x08, 0);
for (i = 0; i < j; i++) { for (i = 0; i < j; i++) {
m = 1; m = 1;
...@@ -955,70 +988,69 @@ static void tscam(struct Scsi_Host *host) ...@@ -955,70 +988,69 @@ static void tscam(struct Scsi_Host *host)
if ((m & assignid_map) != 0) { if ((m & assignid_map) != 0) {
continue; continue;
} }
outb(0, dev->ioport[0] + 0x0f); atp_writeb_io(dev, 0, 0x0f, 0);
outb(0, dev->ioport[0] + 0x12); atp_writeb_io(dev, 0, 0x12, 0);
outb(0, dev->ioport[0] + 0x13); atp_writeb_io(dev, 0, 0x13, 0);
outb(0, dev->ioport[0] + 0x14); atp_writeb_io(dev, 0, 0x14, 0);
if (i > 7) { if (i > 7) {
k = (i & 0x07) | 0x40; k = (i & 0x07) | 0x40;
} else { } else {
k = i; k = i;
} }
outb(k, dev->ioport[0] + 0x15); atp_writeb_io(dev, 0, 0x15, k);
if (dev->chip_ver == 4) { if (dev->chip_ver == 4)
outb(0x01, dev->ioport[0] + 0x1b); atp_writeb_io(dev, 0, 0x1b, 0x01);
} else { else
outb(0x00, dev->ioport[0] + 0x1b); atp_writeb_io(dev, 0, 0x1b, 0x00);
}
do { do {
outb(0x09, dev->ioport[0] + 0x18); atp_writeb_io(dev, 0, 0x18, 0x09);
while ((inb(dev->ioport[0] + 0x1f) & 0x80) == 0x00) while ((atp_readb_io(dev, 0, 0x1f) & 0x80) == 0x00)
cpu_relax(); cpu_relax();
k = inb(dev->ioport[0] + 0x17); k = atp_readb_io(dev, 0, 0x17);
if ((k == 0x85) || (k == 0x42)) if ((k == 0x85) || (k == 0x42))
break; break;
if (k != 0x16) if (k != 0x16)
outb(0x41, dev->ioport[0] + 0x10); atp_writeb_io(dev, 0, 0x10, 0x41);
} while (k != 0x16); } while (k != 0x16);
if ((k == 0x85) || (k == 0x42)) if ((k == 0x85) || (k == 0x42))
continue; continue;
assignid_map |= m; assignid_map |= m;
} }
outb(0x7f, dev->ioport[0] + 0x02); atp_writeb_io(dev, 0, 0x02, 0x7f);
outb(0x02, dev->ioport[0] + 0x1b); atp_writeb_io(dev, 0, 0x1b, 0x02);
outb(0, 0x80); outb(0, 0x80);
val = 0x0080; /* bsy */ val = 0x0080; /* bsy */
outw(val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, val);
val |= 0x0040; /* sel */ val |= 0x0040; /* sel */
outw(val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, val);
val |= 0x0004; /* msg */ val |= 0x0004; /* msg */
outw(val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, val);
inb(0x80); /* 2 deskew delay(45ns*2=90ns) */ inb(0x80); /* 2 deskew delay(45ns*2=90ns) */
val &= 0x007f; /* no bsy */ val &= 0x007f; /* no bsy */
outw(val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, val);
mdelay(128); mdelay(128);
val &= 0x00fb; /* after 1ms no msg */ val &= 0x00fb; /* after 1ms no msg */
outw(val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, val);
while ((inb(dev->ioport[0] + 0x1c) & 0x04) != 0) while ((atp_readb_io(dev, 0, 0x1c) & 0x04) != 0)
; ;
outb(1, 0x80); outb(1, 0x80);
udelay(100); udelay(100);
for (n = 0; n < 0x30000; n++) for (n = 0; n < 0x30000; n++)
if ((inb(dev->ioport[0] + 0x1c) & 0x80) != 0) /* bsy ? */ if ((atp_readb_io(dev, 0, 0x1c) & 0x80) != 0) /* bsy ? */
break; break;
if (n < 0x30000) if (n < 0x30000)
for (n = 0; n < 0x30000; n++) for (n = 0; n < 0x30000; n++)
if ((inb(dev->ioport[0] + 0x1c) & 0x81) == 0x0081) { if ((atp_readb_io(dev, 0, 0x1c) & 0x81) == 0x0081) {
inb(0x80); inb(0x80);
val |= 0x8003; /* io,cd,db7 */ val |= 0x8003; /* io,cd,db7 */
outw(val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, val);
inb(0x80); inb(0x80);
val &= 0x00bf; /* no sel */ val &= 0x00bf; /* no sel */
outw(val, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, val);
outb(2, 0x80); outb(2, 0x80);
break; break;
} }
...@@ -1033,14 +1065,14 @@ static void tscam(struct Scsi_Host *host) ...@@ -1033,14 +1065,14 @@ static void tscam(struct Scsi_Host *host)
*/ */
mdelay(2); mdelay(2);
udelay(48); udelay(48);
if ((inb(dev->ioport[0] + 0x1c) & 0x80) == 0x00) { /* bsy ? */ if ((atp_readb_io(dev, 0, 0x1c) & 0x80) == 0x00) { /* bsy ? */
outw(0, dev->ioport[0] + 0x1c); atp_writew_io(dev, 0, 0x1c, 0);
outb(0, dev->ioport[0] + 0x1b); atp_writeb_io(dev, 0, 0x1b, 0);
outb(0, dev->ioport[0] + 0x15); atp_writeb_io(dev, 0, 0x15, 0);
outb(0x09, dev->ioport[0] + 0x18); atp_writeb_io(dev, 0, 0x18, 0x09);
while ((inb(dev->ioport[0] + 0x1f) & 0x80) == 0) while ((atp_readb_io(dev, 0, 0x1f) & 0x80) == 0)
cpu_relax(); cpu_relax();
inb(dev->ioport[0] + 0x17); atp_readb_io(dev, 0, 0x17);
return; return;
} }
val &= 0x00ff; /* synchronization */ val &= 0x00ff; /* synchronization */
...@@ -1055,7 +1087,7 @@ static void tscam(struct Scsi_Host *host) ...@@ -1055,7 +1087,7 @@ static void tscam(struct Scsi_Host *host)
j = 0; j = 0;
while (1) { while (1) {
if ((inw(dev->ioport[0] + 0x1c) & 0x2000) == 0) if ((atp_readw_io(dev, 0, 0x1c) & 0x2000) == 0)
continue; continue;
outb(5, 0x80); outb(5, 0x80);
val &= 0x00ff; /* get ID_STRING */ val &= 0x00ff; /* get ID_STRING */
...@@ -2232,6 +2264,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2232,6 +2264,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
base_io = pci_resource_start(pdev, 0); base_io = pci_resource_start(pdev, 0);
base_io &= 0xfffffff8; base_io &= 0xfffffff8;
atpdev->baseport = base_io;
if ((ent->device == ATP880_DEVID1)||(ent->device == ATP880_DEVID2)) { if ((ent->device == ATP880_DEVID1)||(ent->device == ATP880_DEVID2)) {
atpdev->chip_ver = pdev->revision; atpdev->chip_ver = pdev->revision;
...@@ -2356,7 +2389,6 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2356,7 +2389,6 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
atpdev->pdev = pdev; atpdev->pdev = pdev;
atpdev->dev_id = ent->device; atpdev->dev_id = ent->device;
atpdev->baseport = base_io;
atpdev->ioport[0] = base_io + 0x80; atpdev->ioport[0] = base_io + 0x80;
atpdev->ioport[1] = base_io + 0xc0; atpdev->ioport[1] = base_io + 0xc0;
atpdev->pciport[0] = base_io + 0x40; atpdev->pciport[0] = base_io + 0x40;
...@@ -2651,12 +2683,12 @@ static int atp870u_abort(struct scsi_cmnd * SCpnt) ...@@ -2651,12 +2683,12 @@ static int atp870u_abort(struct scsi_cmnd * SCpnt)
printk("working=%x last_cmd=%x ", dev->working[c], dev->last_cmd[c]); printk("working=%x last_cmd=%x ", dev->working[c], dev->last_cmd[c]);
printk(" quhdu=%x quendu=%x ", dev->quhd[c], dev->quend[c]); printk(" quhdu=%x quendu=%x ", dev->quhd[c], dev->quend[c]);
for (j = 0; j < 0x18; j++) { for (j = 0; j < 0x18; j++) {
printk(" r%2x=%2x", j, inb(dev->ioport[c] + j)); printk(" r%2x=%2x", j, atp_readb_io(dev, c, j));
} }
printk(" r1c=%2x", inb(dev->ioport[c] + 0x1c)); printk(" r1c=%2x", atp_readb_io(dev, c, 0x1c));
printk(" r1f=%2x in_snd=%2x ", inb(dev->ioport[c] + 0x1f), dev->in_snd[c]); printk(" r1f=%2x in_snd=%2x ", atp_readb_io(dev, c, 0x1f), dev->in_snd[c]);
printk(" d00=%2x", inb(dev->pciport[c])); printk(" d00=%2x", atp_readb_pci(dev, c, 0x00));
printk(" d02=%2x", inb(dev->pciport[c] + 0x02)); printk(" d02=%2x", atp_readb_pci(dev, c, 0x02));
for(j=0;j<16;j++) { for(j=0;j<16;j++) {
if (dev->id[c][j].curr_req != NULL) { if (dev->id[c][j].curr_req != NULL) {
workrequ = dev->id[c][j].curr_req; workrequ = dev->id[c][j].curr_req;
......
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