Linux Audio

Check our new training course

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