patch-2.0.11 linux/drivers/block/ali14xx.c

Next file: linux/drivers/block/cmd640.c
Previous file: linux/drivers/block/Config.in
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.10/linux/drivers/block/ali14xx.c linux/drivers/block/ali14xx.c
@@ -51,20 +51,6 @@
 #include "ide.h"
 #include "ide_modes.h"
 
-/*
- * This should be set to the system's local bus (PCI or VLB) speed,
- * e.g., 33 for a 486DX33 or 486DX2/66.  Legal values are anything
- * from 25 to 50.  Setting this too *low* will make the EIDE
- * controller unable to communicate with the disks.
- *
- * The value is 50 by default -- this should work ok with any system.
- * (Low values cause problems because it multiplies by bus speed
- * to get cycles, and thus gets a too-small cycle count and tries to
- * access the disks too fast.  I tried this once under DOS and it locked
- * up the system.)	-- derekn@vw.ece.cmu.edu
- */
-#define ALI_14xx_BUS_SPEED	50	/* PCI / VLB bus speed */
-
 /* port addresses for auto-detection */
 #define ALI_NUM_PORTS 4
 static int ports[ALI_NUM_PORTS] = {0x074, 0x0f4, 0x034, 0x0e4};
@@ -82,15 +68,7 @@
 	{0x35, 0x03}, {0x00, 0x00}
 };
 
-/* default timing parameters for each PIO mode */
 #define ALI_MAX_PIO 4
-static struct { int time1, time2; } timeTab[ALI_MAX_PIO+1] = {
-	{600, 165},	/* PIO 0 */
-	{383, 125},	/* PIO 1 */
-	{240, 100},	/* PIO 2 */
-	{180,  80},	/* PIO 3 */
-	{120,  70}	/* PIO 4 */
-};
 
 /* timing parameter registers for each drive */
 static struct { byte reg1, reg2, reg3, reg4; } regTab[4] = {
@@ -134,26 +112,19 @@
 static void ali14xx_tune_drive (ide_drive_t *drive, byte pio)
 {
 	int driveNum;
-	int time1, time2, time1a;
+	int time1, time2;
 	byte param1, param2, param3, param4;
-	struct hd_driveid *id = drive->id;
 	unsigned long flags;
+	ide_pio_data_t d;
+	int bus_speed = ide_system_bus_speed();
 
-	if (pio == 255)
-		pio = ide_get_best_pio_mode(drive);
-	if (pio > ALI_MAX_PIO)
-		pio = ALI_MAX_PIO;
+	pio = ide_get_best_pio_mode(drive, pio, ALI_MAX_PIO, &d);
 
 	/* calculate timing, according to PIO mode */
-	time1 = timeTab[pio].time1;
-	time2 = timeTab[pio].time2;
-	if (pio >= 3) {
-		time1a = (id->capability & 0x08) ? id->eide_pio_iordy : id->eide_pio;
-		if (time1a != 0 && time1a < time1)
-			time1 = time1a;
-	}
-	param3 = param1 = (time2 * ALI_14xx_BUS_SPEED + 999) / 1000;
-	param4 = param2 = (time1 * ALI_14xx_BUS_SPEED + 999) / 1000 - param1;
+	time1 = d.cycle_time;
+	time2 = ide_pio_timings[pio].active_time;
+	param3 = param1 = (time2 * bus_speed + 999) / 1000;
+	param4 = param2 = (time1 * bus_speed + 999) / 1000 - param1;
 	if (pio < 3) {
 		param3 += 8;
 		param4 += 8;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov