1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* -*- mode: c; c-basic-offset: 8 -*- */
4 /* PARISC LASI driver for the 53c700 chip
6 * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com
7 **-----------------------------------------------------------------------------
10 **-----------------------------------------------------------------------------
14 * Many thanks to Richard Hirst <rhirst@linuxcare.com> for patiently
15 * debugging this driver on the parisc architecture and suggesting
16 * many improvements and bug fixes.
18 * Thanks also go to Linuxcare Inc. for providing several PARISC
19 * machines for me to debug the driver on.
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/init.h>
25 #include <linux/types.h>
26 #include <linux/stat.h>
28 #include <linux/blkdev.h>
29 #include <linux/ioport.h>
30 #include <linux/dma-mapping.h>
31 #include <linux/slab.h>
35 #include <asm/hardware.h>
36 #include <asm/parisc-device.h>
37 #include <asm/delay.h>
39 #include <scsi/scsi_host.h>
40 #include <scsi/scsi_device.h>
41 #include <scsi/scsi_transport.h>
42 #include <scsi/scsi_transport_spi.h>
46 MODULE_AUTHOR("James Bottomley");
47 MODULE_DESCRIPTION("lasi700 SCSI Driver");
48 MODULE_LICENSE("GPL");
50 #define LASI_700_SVERSION 0x00071
51 #define LASI_710_SVERSION 0x00082
53 #define LASI700_ID_TABLE { \
54 .hw_type = HPHW_FIO, \
55 .sversion = LASI_700_SVERSION, \
56 .hversion = HVERSION_ANY_ID, \
57 .hversion_rev = HVERSION_REV_ANY_ID, \
60 #define LASI710_ID_TABLE { \
61 .hw_type = HPHW_FIO, \
62 .sversion = LASI_710_SVERSION, \
63 .hversion = HVERSION_ANY_ID, \
64 .hversion_rev = HVERSION_REV_ANY_ID, \
67 #define LASI700_CLOCK 25
68 #define LASI710_CLOCK 40
69 #define LASI_SCSI_CORE_OFFSET 0x100
71 static const struct parisc_device_id lasi700_ids[] __initconst = {
77 static struct scsi_host_template lasi700_template = {
78 .name = "LASI SCSI 53c700",
79 .proc_name = "lasi700",
81 .module = THIS_MODULE,
83 MODULE_DEVICE_TABLE(parisc, lasi700_ids);
86 lasi700_probe(struct parisc_device *dev)
88 unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET;
89 struct NCR_700_Host_Parameters *hostdata;
90 struct Scsi_Host *host;
92 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
94 dev_printk(KERN_ERR, &dev->dev, "Failed to allocate host data\n");
98 hostdata->dev = &dev->dev;
99 dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
100 hostdata->base = ioremap(base, 0x100);
101 hostdata->differential = 0;
103 if (dev->id.sversion == LASI_700_SVERSION) {
104 hostdata->clock = LASI700_CLOCK;
105 hostdata->force_le_on_be = 1;
107 hostdata->clock = LASI710_CLOCK;
108 hostdata->force_le_on_be = 0;
109 hostdata->chip710 = 1;
110 hostdata->dmode_extra = DMODE_FC2;
111 hostdata->burst_length = 8;
114 host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev);
119 host->irq = dev->irq;
120 if(request_irq(dev->irq, NCR_700_intr, IRQF_SHARED, "lasi700", host)) {
121 printk(KERN_ERR "lasi700: request_irq failed!\n");
125 dev_set_drvdata(&dev->dev, host);
126 scsi_scan_host(host);
133 iounmap(hostdata->base);
139 lasi700_driver_remove(struct parisc_device *dev)
141 struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
142 struct NCR_700_Host_Parameters *hostdata =
143 (struct NCR_700_Host_Parameters *)host->hostdata[0];
145 scsi_remove_host(host);
146 NCR_700_release(host);
147 free_irq(host->irq, host);
148 iounmap(hostdata->base);
154 static struct parisc_driver lasi700_driver __refdata = {
156 .id_table = lasi700_ids,
157 .probe = lasi700_probe,
158 .remove = __exit_p(lasi700_driver_remove),
164 return register_parisc_driver(&lasi700_driver);
170 unregister_parisc_driver(&lasi700_driver);
173 module_init(lasi700_init);
174 module_exit(lasi700_exit);