⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3c59x.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 5 页
字号:
		else if (vci->drv_flags & EEPROM_OFFSET)			base = EEPROM_Read + 0x30;		else			base = EEPROM_Read;		for (i = 0; i < 0x40; i++) {			int timer;			outw(base + i, ioaddr + Wn0EepromCmd);			/* Pause for at least 162 us. for the read to take place. */			for (timer = 10; timer >= 0; timer--) {				udelay(162);				if ((inw(ioaddr + Wn0EepromCmd) & 0x8000) == 0)					break;			}			eeprom[i] = inw(ioaddr + Wn0EepromData);		}	}	for (i = 0; i < 0x18; i++)		checksum ^= eeprom[i];	checksum = (checksum ^ (checksum >> 8)) & 0xff;	if (checksum != 0x00) {		/* Grrr, needless incompatible change 3Com. */		while (i < 0x21)			checksum ^= eeprom[i++];		checksum = (checksum ^ (checksum >> 8)) & 0xff;	}	if ((checksum != 0x00) && !(vci->drv_flags & IS_TORNADO))		printk(" ***INVALID CHECKSUM %4.4x*** ", checksum);	for (i = 0; i < 3; i++)		((u16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]);	if (print_info) {		for (i = 0; i < 6; i++)			printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);	}	EL3WINDOW(2);	for (i = 0; i < 6; i++)		outb(dev->dev_addr[i], ioaddr + i);#ifdef __sparc__	if (print_info)		printk(", IRQ %s\n", __irq_itoa(dev->irq));#else	if (print_info)		printk(", IRQ %d\n", dev->irq);	/* Tell them about an invalid IRQ. */	if (dev->irq <= 0 || dev->irq >= NR_IRQS)		printk(KERN_WARNING " *** Warning: IRQ %d is unlikely to work! ***\n",			   dev->irq);#endif	EL3WINDOW(4);	step = (inb(ioaddr + Wn4_NetDiag) & 0x1e) >> 1;	if (print_info) {		printk(KERN_INFO "  product code %02x%02x rev %02x.%d date %02d-"			"%02d-%02d\n", eeprom[6]&0xff, eeprom[6]>>8, eeprom[0x14],			step, (eeprom[4]>>5) & 15, eeprom[4] & 31, eeprom[4]>>9);	}	if (pdev && vci->drv_flags & HAS_CB_FNS) {		unsigned long fn_st_addr;			/* Cardbus function status space */		unsigned short n;		fn_st_addr = pci_resource_start (pdev, 2);		if (fn_st_addr) {			vp->cb_fn_base = ioremap(fn_st_addr, 128);			retval = -ENOMEM;			if (!vp->cb_fn_base)				goto free_ring;		}		if (print_info) {			printk(KERN_INFO "%s: CardBus functions mapped %8.8lx->%p\n",				print_name, fn_st_addr, vp->cb_fn_base);		}		EL3WINDOW(2);		n = inw(ioaddr + Wn2_ResetOptions) & ~0x4010;		if (vp->drv_flags & INVERT_LED_PWR)			n |= 0x10;		if (vp->drv_flags & INVERT_MII_PWR)			n |= 0x4000;		outw(n, ioaddr + Wn2_ResetOptions);	}	/* Extract our information from the EEPROM data. */	vp->info1 = eeprom[13];	vp->info2 = eeprom[15];	vp->capabilities = eeprom[16];	if (vp->info1 & 0x8000) {		vp->full_duplex = 1;		if (print_info)			printk(KERN_INFO "Full duplex capable\n");	}	{		static const char * ram_split[] = {"5:3", "3:1", "1:1", "3:5"};		unsigned int config;		EL3WINDOW(3);		vp->available_media = inw(ioaddr + Wn3_Options);		if ((vp->available_media & 0xff) == 0)		/* Broken 3c916 */			vp->available_media = 0x40;		config = inl(ioaddr + Wn3_Config);		if (print_info) {			printk(KERN_DEBUG "  Internal config register is %4.4x, "				   "transceivers %#x.\n", config, inw(ioaddr + Wn3_Options));			printk(KERN_INFO "  %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n",				   8 << RAM_SIZE(config),				   RAM_WIDTH(config) ? "word" : "byte",				   ram_split[RAM_SPLIT(config)],				   AUTOSELECT(config) ? "autoselect/" : "",				   XCVR(config) > XCVR_ExtMII ? "<invalid transceiver>" :				   media_tbl[XCVR(config)].name);		}		vp->default_media = XCVR(config);		if (vp->default_media == XCVR_NWAY)			vp->has_nway = 1;		vp->autoselect = AUTOSELECT(config);	}	if (vp->media_override != 7) {		printk(KERN_INFO "%s:  Media override to transceiver type %d (%s).\n",				print_name, vp->media_override,				media_tbl[vp->media_override].name);		dev->if_port = vp->media_override;	} else		dev->if_port = vp->default_media;	if (dev->if_port == XCVR_MII || dev->if_port == XCVR_NWAY) {		int phy, phy_idx = 0;		EL3WINDOW(4);		mii_preamble_required++;		mii_preamble_required++;		mdio_read(dev, 24, 1);		for (phy = 0; phy < 32 && phy_idx < 1; phy++) {			int mii_status, phyx;			/*			 * For the 3c905CX we look at index 24 first, because it bogusly			 * reports an external PHY at all indices			 */			if (phy == 0)				phyx = 24;			else if (phy <= 24)				phyx = phy - 1;			else				phyx = phy;			mii_status = mdio_read(dev, phyx, 1);			if (mii_status  &&  mii_status != 0xffff) {				vp->phys[phy_idx++] = phyx;				if (print_info) {					printk(KERN_INFO "  MII transceiver found at address %d,"						" status %4x.\n", phyx, mii_status);				}				if ((mii_status & 0x0040) == 0)					mii_preamble_required++;			}		}		mii_preamble_required--;		if (phy_idx == 0) {			printk(KERN_WARNING"  ***WARNING*** No MII transceivers found!\n");			vp->phys[0] = 24;		} else {			vp->advertising = mdio_read(dev, vp->phys[0], 4);			if (vp->full_duplex) {				/* Only advertise the FD media types. */				vp->advertising &= ~0x02A0;				mdio_write(dev, vp->phys[0], 4, vp->advertising);			}		}	}	if (vp->capabilities & CapBusMaster) {		vp->full_bus_master_tx = 1;		if (print_info) {			printk(KERN_INFO "  Enabling bus-master transmits and %s receives.\n",			(vp->info2 & 1) ? "early" : "whole-frame" );		}		vp->full_bus_master_rx = (vp->info2 & 1) ? 1 : 2;		vp->bus_master = 0;		/* AKPM: vortex only */	}	/* The 3c59x-specific entries in the device structure. */	dev->open = vortex_open;	if (vp->full_bus_master_tx) {		dev->hard_start_xmit = boomerang_start_xmit;		/* Actually, it still should work with iommu. */		dev->features |= NETIF_F_SG;		if (((hw_checksums[card_idx] == -1) && (vp->drv_flags & HAS_HWCKSM)) ||					(hw_checksums[card_idx] == 1)) {				dev->features |= NETIF_F_IP_CSUM;		}	} else {		dev->hard_start_xmit = vortex_start_xmit;	}	if (print_info) {		printk(KERN_INFO "%s: scatter/gather %sabled. h/w checksums %sabled\n",				print_name,				(dev->features & NETIF_F_SG) ? "en":"dis",				(dev->features & NETIF_F_IP_CSUM) ? "en":"dis");	}	dev->stop = vortex_close;	dev->get_stats = vortex_get_stats;	dev->do_ioctl = vortex_ioctl;	dev->set_multicast_list = set_rx_mode;	dev->tx_timeout = vortex_tx_timeout;	dev->watchdog_timeo = (watchdog * HZ) / 1000;	if (pdev && vp->enable_wol) {		vp->pm_state_valid = 1; 		pci_save_state(vp->pdev, vp->power_state); 		acpi_set_WOL(dev);	}	retval = register_netdev(dev);	if (retval == 0)		return 0;free_ring:	pci_free_consistent(pdev,						sizeof(struct boom_rx_desc) * RX_RING_SIZE							+ sizeof(struct boom_tx_desc) * TX_RING_SIZE,						vp->rx_ring,						vp->rx_ring_dma);free_region:	if (vp->must_free_region)		release_region(ioaddr, vci->io_size);	kfree (dev);	printk(KERN_ERR PFX "vortex_probe1 fails.  Returns %d\n", retval);out:	return retval;}static voidissue_and_wait(struct net_device *dev, int cmd){	int i;	outw(cmd, dev->base_addr + EL3_CMD);	for (i = 0; i < 2000; i++) {		if (!(inw(dev->base_addr + EL3_STATUS) & CmdInProgress))			return;	}	/* OK, that didn't work.  Do it the slow way.  One second */	for (i = 0; i < 100000; i++) {		if (!(inw(dev->base_addr + EL3_STATUS) & CmdInProgress)) {			if (vortex_debug > 1)				printk(KERN_INFO "%s: command 0x%04x took %d usecs\n",					   dev->name, cmd, i * 10);			return;		}		udelay(10);	}	printk(KERN_ERR "%s: command 0x%04x did not complete! Status=0x%x\n",			   dev->name, cmd, inw(dev->base_addr + EL3_STATUS));}static voidvortex_up(struct net_device *dev){	long ioaddr = dev->base_addr;	struct vortex_private *vp = (struct vortex_private *)dev->priv;	unsigned int config;	int i;	if (vp->pdev && vp->enable_wol) {		pci_set_power_state(vp->pdev, 0);	/* Go active */		pci_restore_state(vp->pdev, vp->power_state);	}	/* Before initializing select the active media port. */	EL3WINDOW(3);	config = inl(ioaddr + Wn3_Config);	if (vp->media_override != 7) {		printk(KERN_INFO "%s: Media override to transceiver %d (%s).\n",			   dev->name, vp->media_override,			   media_tbl[vp->media_override].name);		dev->if_port = vp->media_override;	} else if (vp->autoselect) {		if (vp->has_nway) {			if (vortex_debug > 1)				printk(KERN_INFO "%s: using NWAY device table, not %d\n",								dev->name, dev->if_port);			dev->if_port = XCVR_NWAY;		} else {			/* Find first available media type, starting with 100baseTx. */			dev->if_port = XCVR_100baseTx;			while (! (vp->available_media & media_tbl[dev->if_port].mask))				dev->if_port = media_tbl[dev->if_port].next;			if (vortex_debug > 1)				printk(KERN_INFO "%s: first available media type: %s\n",					dev->name, media_tbl[dev->if_port].name);		}	} else {		dev->if_port = vp->default_media;		if (vortex_debug > 1)			printk(KERN_INFO "%s: using default media %s\n",				dev->name, media_tbl[dev->if_port].name);	}	init_timer(&vp->timer);	vp->timer.expires = RUN_AT(media_tbl[dev->if_port].wait);	vp->timer.data = (unsigned long)dev;	vp->timer.function = vortex_timer;		/* timer handler */	add_timer(&vp->timer);	init_timer(&vp->rx_oom_timer);	vp->rx_oom_timer.data = (unsigned long)dev;	vp->rx_oom_timer.function = rx_oom_timer;	if (vortex_debug > 1)		printk(KERN_DEBUG "%s: Initial media type %s.\n",			   dev->name, media_tbl[dev->if_port].name);	vp->full_duplex = vp->force_fd;	config = BFINS(config, dev->if_port, 20, 4);	if (vortex_debug > 6)		printk(KERN_DEBUG "vortex_up(): writing 0x%x to InternalConfig\n", config);	outl(config, ioaddr + Wn3_Config);	if (dev->if_port == XCVR_MII || dev->if_port == XCVR_NWAY) {		int mii_reg1, mii_reg5;		EL3WINDOW(4);		/* Read BMSR (reg1) only to clear old status. */		mii_reg1 = mdio_read(dev, vp->phys[0], 1);		mii_reg5 = mdio_read(dev, vp->phys[0], 5);		if (mii_reg5 == 0xffff  ||  mii_reg5 == 0x0000)			;					/* No MII device or no link partner report */		else if ((mii_reg5 & 0x0100) != 0	/* 100baseTx-FD */				 || (mii_reg5 & 0x00C0) == 0x0040) /* 10T-FD, but not 100-HD */			vp->full_duplex = 1;		vp->partner_flow_ctrl = ((mii_reg5 & 0x0400) != 0);		if (vortex_debug > 1)			printk(KERN_INFO "%s: MII #%d status %4.4x, link partner capability %4.4x,"				   " info1 %04x, setting %s-duplex.\n",					dev->name, vp->phys[0],					mii_reg1, mii_reg5,					vp->info1, ((vp->info1 & 0x8000) || vp->full_duplex) ? "full" : "half");		EL3WINDOW(3);	}	/* Set the full-duplex bit. */	outw(	((vp->info1 & 0x8000) || vp->full_duplex ? 0x20 : 0) |		 	(dev->mtu > 1500 ? 0x40 : 0) |			((vp->full_duplex && vp->flow_ctrl && vp->partner_flow_ctrl) ? 0x100 : 0),			ioaddr + Wn3_MAC_Ctrl);	if (vortex_debug > 1) {		printk(KERN_DEBUG "%s: vortex_up() InternalConfig %8.8x.\n",			dev->name, config);	}	issue_and_wait(dev, TxReset);	/*	 * Don't reset the PHY - that upsets autonegotiation during DHCP operations.	 */	issue_and_wait(dev, RxReset|0x04);	outw(SetStatusEnb | 0x00, ioaddr + EL3_CMD);	if (vortex_debug > 1) {		EL3WINDOW(4);		printk(KERN_DEBUG "%s: vortex_up() irq %d media status %4.4x.\n",			   dev->name, dev->irq, inw(ioaddr + Wn4_Media));	}	/* Set the station address and mask in window 2 each time opened. */	EL3WINDOW(2);	for (i = 0; i < 6; i++)		outb(dev->dev_addr[i], ioaddr + i);	for (; i < 12; i+=2)		outw(0, ioaddr + i);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -