diff options
Diffstat (limited to 'drivers/ide/pci/cs5535.c')
-rw-r--r-- | drivers/ide/pci/cs5535.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index ce44e38390aa..082ca7da2cbc 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * linux/drivers/ide/pci/cs5535.c | 2 | * linux/drivers/ide/pci/cs5535.c |
3 | * | 3 | * |
4 | * Copyright (C) 2004-2005 Advanced Micro Devices, Inc. | 4 | * Copyright (C) 2004-2005 Advanced Micro Devices, Inc. |
5 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | ||
5 | * | 6 | * |
6 | * History: | 7 | * History: |
7 | * 09/20/2005 - Jaya Kumar <jayakumar.ide@gmail.com> | 8 | * 09/20/2005 - Jaya Kumar <jayakumar.ide@gmail.com> |
@@ -83,14 +84,17 @@ static void cs5535_set_speed(ide_drive_t *drive, u8 speed) | |||
83 | 84 | ||
84 | /* Set the PIO timings */ | 85 | /* Set the PIO timings */ |
85 | if ((speed & XFER_MODE) == XFER_PIO) { | 86 | if ((speed & XFER_MODE) == XFER_PIO) { |
86 | u8 pioa; | 87 | ide_drive_t *pair = &drive->hwif->drives[drive->dn ^ 1]; |
87 | u8 piob; | 88 | u8 cmd, pioa; |
88 | u8 cmd; | ||
89 | 89 | ||
90 | pioa = speed - XFER_PIO_0; | 90 | cmd = pioa = speed - XFER_PIO_0; |
91 | piob = ide_get_best_pio_mode(&(drive->hwif->drives[!unit]), | 91 | |
92 | 255, 4); | 92 | if (pair->present) { |
93 | cmd = pioa < piob ? pioa : piob; | 93 | u8 piob = ide_get_best_pio_mode(pair, 255, 4); |
94 | |||
95 | if (piob < cmd) | ||
96 | cmd = piob; | ||
97 | } | ||
94 | 98 | ||
95 | /* Write the speed of the current drive */ | 99 | /* Write the speed of the current drive */ |
96 | reg = (cs5535_pio_cmd_timings[cmd] << 16) | | 100 | reg = (cs5535_pio_cmd_timings[cmd] << 16) | |
@@ -116,7 +120,7 @@ static void cs5535_set_speed(ide_drive_t *drive, u8 speed) | |||
116 | 120 | ||
117 | reg &= 0x80000000UL; /* Preserve the PIO format bit */ | 121 | reg &= 0x80000000UL; /* Preserve the PIO format bit */ |
118 | 122 | ||
119 | if (speed >= XFER_UDMA_0 && speed <= XFER_UDMA_7) | 123 | if (speed >= XFER_UDMA_0 && speed <= XFER_UDMA_4) |
120 | reg |= cs5535_udma_timings[speed - XFER_UDMA_0]; | 124 | reg |= cs5535_udma_timings[speed - XFER_UDMA_0]; |
121 | else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) | 125 | else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) |
122 | reg |= cs5535_mwdma_timings[speed - XFER_MW_DMA_0]; | 126 | reg |= cs5535_mwdma_timings[speed - XFER_MW_DMA_0]; |
@@ -151,32 +155,22 @@ static int cs5535_set_drive(ide_drive_t *drive, u8 speed) | |||
151 | * | 155 | * |
152 | * A callback from the upper layers for PIO-only tuning. | 156 | * A callback from the upper layers for PIO-only tuning. |
153 | */ | 157 | */ |
154 | static void cs5535_tuneproc(ide_drive_t *drive, u8 xferspeed) | 158 | static void cs5535_tuneproc(ide_drive_t *drive, u8 pio) |
155 | { | 159 | { |
156 | u8 modes[] = { XFER_PIO_0, XFER_PIO_1, XFER_PIO_2, XFER_PIO_3, | 160 | pio = ide_get_best_pio_mode(drive, pio, 4); |
157 | XFER_PIO_4 }; | 161 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
158 | 162 | cs5535_set_speed(drive, XFER_PIO_0 + pio); | |
159 | /* cs5535 max pio is pio 4, best_pio will check the blacklist. | ||
160 | i think we don't need to rate_filter the incoming xferspeed | ||
161 | since we know we're only going to choose pio */ | ||
162 | xferspeed = ide_get_best_pio_mode(drive, xferspeed, 4); | ||
163 | ide_config_drive_speed(drive, modes[xferspeed]); | ||
164 | cs5535_set_speed(drive, xferspeed); | ||
165 | } | 163 | } |
166 | 164 | ||
167 | static int cs5535_dma_check(ide_drive_t *drive) | 165 | static int cs5535_dma_check(ide_drive_t *drive) |
168 | { | 166 | { |
169 | u8 speed; | ||
170 | |||
171 | drive->init_speed = 0; | 167 | drive->init_speed = 0; |
172 | 168 | ||
173 | if (ide_tune_dma(drive)) | 169 | if (ide_tune_dma(drive)) |
174 | return 0; | 170 | return 0; |
175 | 171 | ||
176 | if (ide_use_fast_pio(drive)) { | 172 | if (ide_use_fast_pio(drive)) |
177 | speed = ide_get_best_pio_mode(drive, 255, 4); | 173 | cs5535_tuneproc(drive, 255); |
178 | cs5535_set_drive(drive, speed); | ||
179 | } | ||
180 | 174 | ||
181 | return -1; | 175 | return -1; |
182 | } | 176 | } |