blob: c48a73a0f517966ac2986e0c9e1897b717ec7eb8 [file] [log] [blame]
Thomas Gleixner74ba9202019-05-20 09:19:02 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/* -*- mode: c; c-basic-offset: 8 -*- */
3
4/* PARISC LASI driver for the 53c700 chip
5 *
6 * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com
7**-----------------------------------------------------------------------------
8**
Linus Torvalds1da177e2005-04-16 15:20:36 -07009**
10**-----------------------------------------------------------------------------
11 */
12
13/*
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.
17 *
18 * Thanks also go to Linuxcare Inc. for providing several PARISC
19 * machines for me to debug the driver on.
20 */
21
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>
27#include <linux/mm.h>
28#include <linux/blkdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/ioport.h>
30#include <linux/dma-mapping.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090031#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#include <asm/page.h>
34#include <asm/pgtable.h>
35#include <asm/irq.h>
36#include <asm/hardware.h>
37#include <asm/parisc-device.h>
38#include <asm/delay.h>
39
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>
44
45#include "53c700.h"
46
47MODULE_AUTHOR("James Bottomley");
48MODULE_DESCRIPTION("lasi700 SCSI Driver");
49MODULE_LICENSE("GPL");
50
51#define LASI_700_SVERSION 0x00071
52#define LASI_710_SVERSION 0x00082
53
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, \
59}
60
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, \
66}
67
68#define LASI700_CLOCK 25
69#define LASI710_CLOCK 40
70#define LASI_SCSI_CORE_OFFSET 0x100
71
Helge Deller6ade2a02017-08-21 21:57:39 +020072static const struct parisc_device_id lasi700_ids[] __initconst = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 LASI700_ID_TABLE,
74 LASI710_ID_TABLE,
75 { 0 }
76};
77
78static struct scsi_host_template lasi700_template = {
79 .name = "LASI SCSI 53c700",
80 .proc_name = "lasi700",
81 .this_id = 7,
82 .module = THIS_MODULE,
83};
84MODULE_DEVICE_TABLE(parisc, lasi700_ids);
85
86static int __init
87lasi700_probe(struct parisc_device *dev)
88{
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040089 unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 struct NCR_700_Host_Parameters *hostdata;
91 struct Scsi_Host *host;
92
Yoann Padioleaudd00cc42007-07-19 01:49:03 -070093 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 if (!hostdata) {
Helge Deller7f384ce2009-01-13 21:14:51 +010095 dev_printk(KERN_ERR, &dev->dev, "Failed to allocate host data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 return -ENOMEM;
97 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99 hostdata->dev = &dev->dev;
Yang Hongyang284901a2009-04-06 19:01:15 -0700100 dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
Christoph Hellwig4bdc0d62020-01-06 09:43:50 +0100101 hostdata->base = ioremap(base, 0x100);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 hostdata->differential = 0;
103
104 if (dev->id.sversion == LASI_700_SVERSION) {
105 hostdata->clock = LASI700_CLOCK;
106 hostdata->force_le_on_be = 1;
107 } else {
108 hostdata->clock = LASI710_CLOCK;
109 hostdata->force_le_on_be = 0;
110 hostdata->chip710 = 1;
111 hostdata->dmode_extra = DMODE_FC2;
Thomas Bogendoerferf67a9c12006-12-25 21:30:08 +0100112 hostdata->burst_length = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 }
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev);
116 if (!host)
117 goto out_kfree;
118 host->this_id = 7;
56fece22005-04-03 03:57:48 -0600119 host->base = base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 host->irq = dev->irq;
Thomas Gleixner1d6f3592006-07-01 19:29:42 -0700121 if(request_irq(dev->irq, NCR_700_intr, IRQF_SHARED, "lasi700", host)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 printk(KERN_ERR "lasi700: request_irq failed!\n");
123 goto out_put_host;
124 }
125
126 dev_set_drvdata(&dev->dev, host);
127 scsi_scan_host(host);
128
129 return 0;
130
131 out_put_host:
132 scsi_host_put(host);
133 out_kfree:
134 iounmap(hostdata->base);
135 kfree(hostdata);
136 return -ENODEV;
137}
138
139static int __exit
140lasi700_driver_remove(struct parisc_device *dev)
141{
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];
145
146 scsi_remove_host(host);
147 NCR_700_release(host);
148 free_irq(host->irq, host);
149 iounmap(hostdata->base);
150 kfree(hostdata);
151
152 return 0;
153}
154
Helge Deller6ade2a02017-08-21 21:57:39 +0200155static struct parisc_driver lasi700_driver __refdata = {
Matthew Wilcoxbdad1f82005-10-21 22:36:23 -0400156 .name = "lasi_scsi",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 .id_table = lasi700_ids,
158 .probe = lasi700_probe,
Helge Deller6ade2a02017-08-21 21:57:39 +0200159 .remove = __exit_p(lasi700_driver_remove),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160};
161
162static int __init
163lasi700_init(void)
164{
165 return register_parisc_driver(&lasi700_driver);
166}
167
168static void __exit
169lasi700_exit(void)
170{
171 unregister_parisc_driver(&lasi700_driver);
172}
173
174module_init(lasi700_init);
175module_exit(lasi700_exit);