aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/smc911x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/smc911x.c')
-rw-r--r--drivers/net/smc911x.c406
1 files changed, 170 insertions, 236 deletions
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 4e2800205189..2ca4db85f938 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -106,56 +106,6 @@ MODULE_ALIAS("platform:smc911x");
106 */ 106 */
107#define POWER_DOWN 1 107#define POWER_DOWN 1
108 108
109
110/* store this information for the driver.. */
111struct smc911x_local {
112 /*
113 * If I have to wait until the DMA is finished and ready to reload a
114 * packet, I will store the skbuff here. Then, the DMA will send it
115 * out and free it.
116 */
117 struct sk_buff *pending_tx_skb;
118
119 /* version/revision of the SMC911x chip */
120 u16 version;
121 u16 revision;
122
123 /* FIFO sizes */
124 int tx_fifo_kb;
125 int tx_fifo_size;
126 int rx_fifo_size;
127 int afc_cfg;
128
129 /* Contains the current active receive/phy mode */
130 int ctl_rfduplx;
131 int ctl_rspeed;
132
133 u32 msg_enable;
134 u32 phy_type;
135 struct mii_if_info mii;
136
137 /* work queue */
138 struct work_struct phy_configure;
139 int work_pending;
140
141 int tx_throttle;
142 spinlock_t lock;
143
144 struct net_device *netdev;
145
146#ifdef SMC_USE_DMA
147 /* DMA needs the physical address of the chip */
148 u_long physaddr;
149 int rxdma;
150 int txdma;
151 int rxdma_active;
152 int txdma_active;
153 struct sk_buff *current_rx_skb;
154 struct sk_buff *current_tx_skb;
155 struct device *dev;
156#endif
157};
158
159#if SMC_DEBUG > 0 109#if SMC_DEBUG > 0
160#define DBG(n, args...) \ 110#define DBG(n, args...) \
161 do { \ 111 do { \
@@ -203,24 +153,24 @@ static void PRINT_PKT(u_char *buf, int length)
203 153
204 154
205/* this enables an interrupt in the interrupt mask register */ 155/* this enables an interrupt in the interrupt mask register */
206#define SMC_ENABLE_INT(x) do { \ 156#define SMC_ENABLE_INT(lp, x) do { \
207 unsigned int __mask; \ 157 unsigned int __mask; \
208 unsigned long __flags; \ 158 unsigned long __flags; \
209 spin_lock_irqsave(&lp->lock, __flags); \ 159 spin_lock_irqsave(&lp->lock, __flags); \
210 __mask = SMC_GET_INT_EN(); \ 160 __mask = SMC_GET_INT_EN((lp)); \
211 __mask |= (x); \ 161 __mask |= (x); \
212 SMC_SET_INT_EN(__mask); \ 162 SMC_SET_INT_EN((lp), __mask); \
213 spin_unlock_irqrestore(&lp->lock, __flags); \ 163 spin_unlock_irqrestore(&lp->lock, __flags); \
214} while (0) 164} while (0)
215 165
216/* this disables an interrupt from the interrupt mask register */ 166/* this disables an interrupt from the interrupt mask register */
217#define SMC_DISABLE_INT(x) do { \ 167#define SMC_DISABLE_INT(lp, x) do { \
218 unsigned int __mask; \ 168 unsigned int __mask; \
219 unsigned long __flags; \ 169 unsigned long __flags; \
220 spin_lock_irqsave(&lp->lock, __flags); \ 170 spin_lock_irqsave(&lp->lock, __flags); \
221 __mask = SMC_GET_INT_EN(); \ 171 __mask = SMC_GET_INT_EN((lp)); \
222 __mask &= ~(x); \ 172 __mask &= ~(x); \
223 SMC_SET_INT_EN(__mask); \ 173 SMC_SET_INT_EN((lp), __mask); \
224 spin_unlock_irqrestore(&lp->lock, __flags); \ 174 spin_unlock_irqrestore(&lp->lock, __flags); \
225} while (0) 175} while (0)
226 176
@@ -229,7 +179,6 @@ static void PRINT_PKT(u_char *buf, int length)
229 */ 179 */
230static void smc911x_reset(struct net_device *dev) 180static void smc911x_reset(struct net_device *dev)
231{ 181{
232 unsigned long ioaddr = dev->base_addr;
233 struct smc911x_local *lp = netdev_priv(dev); 182 struct smc911x_local *lp = netdev_priv(dev);
234 unsigned int reg, timeout=0, resets=1; 183 unsigned int reg, timeout=0, resets=1;
235 unsigned long flags; 184 unsigned long flags;
@@ -237,13 +186,13 @@ static void smc911x_reset(struct net_device *dev)
237 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); 186 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
238 187
239 /* Take out of PM setting first */ 188 /* Take out of PM setting first */
240 if ((SMC_GET_PMT_CTRL() & PMT_CTRL_READY_) == 0) { 189 if ((SMC_GET_PMT_CTRL(lp) & PMT_CTRL_READY_) == 0) {
241 /* Write to the bytetest will take out of powerdown */ 190 /* Write to the bytetest will take out of powerdown */
242 SMC_SET_BYTE_TEST(0); 191 SMC_SET_BYTE_TEST(lp, 0);
243 timeout=10; 192 timeout=10;
244 do { 193 do {
245 udelay(10); 194 udelay(10);
246 reg = SMC_GET_PMT_CTRL() & PMT_CTRL_READY_; 195 reg = SMC_GET_PMT_CTRL(lp) & PMT_CTRL_READY_;
247 } while (--timeout && !reg); 196 } while (--timeout && !reg);
248 if (timeout == 0) { 197 if (timeout == 0) {
249 PRINTK("%s: smc911x_reset timeout waiting for PM restore\n", dev->name); 198 PRINTK("%s: smc911x_reset timeout waiting for PM restore\n", dev->name);
@@ -253,15 +202,15 @@ static void smc911x_reset(struct net_device *dev)
253 202
254 /* Disable all interrupts */ 203 /* Disable all interrupts */
255 spin_lock_irqsave(&lp->lock, flags); 204 spin_lock_irqsave(&lp->lock, flags);
256 SMC_SET_INT_EN(0); 205 SMC_SET_INT_EN(lp, 0);
257 spin_unlock_irqrestore(&lp->lock, flags); 206 spin_unlock_irqrestore(&lp->lock, flags);
258 207
259 while (resets--) { 208 while (resets--) {
260 SMC_SET_HW_CFG(HW_CFG_SRST_); 209 SMC_SET_HW_CFG(lp, HW_CFG_SRST_);
261 timeout=10; 210 timeout=10;
262 do { 211 do {
263 udelay(10); 212 udelay(10);
264 reg = SMC_GET_HW_CFG(); 213 reg = SMC_GET_HW_CFG(lp);
265 /* If chip indicates reset timeout then try again */ 214 /* If chip indicates reset timeout then try again */
266 if (reg & HW_CFG_SRST_TO_) { 215 if (reg & HW_CFG_SRST_TO_) {
267 PRINTK("%s: chip reset timeout, retrying...\n", dev->name); 216 PRINTK("%s: chip reset timeout, retrying...\n", dev->name);
@@ -277,7 +226,7 @@ static void smc911x_reset(struct net_device *dev)
277 226
278 /* make sure EEPROM has finished loading before setting GPIO_CFG */ 227 /* make sure EEPROM has finished loading before setting GPIO_CFG */
279 timeout=1000; 228 timeout=1000;
280 while ( timeout-- && (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)) { 229 while ( timeout-- && (SMC_GET_E2P_CMD(lp) & E2P_CMD_EPC_BUSY_)) {
281 udelay(10); 230 udelay(10);
282 } 231 }
283 if (timeout == 0){ 232 if (timeout == 0){
@@ -286,24 +235,24 @@ static void smc911x_reset(struct net_device *dev)
286 } 235 }
287 236
288 /* Initialize interrupts */ 237 /* Initialize interrupts */
289 SMC_SET_INT_EN(0); 238 SMC_SET_INT_EN(lp, 0);
290 SMC_ACK_INT(-1); 239 SMC_ACK_INT(lp, -1);
291 240
292 /* Reset the FIFO level and flow control settings */ 241 /* Reset the FIFO level and flow control settings */
293 SMC_SET_HW_CFG((lp->tx_fifo_kb & 0xF) << 16); 242 SMC_SET_HW_CFG(lp, (lp->tx_fifo_kb & 0xF) << 16);
294//TODO: Figure out what appropriate pause time is 243//TODO: Figure out what appropriate pause time is
295 SMC_SET_FLOW(FLOW_FCPT_ | FLOW_FCEN_); 244 SMC_SET_FLOW(lp, FLOW_FCPT_ | FLOW_FCEN_);
296 SMC_SET_AFC_CFG(lp->afc_cfg); 245 SMC_SET_AFC_CFG(lp, lp->afc_cfg);
297 246
298 247
299 /* Set to LED outputs */ 248 /* Set to LED outputs */
300 SMC_SET_GPIO_CFG(0x70070000); 249 SMC_SET_GPIO_CFG(lp, 0x70070000);
301 250
302 /* 251 /*
303 * Deassert IRQ for 1*10us for edge type interrupts 252 * Deassert IRQ for 1*10us for edge type interrupts
304 * and drive IRQ pin push-pull 253 * and drive IRQ pin push-pull
305 */ 254 */
306 SMC_SET_IRQ_CFG( (1 << 24) | INT_CFG_IRQ_EN_ | INT_CFG_IRQ_TYPE_ ); 255 SMC_SET_IRQ_CFG(lp, (1 << 24) | INT_CFG_IRQ_EN_ | INT_CFG_IRQ_TYPE_);
307 256
308 /* clear anything saved */ 257 /* clear anything saved */
309 if (lp->pending_tx_skb != NULL) { 258 if (lp->pending_tx_skb != NULL) {
@@ -319,46 +268,45 @@ static void smc911x_reset(struct net_device *dev)
319 */ 268 */
320static void smc911x_enable(struct net_device *dev) 269static void smc911x_enable(struct net_device *dev)
321{ 270{
322 unsigned long ioaddr = dev->base_addr;
323 struct smc911x_local *lp = netdev_priv(dev); 271 struct smc911x_local *lp = netdev_priv(dev);
324 unsigned mask, cfg, cr; 272 unsigned mask, cfg, cr;
325 unsigned long flags; 273 unsigned long flags;
326 274
327 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); 275 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
328 276
329 SMC_SET_MAC_ADDR(dev->dev_addr); 277 SMC_SET_MAC_ADDR(lp, dev->dev_addr);
330 278
331 /* Enable TX */ 279 /* Enable TX */
332 cfg = SMC_GET_HW_CFG(); 280 cfg = SMC_GET_HW_CFG(lp);
333 cfg &= HW_CFG_TX_FIF_SZ_ | 0xFFF; 281 cfg &= HW_CFG_TX_FIF_SZ_ | 0xFFF;
334 cfg |= HW_CFG_SF_; 282 cfg |= HW_CFG_SF_;
335 SMC_SET_HW_CFG(cfg); 283 SMC_SET_HW_CFG(lp, cfg);
336 SMC_SET_FIFO_TDA(0xFF); 284 SMC_SET_FIFO_TDA(lp, 0xFF);
337 /* Update TX stats on every 64 packets received or every 1 sec */ 285 /* Update TX stats on every 64 packets received or every 1 sec */
338 SMC_SET_FIFO_TSL(64); 286 SMC_SET_FIFO_TSL(lp, 64);
339 SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000); 287 SMC_SET_GPT_CFG(lp, GPT_CFG_TIMER_EN_ | 10000);
340 288
341 spin_lock_irqsave(&lp->lock, flags); 289 spin_lock_irqsave(&lp->lock, flags);
342 SMC_GET_MAC_CR(cr); 290 SMC_GET_MAC_CR(lp, cr);
343 cr |= MAC_CR_TXEN_ | MAC_CR_HBDIS_; 291 cr |= MAC_CR_TXEN_ | MAC_CR_HBDIS_;
344 SMC_SET_MAC_CR(cr); 292 SMC_SET_MAC_CR(lp, cr);
345 SMC_SET_TX_CFG(TX_CFG_TX_ON_); 293 SMC_SET_TX_CFG(lp, TX_CFG_TX_ON_);
346 spin_unlock_irqrestore(&lp->lock, flags); 294 spin_unlock_irqrestore(&lp->lock, flags);
347 295
348 /* Add 2 byte padding to start of packets */ 296 /* Add 2 byte padding to start of packets */
349 SMC_SET_RX_CFG((2<<8) & RX_CFG_RXDOFF_); 297 SMC_SET_RX_CFG(lp, (2<<8) & RX_CFG_RXDOFF_);
350 298
351 /* Turn on receiver and enable RX */ 299 /* Turn on receiver and enable RX */
352 if (cr & MAC_CR_RXEN_) 300 if (cr & MAC_CR_RXEN_)
353 DBG(SMC_DEBUG_RX, "%s: Receiver already enabled\n", dev->name); 301 DBG(SMC_DEBUG_RX, "%s: Receiver already enabled\n", dev->name);
354 302
355 spin_lock_irqsave(&lp->lock, flags); 303 spin_lock_irqsave(&lp->lock, flags);
356 SMC_SET_MAC_CR( cr | MAC_CR_RXEN_ ); 304 SMC_SET_MAC_CR(lp, cr | MAC_CR_RXEN_);
357 spin_unlock_irqrestore(&lp->lock, flags); 305 spin_unlock_irqrestore(&lp->lock, flags);
358 306
359 /* Interrupt on every received packet */ 307 /* Interrupt on every received packet */
360 SMC_SET_FIFO_RSA(0x01); 308 SMC_SET_FIFO_RSA(lp, 0x01);
361 SMC_SET_FIFO_RSL(0x00); 309 SMC_SET_FIFO_RSL(lp, 0x00);
362 310
363 /* now, enable interrupts */ 311 /* now, enable interrupts */
364 mask = INT_EN_TDFA_EN_ | INT_EN_TSFL_EN_ | INT_EN_RSFL_EN_ | 312 mask = INT_EN_TDFA_EN_ | INT_EN_TSFL_EN_ | INT_EN_RSFL_EN_ |
@@ -369,7 +317,7 @@ static void smc911x_enable(struct net_device *dev)
369 else { 317 else {
370 mask|=INT_EN_RDFO_EN_; 318 mask|=INT_EN_RDFO_EN_;
371 } 319 }
372 SMC_ENABLE_INT(mask); 320 SMC_ENABLE_INT(lp, mask);
373} 321}
374 322
375/* 323/*
@@ -377,7 +325,6 @@ static void smc911x_enable(struct net_device *dev)
377 */ 325 */
378static void smc911x_shutdown(struct net_device *dev) 326static void smc911x_shutdown(struct net_device *dev)
379{ 327{
380 unsigned long ioaddr = dev->base_addr;
381 struct smc911x_local *lp = netdev_priv(dev); 328 struct smc911x_local *lp = netdev_priv(dev);
382 unsigned cr; 329 unsigned cr;
383 unsigned long flags; 330 unsigned long flags;
@@ -385,35 +332,35 @@ static void smc911x_shutdown(struct net_device *dev)
385 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", CARDNAME, __FUNCTION__); 332 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", CARDNAME, __FUNCTION__);
386 333
387 /* Disable IRQ's */ 334 /* Disable IRQ's */
388 SMC_SET_INT_EN(0); 335 SMC_SET_INT_EN(lp, 0);
389 336
390 /* Turn of Rx and TX */ 337 /* Turn of Rx and TX */
391 spin_lock_irqsave(&lp->lock, flags); 338 spin_lock_irqsave(&lp->lock, flags);
392 SMC_GET_MAC_CR(cr); 339 SMC_GET_MAC_CR(lp, cr);
393 cr &= ~(MAC_CR_TXEN_ | MAC_CR_RXEN_ | MAC_CR_HBDIS_); 340 cr &= ~(MAC_CR_TXEN_ | MAC_CR_RXEN_ | MAC_CR_HBDIS_);
394 SMC_SET_MAC_CR(cr); 341 SMC_SET_MAC_CR(lp, cr);
395 SMC_SET_TX_CFG(TX_CFG_STOP_TX_); 342 SMC_SET_TX_CFG(lp, TX_CFG_STOP_TX_);
396 spin_unlock_irqrestore(&lp->lock, flags); 343 spin_unlock_irqrestore(&lp->lock, flags);
397} 344}
398 345
399static inline void smc911x_drop_pkt(struct net_device *dev) 346static inline void smc911x_drop_pkt(struct net_device *dev)
400{ 347{
401 unsigned long ioaddr = dev->base_addr; 348 struct smc911x_local *lp = netdev_priv(dev);
402 unsigned int fifo_count, timeout, reg; 349 unsigned int fifo_count, timeout, reg;
403 350
404 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n", CARDNAME, __FUNCTION__); 351 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n", CARDNAME, __FUNCTION__);
405 fifo_count = SMC_GET_RX_FIFO_INF() & 0xFFFF; 352 fifo_count = SMC_GET_RX_FIFO_INF(lp) & 0xFFFF;
406 if (fifo_count <= 4) { 353 if (fifo_count <= 4) {
407 /* Manually dump the packet data */ 354 /* Manually dump the packet data */
408 while (fifo_count--) 355 while (fifo_count--)
409 SMC_GET_RX_FIFO(); 356 SMC_GET_RX_FIFO(lp);
410 } else { 357 } else {
411 /* Fast forward through the bad packet */ 358 /* Fast forward through the bad packet */
412 SMC_SET_RX_DP_CTRL(RX_DP_CTRL_FFWD_BUSY_); 359 SMC_SET_RX_DP_CTRL(lp, RX_DP_CTRL_FFWD_BUSY_);
413 timeout=50; 360 timeout=50;
414 do { 361 do {
415 udelay(10); 362 udelay(10);
416 reg = SMC_GET_RX_DP_CTRL() & RX_DP_CTRL_FFWD_BUSY_; 363 reg = SMC_GET_RX_DP_CTRL(lp) & RX_DP_CTRL_FFWD_BUSY_;
417 } while (--timeout && reg); 364 } while (--timeout && reg);
418 if (timeout == 0) { 365 if (timeout == 0) {
419 PRINTK("%s: timeout waiting for RX fast forward\n", dev->name); 366 PRINTK("%s: timeout waiting for RX fast forward\n", dev->name);
@@ -429,14 +376,14 @@ static inline void smc911x_drop_pkt(struct net_device *dev)
429 */ 376 */
430static inline void smc911x_rcv(struct net_device *dev) 377static inline void smc911x_rcv(struct net_device *dev)
431{ 378{
432 unsigned long ioaddr = dev->base_addr; 379 struct smc911x_local *lp = netdev_priv(dev);
433 unsigned int pkt_len, status; 380 unsigned int pkt_len, status;
434 struct sk_buff *skb; 381 struct sk_buff *skb;
435 unsigned char *data; 382 unsigned char *data;
436 383
437 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n", 384 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n",
438 dev->name, __FUNCTION__); 385 dev->name, __FUNCTION__);
439 status = SMC_GET_RX_STS_FIFO(); 386 status = SMC_GET_RX_STS_FIFO(lp);
440 DBG(SMC_DEBUG_RX, "%s: Rx pkt len %d status 0x%08x \n", 387 DBG(SMC_DEBUG_RX, "%s: Rx pkt len %d status 0x%08x \n",
441 dev->name, (status & 0x3fff0000) >> 16, status & 0xc000ffff); 388 dev->name, (status & 0x3fff0000) >> 16, status & 0xc000ffff);
442 pkt_len = (status & RX_STS_PKT_LEN_) >> 16; 389 pkt_len = (status & RX_STS_PKT_LEN_) >> 16;
@@ -473,24 +420,23 @@ static inline void smc911x_rcv(struct net_device *dev)
473 skb_put(skb,pkt_len-4); 420 skb_put(skb,pkt_len-4);
474#ifdef SMC_USE_DMA 421#ifdef SMC_USE_DMA
475 { 422 {
476 struct smc911x_local *lp = netdev_priv(dev);
477 unsigned int fifo; 423 unsigned int fifo;
478 /* Lower the FIFO threshold if possible */ 424 /* Lower the FIFO threshold if possible */
479 fifo = SMC_GET_FIFO_INT(); 425 fifo = SMC_GET_FIFO_INT(lp);
480 if (fifo & 0xFF) fifo--; 426 if (fifo & 0xFF) fifo--;
481 DBG(SMC_DEBUG_RX, "%s: Setting RX stat FIFO threshold to %d\n", 427 DBG(SMC_DEBUG_RX, "%s: Setting RX stat FIFO threshold to %d\n",
482 dev->name, fifo & 0xff); 428 dev->name, fifo & 0xff);
483 SMC_SET_FIFO_INT(fifo); 429 SMC_SET_FIFO_INT(lp, fifo);
484 /* Setup RX DMA */ 430 /* Setup RX DMA */
485 SMC_SET_RX_CFG(RX_CFG_RX_END_ALGN16_ | ((2<<8) & RX_CFG_RXDOFF_)); 431 SMC_SET_RX_CFG(lp, RX_CFG_RX_END_ALGN16_ | ((2<<8) & RX_CFG_RXDOFF_));
486 lp->rxdma_active = 1; 432 lp->rxdma_active = 1;
487 lp->current_rx_skb = skb; 433 lp->current_rx_skb = skb;
488 SMC_PULL_DATA(data, (pkt_len+2+15) & ~15); 434 SMC_PULL_DATA(lp, data, (pkt_len+2+15) & ~15);
489 /* Packet processing deferred to DMA RX interrupt */ 435 /* Packet processing deferred to DMA RX interrupt */
490 } 436 }
491#else 437#else
492 SMC_SET_RX_CFG(RX_CFG_RX_END_ALGN4_ | ((2<<8) & RX_CFG_RXDOFF_)); 438 SMC_SET_RX_CFG(lp, RX_CFG_RX_END_ALGN4_ | ((2<<8) & RX_CFG_RXDOFF_));
493 SMC_PULL_DATA(data, pkt_len+2+3); 439 SMC_PULL_DATA(lp, data, pkt_len+2+3);
494 440
495 DBG(SMC_DEBUG_PKTS, "%s: Received packet\n", dev->name); 441 DBG(SMC_DEBUG_PKTS, "%s: Received packet\n", dev->name);
496 PRINT_PKT(data, ((pkt_len - 4) <= 64) ? pkt_len - 4 : 64); 442 PRINT_PKT(data, ((pkt_len - 4) <= 64) ? pkt_len - 4 : 64);
@@ -509,7 +455,6 @@ static inline void smc911x_rcv(struct net_device *dev)
509static void smc911x_hardware_send_pkt(struct net_device *dev) 455static void smc911x_hardware_send_pkt(struct net_device *dev)
510{ 456{
511 struct smc911x_local *lp = netdev_priv(dev); 457 struct smc911x_local *lp = netdev_priv(dev);
512 unsigned long ioaddr = dev->base_addr;
513 struct sk_buff *skb; 458 struct sk_buff *skb;
514 unsigned int cmdA, cmdB, len; 459 unsigned int cmdA, cmdB, len;
515 unsigned char *buf; 460 unsigned char *buf;
@@ -542,8 +487,8 @@ static void smc911x_hardware_send_pkt(struct net_device *dev)
542 487
543 DBG(SMC_DEBUG_TX, "%s: TX PKT LENGTH 0x%04x (%d) BUF 0x%p CMDA 0x%08x CMDB 0x%08x\n", 488 DBG(SMC_DEBUG_TX, "%s: TX PKT LENGTH 0x%04x (%d) BUF 0x%p CMDA 0x%08x CMDB 0x%08x\n",
544 dev->name, len, len, buf, cmdA, cmdB); 489 dev->name, len, len, buf, cmdA, cmdB);
545 SMC_SET_TX_FIFO(cmdA); 490 SMC_SET_TX_FIFO(lp, cmdA);
546 SMC_SET_TX_FIFO(cmdB); 491 SMC_SET_TX_FIFO(lp, cmdB);
547 492
548 DBG(SMC_DEBUG_PKTS, "%s: Transmitted packet\n", dev->name); 493 DBG(SMC_DEBUG_PKTS, "%s: Transmitted packet\n", dev->name);
549 PRINT_PKT(buf, len <= 64 ? len : 64); 494 PRINT_PKT(buf, len <= 64 ? len : 64);
@@ -551,10 +496,10 @@ static void smc911x_hardware_send_pkt(struct net_device *dev)
551 /* Send pkt via PIO or DMA */ 496 /* Send pkt via PIO or DMA */
552#ifdef SMC_USE_DMA 497#ifdef SMC_USE_DMA
553 lp->current_tx_skb = skb; 498 lp->current_tx_skb = skb;
554 SMC_PUSH_DATA(buf, len); 499 SMC_PUSH_DATA(lp, buf, len);
555 /* DMA complete IRQ will free buffer and set jiffies */ 500 /* DMA complete IRQ will free buffer and set jiffies */
556#else 501#else
557 SMC_PUSH_DATA(buf, len); 502 SMC_PUSH_DATA(lp, buf, len);
558 dev->trans_start = jiffies; 503 dev->trans_start = jiffies;
559 dev_kfree_skb(skb); 504 dev_kfree_skb(skb);
560#endif 505#endif
@@ -563,7 +508,7 @@ static void smc911x_hardware_send_pkt(struct net_device *dev)
563 netif_wake_queue(dev); 508 netif_wake_queue(dev);
564 } 509 }
565 spin_unlock_irqrestore(&lp->lock, flags); 510 spin_unlock_irqrestore(&lp->lock, flags);
566 SMC_ENABLE_INT(INT_EN_TDFA_EN_ | INT_EN_TSFL_EN_); 511 SMC_ENABLE_INT(lp, INT_EN_TDFA_EN_ | INT_EN_TSFL_EN_);
567} 512}
568 513
569/* 514/*
@@ -575,7 +520,6 @@ static void smc911x_hardware_send_pkt(struct net_device *dev)
575static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) 520static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
576{ 521{
577 struct smc911x_local *lp = netdev_priv(dev); 522 struct smc911x_local *lp = netdev_priv(dev);
578 unsigned long ioaddr = dev->base_addr;
579 unsigned int free; 523 unsigned int free;
580 unsigned long flags; 524 unsigned long flags;
581 525
@@ -584,7 +528,7 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
584 528
585 BUG_ON(lp->pending_tx_skb != NULL); 529 BUG_ON(lp->pending_tx_skb != NULL);
586 530
587 free = SMC_GET_TX_FIFO_INF() & TX_FIFO_INF_TDFREE_; 531 free = SMC_GET_TX_FIFO_INF(lp) & TX_FIFO_INF_TDFREE_;
588 DBG(SMC_DEBUG_TX, "%s: TX free space %d\n", dev->name, free); 532 DBG(SMC_DEBUG_TX, "%s: TX free space %d\n", dev->name, free);
589 533
590 /* Turn off the flow when running out of space in FIFO */ 534 /* Turn off the flow when running out of space in FIFO */
@@ -593,7 +537,7 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
593 dev->name, free); 537 dev->name, free);
594 spin_lock_irqsave(&lp->lock, flags); 538 spin_lock_irqsave(&lp->lock, flags);
595 /* Reenable when at least 1 packet of size MTU present */ 539 /* Reenable when at least 1 packet of size MTU present */
596 SMC_SET_FIFO_TDA((SMC911X_TX_FIFO_LOW_THRESHOLD)/64); 540 SMC_SET_FIFO_TDA(lp, (SMC911X_TX_FIFO_LOW_THRESHOLD)/64);
597 lp->tx_throttle = 1; 541 lp->tx_throttle = 1;
598 netif_stop_queue(dev); 542 netif_stop_queue(dev);
599 spin_unlock_irqrestore(&lp->lock, flags); 543 spin_unlock_irqrestore(&lp->lock, flags);
@@ -648,7 +592,6 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
648 */ 592 */
649static void smc911x_tx(struct net_device *dev) 593static void smc911x_tx(struct net_device *dev)
650{ 594{
651 unsigned long ioaddr = dev->base_addr;
652 struct smc911x_local *lp = netdev_priv(dev); 595 struct smc911x_local *lp = netdev_priv(dev);
653 unsigned int tx_status; 596 unsigned int tx_status;
654 597
@@ -656,11 +599,11 @@ static void smc911x_tx(struct net_device *dev)
656 dev->name, __FUNCTION__); 599 dev->name, __FUNCTION__);
657 600
658 /* Collect the TX status */ 601 /* Collect the TX status */
659 while (((SMC_GET_TX_FIFO_INF() & TX_FIFO_INF_TSUSED_) >> 16) != 0) { 602 while (((SMC_GET_TX_FIFO_INF(lp) & TX_FIFO_INF_TSUSED_) >> 16) != 0) {
660 DBG(SMC_DEBUG_TX, "%s: Tx stat FIFO used 0x%04x\n", 603 DBG(SMC_DEBUG_TX, "%s: Tx stat FIFO used 0x%04x\n",
661 dev->name, 604 dev->name,
662 (SMC_GET_TX_FIFO_INF() & TX_FIFO_INF_TSUSED_) >> 16); 605 (SMC_GET_TX_FIFO_INF(lp) & TX_FIFO_INF_TSUSED_) >> 16);
663 tx_status = SMC_GET_TX_STS_FIFO(); 606 tx_status = SMC_GET_TX_STS_FIFO(lp);
664 dev->stats.tx_packets++; 607 dev->stats.tx_packets++;
665 dev->stats.tx_bytes+=tx_status>>16; 608 dev->stats.tx_bytes+=tx_status>>16;
666 DBG(SMC_DEBUG_TX, "%s: Tx FIFO tag 0x%04x status 0x%04x\n", 609 DBG(SMC_DEBUG_TX, "%s: Tx FIFO tag 0x%04x status 0x%04x\n",
@@ -698,10 +641,10 @@ static void smc911x_tx(struct net_device *dev)
698 641
699static int smc911x_phy_read(struct net_device *dev, int phyaddr, int phyreg) 642static int smc911x_phy_read(struct net_device *dev, int phyaddr, int phyreg)
700{ 643{
701 unsigned long ioaddr = dev->base_addr; 644 struct smc911x_local *lp = netdev_priv(dev);
702 unsigned int phydata; 645 unsigned int phydata;
703 646
704 SMC_GET_MII(phyreg, phyaddr, phydata); 647 SMC_GET_MII(lp, phyreg, phyaddr, phydata);
705 648
706 DBG(SMC_DEBUG_MISC, "%s: phyaddr=0x%x, phyreg=0x%02x, phydata=0x%04x\n", 649 DBG(SMC_DEBUG_MISC, "%s: phyaddr=0x%x, phyreg=0x%02x, phydata=0x%04x\n",
707 __FUNCTION__, phyaddr, phyreg, phydata); 650 __FUNCTION__, phyaddr, phyreg, phydata);
@@ -715,12 +658,12 @@ static int smc911x_phy_read(struct net_device *dev, int phyaddr, int phyreg)
715static void smc911x_phy_write(struct net_device *dev, int phyaddr, int phyreg, 658static void smc911x_phy_write(struct net_device *dev, int phyaddr, int phyreg,
716 int phydata) 659 int phydata)
717{ 660{
718 unsigned long ioaddr = dev->base_addr; 661 struct smc911x_local *lp = netdev_priv(dev);
719 662
720 DBG(SMC_DEBUG_MISC, "%s: phyaddr=0x%x, phyreg=0x%x, phydata=0x%x\n", 663 DBG(SMC_DEBUG_MISC, "%s: phyaddr=0x%x, phyreg=0x%x, phydata=0x%x\n",
721 __FUNCTION__, phyaddr, phyreg, phydata); 664 __FUNCTION__, phyaddr, phyreg, phydata);
722 665
723 SMC_SET_MII(phyreg, phyaddr, phydata); 666 SMC_SET_MII(lp, phyreg, phyaddr, phydata);
724} 667}
725 668
726/* 669/*
@@ -729,7 +672,6 @@ static void smc911x_phy_write(struct net_device *dev, int phyaddr, int phyreg,
729 */ 672 */
730static void smc911x_phy_detect(struct net_device *dev) 673static void smc911x_phy_detect(struct net_device *dev)
731{ 674{
732 unsigned long ioaddr = dev->base_addr;
733 struct smc911x_local *lp = netdev_priv(dev); 675 struct smc911x_local *lp = netdev_priv(dev);
734 int phyaddr; 676 int phyaddr;
735 unsigned int cfg, id1, id2; 677 unsigned int cfg, id1, id2;
@@ -745,30 +687,30 @@ static void smc911x_phy_detect(struct net_device *dev)
745 switch(lp->version) { 687 switch(lp->version) {
746 case 0x115: 688 case 0x115:
747 case 0x117: 689 case 0x117:
748 cfg = SMC_GET_HW_CFG(); 690 cfg = SMC_GET_HW_CFG(lp);
749 if (cfg & HW_CFG_EXT_PHY_DET_) { 691 if (cfg & HW_CFG_EXT_PHY_DET_) {
750 cfg &= ~HW_CFG_PHY_CLK_SEL_; 692 cfg &= ~HW_CFG_PHY_CLK_SEL_;
751 cfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS_; 693 cfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS_;
752 SMC_SET_HW_CFG(cfg); 694 SMC_SET_HW_CFG(lp, cfg);
753 udelay(10); /* Wait for clocks to stop */ 695 udelay(10); /* Wait for clocks to stop */
754 696
755 cfg |= HW_CFG_EXT_PHY_EN_; 697 cfg |= HW_CFG_EXT_PHY_EN_;
756 SMC_SET_HW_CFG(cfg); 698 SMC_SET_HW_CFG(lp, cfg);
757 udelay(10); /* Wait for clocks to stop */ 699 udelay(10); /* Wait for clocks to stop */
758 700
759 cfg &= ~HW_CFG_PHY_CLK_SEL_; 701 cfg &= ~HW_CFG_PHY_CLK_SEL_;
760 cfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY_; 702 cfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY_;
761 SMC_SET_HW_CFG(cfg); 703 SMC_SET_HW_CFG(lp, cfg);
762 udelay(10); /* Wait for clocks to stop */ 704 udelay(10); /* Wait for clocks to stop */
763 705
764 cfg |= HW_CFG_SMI_SEL_; 706 cfg |= HW_CFG_SMI_SEL_;
765 SMC_SET_HW_CFG(cfg); 707 SMC_SET_HW_CFG(lp, cfg);
766 708
767 for (phyaddr = 1; phyaddr < 32; ++phyaddr) { 709 for (phyaddr = 1; phyaddr < 32; ++phyaddr) {
768 710
769 /* Read the PHY identifiers */ 711 /* Read the PHY identifiers */
770 SMC_GET_PHY_ID1(phyaddr & 31, id1); 712 SMC_GET_PHY_ID1(lp, phyaddr & 31, id1);
771 SMC_GET_PHY_ID2(phyaddr & 31, id2); 713 SMC_GET_PHY_ID2(lp, phyaddr & 31, id2);
772 714
773 /* Make sure it is a valid identifier */ 715 /* Make sure it is a valid identifier */
774 if (id1 != 0x0000 && id1 != 0xffff && 716 if (id1 != 0x0000 && id1 != 0xffff &&
@@ -783,8 +725,8 @@ static void smc911x_phy_detect(struct net_device *dev)
783 } 725 }
784 default: 726 default:
785 /* Internal media only */ 727 /* Internal media only */
786 SMC_GET_PHY_ID1(1, id1); 728 SMC_GET_PHY_ID1(lp, 1, id1);
787 SMC_GET_PHY_ID2(1, id2); 729 SMC_GET_PHY_ID2(lp, 1, id2);
788 /* Save the PHY's address */ 730 /* Save the PHY's address */
789 lp->mii.phy_id = 1; 731 lp->mii.phy_id = 1;
790 lp->phy_type = id1 << 16 | id2; 732 lp->phy_type = id1 << 16 | id2;
@@ -801,16 +743,15 @@ static void smc911x_phy_detect(struct net_device *dev)
801static int smc911x_phy_fixed(struct net_device *dev) 743static int smc911x_phy_fixed(struct net_device *dev)
802{ 744{
803 struct smc911x_local *lp = netdev_priv(dev); 745 struct smc911x_local *lp = netdev_priv(dev);
804 unsigned long ioaddr = dev->base_addr;
805 int phyaddr = lp->mii.phy_id; 746 int phyaddr = lp->mii.phy_id;
806 int bmcr; 747 int bmcr;
807 748
808 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); 749 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
809 750
810 /* Enter Link Disable state */ 751 /* Enter Link Disable state */
811 SMC_GET_PHY_BMCR(phyaddr, bmcr); 752 SMC_GET_PHY_BMCR(lp, phyaddr, bmcr);
812 bmcr |= BMCR_PDOWN; 753 bmcr |= BMCR_PDOWN;
813 SMC_SET_PHY_BMCR(phyaddr, bmcr); 754 SMC_SET_PHY_BMCR(lp, phyaddr, bmcr);
814 755
815 /* 756 /*
816 * Set our fixed capabilities 757 * Set our fixed capabilities
@@ -824,11 +765,11 @@ static int smc911x_phy_fixed(struct net_device *dev)
824 bmcr |= BMCR_SPEED100; 765 bmcr |= BMCR_SPEED100;
825 766
826 /* Write our capabilities to the phy control register */ 767 /* Write our capabilities to the phy control register */
827 SMC_SET_PHY_BMCR(phyaddr, bmcr); 768 SMC_SET_PHY_BMCR(lp, phyaddr, bmcr);
828 769
829 /* Re-Configure the Receive/Phy Control register */ 770 /* Re-Configure the Receive/Phy Control register */
830 bmcr &= ~BMCR_PDOWN; 771 bmcr &= ~BMCR_PDOWN;
831 SMC_SET_PHY_BMCR(phyaddr, bmcr); 772 SMC_SET_PHY_BMCR(lp, phyaddr, bmcr);
832 773
833 return 1; 774 return 1;
834} 775}
@@ -848,7 +789,6 @@ static int smc911x_phy_fixed(struct net_device *dev)
848static int smc911x_phy_reset(struct net_device *dev, int phy) 789static int smc911x_phy_reset(struct net_device *dev, int phy)
849{ 790{
850 struct smc911x_local *lp = netdev_priv(dev); 791 struct smc911x_local *lp = netdev_priv(dev);
851 unsigned long ioaddr = dev->base_addr;
852 int timeout; 792 int timeout;
853 unsigned long flags; 793 unsigned long flags;
854 unsigned int reg; 794 unsigned int reg;
@@ -856,15 +796,15 @@ static int smc911x_phy_reset(struct net_device *dev, int phy)
856 DBG(SMC_DEBUG_FUNC, "%s: --> %s()\n", dev->name, __FUNCTION__); 796 DBG(SMC_DEBUG_FUNC, "%s: --> %s()\n", dev->name, __FUNCTION__);
857 797
858 spin_lock_irqsave(&lp->lock, flags); 798 spin_lock_irqsave(&lp->lock, flags);
859 reg = SMC_GET_PMT_CTRL(); 799 reg = SMC_GET_PMT_CTRL(lp);
860 reg &= ~0xfffff030; 800 reg &= ~0xfffff030;
861 reg |= PMT_CTRL_PHY_RST_; 801 reg |= PMT_CTRL_PHY_RST_;
862 SMC_SET_PMT_CTRL(reg); 802 SMC_SET_PMT_CTRL(lp, reg);
863 spin_unlock_irqrestore(&lp->lock, flags); 803 spin_unlock_irqrestore(&lp->lock, flags);
864 for (timeout = 2; timeout; timeout--) { 804 for (timeout = 2; timeout; timeout--) {
865 msleep(50); 805 msleep(50);
866 spin_lock_irqsave(&lp->lock, flags); 806 spin_lock_irqsave(&lp->lock, flags);
867 reg = SMC_GET_PMT_CTRL(); 807 reg = SMC_GET_PMT_CTRL(lp);
868 spin_unlock_irqrestore(&lp->lock, flags); 808 spin_unlock_irqrestore(&lp->lock, flags);
869 if (!(reg & PMT_CTRL_PHY_RST_)) { 809 if (!(reg & PMT_CTRL_PHY_RST_)) {
870 /* extra delay required because the phy may 810 /* extra delay required because the phy may
@@ -889,13 +829,13 @@ static int smc911x_phy_reset(struct net_device *dev, int phy)
889 */ 829 */
890static void smc911x_phy_powerdown(struct net_device *dev, int phy) 830static void smc911x_phy_powerdown(struct net_device *dev, int phy)
891{ 831{
892 unsigned long ioaddr = dev->base_addr; 832 struct smc911x_local *lp = netdev_priv(dev);
893 unsigned int bmcr; 833 unsigned int bmcr;
894 834
895 /* Enter Link Disable state */ 835 /* Enter Link Disable state */
896 SMC_GET_PHY_BMCR(phy, bmcr); 836 SMC_GET_PHY_BMCR(lp, phy, bmcr);
897 bmcr |= BMCR_PDOWN; 837 bmcr |= BMCR_PDOWN;
898 SMC_SET_PHY_BMCR(phy, bmcr); 838 SMC_SET_PHY_BMCR(lp, phy, bmcr);
899} 839}
900 840
901/* 841/*
@@ -909,7 +849,6 @@ static void smc911x_phy_powerdown(struct net_device *dev, int phy)
909static void smc911x_phy_check_media(struct net_device *dev, int init) 849static void smc911x_phy_check_media(struct net_device *dev, int init)
910{ 850{
911 struct smc911x_local *lp = netdev_priv(dev); 851 struct smc911x_local *lp = netdev_priv(dev);
912 unsigned long ioaddr = dev->base_addr;
913 int phyaddr = lp->mii.phy_id; 852 int phyaddr = lp->mii.phy_id;
914 unsigned int bmcr, cr; 853 unsigned int bmcr, cr;
915 854
@@ -917,8 +856,8 @@ static void smc911x_phy_check_media(struct net_device *dev, int init)
917 856
918 if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) { 857 if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) {
919 /* duplex state has changed */ 858 /* duplex state has changed */
920 SMC_GET_PHY_BMCR(phyaddr, bmcr); 859 SMC_GET_PHY_BMCR(lp, phyaddr, bmcr);
921 SMC_GET_MAC_CR(cr); 860 SMC_GET_MAC_CR(lp, cr);
922 if (lp->mii.full_duplex) { 861 if (lp->mii.full_duplex) {
923 DBG(SMC_DEBUG_MISC, "%s: Configuring for full-duplex mode\n", dev->name); 862 DBG(SMC_DEBUG_MISC, "%s: Configuring for full-duplex mode\n", dev->name);
924 bmcr |= BMCR_FULLDPLX; 863 bmcr |= BMCR_FULLDPLX;
@@ -928,8 +867,8 @@ static void smc911x_phy_check_media(struct net_device *dev, int init)
928 bmcr &= ~BMCR_FULLDPLX; 867 bmcr &= ~BMCR_FULLDPLX;
929 cr &= ~MAC_CR_RCVOWN_; 868 cr &= ~MAC_CR_RCVOWN_;
930 } 869 }
931 SMC_SET_PHY_BMCR(phyaddr, bmcr); 870 SMC_SET_PHY_BMCR(lp, phyaddr, bmcr);
932 SMC_SET_MAC_CR(cr); 871 SMC_SET_MAC_CR(lp, cr);
933 } 872 }
934} 873}
935 874
@@ -947,7 +886,6 @@ static void smc911x_phy_configure(struct work_struct *work)
947 struct smc911x_local *lp = container_of(work, struct smc911x_local, 886 struct smc911x_local *lp = container_of(work, struct smc911x_local,
948 phy_configure); 887 phy_configure);
949 struct net_device *dev = lp->netdev; 888 struct net_device *dev = lp->netdev;
950 unsigned long ioaddr = dev->base_addr;
951 int phyaddr = lp->mii.phy_id; 889 int phyaddr = lp->mii.phy_id;
952 int my_phy_caps; /* My PHY capabilities */ 890 int my_phy_caps; /* My PHY capabilities */
953 int my_ad_caps; /* My Advertised capabilities */ 891 int my_ad_caps; /* My Advertised capabilities */
@@ -972,7 +910,7 @@ static void smc911x_phy_configure(struct work_struct *work)
972 * Enable PHY Interrupts (for register 18) 910 * Enable PHY Interrupts (for register 18)
973 * Interrupts listed here are enabled 911 * Interrupts listed here are enabled
974 */ 912 */
975 SMC_SET_PHY_INT_MASK(phyaddr, PHY_INT_MASK_ENERGY_ON_ | 913 SMC_SET_PHY_INT_MASK(lp, phyaddr, PHY_INT_MASK_ENERGY_ON_ |
976 PHY_INT_MASK_ANEG_COMP_ | PHY_INT_MASK_REMOTE_FAULT_ | 914 PHY_INT_MASK_ANEG_COMP_ | PHY_INT_MASK_REMOTE_FAULT_ |
977 PHY_INT_MASK_LINK_DOWN_); 915 PHY_INT_MASK_LINK_DOWN_);
978 916
@@ -983,7 +921,7 @@ static void smc911x_phy_configure(struct work_struct *work)
983 } 921 }
984 922
985 /* Copy our capabilities from MII_BMSR to MII_ADVERTISE */ 923 /* Copy our capabilities from MII_BMSR to MII_ADVERTISE */
986 SMC_GET_PHY_BMSR(phyaddr, my_phy_caps); 924 SMC_GET_PHY_BMSR(lp, phyaddr, my_phy_caps);
987 if (!(my_phy_caps & BMSR_ANEGCAPABLE)) { 925 if (!(my_phy_caps & BMSR_ANEGCAPABLE)) {
988 printk(KERN_INFO "Auto negotiation NOT supported\n"); 926 printk(KERN_INFO "Auto negotiation NOT supported\n");
989 smc911x_phy_fixed(dev); 927 smc911x_phy_fixed(dev);
@@ -1012,7 +950,7 @@ static void smc911x_phy_configure(struct work_struct *work)
1012 my_ad_caps &= ~(ADVERTISE_100FULL|ADVERTISE_10FULL); 950 my_ad_caps &= ~(ADVERTISE_100FULL|ADVERTISE_10FULL);
1013 951
1014 /* Update our Auto-Neg Advertisement Register */ 952 /* Update our Auto-Neg Advertisement Register */
1015 SMC_SET_PHY_MII_ADV(phyaddr, my_ad_caps); 953 SMC_SET_PHY_MII_ADV(lp, phyaddr, my_ad_caps);
1016 lp->mii.advertising = my_ad_caps; 954 lp->mii.advertising = my_ad_caps;
1017 955
1018 /* 956 /*
@@ -1021,13 +959,13 @@ static void smc911x_phy_configure(struct work_struct *work)
1021 * the link does not come up. 959 * the link does not come up.
1022 */ 960 */
1023 udelay(10); 961 udelay(10);
1024 SMC_GET_PHY_MII_ADV(phyaddr, status); 962 SMC_GET_PHY_MII_ADV(lp, phyaddr, status);
1025 963
1026 DBG(SMC_DEBUG_MISC, "%s: phy caps=0x%04x\n", dev->name, my_phy_caps); 964 DBG(SMC_DEBUG_MISC, "%s: phy caps=0x%04x\n", dev->name, my_phy_caps);
1027 DBG(SMC_DEBUG_MISC, "%s: phy advertised caps=0x%04x\n", dev->name, my_ad_caps); 965 DBG(SMC_DEBUG_MISC, "%s: phy advertised caps=0x%04x\n", dev->name, my_ad_caps);
1028 966
1029 /* Restart auto-negotiation process in order to advertise my caps */ 967 /* Restart auto-negotiation process in order to advertise my caps */
1030 SMC_SET_PHY_BMCR(phyaddr, BMCR_ANENABLE | BMCR_ANRESTART); 968 SMC_SET_PHY_BMCR(lp, phyaddr, BMCR_ANENABLE | BMCR_ANRESTART);
1031 969
1032 smc911x_phy_check_media(dev, 1); 970 smc911x_phy_check_media(dev, 1);
1033 971
@@ -1046,7 +984,6 @@ smc911x_phy_configure_exit_nolock:
1046static void smc911x_phy_interrupt(struct net_device *dev) 984static void smc911x_phy_interrupt(struct net_device *dev)
1047{ 985{
1048 struct smc911x_local *lp = netdev_priv(dev); 986 struct smc911x_local *lp = netdev_priv(dev);
1049 unsigned long ioaddr = dev->base_addr;
1050 int phyaddr = lp->mii.phy_id; 987 int phyaddr = lp->mii.phy_id;
1051 int status; 988 int status;
1052 989
@@ -1057,11 +994,11 @@ static void smc911x_phy_interrupt(struct net_device *dev)
1057 994
1058 smc911x_phy_check_media(dev, 0); 995 smc911x_phy_check_media(dev, 0);
1059 /* read to clear status bits */ 996 /* read to clear status bits */
1060 SMC_GET_PHY_INT_SRC(phyaddr,status); 997 SMC_GET_PHY_INT_SRC(lp, phyaddr,status);
1061 DBG(SMC_DEBUG_MISC, "%s: PHY interrupt status 0x%04x\n", 998 DBG(SMC_DEBUG_MISC, "%s: PHY interrupt status 0x%04x\n",
1062 dev->name, status & 0xffff); 999 dev->name, status & 0xffff);
1063 DBG(SMC_DEBUG_MISC, "%s: AFC_CFG 0x%08x\n", 1000 DBG(SMC_DEBUG_MISC, "%s: AFC_CFG 0x%08x\n",
1064 dev->name, SMC_GET_AFC_CFG()); 1001 dev->name, SMC_GET_AFC_CFG(lp));
1065} 1002}
1066 1003
1067/*--- END PHY CONTROL AND CONFIGURATION-------------------------------------*/ 1004/*--- END PHY CONTROL AND CONFIGURATION-------------------------------------*/
@@ -1073,7 +1010,6 @@ static void smc911x_phy_interrupt(struct net_device *dev)
1073static irqreturn_t smc911x_interrupt(int irq, void *dev_id) 1010static irqreturn_t smc911x_interrupt(int irq, void *dev_id)
1074{ 1011{
1075 struct net_device *dev = dev_id; 1012 struct net_device *dev = dev_id;
1076 unsigned long ioaddr = dev->base_addr;
1077 struct smc911x_local *lp = netdev_priv(dev); 1013 struct smc911x_local *lp = netdev_priv(dev);
1078 unsigned int status, mask, timeout; 1014 unsigned int status, mask, timeout;
1079 unsigned int rx_overrun=0, cr, pkts; 1015 unsigned int rx_overrun=0, cr, pkts;
@@ -1084,21 +1020,21 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id)
1084 spin_lock_irqsave(&lp->lock, flags); 1020 spin_lock_irqsave(&lp->lock, flags);
1085 1021
1086 /* Spurious interrupt check */ 1022 /* Spurious interrupt check */
1087 if ((SMC_GET_IRQ_CFG() & (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) != 1023 if ((SMC_GET_IRQ_CFG(lp) & (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) !=
1088 (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) { 1024 (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) {
1089 spin_unlock_irqrestore(&lp->lock, flags); 1025 spin_unlock_irqrestore(&lp->lock, flags);
1090 return IRQ_NONE; 1026 return IRQ_NONE;
1091 } 1027 }
1092 1028
1093 mask = SMC_GET_INT_EN(); 1029 mask = SMC_GET_INT_EN(lp);
1094 SMC_SET_INT_EN(0); 1030 SMC_SET_INT_EN(lp, 0);
1095 1031
1096 /* set a timeout value, so I don't stay here forever */ 1032 /* set a timeout value, so I don't stay here forever */
1097 timeout = 8; 1033 timeout = 8;
1098 1034
1099 1035
1100 do { 1036 do {
1101 status = SMC_GET_INT(); 1037 status = SMC_GET_INT(lp);
1102 1038
1103 DBG(SMC_DEBUG_MISC, "%s: INT 0x%08x MASK 0x%08x OUTSIDE MASK 0x%08x\n", 1039 DBG(SMC_DEBUG_MISC, "%s: INT 0x%08x MASK 0x%08x OUTSIDE MASK 0x%08x\n",
1104 dev->name, status, mask, status & ~mask); 1040 dev->name, status, mask, status & ~mask);
@@ -1109,53 +1045,53 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id)
1109 1045
1110 /* Handle SW interrupt condition */ 1046 /* Handle SW interrupt condition */
1111 if (status & INT_STS_SW_INT_) { 1047 if (status & INT_STS_SW_INT_) {
1112 SMC_ACK_INT(INT_STS_SW_INT_); 1048 SMC_ACK_INT(lp, INT_STS_SW_INT_);
1113 mask &= ~INT_EN_SW_INT_EN_; 1049 mask &= ~INT_EN_SW_INT_EN_;
1114 } 1050 }
1115 /* Handle various error conditions */ 1051 /* Handle various error conditions */
1116 if (status & INT_STS_RXE_) { 1052 if (status & INT_STS_RXE_) {
1117 SMC_ACK_INT(INT_STS_RXE_); 1053 SMC_ACK_INT(lp, INT_STS_RXE_);
1118 dev->stats.rx_errors++; 1054 dev->stats.rx_errors++;
1119 } 1055 }
1120 if (status & INT_STS_RXDFH_INT_) { 1056 if (status & INT_STS_RXDFH_INT_) {
1121 SMC_ACK_INT(INT_STS_RXDFH_INT_); 1057 SMC_ACK_INT(lp, INT_STS_RXDFH_INT_);
1122 dev->stats.rx_dropped+=SMC_GET_RX_DROP(); 1058 dev->stats.rx_dropped+=SMC_GET_RX_DROP(lp);
1123 } 1059 }
1124 /* Undocumented interrupt-what is the right thing to do here? */ 1060 /* Undocumented interrupt-what is the right thing to do here? */
1125 if (status & INT_STS_RXDF_INT_) { 1061 if (status & INT_STS_RXDF_INT_) {
1126 SMC_ACK_INT(INT_STS_RXDF_INT_); 1062 SMC_ACK_INT(lp, INT_STS_RXDF_INT_);
1127 } 1063 }
1128 1064
1129 /* Rx Data FIFO exceeds set level */ 1065 /* Rx Data FIFO exceeds set level */
1130 if (status & INT_STS_RDFL_) { 1066 if (status & INT_STS_RDFL_) {
1131 if (IS_REV_A(lp->revision)) { 1067 if (IS_REV_A(lp->revision)) {
1132 rx_overrun=1; 1068 rx_overrun=1;
1133 SMC_GET_MAC_CR(cr); 1069 SMC_GET_MAC_CR(lp, cr);
1134 cr &= ~MAC_CR_RXEN_; 1070 cr &= ~MAC_CR_RXEN_;
1135 SMC_SET_MAC_CR(cr); 1071 SMC_SET_MAC_CR(lp, cr);
1136 DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name); 1072 DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name);
1137 dev->stats.rx_errors++; 1073 dev->stats.rx_errors++;
1138 dev->stats.rx_fifo_errors++; 1074 dev->stats.rx_fifo_errors++;
1139 } 1075 }
1140 SMC_ACK_INT(INT_STS_RDFL_); 1076 SMC_ACK_INT(lp, INT_STS_RDFL_);
1141 } 1077 }
1142 if (status & INT_STS_RDFO_) { 1078 if (status & INT_STS_RDFO_) {
1143 if (!IS_REV_A(lp->revision)) { 1079 if (!IS_REV_A(lp->revision)) {
1144 SMC_GET_MAC_CR(cr); 1080 SMC_GET_MAC_CR(lp, cr);
1145 cr &= ~MAC_CR_RXEN_; 1081 cr &= ~MAC_CR_RXEN_;
1146 SMC_SET_MAC_CR(cr); 1082 SMC_SET_MAC_CR(lp, cr);
1147 rx_overrun=1; 1083 rx_overrun=1;
1148 DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name); 1084 DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name);
1149 dev->stats.rx_errors++; 1085 dev->stats.rx_errors++;
1150 dev->stats.rx_fifo_errors++; 1086 dev->stats.rx_fifo_errors++;
1151 } 1087 }
1152 SMC_ACK_INT(INT_STS_RDFO_); 1088 SMC_ACK_INT(lp, INT_STS_RDFO_);
1153 } 1089 }
1154 /* Handle receive condition */ 1090 /* Handle receive condition */
1155 if ((status & INT_STS_RSFL_) || rx_overrun) { 1091 if ((status & INT_STS_RSFL_) || rx_overrun) {
1156 unsigned int fifo; 1092 unsigned int fifo;
1157 DBG(SMC_DEBUG_RX, "%s: RX irq\n", dev->name); 1093 DBG(SMC_DEBUG_RX, "%s: RX irq\n", dev->name);
1158 fifo = SMC_GET_RX_FIFO_INF(); 1094 fifo = SMC_GET_RX_FIFO_INF(lp);
1159 pkts = (fifo & RX_FIFO_INF_RXSUSED_) >> 16; 1095 pkts = (fifo & RX_FIFO_INF_RXSUSED_) >> 16;
1160 DBG(SMC_DEBUG_RX, "%s: Rx FIFO pkts %d, bytes %d\n", 1096 DBG(SMC_DEBUG_RX, "%s: Rx FIFO pkts %d, bytes %d\n",
1161 dev->name, pkts, fifo & 0xFFFF ); 1097 dev->name, pkts, fifo & 0xFFFF );
@@ -1166,61 +1102,61 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id)
1166 DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, 1102 DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA,
1167 "%s: RX DMA active\n", dev->name); 1103 "%s: RX DMA active\n", dev->name);
1168 /* The DMA is already running so up the IRQ threshold */ 1104 /* The DMA is already running so up the IRQ threshold */
1169 fifo = SMC_GET_FIFO_INT() & ~0xFF; 1105 fifo = SMC_GET_FIFO_INT(lp) & ~0xFF;
1170 fifo |= pkts & 0xFF; 1106 fifo |= pkts & 0xFF;
1171 DBG(SMC_DEBUG_RX, 1107 DBG(SMC_DEBUG_RX,
1172 "%s: Setting RX stat FIFO threshold to %d\n", 1108 "%s: Setting RX stat FIFO threshold to %d\n",
1173 dev->name, fifo & 0xff); 1109 dev->name, fifo & 0xff);
1174 SMC_SET_FIFO_INT(fifo); 1110 SMC_SET_FIFO_INT(lp, fifo);
1175 } else 1111 } else
1176#endif 1112#endif
1177 smc911x_rcv(dev); 1113 smc911x_rcv(dev);
1178 } 1114 }
1179 SMC_ACK_INT(INT_STS_RSFL_); 1115 SMC_ACK_INT(lp, INT_STS_RSFL_);
1180 } 1116 }
1181 /* Handle transmit FIFO available */ 1117 /* Handle transmit FIFO available */
1182 if (status & INT_STS_TDFA_) { 1118 if (status & INT_STS_TDFA_) {
1183 DBG(SMC_DEBUG_TX, "%s: TX data FIFO space available irq\n", dev->name); 1119 DBG(SMC_DEBUG_TX, "%s: TX data FIFO space available irq\n", dev->name);
1184 SMC_SET_FIFO_TDA(0xFF); 1120 SMC_SET_FIFO_TDA(lp, 0xFF);
1185 lp->tx_throttle = 0; 1121 lp->tx_throttle = 0;
1186#ifdef SMC_USE_DMA 1122#ifdef SMC_USE_DMA
1187 if (!lp->txdma_active) 1123 if (!lp->txdma_active)
1188#endif 1124#endif
1189 netif_wake_queue(dev); 1125 netif_wake_queue(dev);
1190 SMC_ACK_INT(INT_STS_TDFA_); 1126 SMC_ACK_INT(lp, INT_STS_TDFA_);
1191 } 1127 }
1192 /* Handle transmit done condition */ 1128 /* Handle transmit done condition */
1193#if 1 1129#if 1
1194 if (status & (INT_STS_TSFL_ | INT_STS_GPT_INT_)) { 1130 if (status & (INT_STS_TSFL_ | INT_STS_GPT_INT_)) {
1195 DBG(SMC_DEBUG_TX | SMC_DEBUG_MISC, 1131 DBG(SMC_DEBUG_TX | SMC_DEBUG_MISC,
1196 "%s: Tx stat FIFO limit (%d) /GPT irq\n", 1132 "%s: Tx stat FIFO limit (%d) /GPT irq\n",
1197 dev->name, (SMC_GET_FIFO_INT() & 0x00ff0000) >> 16); 1133 dev->name, (SMC_GET_FIFO_INT(lp) & 0x00ff0000) >> 16);
1198 smc911x_tx(dev); 1134 smc911x_tx(dev);
1199 SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000); 1135 SMC_SET_GPT_CFG(lp, GPT_CFG_TIMER_EN_ | 10000);
1200 SMC_ACK_INT(INT_STS_TSFL_); 1136 SMC_ACK_INT(lp, INT_STS_TSFL_);
1201 SMC_ACK_INT(INT_STS_TSFL_ | INT_STS_GPT_INT_); 1137 SMC_ACK_INT(lp, INT_STS_TSFL_ | INT_STS_GPT_INT_);
1202 } 1138 }
1203#else 1139#else
1204 if (status & INT_STS_TSFL_) { 1140 if (status & INT_STS_TSFL_) {
1205 DBG(SMC_DEBUG_TX, "%s: TX status FIFO limit (%d) irq \n", dev->name, ); 1141 DBG(SMC_DEBUG_TX, "%s: TX status FIFO limit (%d) irq \n", dev->name, );
1206 smc911x_tx(dev); 1142 smc911x_tx(dev);
1207 SMC_ACK_INT(INT_STS_TSFL_); 1143 SMC_ACK_INT(lp, INT_STS_TSFL_);
1208 } 1144 }
1209 1145
1210 if (status & INT_STS_GPT_INT_) { 1146 if (status & INT_STS_GPT_INT_) {
1211 DBG(SMC_DEBUG_RX, "%s: IRQ_CFG 0x%08x FIFO_INT 0x%08x RX_CFG 0x%08x\n", 1147 DBG(SMC_DEBUG_RX, "%s: IRQ_CFG 0x%08x FIFO_INT 0x%08x RX_CFG 0x%08x\n",
1212 dev->name, 1148 dev->name,
1213 SMC_GET_IRQ_CFG(), 1149 SMC_GET_IRQ_CFG(lp),
1214 SMC_GET_FIFO_INT(), 1150 SMC_GET_FIFO_INT(lp),
1215 SMC_GET_RX_CFG()); 1151 SMC_GET_RX_CFG(lp));
1216 DBG(SMC_DEBUG_RX, "%s: Rx Stat FIFO Used 0x%02x " 1152 DBG(SMC_DEBUG_RX, "%s: Rx Stat FIFO Used 0x%02x "
1217 "Data FIFO Used 0x%04x Stat FIFO 0x%08x\n", 1153 "Data FIFO Used 0x%04x Stat FIFO 0x%08x\n",
1218 dev->name, 1154 dev->name,
1219 (SMC_GET_RX_FIFO_INF() & 0x00ff0000) >> 16, 1155 (SMC_GET_RX_FIFO_INF(lp) & 0x00ff0000) >> 16,
1220 SMC_GET_RX_FIFO_INF() & 0xffff, 1156 SMC_GET_RX_FIFO_INF(lp) & 0xffff,
1221 SMC_GET_RX_STS_FIFO_PEEK()); 1157 SMC_GET_RX_STS_FIFO_PEEK(lp));
1222 SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000); 1158 SMC_SET_GPT_CFG(lp, GPT_CFG_TIMER_EN_ | 10000);
1223 SMC_ACK_INT(INT_STS_GPT_INT_); 1159 SMC_ACK_INT(lp, INT_STS_GPT_INT_);
1224 } 1160 }
1225#endif 1161#endif
1226 1162
@@ -1228,12 +1164,12 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id)
1228 if (status & INT_STS_PHY_INT_) { 1164 if (status & INT_STS_PHY_INT_) {
1229 DBG(SMC_DEBUG_MISC, "%s: PHY irq\n", dev->name); 1165 DBG(SMC_DEBUG_MISC, "%s: PHY irq\n", dev->name);
1230 smc911x_phy_interrupt(dev); 1166 smc911x_phy_interrupt(dev);
1231 SMC_ACK_INT(INT_STS_PHY_INT_); 1167 SMC_ACK_INT(lp, INT_STS_PHY_INT_);
1232 } 1168 }
1233 } while (--timeout); 1169 } while (--timeout);
1234 1170
1235 /* restore mask state */ 1171 /* restore mask state */
1236 SMC_SET_INT_EN(mask); 1172 SMC_SET_INT_EN(lp, mask);
1237 1173
1238 DBG(SMC_DEBUG_MISC, "%s: Interrupt done (%d loops)\n", 1174 DBG(SMC_DEBUG_MISC, "%s: Interrupt done (%d loops)\n",
1239 dev->name, 8-timeout); 1175 dev->name, 8-timeout);
@@ -1335,22 +1271,21 @@ static void smc911x_poll_controller(struct net_device *dev)
1335static void smc911x_timeout(struct net_device *dev) 1271static void smc911x_timeout(struct net_device *dev)
1336{ 1272{
1337 struct smc911x_local *lp = netdev_priv(dev); 1273 struct smc911x_local *lp = netdev_priv(dev);
1338 unsigned long ioaddr = dev->base_addr;
1339 int status, mask; 1274 int status, mask;
1340 unsigned long flags; 1275 unsigned long flags;
1341 1276
1342 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); 1277 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1343 1278
1344 spin_lock_irqsave(&lp->lock, flags); 1279 spin_lock_irqsave(&lp->lock, flags);
1345 status = SMC_GET_INT(); 1280 status = SMC_GET_INT(lp);
1346 mask = SMC_GET_INT_EN(); 1281 mask = SMC_GET_INT_EN(lp);
1347 spin_unlock_irqrestore(&lp->lock, flags); 1282 spin_unlock_irqrestore(&lp->lock, flags);
1348 DBG(SMC_DEBUG_MISC, "%s: INT 0x%02x MASK 0x%02x \n", 1283 DBG(SMC_DEBUG_MISC, "%s: INT 0x%02x MASK 0x%02x \n",
1349 dev->name, status, mask); 1284 dev->name, status, mask);
1350 1285
1351 /* Dump the current TX FIFO contents and restart */ 1286 /* Dump the current TX FIFO contents and restart */
1352 mask = SMC_GET_TX_CFG(); 1287 mask = SMC_GET_TX_CFG(lp);
1353 SMC_SET_TX_CFG(mask | TX_CFG_TXS_DUMP_ | TX_CFG_TXD_DUMP_); 1288 SMC_SET_TX_CFG(lp, mask | TX_CFG_TXS_DUMP_ | TX_CFG_TXD_DUMP_);
1354 /* 1289 /*
1355 * Reconfiguring the PHY doesn't seem like a bad idea here, but 1290 * Reconfiguring the PHY doesn't seem like a bad idea here, but
1356 * smc911x_phy_configure() calls msleep() which calls schedule_timeout() 1291 * smc911x_phy_configure() calls msleep() which calls schedule_timeout()
@@ -1376,7 +1311,6 @@ static void smc911x_timeout(struct net_device *dev)
1376static void smc911x_set_multicast_list(struct net_device *dev) 1311static void smc911x_set_multicast_list(struct net_device *dev)
1377{ 1312{
1378 struct smc911x_local *lp = netdev_priv(dev); 1313 struct smc911x_local *lp = netdev_priv(dev);
1379 unsigned long ioaddr = dev->base_addr;
1380 unsigned int multicast_table[2]; 1314 unsigned int multicast_table[2];
1381 unsigned int mcr, update_multicast = 0; 1315 unsigned int mcr, update_multicast = 0;
1382 unsigned long flags; 1316 unsigned long flags;
@@ -1384,7 +1318,7 @@ static void smc911x_set_multicast_list(struct net_device *dev)
1384 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); 1318 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1385 1319
1386 spin_lock_irqsave(&lp->lock, flags); 1320 spin_lock_irqsave(&lp->lock, flags);
1387 SMC_GET_MAC_CR(mcr); 1321 SMC_GET_MAC_CR(lp, mcr);
1388 spin_unlock_irqrestore(&lp->lock, flags); 1322 spin_unlock_irqrestore(&lp->lock, flags);
1389 1323
1390 if (dev->flags & IFF_PROMISC) { 1324 if (dev->flags & IFF_PROMISC) {
@@ -1461,13 +1395,13 @@ static void smc911x_set_multicast_list(struct net_device *dev)
1461 } 1395 }
1462 1396
1463 spin_lock_irqsave(&lp->lock, flags); 1397 spin_lock_irqsave(&lp->lock, flags);
1464 SMC_SET_MAC_CR(mcr); 1398 SMC_SET_MAC_CR(lp, mcr);
1465 if (update_multicast) { 1399 if (update_multicast) {
1466 DBG(SMC_DEBUG_MISC, 1400 DBG(SMC_DEBUG_MISC,
1467 "%s: update mcast hash table 0x%08x 0x%08x\n", 1401 "%s: update mcast hash table 0x%08x 0x%08x\n",
1468 dev->name, multicast_table[0], multicast_table[1]); 1402 dev->name, multicast_table[0], multicast_table[1]);
1469 SMC_SET_HASHL(multicast_table[0]); 1403 SMC_SET_HASHL(lp, multicast_table[0]);
1470 SMC_SET_HASHH(multicast_table[1]); 1404 SMC_SET_HASHH(lp, multicast_table[1]);
1471 } 1405 }
1472 spin_unlock_irqrestore(&lp->lock, flags); 1406 spin_unlock_irqrestore(&lp->lock, flags);
1473} 1407}
@@ -1559,7 +1493,6 @@ static int
1559smc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) 1493smc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
1560{ 1494{
1561 struct smc911x_local *lp = netdev_priv(dev); 1495 struct smc911x_local *lp = netdev_priv(dev);
1562 unsigned long ioaddr = dev->base_addr;
1563 int ret, status; 1496 int ret, status;
1564 unsigned long flags; 1497 unsigned long flags;
1565 1498
@@ -1587,7 +1520,7 @@ smc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
1587 else 1520 else
1588 cmd->transceiver = XCVR_EXTERNAL; 1521 cmd->transceiver = XCVR_EXTERNAL;
1589 cmd->port = 0; 1522 cmd->port = 0;
1590 SMC_GET_PHY_SPECIAL(lp->mii.phy_id, status); 1523 SMC_GET_PHY_SPECIAL(lp, lp->mii.phy_id, status);
1591 cmd->duplex = 1524 cmd->duplex =
1592 (status & (PHY_SPECIAL_SPD_10FULL_ | PHY_SPECIAL_SPD_100FULL_)) ? 1525 (status & (PHY_SPECIAL_SPD_10FULL_ | PHY_SPECIAL_SPD_100FULL_)) ?
1593 DUPLEX_FULL : DUPLEX_HALF; 1526 DUPLEX_FULL : DUPLEX_HALF;
@@ -1668,7 +1601,6 @@ static int smc911x_ethtool_getregslen(struct net_device *dev)
1668static void smc911x_ethtool_getregs(struct net_device *dev, 1601static void smc911x_ethtool_getregs(struct net_device *dev,
1669 struct ethtool_regs* regs, void *buf) 1602 struct ethtool_regs* regs, void *buf)
1670{ 1603{
1671 unsigned long ioaddr = dev->base_addr;
1672 struct smc911x_local *lp = netdev_priv(dev); 1604 struct smc911x_local *lp = netdev_priv(dev);
1673 unsigned long flags; 1605 unsigned long flags;
1674 u32 reg,i,j=0; 1606 u32 reg,i,j=0;
@@ -1676,17 +1608,17 @@ static void smc911x_ethtool_getregs(struct net_device *dev,
1676 1608
1677 regs->version = lp->version; 1609 regs->version = lp->version;
1678 for(i=ID_REV;i<=E2P_CMD;i+=4) { 1610 for(i=ID_REV;i<=E2P_CMD;i+=4) {
1679 data[j++] = SMC_inl(ioaddr,i); 1611 data[j++] = SMC_inl(lp, i);
1680 } 1612 }
1681 for(i=MAC_CR;i<=WUCSR;i++) { 1613 for(i=MAC_CR;i<=WUCSR;i++) {
1682 spin_lock_irqsave(&lp->lock, flags); 1614 spin_lock_irqsave(&lp->lock, flags);
1683 SMC_GET_MAC_CSR(i, reg); 1615 SMC_GET_MAC_CSR(lp, i, reg);
1684 spin_unlock_irqrestore(&lp->lock, flags); 1616 spin_unlock_irqrestore(&lp->lock, flags);
1685 data[j++] = reg; 1617 data[j++] = reg;
1686 } 1618 }
1687 for(i=0;i<=31;i++) { 1619 for(i=0;i<=31;i++) {
1688 spin_lock_irqsave(&lp->lock, flags); 1620 spin_lock_irqsave(&lp->lock, flags);
1689 SMC_GET_MII(i, lp->mii.phy_id, reg); 1621 SMC_GET_MII(lp, i, lp->mii.phy_id, reg);
1690 spin_unlock_irqrestore(&lp->lock, flags); 1622 spin_unlock_irqrestore(&lp->lock, flags);
1691 data[j++] = reg & 0xFFFF; 1623 data[j++] = reg & 0xFFFF;
1692 } 1624 }
@@ -1694,11 +1626,11 @@ static void smc911x_ethtool_getregs(struct net_device *dev,
1694 1626
1695static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev) 1627static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev)
1696{ 1628{
1697 unsigned long ioaddr = dev->base_addr; 1629 struct smc911x_local *lp = netdev_priv(dev);
1698 unsigned int timeout; 1630 unsigned int timeout;
1699 int e2p_cmd; 1631 int e2p_cmd;
1700 1632
1701 e2p_cmd = SMC_GET_E2P_CMD(); 1633 e2p_cmd = SMC_GET_E2P_CMD(lp);
1702 for(timeout=10;(e2p_cmd & E2P_CMD_EPC_BUSY_) && timeout; timeout--) { 1634 for(timeout=10;(e2p_cmd & E2P_CMD_EPC_BUSY_) && timeout; timeout--) {
1703 if (e2p_cmd & E2P_CMD_EPC_TIMEOUT_) { 1635 if (e2p_cmd & E2P_CMD_EPC_TIMEOUT_) {
1704 PRINTK("%s: %s timeout waiting for EEPROM to respond\n", 1636 PRINTK("%s: %s timeout waiting for EEPROM to respond\n",
@@ -1706,7 +1638,7 @@ static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev)
1706 return -EFAULT; 1638 return -EFAULT;
1707 } 1639 }
1708 mdelay(1); 1640 mdelay(1);
1709 e2p_cmd = SMC_GET_E2P_CMD(); 1641 e2p_cmd = SMC_GET_E2P_CMD(lp);
1710 } 1642 }
1711 if (timeout == 0) { 1643 if (timeout == 0) {
1712 PRINTK("%s: %s timeout waiting for EEPROM CMD not busy\n", 1644 PRINTK("%s: %s timeout waiting for EEPROM CMD not busy\n",
@@ -1719,12 +1651,12 @@ static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev)
1719static inline int smc911x_ethtool_write_eeprom_cmd(struct net_device *dev, 1651static inline int smc911x_ethtool_write_eeprom_cmd(struct net_device *dev,
1720 int cmd, int addr) 1652 int cmd, int addr)
1721{ 1653{
1722 unsigned long ioaddr = dev->base_addr; 1654 struct smc911x_local *lp = netdev_priv(dev);
1723 int ret; 1655 int ret;
1724 1656
1725 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) 1657 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0)
1726 return ret; 1658 return ret;
1727 SMC_SET_E2P_CMD(E2P_CMD_EPC_BUSY_ | 1659 SMC_SET_E2P_CMD(lp, E2P_CMD_EPC_BUSY_ |
1728 ((cmd) & (0x7<<28)) | 1660 ((cmd) & (0x7<<28)) |
1729 ((addr) & 0xFF)); 1661 ((addr) & 0xFF));
1730 return 0; 1662 return 0;
@@ -1733,24 +1665,24 @@ static inline int smc911x_ethtool_write_eeprom_cmd(struct net_device *dev,
1733static inline int smc911x_ethtool_read_eeprom_byte(struct net_device *dev, 1665static inline int smc911x_ethtool_read_eeprom_byte(struct net_device *dev,
1734 u8 *data) 1666 u8 *data)
1735{ 1667{
1736 unsigned long ioaddr = dev->base_addr; 1668 struct smc911x_local *lp = netdev_priv(dev);
1737 int ret; 1669 int ret;
1738 1670
1739 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) 1671 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0)
1740 return ret; 1672 return ret;
1741 *data = SMC_GET_E2P_DATA(); 1673 *data = SMC_GET_E2P_DATA(lp);
1742 return 0; 1674 return 0;
1743} 1675}
1744 1676
1745static inline int smc911x_ethtool_write_eeprom_byte(struct net_device *dev, 1677static inline int smc911x_ethtool_write_eeprom_byte(struct net_device *dev,
1746 u8 data) 1678 u8 data)
1747{ 1679{
1748 unsigned long ioaddr = dev->base_addr; 1680 struct smc911x_local *lp = netdev_priv(dev);
1749 int ret; 1681 int ret;
1750 1682
1751 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) 1683 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0)
1752 return ret; 1684 return ret;
1753 SMC_SET_E2P_DATA(data); 1685 SMC_SET_E2P_DATA(lp, data);
1754 return 0; 1686 return 0;
1755} 1687}
1756 1688
@@ -1817,8 +1749,9 @@ static const struct ethtool_ops smc911x_ethtool_ops = {
1817 * This routine has a simple purpose -- make the SMC chip generate an 1749 * This routine has a simple purpose -- make the SMC chip generate an
1818 * interrupt, so an auto-detect routine can detect it, and find the IRQ, 1750 * interrupt, so an auto-detect routine can detect it, and find the IRQ,
1819 */ 1751 */
1820static int __init smc911x_findirq(unsigned long ioaddr) 1752static int __init smc911x_findirq(struct net_device *dev)
1821{ 1753{
1754 struct smc911x_local *lp = netdev_priv(dev);
1822 int timeout = 20; 1755 int timeout = 20;
1823 unsigned long cookie; 1756 unsigned long cookie;
1824 1757
@@ -1830,7 +1763,7 @@ static int __init smc911x_findirq(unsigned long ioaddr)
1830 * Force a SW interrupt 1763 * Force a SW interrupt
1831 */ 1764 */
1832 1765
1833 SMC_SET_INT_EN(INT_EN_SW_INT_EN_); 1766 SMC_SET_INT_EN(lp, INT_EN_SW_INT_EN_);
1834 1767
1835 /* 1768 /*
1836 * Wait until positive that the interrupt has been generated 1769 * Wait until positive that the interrupt has been generated
@@ -1838,7 +1771,7 @@ static int __init smc911x_findirq(unsigned long ioaddr)
1838 do { 1771 do {
1839 int int_status; 1772 int int_status;
1840 udelay(10); 1773 udelay(10);
1841 int_status = SMC_GET_INT_EN(); 1774 int_status = SMC_GET_INT_EN(lp);
1842 if (int_status & INT_EN_SW_INT_EN_) 1775 if (int_status & INT_EN_SW_INT_EN_)
1843 break; /* got the interrupt */ 1776 break; /* got the interrupt */
1844 } while (--timeout); 1777 } while (--timeout);
@@ -1851,7 +1784,7 @@ static int __init smc911x_findirq(unsigned long ioaddr)
1851 */ 1784 */
1852 1785
1853 /* and disable all interrupts again */ 1786 /* and disable all interrupts again */
1854 SMC_SET_INT_EN(0); 1787 SMC_SET_INT_EN(lp, 0);
1855 1788
1856 /* and return what I found */ 1789 /* and return what I found */
1857 return probe_irq_off(cookie); 1790 return probe_irq_off(cookie);
@@ -1880,7 +1813,7 @@ static int __init smc911x_findirq(unsigned long ioaddr)
1880 * o actually GRAB the irq. 1813 * o actually GRAB the irq.
1881 * o GRAB the region 1814 * o GRAB the region
1882 */ 1815 */
1883static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr) 1816static int __init smc911x_probe(struct net_device *dev)
1884{ 1817{
1885 struct smc911x_local *lp = netdev_priv(dev); 1818 struct smc911x_local *lp = netdev_priv(dev);
1886 int i, retval; 1819 int i, retval;
@@ -1890,7 +1823,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr)
1890 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); 1823 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1891 1824
1892 /* First, see if the endian word is recognized */ 1825 /* First, see if the endian word is recognized */
1893 val = SMC_GET_BYTE_TEST(); 1826 val = SMC_GET_BYTE_TEST(lp);
1894 DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val); 1827 DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val);
1895 if (val != 0x87654321) { 1828 if (val != 0x87654321) {
1896 printk(KERN_ERR "Invalid chip endian 0x08%x\n",val); 1829 printk(KERN_ERR "Invalid chip endian 0x08%x\n",val);
@@ -1903,7 +1836,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr)
1903 * recognize. These might need to be added to later, 1836 * recognize. These might need to be added to later,
1904 * as future revisions could be added. 1837 * as future revisions could be added.
1905 */ 1838 */
1906 chip_id = SMC_GET_PN(); 1839 chip_id = SMC_GET_PN(lp);
1907 DBG(SMC_DEBUG_MISC, "%s: id probe returned 0x%04x\n", CARDNAME, chip_id); 1840 DBG(SMC_DEBUG_MISC, "%s: id probe returned 0x%04x\n", CARDNAME, chip_id);
1908 for(i=0;chip_ids[i].id != 0; i++) { 1841 for(i=0;chip_ids[i].id != 0; i++) {
1909 if (chip_ids[i].id == chip_id) break; 1842 if (chip_ids[i].id == chip_id) break;
@@ -1915,7 +1848,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr)
1915 } 1848 }
1916 version_string = chip_ids[i].name; 1849 version_string = chip_ids[i].name;
1917 1850
1918 revision = SMC_GET_REV(); 1851 revision = SMC_GET_REV(lp);
1919 DBG(SMC_DEBUG_MISC, "%s: revision = 0x%04x\n", CARDNAME, revision); 1852 DBG(SMC_DEBUG_MISC, "%s: revision = 0x%04x\n", CARDNAME, revision);
1920 1853
1921 /* At this point I'll assume that the chip is an SMC911x. */ 1854 /* At this point I'll assume that the chip is an SMC911x. */
@@ -1929,7 +1862,6 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr)
1929 } 1862 }
1930 1863
1931 /* fill in some of the fields */ 1864 /* fill in some of the fields */
1932 dev->base_addr = ioaddr;
1933 lp->version = chip_ids[i].id; 1865 lp->version = chip_ids[i].id;
1934 lp->revision = revision; 1866 lp->revision = revision;
1935 lp->tx_fifo_kb = tx_fifo_kb; 1867 lp->tx_fifo_kb = tx_fifo_kb;
@@ -1988,7 +1920,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr)
1988 spin_lock_init(&lp->lock); 1920 spin_lock_init(&lp->lock);
1989 1921
1990 /* Get the MAC address */ 1922 /* Get the MAC address */
1991 SMC_GET_MAC_ADDR(dev->dev_addr); 1923 SMC_GET_MAC_ADDR(lp, dev->dev_addr);
1992 1924
1993 /* now, reset the chip, and put it into a known state */ 1925 /* now, reset the chip, and put it into a known state */
1994 smc911x_reset(dev); 1926 smc911x_reset(dev);
@@ -2005,7 +1937,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr)
2005 1937
2006 trials = 3; 1938 trials = 3;
2007 while (trials--) { 1939 while (trials--) {
2008 dev->irq = smc911x_findirq(ioaddr); 1940 dev->irq = smc911x_findirq(dev);
2009 if (dev->irq) 1941 if (dev->irq)
2010 break; 1942 break;
2011 /* kick the card and try again */ 1943 /* kick the card and try again */
@@ -2166,7 +2098,9 @@ static int smc911x_drv_probe(struct platform_device *pdev)
2166 } 2098 }
2167 2099
2168 platform_set_drvdata(pdev, ndev); 2100 platform_set_drvdata(pdev, ndev);
2169 ret = smc911x_probe(ndev, (unsigned long)addr); 2101 lp->base = addr;
2102 ndev->base_addr = res->start;
2103 ret = smc911x_probe(ndev);
2170 if (ret != 0) { 2104 if (ret != 0) {
2171 platform_set_drvdata(pdev, NULL); 2105 platform_set_drvdata(pdev, NULL);
2172 iounmap(addr); 2106 iounmap(addr);
@@ -2190,6 +2124,7 @@ out:
2190static int smc911x_drv_remove(struct platform_device *pdev) 2124static int smc911x_drv_remove(struct platform_device *pdev)
2191{ 2125{
2192 struct net_device *ndev = platform_get_drvdata(pdev); 2126 struct net_device *ndev = platform_get_drvdata(pdev);
2127 struct smc911x_local *lp = netdev_priv(ndev);
2193 struct resource *res; 2128 struct resource *res;
2194 2129
2195 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__); 2130 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__);
@@ -2201,7 +2136,6 @@ static int smc911x_drv_remove(struct platform_device *pdev)
2201 2136
2202#ifdef SMC_USE_DMA 2137#ifdef SMC_USE_DMA
2203 { 2138 {
2204 struct smc911x_local *lp = netdev_priv(ndev);
2205 if (lp->rxdma != -1) { 2139 if (lp->rxdma != -1) {
2206 SMC_DMA_FREE(dev, lp->rxdma); 2140 SMC_DMA_FREE(dev, lp->rxdma);
2207 } 2141 }
@@ -2210,7 +2144,7 @@ static int smc911x_drv_remove(struct platform_device *pdev)
2210 } 2144 }
2211 } 2145 }
2212#endif 2146#endif
2213 iounmap((void *)ndev->base_addr); 2147 iounmap(lp->base);
2214 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2148 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2215 release_mem_region(res->start, SMC911X_IO_EXTENT); 2149 release_mem_region(res->start, SMC911X_IO_EXTENT);
2216 2150
@@ -2221,7 +2155,7 @@ static int smc911x_drv_remove(struct platform_device *pdev)
2221static int smc911x_drv_suspend(struct platform_device *dev, pm_message_t state) 2155static int smc911x_drv_suspend(struct platform_device *dev, pm_message_t state)
2222{ 2156{
2223 struct net_device *ndev = platform_get_drvdata(dev); 2157 struct net_device *ndev = platform_get_drvdata(dev);
2224 unsigned long ioaddr = ndev->base_addr; 2158 struct smc911x_local *lp = netdev_priv(ndev);
2225 2159
2226 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__); 2160 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__);
2227 if (ndev) { 2161 if (ndev) {
@@ -2230,7 +2164,7 @@ static int smc911x_drv_suspend(struct platform_device *dev, pm_message_t state)
2230 smc911x_shutdown(ndev); 2164 smc911x_shutdown(ndev);
2231#if POWER_DOWN 2165#if POWER_DOWN
2232 /* Set D2 - Energy detect only setting */ 2166 /* Set D2 - Energy detect only setting */
2233 SMC_SET_PMT_CTRL(2<<12); 2167 SMC_SET_PMT_CTRL(lp, 2<<12);
2234#endif 2168#endif
2235 } 2169 }
2236 } 2170 }