coresight-catu.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2018 Arm Limited. All rights reserved.
  4. *
  5. * Author: Suzuki K Poulose <suzuki.poulose@arm.com>
  6. */
  7. #ifndef _CORESIGHT_CATU_H
  8. #define _CORESIGHT_CATU_H
  9. #include "coresight-priv.h"
  10. /* Register offset from base */
  11. #define CATU_CONTROL 0x000
  12. #define CATU_MODE 0x004
  13. #define CATU_AXICTRL 0x008
  14. #define CATU_IRQEN 0x00c
  15. #define CATU_SLADDRLO 0x020
  16. #define CATU_SLADDRHI 0x024
  17. #define CATU_INADDRLO 0x028
  18. #define CATU_INADDRHI 0x02c
  19. #define CATU_STATUS 0x100
  20. #define CATU_DEVARCH 0xfbc
  21. #define CATU_CONTROL_ENABLE 0
  22. #define CATU_MODE_PASS_THROUGH 0U
  23. #define CATU_MODE_TRANSLATE 1U
  24. #define CATU_AXICTRL_ARCACHE_SHIFT 4
  25. #define CATU_AXICTRL_ARCACHE_MASK 0xf
  26. #define CATU_AXICTRL_ARPROT_MASK 0x3
  27. #define CATU_AXICTRL_ARCACHE(arcache) \
  28. (((arcache) & CATU_AXICTRL_ARCACHE_MASK) << CATU_AXICTRL_ARCACHE_SHIFT)
  29. #define CATU_AXICTRL_VAL(arcache, arprot) \
  30. (CATU_AXICTRL_ARCACHE(arcache) | ((arprot) & CATU_AXICTRL_ARPROT_MASK))
  31. #define AXI3_AxCACHE_WB_READ_ALLOC 0x7
  32. /*
  33. * AXI - ARPROT bits:
  34. * See AMBA AXI & ACE Protocol specification (ARM IHI 0022E)
  35. * sectionA4.7 Access Permissions.
  36. *
  37. * Bit 0: 0 - Unprivileged access, 1 - Privileged access
  38. * Bit 1: 0 - Secure access, 1 - Non-secure access.
  39. * Bit 2: 0 - Data access, 1 - instruction access.
  40. *
  41. * CATU AXICTRL:ARPROT[2] is res0 as we always access data.
  42. */
  43. #define CATU_OS_ARPROT 0x2
  44. #define CATU_OS_AXICTRL \
  45. CATU_AXICTRL_VAL(AXI3_AxCACHE_WB_READ_ALLOC, CATU_OS_ARPROT)
  46. #define CATU_STATUS_READY 8
  47. #define CATU_STATUS_ADRERR 0
  48. #define CATU_STATUS_AXIERR 4
  49. #define CATU_IRQEN_ON 0x1
  50. #define CATU_IRQEN_OFF 0x0
  51. struct catu_drvdata {
  52. struct device *dev;
  53. void __iomem *base;
  54. struct coresight_device *csdev;
  55. int irq;
  56. };
  57. #define CATU_REG32(name, offset) \
  58. static inline u32 \
  59. catu_read_##name(struct catu_drvdata *drvdata) \
  60. { \
  61. return coresight_read_reg_pair(drvdata->base, offset, -1); \
  62. } \
  63. static inline void \
  64. catu_write_##name(struct catu_drvdata *drvdata, u32 val) \
  65. { \
  66. coresight_write_reg_pair(drvdata->base, val, offset, -1); \
  67. }
  68. #define CATU_REG_PAIR(name, lo_off, hi_off) \
  69. static inline u64 \
  70. catu_read_##name(struct catu_drvdata *drvdata) \
  71. { \
  72. return coresight_read_reg_pair(drvdata->base, lo_off, hi_off); \
  73. } \
  74. static inline void \
  75. catu_write_##name(struct catu_drvdata *drvdata, u64 val) \
  76. { \
  77. coresight_write_reg_pair(drvdata->base, val, lo_off, hi_off); \
  78. }
  79. CATU_REG32(control, CATU_CONTROL);
  80. CATU_REG32(mode, CATU_MODE);
  81. CATU_REG32(irqen, CATU_IRQEN);
  82. CATU_REG32(axictrl, CATU_AXICTRL);
  83. CATU_REG_PAIR(sladdr, CATU_SLADDRLO, CATU_SLADDRHI)
  84. CATU_REG_PAIR(inaddr, CATU_INADDRLO, CATU_INADDRHI)
  85. static inline bool coresight_is_catu_device(struct coresight_device *csdev)
  86. {
  87. if (!IS_ENABLED(CONFIG_CORESIGHT_CATU))
  88. return false;
  89. if (csdev->type != CORESIGHT_DEV_TYPE_HELPER)
  90. return false;
  91. if (csdev->subtype.helper_subtype != CORESIGHT_DEV_SUBTYPE_HELPER_CATU)
  92. return false;
  93. return true;
  94. }
  95. #ifdef CONFIG_CORESIGHT_CATU
  96. extern const struct etr_buf_operations etr_catu_buf_ops;
  97. #else
  98. /* Dummy declaration for the CATU ops */
  99. static const struct etr_buf_operations etr_catu_buf_ops;
  100. #endif
  101. #endif