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.

axge.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #ifndef _AXGE_H
  2. #define _AXGE_H
  3. /** @file
  4. *
  5. * Asix 10/100/1000 USB Ethernet driver
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <ipxe/usb.h>
  10. #include <ipxe/usbnet.h>
  11. /** Read MAC register */
  12. #define AXGE_READ_MAC_REGISTER \
  13. ( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
  14. USB_REQUEST_TYPE ( 0x01 ) )
  15. /** Write MAC register */
  16. #define AXGE_WRITE_MAC_REGISTER \
  17. ( USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
  18. USB_REQUEST_TYPE ( 0x01 ) )
  19. /** Physical Link Status Register */
  20. #define AXGE_PLSR 0x02
  21. #define AXGE_PLSR_EPHY_10 0x10 /**< Ethernet at 10Mbps */
  22. #define AXGE_PLSR_EPHY_100 0x20 /**< Ethernet at 100Mbps */
  23. #define AXGE_PLSR_EPHY_1000 0x40 /**< Ethernet at 1000Mbps */
  24. #define AXGE_PLSR_EPHY_ANY \
  25. ( AXGE_PLSR_EPHY_10 | \
  26. AXGE_PLSR_EPHY_100 | \
  27. AXGE_PLSR_EPHY_1000 )
  28. /** RX Control Register */
  29. #define AXGE_RCR 0x0b
  30. #define AXGE_RCR_PRO 0x0001 /**< Promiscuous mode */
  31. #define AXGE_RCR_AMALL 0x0002 /**< Accept all multicasts */
  32. #define AXGE_RCR_AB 0x0008 /**< Accept broadcasts */
  33. #define AXGE_RCR_SO 0x0080 /**< Start operation */
  34. /** Node ID Register */
  35. #define AXGE_NIDR 0x10
  36. /** Medium Status Register */
  37. #define AXGE_MSR 0x22
  38. #define AXGE_MSR_GM 0x0001 /**< Gigabit mode */
  39. #define AXGE_MSR_FD 0x0002 /**< Full duplex */
  40. #define AXGE_MSR_RFC 0x0010 /**< RX flow control enable */
  41. #define AXGE_MSR_TFC 0x0020 /**< TX flow control enable */
  42. #define AXGE_MSR_RE 0x0100 /**< Receive enable */
  43. /** Ethernet PHY Power and Reset Control Register */
  44. #define AXGE_EPPRCR 0x26
  45. #define AXGE_EPPRCR_IPRL 0x0020 /**< Undocumented */
  46. /** Delay after initialising EPPRCR */
  47. #define AXGE_EPPRCR_DELAY_MS 200
  48. /** Bulk IN Control Register (undocumented) */
  49. #define AXGE_BICR 0x2e
  50. /** Bulk IN Control (undocumented) */
  51. struct axge_bulk_in_control {
  52. /** Control */
  53. uint8_t ctrl;
  54. /** Timer */
  55. uint16_t timer;
  56. /** Size */
  57. uint8_t size;
  58. /** Inter-frame gap */
  59. uint8_t ifg;
  60. } __attribute__ (( packed ));
  61. /** Clock Select Register (undocumented) */
  62. #define AXGE_CSR 0x33
  63. #define AXGE_CSR_BCS 0x01 /**< Undocumented */
  64. #define AXGE_CSR_ACS 0x02 /**< Undocumented */
  65. /** Delay after initialising CSR */
  66. #define AXGE_CSR_DELAY_MS 100
  67. /** Transmit packet header */
  68. struct axge_tx_header {
  69. /** Packet length */
  70. uint32_t len;
  71. /** Answers on a postcard, please */
  72. uint32_t wtf;
  73. } __attribute__ (( packed ));
  74. /** Receive packet footer */
  75. struct axge_rx_footer {
  76. /** Packet count */
  77. uint16_t count;
  78. /** Header offset */
  79. uint16_t offset;
  80. } __attribute__ (( packed ));
  81. /** Receive packet descriptor */
  82. struct axge_rx_descriptor {
  83. /** Checksum information */
  84. uint16_t check;
  85. /** Length and error flags */
  86. uint16_t len_flags;
  87. } __attribute__ (( packed ));
  88. /** Receive packet length mask */
  89. #define AXGE_RX_LEN_MASK 0x1fff
  90. /** Receive packet length alignment */
  91. #define AXGE_RX_LEN_PAD_ALIGN 8
  92. /** Receive packet CRC error */
  93. #define AXGE_RX_CRC_ERROR 0x2000
  94. /** Receive packet dropped error */
  95. #define AXGE_RX_DROP_ERROR 0x8000
  96. /** Interrupt data */
  97. struct axge_interrupt {
  98. /** Magic signature */
  99. uint16_t magic;
  100. /** Link state */
  101. uint16_t link;
  102. /** PHY register MR01 */
  103. uint16_t mr01;
  104. /** PHY register MR05 */
  105. uint16_t mr05;
  106. } __attribute__ (( packed ));
  107. /** Interrupt magic signature */
  108. #define AXGE_INTR_MAGIC 0x00a1
  109. /** Link is up */
  110. #define AXGE_INTR_LINK_PPLS 0x0001
  111. /** An AXGE network device */
  112. struct axge_device {
  113. /** USB device */
  114. struct usb_device *usb;
  115. /** USB bus */
  116. struct usb_bus *bus;
  117. /** Network device */
  118. struct net_device *netdev;
  119. /** USB network device */
  120. struct usbnet_device usbnet;
  121. };
  122. /** Interrupt maximum fill level
  123. *
  124. * This is a policy decision.
  125. */
  126. #define AXGE_INTR_MAX_FILL 2
  127. /** Bulk IN maximum fill level
  128. *
  129. * This is a policy decision.
  130. */
  131. #define AXGE_IN_MAX_FILL 8
  132. /** Bulk IN buffer size
  133. *
  134. * This is a policy decision.
  135. */
  136. #define AXGE_IN_MTU 2048
  137. /** Amount of space to reserve at start of bulk IN buffers
  138. *
  139. * This is required to allow for protocols such as ARP which may reuse
  140. * a received I/O buffer for transmission.
  141. */
  142. #define AXGE_IN_RESERVE sizeof ( struct axge_tx_header )
  143. #endif /* _AXGE_H */