1 // SPDX-License-Identifier: GPL-2.0-only
3 * Detection routine for the NCR53c710 based MVME16x SCSI Controllers for Linux.
5 * Based on work by Alan Hourihane
7 * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
10 #include <linux/module.h>
11 #include <linux/blkdev.h>
12 #include <linux/device.h>
13 #include <linux/platform_device.h>
14 #include <linux/init.h>
15 #include <linux/interrupt.h>
16 #include <linux/slab.h>
17 #include <asm/mvme16xhw.h>
18 #include <scsi/scsi_host.h>
19 #include <scsi/scsi_device.h>
20 #include <scsi/scsi_transport.h>
21 #include <scsi/scsi_transport_spi.h>
25 MODULE_AUTHOR("Kars de Jong <jongk@linux-m68k.org>");
26 MODULE_DESCRIPTION("MVME16x NCR53C710 driver");
27 MODULE_LICENSE("GPL");
29 static struct scsi_host_template mvme16x_scsi_driver_template
= {
30 .name
= "MVME16x NCR53c710 SCSI",
31 .proc_name
= "MVME16x",
33 .module
= THIS_MODULE
,
36 static struct platform_device
*mvme16x_scsi_device
;
38 static int mvme16x_probe(struct platform_device
*dev
)
40 struct Scsi_Host
* host
= NULL
;
41 struct NCR_700_Host_Parameters
*hostdata
;
46 if (mvme16x_config
& MVME16x_CONFIG_NO_SCSICHIP
) {
47 printk(KERN_INFO
"mvme16x-scsi: detection disabled, "
48 "SCSI chip not present\n");
52 hostdata
= kzalloc(sizeof(struct NCR_700_Host_Parameters
), GFP_KERNEL
);
53 if (hostdata
== NULL
) {
54 printk(KERN_ERR
"mvme16x-scsi: "
55 "Failed to allocate host data\n");
59 /* Fill in the required pieces of hostdata */
60 hostdata
->base
= (void __iomem
*)0xfff47000UL
;
61 hostdata
->clock
= 50; /* XXX - depends on the CPU clock! */
62 hostdata
->chip710
= 1;
63 hostdata
->dmode_extra
= DMODE_FC2
;
64 hostdata
->dcntl_extra
= EA_710
;
65 hostdata
->ctest7_extra
= CTEST7_TT1
;
67 /* and register the chip */
68 host
= NCR_700_detect(&mvme16x_scsi_driver_template
, hostdata
,
71 printk(KERN_ERR
"mvme16x-scsi: No host detected; "
72 "board configuration problem?\n");
76 host
->base
= 0xfff47000UL
;
77 host
->irq
= MVME16x_IRQ_SCSI
;
78 if (request_irq(host
->irq
, NCR_700_intr
, 0, "mvme16x-scsi", host
)) {
79 printk(KERN_ERR
"mvme16x-scsi: request_irq failed\n");
83 /* Enable scsi chip ints */
85 volatile unsigned long v
;
87 /* Enable scsi interrupts at level 4 in PCCchip2 */
88 v
= in_be32(0xfff4202c);
89 v
= (v
& ~0xff) | 0x10 | 4;
90 out_be32(0xfff4202c, v
);
93 platform_set_drvdata(dev
, host
);
106 static void mvme16x_device_remove(struct platform_device
*dev
)
108 struct Scsi_Host
*host
= platform_get_drvdata(dev
);
109 struct NCR_700_Host_Parameters
*hostdata
= shost_priv(host
);
111 /* Disable scsi chip ints */
113 volatile unsigned long v
;
115 v
= in_be32(0xfff4202c);
117 out_be32(0xfff4202c, v
);
119 scsi_remove_host(host
);
120 NCR_700_release(host
);
122 free_irq(host
->irq
, host
);
125 static struct platform_driver mvme16x_scsi_driver
= {
127 .name
= "mvme16x-scsi",
129 .probe
= mvme16x_probe
,
130 .remove_new
= mvme16x_device_remove
,
133 static int __init
mvme16x_scsi_init(void)
137 err
= platform_driver_register(&mvme16x_scsi_driver
);
141 mvme16x_scsi_device
= platform_device_register_simple("mvme16x-scsi",
143 if (IS_ERR(mvme16x_scsi_device
)) {
144 platform_driver_unregister(&mvme16x_scsi_driver
);
145 return PTR_ERR(mvme16x_scsi_device
);
151 static void __exit
mvme16x_scsi_exit(void)
153 platform_device_unregister(mvme16x_scsi_device
);
154 platform_driver_unregister(&mvme16x_scsi_driver
);
157 module_init(mvme16x_scsi_init
);
158 module_exit(mvme16x_scsi_exit
);