forked from len0rd/rockbox
Possibly better USB handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1419 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
adfbc11960
commit
2f4b88e9bb
2 changed files with 27 additions and 32 deletions
|
@ -125,7 +125,6 @@ int ata_read_sectors(unsigned long start,
|
||||||
|
|
||||||
if ( sleeping ) {
|
if ( sleeping ) {
|
||||||
if (ata_soft_reset()) {
|
if (ata_soft_reset()) {
|
||||||
mutex_unlock(&ata_mtx);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +183,6 @@ int ata_write_sectors(unsigned long start,
|
||||||
|
|
||||||
if ( sleeping ) {
|
if ( sleeping ) {
|
||||||
if (ata_soft_reset()) {
|
if (ata_soft_reset()) {
|
||||||
mutex_unlock(&ata_mtx);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,14 +305,14 @@ static void ata_thread(void)
|
||||||
while (1) {
|
while (1) {
|
||||||
queue_wait(&ata_queue, &ev);
|
queue_wait(&ata_queue, &ev);
|
||||||
switch ( ev.id ) {
|
switch ( ev.id ) {
|
||||||
case SYS_USB_CONNECTED:
|
case SYS_USB_CONNECTED:
|
||||||
/* Tell the USB thread that we are safe */
|
/* Tell the USB thread that we are safe */
|
||||||
DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
|
DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
|
||||||
usb_acknowledge(SYS_USB_CONNECTED_ACK);
|
usb_acknowledge(SYS_USB_CONNECTED_ACK);
|
||||||
|
|
||||||
/* Wait until the USB cable is extracted again */
|
/* Wait until the USB cable is extracted again */
|
||||||
usb_wait_for_disconnect(&ata_queue);
|
usb_wait_for_disconnect(&ata_queue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Q_SLEEP:
|
case Q_SLEEP:
|
||||||
ata_perform_sleep();
|
ata_perform_sleep();
|
||||||
|
@ -372,7 +370,7 @@ int ata_soft_reset(void)
|
||||||
retry_count = 8;
|
retry_count = 8;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = wait_for_rdy();
|
ret = wait_for_rdy();
|
||||||
} while(!ret && retry_count--);
|
} while(!ret && retry_count--);
|
||||||
|
|
||||||
/* Massage the return code so it is 0 on success and -1 on failure */
|
/* Massage the return code so it is 0 on success and -1 on failure */
|
||||||
|
@ -447,9 +445,9 @@ static int io_address_detect(void)
|
||||||
void ata_enable(bool on)
|
void ata_enable(bool on)
|
||||||
{
|
{
|
||||||
if(on)
|
if(on)
|
||||||
PADR &= ~0x80; /* enable ATA */
|
PADR &= ~0x80; /* enable ATA */
|
||||||
else
|
else
|
||||||
PADR |= 0x80; /* disable ATA */
|
PADR |= 0x80; /* disable ATA */
|
||||||
|
|
||||||
PAIOR |= 0x80;
|
PAIOR |= 0x80;
|
||||||
}
|
}
|
||||||
|
@ -462,19 +460,19 @@ int ata_init(void)
|
||||||
|
|
||||||
ata_enable(true);
|
ata_enable(true);
|
||||||
|
|
||||||
if (master_slave_detect())
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (io_address_detect())
|
|
||||||
return -2;
|
|
||||||
|
|
||||||
if (check_registers())
|
|
||||||
return -3;
|
|
||||||
|
|
||||||
if (freeze_lock())
|
|
||||||
return -4;
|
|
||||||
|
|
||||||
if ( !initialized ) {
|
if ( !initialized ) {
|
||||||
|
if (master_slave_detect())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (io_address_detect())
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if (check_registers())
|
||||||
|
return -3;
|
||||||
|
|
||||||
|
if (freeze_lock())
|
||||||
|
return -4;
|
||||||
|
|
||||||
queue_init(&ata_queue);
|
queue_init(&ata_queue);
|
||||||
create_thread(ata_thread, ata_stack,
|
create_thread(ata_thread, ata_stack,
|
||||||
sizeof(ata_stack), ata_thread_name);
|
sizeof(ata_stack), ata_thread_name);
|
||||||
|
|
|
@ -32,9 +32,7 @@
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "sprintf.h"
|
#include "sprintf.h"
|
||||||
|
|
||||||
#ifdef ARCHOS_RECORDER
|
extern void dbg_ports(void); /* NASTY! defined in apps/ */
|
||||||
extern void dbg_ports(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define USB_REALLY_BRAVE
|
#define USB_REALLY_BRAVE
|
||||||
|
|
||||||
|
@ -86,6 +84,7 @@ static void usb_slave_mode(bool on)
|
||||||
if(on)
|
if(on)
|
||||||
{
|
{
|
||||||
DEBUGF("Entering USB slave mode\n");
|
DEBUGF("Entering USB slave mode\n");
|
||||||
|
ata_soft_reset();
|
||||||
ata_enable(false);
|
ata_enable(false);
|
||||||
usb_enable(true);
|
usb_enable(true);
|
||||||
}
|
}
|
||||||
|
@ -101,16 +100,14 @@ static void usb_slave_mode(bool on)
|
||||||
rc = ata_init();
|
rc = ata_init();
|
||||||
if(rc)
|
if(rc)
|
||||||
{
|
{
|
||||||
#ifdef ARCHOS_RECORDER
|
|
||||||
char str[32];
|
char str[32];
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
snprintf(str, 31, "ATA error: %d", rc);
|
snprintf(str, 31, "ATA error: %d", rc);
|
||||||
lcd_puts(0, 1, str);
|
lcd_puts(0, 0, str);
|
||||||
lcd_puts(0, 3, "Press ON to debug");
|
lcd_puts(0, 1, "Press ON to debug");
|
||||||
lcd_update();
|
lcd_update();
|
||||||
while(button_get(true) != BUTTON_ON) {};
|
while(button_get(true) != BUTTON_ON) {};
|
||||||
dbg_ports();
|
dbg_ports();
|
||||||
#endif
|
|
||||||
panicf("ata: %d",rc);
|
panicf("ata: %d",rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +245,7 @@ static void usb_tick(void)
|
||||||
|
|
||||||
void usb_acknowledge(int id)
|
void usb_acknowledge(int id)
|
||||||
{
|
{
|
||||||
queue_post(&usb_queue, id, NULL);
|
queue_post(&usb_queue, id, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_init(void)
|
void usb_init(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue