]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/scsi/bvme6000_scsi.c
iwlwifi: don't include iwl-dev.h from iwl-devtrace.h
[mirror_ubuntu-artful-kernel.git] / drivers / scsi / bvme6000_scsi.c
CommitLineData
8276b58a
KJ
1/*
2 * Detection routine for the NCR53c710 based BVME6000 SCSI Controllers for Linux.
3 *
4 * Based on work by Alan Hourihane and Kars de Jong
5 *
6 * Rewritten to use 53c700.c by Richard Hirst <richard@sleepie.demon.co.uk>
7 */
8
9#include <linux/module.h>
10#include <linux/blkdev.h>
11#include <linux/device.h>
12#include <linux/platform_device.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <asm/bvme6000hw.h>
16#include <scsi/scsi_host.h>
17#include <scsi/scsi_device.h>
18#include <scsi/scsi_transport.h>
19#include <scsi/scsi_transport_spi.h>
20
21#include "53c700.h"
22
23MODULE_AUTHOR("Richard Hirst <richard@sleepie.demon.co.uk>");
24MODULE_DESCRIPTION("BVME6000 NCR53C710 driver");
25MODULE_LICENSE("GPL");
26
27static struct scsi_host_template bvme6000_scsi_driver_template = {
28 .name = "BVME6000 NCR53c710 SCSI",
29 .proc_name = "BVME6000",
30 .this_id = 7,
31 .module = THIS_MODULE,
32};
33
34static struct platform_device *bvme6000_scsi_device;
35
36static __devinit int
7a192ec3 37bvme6000_probe(struct platform_device *dev)
8276b58a 38{
bbfbbbc1 39 struct Scsi_Host *host;
8276b58a
KJ
40 struct NCR_700_Host_Parameters *hostdata;
41
42 if (!MACH_IS_BVME6000)
43 goto out;
44
bbfbbbc1
MK
45 hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
46 if (!hostdata) {
8276b58a
KJ
47 printk(KERN_ERR "bvme6000-scsi: "
48 "Failed to allocate host data\n");
49 goto out;
50 }
8276b58a
KJ
51
52 /* Fill in the required pieces of hostdata */
53 hostdata->base = (void __iomem *)BVME_NCR53C710_BASE;
54 hostdata->clock = 40; /* XXX - depends on the CPU clock! */
55 hostdata->chip710 = 1;
56 hostdata->dmode_extra = DMODE_FC2;
57 hostdata->dcntl_extra = EA_710;
58 hostdata->ctest7_extra = CTEST7_TT1;
59
60 /* and register the chip */
e5779a58
GU
61 host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata,
62 &dev->dev);
8276b58a
KJ
63 if (!host) {
64 printk(KERN_ERR "bvme6000-scsi: No host detected; "
65 "board configuration problem?\n");
66 goto out_free;
67 }
68 host->base = BVME_NCR53C710_BASE;
69 host->this_id = 7;
70 host->irq = BVME_IRQ_SCSI;
71 if (request_irq(BVME_IRQ_SCSI, NCR_700_intr, 0, "bvme6000-scsi",
72 host)) {
73 printk(KERN_ERR "bvme6000-scsi: request_irq failed\n");
74 goto out_put_host;
75 }
76
7a192ec3 77 platform_set_drvdata(dev, host);
8276b58a
KJ
78 scsi_scan_host(host);
79
80 return 0;
81
82 out_put_host:
83 scsi_host_put(host);
84 out_free:
85 kfree(hostdata);
86 out:
87 return -ENODEV;
88}
89
90static __devexit int
7a192ec3 91bvme6000_device_remove(struct platform_device *dev)
8276b58a 92{
7a192ec3 93 struct Scsi_Host *host = platform_get_drvdata(dev);
8276b58a
KJ
94 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
95
96 scsi_remove_host(host);
97 NCR_700_release(host);
98 kfree(hostdata);
99 free_irq(host->irq, host);
100
101 return 0;
102}
103
7a192ec3
ML
104static struct platform_driver bvme6000_scsi_driver = {
105 .driver = {
106 .name = "bvme6000-scsi",
107 .owner = THIS_MODULE,
108 },
109 .probe = bvme6000_probe,
110 .remove = __devexit_p(bvme6000_device_remove),
8276b58a
KJ
111};
112
113static int __init bvme6000_scsi_init(void)
114{
115 int err;
116
7a192ec3 117 err = platform_driver_register(&bvme6000_scsi_driver);
96249cf9 118 if (err)
8276b58a
KJ
119 return err;
120
121 bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
122 -1, NULL, 0);
123 if (IS_ERR(bvme6000_scsi_device)) {
7a192ec3 124 platform_driver_unregister(&bvme6000_scsi_driver);
8276b58a
KJ
125 return PTR_ERR(bvme6000_scsi_device);
126 }
127
128 return 0;
129}
130
131static void __exit bvme6000_scsi_exit(void)
132{
133 platform_device_unregister(bvme6000_scsi_device);
7a192ec3 134 platform_driver_unregister(&bvme6000_scsi_driver);
8276b58a
KJ
135}
136
137module_init(bvme6000_scsi_init);
138module_exit(bvme6000_scsi_exit);