printk("%s: FEC ENET Version 0.2, ", dev->name); for (i=0; i<5; i++) printk("%02x:", dev->dev_addr[i]); printk("%02x\n", dev->dev_addr[5]);  
int __init fec_enet_init(struct net_device *dev){	struct fec_enet_private *fep = netdev_priv(dev);	unsigned long	mem_addr;	volatile cbd_t	*bdp;	cbd_t		*cbd_base;	volatile fec_t	*fecp;	int 		i, j;	static int	index = 0;	/* Only allow us to be probed once. */	if (index >= FEC_MAX_PORTS)		return -ENXIO;	/* Create an Ethernet device instance.	*/	fecp = (volatile fec_t *) fec_hw[index];	fep->index = index;	fep->hwp = fecp;	/* Whack a reset.  We should wait for this.	*/	fecp->fec_ecntrl = 1;	udelay(10);	/* Clear and enable interrupts */	fecp->fec_ievent = 0xffc0;	fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |		FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);	fecp->fec_hash_table_high = 0;	fecp->fec_hash_table_low = 0;	fecp->fec_r_buff_size = PKT_MAXBLR_SIZE;        fecp->fec_ecntrl = 2;        fecp->fec_r_des_active = 0x01000000;	/* Set the Ethernet address.  If using multiple Enets on the 8xx,	 * this needs some work to get unique addresses.	 *	 * This is our default MAC address unless the user changes	 * it via eth_mac_addr (our dev->set_mac_addr handler).	 */	fec_get_mac(dev);	/* Allocate memory for buffer descriptors.	*/	if (((RX_RING_SIZE + TX_RING_SIZE) * sizeof(cbd_t)) > PAGE_SIZE) {		printk("FEC init error.  Need more space.\n");		printk("FEC initialization failed.\n");		return 1;	}	mem_addr = __get_free_page(GFP_KERNEL);	cbd_base = (cbd_t *)mem_addr;	/* XXX: missing check for allocation failure */	fec_uncache(mem_addr);	/* Set receive and transmit descriptor base.	*/	fep->rx_bd_base = cbd_base;	fep->tx_bd_base = cbd_base + RX_RING_SIZE;	fep->dirty_tx = fep->cur_tx = fep->tx_bd_base;	fep->cur_rx = fep->rx_bd_base;	fep->skb_cur = fep->skb_dirty = 0;	/* Initialize the receive buffer descriptors.	*/	bdp = fep->rx_bd_base;	for (i=0; i<FEC_ENET_RX_PAGES; i++) {		/* Allocate a page.		*/		mem_addr = __get_free_page(GFP_KERNEL);		/* XXX: missing check for allocation failure */		fec_uncache(mem_addr);		/* Initialize the BD for every fragment in the page.		*/		for (j=0; j<FEC_ENET_RX_FRPPG; j++) {			bdp->cbd_sc = BD_ENET_RX_EMPTY;			bdp->cbd_bufaddr = __pa(mem_addr);			mem_addr += FEC_ENET_RX_FRSIZE;			bdp++;		}	}	/* Set the last buffer to wrap.	*/	bdp--;	bdp->cbd_sc |= BD_SC_WRAP;	/* ...and the same for transmmit.	*/	bdp = fep->tx_bd_base;	for (i=0, j=FEC_ENET_TX_FRPPG; i<TX_RING_SIZE; i++) {		if (j >= FEC_ENET_TX_FRPPG) {			mem_addr = __get_free_page(GFP_KERNEL);			j = 1;		} else {			mem_addr += FEC_ENET_TX_FRSIZE;			j++;		}		fep->tx_bounce[i] = (unsigned char *) mem_addr;		/* Initialize the BD for every fragment in the page.		*/		bdp->cbd_sc = 0;		bdp->cbd_bufaddr = 0;		bdp++;	}	/* Set the last buffer to wrap.	*/	bdp--;	bdp->cbd_sc |= BD_SC_WRAP;	/* Set receive and transmit descriptor base.	*/	fecp->fec_r_des_start = __pa((uint)(fep->rx_bd_base));	fecp->fec_x_des_start = __pa((uint)(fep->tx_bd_base));	/* Install our interrupt handlers. This varies depending on	 * the architecture.	*/	fec_request_intrs(dev);	dev->base_addr = (unsigned long)fecp;	/* The FEC Ethernet specific entries in the device structure. */	dev->open = fec_enet_open;	dev->hard_start_xmit = fec_enet_start_xmit;	dev->tx_timeout = fec_timeout;	dev->watchdog_timeo = TX_TIMEOUT;	dev->stop = fec_enet_close;	dev->get_stats = fec_enet_get_stats;	dev->set_multicast_list = set_multicast_list;	for (i=0; i<NMII-1; i++)		mii_cmds[i].mii_next = &mii_cmds[i+1];	mii_free = mii_cmds;	/* setup MII interface */	fec_set_mii(dev, fep);	printk("%s: FEC ENET Version 0.2, ", dev->name);	for (i=0; i<5; i++)		printk("%02x:", dev->dev_addr[i]);	printk("%02x\n", dev->dev_addr[5]);	/* Queue up command to detect the PHY and initialize the	 * remainder of the interface.	 */	fep->phy_id_done = 0;	fep->phy_addr = 0;	mii_queue(dev, mk_mii_read(MII_REG_PHYIR1), mii_discover_phy);	index++;	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/7dd6a2aa27a7a8036fbaf60cbce38a64128d1d4d/fec.c/clean/drivers/net/fec.c