summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2024-04-22 21:54:21 -0400
committerSolomon Peachy <pizza@shaftnet.org>2024-04-26 07:25:35 -0400
commit9a17185e631b76d787152a9534bc2744036f57c0 (patch)
treeb273c1785fb49ea450afb0eda0581fe014b1308f
parent8fb2cedc8e202871e1770adbd6fe93103bcd3db6 (diff)
downloadrockbox-9a17185e631b76d787152a9534bc2744036f57c0.tar.gz
rockbox-9a17185e631b76d787152a9534bc2744036f57c0.zip
ata: Enable volatile write cache (if device supports it)
Rejigger the options table a little for clarity Change-Id: I02fdcc6521e42cc735d9b1da741b80db5b739858
-rw-r--r--firmware/drivers/ata.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 9896fa87e0..bb87357a1a 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -287,7 +287,6 @@ static int ata_perform_flush_cache(void)
287 return 0; 287 return 0;
288} 288}
289 289
290
291static ICODE_ATTR int wait_for_start_of_transfer(void) 290static ICODE_ATTR int wait_for_start_of_transfer(void)
292{ 291{
293 if (!wait_for_bsy()) 292 if (!wait_for_bsy())
@@ -1092,16 +1091,18 @@ static int set_features(void)
1092 unsigned char subcommand; 1091 unsigned char subcommand;
1093 unsigned char parameter; 1092 unsigned char parameter;
1094 } features[] = { 1093 } features[] = {
1095 { 83, 14, 0x03, 0 }, /* force PIO mode */ 1094 { 83, 14, 0x03, 0 }, /* force PIO mode by default */
1096 { 83, 3, 0x05, 0x80 }, /* adv. power management: lowest w/o standby */
1097 { 83, 9, 0x42, 0x80 }, /* acoustic management: lowest noise */
1098 { 82, 6, 0xaa, 0 }, /* enable read look-ahead */
1099#ifdef HAVE_ATA_DMA 1095#ifdef HAVE_ATA_DMA
1100 { 0, 0, 0x03, 0 }, /* DMA mode */ 1096 { 0, 0, 0x03, 0 }, /* DMA mode */
1101#endif 1097#endif
1098 /* NOTE: Above two MUST come first! */
1099 { 83, 3, 0x05, 0x80 }, /* adv. power management: lowest w/o standby */
1100 { 83, 9, 0x42, 0x80 }, /* acoustic management: lowest noise */
1101 { 82, 5, 0x02, 0 }, /* enable volatile write cache */
1102 { 82, 6, 0xaa, 0 }, /* enable read look-ahead */
1102 }; 1103 };
1103 int i; 1104 int i;
1104 int pio_mode = 2; 1105 int pio_mode = 2; /* Lowest */
1105 1106
1106 /* Find out the highest supported PIO mode */ 1107 /* Find out the highest supported PIO mode */
1107 if (identify_info[53] & (1<<1)) { /* Is word 64 valid? */ 1108 if (identify_info[53] & (1<<1)) { /* Is word 64 valid? */
@@ -1115,20 +1116,21 @@ static int set_features(void)
1115 features[0].parameter = 8 + pio_mode; 1116 features[0].parameter = 8 + pio_mode;
1116 1117
1117#ifdef HAVE_ATA_DMA 1118#ifdef HAVE_ATA_DMA
1118 if (identify_info[53] & (1<<2)) 1119 if (identify_info[53] & (1<<2)) {
1119 /* Ultra DMA mode info present, find a mode */ 1120 /* Ultra DMA mode info present, find a mode */
1120 dma_mode = get_best_mode(identify_info[88], ATA_MAX_UDMA, 0x40); 1121 dma_mode = get_best_mode(identify_info[88], ATA_MAX_UDMA, 0x40);
1122 }
1121 1123
1122 if (!dma_mode) { 1124 if (!dma_mode) {
1123 /* No UDMA mode found, try to find a multi-word DMA mode */ 1125 /* No UDMA mode found, try to find a multi-word DMA mode */
1124 dma_mode = get_best_mode(identify_info[63], ATA_MAX_MWDMA, 0x20); 1126 dma_mode = get_best_mode(identify_info[63], ATA_MAX_MWDMA, 0x20);
1125 features[4].id_word = 63; 1127 features[1].id_word = 63;
1128 } else {
1129 features[1].id_word = 88;
1126 } 1130 }
1127 else
1128 features[4].id_word = 88;
1129 1131
1130 features[4].id_bit = dma_mode & 7; 1132 features[1].id_bit = dma_mode & 7;
1131 features[4].parameter = dma_mode; 1133 features[1].parameter = dma_mode;
1132#endif /* HAVE_ATA_DMA */ 1134#endif /* HAVE_ATA_DMA */
1133 1135
1134 ATA_OUT8(ATA_SELECT, ata_device); 1136 ATA_OUT8(ATA_SELECT, ata_device);