forked from len0rd/rockbox
Killed a few bugs. Tested in target. Works fairly good.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@501 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4674e87017
commit
dc4977d98c
1 changed files with 18 additions and 10 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "sh7034.h"
|
#include "sh7034.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#define ATA_DATA (*((volatile unsigned short*)0x06104100))
|
#define ATA_DATA (*((volatile unsigned short*)0x06104100))
|
||||||
#define ATA_ERROR (*((volatile unsigned char*)0x06100101))
|
#define ATA_ERROR (*((volatile unsigned char*)0x06100101))
|
||||||
|
|
@ -32,7 +33,7 @@
|
||||||
#define ATA_SELECT (*((volatile unsigned char*)0x06100106))
|
#define ATA_SELECT (*((volatile unsigned char*)0x06100106))
|
||||||
#define ATA_COMMAND (*((volatile unsigned char*)0x06100107))
|
#define ATA_COMMAND (*((volatile unsigned char*)0x06100107))
|
||||||
#define ATA_STATUS ATA_COMMAND
|
#define ATA_STATUS ATA_COMMAND
|
||||||
#define ATA_CONTROL (*((volatile unsigned char*)0x06100306))
|
#define ATA_CONTROL (*((volatile unsigned char*)0x06200306))
|
||||||
#define ATA_ALT_STATUS ATA_CONTROL
|
#define ATA_ALT_STATUS ATA_CONTROL
|
||||||
|
|
||||||
#define SELECT_LBA 0x40
|
#define SELECT_LBA 0x40
|
||||||
|
|
@ -59,10 +60,14 @@ static int wait_for_bsy(void)
|
||||||
yield();
|
yield();
|
||||||
|
|
||||||
if (TIME_BEFORE(current_tick, timeout))
|
if (TIME_BEFORE(current_tick, timeout))
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return 0; /* timeout */
|
return 0; /* timeout */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int wait_for_rdy(void)
|
static int wait_for_rdy(void)
|
||||||
{
|
{
|
||||||
|
|
@ -231,11 +236,11 @@ int ata_spindown(int time)
|
||||||
|
|
||||||
int ata_hard_reset(void)
|
int ata_hard_reset(void)
|
||||||
{
|
{
|
||||||
clear_bit(1,PADR);
|
PADR &= ~0x0002;
|
||||||
sleep(HZ/500);
|
|
||||||
|
|
||||||
set_bit(1,PADR);
|
sleep(2);
|
||||||
sleep(HZ/500);
|
|
||||||
|
PADR |= 0x0002;
|
||||||
|
|
||||||
return wait_for_rdy();
|
return wait_for_rdy();
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +262,7 @@ int ata_init(void)
|
||||||
led(FALSE);
|
led(FALSE);
|
||||||
|
|
||||||
/* activate ATA */
|
/* activate ATA */
|
||||||
PADR |= 0x80;
|
PADR &= ~0x80;
|
||||||
|
|
||||||
if (!ata_hard_reset())
|
if (!ata_hard_reset())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -265,12 +270,15 @@ int ata_init(void)
|
||||||
if (!check_registers())
|
if (!check_registers())
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
if (!check_harddisk())
|
// if (!check_harddisk())
|
||||||
return -3;
|
// return -3;
|
||||||
|
|
||||||
if (!freeze_lock())
|
if (freeze_lock() < 0)
|
||||||
return -4;
|
return -4;
|
||||||
|
|
||||||
|
// if(ata_spindown(-1) < 0)
|
||||||
|
// return -5;
|
||||||
|
|
||||||
ATA_SELECT = SELECT_LBA;
|
ATA_SELECT = SELECT_LBA;
|
||||||
ATA_CONTROL = CONTROL_nIEN;
|
ATA_CONTROL = CONTROL_nIEN;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue