]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/devfreq/exynos/exynos_ppmu.c
2 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com/
5 * EXYNOS - PPMU support
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.
12 #include <linux/kernel.h>
13 #include <linux/types.h>
16 #include "exynos_ppmu.h"
18 void exynos_ppmu_reset(void __iomem
*ppmu_base
)
20 __raw_writel(PPMU_CYCLE_RESET
| PPMU_COUNTER_RESET
, ppmu_base
);
21 __raw_writel(PPMU_ENABLE_CYCLE
|
26 ppmu_base
+ PPMU_CNTENS
);
29 void exynos_ppmu_setevent(void __iomem
*ppmu_base
, unsigned int ch
,
32 __raw_writel(evt
, ppmu_base
+ PPMU_BEVTSEL(ch
));
35 void exynos_ppmu_start(void __iomem
*ppmu_base
)
37 __raw_writel(PPMU_ENABLE
, ppmu_base
);
40 void exynos_ppmu_stop(void __iomem
*ppmu_base
)
42 __raw_writel(PPMU_DISABLE
, ppmu_base
);
45 unsigned int exynos_ppmu_read(void __iomem
*ppmu_base
, unsigned int ch
)
49 if (ch
== PPMU_PMNCNT3
)
50 total
= ((__raw_readl(ppmu_base
+ PMCNT_OFFSET(ch
)) << 8) |
51 __raw_readl(ppmu_base
+ PMCNT_OFFSET(ch
+ 1)));
53 total
= __raw_readl(ppmu_base
+ PMCNT_OFFSET(ch
));
58 void busfreq_mon_reset(struct busfreq_ppmu_data
*ppmu_data
)
62 for (i
= 0; i
< ppmu_data
->ppmu_end
; i
++) {
63 void __iomem
*ppmu_base
= ppmu_data
->ppmu
[i
].hw_base
;
65 /* Reset the performance and cycle counters */
66 exynos_ppmu_reset(ppmu_base
);
68 /* Setup count registers to monitor read/write transactions */
69 ppmu_data
->ppmu
[i
].event
[PPMU_PMNCNT3
] = RDWR_DATA_COUNT
;
70 exynos_ppmu_setevent(ppmu_base
, PPMU_PMNCNT3
,
71 ppmu_data
->ppmu
[i
].event
[PPMU_PMNCNT3
]);
73 exynos_ppmu_start(ppmu_base
);
77 void exynos_read_ppmu(struct busfreq_ppmu_data
*ppmu_data
)
81 for (i
= 0; i
< ppmu_data
->ppmu_end
; i
++) {
82 void __iomem
*ppmu_base
= ppmu_data
->ppmu
[i
].hw_base
;
84 exynos_ppmu_stop(ppmu_base
);
86 /* Update local data from PPMU */
87 ppmu_data
->ppmu
[i
].ccnt
= __raw_readl(ppmu_base
+ PPMU_CCNT
);
89 for (j
= PPMU_PMNCNT0
; j
< PPMU_PMNCNT_MAX
; j
++) {
90 if (ppmu_data
->ppmu
[i
].event
[j
] == 0)
91 ppmu_data
->ppmu
[i
].count
[j
] = 0;
93 ppmu_data
->ppmu
[i
].count
[j
] =
94 exynos_ppmu_read(ppmu_base
, j
);
98 busfreq_mon_reset(ppmu_data
);
101 int exynos_get_busier_ppmu(struct busfreq_ppmu_data
*ppmu_data
)
103 unsigned int count
= 0;
106 for (i
= 0; i
< ppmu_data
->ppmu_end
; i
++) {
107 for (j
= PPMU_PMNCNT0
; j
< PPMU_PMNCNT_MAX
; j
++) {
108 if (ppmu_data
->ppmu
[i
].count
[j
] > count
) {
109 count
= ppmu_data
->ppmu
[i
].count
[j
];