msu.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Intel(R) Trace Hub Memory Storage Unit (MSU) data structures
  3. *
  4. * Copyright (C) 2014-2015 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. */
  15. #ifndef __INTEL_TH_MSU_H__
  16. #define __INTEL_TH_MSU_H__
  17. enum {
  18. REG_MSU_MSUPARAMS = 0x0000,
  19. REG_MSU_MSUSTS = 0x0008,
  20. REG_MSU_MSC0CTL = 0x0100, /* MSC0 control */
  21. REG_MSU_MSC0STS = 0x0104, /* MSC0 status */
  22. REG_MSU_MSC0BAR = 0x0108, /* MSC0 output base address */
  23. REG_MSU_MSC0SIZE = 0x010c, /* MSC0 output size */
  24. REG_MSU_MSC0MWP = 0x0110, /* MSC0 write pointer */
  25. REG_MSU_MSC0NWSA = 0x011c, /* MSC0 next window start address */
  26. REG_MSU_MSC1CTL = 0x0200, /* MSC1 control */
  27. REG_MSU_MSC1STS = 0x0204, /* MSC1 status */
  28. REG_MSU_MSC1BAR = 0x0208, /* MSC1 output base address */
  29. REG_MSU_MSC1SIZE = 0x020c, /* MSC1 output size */
  30. REG_MSU_MSC1MWP = 0x0210, /* MSC1 write pointer */
  31. REG_MSU_MSC1NWSA = 0x021c, /* MSC1 next window start address */
  32. };
  33. /* MSUSTS bits */
  34. #define MSUSTS_MSU_INT BIT(0)
  35. /* MSCnCTL bits */
  36. #define MSC_EN BIT(0)
  37. #define MSC_WRAPEN BIT(1)
  38. #define MSC_RD_HDR_OVRD BIT(2)
  39. #define MSC_MODE (BIT(4) | BIT(5))
  40. #define MSC_LEN (BIT(8) | BIT(9) | BIT(10))
  41. /* MSC operating modes (MSC_MODE) */
  42. enum {
  43. MSC_MODE_SINGLE = 0,
  44. MSC_MODE_MULTI,
  45. MSC_MODE_EXI,
  46. MSC_MODE_DEBUG,
  47. };
  48. /* MSCnSTS bits */
  49. #define MSCSTS_WRAPSTAT BIT(1) /* Wrap occurred */
  50. #define MSCSTS_PLE BIT(2) /* Pipeline Empty */
  51. /*
  52. * Multiblock/multiwindow block descriptor
  53. */
  54. struct msc_block_desc {
  55. u32 sw_tag;
  56. u32 block_sz;
  57. u32 next_blk;
  58. u32 next_win;
  59. u32 res0[4];
  60. u32 hw_tag;
  61. u32 valid_dw;
  62. u32 ts_low;
  63. u32 ts_high;
  64. u32 res1[4];
  65. } __packed;
  66. #define MSC_BDESC sizeof(struct msc_block_desc)
  67. #define DATA_IN_PAGE (PAGE_SIZE - MSC_BDESC)
  68. /* MSC multiblock sw tag bits */
  69. #define MSC_SW_TAG_LASTBLK BIT(0)
  70. #define MSC_SW_TAG_LASTWIN BIT(1)
  71. /* MSC multiblock hw tag bits */
  72. #define MSC_HW_TAG_TRIGGER BIT(0)
  73. #define MSC_HW_TAG_BLOCKWRAP BIT(1)
  74. #define MSC_HW_TAG_WINWRAP BIT(2)
  75. #define MSC_HW_TAG_ENDBIT BIT(3)
  76. static inline unsigned long msc_data_sz(struct msc_block_desc *bdesc)
  77. {
  78. if (!bdesc->valid_dw)
  79. return 0;
  80. return bdesc->valid_dw * 4 - MSC_BDESC;
  81. }
  82. static inline bool msc_block_wrapped(struct msc_block_desc *bdesc)
  83. {
  84. if (bdesc->hw_tag & MSC_HW_TAG_BLOCKWRAP)
  85. return true;
  86. return false;
  87. }
  88. static inline bool msc_block_last_written(struct msc_block_desc *bdesc)
  89. {
  90. if ((bdesc->hw_tag & MSC_HW_TAG_ENDBIT) ||
  91. (msc_data_sz(bdesc) != DATA_IN_PAGE))
  92. return true;
  93. return false;
  94. }
  95. /* waiting for Pipeline Empty bit(s) to assert for MSC */
  96. #define MSC_PLE_WAITLOOP_DEPTH 10000
  97. #endif /* __INTEL_TH_MSU_H__ */