ATA: Restrict to UDMA2 if we don't detect an "80-pin" cable

Change-Id: I55861065741f3365491445f1f3f5b0041f33e1c6
This commit is contained in:
Solomon Peachy 2024-10-26 15:07:57 -04:00
parent aea4974b88
commit 3951fbf9d2
3 changed files with 23 additions and 6 deletions

View file

@ -1567,9 +1567,9 @@ static int disk_callback(int btn, struct gui_synclist *lists)
'0' + (i & 7));
}
#endif /* HAVE_ATA_DMA */
i = identify_info[0] & (1 << 15);
i = identify_info[83] & (1 << 2);
simplelist_addline(
"CF compatible: %s", i ? "yes" : "no");
"CFA compatible: %s", i ? "yes" : "no");
i = identify_info[0] & (1 << 6);
simplelist_addline(
"Fixed device: %s", i ? "yes" : "no");

View file

@ -1116,8 +1116,13 @@ static int set_features(void)
#ifdef HAVE_ATA_DMA
if (identify_info[53] & (1<<2)) {
int max_udma = ATA_MAX_UDMA;
#if ATA_MAX_UDMA > 2
if (!(ata_identify_data[93] & BIT(13)))
max_udma = 2;
#endif
/* Ultra DMA mode info present, find a mode */
dma_mode = ata_get_best_mode(identify_info[88], ATA_MAX_UDMA, 0x40);
dma_mode = ata_get_best_mode(identify_info[88], max_udma, 0x40);
}
if (!dma_mode) {

View file

@ -609,15 +609,22 @@ static int ata_set_feature(uint32_t feature, uint32_t param)
static int udmatimes[ATA_MAX_UDMA + 1] = {
0x4071152,
0x2050d52,
#if ATA_MAX_UDMA >= 2
0x2030a52,
#endif
#if ATA_MAX_UDMA >= 3
0x1020a52,
0x1010a52
#endif
#if ATA_MAX_UDMA >= 4
0x1010a52,
#endif
};
static int mwdmatimes[ATA_MAX_MWDMA + 1] = {
0x1c175,
0x7083,
0x5072
0x5072,
};
static int ata_get_best_mode(unsigned short identword, int max, int modetype)
{
unsigned short testbit = BIT_N(max);
@ -719,7 +726,12 @@ static int ata_power_up(void)
#ifdef HAVE_ATA_DMA
if ((ata_identify_data[53] & BIT(2)) && (ata_identify_data[88] & BITRANGE(0, 4))) /* Any UDMA */
{
param = ata_get_best_mode(ata_identify_data[88], ATA_MAX_UDMA, 0x40);
int max_udma = ATA_MAX_UDMA;
#if ATA_MAX_UDMA > 2
if (!(ata_identify_data[93] & BIT(13)))
max_udma = 2;
#endif
param = ata_get_best_mode(ata_identify_data[88], max_udma, 0x40);
ATA_UDMA_TIME = udmatimes[param & 0xf];
ata_dma_flags = BIT(2) | BIT(3) | BIT(9) | BIT(10);
}