示例#1
0
int eth_init (bd_t * bd)
{
	gpio_init_cs8900();
	/* verify chip id */
	if (get_reg_init_bus (PP_ChipID) != 0x630e) {
		printf ("CS8900 Ethernet chip not found?!\n");
		return 0;
	}

	eth_reset ();
	/* set the ethernet address */
	put_reg (PP_IA + 0, bd->bi_enetaddr[0] | (bd->bi_enetaddr[1] << 8));
	put_reg (PP_IA + 2, bd->bi_enetaddr[2] | (bd->bi_enetaddr[3] << 8));
	put_reg (PP_IA + 4, bd->bi_enetaddr[4] | (bd->bi_enetaddr[5] << 8));

	eth_reginit ();
	return 0;
}
示例#2
0
  int eth_init (bd_t * bd)
{
	uchar enetaddr[6];

	gpio_init_cs8900();
	/* verify chip id */
	if (get_reg_init_bus (PP_ChipID) != 0x630e) {
		printf ("CS8900 Ethernet chip not found?!\n");
		return 0;
	}

	eth_reset ();
	/* set the ethernet address */
	eth_getenv_enetaddr("ethaddr", enetaddr);
	put_reg (PP_IA + 0, enetaddr[0] | (enetaddr[1] << 8));
	put_reg (PP_IA + 2, enetaddr[2] | (enetaddr[3] << 8));
	put_reg (PP_IA + 4, enetaddr[4] | (enetaddr[5] << 8));

	eth_reginit ();
	return 0;
}
示例#3
0
int __init cirrus_probe(void)
{
	static cirrus_t priv;
	int i;
	u16 value;

	printk ("Jz CS8900A driver for Linux (V0.02)\n");

	/* Init hardware for PAVO board */
	gpio_init_cs8900();

	/* Allocate ethernet device */
	dev = alloc_etherdev(sizeof(struct net_device));

	memset (&priv,0,sizeof (cirrus_t));

	ether_setup (dev);

	dev->open               = cirrus_start;
	dev->stop               = cirrus_stop;
	dev->hard_start_xmit    = cirrus_send_start;
	dev->get_stats          = cirrus_get_stats;
	dev->set_multicast_list = cirrus_set_receive_mode;
	dev->set_mac_address	= cirrus_set_mac_address;
	dev->tx_timeout         = cirrus_transmit_timeout;
	dev->watchdog_timeo     = HZ;

        if (ethaddr_cmd==1)
	{
		dev->dev_addr[0] = ethaddr_hex[0];
		dev->dev_addr[1] = ethaddr_hex[1];
		dev->dev_addr[2] = ethaddr_hex[2];
		dev->dev_addr[3] = ethaddr_hex[3];
		dev->dev_addr[4] = ethaddr_hex[4];
		dev->dev_addr[5] = ethaddr_hex[5];
	}
	else         //default mac address 00:2a:cc:2a:af:fe
	{
		dev->dev_addr[0] = 0x00;
		dev->dev_addr[1] = 0x62;
		dev->dev_addr[2] = 0x9c;
		dev->dev_addr[3] = 0x61;
		dev->dev_addr[4] = 0xcf;
		dev->dev_addr[5] = 0x16;
	}
	dev->if_port   = IF_PORT_10BASET;
	dev->priv      = (void *) &priv;

	dev->base_addr = CIRRUS_DEFAULT_IO;
	dev->irq = CIRRUS_DEFAULT_IRQ;


	/* module parameters override everything */
	if (!dev->base_addr) {
		printk (KERN_ERR
				"%s: No default I/O base address defined. Use io=... or\n"
				"%s: define CIRRUS_DEFAULT_IO for your platform\n",
				dev->name,dev->name);
		return (-EINVAL);
	}

	if (!dev->irq) {
		printk (KERN_ERR
				"%s: No default IRQ number defined. Use irq=... or\n"
				"%s: define CIRRUS_DEFAULT_IRQ for your platform\n",
				dev->name,dev->name);
		return (-EINVAL);
	}
#if 0
	if ((result = check_region (dev->base_addr,16))) {
		printk (KERN_ERR "%s: can't get I/O port address 0x%lx\n",dev->name,dev->base_addr);
		return (result);
	}
#endif
	if (!request_region (dev->base_addr,16,dev->name))
		return -EBUSY;
#if 0
	/* verify EISA registration number for Cirrus Logic */
	if ((value = cirrus_read (dev,PP_ProductID)) != EISA_REG_CODE) {
		printk (KERN_ERR "%s: incorrect signature 0x%.4x\n",dev->name,value);
		return (-ENXIO);
	}
#endif

	/* verify chip version */
	value = cirrus_read (dev,PP_ProductID + 2);
	if (VERSION (value) != CS8900A) {
		printk (KERN_ERR "%s: unknown chip version 0x%.8x\n",dev->name,VERSION (value));
		return (-ENXIO);
	}
	printk (KERN_INFO "%s: CS8900A rev %c detected\n",dev->name,'B' + REVISION (value) - REV_B);

	/* setup interrupt number */
	cirrus_write (dev,PP_IntNum,INT_PIN);

	/* configure MAC address */
	for (i = 0; i < ETH_ALEN; i += 2)
	{
		//printk(" %x",dev->dev_addr[i] | (dev->dev_addr[i + 1] << 8));
		cirrus_write (dev,PP_IA + i,dev->dev_addr[i] | (dev->dev_addr[i + 1] << 8));
	}

	if (register_netdev(dev) != 0) {
		printk(KERN_ERR " Cannot register net device\n");
		free_netdev(dev);
		return -ENOMEM;
	}	
	
	return (0);
}