コード例 #1
0
ファイル: ne2000.c プロジェクト: 8devices/Caraboot
static void pcnet_reset_8390(void)
{
	int i, r;

	PRINTK("nic base is %lx\n", nic_base);

#if 1
	n2k_outb(E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD);
	PRINTK("cmd (at %lx) is %x\n", nic_base+ E8390_CMD, n2k_inb(E8390_CMD));
	n2k_outb(E8390_NODMA+E8390_PAGE1+E8390_STOP, E8390_CMD);
	PRINTK("cmd (at %lx) is %x\n", nic_base+ E8390_CMD, n2k_inb(E8390_CMD));
	n2k_outb(E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD);
	PRINTK("cmd (at %lx) is %x\n", nic_base+ E8390_CMD, n2k_inb(E8390_CMD));
#endif
	n2k_outb(E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD);

	n2k_outb(n2k_inb(nic_base + PCNET_RESET), PCNET_RESET);

	for (i = 0; i < 100; i++) {
		if ((r = (n2k_inb(EN0_ISR) & ENISR_RESET)) != 0)
			break;
		PRINTK("got %x in reset\n", r);
		my_udelay(100);
	}
	n2k_outb(ENISR_RESET, EN0_ISR); /* Ack intr. */

	if (i == 100)
		printf("pcnet_reset_8390() did not complete.\n");
} /* pcnet_reset_8390 */
コード例 #2
0
int my_check_delay(long delay)
{
	struct timeval tv_start ;
	struct timeval tv_end ;
	volatile unsigned long time_diff ;
	int result ;
	int max_try = 3;
	do_gettimeofday(&tv_start) ;
	while(1){
		time_diff = my_udelay(delay) ;
		do_gettimeofday(&tv_end) ;
		time_diff = my_check_diff_time(tv_start, tv_end);
		if(time_diff >= delay || max_try-- <= 0)
			break ;
	}
	if( (time_diff > (delay + delay)) || (time_diff < (delay - delay/2))){
		printk("delay routine err req %d actual %d \n", delay, time_diff) ;
		return -1 ;
	}

	return 0 ;
}