nhi_regs.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Thunderbolt Cactus Ridge driver - NHI registers
  3. *
  4. * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
  5. */
  6. #ifndef DSL3510_REGS_H_
  7. #define DSL3510_REGS_H_
  8. #include <linux/types.h>
  9. enum ring_flags {
  10. RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */
  11. RING_FLAG_E2E_FLOW_CONTROL = 1 << 28,
  12. RING_FLAG_PCI_NO_SNOOP = 1 << 29,
  13. RING_FLAG_RAW = 1 << 30, /* ignore EOF/SOF mask, include checksum */
  14. RING_FLAG_ENABLE = 1 << 31,
  15. };
  16. enum ring_desc_flags {
  17. RING_DESC_ISOCH = 0x1, /* TX only? */
  18. RING_DESC_COMPLETED = 0x2, /* set by NHI */
  19. RING_DESC_POSTED = 0x4, /* always set this */
  20. RING_DESC_INTERRUPT = 0x8, /* request an interrupt on completion */
  21. };
  22. /**
  23. * struct ring_desc - TX/RX ring entry
  24. *
  25. * For TX set length/eof/sof.
  26. * For RX length/eof/sof are set by the NHI.
  27. */
  28. struct ring_desc {
  29. u64 phys;
  30. u32 length:12;
  31. u32 eof:4;
  32. u32 sof:4;
  33. enum ring_desc_flags flags:12;
  34. u32 time; /* write zero */
  35. } __packed;
  36. /* NHI registers in bar 0 */
  37. /*
  38. * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  39. * 00: physical pointer to an array of struct ring_desc
  40. * 08: ring tail (set by NHI)
  41. * 10: ring head (index of first non posted descriptor)
  42. * 12: descriptor count
  43. */
  44. #define REG_TX_RING_BASE 0x00000
  45. /*
  46. * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  47. * 00: physical pointer to an array of struct ring_desc
  48. * 08: ring head (index of first not posted descriptor)
  49. * 10: ring tail (set by NHI)
  50. * 12: descriptor count
  51. * 14: max frame sizes (anything larger than 0x100 has no effect)
  52. */
  53. #define REG_RX_RING_BASE 0x08000
  54. /*
  55. * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  56. * 00: enum_ring_flags
  57. * 04: isoch time stamp ?? (write 0)
  58. * ..: unknown
  59. */
  60. #define REG_TX_OPTIONS_BASE 0x19800
  61. /*
  62. * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  63. * 00: enum ring_flags
  64. * If RING_FLAG_E2E_FLOW_CONTROL is set then bits 13-23 must be set to
  65. * the corresponding TX hop id.
  66. * 04: EOF/SOF mask (ignored for RING_FLAG_RAW rings)
  67. * ..: unknown
  68. */
  69. #define REG_RX_OPTIONS_BASE 0x29800
  70. /*
  71. * three bitfields: tx, rx, rx overflow
  72. * Every bitfield contains one bit for every hop (REG_HOP_COUNT). Registers are
  73. * cleared on read. New interrupts are fired only after ALL registers have been
  74. * read (even those containing only disabled rings).
  75. */
  76. #define REG_RING_NOTIFY_BASE 0x37800
  77. #define RING_NOTIFY_REG_COUNT(nhi) ((31 + 3 * nhi->hop_count) / 32)
  78. /*
  79. * two bitfields: rx, tx
  80. * Both bitfields contains one bit for every hop (REG_HOP_COUNT). To
  81. * enable/disable interrupts set/clear the corresponding bits.
  82. */
  83. #define REG_RING_INTERRUPT_BASE 0x38200
  84. #define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32)
  85. /* The last 11 bits contain the number of hops supported by the NHI port. */
  86. #define REG_HOP_COUNT 0x39640
  87. #endif