diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2007-05-01 16:32:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-04 20:59:05 -0400 |
commit | c28bda25175913c88396b643813321ef9cffe663 (patch) | |
tree | 0245b5b6fdd5914b68574359a8f1b10a8896c501 /drivers/scsi/atari_scsi.c | |
parent | fb810d121bceb945c5e576356bccba11cbfad7e3 (diff) |
m68k: Reformat the Atari SCSI driver
Reformat the Atari SCSI driver
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/scsi/atari_scsi.c')
-rw-r--r-- | drivers/scsi/atari_scsi.c | 361 |
1 files changed, 175 insertions, 186 deletions
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 85b8acc94034..f766d0d81c99 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c | |||
@@ -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); | 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 | ||
@@ -467,7 +464,7 @@ static irqreturn_t scsi_falcon_intr (int irq, void *dummy) | |||
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_irq() && 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_irq()) | 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,19 +751,19 @@ 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 | int atari_scsi_release (struct Scsi_Host *sh) | 761 | int atari_scsi_release(struct Scsi_Host *sh) |
767 | { | 762 | { |
768 | if (IS_A_TT()) | 763 | if (IS_A_TT()) |
769 | free_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr); | 764 | free_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr); |
770 | if (atari_dma_buffer) | 765 | if (atari_dma_buffer) |
771 | atari_stram_free (atari_dma_buffer); | 766 | atari_stram_free(atari_dma_buffer); |
772 | return 1; | 767 | return 1; |
773 | } | 768 | } |
774 | 769 | ||
@@ -779,9 +774,9 @@ void __init atari_scsi_setup(char *str, int *ints) | |||
779 | * Defaults depend on TT or Falcon, hostid determined at run time. | 774 | * Defaults depend on TT or Falcon, hostid determined at run time. |
780 | * Negative values mean don't change. | 775 | * Negative values mean don't change. |
781 | */ | 776 | */ |
782 | 777 | ||
783 | if (ints[0] < 1) { | 778 | if (ints[0] < 1) { |
784 | printk( "atari_scsi_setup: no arguments!\n" ); | 779 | printk("atari_scsi_setup: no arguments!\n"); |
785 | return; | 780 | return; |
786 | } | 781 | } |
787 | 782 | ||
@@ -807,7 +802,7 @@ void __init atari_scsi_setup(char *str, int *ints) | |||
807 | if (ints[4] >= 0 && ints[4] <= 7) | 802 | if (ints[4] >= 0 && ints[4] <= 7) |
808 | setup_hostid = ints[4]; | 803 | setup_hostid = ints[4]; |
809 | else if (ints[4] > 7) | 804 | else if (ints[4] > 7) |
810 | printk( "atari_scsi_setup: invalid host ID %d !\n", ints[4] ); | 805 | printk("atari_scsi_setup: invalid host ID %d !\n", ints[4]); |
811 | } | 806 | } |
812 | #ifdef SUPPORT_TAGS | 807 | #ifdef SUPPORT_TAGS |
813 | if (ints[0] >= 5) { | 808 | if (ints[0] >= 5) { |
@@ -819,7 +814,7 @@ void __init atari_scsi_setup(char *str, int *ints) | |||
819 | 814 | ||
820 | int atari_scsi_bus_reset(Scsi_Cmnd *cmd) | 815 | int atari_scsi_bus_reset(Scsi_Cmnd *cmd) |
821 | { | 816 | { |
822 | int rv; | 817 | int rv; |
823 | struct NCR5380_hostdata *hostdata = | 818 | struct NCR5380_hostdata *hostdata = |
824 | (struct NCR5380_hostdata *)cmd->device->host->hostdata; | 819 | (struct NCR5380_hostdata *)cmd->device->host->hostdata; |
825 | 820 | ||
@@ -829,13 +824,12 @@ int atari_scsi_bus_reset(Scsi_Cmnd *cmd) | |||
829 | */ | 824 | */ |
830 | /* And abort a maybe active DMA transfer */ | 825 | /* And abort a maybe active DMA transfer */ |
831 | if (IS_A_TT()) { | 826 | if (IS_A_TT()) { |
832 | atari_turnoff_irq( IRQ_TT_MFP_SCSI ); | 827 | atari_turnoff_irq(IRQ_TT_MFP_SCSI); |
833 | #ifdef REAL_DMA | 828 | #ifdef REAL_DMA |
834 | tt_scsi_dma.dma_ctrl = 0; | 829 | tt_scsi_dma.dma_ctrl = 0; |
835 | #endif /* REAL_DMA */ | 830 | #endif /* REAL_DMA */ |
836 | } | 831 | } else { |
837 | else { | 832 | atari_turnoff_irq(IRQ_MFP_FSCSI); |
838 | atari_turnoff_irq( IRQ_MFP_FSCSI ); | ||
839 | #ifdef REAL_DMA | 833 | #ifdef REAL_DMA |
840 | st_dma.dma_mode_status = 0x90; | 834 | st_dma.dma_mode_status = 0x90; |
841 | atari_dma_active = 0; | 835 | atari_dma_active = 0; |
@@ -847,52 +841,51 @@ int atari_scsi_bus_reset(Scsi_Cmnd *cmd) | |||
847 | 841 | ||
848 | /* Re-enable ints */ | 842 | /* Re-enable ints */ |
849 | if (IS_A_TT()) { | 843 | if (IS_A_TT()) { |
850 | atari_turnon_irq( IRQ_TT_MFP_SCSI ); | 844 | atari_turnon_irq(IRQ_TT_MFP_SCSI); |
851 | } | 845 | } else { |
852 | else { | 846 | atari_turnon_irq(IRQ_MFP_FSCSI); |
853 | atari_turnon_irq( IRQ_MFP_FSCSI ); | ||
854 | } | 847 | } |
855 | if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS) | 848 | if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS) |
856 | falcon_release_lock_if_possible(hostdata); | 849 | falcon_release_lock_if_possible(hostdata); |
857 | 850 | ||
858 | return( rv ); | 851 | return rv; |
859 | } | 852 | } |
860 | 853 | ||
861 | 854 | ||
862 | #ifdef CONFIG_ATARI_SCSI_RESET_BOOT | 855 | #ifdef CONFIG_ATARI_SCSI_RESET_BOOT |
863 | static void __init atari_scsi_reset_boot(void) | 856 | static void __init atari_scsi_reset_boot(void) |
864 | { | 857 | { |
865 | unsigned long end; | 858 | unsigned long end; |
866 | 859 | ||
867 | /* | 860 | /* |
868 | * 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 |
869 | * with the queues, interrupts, or locks necessary here. | 862 | * with the queues, interrupts, or locks necessary here. |
870 | */ | 863 | */ |
871 | 864 | ||
872 | printk( "Atari SCSI: resetting the SCSI bus..." ); | 865 | printk("Atari SCSI: resetting the SCSI bus..."); |
873 | 866 | ||
874 | /* get in phase */ | 867 | /* get in phase */ |
875 | NCR5380_write( TARGET_COMMAND_REG, | 868 | NCR5380_write(TARGET_COMMAND_REG, |
876 | PHASE_SR_TO_TCR( NCR5380_read(STATUS_REG) )); | 869 | PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG))); |
877 | 870 | ||
878 | /* assert RST */ | 871 | /* assert RST */ |
879 | NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST ); | 872 | NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST); |
880 | /* 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 */ |
881 | udelay( 50 ); | 874 | udelay(50); |
882 | /* reset RST and interrupt */ | 875 | /* reset RST and interrupt */ |
883 | NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE ); | 876 | NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); |
884 | NCR5380_read( RESET_PARITY_INTERRUPT_REG ); | 877 | NCR5380_read(RESET_PARITY_INTERRUPT_REG); |
885 | 878 | ||
886 | end = jiffies + AFTER_RESET_DELAY; | 879 | end = jiffies + AFTER_RESET_DELAY; |
887 | while (time_before(jiffies, end)) | 880 | while (time_before(jiffies, end)) |
888 | barrier(); | 881 | barrier(); |
889 | 882 | ||
890 | printk( " done\n" ); | 883 | printk(" done\n"); |
891 | } | 884 | } |
892 | #endif | 885 | #endif |
893 | 886 | ||
894 | 887 | ||
895 | const char * atari_scsi_info (struct Scsi_Host *host) | 888 | const char *atari_scsi_info(struct Scsi_Host *host) |
896 | { | 889 | { |
897 | /* atari_scsi_detect() is verbose enough... */ | 890 | /* atari_scsi_detect() is verbose enough... */ |
898 | static const char string[] = "Atari native SCSI"; | 891 | static const char string[] = "Atari native SCSI"; |
@@ -902,10 +895,10 @@ const char * atari_scsi_info (struct Scsi_Host *host) | |||
902 | 895 | ||
903 | #if defined(REAL_DMA) | 896 | #if defined(REAL_DMA) |
904 | 897 | ||
905 | 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, |
906 | unsigned long count, int dir ) | 899 | unsigned long count, int dir) |
907 | { | 900 | { |
908 | unsigned long addr = virt_to_phys( data ); | 901 | unsigned long addr = virt_to_phys(data); |
909 | 902 | ||
910 | 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, " |
911 | "dir = %d\n", instance->host_no, data, addr, count, dir); | 904 | "dir = %d\n", instance->host_no, data, addr, count, dir); |
@@ -917,38 +910,37 @@ unsigned long atari_scsi_dma_setup( struct Scsi_Host *instance, void *data, | |||
917 | * wanted address. | 910 | * wanted address. |
918 | */ | 911 | */ |
919 | if (dir) | 912 | if (dir) |
920 | memcpy( atari_dma_buffer, data, count ); | 913 | memcpy(atari_dma_buffer, data, count); |
921 | else | 914 | else |
922 | atari_dma_orig_addr = data; | 915 | atari_dma_orig_addr = data; |
923 | addr = atari_dma_phys_buffer; | 916 | addr = atari_dma_phys_buffer; |
924 | } | 917 | } |
925 | 918 | ||
926 | atari_dma_startaddr = addr; /* Needed for calculating residual later. */ | 919 | atari_dma_startaddr = addr; /* Needed for calculating residual later. */ |
927 | 920 | ||
928 | /* 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 |
929 | * 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 |
930 | * 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 |
931 | * reads, invalidate any cache, may be altered after DMA without CPU | 924 | * reads, invalidate any cache, may be altered after DMA without CPU |
932 | * knowledge. | 925 | * knowledge. |
933 | * | 926 | * |
934 | * ++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, |
935 | * because the hardware does bus snooping (fine!). | 928 | * because the hardware does bus snooping (fine!). |
936 | */ | 929 | */ |
937 | dma_cache_maintenance( addr, count, dir ); | 930 | dma_cache_maintenance(addr, count, dir); |
938 | 931 | ||
939 | if (count == 0) | 932 | if (count == 0) |
940 | printk(KERN_NOTICE "SCSI warning: DMA programmed for 0 bytes !\n"); | 933 | printk(KERN_NOTICE "SCSI warning: DMA programmed for 0 bytes !\n"); |
941 | 934 | ||
942 | if (IS_A_TT()) { | 935 | if (IS_A_TT()) { |
943 | tt_scsi_dma.dma_ctrl = dir; | 936 | tt_scsi_dma.dma_ctrl = dir; |
944 | SCSI_DMA_WRITE_P( dma_addr, addr ); | 937 | SCSI_DMA_WRITE_P(dma_addr, addr); |
945 | SCSI_DMA_WRITE_P( dma_cnt, count ); | 938 | SCSI_DMA_WRITE_P(dma_cnt, count); |
946 | tt_scsi_dma.dma_ctrl = dir | 2; | 939 | tt_scsi_dma.dma_ctrl = dir | 2; |
947 | } | 940 | } else { /* ! IS_A_TT */ |
948 | else { /* ! IS_A_TT */ | 941 | |
949 | |||
950 | /* set address */ | 942 | /* set address */ |
951 | SCSI_DMA_SETADR( addr ); | 943 | SCSI_DMA_SETADR(addr); |
952 | 944 | ||
953 | /* toggle direction bit to clear FIFO and set DMA direction */ | 945 | /* toggle direction bit to clear FIFO and set DMA direction */ |
954 | dir <<= 8; | 946 | dir <<= 8; |
@@ -966,13 +958,13 @@ unsigned long atari_scsi_dma_setup( struct Scsi_Host *instance, void *data, | |||
966 | atari_dma_active = 1; | 958 | atari_dma_active = 1; |
967 | } | 959 | } |
968 | 960 | ||
969 | return( count ); | 961 | return count; |
970 | } | 962 | } |
971 | 963 | ||
972 | 964 | ||
973 | static long atari_scsi_dma_residual( struct Scsi_Host *instance ) | 965 | static long atari_scsi_dma_residual(struct Scsi_Host *instance) |
974 | { | 966 | { |
975 | return( atari_dma_residual ); | 967 | return atari_dma_residual; |
976 | } | 968 | } |
977 | 969 | ||
978 | 970 | ||
@@ -980,13 +972,13 @@ static long atari_scsi_dma_residual( struct Scsi_Host *instance ) | |||
980 | #define CMD_SURELY_BYTE_MODE 1 | 972 | #define CMD_SURELY_BYTE_MODE 1 |
981 | #define CMD_MODE_UNKNOWN 2 | 973 | #define CMD_MODE_UNKNOWN 2 |
982 | 974 | ||
983 | static int falcon_classify_cmd( Scsi_Cmnd *cmd ) | 975 | static int falcon_classify_cmd(Scsi_Cmnd *cmd) |
984 | { | 976 | { |
985 | unsigned char opcode = cmd->cmnd[0]; | 977 | unsigned char opcode = cmd->cmnd[0]; |
986 | 978 | ||
987 | if (opcode == READ_DEFECT_DATA || opcode == READ_LONG || | 979 | if (opcode == READ_DEFECT_DATA || opcode == READ_LONG || |
988 | opcode == READ_BUFFER) | 980 | opcode == READ_BUFFER) |
989 | return( CMD_SURELY_BYTE_MODE ); | 981 | return CMD_SURELY_BYTE_MODE; |
990 | else if (opcode == READ_6 || opcode == READ_10 || | 982 | else if (opcode == READ_6 || opcode == READ_10 || |
991 | opcode == 0xa8 /* READ_12 */ || opcode == READ_REVERSE || | 983 | opcode == 0xa8 /* READ_12 */ || opcode == READ_REVERSE || |
992 | opcode == RECOVER_BUFFERED_DATA) { | 984 | opcode == RECOVER_BUFFERED_DATA) { |
@@ -994,12 +986,11 @@ static int falcon_classify_cmd( Scsi_Cmnd *cmd ) | |||
994 | * 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 |
995 | * set! */ | 987 | * set! */ |
996 | if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1)) | 988 | if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1)) |
997 | return( CMD_SURELY_BYTE_MODE ); | 989 | return CMD_SURELY_BYTE_MODE; |
998 | else | 990 | else |
999 | return( CMD_SURELY_BLOCK_MODE ); | 991 | return CMD_SURELY_BLOCK_MODE; |
1000 | } | 992 | } else |
1001 | else | 993 | return CMD_MODE_UNKNOWN; |
1002 | return( CMD_MODE_UNKNOWN ); | ||
1003 | } | 994 | } |
1004 | 995 | ||
1005 | 996 | ||
@@ -1012,19 +1003,18 @@ static int falcon_classify_cmd( Scsi_Cmnd *cmd ) | |||
1012 | * the overrun problem, so this question is academic :-) | 1003 | * the overrun problem, so this question is academic :-) |
1013 | */ | 1004 | */ |
1014 | 1005 | ||
1015 | static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | 1006 | static unsigned long atari_dma_xfer_len(unsigned long wanted_len, |
1016 | Scsi_Cmnd *cmd, | 1007 | Scsi_Cmnd *cmd, int write_flag) |
1017 | int write_flag ) | ||
1018 | { | 1008 | { |
1019 | unsigned long possible_len, limit; | 1009 | unsigned long possible_len, limit; |
1020 | #ifndef CONFIG_TT_DMA_EMUL | 1010 | #ifndef CONFIG_TT_DMA_EMUL |
1021 | if (MACH_IS_HADES) | 1011 | if (MACH_IS_HADES) |
1022 | /* 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 */ |
1023 | return( 0 ); | 1013 | return 0; |
1024 | #endif | 1014 | #endif |
1025 | if (IS_A_TT()) | 1015 | if (IS_A_TT()) |
1026 | /* TT SCSI DMA can transfer arbitrary #bytes */ | 1016 | /* TT SCSI DMA can transfer arbitrary #bytes */ |
1027 | return( wanted_len ); | 1017 | return wanted_len; |
1028 | 1018 | ||
1029 | /* 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. |
1030 | * 255*512 bytes, but this should be enough) | 1020 | * 255*512 bytes, but this should be enough) |
@@ -1060,8 +1050,7 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1060 | * this). | 1050 | * this). |
1061 | */ | 1051 | */ |
1062 | possible_len = wanted_len; | 1052 | possible_len = wanted_len; |
1063 | } | 1053 | } else { |
1064 | else { | ||
1065 | /* 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 |
1066 | * 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 |
1067 | * (no interrupt on DMA finished!) | 1056 | * (no interrupt on DMA finished!) |
@@ -1071,15 +1060,15 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1071 | else { | 1060 | else { |
1072 | /* Now classify the command (see above) and decide whether it is | 1061 | /* Now classify the command (see above) and decide whether it is |
1073 | * allowed to do DMA at all */ | 1062 | * allowed to do DMA at all */ |
1074 | switch( falcon_classify_cmd( cmd )) { | 1063 | switch (falcon_classify_cmd(cmd)) { |
1075 | case CMD_SURELY_BLOCK_MODE: | 1064 | case CMD_SURELY_BLOCK_MODE: |
1076 | possible_len = wanted_len; | 1065 | possible_len = wanted_len; |
1077 | break; | 1066 | break; |
1078 | case CMD_SURELY_BYTE_MODE: | 1067 | case CMD_SURELY_BYTE_MODE: |
1079 | possible_len = 0; /* DMA prohibited */ | 1068 | possible_len = 0; /* DMA prohibited */ |
1080 | break; | 1069 | break; |
1081 | case CMD_MODE_UNKNOWN: | 1070 | case CMD_MODE_UNKNOWN: |
1082 | default: | 1071 | default: |
1083 | /* For unknown commands assume block transfers if the transfer | 1072 | /* For unknown commands assume block transfers if the transfer |
1084 | * size/allocation length is >= 1024 */ | 1073 | * size/allocation length is >= 1024 */ |
1085 | possible_len = (wanted_len < 1024) ? 0 : wanted_len; | 1074 | possible_len = (wanted_len < 1024) ? 0 : wanted_len; |
@@ -1087,9 +1076,9 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1087 | } | 1076 | } |
1088 | } | 1077 | } |
1089 | } | 1078 | } |
1090 | 1079 | ||
1091 | /* Last step: apply the hard limit on DMA transfers */ | 1080 | /* Last step: apply the hard limit on DMA transfers */ |
1092 | 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))) ? |
1093 | STRAM_BUFFER_SIZE : 255*512; | 1082 | STRAM_BUFFER_SIZE : 255*512; |
1094 | if (possible_len > limit) | 1083 | if (possible_len > limit) |
1095 | possible_len = limit; | 1084 | possible_len = limit; |
@@ -1098,7 +1087,7 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1098 | DMA_PRINTK("Sorry, must cut DMA transfer size to %ld bytes " | 1087 | DMA_PRINTK("Sorry, must cut DMA transfer size to %ld bytes " |
1099 | "instead of %ld\n", possible_len, wanted_len); | 1088 | "instead of %ld\n", possible_len, wanted_len); |
1100 | 1089 | ||
1101 | return( possible_len ); | 1090 | return possible_len; |
1102 | } | 1091 | } |
1103 | 1092 | ||
1104 | 1093 | ||
@@ -1112,23 +1101,23 @@ static unsigned long atari_dma_xfer_len( unsigned long wanted_len, | |||
1112 | * NCR5380_write call these functions via function pointers. | 1101 | * NCR5380_write call these functions via function pointers. |
1113 | */ | 1102 | */ |
1114 | 1103 | ||
1115 | static unsigned char atari_scsi_tt_reg_read( unsigned char reg ) | 1104 | static unsigned char atari_scsi_tt_reg_read(unsigned char reg) |
1116 | { | 1105 | { |
1117 | return( tt_scsi_regp[reg * 2] ); | 1106 | return tt_scsi_regp[reg * 2]; |
1118 | } | 1107 | } |
1119 | 1108 | ||
1120 | 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) |
1121 | { | 1110 | { |
1122 | tt_scsi_regp[reg * 2] = value; | 1111 | tt_scsi_regp[reg * 2] = value; |
1123 | } | 1112 | } |
1124 | 1113 | ||
1125 | static unsigned char atari_scsi_falcon_reg_read( unsigned char reg ) | 1114 | static unsigned char atari_scsi_falcon_reg_read(unsigned char reg) |
1126 | { | 1115 | { |
1127 | dma_wd.dma_mode_status= (u_short)(0x88 + reg); | 1116 | dma_wd.dma_mode_status= (u_short)(0x88 + reg); |
1128 | return( (u_char)dma_wd.fdc_acces_seccount ); | 1117 | return (u_char)dma_wd.fdc_acces_seccount; |
1129 | } | 1118 | } |
1130 | 1119 | ||
1131 | 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) |
1132 | { | 1121 | { |
1133 | dma_wd.dma_mode_status = (u_short)(0x88 + reg); | 1122 | dma_wd.dma_mode_status = (u_short)(0x88 + reg); |
1134 | dma_wd.fdc_acces_seccount = (u_short)value; | 1123 | dma_wd.fdc_acces_seccount = (u_short)value; |