aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lasi700.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/scsi/lasi700.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/scsi/lasi700.c')
-rw-r--r--drivers/scsi/lasi700.c189
1 files changed, 189 insertions, 0 deletions
diff --git a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c
new file mode 100644
index 000000000000..29f250c80b98
--- /dev/null
+++ b/drivers/scsi/lasi700.c
@@ -0,0 +1,189 @@
1/* -*- mode: c; c-basic-offset: 8 -*- */
2
3/* PARISC LASI driver for the 53c700 chip
4 *
5 * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com
6**-----------------------------------------------------------------------------
7**
8** This program is free software; you can redistribute it and/or modify
9** it under the terms of the GNU General Public License as published by
10** the Free Software Foundation; either version 2 of the License, or
11** (at your option) any later version.
12**
13** This program is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** GNU General Public License for more details.
17**
18** You should have received a copy of the GNU General Public License
19** along with this program; if not, write to the Free Software
20** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21**
22**-----------------------------------------------------------------------------
23 */
24
25/*
26 * Many thanks to Richard Hirst <rhirst@linuxcare.com> for patiently
27 * debugging this driver on the parisc architecture and suggesting
28 * many improvements and bug fixes.
29 *
30 * Thanks also go to Linuxcare Inc. for providing several PARISC
31 * machines for me to debug the driver on.
32 */
33
34#include <linux/kernel.h>
35#include <linux/module.h>
36#include <linux/init.h>
37#include <linux/types.h>
38#include <linux/stat.h>
39#include <linux/mm.h>
40#include <linux/blkdev.h>
41#include <linux/sched.h>
42#include <linux/ioport.h>
43#include <linux/dma-mapping.h>
44
45#include <asm/page.h>
46#include <asm/pgtable.h>
47#include <asm/irq.h>
48#include <asm/hardware.h>
49#include <asm/parisc-device.h>
50#include <asm/delay.h>
51
52#include <scsi/scsi_host.h>
53#include <scsi/scsi_device.h>
54#include <scsi/scsi_transport.h>
55#include <scsi/scsi_transport_spi.h>
56
57#include "53c700.h"
58
59MODULE_AUTHOR("James Bottomley");
60MODULE_DESCRIPTION("lasi700 SCSI Driver");
61MODULE_LICENSE("GPL");
62
63#define LASI_700_SVERSION 0x00071
64#define LASI_710_SVERSION 0x00082
65
66#define LASI700_ID_TABLE { \
67 .hw_type = HPHW_FIO, \
68 .sversion = LASI_700_SVERSION, \
69 .hversion = HVERSION_ANY_ID, \
70 .hversion_rev = HVERSION_REV_ANY_ID, \
71}
72
73#define LASI710_ID_TABLE { \
74 .hw_type = HPHW_FIO, \
75 .sversion = LASI_710_SVERSION, \
76 .hversion = HVERSION_ANY_ID, \
77 .hversion_rev = HVERSION_REV_ANY_ID, \
78}
79
80#define LASI700_CLOCK 25
81#define LASI710_CLOCK 40
82#define LASI_SCSI_CORE_OFFSET 0x100
83
84static struct parisc_device_id lasi700_ids[] = {
85 LASI700_ID_TABLE,
86 LASI710_ID_TABLE,
87 { 0 }
88};
89
90static struct scsi_host_template lasi700_template = {
91 .name = "LASI SCSI 53c700",
92 .proc_name = "lasi700",
93 .this_id = 7,
94 .module = THIS_MODULE,
95};
96MODULE_DEVICE_TABLE(parisc, lasi700_ids);
97
98static int __init
99lasi700_probe(struct parisc_device *dev)
100{
101 unsigned long base = dev->hpa + LASI_SCSI_CORE_OFFSET;
102 struct NCR_700_Host_Parameters *hostdata;
103 struct Scsi_Host *host;
104
105 hostdata = kmalloc(sizeof(*hostdata), GFP_KERNEL);
106 if (!hostdata) {
107 printk(KERN_ERR "%s: Failed to allocate host data\n",
108 dev->dev.bus_id);
109 return -ENOMEM;
110 }
111 memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
112
113 hostdata->dev = &dev->dev;
114 dma_set_mask(&dev->dev, DMA_32BIT_MASK);
115 hostdata->base = ioremap(base, 0x100);
116 hostdata->differential = 0;
117
118 if (dev->id.sversion == LASI_700_SVERSION) {
119 hostdata->clock = LASI700_CLOCK;
120 hostdata->force_le_on_be = 1;
121 } else {
122 hostdata->clock = LASI710_CLOCK;
123 hostdata->force_le_on_be = 0;
124 hostdata->chip710 = 1;
125 hostdata->dmode_extra = DMODE_FC2;
126 }
127
128 NCR_700_set_mem_mapped(hostdata);
129
130 host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev);
131 if (!host)
132 goto out_kfree;
133 host->this_id = 7;
134 host->irq = dev->irq;
135 if(request_irq(dev->irq, NCR_700_intr, SA_SHIRQ, "lasi700", host)) {
136 printk(KERN_ERR "lasi700: request_irq failed!\n");
137 goto out_put_host;
138 }
139
140 dev_set_drvdata(&dev->dev, host);
141 scsi_scan_host(host);
142
143 return 0;
144
145 out_put_host:
146 scsi_host_put(host);
147 out_kfree:
148 iounmap(hostdata->base);
149 kfree(hostdata);
150 return -ENODEV;
151}
152
153static int __exit
154lasi700_driver_remove(struct parisc_device *dev)
155{
156 struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
157 struct NCR_700_Host_Parameters *hostdata =
158 (struct NCR_700_Host_Parameters *)host->hostdata[0];
159
160 scsi_remove_host(host);
161 NCR_700_release(host);
162 free_irq(host->irq, host);
163 iounmap(hostdata->base);
164 kfree(hostdata);
165
166 return 0;
167}
168
169static struct parisc_driver lasi700_driver = {
170 .name = "Lasi SCSI",
171 .id_table = lasi700_ids,
172 .probe = lasi700_probe,
173 .remove = __devexit_p(lasi700_driver_remove),
174};
175
176static int __init
177lasi700_init(void)
178{
179 return register_parisc_driver(&lasi700_driver);
180}
181
182static void __exit
183lasi700_exit(void)
184{
185 unregister_parisc_driver(&lasi700_driver);
186}
187
188module_init(lasi700_init);
189module_exit(lasi700_exit);