blob: b0f5220ae23a8b62213551b8e5336fecd351286e [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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090033#include <linux/slab.h>
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010034#include <linux/stat.h>
35#include <linux/mm.h>
36#include <linux/blkdev.h>
37#include <linux/sched.h>
38#include <linux/ioport.h>
39#include <linux/dma-mapping.h>
40#include <linux/platform_device.h>
41
42#include <asm/page.h>
43#include <asm/pgtable.h>
44#include <asm/irq.h>
45#include <asm/delay.h>
46
47#include <scsi/scsi_host.h>
48#include <scsi/scsi_device.h>
49#include <scsi/scsi_transport.h>
50#include <scsi/scsi_transport_spi.h>
51
52#include "53c700.h"
53
Al Virod36b6912011-12-29 17:09:01 -050054MODULE_AUTHOR("Thomas Bogendörfer");
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010055MODULE_DESCRIPTION("SNI RM 53c710 SCSI Driver");
56MODULE_LICENSE("GPL");
Kay Sieversecc1241e2008-04-18 13:57:19 -070057MODULE_ALIAS("platform:snirm_53c710");
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010058
59#define SNIRM710_CLOCK 32
60
61static struct scsi_host_template snirm710_template = {
62 .name = "SNI RM SCSI 53c710",
63 .proc_name = "snirm_53c710",
64 .this_id = 7,
65 .module = THIS_MODULE,
66};
67
Greg Kroah-Hartman6f039792012-12-21 13:08:55 -080068static int snirm710_probe(struct platform_device *dev)
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010069{
70 unsigned long base;
71 struct NCR_700_Host_Parameters *hostdata;
72 struct Scsi_Host *host;
73 struct resource *res;
74
75 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
76 if (!res)
77 return -ENODEV;
78
79 base = res->start;
80 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
Thomas Bogendoerfer8ae7d252019-10-09 17:11:18 +020081 if (!hostdata)
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010082 return -ENOMEM;
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010083
84 hostdata->dev = &dev->dev;
Yang Hongyang284901a2009-04-06 19:01:15 -070085 dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
Thomas Bogendoerfer2da86582007-07-11 19:09:36 +020086 hostdata->base = ioremap_nocache(base, 0x100);
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +010087 hostdata->differential = 0;
88
89 hostdata->clock = SNIRM710_CLOCK;
90 hostdata->force_le_on_be = 1;
91 hostdata->chip710 = 1;
92 hostdata->burst_length = 4;
93
94 host = NCR_700_detect(&snirm710_template, hostdata, &dev->dev);
95 if (!host)
96 goto out_kfree;
97 host->this_id = 7;
98 host->base = base;
99 host->irq = platform_get_irq(dev, 0);
Thomas Gleixner2833bf62007-05-08 00:28:52 -0700100 if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) {
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +0100101 printk(KERN_ERR "snirm710: request_irq failed!\n");
102 goto out_put_host;
103 }
104
105 dev_set_drvdata(&dev->dev, host);
106 scsi_scan_host(host);
107
108 return 0;
109
110 out_put_host:
111 scsi_host_put(host);
112 out_kfree:
113 iounmap(hostdata->base);
114 kfree(hostdata);
115 return -ENODEV;
116}
117
118static int __exit snirm710_driver_remove(struct platform_device *dev)
119{
120 struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
121 struct NCR_700_Host_Parameters *hostdata =
122 (struct NCR_700_Host_Parameters *)host->hostdata[0];
123
124 scsi_remove_host(host);
125 NCR_700_release(host);
126 free_irq(host->irq, host);
127 iounmap(hostdata->base);
128 kfree(hostdata);
129
130 return 0;
131}
132
133static struct platform_driver snirm710_driver = {
134 .probe = snirm710_probe,
Greg Kroah-Hartman6f039792012-12-21 13:08:55 -0800135 .remove = snirm710_driver_remove,
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +0100136 .driver = {
137 .name = "snirm_53c710",
138 },
139};
140
141static int __init snirm710_init(void)
142{
Thomas Bogendoerfer2da86582007-07-11 19:09:36 +0200143 return platform_driver_register(&snirm710_driver);
Thomas Bogendoerferc27d85f2006-12-25 21:32:04 +0100144}
145
146static void __exit snirm710_exit(void)
147{
148 platform_driver_unregister(&snirm710_driver);
149}
150
151module_init(snirm710_init);
152module_exit(snirm710_exit);