diff options
Diffstat (limited to 'drivers/ide/pci/it8213.c')
-rw-r--r-- | drivers/ide/pci/it8213.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index ecf4ce078dce..6dab0daf4943 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 |
@@ -124,7 +93,7 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
124 | int w_flag = 0x10 << drive->dn; | 93 | int w_flag = 0x10 << drive->dn; |
125 | int u_speed = 0; | 94 | int u_speed = 0; |
126 | u16 reg4042, reg4a; | 95 | u16 reg4042, reg4a; |
127 | u8 reg48, reg54, reg55; | 96 | u8 reg48, reg54, reg55, pio; |
128 | 97 | ||
129 | pci_read_config_word(dev, maslave, ®4042); | 98 | pci_read_config_word(dev, maslave, ®4042); |
130 | pci_read_config_byte(dev, 0x48, ®48); | 99 | pci_read_config_byte(dev, 0x48, ®48); |
@@ -165,7 +134,11 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
165 | pci_write_config_byte(dev, 0x54, reg54 | v_flag); | 134 | pci_write_config_byte(dev, 0x54, reg54 | v_flag); |
166 | } else | 135 | } else |
167 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); | 136 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); |
137 | |||
138 | pio = 4; | ||
168 | } else { | 139 | } else { |
140 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; | ||
141 | |||
169 | if (reg48 & u_flag) | 142 | if (reg48 & u_flag) |
170 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); | 143 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); |
171 | if (reg4a & a_speed) | 144 | if (reg4a & a_speed) |
@@ -174,9 +147,14 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
174 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); | 147 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); |
175 | if (reg55 & w_flag) | 148 | if (reg55 & w_flag) |
176 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); | 149 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); |
150 | |||
151 | if (speed >= XFER_MW_DMA_0) | ||
152 | pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; | ||
153 | else | ||
154 | pio = 2; /* only SWDMA2 is allowed */ | ||
177 | } | 155 | } |
178 | 156 | ||
179 | it8213_set_pio_mode(drive, it8213_dma_2_pio(speed)); | 157 | it8213_set_pio_mode(drive, pio); |
180 | } | 158 | } |
181 | 159 | ||
182 | /** | 160 | /** |