1 // SPDX-License-Identifier: GPL-2.0-only
3 * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
4 * Amiga Technologies A4000T SCSI controller.
6 * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
7 * plus modifications of the 53c7xx.c driver to support the Amiga.
9 * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
12 #include <linux/module.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/amigahw.h>
18 #include <asm/amigaints.h>
19 #include <scsi/scsi_host.h>
20 #include <scsi/scsi_transport_spi.h>
25 static struct scsi_host_template a4000t_scsi_driver_template
= {
26 .name
= "A4000T builtin SCSI",
27 .proc_name
= "A4000t",
29 .module
= THIS_MODULE
,
33 #define A4000T_SCSI_OFFSET 0x40
35 static int __init
amiga_a4000t_scsi_probe(struct platform_device
*pdev
)
38 phys_addr_t scsi_addr
;
39 struct NCR_700_Host_Parameters
*hostdata
;
40 struct Scsi_Host
*host
;
42 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
46 if (!request_mem_region(res
->start
, resource_size(res
),
47 "A4000T builtin SCSI"))
50 hostdata
= kzalloc(sizeof(struct NCR_700_Host_Parameters
),
53 dev_err(&pdev
->dev
, "Failed to allocate host data\n");
57 scsi_addr
= res
->start
+ A4000T_SCSI_OFFSET
;
59 /* Fill in the required pieces of hostdata */
60 hostdata
->base
= ZTWO_VADDR(scsi_addr
);
62 hostdata
->chip710
= 1;
63 hostdata
->dmode_extra
= DMODE_FC2
;
64 hostdata
->dcntl_extra
= EA_710
;
66 /* and register the chip */
67 host
= NCR_700_detect(&a4000t_scsi_driver_template
, hostdata
,
71 "No host detected; board configuration problem?\n");
76 host
->base
= scsi_addr
;
77 host
->irq
= IRQ_AMIGA_PORTS
;
79 if (request_irq(host
->irq
, NCR_700_intr
, IRQF_SHARED
, "a4000t-scsi",
81 dev_err(&pdev
->dev
, "request_irq failed\n");
85 platform_set_drvdata(pdev
, host
);
94 release_mem_region(res
->start
, resource_size(res
));
98 static void __exit
amiga_a4000t_scsi_remove(struct platform_device
*pdev
)
100 struct Scsi_Host
*host
= platform_get_drvdata(pdev
);
101 struct NCR_700_Host_Parameters
*hostdata
= shost_priv(host
);
102 struct resource
*res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
104 scsi_remove_host(host
);
105 NCR_700_release(host
);
107 free_irq(host
->irq
, host
);
108 release_mem_region(res
->start
, resource_size(res
));
112 * amiga_a4000t_scsi_remove() lives in .exit.text. For drivers registered via
113 * module_platform_driver_probe() this is ok because they cannot get unbound at
114 * runtime. So mark the driver struct with __refdata to prevent modpost
115 * triggering a section mismatch warning.
117 static struct platform_driver amiga_a4000t_scsi_driver __refdata
= {
118 .remove_new
= __exit_p(amiga_a4000t_scsi_remove
),
120 .name
= "amiga-a4000t-scsi",
124 module_platform_driver_probe(amiga_a4000t_scsi_driver
, amiga_a4000t_scsi_probe
);
126 MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / "
127 "Kars de Jong <jongk@linux-m68k.org>");
128 MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
129 MODULE_LICENSE("GPL");
130 MODULE_ALIAS("platform:amiga-a4000t-scsi");