Example #1
0
static void dmfe_reset(struct net_device * dev)
{
	board_info_t *db = (board_info_t *)dev->priv;
	u8 reg_save;
	int i;
	/* Save previous register address */
	reg_save = inb(db->io_addr);

	netif_stop_queue(dev); 
	db->reset_counter++;
	dmfe_init_dm9000(dev);
	
	db->Speed =10;
	for(i=0; i<1000; i++) /*wait link OK, waiting time=1 second */
	{
		if(phy_read(db,0x1) & 0x4) /*Link OK*/
		{
			if(phy_read(db,0)&0x2000) db->Speed =100;
			else db->Speed =10;
			break;
		}
		udelay(1000);
	}
	
	netif_wake_queue(dev);
	
	/* Restore previous register address */
	outb(reg_save, db->io_addr);

}
Example #2
0
File: DM9K.c Project: tonyho/LDD
/*
  Open the interface.
  The interface is opened whenever "ifconfig" actives it.
*/
static int dmfe_open(struct net_device *dev)
{
	board_info_t *db = (board_info_t *)dev->priv;
	u8 reg_nsr;
	int i;
	DMFE_DBUG(0, "dmfe_open", 0);

	/* [email protected] */
	if (request_irq(dev->irq,&dmfe_interrupt, IRQF_TRIGGER_RISING,dev->name,dev)) 
		return -EAGAIN;

	/* Initilize DM910X board */
	dmfe_init_dm9000(dev);
#ifdef DM8606
	// control DM8606
	printk("[8606]reg0=0x%04x\n",dm8606_read(db,0));
	printk("[8606]reg1=0x%04x\n",dm8606_read(db,0x1));
#endif 
	/* Init driver variable */
	db->reset_counter 	= 0;
	db->reset_tx_timeout 	= 0;
	db->cont_rx_pkt_cnt	= 0;
	
	/* check link state and media speed */
	db->Speed =10;
	i=0;
	do {
		reg_nsr = ior(db,DM9KS_NSR);
		if(reg_nsr & 0x40) /* link OK!! */
		{
			/* wait for detected Speed */
			mdelay(200);
			reg_nsr = ior(db,DM9KS_NSR);
			if(reg_nsr & 0x80)
				db->Speed =10;
			else
				db->Speed =100;
			break;
		}
		i++;
		mdelay(1);
	}while(i<3000);	/* wait 3 second  */
	//printk("i=%d  Speed=%d\n",i,db->Speed);	
	/* set and active a timer process */
	init_timer(&db->timer);
	db->timer.expires 	= DMFE_TIMER_WUT;
	db->timer.data 		= (unsigned long)dev;
	db->timer.function 	= &dmfe_timer;
	add_timer(&db->timer);	//Move to DM9000 initiallization was finished.
 	
	netif_start_queue(dev);

	return 0;
}
Example #3
0
/* 
* Enable/Disable RX checksum offload
*/
static int dmfe_set_rx_csum(struct net_device *dev, uint32_t data)
{
#ifdef CHECKSUM
	board_info_t *db = (board_info_t *)dev->priv;
	db->rx_csum = data;

	if(netif_running(dev)) {
		dmfe_stop(dev);
		dmfe_open(dev);
	} else
		dmfe_init_dm9000(dev);
#else
	printk(KERN_ERR "DM9:Don't support checksum\n");
#endif
	return 0;
}
Example #4
0
/* Open the interface.
 * The interface is opened whenever "ifconfig" actives it.
 */
static int dmfe_open(struct net_device *dev)
{
    board_info_t *db = (board_info_t *) dev->priv;

    DMFE_DBUG(0, "dmfe_open", 0);

    if (request_irq(dev->irq, &dmfe_interrupt, /*SA_INTERRUPT*/SA_SHIRQ, dev->name/*"DM9000 device"*/, dev))
    {
        return -EAGAIN;
    }

    /* Initilize DM910X board */
    dmfe_init_dm9000(dev);

    /* Init driver variable */
    db->dbug_cnt	    = 0;
    db->runt_length_counter = 0;
    db->long_length_counter = 0;
    db->reset_counter	    = 0;

    /* set and active a timer process */
    init_timer(&db->timer);
    db->timer.expires	    = DMFE_TIMER_WUT * 2;
    db->timer.data	    = (unsigned long) dev;
    db->timer.function	    = &dmfe_timer;
    add_timer(&db->timer);	// Move to DM9000 initiallization was finished.

#if defined(AUTOMDIX)
    /* set and active a timer process for Auto-MDIX */
    init_timer(&db->mdix_timer);
    db->mdix_timer.expires  = DMFE_TIMER_MDIX;
    db->mdix_timer.data	    = (unsigned long) dev;
    db->mdix_timer.function = &dmfe_mdix_timer;
    add_timer(&db->mdix_timer);
#endif

    netif_start_queue(dev);

    enable_irq(dev->irq);

    return 0;
}