aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/piix.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/piix.c')
-rw-r--r--drivers/ide/piix.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c
index bf14f39bd3a7..1bdca49e5a03 100644
--- a/drivers/ide/piix.c
+++ b/drivers/ide/piix.c
@@ -59,15 +59,14 @@ static int no_piix_dma;
59 59
60/** 60/**
61 * piix_set_pio_mode - set host controller for PIO mode 61 * piix_set_pio_mode - set host controller for PIO mode
62 * @port: port
62 * @drive: drive 63 * @drive: drive
63 * @pio: PIO mode number
64 * 64 *
65 * Set the interface PIO mode based upon the settings done by AMI BIOS. 65 * Set the interface PIO mode based upon the settings done by AMI BIOS.
66 */ 66 */
67 67
68static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) 68static void piix_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
69{ 69{
70 ide_hwif_t *hwif = drive->hwif;
71 struct pci_dev *dev = to_pci_dev(hwif->dev); 70 struct pci_dev *dev = to_pci_dev(hwif->dev);
72 int is_slave = drive->dn & 1; 71 int is_slave = drive->dn & 1;
73 int master_port = hwif->channel ? 0x42 : 0x40; 72 int master_port = hwif->channel ? 0x42 : 0x40;
@@ -77,6 +76,7 @@ static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio)
77 u8 slave_data; 76 u8 slave_data;
78 static DEFINE_SPINLOCK(tune_lock); 77 static DEFINE_SPINLOCK(tune_lock);
79 int control = 0; 78 int control = 0;
79 const u8 pio = drive->pio_mode - XFER_PIO_0;
80 80
81 /* ISP RTC */ 81 /* ISP RTC */
82 static const u8 timings[][2]= { 82 static const u8 timings[][2]= {
@@ -127,16 +127,15 @@ static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio)
127 127
128/** 128/**
129 * piix_set_dma_mode - set host controller for DMA mode 129 * piix_set_dma_mode - set host controller for DMA mode
130 * @hwif: port
130 * @drive: drive 131 * @drive: drive
131 * @speed: DMA mode
132 * 132 *
133 * Set a PIIX host controller to the desired DMA mode. This involves 133 * Set a PIIX host controller to the desired DMA mode. This involves
134 * programming the right timing data into the PCI configuration space. 134 * programming the right timing data into the PCI configuration space.
135 */ 135 */
136 136
137static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) 137static void piix_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
138{ 138{
139 ide_hwif_t *hwif = drive->hwif;
140 struct pci_dev *dev = to_pci_dev(hwif->dev); 139 struct pci_dev *dev = to_pci_dev(hwif->dev);
141 u8 maslave = hwif->channel ? 0x42 : 0x40; 140 u8 maslave = hwif->channel ? 0x42 : 0x40;
142 int a_speed = 3 << (drive->dn * 4); 141 int a_speed = 3 << (drive->dn * 4);
@@ -147,6 +146,7 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
147 int sitre; 146 int sitre;
148 u16 reg4042, reg4a; 147 u16 reg4042, reg4a;
149 u8 reg48, reg54, reg55; 148 u8 reg48, reg54, reg55;
149 const u8 speed = drive->dma_mode;
150 150
151 pci_read_config_word(dev, maslave, &reg4042); 151 pci_read_config_word(dev, maslave, &reg4042);
152 sitre = (reg4042 & 0x4000) ? 1 : 0; 152 sitre = (reg4042 & 0x4000) ? 1 : 0;
@@ -176,7 +176,6 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
176 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 176 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
177 } else { 177 } else {
178 const u8 mwdma_to_pio[] = { 0, 3, 4 }; 178 const u8 mwdma_to_pio[] = { 0, 3, 4 };
179 u8 pio;
180 179
181 if (reg48 & u_flag) 180 if (reg48 & u_flag)
182 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); 181 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
@@ -188,11 +187,12 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
188 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); 187 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
189 188
190 if (speed >= XFER_MW_DMA_0) 189 if (speed >= XFER_MW_DMA_0)
191 pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; 190 drive->pio_mode =
191 mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
192 else 192 else
193 pio = 2; /* only SWDMA2 is allowed */ 193 drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */
194 194
195 piix_set_pio_mode(drive, pio); 195 piix_set_pio_mode(hwif, drive);
196 } 196 }
197} 197}
198 198