dm9051.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Davicom Semiconductor,Inc.
  4. * Davicom DM9051 SPI Fast Ethernet Linux driver
  5. */
  6. #ifndef _DM9051_H_
  7. #define _DM9051_H_
  8. #include <linux/bits.h>
  9. #include <linux/netdevice.h>
  10. #include <linux/types.h>
  11. #define DM9051_ID 0x9051
  12. #define DM9051_NCR 0x00
  13. #define DM9051_NSR 0x01
  14. #define DM9051_TCR 0x02
  15. #define DM9051_RCR 0x05
  16. #define DM9051_BPTR 0x08
  17. #define DM9051_FCR 0x0A
  18. #define DM9051_EPCR 0x0B
  19. #define DM9051_EPAR 0x0C
  20. #define DM9051_EPDRL 0x0D
  21. #define DM9051_EPDRH 0x0E
  22. #define DM9051_PAR 0x10
  23. #define DM9051_MAR 0x16
  24. #define DM9051_GPCR 0x1E
  25. #define DM9051_GPR 0x1F
  26. #define DM9051_VIDL 0x28
  27. #define DM9051_VIDH 0x29
  28. #define DM9051_PIDL 0x2A
  29. #define DM9051_PIDH 0x2B
  30. #define DM9051_SMCR 0x2F
  31. #define DM9051_ATCR 0x30
  32. #define DM9051_SPIBCR 0x38
  33. #define DM9051_INTCR 0x39
  34. #define DM9051_PPCR 0x3D
  35. #define DM9051_MPCR 0x55
  36. #define DM9051_LMCR 0x57
  37. #define DM9051_MBNDRY 0x5E
  38. #define DM9051_MRRL 0x74
  39. #define DM9051_MRRH 0x75
  40. #define DM9051_MWRL 0x7A
  41. #define DM9051_MWRH 0x7B
  42. #define DM9051_TXPLL 0x7C
  43. #define DM9051_TXPLH 0x7D
  44. #define DM9051_ISR 0x7E
  45. #define DM9051_IMR 0x7F
  46. #define DM_SPI_MRCMDX 0x70
  47. #define DM_SPI_MRCMD 0x72
  48. #define DM_SPI_MWCMD 0x78
  49. #define DM_SPI_WR 0x80
  50. /* dm9051 Ethernet controller registers bits
  51. */
  52. /* 0x00 */
  53. #define NCR_WAKEEN BIT(6)
  54. #define NCR_FDX BIT(3)
  55. #define NCR_RST BIT(0)
  56. /* 0x01 */
  57. #define NSR_SPEED BIT(7)
  58. #define NSR_LINKST BIT(6)
  59. #define NSR_WAKEST BIT(5)
  60. #define NSR_TX2END BIT(3)
  61. #define NSR_TX1END BIT(2)
  62. /* 0x02 */
  63. #define TCR_DIS_JABBER_TIMER BIT(6) /* for Jabber Packet support */
  64. #define TCR_TXREQ BIT(0)
  65. /* 0x05 */
  66. #define RCR_DIS_WATCHDOG_TIMER BIT(6) /* for Jabber Packet support */
  67. #define RCR_DIS_LONG BIT(5)
  68. #define RCR_DIS_CRC BIT(4)
  69. #define RCR_ALL BIT(3)
  70. #define RCR_PRMSC BIT(1)
  71. #define RCR_RXEN BIT(0)
  72. #define RCR_RX_DISABLE (RCR_DIS_LONG | RCR_DIS_CRC)
  73. /* 0x06 */
  74. #define RSR_RF BIT(7)
  75. #define RSR_MF BIT(6)
  76. #define RSR_LCS BIT(5)
  77. #define RSR_RWTO BIT(4)
  78. #define RSR_PLE BIT(3)
  79. #define RSR_AE BIT(2)
  80. #define RSR_CE BIT(1)
  81. #define RSR_FOE BIT(0)
  82. #define RSR_ERR_BITS (RSR_RF | RSR_LCS | RSR_RWTO | RSR_PLE | \
  83. RSR_AE | RSR_CE | RSR_FOE)
  84. /* 0x0A */
  85. #define FCR_TXPEN BIT(5)
  86. #define FCR_BKPM BIT(3)
  87. #define FCR_FLCE BIT(0)
  88. #define FCR_RXTX_BITS (FCR_TXPEN | FCR_BKPM | FCR_FLCE)
  89. /* 0x0B */
  90. #define EPCR_WEP BIT(4)
  91. #define EPCR_EPOS BIT(3)
  92. #define EPCR_ERPRR BIT(2)
  93. #define EPCR_ERPRW BIT(1)
  94. #define EPCR_ERRE BIT(0)
  95. /* 0x1E */
  96. #define GPCR_GEP_CNTL BIT(0)
  97. /* 0x1F */
  98. #define GPR_PHY_OFF BIT(0)
  99. /* 0x30 */
  100. #define ATCR_AUTO_TX BIT(7)
  101. /* 0x39 */
  102. #define INTCR_POL_LOW (1 << 0)
  103. #define INTCR_POL_HIGH (0 << 0)
  104. /* 0x3D */
  105. /* Pause Packet Control Register - default = 1 */
  106. #define PPCR_PAUSE_COUNT 0x08
  107. /* 0x55 */
  108. #define MPCR_RSTTX BIT(1)
  109. #define MPCR_RSTRX BIT(0)
  110. /* 0x57 */
  111. /* LEDMode Control Register - LEDMode1 */
  112. /* Value 0x81 : bit[7] = 1, bit[2] = 0, bit[1:0] = 01b */
  113. #define LMCR_NEWMOD BIT(7)
  114. #define LMCR_TYPED1 BIT(1)
  115. #define LMCR_TYPED0 BIT(0)
  116. #define LMCR_MODE1 (LMCR_NEWMOD | LMCR_TYPED0)
  117. /* 0x5E */
  118. #define MBNDRY_BYTE BIT(7)
  119. /* 0xFE */
  120. #define ISR_MBS BIT(7)
  121. #define ISR_LNKCHG BIT(5)
  122. #define ISR_ROOS BIT(3)
  123. #define ISR_ROS BIT(2)
  124. #define ISR_PTS BIT(1)
  125. #define ISR_PRS BIT(0)
  126. #define ISR_CLR_INT (ISR_LNKCHG | ISR_ROOS | ISR_ROS | \
  127. ISR_PTS | ISR_PRS)
  128. #define ISR_STOP_MRCMD (ISR_MBS)
  129. /* 0xFF */
  130. #define IMR_PAR BIT(7)
  131. #define IMR_LNKCHGI BIT(5)
  132. #define IMR_PTM BIT(1)
  133. #define IMR_PRM BIT(0)
  134. /* Const
  135. */
  136. #define DM9051_PHY_ADDR 1 /* PHY id */
  137. #define DM9051_PHY 0x40 /* PHY address 0x01 */
  138. #define DM9051_PKT_RDY 0x01 /* Packet ready to receive */
  139. #define DM9051_PKT_MAX 1536 /* Received packet max size */
  140. #define DM9051_TX_QUE_HI_WATER 50
  141. #define DM9051_TX_QUE_LO_WATER 25
  142. #define DM_EEPROM_MAGIC 0x9051
  143. #define DM_RXHDR_SIZE sizeof(struct dm9051_rxhdr)
  144. static inline struct board_info *to_dm9051_board(struct net_device *ndev)
  145. {
  146. return netdev_priv(ndev);
  147. }
  148. #endif /* _DM9051_H_ */