blob: f23c4ca9a2ee334a89bd0d8a9354f988b64723c3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* -*- 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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/ioport.h>
42#include <linux/dma-mapping.h>
43
44#include <asm/page.h>
45#include <asm/pgtable.h>
46#include <asm/irq.h>
47#include <asm/hardware.h>
48#include <asm/parisc-device.h>
49#include <asm/delay.h>
50
51#include <scsi/scsi_host.h>
52#include <scsi/scsi_device.h>
53#include <scsi/scsi_transport.h>
54#include <scsi/scsi_transport_spi.h>
55
56#include "53c700.h"
57
58MODULE_AUTHOR("James Bottomley");
59MODULE_DESCRIPTION("lasi700 SCSI Driver");
60MODULE_LICENSE("GPL");
61
62#define LASI_700_SVERSION 0x00071
63#define LASI_710_SVERSION 0x00082
64
65#define LASI700_ID_TABLE { \
66 .hw_type = HPHW_FIO, \
67 .sversion = LASI_700_SVERSION, \
68 .hversion = HVERSION_ANY_ID, \
69 .hversion_rev = HVERSION_REV_ANY_ID, \
70}
71
72#define LASI710_ID_TABLE { \
73 .hw_type = HPHW_FIO, \
74 .sversion = LASI_710_SVERSION, \
75 .hversion = HVERSION_ANY_ID, \
76 .hversion_rev = HVERSION_REV_ANY_ID, \
77}
78
79#define LASI700_CLOCK 25
80#define LASI710_CLOCK 40
81#define LASI_SCSI_CORE_OFFSET 0x100
82
83static struct parisc_device_id lasi700_ids[] = {
84 LASI700_ID_TABLE,
85 LASI710_ID_TABLE,
86 { 0 }
87};
88
89static struct scsi_host_template lasi700_template = {
90 .name = "LASI SCSI 53c700",
91 .proc_name = "lasi700",
92 .this_id = 7,
93 .module = THIS_MODULE,
94};
95MODULE_DEVICE_TABLE(parisc, lasi700_ids);
96
97static int __init
98lasi700_probe(struct parisc_device *dev)
99{
Matthew Wilcox53f01bb2005-10-21 22:36:40 -0400100 unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 struct NCR_700_Host_Parameters *hostdata;
102 struct Scsi_Host *host;
103
Yoann Padioleaudd00cc42007-07-19 01:49:03 -0700104 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 if (!hostdata) {
Helge Deller7f384ce2009-01-13 21:14:51 +0100106 dev_printk(KERN_ERR, &dev->dev, "Failed to allocate host data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 return -ENOMEM;
108 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110 hostdata->dev = &dev->dev;
111 dma_set_mask(&dev->dev, DMA_32BIT_MASK);
Helge Deller5076c152006-03-27 12:52:15 -0700112 hostdata->base = ioremap_nocache(base, 0x100);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 hostdata->differential = 0;
114
115 if (dev->id.sversion == LASI_700_SVERSION) {
116 hostdata->clock = LASI700_CLOCK;
117 hostdata->force_le_on_be = 1;
118 } else {
119 hostdata->clock = LASI710_CLOCK;
120 hostdata->force_le_on_be = 0;
121 hostdata->chip710 = 1;
122 hostdata->dmode_extra = DMODE_FC2;
Thomas Bogendoerferf67a9c12006-12-25 21:30:08 +0100123 hostdata->burst_length = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 }
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev);
127 if (!host)
128 goto out_kfree;
129 host->this_id = 7;
56fece22005-04-03 03:57:48 -0600130 host->base = base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 host->irq = dev->irq;
Thomas Gleixner1d6f3592006-07-01 19:29:42 -0700132 if(request_irq(dev->irq, NCR_700_intr, IRQF_SHARED, "lasi700", host)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 printk(KERN_ERR "lasi700: request_irq failed!\n");
134 goto out_put_host;
135 }
136
137 dev_set_drvdata(&dev->dev, host);
138 scsi_scan_host(host);
139
140 return 0;
141
142 out_put_host:
143 scsi_host_put(host);
144 out_kfree:
145 iounmap(hostdata->base);
146 kfree(hostdata);
147 return -ENODEV;
148}
149
150static int __exit
151lasi700_driver_remove(struct parisc_device *dev)
152{
153 struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
154 struct NCR_700_Host_Parameters *hostdata =
155 (struct NCR_700_Host_Parameters *)host->hostdata[0];
156
157 scsi_remove_host(host);
158 NCR_700_release(host);
159 free_irq(host->irq, host);
160 iounmap(hostdata->base);
161 kfree(hostdata);
162
163 return 0;
164}
165
166static struct parisc_driver lasi700_driver = {
Matthew Wilcoxbdad1f82005-10-21 22:36:23 -0400167 .name = "lasi_scsi",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 .id_table = lasi700_ids,
169 .probe = lasi700_probe,
170 .remove = __devexit_p(lasi700_driver_remove),
171};
172
173static int __init
174lasi700_init(void)
175{
176 return register_parisc_driver(&lasi700_driver);
177}
178
179static void __exit
180lasi700_exit(void)
181{
182 unregister_parisc_driver(&lasi700_driver);
183}
184
185module_init(lasi700_init);
186module_exit(lasi700_exit);