Linux Audio

Check our new training course

Loading...
v3.1
  1/*
  2 * Detection routine for the NCR53c710 based BVME6000 SCSI Controllers for Linux.
  3 *
  4 * Based on work by Alan Hourihane and Kars de Jong
  5 *
  6 * Rewritten to use 53c700.c by Richard Hirst <richard@sleepie.demon.co.uk>
  7 */
  8
  9#include <linux/module.h>
 10#include <linux/blkdev.h>
 11#include <linux/device.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/bvme6000hw.h>
 17#include <scsi/scsi_host.h>
 18#include <scsi/scsi_device.h>
 19#include <scsi/scsi_transport.h>
 20#include <scsi/scsi_transport_spi.h>
 21
 22#include "53c700.h"
 23
 24MODULE_AUTHOR("Richard Hirst <richard@sleepie.demon.co.uk>");
 25MODULE_DESCRIPTION("BVME6000 NCR53C710 driver");
 26MODULE_LICENSE("GPL");
 27
 28static struct scsi_host_template bvme6000_scsi_driver_template = {
 29	.name			= "BVME6000 NCR53c710 SCSI",
 30	.proc_name		= "BVME6000",
 31	.this_id		= 7,
 32	.module			= THIS_MODULE,
 33};
 34
 35static struct platform_device *bvme6000_scsi_device;
 36
 37static __devinit int
 38bvme6000_probe(struct platform_device *dev)
 39{
 40	struct Scsi_Host *host;
 41	struct NCR_700_Host_Parameters *hostdata;
 42
 43	if (!MACH_IS_BVME6000)
 44		goto out;
 45
 46	hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
 47	if (!hostdata) {
 48		printk(KERN_ERR "bvme6000-scsi: "
 49				"Failed to allocate host data\n");
 50		goto out;
 51	}
 52
 53	/* Fill in the required pieces of hostdata */
 54	hostdata->base = (void __iomem *)BVME_NCR53C710_BASE;
 55	hostdata->clock = 40;	/* XXX - depends on the CPU clock! */
 56	hostdata->chip710 = 1;
 57	hostdata->dmode_extra = DMODE_FC2;
 58	hostdata->dcntl_extra = EA_710;
 59	hostdata->ctest7_extra = CTEST7_TT1;
 60
 61	/* and register the chip */
 62	host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata,
 63			      &dev->dev);
 64	if (!host) {
 65		printk(KERN_ERR "bvme6000-scsi: No host detected; "
 66				"board configuration problem?\n");
 67		goto out_free;
 68	}
 69	host->base = BVME_NCR53C710_BASE;
 70	host->this_id = 7;
 71	host->irq = BVME_IRQ_SCSI;
 72	if (request_irq(BVME_IRQ_SCSI, NCR_700_intr, 0, "bvme6000-scsi",
 73			host)) {
 74		printk(KERN_ERR "bvme6000-scsi: request_irq failed\n");
 75		goto out_put_host;
 76	}
 77
 78	platform_set_drvdata(dev, host);
 79	scsi_scan_host(host);
 80
 81	return 0;
 82
 83 out_put_host:
 84	scsi_host_put(host);
 85 out_free:
 86	kfree(hostdata);
 87 out:
 88	return -ENODEV;
 89}
 90
 91static __devexit int
 92bvme6000_device_remove(struct platform_device *dev)
 93{
 94	struct Scsi_Host *host = platform_get_drvdata(dev);
 95	struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
 96
 97	scsi_remove_host(host);
 98	NCR_700_release(host);
 99	kfree(hostdata);
100	free_irq(host->irq, host);
101
102	return 0;
103}
104
105static struct platform_driver bvme6000_scsi_driver = {
106	.driver = {
107		.name		= "bvme6000-scsi",
108		.owner		= THIS_MODULE,
109	},
110	.probe		= bvme6000_probe,
111	.remove		= __devexit_p(bvme6000_device_remove),
112};
113
114static int __init bvme6000_scsi_init(void)
115{
116	int err;
117
118	err = platform_driver_register(&bvme6000_scsi_driver);
119	if (err)
120		return err;
121
122	bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
123							       -1, NULL, 0);
124	if (IS_ERR(bvme6000_scsi_device)) {
125		platform_driver_unregister(&bvme6000_scsi_driver);
126		return PTR_ERR(bvme6000_scsi_device);
127	}
128
129	return 0;
130}
131
132static void __exit bvme6000_scsi_exit(void)
133{
134	platform_device_unregister(bvme6000_scsi_device);
135	platform_driver_unregister(&bvme6000_scsi_driver);
136}
137
138module_init(bvme6000_scsi_init);
139module_exit(bvme6000_scsi_exit);
v3.5.6
  1/*
  2 * Detection routine for the NCR53c710 based BVME6000 SCSI Controllers for Linux.
  3 *
  4 * Based on work by Alan Hourihane and Kars de Jong
  5 *
  6 * Rewritten to use 53c700.c by Richard Hirst <richard@sleepie.demon.co.uk>
  7 */
  8
  9#include <linux/module.h>
 10#include <linux/blkdev.h>
 11#include <linux/device.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/bvme6000hw.h>
 17#include <scsi/scsi_host.h>
 18#include <scsi/scsi_device.h>
 19#include <scsi/scsi_transport.h>
 20#include <scsi/scsi_transport_spi.h>
 21
 22#include "53c700.h"
 23
 24MODULE_AUTHOR("Richard Hirst <richard@sleepie.demon.co.uk>");
 25MODULE_DESCRIPTION("BVME6000 NCR53C710 driver");
 26MODULE_LICENSE("GPL");
 27
 28static struct scsi_host_template bvme6000_scsi_driver_template = {
 29	.name			= "BVME6000 NCR53c710 SCSI",
 30	.proc_name		= "BVME6000",
 31	.this_id		= 7,
 32	.module			= THIS_MODULE,
 33};
 34
 35static struct platform_device *bvme6000_scsi_device;
 36
 37static __devinit int
 38bvme6000_probe(struct platform_device *dev)
 39{
 40	struct Scsi_Host *host;
 41	struct NCR_700_Host_Parameters *hostdata;
 42
 43	if (!MACH_IS_BVME6000)
 44		goto out;
 45
 46	hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
 47	if (!hostdata) {
 48		printk(KERN_ERR "bvme6000-scsi: "
 49				"Failed to allocate host data\n");
 50		goto out;
 51	}
 52
 53	/* Fill in the required pieces of hostdata */
 54	hostdata->base = (void __iomem *)BVME_NCR53C710_BASE;
 55	hostdata->clock = 40;	/* XXX - depends on the CPU clock! */
 56	hostdata->chip710 = 1;
 57	hostdata->dmode_extra = DMODE_FC2;
 58	hostdata->dcntl_extra = EA_710;
 59	hostdata->ctest7_extra = CTEST7_TT1;
 60
 61	/* and register the chip */
 62	host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata,
 63			      &dev->dev);
 64	if (!host) {
 65		printk(KERN_ERR "bvme6000-scsi: No host detected; "
 66				"board configuration problem?\n");
 67		goto out_free;
 68	}
 69	host->base = BVME_NCR53C710_BASE;
 70	host->this_id = 7;
 71	host->irq = BVME_IRQ_SCSI;
 72	if (request_irq(BVME_IRQ_SCSI, NCR_700_intr, 0, "bvme6000-scsi",
 73			host)) {
 74		printk(KERN_ERR "bvme6000-scsi: request_irq failed\n");
 75		goto out_put_host;
 76	}
 77
 78	platform_set_drvdata(dev, host);
 79	scsi_scan_host(host);
 80
 81	return 0;
 82
 83 out_put_host:
 84	scsi_host_put(host);
 85 out_free:
 86	kfree(hostdata);
 87 out:
 88	return -ENODEV;
 89}
 90
 91static __devexit int
 92bvme6000_device_remove(struct platform_device *dev)
 93{
 94	struct Scsi_Host *host = platform_get_drvdata(dev);
 95	struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
 96
 97	scsi_remove_host(host);
 98	NCR_700_release(host);
 99	kfree(hostdata);
100	free_irq(host->irq, host);
101
102	return 0;
103}
104
105static struct platform_driver bvme6000_scsi_driver = {
106	.driver = {
107		.name		= "bvme6000-scsi",
108		.owner		= THIS_MODULE,
109	},
110	.probe		= bvme6000_probe,
111	.remove		= __devexit_p(bvme6000_device_remove),
112};
113
114static int __init bvme6000_scsi_init(void)
115{
116	int err;
117
118	err = platform_driver_register(&bvme6000_scsi_driver);
119	if (err)
120		return err;
121
122	bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
123							       -1, NULL, 0);
124	if (IS_ERR(bvme6000_scsi_device)) {
125		platform_driver_unregister(&bvme6000_scsi_driver);
126		return PTR_ERR(bvme6000_scsi_device);
127	}
128
129	return 0;
130}
131
132static void __exit bvme6000_scsi_exit(void)
133{
134	platform_device_unregister(bvme6000_scsi_device);
135	platform_driver_unregister(&bvme6000_scsi_driver);
136}
137
138module_init(bvme6000_scsi_init);
139module_exit(bvme6000_scsi_exit);