diff options
Diffstat (limited to 'firmware/drivers/ata.c')
-rw-r--r-- | firmware/drivers/ata.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 3fdc93669e..6cab3d3872 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -125,7 +125,6 @@ int ata_read_sectors(unsigned long start, | |||
125 | 125 | ||
126 | if ( sleeping ) { | 126 | if ( sleeping ) { |
127 | if (ata_soft_reset()) { | 127 | if (ata_soft_reset()) { |
128 | mutex_unlock(&ata_mtx); | ||
129 | return -1; | 128 | return -1; |
130 | } | 129 | } |
131 | } | 130 | } |
@@ -184,7 +183,6 @@ int ata_write_sectors(unsigned long start, | |||
184 | 183 | ||
185 | if ( sleeping ) { | 184 | if ( sleeping ) { |
186 | if (ata_soft_reset()) { | 185 | if (ata_soft_reset()) { |
187 | mutex_unlock(&ata_mtx); | ||
188 | return -1; | 186 | return -1; |
189 | } | 187 | } |
190 | } | 188 | } |
@@ -307,14 +305,14 @@ static void ata_thread(void) | |||
307 | while (1) { | 305 | while (1) { |
308 | queue_wait(&ata_queue, &ev); | 306 | queue_wait(&ata_queue, &ev); |
309 | switch ( ev.id ) { | 307 | switch ( ev.id ) { |
310 | case SYS_USB_CONNECTED: | 308 | case SYS_USB_CONNECTED: |
311 | /* Tell the USB thread that we are safe */ | 309 | /* Tell the USB thread that we are safe */ |
312 | DEBUGF("backlight_thread got SYS_USB_CONNECTED\n"); | 310 | DEBUGF("backlight_thread got SYS_USB_CONNECTED\n"); |
313 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | 311 | usb_acknowledge(SYS_USB_CONNECTED_ACK); |
314 | 312 | ||
315 | /* Wait until the USB cable is extracted again */ | 313 | /* Wait until the USB cable is extracted again */ |
316 | usb_wait_for_disconnect(&ata_queue); | 314 | usb_wait_for_disconnect(&ata_queue); |
317 | break; | 315 | break; |
318 | 316 | ||
319 | case Q_SLEEP: | 317 | case Q_SLEEP: |
320 | ata_perform_sleep(); | 318 | ata_perform_sleep(); |
@@ -372,7 +370,7 @@ int ata_soft_reset(void) | |||
372 | retry_count = 8; | 370 | retry_count = 8; |
373 | do | 371 | do |
374 | { | 372 | { |
375 | ret = wait_for_rdy(); | 373 | ret = wait_for_rdy(); |
376 | } while(!ret && retry_count--); | 374 | } while(!ret && retry_count--); |
377 | 375 | ||
378 | /* Massage the return code so it is 0 on success and -1 on failure */ | 376 | /* Massage the return code so it is 0 on success and -1 on failure */ |
@@ -447,9 +445,9 @@ static int io_address_detect(void) | |||
447 | void ata_enable(bool on) | 445 | void ata_enable(bool on) |
448 | { | 446 | { |
449 | if(on) | 447 | if(on) |
450 | PADR &= ~0x80; /* enable ATA */ | 448 | PADR &= ~0x80; /* enable ATA */ |
451 | else | 449 | else |
452 | PADR |= 0x80; /* disable ATA */ | 450 | PADR |= 0x80; /* disable ATA */ |
453 | 451 | ||
454 | PAIOR |= 0x80; | 452 | PAIOR |= 0x80; |
455 | } | 453 | } |
@@ -462,19 +460,19 @@ int ata_init(void) | |||
462 | 460 | ||
463 | ata_enable(true); | 461 | ata_enable(true); |
464 | 462 | ||
465 | if (master_slave_detect()) | ||
466 | return -1; | ||
467 | |||
468 | if (io_address_detect()) | ||
469 | return -2; | ||
470 | |||
471 | if (check_registers()) | ||
472 | return -3; | ||
473 | |||
474 | if (freeze_lock()) | ||
475 | return -4; | ||
476 | |||
477 | if ( !initialized ) { | 463 | if ( !initialized ) { |
464 | if (master_slave_detect()) | ||
465 | return -1; | ||
466 | |||
467 | if (io_address_detect()) | ||
468 | return -2; | ||
469 | |||
470 | if (check_registers()) | ||
471 | return -3; | ||
472 | |||
473 | if (freeze_lock()) | ||
474 | return -4; | ||
475 | |||
478 | queue_init(&ata_queue); | 476 | queue_init(&ata_queue); |
479 | create_thread(ata_thread, ata_stack, | 477 | create_thread(ata_thread, ata_stack, |
480 | sizeof(ata_stack), ata_thread_name); | 478 | sizeof(ata_stack), ata_thread_name); |