aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/opti621.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/opti621.c')
-rw-r--r--drivers/ide/pci/opti621.c82
1 files changed, 40 insertions, 42 deletions
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index 46e8748f507e..6e99080497bf 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -53,13 +53,12 @@
53 * If you then set the second drive to another PIO, the old value 53 * If you then set the second drive to another PIO, the old value
54 * (automatically selected) will be overrided by yours. 54 * (automatically selected) will be overrided by yours.
55 * There is a 25/33MHz switch in configuration 55 * There is a 25/33MHz switch in configuration
56 * register, but driver is written for use at any frequency which get 56 * register, but driver is written for use at any frequency.
57 * (use idebus=xx to select PCI bus speed).
58 * 57 *
59 * Version 0.1, Nov 8, 1996 58 * Version 0.1, Nov 8, 1996
60 * by Jaromir Koutek, for 2.1.8. 59 * by Jaromir Koutek, for 2.1.8.
61 * Initial version of driver. 60 * Initial version of driver.
62 * 61 *
63 * Version 0.2 62 * Version 0.2
64 * Number 0.2 skipped. 63 * Number 0.2 skipped.
65 * 64 *
@@ -75,7 +74,7 @@
75 * by Jaromir Koutek 74 * by Jaromir Koutek
76 * Updates for use with (again) new IDE block driver. 75 * Updates for use with (again) new IDE block driver.
77 * Update of documentation. 76 * Update of documentation.
78 * 77 *
79 * Version 0.6, Jan 2, 1999 78 * Version 0.6, Jan 2, 1999
80 * by Jaromir Koutek 79 * by Jaromir Koutek
81 * Reversed to version 0.3 of the driver, because 80 * Reversed to version 0.3 of the driver, because
@@ -208,29 +207,34 @@ typedef struct pio_clocks_s {
208 207
209static void compute_clocks(int pio, pio_clocks_t *clks) 208static void compute_clocks(int pio, pio_clocks_t *clks)
210{ 209{
211 if (pio != PIO_NOT_EXIST) { 210 if (pio != PIO_NOT_EXIST) {
212 int adr_setup, data_pls; 211 int adr_setup, data_pls;
213 int bus_speed = system_bus_clock(); 212 int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock();
214 213
215 adr_setup = ide_pio_timings[pio].setup_time; 214 adr_setup = ide_pio_timings[pio].setup_time;
216 data_pls = ide_pio_timings[pio].active_time; 215 data_pls = ide_pio_timings[pio].active_time;
217 clks->address_time = cmpt_clk(adr_setup, bus_speed); 216 clks->address_time = cmpt_clk(adr_setup, bus_speed);
218 clks->data_time = cmpt_clk(data_pls, bus_speed); 217 clks->data_time = cmpt_clk(data_pls, bus_speed);
219 clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time 218 clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time
220 - adr_setup-data_pls, bus_speed); 219 - adr_setup-data_pls, bus_speed);
221 if (clks->address_time<1) clks->address_time = 1; 220 if (clks->address_time < 1)
222 if (clks->address_time>4) clks->address_time = 4; 221 clks->address_time = 1;
223 if (clks->data_time<1) clks->data_time = 1; 222 if (clks->address_time > 4)
224 if (clks->data_time>16) clks->data_time = 16; 223 clks->address_time = 4;
225 if (clks->recovery_time<2) clks->recovery_time = 2; 224 if (clks->data_time < 1)
226 if (clks->recovery_time>17) clks->recovery_time = 17; 225 clks->data_time = 1;
226 if (clks->data_time > 16)
227 clks->data_time = 16;
228 if (clks->recovery_time < 2)
229 clks->recovery_time = 2;
230 if (clks->recovery_time > 17)
231 clks->recovery_time = 17;
227 } else { 232 } else {
228 clks->address_time = 1; 233 clks->address_time = 1;
229 clks->data_time = 1; 234 clks->data_time = 1;
230 clks->recovery_time = 2; 235 clks->recovery_time = 2;
231 /* minimal values */ 236 /* minimal values */
232 } 237 }
233
234} 238}
235 239
236static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) 240static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
@@ -247,8 +251,8 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
247 251
248 /* sets drive->drive_data for both drives */ 252 /* sets drive->drive_data for both drives */
249 compute_pios(drive, pio); 253 compute_pios(drive, pio);
250 pio1 = hwif->drives[0].drive_data; 254 pio1 = hwif->drives[0].drive_data;
251 pio2 = hwif->drives[1].drive_data; 255 pio2 = hwif->drives[1].drive_data;
252 256
253 compute_clocks(pio1, &first); 257 compute_clocks(pio1, &first);
254 compute_clocks(pio2, &second); 258 compute_clocks(pio2, &second);
@@ -275,7 +279,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
275 279
276 spin_lock_irqsave(&opti621_lock, flags); 280 spin_lock_irqsave(&opti621_lock, flags);
277 281
278 reg_base = hwif->io_ports[IDE_DATA_OFFSET]; 282 reg_base = hwif->io_ports.data_addr;
279 283
280 /* allow Register-B */ 284 /* allow Register-B */
281 outb(0xc0, reg_base + CNTRL_REG); 285 outb(0xc0, reg_base + CNTRL_REG);
@@ -321,31 +325,25 @@ static void __devinit opti621_port_init_devs(ide_hwif_t *hwif)
321 hwif->drives[1].drive_data = PIO_DONT_KNOW; 325 hwif->drives[1].drive_data = PIO_DONT_KNOW;
322} 326}
323 327
324/* 328static const struct ide_port_ops opti621_port_ops = {
325 * init_hwif_opti621() is called once for each hwif found at boot. 329 .port_init_devs = opti621_port_init_devs,
326 */ 330 .set_pio_mode = opti621_set_pio_mode,
327static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) 331};
328{
329 hwif->port_init_devs = opti621_port_init_devs;
330 hwif->set_pio_mode = &opti621_set_pio_mode;
331}
332 332
333static const struct ide_port_info opti621_chipsets[] __devinitdata = { 333static const struct ide_port_info opti621_chipsets[] __devinitdata = {
334 { /* 0 */ 334 { /* 0 */
335 .name = "OPTI621", 335 .name = "OPTI621",
336 .init_hwif = init_hwif_opti621, 336 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
337 .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}}, 337 .port_ops = &opti621_port_ops,
338 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | 338 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
339 IDE_HFLAG_BOOTABLE,
340 .pio_mask = ATA_PIO3, 339 .pio_mask = ATA_PIO3,
341 .swdma_mask = ATA_SWDMA2, 340 .swdma_mask = ATA_SWDMA2,
342 .mwdma_mask = ATA_MWDMA2, 341 .mwdma_mask = ATA_MWDMA2,
343 },{ /* 1 */ 342 }, { /* 1 */
344 .name = "OPTI621X", 343 .name = "OPTI621X",
345 .init_hwif = init_hwif_opti621, 344 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
346 .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}}, 345 .port_ops = &opti621_port_ops,
347 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | 346 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
348 IDE_HFLAG_BOOTABLE,
349 .pio_mask = ATA_PIO3, 347 .pio_mask = ATA_PIO3,
350 .swdma_mask = ATA_SWDMA2, 348 .swdma_mask = ATA_SWDMA2,
351 .mwdma_mask = ATA_MWDMA2, 349 .mwdma_mask = ATA_MWDMA2,