diff options
Diffstat (limited to 'drivers/net/smc911x.c')
-rw-r--r-- | drivers/net/smc911x.c | 422 |
1 files changed, 186 insertions, 236 deletions
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index e2ee91a6ae7e..c5871624f972 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c | |||
@@ -106,55 +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.. */ | ||
111 | struct 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 | |||
140 | int tx_throttle; | ||
141 | spinlock_t lock; | ||
142 | |||
143 | struct net_device *netdev; | ||
144 | |||
145 | #ifdef SMC_USE_DMA | ||
146 | /* DMA needs the physical address of the chip */ | ||
147 | u_long physaddr; | ||
148 | int rxdma; | ||
149 | int txdma; | ||
150 | int rxdma_active; | ||
151 | int txdma_active; | ||
152 | struct sk_buff *current_rx_skb; | ||
153 | struct sk_buff *current_tx_skb; | ||
154 | struct device *dev; | ||
155 | #endif | ||
156 | }; | ||
157 | |||
158 | #if SMC_DEBUG > 0 | 109 | #if SMC_DEBUG > 0 |
159 | #define DBG(n, args...) \ | 110 | #define DBG(n, args...) \ |
160 | do { \ | 111 | do { \ |
@@ -202,24 +153,24 @@ static void PRINT_PKT(u_char *buf, int length) | |||
202 | 153 | ||
203 | 154 | ||
204 | /* this enables an interrupt in the interrupt mask register */ | 155 | /* this enables an interrupt in the interrupt mask register */ |
205 | #define SMC_ENABLE_INT(x) do { \ | 156 | #define SMC_ENABLE_INT(lp, x) do { \ |
206 | unsigned int __mask; \ | 157 | unsigned int __mask; \ |
207 | unsigned long __flags; \ | 158 | unsigned long __flags; \ |
208 | spin_lock_irqsave(&lp->lock, __flags); \ | 159 | spin_lock_irqsave(&lp->lock, __flags); \ |
209 | __mask = SMC_GET_INT_EN(); \ | 160 | __mask = SMC_GET_INT_EN((lp)); \ |
210 | __mask |= (x); \ | 161 | __mask |= (x); \ |
211 | SMC_SET_INT_EN(__mask); \ | 162 | SMC_SET_INT_EN((lp), __mask); \ |
212 | spin_unlock_irqrestore(&lp->lock, __flags); \ | 163 | spin_unlock_irqrestore(&lp->lock, __flags); \ |
213 | } while (0) | 164 | } while (0) |
214 | 165 | ||
215 | /* this disables an interrupt from the interrupt mask register */ | 166 | /* this disables an interrupt from the interrupt mask register */ |
216 | #define SMC_DISABLE_INT(x) do { \ | 167 | #define SMC_DISABLE_INT(lp, x) do { \ |
217 | unsigned int __mask; \ | 168 | unsigned int __mask; \ |
218 | unsigned long __flags; \ | 169 | unsigned long __flags; \ |
219 | spin_lock_irqsave(&lp->lock, __flags); \ | 170 | spin_lock_irqsave(&lp->lock, __flags); \ |
220 | __mask = SMC_GET_INT_EN(); \ | 171 | __mask = SMC_GET_INT_EN((lp)); \ |
221 | __mask &= ~(x); \ | 172 | __mask &= ~(x); \ |
222 | SMC_SET_INT_EN(__mask); \ | 173 | SMC_SET_INT_EN((lp), __mask); \ |
223 | spin_unlock_irqrestore(&lp->lock, __flags); \ | 174 | spin_unlock_irqrestore(&lp->lock, __flags); \ |
224 | } while (0) | 175 | } while (0) |
225 | 176 | ||
@@ -228,7 +179,6 @@ static void PRINT_PKT(u_char *buf, int length) | |||
228 | */ | 179 | */ |
229 | static void smc911x_reset(struct net_device *dev) | 180 | static void smc911x_reset(struct net_device *dev) |
230 | { | 181 | { |
231 | unsigned long ioaddr = dev->base_addr; | ||
232 | struct smc911x_local *lp = netdev_priv(dev); | 182 | struct smc911x_local *lp = netdev_priv(dev); |
233 | unsigned int reg, timeout=0, resets=1; | 183 | unsigned int reg, timeout=0, resets=1; |
234 | unsigned long flags; | 184 | unsigned long flags; |
@@ -236,13 +186,13 @@ static void smc911x_reset(struct net_device *dev) | |||
236 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); | 186 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); |
237 | 187 | ||
238 | /* Take out of PM setting first */ | 188 | /* Take out of PM setting first */ |
239 | if ((SMC_GET_PMT_CTRL() & PMT_CTRL_READY_) == 0) { | 189 | if ((SMC_GET_PMT_CTRL(lp) & PMT_CTRL_READY_) == 0) { |
240 | /* Write to the bytetest will take out of powerdown */ | 190 | /* Write to the bytetest will take out of powerdown */ |
241 | SMC_SET_BYTE_TEST(0); | 191 | SMC_SET_BYTE_TEST(lp, 0); |
242 | timeout=10; | 192 | timeout=10; |
243 | do { | 193 | do { |
244 | udelay(10); | 194 | udelay(10); |
245 | reg = SMC_GET_PMT_CTRL() & PMT_CTRL_READY_; | 195 | reg = SMC_GET_PMT_CTRL(lp) & PMT_CTRL_READY_; |
246 | } while (--timeout && !reg); | 196 | } while (--timeout && !reg); |
247 | if (timeout == 0) { | 197 | if (timeout == 0) { |
248 | 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); |
@@ -252,15 +202,15 @@ static void smc911x_reset(struct net_device *dev) | |||
252 | 202 | ||
253 | /* Disable all interrupts */ | 203 | /* Disable all interrupts */ |
254 | spin_lock_irqsave(&lp->lock, flags); | 204 | spin_lock_irqsave(&lp->lock, flags); |
255 | SMC_SET_INT_EN(0); | 205 | SMC_SET_INT_EN(lp, 0); |
256 | spin_unlock_irqrestore(&lp->lock, flags); | 206 | spin_unlock_irqrestore(&lp->lock, flags); |
257 | 207 | ||
258 | while (resets--) { | 208 | while (resets--) { |
259 | SMC_SET_HW_CFG(HW_CFG_SRST_); | 209 | SMC_SET_HW_CFG(lp, HW_CFG_SRST_); |
260 | timeout=10; | 210 | timeout=10; |
261 | do { | 211 | do { |
262 | udelay(10); | 212 | udelay(10); |
263 | reg = SMC_GET_HW_CFG(); | 213 | reg = SMC_GET_HW_CFG(lp); |
264 | /* If chip indicates reset timeout then try again */ | 214 | /* If chip indicates reset timeout then try again */ |
265 | if (reg & HW_CFG_SRST_TO_) { | 215 | if (reg & HW_CFG_SRST_TO_) { |
266 | PRINTK("%s: chip reset timeout, retrying...\n", dev->name); | 216 | PRINTK("%s: chip reset timeout, retrying...\n", dev->name); |
@@ -276,7 +226,7 @@ static void smc911x_reset(struct net_device *dev) | |||
276 | 226 | ||
277 | /* make sure EEPROM has finished loading before setting GPIO_CFG */ | 227 | /* make sure EEPROM has finished loading before setting GPIO_CFG */ |
278 | timeout=1000; | 228 | timeout=1000; |
279 | while ( timeout-- && (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)) { | 229 | while ( timeout-- && (SMC_GET_E2P_CMD(lp) & E2P_CMD_EPC_BUSY_)) { |
280 | udelay(10); | 230 | udelay(10); |
281 | } | 231 | } |
282 | if (timeout == 0){ | 232 | if (timeout == 0){ |
@@ -285,24 +235,24 @@ static void smc911x_reset(struct net_device *dev) | |||
285 | } | 235 | } |
286 | 236 | ||
287 | /* Initialize interrupts */ | 237 | /* Initialize interrupts */ |
288 | SMC_SET_INT_EN(0); | 238 | SMC_SET_INT_EN(lp, 0); |
289 | SMC_ACK_INT(-1); | 239 | SMC_ACK_INT(lp, -1); |
290 | 240 | ||
291 | /* Reset the FIFO level and flow control settings */ | 241 | /* Reset the FIFO level and flow control settings */ |
292 | SMC_SET_HW_CFG((lp->tx_fifo_kb & 0xF) << 16); | 242 | SMC_SET_HW_CFG(lp, (lp->tx_fifo_kb & 0xF) << 16); |
293 | //TODO: Figure out what appropriate pause time is | 243 | //TODO: Figure out what appropriate pause time is |
294 | SMC_SET_FLOW(FLOW_FCPT_ | FLOW_FCEN_); | 244 | SMC_SET_FLOW(lp, FLOW_FCPT_ | FLOW_FCEN_); |
295 | SMC_SET_AFC_CFG(lp->afc_cfg); | 245 | SMC_SET_AFC_CFG(lp, lp->afc_cfg); |
296 | 246 | ||
297 | 247 | ||
298 | /* Set to LED outputs */ | 248 | /* Set to LED outputs */ |
299 | SMC_SET_GPIO_CFG(0x70070000); | 249 | SMC_SET_GPIO_CFG(lp, 0x70070000); |
300 | 250 | ||
301 | /* | 251 | /* |
302 | * Deassert IRQ for 1*10us for edge type interrupts | 252 | * Deassert IRQ for 1*10us for edge type interrupts |
303 | * and drive IRQ pin push-pull | 253 | * and drive IRQ pin push-pull |
304 | */ | 254 | */ |
305 | 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_); |
306 | 256 | ||
307 | /* clear anything saved */ | 257 | /* clear anything saved */ |
308 | if (lp->pending_tx_skb != NULL) { | 258 | if (lp->pending_tx_skb != NULL) { |
@@ -318,46 +268,45 @@ static void smc911x_reset(struct net_device *dev) | |||
318 | */ | 268 | */ |
319 | static void smc911x_enable(struct net_device *dev) | 269 | static void smc911x_enable(struct net_device *dev) |
320 | { | 270 | { |
321 | unsigned long ioaddr = dev->base_addr; | ||
322 | struct smc911x_local *lp = netdev_priv(dev); | 271 | struct smc911x_local *lp = netdev_priv(dev); |
323 | unsigned mask, cfg, cr; | 272 | unsigned mask, cfg, cr; |
324 | unsigned long flags; | 273 | unsigned long flags; |
325 | 274 | ||
326 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); | 275 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); |
327 | 276 | ||
328 | SMC_SET_MAC_ADDR(dev->dev_addr); | 277 | SMC_SET_MAC_ADDR(lp, dev->dev_addr); |
329 | 278 | ||
330 | /* Enable TX */ | 279 | /* Enable TX */ |
331 | cfg = SMC_GET_HW_CFG(); | 280 | cfg = SMC_GET_HW_CFG(lp); |
332 | cfg &= HW_CFG_TX_FIF_SZ_ | 0xFFF; | 281 | cfg &= HW_CFG_TX_FIF_SZ_ | 0xFFF; |
333 | cfg |= HW_CFG_SF_; | 282 | cfg |= HW_CFG_SF_; |
334 | SMC_SET_HW_CFG(cfg); | 283 | SMC_SET_HW_CFG(lp, cfg); |
335 | SMC_SET_FIFO_TDA(0xFF); | 284 | SMC_SET_FIFO_TDA(lp, 0xFF); |
336 | /* 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 */ |
337 | SMC_SET_FIFO_TSL(64); | 286 | SMC_SET_FIFO_TSL(lp, 64); |
338 | SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000); | 287 | SMC_SET_GPT_CFG(lp, GPT_CFG_TIMER_EN_ | 10000); |
339 | 288 | ||
340 | spin_lock_irqsave(&lp->lock, flags); | 289 | spin_lock_irqsave(&lp->lock, flags); |
341 | SMC_GET_MAC_CR(cr); | 290 | SMC_GET_MAC_CR(lp, cr); |
342 | cr |= MAC_CR_TXEN_ | MAC_CR_HBDIS_; | 291 | cr |= MAC_CR_TXEN_ | MAC_CR_HBDIS_; |
343 | SMC_SET_MAC_CR(cr); | 292 | SMC_SET_MAC_CR(lp, cr); |
344 | SMC_SET_TX_CFG(TX_CFG_TX_ON_); | 293 | SMC_SET_TX_CFG(lp, TX_CFG_TX_ON_); |
345 | spin_unlock_irqrestore(&lp->lock, flags); | 294 | spin_unlock_irqrestore(&lp->lock, flags); |
346 | 295 | ||
347 | /* Add 2 byte padding to start of packets */ | 296 | /* Add 2 byte padding to start of packets */ |
348 | SMC_SET_RX_CFG((2<<8) & RX_CFG_RXDOFF_); | 297 | SMC_SET_RX_CFG(lp, (2<<8) & RX_CFG_RXDOFF_); |
349 | 298 | ||
350 | /* Turn on receiver and enable RX */ | 299 | /* Turn on receiver and enable RX */ |
351 | if (cr & MAC_CR_RXEN_) | 300 | if (cr & MAC_CR_RXEN_) |
352 | DBG(SMC_DEBUG_RX, "%s: Receiver already enabled\n", dev->name); | 301 | DBG(SMC_DEBUG_RX, "%s: Receiver already enabled\n", dev->name); |
353 | 302 | ||
354 | spin_lock_irqsave(&lp->lock, flags); | 303 | spin_lock_irqsave(&lp->lock, flags); |
355 | SMC_SET_MAC_CR( cr | MAC_CR_RXEN_ ); | 304 | SMC_SET_MAC_CR(lp, cr | MAC_CR_RXEN_); |
356 | spin_unlock_irqrestore(&lp->lock, flags); | 305 | spin_unlock_irqrestore(&lp->lock, flags); |
357 | 306 | ||
358 | /* Interrupt on every received packet */ | 307 | /* Interrupt on every received packet */ |
359 | SMC_SET_FIFO_RSA(0x01); | 308 | SMC_SET_FIFO_RSA(lp, 0x01); |
360 | SMC_SET_FIFO_RSL(0x00); | 309 | SMC_SET_FIFO_RSL(lp, 0x00); |
361 | 310 | ||
362 | /* now, enable interrupts */ | 311 | /* now, enable interrupts */ |
363 | 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_ | |
@@ -368,7 +317,7 @@ static void smc911x_enable(struct net_device *dev) | |||
368 | else { | 317 | else { |
369 | mask|=INT_EN_RDFO_EN_; | 318 | mask|=INT_EN_RDFO_EN_; |
370 | } | 319 | } |
371 | SMC_ENABLE_INT(mask); | 320 | SMC_ENABLE_INT(lp, mask); |
372 | } | 321 | } |
373 | 322 | ||
374 | /* | 323 | /* |
@@ -376,7 +325,6 @@ static void smc911x_enable(struct net_device *dev) | |||
376 | */ | 325 | */ |
377 | static void smc911x_shutdown(struct net_device *dev) | 326 | static void smc911x_shutdown(struct net_device *dev) |
378 | { | 327 | { |
379 | unsigned long ioaddr = dev->base_addr; | ||
380 | struct smc911x_local *lp = netdev_priv(dev); | 328 | struct smc911x_local *lp = netdev_priv(dev); |
381 | unsigned cr; | 329 | unsigned cr; |
382 | unsigned long flags; | 330 | unsigned long flags; |
@@ -384,35 +332,35 @@ static void smc911x_shutdown(struct net_device *dev) | |||
384 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", CARDNAME, __FUNCTION__); | 332 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", CARDNAME, __FUNCTION__); |
385 | 333 | ||
386 | /* Disable IRQ's */ | 334 | /* Disable IRQ's */ |
387 | SMC_SET_INT_EN(0); | 335 | SMC_SET_INT_EN(lp, 0); |
388 | 336 | ||
389 | /* Turn of Rx and TX */ | 337 | /* Turn of Rx and TX */ |
390 | spin_lock_irqsave(&lp->lock, flags); | 338 | spin_lock_irqsave(&lp->lock, flags); |
391 | SMC_GET_MAC_CR(cr); | 339 | SMC_GET_MAC_CR(lp, cr); |
392 | cr &= ~(MAC_CR_TXEN_ | MAC_CR_RXEN_ | MAC_CR_HBDIS_); | 340 | cr &= ~(MAC_CR_TXEN_ | MAC_CR_RXEN_ | MAC_CR_HBDIS_); |
393 | SMC_SET_MAC_CR(cr); | 341 | SMC_SET_MAC_CR(lp, cr); |
394 | SMC_SET_TX_CFG(TX_CFG_STOP_TX_); | 342 | SMC_SET_TX_CFG(lp, TX_CFG_STOP_TX_); |
395 | spin_unlock_irqrestore(&lp->lock, flags); | 343 | spin_unlock_irqrestore(&lp->lock, flags); |
396 | } | 344 | } |
397 | 345 | ||
398 | static inline void smc911x_drop_pkt(struct net_device *dev) | 346 | static inline void smc911x_drop_pkt(struct net_device *dev) |
399 | { | 347 | { |
400 | unsigned long ioaddr = dev->base_addr; | 348 | struct smc911x_local *lp = netdev_priv(dev); |
401 | unsigned int fifo_count, timeout, reg; | 349 | unsigned int fifo_count, timeout, reg; |
402 | 350 | ||
403 | 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__); |
404 | fifo_count = SMC_GET_RX_FIFO_INF() & 0xFFFF; | 352 | fifo_count = SMC_GET_RX_FIFO_INF(lp) & 0xFFFF; |
405 | if (fifo_count <= 4) { | 353 | if (fifo_count <= 4) { |
406 | /* Manually dump the packet data */ | 354 | /* Manually dump the packet data */ |
407 | while (fifo_count--) | 355 | while (fifo_count--) |
408 | SMC_GET_RX_FIFO(); | 356 | SMC_GET_RX_FIFO(lp); |
409 | } else { | 357 | } else { |
410 | /* Fast forward through the bad packet */ | 358 | /* Fast forward through the bad packet */ |
411 | SMC_SET_RX_DP_CTRL(RX_DP_CTRL_FFWD_BUSY_); | 359 | SMC_SET_RX_DP_CTRL(lp, RX_DP_CTRL_FFWD_BUSY_); |
412 | timeout=50; | 360 | timeout=50; |
413 | do { | 361 | do { |
414 | udelay(10); | 362 | udelay(10); |
415 | reg = SMC_GET_RX_DP_CTRL() & RX_DP_CTRL_FFWD_BUSY_; | 363 | reg = SMC_GET_RX_DP_CTRL(lp) & RX_DP_CTRL_FFWD_BUSY_; |
416 | } while (--timeout && reg); | 364 | } while (--timeout && reg); |
417 | if (timeout == 0) { | 365 | if (timeout == 0) { |
418 | PRINTK("%s: timeout waiting for RX fast forward\n", dev->name); | 366 | PRINTK("%s: timeout waiting for RX fast forward\n", dev->name); |
@@ -428,14 +376,14 @@ static inline void smc911x_drop_pkt(struct net_device *dev) | |||
428 | */ | 376 | */ |
429 | static inline void smc911x_rcv(struct net_device *dev) | 377 | static inline void smc911x_rcv(struct net_device *dev) |
430 | { | 378 | { |
431 | unsigned long ioaddr = dev->base_addr; | 379 | struct smc911x_local *lp = netdev_priv(dev); |
432 | unsigned int pkt_len, status; | 380 | unsigned int pkt_len, status; |
433 | struct sk_buff *skb; | 381 | struct sk_buff *skb; |
434 | unsigned char *data; | 382 | unsigned char *data; |
435 | 383 | ||
436 | DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n", | 384 | DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n", |
437 | dev->name, __FUNCTION__); | 385 | dev->name, __FUNCTION__); |
438 | status = SMC_GET_RX_STS_FIFO(); | 386 | status = SMC_GET_RX_STS_FIFO(lp); |
439 | 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", |
440 | dev->name, (status & 0x3fff0000) >> 16, status & 0xc000ffff); | 388 | dev->name, (status & 0x3fff0000) >> 16, status & 0xc000ffff); |
441 | pkt_len = (status & RX_STS_PKT_LEN_) >> 16; | 389 | pkt_len = (status & RX_STS_PKT_LEN_) >> 16; |
@@ -472,24 +420,23 @@ static inline void smc911x_rcv(struct net_device *dev) | |||
472 | skb_put(skb,pkt_len-4); | 420 | skb_put(skb,pkt_len-4); |
473 | #ifdef SMC_USE_DMA | 421 | #ifdef SMC_USE_DMA |
474 | { | 422 | { |
475 | struct smc911x_local *lp = netdev_priv(dev); | ||
476 | unsigned int fifo; | 423 | unsigned int fifo; |
477 | /* Lower the FIFO threshold if possible */ | 424 | /* Lower the FIFO threshold if possible */ |
478 | fifo = SMC_GET_FIFO_INT(); | 425 | fifo = SMC_GET_FIFO_INT(lp); |
479 | if (fifo & 0xFF) fifo--; | 426 | if (fifo & 0xFF) fifo--; |
480 | 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", |
481 | dev->name, fifo & 0xff); | 428 | dev->name, fifo & 0xff); |
482 | SMC_SET_FIFO_INT(fifo); | 429 | SMC_SET_FIFO_INT(lp, fifo); |
483 | /* Setup RX DMA */ | 430 | /* Setup RX DMA */ |
484 | 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_)); |
485 | lp->rxdma_active = 1; | 432 | lp->rxdma_active = 1; |
486 | lp->current_rx_skb = skb; | 433 | lp->current_rx_skb = skb; |
487 | SMC_PULL_DATA(data, (pkt_len+2+15) & ~15); | 434 | SMC_PULL_DATA(lp, data, (pkt_len+2+15) & ~15); |
488 | /* Packet processing deferred to DMA RX interrupt */ | 435 | /* Packet processing deferred to DMA RX interrupt */ |
489 | } | 436 | } |
490 | #else | 437 | #else |
491 | 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_)); |
492 | SMC_PULL_DATA(data, pkt_len+2+3); | 439 | SMC_PULL_DATA(lp, data, pkt_len+2+3); |
493 | 440 | ||
494 | DBG(SMC_DEBUG_PKTS, "%s: Received packet\n", dev->name); | 441 | DBG(SMC_DEBUG_PKTS, "%s: Received packet\n", dev->name); |
495 | PRINT_PKT(data, ((pkt_len - 4) <= 64) ? pkt_len - 4 : 64); | 442 | PRINT_PKT(data, ((pkt_len - 4) <= 64) ? pkt_len - 4 : 64); |
@@ -508,7 +455,6 @@ static inline void smc911x_rcv(struct net_device *dev) | |||
508 | static void smc911x_hardware_send_pkt(struct net_device *dev) | 455 | static void smc911x_hardware_send_pkt(struct net_device *dev) |
509 | { | 456 | { |
510 | struct smc911x_local *lp = netdev_priv(dev); | 457 | struct smc911x_local *lp = netdev_priv(dev); |
511 | unsigned long ioaddr = dev->base_addr; | ||
512 | struct sk_buff *skb; | 458 | struct sk_buff *skb; |
513 | unsigned int cmdA, cmdB, len; | 459 | unsigned int cmdA, cmdB, len; |
514 | unsigned char *buf; | 460 | unsigned char *buf; |
@@ -541,8 +487,8 @@ static void smc911x_hardware_send_pkt(struct net_device *dev) | |||
541 | 487 | ||
542 | 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", |
543 | dev->name, len, len, buf, cmdA, cmdB); | 489 | dev->name, len, len, buf, cmdA, cmdB); |
544 | SMC_SET_TX_FIFO(cmdA); | 490 | SMC_SET_TX_FIFO(lp, cmdA); |
545 | SMC_SET_TX_FIFO(cmdB); | 491 | SMC_SET_TX_FIFO(lp, cmdB); |
546 | 492 | ||
547 | DBG(SMC_DEBUG_PKTS, "%s: Transmitted packet\n", dev->name); | 493 | DBG(SMC_DEBUG_PKTS, "%s: Transmitted packet\n", dev->name); |
548 | PRINT_PKT(buf, len <= 64 ? len : 64); | 494 | PRINT_PKT(buf, len <= 64 ? len : 64); |
@@ -550,10 +496,10 @@ static void smc911x_hardware_send_pkt(struct net_device *dev) | |||
550 | /* Send pkt via PIO or DMA */ | 496 | /* Send pkt via PIO or DMA */ |
551 | #ifdef SMC_USE_DMA | 497 | #ifdef SMC_USE_DMA |
552 | lp->current_tx_skb = skb; | 498 | lp->current_tx_skb = skb; |
553 | SMC_PUSH_DATA(buf, len); | 499 | SMC_PUSH_DATA(lp, buf, len); |
554 | /* DMA complete IRQ will free buffer and set jiffies */ | 500 | /* DMA complete IRQ will free buffer and set jiffies */ |
555 | #else | 501 | #else |
556 | SMC_PUSH_DATA(buf, len); | 502 | SMC_PUSH_DATA(lp, buf, len); |
557 | dev->trans_start = jiffies; | 503 | dev->trans_start = jiffies; |
558 | dev_kfree_skb(skb); | 504 | dev_kfree_skb(skb); |
559 | #endif | 505 | #endif |
@@ -562,7 +508,7 @@ static void smc911x_hardware_send_pkt(struct net_device *dev) | |||
562 | netif_wake_queue(dev); | 508 | netif_wake_queue(dev); |
563 | } | 509 | } |
564 | spin_unlock_irqrestore(&lp->lock, flags); | 510 | spin_unlock_irqrestore(&lp->lock, flags); |
565 | SMC_ENABLE_INT(INT_EN_TDFA_EN_ | INT_EN_TSFL_EN_); | 511 | SMC_ENABLE_INT(lp, INT_EN_TDFA_EN_ | INT_EN_TSFL_EN_); |
566 | } | 512 | } |
567 | 513 | ||
568 | /* | 514 | /* |
@@ -574,7 +520,6 @@ static void smc911x_hardware_send_pkt(struct net_device *dev) | |||
574 | static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | 520 | static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
575 | { | 521 | { |
576 | struct smc911x_local *lp = netdev_priv(dev); | 522 | struct smc911x_local *lp = netdev_priv(dev); |
577 | unsigned long ioaddr = dev->base_addr; | ||
578 | unsigned int free; | 523 | unsigned int free; |
579 | unsigned long flags; | 524 | unsigned long flags; |
580 | 525 | ||
@@ -583,7 +528,7 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
583 | 528 | ||
584 | BUG_ON(lp->pending_tx_skb != NULL); | 529 | BUG_ON(lp->pending_tx_skb != NULL); |
585 | 530 | ||
586 | free = SMC_GET_TX_FIFO_INF() & TX_FIFO_INF_TDFREE_; | 531 | free = SMC_GET_TX_FIFO_INF(lp) & TX_FIFO_INF_TDFREE_; |
587 | 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); |
588 | 533 | ||
589 | /* Turn off the flow when running out of space in FIFO */ | 534 | /* Turn off the flow when running out of space in FIFO */ |
@@ -592,7 +537,7 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
592 | dev->name, free); | 537 | dev->name, free); |
593 | spin_lock_irqsave(&lp->lock, flags); | 538 | spin_lock_irqsave(&lp->lock, flags); |
594 | /* Reenable when at least 1 packet of size MTU present */ | 539 | /* Reenable when at least 1 packet of size MTU present */ |
595 | SMC_SET_FIFO_TDA((SMC911X_TX_FIFO_LOW_THRESHOLD)/64); | 540 | SMC_SET_FIFO_TDA(lp, (SMC911X_TX_FIFO_LOW_THRESHOLD)/64); |
596 | lp->tx_throttle = 1; | 541 | lp->tx_throttle = 1; |
597 | netif_stop_queue(dev); | 542 | netif_stop_queue(dev); |
598 | spin_unlock_irqrestore(&lp->lock, flags); | 543 | spin_unlock_irqrestore(&lp->lock, flags); |
@@ -647,7 +592,6 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
647 | */ | 592 | */ |
648 | static void smc911x_tx(struct net_device *dev) | 593 | static void smc911x_tx(struct net_device *dev) |
649 | { | 594 | { |
650 | unsigned long ioaddr = dev->base_addr; | ||
651 | struct smc911x_local *lp = netdev_priv(dev); | 595 | struct smc911x_local *lp = netdev_priv(dev); |
652 | unsigned int tx_status; | 596 | unsigned int tx_status; |
653 | 597 | ||
@@ -655,11 +599,11 @@ static void smc911x_tx(struct net_device *dev) | |||
655 | dev->name, __FUNCTION__); | 599 | dev->name, __FUNCTION__); |
656 | 600 | ||
657 | /* Collect the TX status */ | 601 | /* Collect the TX status */ |
658 | 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) { |
659 | 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", |
660 | dev->name, | 604 | dev->name, |
661 | (SMC_GET_TX_FIFO_INF() & TX_FIFO_INF_TSUSED_) >> 16); | 605 | (SMC_GET_TX_FIFO_INF(lp) & TX_FIFO_INF_TSUSED_) >> 16); |
662 | tx_status = SMC_GET_TX_STS_FIFO(); | 606 | tx_status = SMC_GET_TX_STS_FIFO(lp); |
663 | dev->stats.tx_packets++; | 607 | dev->stats.tx_packets++; |
664 | dev->stats.tx_bytes+=tx_status>>16; | 608 | dev->stats.tx_bytes+=tx_status>>16; |
665 | 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", |
@@ -697,10 +641,10 @@ static void smc911x_tx(struct net_device *dev) | |||
697 | 641 | ||
698 | static int smc911x_phy_read(struct net_device *dev, int phyaddr, int phyreg) | 642 | static int smc911x_phy_read(struct net_device *dev, int phyaddr, int phyreg) |
699 | { | 643 | { |
700 | unsigned long ioaddr = dev->base_addr; | 644 | struct smc911x_local *lp = netdev_priv(dev); |
701 | unsigned int phydata; | 645 | unsigned int phydata; |
702 | 646 | ||
703 | SMC_GET_MII(phyreg, phyaddr, phydata); | 647 | SMC_GET_MII(lp, phyreg, phyaddr, phydata); |
704 | 648 | ||
705 | 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", |
706 | __FUNCTION__, phyaddr, phyreg, phydata); | 650 | __FUNCTION__, phyaddr, phyreg, phydata); |
@@ -714,12 +658,12 @@ static int smc911x_phy_read(struct net_device *dev, int phyaddr, int phyreg) | |||
714 | static void smc911x_phy_write(struct net_device *dev, int phyaddr, int phyreg, | 658 | static void smc911x_phy_write(struct net_device *dev, int phyaddr, int phyreg, |
715 | int phydata) | 659 | int phydata) |
716 | { | 660 | { |
717 | unsigned long ioaddr = dev->base_addr; | 661 | struct smc911x_local *lp = netdev_priv(dev); |
718 | 662 | ||
719 | 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", |
720 | __FUNCTION__, phyaddr, phyreg, phydata); | 664 | __FUNCTION__, phyaddr, phyreg, phydata); |
721 | 665 | ||
722 | SMC_SET_MII(phyreg, phyaddr, phydata); | 666 | SMC_SET_MII(lp, phyreg, phyaddr, phydata); |
723 | } | 667 | } |
724 | 668 | ||
725 | /* | 669 | /* |
@@ -728,7 +672,6 @@ static void smc911x_phy_write(struct net_device *dev, int phyaddr, int phyreg, | |||
728 | */ | 672 | */ |
729 | static void smc911x_phy_detect(struct net_device *dev) | 673 | static void smc911x_phy_detect(struct net_device *dev) |
730 | { | 674 | { |
731 | unsigned long ioaddr = dev->base_addr; | ||
732 | struct smc911x_local *lp = netdev_priv(dev); | 675 | struct smc911x_local *lp = netdev_priv(dev); |
733 | int phyaddr; | 676 | int phyaddr; |
734 | unsigned int cfg, id1, id2; | 677 | unsigned int cfg, id1, id2; |
@@ -744,30 +687,30 @@ static void smc911x_phy_detect(struct net_device *dev) | |||
744 | switch(lp->version) { | 687 | switch(lp->version) { |
745 | case 0x115: | 688 | case 0x115: |
746 | case 0x117: | 689 | case 0x117: |
747 | cfg = SMC_GET_HW_CFG(); | 690 | cfg = SMC_GET_HW_CFG(lp); |
748 | if (cfg & HW_CFG_EXT_PHY_DET_) { | 691 | if (cfg & HW_CFG_EXT_PHY_DET_) { |
749 | cfg &= ~HW_CFG_PHY_CLK_SEL_; | 692 | cfg &= ~HW_CFG_PHY_CLK_SEL_; |
750 | cfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS_; | 693 | cfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS_; |
751 | SMC_SET_HW_CFG(cfg); | 694 | SMC_SET_HW_CFG(lp, cfg); |
752 | udelay(10); /* Wait for clocks to stop */ | 695 | udelay(10); /* Wait for clocks to stop */ |
753 | 696 | ||
754 | cfg |= HW_CFG_EXT_PHY_EN_; | 697 | cfg |= HW_CFG_EXT_PHY_EN_; |
755 | SMC_SET_HW_CFG(cfg); | 698 | SMC_SET_HW_CFG(lp, cfg); |
756 | udelay(10); /* Wait for clocks to stop */ | 699 | udelay(10); /* Wait for clocks to stop */ |
757 | 700 | ||
758 | cfg &= ~HW_CFG_PHY_CLK_SEL_; | 701 | cfg &= ~HW_CFG_PHY_CLK_SEL_; |
759 | cfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY_; | 702 | cfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY_; |
760 | SMC_SET_HW_CFG(cfg); | 703 | SMC_SET_HW_CFG(lp, cfg); |
761 | udelay(10); /* Wait for clocks to stop */ | 704 | udelay(10); /* Wait for clocks to stop */ |
762 | 705 | ||
763 | cfg |= HW_CFG_SMI_SEL_; | 706 | cfg |= HW_CFG_SMI_SEL_; |
764 | SMC_SET_HW_CFG(cfg); | 707 | SMC_SET_HW_CFG(lp, cfg); |
765 | 708 | ||
766 | for (phyaddr = 1; phyaddr < 32; ++phyaddr) { | 709 | for (phyaddr = 1; phyaddr < 32; ++phyaddr) { |
767 | 710 | ||
768 | /* Read the PHY identifiers */ | 711 | /* Read the PHY identifiers */ |
769 | SMC_GET_PHY_ID1(phyaddr & 31, id1); | 712 | SMC_GET_PHY_ID1(lp, phyaddr & 31, id1); |
770 | SMC_GET_PHY_ID2(phyaddr & 31, id2); | 713 | SMC_GET_PHY_ID2(lp, phyaddr & 31, id2); |
771 | 714 | ||
772 | /* Make sure it is a valid identifier */ | 715 | /* Make sure it is a valid identifier */ |
773 | if (id1 != 0x0000 && id1 != 0xffff && | 716 | if (id1 != 0x0000 && id1 != 0xffff && |
@@ -782,8 +725,8 @@ static void smc911x_phy_detect(struct net_device *dev) | |||
782 | } | 725 | } |
783 | default: | 726 | default: |
784 | /* Internal media only */ | 727 | /* Internal media only */ |
785 | SMC_GET_PHY_ID1(1, id1); | 728 | SMC_GET_PHY_ID1(lp, 1, id1); |
786 | SMC_GET_PHY_ID2(1, id2); | 729 | SMC_GET_PHY_ID2(lp, 1, id2); |
787 | /* Save the PHY's address */ | 730 | /* Save the PHY's address */ |
788 | lp->mii.phy_id = 1; | 731 | lp->mii.phy_id = 1; |
789 | lp->phy_type = id1 << 16 | id2; | 732 | lp->phy_type = id1 << 16 | id2; |
@@ -800,16 +743,15 @@ static void smc911x_phy_detect(struct net_device *dev) | |||
800 | static int smc911x_phy_fixed(struct net_device *dev) | 743 | static int smc911x_phy_fixed(struct net_device *dev) |
801 | { | 744 | { |
802 | struct smc911x_local *lp = netdev_priv(dev); | 745 | struct smc911x_local *lp = netdev_priv(dev); |
803 | unsigned long ioaddr = dev->base_addr; | ||
804 | int phyaddr = lp->mii.phy_id; | 746 | int phyaddr = lp->mii.phy_id; |
805 | int bmcr; | 747 | int bmcr; |
806 | 748 | ||
807 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); | 749 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); |
808 | 750 | ||
809 | /* Enter Link Disable state */ | 751 | /* Enter Link Disable state */ |
810 | SMC_GET_PHY_BMCR(phyaddr, bmcr); | 752 | SMC_GET_PHY_BMCR(lp, phyaddr, bmcr); |
811 | bmcr |= BMCR_PDOWN; | 753 | bmcr |= BMCR_PDOWN; |
812 | SMC_SET_PHY_BMCR(phyaddr, bmcr); | 754 | SMC_SET_PHY_BMCR(lp, phyaddr, bmcr); |
813 | 755 | ||
814 | /* | 756 | /* |
815 | * Set our fixed capabilities | 757 | * Set our fixed capabilities |
@@ -823,11 +765,11 @@ static int smc911x_phy_fixed(struct net_device *dev) | |||
823 | bmcr |= BMCR_SPEED100; | 765 | bmcr |= BMCR_SPEED100; |
824 | 766 | ||
825 | /* Write our capabilities to the phy control register */ | 767 | /* Write our capabilities to the phy control register */ |
826 | SMC_SET_PHY_BMCR(phyaddr, bmcr); | 768 | SMC_SET_PHY_BMCR(lp, phyaddr, bmcr); |
827 | 769 | ||
828 | /* Re-Configure the Receive/Phy Control register */ | 770 | /* Re-Configure the Receive/Phy Control register */ |
829 | bmcr &= ~BMCR_PDOWN; | 771 | bmcr &= ~BMCR_PDOWN; |
830 | SMC_SET_PHY_BMCR(phyaddr, bmcr); | 772 | SMC_SET_PHY_BMCR(lp, phyaddr, bmcr); |
831 | 773 | ||
832 | return 1; | 774 | return 1; |
833 | } | 775 | } |
@@ -847,7 +789,6 @@ static int smc911x_phy_fixed(struct net_device *dev) | |||
847 | static int smc911x_phy_reset(struct net_device *dev, int phy) | 789 | static int smc911x_phy_reset(struct net_device *dev, int phy) |
848 | { | 790 | { |
849 | struct smc911x_local *lp = netdev_priv(dev); | 791 | struct smc911x_local *lp = netdev_priv(dev); |
850 | unsigned long ioaddr = dev->base_addr; | ||
851 | int timeout; | 792 | int timeout; |
852 | unsigned long flags; | 793 | unsigned long flags; |
853 | unsigned int reg; | 794 | unsigned int reg; |
@@ -855,15 +796,15 @@ static int smc911x_phy_reset(struct net_device *dev, int phy) | |||
855 | DBG(SMC_DEBUG_FUNC, "%s: --> %s()\n", dev->name, __FUNCTION__); | 796 | DBG(SMC_DEBUG_FUNC, "%s: --> %s()\n", dev->name, __FUNCTION__); |
856 | 797 | ||
857 | spin_lock_irqsave(&lp->lock, flags); | 798 | spin_lock_irqsave(&lp->lock, flags); |
858 | reg = SMC_GET_PMT_CTRL(); | 799 | reg = SMC_GET_PMT_CTRL(lp); |
859 | reg &= ~0xfffff030; | 800 | reg &= ~0xfffff030; |
860 | reg |= PMT_CTRL_PHY_RST_; | 801 | reg |= PMT_CTRL_PHY_RST_; |
861 | SMC_SET_PMT_CTRL(reg); | 802 | SMC_SET_PMT_CTRL(lp, reg); |
862 | spin_unlock_irqrestore(&lp->lock, flags); | 803 | spin_unlock_irqrestore(&lp->lock, flags); |
863 | for (timeout = 2; timeout; timeout--) { | 804 | for (timeout = 2; timeout; timeout--) { |
864 | msleep(50); | 805 | msleep(50); |
865 | spin_lock_irqsave(&lp->lock, flags); | 806 | spin_lock_irqsave(&lp->lock, flags); |
866 | reg = SMC_GET_PMT_CTRL(); | 807 | reg = SMC_GET_PMT_CTRL(lp); |
867 | spin_unlock_irqrestore(&lp->lock, flags); | 808 | spin_unlock_irqrestore(&lp->lock, flags); |
868 | if (!(reg & PMT_CTRL_PHY_RST_)) { | 809 | if (!(reg & PMT_CTRL_PHY_RST_)) { |
869 | /* extra delay required because the phy may | 810 | /* extra delay required because the phy may |
@@ -888,13 +829,13 @@ static int smc911x_phy_reset(struct net_device *dev, int phy) | |||
888 | */ | 829 | */ |
889 | static void smc911x_phy_powerdown(struct net_device *dev, int phy) | 830 | static void smc911x_phy_powerdown(struct net_device *dev, int phy) |
890 | { | 831 | { |
891 | unsigned long ioaddr = dev->base_addr; | 832 | struct smc911x_local *lp = netdev_priv(dev); |
892 | unsigned int bmcr; | 833 | unsigned int bmcr; |
893 | 834 | ||
894 | /* Enter Link Disable state */ | 835 | /* Enter Link Disable state */ |
895 | SMC_GET_PHY_BMCR(phy, bmcr); | 836 | SMC_GET_PHY_BMCR(lp, phy, bmcr); |
896 | bmcr |= BMCR_PDOWN; | 837 | bmcr |= BMCR_PDOWN; |
897 | SMC_SET_PHY_BMCR(phy, bmcr); | 838 | SMC_SET_PHY_BMCR(lp, phy, bmcr); |
898 | } | 839 | } |
899 | 840 | ||
900 | /* | 841 | /* |
@@ -908,7 +849,6 @@ static void smc911x_phy_powerdown(struct net_device *dev, int phy) | |||
908 | static void smc911x_phy_check_media(struct net_device *dev, int init) | 849 | static void smc911x_phy_check_media(struct net_device *dev, int init) |
909 | { | 850 | { |
910 | struct smc911x_local *lp = netdev_priv(dev); | 851 | struct smc911x_local *lp = netdev_priv(dev); |
911 | unsigned long ioaddr = dev->base_addr; | ||
912 | int phyaddr = lp->mii.phy_id; | 852 | int phyaddr = lp->mii.phy_id; |
913 | unsigned int bmcr, cr; | 853 | unsigned int bmcr, cr; |
914 | 854 | ||
@@ -916,8 +856,8 @@ static void smc911x_phy_check_media(struct net_device *dev, int init) | |||
916 | 856 | ||
917 | if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) { | 857 | if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) { |
918 | /* duplex state has changed */ | 858 | /* duplex state has changed */ |
919 | SMC_GET_PHY_BMCR(phyaddr, bmcr); | 859 | SMC_GET_PHY_BMCR(lp, phyaddr, bmcr); |
920 | SMC_GET_MAC_CR(cr); | 860 | SMC_GET_MAC_CR(lp, cr); |
921 | if (lp->mii.full_duplex) { | 861 | if (lp->mii.full_duplex) { |
922 | 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); |
923 | bmcr |= BMCR_FULLDPLX; | 863 | bmcr |= BMCR_FULLDPLX; |
@@ -927,8 +867,8 @@ static void smc911x_phy_check_media(struct net_device *dev, int init) | |||
927 | bmcr &= ~BMCR_FULLDPLX; | 867 | bmcr &= ~BMCR_FULLDPLX; |
928 | cr &= ~MAC_CR_RCVOWN_; | 868 | cr &= ~MAC_CR_RCVOWN_; |
929 | } | 869 | } |
930 | SMC_SET_PHY_BMCR(phyaddr, bmcr); | 870 | SMC_SET_PHY_BMCR(lp, phyaddr, bmcr); |
931 | SMC_SET_MAC_CR(cr); | 871 | SMC_SET_MAC_CR(lp, cr); |
932 | } | 872 | } |
933 | } | 873 | } |
934 | 874 | ||
@@ -946,7 +886,6 @@ static void smc911x_phy_configure(struct work_struct *work) | |||
946 | struct smc911x_local *lp = container_of(work, struct smc911x_local, | 886 | struct smc911x_local *lp = container_of(work, struct smc911x_local, |
947 | phy_configure); | 887 | phy_configure); |
948 | struct net_device *dev = lp->netdev; | 888 | struct net_device *dev = lp->netdev; |
949 | unsigned long ioaddr = dev->base_addr; | ||
950 | int phyaddr = lp->mii.phy_id; | 889 | int phyaddr = lp->mii.phy_id; |
951 | int my_phy_caps; /* My PHY capabilities */ | 890 | int my_phy_caps; /* My PHY capabilities */ |
952 | int my_ad_caps; /* My Advertised capabilities */ | 891 | int my_ad_caps; /* My Advertised capabilities */ |
@@ -971,7 +910,7 @@ static void smc911x_phy_configure(struct work_struct *work) | |||
971 | * Enable PHY Interrupts (for register 18) | 910 | * Enable PHY Interrupts (for register 18) |
972 | * Interrupts listed here are enabled | 911 | * Interrupts listed here are enabled |
973 | */ | 912 | */ |
974 | SMC_SET_PHY_INT_MASK(phyaddr, PHY_INT_MASK_ENERGY_ON_ | | 913 | SMC_SET_PHY_INT_MASK(lp, phyaddr, PHY_INT_MASK_ENERGY_ON_ | |
975 | PHY_INT_MASK_ANEG_COMP_ | PHY_INT_MASK_REMOTE_FAULT_ | | 914 | PHY_INT_MASK_ANEG_COMP_ | PHY_INT_MASK_REMOTE_FAULT_ | |
976 | PHY_INT_MASK_LINK_DOWN_); | 915 | PHY_INT_MASK_LINK_DOWN_); |
977 | 916 | ||
@@ -982,7 +921,7 @@ static void smc911x_phy_configure(struct work_struct *work) | |||
982 | } | 921 | } |
983 | 922 | ||
984 | /* Copy our capabilities from MII_BMSR to MII_ADVERTISE */ | 923 | /* Copy our capabilities from MII_BMSR to MII_ADVERTISE */ |
985 | SMC_GET_PHY_BMSR(phyaddr, my_phy_caps); | 924 | SMC_GET_PHY_BMSR(lp, phyaddr, my_phy_caps); |
986 | if (!(my_phy_caps & BMSR_ANEGCAPABLE)) { | 925 | if (!(my_phy_caps & BMSR_ANEGCAPABLE)) { |
987 | printk(KERN_INFO "Auto negotiation NOT supported\n"); | 926 | printk(KERN_INFO "Auto negotiation NOT supported\n"); |
988 | smc911x_phy_fixed(dev); | 927 | smc911x_phy_fixed(dev); |
@@ -1011,7 +950,7 @@ static void smc911x_phy_configure(struct work_struct *work) | |||
1011 | my_ad_caps &= ~(ADVERTISE_100FULL|ADVERTISE_10FULL); | 950 | my_ad_caps &= ~(ADVERTISE_100FULL|ADVERTISE_10FULL); |
1012 | 951 | ||
1013 | /* Update our Auto-Neg Advertisement Register */ | 952 | /* Update our Auto-Neg Advertisement Register */ |
1014 | SMC_SET_PHY_MII_ADV(phyaddr, my_ad_caps); | 953 | SMC_SET_PHY_MII_ADV(lp, phyaddr, my_ad_caps); |
1015 | lp->mii.advertising = my_ad_caps; | 954 | lp->mii.advertising = my_ad_caps; |
1016 | 955 | ||
1017 | /* | 956 | /* |
@@ -1020,13 +959,13 @@ static void smc911x_phy_configure(struct work_struct *work) | |||
1020 | * the link does not come up. | 959 | * the link does not come up. |
1021 | */ | 960 | */ |
1022 | udelay(10); | 961 | udelay(10); |
1023 | SMC_GET_PHY_MII_ADV(phyaddr, status); | 962 | SMC_GET_PHY_MII_ADV(lp, phyaddr, status); |
1024 | 963 | ||
1025 | 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); |
1026 | 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); |
1027 | 966 | ||
1028 | /* Restart auto-negotiation process in order to advertise my caps */ | 967 | /* Restart auto-negotiation process in order to advertise my caps */ |
1029 | SMC_SET_PHY_BMCR(phyaddr, BMCR_ANENABLE | BMCR_ANRESTART); | 968 | SMC_SET_PHY_BMCR(lp, phyaddr, BMCR_ANENABLE | BMCR_ANRESTART); |
1030 | 969 | ||
1031 | smc911x_phy_check_media(dev, 1); | 970 | smc911x_phy_check_media(dev, 1); |
1032 | 971 | ||
@@ -1043,7 +982,6 @@ smc911x_phy_configure_exit: | |||
1043 | static void smc911x_phy_interrupt(struct net_device *dev) | 982 | static void smc911x_phy_interrupt(struct net_device *dev) |
1044 | { | 983 | { |
1045 | struct smc911x_local *lp = netdev_priv(dev); | 984 | struct smc911x_local *lp = netdev_priv(dev); |
1046 | unsigned long ioaddr = dev->base_addr; | ||
1047 | int phyaddr = lp->mii.phy_id; | 985 | int phyaddr = lp->mii.phy_id; |
1048 | int status; | 986 | int status; |
1049 | 987 | ||
@@ -1054,11 +992,11 @@ static void smc911x_phy_interrupt(struct net_device *dev) | |||
1054 | 992 | ||
1055 | smc911x_phy_check_media(dev, 0); | 993 | smc911x_phy_check_media(dev, 0); |
1056 | /* read to clear status bits */ | 994 | /* read to clear status bits */ |
1057 | SMC_GET_PHY_INT_SRC(phyaddr,status); | 995 | SMC_GET_PHY_INT_SRC(lp, phyaddr,status); |
1058 | DBG(SMC_DEBUG_MISC, "%s: PHY interrupt status 0x%04x\n", | 996 | DBG(SMC_DEBUG_MISC, "%s: PHY interrupt status 0x%04x\n", |
1059 | dev->name, status & 0xffff); | 997 | dev->name, status & 0xffff); |
1060 | DBG(SMC_DEBUG_MISC, "%s: AFC_CFG 0x%08x\n", | 998 | DBG(SMC_DEBUG_MISC, "%s: AFC_CFG 0x%08x\n", |
1061 | dev->name, SMC_GET_AFC_CFG()); | 999 | dev->name, SMC_GET_AFC_CFG(lp)); |
1062 | } | 1000 | } |
1063 | 1001 | ||
1064 | /*--- END PHY CONTROL AND CONFIGURATION-------------------------------------*/ | 1002 | /*--- END PHY CONTROL AND CONFIGURATION-------------------------------------*/ |
@@ -1070,7 +1008,6 @@ static void smc911x_phy_interrupt(struct net_device *dev) | |||
1070 | static irqreturn_t smc911x_interrupt(int irq, void *dev_id) | 1008 | static irqreturn_t smc911x_interrupt(int irq, void *dev_id) |
1071 | { | 1009 | { |
1072 | struct net_device *dev = dev_id; | 1010 | struct net_device *dev = dev_id; |
1073 | unsigned long ioaddr = dev->base_addr; | ||
1074 | struct smc911x_local *lp = netdev_priv(dev); | 1011 | struct smc911x_local *lp = netdev_priv(dev); |
1075 | unsigned int status, mask, timeout; | 1012 | unsigned int status, mask, timeout; |
1076 | unsigned int rx_overrun=0, cr, pkts; | 1013 | unsigned int rx_overrun=0, cr, pkts; |
@@ -1081,21 +1018,21 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id) | |||
1081 | spin_lock_irqsave(&lp->lock, flags); | 1018 | spin_lock_irqsave(&lp->lock, flags); |
1082 | 1019 | ||
1083 | /* Spurious interrupt check */ | 1020 | /* Spurious interrupt check */ |
1084 | if ((SMC_GET_IRQ_CFG() & (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) != | 1021 | if ((SMC_GET_IRQ_CFG(lp) & (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) != |
1085 | (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) { | 1022 | (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) { |
1086 | spin_unlock_irqrestore(&lp->lock, flags); | 1023 | spin_unlock_irqrestore(&lp->lock, flags); |
1087 | return IRQ_NONE; | 1024 | return IRQ_NONE; |
1088 | } | 1025 | } |
1089 | 1026 | ||
1090 | mask = SMC_GET_INT_EN(); | 1027 | mask = SMC_GET_INT_EN(lp); |
1091 | SMC_SET_INT_EN(0); | 1028 | SMC_SET_INT_EN(lp, 0); |
1092 | 1029 | ||
1093 | /* set a timeout value, so I don't stay here forever */ | 1030 | /* set a timeout value, so I don't stay here forever */ |
1094 | timeout = 8; | 1031 | timeout = 8; |
1095 | 1032 | ||
1096 | 1033 | ||
1097 | do { | 1034 | do { |
1098 | status = SMC_GET_INT(); | 1035 | status = SMC_GET_INT(lp); |
1099 | 1036 | ||
1100 | DBG(SMC_DEBUG_MISC, "%s: INT 0x%08x MASK 0x%08x OUTSIDE MASK 0x%08x\n", | 1037 | DBG(SMC_DEBUG_MISC, "%s: INT 0x%08x MASK 0x%08x OUTSIDE MASK 0x%08x\n", |
1101 | dev->name, status, mask, status & ~mask); | 1038 | dev->name, status, mask, status & ~mask); |
@@ -1106,53 +1043,53 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id) | |||
1106 | 1043 | ||
1107 | /* Handle SW interrupt condition */ | 1044 | /* Handle SW interrupt condition */ |
1108 | if (status & INT_STS_SW_INT_) { | 1045 | if (status & INT_STS_SW_INT_) { |
1109 | SMC_ACK_INT(INT_STS_SW_INT_); | 1046 | SMC_ACK_INT(lp, INT_STS_SW_INT_); |
1110 | mask &= ~INT_EN_SW_INT_EN_; | 1047 | mask &= ~INT_EN_SW_INT_EN_; |
1111 | } | 1048 | } |
1112 | /* Handle various error conditions */ | 1049 | /* Handle various error conditions */ |
1113 | if (status & INT_STS_RXE_) { | 1050 | if (status & INT_STS_RXE_) { |
1114 | SMC_ACK_INT(INT_STS_RXE_); | 1051 | SMC_ACK_INT(lp, INT_STS_RXE_); |
1115 | dev->stats.rx_errors++; | 1052 | dev->stats.rx_errors++; |
1116 | } | 1053 | } |
1117 | if (status & INT_STS_RXDFH_INT_) { | 1054 | if (status & INT_STS_RXDFH_INT_) { |
1118 | SMC_ACK_INT(INT_STS_RXDFH_INT_); | 1055 | SMC_ACK_INT(lp, INT_STS_RXDFH_INT_); |
1119 | dev->stats.rx_dropped+=SMC_GET_RX_DROP(); | 1056 | dev->stats.rx_dropped+=SMC_GET_RX_DROP(lp); |
1120 | } | 1057 | } |
1121 | /* Undocumented interrupt-what is the right thing to do here? */ | 1058 | /* Undocumented interrupt-what is the right thing to do here? */ |
1122 | if (status & INT_STS_RXDF_INT_) { | 1059 | if (status & INT_STS_RXDF_INT_) { |
1123 | SMC_ACK_INT(INT_STS_RXDF_INT_); | 1060 | SMC_ACK_INT(lp, INT_STS_RXDF_INT_); |
1124 | } | 1061 | } |
1125 | 1062 | ||
1126 | /* Rx Data FIFO exceeds set level */ | 1063 | /* Rx Data FIFO exceeds set level */ |
1127 | if (status & INT_STS_RDFL_) { | 1064 | if (status & INT_STS_RDFL_) { |
1128 | if (IS_REV_A(lp->revision)) { | 1065 | if (IS_REV_A(lp->revision)) { |
1129 | rx_overrun=1; | 1066 | rx_overrun=1; |
1130 | SMC_GET_MAC_CR(cr); | 1067 | SMC_GET_MAC_CR(lp, cr); |
1131 | cr &= ~MAC_CR_RXEN_; | 1068 | cr &= ~MAC_CR_RXEN_; |
1132 | SMC_SET_MAC_CR(cr); | 1069 | SMC_SET_MAC_CR(lp, cr); |
1133 | DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name); | 1070 | DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name); |
1134 | dev->stats.rx_errors++; | 1071 | dev->stats.rx_errors++; |
1135 | dev->stats.rx_fifo_errors++; | 1072 | dev->stats.rx_fifo_errors++; |
1136 | } | 1073 | } |
1137 | SMC_ACK_INT(INT_STS_RDFL_); | 1074 | SMC_ACK_INT(lp, INT_STS_RDFL_); |
1138 | } | 1075 | } |
1139 | if (status & INT_STS_RDFO_) { | 1076 | if (status & INT_STS_RDFO_) { |
1140 | if (!IS_REV_A(lp->revision)) { | 1077 | if (!IS_REV_A(lp->revision)) { |
1141 | SMC_GET_MAC_CR(cr); | 1078 | SMC_GET_MAC_CR(lp, cr); |
1142 | cr &= ~MAC_CR_RXEN_; | 1079 | cr &= ~MAC_CR_RXEN_; |
1143 | SMC_SET_MAC_CR(cr); | 1080 | SMC_SET_MAC_CR(lp, cr); |
1144 | rx_overrun=1; | 1081 | rx_overrun=1; |
1145 | DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name); | 1082 | DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name); |
1146 | dev->stats.rx_errors++; | 1083 | dev->stats.rx_errors++; |
1147 | dev->stats.rx_fifo_errors++; | 1084 | dev->stats.rx_fifo_errors++; |
1148 | } | 1085 | } |
1149 | SMC_ACK_INT(INT_STS_RDFO_); | 1086 | SMC_ACK_INT(lp, INT_STS_RDFO_); |
1150 | } | 1087 | } |
1151 | /* Handle receive condition */ | 1088 | /* Handle receive condition */ |
1152 | if ((status & INT_STS_RSFL_) || rx_overrun) { | 1089 | if ((status & INT_STS_RSFL_) || rx_overrun) { |
1153 | unsigned int fifo; | 1090 | unsigned int fifo; |
1154 | DBG(SMC_DEBUG_RX, "%s: RX irq\n", dev->name); | 1091 | DBG(SMC_DEBUG_RX, "%s: RX irq\n", dev->name); |
1155 | fifo = SMC_GET_RX_FIFO_INF(); | 1092 | fifo = SMC_GET_RX_FIFO_INF(lp); |
1156 | pkts = (fifo & RX_FIFO_INF_RXSUSED_) >> 16; | 1093 | pkts = (fifo & RX_FIFO_INF_RXSUSED_) >> 16; |
1157 | DBG(SMC_DEBUG_RX, "%s: Rx FIFO pkts %d, bytes %d\n", | 1094 | DBG(SMC_DEBUG_RX, "%s: Rx FIFO pkts %d, bytes %d\n", |
1158 | dev->name, pkts, fifo & 0xFFFF ); | 1095 | dev->name, pkts, fifo & 0xFFFF ); |
@@ -1163,61 +1100,61 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id) | |||
1163 | DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, | 1100 | DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, |
1164 | "%s: RX DMA active\n", dev->name); | 1101 | "%s: RX DMA active\n", dev->name); |
1165 | /* The DMA is already running so up the IRQ threshold */ | 1102 | /* The DMA is already running so up the IRQ threshold */ |
1166 | fifo = SMC_GET_FIFO_INT() & ~0xFF; | 1103 | fifo = SMC_GET_FIFO_INT(lp) & ~0xFF; |
1167 | fifo |= pkts & 0xFF; | 1104 | fifo |= pkts & 0xFF; |
1168 | DBG(SMC_DEBUG_RX, | 1105 | DBG(SMC_DEBUG_RX, |
1169 | "%s: Setting RX stat FIFO threshold to %d\n", | 1106 | "%s: Setting RX stat FIFO threshold to %d\n", |
1170 | dev->name, fifo & 0xff); | 1107 | dev->name, fifo & 0xff); |
1171 | SMC_SET_FIFO_INT(fifo); | 1108 | SMC_SET_FIFO_INT(lp, fifo); |
1172 | } else | 1109 | } else |
1173 | #endif | 1110 | #endif |
1174 | smc911x_rcv(dev); | 1111 | smc911x_rcv(dev); |
1175 | } | 1112 | } |
1176 | SMC_ACK_INT(INT_STS_RSFL_); | 1113 | SMC_ACK_INT(lp, INT_STS_RSFL_); |
1177 | } | 1114 | } |
1178 | /* Handle transmit FIFO available */ | 1115 | /* Handle transmit FIFO available */ |
1179 | if (status & INT_STS_TDFA_) { | 1116 | if (status & INT_STS_TDFA_) { |
1180 | DBG(SMC_DEBUG_TX, "%s: TX data FIFO space available irq\n", dev->name); | 1117 | DBG(SMC_DEBUG_TX, "%s: TX data FIFO space available irq\n", dev->name); |
1181 | SMC_SET_FIFO_TDA(0xFF); | 1118 | SMC_SET_FIFO_TDA(lp, 0xFF); |
1182 | lp->tx_throttle = 0; | 1119 | lp->tx_throttle = 0; |
1183 | #ifdef SMC_USE_DMA | 1120 | #ifdef SMC_USE_DMA |
1184 | if (!lp->txdma_active) | 1121 | if (!lp->txdma_active) |
1185 | #endif | 1122 | #endif |
1186 | netif_wake_queue(dev); | 1123 | netif_wake_queue(dev); |
1187 | SMC_ACK_INT(INT_STS_TDFA_); | 1124 | SMC_ACK_INT(lp, INT_STS_TDFA_); |
1188 | } | 1125 | } |
1189 | /* Handle transmit done condition */ | 1126 | /* Handle transmit done condition */ |
1190 | #if 1 | 1127 | #if 1 |
1191 | if (status & (INT_STS_TSFL_ | INT_STS_GPT_INT_)) { | 1128 | if (status & (INT_STS_TSFL_ | INT_STS_GPT_INT_)) { |
1192 | DBG(SMC_DEBUG_TX | SMC_DEBUG_MISC, | 1129 | DBG(SMC_DEBUG_TX | SMC_DEBUG_MISC, |
1193 | "%s: Tx stat FIFO limit (%d) /GPT irq\n", | 1130 | "%s: Tx stat FIFO limit (%d) /GPT irq\n", |
1194 | dev->name, (SMC_GET_FIFO_INT() & 0x00ff0000) >> 16); | 1131 | dev->name, (SMC_GET_FIFO_INT(lp) & 0x00ff0000) >> 16); |
1195 | smc911x_tx(dev); | 1132 | smc911x_tx(dev); |
1196 | SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000); | 1133 | SMC_SET_GPT_CFG(lp, GPT_CFG_TIMER_EN_ | 10000); |
1197 | SMC_ACK_INT(INT_STS_TSFL_); | 1134 | SMC_ACK_INT(lp, INT_STS_TSFL_); |
1198 | SMC_ACK_INT(INT_STS_TSFL_ | INT_STS_GPT_INT_); | 1135 | SMC_ACK_INT(lp, INT_STS_TSFL_ | INT_STS_GPT_INT_); |
1199 | } | 1136 | } |
1200 | #else | 1137 | #else |
1201 | if (status & INT_STS_TSFL_) { | 1138 | if (status & INT_STS_TSFL_) { |
1202 | DBG(SMC_DEBUG_TX, "%s: TX status FIFO limit (%d) irq \n", dev->name, ); | 1139 | DBG(SMC_DEBUG_TX, "%s: TX status FIFO limit (%d) irq \n", dev->name, ); |
1203 | smc911x_tx(dev); | 1140 | smc911x_tx(dev); |
1204 | SMC_ACK_INT(INT_STS_TSFL_); | 1141 | SMC_ACK_INT(lp, INT_STS_TSFL_); |
1205 | } | 1142 | } |
1206 | 1143 | ||
1207 | if (status & INT_STS_GPT_INT_) { | 1144 | if (status & INT_STS_GPT_INT_) { |
1208 | DBG(SMC_DEBUG_RX, "%s: IRQ_CFG 0x%08x FIFO_INT 0x%08x RX_CFG 0x%08x\n", | 1145 | DBG(SMC_DEBUG_RX, "%s: IRQ_CFG 0x%08x FIFO_INT 0x%08x RX_CFG 0x%08x\n", |
1209 | dev->name, | 1146 | dev->name, |
1210 | SMC_GET_IRQ_CFG(), | 1147 | SMC_GET_IRQ_CFG(lp), |
1211 | SMC_GET_FIFO_INT(), | 1148 | SMC_GET_FIFO_INT(lp), |
1212 | SMC_GET_RX_CFG()); | 1149 | SMC_GET_RX_CFG(lp)); |
1213 | DBG(SMC_DEBUG_RX, "%s: Rx Stat FIFO Used 0x%02x " | 1150 | DBG(SMC_DEBUG_RX, "%s: Rx Stat FIFO Used 0x%02x " |
1214 | "Data FIFO Used 0x%04x Stat FIFO 0x%08x\n", | 1151 | "Data FIFO Used 0x%04x Stat FIFO 0x%08x\n", |
1215 | dev->name, | 1152 | dev->name, |
1216 | (SMC_GET_RX_FIFO_INF() & 0x00ff0000) >> 16, | 1153 | (SMC_GET_RX_FIFO_INF(lp) & 0x00ff0000) >> 16, |
1217 | SMC_GET_RX_FIFO_INF() & 0xffff, | 1154 | SMC_GET_RX_FIFO_INF(lp) & 0xffff, |
1218 | SMC_GET_RX_STS_FIFO_PEEK()); | 1155 | SMC_GET_RX_STS_FIFO_PEEK(lp)); |
1219 | SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000); | 1156 | SMC_SET_GPT_CFG(lp, GPT_CFG_TIMER_EN_ | 10000); |
1220 | SMC_ACK_INT(INT_STS_GPT_INT_); | 1157 | SMC_ACK_INT(lp, INT_STS_GPT_INT_); |
1221 | } | 1158 | } |
1222 | #endif | 1159 | #endif |
1223 | 1160 | ||
@@ -1225,12 +1162,12 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id) | |||
1225 | if (status & INT_STS_PHY_INT_) { | 1162 | if (status & INT_STS_PHY_INT_) { |
1226 | DBG(SMC_DEBUG_MISC, "%s: PHY irq\n", dev->name); | 1163 | DBG(SMC_DEBUG_MISC, "%s: PHY irq\n", dev->name); |
1227 | smc911x_phy_interrupt(dev); | 1164 | smc911x_phy_interrupt(dev); |
1228 | SMC_ACK_INT(INT_STS_PHY_INT_); | 1165 | SMC_ACK_INT(lp, INT_STS_PHY_INT_); |
1229 | } | 1166 | } |
1230 | } while (--timeout); | 1167 | } while (--timeout); |
1231 | 1168 | ||
1232 | /* restore mask state */ | 1169 | /* restore mask state */ |
1233 | SMC_SET_INT_EN(mask); | 1170 | SMC_SET_INT_EN(lp, mask); |
1234 | 1171 | ||
1235 | DBG(SMC_DEBUG_MISC, "%s: Interrupt done (%d loops)\n", | 1172 | DBG(SMC_DEBUG_MISC, "%s: Interrupt done (%d loops)\n", |
1236 | dev->name, 8-timeout); | 1173 | dev->name, 8-timeout); |
@@ -1332,22 +1269,21 @@ static void smc911x_poll_controller(struct net_device *dev) | |||
1332 | static void smc911x_timeout(struct net_device *dev) | 1269 | static void smc911x_timeout(struct net_device *dev) |
1333 | { | 1270 | { |
1334 | struct smc911x_local *lp = netdev_priv(dev); | 1271 | struct smc911x_local *lp = netdev_priv(dev); |
1335 | unsigned long ioaddr = dev->base_addr; | ||
1336 | int status, mask; | 1272 | int status, mask; |
1337 | unsigned long flags; | 1273 | unsigned long flags; |
1338 | 1274 | ||
1339 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); | 1275 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); |
1340 | 1276 | ||
1341 | spin_lock_irqsave(&lp->lock, flags); | 1277 | spin_lock_irqsave(&lp->lock, flags); |
1342 | status = SMC_GET_INT(); | 1278 | status = SMC_GET_INT(lp); |
1343 | mask = SMC_GET_INT_EN(); | 1279 | mask = SMC_GET_INT_EN(lp); |
1344 | spin_unlock_irqrestore(&lp->lock, flags); | 1280 | spin_unlock_irqrestore(&lp->lock, flags); |
1345 | DBG(SMC_DEBUG_MISC, "%s: INT 0x%02x MASK 0x%02x \n", | 1281 | DBG(SMC_DEBUG_MISC, "%s: INT 0x%02x MASK 0x%02x \n", |
1346 | dev->name, status, mask); | 1282 | dev->name, status, mask); |
1347 | 1283 | ||
1348 | /* Dump the current TX FIFO contents and restart */ | 1284 | /* Dump the current TX FIFO contents and restart */ |
1349 | mask = SMC_GET_TX_CFG(); | 1285 | mask = SMC_GET_TX_CFG(lp); |
1350 | SMC_SET_TX_CFG(mask | TX_CFG_TXS_DUMP_ | TX_CFG_TXD_DUMP_); | 1286 | SMC_SET_TX_CFG(lp, mask | TX_CFG_TXS_DUMP_ | TX_CFG_TXD_DUMP_); |
1351 | /* | 1287 | /* |
1352 | * Reconfiguring the PHY doesn't seem like a bad idea here, but | 1288 | * Reconfiguring the PHY doesn't seem like a bad idea here, but |
1353 | * smc911x_phy_configure() calls msleep() which calls schedule_timeout() | 1289 | * smc911x_phy_configure() calls msleep() which calls schedule_timeout() |
@@ -1370,7 +1306,6 @@ static void smc911x_timeout(struct net_device *dev) | |||
1370 | static void smc911x_set_multicast_list(struct net_device *dev) | 1306 | static void smc911x_set_multicast_list(struct net_device *dev) |
1371 | { | 1307 | { |
1372 | struct smc911x_local *lp = netdev_priv(dev); | 1308 | struct smc911x_local *lp = netdev_priv(dev); |
1373 | unsigned long ioaddr = dev->base_addr; | ||
1374 | unsigned int multicast_table[2]; | 1309 | unsigned int multicast_table[2]; |
1375 | unsigned int mcr, update_multicast = 0; | 1310 | unsigned int mcr, update_multicast = 0; |
1376 | unsigned long flags; | 1311 | unsigned long flags; |
@@ -1378,7 +1313,7 @@ static void smc911x_set_multicast_list(struct net_device *dev) | |||
1378 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); | 1313 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); |
1379 | 1314 | ||
1380 | spin_lock_irqsave(&lp->lock, flags); | 1315 | spin_lock_irqsave(&lp->lock, flags); |
1381 | SMC_GET_MAC_CR(mcr); | 1316 | SMC_GET_MAC_CR(lp, mcr); |
1382 | spin_unlock_irqrestore(&lp->lock, flags); | 1317 | spin_unlock_irqrestore(&lp->lock, flags); |
1383 | 1318 | ||
1384 | if (dev->flags & IFF_PROMISC) { | 1319 | if (dev->flags & IFF_PROMISC) { |
@@ -1455,13 +1390,13 @@ static void smc911x_set_multicast_list(struct net_device *dev) | |||
1455 | } | 1390 | } |
1456 | 1391 | ||
1457 | spin_lock_irqsave(&lp->lock, flags); | 1392 | spin_lock_irqsave(&lp->lock, flags); |
1458 | SMC_SET_MAC_CR(mcr); | 1393 | SMC_SET_MAC_CR(lp, mcr); |
1459 | if (update_multicast) { | 1394 | if (update_multicast) { |
1460 | DBG(SMC_DEBUG_MISC, | 1395 | DBG(SMC_DEBUG_MISC, |
1461 | "%s: update mcast hash table 0x%08x 0x%08x\n", | 1396 | "%s: update mcast hash table 0x%08x 0x%08x\n", |
1462 | dev->name, multicast_table[0], multicast_table[1]); | 1397 | dev->name, multicast_table[0], multicast_table[1]); |
1463 | SMC_SET_HASHL(multicast_table[0]); | 1398 | SMC_SET_HASHL(lp, multicast_table[0]); |
1464 | SMC_SET_HASHH(multicast_table[1]); | 1399 | SMC_SET_HASHH(lp, multicast_table[1]); |
1465 | } | 1400 | } |
1466 | spin_unlock_irqrestore(&lp->lock, flags); | 1401 | spin_unlock_irqrestore(&lp->lock, flags); |
1467 | } | 1402 | } |
@@ -1545,7 +1480,6 @@ static int | |||
1545 | smc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) | 1480 | smc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) |
1546 | { | 1481 | { |
1547 | struct smc911x_local *lp = netdev_priv(dev); | 1482 | struct smc911x_local *lp = netdev_priv(dev); |
1548 | unsigned long ioaddr = dev->base_addr; | ||
1549 | int ret, status; | 1483 | int ret, status; |
1550 | unsigned long flags; | 1484 | unsigned long flags; |
1551 | 1485 | ||
@@ -1573,7 +1507,7 @@ smc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1573 | else | 1507 | else |
1574 | cmd->transceiver = XCVR_EXTERNAL; | 1508 | cmd->transceiver = XCVR_EXTERNAL; |
1575 | cmd->port = 0; | 1509 | cmd->port = 0; |
1576 | SMC_GET_PHY_SPECIAL(lp->mii.phy_id, status); | 1510 | SMC_GET_PHY_SPECIAL(lp, lp->mii.phy_id, status); |
1577 | cmd->duplex = | 1511 | cmd->duplex = |
1578 | (status & (PHY_SPECIAL_SPD_10FULL_ | PHY_SPECIAL_SPD_100FULL_)) ? | 1512 | (status & (PHY_SPECIAL_SPD_10FULL_ | PHY_SPECIAL_SPD_100FULL_)) ? |
1579 | DUPLEX_FULL : DUPLEX_HALF; | 1513 | DUPLEX_FULL : DUPLEX_HALF; |
@@ -1654,7 +1588,6 @@ static int smc911x_ethtool_getregslen(struct net_device *dev) | |||
1654 | static void smc911x_ethtool_getregs(struct net_device *dev, | 1588 | static void smc911x_ethtool_getregs(struct net_device *dev, |
1655 | struct ethtool_regs* regs, void *buf) | 1589 | struct ethtool_regs* regs, void *buf) |
1656 | { | 1590 | { |
1657 | unsigned long ioaddr = dev->base_addr; | ||
1658 | struct smc911x_local *lp = netdev_priv(dev); | 1591 | struct smc911x_local *lp = netdev_priv(dev); |
1659 | unsigned long flags; | 1592 | unsigned long flags; |
1660 | u32 reg,i,j=0; | 1593 | u32 reg,i,j=0; |
@@ -1662,17 +1595,17 @@ static void smc911x_ethtool_getregs(struct net_device *dev, | |||
1662 | 1595 | ||
1663 | regs->version = lp->version; | 1596 | regs->version = lp->version; |
1664 | for(i=ID_REV;i<=E2P_CMD;i+=4) { | 1597 | for(i=ID_REV;i<=E2P_CMD;i+=4) { |
1665 | data[j++] = SMC_inl(ioaddr,i); | 1598 | data[j++] = SMC_inl(lp, i); |
1666 | } | 1599 | } |
1667 | for(i=MAC_CR;i<=WUCSR;i++) { | 1600 | for(i=MAC_CR;i<=WUCSR;i++) { |
1668 | spin_lock_irqsave(&lp->lock, flags); | 1601 | spin_lock_irqsave(&lp->lock, flags); |
1669 | SMC_GET_MAC_CSR(i, reg); | 1602 | SMC_GET_MAC_CSR(lp, i, reg); |
1670 | spin_unlock_irqrestore(&lp->lock, flags); | 1603 | spin_unlock_irqrestore(&lp->lock, flags); |
1671 | data[j++] = reg; | 1604 | data[j++] = reg; |
1672 | } | 1605 | } |
1673 | for(i=0;i<=31;i++) { | 1606 | for(i=0;i<=31;i++) { |
1674 | spin_lock_irqsave(&lp->lock, flags); | 1607 | spin_lock_irqsave(&lp->lock, flags); |
1675 | SMC_GET_MII(i, lp->mii.phy_id, reg); | 1608 | SMC_GET_MII(lp, i, lp->mii.phy_id, reg); |
1676 | spin_unlock_irqrestore(&lp->lock, flags); | 1609 | spin_unlock_irqrestore(&lp->lock, flags); |
1677 | data[j++] = reg & 0xFFFF; | 1610 | data[j++] = reg & 0xFFFF; |
1678 | } | 1611 | } |
@@ -1680,11 +1613,11 @@ static void smc911x_ethtool_getregs(struct net_device *dev, | |||
1680 | 1613 | ||
1681 | static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev) | 1614 | static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev) |
1682 | { | 1615 | { |
1683 | unsigned long ioaddr = dev->base_addr; | 1616 | struct smc911x_local *lp = netdev_priv(dev); |
1684 | unsigned int timeout; | 1617 | unsigned int timeout; |
1685 | int e2p_cmd; | 1618 | int e2p_cmd; |
1686 | 1619 | ||
1687 | e2p_cmd = SMC_GET_E2P_CMD(); | 1620 | e2p_cmd = SMC_GET_E2P_CMD(lp); |
1688 | for(timeout=10;(e2p_cmd & E2P_CMD_EPC_BUSY_) && timeout; timeout--) { | 1621 | for(timeout=10;(e2p_cmd & E2P_CMD_EPC_BUSY_) && timeout; timeout--) { |
1689 | if (e2p_cmd & E2P_CMD_EPC_TIMEOUT_) { | 1622 | if (e2p_cmd & E2P_CMD_EPC_TIMEOUT_) { |
1690 | PRINTK("%s: %s timeout waiting for EEPROM to respond\n", | 1623 | PRINTK("%s: %s timeout waiting for EEPROM to respond\n", |
@@ -1692,7 +1625,7 @@ static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev) | |||
1692 | return -EFAULT; | 1625 | return -EFAULT; |
1693 | } | 1626 | } |
1694 | mdelay(1); | 1627 | mdelay(1); |
1695 | e2p_cmd = SMC_GET_E2P_CMD(); | 1628 | e2p_cmd = SMC_GET_E2P_CMD(lp); |
1696 | } | 1629 | } |
1697 | if (timeout == 0) { | 1630 | if (timeout == 0) { |
1698 | PRINTK("%s: %s timeout waiting for EEPROM CMD not busy\n", | 1631 | PRINTK("%s: %s timeout waiting for EEPROM CMD not busy\n", |
@@ -1705,12 +1638,12 @@ static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev) | |||
1705 | static inline int smc911x_ethtool_write_eeprom_cmd(struct net_device *dev, | 1638 | static inline int smc911x_ethtool_write_eeprom_cmd(struct net_device *dev, |
1706 | int cmd, int addr) | 1639 | int cmd, int addr) |
1707 | { | 1640 | { |
1708 | unsigned long ioaddr = dev->base_addr; | 1641 | struct smc911x_local *lp = netdev_priv(dev); |
1709 | int ret; | 1642 | int ret; |
1710 | 1643 | ||
1711 | if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) | 1644 | if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) |
1712 | return ret; | 1645 | return ret; |
1713 | SMC_SET_E2P_CMD(E2P_CMD_EPC_BUSY_ | | 1646 | SMC_SET_E2P_CMD(lp, E2P_CMD_EPC_BUSY_ | |
1714 | ((cmd) & (0x7<<28)) | | 1647 | ((cmd) & (0x7<<28)) | |
1715 | ((addr) & 0xFF)); | 1648 | ((addr) & 0xFF)); |
1716 | return 0; | 1649 | return 0; |
@@ -1719,24 +1652,24 @@ static inline int smc911x_ethtool_write_eeprom_cmd(struct net_device *dev, | |||
1719 | static inline int smc911x_ethtool_read_eeprom_byte(struct net_device *dev, | 1652 | static inline int smc911x_ethtool_read_eeprom_byte(struct net_device *dev, |
1720 | u8 *data) | 1653 | u8 *data) |
1721 | { | 1654 | { |
1722 | unsigned long ioaddr = dev->base_addr; | 1655 | struct smc911x_local *lp = netdev_priv(dev); |
1723 | int ret; | 1656 | int ret; |
1724 | 1657 | ||
1725 | if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) | 1658 | if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) |
1726 | return ret; | 1659 | return ret; |
1727 | *data = SMC_GET_E2P_DATA(); | 1660 | *data = SMC_GET_E2P_DATA(lp); |
1728 | return 0; | 1661 | return 0; |
1729 | } | 1662 | } |
1730 | 1663 | ||
1731 | static inline int smc911x_ethtool_write_eeprom_byte(struct net_device *dev, | 1664 | static inline int smc911x_ethtool_write_eeprom_byte(struct net_device *dev, |
1732 | u8 data) | 1665 | u8 data) |
1733 | { | 1666 | { |
1734 | unsigned long ioaddr = dev->base_addr; | 1667 | struct smc911x_local *lp = netdev_priv(dev); |
1735 | int ret; | 1668 | int ret; |
1736 | 1669 | ||
1737 | if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) | 1670 | if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0) |
1738 | return ret; | 1671 | return ret; |
1739 | SMC_SET_E2P_DATA(data); | 1672 | SMC_SET_E2P_DATA(lp, data); |
1740 | return 0; | 1673 | return 0; |
1741 | } | 1674 | } |
1742 | 1675 | ||
@@ -1803,8 +1736,9 @@ static const struct ethtool_ops smc911x_ethtool_ops = { | |||
1803 | * This routine has a simple purpose -- make the SMC chip generate an | 1736 | * This routine has a simple purpose -- make the SMC chip generate an |
1804 | * interrupt, so an auto-detect routine can detect it, and find the IRQ, | 1737 | * interrupt, so an auto-detect routine can detect it, and find the IRQ, |
1805 | */ | 1738 | */ |
1806 | static int __init smc911x_findirq(unsigned long ioaddr) | 1739 | static int __init smc911x_findirq(struct net_device *dev) |
1807 | { | 1740 | { |
1741 | struct smc911x_local *lp = netdev_priv(dev); | ||
1808 | int timeout = 20; | 1742 | int timeout = 20; |
1809 | unsigned long cookie; | 1743 | unsigned long cookie; |
1810 | 1744 | ||
@@ -1816,7 +1750,7 @@ static int __init smc911x_findirq(unsigned long ioaddr) | |||
1816 | * Force a SW interrupt | 1750 | * Force a SW interrupt |
1817 | */ | 1751 | */ |
1818 | 1752 | ||
1819 | SMC_SET_INT_EN(INT_EN_SW_INT_EN_); | 1753 | SMC_SET_INT_EN(lp, INT_EN_SW_INT_EN_); |
1820 | 1754 | ||
1821 | /* | 1755 | /* |
1822 | * Wait until positive that the interrupt has been generated | 1756 | * Wait until positive that the interrupt has been generated |
@@ -1824,7 +1758,7 @@ static int __init smc911x_findirq(unsigned long ioaddr) | |||
1824 | do { | 1758 | do { |
1825 | int int_status; | 1759 | int int_status; |
1826 | udelay(10); | 1760 | udelay(10); |
1827 | int_status = SMC_GET_INT_EN(); | 1761 | int_status = SMC_GET_INT_EN(lp); |
1828 | if (int_status & INT_EN_SW_INT_EN_) | 1762 | if (int_status & INT_EN_SW_INT_EN_) |
1829 | break; /* got the interrupt */ | 1763 | break; /* got the interrupt */ |
1830 | } while (--timeout); | 1764 | } while (--timeout); |
@@ -1837,7 +1771,7 @@ static int __init smc911x_findirq(unsigned long ioaddr) | |||
1837 | */ | 1771 | */ |
1838 | 1772 | ||
1839 | /* and disable all interrupts again */ | 1773 | /* and disable all interrupts again */ |
1840 | SMC_SET_INT_EN(0); | 1774 | SMC_SET_INT_EN(lp, 0); |
1841 | 1775 | ||
1842 | /* and return what I found */ | 1776 | /* and return what I found */ |
1843 | return probe_irq_off(cookie); | 1777 | return probe_irq_off(cookie); |
@@ -1866,17 +1800,18 @@ static int __init smc911x_findirq(unsigned long ioaddr) | |||
1866 | * o actually GRAB the irq. | 1800 | * o actually GRAB the irq. |
1867 | * o GRAB the region | 1801 | * o GRAB the region |
1868 | */ | 1802 | */ |
1869 | static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr) | 1803 | static int __init smc911x_probe(struct net_device *dev) |
1870 | { | 1804 | { |
1871 | struct smc911x_local *lp = netdev_priv(dev); | 1805 | struct smc911x_local *lp = netdev_priv(dev); |
1872 | int i, retval; | 1806 | int i, retval; |
1873 | unsigned int val, chip_id, revision; | 1807 | unsigned int val, chip_id, revision; |
1874 | const char *version_string; | 1808 | const char *version_string; |
1809 | unsigned long irq_flags; | ||
1875 | 1810 | ||
1876 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); | 1811 | DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__); |
1877 | 1812 | ||
1878 | /* First, see if the endian word is recognized */ | 1813 | /* First, see if the endian word is recognized */ |
1879 | val = SMC_GET_BYTE_TEST(); | 1814 | val = SMC_GET_BYTE_TEST(lp); |
1880 | DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val); | 1815 | DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val); |
1881 | if (val != 0x87654321) { | 1816 | if (val != 0x87654321) { |
1882 | printk(KERN_ERR "Invalid chip endian 0x08%x\n",val); | 1817 | printk(KERN_ERR "Invalid chip endian 0x08%x\n",val); |
@@ -1889,7 +1824,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr) | |||
1889 | * recognize. These might need to be added to later, | 1824 | * recognize. These might need to be added to later, |
1890 | * as future revisions could be added. | 1825 | * as future revisions could be added. |
1891 | */ | 1826 | */ |
1892 | chip_id = SMC_GET_PN(); | 1827 | chip_id = SMC_GET_PN(lp); |
1893 | DBG(SMC_DEBUG_MISC, "%s: id probe returned 0x%04x\n", CARDNAME, chip_id); | 1828 | DBG(SMC_DEBUG_MISC, "%s: id probe returned 0x%04x\n", CARDNAME, chip_id); |
1894 | for(i=0;chip_ids[i].id != 0; i++) { | 1829 | for(i=0;chip_ids[i].id != 0; i++) { |
1895 | if (chip_ids[i].id == chip_id) break; | 1830 | if (chip_ids[i].id == chip_id) break; |
@@ -1901,7 +1836,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr) | |||
1901 | } | 1836 | } |
1902 | version_string = chip_ids[i].name; | 1837 | version_string = chip_ids[i].name; |
1903 | 1838 | ||
1904 | revision = SMC_GET_REV(); | 1839 | revision = SMC_GET_REV(lp); |
1905 | DBG(SMC_DEBUG_MISC, "%s: revision = 0x%04x\n", CARDNAME, revision); | 1840 | DBG(SMC_DEBUG_MISC, "%s: revision = 0x%04x\n", CARDNAME, revision); |
1906 | 1841 | ||
1907 | /* At this point I'll assume that the chip is an SMC911x. */ | 1842 | /* At this point I'll assume that the chip is an SMC911x. */ |
@@ -1915,7 +1850,6 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr) | |||
1915 | } | 1850 | } |
1916 | 1851 | ||
1917 | /* fill in some of the fields */ | 1852 | /* fill in some of the fields */ |
1918 | dev->base_addr = ioaddr; | ||
1919 | lp->version = chip_ids[i].id; | 1853 | lp->version = chip_ids[i].id; |
1920 | lp->revision = revision; | 1854 | lp->revision = revision; |
1921 | lp->tx_fifo_kb = tx_fifo_kb; | 1855 | lp->tx_fifo_kb = tx_fifo_kb; |
@@ -1974,7 +1908,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr) | |||
1974 | spin_lock_init(&lp->lock); | 1908 | spin_lock_init(&lp->lock); |
1975 | 1909 | ||
1976 | /* Get the MAC address */ | 1910 | /* Get the MAC address */ |
1977 | SMC_GET_MAC_ADDR(dev->dev_addr); | 1911 | SMC_GET_MAC_ADDR(lp, dev->dev_addr); |
1978 | 1912 | ||
1979 | /* now, reset the chip, and put it into a known state */ | 1913 | /* now, reset the chip, and put it into a known state */ |
1980 | smc911x_reset(dev); | 1914 | smc911x_reset(dev); |
@@ -1991,7 +1925,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr) | |||
1991 | 1925 | ||
1992 | trials = 3; | 1926 | trials = 3; |
1993 | while (trials--) { | 1927 | while (trials--) { |
1994 | dev->irq = smc911x_findirq(ioaddr); | 1928 | dev->irq = smc911x_findirq(dev); |
1995 | if (dev->irq) | 1929 | if (dev->irq) |
1996 | break; | 1930 | break; |
1997 | /* kick the card and try again */ | 1931 | /* kick the card and try again */ |
@@ -2039,9 +1973,15 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr) | |||
2039 | lp->ctl_rfduplx = 1; | 1973 | lp->ctl_rfduplx = 1; |
2040 | lp->ctl_rspeed = 100; | 1974 | lp->ctl_rspeed = 100; |
2041 | 1975 | ||
1976 | #ifdef SMC_DYNAMIC_BUS_CONFIG | ||
1977 | irq_flags = lp->cfg.irq_flags; | ||
1978 | #else | ||
1979 | irq_flags = IRQF_SHARED | SMC_IRQ_SENSE; | ||
1980 | #endif | ||
1981 | |||
2042 | /* Grab the IRQ */ | 1982 | /* Grab the IRQ */ |
2043 | retval = request_irq(dev->irq, &smc911x_interrupt, | 1983 | retval = request_irq(dev->irq, &smc911x_interrupt, |
2044 | IRQF_SHARED | SMC_IRQ_SENSE, dev->name, dev); | 1984 | irq_flags, dev->name, dev); |
2045 | if (retval) | 1985 | if (retval) |
2046 | goto err_out; | 1986 | goto err_out; |
2047 | 1987 | ||
@@ -2111,6 +2051,7 @@ err_out: | |||
2111 | */ | 2051 | */ |
2112 | static int smc911x_drv_probe(struct platform_device *pdev) | 2052 | static int smc911x_drv_probe(struct platform_device *pdev) |
2113 | { | 2053 | { |
2054 | struct smc91x_platdata *pd = pdev->dev.platform_data; | ||
2114 | struct net_device *ndev; | 2055 | struct net_device *ndev; |
2115 | struct resource *res; | 2056 | struct resource *res; |
2116 | struct smc911x_local *lp; | 2057 | struct smc911x_local *lp; |
@@ -2144,6 +2085,13 @@ static int smc911x_drv_probe(struct platform_device *pdev) | |||
2144 | ndev->irq = platform_get_irq(pdev, 0); | 2085 | ndev->irq = platform_get_irq(pdev, 0); |
2145 | lp = netdev_priv(ndev); | 2086 | lp = netdev_priv(ndev); |
2146 | lp->netdev = ndev; | 2087 | lp->netdev = ndev; |
2088 | #ifdef SMC_DYNAMIC_BUS_CONFIG | ||
2089 | if (!pd) { | ||
2090 | ret = -EINVAL; | ||
2091 | goto release_both; | ||
2092 | } | ||
2093 | memcpy(&lp->cfg, pd, sizeof(lp->cfg)); | ||
2094 | #endif | ||
2147 | 2095 | ||
2148 | addr = ioremap(res->start, SMC911X_IO_EXTENT); | 2096 | addr = ioremap(res->start, SMC911X_IO_EXTENT); |
2149 | if (!addr) { | 2097 | if (!addr) { |
@@ -2152,7 +2100,9 @@ static int smc911x_drv_probe(struct platform_device *pdev) | |||
2152 | } | 2100 | } |
2153 | 2101 | ||
2154 | platform_set_drvdata(pdev, ndev); | 2102 | platform_set_drvdata(pdev, ndev); |
2155 | ret = smc911x_probe(ndev, (unsigned long)addr); | 2103 | lp->base = addr; |
2104 | ndev->base_addr = res->start; | ||
2105 | ret = smc911x_probe(ndev); | ||
2156 | if (ret != 0) { | 2106 | if (ret != 0) { |
2157 | platform_set_drvdata(pdev, NULL); | 2107 | platform_set_drvdata(pdev, NULL); |
2158 | iounmap(addr); | 2108 | iounmap(addr); |
@@ -2176,6 +2126,7 @@ out: | |||
2176 | static int smc911x_drv_remove(struct platform_device *pdev) | 2126 | static int smc911x_drv_remove(struct platform_device *pdev) |
2177 | { | 2127 | { |
2178 | struct net_device *ndev = platform_get_drvdata(pdev); | 2128 | struct net_device *ndev = platform_get_drvdata(pdev); |
2129 | struct smc911x_local *lp = netdev_priv(ndev); | ||
2179 | struct resource *res; | 2130 | struct resource *res; |
2180 | 2131 | ||
2181 | DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__); | 2132 | DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__); |
@@ -2187,7 +2138,6 @@ static int smc911x_drv_remove(struct platform_device *pdev) | |||
2187 | 2138 | ||
2188 | #ifdef SMC_USE_DMA | 2139 | #ifdef SMC_USE_DMA |
2189 | { | 2140 | { |
2190 | struct smc911x_local *lp = netdev_priv(ndev); | ||
2191 | if (lp->rxdma != -1) { | 2141 | if (lp->rxdma != -1) { |
2192 | SMC_DMA_FREE(dev, lp->rxdma); | 2142 | SMC_DMA_FREE(dev, lp->rxdma); |
2193 | } | 2143 | } |
@@ -2196,7 +2146,7 @@ static int smc911x_drv_remove(struct platform_device *pdev) | |||
2196 | } | 2146 | } |
2197 | } | 2147 | } |
2198 | #endif | 2148 | #endif |
2199 | iounmap((void *)ndev->base_addr); | 2149 | iounmap(lp->base); |
2200 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2150 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
2201 | release_mem_region(res->start, SMC911X_IO_EXTENT); | 2151 | release_mem_region(res->start, SMC911X_IO_EXTENT); |
2202 | 2152 | ||
@@ -2207,7 +2157,7 @@ static int smc911x_drv_remove(struct platform_device *pdev) | |||
2207 | static int smc911x_drv_suspend(struct platform_device *dev, pm_message_t state) | 2157 | static int smc911x_drv_suspend(struct platform_device *dev, pm_message_t state) |
2208 | { | 2158 | { |
2209 | struct net_device *ndev = platform_get_drvdata(dev); | 2159 | struct net_device *ndev = platform_get_drvdata(dev); |
2210 | unsigned long ioaddr = ndev->base_addr; | 2160 | struct smc911x_local *lp = netdev_priv(ndev); |
2211 | 2161 | ||
2212 | DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__); | 2162 | DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__); |
2213 | if (ndev) { | 2163 | if (ndev) { |
@@ -2216,7 +2166,7 @@ static int smc911x_drv_suspend(struct platform_device *dev, pm_message_t state) | |||
2216 | smc911x_shutdown(ndev); | 2166 | smc911x_shutdown(ndev); |
2217 | #if POWER_DOWN | 2167 | #if POWER_DOWN |
2218 | /* Set D2 - Energy detect only setting */ | 2168 | /* Set D2 - Energy detect only setting */ |
2219 | SMC_SET_PMT_CTRL(2<<12); | 2169 | SMC_SET_PMT_CTRL(lp, 2<<12); |
2220 | #endif | 2170 | #endif |
2221 | } | 2171 | } |
2222 | } | 2172 | } |