ia64/kvm: compilation fix. export account_system_vtime.
[pv_ops_mirror.git] / drivers / scsi / mvme16x_scsi.c
blobb264b499d982203e00134e19f1aa80c41014c750
1 /*
2 * Detection routine for the NCR53c710 based MVME16x SCSI Controllers for Linux.
4 * Based on work by Alan Hourihane
6 * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
7 */
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/mvme16xhw.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>
21 #include "53c700.h"
23 MODULE_AUTHOR("Kars de Jong <jongk@linux-m68k.org>");
24 MODULE_DESCRIPTION("MVME16x NCR53C710 driver");
25 MODULE_LICENSE("GPL");
27 static struct scsi_host_template mvme16x_scsi_driver_template = {
28 .name = "MVME16x NCR53c710 SCSI",
29 .proc_name = "MVME16x",
30 .this_id = 7,
31 .module = THIS_MODULE,
34 static struct platform_device *mvme16x_scsi_device;
36 static __devinit int
37 mvme16x_probe(struct device *dev)
39 struct Scsi_Host * host = NULL;
40 struct NCR_700_Host_Parameters *hostdata;
42 if (!MACH_IS_MVME16x)
43 goto out;
45 if (mvme16x_config & MVME16x_CONFIG_NO_SCSICHIP) {
46 printk(KERN_INFO "mvme16x-scsi: detection disabled, "
47 "SCSI chip not present\n");
48 goto out;
51 hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
52 if (hostdata == NULL) {
53 printk(KERN_ERR "mvme16x-scsi: "
54 "Failed to allocate host data\n");
55 goto out;
58 /* Fill in the required pieces of hostdata */
59 hostdata->base = (void __iomem *)0xfff47000UL;
60 hostdata->clock = 50; /* XXX - depends on the CPU clock! */
61 hostdata->chip710 = 1;
62 hostdata->dmode_extra = DMODE_FC2;
63 hostdata->dcntl_extra = EA_710;
64 hostdata->ctest7_extra = CTEST7_TT1;
66 /* and register the chip */
67 host = NCR_700_detect(&mvme16x_scsi_driver_template, hostdata, dev);
68 if (!host) {
69 printk(KERN_ERR "mvme16x-scsi: No host detected; "
70 "board configuration problem?\n");
71 goto out_free;
73 host->this_id = 7;
74 host->base = 0xfff47000UL;
75 host->irq = MVME16x_IRQ_SCSI;
76 if (request_irq(host->irq, NCR_700_intr, 0, "mvme16x-scsi", host)) {
77 printk(KERN_ERR "mvme16x-scsi: request_irq failed\n");
78 goto out_put_host;
81 /* Enable scsi chip ints */
83 volatile unsigned long v;
85 /* Enable scsi interrupts at level 4 in PCCchip2 */
86 v = in_be32(0xfff4202c);
87 v = (v & ~0xff) | 0x10 | 4;
88 out_be32(0xfff4202c, v);
91 dev_set_drvdata(dev, host);
92 scsi_scan_host(host);
94 return 0;
96 out_put_host:
97 scsi_host_put(host);
98 out_free:
99 kfree(hostdata);
100 out:
101 return -ENODEV;
104 static __devexit int
105 mvme16x_device_remove(struct device *dev)
107 struct Scsi_Host *host = dev_get_drvdata(dev);
108 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
110 /* Disable scsi chip ints */
112 volatile unsigned long v;
114 v = in_be32(0xfff4202c);
115 v &= ~0x10;
116 out_be32(0xfff4202c, v);
118 scsi_remove_host(host);
119 NCR_700_release(host);
120 kfree(hostdata);
121 free_irq(host->irq, host);
123 return 0;
126 static struct device_driver mvme16x_scsi_driver = {
127 .name = "mvme16x-scsi",
128 .bus = &platform_bus_type,
129 .probe = mvme16x_probe,
130 .remove = __devexit_p(mvme16x_device_remove),
133 static int __init mvme16x_scsi_init(void)
135 int err;
137 err = driver_register(&mvme16x_scsi_driver);
138 if (err)
139 return err;
141 mvme16x_scsi_device = platform_device_register_simple("mvme16x-scsi",
142 -1, NULL, 0);
143 if (IS_ERR(mvme16x_scsi_device)) {
144 driver_unregister(&mvme16x_scsi_driver);
145 return PTR_ERR(mvme16x_scsi_device);
148 return 0;
151 static void __exit mvme16x_scsi_exit(void)
153 platform_device_unregister(mvme16x_scsi_device);
154 driver_unregister(&mvme16x_scsi_driver);
157 module_init(mvme16x_scsi_init);
158 module_exit(mvme16x_scsi_exit);