upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / ppc.c
1 /* linux/arch/arm/mach-s5pv310/ppc.c
2  *
3  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com/
5  *
6  * S5PV310 - 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_ppc_reset(struct s5pv310_ppmu_hw *ppmu)
23 {
24         void __iomem *ppmu_base = ppmu->hw_base;
25
26         __raw_writel(0x8000000f, ppmu_base + 0xf010);
27         __raw_writel(0x8000000f, ppmu_base + 0xf050);
28         __raw_writel(0x6, ppmu_base + 0xf000);
29         __raw_writel(0x0, ppmu_base + 0xf100);
30
31         ppmu->ccnt = 0;
32         ppmu->event = 0;
33         ppmu->count[0] = 0;
34         ppmu->count[1] = 0;
35         ppmu->count[2] = 0;
36         ppmu->count[3] = 0;
37 }
38
39 void s5pv310_ppc_setevent(struct s5pv310_ppmu_hw *ppmu,
40                                   unsigned int evt)
41 {
42         void __iomem *ppmu_base = ppmu->hw_base;
43
44         ppmu->event = evt;
45
46         __raw_writel(((evt << 12) | 0x1), ppmu_base + 0xfc);
47 }
48
49 void s5pv310_ppc_start(struct s5pv310_ppmu_hw *ppmu)
50 {
51         void __iomem *ppmu_base = ppmu->hw_base;
52
53         __raw_writel(0x1, ppmu_base + 0xf000);
54 }
55
56 void s5pv310_ppc_stop(struct s5pv310_ppmu_hw *ppmu)
57 {
58         void __iomem *ppmu_base = ppmu->hw_base;
59
60         __raw_writel(0x0, ppmu_base + 0xf000);
61 }
62
63 void s5pv310_ppc_update(struct s5pv310_ppmu_hw *ppmu)
64 {
65         void __iomem *ppmu_base = ppmu->hw_base;
66         unsigned int i;
67
68         ppmu->ccnt = __raw_readl(ppmu_base + 0xf100);
69
70         for (i = 0; i < NUMBER_OF_COUNTER; i++) {
71                 ppmu->count[i] =
72                         __raw_readl(ppmu_base + (0xf110 + (0x10 * i)));
73         }
74 }
75