forked from len0rd/rockbox
Gigabeat S: Do the controller timing settings a more cleanly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17379 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c8130b2666
commit
57cbd77788
3 changed files with 15 additions and 47 deletions
|
|
@ -1090,10 +1090,6 @@ static int identify(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ATA_NOTIFY_IDENTIFY_READY
|
|
||||||
ata_identify_ready();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1172,6 +1168,10 @@ static int set_features(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ATA_SET_DEVICE_FEATURES
|
||||||
|
ata_set_pio_timings(pio_mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,17 +79,18 @@ static const struct ata_pio_timings
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool initialized = false;
|
static int pio_mode = 0; /* Setup mode 0 by default */
|
||||||
|
|
||||||
/* Setup the timing for PIO mode */
|
/* Setup the timing for PIO mode */
|
||||||
static void ata_set_pio_mode(int mode)
|
void ata_set_pio_timings(int mode)
|
||||||
{
|
{
|
||||||
const struct ata_pio_timings * const timings = &pio_timings[mode];
|
while (!(ATA_INTERRUPT_PENDING & ATA_CONTROLLER_IDLE));
|
||||||
|
|
||||||
|
const struct ata_pio_timings * const timings = &pio_timings[mode];
|
||||||
/* T = period in nanoseconds */
|
/* T = period in nanoseconds */
|
||||||
int T = 1000 * 1000 * 1000 / imx31_clkctl_get_ata_clk();
|
int T = 1000 * 1000 * 1000 / imx31_clkctl_get_ata_clk();
|
||||||
|
|
||||||
while (!(ATA_INTERRUPT_PENDING & ATA_CONTROLLER_IDLE));
|
pio_mode = mode;
|
||||||
|
|
||||||
ATA_TIME_OFF = 3;
|
ATA_TIME_OFF = 3;
|
||||||
ATA_TIME_ON = 3;
|
ATA_TIME_ON = 3;
|
||||||
|
|
@ -128,40 +129,7 @@ void ata_device_init(void)
|
||||||
{
|
{
|
||||||
ATA_INTF_CONTROL |= ATA_ATA_RST; /* Make sure we're not in reset mode */
|
ATA_INTF_CONTROL |= ATA_ATA_RST; /* Make sure we're not in reset mode */
|
||||||
|
|
||||||
if (!initialized)
|
|
||||||
{
|
|
||||||
initialized = true;
|
|
||||||
/* Setup mode 0 by default */
|
|
||||||
ata_set_pio_mode(0);
|
|
||||||
/* mode may be switched later once identify info is ready in which
|
/* mode may be switched later once identify info is ready in which
|
||||||
* case the main driver calls back */
|
* case the main driver calls back */
|
||||||
}
|
ata_set_pio_timings(pio_mode);
|
||||||
else
|
|
||||||
{
|
|
||||||
/* identify info will be ready */
|
|
||||||
ata_identify_ready();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ata_identify_ready(void)
|
|
||||||
{
|
|
||||||
const unsigned short* identify_info = ata_get_identify();
|
|
||||||
int mode = 0;
|
|
||||||
|
|
||||||
if (identify_info[53] & (1 << 1))
|
|
||||||
{
|
|
||||||
/* Set up advanced timings */
|
|
||||||
if (identify_info[64] & (1 << 1))
|
|
||||||
mode = 4; /* Mode 0, 1, 2, 3, 4 */
|
|
||||||
else if (identify_info[64] & (1 << 0))
|
|
||||||
mode = 3; /* Mode 0, 1, 2, 3 */
|
|
||||||
else
|
|
||||||
mode = 2; /* Mode 0, 1, 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If mode changed, actually set the timings */
|
|
||||||
if (mode != 0)
|
|
||||||
{
|
|
||||||
ata_set_pio_mode(mode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ void ata_reset(void);
|
||||||
void ata_device_init(void);
|
void ata_device_init(void);
|
||||||
bool ata_is_coldstart(void);
|
bool ata_is_coldstart(void);
|
||||||
|
|
||||||
#define ATA_NOTIFY_IDENTIFY_READY
|
#define ATA_SET_DEVICE_FEATURES
|
||||||
void ata_identify_ready(void);
|
void ata_set_pio_timings(int mode);
|
||||||
|
|
||||||
#endif
|
#endif /* ATA_TARGET_H */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue