pmu.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * linux/arch/arm/include/asm/pmu.h
  3. *
  4. * Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #ifndef __ARM_PMU_H__
  12. #define __ARM_PMU_H__
  13. #include <linux/interrupt.h>
  14. enum arm_pmu_type {
  15. ARM_PMU_DEVICE_CPU = 0,
  16. ARM_NUM_PMU_DEVICES,
  17. };
  18. /*
  19. * struct arm_pmu_platdata - ARM PMU platform data
  20. *
  21. * @handle_irq: an optional handler which will be called from the interrupt and
  22. * passed the address of the low level handler, and can be used to implement
  23. * any platform specific handling before or after calling it.
  24. */
  25. struct arm_pmu_platdata {
  26. irqreturn_t (*handle_irq)(int irq, void *dev,
  27. irq_handler_t pmu_handler);
  28. };
  29. #ifdef CONFIG_CPU_HAS_PMU
  30. /**
  31. * reserve_pmu() - reserve the hardware performance counters
  32. *
  33. * Reserve the hardware performance counters in the system for exclusive use.
  34. * The platform_device for the system is returned on success, ERR_PTR()
  35. * encoded error on failure.
  36. */
  37. extern struct platform_device *
  38. reserve_pmu(enum arm_pmu_type device);
  39. /**
  40. * release_pmu() - Relinquish control of the performance counters
  41. *
  42. * Release the performance counters and allow someone else to use them.
  43. * Callers must have disabled the counters and released IRQs before calling
  44. * this. The platform_device returned from reserve_pmu() must be passed as
  45. * a cookie.
  46. */
  47. extern int
  48. release_pmu(enum arm_pmu_type type);
  49. /**
  50. * init_pmu() - Initialise the PMU.
  51. *
  52. * Initialise the system ready for PMU enabling. This should typically set the
  53. * IRQ affinity and nothing else. The users (oprofile/perf events etc) will do
  54. * the actual hardware initialisation.
  55. */
  56. extern int
  57. init_pmu(enum arm_pmu_type device);
  58. #else /* CONFIG_CPU_HAS_PMU */
  59. #include <linux/err.h>
  60. static inline struct platform_device *
  61. reserve_pmu(enum arm_pmu_type device)
  62. {
  63. return ERR_PTR(-ENODEV);
  64. }
  65. static inline int
  66. release_pmu(struct platform_device *pdev)
  67. {
  68. return -ENODEV;
  69. }
  70. static inline int
  71. init_pmu(enum arm_pmu_type device)
  72. {
  73. return -ENODEV;
  74. }
  75. #endif /* CONFIG_CPU_HAS_PMU */
  76. #endif /* __ARM_PMU_H__ */