Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  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 <asm/amigahw.h>
 16 #include <asm/amigaints.h>
 17 #include <scsi/scsi_host.h>
 18 #include <scsi/scsi_transport_spi.h>
 19 
 20 #include "53c700.h"
 21 
 22 MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>");
 23 MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
 24 MODULE_LICENSE("GPL");
 25 
 26 
 27 static struct scsi_host_template a4000t_scsi_driver_template = {
 28         .name           = "A4000T builtin SCSI",
 29         .proc_name      = "A4000t",
 30         .this_id        = 7,
 31         .module         = THIS_MODULE,
 32 };
 33 
 34 static struct platform_device *a4000t_scsi_device;
 35 
 36 #define A4000T_SCSI_ADDR 0xdd0040
 37 
 38 static int __devinit a4000t_probe(struct device *dev)
 39 {
 40         struct Scsi_Host *host;
 41         struct NCR_700_Host_Parameters *hostdata;
 42 
 43         if (!(MACH_IS_AMIGA && AMIGAHW_PRESENT(A4000_SCSI)))
 44                 goto out;
 45 
 46         if (!request_mem_region(A4000T_SCSI_ADDR, 0x1000,
 47                                 "A4000T builtin SCSI"))
 48                 goto out;
 49 
 50         hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
 51         if (!hostdata) {
 52                 printk(KERN_ERR "a4000t-scsi: Failed to allocate host data\n");
 53                 goto out_release;
 54         }
 55 
 56         /* Fill in the required pieces of hostdata */
 57         hostdata->base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR);
 58         hostdata->clock = 50;
 59         hostdata->chip710 = 1;
 60         hostdata->dmode_extra = DMODE_FC2;
 61         hostdata->dcntl_extra = EA_710;
 62 
 63         /* and register the chip */
 64         host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, dev);
 65         if (!host) {
 66                 printk(KERN_ERR "a4000t-scsi: No host detected; "
 67                                 "board configuration problem?\n");
 68                 goto out_free;
 69         }
 70 
 71         host->this_id = 7;
 72         host->base = A4000T_SCSI_ADDR;
 73         host->irq = IRQ_AMIGA_PORTS;
 74 
 75         if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi",
 76                         host)) {
 77                 printk(KERN_ERR "a4000t-scsi: request_irq failed\n");
 78                 goto out_put_host;
 79         }
 80 
 81         dev_set_drvdata(dev, host);
 82         scsi_scan_host(host);
 83 
 84         return 0;
 85 
 86  out_put_host:
 87         scsi_host_put(host);
 88  out_free:
 89         kfree(hostdata);
 90  out_release:
 91         release_mem_region(A4000T_SCSI_ADDR, 0x1000);
 92  out:
 93         return -ENODEV;
 94 }
 95 
 96 static __devexit int a4000t_device_remove(struct device *dev)
 97 {
 98         struct Scsi_Host *host = dev_get_drvdata(dev);
 99         struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
100 
101         scsi_remove_host(host);
102 
103         NCR_700_release(host);
104         kfree(hostdata);
105         free_irq(host->irq, host);
106         release_mem_region(A4000T_SCSI_ADDR, 0x1000);
107 
108         return 0;
109 }
110 
111 static struct device_driver a4000t_scsi_driver = {
112         .name   = "a4000t-scsi",
113         .bus    = &platform_bus_type,
114         .probe  = a4000t_probe,
115         .remove = __devexit_p(a4000t_device_remove),
116 };
117 
118 static int __init a4000t_scsi_init(void)
119 {
120         int err;
121 
122         err = driver_register(&a4000t_scsi_driver);
123         if (err)
124                 return err;
125 
126         a4000t_scsi_device = platform_device_register_simple("a4000t-scsi",
127                         -1, NULL, 0);
128         if (IS_ERR(a4000t_scsi_device)) {
129                 driver_unregister(&a4000t_scsi_driver);
130                 return PTR_ERR(a4000t_scsi_device);
131         }
132 
133         return err;
134 }
135 
136 static void __exit a4000t_scsi_exit(void)
137 {
138         platform_device_unregister(a4000t_scsi_device);
139         driver_unregister(&a4000t_scsi_driver);
140 }
141 
142 module_init(a4000t_scsi_init);
143 module_exit(a4000t_scsi_exit);
144 
  This page was automatically generated by the LXR engine.