cell-pmu.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Cell Broadband Engine Performance Monitor
  4. *
  5. * (C) Copyright IBM Corporation 2006
  6. *
  7. * Author:
  8. * David Erb ([email protected])
  9. * Kevin Corry ([email protected])
  10. */
  11. #ifndef __ASM_CELL_PMU_H__
  12. #define __ASM_CELL_PMU_H__
  13. /* The Cell PMU has four hardware performance counters, which can be
  14. * configured as four 32-bit counters or eight 16-bit counters.
  15. */
  16. #define NR_PHYS_CTRS 4
  17. #define NR_CTRS (NR_PHYS_CTRS * 2)
  18. /* Macros for the pm_control register. */
  19. #define CBE_PM_16BIT_CTR(ctr) (1 << (24 - ((ctr) & (NR_PHYS_CTRS - 1))))
  20. #define CBE_PM_ENABLE_PERF_MON 0x80000000
  21. #define CBE_PM_STOP_AT_MAX 0x40000000
  22. #define CBE_PM_TRACE_MODE_GET(pm_control) (((pm_control) >> 28) & 0x3)
  23. #define CBE_PM_TRACE_MODE_SET(mode) (((mode) & 0x3) << 28)
  24. #define CBE_PM_TRACE_BUF_OVFLW(bit) (((bit) & 0x1) << 17)
  25. #define CBE_PM_COUNT_MODE_SET(count) (((count) & 0x3) << 18)
  26. #define CBE_PM_FREEZE_ALL_CTRS 0x00100000
  27. #define CBE_PM_ENABLE_EXT_TRACE 0x00008000
  28. #define CBE_PM_SPU_ADDR_TRACE_SET(msk) (((msk) & 0x3) << 9)
  29. /* Macros for the trace_address register. */
  30. #define CBE_PM_TRACE_BUF_FULL 0x00000800
  31. #define CBE_PM_TRACE_BUF_EMPTY 0x00000400
  32. #define CBE_PM_TRACE_BUF_DATA_COUNT(ta) ((ta) & 0x3ff)
  33. #define CBE_PM_TRACE_BUF_MAX_COUNT 0x400
  34. /* Macros for the pm07_control registers. */
  35. #define CBE_PM_CTR_INPUT_MUX(pm07_control) (((pm07_control) >> 26) & 0x3f)
  36. #define CBE_PM_CTR_INPUT_CONTROL 0x02000000
  37. #define CBE_PM_CTR_POLARITY 0x01000000
  38. #define CBE_PM_CTR_COUNT_CYCLES 0x00800000
  39. #define CBE_PM_CTR_ENABLE 0x00400000
  40. #define PM07_CTR_INPUT_MUX(x) (((x) & 0x3F) << 26)
  41. #define PM07_CTR_INPUT_CONTROL(x) (((x) & 1) << 25)
  42. #define PM07_CTR_POLARITY(x) (((x) & 1) << 24)
  43. #define PM07_CTR_COUNT_CYCLES(x) (((x) & 1) << 23)
  44. #define PM07_CTR_ENABLE(x) (((x) & 1) << 22)
  45. /* Macros for the pm_status register. */
  46. #define CBE_PM_CTR_OVERFLOW_INTR(ctr) (1 << (31 - ((ctr) & 7)))
  47. enum pm_reg_name {
  48. group_control,
  49. debug_bus_control,
  50. trace_address,
  51. ext_tr_timer,
  52. pm_status,
  53. pm_control,
  54. pm_interval,
  55. pm_start_stop,
  56. };
  57. /* Routines for reading/writing the PMU registers. */
  58. extern u32 cbe_read_phys_ctr(u32 cpu, u32 phys_ctr);
  59. extern void cbe_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val);
  60. extern u32 cbe_read_ctr(u32 cpu, u32 ctr);
  61. extern void cbe_write_ctr(u32 cpu, u32 ctr, u32 val);
  62. extern u32 cbe_read_pm07_control(u32 cpu, u32 ctr);
  63. extern void cbe_write_pm07_control(u32 cpu, u32 ctr, u32 val);
  64. extern u32 cbe_read_pm(u32 cpu, enum pm_reg_name reg);
  65. extern void cbe_write_pm(u32 cpu, enum pm_reg_name reg, u32 val);
  66. extern u32 cbe_get_ctr_size(u32 cpu, u32 phys_ctr);
  67. extern void cbe_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size);
  68. extern void cbe_enable_pm(u32 cpu);
  69. extern void cbe_disable_pm(u32 cpu);
  70. extern void cbe_read_trace_buffer(u32 cpu, u64 *buf);
  71. extern void cbe_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask);
  72. extern void cbe_disable_pm_interrupts(u32 cpu);
  73. extern u32 cbe_get_and_clear_pm_interrupts(u32 cpu);
  74. extern void cbe_sync_irq(int node);
  75. #define CBE_COUNT_SUPERVISOR_MODE 0
  76. #define CBE_COUNT_HYPERVISOR_MODE 1
  77. #define CBE_COUNT_PROBLEM_MODE 2
  78. #define CBE_COUNT_ALL_MODES 3
  79. #endif /* __ASM_CELL_PMU_H__ */