Diff markup
1 #define AUTOSENSE 1 #define AUTOSENSE
2 #define PSEUDO_DMA 2 #define PSEUDO_DMA
3 #define FOO 3 #define FOO
4 #define UNSAFE /* Not unsafe for PAS16 -- use 4 #define UNSAFE /* Not unsafe for PAS16 -- use it */
5 #define PDEBUG 0 <<
6 5
7 /* 6 /*
8 * This driver adapted from Drew Eckhardt's Tr 7 * This driver adapted from Drew Eckhardt's Trantor T128 driver
9 * 8 *
10 * Copyright 1993, Drew Eckhardt 9 * Copyright 1993, Drew Eckhardt
11 * Visionary Computing 10 * Visionary Computing
12 * (Unix and Linux consulting and custom 11 * (Unix and Linux consulting and custom programming)
13 * drew@colorado.edu 12 * drew@colorado.edu
14 * +1 (303) 666-5836 13 * +1 (303) 666-5836
15 * 14 *
16 * ( Based on T128 - DISTRIBUTION RELEASE 3. 15 * ( Based on T128 - DISTRIBUTION RELEASE 3. )
17 * 16 *
18 * Modified to work with the Pro Audio Spectru 17 * Modified to work with the Pro Audio Spectrum/Studio 16
19 * by John Weidman. 18 * by John Weidman.
20 * 19 *
21 * 20 *
22 * For more information, please consult 21 * For more information, please consult
23 * 22 *
24 * Media Vision 23 * Media Vision
25 * (510) 770-8600 24 * (510) 770-8600
26 * (800) 348-7116 25 * (800) 348-7116
27 * 26 *
28 * and 27 * and
29 * 28 *
30 * NCR 5380 Family 29 * NCR 5380 Family
31 * SCSI Protocol Controller 30 * SCSI Protocol Controller
32 * Databook 31 * Databook
33 * 32 *
34 * NCR Microelectronics 33 * NCR Microelectronics
35 * 1635 Aeroplaza Drive 34 * 1635 Aeroplaza Drive
36 * Colorado Springs, CO 80916 35 * Colorado Springs, CO 80916
37 * 1+ (719) 578-3400 36 * 1+ (719) 578-3400
38 * 1+ (800) 334-5454 37 * 1+ (800) 334-5454
39 */ 38 */
40 39
41 /* 40 /*
42 * Options : 41 * Options :
43 * AUTOSENSE - if defined, REQUEST SENSE will 42 * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
44 * for commands that return with a CHECK 43 * for commands that return with a CHECK CONDITION status.
45 * 44 *
46 * LIMIT_TRANSFERSIZE - if defined, limit the 45 * LIMIT_TRANSFERSIZE - if defined, limit the pseudo-dma transfers to 512
47 * bytes at a time. Since interrupts are 46 * bytes at a time. Since interrupts are disabled by default during
48 * these transfers, we might need this to 47 * these transfers, we might need this to give reasonable interrupt
49 * service time if the transfer size gets 48 * service time if the transfer size gets too large.
50 * 49 *
51 * PSEUDO_DMA - enables PSEUDO-DMA hardware, s 50 * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
52 * increase compared to polled I/O. 51 * increase compared to polled I/O.
53 * 52 *
54 * PARITY - enable parity checking. Not suppo 53 * PARITY - enable parity checking. Not supported.
55 * 54 *
56 * SCSI2 - enable support for SCSI-II tagged q 55 * SCSI2 - enable support for SCSI-II tagged queueing. Untested.
57 * 56 *
58 * UNSAFE - leave interrupts enabled during ps 57 * UNSAFE - leave interrupts enabled during pseudo-DMA transfers. This
59 * parameter comes from the NCR5380 c 58 * parameter comes from the NCR5380 code. It is NOT unsafe with
60 * the PAS16 and you should use it. 59 * the PAS16 and you should use it. If you don't you will have
61 * a problem with dropped characters 60 * a problem with dropped characters during high speed
62 * communications during SCSI transfe 61 * communications during SCSI transfers. If you really don't
63 * want to use UNSAFE you can try def 62 * want to use UNSAFE you can try defining LIMIT_TRANSFERSIZE or
64 * twiddle with the transfer size in 63 * twiddle with the transfer size in the high level code.
65 * 64 *
66 * USLEEP - enable support for devices that do 65 * USLEEP - enable support for devices that don't disconnect. Untested.
67 * 66 *
68 * The card is detected and initialized in one 67 * The card is detected and initialized in one of several ways :
69 * 1. Autoprobe (default) - There are many di 68 * 1. Autoprobe (default) - There are many different models of
70 * the Pro Audio Spectrum/Studio 16, and I 69 * the Pro Audio Spectrum/Studio 16, and I only have one of
71 * them, so this may require a little twea 70 * them, so this may require a little tweaking. An interrupt
72 * is triggered to autoprobe for the inter 71 * is triggered to autoprobe for the interrupt line. Note:
73 * with the newer model boards, the interr 72 * with the newer model boards, the interrupt is set via
74 * software after reset using the default_ 73 * software after reset using the default_irq for the
75 * current board number. 74 * current board number.
76 * 75 *
77 * 2. With command line overrides - pas16=por 76 * 2. With command line overrides - pas16=port,irq may be
78 * used on the LILO command line to overri 77 * used on the LILO command line to override the defaults.
79 * 78 *
80 * 3. With the PAS16_OVERRIDE compile time de 79 * 3. With the PAS16_OVERRIDE compile time define. This is
81 * specified as an array of address, irq t 80 * specified as an array of address, irq tuples. Ie, for
82 * one board at the default 0x388 address, 81 * one board at the default 0x388 address, IRQ10, I could say
83 * -DPAS16_OVERRIDE={{0x388, 10}} 82 * -DPAS16_OVERRIDE={{0x388, 10}}
84 * NOTE: Untested. 83 * NOTE: Untested.
85 * 84 *
86 * 4. When included as a module, with argumen 85 * 4. When included as a module, with arguments passed on the command line:
87 * pas16_irq=xx the interrupt 86 * pas16_irq=xx the interrupt
88 * pas16_addr=xx the port 87 * pas16_addr=xx the port
89 * e.g. "modprobe pas16 pas16_addr=0x388 p 88 * e.g. "modprobe pas16 pas16_addr=0x388 pas16_irq=5"
90 * 89 *
91 * Note that if the override methods are u 90 * Note that if the override methods are used, place holders must
92 * be specified for other boards in the sy 91 * be specified for other boards in the system.
93 * 92 *
94 * 93 *
95 * Configuration notes : 94 * Configuration notes :
96 * The current driver does not support inter 95 * The current driver does not support interrupt sharing with the
97 * sound portion of the card. If you use th 96 * sound portion of the card. If you use the same irq for the
98 * scsi port and sound you will have problem 97 * scsi port and sound you will have problems. Either use
99 * a different irq for the scsi port or don' 98 * a different irq for the scsi port or don't use interrupts
100 * for the scsi port. 99 * for the scsi port.
101 * 100 *
102 * If you have problems with your card not b 101 * If you have problems with your card not being recognized, use
103 * the LILO command line override. Try to g 102 * the LILO command line override. Try to get it recognized without
104 * interrupts. Ie, for a board at the defau 103 * interrupts. Ie, for a board at the default 0x388 base port,
105 * boot: linux pas16=0x388,255 104 * boot: linux pas16=0x388,255
106 * 105 *
107 * SCSI_IRQ_NONE (255) should be specified f 106 * SCSI_IRQ_NONE (255) should be specified for no interrupt,
108 * IRQ_AUTO (254) to autoprobe for an IRQ li 107 * IRQ_AUTO (254) to autoprobe for an IRQ line if overridden
109 * on the command line. 108 * on the command line.
110 * 109 *
111 * (IRQ_AUTO == 254, SCSI_IRQ_NONE == 255 in 110 * (IRQ_AUTO == 254, SCSI_IRQ_NONE == 255 in NCR5380.h)
112 */ 111 */
113 112
114 #include <linux/module.h> 113 #include <linux/module.h>
115 114
116 #include <asm/system.h> 115 #include <asm/system.h>
117 #include <linux/signal.h> 116 #include <linux/signal.h>
118 #include <linux/proc_fs.h> 117 #include <linux/proc_fs.h>
>> 118 #include <linux/sched.h>
119 #include <asm/io.h> 119 #include <asm/io.h>
120 #include <asm/dma.h> 120 #include <asm/dma.h>
121 #include <linux/blkdev.h> 121 #include <linux/blkdev.h>
122 #include <linux/delay.h> 122 #include <linux/delay.h>
123 #include <linux/interrupt.h> 123 #include <linux/interrupt.h>
124 #include <linux/stat.h> 124 #include <linux/stat.h>
125 #include <linux/init.h> 125 #include <linux/init.h>
126 126
127 #include "scsi.h" 127 #include "scsi.h"
128 #include <scsi/scsi_host.h> 128 #include <scsi/scsi_host.h>
129 #include "pas16.h" 129 #include "pas16.h"
130 #define AUTOPROBE_IRQ 130 #define AUTOPROBE_IRQ
131 #include "NCR5380.h" 131 #include "NCR5380.h"
132 132
133 133
134 static int pas_maxi = 0; 134 static int pas_maxi = 0;
135 static int pas_wmaxi = 0; 135 static int pas_wmaxi = 0;
136 static unsigned short pas16_addr = 0; 136 static unsigned short pas16_addr = 0;
137 static int pas16_irq = 0; 137 static int pas16_irq = 0;
138 138
139 139
140 static const int scsi_irq_translate[] = !! 140 int scsi_irq_translate[] =
141 { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0 141 { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 };
142 142
143 /* The default_irqs array contains values used 143 /* The default_irqs array contains values used to set the irq into the
144 * board via software (as must be done on newe 144 * board via software (as must be done on newer model boards without
145 * irq jumpers on the board). The first value 145 * irq jumpers on the board). The first value in the array will be
146 * assigned to logical board 0, the next to bo 146 * assigned to logical board 0, the next to board 1, etc.
147 */ 147 */
148 static int default_irqs[] __initdata = !! 148 int default_irqs[] __initdata =
149 { PAS16_DEFAULT_BOARD_1_IRQ, 149 { PAS16_DEFAULT_BOARD_1_IRQ,
150 PAS16_DEFAULT_BOARD_2_IRQ, 150 PAS16_DEFAULT_BOARD_2_IRQ,
151 PAS16_DEFAULT_BOARD_3_IRQ, 151 PAS16_DEFAULT_BOARD_3_IRQ,
152 PAS16_DEFAULT_BOARD_4_IRQ 152 PAS16_DEFAULT_BOARD_4_IRQ
153 }; 153 };
154 154
155 static struct override { 155 static struct override {
156 unsigned short io_port; 156 unsigned short io_port;
157 int irq; 157 int irq;
158 } overrides !! 158 } overrides
159 #ifdef PAS16_OVERRIDE 159 #ifdef PAS16_OVERRIDE
160 [] __initdata = PAS16_OVERRIDE; 160 [] __initdata = PAS16_OVERRIDE;
161 #else 161 #else
162 [4] __initdata = {{0,IRQ_AUTO}, {0,IRQ_AUT 162 [4] __initdata = {{0,IRQ_AUTO}, {0,IRQ_AUTO}, {0,IRQ_AUTO},
163 {0,IRQ_AUTO}}; 163 {0,IRQ_AUTO}};
164 #endif 164 #endif
165 165
166 #define NO_OVERRIDES ARRAY_SIZE(overrides) !! 166 #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
167 167
168 static struct base { 168 static struct base {
169 unsigned short io_port; 169 unsigned short io_port;
170 int noauto; 170 int noauto;
171 } bases[] __initdata = !! 171 } bases[] __initdata =
172 { {PAS16_DEFAULT_BASE_1, 0}, 172 { {PAS16_DEFAULT_BASE_1, 0},
173 {PAS16_DEFAULT_BASE_2, 0}, 173 {PAS16_DEFAULT_BASE_2, 0},
174 {PAS16_DEFAULT_BASE_3, 0}, 174 {PAS16_DEFAULT_BASE_3, 0},
175 {PAS16_DEFAULT_BASE_4, 0} 175 {PAS16_DEFAULT_BASE_4, 0}
176 }; 176 };
177 177
178 #define NO_BASES ARRAY_SIZE(bases) !! 178 #define NO_BASES (sizeof (bases) / sizeof (struct base))
179 179
180 static const unsigned short pas16_offset[ 8 ] !! 180 unsigned short pas16_offset[ 8 ] =
181 { 181 {
182 0x1c00, /* OUTPUT_DATA_REG */ 182 0x1c00, /* OUTPUT_DATA_REG */
183 0x1c01, /* INITIATOR_COMMAND_REG */ 183 0x1c01, /* INITIATOR_COMMAND_REG */
184 0x1c02, /* MODE_REG */ 184 0x1c02, /* MODE_REG */
185 0x1c03, /* TARGET_COMMAND_REG */ 185 0x1c03, /* TARGET_COMMAND_REG */
186 0x3c00, /* STATUS_REG ro, SELECT_EN 186 0x3c00, /* STATUS_REG ro, SELECT_ENABLE_REG wo */
187 0x3c01, /* BUS_AND_STATUS_REG ro, S 187 0x3c01, /* BUS_AND_STATUS_REG ro, START_DMA_SEND_REG wo */
188 0x3c02, /* INPUT_DATA_REGISTER ro, 188 0x3c02, /* INPUT_DATA_REGISTER ro, (N/A on PAS16 ?)
189 * START_DMA_TARGET_RECEIVE 189 * START_DMA_TARGET_RECEIVE_REG wo
190 */ 190 */
191 0x3c03, /* RESET_PARITY_INTERRUPT_R 191 0x3c03, /* RESET_PARITY_INTERRUPT_REG ro,
192 * START_DMA_INITIATOR_RECE 192 * START_DMA_INITIATOR_RECEIVE_REG wo
193 */ 193 */
194 }; 194 };
195 /*-------------------------------------------- 195 /*----------------------------------------------------------------*/
196 /* the following will set the monitor border c 196 /* the following will set the monitor border color (useful to find
197 where something crashed or gets stuck at */ 197 where something crashed or gets stuck at */
198 /* 1 = blue 198 /* 1 = blue
199 2 = green 199 2 = green
200 3 = cyan 200 3 = cyan
201 4 = red 201 4 = red
202 5 = magenta 202 5 = magenta
203 6 = yellow 203 6 = yellow
204 7 = white 204 7 = white
205 */ 205 */
206 #if 1 206 #if 1
207 #define rtrc(i) {inb(0x3da); outb(0x31, 0x3c0) 207 #define rtrc(i) {inb(0x3da); outb(0x31, 0x3c0); outb((i), 0x3c0);}
208 #else 208 #else
209 #define rtrc(i) {} 209 #define rtrc(i) {}
210 #endif 210 #endif
211 211
212 212
213 /* 213 /*
214 * Function : enable_board( int board_num, un 214 * Function : enable_board( int board_num, unsigned short port )
215 * 215 *
216 * Purpose : set address in new model board 216 * Purpose : set address in new model board
217 * 217 *
218 * Inputs : board_num - logical board number 0 218 * Inputs : board_num - logical board number 0-3, port - base address
219 * 219 *
220 */ 220 */
221 221
222 static void __init 222 static void __init
223 enable_board( int board_num, unsigne 223 enable_board( int board_num, unsigned short port )
224 { 224 {
225 outb( 0xbc + board_num, MASTER_ADDRESS_PTR 225 outb( 0xbc + board_num, MASTER_ADDRESS_PTR );
226 outb( port >> 2, MASTER_ADDRESS_PTR ); 226 outb( port >> 2, MASTER_ADDRESS_PTR );
227 } 227 }
228 228
229 229
230 230
231 /* 231 /*
232 * Function : init_board( unsigned short port, 232 * Function : init_board( unsigned short port, int irq )
233 * 233 *
234 * Purpose : Set the board up to handle the S 234 * Purpose : Set the board up to handle the SCSI interface
235 * 235 *
236 * Inputs : port - base address of the board, 236 * Inputs : port - base address of the board,
237 * irq - irq to assign to the SCSI po 237 * irq - irq to assign to the SCSI port
238 * force_irq - set it even if it conf 238 * force_irq - set it even if it conflicts with sound driver
239 * 239 *
240 */ 240 */
241 241
242 static void __init 242 static void __init
243 init_board( unsigned short io_port, in 243 init_board( unsigned short io_port, int irq, int force_irq )
244 { 244 {
245 unsigned int tmp; 245 unsigned int tmp;
246 unsigned int pas_irq_code; 246 unsigned int pas_irq_code;
247 247
248 /* Initialize the SCSI part of the boa 248 /* Initialize the SCSI part of the board */
249 249
250 outb( 0x30, io_port + P_TIMEOUT_COUNTE 250 outb( 0x30, io_port + P_TIMEOUT_COUNTER_REG ); /* Timeout counter */
251 outb( 0x01, io_port + P_TIMEOUT_STATUS 251 outb( 0x01, io_port + P_TIMEOUT_STATUS_REG_OFFSET ); /* Reset TC */
252 outb( 0x01, io_port + WAIT_STATE ); 252 outb( 0x01, io_port + WAIT_STATE ); /* 1 Wait state */
253 253
254 NCR5380_read( RESET_PARITY_INTERRUPT_R 254 NCR5380_read( RESET_PARITY_INTERRUPT_REG );
255 255
256 /* Set the SCSI interrupt pointer with 256 /* Set the SCSI interrupt pointer without mucking up the sound
257 * interrupt pointer in the same byte. 257 * interrupt pointer in the same byte.
258 */ 258 */
259 pas_irq_code = ( irq < 16 ) ? scsi_irq 259 pas_irq_code = ( irq < 16 ) ? scsi_irq_translate[irq] : 0;
260 tmp = inb( io_port + IO_CONFIG_3 ); 260 tmp = inb( io_port + IO_CONFIG_3 );
261 261
262 if( (( tmp & 0x0f ) == pas_irq_code) & 262 if( (( tmp & 0x0f ) == pas_irq_code) && pas_irq_code > 0
263 && !force_irq ) 263 && !force_irq )
264 { 264 {
265 printk( "pas16: WARNING: Can't use 265 printk( "pas16: WARNING: Can't use same irq as sound "
266 "driver -- interrupts disa 266 "driver -- interrupts disabled\n" );
267 /* Set up the drive parameters, di 267 /* Set up the drive parameters, disable 5380 interrupts */
268 outb( 0x4d, io_port + SYS_CONFIG_4 268 outb( 0x4d, io_port + SYS_CONFIG_4 );
269 } 269 }
270 else 270 else
271 { 271 {
272 tmp = ( tmp & 0x0f ) | ( pas_irq_ 272 tmp = ( tmp & 0x0f ) | ( pas_irq_code << 4 );
273 outb( tmp, io_port + IO_CONFIG_3 ) 273 outb( tmp, io_port + IO_CONFIG_3 );
274 274
275 /* Set up the drive parameters and 275 /* Set up the drive parameters and enable 5380 interrupts */
276 outb( 0x6d, io_port + SYS_CONFIG_4 276 outb( 0x6d, io_port + SYS_CONFIG_4 );
277 } 277 }
278 } 278 }
279 279
280 280
281 /* 281 /*
282 * Function : pas16_hw_detect( unsigned short 282 * Function : pas16_hw_detect( unsigned short board_num )
283 * 283 *
284 * Purpose : determine if a pas16 board is pre 284 * Purpose : determine if a pas16 board is present
285 * 285 *
286 * Inputs : board_num - logical board number ( 286 * Inputs : board_num - logical board number ( 0 - 3 )
287 * 287 *
288 * Returns : 0 if board not found, 1 if found. 288 * Returns : 0 if board not found, 1 if found.
289 */ 289 */
290 290
291 static int __init 291 static int __init
292 pas16_hw_detect( unsigned short board_nu 292 pas16_hw_detect( unsigned short board_num )
293 { 293 {
294 unsigned char board_rev, tmp; 294 unsigned char board_rev, tmp;
295 unsigned short io_port = bases[ board 295 unsigned short io_port = bases[ board_num ].io_port;
296 296
297 /* See if we can find a PAS16 board at the 297 /* See if we can find a PAS16 board at the address associated
298 * with this logical board number. 298 * with this logical board number.
299 */ 299 */
300 300
301 /* First, attempt to take a newer model bo 301 /* First, attempt to take a newer model board out of reset and
302 * give it a base address. This shouldn't 302 * give it a base address. This shouldn't affect older boards.
303 */ 303 */
304 enable_board( board_num, io_port ); 304 enable_board( board_num, io_port );
305 305
306 /* Now see if it looks like a PAS16 board 306 /* Now see if it looks like a PAS16 board */
307 board_rev = inb( io_port + PCB_CONFIG ); 307 board_rev = inb( io_port + PCB_CONFIG );
308 308
309 if( board_rev == 0xff ) 309 if( board_rev == 0xff )
310 return 0; 310 return 0;
311 311
312 tmp = board_rev ^ 0xe0; 312 tmp = board_rev ^ 0xe0;
313 313
314 outb( tmp, io_port + PCB_CONFIG ); 314 outb( tmp, io_port + PCB_CONFIG );
315 tmp = inb( io_port + PCB_CONFIG ); 315 tmp = inb( io_port + PCB_CONFIG );
316 outb( board_rev, io_port + PCB_CONFIG ); 316 outb( board_rev, io_port + PCB_CONFIG );
317 317
318 if( board_rev != tmp ) /* Not a PAS-1 318 if( board_rev != tmp ) /* Not a PAS-16 */
319 return 0; 319 return 0;
320 320
321 if( ( inb( io_port + OPERATION_MODE_1 ) & 321 if( ( inb( io_port + OPERATION_MODE_1 ) & 0x03 ) != 0x03 )
322 return 0; /* return if no SCSI i 322 return 0; /* return if no SCSI interface found */
323 323
324 /* Mediavision has some new model boards t 324 /* Mediavision has some new model boards that return ID bits
325 * that indicate a SCSI interface, but the 325 * that indicate a SCSI interface, but they're not (LMS). We'll
326 * put in an additional test to try to wee 326 * put in an additional test to try to weed them out.
327 */ 327 */
328 328
329 outb( 0x01, io_port + WAIT_STATE ); 329 outb( 0x01, io_port + WAIT_STATE ); /* 1 Wait state */
330 NCR5380_write( MODE_REG, 0x20 ); 330 NCR5380_write( MODE_REG, 0x20 ); /* Is it really SCSI? */
331 if( NCR5380_read( MODE_REG ) != 0x20 ) 331 if( NCR5380_read( MODE_REG ) != 0x20 ) /* Write to a reg. */
332 return 0; 332 return 0; /* and try to read */
333 NCR5380_write( MODE_REG, 0x00 ); 333 NCR5380_write( MODE_REG, 0x00 ); /* it back. */
334 if( NCR5380_read( MODE_REG ) != 0x00 ) 334 if( NCR5380_read( MODE_REG ) != 0x00 )
335 return 0; 335 return 0;
336 336
337 return 1; 337 return 1;
338 } 338 }
339 339
340 340
341 /* 341 /*
342 * Function : pas16_setup(char *str, int *ints 342 * Function : pas16_setup(char *str, int *ints)
343 * 343 *
344 * Purpose : LILO command line initialization 344 * Purpose : LILO command line initialization of the overrides array,
345 * 345 *
346 * Inputs : str - unused, ints - array of inte 346 * Inputs : str - unused, ints - array of integer parameters with ints[0]
347 * equal to the number of ints. 347 * equal to the number of ints.
348 * 348 *
349 */ 349 */
350 350
351 void __init pas16_setup(char *str, int *ints) 351 void __init pas16_setup(char *str, int *ints)
352 { 352 {
353 static int commandline_current = 0; 353 static int commandline_current = 0;
354 int i; 354 int i;
355 if (ints[0] != 2) 355 if (ints[0] != 2)
356 printk("pas16_setup : usage pas16=io_p 356 printk("pas16_setup : usage pas16=io_port,irq\n");
357 else 357 else
358 if (commandline_current < NO_OVERRIDES 358 if (commandline_current < NO_OVERRIDES) {
359 overrides[commandline_current].io_ 359 overrides[commandline_current].io_port = (unsigned short) ints[1];
360 overrides[commandline_current].irq 360 overrides[commandline_current].irq = ints[2];
361 for (i = 0; i < NO_BASES; ++i) 361 for (i = 0; i < NO_BASES; ++i)
362 if (bases[i].io_port == (unsig 362 if (bases[i].io_port == (unsigned short) ints[1]) {
363 bases[i].noauto = 1; 363 bases[i].noauto = 1;
364 break; 364 break;
365 } 365 }
366 ++commandline_current; 366 ++commandline_current;
367 } 367 }
368 } 368 }
369 369
370 /* 370 /*
371 * Function : int pas16_detect(struct scsi_hos !! 371 * Function : int pas16_detect(Scsi_Host_Template * tpnt)
372 * 372 *
373 * Purpose : detects and initializes PAS16 con 373 * Purpose : detects and initializes PAS16 controllers
374 * that were autoprobed, overridden on th 374 * that were autoprobed, overridden on the LILO command line,
375 * or specified at compile time. 375 * or specified at compile time.
376 * 376 *
377 * Inputs : tpnt - template for this SCSI adap 377 * Inputs : tpnt - template for this SCSI adapter.
378 * 378 *
379 * Returns : 1 if a host adapter was found, 0 379 * Returns : 1 if a host adapter was found, 0 if not.
380 * 380 *
381 */ 381 */
382 382
383 int __init pas16_detect(struct scsi_host_templ !! 383 int __init pas16_detect(Scsi_Host_Template * tpnt)
384 { 384 {
385 static int current_override = 0; 385 static int current_override = 0;
386 static unsigned short current_base = 0; 386 static unsigned short current_base = 0;
387 struct Scsi_Host *instance; 387 struct Scsi_Host *instance;
388 unsigned short io_port; 388 unsigned short io_port;
389 int count; 389 int count;
390 390
391 tpnt->proc_name = "pas16"; 391 tpnt->proc_name = "pas16";
392 tpnt->proc_info = &pas16_proc_info; 392 tpnt->proc_info = &pas16_proc_info;
393 393
394 if (pas16_addr != 0) { 394 if (pas16_addr != 0) {
395 overrides[0].io_port = pas16_addr; 395 overrides[0].io_port = pas16_addr;
396 /* 396 /*
397 * This is how we avoid seeing more th 397 * This is how we avoid seeing more than
398 * one host adapter at the same I/O po 398 * one host adapter at the same I/O port.
399 * Cribbed shamelessly from pas16_setu 399 * Cribbed shamelessly from pas16_setup().
400 */ 400 */
401 for (count = 0; count < NO_BASES; ++co 401 for (count = 0; count < NO_BASES; ++count)
402 if (bases[count].io_port == pas16_ 402 if (bases[count].io_port == pas16_addr) {
403 bases[count].noauto = 1; 403 bases[count].noauto = 1;
404 break; 404 break;
405 } 405 }
406 } 406 }
407 if (pas16_irq != 0) 407 if (pas16_irq != 0)
408 overrides[0].irq = pas16_irq; 408 overrides[0].irq = pas16_irq;
409 409
410 for (count = 0; current_override < NO_OVER 410 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
411 io_port = 0; 411 io_port = 0;
412 412
413 if (overrides[current_override].io_por 413 if (overrides[current_override].io_port)
414 { 414 {
415 io_port = overrides[current_overri 415 io_port = overrides[current_override].io_port;
416 enable_board( current_override, io 416 enable_board( current_override, io_port );
417 init_board( io_port, overrides[cur 417 init_board( io_port, overrides[current_override].irq, 1 );
418 } 418 }
419 else 419 else
420 for (; !io_port && (current_base < 420 for (; !io_port && (current_base < NO_BASES); ++current_base) {
421 #if (PDEBUG & PDEBUG_INIT) 421 #if (PDEBUG & PDEBUG_INIT)
422 printk("scsi-pas16 : probing io_port %04x\ 422 printk("scsi-pas16 : probing io_port %04x\n", (unsigned int) bases[current_base].io_port);
423 #endif 423 #endif
424 if ( !bases[current_base].noau 424 if ( !bases[current_base].noauto &&
425 pas16_hw_detect( current_ 425 pas16_hw_detect( current_base ) ){
426 io_port = bases[curren 426 io_port = bases[current_base].io_port;
427 init_board( io_port, d 427 init_board( io_port, default_irqs[ current_base ], 0 );
428 #if (PDEBUG & PDEBUG_INIT) 428 #if (PDEBUG & PDEBUG_INIT)
429 printk("scsi-pas16 : d 429 printk("scsi-pas16 : detected board.\n");
430 #endif 430 #endif
431 } 431 }
432 } 432 }
433 433
434 434
435 #if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT) 435 #if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT)
436 printk("scsi-pas16 : io_port = %04x\n" 436 printk("scsi-pas16 : io_port = %04x\n", (unsigned int) io_port);
437 #endif 437 #endif
438 438
439 if (!io_port) 439 if (!io_port)
440 break; 440 break;
441 441
442 instance = scsi_register (tpnt, sizeof 442 instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
443 if(instance == NULL) 443 if(instance == NULL)
444 break; 444 break;
445 445
446 instance->io_port = io_port; 446 instance->io_port = io_port;
447 447
448 NCR5380_init(instance, 0); 448 NCR5380_init(instance, 0);
449 449
450 if (overrides[current_override].irq != 450 if (overrides[current_override].irq != IRQ_AUTO)
451 instance->irq = overrides[current_ 451 instance->irq = overrides[current_override].irq;
452 else 452 else
453 instance->irq = NCR5380_probe_irq( 453 instance->irq = NCR5380_probe_irq(instance, PAS16_IRQS);
454 454
455 if (instance->irq != SCSI_IRQ_NONE) 455 if (instance->irq != SCSI_IRQ_NONE)
456 if (request_irq(instance->irq, pas !! 456 if (request_irq(instance->irq, pas16_intr, SA_INTERRUPT, "pas16", instance)) {
457 "pas16", instance) <<
458 printk("scsi%d : IRQ%d not fre 457 printk("scsi%d : IRQ%d not free, interrupts disabled\n",
459 instance->host_no, instanc 458 instance->host_no, instance->irq);
460 instance->irq = SCSI_IRQ_NONE; 459 instance->irq = SCSI_IRQ_NONE;
461 } 460 }
462 461
463 if (instance->irq == SCSI_IRQ_NONE) { 462 if (instance->irq == SCSI_IRQ_NONE) {
464 printk("scsi%d : interrupts not en 463 printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
465 printk("scsi%d : please jumper the 464 printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
466 /* Disable 5380 interrupts, leave 465 /* Disable 5380 interrupts, leave drive params the same */
467 outb( 0x4d, io_port + SYS_CONFIG_4 466 outb( 0x4d, io_port + SYS_CONFIG_4 );
468 outb( (inb(io_port + IO_CONFIG_3) 467 outb( (inb(io_port + IO_CONFIG_3) & 0x0f), io_port + IO_CONFIG_3 );
469 } 468 }
470 469
471 #if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT) 470 #if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT)
472 printk("scsi%d : irq = %d\n", instance 471 printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
473 #endif 472 #endif
474 473
475 printk("scsi%d : at 0x%04x", instance- 474 printk("scsi%d : at 0x%04x", instance->host_no, (int)
476 instance->io_port); 475 instance->io_port);
477 if (instance->irq == SCSI_IRQ_NONE) 476 if (instance->irq == SCSI_IRQ_NONE)
478 printk (" interrupts disabled"); 477 printk (" interrupts disabled");
479 else 478 else
480 printk (" irq %d", instance->irq); 479 printk (" irq %d", instance->irq);
481 printk(" options CAN_QUEUE=%d CMD_PER 480 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
482 CAN_QUEUE, CMD_PER_LUN, PAS16_PUBL 481 CAN_QUEUE, CMD_PER_LUN, PAS16_PUBLIC_RELEASE);
483 NCR5380_print_options(instance); 482 NCR5380_print_options(instance);
484 printk("\n"); 483 printk("\n");
485 484
486 ++current_override; 485 ++current_override;
487 ++count; 486 ++count;
488 } 487 }
489 return count; 488 return count;
490 } 489 }
491 490
492 /* 491 /*
493 * Function : int pas16_biosparam(Disk *disk, 492 * Function : int pas16_biosparam(Disk *disk, struct block_device *dev, int *ip)
494 * 493 *
495 * Purpose : Generates a BIOS / DOS compatible 494 * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for
496 * the specified device / size. 495 * the specified device / size.
497 * 496 *
498 * Inputs : size = size of device in sectors ( 497 * Inputs : size = size of device in sectors (512 bytes), dev = block device
499 * major / minor, ip[] = {heads, sectors, 498 * major / minor, ip[] = {heads, sectors, cylinders}
500 * 499 *
501 * Returns : always 0 (success), initializes i 500 * Returns : always 0 (success), initializes ip
502 * 501 *
503 */ 502 */
504 503
505 /* 504 /*
506 * XXX Most SCSI boards use this mapping, I co 505 * XXX Most SCSI boards use this mapping, I could be incorrect. Some one
507 * using hard disks on a trantor should verify 506 * using hard disks on a trantor should verify that this mapping corresponds
508 * to that used by the BIOS / ASPI driver by r 507 * to that used by the BIOS / ASPI driver by running the linux fdisk program
509 * and matching the H_C_S coordinates to what 508 * and matching the H_C_S coordinates to what DOS uses.
510 */ 509 */
511 510
512 int pas16_biosparam(struct scsi_device *sdev, 511 int pas16_biosparam(struct scsi_device *sdev, struct block_device *dev,
513 sector_t capacity, int * ip) 512 sector_t capacity, int * ip)
514 { 513 {
515 int size = capacity; 514 int size = capacity;
516 ip[0] = 64; 515 ip[0] = 64;
517 ip[1] = 32; 516 ip[1] = 32;
518 ip[2] = size >> 11; /* I think I h 517 ip[2] = size >> 11; /* I think I have it as /(32*64) */
519 if( ip[2] > 1024 ) { /* yes, >, not 518 if( ip[2] > 1024 ) { /* yes, >, not >= */
520 ip[0]=255; 519 ip[0]=255;
521 ip[1]=63; 520 ip[1]=63;
522 ip[2]=size/(63*255); 521 ip[2]=size/(63*255);
523 if( ip[2] > 1023 ) /* yes >1023.. 522 if( ip[2] > 1023 ) /* yes >1023... */
524 ip[2] = 1023; 523 ip[2] = 1023;
525 } 524 }
526 525
527 return 0; 526 return 0;
528 } 527 }
529 528
530 /* 529 /*
531 * Function : int NCR5380_pread (struct Scsi_H 530 * Function : int NCR5380_pread (struct Scsi_Host *instance,
532 * unsigned char *dst, int len) 531 * unsigned char *dst, int len)
533 * 532 *
534 * Purpose : Fast 5380 pseudo-dma read functio 533 * Purpose : Fast 5380 pseudo-dma read function, transfers len bytes to
535 * dst 534 * dst
536 * 535 *
537 * Inputs : dst = destination, len = length in 536 * Inputs : dst = destination, len = length in bytes
538 * 537 *
539 * Returns : 0 on success, non zero on a failu 538 * Returns : 0 on success, non zero on a failure such as a watchdog
540 * timeout. 539 * timeout.
541 */ 540 */
542 541
543 static inline int NCR5380_pread (struct Scsi_H 542 static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
544 int len) { 543 int len) {
545 register unsigned char *d = dst; 544 register unsigned char *d = dst;
546 register unsigned short reg = (unsigned sh 545 register unsigned short reg = (unsigned short) (instance->io_port +
547 P_DATA_REG_OFFSET); 546 P_DATA_REG_OFFSET);
548 register int i = len; 547 register int i = len;
549 int ii = 0; 548 int ii = 0;
550 549
551 while ( !(inb(instance->io_port + P_STATUS 550 while ( !(inb(instance->io_port + P_STATUS_REG_OFFSET) & P_ST_RDY) )
552 ++ii; 551 ++ii;
553 552
554 insb( reg, d, i ); 553 insb( reg, d, i );
555 554
556 if ( inb(instance->io_port + P_TIMEOUT_STA 555 if ( inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) {
557 outb( P_TS_CT, instance->io_port + P_T 556 outb( P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET);
558 printk("scsi%d : watchdog timer fired 557 printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
559 instance->host_no); 558 instance->host_no);
560 return -1; 559 return -1;
561 } 560 }
562 if (ii > pas_maxi) 561 if (ii > pas_maxi)
563 pas_maxi = ii; 562 pas_maxi = ii;
564 return 0; 563 return 0;
565 } 564 }
566 565
567 /* 566 /*
568 * Function : int NCR5380_pwrite (struct Scsi_ 567 * Function : int NCR5380_pwrite (struct Scsi_Host *instance,
569 * unsigned char *src, int len) 568 * unsigned char *src, int len)
570 * 569 *
571 * Purpose : Fast 5380 pseudo-dma write functi 570 * Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from
572 * src 571 * src
573 * 572 *
574 * Inputs : src = source, len = length in byte 573 * Inputs : src = source, len = length in bytes
575 * 574 *
576 * Returns : 0 on success, non zero on a failu 575 * Returns : 0 on success, non zero on a failure such as a watchdog
577 * timeout. 576 * timeout.
578 */ 577 */
579 578
580 static inline int NCR5380_pwrite (struct Scsi_ 579 static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
581 int len) { 580 int len) {
582 register unsigned char *s = src; 581 register unsigned char *s = src;
583 register unsigned short reg = (instance->i 582 register unsigned short reg = (instance->io_port + P_DATA_REG_OFFSET);
584 register int i = len; 583 register int i = len;
585 int ii = 0; 584 int ii = 0;
586 585
587 while ( !((inb(instance->io_port + P_STATU 586 while ( !((inb(instance->io_port + P_STATUS_REG_OFFSET)) & P_ST_RDY) )
588 ++ii; 587 ++ii;
589 588
590 outsb( reg, s, i ); 589 outsb( reg, s, i );
591 590
592 if (inb(instance->io_port + P_TIMEOUT_STAT 591 if (inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) {
593 outb( P_TS_CT, instance->io_port + P_T 592 outb( P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET);
594 printk("scsi%d : watchdog timer fired 593 printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
595 instance->host_no); 594 instance->host_no);
596 return -1; 595 return -1;
597 } 596 }
598 if (ii > pas_maxi) 597 if (ii > pas_maxi)
599 pas_wmaxi = ii; 598 pas_wmaxi = ii;
600 return 0; 599 return 0;
601 } 600 }
602 601
603 #include "NCR5380.c" 602 #include "NCR5380.c"
604 603
605 static int pas16_release(struct Scsi_Host *sho 604 static int pas16_release(struct Scsi_Host *shost)
606 { 605 {
607 if (shost->irq) 606 if (shost->irq)
608 free_irq(shost->irq, shost); !! 607 free_irq(shost->irq, NULL);
609 NCR5380_exit(shost); 608 NCR5380_exit(shost);
610 if (shost->dma_channel != 0xff) 609 if (shost->dma_channel != 0xff)
611 free_dma(shost->dma_channel); 610 free_dma(shost->dma_channel);
612 if (shost->io_port && shost->n_io_port 611 if (shost->io_port && shost->n_io_port)
613 release_region(shost->io_port, 612 release_region(shost->io_port, shost->n_io_port);
614 scsi_unregister(shost); 613 scsi_unregister(shost);
615 return 0; 614 return 0;
616 } 615 }
617 616
618 static struct scsi_host_template driver_templa !! 617 static Scsi_Host_Template driver_template = {
619 .name = "Pro Audio Spectrum- 618 .name = "Pro Audio Spectrum-16 SCSI",
620 .detect = pas16_detect, 619 .detect = pas16_detect,
621 .release = pas16_release, 620 .release = pas16_release,
622 .queuecommand = pas16_queue_command, 621 .queuecommand = pas16_queue_command,
623 .eh_abort_handler = pas16_abort, 622 .eh_abort_handler = pas16_abort,
624 .eh_bus_reset_handler = pas16_bus_rese 623 .eh_bus_reset_handler = pas16_bus_reset,
>> 624 .eh_device_reset_handler = pas16_device_reset,
>> 625 .eh_host_reset_handler = pas16_host_reset,
625 .bios_param = pas16_biosparam, 626 .bios_param = pas16_biosparam,
626 .can_queue = CAN_QUEUE, 627 .can_queue = CAN_QUEUE,
627 .this_id = 7, 628 .this_id = 7,
628 .sg_tablesize = SG_ALL, 629 .sg_tablesize = SG_ALL,
629 .cmd_per_lun = CMD_PER_LUN, 630 .cmd_per_lun = CMD_PER_LUN,
630 .use_clustering = DISABLE_CLUSTERING, 631 .use_clustering = DISABLE_CLUSTERING,
631 }; 632 };
632 #include "scsi_module.c" 633 #include "scsi_module.c"
633 634
634 #ifdef MODULE 635 #ifdef MODULE
635 module_param(pas16_addr, ushort, 0); 636 module_param(pas16_addr, ushort, 0);
636 module_param(pas16_irq, int, 0); 637 module_param(pas16_irq, int, 0);
637 #endif 638 #endif
638 MODULE_LICENSE("GPL"); 639 MODULE_LICENSE("GPL");
639 640
|
This page was automatically generated by the
LXR engine.
|