aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ax88796.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2011-02-19 11:07:40 -0500
committerMarc Kleine-Budde <mkl@pengutronix.de>2011-02-21 07:13:36 -0500
commit9f072429592d70b0f88c4d66f83735cc693a9870 (patch)
treecd8e8ea0e18f7cb7629bf58a89f7edb5a198c3ea /drivers/net/ax88796.c
parent59ed5aba9ca1c799e272b352d5d2d7fe12bd32e8 (diff)
ax88796: fix codingstyle and checkpatch warnings
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/ax88796.c')
-rw-r--r--drivers/net/ax88796.c262
1 files changed, 134 insertions, 128 deletions
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index 4bebff3faeab..6d1d5ca112eb 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -9,7 +9,7 @@
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12*/ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
@@ -17,6 +17,7 @@
17#include <linux/isapnp.h> 17#include <linux/isapnp.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/io.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
22#include <linux/timer.h> 23#include <linux/timer.h>
@@ -30,33 +31,32 @@
30#include <net/ax88796.h> 31#include <net/ax88796.h>
31 32
32#include <asm/system.h> 33#include <asm/system.h>
33#include <asm/io.h>
34 34
35static int phy_debug = 0; 35static int phy_debug;
36 36
37/* Rename the lib8390.c functions to show that they are in this driver */ 37/* Rename the lib8390.c functions to show that they are in this driver */
38#define __ei_open ax_ei_open 38#define __ei_open ax_ei_open
39#define __ei_close ax_ei_close 39#define __ei_close ax_ei_close
40#define __ei_poll ax_ei_poll 40#define __ei_poll ax_ei_poll
41#define __ei_start_xmit ax_ei_start_xmit 41#define __ei_start_xmit ax_ei_start_xmit
42#define __ei_tx_timeout ax_ei_tx_timeout 42#define __ei_tx_timeout ax_ei_tx_timeout
43#define __ei_get_stats ax_ei_get_stats 43#define __ei_get_stats ax_ei_get_stats
44#define __ei_set_multicast_list ax_ei_set_multicast_list 44#define __ei_set_multicast_list ax_ei_set_multicast_list
45#define __ei_interrupt ax_ei_interrupt 45#define __ei_interrupt ax_ei_interrupt
46#define ____alloc_ei_netdev ax__alloc_ei_netdev 46#define ____alloc_ei_netdev ax__alloc_ei_netdev
47#define __NS8390_init ax_NS8390_init 47#define __NS8390_init ax_NS8390_init
48 48
49/* force unsigned long back to 'void __iomem *' */ 49/* force unsigned long back to 'void __iomem *' */
50#define ax_convert_addr(_a) ((void __force __iomem *)(_a)) 50#define ax_convert_addr(_a) ((void __force __iomem *)(_a))
51 51
52#define ei_inb(_a) readb(ax_convert_addr(_a)) 52#define ei_inb(_a) readb(ax_convert_addr(_a))
53#define ei_outb(_v, _a) writeb(_v, ax_convert_addr(_a)) 53#define ei_outb(_v, _a) writeb(_v, ax_convert_addr(_a))
54 54
55#define ei_inb_p(_a) ei_inb(_a) 55#define ei_inb_p(_a) ei_inb(_a)
56#define ei_outb_p(_v, _a) ei_outb(_v, _a) 56#define ei_outb_p(_v, _a) ei_outb(_v, _a)
57 57
58/* define EI_SHIFT() to take into account our register offsets */ 58/* define EI_SHIFT() to take into account our register offsets */
59#define EI_SHIFT(x) (ei_local->reg_offset[(x)]) 59#define EI_SHIFT(x) (ei_local->reg_offset[(x)])
60 60
61/* Ensure we have our RCR base value */ 61/* Ensure we have our RCR base value */
62#define AX88796_PLATFORM 62#define AX88796_PLATFORM
@@ -74,43 +74,43 @@ static unsigned char version[] = "ax88796.c: Copyright 2005,2007 Simtec Electron
74#define NE_DATAPORT EI_SHIFT(0x10) 74#define NE_DATAPORT EI_SHIFT(0x10)
75 75
76#define NE1SM_START_PG 0x20 /* First page of TX buffer */ 76#define NE1SM_START_PG 0x20 /* First page of TX buffer */
77#define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */ 77#define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */
78#define NESM_START_PG 0x40 /* First page of TX buffer */ 78#define NESM_START_PG 0x40 /* First page of TX buffer */
79#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ 79#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
80 80
81/* device private data */ 81/* device private data */
82 82
83struct ax_device { 83struct ax_device {
84 struct timer_list mii_timer; 84 struct timer_list mii_timer;
85 spinlock_t mii_lock; 85 spinlock_t mii_lock;
86 struct mii_if_info mii; 86 struct mii_if_info mii;
87 87
88 u32 msg_enable; 88 u32 msg_enable;
89 void __iomem *map2; 89 void __iomem *map2;
90 struct platform_device *dev; 90 struct platform_device *dev;
91 struct resource *mem; 91 struct resource *mem;
92 struct resource *mem2; 92 struct resource *mem2;
93 struct ax_plat_data *plat; 93 struct ax_plat_data *plat;
94 94
95 unsigned char running; 95 unsigned char running;
96 unsigned char resume_open; 96 unsigned char resume_open;
97 unsigned int irqflags; 97 unsigned int irqflags;
98 98
99 u32 reg_offsets[0x20]; 99 u32 reg_offsets[0x20];
100}; 100};
101 101
102static inline struct ax_device *to_ax_dev(struct net_device *dev) 102static inline struct ax_device *to_ax_dev(struct net_device *dev)
103{ 103{
104 struct ei_device *ei_local = netdev_priv(dev); 104 struct ei_device *ei_local = netdev_priv(dev);
105 return (struct ax_device *)(ei_local+1); 105 return (struct ax_device *)(ei_local + 1);
106} 106}
107 107
108/* ax_initial_check 108/*
109 * ax_initial_check
109 * 110 *
110 * do an initial probe for the card to check wether it exists 111 * do an initial probe for the card to check wether it exists
111 * and is functional 112 * and is functional
112 */ 113 */
113
114static int ax_initial_check(struct net_device *dev) 114static int ax_initial_check(struct net_device *dev)
115{ 115{
116 struct ei_device *ei_local = netdev_priv(dev); 116 struct ei_device *ei_local = netdev_priv(dev);
@@ -122,10 +122,10 @@ static int ax_initial_check(struct net_device *dev)
122 if (reg0 == 0xFF) 122 if (reg0 == 0xFF)
123 return -ENODEV; 123 return -ENODEV;
124 124
125 ei_outb(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD); 125 ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP, ioaddr + E8390_CMD);
126 regd = ei_inb(ioaddr + 0x0d); 126 regd = ei_inb(ioaddr + 0x0d);
127 ei_outb(0xff, ioaddr + 0x0d); 127 ei_outb(0xff, ioaddr + 0x0d);
128 ei_outb(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD); 128 ei_outb(E8390_NODMA + E8390_PAGE0, ioaddr + E8390_CMD);
129 ei_inb(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */ 129 ei_inb(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */
130 if (ei_inb(ioaddr + EN0_COUNTER0) != 0) { 130 if (ei_inb(ioaddr + EN0_COUNTER0) != 0) {
131 ei_outb(reg0, ioaddr); 131 ei_outb(reg0, ioaddr);
@@ -136,13 +136,14 @@ static int ax_initial_check(struct net_device *dev)
136 return 0; 136 return 0;
137} 137}
138 138
139/* Hard reset the card. This used to pause for the same period that a 139/*
140 8390 reset command required, but that shouldn't be necessary. */ 140 * Hard reset the card. This used to pause for the same period that a
141 141 * 8390 reset command required, but that shouldn't be necessary.
142 */
142static void ax_reset_8390(struct net_device *dev) 143static void ax_reset_8390(struct net_device *dev)
143{ 144{
144 struct ei_device *ei_local = netdev_priv(dev); 145 struct ei_device *ei_local = netdev_priv(dev);
145 struct ax_device *ax = to_ax_dev(dev); 146 struct ax_device *ax = to_ax_dev(dev);
146 unsigned long reset_start_time = jiffies; 147 unsigned long reset_start_time = jiffies;
147 void __iomem *addr = (void __iomem *)dev->base_addr; 148 void __iomem *addr = (void __iomem *)dev->base_addr;
148 149
@@ -156,7 +157,7 @@ static void ax_reset_8390(struct net_device *dev)
156 157
157 /* This check _should_not_ be necessary, omit eventually. */ 158 /* This check _should_not_ be necessary, omit eventually. */
158 while ((ei_inb(addr + EN0_ISR) & ENISR_RESET) == 0) { 159 while ((ei_inb(addr + EN0_ISR) & ENISR_RESET) == 0) {
159 if (jiffies - reset_start_time > 2*HZ/100) { 160 if (jiffies - reset_start_time > 2 * HZ / 100) {
160 dev_warn(&ax->dev->dev, "%s: %s did not complete.\n", 161 dev_warn(&ax->dev->dev, "%s: %s did not complete.\n",
161 __func__, dev->name); 162 __func__, dev->name);
162 break; 163 break;
@@ -171,7 +172,7 @@ static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
171 int ring_page) 172 int ring_page)
172{ 173{
173 struct ei_device *ei_local = netdev_priv(dev); 174 struct ei_device *ei_local = netdev_priv(dev);
174 struct ax_device *ax = to_ax_dev(dev); 175 struct ax_device *ax = to_ax_dev(dev);
175 void __iomem *nic_base = ei_local->mem; 176 void __iomem *nic_base = ei_local->mem;
176 177
177 /* This *shouldn't* happen. If it does, it's the last thing you'll see */ 178 /* This *shouldn't* happen. If it does, it's the last thing you'll see */
@@ -184,7 +185,7 @@ static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
184 } 185 }
185 186
186 ei_status.dmaing |= 0x01; 187 ei_status.dmaing |= 0x01;
187 ei_outb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); 188 ei_outb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD);
188 ei_outb(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO); 189 ei_outb(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
189 ei_outb(0, nic_base + EN0_RCNTHI); 190 ei_outb(0, nic_base + EN0_RCNTHI);
190 ei_outb(0, nic_base + EN0_RSARLO); /* On page boundary */ 191 ei_outb(0, nic_base + EN0_RSARLO); /* On page boundary */
@@ -192,9 +193,11 @@ static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
192 ei_outb(E8390_RREAD+E8390_START, nic_base + NE_CMD); 193 ei_outb(E8390_RREAD+E8390_START, nic_base + NE_CMD);
193 194
194 if (ei_status.word16) 195 if (ei_status.word16)
195 readsw(nic_base + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1); 196 readsw(nic_base + NE_DATAPORT, hdr,
197 sizeof(struct e8390_pkt_hdr) >> 1);
196 else 198 else
197 readsb(nic_base + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)); 199 readsb(nic_base + NE_DATAPORT, hdr,
200 sizeof(struct e8390_pkt_hdr));
198 201
199 ei_outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ 202 ei_outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
200 ei_status.dmaing &= ~0x01; 203 ei_status.dmaing &= ~0x01;
@@ -203,16 +206,18 @@ static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
203} 206}
204 207
205 208
206/* Block input and output, similar to the Crynwr packet driver. If you 209/*
207 are porting to a new ethercard, look at the packet driver source for hints. 210 * Block input and output, similar to the Crynwr packet driver. If
208 The NEx000 doesn't share the on-board packet memory -- you have to put 211 * you are porting to a new ethercard, look at the packet driver
209 the packet out through the "remote DMA" dataport using ei_outb. */ 212 * source for hints. The NEx000 doesn't share the on-board packet
210 213 * memory -- you have to put the packet out through the "remote DMA"
214 * dataport using ei_outb.
215 */
211static void ax_block_input(struct net_device *dev, int count, 216static void ax_block_input(struct net_device *dev, int count,
212 struct sk_buff *skb, int ring_offset) 217 struct sk_buff *skb, int ring_offset)
213{ 218{
214 struct ei_device *ei_local = netdev_priv(dev); 219 struct ei_device *ei_local = netdev_priv(dev);
215 struct ax_device *ax = to_ax_dev(dev); 220 struct ax_device *ax = to_ax_dev(dev);
216 void __iomem *nic_base = ei_local->mem; 221 void __iomem *nic_base = ei_local->mem;
217 char *buf = skb->data; 222 char *buf = skb->data;
218 223
@@ -227,7 +232,7 @@ static void ax_block_input(struct net_device *dev, int count,
227 232
228 ei_status.dmaing |= 0x01; 233 ei_status.dmaing |= 0x01;
229 234
230 ei_outb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); 235 ei_outb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base + NE_CMD);
231 ei_outb(count & 0xff, nic_base + EN0_RCNTLO); 236 ei_outb(count & 0xff, nic_base + EN0_RCNTLO);
232 ei_outb(count >> 8, nic_base + EN0_RCNTHI); 237 ei_outb(count >> 8, nic_base + EN0_RCNTHI);
233 ei_outb(ring_offset & 0xff, nic_base + EN0_RSARLO); 238 ei_outb(ring_offset & 0xff, nic_base + EN0_RSARLO);
@@ -250,14 +255,15 @@ static void ax_block_output(struct net_device *dev, int count,
250 const unsigned char *buf, const int start_page) 255 const unsigned char *buf, const int start_page)
251{ 256{
252 struct ei_device *ei_local = netdev_priv(dev); 257 struct ei_device *ei_local = netdev_priv(dev);
253 struct ax_device *ax = to_ax_dev(dev); 258 struct ax_device *ax = to_ax_dev(dev);
254 void __iomem *nic_base = ei_local->mem; 259 void __iomem *nic_base = ei_local->mem;
255 unsigned long dma_start; 260 unsigned long dma_start;
256 261
257 /* Round the count up for word writes. Do we need to do this? 262 /*
258 What effect will an odd byte count have on the 8390? 263 * Round the count up for word writes. Do we need to do this?
259 I should check someday. */ 264 * What effect will an odd byte count have on the 8390? I
260 265 * should check someday.
266 */
261 if (ei_status.word16 && (count & 0x01)) 267 if (ei_status.word16 && (count & 0x01))
262 count++; 268 count++;
263 269
@@ -278,25 +284,24 @@ static void ax_block_output(struct net_device *dev, int count,
278 284
279 /* Now the normal output. */ 285 /* Now the normal output. */
280 ei_outb(count & 0xff, nic_base + EN0_RCNTLO); 286 ei_outb(count & 0xff, nic_base + EN0_RCNTLO);
281 ei_outb(count >> 8, nic_base + EN0_RCNTHI); 287 ei_outb(count >> 8, nic_base + EN0_RCNTHI);
282 ei_outb(0x00, nic_base + EN0_RSARLO); 288 ei_outb(0x00, nic_base + EN0_RSARLO);
283 ei_outb(start_page, nic_base + EN0_RSARHI); 289 ei_outb(start_page, nic_base + EN0_RSARHI);
284 290
285 ei_outb(E8390_RWRITE+E8390_START, nic_base + NE_CMD); 291 ei_outb(E8390_RWRITE+E8390_START, nic_base + NE_CMD);
286 if (ei_status.word16) { 292 if (ei_status.word16)
287 writesw(nic_base + NE_DATAPORT, buf, count>>1); 293 writesw(nic_base + NE_DATAPORT, buf, count >> 1);
288 } else { 294 else
289 writesb(nic_base + NE_DATAPORT, buf, count); 295 writesb(nic_base + NE_DATAPORT, buf, count);
290 }
291 296
292 dma_start = jiffies; 297 dma_start = jiffies;
293 298
294 while ((ei_inb(nic_base + EN0_ISR) & ENISR_RDC) == 0) { 299 while ((ei_inb(nic_base + EN0_ISR) & ENISR_RDC) == 0) {
295 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ 300 if (jiffies - dma_start > 2 * HZ / 100) { /* 20ms */
296 dev_warn(&ax->dev->dev, 301 dev_warn(&ax->dev->dev,
297 "%s: timeout waiting for Tx RDC.\n", dev->name); 302 "%s: timeout waiting for Tx RDC.\n", dev->name);
298 ax_reset_8390(dev); 303 ax_reset_8390(dev);
299 ax_NS8390_init(dev,1); 304 ax_NS8390_init(dev, 1);
300 break; 305 break;
301 } 306 }
302 } 307 }
@@ -308,20 +313,20 @@ static void ax_block_output(struct net_device *dev, int count,
308/* definitions for accessing MII/EEPROM interface */ 313/* definitions for accessing MII/EEPROM interface */
309 314
310#define AX_MEMR EI_SHIFT(0x14) 315#define AX_MEMR EI_SHIFT(0x14)
311#define AX_MEMR_MDC (1<<0) 316#define AX_MEMR_MDC BIT(0)
312#define AX_MEMR_MDIR (1<<1) 317#define AX_MEMR_MDIR BIT(1)
313#define AX_MEMR_MDI (1<<2) 318#define AX_MEMR_MDI BIT(2)
314#define AX_MEMR_MDO (1<<3) 319#define AX_MEMR_MDO BIT(3)
315#define AX_MEMR_EECS (1<<4) 320#define AX_MEMR_EECS BIT(4)
316#define AX_MEMR_EEI (1<<5) 321#define AX_MEMR_EEI BIT(5)
317#define AX_MEMR_EEO (1<<6) 322#define AX_MEMR_EEO BIT(6)
318#define AX_MEMR_EECLK (1<<7) 323#define AX_MEMR_EECLK BIT(7)
319 324
320/* ax_mii_ei_outbits 325/*
326 * ax_mii_ei_outbits
321 * 327 *
322 * write the specified set of bits to the phy 328 * write the specified set of bits to the phy
323*/ 329 */
324
325static void 330static void
326ax_mii_ei_outbits(struct net_device *dev, unsigned int bits, int len) 331ax_mii_ei_outbits(struct net_device *dev, unsigned int bits, int len)
327{ 332{
@@ -356,11 +361,11 @@ ax_mii_ei_outbits(struct net_device *dev, unsigned int bits, int len)
356 ei_outb(memr, (void __iomem *)dev->base_addr + AX_MEMR); 361 ei_outb(memr, (void __iomem *)dev->base_addr + AX_MEMR);
357} 362}
358 363
359/* ax_phy_ei_inbits 364/*
365 * ax_phy_ei_inbits
360 * 366 *
361 * read a specified number of bits from the phy 367 * read a specified number of bits from the phy
362*/ 368 */
363
364static unsigned int 369static unsigned int
365ax_phy_ei_inbits(struct net_device *dev, int no) 370ax_phy_ei_inbits(struct net_device *dev, int no)
366{ 371{
@@ -381,7 +386,7 @@ ax_phy_ei_inbits(struct net_device *dev, int no)
381 udelay(1); 386 udelay(1);
382 387
383 if (ei_inb(memr_addr) & AX_MEMR_MDI) 388 if (ei_inb(memr_addr) & AX_MEMR_MDI)
384 result |= (1<<no); 389 result |= (1 << no);
385 390
386 ei_outb(memr, memr_addr); 391 ei_outb(memr, memr_addr);
387 } 392 }
@@ -389,12 +394,12 @@ ax_phy_ei_inbits(struct net_device *dev, int no)
389 return result; 394 return result;
390} 395}
391 396
392/* ax_phy_issueaddr 397/*
398 * ax_phy_issueaddr
393 * 399 *
394 * use the low level bit shifting routines to send the address 400 * use the low level bit shifting routines to send the address
395 * and command to the specified phy 401 * and command to the specified phy
396*/ 402 */
397
398static void 403static void
399ax_phy_issueaddr(struct net_device *dev, int phy_addr, int reg, int opc) 404ax_phy_issueaddr(struct net_device *dev, int phy_addr, int reg, int opc)
400{ 405{
@@ -414,16 +419,16 @@ ax_phy_read(struct net_device *dev, int phy_addr, int reg)
414{ 419{
415 struct ei_device *ei_local = netdev_priv(dev); 420 struct ei_device *ei_local = netdev_priv(dev);
416 unsigned long flags; 421 unsigned long flags;
417 unsigned int result; 422 unsigned int result;
418 423
419 spin_lock_irqsave(&ei_local->page_lock, flags); 424 spin_lock_irqsave(&ei_local->page_lock, flags);
420 425
421 ax_phy_issueaddr(dev, phy_addr, reg, 2); 426 ax_phy_issueaddr(dev, phy_addr, reg, 2);
422 427
423 result = ax_phy_ei_inbits(dev, 17); 428 result = ax_phy_ei_inbits(dev, 17);
424 result &= ~(3<<16); 429 result &= ~(3 << 16);
425 430
426 spin_unlock_irqrestore(&ei_local->page_lock, flags); 431 spin_unlock_irqrestore(&ei_local->page_lock, flags);
427 432
428 if (phy_debug) 433 if (phy_debug)
429 pr_debug("%s: %04x.%04x => read %04x\n", __func__, 434 pr_debug("%s: %04x.%04x => read %04x\n", __func__,
@@ -436,25 +441,25 @@ static void
436ax_phy_write(struct net_device *dev, int phy_addr, int reg, int value) 441ax_phy_write(struct net_device *dev, int phy_addr, int reg, int value)
437{ 442{
438 struct ei_device *ei = netdev_priv(dev); 443 struct ei_device *ei = netdev_priv(dev);
439 struct ax_device *ax = to_ax_dev(dev); 444 struct ax_device *ax = to_ax_dev(dev);
440 unsigned long flags; 445 unsigned long flags;
441 446
442 dev_dbg(&ax->dev->dev, "%s: %p, %04x, %04x %04x\n", 447 dev_dbg(&ax->dev->dev, "%s: %p, %04x, %04x %04x\n",
443 __func__, dev, phy_addr, reg, value); 448 __func__, dev, phy_addr, reg, value);
444 449
445 spin_lock_irqsave(&ei->page_lock, flags); 450 spin_lock_irqsave(&ei->page_lock, flags);
446 451
447 ax_phy_issueaddr(dev, phy_addr, reg, 1); 452 ax_phy_issueaddr(dev, phy_addr, reg, 1);
448 ax_mii_ei_outbits(dev, 2, 2); /* send TA */ 453 ax_mii_ei_outbits(dev, 2, 2); /* send TA */
449 ax_mii_ei_outbits(dev, value, 16); 454 ax_mii_ei_outbits(dev, value, 16);
450 455
451 spin_unlock_irqrestore(&ei->page_lock, flags); 456 spin_unlock_irqrestore(&ei->page_lock, flags);
452} 457}
453 458
454static void ax_mii_expiry(unsigned long data) 459static void ax_mii_expiry(unsigned long data)
455{ 460{
456 struct net_device *dev = (struct net_device *)data; 461 struct net_device *dev = (struct net_device *)data;
457 struct ax_device *ax = to_ax_dev(dev); 462 struct ax_device *ax = to_ax_dev(dev);
458 unsigned long flags; 463 unsigned long flags;
459 464
460 spin_lock_irqsave(&ax->mii_lock, flags); 465 spin_lock_irqsave(&ax->mii_lock, flags);
@@ -469,7 +474,7 @@ static void ax_mii_expiry(unsigned long data)
469 474
470static int ax_open(struct net_device *dev) 475static int ax_open(struct net_device *dev)
471{ 476{
472 struct ax_device *ax = to_ax_dev(dev); 477 struct ax_device *ax = to_ax_dev(dev);
473 struct ei_device *ei_local = netdev_priv(dev); 478 struct ei_device *ei_local = netdev_priv(dev);
474 int ret; 479 int ret;
475 480
@@ -495,8 +500,8 @@ static int ax_open(struct net_device *dev)
495 500
496 init_timer(&ax->mii_timer); 501 init_timer(&ax->mii_timer);
497 502
498 ax->mii_timer.expires = jiffies+1; 503 ax->mii_timer.expires = jiffies + 1;
499 ax->mii_timer.data = (unsigned long) dev; 504 ax->mii_timer.data = (unsigned long) dev;
500 ax->mii_timer.function = ax_mii_expiry; 505 ax->mii_timer.function = ax_mii_expiry;
501 506
502 add_timer(&ax->mii_timer); 507 add_timer(&ax->mii_timer);
@@ -513,7 +518,7 @@ static int ax_close(struct net_device *dev)
513 518
514 /* turn the phy off */ 519 /* turn the phy off */
515 520
516 ei_outb(ax->plat->gpoc_val | (1<<6), 521 ei_outb(ax->plat->gpoc_val | (1 << 6),
517 ei_local->mem + EI_SHIFT(0x17)); 522 ei_local->mem + EI_SHIFT(0x17));
518 523
519 ax->running = 0; 524 ax->running = 0;
@@ -640,7 +645,7 @@ static const struct net_device_ops ax_netdev_ops = {
640 .ndo_get_stats = ax_ei_get_stats, 645 .ndo_get_stats = ax_ei_get_stats,
641 .ndo_set_multicast_list = ax_ei_set_multicast_list, 646 .ndo_set_multicast_list = ax_ei_set_multicast_list,
642 .ndo_validate_addr = eth_validate_addr, 647 .ndo_validate_addr = eth_validate_addr,
643 .ndo_set_mac_address = eth_mac_addr, 648 .ndo_set_mac_address = eth_mac_addr,
644 .ndo_change_mtu = eth_change_mtu, 649 .ndo_change_mtu = eth_change_mtu,
645#ifdef CONFIG_NET_POLL_CONTROLLER 650#ifdef CONFIG_NET_POLL_CONTROLLER
646 .ndo_poll_controller = ax_ei_poll, 651 .ndo_poll_controller = ax_ei_poll,
@@ -654,22 +659,22 @@ static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local)
654 void __iomem *ioaddr = ei_local->mem; 659 void __iomem *ioaddr = ei_local->mem;
655 struct ax_device *ax = to_ax_dev(dev); 660 struct ax_device *ax = to_ax_dev(dev);
656 661
657 /* Select page 0*/ 662 /* Select page 0 */
658 ei_outb(E8390_NODMA+E8390_PAGE0+E8390_STOP, ioaddr + E8390_CMD); 663 ei_outb(E8390_NODMA + E8390_PAGE0 + E8390_STOP, ioaddr + E8390_CMD);
659 664
660 /* set to byte access */ 665 /* set to byte access */
661 ei_outb(ax->plat->dcr_val & ~1, ioaddr + EN0_DCFG); 666 ei_outb(ax->plat->dcr_val & ~1, ioaddr + EN0_DCFG);
662 ei_outb(ax->plat->gpoc_val, ioaddr + EI_SHIFT(0x17)); 667 ei_outb(ax->plat->gpoc_val, ioaddr + EI_SHIFT(0x17));
663} 668}
664 669
665/* ax_init_dev 670/*
671 * ax_init_dev
666 * 672 *
667 * initialise the specified device, taking care to note the MAC 673 * initialise the specified device, taking care to note the MAC
668 * address it may already have (if configured), ensure 674 * address it may already have (if configured), ensure
669 * the device is ready to be used by lib8390.c and registerd with 675 * the device is ready to be used by lib8390.c and registerd with
670 * the network layer. 676 * the network layer.
671 */ 677 */
672
673static int ax_init_dev(struct net_device *dev, int first_init) 678static int ax_init_dev(struct net_device *dev, int first_init)
674{ 679{
675 struct ei_device *ei_local = netdev_priv(dev); 680 struct ei_device *ei_local = netdev_priv(dev);
@@ -693,16 +698,16 @@ static int ax_init_dev(struct net_device *dev, int first_init)
693 if (first_init && ax->plat->flags & AXFLG_HAS_EEPROM) { 698 if (first_init && ax->plat->flags & AXFLG_HAS_EEPROM) {
694 unsigned char SA_prom[32]; 699 unsigned char SA_prom[32];
695 700
696 for(i = 0; i < sizeof(SA_prom); i+=2) { 701 for (i = 0; i < sizeof(SA_prom); i += 2) {
697 SA_prom[i] = ei_inb(ioaddr + NE_DATAPORT); 702 SA_prom[i] = ei_inb(ioaddr + NE_DATAPORT);
698 SA_prom[i+1] = ei_inb(ioaddr + NE_DATAPORT); 703 SA_prom[i + 1] = ei_inb(ioaddr + NE_DATAPORT);
699 } 704 }
700 705
701 if (ax->plat->wordlength == 2) 706 if (ax->plat->wordlength == 2)
702 for (i = 0; i < 16; i++) 707 for (i = 0; i < 16; i++)
703 SA_prom[i] = SA_prom[i+i]; 708 SA_prom[i] = SA_prom[i+i];
704 709
705 memcpy(dev->dev_addr, SA_prom, 6); 710 memcpy(dev->dev_addr, SA_prom, 6);
706 } 711 }
707 712
708#ifdef CONFIG_AX88796_93CX6 713#ifdef CONFIG_AX88796_93CX6
@@ -719,7 +724,7 @@ static int ax_init_dev(struct net_device *dev, int first_init)
719 (__le16 __force *)mac_addr, 724 (__le16 __force *)mac_addr,
720 sizeof(mac_addr) >> 1); 725 sizeof(mac_addr) >> 1);
721 726
722 memcpy(dev->dev_addr, mac_addr, 6); 727 memcpy(dev->dev_addr, mac_addr, 6);
723 } 728 }
724#endif 729#endif
725 if (ax->plat->wordlength == 2) { 730 if (ax->plat->wordlength == 2) {
@@ -732,9 +737,10 @@ static int ax_init_dev(struct net_device *dev, int first_init)
732 stop_page = NE1SM_STOP_PG; 737 stop_page = NE1SM_STOP_PG;
733 } 738 }
734 739
735 /* load the mac-address from the device if this is the 740 /*
736 * first time we've initialised */ 741 * load the mac-address from the device if this is the first
737 742 * time we've initialised
743 */
738 if (first_init) { 744 if (first_init) {
739 if (ax->plat->flags & AXFLG_MAC_FROMDEV) { 745 if (ax->plat->flags & AXFLG_MAC_FROMDEV) {
740 ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP, 746 ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP,
@@ -759,7 +765,7 @@ static int ax_init_dev(struct net_device *dev, int first_init)
759 ei_status.rx_start_page = start_page + TX_PAGES; 765 ei_status.rx_start_page = start_page + TX_PAGES;
760 766
761#ifdef PACKETBUF_MEMSIZE 767#ifdef PACKETBUF_MEMSIZE
762 /* Allow the packet buffer size to be overridden by know-it-alls. */ 768 /* Allow the packet buffer size to be overridden by know-it-alls. */
763 ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE; 769 ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;
764#endif 770#endif
765 771
@@ -769,8 +775,8 @@ static int ax_init_dev(struct net_device *dev, int first_init)
769 ei_status.get_8390_hdr = &ax_get_8390_hdr; 775 ei_status.get_8390_hdr = &ax_get_8390_hdr;
770 ei_status.priv = 0; 776 ei_status.priv = 0;
771 777
772 dev->netdev_ops = &ax_netdev_ops; 778 dev->netdev_ops = &ax_netdev_ops;
773 dev->ethtool_ops = &ax_ethtool_ops; 779 dev->ethtool_ops = &ax_ethtool_ops;
774 780
775 ax->msg_enable = NETIF_MSG_LINK; 781 ax->msg_enable = NETIF_MSG_LINK;
776 ax->mii.phy_id_mask = 0x1f; 782 ax->mii.phy_id_mask = 0x1f;
@@ -786,7 +792,7 @@ static int ax_init_dev(struct net_device *dev, int first_init)
786 792
787 if (first_init) 793 if (first_init)
788 dev_info(&ax->dev->dev, "%dbit, irq %d, %lx, MAC: %pM\n", 794 dev_info(&ax->dev->dev, "%dbit, irq %d, %lx, MAC: %pM\n",
789 ei_status.word16 ? 16:8, dev->irq, dev->base_addr, 795 ei_status.word16 ? 16 : 8, dev->irq, dev->base_addr,
790 dev->dev_addr); 796 dev->dev_addr);
791 797
792 ret = register_netdev(dev); 798 ret = register_netdev(dev);
@@ -805,7 +811,7 @@ static int ax_init_dev(struct net_device *dev, int first_init)
805static int ax_remove(struct platform_device *_dev) 811static int ax_remove(struct platform_device *_dev)
806{ 812{
807 struct net_device *dev = platform_get_drvdata(_dev); 813 struct net_device *dev = platform_get_drvdata(_dev);
808 struct ax_device *ax; 814 struct ax_device *ax;
809 815
810 ax = to_ax_dev(dev); 816 ax = to_ax_dev(dev);
811 817
@@ -827,18 +833,18 @@ static int ax_remove(struct platform_device *_dev)
827 return 0; 833 return 0;
828} 834}
829 835
830/* ax_probe 836/*
837 * ax_probe
831 * 838 *
832 * This is the entry point when the platform device system uses to 839 * This is the entry point when the platform device system uses to
833 * notify us of a new device to attach to. Allocate memory, find 840 * notify us of a new device to attach to. Allocate memory, find the
834 * the resources and information passed, and map the necessary registers. 841 * resources and information passed, and map the necessary registers.
835*/ 842 */
836
837static int ax_probe(struct platform_device *pdev) 843static int ax_probe(struct platform_device *pdev)
838{ 844{
839 struct net_device *dev; 845 struct net_device *dev;
840 struct ax_device *ax; 846 struct ax_device *ax;
841 struct resource *res; 847 struct resource *res;
842 size_t size; 848 size_t size;
843 int ret = 0; 849 int ret = 0;
844 850
@@ -857,10 +863,9 @@ static int ax_probe(struct platform_device *pdev)
857 ax->plat = pdev->dev.platform_data; 863 ax->plat = pdev->dev.platform_data;
858 platform_set_drvdata(pdev, dev); 864 platform_set_drvdata(pdev, dev);
859 865
860 ei_status.rxcr_base = ax->plat->rcr_val; 866 ei_status.rxcr_base = ax->plat->rcr_val;
861 867
862 /* find the platform resources */ 868 /* find the platform resources */
863
864 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 869 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
865 if (res == NULL) { 870 if (res == NULL) {
866 dev_err(&pdev->dev, "no IRQ specified\n"); 871 dev_err(&pdev->dev, "no IRQ specified\n");
@@ -880,9 +885,10 @@ static int ax_probe(struct platform_device *pdev)
880 885
881 size = (res->end - res->start) + 1; 886 size = (res->end - res->start) + 1;
882 887
883 /* setup the register offsets from either the platform data 888 /*
884 * or by using the size of the resource provided */ 889 * setup the register offsets from either the platform data or
885 890 * by using the size of the resource provided
891 */
886 if (ax->plat->reg_offsets) 892 if (ax->plat->reg_offsets)
887 ei_status.reg_offset = ax->plat->reg_offsets; 893 ei_status.reg_offset = ax->plat->reg_offsets;
888 else { 894 else {
@@ -894,7 +900,7 @@ static int ax_probe(struct platform_device *pdev)
894 ax->mem = request_mem_region(res->start, size, pdev->name); 900 ax->mem = request_mem_region(res->start, size, pdev->name);
895 if (ax->mem == NULL) { 901 if (ax->mem == NULL) {
896 dev_err(&pdev->dev, "cannot reserve registers\n"); 902 dev_err(&pdev->dev, "cannot reserve registers\n");
897 ret = -ENXIO; 903 ret = -ENXIO;
898 goto exit_mem; 904 goto exit_mem;
899 } 905 }
900 906
@@ -906,7 +912,7 @@ static int ax_probe(struct platform_device *pdev)
906 (unsigned long long)res->start, 912 (unsigned long long)res->start,
907 (unsigned long long)res->end); 913 (unsigned long long)res->end);
908 914
909 ret = -ENXIO; 915 ret = -ENXIO;
910 goto exit_req; 916 goto exit_req;
911 } 917 }
912 918
@@ -921,7 +927,7 @@ static int ax_probe(struct platform_device *pdev)
921 927
922 ax->map2 = NULL; 928 ax->map2 = NULL;
923 } else { 929 } else {
924 size = (res->end - res->start) + 1; 930 size = (res->end - res->start) + 1;
925 931
926 ax->mem2 = request_mem_region(res->start, size, pdev->name); 932 ax->mem2 = request_mem_region(res->start, size, pdev->name);
927 if (ax->mem2 == NULL) { 933 if (ax->mem2 == NULL) {
@@ -974,7 +980,7 @@ static int ax_probe(struct platform_device *pdev)
974static int ax_suspend(struct platform_device *dev, pm_message_t state) 980static int ax_suspend(struct platform_device *dev, pm_message_t state)
975{ 981{
976 struct net_device *ndev = platform_get_drvdata(dev); 982 struct net_device *ndev = platform_get_drvdata(dev);
977 struct ax_device *ax = to_ax_dev(ndev); 983 struct ax_device *ax = to_ax_dev(ndev);
978 984
979 ax->resume_open = ax->running; 985 ax->resume_open = ax->running;
980 986
@@ -987,7 +993,7 @@ static int ax_suspend(struct platform_device *dev, pm_message_t state)
987static int ax_resume(struct platform_device *pdev) 993static int ax_resume(struct platform_device *pdev)
988{ 994{
989 struct net_device *ndev = platform_get_drvdata(pdev); 995 struct net_device *ndev = platform_get_drvdata(pdev);
990 struct ax_device *ax = to_ax_dev(ndev); 996 struct ax_device *ax = to_ax_dev(ndev);
991 997
992 ax_initial_setup(ndev, netdev_priv(ndev)); 998 ax_initial_setup(ndev, netdev_priv(ndev));
993 ax_NS8390_init(ndev, ax->resume_open); 999 ax_NS8390_init(ndev, ax->resume_open);
@@ -1001,7 +1007,7 @@ static int ax_resume(struct platform_device *pdev)
1001 1007
1002#else 1008#else
1003#define ax_suspend NULL 1009#define ax_suspend NULL
1004#define ax_resume NULL 1010#define ax_resume NULL
1005#endif 1011#endif
1006 1012
1007static struct platform_driver axdrv = { 1013static struct platform_driver axdrv = {