exynos_ppmu.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com/
  4. *
  5. * EXYNOS - PPMU support
  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. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/io.h>
  14. #include "exynos_ppmu.h"
  15. void exynos_ppmu_reset(void __iomem *ppmu_base)
  16. {
  17. __raw_writel(PPMU_CYCLE_RESET | PPMU_COUNTER_RESET, ppmu_base);
  18. __raw_writel(PPMU_ENABLE_CYCLE |
  19. PPMU_ENABLE_COUNT0 |
  20. PPMU_ENABLE_COUNT1 |
  21. PPMU_ENABLE_COUNT2 |
  22. PPMU_ENABLE_COUNT3,
  23. ppmu_base + PPMU_CNTENS);
  24. }
  25. void exynos_ppmu_setevent(void __iomem *ppmu_base, unsigned int ch,
  26. unsigned int evt)
  27. {
  28. __raw_writel(evt, ppmu_base + PPMU_BEVTSEL(ch));
  29. }
  30. void exynos_ppmu_start(void __iomem *ppmu_base)
  31. {
  32. __raw_writel(PPMU_ENABLE, ppmu_base);
  33. }
  34. void exynos_ppmu_stop(void __iomem *ppmu_base)
  35. {
  36. __raw_writel(PPMU_DISABLE, ppmu_base);
  37. }
  38. unsigned int exynos_ppmu_read(void __iomem *ppmu_base, unsigned int ch)
  39. {
  40. unsigned int total;
  41. if (ch == PPMU_PMNCNT3)
  42. total = ((__raw_readl(ppmu_base + PMCNT_OFFSET(ch)) << 8) |
  43. __raw_readl(ppmu_base + PMCNT_OFFSET(ch + 1)));
  44. else
  45. total = __raw_readl(ppmu_base + PMCNT_OFFSET(ch));
  46. return total;
  47. }