msu.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Intel(R) Trace Hub Memory Storage Unit (MSU) data structures
  4. *
  5. * Copyright (C) 2014-2015 Intel Corporation.
  6. */
  7. #ifndef __INTEL_TH_MSU_H__
  8. #define __INTEL_TH_MSU_H__
  9. enum {
  10. REG_MSU_MSUPARAMS = 0x0000,
  11. REG_MSU_MSUSTS = 0x0008,
  12. REG_MSU_MSC0CTL = 0x0100, /* MSC0 control */
  13. REG_MSU_MSC0STS = 0x0104, /* MSC0 status */
  14. REG_MSU_MSC0BAR = 0x0108, /* MSC0 output base address */
  15. REG_MSU_MSC0SIZE = 0x010c, /* MSC0 output size */
  16. REG_MSU_MSC0MWP = 0x0110, /* MSC0 write pointer */
  17. REG_MSU_MSC0NWSA = 0x011c, /* MSC0 next window start address */
  18. REG_MSU_MSC1CTL = 0x0200, /* MSC1 control */
  19. REG_MSU_MSC1STS = 0x0204, /* MSC1 status */
  20. REG_MSU_MSC1BAR = 0x0208, /* MSC1 output base address */
  21. REG_MSU_MSC1SIZE = 0x020c, /* MSC1 output size */
  22. REG_MSU_MSC1MWP = 0x0210, /* MSC1 write pointer */
  23. REG_MSU_MSC1NWSA = 0x021c, /* MSC1 next window start address */
  24. };
  25. /* MSUSTS bits */
  26. #define MSUSTS_MSU_INT BIT(0)
  27. /* MSCnCTL bits */
  28. #define MSC_EN BIT(0)
  29. #define MSC_WRAPEN BIT(1)
  30. #define MSC_RD_HDR_OVRD BIT(2)
  31. #define MSC_MODE (BIT(4) | BIT(5))
  32. #define MSC_LEN (BIT(8) | BIT(9) | BIT(10))
  33. /* MSC operating modes (MSC_MODE) */
  34. enum {
  35. MSC_MODE_SINGLE = 0,
  36. MSC_MODE_MULTI,
  37. MSC_MODE_EXI,
  38. MSC_MODE_DEBUG,
  39. };
  40. /* MSCnSTS bits */
  41. #define MSCSTS_WRAPSTAT BIT(1) /* Wrap occurred */
  42. #define MSCSTS_PLE BIT(2) /* Pipeline Empty */
  43. /*
  44. * Multiblock/multiwindow block descriptor
  45. */
  46. struct msc_block_desc {
  47. u32 sw_tag;
  48. u32 block_sz;
  49. u32 next_blk;
  50. u32 next_win;
  51. u32 res0[4];
  52. u32 hw_tag;
  53. u32 valid_dw;
  54. u32 ts_low;
  55. u32 ts_high;
  56. u32 res1[4];
  57. } __packed;
  58. #define MSC_BDESC sizeof(struct msc_block_desc)
  59. #define DATA_IN_PAGE (PAGE_SIZE - MSC_BDESC)
  60. /* MSC multiblock sw tag bits */
  61. #define MSC_SW_TAG_LASTBLK BIT(0)
  62. #define MSC_SW_TAG_LASTWIN BIT(1)
  63. /* MSC multiblock hw tag bits */
  64. #define MSC_HW_TAG_TRIGGER BIT(0)
  65. #define MSC_HW_TAG_BLOCKWRAP BIT(1)
  66. #define MSC_HW_TAG_WINWRAP BIT(2)
  67. #define MSC_HW_TAG_ENDBIT BIT(3)
  68. static inline unsigned long msc_data_sz(struct msc_block_desc *bdesc)
  69. {
  70. if (!bdesc->valid_dw)
  71. return 0;
  72. return bdesc->valid_dw * 4 - MSC_BDESC;
  73. }
  74. static inline bool msc_block_wrapped(struct msc_block_desc *bdesc)
  75. {
  76. if (bdesc->hw_tag & MSC_HW_TAG_BLOCKWRAP)
  77. return true;
  78. return false;
  79. }
  80. static inline bool msc_block_last_written(struct msc_block_desc *bdesc)
  81. {
  82. if ((bdesc->hw_tag & MSC_HW_TAG_ENDBIT) ||
  83. (msc_data_sz(bdesc) != DATA_IN_PAGE))
  84. return true;
  85. return false;
  86. }
  87. /* waiting for Pipeline Empty bit(s) to assert for MSC */
  88. #define MSC_PLE_WAITLOOP_DEPTH 10000
  89. #endif /* __INTEL_TH_MSU_H__ */