diff options
Diffstat (limited to 'drivers/ide/pci/piix.c')
-rw-r--r-- | drivers/ide/pci/piix.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index 38c91ba6497b..4b397d641848 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -106,37 +106,6 @@ | |||
106 | static int no_piix_dma; | 106 | static int no_piix_dma; |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * piix_dma_2_pio - return the PIO mode matching DMA | ||
110 | * @xfer_rate: transfer speed | ||
111 | * | ||
112 | * Returns the nearest equivalent PIO timing for the DMA | ||
113 | * mode requested by the controller. | ||
114 | */ | ||
115 | |||
116 | static u8 piix_dma_2_pio (u8 xfer_rate) { | ||
117 | switch(xfer_rate) { | ||
118 | case XFER_UDMA_6: | ||
119 | case XFER_UDMA_5: | ||
120 | case XFER_UDMA_4: | ||
121 | case XFER_UDMA_3: | ||
122 | case XFER_UDMA_2: | ||
123 | case XFER_UDMA_1: | ||
124 | case XFER_UDMA_0: | ||
125 | case XFER_MW_DMA_2: | ||
126 | return 4; | ||
127 | case XFER_MW_DMA_1: | ||
128 | return 3; | ||
129 | case XFER_SW_DMA_2: | ||
130 | return 2; | ||
131 | case XFER_MW_DMA_0: | ||
132 | case XFER_SW_DMA_1: | ||
133 | case XFER_SW_DMA_0: | ||
134 | default: | ||
135 | return 0; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * piix_set_pio_mode - set host controller for PIO mode | 109 | * piix_set_pio_mode - set host controller for PIO mode |
141 | * @drive: drive | 110 | * @drive: drive |
142 | * @pio: PIO mode number | 111 | * @pio: PIO mode number |
@@ -225,7 +194,7 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
225 | int u_speed = 0; | 194 | int u_speed = 0; |
226 | int sitre; | 195 | int sitre; |
227 | u16 reg4042, reg4a; | 196 | u16 reg4042, reg4a; |
228 | u8 reg48, reg54, reg55; | 197 | u8 reg48, reg54, reg55, pio; |
229 | 198 | ||
230 | pci_read_config_word(dev, maslave, ®4042); | 199 | pci_read_config_word(dev, maslave, ®4042); |
231 | sitre = (reg4042 & 0x4000) ? 1 : 0; | 200 | sitre = (reg4042 & 0x4000) ? 1 : 0; |
@@ -262,7 +231,11 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
262 | pci_write_config_byte(dev, 0x54, reg54 | v_flag); | 231 | pci_write_config_byte(dev, 0x54, reg54 | v_flag); |
263 | } else | 232 | } else |
264 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); | 233 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); |
234 | |||
235 | pio = 4; | ||
265 | } else { | 236 | } else { |
237 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; | ||
238 | |||
266 | if (reg48 & u_flag) | 239 | if (reg48 & u_flag) |
267 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); | 240 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); |
268 | if (reg4a & a_speed) | 241 | if (reg4a & a_speed) |
@@ -271,9 +244,14 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
271 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); | 244 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); |
272 | if (reg55 & w_flag) | 245 | if (reg55 & w_flag) |
273 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); | 246 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); |
247 | |||
248 | if (speed >= XFER_MW_DMA_0) | ||
249 | pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; | ||
250 | else | ||
251 | pio = 2; /* only SWDMA2 is allowed */ | ||
274 | } | 252 | } |
275 | 253 | ||
276 | piix_set_pio_mode(drive, piix_dma_2_pio(speed)); | 254 | piix_set_pio_mode(drive, pio); |
277 | } | 255 | } |
278 | 256 | ||
279 | /** | 257 | /** |