Commit c1d288a5 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

m68k: amiga - GVP Series II SCSI zorro_driver conversion

Acked-by: default avatarJames Bottomley <James.Bottomley@suse.de>
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
parent 65c2784a
#include <linux/types.h> #include <linux/types.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/blkdev.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/zorro.h>
#include <asm/setup.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/amigaints.h> #include <asm/amigaints.h>
#include <asm/amigahw.h> #include <asm/amigahw.h>
#include <linux/zorro.h>
#include <asm/irq.h>
#include <linux/spinlock.h>
#include "scsi.h" #include "scsi.h"
#include <scsi/scsi_host.h>
#include "wd33c93.h" #include "wd33c93.h"
#include "gvp11.h" #include "gvp11.h"
#include <linux/stat.h>
#define CHECK_WD33C93 #define CHECK_WD33C93
...@@ -169,7 +163,40 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, ...@@ -169,7 +163,40 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
} }
} }
static int __init check_wd33c93(struct gvp11_scsiregs *regs) static int gvp11_bus_reset(struct scsi_cmnd *cmd)
{
struct Scsi_Host *instance = cmd->device->host;
/* FIXME perform bus-specific reset */
/* FIXME 2: shouldn't we no-op this function (return
FAILED), and fall back to host reset function,
wd33c93_host_reset ? */
spin_lock_irq(instance->host_lock);
wd33c93_host_reset(cmd);
spin_unlock_irq(instance->host_lock);
return SUCCESS;
}
static struct scsi_host_template gvp11_scsi_template = {
.module = THIS_MODULE,
.name = "GVP Series II SCSI",
.proc_info = wd33c93_proc_info,
.proc_name = "GVP11",
.queuecommand = wd33c93_queuecommand,
.eh_abort_handler = wd33c93_abort,
.eh_bus_reset_handler = gvp11_bus_reset,
.eh_host_reset_handler = wd33c93_host_reset,
.can_queue = CAN_QUEUE,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = CMD_PER_LUN,
.use_clustering = DISABLE_CLUSTERING
};
static int __devinit check_wd33c93(struct gvp11_scsiregs *regs)
{ {
#ifdef CHECK_WD33C93 #ifdef CHECK_WD33C93
volatile unsigned char *sasr_3393, *scmd_3393; volatile unsigned char *sasr_3393, *scmd_3393;
...@@ -249,163 +276,150 @@ static int __init check_wd33c93(struct gvp11_scsiregs *regs) ...@@ -249,163 +276,150 @@ static int __init check_wd33c93(struct gvp11_scsiregs *regs)
return 0; return 0;
} }
int __init gvp11_detect(struct scsi_host_template *tpnt) static int __devinit gvp11_probe(struct zorro_dev *z,
const struct zorro_device_id *ent)
{ {
static unsigned char called = 0;
struct Scsi_Host *instance; struct Scsi_Host *instance;
unsigned long address; unsigned long address;
int error;
unsigned int epc; unsigned int epc;
struct zorro_dev *z = NULL;
unsigned int default_dma_xfer_mask; unsigned int default_dma_xfer_mask;
struct WD33C93_hostdata *hdata; struct WD33C93_hostdata *hdata;
struct gvp11_scsiregs *regs; struct gvp11_scsiregs *regs;
wd33c93_regs wdregs; wd33c93_regs wdregs;
int num_gvp11 = 0;
default_dma_xfer_mask = ent->driver_data;
if (!MACH_IS_AMIGA || called)
return 0; /*
called = 1; * Rumors state that some GVP ram boards use the same product
* code as the SCSI controllers. Therefore if the board-size
tpnt->proc_name = "GVP11"; * is not 64KB we asume it is a ram board and bail out.
tpnt->proc_info = &wd33c93_proc_info; */
if (zorro_resource_len(z) != 0x10000)
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { return -ENODEV;
/*
* This should (hopefully) be the correct way to identify address = z->resource.start;
* all the different GVP SCSI controllers (except for the if (!request_mem_region(address, 256, "wd33c93"))
* SERIES I though). return -EBUSY;
*/
regs = (struct gvp11_scsiregs *)(ZTWO_VADDR(address));
if (z->id == ZORRO_PROD_GVP_COMBO_030_R3_SCSI ||
z->id == ZORRO_PROD_GVP_SERIES_II) error = check_wd33c93(regs);
default_dma_xfer_mask = ~0x00ffffff; if (error)
else if (z->id == ZORRO_PROD_GVP_GFORCE_030_SCSI || goto fail_check_or_alloc;
z->id == ZORRO_PROD_GVP_A530_SCSI ||
z->id == ZORRO_PROD_GVP_COMBO_030_R4_SCSI) instance = scsi_host_alloc(&gvp11_scsi_template,
default_dma_xfer_mask = ~0x01ffffff; sizeof(struct WD33C93_hostdata));
else if (z->id == ZORRO_PROD_GVP_A1291 || if (!instance) {
z->id == ZORRO_PROD_GVP_GFORCE_040_SCSI_1) error = -ENOMEM;
default_dma_xfer_mask = ~0x07ffffff; goto fail_check_or_alloc;
else
continue;
/*
* Rumors state that some GVP ram boards use the same product
* code as the SCSI controllers. Therefore if the board-size
* is not 64KB we asume it is a ram board and bail out.
*/
if (z->resource.end - z->resource.start != 0xffff)
continue;
address = z->resource.start;
if (!request_mem_region(address, 256, "wd33c93"))
continue;
regs = (struct gvp11_scsiregs *)(ZTWO_VADDR(address));
if (check_wd33c93(regs))
goto release;
instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
if (instance == NULL)
goto release;
instance->base = ZTWO_VADDR(address);
instance->irq = IRQ_AMIGA_PORTS;
instance->unique_id = z->slotaddr;
hdata = shost_priv(instance);
if (gvp11_xfer_mask)
hdata->dma_xfer_mask = gvp11_xfer_mask;
else
hdata->dma_xfer_mask = default_dma_xfer_mask;
regs->secret2 = 1;
regs->secret1 = 0;
regs->secret3 = 15;
while (regs->CNTR & GVP11_DMAC_BUSY)
;
regs->CNTR = 0;
regs->BANK = 0;
epc = *(unsigned short *)(ZTWO_VADDR(address) + 0x8000);
/*
* Check for 14MHz SCSI clock
*/
wdregs.SASR = &regs->SASR;
wdregs.SCMD = &regs->SCMD;
hdata->no_sync = 0xff;
hdata->fast = 0;
hdata->dma_mode = CTRL_DMA;
wd33c93_init(instance, wdregs, dma_setup, dma_stop,
(epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10
: WD33C93_FS_12_15);
if (request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED,
"GVP11 SCSI", instance))
goto unregister;
regs->CNTR = GVP11_DMAC_INT_ENABLE;
num_gvp11++;
continue;
unregister:
scsi_unregister(instance);
release:
release_mem_region(address, 256);
} }
return num_gvp11; instance->base = (unsigned long)regs;
} instance->irq = IRQ_AMIGA_PORTS;
instance->unique_id = z->slotaddr;
static int gvp11_bus_reset(struct scsi_cmnd *cmd) regs->secret2 = 1;
{ regs->secret1 = 0;
/* FIXME perform bus-specific reset */ regs->secret3 = 15;
while (regs->CNTR & GVP11_DMAC_BUSY)
;
regs->CNTR = 0;
regs->BANK = 0;
/* FIXME 2: shouldn't we no-op this function (return wdregs.SASR = &regs->SASR;
FAILED), and fall back to host reset function, wdregs.SCMD = &regs->SCMD;
wd33c93_host_reset ? */
spin_lock_irq(cmd->device->host->host_lock); hdata = shost_priv(instance);
wd33c93_host_reset(cmd); if (gvp11_xfer_mask)
spin_unlock_irq(cmd->device->host->host_lock); hdata->dma_xfer_mask = gvp11_xfer_mask;
else
hdata->dma_xfer_mask = default_dma_xfer_mask;
return SUCCESS; hdata->no_sync = 0xff;
} hdata->fast = 0;
hdata->dma_mode = CTRL_DMA;
/*
* Check for 14MHz SCSI clock
*/
epc = *(unsigned short *)(ZTWO_VADDR(address) + 0x8000);
wd33c93_init(instance, wdregs, dma_setup, dma_stop,
(epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10
: WD33C93_FS_12_15);
#define HOSTS_C error = request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED,
"GVP11 SCSI", instance);
if (error)
goto fail_irq;
#include "gvp11.h" regs->CNTR = GVP11_DMAC_INT_ENABLE;
static struct scsi_host_template driver_template = { error = scsi_add_host(instance, NULL);
.proc_name = "GVP11", if (error)
.name = "GVP Series II SCSI", goto fail_host;
.detect = gvp11_detect,
.release = gvp11_release,
.queuecommand = wd33c93_queuecommand,
.eh_abort_handler = wd33c93_abort,
.eh_bus_reset_handler = gvp11_bus_reset,
.eh_host_reset_handler = wd33c93_host_reset,
.can_queue = CAN_QUEUE,
.this_id = 7,
.sg_tablesize = SG_ALL,
.cmd_per_lun = CMD_PER_LUN,
.use_clustering = DISABLE_CLUSTERING
};
zorro_set_drvdata(z, instance);
scsi_scan_host(instance);
return 0;
#include "scsi_module.c" fail_host:
free_irq(IRQ_AMIGA_PORTS, instance);
fail_irq:
scsi_host_put(instance);
fail_check_or_alloc:
release_mem_region(address, 256);
return error;
}
int gvp11_release(struct Scsi_Host *instance) static void __devexit gvp11_remove(struct zorro_dev *z)
{ {
#ifdef MODULE struct Scsi_Host *instance = zorro_get_drvdata(z);
struct gvp11_scsiregs *regs = (struct gvp11_scsiregs *)(instance->base); struct gvp11_scsiregs *regs = (struct gvp11_scsiregs *)(instance->base);
regs->CNTR = 0; regs->CNTR = 0;
release_mem_region(ZTWO_PADDR(instance->base), 256); scsi_remove_host(instance);
free_irq(IRQ_AMIGA_PORTS, instance); free_irq(IRQ_AMIGA_PORTS, instance);
#endif scsi_host_put(instance);
return 1; release_mem_region(z->resource.start, 256);
}
/*
* This should (hopefully) be the correct way to identify
* all the different GVP SCSI controllers (except for the
* SERIES I though).
*/
static struct zorro_device_id gvp11_zorro_tbl[] __devinitdata = {
{ ZORRO_PROD_GVP_COMBO_030_R3_SCSI, ~0x00ffffff },
{ ZORRO_PROD_GVP_SERIES_II, ~0x00ffffff },
{ ZORRO_PROD_GVP_GFORCE_030_SCSI, ~0x01ffffff },
{ ZORRO_PROD_GVP_A530_SCSI, ~0x01ffffff },
{ ZORRO_PROD_GVP_COMBO_030_R4_SCSI, ~0x01ffffff },
{ ZORRO_PROD_GVP_A1291, ~0x07ffffff },
{ ZORRO_PROD_GVP_GFORCE_040_SCSI_1, ~0x07ffffff },
{ 0 }
};
MODULE_DEVICE_TABLE(zorro, gvp11_zorro_tbl);
static struct zorro_driver gvp11_driver = {
.name = "gvp11",
.id_table = gvp11_zorro_tbl,
.probe = gvp11_probe,
.remove = __devexit_p(gvp11_remove),
};
static int __init gvp11_init(void)
{
return zorro_register_driver(&gvp11_driver);
}
module_init(gvp11_init);
static void __exit gvp11_exit(void)
{
zorro_unregister_driver(&gvp11_driver);
} }
module_exit(gvp11_exit);
MODULE_DESCRIPTION("GVP Series II SCSI");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
#include <linux/types.h> #include <linux/types.h>
int gvp11_detect(struct scsi_host_template *);
int gvp11_release(struct Scsi_Host *);
#ifndef CMD_PER_LUN #ifndef CMD_PER_LUN
#define CMD_PER_LUN 2 #define CMD_PER_LUN 2
#endif #endif
...@@ -22,8 +19,6 @@ int gvp11_release(struct Scsi_Host *); ...@@ -22,8 +19,6 @@ int gvp11_release(struct Scsi_Host *);
#define CAN_QUEUE 16 #define CAN_QUEUE 16
#endif #endif
#ifndef HOSTS_C
/* /*
* if the transfer address ANDed with this results in a non-zero * if the transfer address ANDed with this results in a non-zero
* result, then we can't use DMA. * result, then we can't use DMA.
...@@ -54,6 +49,4 @@ struct gvp11_scsiregs { ...@@ -54,6 +49,4 @@ struct gvp11_scsiregs {
#define GVP11_DMAC_INT_ENABLE (1<<3) #define GVP11_DMAC_INT_ENABLE (1<<3)
#define GVP11_DMAC_DIR_WRITE (1<<4) #define GVP11_DMAC_DIR_WRITE (1<<4)
#endif /* else def HOSTS_C */
#endif /* GVP11_H */ #endif /* GVP11_H */
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