5 * Trantor T128/T128F/T228 driver
6 * Note : architecturally, the T100 and T130 are different and won't
9 * Copyright 1993, Drew Eckhardt
11 * (Unix and Linux consulting and custom programming)
15 * DISTRIBUTION RELEASE 3.
17 * For more information, please consult
19 * Trantor Systems, Ltd.
20 * T128/T128F/T228 SCSI Host Adapter
21 * Hardware Specifications
23 * Trantor Systems, Ltd.
26 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910
31 * SCSI Protocol Controller
34 * NCR Microelectronics
35 * 1635 Aeroplaza Drive
36 * Colorado Springs, CO 80916
43 * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
44 * for commands that return with a CHECK CONDITION status.
46 * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
47 * increase compared to polled I/O.
49 * PARITY - enable parity checking. Not supported.
51 * SCSI2 - enable support for SCSI-II tagged queueing. Untested.
54 * UNSAFE - leave interrupts enabled during pseudo-DMA transfers. You
55 * only really want to use this if you're having a problem with
56 * dropped characters during high speed communications, and even
57 * then, you're going to be better off twiddling with transfersize.
59 * USLEEP - enable support for devices that don't disconnect. Untested.
61 * The card is detected and initialized in one of several ways :
62 * 1. Autoprobe (default) - since the board is memory mapped,
63 * a BIOS signature is scanned for to locate the registers.
64 * An interrupt is triggered to autoprobe for the interrupt
67 * 2. With command line overrides - t128=address,irq may be
68 * used on the LILO command line to override the defaults.
70 * 3. With the T128_OVERRIDE compile time define. This is
71 * specified as an array of address, irq tuples. Ie, for
72 * one board at the default 0xcc000 address, IRQ5, I could say
73 * -DT128_OVERRIDE={{0xcc000, 5}}
75 * Note that if the override methods are used, place holders must
76 * be specified for other boards in the system.
78 * T128/T128F jumper/dipswitch settings (note : on my sample, the switches
79 * were epoxy'd shut, meaning I couldn't change the 0xcc000 base address) :
81 * T128 Sw7 Sw8 Sw6 = 0ws Sw5 = boot
82 * T128F Sw6 Sw7 Sw5 = 0ws Sw4 = boot Sw8 = floppy disable
90 * There is a 12 pin jumper block, jp1, numbered as follows :
91 * T128 (JP1) T128F (J5)
92 * 2 4 6 8 10 12 11 9 7 5 3 1
93 * 1 3 5 7 9 11 12 10 8 6 4 2
109 #include <asm/system.h>
110 #include <linux/signal.h>
111 #include <linux/sched.h>
113 #include <linux/blkdev.h>
114 #include <linux/interrupt.h>
115 #include <linux/stat.h>
116 #include <linux/init.h>
117 #include <linux/module.h>
118 #include <linux/delay.h>
121 #include <scsi/scsi_host.h>
123 #define AUTOPROBE_IRQ
126 static struct override {
127 unsigned long address;
131 [] __initdata = T128_OVERRIDE;
133 [4] __initdata = {{0, IRQ_AUTO}, {0, IRQ_AUTO},
134 {0 ,IRQ_AUTO}, {0, IRQ_AUTO}};
137 #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
140 unsigned int address;
142 } bases[] __initdata = {
143 { 0xcc000, 0}, { 0xc8000, 0}, { 0xdc000, 0}, { 0xd8000, 0}
146 #define NO_BASES (sizeof (bases) / sizeof (struct base))
148 static struct signature {
151 } signatures[] __initdata = {
152 {"TSROM: SCSI BIOS, Version 1.12", 0x36},
155 #define NO_SIGNATURES (sizeof (signatures) / sizeof (struct signature))
158 * Function : t128_setup(char *str, int *ints)
160 * Purpose : LILO command line initialization of the overrides array,
162 * Inputs : str - unused, ints - array of integer parameters with ints[0]
163 * equal to the number of ints.
167 void __init t128_setup(char *str, int *ints){
168 static int commandline_current = 0;
171 printk("t128_setup : usage t128=address,irq\n");
173 if (commandline_current < NO_OVERRIDES) {
174 overrides[commandline_current].address = ints[1];
175 overrides[commandline_current].irq = ints[2];
176 for (i = 0; i < NO_BASES; ++i)
177 if (bases[i].address == ints[1]) {
181 ++commandline_current;
186 * Function : int t128_detect(Scsi_Host_Template * tpnt)
188 * Purpose : detects and initializes T128,T128F, or T228 controllers
189 * that were autoprobed, overridden on the LILO command line,
190 * or specified at compile time.
192 * Inputs : tpnt - template for this SCSI adapter.
194 * Returns : 1 if a host adapter was found, 0 if not.
198 int __init t128_detect(Scsi_Host_Template * tpnt){
199 static int current_override = 0, current_base = 0;
200 struct Scsi_Host *instance;
205 tpnt->proc_name = "t128";
206 tpnt->proc_info = &t128_proc_info;
208 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
212 if (overrides[current_override].address) {
213 base = overrides[current_override].address;
214 p = ioremap(bases[current_base].address, 0x2000);
218 for (; !base && (current_base < NO_BASES); ++current_base) {
219 #if (TDEBUG & TDEBUG_INIT)
220 printk("scsi-t128 : probing address %08x\n", bases[current_base].address);
222 if (bases[current_base].noauto)
224 p = ioremap(bases[current_base].address, 0x2000);
227 for (sig = 0; sig < NO_SIGNATURES; ++sig)
228 if (check_signature(p + signatures[sig].offset,
229 signatures[sig].string,
230 strlen(signatures[sig].string))) {
231 base = bases[current_base].address;
232 #if (TDEBUG & TDEBUG_INIT)
233 printk("scsi-t128 : detected board.\n");
240 #if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
241 printk("scsi-t128 : base = %08x\n", (unsigned int) base);
248 instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
252 instance->base = base;
253 ((struct NCR5380_hostdata *)instance->hostdata)->base = p;
255 NCR5380_init(instance, 0);
257 if (overrides[current_override].irq != IRQ_AUTO)
258 instance->irq = overrides[current_override].irq;
260 instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
262 if (instance->irq != SCSI_IRQ_NONE)
263 if (request_irq(instance->irq, t128_intr, SA_INTERRUPT, "t128", instance)) {
264 printk("scsi%d : IRQ%d not free, interrupts disabled\n",
265 instance->host_no, instance->irq);
266 instance->irq = SCSI_IRQ_NONE;
269 if (instance->irq == SCSI_IRQ_NONE) {
270 printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
271 printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
274 #if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
275 printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
278 printk("scsi%d : at 0x%08lx", instance->host_no, instance->base);
279 if (instance->irq == SCSI_IRQ_NONE)
280 printk (" interrupts disabled");
282 printk (" irq %d", instance->irq);
283 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
284 CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE);
285 NCR5380_print_options(instance);
294 static int t128_release(struct Scsi_Host *shost)
296 NCR5380_local_declare();
297 NCR5380_setup(shost);
299 free_irq(shost->irq, NULL);
301 if (shost->io_port && shost->n_io_port)
302 release_region(shost->io_port, shost->n_io_port);
303 scsi_unregister(shost);
309 * Function : int t128_biosparam(Disk * disk, struct block_device *dev, int *ip)
311 * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for
312 * the specified device / size.
314 * Inputs : size = size of device in sectors (512 bytes), dev = block device
315 * major / minor, ip[] = {heads, sectors, cylinders}
317 * Returns : always 0 (success), initializes ip
322 * XXX Most SCSI boards use this mapping, I could be incorrect. Some one
323 * using hard disks on a trantor should verify that this mapping corresponds
324 * to that used by the BIOS / ASPI driver by running the linux fdisk program
325 * and matching the H_C_S coordinates to what DOS uses.
328 int t128_biosparam(struct scsi_device *sdev, struct block_device *bdev,
329 sector_t capacity, int * ip)
333 ip[2] = capacity >> 11;
338 * Function : int NCR5380_pread (struct Scsi_Host *instance,
339 * unsigned char *dst, int len)
341 * Purpose : Fast 5380 pseudo-dma read function, transfers len bytes to
344 * Inputs : dst = destination, len = length in bytes
346 * Returns : 0 on success, non zero on a failure such as a watchdog
350 static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
352 NCR5380_local_declare();
354 unsigned char *d = dst;
355 register int i = len;
357 NCR5380_setup(instance);
358 reg = base + T_DATA_REG_OFFSET;
362 while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
364 while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
370 if (readb(base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
372 void __iomem *foo = base + T_CONTROL_REG_OFFSET;
374 writeb(tmp | T_CR_CT, foo);
376 printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
384 * Function : int NCR5380_pwrite (struct Scsi_Host *instance,
385 * unsigned char *src, int len)
387 * Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from
390 * Inputs : src = source, len = length in bytes
392 * Returns : 0 on success, non zero on a failure such as a watchdog
396 static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
398 NCR5380_local_declare();
400 unsigned char *s = src;
401 register int i = len;
403 NCR5380_setup(instance);
404 reg = base + T_DATA_REG_OFFSET;
408 while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
410 while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
416 if (readb(base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
418 void __iomem *foo = base + T_CONTROL_REG_OFFSET;
420 writeb(tmp | T_CR_CT, foo);
422 printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
429 MODULE_LICENSE("GPL");
433 static Scsi_Host_Template driver_template = {
434 .name = "Trantor T128/T128F/T228",
435 .detect = t128_detect,
436 .release = t128_release,
437 .queuecommand = t128_queue_command,
438 .eh_abort_handler = t128_abort,
439 .eh_bus_reset_handler = t128_bus_reset,
440 .bios_param = t128_biosparam,
441 .can_queue = CAN_QUEUE,
443 .sg_tablesize = SG_ALL,
444 .cmd_per_lun = CMD_PER_LUN,
445 .use_clustering = DISABLE_CLUSTERING,
447 #include "scsi_module.c"