Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
0004  *      Amiga Technologies A4000T SCSI controller.
0005  *
0006  * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
0007  * plus modifications of the 53c7xx.c driver to support the Amiga.
0008  *
0009  * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
0010  */
0011 
0012 #include <linux/module.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/init.h>
0015 #include <linux/interrupt.h>
0016 #include <linux/slab.h>
0017 #include <asm/amigahw.h>
0018 #include <asm/amigaints.h>
0019 #include <scsi/scsi_host.h>
0020 #include <scsi/scsi_transport_spi.h>
0021 
0022 #include "53c700.h"
0023 
0024 
0025 static struct scsi_host_template a4000t_scsi_driver_template = {
0026     .name       = "A4000T builtin SCSI",
0027     .proc_name  = "A4000t",
0028     .this_id    = 7,
0029     .module     = THIS_MODULE,
0030 };
0031 
0032 
0033 #define A4000T_SCSI_OFFSET  0x40
0034 
0035 static int __init amiga_a4000t_scsi_probe(struct platform_device *pdev)
0036 {
0037     struct resource *res;
0038     phys_addr_t scsi_addr;
0039     struct NCR_700_Host_Parameters *hostdata;
0040     struct Scsi_Host *host;
0041 
0042     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
0043     if (!res)
0044         return -ENODEV;
0045 
0046     if (!request_mem_region(res->start, resource_size(res),
0047                 "A4000T builtin SCSI"))
0048         return -EBUSY;
0049 
0050     hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters),
0051                GFP_KERNEL);
0052     if (!hostdata) {
0053         dev_err(&pdev->dev, "Failed to allocate host data\n");
0054         goto out_release;
0055     }
0056 
0057     scsi_addr = res->start + A4000T_SCSI_OFFSET;
0058 
0059     /* Fill in the required pieces of hostdata */
0060     hostdata->base = ZTWO_VADDR(scsi_addr);
0061     hostdata->clock = 50;
0062     hostdata->chip710 = 1;
0063     hostdata->dmode_extra = DMODE_FC2;
0064     hostdata->dcntl_extra = EA_710;
0065 
0066     /* and register the chip */
0067     host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata,
0068                   &pdev->dev);
0069     if (!host) {
0070         dev_err(&pdev->dev,
0071             "No host detected; board configuration problem?\n");
0072         goto out_free;
0073     }
0074 
0075     host->this_id = 7;
0076     host->base = scsi_addr;
0077     host->irq = IRQ_AMIGA_PORTS;
0078 
0079     if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi",
0080             host)) {
0081         dev_err(&pdev->dev, "request_irq failed\n");
0082         goto out_put_host;
0083     }
0084 
0085     platform_set_drvdata(pdev, host);
0086     scsi_scan_host(host);
0087     return 0;
0088 
0089  out_put_host:
0090     scsi_host_put(host);
0091  out_free:
0092     kfree(hostdata);
0093  out_release:
0094     release_mem_region(res->start, resource_size(res));
0095     return -ENODEV;
0096 }
0097 
0098 static int __exit amiga_a4000t_scsi_remove(struct platform_device *pdev)
0099 {
0100     struct Scsi_Host *host = platform_get_drvdata(pdev);
0101     struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
0102     struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
0103 
0104     scsi_remove_host(host);
0105     NCR_700_release(host);
0106     kfree(hostdata);
0107     free_irq(host->irq, host);
0108     release_mem_region(res->start, resource_size(res));
0109     return 0;
0110 }
0111 
0112 static struct platform_driver amiga_a4000t_scsi_driver = {
0113     .remove = __exit_p(amiga_a4000t_scsi_remove),
0114     .driver   = {
0115         .name   = "amiga-a4000t-scsi",
0116     },
0117 };
0118 
0119 module_platform_driver_probe(amiga_a4000t_scsi_driver, amiga_a4000t_scsi_probe);
0120 
0121 MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / "
0122           "Kars de Jong <jongk@linux-m68k.org>");
0123 MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
0124 MODULE_LICENSE("GPL");
0125 MODULE_ALIAS("platform:amiga-a4000t-scsi");