2 * Trantor T128/T128F/T228 driver
3 * Note : architecturally, the T100 and T130 are different and won't
6 * Copyright 1993, Drew Eckhardt
8 * (Unix and Linux consulting and custom programming)
12 * For more information, please consult
14 * Trantor Systems, Ltd.
15 * T128/T128F/T228 SCSI Host Adapter
16 * Hardware Specifications
18 * Trantor Systems, Ltd.
21 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910
25 * The card is detected and initialized in one of several ways :
26 * 1. Autoprobe (default) - since the board is memory mapped,
27 * a BIOS signature is scanned for to locate the registers.
28 * An interrupt is triggered to autoprobe for the interrupt
31 * 2. With command line overrides - t128=address,irq may be
32 * used on the LILO command line to override the defaults.
34 * 3. With the T128_OVERRIDE compile time define. This is
35 * specified as an array of address, irq tuples. Ie, for
36 * one board at the default 0xcc000 address, IRQ5, I could say
37 * -DT128_OVERRIDE={{0xcc000, 5}}
39 * Note that if the override methods are used, place holders must
40 * be specified for other boards in the system.
42 * T128/T128F jumper/dipswitch settings (note : on my sample, the switches
43 * were epoxy'd shut, meaning I couldn't change the 0xcc000 base address) :
45 * T128 Sw7 Sw8 Sw6 = 0ws Sw5 = boot
46 * T128F Sw6 Sw7 Sw5 = 0ws Sw4 = boot Sw8 = floppy disable
54 * There is a 12 pin jumper block, jp1, numbered as follows :
55 * T128 (JP1) T128F (J5)
56 * 2 4 6 8 10 12 11 9 7 5 3 1
57 * 1 3 5 7 9 11 12 10 8 6 4 2
70 #include <linux/blkdev.h>
71 #include <linux/interrupt.h>
72 #include <linux/init.h>
73 #include <linux/module.h>
75 #include <scsi/scsi_host.h>
79 static struct override
{
80 unsigned long address
;
84 [] __initdata
= T128_OVERRIDE
;
86 [4] __initdata
= {{0, IRQ_AUTO
}, {0, IRQ_AUTO
},
87 {0 ,IRQ_AUTO
}, {0, IRQ_AUTO
}};
90 #define NO_OVERRIDES ARRAY_SIZE(overrides)
95 } bases
[] __initdata
= {
96 { 0xcc000, 0}, { 0xc8000, 0}, { 0xdc000, 0}, { 0xd8000, 0}
99 #define NO_BASES ARRAY_SIZE(bases)
101 static struct signature
{
104 } signatures
[] __initdata
= {
105 {"TSROM: SCSI BIOS, Version 1.12", 0x36},
108 #define NO_SIGNATURES ARRAY_SIZE(signatures)
112 * Function : t128_setup(char *str, int *ints)
114 * Purpose : LILO command line initialization of the overrides array,
116 * Inputs : str - unused, ints - array of integer parameters with ints[0]
117 * equal to the number of ints.
121 static int __init
t128_setup(char *str
)
123 static int commandline_current
;
127 get_options(str
, ARRAY_SIZE(ints
), ints
);
129 printk("t128_setup : usage t128=address,irq\n");
131 if (commandline_current
< NO_OVERRIDES
) {
132 overrides
[commandline_current
].address
= ints
[1];
133 overrides
[commandline_current
].irq
= ints
[2];
134 for (i
= 0; i
< NO_BASES
; ++i
)
135 if (bases
[i
].address
== ints
[1]) {
139 ++commandline_current
;
144 __setup("t128=", t128_setup
);
148 * Function : int t128_detect(struct scsi_host_template * tpnt)
150 * Purpose : detects and initializes T128,T128F, or T228 controllers
151 * that were autoprobed, overridden on the LILO command line,
152 * or specified at compile time.
154 * Inputs : tpnt - template for this SCSI adapter.
156 * Returns : 1 if a host adapter was found, 0 if not.
160 static int __init
t128_detect(struct scsi_host_template
*tpnt
)
162 static int current_override
, current_base
;
163 struct Scsi_Host
*instance
;
168 for (count
= 0; current_override
< NO_OVERRIDES
; ++current_override
) {
172 if (overrides
[current_override
].address
) {
173 base
= overrides
[current_override
].address
;
174 p
= ioremap(bases
[current_base
].address
, 0x2000);
178 for (; !base
&& (current_base
< NO_BASES
); ++current_base
) {
179 dprintk(NDEBUG_INIT
, "t128: probing address 0x%08x\n",
180 bases
[current_base
].address
);
181 if (bases
[current_base
].noauto
)
183 p
= ioremap(bases
[current_base
].address
, 0x2000);
186 for (sig
= 0; sig
< NO_SIGNATURES
; ++sig
)
187 if (check_signature(p
+ signatures
[sig
].offset
,
188 signatures
[sig
].string
,
189 strlen(signatures
[sig
].string
))) {
190 base
= bases
[current_base
].address
;
191 dprintk(NDEBUG_INIT
, "t128: detected board\n");
197 dprintk(NDEBUG_INIT
, "t128: base = 0x%08x\n", (unsigned int)base
);
203 instance
= scsi_register (tpnt
, sizeof(struct NCR5380_hostdata
));
207 instance
->base
= base
;
208 ((struct NCR5380_hostdata
*)instance
->hostdata
)->base
= p
;
210 if (NCR5380_init(instance
, FLAG_DMA_FIXUP
| FLAG_LATE_DMA_SETUP
))
213 NCR5380_maybe_reset_bus(instance
);
215 if (overrides
[current_override
].irq
!= IRQ_AUTO
)
216 instance
->irq
= overrides
[current_override
].irq
;
218 instance
->irq
= NCR5380_probe_irq(instance
, T128_IRQS
);
220 /* Compatibility with documented NCR5380 kernel parameters */
221 if (instance
->irq
== 255)
222 instance
->irq
= NO_IRQ
;
224 if (instance
->irq
!= NO_IRQ
)
225 if (request_irq(instance
->irq
, t128_intr
, 0, "t128",
227 printk("scsi%d : IRQ%d not free, interrupts disabled\n",
228 instance
->host_no
, instance
->irq
);
229 instance
->irq
= NO_IRQ
;
232 if (instance
->irq
== NO_IRQ
) {
233 printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance
->host_no
);
234 printk("scsi%d : please jumper the board for a free IRQ.\n", instance
->host_no
);
237 dprintk(NDEBUG_INIT
, "scsi%d: irq = %d\n",
238 instance
->host_no
, instance
->irq
);
246 scsi_unregister(instance
);
252 static int t128_release(struct Scsi_Host
*shost
)
254 struct NCR5380_hostdata
*hostdata
= shost_priv(shost
);
256 if (shost
->irq
!= NO_IRQ
)
257 free_irq(shost
->irq
, shost
);
259 scsi_unregister(shost
);
260 iounmap(hostdata
->base
);
265 * Function : int t128_biosparam(Disk * disk, struct block_device *dev, int *ip)
267 * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for
268 * the specified device / size.
270 * Inputs : size = size of device in sectors (512 bytes), dev = block device
271 * major / minor, ip[] = {heads, sectors, cylinders}
273 * Returns : always 0 (success), initializes ip
278 * XXX Most SCSI boards use this mapping, I could be incorrect. Some one
279 * using hard disks on a trantor should verify that this mapping corresponds
280 * to that used by the BIOS / ASPI driver by running the linux fdisk program
281 * and matching the H_C_S coordinates to what DOS uses.
284 static int t128_biosparam(struct scsi_device
*sdev
, struct block_device
*bdev
,
285 sector_t capacity
, int *ip
)
289 ip
[2] = capacity
>> 11;
294 * Function : int t128_pread (struct Scsi_Host *instance,
295 * unsigned char *dst, int len)
297 * Purpose : Fast 5380 pseudo-dma read function, transfers len bytes to
300 * Inputs : dst = destination, len = length in bytes
302 * Returns : 0 on success, non zero on a failure such as a watchdog
306 static inline int t128_pread(struct Scsi_Host
*instance
,
307 unsigned char *dst
, int len
)
309 struct NCR5380_hostdata
*hostdata
= shost_priv(instance
);
310 void __iomem
*reg
, *base
= hostdata
->base
;
311 unsigned char *d
= dst
;
312 register int i
= len
;
314 reg
= base
+ T_DATA_REG_OFFSET
;
318 while (!(readb(base
+T_STATUS_REG_OFFSET
) & T_ST_RDY
)) barrier();
320 while (!(readb(base
+T_STATUS_REG_OFFSET
) & T_ST_RDY
)) barrier();
326 if (readb(base
+ T_STATUS_REG_OFFSET
) & T_ST_TIM
) {
328 void __iomem
*foo
= base
+ T_CONTROL_REG_OFFSET
;
330 writeb(tmp
| T_CR_CT
, foo
);
332 printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
340 * Function : int t128_pwrite (struct Scsi_Host *instance,
341 * unsigned char *src, int len)
343 * Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from
346 * Inputs : src = source, len = length in bytes
348 * Returns : 0 on success, non zero on a failure such as a watchdog
352 static inline int t128_pwrite(struct Scsi_Host
*instance
,
353 unsigned char *src
, int len
)
355 struct NCR5380_hostdata
*hostdata
= shost_priv(instance
);
356 void __iomem
*reg
, *base
= hostdata
->base
;
357 unsigned char *s
= src
;
358 register int i
= len
;
360 reg
= base
+ T_DATA_REG_OFFSET
;
364 while (!(readb(base
+T_STATUS_REG_OFFSET
) & T_ST_RDY
)) barrier();
366 while (!(readb(base
+T_STATUS_REG_OFFSET
) & T_ST_RDY
)) barrier();
372 if (readb(base
+ T_STATUS_REG_OFFSET
) & T_ST_TIM
) {
374 void __iomem
*foo
= base
+ T_CONTROL_REG_OFFSET
;
376 writeb(tmp
| T_CR_CT
, foo
);
378 printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
385 MODULE_LICENSE("GPL");
389 static struct scsi_host_template driver_template
= {
390 .name
= "Trantor T128/T128F/T228",
391 .detect
= t128_detect
,
392 .release
= t128_release
,
395 .queuecommand
= t128_queue_command
,
396 .eh_abort_handler
= t128_abort
,
397 .eh_bus_reset_handler
= t128_bus_reset
,
398 .bios_param
= t128_biosparam
,
401 .sg_tablesize
= SG_ALL
,
403 .use_clustering
= DISABLE_CLUSTERING
,
404 .cmd_size
= NCR5380_CMD_SIZE
,
407 #include "scsi_module.c"