blob: 2bbef4c45a0d64404c11dfc1ae1fbc0b071d0c21 [file] [log] [blame]
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +01001/* -*- mode: c; c-basic-offset: 8 -*- */
2
3/* SNI RM driver
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 * Based on lasi700.c
27 */
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/types.h>
33#include <linux/stat.h>
34#include <linux/mm.h>
35#include <linux/blkdev.h>
36#include <linux/sched.h>
37#include <linux/ioport.h>
38#include <linux/dma-mapping.h>
39#include <linux/platform_device.h>
40
41#include <asm/page.h>
42#include <asm/pgtable.h>
43#include <asm/irq.h>
44#include <asm/delay.h>
45
46#include <scsi/scsi_host.h>
47#include <scsi/scsi_device.h>
48#include <scsi/scsi_transport.h>
49#include <scsi/scsi_transport_spi.h>
50
51#include "53c700.h"
52
53MODULE_AUTHOR("Thomas Bogendörfer");
54MODULE_DESCRIPTION("SNI RM 53c710 SCSI Driver");
55MODULE_LICENSE("GPL");
Kay Sieversecc12412008-04-18 13:57:19 -070056MODULE_ALIAS("platform:snirm_53c710");
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010057
58#define SNIRM710_CLOCK 32
59
60static struct scsi_host_template snirm710_template = {
61 .name = "SNI RM SCSI 53c710",
62 .proc_name = "snirm_53c710",
63 .this_id = 7,
64 .module = THIS_MODULE,
65};
66
67static int __init snirm710_probe(struct platform_device *dev)
68{
69 unsigned long base;
70 struct NCR_700_Host_Parameters *hostdata;
71 struct Scsi_Host *host;
72 struct resource *res;
73
74 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
75 if (!res)
76 return -ENODEV;
77
78 base = res->start;
79 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
80 if (!hostdata) {
81 printk(KERN_ERR "%s: Failed to allocate host data\n",
82 dev->dev.bus_id);
83 return -ENOMEM;
84 }
85
86 hostdata->dev = &dev->dev;
87 dma_set_mask(&dev->dev, DMA_32BIT_MASK);
Thomas Bogendoerfer2da86582007-07-11 19:09:36 +020088 hostdata->base = ioremap_nocache(base, 0x100);
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010089 hostdata->differential = 0;
90
91 hostdata->clock = SNIRM710_CLOCK;
92 hostdata->force_le_on_be = 1;
93 hostdata->chip710 = 1;
94 hostdata->burst_length = 4;
95
96 host = NCR_700_detect(&snirm710_template, hostdata, &dev->dev);
97 if (!host)
98 goto out_kfree;
99 host->this_id = 7;
100 host->base = base;
101 host->irq = platform_get_irq(dev, 0);
Thomas Gleixner2833bf62007-05-08 00:28:52 -0700102 if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) {
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +0100103 printk(KERN_ERR "snirm710: request_irq failed!\n");
104 goto out_put_host;
105 }
106
107 dev_set_drvdata(&dev->dev, host);
108 scsi_scan_host(host);
109
110 return 0;
111
112 out_put_host:
113 scsi_host_put(host);
114 out_kfree:
115 iounmap(hostdata->base);
116 kfree(hostdata);
117 return -ENODEV;
118}
119
120static int __exit snirm710_driver_remove(struct platform_device *dev)
121{
122 struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
123 struct NCR_700_Host_Parameters *hostdata =
124 (struct NCR_700_Host_Parameters *)host->hostdata[0];
125
126 scsi_remove_host(host);
127 NCR_700_release(host);
128 free_irq(host->irq, host);
129 iounmap(hostdata->base);
130 kfree(hostdata);
131
132 return 0;
133}
134
135static struct platform_driver snirm710_driver = {
136 .probe = snirm710_probe,
137 .remove = __devexit_p(snirm710_driver_remove),
138 .driver = {
139 .name = "snirm_53c710",
Kay Sieversecc12412008-04-18 13:57:19 -0700140 .owner = THIS_MODULE,
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +0100141 },
142};
143
144static int __init snirm710_init(void)
145{
Thomas Bogendoerfer2da86582007-07-11 19:09:36 +0200146 return platform_driver_register(&snirm710_driver);
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +0100147}
148
149static void __exit snirm710_exit(void)
150{
151 platform_driver_unregister(&snirm710_driver);
152}
153
154module_init(snirm710_init);
155module_exit(snirm710_exit);