0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <linux/kernel.h>
0022 #include <linux/module.h>
0023 #include <linux/init.h>
0024 #include <linux/types.h>
0025 #include <linux/stat.h>
0026 #include <linux/mm.h>
0027 #include <linux/blkdev.h>
0028 #include <linux/ioport.h>
0029 #include <linux/dma-mapping.h>
0030 #include <linux/slab.h>
0031
0032 #include <asm/page.h>
0033 #include <asm/irq.h>
0034 #include <asm/hardware.h>
0035 #include <asm/parisc-device.h>
0036 #include <asm/delay.h>
0037
0038 #include <scsi/scsi_host.h>
0039 #include <scsi/scsi_device.h>
0040 #include <scsi/scsi_transport.h>
0041 #include <scsi/scsi_transport_spi.h>
0042
0043 #include "53c700.h"
0044
0045 MODULE_AUTHOR("James Bottomley");
0046 MODULE_DESCRIPTION("lasi700 SCSI Driver");
0047 MODULE_LICENSE("GPL");
0048
0049 #define LASI_700_SVERSION 0x00071
0050 #define LASI_710_SVERSION 0x00082
0051
0052 #define LASI700_ID_TABLE { \
0053 .hw_type = HPHW_FIO, \
0054 .sversion = LASI_700_SVERSION, \
0055 .hversion = HVERSION_ANY_ID, \
0056 .hversion_rev = HVERSION_REV_ANY_ID, \
0057 }
0058
0059 #define LASI710_ID_TABLE { \
0060 .hw_type = HPHW_FIO, \
0061 .sversion = LASI_710_SVERSION, \
0062 .hversion = HVERSION_ANY_ID, \
0063 .hversion_rev = HVERSION_REV_ANY_ID, \
0064 }
0065
0066 #define LASI700_CLOCK 25
0067 #define LASI710_CLOCK 40
0068 #define LASI_SCSI_CORE_OFFSET 0x100
0069
0070 static const struct parisc_device_id lasi700_ids[] __initconst = {
0071 LASI700_ID_TABLE,
0072 LASI710_ID_TABLE,
0073 { 0 }
0074 };
0075
0076 static struct scsi_host_template lasi700_template = {
0077 .name = "LASI SCSI 53c700",
0078 .proc_name = "lasi700",
0079 .this_id = 7,
0080 .module = THIS_MODULE,
0081 };
0082 MODULE_DEVICE_TABLE(parisc, lasi700_ids);
0083
0084 static int __init
0085 lasi700_probe(struct parisc_device *dev)
0086 {
0087 unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET;
0088 struct NCR_700_Host_Parameters *hostdata;
0089 struct Scsi_Host *host;
0090
0091 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
0092 if (!hostdata) {
0093 dev_printk(KERN_ERR, &dev->dev, "Failed to allocate host data\n");
0094 return -ENOMEM;
0095 }
0096
0097 hostdata->dev = &dev->dev;
0098 dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
0099 hostdata->base = ioremap(base, 0x100);
0100 hostdata->differential = 0;
0101
0102 if (dev->id.sversion == LASI_700_SVERSION) {
0103 hostdata->clock = LASI700_CLOCK;
0104 hostdata->force_le_on_be = 1;
0105 } else {
0106 hostdata->clock = LASI710_CLOCK;
0107 hostdata->force_le_on_be = 0;
0108 hostdata->chip710 = 1;
0109 hostdata->dmode_extra = DMODE_FC2;
0110 hostdata->burst_length = 8;
0111 }
0112
0113 host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev);
0114 if (!host)
0115 goto out_kfree;
0116 host->this_id = 7;
0117 host->base = base;
0118 host->irq = dev->irq;
0119 if(request_irq(dev->irq, NCR_700_intr, IRQF_SHARED, "lasi700", host)) {
0120 printk(KERN_ERR "lasi700: request_irq failed!\n");
0121 goto out_put_host;
0122 }
0123
0124 dev_set_drvdata(&dev->dev, host);
0125 scsi_scan_host(host);
0126
0127 return 0;
0128
0129 out_put_host:
0130 scsi_host_put(host);
0131 out_kfree:
0132 iounmap(hostdata->base);
0133 kfree(hostdata);
0134 return -ENODEV;
0135 }
0136
0137 static void __exit
0138 lasi700_driver_remove(struct parisc_device *dev)
0139 {
0140 struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
0141 struct NCR_700_Host_Parameters *hostdata =
0142 (struct NCR_700_Host_Parameters *)host->hostdata[0];
0143
0144 scsi_remove_host(host);
0145 NCR_700_release(host);
0146 free_irq(host->irq, host);
0147 iounmap(hostdata->base);
0148 kfree(hostdata);
0149 }
0150
0151 static struct parisc_driver lasi700_driver __refdata = {
0152 .name = "lasi_scsi",
0153 .id_table = lasi700_ids,
0154 .probe = lasi700_probe,
0155 .remove = __exit_p(lasi700_driver_remove),
0156 };
0157
0158 static int __init
0159 lasi700_init(void)
0160 {
0161 return register_parisc_driver(&lasi700_driver);
0162 }
0163
0164 static void __exit
0165 lasi700_exit(void)
0166 {
0167 unregister_parisc_driver(&lasi700_driver);
0168 }
0169
0170 module_init(lasi700_init);
0171 module_exit(lasi700_exit);