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>
34 #include <asm/pgtable.h>
36 #include <asm/hardware.h>
37 #include <asm/parisc-device.h>
38 #include <asm/delay.h>
40 #include <scsi/scsi_host.h>
41 #include <scsi/scsi_device.h>
42 #include <scsi/scsi_transport.h>
43 #include <scsi/scsi_transport_spi.h>
47 MODULE_AUTHOR("James Bottomley");
48 MODULE_DESCRIPTION("lasi700 SCSI Driver");
49 MODULE_LICENSE("GPL");
51 #define LASI_700_SVERSION 0x00071
52 #define LASI_710_SVERSION 0x00082
54 #define LASI700_ID_TABLE { \
55 .hw_type = HPHW_FIO, \
56 .sversion = LASI_700_SVERSION, \
57 .hversion = HVERSION_ANY_ID, \
58 .hversion_rev = HVERSION_REV_ANY_ID, \
61 #define LASI710_ID_TABLE { \
62 .hw_type = HPHW_FIO, \
63 .sversion = LASI_710_SVERSION, \
64 .hversion = HVERSION_ANY_ID, \
65 .hversion_rev = HVERSION_REV_ANY_ID, \
68 #define LASI700_CLOCK 25
69 #define LASI710_CLOCK 40
70 #define LASI_SCSI_CORE_OFFSET 0x100
72 static const struct parisc_device_id lasi700_ids
[] __initconst
= {
78 static struct scsi_host_template lasi700_template
= {
79 .name
= "LASI SCSI 53c700",
80 .proc_name
= "lasi700",
82 .module
= THIS_MODULE
,
84 MODULE_DEVICE_TABLE(parisc
, lasi700_ids
);
87 lasi700_probe(struct parisc_device
*dev
)
89 unsigned long base
= dev
->hpa
.start
+ LASI_SCSI_CORE_OFFSET
;
90 struct NCR_700_Host_Parameters
*hostdata
;
91 struct Scsi_Host
*host
;
93 hostdata
= kzalloc(sizeof(*hostdata
), GFP_KERNEL
);
95 dev_printk(KERN_ERR
, &dev
->dev
, "Failed to allocate host data\n");
99 hostdata
->dev
= &dev
->dev
;
100 dma_set_mask(&dev
->dev
, DMA_BIT_MASK(32));
101 hostdata
->base
= ioremap(base
, 0x100);
102 hostdata
->differential
= 0;
104 if (dev
->id
.sversion
== LASI_700_SVERSION
) {
105 hostdata
->clock
= LASI700_CLOCK
;
106 hostdata
->force_le_on_be
= 1;
108 hostdata
->clock
= LASI710_CLOCK
;
109 hostdata
->force_le_on_be
= 0;
110 hostdata
->chip710
= 1;
111 hostdata
->dmode_extra
= DMODE_FC2
;
112 hostdata
->burst_length
= 8;
115 host
= NCR_700_detect(&lasi700_template
, hostdata
, &dev
->dev
);
120 host
->irq
= dev
->irq
;
121 if(request_irq(dev
->irq
, NCR_700_intr
, IRQF_SHARED
, "lasi700", host
)) {
122 printk(KERN_ERR
"lasi700: request_irq failed!\n");
126 dev_set_drvdata(&dev
->dev
, host
);
127 scsi_scan_host(host
);
134 iounmap(hostdata
->base
);
140 lasi700_driver_remove(struct parisc_device
*dev
)
142 struct Scsi_Host
*host
= dev_get_drvdata(&dev
->dev
);
143 struct NCR_700_Host_Parameters
*hostdata
=
144 (struct NCR_700_Host_Parameters
*)host
->hostdata
[0];
146 scsi_remove_host(host
);
147 NCR_700_release(host
);
148 free_irq(host
->irq
, host
);
149 iounmap(hostdata
->base
);
155 static struct parisc_driver lasi700_driver __refdata
= {
157 .id_table
= lasi700_ids
,
158 .probe
= lasi700_probe
,
159 .remove
= __exit_p(lasi700_driver_remove
),
165 return register_parisc_driver(&lasi700_driver
);
171 unregister_parisc_driver(&lasi700_driver
);
174 module_init(lasi700_init
);
175 module_exit(lasi700_exit
);