sk_mca.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #ifndef _SK_MCA_INCLUDE_
  2. #define _SK_MCA_INCLUDE_
  3. #ifdef _SK_MCA_DRIVER_
  4. /* Adapter ID's */
  5. #define SKNET_MCA_ID 0x6afd
  6. #define SKNET_JUNIOR_MCA_ID 0x6be9
  7. /* media enumeration - defined in a way that it fits onto the MC2+'s
  8. POS registers... */
  9. typedef enum { Media_10Base2, Media_10BaseT,
  10. Media_10Base5, Media_Unknown, Media_Count
  11. } skmca_medium;
  12. /* private structure */
  13. typedef struct {
  14. unsigned int slot; /* MCA-Slot-# */
  15. void __iomem *base;
  16. void __iomem *macbase; /* base address of MAC address PROM */
  17. void __iomem *ioregaddr;/* address of I/O-register (Lo) */
  18. void __iomem *ctrladdr; /* address of control/stat register */
  19. void __iomem *cmdaddr; /* address of I/O-command register */
  20. int nextrx; /* index of next RX descriptor to
  21. be read */
  22. int nexttxput; /* index of next free TX descriptor */
  23. int nexttxdone; /* index of next TX descriptor to
  24. be finished */
  25. int txbusy; /* # of busy TX descriptors */
  26. struct net_device_stats stat; /* packet statistics */
  27. int realirq; /* memorizes actual IRQ, even when
  28. currently not allocated */
  29. skmca_medium medium; /* physical cannector */
  30. spinlock_t lock;
  31. } skmca_priv;
  32. /* card registers: control/status register bits */
  33. #define CTRL_ADR_DATA 0 /* Bit 0 = 0 ->access data register */
  34. #define CTRL_ADR_RAP 1 /* Bit 0 = 1 ->access RAP register */
  35. #define CTRL_RW_WRITE 0 /* Bit 1 = 0 ->write register */
  36. #define CTRL_RW_READ 2 /* Bit 1 = 1 ->read register */
  37. #define CTRL_RESET_ON 0 /* Bit 3 = 0 ->reset board */
  38. #define CTRL_RESET_OFF 8 /* Bit 3 = 1 ->no reset of board */
  39. #define STAT_ADR_DATA 0 /* Bit 0 of ctrl register read back */
  40. #define STAT_ADR_RAP 1
  41. #define STAT_RW_WRITE 0 /* Bit 1 of ctrl register read back */
  42. #define STAT_RW_READ 2
  43. #define STAT_RESET_ON 0 /* Bit 3 of ctrl register read back */
  44. #define STAT_RESET_OFF 8
  45. #define STAT_IRQ_ACT 0 /* interrupt pending */
  46. #define STAT_IRQ_NOACT 16 /* no interrupt pending */
  47. #define STAT_IO_NOBUSY 0 /* no transfer busy */
  48. #define STAT_IO_BUSY 32 /* transfer busy */
  49. /* I/O command register bits */
  50. #define IOCMD_GO 128 /* Bit 7 = 1 -> start register xfer */
  51. /* LANCE registers */
  52. #define LANCE_CSR0 0 /* Status/Control */
  53. #define CSR0_ERR 0x8000 /* general error flag */
  54. #define CSR0_BABL 0x4000 /* transmitter timeout */
  55. #define CSR0_CERR 0x2000 /* collision error */
  56. #define CSR0_MISS 0x1000 /* lost Rx block */
  57. #define CSR0_MERR 0x0800 /* memory access error */
  58. #define CSR0_RINT 0x0400 /* receiver interrupt */
  59. #define CSR0_TINT 0x0200 /* transmitter interrupt */
  60. #define CSR0_IDON 0x0100 /* initialization done */
  61. #define CSR0_INTR 0x0080 /* general interrupt flag */
  62. #define CSR0_INEA 0x0040 /* interrupt enable */
  63. #define CSR0_RXON 0x0020 /* receiver enabled */
  64. #define CSR0_TXON 0x0010 /* transmitter enabled */
  65. #define CSR0_TDMD 0x0008 /* force transmission now */
  66. #define CSR0_STOP 0x0004 /* stop LANCE */
  67. #define CSR0_STRT 0x0002 /* start LANCE */
  68. #define CSR0_INIT 0x0001 /* read initialization block */
  69. #define LANCE_CSR1 1 /* addr bit 0..15 of initialization */
  70. #define LANCE_CSR2 2 /* 16..23 block */
  71. #define LANCE_CSR3 3 /* Bus control */
  72. #define CSR3_BCON_HOLD 0 /* Bit 0 = 0 -> BM1,BM0,HOLD */
  73. #define CSR3_BCON_BUSRQ 1 /* Bit 0 = 1 -> BUSAK0,BYTE,BUSRQ */
  74. #define CSR3_ALE_HIGH 0 /* Bit 1 = 0 -> ALE asserted high */
  75. #define CSR3_ALE_LOW 2 /* Bit 1 = 1 -> ALE asserted low */
  76. #define CSR3_BSWAP_OFF 0 /* Bit 2 = 0 -> no byte swap */
  77. #define CSR3_BSWAP_ON 4 /* Bit 2 = 1 -> byte swap */
  78. /* LANCE structures */
  79. typedef struct { /* LANCE initialization block */
  80. u16 Mode; /* mode flags */
  81. u8 PAdr[6]; /* MAC address */
  82. u8 LAdrF[8]; /* Multicast filter */
  83. u32 RdrP; /* Receive descriptor */
  84. u32 TdrP; /* Transmit descriptor */
  85. } LANCE_InitBlock;
  86. /* Mode flags init block */
  87. #define LANCE_INIT_PROM 0x8000 /* enable promiscous mode */
  88. #define LANCE_INIT_INTL 0x0040 /* internal loopback */
  89. #define LANCE_INIT_DRTY 0x0020 /* disable retry */
  90. #define LANCE_INIT_COLL 0x0010 /* force collision */
  91. #define LANCE_INIT_DTCR 0x0008 /* disable transmit CRC */
  92. #define LANCE_INIT_LOOP 0x0004 /* loopback */
  93. #define LANCE_INIT_DTX 0x0002 /* disable transmitter */
  94. #define LANCE_INIT_DRX 0x0001 /* disable receiver */
  95. typedef struct { /* LANCE Tx descriptor */
  96. u16 LowAddr; /* bit 0..15 of address */
  97. u16 Flags; /* bit 16..23 of address + Flags */
  98. u16 Len; /* 2s complement of packet length */
  99. u16 Status; /* Result of transmission */
  100. } LANCE_TxDescr;
  101. #define TXDSCR_FLAGS_OWN 0x8000 /* LANCE owns descriptor */
  102. #define TXDSCR_FLAGS_ERR 0x4000 /* summary error flag */
  103. #define TXDSCR_FLAGS_MORE 0x1000 /* more than one retry needed? */
  104. #define TXDSCR_FLAGS_ONE 0x0800 /* one retry? */
  105. #define TXDSCR_FLAGS_DEF 0x0400 /* transmission deferred? */
  106. #define TXDSCR_FLAGS_STP 0x0200 /* first packet in chain? */
  107. #define TXDSCR_FLAGS_ENP 0x0100 /* last packet in chain? */
  108. #define TXDSCR_STATUS_BUFF 0x8000 /* buffer error? */
  109. #define TXDSCR_STATUS_UFLO 0x4000 /* silo underflow during transmit? */
  110. #define TXDSCR_STATUS_LCOL 0x1000 /* late collision? */
  111. #define TXDSCR_STATUS_LCAR 0x0800 /* loss of carrier? */
  112. #define TXDSCR_STATUS_RTRY 0x0400 /* retry error? */
  113. typedef struct { /* LANCE Rx descriptor */
  114. u16 LowAddr; /* bit 0..15 of address */
  115. u16 Flags; /* bit 16..23 of address + Flags */
  116. u16 MaxLen; /* 2s complement of buffer length */
  117. u16 Len; /* packet length */
  118. } LANCE_RxDescr;
  119. #define RXDSCR_FLAGS_OWN 0x8000 /* LANCE owns descriptor */
  120. #define RXDSCR_FLAGS_ERR 0x4000 /* summary error flag */
  121. #define RXDSCR_FLAGS_FRAM 0x2000 /* framing error flag */
  122. #define RXDSCR_FLAGS_OFLO 0x1000 /* FIFO overflow? */
  123. #define RXDSCR_FLAGS_CRC 0x0800 /* CRC error? */
  124. #define RXDSCR_FLAGS_BUFF 0x0400 /* buffer error? */
  125. #define RXDSCR_FLAGS_STP 0x0200 /* first packet in chain? */
  126. #define RXDCSR_FLAGS_ENP 0x0100 /* last packet in chain? */
  127. /* RAM layout */
  128. #define TXCOUNT 4 /* length of TX descriptor queue */
  129. #define LTXCOUNT 2 /* log2 of it */
  130. #define RXCOUNT 4 /* length of RX descriptor queue */
  131. #define LRXCOUNT 2 /* log2 of it */
  132. #define RAM_INITBASE 0 /* LANCE init block */
  133. #define RAM_TXBASE 24 /* Start of TX descriptor queue */
  134. #define RAM_RXBASE \
  135. (RAM_TXBASE + (TXCOUNT * 8)) /* Start of RX descriptor queue */
  136. #define RAM_DATABASE \
  137. (RAM_RXBASE + (RXCOUNT * 8)) /* Start of data area for frames */
  138. #define RAM_BUFSIZE 1580 /* max. frame size - should never be
  139. reached */
  140. #endif /* _SK_MCA_DRIVER_ */
  141. #endif /* _SK_MCA_INCLUDE_ */