704786ae768abe8d2fea5b64d0366c5454f1e3d7
[openwrt.git] / target / linux / rdc / patches-2.6.28 / 007-r6040_git_updates.patch
1 --- a/drivers/net/r6040.c
2 +++ b/drivers/net/r6040.c
3 @@ -49,12 +49,12 @@
4 #include <asm/processor.h>
5
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"
11
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 */
18
19 @@ -160,6 +160,7 @@ MODULE_AUTHOR("Sten Wang <sten.wang@rdc.
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);
24
25 /* RX and TX interrupts that we handle */
26 #define RX_INTS (RX_FIFO_FULL | RX_NO_DESC | RX_FINISH)
27 @@ -200,7 +201,7 @@ struct r6040_private {
28
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 ")";
33
34 static int phy_table[] = { PHY1_ADDR, PHY2_ADDR };
35
36 @@ -330,7 +331,7 @@ static int r6040_alloc_rxbufs(struct net
37 do {
38 skb = netdev_alloc_skb(dev, MAX_BUF_SIZE);
39 if (!skb) {
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);
42 rc = -ENOMEM;
43 goto err_exit;
44 }
45 @@ -438,7 +439,6 @@ static void r6040_down(struct net_device
46 {
47 struct r6040_private *lp = netdev_priv(dev);
48 void __iomem *ioaddr = lp->base;
49 - struct pci_dev *pdev = lp->pdev;
50 int limit = 2048;
51 u16 *adrp;
52 u16 cmd;
53 @@ -457,22 +457,12 @@ static void r6040_down(struct net_device
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);
58 -
59 - /* Free RX buffer */
60 - r6040_free_rxbufs(dev);
61 -
62 - /* Free TX buffer */
63 - r6040_free_txbufs(dev);
64 -
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);
68 }
69
70 static int r6040_close(struct net_device *dev)
71 {
72 struct r6040_private *lp = netdev_priv(dev);
73 + struct pci_dev *pdev = lp->pdev;
74
75 /* deleted timer */
76 del_timer_sync(&lp->timer);
77 @@ -481,8 +471,28 @@ static int r6040_close(struct net_device
78 napi_disable(&lp->napi);
79 netif_stop_queue(dev);
80 r6040_down(dev);
81 +
82 + free_irq(dev->irq, dev);
83 +
84 + /* Free RX buffer */
85 + r6040_free_rxbufs(dev);
86 +
87 + /* Free TX buffer */
88 + r6040_free_txbufs(dev);
89 +
90 spin_unlock_irq(&lp->lock);
91
92 + /* Free Descriptor memory */
93 + if (lp->rx_ring) {
94 + pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
95 + lp->rx_ring = NULL;
96 + }
97 +
98 + if (lp->tx_ring) {
99 + pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
100 + lp->tx_ring = NULL;
101 + }
102 +
103 return 0;
104 }
105
106 @@ -598,7 +608,6 @@ static int r6040_rx(struct net_device *d
107
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;
113
114 @@ -668,7 +677,7 @@ static int r6040_poll(struct napi_struct
115 work_done = r6040_rx(dev, budget);
116
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);
122 }
123 @@ -705,7 +714,7 @@ static irqreturn_t r6040_interrupt(int i
124
125 /* Mask off RX interrupt */
126 misr &= ~RX_INTS;
127 - netif_rx_schedule(dev, &lp->napi);
128 + napi_schedule(&lp->napi);
129 }
130
131 /* TX interrupt request */
132 @@ -1063,20 +1072,20 @@ static int __devinit r6040_init_one(stru
133 /* this should always be supported */
134 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
135 if (err) {
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");
139 goto err_out;
140 }
141 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
142 if (err) {
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");
146 goto err_out;
147 }
148
149 /* IO Size check */
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");
153 err = -EIO;
154 goto err_out;
155 }
156 @@ -1086,7 +1095,7 @@ static int __devinit r6040_init_one(stru
157
158 dev = alloc_etherdev(sizeof(struct r6040_private));
159 if (!dev) {
160 - printk(KERN_ERR DRV_NAME "Failed to allocate etherdev\n");
161 + printk(KERN_ERR DRV_NAME ": Failed to allocate etherdev\n");
162 err = -ENOMEM;
163 goto err_out;
164 }
165 @@ -1102,11 +1111,15 @@ static int __devinit r6040_init_one(stru
166
167 ioaddr = pci_iomap(pdev, bar, io_size);
168 if (!ioaddr) {
169 - printk(KERN_ERR "ioremap failed for device %s\n",
170 + printk(KERN_ERR DRV_NAME ": ioremap failed for device %s\n",
171 pci_name(pdev));
172 err = -EIO;
173 goto err_out_free_res;
174 }
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);
179
180 /* Init system & device */
181 lp->base = ioaddr;
182 @@ -1123,6 +1136,13 @@ static int __devinit r6040_init_one(stru
183 adrp[1] = ioread16(ioaddr + MID_0M);
184 adrp[2] = ioread16(ioaddr + MID_0H);
185
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);
191 + }
192 +
193 /* Link new device into r6040_root_dev */
194 lp->pdev = pdev;
195 lp->dev = dev;
196 --- a/drivers/net/r6040.c
197 +++ b/drivers/net/r6040.c
198 @@ -742,6 +742,14 @@ static int r6040_up(struct net_device *d
199 struct r6040_private *lp = netdev_priv(dev);
200 void __iomem *ioaddr = lp->base;
201 int ret;
202 + u16 val;
203 +
204 + /* Check presence of a second PHY */
205 + val = r6040_phy_read(ioaddr, lp->phy_addr, 2);
206 + if (val == 0xFFFF) {
207 + printk(KERN_ERR DRV_NAME " no second PHY attached\n");
208 + return -EIO;
209 + }
210
211 /* Initialise and alloc RX/TX buffers */
212 r6040_init_txbufs(dev);
213 --- a/drivers/net/r6040.c
214 +++ b/drivers/net/r6040.c
215 @@ -401,6 +401,9 @@ static void r6040_init_mac_regs(struct n
216 * we may got called by r6040_tx_timeout which has left
217 * some unsent tx buffers */
218 iowrite16(0x01, ioaddr + MTPR);
219 +
220 + /* Check media */
221 + mii_check_media(&lp->mii_if, 1, 1);
222 }
223
224 static void r6040_tx_timeout(struct net_device *dev)
225 @@ -528,6 +531,8 @@ static int r6040_phy_mode_chk(struct net
226 phy_dat = 0x0000;
227 }
228
229 + mii_check_media(&lp->mii_if, 0, 1);
230 +
231 return phy_dat;
232 };
233
234 @@ -810,7 +815,6 @@ static void r6040_timer(unsigned long da
235 lp->phy_mode = phy_mode;
236 lp->mcr0 = (lp->mcr0 & 0x7fff) | phy_mode;
237 iowrite16(lp->mcr0, ioaddr);
238 - printk(KERN_INFO "Link Change %x \n", ioread16(ioaddr));
239 }
240
241 /* Timer active again */
This page took 0.052866 seconds and 3 git commands to generate.