coresight-priv.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. enum cs_mode {
  35. CS_MODE_DISABLED,
  36. CS_MODE_SYSFS,
  37. CS_MODE_PERF,
  38. };
  39. static inline void CS_LOCK(void __iomem *addr)
  40. {
  41. do {
  42. /* Wait for things to settle */
  43. mb();
  44. writel_relaxed(0x0, addr + CORESIGHT_LAR);
  45. } while (0);
  46. }
  47. static inline void CS_UNLOCK(void __iomem *addr)
  48. {
  49. do {
  50. writel_relaxed(CORESIGHT_UNLOCK, addr + CORESIGHT_LAR);
  51. /* Make sure everyone has seen this */
  52. mb();
  53. } while (0);
  54. }
  55. void coresight_disable_path(struct list_head *path);
  56. int coresight_enable_path(struct list_head *path, u32 mode);
  57. struct coresight_device *coresight_get_sink(struct list_head *path);
  58. struct list_head *coresight_build_path(struct coresight_device *csdev);
  59. void coresight_release_path(struct list_head *path);
  60. #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
  61. extern int etm_readl_cp14(u32 off, unsigned int *val);
  62. extern int etm_writel_cp14(u32 off, u32 val);
  63. #else
  64. static inline int etm_readl_cp14(u32 off, unsigned int *val) { return 0; }
  65. static inline int etm_writel_cp14(u32 off, u32 val) { return 0; }
  66. #endif
  67. #endif