36 #ifdef CONFIG_ARCH_PXA
37 #define SMC_USE_PXA_DMA 1
38 #define SMC_USE_16BIT 0
39 #define SMC_USE_32BIT 1
40 #define SMC_IRQ_SENSE IRQF_TRIGGER_FALLING
41 #elif defined(CONFIG_SH_MAGIC_PANEL_R2)
42 #define SMC_USE_16BIT 0
43 #define SMC_USE_32BIT 1
44 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
45 #elif defined(CONFIG_ARCH_OMAP3)
46 #define SMC_USE_16BIT 0
47 #define SMC_USE_32BIT 1
48 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
49 #define SMC_MEM_RESERVED 1
50 #elif defined(CONFIG_ARCH_OMAP2)
51 #define SMC_USE_16BIT 0
52 #define SMC_USE_32BIT 1
53 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
54 #define SMC_MEM_RESERVED 1
60 #define SMC_DYNAMIC_BUS_CONFIG
63 #ifdef SMC_USE_PXA_DMA
109 struct sk_buff *current_rx_skb;
110 struct sk_buff *current_tx_skb;
114 #ifdef SMC_DYNAMIC_BUS_CONFIG
123 #ifdef SMC_DYNAMIC_BUS_CONFIG
129 return readl(ioaddr);
132 return readw(ioaddr) | (
readw(ioaddr + 2) << 16);
148 writew(value & 0xffff, ioaddr);
149 writew(value >> 16, ioaddr + 2);
162 readsl(ioaddr, addr, count);
167 readsw(ioaddr, addr, count * 2);
175 void *addr,
unsigned int count)
185 writesw(ioaddr, addr, count * 2);
193 #define SMC_inl(lp, r) ((readw((lp)->base + (r)) & 0xFFFF) + (readw((lp)->base + (r) + 2) << 16))
194 #define SMC_outl(v, lp, r) \
196 writew(v & 0xFFFF, (lp)->base + (r)); \
197 writew(v >> 16, (lp)->base + (r) + 2); \
199 #define SMC_insl(lp, r, p, l) readsw((short*)((lp)->base + (r)), p, l*2)
200 #define SMC_outsl(lp, r, p, l) writesw((short*)((lp)->base + (r)), p, l*2)
203 #define SMC_inl(lp, r) readl((lp)->base + (r))
204 #define SMC_outl(v, lp, r) writel(v, (lp)->base + (r))
205 #define SMC_insl(lp, r, p, l) readsl((int*)((lp)->base + (r)), p, l)
206 #define SMC_outsl(lp, r, p, l) writesl((int*)((lp)->base + (r)), p, l)
212 #ifdef SMC_USE_PXA_DMA
214 #include <mach/dma.h>
221 #define SMC_DMA_REQUEST(dev, handler) \
222 pxa_request_dma(dev->name, DMA_PRIO_LOW, handler, dev)
224 #define SMC_DMA_FREE(dev, dma) \
227 #define SMC_DMA_ACK_IRQ(dev, dma) \
229 if (DCSR(dma) & DCSR_BUSERR) { \
230 printk("%s: DMA %d bus error!\n", dev->name, dma); \
232 DCSR(dma) = DCSR_STARTINTR|DCSR_ENDINTR|DCSR_BUSERR; \
241 static int rx_dmalen, tx_dmalen;
245 #define SMC_insl(lp, r, p, l) \
246 smc_pxa_dma_insl(lp, lp->physaddr, r, lp->rxdma, p, l)
263 DTADR(dma) = rx_dmabuf;
273 #define SMC_outsl(lp, r, p, l) \
274 smc_pxa_dma_outsl(lp, lp->physaddr, r, lp->txdma, p, l)
278 int reg,
int dma,
u_char *buf,
int len)
291 DSADR(dma) = tx_dmabuf;
303 #define SMC911X_TX_FIFO_LOW_THRESHOLD (1536*2)
305 #define SMC911X_IO_EXTENT 0x100
307 #define SMC911X_EEPROM_LEN 7
312 #define RX_DATA_FIFO (0x00)
314 #define TX_DATA_FIFO (0x20)
315 #define TX_CMD_A_INT_ON_COMP_ (0x80000000)
316 #define TX_CMD_A_INT_BUF_END_ALGN_ (0x03000000)
317 #define TX_CMD_A_INT_4_BYTE_ALGN_ (0x00000000)
318 #define TX_CMD_A_INT_16_BYTE_ALGN_ (0x01000000)
319 #define TX_CMD_A_INT_32_BYTE_ALGN_ (0x02000000)
320 #define TX_CMD_A_INT_DATA_OFFSET_ (0x001F0000)
321 #define TX_CMD_A_INT_FIRST_SEG_ (0x00002000)
322 #define TX_CMD_A_INT_LAST_SEG_ (0x00001000)
323 #define TX_CMD_A_BUF_SIZE_ (0x000007FF)
324 #define TX_CMD_B_PKT_TAG_ (0xFFFF0000)
325 #define TX_CMD_B_ADD_CRC_DISABLE_ (0x00002000)
326 #define TX_CMD_B_DISABLE_PADDING_ (0x00001000)
327 #define TX_CMD_B_PKT_BYTE_LENGTH_ (0x000007FF)
329 #define RX_STATUS_FIFO (0x40)
330 #define RX_STS_PKT_LEN_ (0x3FFF0000)
331 #define RX_STS_ES_ (0x00008000)
332 #define RX_STS_BCST_ (0x00002000)
333 #define RX_STS_LEN_ERR_ (0x00001000)
334 #define RX_STS_RUNT_ERR_ (0x00000800)
335 #define RX_STS_MCAST_ (0x00000400)
336 #define RX_STS_TOO_LONG_ (0x00000080)
337 #define RX_STS_COLL_ (0x00000040)
338 #define RX_STS_ETH_TYPE_ (0x00000020)
339 #define RX_STS_WDOG_TMT_ (0x00000010)
340 #define RX_STS_MII_ERR_ (0x00000008)
341 #define RX_STS_DRIBBLING_ (0x00000004)
342 #define RX_STS_CRC_ERR_ (0x00000002)
343 #define RX_STATUS_FIFO_PEEK (0x44)
344 #define TX_STATUS_FIFO (0x48)
345 #define TX_STS_TAG_ (0xFFFF0000)
346 #define TX_STS_ES_ (0x00008000)
347 #define TX_STS_LOC_ (0x00000800)
348 #define TX_STS_NO_CARR_ (0x00000400)
349 #define TX_STS_LATE_COLL_ (0x00000200)
350 #define TX_STS_MANY_COLL_ (0x00000100)
351 #define TX_STS_COLL_CNT_ (0x00000078)
352 #define TX_STS_MANY_DEFER_ (0x00000004)
353 #define TX_STS_UNDERRUN_ (0x00000002)
354 #define TX_STS_DEFERRED_ (0x00000001)
355 #define TX_STATUS_FIFO_PEEK (0x4C)
356 #define ID_REV (0x50)
357 #define ID_REV_CHIP_ID_ (0xFFFF0000)
358 #define ID_REV_REV_ID_ (0x0000FFFF)
360 #define INT_CFG (0x54)
361 #define INT_CFG_INT_DEAS_ (0xFF000000)
362 #define INT_CFG_INT_DEAS_CLR_ (0x00004000)
363 #define INT_CFG_INT_DEAS_STS_ (0x00002000)
364 #define INT_CFG_IRQ_INT_ (0x00001000)
365 #define INT_CFG_IRQ_EN_ (0x00000100)
366 #define INT_CFG_IRQ_POL_ (0x00000010)
367 #define INT_CFG_IRQ_TYPE_ (0x00000001)
369 #define INT_STS (0x58)
370 #define INT_STS_SW_INT_ (0x80000000)
371 #define INT_STS_TXSTOP_INT_ (0x02000000)
372 #define INT_STS_RXSTOP_INT_ (0x01000000)
373 #define INT_STS_RXDFH_INT_ (0x00800000)
374 #define INT_STS_RXDF_INT_ (0x00400000)
375 #define INT_STS_TX_IOC_ (0x00200000)
376 #define INT_STS_RXD_INT_ (0x00100000)
377 #define INT_STS_GPT_INT_ (0x00080000)
378 #define INT_STS_PHY_INT_ (0x00040000)
379 #define INT_STS_PME_INT_ (0x00020000)
380 #define INT_STS_TXSO_ (0x00010000)
381 #define INT_STS_RWT_ (0x00008000)
382 #define INT_STS_RXE_ (0x00004000)
383 #define INT_STS_TXE_ (0x00002000)
385 #define INT_STS_TDFU_ (0x00000800)
386 #define INT_STS_TDFO_ (0x00000400)
387 #define INT_STS_TDFA_ (0x00000200)
388 #define INT_STS_TSFF_ (0x00000100)
389 #define INT_STS_TSFL_ (0x00000080)
391 #define INT_STS_RDFO_ (0x00000040)
392 #define INT_STS_RDFL_ (0x00000020)
393 #define INT_STS_RSFF_ (0x00000010)
394 #define INT_STS_RSFL_ (0x00000008)
395 #define INT_STS_GPIO2_INT_ (0x00000004)
396 #define INT_STS_GPIO1_INT_ (0x00000002)
397 #define INT_STS_GPIO0_INT_ (0x00000001)
399 #define INT_EN (0x5C)
400 #define INT_EN_SW_INT_EN_ (0x80000000)
401 #define INT_EN_TXSTOP_INT_EN_ (0x02000000)
402 #define INT_EN_RXSTOP_INT_EN_ (0x01000000)
403 #define INT_EN_RXDFH_INT_EN_ (0x00800000)
405 #define INT_EN_TIOC_INT_EN_ (0x00200000)
406 #define INT_EN_RXD_INT_EN_ (0x00100000)
407 #define INT_EN_GPT_INT_EN_ (0x00080000)
408 #define INT_EN_PHY_INT_EN_ (0x00040000)
409 #define INT_EN_PME_INT_EN_ (0x00020000)
410 #define INT_EN_TXSO_EN_ (0x00010000)
411 #define INT_EN_RWT_EN_ (0x00008000)
412 #define INT_EN_RXE_EN_ (0x00004000)
413 #define INT_EN_TXE_EN_ (0x00002000)
415 #define INT_EN_TDFU_EN_ (0x00000800)
416 #define INT_EN_TDFO_EN_ (0x00000400)
417 #define INT_EN_TDFA_EN_ (0x00000200)
418 #define INT_EN_TSFF_EN_ (0x00000100)
419 #define INT_EN_TSFL_EN_ (0x00000080)
421 #define INT_EN_RDFO_EN_ (0x00000040)
422 #define INT_EN_RDFL_EN_ (0x00000020)
423 #define INT_EN_RSFF_EN_ (0x00000010)
424 #define INT_EN_RSFL_EN_ (0x00000008)
425 #define INT_EN_GPIO2_INT_ (0x00000004)
426 #define INT_EN_GPIO1_INT_ (0x00000002)
427 #define INT_EN_GPIO0_INT_ (0x00000001)
429 #define BYTE_TEST (0x64)
430 #define FIFO_INT (0x68)
431 #define FIFO_INT_TX_AVAIL_LEVEL_ (0xFF000000)
432 #define FIFO_INT_TX_STS_LEVEL_ (0x00FF0000)
433 #define FIFO_INT_RX_AVAIL_LEVEL_ (0x0000FF00)
434 #define FIFO_INT_RX_STS_LEVEL_ (0x000000FF)
436 #define RX_CFG (0x6C)
437 #define RX_CFG_RX_END_ALGN_ (0xC0000000)
438 #define RX_CFG_RX_END_ALGN4_ (0x00000000)
439 #define RX_CFG_RX_END_ALGN16_ (0x40000000)
440 #define RX_CFG_RX_END_ALGN32_ (0x80000000)
441 #define RX_CFG_RX_DMA_CNT_ (0x0FFF0000)
442 #define RX_CFG_RX_DUMP_ (0x00008000)
443 #define RX_CFG_RXDOFF_ (0x00001F00)
446 #define TX_CFG (0x70)
449 #define TX_CFG_TXS_DUMP_ (0x00008000)
450 #define TX_CFG_TXD_DUMP_ (0x00004000)
451 #define TX_CFG_TXSAO_ (0x00000004)
452 #define TX_CFG_TX_ON_ (0x00000002)
453 #define TX_CFG_STOP_TX_ (0x00000001)
455 #define HW_CFG (0x74)
456 #define HW_CFG_TTM_ (0x00200000)
457 #define HW_CFG_SF_ (0x00100000)
458 #define HW_CFG_TX_FIF_SZ_ (0x000F0000)
459 #define HW_CFG_TR_ (0x00003000)
460 #define HW_CFG_PHY_CLK_SEL_ (0x00000060)
461 #define HW_CFG_PHY_CLK_SEL_INT_PHY_ (0x00000000)
462 #define HW_CFG_PHY_CLK_SEL_EXT_PHY_ (0x00000020)
463 #define HW_CFG_PHY_CLK_SEL_CLK_DIS_ (0x00000040)
464 #define HW_CFG_SMI_SEL_ (0x00000010)
465 #define HW_CFG_EXT_PHY_DET_ (0x00000008)
466 #define HW_CFG_EXT_PHY_EN_ (0x00000004)
467 #define HW_CFG_32_16_BIT_MODE_ (0x00000004)
468 #define HW_CFG_SRST_TO_ (0x00000002)
469 #define HW_CFG_SRST_ (0x00000001)
471 #define RX_DP_CTRL (0x78)
472 #define RX_DP_CTRL_RX_FFWD_ (0x80000000)
473 #define RX_DP_CTRL_FFWD_BUSY_ (0x80000000)
475 #define RX_FIFO_INF (0x7C)
476 #define RX_FIFO_INF_RXSUSED_ (0x00FF0000)
477 #define RX_FIFO_INF_RXDUSED_ (0x0000FFFF)
479 #define TX_FIFO_INF (0x80)
480 #define TX_FIFO_INF_TSUSED_ (0x00FF0000)
481 #define TX_FIFO_INF_TDFREE_ (0x0000FFFF)
483 #define PMT_CTRL (0x84)
484 #define PMT_CTRL_PM_MODE_ (0x00003000)
485 #define PMT_CTRL_PHY_RST_ (0x00000400)
486 #define PMT_CTRL_WOL_EN_ (0x00000200)
487 #define PMT_CTRL_ED_EN_ (0x00000100)
488 #define PMT_CTRL_PME_TYPE_ (0x00000040)
489 #define PMT_CTRL_WUPS_ (0x00000030)
490 #define PMT_CTRL_WUPS_NOWAKE_ (0x00000000)
491 #define PMT_CTRL_WUPS_ED_ (0x00000010)
492 #define PMT_CTRL_WUPS_WOL_ (0x00000020)
493 #define PMT_CTRL_WUPS_MULTI_ (0x00000030)
494 #define PMT_CTRL_PME_IND_ (0x00000008)
495 #define PMT_CTRL_PME_POL_ (0x00000004)
496 #define PMT_CTRL_PME_EN_ (0x00000002)
497 #define PMT_CTRL_READY_ (0x00000001)
499 #define GPIO_CFG (0x88)
500 #define GPIO_CFG_LED3_EN_ (0x40000000)
501 #define GPIO_CFG_LED2_EN_ (0x20000000)
502 #define GPIO_CFG_LED1_EN_ (0x10000000)
503 #define GPIO_CFG_GPIO2_INT_POL_ (0x04000000)
504 #define GPIO_CFG_GPIO1_INT_POL_ (0x02000000)
505 #define GPIO_CFG_GPIO0_INT_POL_ (0x01000000)
506 #define GPIO_CFG_EEPR_EN_ (0x00700000)
507 #define GPIO_CFG_GPIOBUF2_ (0x00040000)
508 #define GPIO_CFG_GPIOBUF1_ (0x00020000)
509 #define GPIO_CFG_GPIOBUF0_ (0x00010000)
510 #define GPIO_CFG_GPIODIR2_ (0x00000400)
511 #define GPIO_CFG_GPIODIR1_ (0x00000200)
512 #define GPIO_CFG_GPIODIR0_ (0x00000100)
513 #define GPIO_CFG_GPIOD4_ (0x00000010)
514 #define GPIO_CFG_GPIOD3_ (0x00000008)
515 #define GPIO_CFG_GPIOD2_ (0x00000004)
516 #define GPIO_CFG_GPIOD1_ (0x00000002)
517 #define GPIO_CFG_GPIOD0_ (0x00000001)
519 #define GPT_CFG (0x8C)
520 #define GPT_CFG_TIMER_EN_ (0x20000000)
521 #define GPT_CFG_GPT_LOAD_ (0x0000FFFF)
523 #define GPT_CNT (0x90)
524 #define GPT_CNT_GPT_CNT_ (0x0000FFFF)
526 #define ENDIAN (0x98)
527 #define FREE_RUN (0x9C)
528 #define RX_DROP (0xA0)
529 #define MAC_CSR_CMD (0xA4)
530 #define MAC_CSR_CMD_CSR_BUSY_ (0x80000000)
531 #define MAC_CSR_CMD_R_NOT_W_ (0x40000000)
532 #define MAC_CSR_CMD_CSR_ADDR_ (0x000000FF)
534 #define MAC_CSR_DATA (0xA8)
535 #define AFC_CFG (0xAC)
536 #define AFC_CFG_AFC_HI_ (0x00FF0000)
537 #define AFC_CFG_AFC_LO_ (0x0000FF00)
538 #define AFC_CFG_BACK_DUR_ (0x000000F0)
539 #define AFC_CFG_FCMULT_ (0x00000008)
540 #define AFC_CFG_FCBRD_ (0x00000004)
541 #define AFC_CFG_FCADD_ (0x00000002)
542 #define AFC_CFG_FCANY_ (0x00000001)
544 #define E2P_CMD (0xB0)
545 #define E2P_CMD_EPC_BUSY_ (0x80000000)
546 #define E2P_CMD_EPC_CMD_ (0x70000000)
547 #define E2P_CMD_EPC_CMD_READ_ (0x00000000)
548 #define E2P_CMD_EPC_CMD_EWDS_ (0x10000000)
549 #define E2P_CMD_EPC_CMD_EWEN_ (0x20000000)
550 #define E2P_CMD_EPC_CMD_WRITE_ (0x30000000)
551 #define E2P_CMD_EPC_CMD_WRAL_ (0x40000000)
552 #define E2P_CMD_EPC_CMD_ERASE_ (0x50000000)
553 #define E2P_CMD_EPC_CMD_ERAL_ (0x60000000)
554 #define E2P_CMD_EPC_CMD_RELOAD_ (0x70000000)
555 #define E2P_CMD_EPC_TIMEOUT_ (0x00000200)
556 #define E2P_CMD_MAC_ADDR_LOADED_ (0x00000100)
557 #define E2P_CMD_EPC_ADDR_ (0x000000FF)
559 #define E2P_DATA (0xB4)
560 #define E2P_DATA_EEPROM_DATA_ (0x000000FF)
572 #define MAC_CR (0x01)
575 #define MAC_CR_RXALL_ (0x80000000)
577 #define MAC_CR_HBDIS_ (0x10000000)
578 #define MAC_CR_RCVOWN_ (0x00800000)
579 #define MAC_CR_LOOPBK_ (0x00200000)
580 #define MAC_CR_FDPX_ (0x00100000)
581 #define MAC_CR_MCPAS_ (0x00080000)
582 #define MAC_CR_PRMS_ (0x00040000)
583 #define MAC_CR_INVFILT_ (0x00020000)
584 #define MAC_CR_PASSBAD_ (0x00010000)
585 #define MAC_CR_HFILT_ (0x00008000)
586 #define MAC_CR_HPFILT_ (0x00002000)
587 #define MAC_CR_LCOLL_ (0x00001000)
588 #define MAC_CR_BCAST_ (0x00000800)
589 #define MAC_CR_DISRTY_ (0x00000400)
590 #define MAC_CR_PADSTR_ (0x00000100)
591 #define MAC_CR_BOLMT_MASK_ (0x000000C0)
592 #define MAC_CR_DFCHK_ (0x00000020)
593 #define MAC_CR_TXEN_ (0x00000008)
594 #define MAC_CR_RXEN_ (0x00000004)
601 #define MII_ACC (0x06)
602 #define MII_ACC_PHY_ADDR_ (0x0000F800)
603 #define MII_ACC_MIIRINDA_ (0x000007C0)
604 #define MII_ACC_MII_WRITE_ (0x00000002)
605 #define MII_ACC_MII_BUSY_ (0x00000001)
607 #define MII_DATA (0x07)
610 #define FLOW_FCPT_ (0xFFFF0000)
611 #define FLOW_FCPASS_ (0x00000004)
612 #define FLOW_FCEN_ (0x00000002)
613 #define FLOW_FCBSY_ (0x00000001)
616 #define VLAN1_VTI1_ (0x0000ffff)
619 #define VLAN2_VTI2_ (0x0000ffff)
624 #define WUCSR_GUE_ (0x00000200)
625 #define WUCSR_WUFR_ (0x00000040)
626 #define WUCSR_MPR_ (0x00000020)
627 #define WUCSR_WAKE_EN_ (0x00000004)
628 #define WUCSR_MPEN_ (0x00000002)
639 #define PHY_MODE_CTRL_STS ((u32)17)
641 #define MODE_CTRL_STS_EDPWRDOWN_ ((u16)0x2000)
649 #define MODE_CTRL_STS_ENERGYON_ ((u16)0x0002)
651 #define PHY_INT_SRC ((u32)29)
652 #define PHY_INT_SRC_ENERGY_ON_ ((u16)0x0080)
653 #define PHY_INT_SRC_ANEG_COMP_ ((u16)0x0040)
654 #define PHY_INT_SRC_REMOTE_FAULT_ ((u16)0x0020)
655 #define PHY_INT_SRC_LINK_DOWN_ ((u16)0x0010)
656 #define PHY_INT_SRC_ANEG_LP_ACK_ ((u16)0x0008)
657 #define PHY_INT_SRC_PAR_DET_FAULT_ ((u16)0x0004)
658 #define PHY_INT_SRC_ANEG_PGRX_ ((u16)0x0002)
660 #define PHY_INT_MASK ((u32)30)
661 #define PHY_INT_MASK_ENERGY_ON_ ((u16)0x0080)
662 #define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040)
663 #define PHY_INT_MASK_REMOTE_FAULT_ ((u16)0x0020)
664 #define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010)
665 #define PHY_INT_MASK_ANEG_LP_ACK_ ((u16)0x0008)
666 #define PHY_INT_MASK_PAR_DET_FAULT_ ((u16)0x0004)
667 #define PHY_INT_MASK_ANEG_PGRX_ ((u16)0x0002)
669 #define PHY_SPECIAL ((u32)31)
670 #define PHY_SPECIAL_ANEG_DONE_ ((u16)0x1000)
671 #define PHY_SPECIAL_RES_ ((u16)0x0040)
672 #define PHY_SPECIAL_RES_MASK_ ((u16)0x0FE1)
673 #define PHY_SPECIAL_SPD_ ((u16)0x001C)
674 #define PHY_SPECIAL_SPD_10HALF_ ((u16)0x0004)
675 #define PHY_SPECIAL_SPD_10FULL_ ((u16)0x0014)
676 #define PHY_SPECIAL_SPD_100HALF_ ((u16)0x0008)
677 #define PHY_SPECIAL_SPD_100FULL_ ((u16)0x0018)
679 #define LAN911X_INTERNAL_PHY_ID (0x0007C000)
682 #define CHIP_9115 0x0115
683 #define CHIP_9116 0x0116
684 #define CHIP_9117 0x0117
685 #define CHIP_9118 0x0118
686 #define CHIP_9211 0x9211
687 #define CHIP_9215 0x115A
688 #define CHIP_9217 0x117A
689 #define CHIP_9218 0x118A
696 static const struct chip_id chip_ids[] = {
708 #define IS_REV_A(x) ((x & 0xFFFF)==0)
715 #define SMC_PUSH_DATA(lp, p, l) SMC_outsl( lp, TX_DATA_FIFO, p, (l) >> 2 )
716 #define SMC_PULL_DATA(lp, p, l) SMC_insl ( lp, RX_DATA_FIFO, p, (l) >> 2 )
717 #define SMC_SET_TX_FIFO(lp, x) SMC_outl( x, lp, TX_DATA_FIFO )
718 #define SMC_GET_RX_FIFO(lp) SMC_inl( lp, RX_DATA_FIFO )
722 #define SMC_GET_TX_STS_FIFO(lp) SMC_inl( lp, TX_STATUS_FIFO )
723 #define SMC_GET_RX_STS_FIFO(lp) SMC_inl( lp, RX_STATUS_FIFO )
724 #define SMC_GET_RX_STS_FIFO_PEEK(lp) SMC_inl( lp, RX_STATUS_FIFO_PEEK )
725 #define SMC_GET_PN(lp) (SMC_inl( lp, ID_REV ) >> 16)
726 #define SMC_GET_REV(lp) (SMC_inl( lp, ID_REV ) & 0xFFFF)
727 #define SMC_GET_IRQ_CFG(lp) SMC_inl( lp, INT_CFG )
728 #define SMC_SET_IRQ_CFG(lp, x) SMC_outl( x, lp, INT_CFG )
729 #define SMC_GET_INT(lp) SMC_inl( lp, INT_STS )
730 #define SMC_ACK_INT(lp, x) SMC_outl( x, lp, INT_STS )
731 #define SMC_GET_INT_EN(lp) SMC_inl( lp, INT_EN )
732 #define SMC_SET_INT_EN(lp, x) SMC_outl( x, lp, INT_EN )
733 #define SMC_GET_BYTE_TEST(lp) SMC_inl( lp, BYTE_TEST )
734 #define SMC_SET_BYTE_TEST(lp, x) SMC_outl( x, lp, BYTE_TEST )
735 #define SMC_GET_FIFO_INT(lp) SMC_inl( lp, FIFO_INT )
736 #define SMC_SET_FIFO_INT(lp, x) SMC_outl( x, lp, FIFO_INT )
737 #define SMC_SET_FIFO_TDA(lp, x) \
739 unsigned long __flags; \
741 local_irq_save(__flags); \
742 __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<24); \
743 SMC_SET_FIFO_INT( (lp), __mask | (x)<<24 ); \
744 local_irq_restore(__flags); \
746 #define SMC_SET_FIFO_TSL(lp, x) \
748 unsigned long __flags; \
750 local_irq_save(__flags); \
751 __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<16); \
752 SMC_SET_FIFO_INT( (lp), __mask | (((x) & 0xFF)<<16)); \
753 local_irq_restore(__flags); \
755 #define SMC_SET_FIFO_RSA(lp, x) \
757 unsigned long __flags; \
759 local_irq_save(__flags); \
760 __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<8); \
761 SMC_SET_FIFO_INT( (lp), __mask | (((x) & 0xFF)<<8)); \
762 local_irq_restore(__flags); \
764 #define SMC_SET_FIFO_RSL(lp, x) \
766 unsigned long __flags; \
768 local_irq_save(__flags); \
769 __mask = SMC_GET_FIFO_INT((lp)) & ~0xFF; \
770 SMC_SET_FIFO_INT( (lp),__mask | ((x) & 0xFF)); \
771 local_irq_restore(__flags); \
773 #define SMC_GET_RX_CFG(lp) SMC_inl( lp, RX_CFG )
774 #define SMC_SET_RX_CFG(lp, x) SMC_outl( x, lp, RX_CFG )
775 #define SMC_GET_TX_CFG(lp) SMC_inl( lp, TX_CFG )
776 #define SMC_SET_TX_CFG(lp, x) SMC_outl( x, lp, TX_CFG )
777 #define SMC_GET_HW_CFG(lp) SMC_inl( lp, HW_CFG )
778 #define SMC_SET_HW_CFG(lp, x) SMC_outl( x, lp, HW_CFG )
779 #define SMC_GET_RX_DP_CTRL(lp) SMC_inl( lp, RX_DP_CTRL )
780 #define SMC_SET_RX_DP_CTRL(lp, x) SMC_outl( x, lp, RX_DP_CTRL )
781 #define SMC_GET_PMT_CTRL(lp) SMC_inl( lp, PMT_CTRL )
782 #define SMC_SET_PMT_CTRL(lp, x) SMC_outl( x, lp, PMT_CTRL )
783 #define SMC_GET_GPIO_CFG(lp) SMC_inl( lp, GPIO_CFG )
784 #define SMC_SET_GPIO_CFG(lp, x) SMC_outl( x, lp, GPIO_CFG )
785 #define SMC_GET_RX_FIFO_INF(lp) SMC_inl( lp, RX_FIFO_INF )
786 #define SMC_SET_RX_FIFO_INF(lp, x) SMC_outl( x, lp, RX_FIFO_INF )
787 #define SMC_GET_TX_FIFO_INF(lp) SMC_inl( lp, TX_FIFO_INF )
788 #define SMC_SET_TX_FIFO_INF(lp, x) SMC_outl( x, lp, TX_FIFO_INF )
789 #define SMC_GET_GPT_CFG(lp) SMC_inl( lp, GPT_CFG )
790 #define SMC_SET_GPT_CFG(lp, x) SMC_outl( x, lp, GPT_CFG )
791 #define SMC_GET_RX_DROP(lp) SMC_inl( lp, RX_DROP )
792 #define SMC_SET_RX_DROP(lp, x) SMC_outl( x, lp, RX_DROP )
793 #define SMC_GET_MAC_CMD(lp) SMC_inl( lp, MAC_CSR_CMD )
794 #define SMC_SET_MAC_CMD(lp, x) SMC_outl( x, lp, MAC_CSR_CMD )
795 #define SMC_GET_MAC_DATA(lp) SMC_inl( lp, MAC_CSR_DATA )
796 #define SMC_SET_MAC_DATA(lp, x) SMC_outl( x, lp, MAC_CSR_DATA )
797 #define SMC_GET_AFC_CFG(lp) SMC_inl( lp, AFC_CFG )
798 #define SMC_SET_AFC_CFG(lp, x) SMC_outl( x, lp, AFC_CFG )
799 #define SMC_GET_E2P_CMD(lp) SMC_inl( lp, E2P_CMD )
800 #define SMC_SET_E2P_CMD(lp, x) SMC_outl( x, lp, E2P_CMD )
801 #define SMC_GET_E2P_DATA(lp) SMC_inl( lp, E2P_DATA )
802 #define SMC_SET_E2P_DATA(lp, x) SMC_outl( x, lp, E2P_DATA )
805 #define SMC_GET_MAC_CSR(lp,a,v) \
807 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
808 SMC_SET_MAC_CMD((lp),MAC_CSR_CMD_CSR_BUSY_ | \
809 MAC_CSR_CMD_R_NOT_W_ | (a) ); \
810 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
811 v = SMC_GET_MAC_DATA((lp)); \
813 #define SMC_SET_MAC_CSR(lp,a,v) \
815 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
816 SMC_SET_MAC_DATA((lp), v); \
817 SMC_SET_MAC_CMD((lp), MAC_CSR_CMD_CSR_BUSY_ | (a) ); \
818 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
820 #define SMC_GET_MAC_CR(lp, x) SMC_GET_MAC_CSR( (lp), MAC_CR, x )
821 #define SMC_SET_MAC_CR(lp, x) SMC_SET_MAC_CSR( (lp), MAC_CR, x )
822 #define SMC_GET_ADDRH(lp, x) SMC_GET_MAC_CSR( (lp), ADDRH, x )
823 #define SMC_SET_ADDRH(lp, x) SMC_SET_MAC_CSR( (lp), ADDRH, x )
824 #define SMC_GET_ADDRL(lp, x) SMC_GET_MAC_CSR( (lp), ADDRL, x )
825 #define SMC_SET_ADDRL(lp, x) SMC_SET_MAC_CSR( (lp), ADDRL, x )
826 #define SMC_GET_HASHH(lp, x) SMC_GET_MAC_CSR( (lp), HASHH, x )
827 #define SMC_SET_HASHH(lp, x) SMC_SET_MAC_CSR( (lp), HASHH, x )
828 #define SMC_GET_HASHL(lp, x) SMC_GET_MAC_CSR( (lp), HASHL, x )
829 #define SMC_SET_HASHL(lp, x) SMC_SET_MAC_CSR( (lp), HASHL, x )
830 #define SMC_GET_MII_ACC(lp, x) SMC_GET_MAC_CSR( (lp), MII_ACC, x )
831 #define SMC_SET_MII_ACC(lp, x) SMC_SET_MAC_CSR( (lp), MII_ACC, x )
832 #define SMC_GET_MII_DATA(lp, x) SMC_GET_MAC_CSR( (lp), MII_DATA, x )
833 #define SMC_SET_MII_DATA(lp, x) SMC_SET_MAC_CSR( (lp), MII_DATA, x )
834 #define SMC_GET_FLOW(lp, x) SMC_GET_MAC_CSR( (lp), FLOW, x )
835 #define SMC_SET_FLOW(lp, x) SMC_SET_MAC_CSR( (lp), FLOW, x )
836 #define SMC_GET_VLAN1(lp, x) SMC_GET_MAC_CSR( (lp), VLAN1, x )
837 #define SMC_SET_VLAN1(lp, x) SMC_SET_MAC_CSR( (lp), VLAN1, x )
838 #define SMC_GET_VLAN2(lp, x) SMC_GET_MAC_CSR( (lp), VLAN2, x )
839 #define SMC_SET_VLAN2(lp, x) SMC_SET_MAC_CSR( (lp), VLAN2, x )
840 #define SMC_SET_WUFF(lp, x) SMC_SET_MAC_CSR( (lp), WUFF, x )
841 #define SMC_GET_WUCSR(lp, x) SMC_GET_MAC_CSR( (lp), WUCSR, x )
842 #define SMC_SET_WUCSR(lp, x) SMC_SET_MAC_CSR( (lp), WUCSR, x )
845 #define SMC_GET_MII(lp,a,phy,v) \
849 SMC_GET_MII_ACC((lp), __v); \
850 } while ( __v & MII_ACC_MII_BUSY_ ); \
851 SMC_SET_MII_ACC( (lp), ((phy)<<11) | ((a)<<6) | \
852 MII_ACC_MII_BUSY_); \
854 SMC_GET_MII_ACC( (lp), __v); \
855 } while ( __v & MII_ACC_MII_BUSY_ ); \
856 SMC_GET_MII_DATA((lp), v); \
858 #define SMC_SET_MII(lp,a,phy,v) \
862 SMC_GET_MII_ACC((lp), __v); \
863 } while ( __v & MII_ACC_MII_BUSY_ ); \
864 SMC_SET_MII_DATA((lp), v); \
865 SMC_SET_MII_ACC( (lp), ((phy)<<11) | ((a)<<6) | \
866 MII_ACC_MII_BUSY_ | \
867 MII_ACC_MII_WRITE_ ); \
869 SMC_GET_MII_ACC((lp), __v); \
870 } while ( __v & MII_ACC_MII_BUSY_ ); \
872 #define SMC_GET_PHY_BMCR(lp,phy,x) SMC_GET_MII( (lp), MII_BMCR, phy, x )
873 #define SMC_SET_PHY_BMCR(lp,phy,x) SMC_SET_MII( (lp), MII_BMCR, phy, x )
874 #define SMC_GET_PHY_BMSR(lp,phy,x) SMC_GET_MII( (lp), MII_BMSR, phy, x )
875 #define SMC_GET_PHY_ID1(lp,phy,x) SMC_GET_MII( (lp), MII_PHYSID1, phy, x )
876 #define SMC_GET_PHY_ID2(lp,phy,x) SMC_GET_MII( (lp), MII_PHYSID2, phy, x )
877 #define SMC_GET_PHY_MII_ADV(lp,phy,x) SMC_GET_MII( (lp), MII_ADVERTISE, phy, x )
878 #define SMC_SET_PHY_MII_ADV(lp,phy,x) SMC_SET_MII( (lp), MII_ADVERTISE, phy, x )
879 #define SMC_GET_PHY_MII_LPA(lp,phy,x) SMC_GET_MII( (lp), MII_LPA, phy, x )
880 #define SMC_SET_PHY_MII_LPA(lp,phy,x) SMC_SET_MII( (lp), MII_LPA, phy, x )
881 #define SMC_GET_PHY_CTRL_STS(lp,phy,x) SMC_GET_MII( (lp), PHY_MODE_CTRL_STS, phy, x )
882 #define SMC_SET_PHY_CTRL_STS(lp,phy,x) SMC_SET_MII( (lp), PHY_MODE_CTRL_STS, phy, x )
883 #define SMC_GET_PHY_INT_SRC(lp,phy,x) SMC_GET_MII( (lp), PHY_INT_SRC, phy, x )
884 #define SMC_SET_PHY_INT_SRC(lp,phy,x) SMC_SET_MII( (lp), PHY_INT_SRC, phy, x )
885 #define SMC_GET_PHY_INT_MASK(lp,phy,x) SMC_GET_MII( (lp), PHY_INT_MASK, phy, x )
886 #define SMC_SET_PHY_INT_MASK(lp,phy,x) SMC_SET_MII( (lp), PHY_INT_MASK, phy, x )
887 #define SMC_GET_PHY_SPECIAL(lp,phy,x) SMC_GET_MII( (lp), PHY_SPECIAL, phy, x )
893 #ifndef SMC_GET_MAC_ADDR
894 #define SMC_GET_MAC_ADDR(lp, addr) \
898 SMC_GET_MAC_CSR((lp), ADDRL, __v); \
899 addr[0] = __v; addr[1] = __v >> 8; \
900 addr[2] = __v >> 16; addr[3] = __v >> 24; \
901 SMC_GET_MAC_CSR((lp), ADDRH, __v); \
902 addr[4] = __v; addr[5] = __v >> 8; \
906 #define SMC_SET_MAC_ADDR(lp, addr) \
908 SMC_SET_MAC_CSR((lp), ADDRL, \
913 SMC_SET_MAC_CSR((lp), ADDRH, addr[4]|(addr[5] << 8));\
917 #define SMC_WRITE_EEPROM_CMD(lp, cmd, addr) \
919 while (SMC_GET_E2P_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
920 SMC_SET_MAC_CMD((lp), MAC_CSR_CMD_R_NOT_W_ | a ); \
921 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \