upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / power-debug.c
1 /*
2  * S5PC210 Power/Clock debugging stuff
3  *
4  * Copyright (C) 2011 Samsung Electronics
5  */
6
7 #include <linux/kernel.h>
8 #include <linux/init.h>
9 #include <linux/io.h>
10 #include <linux/platform_device.h>
11 #include <linux/seq_file.h>
12 #include <linux/debugfs.h>
13
14 #include <plat/pd.h>
15 #include <plat/devs.h>
16
17 #include <mach/regs-pmu.h>
18 #include <mach/regs-clock.h>
19
20 static const char *powerdomain_name[] = {
21         "CAM",
22         "TV",
23         "MFC",
24         "G3D",
25         "LCD0",
26         "LCD1",
27         "MAUDIO",
28         "GPS",
29 };
30
31 #define MAX_GATE_IP_NUM         17
32
33 static const char *clock_gate_ip[][MAX_GATE_IP_NUM] = {
34         {
35                 "FIMC0", "FIMC1", "FIMC2", "FIMC3",
36                 "CSIC0", "CSIS1", "JPEG", "SMMUFIMC0",
37                 "SMMUFIMC1", "SMMUFIMC2", "SMMUFIMC3", "SMMUJPEG",
38                 "QEFIMC0", "QEFIMC1", "QEFIMC2", "QEFIMC3",
39                 "PPMUCAMIF",
40         }, {
41                 "VP", "MIXER", "TVENC", "HDMI",
42                 "SMMUTV", "PPMUTV",
43         }, {
44                 "MFC",
45         }, {
46                 "G3D",
47         }, {
48                 "FIMD0", "MIE0", "MDNIE0", "DSIM0",
49                 "SMMUFIMD0", "PPMULCD0",
50         }, {
51                 "FIMD1", "MIE1", "MDNIE1", "DSIM1",
52                 "SMMUFIMD1", "PPMULCD1",
53         }, {
54                 "nonn",
55         }, {
56                 "GPS",
57         },
58 };
59
60 static int pd_show(struct seq_file *s, void *unused)
61 {
62         struct samsung_pd_info *spi;
63         struct s5pv310_pd_data *spd;
64         struct platform_device *p;
65         int start, end, val;
66         int i;
67
68         /* Power Domain */
69         for (i = 0; i <= PD_GPS; i++) {
70                 p = &s5pv310_device_pd[i];
71
72                 if (i == 6)
73                         continue;
74
75                 spi = dev_get_platdata(&p->dev);
76                 WARN_ON(!spi);
77                 spd = spi->data;
78                 WARN_ON(!spd);
79
80                 seq_printf(s, "ID %d %4s, ", p->id, powerdomain_name[i]);
81                 seq_printf(s, "base 0x%x : 0x%x\n",
82                                 (u32) spi->base, __raw_readl(spi->base));
83
84                 if (__raw_readl(spi->base) == 0)
85                         continue;
86
87                 switch (p->id) {
88                 case PD_CAM:
89                         end = 16; break;
90                 case PD_TV:
91                         end = 5; break;
92                 case PD_MFC:
93                         end = 0; break;
94                 case PD_G3D:
95                         end = 0; break;
96                 case PD_LCD0:
97                         end = 5; break;
98                 case PD_LCD1:
99                         end = 5; break;
100                 case PD_GPS:
101                         end = 0; break;
102                 default:
103                         end = 0;
104                         break;
105                 }
106                 seq_printf(s, "\t");
107
108                 /* Clock Gate IP */
109                 val = __raw_readl(spd->clk_base);
110                 for (start = 0; start < MAX_GATE_IP_NUM; start++) {
111                         if (start > end)
112                                 break;
113                         if (val & 1) {
114                                 seq_printf(s, "%s, ", clock_gate_ip[i][start]);
115                         }
116                         val >>= 1;
117                 }
118                 seq_printf(s, "\n");
119 #if 0
120                 if (spd->read_base)
121                         seq_printf(s, "\tread_base 0x%x : 0x%x\n",
122                                 (u32) spd->read_base, __raw_readl(spd->read_base));
123 #endif
124         }
125
126         return 0;
127 }
128
129 static int pd_open(struct inode *inode, struct file *file)
130 {
131         return single_open(file, pd_show, NULL);
132 }
133
134 static const struct file_operations pd_operations = {
135         .open           = pd_open,
136         .read           = seq_read,
137         .llseek         = seq_lseek,
138         .release        = single_release,
139 };
140
141 static int __init pd_debugfs_init(void)
142 {
143         (void) debugfs_create_file("power-debug", S_IFREG | S_IRUGO,
144                         NULL, NULL, &pd_operations);
145         return 0;
146 }
147
148 late_initcall(pd_debugfs_init);