diff options
Diffstat (limited to 'drivers/ide/pci/it8213.c')
-rw-r--r-- | drivers/ide/pci/it8213.c | 84 |
1 files changed, 12 insertions, 72 deletions
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index ecf4ce078dce..24a71d03744a 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -18,37 +18,6 @@ | |||
18 | #include <asm/io.h> | 18 | #include <asm/io.h> |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * it8213_dma_2_pio - return the PIO mode matching DMA | ||
22 | * @xfer_rate: transfer speed | ||
23 | * | ||
24 | * Returns the nearest equivalent PIO timing for the DMA | ||
25 | * mode requested by the controller. | ||
26 | */ | ||
27 | |||
28 | static u8 it8213_dma_2_pio (u8 xfer_rate) { | ||
29 | switch(xfer_rate) { | ||
30 | case XFER_UDMA_6: | ||
31 | case XFER_UDMA_5: | ||
32 | case XFER_UDMA_4: | ||
33 | case XFER_UDMA_3: | ||
34 | case XFER_UDMA_2: | ||
35 | case XFER_UDMA_1: | ||
36 | case XFER_UDMA_0: | ||
37 | case XFER_MW_DMA_2: | ||
38 | return 4; | ||
39 | case XFER_MW_DMA_1: | ||
40 | return 3; | ||
41 | case XFER_SW_DMA_2: | ||
42 | return 2; | ||
43 | case XFER_MW_DMA_0: | ||
44 | case XFER_SW_DMA_1: | ||
45 | case XFER_SW_DMA_0: | ||
46 | default: | ||
47 | return 0; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * it8213_set_pio_mode - set host controller for PIO mode | 21 | * it8213_set_pio_mode - set host controller for PIO mode |
53 | * @drive: drive | 22 | * @drive: drive |
54 | * @pio: PIO mode number | 23 | * @pio: PIO mode number |
@@ -166,6 +135,9 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
166 | } else | 135 | } else |
167 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); | 136 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); |
168 | } else { | 137 | } else { |
138 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; | ||
139 | u8 pio; | ||
140 | |||
169 | if (reg48 & u_flag) | 141 | if (reg48 & u_flag) |
170 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); | 142 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); |
171 | if (reg4a & a_speed) | 143 | if (reg4a & a_speed) |
@@ -174,38 +146,21 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
174 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); | 146 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); |
175 | if (reg55 & w_flag) | 147 | if (reg55 & w_flag) |
176 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); | 148 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); |
177 | } | ||
178 | |||
179 | it8213_set_pio_mode(drive, it8213_dma_2_pio(speed)); | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * it8213_configure_drive_for_dma - set up for DMA transfers | ||
184 | * @drive: drive we are going to set up | ||
185 | * | ||
186 | * Set up the drive for DMA, tune the controller and drive as | ||
187 | * required. If the drive isn't suitable for DMA or we hit | ||
188 | * other problems then we will drop down to PIO and set up | ||
189 | * PIO appropriately | ||
190 | */ | ||
191 | 149 | ||
192 | static int it8213_config_drive_for_dma (ide_drive_t *drive) | 150 | if (speed >= XFER_MW_DMA_0) |
193 | { | 151 | pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; |
194 | if (ide_tune_dma(drive)) | 152 | else |
195 | return 0; | 153 | pio = 2; /* only SWDMA2 is allowed */ |
196 | 154 | ||
197 | ide_set_max_pio(drive); | 155 | it8213_set_pio_mode(drive, pio); |
198 | 156 | } | |
199 | return -1; | ||
200 | } | 157 | } |
201 | 158 | ||
202 | /** | 159 | /** |
203 | * init_hwif_it8213 - set up hwif structs | 160 | * init_hwif_it8213 - set up hwif structs |
204 | * @hwif: interface to set up | 161 | * @hwif: interface to set up |
205 | * | 162 | * |
206 | * We do the basic set up of the interface structure. The IT8212 | 163 | * We do the basic set up of the interface structure. |
207 | * requires several custom handlers so we override the default | ||
208 | * ide DMA handlers appropriately | ||
209 | */ | 164 | */ |
210 | 165 | ||
211 | static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | 166 | static void __devinit init_hwif_it8213(ide_hwif_t *hwif) |
@@ -215,8 +170,6 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | |||
215 | hwif->set_dma_mode = &it8213_set_dma_mode; | 170 | hwif->set_dma_mode = &it8213_set_dma_mode; |
216 | hwif->set_pio_mode = &it8213_set_pio_mode; | 171 | hwif->set_pio_mode = &it8213_set_pio_mode; |
217 | 172 | ||
218 | hwif->autodma = 0; | ||
219 | |||
220 | hwif->drives[0].autotune = 1; | 173 | hwif->drives[0].autotune = 1; |
221 | hwif->drives[1].autotune = 1; | 174 | hwif->drives[1].autotune = 1; |
222 | 175 | ||
@@ -230,20 +183,8 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | |||
230 | 183 | ||
231 | pci_read_config_byte(hwif->pci_dev, 0x42, ®42h); | 184 | pci_read_config_byte(hwif->pci_dev, 0x42, ®42h); |
232 | 185 | ||
233 | hwif->ide_dma_check = &it8213_config_drive_for_dma; | ||
234 | |||
235 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 186 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
236 | hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 187 | hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
237 | |||
238 | /* | ||
239 | * The BIOS often doesn't set up DMA on this controller | ||
240 | * so we always do it. | ||
241 | */ | ||
242 | if (!noautodma) | ||
243 | hwif->autodma = 1; | ||
244 | |||
245 | hwif->drives[0].autodma = hwif->autodma; | ||
246 | hwif->drives[1].autodma = hwif->autodma; | ||
247 | } | 188 | } |
248 | 189 | ||
249 | 190 | ||
@@ -279,9 +220,8 @@ static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_devic | |||
279 | return 0; | 220 | return 0; |
280 | } | 221 | } |
281 | 222 | ||
282 | 223 | static const struct pci_device_id it8213_pci_tbl[] = { | |
283 | static struct pci_device_id it8213_pci_tbl[] = { | 224 | { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8213), 0 }, |
284 | { PCI_VENDOR_ID_ITE, 0x8213, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | ||
285 | { 0, }, | 225 | { 0, }, |
286 | }; | 226 | }; |
287 | 227 | ||