Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *		Amiga Technologies A4000T SCSI controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * plus modifications of the 53c7xx.c driver to support the Amiga.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/amigahw.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/amigaints.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <scsi/scsi_transport_spi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "53c700.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static struct scsi_host_template a4000t_scsi_driver_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	.name		= "A4000T builtin SCSI",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	.proc_name	= "A4000t",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	.this_id	= 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	.module		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define A4000T_SCSI_OFFSET	0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static int __init amiga_a4000t_scsi_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	phys_addr_t scsi_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	struct NCR_700_Host_Parameters *hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct Scsi_Host *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	if (!res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	if (!request_mem_region(res->start, resource_size(res),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 				"A4000T builtin SCSI"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 			   GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	if (!hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		dev_err(&pdev->dev, "Failed to allocate host data\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		goto out_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	scsi_addr = res->start + A4000T_SCSI_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	/* Fill in the required pieces of hostdata */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	hostdata->base = ZTWO_VADDR(scsi_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	hostdata->clock = 50;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	hostdata->chip710 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	hostdata->dmode_extra = DMODE_FC2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	hostdata->dcntl_extra = EA_710;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	/* and register the chip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			      &pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	if (!host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			"No host detected; board configuration problem?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	host->this_id = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	host->base = scsi_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	host->irq = IRQ_AMIGA_PORTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			host)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		dev_err(&pdev->dev, "request_irq failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		goto out_put_host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	platform_set_drvdata(pdev, host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	scsi_scan_host(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  out_put_host:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	scsi_host_put(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	kfree(hostdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  out_release:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	release_mem_region(res->start, resource_size(res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static int __exit amiga_a4000t_scsi_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct Scsi_Host *host = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	scsi_remove_host(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	NCR_700_release(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	kfree(hostdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	free_irq(host->irq, host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	release_mem_region(res->start, resource_size(res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static struct platform_driver amiga_a4000t_scsi_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	.remove = __exit_p(amiga_a4000t_scsi_remove),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	.driver   = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		.name	= "amiga-a4000t-scsi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) module_platform_driver_probe(amiga_a4000t_scsi_driver, amiga_a4000t_scsi_probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	      "Kars de Jong <jongk@linux-m68k.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) MODULE_ALIAS("platform:amiga-a4000t-scsi");