aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/pci/piix.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index eb5bab1890cd..cdc3aab9ebcb 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -222,13 +222,15 @@ static void piix_tune_drive (ide_drive_t *drive, u8 pio)
222 u16 master_data; 222 u16 master_data;
223 u8 slave_data; 223 u8 slave_data;
224 static DEFINE_SPINLOCK(tune_lock); 224 static DEFINE_SPINLOCK(tune_lock);
225 int control = 0;
225 226
226 /* ISP RTC */ 227 /* ISP RTC */
227 u8 timings[][2] = { { 0, 0 }, 228 static const u8 timings[][2]= {
228 { 0, 0 }, 229 { 0, 0 },
229 { 1, 0 }, 230 { 0, 0 },
230 { 2, 1 }, 231 { 1, 0 },
231 { 2, 3 }, }; 232 { 2, 1 },
233 { 2, 3 }, };
232 234
233 pio = ide_get_best_pio_mode(drive, pio, 5, NULL); 235 pio = ide_get_best_pio_mode(drive, pio, 5, NULL);
234 236
@@ -239,19 +241,30 @@ static void piix_tune_drive (ide_drive_t *drive, u8 pio)
239 */ 241 */
240 spin_lock_irqsave(&tune_lock, flags); 242 spin_lock_irqsave(&tune_lock, flags);
241 pci_read_config_word(dev, master_port, &master_data); 243 pci_read_config_word(dev, master_port, &master_data);
244
245 if (pio >= 2)
246 control |= 1; /* Programmable timing on */
247 if (drive->media == ide_disk)
248 control |= 4; /* Prefetch, post write */
249 if (pio >= 3)
250 control |= 2; /* IORDY */
242 if (is_slave) { 251 if (is_slave) {
243 master_data = master_data | 0x4000; 252 master_data = master_data | 0x4000;
244 if (pio > 1) 253 if (pio > 1) {
245 /* enable PPE, IE and TIME */ 254 /* enable PPE, IE and TIME */
246 master_data = master_data | 0x0070; 255 master_data = master_data | (control << 4);
256 } else {
257 master_data &= ~0x0070;
258 }
247 pci_read_config_byte(dev, slave_port, &slave_data); 259 pci_read_config_byte(dev, slave_port, &slave_data);
248 slave_data = slave_data & (hwif->channel ? 0x0f : 0xf0); 260 slave_data = slave_data & (hwif->channel ? 0x0f : 0xf0);
249 slave_data = slave_data | (((timings[pio][0] << 2) | timings[pio][1]) << (hwif->channel ? 4 : 0)); 261 slave_data = slave_data | (((timings[pio][0] << 2) | timings[pio][1]) << (hwif->channel ? 4 : 0));
250 } else { 262 } else {
251 master_data = master_data & 0xccf8; 263 master_data = master_data & 0xccf8;
252 if (pio > 1) 264 if (pio > 1) {
253 /* enable PPE, IE and TIME */ 265 /* enable PPE, IE and TIME */
254 master_data = master_data | 0x0007; 266 master_data = master_data | control;
267 }
255 master_data = master_data | (timings[pio][0] << 12) | (timings[pio][1] << 8); 268 master_data = master_data | (timings[pio][0] << 12) | (timings[pio][1] << 8);
256 } 269 }
257 pci_write_config_word(dev, master_port, master_data); 270 pci_write_config_word(dev, master_port, master_data);