coresight-priv.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _CORESIGHT_PRIV_H
  13. #define _CORESIGHT_PRIV_H
  14. #include <linux/bitops.h>
  15. #include <linux/io.h>
  16. #include <linux/coresight.h>
  17. /*
  18. * Coresight management registers (0xf00-0xfcc)
  19. * 0xfa0 - 0xfa4: Management registers in PFTv1.0
  20. * Trace registers in PFTv1.1
  21. */
  22. #define CORESIGHT_ITCTRL 0xf00
  23. #define CORESIGHT_CLAIMSET 0xfa0
  24. #define CORESIGHT_CLAIMCLR 0xfa4
  25. #define CORESIGHT_LAR 0xfb0
  26. #define CORESIGHT_LSR 0xfb4
  27. #define CORESIGHT_AUTHSTATUS 0xfb8
  28. #define CORESIGHT_DEVID 0xfc8
  29. #define CORESIGHT_DEVTYPE 0xfcc
  30. #define TIMEOUT_US 100
  31. #define BMVAL(val, lsb, msb) ((val & GENMASK(msb, lsb)) >> lsb)
  32. #define ETM_MODE_EXCL_KERN BIT(30)
  33. #define ETM_MODE_EXCL_USER BIT(31)
  34. #define coresight_simple_func(type, name, offset) \
  35. static ssize_t name##_show(struct device *_dev, \
  36. struct device_attribute *attr, char *buf) \
  37. { \
  38. type *drvdata = dev_get_drvdata(_dev->parent); \
  39. return scnprintf(buf, PAGE_SIZE, "0x%x\n", \
  40. readl_relaxed(drvdata->base + offset)); \
  41. } \
  42. static DEVICE_ATTR_RO(name)
  43. enum cs_mode {
  44. CS_MODE_DISABLED,
  45. CS_MODE_SYSFS,
  46. CS_MODE_PERF,
  47. };
  48. /**
  49. * struct cs_buffer - keep track of a recording session' specifics
  50. * @cur: index of the current buffer
  51. * @nr_pages: max number of pages granted to us
  52. * @offset: offset within the current buffer
  53. * @data_size: how much we collected in this run
  54. * @lost: other than zero if we had a HW buffer wrap around
  55. * @snapshot: is this run in snapshot mode
  56. * @data_pages: a handle the ring buffer
  57. */
  58. struct cs_buffers {
  59. unsigned int cur;
  60. unsigned int nr_pages;
  61. unsigned long offset;
  62. local_t data_size;
  63. local_t lost;
  64. bool snapshot;
  65. void **data_pages;
  66. };
  67. static inline void CS_LOCK(void __iomem *addr)
  68. {
  69. do {
  70. /* Wait for things to settle */
  71. mb();
  72. writel_relaxed(0x0, addr + CORESIGHT_LAR);
  73. } while (0);
  74. }
  75. static inline void CS_UNLOCK(void __iomem *addr)
  76. {
  77. do {
  78. writel_relaxed(CORESIGHT_UNLOCK, addr + CORESIGHT_LAR);
  79. /* Make sure everyone has seen this */
  80. mb();
  81. } while (0);
  82. }
  83. void coresight_disable_path(struct list_head *path);
  84. int coresight_enable_path(struct list_head *path, u32 mode);
  85. struct coresight_device *coresight_get_sink(struct list_head *path);
  86. struct list_head *coresight_build_path(struct coresight_device *csdev);
  87. void coresight_release_path(struct list_head *path);
  88. #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
  89. extern int etm_readl_cp14(u32 off, unsigned int *val);
  90. extern int etm_writel_cp14(u32 off, u32 val);
  91. #else
  92. static inline int etm_readl_cp14(u32 off, unsigned int *val) { return 0; }
  93. static inline int etm_writel_cp14(u32 off, u32 val) { return 0; }
  94. #endif
  95. #endif