xilinx_ll_temac_fifo.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Xilinx xps_ll_temac ethernet driver for u-boot
  3. *
  4. * FIFO sub-controller interface
  5. *
  6. * Copyright (C) 2011 - 2012 Stephan Linz <linz@li-pro.net>
  7. * Copyright (C) 2008 - 2011 Michal Simek <monstr@monstr.eu>
  8. * Copyright (C) 2008 - 2011 PetaLogix
  9. *
  10. * Based on Yoshio Kashiwagi kashiwagi@co-nss.co.jp driver
  11. * Copyright (C) 2008 Nissin Systems Co.,Ltd.
  12. * March 2008 created
  13. *
  14. * SPDX-License-Identifier: GPL-2.0+
  15. *
  16. * [0]: http://www.xilinx.com/support/documentation
  17. *
  18. * [S]: [0]/ip_documentation/xps_ll_temac.pdf
  19. * [A]: [0]/application_notes/xapp1041.pdf
  20. */
  21. #ifndef _XILINX_LL_TEMAC_FIFO_
  22. #define _XILINX_LL_TEMAC_FIFO_
  23. #include <net.h>
  24. #include <asm/types.h>
  25. #include <asm/byteorder.h>
  26. #if !defined(__BIG_ENDIAN)
  27. # error LL_TEMAC requires big endianess
  28. #endif
  29. /*
  30. * FIFO Register Definition
  31. *
  32. * Used for memory mapped access from and to (Rd/Td) the LocalLink (LL)
  33. * Tri-Mode Ether MAC (TEMAC) via the 2 kb full duplex FIFO Controller,
  34. * one for each.
  35. *
  36. * [1]: [0]/ip_documentation/xps_ll_fifo.pdf
  37. * page 10, Registers Definition
  38. */
  39. struct fifo_ctrl {
  40. u32 isr; /* Interrupt Status Register (RW) */
  41. u32 ier; /* Interrupt Enable Register (RW) */
  42. u32 tdfr; /* Transmit Data FIFO Reset (WO) */
  43. u32 tdfv; /* Transmit Data FIFO Vacancy (RO) */
  44. u32 tdfd; /* Transmit Data FIFO 32bit wide Data write port (WO) */
  45. u32 tlf; /* Transmit Length FIFO (WO) */
  46. u32 rdfr; /* Receive Data FIFO Reset (WO) */
  47. u32 rdfo; /* Receive Data FIFO Occupancy (RO) */
  48. u32 rdfd; /* Receive Data FIFO 32bit wide Data read port (RO) */
  49. u32 rlf; /* Receive Length FIFO (RO) */
  50. u32 llr; /* LocalLink Reset (WO) */
  51. };
  52. /* Interrupt Status Register (ISR), [1] p11 */
  53. #define LL_FIFO_ISR_RPURE (1 << 31) /* Receive Packet Underrun Read Err */
  54. #define LL_FIFO_ISR_RPORE (1 << 30) /* Receive Packet Overrun Read Err */
  55. #define LL_FIFO_ISR_RPUE (1 << 29) /* Receive Packet Underrun Error */
  56. #define LL_FIFO_ISR_TPOE (1 << 28) /* Transmit Packet Overrun Error */
  57. #define LL_FIFO_ISR_TC (1 << 27) /* Transmit Complete */
  58. #define LL_FIFO_ISR_RC (1 << 26) /* Receive Complete */
  59. #define LL_FIFO_ISR_TSE (1 << 25) /* Transmit Size Error */
  60. #define LL_FIFO_ISR_TRC (1 << 24) /* Transmit Reset Complete */
  61. #define LL_FIFO_ISR_RRC (1 << 23) /* Receive Reset Complete */
  62. /* Interrupt Enable Register (IER), [1] p12/p13 */
  63. #define LL_FIFO_IER_RPURE (1 << 31) /* Receive Packet Underrun Read Err */
  64. #define LL_FIFO_IER_RPORE (1 << 30) /* Receive Packet Overrun Read Err */
  65. #define LL_FIFO_IER_RPUE (1 << 29) /* Receive Packet Underrun Error */
  66. #define LL_FIFO_IER_TPOE (1 << 28) /* Transmit Packet Overrun Error */
  67. #define LL_FIFO_IER_TC (1 << 27) /* Transmit Complete */
  68. #define LL_FIFO_IER_RC (1 << 26) /* Receive Complete */
  69. #define LL_FIFO_IER_TSE (1 << 25) /* Transmit Size Error */
  70. #define LL_FIFO_IER_TRC (1 << 24) /* Transmit Reset Complete */
  71. #define LL_FIFO_IER_RRC (1 << 23) /* Receive Reset Complete */
  72. /* Transmit Data FIFO Reset (TDFR), [1] p13/p14 */
  73. #define LL_FIFO_TDFR_KEY 0x000000A5UL
  74. /* Transmit Data FIFO Vacancy (TDFV), [1] p14 */
  75. #define LL_FIFO_TDFV_POS 0
  76. #define LL_FIFO_TDFV_MASK (0x000001FFUL << LL_FIFO_TDFV_POS)
  77. /* Transmit Length FIFO (TLF), [1] p16/p17 */
  78. #define LL_FIFO_TLF_POS 0
  79. #define LL_FIFO_TLF_MASK (0x000007FFUL << LL_FIFO_TLF_POS)
  80. #define LL_FIFO_TLF_MIN ((4 * sizeof(u32)) & LL_FIFO_TLF_MASK)
  81. #define LL_FIFO_TLF_MAX ((510 * sizeof(u32)) & LL_FIFO_TLF_MASK)
  82. /* Receive Data FIFO Reset (RDFR), [1] p15 */
  83. #define LL_FIFO_RDFR_KEY 0x000000A5UL
  84. /* Receive Data FIFO Occupancy (RDFO), [1] p16 */
  85. #define LL_FIFO_RDFO_POS 0
  86. #define LL_FIFO_RDFO_MASK (0x000001FFUL << LL_FIFO_RDFO_POS)
  87. /* Receive Length FIFO (RLF), [1] p17/p18 */
  88. #define LL_FIFO_RLF_POS 0
  89. #define LL_FIFO_RLF_MASK (0x000007FFUL << LL_FIFO_RLF_POS)
  90. #define LL_FIFO_RLF_MIN ((4 * sizeof(uint32)) & LL_FIFO_RLF_MASK)
  91. #define LL_FIFO_RLF_MAX ((510 * sizeof(uint32)) & LL_FIFO_RLF_MASK)
  92. /* LocalLink Reset (LLR), [1] p18 */
  93. #define LL_FIFO_LLR_KEY 0x000000A5UL
  94. /* reset FIFO and IRQ, disable interrupts */
  95. int ll_temac_reset_fifo(struct eth_device *dev);
  96. /* receive buffered data from FIFO (polling ISR) */
  97. int ll_temac_recv_fifo(struct eth_device *dev);
  98. /* send buffered data to FIFO */
  99. int ll_temac_send_fifo(struct eth_device *dev, void *packet, int length);
  100. #endif /* _XILINX_LL_TEMAC_FIFO_ */