You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

natsemi.h 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. #define NATSEMI_HW_TIMEOUT 400
  2. #define TX_RING_SIZE 4
  3. #define NUM_RX_DESC 4
  4. #define RX_BUF_SIZE 1536
  5. #define OWN 0x80000000
  6. #define DSIZE 0x00000FFF
  7. #define CRC_SIZE 4
  8. struct natsemi_tx {
  9. uint32_t link;
  10. uint32_t cmdsts;
  11. uint32_t bufptr;
  12. };
  13. struct natsemi_rx {
  14. uint32_t link;
  15. uint32_t cmdsts;
  16. uint32_t bufptr;
  17. };
  18. struct natsemi_private {
  19. unsigned short ioaddr;
  20. unsigned short tx_cur;
  21. unsigned short tx_dirty;
  22. unsigned short rx_cur;
  23. struct natsemi_tx tx[TX_RING_SIZE];
  24. struct natsemi_rx rx[NUM_RX_DESC];
  25. /* need to add iobuf as we cannot free iobuf->data in close without this
  26. * alternatively substracting sizeof(head) and sizeof(list_head) can also
  27. * give the same.
  28. */
  29. struct io_buffer *iobuf[NUM_RX_DESC];
  30. /* netdev_tx_complete needs pointer to the iobuf of the data so as to free
  31. * it from the memory.
  32. */
  33. struct io_buffer *tx_iobuf[TX_RING_SIZE];
  34. struct spi_bit_basher spibit;
  35. struct spi_device eeprom;
  36. struct nvo_block nvo;
  37. };
  38. /*
  39. * Support for fibre connections on Am79C874:
  40. * This phy needs a special setup when connected to a fibre cable.
  41. * http://www.amd.com/files/connectivitysolutions/networking/archivednetworking/22235.pdf
  42. */
  43. #define PHYID_AM79C874 0x0022561b
  44. enum {
  45. MII_MCTRL = 0x15, /* mode control register */
  46. MII_FX_SEL = 0x0001, /* 100BASE-FX (fiber) */
  47. MII_EN_SCRM = 0x0004, /* enable scrambler (tp) */
  48. };
  49. /* values we might find in the silicon revision register */
  50. #define SRR_DP83815_C 0x0302
  51. #define SRR_DP83815_D 0x0403
  52. #define SRR_DP83816_A4 0x0504
  53. #define SRR_DP83816_A5 0x0505
  54. /* NATSEMI: Offsets to the device registers.
  55. * Unlike software-only systems, device drivers interact with complex hardware.
  56. * It's not useful to define symbolic names for every register bit in the
  57. * device.
  58. */
  59. enum register_offsets {
  60. ChipCmd = 0x00,
  61. ChipConfig = 0x04,
  62. EECtrl = 0x08,
  63. PCIBusCfg = 0x0C,
  64. IntrStatus = 0x10,
  65. IntrMask = 0x14,
  66. IntrEnable = 0x18,
  67. TxRingPtr = 0x20,
  68. TxConfig = 0x24,
  69. RxRingPtr = 0x30,
  70. RxConfig = 0x34,
  71. ClkRun = 0x3C,
  72. WOLCmd = 0x40,
  73. PauseCmd = 0x44,
  74. RxFilterAddr = 0x48,
  75. RxFilterData = 0x4C,
  76. BootRomAddr = 0x50,
  77. BootRomData = 0x54,
  78. SiliconRev = 0x58,
  79. StatsCtrl = 0x5C,
  80. StatsData = 0x60,
  81. RxPktErrs = 0x60,
  82. RxMissed = 0x68,
  83. RxCRCErrs = 0x64,
  84. PCIPM = 0x44,
  85. PhyStatus = 0xC0,
  86. MIntrCtrl = 0xC4,
  87. MIntrStatus = 0xC8,
  88. /* These are from the spec, around page 78... on a separate table.
  89. */
  90. PGSEL = 0xCC,
  91. PMDCSR = 0xE4,
  92. TSTDAT = 0xFC,
  93. DSPCFG = 0xF4,
  94. SDCFG = 0x8C,
  95. BasicControl = 0x80,
  96. BasicStatus = 0x84
  97. };
  98. /* the values for the 'magic' registers above (PGSEL=1) */
  99. #define PMDCSR_VAL 0x189c /* enable preferred adaptation circuitry */
  100. #define TSTDAT_VAL 0x0
  101. #define DSPCFG_VAL 0x5040
  102. #define SDCFG_VAL 0x008c /* set voltage thresholds for Signal Detect */
  103. #define DSPCFG_LOCK 0x20 /* coefficient lock bit in DSPCFG */
  104. #define DSPCFG_COEF 0x1000 /* see coefficient (in TSTDAT) bit in DSPCFG */
  105. #define TSTDAT_FIXED 0xe8 /* magic number for bad coefficients */
  106. /* Bit in ChipCmd.
  107. */
  108. enum ChipCmdBits {
  109. ChipReset = 0x100,
  110. RxReset = 0x20,
  111. TxReset = 0x10,
  112. RxOff = 0x08,
  113. RxOn = 0x04,
  114. TxOff = 0x02,
  115. TxOn = 0x01
  116. };
  117. enum ChipConfig_bits {
  118. CfgPhyDis = 0x200,
  119. CfgPhyRst = 0x400,
  120. CfgExtPhy = 0x1000,
  121. CfgAnegEnable = 0x2000,
  122. CfgAneg100 = 0x4000,
  123. CfgAnegFull = 0x8000,
  124. CfgAnegDone = 0x8000000,
  125. CfgFullDuplex = 0x20000000,
  126. CfgSpeed100 = 0x40000000,
  127. CfgLink = 0x80000000,
  128. };
  129. /* Bits in the RxMode register.
  130. */
  131. enum rx_mode_bits {
  132. AcceptErr = 0x20,
  133. AcceptRunt = 0x10,
  134. AcceptBroadcast = 0xC0000000,
  135. AcceptMulticast = 0x00200000,
  136. AcceptAllMulticast = 0x20000000,
  137. AcceptAllPhys = 0x10000000,
  138. AcceptMyPhys = 0x08000000,
  139. RxFilterEnable = 0x80000000
  140. };
  141. /* Bits in network_desc.status
  142. */
  143. enum desc_status_bits {
  144. DescOwn = 0x80000000,
  145. DescMore = 0x40000000,
  146. DescIntr = 0x20000000,
  147. DescNoCRC = 0x10000000,
  148. DescPktOK = 0x08000000,
  149. RxTooLong = 0x00400000
  150. };
  151. /*Bits in Interrupt Mask register
  152. */
  153. enum Intr_mask_register_bits {
  154. RxOk = 0x001,
  155. RxErr = 0x004,
  156. TxOk = 0x040,
  157. TxErr = 0x100
  158. };
  159. enum MIntrCtrl_bits {
  160. MICRIntEn = 0x2,
  161. };
  162. /* CFG bits [13:16] [18:23] */
  163. #define CFG_RESET_SAVE 0xfde000
  164. /* WCSR bits [0:4] [9:10] */
  165. #define WCSR_RESET_SAVE 0x61f
  166. /* RFCR bits [20] [22] [27:31] */
  167. #define RFCR_RESET_SAVE 0xf8500000;
  168. /* Delay between EEPROM clock transitions.
  169. No extra delay is needed with 33Mhz PCI, but future 66Mhz access may need
  170. a delay. */
  171. #define eeprom_delay(ee_addr) inl(ee_addr)
  172. enum EEPROM_Ctrl_Bits {
  173. EE_ShiftClk = 0x04,
  174. EE_DataIn = 0x01,
  175. EE_ChipSelect = 0x08,
  176. EE_DataOut = 0x02
  177. };
  178. #define EE_Write0 (EE_ChipSelect)
  179. #define EE_Write1 (EE_ChipSelect | EE_DataIn)
  180. /* The EEPROM commands include the alway-set leading bit. */
  181. enum EEPROM_Cmds {
  182. EE_WriteCmd=(5 << 6), EE_ReadCmd=(6 << 6), EE_EraseCmd=(7 << 6),
  183. };
  184. /* EEPROM access , values are devices specific
  185. */
  186. #define EE_CS 0x08 /* EEPROM chip select */
  187. #define EE_SK 0x04 /* EEPROM shift clock */
  188. #define EE_DI 0x01 /* Data in */
  189. #define EE_DO 0x02 /* Data out */
  190. /* Offsets within EEPROM (these are word offsets)
  191. */
  192. #define EE_MAC 7
  193. #define EE_REG EECtrl
  194. static const uint8_t natsemi_ee_bits[] = {
  195. [SPI_BIT_SCLK] = EE_SK,
  196. [SPI_BIT_MOSI] = EE_DI,
  197. [SPI_BIT_MISO] = EE_DO,
  198. [SPI_BIT_SS(0)] = EE_CS,
  199. };