exynos_ppmu.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com/
  4. *
  5. * EXYNOS PPMU header
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef __DEVFREQ_EXYNOS_PPMU_H
  12. #define __DEVFREQ_EXYNOS_PPMU_H __FILE__
  13. #include <linux/ktime.h>
  14. /* For PPMU Control */
  15. #define PPMU_ENABLE BIT(0)
  16. #define PPMU_DISABLE 0x0
  17. #define PPMU_CYCLE_RESET BIT(1)
  18. #define PPMU_COUNTER_RESET BIT(2)
  19. #define PPMU_ENABLE_COUNT0 BIT(0)
  20. #define PPMU_ENABLE_COUNT1 BIT(1)
  21. #define PPMU_ENABLE_COUNT2 BIT(2)
  22. #define PPMU_ENABLE_COUNT3 BIT(3)
  23. #define PPMU_ENABLE_CYCLE BIT(31)
  24. #define PPMU_CNTENS 0x10
  25. #define PPMU_FLAG 0x50
  26. #define PPMU_CCNT_OVERFLOW BIT(31)
  27. #define PPMU_CCNT 0x100
  28. #define PPMU_PMCNT0 0x110
  29. #define PPMU_PMCNT_OFFSET 0x10
  30. #define PMCNT_OFFSET(x) (PPMU_PMCNT0 + (PPMU_PMCNT_OFFSET * x))
  31. #define PPMU_BEVT0SEL 0x1000
  32. #define PPMU_BEVTSEL_OFFSET 0x100
  33. #define PPMU_BEVTSEL(x) (PPMU_BEVT0SEL + (ch * PPMU_BEVTSEL_OFFSET))
  34. /* For Event Selection */
  35. #define RD_DATA_COUNT 0x5
  36. #define WR_DATA_COUNT 0x6
  37. #define RDWR_DATA_COUNT 0x7
  38. enum ppmu_counter {
  39. PPMU_PMNCNT0,
  40. PPMU_PMCCNT1,
  41. PPMU_PMNCNT2,
  42. PPMU_PMNCNT3,
  43. PPMU_PMNCNT_MAX,
  44. };
  45. struct bus_opp_table {
  46. unsigned int idx;
  47. unsigned long clk;
  48. unsigned long volt;
  49. };
  50. struct exynos_ppmu {
  51. void __iomem *hw_base;
  52. unsigned int ccnt;
  53. unsigned int event[PPMU_PMNCNT_MAX];
  54. unsigned int count[PPMU_PMNCNT_MAX];
  55. unsigned long long ns;
  56. ktime_t reset_time;
  57. bool ccnt_overflow;
  58. bool count_overflow[PPMU_PMNCNT_MAX];
  59. };
  60. struct busfreq_ppmu_data {
  61. struct exynos_ppmu *ppmu;
  62. int ppmu_end;
  63. };
  64. void exynos_ppmu_reset(void __iomem *ppmu_base);
  65. void exynos_ppmu_setevent(void __iomem *ppmu_base, unsigned int ch,
  66. unsigned int evt);
  67. void exynos_ppmu_start(void __iomem *ppmu_base);
  68. void exynos_ppmu_stop(void __iomem *ppmu_base);
  69. unsigned int exynos_ppmu_read(void __iomem *ppmu_base, unsigned int ch);
  70. void busfreq_mon_reset(struct busfreq_ppmu_data *ppmu_data);
  71. void exynos_read_ppmu(struct busfreq_ppmu_data *ppmu_data);
  72. int exynos_get_busier_ppmu(struct busfreq_ppmu_data *ppmu_data);
  73. #endif /* __DEVFREQ_EXYNOS_PPMU_H */