mipsnet.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. */
  6. #ifndef __MIPSNET_H
  7. #define __MIPSNET_H
  8. /*
  9. * Id of this Net device, as seen by the core.
  10. */
  11. #define MIPS_NET_DEV_ID ((uint64_t) \
  12. ((uint64_t) 'M' << 0)| \
  13. ((uint64_t) 'I' << 8)| \
  14. ((uint64_t) 'P' << 16)| \
  15. ((uint64_t) 'S' << 24)| \
  16. ((uint64_t) 'N' << 32)| \
  17. ((uint64_t) 'E' << 40)| \
  18. ((uint64_t) 'T' << 48)| \
  19. ((uint64_t) '0' << 56))
  20. /*
  21. * Net status/control block as seen by sw in the core.
  22. * (Why not use bit fields? can't be bothered with cross-platform struct
  23. * packing.)
  24. */
  25. struct net_control_block {
  26. /*
  27. * dev info for probing
  28. * reads as MIPSNET%d where %d is some form of version
  29. */
  30. uint64_t devId; /* 0x00 */
  31. /*
  32. * read only busy flag.
  33. * Set and cleared by the Net Device to indicate that an rx or a tx
  34. * is in progress.
  35. */
  36. uint32_t busy; /* 0x08 */
  37. /*
  38. * Set by the Net Device.
  39. * The device will set it once data has been received.
  40. * The value is the number of bytes that should be read from
  41. * rxDataBuffer. The value will decrease till 0 until all the data
  42. * from rxDataBuffer has been read.
  43. */
  44. uint32_t rxDataCount; /* 0x0c */
  45. #define MIPSNET_MAX_RXTX_DATACOUNT (1<<16)
  46. /*
  47. * Settable from the MIPS core, cleared by the Net Device. The core
  48. * should set the number of bytes it wants to send, then it should
  49. * write those bytes of data to txDataBuffer. The device will clear
  50. * txDataCount has been processed (not necessarily sent).
  51. */
  52. uint32_t txDataCount; /* 0x10 */
  53. /*
  54. * Interrupt control
  55. *
  56. * Used to clear the interrupted generated by this dev.
  57. * Write a 1 to clear the interrupt. (except bit31).
  58. *
  59. * Bit0 is set if it was a tx-done interrupt.
  60. * Bit1 is set when new rx-data is available.
  61. * Until this bit is cleared there will be no other RXs.
  62. *
  63. * Bit31 is used for testing, it clears after a read.
  64. * Writing 1 to this bit will cause an interrupt to be generated.
  65. * To clear the test interrupt, write 0 to this register.
  66. */
  67. uint32_t interruptControl; /*0x14 */
  68. #define MIPSNET_INTCTL_TXDONE ((uint32_t)(1 << 0))
  69. #define MIPSNET_INTCTL_RXDONE ((uint32_t)(1 << 1))
  70. #define MIPSNET_INTCTL_TESTBIT ((uint32_t)(1 << 31))
  71. #define MIPSNET_INTCTL_ALLSOURCES (MIPSNET_INTCTL_TXDONE | \
  72. MIPSNET_INTCTL_RXDONE | \
  73. MIPSNET_INTCTL_TESTBIT)
  74. /*
  75. * Readonly core-specific interrupt info for the device to signal the
  76. * core. The meaning of the contents of this field might change.
  77. *
  78. * TODO: the whole memIntf interrupt scheme is messy: the device should
  79. * have no control what so ever of what VPE/register set is being
  80. * used. The MemIntf should only expose interrupt lines, and
  81. * something in the config should be responsible for the
  82. * line<->core/vpe bindings.
  83. */
  84. uint32_t interruptInfo; /* 0x18 */
  85. /*
  86. * This is where the received data is read out.
  87. * There is more data to read until rxDataReady is 0.
  88. * Only 1 byte at this regs offset is used.
  89. */
  90. uint32_t rxDataBuffer; /* 0x1c */
  91. /*
  92. * This is where the data to transmit is written. Data should be
  93. * written for the amount specified in the txDataCount register. Only
  94. * 1 byte at this regs offset is used.
  95. */
  96. uint32_t txDataBuffer; /* 0x20 */
  97. };
  98. #define MIPSNET_IO_EXTENT 0x40 /* being generous */
  99. #define field_offset(field) (offsetof(struct net_control_block, field))
  100. #endif /* __MIPSNET_H */