Beispiel #1
0
static int __init 
cs89x0_probe1(struct net_device *dev, int ioaddr)
{
	struct net_local *lp;
	static unsigned version_printed = 0;
	int i;
	unsigned rev_type = 0;

/*	irq2dev_map[0] = dev;  */

#ifdef CONFIG_UCSIMM
	/* set up the chip select */
	*(volatile unsigned  char *)0xfffff42b |= 0x01; /* output /sleep */
	*(volatile unsigned short *)0xfffff428 |= 0x0101; /* not sleeping */

	*(volatile unsigned  char *)0xfffff42b &= ~0x02; /* input irq5 */
	*(volatile unsigned short *)0xfffff428 &= ~0x0202; /* irq5 fcn on */
	
	*(volatile unsigned short *)0xfffff102 = 0x8000; /* 0x04000000 */
	*(volatile unsigned short *)0xfffff112 = 0x01e1; /* 128k, 2ws, FLASH, en */
#endif

#ifdef CONFIG_ARCH_ATMEL
	*(volatile unsigned int *) AIC_IDCR = AIC_IRQ1; /* disable interrupt IRQ1 */
#ifdef	CONFIG_EB40LS	 
	*(volatile unsigned int *) PIO_DISABLE_REGISTER = (1 << 10); /* disable PIO for IRQ1 */
#endif	
	*(volatile unsigned int *) AIC_ICCR = AIC_IRQ1; /* clear interrupt IRQ1 */
	*(volatile unsigned int *) AIC_IECR = AIC_IRQ1; /* enable interrupt IRQ1 */
#endif


#ifdef CONFIG_ALMA_ANS
        /* 
         * Make sure the chip select (CSA1) is enabled 
	 * Note, that we don't have to program the base address, since
         * it is programmed once for both CSA0 and CSA1 in *-head.S
	 */
        PFSEL &= ~PF_CSA1;
        PFDIR |= PF_CSA1;
 
        /* Make sure that interrupt line (irq3) is enabled too */
        PDSEL  &= ~PD_IRQ3;
        PDDIR  &= ~PD_IRQ3;
        PDKBEN |= PD_IRQ3;                                                       
#endif

	/* Initialize the device structure. */
	if (dev->priv == NULL) {
		dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
                memset(dev->priv, 0, sizeof(struct net_local));
        }
	dev->base_addr = ioaddr;
	lp = (struct net_local *)dev->priv;

	if (readreg(dev, PP_ChipID) != CHIP_EISA_ID_SIG) {
	  printk("cs89x0.c: No CrystalLan device found.\n");
		return ENODEV;
	}

	/* get the chip type */
	rev_type = readreg(dev, PRODUCT_ID_ADD);
	lp->chip_type = rev_type &~ REVISON_BITS;
	lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';

	/* Check the chip type and revision in order to set the correct send command
	CS8920 revision C and CS8900 revision F can use the faster send. */
	lp->send_cmd = TX_AFTER_ALL;
#if 0
	if (lp->chip_type == CS8900 && lp->chip_revision >= 'F')
		lp->send_cmd = TX_NOW;
	if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
		lp->send_cmd = TX_NOW;
#endif
	if (net_debug  &&  version_printed++ == 0)
		printk(version);

	printk("%s: cs89%c0%s rev %c found at 0x%.8lx %s",
	       dev->name,
	       lp->chip_type==CS8900?'0':'2',
	       lp->chip_type==CS8920M?"M":"",
	       lp->chip_revision,
	       dev->base_addr,
	       readreg(dev, PP_SelfST) & ACTIVE_33V ? "3.3Volts" : "5Volts");

	reset_chip(dev);

	/* Fill this in, we don't have an EEPROM */
	lp->adapter_cnf = A_CNF_10B_T | A_CNF_MEDIA_10B_T;
	lp->auto_neg_cnf = EE_AUTO_NEG_ENABLE | IMM_BIT;

	printk(" media %s%s%s",
	       (lp->adapter_cnf & A_CNF_10B_T)?"RJ-45,":"",
	       (lp->adapter_cnf & A_CNF_AUI)?"AUI,":"",
	       (lp->adapter_cnf & A_CNF_10B_2)?"BNC,":"");

	lp->irq_map = 0xffff;

	/* dev->dev_addr[0] through dev->dev_addr[6] holds the mac address
	 * of this ethernet device.  This can be set to anything we want it
	 * to be.  But care should be taken to make this number unique... */

#if   defined(CONFIG_UCSIMM) || defined(CONFIG_EB40LS) || \
      defined(CONFIG_BLIP)   || defined(CONFIG_UCLINKII)
	{
 		extern unsigned char *cs8900a_hwaddr;
 		memcpy(dev->dev_addr, cs8900a_hwaddr, 6);
	}
	
#elif defined (CONFIG_BOARD_UCLINKII) || \
      defined (CONFIG_BOARD_EVS3C4530LII) || \
      defined (CONFIG_BOARD_EVS3C4530HEI)
      memcpy(dev->dev_addr, get_MAC_address("dev1"), 6);
#else
#error	    MAC address is not defined
#endif

	/* print the ethernet address. */
	for (i = 0; i < ETH_ALEN; i++)
		printk(" %2.2x", dev->dev_addr[i]);

#ifdef FIXME
	/* Grab the region so we can find another board if autoIRQ fails. */
	request_region(ioaddr, NETCARD_IO_EXTENT,"cs89x0");
#endif

	dev->open		= net_open;
	dev->stop		= net_close;
	dev->hard_start_xmit 	= net_send_packet;
	dev->get_stats		= net_get_stats;
	dev->set_multicast_list = &set_multicast_list;
	dev->set_mac_address 	= &set_mac_address;

	/* Fill in the fields of the device structure with ethernet values. */
	ether_setup(dev);

	printk("\n");
	return 0;
}
static int __init 
cs89x0_probe1(struct net_device *dev, int ioaddr)
{
	struct net_local *lp;
	static unsigned version_printed = 0;
	int i;
	unsigned rev_type = 0;

/*	irq2dev_map[0] = dev;  */

#if defined(CONFIG_UCSIMM)
	/* set up PF1 as sleep control */
	PFSEL  |= 0x01;  /* IO, not LCONTRAST */
	PFDIR  |= 0x01;  /* output */
	PFDATA |= 0x01;  /* not sleeping */
#elif defined(CONFIG_UCDIMM)
	/* set up PG3 (~HiZ/P/~D) as sleep control */
	PGSEL  |= 0x08;  /* IO */
	PGDIR  |= 0x08;  /* output */
	PGDATA |= 0x08;  /* not sleeping */
#endif

#if defined(CONFIG_UCSIMM) || defined(CONFIG_UCDIMM)
	*(volatile unsigned  char *)PFSEL_ADDR &=   ~0x02; /* input irq5 */
	*(volatile unsigned short *)PFDIR_ADDR &= ~0x0202; /* irq5 fcn on */
	
	*(volatile unsigned short *)CSGBB_ADDR  = 0x8000;  /* 0x10000000 */
	*(volatile unsigned short *)CSB_ADDR    = 0x01e1;  /* 128k, 2ws, FLASH, en */
#endif

#ifdef CONFIG_ARCH_ATMEL
	*(volatile unsigned int *) AIC_IDCR = AIC_IRQ1; /* disable interrupt IRQ1 */
#ifdef	CONFIG_EB40LS	 
	*(volatile unsigned int *) PIO_DISABLE_REGISTER = (1 << 10); /* disable PIO for IRQ1 */
#endif	
	*(volatile unsigned int *) AIC_ICCR = AIC_IRQ1; /* clear interrupt IRQ1 */
	*(volatile unsigned int *) AIC_IECR = AIC_IRQ1; /* enable interrupt IRQ1 */
#endif

#ifdef CONFIG_ARCH_DM270
	printk("uCcs89x0: Setting up TI TMS320DM270 CS8900A IRQ ioaddr = 0x%X\n",ioaddr);
	/* Set GIO port to input */
	outw(inw(DM270_GIO_DIR(DM270_INTERRUPT_EXT4)) | (1<<DM270_GIO_DIR_SHIFT(DM270_INTERRUPT_EXT4)),
			DM270_GIO_DIR(DM270_INTERRUPT_EXT4));

	/* Set GIO as interrupt port */
	outw(inw(DM270_GIO_IRQPORT) | (1<<DM270_GIO_IRQPORT_SHIFT(DM270_INTERRUPT_EXT4)),
			DM270_GIO_IRQPORT);

	/*
	 * CS8900A INTRQ goes high when an enabled interrupt is triggered
	 * and goes low after ISQ is read as all 0's
	 */

	/* Trigger on rising edge */
	outw(inw(DM270_GIO_INV(DM270_INTERRUPT_EXT4)) | (1<<DM270_GIO_INV_SHIFT(DM270_INTERRUPT_EXT4)),
			DM270_GIO_INV(DM270_INTERRUPT_EXT4));

	/* Use single-sided edge interrupts */
	outw(inw(DM270_GIO_IRQEDGE) & ~(1<<DM270_GIO_IRQEDGE_SHIFT(DM270_INTERRUPT_EXT4)), DM270_GIO_IRQEDGE);
#endif

#ifdef CONFIG_ALMA_ANS
        /* 
         * Make sure the chip select (CSA1) is enabled 
	 * Note, that we don't have to program the base address, since
         * it is programmed once for both CSA0 and CSA1 in *-head.S
	 */
        PFSEL &= ~PF_CSA1;
        PFDIR |= PF_CSA1;
 
        /* Make sure that interrupt line (irq3) is enabled too */
        PDSEL  &= ~PD_IRQ3;
        PDDIR  &= ~PD_IRQ3;
        PDKBEN |= PD_IRQ3;                                                       
#endif

	/* Initialize the device structure. */
	if (dev->priv == NULL) {
		dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
                memset(dev->priv, 0, sizeof(struct net_local));
        }
	dev->base_addr = ioaddr;
	lp = (struct net_local *)dev->priv;

	if (readreg(dev, PP_ChipID) != CHIP_EISA_ID_SIG) {
	  printk("cs89x0.c: No CrystalLan device found.\n");
		return ENODEV;
	}

	/* get the chip type */
	printk ("CrystalLAN EISA ID: 0x%04x\n", readreg(dev, 0));

	rev_type = readreg(dev, PRODUCT_ID_ADD);
	lp->chip_type = rev_type &~ REVISON_BITS;
	lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';

	/* Check the chip type and revision in order to set the correct send command
	CS8920 revision C and CS8900 revision F can use the faster send. */
	lp->send_cmd = TX_AFTER_ALL;
#if 0
	if (lp->chip_type == CS8900 && lp->chip_revision >= 'F')
		lp->send_cmd = TX_NOW;
	if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
		lp->send_cmd = TX_NOW;
#endif
	if (net_debug  &&  version_printed++ == 0)
		printk(version);

	printk("%s: cs89%c0%s rev %c found at 0x%.8lx %s",
	       dev->name,
	       lp->chip_type==CS8900?'0':'2',
	       lp->chip_type==CS8920M?"M":"",
	       lp->chip_revision,
	       dev->base_addr,
	       readreg(dev, PP_SelfST) & ACTIVE_33V ? "3.3Volts" : "5Volts");

	reset_chip(dev);

	/* Fill this in, we don't have an EEPROM */
	lp->adapter_cnf = A_CNF_10B_T | A_CNF_MEDIA_10B_T;
	lp->auto_neg_cnf = EE_AUTO_NEG_ENABLE | IMM_BIT;

	printk(" media %s%s%s",
	       (lp->adapter_cnf & A_CNF_10B_T)?"RJ-45,":"",
	       (lp->adapter_cnf & A_CNF_AUI)?"AUI,":"",
	       (lp->adapter_cnf & A_CNF_10B_2)?"BNC,":"");

	lp->irq_map = 0xffff;

	/* dev->dev_addr[0] through dev->dev_addr[6] holds the mac address
	 * of this ethernet device.  This can be set to anything we want it
	 * to be.  But care should be taken to make this number unique... */

#if defined (CONFIG_UCBOOTSTRAP)
 		memcpy(dev->dev_addr, cs8900a_hwaddr, 6);
	
#elif defined (CONFIG_ARCH_DM270)
      memcpy(dev->dev_addr, get_MAC_address("dev1"), 6);
#else
#warning	    MAC address is not defined - uxing 00:de:ad:be:ef:53
	{                         
	  dev->dev_addr[0] = 0x00;
	  dev->dev_addr[1] = 0xde;
	  dev->dev_addr[2] = 0xad;
	  dev->dev_addr[3] = 0xbe;
	  dev->dev_addr[4] = 0xef;
	  dev->dev_addr[5] = 0x53;
	}                         

#endif

	/* print the ethernet address. */
	for (i = 0; i < ETH_ALEN; i++)
		printk(" %2.2x", dev->dev_addr[i]);

#ifdef FIXME
	/* Grab the region so we can find another board if autoIRQ fails. */
	request_region(ioaddr, NETCARD_IO_EXTENT,"cs89x0");
#endif

	dev->open		= net_open;
	dev->stop		= net_close;
	dev->hard_start_xmit 	= net_send_packet;
	dev->get_stats		= net_get_stats;
	dev->set_multicast_list = &set_multicast_list;
	dev->set_mac_address 	= &set_mac_address;

	/* Fill in the fields of the device structure with ethernet values. */
	ether_setup(dev);

	printk("\n");
	return 0;
}