upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / ppmu.c
1 /* linux/arch/arm/mach-s5pv310/ppmu.c
2  *
3  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com/
5  *
6  * S5PV310 - CPU PPMU support
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12
13 #include <linux/types.h>
14 #include <linux/kernel.h>
15 #include <linux/err.h>
16 #include <linux/io.h>
17
18 #include <mach/map.h>
19 #include <mach/regs-clock.h>
20 #include <mach/ppmu.h>
21
22 void s5pv310_ppmu_reset(struct s5pv310_ppmu_hw *ppmu)
23 {
24         void __iomem *ppmu_base = ppmu->hw_base;
25
26         __raw_writel(0x3 << 1, ppmu_base);
27         __raw_writel(0x8000000f, ppmu_base + 0x0010);
28         __raw_writel(0x8000000f, ppmu_base + 0x0030);
29
30         __raw_writel(0x0, ppmu_base + DEVT0_ID);
31         __raw_writel(0x0, ppmu_base + DEVT0_IDMSK);
32
33         __raw_writel(0x0, ppmu_base + DEVT1_ID);
34         __raw_writel(0x0, ppmu_base + DEVT1_IDMSK);
35
36         ppmu->ccnt = 0;
37         ppmu->event = 0;
38         ppmu->count[0] = 0;
39         ppmu->count[1] = 0;
40         ppmu->count[2] = 0;
41         ppmu->count[3] = 0;
42 }
43
44 void s5pv310_ppmu_setevent(struct s5pv310_ppmu_hw *ppmu,
45                 unsigned int evt, unsigned int evt_num)
46 {
47         void __iomem *ppmu_base = ppmu->hw_base;
48
49         ppmu->event = evt;
50
51         __raw_writel(evt , ppmu_base + DEVT0_SEL + (evt_num * 0x100));
52 }
53
54 void s5pv310_ppmu_start(struct s5pv310_ppmu_hw *ppmu)
55 {
56         void __iomem *ppmu_base = ppmu->hw_base;
57
58         __raw_writel(0x1, ppmu_base);
59 }
60
61 void s5pv310_ppmu_stop(struct s5pv310_ppmu_hw *ppmu)
62 {
63         void __iomem *ppmu_base = ppmu->hw_base;
64
65         __raw_writel(0x0, ppmu_base);
66 }
67
68 void s5pv310_ppmu_update(struct s5pv310_ppmu_hw *ppmu)
69 {
70         void __iomem *ppmu_base = ppmu->hw_base;
71         unsigned int i;
72
73         ppmu->ccnt = __raw_readl(ppmu_base + 0x0100);
74
75
76         for (i = 0; i < NUMBER_OF_COUNTER; i++) {
77                 ppmu->count[i] =
78                         __raw_readl(ppmu_base + (0x110 + (0x10 * i)));
79         }
80
81 }