drv_pcnet32.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-08-19 JasonHu first version
  9. */
  10. #ifndef __DRV_PCNET32_H__
  11. #define __DRV_PCNET32_H__
  12. #include <rtdef.h>
  13. #define ETH_ALEN 6 /* MAC addr */
  14. #define ETH_ZLEN 60 /* Minimum length of data without CRC check */
  15. #define ETH_DATA_LEN 1500 /* Maximum length of data in a frame */
  16. #define ETH_FRAME_LEN 1518 /* Maximum Ethernet data length */
  17. #define RX_MSG_CNT 8 /* 4 msg queue */
  18. #define RX_MSG_SIZE (ETH_FRAME_LEN + 4) /* 4 save real msg size */
  19. #define TX_CACHE_BUF_SIZE (2048)
  20. #define JUMP_TO(label) goto label
  21. #define PCNET32_VENDOR_ID 0x1022
  22. #define PCNET32_DEVICE_ID 0x2000
  23. /* Offsets from base I/O address. */
  24. #define PCNET32_WIO_RDP 0x10
  25. #define PCNET32_WIO_RAP 0x12
  26. #define PCNET32_WIO_RESET 0x14
  27. #define PCNET32_WIO_BDP 0x16
  28. #define CSR0 0
  29. #define CSR0_INIT 0x1
  30. #define CSR0_START 0x2
  31. #define CSR0_STOP 0x4
  32. #define CSR0_TXPOLL 0x8
  33. #define CSR0_INTEN 0x40
  34. #define CSR0_IDON 0x0100
  35. #define CSR0_NORMAL (CSR0_START | CSR0_INTEN)
  36. #define CSR0_TINT 0x0200 /* Transmit Interrupt */
  37. #define CSR0_RINT 0x0400 /* Receive Interrupt */
  38. #define CSR0_MERR 0x0800 /* Memory Error */
  39. #define CSR0_MISS 0x1000 /* Missed Frame */
  40. #define CSR0_CERR 0x2000 /* Collision Error */
  41. #define CSR0_BABL 0x4000 /* Babble is a transmitter time-out error. */
  42. /* Error is set by the ORing of BABL, CERR, MISS, and MERR.
  43. * ERR remains set as long as any of the error flags are true.
  44. */
  45. #define CSR0_ERR 0x8000
  46. #define CSR1 1
  47. #define CSR2 2
  48. #define CSR3 3 /* Interrupt Masks and Deferral Control */
  49. #define CSR3_IDONM (1 << 8) /* Initialization Done Mask. */
  50. #define CSR4 4 /* Test and Features Control */
  51. #define CSR4_ASTRP_RCV (1 << 10) /* Auto Strip Receive */
  52. #define CSR4_APAD_XMT (1 << 11) /* Auto Pad Transmit */
  53. #define CSR5 5
  54. #define CSR5_SUSPEND 0x0001
  55. #define CSR6 6 /* RX/TX Descriptor Table Length */
  56. #define CSR15 15 /* Mode */
  57. #define CSR18 18 /* Current Receive Buffer Address Lower */
  58. #define CSR19 19 /* Current Receive Buffer Address Upper */
  59. #define CSR24 24 /* Base Address of Receive Descriptor Ring Lower */
  60. #define CSR25 25 /* Base Address of Receive Descriptor Ring Upper */
  61. #define CSR30 30 /* Base Address of Transmit Descriptor Ring Lower */
  62. #define CSR31 31 /* Base Address of Transmit Descriptor Ring Upper */
  63. #define CSR58 58 /* Software Style */
  64. #define CSR58_PCNET_PCI_II 0x02
  65. #define PCNET32_INIT_LOW 1
  66. #define PCNET32_INIT_HIGH 2
  67. #define PCNET32_MC_FILTER 8 /* broadcast filter */
  68. #define CSR72 72 /* Receive Descriptor Ring Counter */
  69. #define CSR74 74 /* Transmit Descriptor Ring Counter */
  70. #define BCR2 2
  71. #define BCR2_ASEL (1 << 1)
  72. #define PCNET32_TX_BUFFERS 8
  73. #define PCNET32_RX_BUFFERS 32
  74. #define PCNET32_LOG_TX_BUFFERS 3 /* 2^3 = 8 buffers */
  75. #define PCNET32_LOG_RX_BUFFERS 5 /* 2^5 = 32 buffers */
  76. #define PCNET32_RING_DE_SIZE 16
  77. #define PCNET32_TX_RETRY 10 /* tx retry counter when no available descriptor entry */
  78. #define PCNET32_DESC_STATUS_OWN 0x8000 /* card own the desc */
  79. /**
  80. * End of Packet indicates that this is the last buffer used by
  81. * the PCnet-PCI II controller for this frame.
  82. */
  83. #define PCNET32_DESC_STATUS_ENP 0x0100
  84. /**
  85. * Start of Packet indicates that this
  86. * is the first buffer used by the
  87. * PCnet-PCI II controller for this
  88. * frame.
  89. */
  90. #define PCNET32_DESC_STATUS_STP 0x0200
  91. #endif /* __DRV_PCNET32_H__ */