diff options
Diffstat (limited to 'drivers/scsi/atari_scsi.c')
-rw-r--r-- | drivers/scsi/atari_scsi.c | 377 |
1 files changed, 182 insertions, 195 deletions
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 642de7b2b7a2..6f8403b82ba1 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c | |||
@@ -69,9 +69,9 @@ | |||
69 | 69 | ||
70 | #define NDEBUG (0) | 70 | #define NDEBUG (0) |
71 | 71 | ||
72 | #define NDEBUG_ABORT 0x800000 | 72 | #define NDEBUG_ABORT 0x00100000 |
73 | #define NDEBUG_TAGS 0x1000000 | 73 | #define NDEBUG_TAGS 0x00200000 |
74 | #define NDEBUG_MERGING 0x2000000 | 74 | #define NDEBUG_MERGING 0x00400000 |
75 | 75 | ||
76 | #define AUTOSENSE | 76 | #define AUTOSENSE |
77 | /* For the Atari version, use only polled IO or REAL_DMA */ | 77 | /* For the Atari version, use only polled IO or REAL_DMA */ |
@@ -186,38 +186,37 @@ static inline void DISABLE_IRQ(void) | |||
186 | /***************************** Prototypes *****************************/ | 186 | /***************************** Prototypes *****************************/ |
187 | 187 | ||
188 | #ifdef REAL_DMA | 188 | #ifdef REAL_DMA |
189 | static int scsi_dma_is_ignored_buserr( unsigned char dma_stat ); | 189 | static int scsi_dma_is_ignored_buserr(unsigned char dma_stat); |
190 | static void atari_scsi_fetch_restbytes( void ); | 190 | static void atari_scsi_fetch_restbytes(void); |
191 | static long atari_scsi_dma_residual( struct Scsi_Host *instance ); | 191 | static long atari_scsi_dma_residual(struct Scsi_Host *instance); |
192 | static int falcon_classify_cmd( Scsi_Cmnd *cmd ); | 192 | static int falcon_classify_cmd(Scsi_Cmnd *cmd); |
193 | static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | 193 | static unsigned long atari_dma_xfer_len(unsigned long wanted_len, |
194 | Scsi_Cmnd *cmd, int write_flag ); | 194 | Scsi_Cmnd *cmd, int write_flag); |
195 | #endif | 195 | #endif |
196 | static irqreturn_t scsi_tt_intr( int irq, void *dummy); | 196 | static irqreturn_t scsi_tt_intr(int irq, void *dummy); |
197 | static irqreturn_t scsi_falcon_intr( int irq, void *dummy); | 197 | static irqreturn_t scsi_falcon_intr(int irq, void *dummy); |
198 | static void falcon_release_lock_if_possible( struct NCR5380_hostdata * | 198 | static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata); |
199 | hostdata ); | 199 | static void falcon_get_lock(void); |
200 | static void falcon_get_lock( void ); | ||
201 | #ifdef CONFIG_ATARI_SCSI_RESET_BOOT | 200 | #ifdef CONFIG_ATARI_SCSI_RESET_BOOT |
202 | static void atari_scsi_reset_boot( void ); | 201 | static void atari_scsi_reset_boot(void); |
203 | #endif | 202 | #endif |
204 | static unsigned char atari_scsi_tt_reg_read( unsigned char reg ); | 203 | static unsigned char atari_scsi_tt_reg_read(unsigned char reg); |
205 | static void atari_scsi_tt_reg_write( unsigned char reg, unsigned char value); | 204 | static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value); |
206 | static unsigned char atari_scsi_falcon_reg_read( unsigned char reg ); | 205 | static unsigned char atari_scsi_falcon_reg_read(unsigned char reg); |
207 | static void atari_scsi_falcon_reg_write( unsigned char reg, unsigned char value ); | 206 | static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value); |
208 | 207 | ||
209 | /************************* End of Prototypes **************************/ | 208 | /************************* End of Prototypes **************************/ |
210 | 209 | ||
211 | 210 | ||
212 | static struct Scsi_Host *atari_scsi_host = NULL; | 211 | static struct Scsi_Host *atari_scsi_host; |
213 | static unsigned char (*atari_scsi_reg_read)( unsigned char reg ); | 212 | static unsigned char (*atari_scsi_reg_read)(unsigned char reg); |
214 | static void (*atari_scsi_reg_write)( unsigned char reg, unsigned char value ); | 213 | static void (*atari_scsi_reg_write)(unsigned char reg, unsigned char value); |
215 | 214 | ||
216 | #ifdef REAL_DMA | 215 | #ifdef REAL_DMA |
217 | static unsigned long atari_dma_residual, atari_dma_startaddr; | 216 | static unsigned long atari_dma_residual, atari_dma_startaddr; |
218 | static short atari_dma_active; | 217 | static short atari_dma_active; |
219 | /* pointer to the dribble buffer */ | 218 | /* pointer to the dribble buffer */ |
220 | static char *atari_dma_buffer = NULL; | 219 | static char *atari_dma_buffer; |
221 | /* precalculated physical address of the dribble buffer */ | 220 | /* precalculated physical address of the dribble buffer */ |
222 | static unsigned long atari_dma_phys_buffer; | 221 | static unsigned long atari_dma_phys_buffer; |
223 | /* != 0 tells the Falcon int handler to copy data from the dribble buffer */ | 222 | /* != 0 tells the Falcon int handler to copy data from the dribble buffer */ |
@@ -233,7 +232,7 @@ static char *atari_dma_orig_addr; | |||
233 | static unsigned long atari_dma_stram_mask; | 232 | static unsigned long atari_dma_stram_mask; |
234 | #define STRAM_ADDR(a) (((a) & atari_dma_stram_mask) == 0) | 233 | #define STRAM_ADDR(a) (((a) & atari_dma_stram_mask) == 0) |
235 | /* number of bytes to cut from a transfer to handle NCR overruns */ | 234 | /* number of bytes to cut from a transfer to handle NCR overruns */ |
236 | static int atari_read_overruns = 0; | 235 | static int atari_read_overruns; |
237 | #endif | 236 | #endif |
238 | 237 | ||
239 | static int setup_can_queue = -1; | 238 | static int setup_can_queue = -1; |
@@ -256,10 +255,10 @@ module_param(setup_hostid, int, 0); | |||
256 | 255 | ||
257 | #if defined(REAL_DMA) | 256 | #if defined(REAL_DMA) |
258 | 257 | ||
259 | static int scsi_dma_is_ignored_buserr( unsigned char dma_stat ) | 258 | static int scsi_dma_is_ignored_buserr(unsigned char dma_stat) |
260 | { | 259 | { |
261 | int i; | 260 | int i; |
262 | unsigned long addr = SCSI_DMA_READ_P( dma_addr ), end_addr; | 261 | unsigned long addr = SCSI_DMA_READ_P(dma_addr), end_addr; |
263 | 262 | ||
264 | if (dma_stat & 0x01) { | 263 | if (dma_stat & 0x01) { |
265 | 264 | ||
@@ -267,15 +266,14 @@ static int scsi_dma_is_ignored_buserr( unsigned char dma_stat ) | |||
267 | * physical memory chunk (DMA prefetch!), but that doesn't hurt. | 266 | * physical memory chunk (DMA prefetch!), but that doesn't hurt. |
268 | * Check for this case: | 267 | * Check for this case: |
269 | */ | 268 | */ |
270 | 269 | ||
271 | for( i = 0; i < m68k_num_memory; ++i ) { | 270 | for (i = 0; i < m68k_num_memory; ++i) { |
272 | end_addr = m68k_memory[i].addr + | 271 | end_addr = m68k_memory[i].addr + m68k_memory[i].size; |
273 | m68k_memory[i].size; | ||
274 | if (end_addr <= addr && addr <= end_addr + 4) | 272 | if (end_addr <= addr && addr <= end_addr + 4) |
275 | return( 1 ); | 273 | return 1; |
276 | } | 274 | } |
277 | } | 275 | } |
278 | return( 0 ); | 276 | return 0; |
279 | } | 277 | } |
280 | 278 | ||
281 | 279 | ||
@@ -284,28 +282,27 @@ static int scsi_dma_is_ignored_buserr( unsigned char dma_stat ) | |||
284 | * end-of-DMA, both SCSI ints are triggered simultaneously, so the NCR int has | 282 | * end-of-DMA, both SCSI ints are triggered simultaneously, so the NCR int has |
285 | * to clear the DMA int pending bit before it allows other level 6 interrupts. | 283 | * to clear the DMA int pending bit before it allows other level 6 interrupts. |
286 | */ | 284 | */ |
287 | static void scsi_dma_buserr (int irq, void *dummy) | 285 | static void scsi_dma_buserr(int irq, void *dummy) |
288 | { | 286 | { |
289 | unsigned char dma_stat = tt_scsi_dma.dma_ctrl; | 287 | unsigned char dma_stat = tt_scsi_dma.dma_ctrl; |
290 | 288 | ||
291 | /* Don't do anything if a NCR interrupt is pending. Probably it's just | 289 | /* Don't do anything if a NCR interrupt is pending. Probably it's just |
292 | * masked... */ | 290 | * masked... */ |
293 | if (atari_irq_pending( IRQ_TT_MFP_SCSI )) | 291 | if (atari_irq_pending(IRQ_TT_MFP_SCSI)) |
294 | return; | 292 | return; |
295 | 293 | ||
296 | printk("Bad SCSI DMA interrupt! dma_addr=0x%08lx dma_stat=%02x dma_cnt=%08lx\n", | 294 | printk("Bad SCSI DMA interrupt! dma_addr=0x%08lx dma_stat=%02x dma_cnt=%08lx\n", |
297 | SCSI_DMA_READ_P(dma_addr), dma_stat, SCSI_DMA_READ_P(dma_cnt)); | 295 | SCSI_DMA_READ_P(dma_addr), dma_stat, SCSI_DMA_READ_P(dma_cnt)); |
298 | if (dma_stat & 0x80) { | 296 | if (dma_stat & 0x80) { |
299 | if (!scsi_dma_is_ignored_buserr( dma_stat )) | 297 | if (!scsi_dma_is_ignored_buserr(dma_stat)) |
300 | printk( "SCSI DMA bus error -- bad DMA programming!\n" ); | 298 | printk("SCSI DMA bus error -- bad DMA programming!\n"); |
301 | } | 299 | } else { |
302 | else { | ||
303 | /* Under normal circumstances we never should get to this point, | 300 | /* Under normal circumstances we never should get to this point, |
304 | * since both interrupts are triggered simultaneously and the 5380 | 301 | * since both interrupts are triggered simultaneously and the 5380 |
305 | * int has higher priority. When this irq is handled, that DMA | 302 | * int has higher priority. When this irq is handled, that DMA |
306 | * interrupt is cleared. So a warning message is printed here. | 303 | * interrupt is cleared. So a warning message is printed here. |
307 | */ | 304 | */ |
308 | printk( "SCSI DMA intr ?? -- this shouldn't happen!\n" ); | 305 | printk("SCSI DMA intr ?? -- this shouldn't happen!\n"); |
309 | } | 306 | } |
310 | } | 307 | } |
311 | #endif | 308 | #endif |
@@ -313,7 +310,7 @@ static void scsi_dma_buserr (int irq, void *dummy) | |||
313 | #endif | 310 | #endif |
314 | 311 | ||
315 | 312 | ||
316 | static irqreturn_t scsi_tt_intr (int irq, void *dummy) | 313 | static irqreturn_t scsi_tt_intr(int irq, void *dummy) |
317 | { | 314 | { |
318 | #ifdef REAL_DMA | 315 | #ifdef REAL_DMA |
319 | int dma_stat; | 316 | int dma_stat; |
@@ -327,7 +324,7 @@ static irqreturn_t scsi_tt_intr (int irq, void *dummy) | |||
327 | * is that a bus error occurred... | 324 | * is that a bus error occurred... |
328 | */ | 325 | */ |
329 | if (dma_stat & 0x80) { | 326 | if (dma_stat & 0x80) { |
330 | if (!scsi_dma_is_ignored_buserr( dma_stat )) { | 327 | if (!scsi_dma_is_ignored_buserr(dma_stat)) { |
331 | printk(KERN_ERR "SCSI DMA caused bus error near 0x%08lx\n", | 328 | printk(KERN_ERR "SCSI DMA caused bus error near 0x%08lx\n", |
332 | SCSI_DMA_READ_P(dma_addr)); | 329 | SCSI_DMA_READ_P(dma_addr)); |
333 | printk(KERN_CRIT "SCSI DMA bus error -- bad DMA programming!"); | 330 | printk(KERN_CRIT "SCSI DMA bus error -- bad DMA programming!"); |
@@ -344,8 +341,7 @@ static irqreturn_t scsi_tt_intr (int irq, void *dummy) | |||
344 | * data reg! | 341 | * data reg! |
345 | */ | 342 | */ |
346 | if ((dma_stat & 0x02) && !(dma_stat & 0x40)) { | 343 | if ((dma_stat & 0x02) && !(dma_stat & 0x40)) { |
347 | atari_dma_residual = HOSTDATA_DMALEN - (SCSI_DMA_READ_P( dma_addr ) - | 344 | atari_dma_residual = HOSTDATA_DMALEN - (SCSI_DMA_READ_P(dma_addr) - atari_dma_startaddr); |
348 | atari_dma_startaddr); | ||
349 | 345 | ||
350 | DMA_PRINTK("SCSI DMA: There are %ld residual bytes.\n", | 346 | DMA_PRINTK("SCSI DMA: There are %ld residual bytes.\n", |
351 | atari_dma_residual); | 347 | atari_dma_residual); |
@@ -353,28 +349,30 @@ static irqreturn_t scsi_tt_intr (int irq, void *dummy) | |||
353 | if ((signed int)atari_dma_residual < 0) | 349 | if ((signed int)atari_dma_residual < 0) |
354 | atari_dma_residual = 0; | 350 | atari_dma_residual = 0; |
355 | if ((dma_stat & 1) == 0) { | 351 | if ((dma_stat & 1) == 0) { |
356 | /* After read operations, we maybe have to | 352 | /* |
357 | transport some rest bytes */ | 353 | * After read operations, we maybe have to |
354 | * transport some rest bytes | ||
355 | */ | ||
358 | atari_scsi_fetch_restbytes(); | 356 | atari_scsi_fetch_restbytes(); |
359 | } | 357 | } else { |
360 | else { | 358 | /* |
361 | /* There seems to be a nasty bug in some SCSI-DMA/NCR | 359 | * There seems to be a nasty bug in some SCSI-DMA/NCR |
362 | combinations: If a target disconnects while a write | 360 | * combinations: If a target disconnects while a write |
363 | operation is going on, the address register of the | 361 | * operation is going on, the address register of the |
364 | DMA may be a few bytes farer than it actually read. | 362 | * DMA may be a few bytes farer than it actually read. |
365 | This is probably due to DMA prefetching and a delay | 363 | * This is probably due to DMA prefetching and a delay |
366 | between DMA and NCR. Experiments showed that the | 364 | * between DMA and NCR. Experiments showed that the |
367 | dma_addr is 9 bytes to high, but this could vary. | 365 | * dma_addr is 9 bytes to high, but this could vary. |
368 | The problem is, that the residual is thus calculated | 366 | * The problem is, that the residual is thus calculated |
369 | wrong and the next transfer will start behind where | 367 | * wrong and the next transfer will start behind where |
370 | it should. So we round up the residual to the next | 368 | * it should. So we round up the residual to the next |
371 | multiple of a sector size, if it isn't already a | 369 | * multiple of a sector size, if it isn't already a |
372 | multiple and the originally expected transfer size | 370 | * multiple and the originally expected transfer size |
373 | was. The latter condition is there to ensure that | 371 | * was. The latter condition is there to ensure that |
374 | the correction is taken only for "real" data | 372 | * the correction is taken only for "real" data |
375 | transfers and not for, e.g., the parameters of some | 373 | * transfers and not for, e.g., the parameters of some |
376 | other command. These shouldn't disconnect anyway. | 374 | * other command. These shouldn't disconnect anyway. |
377 | */ | 375 | */ |
378 | if (atari_dma_residual & 0x1ff) { | 376 | if (atari_dma_residual & 0x1ff) { |
379 | DMA_PRINTK("SCSI DMA: DMA bug corrected, " | 377 | DMA_PRINTK("SCSI DMA: DMA bug corrected, " |
380 | "difference %ld bytes\n", | 378 | "difference %ld bytes\n", |
@@ -394,18 +392,18 @@ static irqreturn_t scsi_tt_intr (int irq, void *dummy) | |||
394 | } | 392 | } |
395 | 393 | ||
396 | #endif /* REAL_DMA */ | 394 | #endif /* REAL_DMA */ |
397 | 395 | ||
398 | NCR5380_intr (0, 0, 0); | 396 | NCR5380_intr(0, 0); |
399 | 397 | ||
400 | #if 0 | 398 | #if 0 |
401 | /* To be sure the int is not masked */ | 399 | /* To be sure the int is not masked */ |
402 | atari_enable_irq( IRQ_TT_MFP_SCSI ); | 400 | atari_enable_irq(IRQ_TT_MFP_SCSI); |
403 | #endif | 401 | #endif |
404 | return IRQ_HANDLED; | 402 | return IRQ_HANDLED; |
405 | } | 403 | } |
406 | 404 | ||
407 | 405 | ||
408 | static irqreturn_t scsi_falcon_intr (int irq, void *dummy) | 406 | static irqreturn_t scsi_falcon_intr(int irq, void *dummy) |
409 | { | 407 | { |
410 | #ifdef REAL_DMA | 408 | #ifdef REAL_DMA |
411 | int dma_stat; | 409 | int dma_stat; |
@@ -430,7 +428,7 @@ static irqreturn_t scsi_falcon_intr (int irq, void *dummy) | |||
430 | * bytes are stuck in the ST-DMA fifo (there's no way to reach them!) | 428 | * bytes are stuck in the ST-DMA fifo (there's no way to reach them!) |
431 | */ | 429 | */ |
432 | if (atari_dma_active && (dma_stat & 0x02)) { | 430 | if (atari_dma_active && (dma_stat & 0x02)) { |
433 | unsigned long transferred; | 431 | unsigned long transferred; |
434 | 432 | ||
435 | transferred = SCSI_DMA_GETADR() - atari_dma_startaddr; | 433 | transferred = SCSI_DMA_GETADR() - atari_dma_startaddr; |
436 | /* The ST-DMA address is incremented in 2-byte steps, but the | 434 | /* The ST-DMA address is incremented in 2-byte steps, but the |
@@ -445,8 +443,7 @@ static irqreturn_t scsi_falcon_intr (int irq, void *dummy) | |||
445 | atari_dma_residual = HOSTDATA_DMALEN - transferred; | 443 | atari_dma_residual = HOSTDATA_DMALEN - transferred; |
446 | DMA_PRINTK("SCSI DMA: There are %ld residual bytes.\n", | 444 | DMA_PRINTK("SCSI DMA: There are %ld residual bytes.\n", |
447 | atari_dma_residual); | 445 | atari_dma_residual); |
448 | } | 446 | } else |
449 | else | ||
450 | atari_dma_residual = 0; | 447 | atari_dma_residual = 0; |
451 | atari_dma_active = 0; | 448 | atari_dma_active = 0; |
452 | 449 | ||
@@ -461,13 +458,13 @@ static irqreturn_t scsi_falcon_intr (int irq, void *dummy) | |||
461 | 458 | ||
462 | #endif /* REAL_DMA */ | 459 | #endif /* REAL_DMA */ |
463 | 460 | ||
464 | NCR5380_intr (0, 0, 0); | 461 | NCR5380_intr(0, 0); |
465 | return IRQ_HANDLED; | 462 | return IRQ_HANDLED; |
466 | } | 463 | } |
467 | 464 | ||
468 | 465 | ||
469 | #ifdef REAL_DMA | 466 | #ifdef REAL_DMA |
470 | static void atari_scsi_fetch_restbytes( void ) | 467 | static void atari_scsi_fetch_restbytes(void) |
471 | { | 468 | { |
472 | int nr; | 469 | int nr; |
473 | char *src, *dst; | 470 | char *src, *dst; |
@@ -505,19 +502,17 @@ static int falcon_dont_release = 0; | |||
505 | * again (but others waiting longer more probably will win). | 502 | * again (but others waiting longer more probably will win). |
506 | */ | 503 | */ |
507 | 504 | ||
508 | static void | 505 | static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata) |
509 | falcon_release_lock_if_possible( struct NCR5380_hostdata * hostdata ) | ||
510 | { | 506 | { |
511 | unsigned long flags; | 507 | unsigned long flags; |
512 | 508 | ||
513 | if (IS_A_TT()) return; | 509 | if (IS_A_TT()) |
514 | 510 | return; | |
511 | |||
515 | local_irq_save(flags); | 512 | local_irq_save(flags); |
516 | 513 | ||
517 | if (falcon_got_lock && | 514 | if (falcon_got_lock && !hostdata->disconnected_queue && |
518 | !hostdata->disconnected_queue && | 515 | !hostdata->issue_queue && !hostdata->connected) { |
519 | !hostdata->issue_queue && | ||
520 | !hostdata->connected) { | ||
521 | 516 | ||
522 | if (falcon_dont_release) { | 517 | if (falcon_dont_release) { |
523 | #if 0 | 518 | #if 0 |
@@ -528,7 +523,7 @@ falcon_release_lock_if_possible( struct NCR5380_hostdata * hostdata ) | |||
528 | } | 523 | } |
529 | falcon_got_lock = 0; | 524 | falcon_got_lock = 0; |
530 | stdma_release(); | 525 | stdma_release(); |
531 | wake_up( &falcon_fairness_wait ); | 526 | wake_up(&falcon_fairness_wait); |
532 | } | 527 | } |
533 | 528 | ||
534 | local_irq_restore(flags); | 529 | local_irq_restore(flags); |
@@ -549,31 +544,31 @@ falcon_release_lock_if_possible( struct NCR5380_hostdata * hostdata ) | |||
549 | * Complicated, complicated.... Sigh... | 544 | * Complicated, complicated.... Sigh... |
550 | */ | 545 | */ |
551 | 546 | ||
552 | static void falcon_get_lock( void ) | 547 | static void falcon_get_lock(void) |
553 | { | 548 | { |
554 | unsigned long flags; | 549 | unsigned long flags; |
555 | 550 | ||
556 | if (IS_A_TT()) return; | 551 | if (IS_A_TT()) |
552 | return; | ||
557 | 553 | ||
558 | local_irq_save(flags); | 554 | local_irq_save(flags); |
559 | 555 | ||
560 | while( !in_interrupt() && falcon_got_lock && stdma_others_waiting() ) | 556 | while (!in_irq() && falcon_got_lock && stdma_others_waiting()) |
561 | sleep_on( &falcon_fairness_wait ); | 557 | sleep_on(&falcon_fairness_wait); |
562 | 558 | ||
563 | while (!falcon_got_lock) { | 559 | while (!falcon_got_lock) { |
564 | if (in_interrupt()) | 560 | if (in_irq()) |
565 | panic( "Falcon SCSI hasn't ST-DMA lock in interrupt" ); | 561 | panic("Falcon SCSI hasn't ST-DMA lock in interrupt"); |
566 | if (!falcon_trying_lock) { | 562 | if (!falcon_trying_lock) { |
567 | falcon_trying_lock = 1; | 563 | falcon_trying_lock = 1; |
568 | stdma_lock(scsi_falcon_intr, NULL); | 564 | stdma_lock(scsi_falcon_intr, NULL); |
569 | falcon_got_lock = 1; | 565 | falcon_got_lock = 1; |
570 | falcon_trying_lock = 0; | 566 | falcon_trying_lock = 0; |
571 | wake_up( &falcon_try_wait ); | 567 | wake_up(&falcon_try_wait); |
572 | } | 568 | } else { |
573 | else { | 569 | sleep_on(&falcon_try_wait); |
574 | sleep_on( &falcon_try_wait ); | ||
575 | } | 570 | } |
576 | } | 571 | } |
577 | 572 | ||
578 | local_irq_restore(flags); | 573 | local_irq_restore(flags); |
579 | if (!falcon_got_lock) | 574 | if (!falcon_got_lock) |
@@ -587,18 +582,18 @@ static void falcon_get_lock( void ) | |||
587 | */ | 582 | */ |
588 | 583 | ||
589 | #if 0 | 584 | #if 0 |
590 | int atari_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) | 585 | int atari_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) |
591 | { | 586 | { |
592 | /* falcon_get_lock(); | 587 | /* falcon_get_lock(); |
593 | * ++guenther: moved to NCR5380_queue_command() to prevent | 588 | * ++guenther: moved to NCR5380_queue_command() to prevent |
594 | * race condition, see there for an explanation. | 589 | * race condition, see there for an explanation. |
595 | */ | 590 | */ |
596 | return( NCR5380_queue_command( cmd, done ) ); | 591 | return NCR5380_queue_command(cmd, done); |
597 | } | 592 | } |
598 | #endif | 593 | #endif |
599 | 594 | ||
600 | 595 | ||
601 | int atari_scsi_detect (struct scsi_host_template *host) | 596 | int atari_scsi_detect(struct scsi_host_template *host) |
602 | { | 597 | { |
603 | static int called = 0; | 598 | static int called = 0; |
604 | struct Scsi_Host *instance; | 599 | struct Scsi_Host *instance; |
@@ -606,7 +601,7 @@ int atari_scsi_detect (struct scsi_host_template *host) | |||
606 | if (!MACH_IS_ATARI || | 601 | if (!MACH_IS_ATARI || |
607 | (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) || | 602 | (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) || |
608 | called) | 603 | called) |
609 | return( 0 ); | 604 | return 0; |
610 | 605 | ||
611 | host->proc_name = "Atari"; | 606 | host->proc_name = "Atari"; |
612 | 607 | ||
@@ -655,32 +650,33 @@ int atari_scsi_detect (struct scsi_host_template *host) | |||
655 | !ATARIHW_PRESENT(EXTD_DMA) && m68k_num_memory > 1) { | 650 | !ATARIHW_PRESENT(EXTD_DMA) && m68k_num_memory > 1) { |
656 | atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI"); | 651 | atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI"); |
657 | if (!atari_dma_buffer) { | 652 | if (!atari_dma_buffer) { |
658 | printk( KERN_ERR "atari_scsi_detect: can't allocate ST-RAM " | 653 | printk(KERN_ERR "atari_scsi_detect: can't allocate ST-RAM " |
659 | "double buffer\n" ); | 654 | "double buffer\n"); |
660 | return( 0 ); | 655 | return 0; |
661 | } | 656 | } |
662 | atari_dma_phys_buffer = virt_to_phys( atari_dma_buffer ); | 657 | atari_dma_phys_buffer = virt_to_phys(atari_dma_buffer); |
663 | atari_dma_orig_addr = 0; | 658 | atari_dma_orig_addr = 0; |
664 | } | 659 | } |
665 | #endif | 660 | #endif |
666 | instance = scsi_register (host, sizeof (struct NCR5380_hostdata)); | 661 | instance = scsi_register(host, sizeof(struct NCR5380_hostdata)); |
667 | if(instance == NULL) | 662 | if (instance == NULL) { |
668 | { | ||
669 | atari_stram_free(atari_dma_buffer); | 663 | atari_stram_free(atari_dma_buffer); |
670 | atari_dma_buffer = 0; | 664 | atari_dma_buffer = 0; |
671 | return 0; | 665 | return 0; |
672 | } | 666 | } |
673 | atari_scsi_host = instance; | 667 | atari_scsi_host = instance; |
674 | /* Set irq to 0, to avoid that the mid-level code disables our interrupt | 668 | /* |
675 | * during queue_command calls. This is completely unnecessary, and even | 669 | * Set irq to 0, to avoid that the mid-level code disables our interrupt |
676 | * worse causes bad problems on the Falcon, where the int is shared with | 670 | * during queue_command calls. This is completely unnecessary, and even |
677 | * IDE and floppy! */ | 671 | * worse causes bad problems on the Falcon, where the int is shared with |
672 | * IDE and floppy! | ||
673 | */ | ||
678 | instance->irq = 0; | 674 | instance->irq = 0; |
679 | 675 | ||
680 | #ifdef CONFIG_ATARI_SCSI_RESET_BOOT | 676 | #ifdef CONFIG_ATARI_SCSI_RESET_BOOT |
681 | atari_scsi_reset_boot(); | 677 | atari_scsi_reset_boot(); |
682 | #endif | 678 | #endif |
683 | NCR5380_init (instance, 0); | 679 | NCR5380_init(instance, 0); |
684 | 680 | ||
685 | if (IS_A_TT()) { | 681 | if (IS_A_TT()) { |
686 | 682 | ||
@@ -727,11 +723,10 @@ int atari_scsi_detect (struct scsi_host_template *host) | |||
727 | * the rest data bug is fixed, this can be lowered to 1. | 723 | * the rest data bug is fixed, this can be lowered to 1. |
728 | */ | 724 | */ |
729 | atari_read_overruns = 4; | 725 | atari_read_overruns = 4; |
730 | } | 726 | } |
731 | #endif /*REAL_DMA*/ | 727 | #endif /*REAL_DMA*/ |
732 | } | 728 | } else { /* ! IS_A_TT */ |
733 | else { /* ! IS_A_TT */ | 729 | |
734 | |||
735 | /* Nothing to do for the interrupt: the ST-DMA is initialized | 730 | /* Nothing to do for the interrupt: the ST-DMA is initialized |
736 | * already by atari_init_INTS() | 731 | * already by atari_init_INTS() |
737 | */ | 732 | */ |
@@ -756,23 +751,21 @@ int atari_scsi_detect (struct scsi_host_template *host) | |||
756 | setup_use_tagged_queuing ? "yes" : "no", | 751 | setup_use_tagged_queuing ? "yes" : "no", |
757 | #endif | 752 | #endif |
758 | instance->hostt->this_id ); | 753 | instance->hostt->this_id ); |
759 | NCR5380_print_options (instance); | 754 | NCR5380_print_options(instance); |
760 | printk ("\n"); | 755 | printk("\n"); |
761 | 756 | ||
762 | called = 1; | 757 | called = 1; |
763 | return( 1 ); | 758 | return 1; |
764 | } | 759 | } |
765 | 760 | ||
766 | #ifdef MODULE | 761 | int atari_scsi_release(struct Scsi_Host *sh) |
767 | int atari_scsi_release (struct Scsi_Host *sh) | ||
768 | { | 762 | { |
769 | if (IS_A_TT()) | 763 | if (IS_A_TT()) |
770 | free_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr); | 764 | free_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr); |
771 | if (atari_dma_buffer) | 765 | if (atari_dma_buffer) |
772 | atari_stram_free (atari_dma_buffer); | 766 | atari_stram_free(atari_dma_buffer); |
773 | return 1; | 767 | return 1; |
774 | } | 768 | } |
775 | #endif | ||
776 | 769 | ||
777 | void __init atari_scsi_setup(char *str, int *ints) | 770 | void __init atari_scsi_setup(char *str, int *ints) |
778 | { | 771 | { |
@@ -781,9 +774,9 @@ void __init atari_scsi_setup(char *str, int *ints) | |||
781 | * Defaults depend on TT or Falcon, hostid determined at run time. | 774 | * Defaults depend on TT or Falcon, hostid determined at run time. |
782 | * Negative values mean don't change. | 775 | * Negative values mean don't change. |
783 | */ | 776 | */ |
784 | 777 | ||
785 | if (ints[0] < 1) { | 778 | if (ints[0] < 1) { |
786 | printk( "atari_scsi_setup: no arguments!\n" ); | 779 | printk("atari_scsi_setup: no arguments!\n"); |
787 | return; | 780 | return; |
788 | } | 781 | } |
789 | 782 | ||
@@ -809,7 +802,7 @@ void __init atari_scsi_setup(char *str, int *ints) | |||
809 | if (ints[4] >= 0 && ints[4] <= 7) | 802 | if (ints[4] >= 0 && ints[4] <= 7) |
810 | setup_hostid = ints[4]; | 803 | setup_hostid = ints[4]; |
811 | else if (ints[4] > 7) | 804 | else if (ints[4] > 7) |
812 | printk( "atari_scsi_setup: invalid host ID %d !\n", ints[4] ); | 805 | printk("atari_scsi_setup: invalid host ID %d !\n", ints[4]); |
813 | } | 806 | } |
814 | #ifdef SUPPORT_TAGS | 807 | #ifdef SUPPORT_TAGS |
815 | if (ints[0] >= 5) { | 808 | if (ints[0] >= 5) { |
@@ -821,7 +814,7 @@ void __init atari_scsi_setup(char *str, int *ints) | |||
821 | 814 | ||
822 | int atari_scsi_bus_reset(Scsi_Cmnd *cmd) | 815 | int atari_scsi_bus_reset(Scsi_Cmnd *cmd) |
823 | { | 816 | { |
824 | int rv; | 817 | int rv; |
825 | struct NCR5380_hostdata *hostdata = | 818 | struct NCR5380_hostdata *hostdata = |
826 | (struct NCR5380_hostdata *)cmd->device->host->hostdata; | 819 | (struct NCR5380_hostdata *)cmd->device->host->hostdata; |
827 | 820 | ||
@@ -831,13 +824,12 @@ int atari_scsi_bus_reset(Scsi_Cmnd *cmd) | |||
831 | */ | 824 | */ |
832 | /* And abort a maybe active DMA transfer */ | 825 | /* And abort a maybe active DMA transfer */ |
833 | if (IS_A_TT()) { | 826 | if (IS_A_TT()) { |
834 | atari_turnoff_irq( IRQ_TT_MFP_SCSI ); | 827 | atari_turnoff_irq(IRQ_TT_MFP_SCSI); |
835 | #ifdef REAL_DMA | 828 | #ifdef REAL_DMA |
836 | tt_scsi_dma.dma_ctrl = 0; | 829 | tt_scsi_dma.dma_ctrl = 0; |
837 | #endif /* REAL_DMA */ | 830 | #endif /* REAL_DMA */ |
838 | } | 831 | } else { |
839 | else { | 832 | atari_turnoff_irq(IRQ_MFP_FSCSI); |
840 | atari_turnoff_irq( IRQ_MFP_FSCSI ); | ||
841 | #ifdef REAL_DMA | 833 | #ifdef REAL_DMA |
842 | st_dma.dma_mode_status = 0x90; | 834 | st_dma.dma_mode_status = 0x90; |
843 | atari_dma_active = 0; | 835 | atari_dma_active = 0; |
@@ -849,52 +841,51 @@ int atari_scsi_bus_reset(Scsi_Cmnd *cmd) | |||
849 | 841 | ||
850 | /* Re-enable ints */ | 842 | /* Re-enable ints */ |
851 | if (IS_A_TT()) { | 843 | if (IS_A_TT()) { |
852 | atari_turnon_irq( IRQ_TT_MFP_SCSI ); | 844 | atari_turnon_irq(IRQ_TT_MFP_SCSI); |
853 | } | 845 | } else { |
854 | else { | 846 | atari_turnon_irq(IRQ_MFP_FSCSI); |
855 | atari_turnon_irq( IRQ_MFP_FSCSI ); | ||
856 | } | 847 | } |
857 | if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS) | 848 | if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS) |
858 | falcon_release_lock_if_possible(hostdata); | 849 | falcon_release_lock_if_possible(hostdata); |
859 | 850 | ||
860 | return( rv ); | 851 | return rv; |
861 | } | 852 | } |
862 | 853 | ||
863 | 854 | ||
864 | #ifdef CONFIG_ATARI_SCSI_RESET_BOOT | 855 | #ifdef CONFIG_ATARI_SCSI_RESET_BOOT |
865 | static void __init atari_scsi_reset_boot(void) | 856 | static void __init atari_scsi_reset_boot(void) |
866 | { | 857 | { |
867 | unsigned long end; | 858 | unsigned long end; |
868 | 859 | ||
869 | /* | 860 | /* |
870 | * Do a SCSI reset to clean up the bus during initialization. No messing | 861 | * Do a SCSI reset to clean up the bus during initialization. No messing |
871 | * with the queues, interrupts, or locks necessary here. | 862 | * with the queues, interrupts, or locks necessary here. |
872 | */ | 863 | */ |
873 | 864 | ||
874 | printk( "Atari SCSI: resetting the SCSI bus..." ); | 865 | printk("Atari SCSI: resetting the SCSI bus..."); |
875 | 866 | ||
876 | /* get in phase */ | 867 | /* get in phase */ |
877 | NCR5380_write( TARGET_COMMAND_REG, | 868 | NCR5380_write(TARGET_COMMAND_REG, |
878 | PHASE_SR_TO_TCR( NCR5380_read(STATUS_REG) )); | 869 | PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG))); |
879 | 870 | ||
880 | /* assert RST */ | 871 | /* assert RST */ |
881 | NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST ); | 872 | NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST); |
882 | /* The min. reset hold time is 25us, so 40us should be enough */ | 873 | /* The min. reset hold time is 25us, so 40us should be enough */ |
883 | udelay( 50 ); | 874 | udelay(50); |
884 | /* reset RST and interrupt */ | 875 | /* reset RST and interrupt */ |
885 | NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE ); | 876 | NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); |
886 | NCR5380_read( RESET_PARITY_INTERRUPT_REG ); | 877 | NCR5380_read(RESET_PARITY_INTERRUPT_REG); |
887 | 878 | ||
888 | end = jiffies + AFTER_RESET_DELAY; | 879 | end = jiffies + AFTER_RESET_DELAY; |
889 | while (time_before(jiffies, end)) | 880 | while (time_before(jiffies, end)) |
890 | barrier(); | 881 | barrier(); |
891 | 882 | ||
892 | printk( " done\n" ); | 883 | printk(" done\n"); |
893 | } | 884 | } |
894 | #endif | 885 | #endif |
895 | 886 | ||
896 | 887 | ||
897 | const char * atari_scsi_info (struct Scsi_Host *host) | 888 | const char *atari_scsi_info(struct Scsi_Host *host) |
898 | { | 889 | { |
899 | /* atari_scsi_detect() is verbose enough... */ | 890 | /* atari_scsi_detect() is verbose enough... */ |
900 | static const char string[] = "Atari native SCSI"; | 891 | static const char string[] = "Atari native SCSI"; |
@@ -904,10 +895,10 @@ const char * atari_scsi_info (struct Scsi_Host *host) | |||
904 | 895 | ||
905 | #if defined(REAL_DMA) | 896 | #if defined(REAL_DMA) |
906 | 897 | ||
907 | unsigned long atari_scsi_dma_setup( struct Scsi_Host *instance, void *data, | 898 | unsigned long atari_scsi_dma_setup(struct Scsi_Host *instance, void *data, |
908 | unsigned long count, int dir ) | 899 | unsigned long count, int dir) |
909 | { | 900 | { |
910 | unsigned long addr = virt_to_phys( data ); | 901 | unsigned long addr = virt_to_phys(data); |
911 | 902 | ||
912 | DMA_PRINTK("scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, " | 903 | DMA_PRINTK("scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, " |
913 | "dir = %d\n", instance->host_no, data, addr, count, dir); | 904 | "dir = %d\n", instance->host_no, data, addr, count, dir); |
@@ -919,38 +910,37 @@ unsigned long atari_scsi_dma_setup( struct Scsi_Host *instance, void *data, | |||
919 | * wanted address. | 910 | * wanted address. |
920 | */ | 911 | */ |
921 | if (dir) | 912 | if (dir) |
922 | memcpy( atari_dma_buffer, data, count ); | 913 | memcpy(atari_dma_buffer, data, count); |
923 | else | 914 | else |
924 | atari_dma_orig_addr = data; | 915 | atari_dma_orig_addr = data; |
925 | addr = atari_dma_phys_buffer; | 916 | addr = atari_dma_phys_buffer; |
926 | } | 917 | } |
927 | 918 | ||
928 | atari_dma_startaddr = addr; /* Needed for calculating residual later. */ | 919 | atari_dma_startaddr = addr; /* Needed for calculating residual later. */ |
929 | 920 | ||
930 | /* Cache cleanup stuff: On writes, push any dirty cache out before sending | 921 | /* Cache cleanup stuff: On writes, push any dirty cache out before sending |
931 | * it to the peripheral. (Must be done before DMA setup, since at least | 922 | * it to the peripheral. (Must be done before DMA setup, since at least |
932 | * the ST-DMA begins to fill internal buffers right after setup. For | 923 | * the ST-DMA begins to fill internal buffers right after setup. For |
933 | * reads, invalidate any cache, may be altered after DMA without CPU | 924 | * reads, invalidate any cache, may be altered after DMA without CPU |
934 | * knowledge. | 925 | * knowledge. |
935 | * | 926 | * |
936 | * ++roman: For the Medusa, there's no need at all for that cache stuff, | 927 | * ++roman: For the Medusa, there's no need at all for that cache stuff, |
937 | * because the hardware does bus snooping (fine!). | 928 | * because the hardware does bus snooping (fine!). |
938 | */ | 929 | */ |
939 | dma_cache_maintenance( addr, count, dir ); | 930 | dma_cache_maintenance(addr, count, dir); |
940 | 931 | ||
941 | if (count == 0) | 932 | if (count == 0) |
942 | printk(KERN_NOTICE "SCSI warning: DMA programmed for 0 bytes !\n"); | 933 | printk(KERN_NOTICE "SCSI warning: DMA programmed for 0 bytes !\n"); |
943 | 934 | ||
944 | if (IS_A_TT()) { | 935 | if (IS_A_TT()) { |
945 | tt_scsi_dma.dma_ctrl = dir; | 936 | tt_scsi_dma.dma_ctrl = dir; |
946 | SCSI_DMA_WRITE_P( dma_addr, addr ); | 937 | SCSI_DMA_WRITE_P(dma_addr, addr); |
947 | SCSI_DMA_WRITE_P( dma_cnt, count ); | 938 | SCSI_DMA_WRITE_P(dma_cnt, count); |
948 | tt_scsi_dma.dma_ctrl = dir | 2; | 939 | tt_scsi_dma.dma_ctrl = dir | 2; |
949 | } | 940 | } else { /* ! IS_A_TT */ |
950 | else { /* ! IS_A_TT */ | 941 | |
951 | |||
952 | /* set address */ | 942 | /* set address */ |
953 | SCSI_DMA_SETADR( addr ); | 943 | SCSI_DMA_SETADR(addr); |
954 | 944 | ||
955 | /* toggle direction bit to clear FIFO and set DMA direction */ | 945 | /* toggle direction bit to clear FIFO and set DMA direction */ |
956 | dir <<= 8; | 946 | dir <<= 8; |
@@ -968,13 +958,13 @@ unsigned long atari_scsi_dma_setup( struct Scsi_Host *instance, void *data, | |||
968 | atari_dma_active = 1; | 958 | atari_dma_active = 1; |
969 | } | 959 | } |
970 | 960 | ||
971 | return( count ); | 961 | return count; |
972 | } | 962 | } |
973 | 963 | ||
974 | 964 | ||
975 | static long atari_scsi_dma_residual( struct Scsi_Host *instance ) | 965 | static long atari_scsi_dma_residual(struct Scsi_Host *instance) |
976 | { | 966 | { |
977 | return( atari_dma_residual ); | 967 | return atari_dma_residual; |
978 | } | 968 | } |
979 | 969 | ||
980 | 970 | ||
@@ -982,13 +972,13 @@ static long atari_scsi_dma_residual( struct Scsi_Host *instance ) | |||
982 | #define CMD_SURELY_BYTE_MODE 1 | 972 | #define CMD_SURELY_BYTE_MODE 1 |
983 | #define CMD_MODE_UNKNOWN 2 | 973 | #define CMD_MODE_UNKNOWN 2 |
984 | 974 | ||
985 | static int falcon_classify_cmd( Scsi_Cmnd *cmd ) | 975 | static int falcon_classify_cmd(Scsi_Cmnd *cmd) |
986 | { | 976 | { |
987 | unsigned char opcode = cmd->cmnd[0]; | 977 | unsigned char opcode = cmd->cmnd[0]; |
988 | 978 | ||
989 | if (opcode == READ_DEFECT_DATA || opcode == READ_LONG || | 979 | if (opcode == READ_DEFECT_DATA || opcode == READ_LONG || |
990 | opcode == READ_BUFFER) | 980 | opcode == READ_BUFFER) |
991 | return( CMD_SURELY_BYTE_MODE ); | 981 | return CMD_SURELY_BYTE_MODE; |
992 | else if (opcode == READ_6 || opcode == READ_10 || | 982 | else if (opcode == READ_6 || opcode == READ_10 || |
993 | opcode == 0xa8 /* READ_12 */ || opcode == READ_REVERSE || | 983 | opcode == 0xa8 /* READ_12 */ || opcode == READ_REVERSE || |
994 | opcode == RECOVER_BUFFERED_DATA) { | 984 | opcode == RECOVER_BUFFERED_DATA) { |
@@ -996,12 +986,11 @@ static int falcon_classify_cmd( Scsi_Cmnd *cmd ) | |||
996 | * needed here: The transfer is block-mode only if the 'fixed' bit is | 986 | * needed here: The transfer is block-mode only if the 'fixed' bit is |
997 | * set! */ | 987 | * set! */ |
998 | if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1)) | 988 | if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1)) |
999 | return( CMD_SURELY_BYTE_MODE ); | 989 | return CMD_SURELY_BYTE_MODE; |
1000 | else | 990 | else |
1001 | return( CMD_SURELY_BLOCK_MODE ); | 991 | return CMD_SURELY_BLOCK_MODE; |
1002 | } | 992 | } else |
1003 | else | 993 | return CMD_MODE_UNKNOWN; |
1004 | return( CMD_MODE_UNKNOWN ); | ||
1005 | } | 994 | } |
1006 | 995 | ||
1007 | 996 | ||
@@ -1014,19 +1003,18 @@ static int falcon_classify_cmd( Scsi_Cmnd *cmd ) | |||
1014 | * the overrun problem, so this question is academic :-) | 1003 | * the overrun problem, so this question is academic :-) |
1015 | */ | 1004 | */ |
1016 | 1005 | ||
1017 | static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | 1006 | static unsigned long atari_dma_xfer_len(unsigned long wanted_len, |
1018 | Scsi_Cmnd *cmd, | 1007 | Scsi_Cmnd *cmd, int write_flag) |
1019 | int write_flag ) | ||
1020 | { | 1008 | { |
1021 | unsigned long possible_len, limit; | 1009 | unsigned long possible_len, limit; |
1022 | #ifndef CONFIG_TT_DMA_EMUL | 1010 | #ifndef CONFIG_TT_DMA_EMUL |
1023 | if (MACH_IS_HADES) | 1011 | if (MACH_IS_HADES) |
1024 | /* Hades has no SCSI DMA at all :-( Always force use of PIO */ | 1012 | /* Hades has no SCSI DMA at all :-( Always force use of PIO */ |
1025 | return( 0 ); | 1013 | return 0; |
1026 | #endif | 1014 | #endif |
1027 | if (IS_A_TT()) | 1015 | if (IS_A_TT()) |
1028 | /* TT SCSI DMA can transfer arbitrary #bytes */ | 1016 | /* TT SCSI DMA can transfer arbitrary #bytes */ |
1029 | return( wanted_len ); | 1017 | return wanted_len; |
1030 | 1018 | ||
1031 | /* ST DMA chip is stupid -- only multiples of 512 bytes! (and max. | 1019 | /* ST DMA chip is stupid -- only multiples of 512 bytes! (and max. |
1032 | * 255*512 bytes, but this should be enough) | 1020 | * 255*512 bytes, but this should be enough) |
@@ -1062,8 +1050,7 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1062 | * this). | 1050 | * this). |
1063 | */ | 1051 | */ |
1064 | possible_len = wanted_len; | 1052 | possible_len = wanted_len; |
1065 | } | 1053 | } else { |
1066 | else { | ||
1067 | /* Read operations: if the wanted transfer length is not a multiple of | 1054 | /* Read operations: if the wanted transfer length is not a multiple of |
1068 | * 512, we cannot use DMA, since the ST-DMA cannot split transfers | 1055 | * 512, we cannot use DMA, since the ST-DMA cannot split transfers |
1069 | * (no interrupt on DMA finished!) | 1056 | * (no interrupt on DMA finished!) |
@@ -1073,15 +1060,15 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1073 | else { | 1060 | else { |
1074 | /* Now classify the command (see above) and decide whether it is | 1061 | /* Now classify the command (see above) and decide whether it is |
1075 | * allowed to do DMA at all */ | 1062 | * allowed to do DMA at all */ |
1076 | switch( falcon_classify_cmd( cmd )) { | 1063 | switch (falcon_classify_cmd(cmd)) { |
1077 | case CMD_SURELY_BLOCK_MODE: | 1064 | case CMD_SURELY_BLOCK_MODE: |
1078 | possible_len = wanted_len; | 1065 | possible_len = wanted_len; |
1079 | break; | 1066 | break; |
1080 | case CMD_SURELY_BYTE_MODE: | 1067 | case CMD_SURELY_BYTE_MODE: |
1081 | possible_len = 0; /* DMA prohibited */ | 1068 | possible_len = 0; /* DMA prohibited */ |
1082 | break; | 1069 | break; |
1083 | case CMD_MODE_UNKNOWN: | 1070 | case CMD_MODE_UNKNOWN: |
1084 | default: | 1071 | default: |
1085 | /* For unknown commands assume block transfers if the transfer | 1072 | /* For unknown commands assume block transfers if the transfer |
1086 | * size/allocation length is >= 1024 */ | 1073 | * size/allocation length is >= 1024 */ |
1087 | possible_len = (wanted_len < 1024) ? 0 : wanted_len; | 1074 | possible_len = (wanted_len < 1024) ? 0 : wanted_len; |
@@ -1089,9 +1076,9 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1089 | } | 1076 | } |
1090 | } | 1077 | } |
1091 | } | 1078 | } |
1092 | 1079 | ||
1093 | /* Last step: apply the hard limit on DMA transfers */ | 1080 | /* Last step: apply the hard limit on DMA transfers */ |
1094 | limit = (atari_dma_buffer && !STRAM_ADDR( virt_to_phys(cmd->SCp.ptr) )) ? | 1081 | limit = (atari_dma_buffer && !STRAM_ADDR(virt_to_phys(cmd->SCp.ptr))) ? |
1095 | STRAM_BUFFER_SIZE : 255*512; | 1082 | STRAM_BUFFER_SIZE : 255*512; |
1096 | if (possible_len > limit) | 1083 | if (possible_len > limit) |
1097 | possible_len = limit; | 1084 | possible_len = limit; |
@@ -1100,7 +1087,7 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1100 | DMA_PRINTK("Sorry, must cut DMA transfer size to %ld bytes " | 1087 | DMA_PRINTK("Sorry, must cut DMA transfer size to %ld bytes " |
1101 | "instead of %ld\n", possible_len, wanted_len); | 1088 | "instead of %ld\n", possible_len, wanted_len); |
1102 | 1089 | ||
1103 | return( possible_len ); | 1090 | return possible_len; |
1104 | } | 1091 | } |
1105 | 1092 | ||
1106 | 1093 | ||
@@ -1114,23 +1101,23 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1114 | * NCR5380_write call these functions via function pointers. | 1101 | * NCR5380_write call these functions via function pointers. |
1115 | */ | 1102 | */ |
1116 | 1103 | ||
1117 | static unsigned char atari_scsi_tt_reg_read( unsigned char reg ) | 1104 | static unsigned char atari_scsi_tt_reg_read(unsigned char reg) |
1118 | { | 1105 | { |
1119 | return( tt_scsi_regp[reg * 2] ); | 1106 | return tt_scsi_regp[reg * 2]; |
1120 | } | 1107 | } |
1121 | 1108 | ||
1122 | static void atari_scsi_tt_reg_write( unsigned char reg, unsigned char value ) | 1109 | static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value) |
1123 | { | 1110 | { |
1124 | tt_scsi_regp[reg * 2] = value; | 1111 | tt_scsi_regp[reg * 2] = value; |
1125 | } | 1112 | } |
1126 | 1113 | ||
1127 | static unsigned char atari_scsi_falcon_reg_read( unsigned char reg ) | 1114 | static unsigned char atari_scsi_falcon_reg_read(unsigned char reg) |
1128 | { | 1115 | { |
1129 | dma_wd.dma_mode_status= (u_short)(0x88 + reg); | 1116 | dma_wd.dma_mode_status= (u_short)(0x88 + reg); |
1130 | return( (u_char)dma_wd.fdc_acces_seccount ); | 1117 | return (u_char)dma_wd.fdc_acces_seccount; |
1131 | } | 1118 | } |
1132 | 1119 | ||
1133 | static void atari_scsi_falcon_reg_write( unsigned char reg, unsigned char value ) | 1120 | static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value) |
1134 | { | 1121 | { |
1135 | dma_wd.dma_mode_status = (u_short)(0x88 + reg); | 1122 | dma_wd.dma_mode_status = (u_short)(0x88 + reg); |
1136 | dma_wd.fdc_acces_seccount = (u_short)value; | 1123 | dma_wd.fdc_acces_seccount = (u_short)value; |