Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.git] / drivers / scsi / arm / ecoscsi.c
1 #define AUTOSENSE
2 /* #define PSEUDO_DMA */
3
4 /*
5  * EcoSCSI Generic NCR5380 driver
6  *
7  * Copyright 1995, Russell King
8  *
9  * ALPHA RELEASE 1.
10  *
11  * For more information, please consult
12  *
13  * NCR 5380 Family
14  * SCSI Protocol Controller
15  * Databook
16  *
17  * NCR Microelectronics
18  * 1635 Aeroplaza Drive
19  * Colorado Springs, CO 80916
20  * 1+ (719) 578-3400
21  * 1+ (800) 334-5454
22  */
23
24 #include <linux/module.h>
25 #include <linux/signal.h>
26 #include <linux/ioport.h>
27 #include <linux/delay.h>
28 #include <linux/init.h>
29 #include <linux/blkdev.h>
30
31 #include <asm/io.h>
32 #include <asm/system.h>
33
34 #include "../scsi.h"
35 #include <scsi/scsi_host.h>
36
37 #define priv(host)                      ((struct NCR5380_hostdata *)(host)->hostdata)
38
39 #define NCR5380_local_declare()         void __iomem *_base
40 #define NCR5380_setup(host)             _base = priv(host)->base
41
42 #define NCR5380_read(reg)               ({ writeb(reg | 8, _base); readb(_base + 4); })
43 #define NCR5380_write(reg, value)       ({ writeb(reg | 8, _base); writeb(value, _base + 4); })
44
45 #define NCR5380_intr                    ecoscsi_intr
46 #define NCR5380_queue_command           ecoscsi_queue_command
47 #define NCR5380_proc_info               ecoscsi_proc_info
48
49 #define NCR5380_implementation_fields   \
50         void __iomem *base
51
52 #include "../NCR5380.h"
53
54 #define ECOSCSI_PUBLIC_RELEASE 1
55
56 /*
57  * Function : ecoscsi_setup(char *str, int *ints)
58  *
59  * Purpose : LILO command line initialization of the overrides array,
60  *
61  * Inputs : str - unused, ints - array of integer parameters with ints[0]
62  *      equal to the number of ints.
63  *
64  */
65
66 void ecoscsi_setup(char *str, int *ints)
67 {
68 }
69
70 const char * ecoscsi_info (struct Scsi_Host *spnt)
71 {
72         return "";
73 }
74
75 #define BOARD_NORMAL    0
76 #define BOARD_NCR53C400 1
77
78 #include "../NCR5380.c"
79
80 static struct scsi_host_template ecoscsi_template =  {
81         .module         = THIS_MODULE,
82         .name           = "Serial Port EcoSCSI NCR5380",
83         .proc_name      = "ecoscsi",
84         .info           = ecoscsi_info,
85         .queuecommand   = ecoscsi_queue_command,
86         .eh_abort_handler       = NCR5380_abort,
87         .eh_bus_reset_handler   = NCR5380_bus_reset,
88         .can_queue      = 16,
89         .this_id        = 7,
90         .sg_tablesize   = SG_ALL,
91         .cmd_per_lun    = 2,
92         .use_clustering = DISABLE_CLUSTERING
93 };
94
95 static struct Scsi_Host *host;
96
97 static int __init ecoscsi_init(void)
98 {
99         void __iomem *_base;
100         int ret;
101
102         if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) {
103                 ret = -EBUSY;
104                 goto out;
105         }
106
107         _base = ioremap(0x33a0000, 4096);
108         if (!_base) {
109                 ret = -ENOMEM;
110                 goto out_release;
111         }
112
113         NCR5380_write(MODE_REG, 0x20);          /* Is it really SCSI? */
114         if (NCR5380_read(MODE_REG) != 0x20)     /* Write to a reg.    */
115                 goto out_unmap;
116
117         NCR5380_write(MODE_REG, 0x00);          /* it back.           */
118         if (NCR5380_read(MODE_REG) != 0x00)
119                 goto out_unmap;
120
121         host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata));
122         if (!host) {
123                 ret = -ENOMEM;
124                 goto out_unmap;
125         }
126
127         priv(host)->base = _base;
128         host->irq = IRQ_NONE;
129
130         NCR5380_init(host, 0);
131
132         printk("scsi%d: at port 0x%08lx irqs disabled", host->host_no, host->io_port);
133         printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
134                 host->can_queue, host->cmd_per_lun, ECOSCSI_PUBLIC_RELEASE);
135         printk("\nscsi%d:", host->host_no);
136         NCR5380_print_options(host);
137         printk("\n");
138
139         scsi_add_host(host, NULL); /* XXX handle failure */
140         scsi_scan_host(host);
141         return 0;
142
143  out_unmap:
144         iounmap(_base);
145  out_release:
146         release_mem_region(0x33a0000, 4096);
147  out:
148         return ret;
149 }
150
151 static void __exit ecoscsi_exit(void)
152 {
153         scsi_remove_host(host);
154         NCR5380_exit(host);
155         scsi_host_put(host);
156         release_mem_region(0x33a0000, 4096);
157         return 0;
158 }
159
160 module_init(ecoscsi_init);
161 module_exit(ecoscsi_exit);
162
163 MODULE_AUTHOR("Russell King");
164 MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines");
165 MODULE_LICENSE("GPL");
166