Commit 820682b1 authored by Finn Thain's avatar Finn Thain Committed by Martin K. Petersen

scsi: ncr5380: Store IO ports and addresses in host private data

The various 5380 drivers inconsistently store register pointers
either in the Scsi_Host struct "legacy crap" area or in special,
board-specific members of the NCR5380_hostdata struct. Uniform
use of the latter struct makes for simpler and faster code (see
the following patches) and helps to reduce use of the
NCR5380_implementation_fields macro.
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Tested-by: default avatarOndrej Zary <linux@rainbow-software.org>
Tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
Acked-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 25894d1f
...@@ -437,14 +437,14 @@ static void prepare_info(struct Scsi_Host *instance) ...@@ -437,14 +437,14 @@ static void prepare_info(struct Scsi_Host *instance)
struct NCR5380_hostdata *hostdata = shost_priv(instance); struct NCR5380_hostdata *hostdata = shost_priv(instance);
snprintf(hostdata->info, sizeof(hostdata->info), snprintf(hostdata->info, sizeof(hostdata->info),
"%s, io_port 0x%lx, n_io_port %d, " "%s, irq %d, "
"base 0x%lx, irq %d, " "io_port 0x%lx, base 0x%lx, "
"can_queue %d, cmd_per_lun %d, " "can_queue %d, cmd_per_lun %d, "
"sg_tablesize %d, this_id %d, " "sg_tablesize %d, this_id %d, "
"flags { %s%s%s}, " "flags { %s%s%s}, "
"options { %s} ", "options { %s} ",
instance->hostt->name, instance->io_port, instance->n_io_port, instance->hostt->name, instance->irq,
instance->base, instance->irq, hostdata->io_port, hostdata->base,
instance->can_queue, instance->cmd_per_lun, instance->can_queue, instance->cmd_per_lun,
instance->sg_tablesize, instance->this_id, instance->sg_tablesize, instance->this_id,
hostdata->flags & FLAG_DMA_FIXUP ? "DMA_FIXUP " : "", hostdata->flags & FLAG_DMA_FIXUP ? "DMA_FIXUP " : "",
......
...@@ -220,6 +220,8 @@ ...@@ -220,6 +220,8 @@
struct NCR5380_hostdata { struct NCR5380_hostdata {
NCR5380_implementation_fields; /* Board-specific data */ NCR5380_implementation_fields; /* Board-specific data */
u8 __iomem *io; /* Remapped 5380 address */
u8 __iomem *pdma_io; /* Remapped PDMA address */
unsigned long poll_loops; /* Register polling limit */ unsigned long poll_loops; /* Register polling limit */
spinlock_t lock; /* Protects this struct */ spinlock_t lock; /* Protects this struct */
struct scsi_cmnd *connected; /* Currently connected cmnd */ struct scsi_cmnd *connected; /* Currently connected cmnd */
...@@ -230,6 +232,8 @@ struct NCR5380_hostdata { ...@@ -230,6 +232,8 @@ struct NCR5380_hostdata {
int flags; /* Board-specific quirks */ int flags; /* Board-specific quirks */
int dma_len; /* Requested length of DMA */ int dma_len; /* Requested length of DMA */
int read_overruns; /* Transfer size reduction for DMA erratum */ int read_overruns; /* Transfer size reduction for DMA erratum */
unsigned long io_port; /* Device IO port */
unsigned long base; /* Device base address */
struct list_head unissued; /* Waiting to be issued */ struct list_head unissued; /* Waiting to be issued */
struct scsi_cmnd *selecting; /* Cmnd to be connected */ struct scsi_cmnd *selecting; /* Cmnd to be connected */
struct list_head autosense; /* Priority cmnd queue */ struct list_head autosense; /* Priority cmnd queue */
...@@ -239,6 +243,7 @@ struct NCR5380_hostdata { ...@@ -239,6 +243,7 @@ struct NCR5380_hostdata {
unsigned char id_mask; /* 1 << Host ID */ unsigned char id_mask; /* 1 << Host ID */
unsigned char id_higher_mask; /* All bits above id_mask */ unsigned char id_higher_mask; /* All bits above id_mask */
unsigned char last_message; /* Last Message Out */ unsigned char last_message; /* Last Message Out */
unsigned long region_size; /* Size of address/port range */
char info[256]; char info[256];
}; };
......
...@@ -27,9 +27,7 @@ ...@@ -27,9 +27,7 @@
#define NCR5380_info cumanascsi_info #define NCR5380_info cumanascsi_info
#define NCR5380_implementation_fields \ #define NCR5380_implementation_fields \
unsigned ctrl; \ unsigned ctrl
void __iomem *base; \
void __iomem *dma
#include "../NCR5380.h" #include "../NCR5380.h"
...@@ -42,17 +40,18 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host, ...@@ -42,17 +40,18 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host,
unsigned char *addr, int len) unsigned char *addr, int len)
{ {
unsigned long *laddr; unsigned long *laddr;
void __iomem *dma = priv(host)->dma + 0x2000; u8 __iomem *base = priv(host)->io;
u8 __iomem *dma = priv(host)->pdma_io + 0x2000;
if(!len) return 0; if(!len) return 0;
writeb(0x02, priv(host)->base + CTRL); writeb(0x02, base + CTRL);
laddr = (unsigned long *)addr; laddr = (unsigned long *)addr;
while(len >= 32) while(len >= 32)
{ {
unsigned int status; unsigned int status;
unsigned long v; unsigned long v;
status = readb(priv(host)->base + STAT); status = readb(base + STAT);
if(status & 0x80) if(status & 0x80)
goto end; goto end;
if(!(status & 0x40)) if(!(status & 0x40))
...@@ -71,12 +70,12 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host, ...@@ -71,12 +70,12 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host,
} }
addr = (unsigned char *)laddr; addr = (unsigned char *)laddr;
writeb(0x12, priv(host)->base + CTRL); writeb(0x12, base + CTRL);
while(len > 0) while(len > 0)
{ {
unsigned int status; unsigned int status;
status = readb(priv(host)->base + STAT); status = readb(base + STAT);
if(status & 0x80) if(status & 0x80)
goto end; goto end;
if(status & 0x40) if(status & 0x40)
...@@ -86,7 +85,7 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host, ...@@ -86,7 +85,7 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host,
break; break;
} }
status = readb(priv(host)->base + STAT); status = readb(base + STAT);
if(status & 0x80) if(status & 0x80)
goto end; goto end;
if(status & 0x40) if(status & 0x40)
...@@ -97,7 +96,7 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host, ...@@ -97,7 +96,7 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host,
} }
} }
end: end:
writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL); writeb(priv(host)->ctrl | 0x40, base + CTRL);
if (len) if (len)
return -1; return -1;
...@@ -108,16 +107,17 @@ static inline int cumanascsi_pread(struct Scsi_Host *host, ...@@ -108,16 +107,17 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
unsigned char *addr, int len) unsigned char *addr, int len)
{ {
unsigned long *laddr; unsigned long *laddr;
void __iomem *dma = priv(host)->dma + 0x2000; u8 __iomem *base = priv(host)->io;
u8 __iomem *dma = priv(host)->pdma_io + 0x2000;
if(!len) return 0; if(!len) return 0;
writeb(0x00, priv(host)->base + CTRL); writeb(0x00, base + CTRL);
laddr = (unsigned long *)addr; laddr = (unsigned long *)addr;
while(len >= 32) while(len >= 32)
{ {
unsigned int status; unsigned int status;
status = readb(priv(host)->base + STAT); status = readb(base + STAT);
if(status & 0x80) if(status & 0x80)
goto end; goto end;
if(!(status & 0x40)) if(!(status & 0x40))
...@@ -136,12 +136,12 @@ static inline int cumanascsi_pread(struct Scsi_Host *host, ...@@ -136,12 +136,12 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
} }
addr = (unsigned char *)laddr; addr = (unsigned char *)laddr;
writeb(0x10, priv(host)->base + CTRL); writeb(0x10, base + CTRL);
while(len > 0) while(len > 0)
{ {
unsigned int status; unsigned int status;
status = readb(priv(host)->base + STAT); status = readb(base + STAT);
if(status & 0x80) if(status & 0x80)
goto end; goto end;
if(status & 0x40) if(status & 0x40)
...@@ -151,7 +151,7 @@ static inline int cumanascsi_pread(struct Scsi_Host *host, ...@@ -151,7 +151,7 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
break; break;
} }
status = readb(priv(host)->base + STAT); status = readb(base + STAT);
if(status & 0x80) if(status & 0x80)
goto end; goto end;
if(status & 0x40) if(status & 0x40)
...@@ -162,7 +162,7 @@ static inline int cumanascsi_pread(struct Scsi_Host *host, ...@@ -162,7 +162,7 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
} }
} }
end: end:
writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL); writeb(priv(host)->ctrl | 0x40, base + CTRL);
if (len) if (len)
return -1; return -1;
...@@ -171,7 +171,7 @@ static inline int cumanascsi_pread(struct Scsi_Host *host, ...@@ -171,7 +171,7 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg) static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg)
{ {
void __iomem *base = priv(host)->base; u8 __iomem *base = priv(host)->io;
unsigned char val; unsigned char val;
writeb(0, base + CTRL); writeb(0, base + CTRL);
...@@ -186,7 +186,7 @@ static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg) ...@@ -186,7 +186,7 @@ static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg)
static void cumanascsi_write(struct Scsi_Host *host, unsigned int reg, unsigned int value) static void cumanascsi_write(struct Scsi_Host *host, unsigned int reg, unsigned int value)
{ {
void __iomem *base = priv(host)->base; u8 __iomem *base = priv(host)->io;
writeb(0, base + CTRL); writeb(0, base + CTRL);
...@@ -231,11 +231,11 @@ static int cumanascsi1_probe(struct expansion_card *ec, ...@@ -231,11 +231,11 @@ static int cumanascsi1_probe(struct expansion_card *ec,
goto out_release; goto out_release;
} }
priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW), priv(host)->io = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW),
ecard_resource_len(ec, ECARD_RES_IOCSLOW)); ecard_resource_len(ec, ECARD_RES_IOCSLOW));
priv(host)->dma = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), priv(host)->pdma_io = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
ecard_resource_len(ec, ECARD_RES_MEMC)); ecard_resource_len(ec, ECARD_RES_MEMC));
if (!priv(host)->base || !priv(host)->dma) { if (!priv(host)->io || !priv(host)->pdma_io) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_unmap; goto out_unmap;
} }
...@@ -249,7 +249,7 @@ static int cumanascsi1_probe(struct expansion_card *ec, ...@@ -249,7 +249,7 @@ static int cumanascsi1_probe(struct expansion_card *ec,
NCR5380_maybe_reset_bus(host); NCR5380_maybe_reset_bus(host);
priv(host)->ctrl = 0; priv(host)->ctrl = 0;
writeb(0, priv(host)->base + CTRL); writeb(0, priv(host)->io + CTRL);
ret = request_irq(host->irq, cumanascsi_intr, 0, ret = request_irq(host->irq, cumanascsi_intr, 0,
"CumanaSCSI-1", host); "CumanaSCSI-1", host);
...@@ -271,8 +271,8 @@ static int cumanascsi1_probe(struct expansion_card *ec, ...@@ -271,8 +271,8 @@ static int cumanascsi1_probe(struct expansion_card *ec,
out_exit: out_exit:
NCR5380_exit(host); NCR5380_exit(host);
out_unmap: out_unmap:
iounmap(priv(host)->base); iounmap(priv(host)->io);
iounmap(priv(host)->dma); iounmap(priv(host)->pdma_io);
scsi_host_put(host); scsi_host_put(host);
out_release: out_release:
ecard_release_resources(ec); ecard_release_resources(ec);
...@@ -283,15 +283,17 @@ static int cumanascsi1_probe(struct expansion_card *ec, ...@@ -283,15 +283,17 @@ static int cumanascsi1_probe(struct expansion_card *ec,
static void cumanascsi1_remove(struct expansion_card *ec) static void cumanascsi1_remove(struct expansion_card *ec)
{ {
struct Scsi_Host *host = ecard_get_drvdata(ec); struct Scsi_Host *host = ecard_get_drvdata(ec);
void __iomem *base = priv(host)->io;
void __iomem *dma = priv(host)->pdma_io;
ecard_set_drvdata(ec, NULL); ecard_set_drvdata(ec, NULL);
scsi_remove_host(host); scsi_remove_host(host);
free_irq(host->irq, host); free_irq(host->irq, host);
NCR5380_exit(host); NCR5380_exit(host);
iounmap(priv(host)->base);
iounmap(priv(host)->dma);
scsi_host_put(host); scsi_host_put(host);
iounmap(base);
iounmap(dma);
ecard_release_resources(ec); ecard_release_resources(ec);
} }
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
#define NCR5380_read(reg) \ #define NCR5380_read(reg) \
readb(priv(instance)->base + ((reg) << 2)) readb(priv(instance)->io + ((reg) << 2))
#define NCR5380_write(reg, value) \ #define NCR5380_write(reg, value) \
writeb(value, priv(instance)->base + ((reg) << 2)) writeb(value, priv(instance)->io + ((reg) << 2))
#define NCR5380_dma_xfer_len(instance, cmd, phase) (0) #define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
#define NCR5380_dma_recv_setup oakscsi_pread #define NCR5380_dma_recv_setup oakscsi_pread
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
#define NCR5380_queue_command oakscsi_queue_command #define NCR5380_queue_command oakscsi_queue_command
#define NCR5380_info oakscsi_info #define NCR5380_info oakscsi_info
#define NCR5380_implementation_fields \ #define NCR5380_implementation_fields /* none */
void __iomem *base
#include "../NCR5380.h" #include "../NCR5380.h"
...@@ -43,7 +42,7 @@ ...@@ -43,7 +42,7 @@
static inline int oakscsi_pwrite(struct Scsi_Host *instance, static inline int oakscsi_pwrite(struct Scsi_Host *instance,
unsigned char *addr, int len) unsigned char *addr, int len)
{ {
void __iomem *base = priv(instance)->base; u8 __iomem *base = priv(instance)->io;
printk("writing %p len %d\n",addr, len); printk("writing %p len %d\n",addr, len);
...@@ -58,7 +57,7 @@ printk("writing %p len %d\n",addr, len); ...@@ -58,7 +57,7 @@ printk("writing %p len %d\n",addr, len);
static inline int oakscsi_pread(struct Scsi_Host *instance, static inline int oakscsi_pread(struct Scsi_Host *instance,
unsigned char *addr, int len) unsigned char *addr, int len)
{ {
void __iomem *base = priv(instance)->base; u8 __iomem *base = priv(instance)->io;
printk("reading %p len %d\n", addr, len); printk("reading %p len %d\n", addr, len);
while(len > 0) while(len > 0)
{ {
...@@ -133,15 +132,14 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -133,15 +132,14 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
goto release; goto release;
} }
priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), priv(host)->io = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
ecard_resource_len(ec, ECARD_RES_MEMC)); ecard_resource_len(ec, ECARD_RES_MEMC));
if (!priv(host)->base) { if (!priv(host)->io) {
ret = -ENOMEM; ret = -ENOMEM;
goto unreg; goto unreg;
} }
host->irq = NO_IRQ; host->irq = NO_IRQ;
host->n_io_port = 255;
ret = NCR5380_init(host, FLAG_DMA_FIXUP | FLAG_LATE_DMA_SETUP); ret = NCR5380_init(host, FLAG_DMA_FIXUP | FLAG_LATE_DMA_SETUP);
if (ret) if (ret)
...@@ -159,7 +157,7 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -159,7 +157,7 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
out_exit: out_exit:
NCR5380_exit(host); NCR5380_exit(host);
out_unmap: out_unmap:
iounmap(priv(host)->base); iounmap(priv(host)->io);
unreg: unreg:
scsi_host_put(host); scsi_host_put(host);
release: release:
...@@ -171,13 +169,14 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -171,13 +169,14 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
static void oakscsi_remove(struct expansion_card *ec) static void oakscsi_remove(struct expansion_card *ec)
{ {
struct Scsi_Host *host = ecard_get_drvdata(ec); struct Scsi_Host *host = ecard_get_drvdata(ec);
void __iomem *base = priv(host)->io;
ecard_set_drvdata(ec, NULL); ecard_set_drvdata(ec, NULL);
scsi_remove_host(host); scsi_remove_host(host);
NCR5380_exit(host); NCR5380_exit(host);
iounmap(priv(host)->base);
scsi_host_put(host); scsi_host_put(host);
iounmap(base);
ecard_release_resources(ec); ecard_release_resources(ec);
} }
......
...@@ -34,8 +34,10 @@ ...@@ -34,8 +34,10 @@
* Definitions for the generic 5380 driver. * Definitions for the generic 5380 driver.
*/ */
#define NCR5380_read(reg) inb(instance->io_port + reg) #define priv(instance) ((struct NCR5380_hostdata *)shost_priv(instance))
#define NCR5380_write(reg, value) outb(value, instance->io_port + reg)
#define NCR5380_read(reg) inb(priv(instance)->base + (reg))
#define NCR5380_write(reg, value) outb(value, priv(instance)->base + (reg))
#define NCR5380_dma_xfer_len(instance, cmd, phase) (0) #define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
#define NCR5380_dma_recv_setup(instance, dst, len) (0) #define NCR5380_dma_recv_setup(instance, dst, len) (0)
...@@ -71,6 +73,7 @@ static int dmx3191d_probe_one(struct pci_dev *pdev, ...@@ -71,6 +73,7 @@ static int dmx3191d_probe_one(struct pci_dev *pdev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
struct Scsi_Host *shost; struct Scsi_Host *shost;
struct NCR5380_hostdata *hostdata;
unsigned long io; unsigned long io;
int error = -ENODEV; int error = -ENODEV;
...@@ -88,7 +91,9 @@ static int dmx3191d_probe_one(struct pci_dev *pdev, ...@@ -88,7 +91,9 @@ static int dmx3191d_probe_one(struct pci_dev *pdev,
sizeof(struct NCR5380_hostdata)); sizeof(struct NCR5380_hostdata));
if (!shost) if (!shost)
goto out_release_region; goto out_release_region;
shost->io_port = io;
hostdata = shost_priv(shost);
hostdata->base = io;
/* This card does not seem to raise an interrupt on pdev->irq. /* This card does not seem to raise an interrupt on pdev->irq.
* Steam-powered SCSI controllers run without an IRQ anyway. * Steam-powered SCSI controllers run without an IRQ anyway.
...@@ -125,7 +130,8 @@ static int dmx3191d_probe_one(struct pci_dev *pdev, ...@@ -125,7 +130,8 @@ static int dmx3191d_probe_one(struct pci_dev *pdev,
static void dmx3191d_remove_one(struct pci_dev *pdev) static void dmx3191d_remove_one(struct pci_dev *pdev)
{ {
struct Scsi_Host *shost = pci_get_drvdata(pdev); struct Scsi_Host *shost = pci_get_drvdata(pdev);
unsigned long io = shost->io_port; struct NCR5380_hostdata *hostdata = shost_priv(shost);
unsigned long io = hostdata->base;
scsi_remove_host(shost); scsi_remove_host(shost);
......
...@@ -115,7 +115,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt, ...@@ -115,7 +115,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
unsigned long region_size; unsigned long region_size;
struct Scsi_Host *instance; struct Scsi_Host *instance;
struct NCR5380_hostdata *hostdata; struct NCR5380_hostdata *hostdata;
void __iomem *iomem; u8 __iomem *iomem;
switch (board) { switch (board) {
case BOARD_NCR5380: case BOARD_NCR5380:
...@@ -201,11 +201,11 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt, ...@@ -201,11 +201,11 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
} }
hostdata = shost_priv(instance); hostdata = shost_priv(instance);
hostdata->iomem = iomem; hostdata->io = iomem;
hostdata->region_size = region_size;
if (is_pmio) { if (is_pmio) {
instance->io_port = base; hostdata->io_port = base;
instance->n_io_port = region_size;
hostdata->io_width = 1; /* 8-bit PDMA by default */ hostdata->io_width = 1; /* 8-bit PDMA by default */
hostdata->offset = 0; hostdata->offset = 0;
...@@ -215,7 +215,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt, ...@@ -215,7 +215,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
*/ */
switch (board) { switch (board) {
case BOARD_NCR53C400: case BOARD_NCR53C400:
instance->io_port += 8; hostdata->io_port += 8;
hostdata->c400_ctl_status = 0; hostdata->c400_ctl_status = 0;
hostdata->c400_blk_cnt = 1; hostdata->c400_blk_cnt = 1;
hostdata->c400_host_buf = 4; hostdata->c400_host_buf = 4;
...@@ -231,8 +231,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt, ...@@ -231,8 +231,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
break; break;
} }
} else { } else {
instance->base = base; hostdata->base = base;
hostdata->iomem_size = region_size;
hostdata->offset = NCR53C400_mem_base; hostdata->offset = NCR53C400_mem_base;
switch (board) { switch (board) {
case BOARD_NCR53C400: case BOARD_NCR53C400:
...@@ -314,17 +313,21 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt, ...@@ -314,17 +313,21 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
static void generic_NCR5380_release_resources(struct Scsi_Host *instance) static void generic_NCR5380_release_resources(struct Scsi_Host *instance)
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance); struct NCR5380_hostdata *hostdata = shost_priv(instance);
void __iomem *iomem = hostdata->io;
unsigned long io_port = hostdata->io_port;
unsigned long base = hostdata->base;
unsigned long region_size = hostdata->region_size;
scsi_remove_host(instance); scsi_remove_host(instance);
if (instance->irq != NO_IRQ) if (instance->irq != NO_IRQ)
free_irq(instance->irq, instance); free_irq(instance->irq, instance);
NCR5380_exit(instance); NCR5380_exit(instance);
iounmap(hostdata->iomem);
if (instance->io_port)
release_region(instance->io_port, instance->n_io_port);
else
release_mem_region(instance->base, hostdata->iomem_size);
scsi_host_put(instance); scsi_host_put(instance);
iounmap(iomem);
if (io_port)
release_region(io_port, region_size);
else
release_mem_region(base, region_size);
} }
/** /**
...@@ -356,15 +359,15 @@ static inline int generic_NCR5380_pread(struct Scsi_Host *instance, ...@@ -356,15 +359,15 @@ static inline int generic_NCR5380_pread(struct Scsi_Host *instance,
while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY) while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY)
; /* FIXME - no timeout */ ; /* FIXME - no timeout */
if (instance->io_port && hostdata->io_width == 2) if (hostdata->io_port && hostdata->io_width == 2)
insw(instance->io_port + hostdata->c400_host_buf, insw(hostdata->io_port + hostdata->c400_host_buf,
dst + start, 64); dst + start, 64);
else if (instance->io_port) else if (hostdata->io_port)
insb(instance->io_port + hostdata->c400_host_buf, insb(hostdata->io_port + hostdata->c400_host_buf,
dst + start, 128); dst + start, 128);
else else
memcpy_fromio(dst + start, memcpy_fromio(dst + start,
hostdata->iomem + NCR53C400_host_buffer, 128); hostdata->io + NCR53C400_host_buffer, 128);
start += 128; start += 128;
blocks--; blocks--;
...@@ -374,15 +377,15 @@ static inline int generic_NCR5380_pread(struct Scsi_Host *instance, ...@@ -374,15 +377,15 @@ static inline int generic_NCR5380_pread(struct Scsi_Host *instance,
while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY) while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY)
; /* FIXME - no timeout */ ; /* FIXME - no timeout */
if (instance->io_port && hostdata->io_width == 2) if (hostdata->io_port && hostdata->io_width == 2)
insw(instance->io_port + hostdata->c400_host_buf, insw(hostdata->io_port + hostdata->c400_host_buf,
dst + start, 64); dst + start, 64);
else if (instance->io_port) else if (hostdata->io_port)
insb(instance->io_port + hostdata->c400_host_buf, insb(hostdata->io_port + hostdata->c400_host_buf,
dst + start, 128); dst + start, 128);
else else
memcpy_fromio(dst + start, memcpy_fromio(dst + start,
hostdata->iomem + NCR53C400_host_buffer, 128); hostdata->io + NCR53C400_host_buffer, 128);
start += 128; start += 128;
blocks--; blocks--;
...@@ -431,14 +434,14 @@ static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance, ...@@ -431,14 +434,14 @@ static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance,
while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY) while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY)
; // FIXME - timeout ; // FIXME - timeout
if (instance->io_port && hostdata->io_width == 2) if (hostdata->io_port && hostdata->io_width == 2)
outsw(instance->io_port + hostdata->c400_host_buf, outsw(hostdata->io_port + hostdata->c400_host_buf,
src + start, 64); src + start, 64);
else if (instance->io_port) else if (hostdata->io_port)
outsb(instance->io_port + hostdata->c400_host_buf, outsb(hostdata->io_port + hostdata->c400_host_buf,
src + start, 128); src + start, 128);
else else
memcpy_toio(hostdata->iomem + NCR53C400_host_buffer, memcpy_toio(hostdata->io + NCR53C400_host_buffer,
src + start, 128); src + start, 128);
start += 128; start += 128;
...@@ -448,14 +451,14 @@ static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance, ...@@ -448,14 +451,14 @@ static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance,
while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY) while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY)
; // FIXME - no timeout ; // FIXME - no timeout
if (instance->io_port && hostdata->io_width == 2) if (hostdata->io_port && hostdata->io_width == 2)
outsw(instance->io_port + hostdata->c400_host_buf, outsw(hostdata->io_port + hostdata->c400_host_buf,
src + start, 64); src + start, 64);
else if (instance->io_port) else if (hostdata->io_port)
outsb(instance->io_port + hostdata->c400_host_buf, outsb(hostdata->io_port + hostdata->c400_host_buf,
src + start, 128); src + start, 128);
else else
memcpy_toio(hostdata->iomem + NCR53C400_host_buffer, memcpy_toio(hostdata->io + NCR53C400_host_buffer,
src + start, 128); src + start, 128);
start += 128; start += 128;
......
...@@ -17,18 +17,16 @@ ...@@ -17,18 +17,16 @@
#define DRV_MODULE_NAME "g_NCR5380" #define DRV_MODULE_NAME "g_NCR5380"
#define NCR5380_read(reg) \ #define NCR5380_read(reg) \
ioread8(((struct NCR5380_hostdata *)shost_priv(instance))->iomem + \ ioread8(((struct NCR5380_hostdata *)shost_priv(instance))->io + \
((struct NCR5380_hostdata *)shost_priv(instance))->offset + \ ((struct NCR5380_hostdata *)shost_priv(instance))->offset + \
(reg)) (reg))
#define NCR5380_write(reg, value) \ #define NCR5380_write(reg, value) \
iowrite8(value, ((struct NCR5380_hostdata *)shost_priv(instance))->iomem + \ iowrite8(value, ((struct NCR5380_hostdata *)shost_priv(instance))->io + \
((struct NCR5380_hostdata *)shost_priv(instance))->offset + \ ((struct NCR5380_hostdata *)shost_priv(instance))->offset + \
(reg)) (reg))
#define NCR5380_implementation_fields \ #define NCR5380_implementation_fields \
int offset; \ int offset; \
void __iomem *iomem; \
resource_size_t iomem_size; \
int c400_ctl_status; \ int c400_ctl_status; \
int c400_blk_cnt; \ int c400_blk_cnt; \
int c400_host_buf; \ int c400_host_buf; \
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
/* Definitions for the core NCR5380 driver. */ /* Definitions for the core NCR5380 driver. */
#define NCR5380_implementation_fields unsigned char *pdma_base; \ #define NCR5380_implementation_fields int pdma_residual
int pdma_residual
#define NCR5380_read(reg) macscsi_read(instance, reg) #define NCR5380_read(reg) macscsi_read(instance, reg)
#define NCR5380_write(reg, value) macscsi_write(instance, reg, value) #define NCR5380_write(reg, value) macscsi_write(instance, reg, value)
...@@ -67,12 +66,16 @@ module_param(setup_toshiba_delay, int, 0); ...@@ -67,12 +66,16 @@ module_param(setup_toshiba_delay, int, 0);
static inline char macscsi_read(struct Scsi_Host *instance, int reg) static inline char macscsi_read(struct Scsi_Host *instance, int reg)
{ {
return in_8(instance->base + (reg << 4)); struct NCR5380_hostdata *hostdata = shost_priv(instance);
return in_8(hostdata->io + (reg << 4));
} }
static inline void macscsi_write(struct Scsi_Host *instance, int reg, int value) static inline void macscsi_write(struct Scsi_Host *instance, int reg, int value)
{ {
out_8(instance->base + (reg << 4), value); struct NCR5380_hostdata *hostdata = shost_priv(instance);
out_8(hostdata->io + (reg << 4), value);
} }
#ifndef MODULE #ifndef MODULE
...@@ -171,7 +174,7 @@ static int macscsi_pread(struct Scsi_Host *instance, ...@@ -171,7 +174,7 @@ static int macscsi_pread(struct Scsi_Host *instance,
unsigned char *dst, int len) unsigned char *dst, int len)
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance); struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char *s = hostdata->pdma_base + (INPUT_DATA_REG << 4); unsigned char *s = hostdata->pdma_io + (INPUT_DATA_REG << 4);
unsigned char *d = dst; unsigned char *d = dst;
int n = len; int n = len;
int transferred; int transferred;
...@@ -275,7 +278,7 @@ static int macscsi_pwrite(struct Scsi_Host *instance, ...@@ -275,7 +278,7 @@ static int macscsi_pwrite(struct Scsi_Host *instance,
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance); struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char *s = src; unsigned char *s = src;
unsigned char *d = hostdata->pdma_base + (OUTPUT_DATA_REG << 4); unsigned char *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4);
int n = len; int n = len;
int transferred; int transferred;
...@@ -356,6 +359,7 @@ static struct scsi_host_template mac_scsi_template = { ...@@ -356,6 +359,7 @@ static struct scsi_host_template mac_scsi_template = {
static int __init mac_scsi_probe(struct platform_device *pdev) static int __init mac_scsi_probe(struct platform_device *pdev)
{ {
struct Scsi_Host *instance; struct Scsi_Host *instance;
struct NCR5380_hostdata *hostdata;
int error; int error;
int host_flags = 0; int host_flags = 0;
struct resource *irq, *pio_mem, *pdma_mem = NULL; struct resource *irq, *pio_mem, *pdma_mem = NULL;
...@@ -388,17 +392,18 @@ static int __init mac_scsi_probe(struct platform_device *pdev) ...@@ -388,17 +392,18 @@ static int __init mac_scsi_probe(struct platform_device *pdev)
if (!instance) if (!instance)
return -ENOMEM; return -ENOMEM;
instance->base = pio_mem->start;
if (irq) if (irq)
instance->irq = irq->start; instance->irq = irq->start;
else else
instance->irq = NO_IRQ; instance->irq = NO_IRQ;
if (pdma_mem && setup_use_pdma) { hostdata = shost_priv(instance);
struct NCR5380_hostdata *hostdata = shost_priv(instance); hostdata->base = pio_mem->start;
hostdata->io = (void *)pio_mem->start;
hostdata->pdma_base = (unsigned char *)pdma_mem->start; if (pdma_mem && setup_use_pdma)
} else hostdata->pdma_io = (void *)pdma_mem->start;
else
host_flags |= FLAG_NO_PSEUDO_DMA; host_flags |= FLAG_NO_PSEUDO_DMA;
host_flags |= setup_toshiba_delay > 0 ? FLAG_TOSHIBA_DELAY : 0; host_flags |= setup_toshiba_delay > 0 ? FLAG_TOSHIBA_DELAY : 0;
......
...@@ -428,6 +428,7 @@ static struct scsi_host_template sun3_scsi_template = { ...@@ -428,6 +428,7 @@ static struct scsi_host_template sun3_scsi_template = {
static int __init sun3_scsi_probe(struct platform_device *pdev) static int __init sun3_scsi_probe(struct platform_device *pdev)
{ {
struct Scsi_Host *instance; struct Scsi_Host *instance;
struct NCR5380_hostdata *hostdata;
int error; int error;
struct resource *irq, *mem; struct resource *irq, *mem;
unsigned char *ioaddr; unsigned char *ioaddr;
...@@ -502,9 +503,11 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) ...@@ -502,9 +503,11 @@ static int __init sun3_scsi_probe(struct platform_device *pdev)
goto fail_alloc; goto fail_alloc;
} }
instance->io_port = (unsigned long)ioaddr;
instance->irq = irq->start; instance->irq = irq->start;
hostdata = shost_priv(instance);
hostdata->base = (unsigned long)ioaddr;
error = NCR5380_init(instance, host_flags); error = NCR5380_init(instance, host_flags);
if (error) if (error)
goto fail_init; goto fail_init;
......
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