1 --- linux-2.6.28.9/drivers/net/r6040.c 2009-03-23 22:55:52.000000000 +0100
2 +++ linux-2.6.28.9.new/drivers/net/r6040.c 2009-04-24 14:24:51.000000000 +0200
4 #include <asm/processor.h>
6 #define DRV_NAME "r6040"
7 -#define DRV_VERSION "0.19"
8 -#define DRV_RELDATE "18Dec2008"
9 +#define DRV_VERSION "0.22"
10 +#define DRV_RELDATE "25Mar2009"
12 /* PHY CHIP Address */
13 #define PHY1_ADDR 1 /* For MAC1 */
14 -#define PHY2_ADDR 2 /* For MAC2 */
15 +#define PHY2_ADDR 3 /* For MAC2 */
16 #define PHY_MODE 0x3100 /* PHY CHIP Register 0 */
17 #define PHY_CAP 0x01E1 /* PHY CHIP Register 4 */
20 "Florian Fainelli <florian@openwrt.org>");
21 MODULE_LICENSE("GPL");
22 MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet driver");
23 +MODULE_VERSION(DRV_VERSION " " DRV_RELDATE);
25 /* RX and TX interrupts that we handle */
26 #define RX_INTS (RX_FIFO_FULL | RX_NO_DESC | RX_FINISH)
29 static char version[] __devinitdata = KERN_INFO DRV_NAME
30 ": RDC R6040 NAPI net driver,"
31 - "version "DRV_VERSION " (" DRV_RELDATE ")\n";
32 + "version "DRV_VERSION " (" DRV_RELDATE ")";
34 static int phy_table[] = { PHY1_ADDR, PHY2_ADDR };
38 skb = netdev_alloc_skb(dev, MAX_BUF_SIZE);
40 - printk(KERN_ERR "%s: failed to alloc skb for rx\n", dev->name);
41 + printk(KERN_ERR DRV_NAME "%s: failed to alloc skb for rx\n", dev->name);
47 struct r6040_private *lp = netdev_priv(dev);
48 void __iomem *ioaddr = lp->base;
49 - struct pci_dev *pdev = lp->pdev;
54 iowrite16(adrp[0], ioaddr + MID_0L);
55 iowrite16(adrp[1], ioaddr + MID_0M);
56 iowrite16(adrp[2], ioaddr + MID_0H);
57 - free_irq(dev->irq, dev);
59 - /* Free RX buffer */
60 - r6040_free_rxbufs(dev);
62 - /* Free TX buffer */
63 - r6040_free_txbufs(dev);
65 - /* Free Descriptor memory */
66 - pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
67 - pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
70 static int r6040_close(struct net_device *dev)
72 struct r6040_private *lp = netdev_priv(dev);
73 + struct pci_dev *pdev = lp->pdev;
76 del_timer_sync(&lp->timer);
78 napi_disable(&lp->napi);
79 netif_stop_queue(dev);
82 + free_irq(dev->irq, dev);
84 + /* Free RX buffer */
85 + r6040_free_rxbufs(dev);
87 + /* Free TX buffer */
88 + r6040_free_txbufs(dev);
90 spin_unlock_irq(&lp->lock);
92 + /* Free Descriptor memory */
94 + pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
99 + pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
100 + lp->tx_ring = NULL;
108 /* Send to upper layer */
109 netif_receive_skb(skb_ptr);
110 - dev->last_rx = jiffies;
111 dev->stats.rx_packets++;
112 dev->stats.rx_bytes += descptr->len - 4;
115 work_done = r6040_rx(dev, budget);
117 if (work_done < budget) {
118 - netif_rx_complete(dev, napi);
119 + napi_complete(napi);
120 /* Enable RX interrupt */
121 iowrite16(ioread16(ioaddr + MIER) | RX_INTS, ioaddr + MIER);
125 /* Mask off RX interrupt */
127 - netif_rx_schedule(dev, &lp->napi);
128 + napi_schedule(&lp->napi);
131 /* TX interrupt request */
132 @@ -1063,20 +1088,20 @@
133 /* this should always be supported */
134 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
136 - printk(KERN_ERR DRV_NAME "32-bit PCI DMA addresses"
137 + printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses"
138 "not supported by the card\n");
141 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
143 - printk(KERN_ERR DRV_NAME "32-bit PCI DMA addresses"
144 + printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses"
145 "not supported by the card\n");
150 if (pci_resource_len(pdev, 0) < io_size) {
151 - printk(KERN_ERR DRV_NAME "Insufficient PCI resources, aborting\n");
152 + printk(KERN_ERR DRV_NAME ": Insufficient PCI resources, aborting\n");
156 @@ -1086,7 +1111,7 @@
158 dev = alloc_etherdev(sizeof(struct r6040_private));
160 - printk(KERN_ERR DRV_NAME "Failed to allocate etherdev\n");
161 + printk(KERN_ERR DRV_NAME ": Failed to allocate etherdev\n");
165 @@ -1102,11 +1127,15 @@
167 ioaddr = pci_iomap(pdev, bar, io_size);
169 - printk(KERN_ERR "ioremap failed for device %s\n",
170 + printk(KERN_ERR DRV_NAME ": ioremap failed for device %s\n",
173 goto err_out_free_res;
175 + /* If PHY status change register is still set to zero it means the
176 + * bootloader didn't initialize it */
177 + if (ioread16(ioaddr + PHY_CC) == 0)
178 + iowrite16(0x9f07, ioaddr + PHY_CC);
180 /* Init system & device */
182 @@ -1123,6 +1152,13 @@
183 adrp[1] = ioread16(ioaddr + MID_0M);
184 adrp[2] = ioread16(ioaddr + MID_0H);
186 + /* Some bootloader/BIOSes do not initialize
187 + * MAC address, warn about that */
188 + if (!(adrp[0] || adrp[1] || adrp[2])) {
189 + printk(KERN_WARNING DRV_NAME ": MAC address not initialized, generating random\n");
190 + random_ether_addr(dev->dev_addr);
193 /* Link new device into r6040_root_dev */