kernels/linux-2.4.0/drivers/ide/qd6580.c
/*
 * tune_drive
 *
 * Finds timings for the specified drive, returns it in struct t
 */
tune_drive
Finds timings for the specified drive, returns it in struct t
tune_drive Finds timings for the specified drive returns it in struct t
static void tune_drive ( ide_drive_t *drive, byte pio, ide_hd_timings_t *t )
{
	ide_pio_data_t d;
	t->active_time   = 175;
	t->recovery_time = 415; 
	if (!drive->present) {	
		t->active_time = 0;
		t->recovery_time = 0;
		return;
	}
	pio = ide_get_best_pio_mode(drive, pio, 255, &d);
	pio = IDE_MIN(pio,4);
	switch (pio) {
		case 0: break;
		case 3:
			if (d.cycle_time >= 110) {
				t->active_time = 86;
				t->recovery_time = d.cycle_time-102;
			} else {
				printk("%s: Strange recovery time !\n",drive->name);
				return;
			}
			break;
		case 4:
			if (d.cycle_time >= 69) {
				t->active_time = 70;
				t->recovery_time = d.cycle_time-61;
			} else {
				printk("%s: Strange recovery time !\n",drive->name);
				return;
			}
			break;
		default:
			if (d.cycle_time >= 180) {
				t->active_time = 110;
				t->recovery_time = d.cycle_time - 120;
			} else {
				t->active_time = ide_pio_timings[pio].active_time;
				t->recovery_time = d.cycle_time
						-t->active_time;
			}
	}
	printk("%s: PIO mode%d, tim1=%dns tim2=%dns\n", drive->name, pio, t->active_time, t->recovery_time);
	if (drive->media == ide_disk)
		nb_disks_prim++;
	else {
		write_reg(0x5f,basePort+0x03);
		printk("%s: Warning: please try to connect this drive to secondary IDE port\nto improve data transfer rate on primary IDE port.\n",drive->name);
	}
}
static void tune_drive ( ide_drive_t * drive , byte pio , ide_hd_timings_t * t ) { ide_pio_data_t d ; t -> active_time = 175 ; t -> recovery_time = 415 ; if ( ! drive -> present ) { t -> active_time = 0 ; t -> recovery_time = 0 ; return ; } pio = ide_get_best_pio_mode ( drive , pio , 255 , & d ) ; pio = IDE_MIN ( pio , 4 ) ; switch ( pio ) { case 0 : break ; case 3 : if ( d . cycle_time >= 110 ) { t -> active_time = 86 ; t -> recovery_time = d . cycle_time - 102 ; } else { printk ( " \n " , drive -> name ) ; return ; } break ; case 4 : if ( d . cycle_time >= 69 ) { t -> active_time = 70 ; t -> recovery_time = d . cycle_time - 61 ; } else { printk ( " \n " , drive -> name ) ; return ; } break ; default : if ( d . cycle_time >= 180 ) { t -> active_time = 110 ; t -> recovery_time = d . cycle_time - 120 ; } else { t -> active_time = ide_pio_timings [ pio ] . active_time ; t -> recovery_time = d . cycle_time - t -> active_time ; } } printk ( " \n " , drive -> name , pio , t -> active_time , t -> recovery_time ) ; if ( drive -> media == ide_disk ) nb_disks_prim ++ ; else { write_reg ( 0x5f , basePort + 0x03 ) ; printk ( " \n \n " , drive -> name ) ; } }
tune_drive
 Finds timings for the specified drive, returns it in struct t
tune_drive Finds timings for the specified drive returns it in struct t
/* worst cases values from the dos driver */ /* not present : free to give any timing */ /* need to disable read-ahead FIFO and post-write buffer for ATAPI drives*/