59b21e752fcecf45bf8c1c5474f1d4c310306f00
[linux-3.10.git] / drivers / platform / tegra / mc / mcerr-t12.c
1 /*
2  * Tegra 12x SoC-specific mcerr code.
3  *
4  * Copyright (c) 2012-2014, NVIDIA Corporation. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 #include <mach/mcerr.h>
22
23 /*** Auto generated by `mcp.pl'. Do not modify! ***/
24
25 #define dummy_client   client("dummy", "dummy")
26
27 struct mc_client mc_clients[] = {
28         client("ptc", "csr_ptcr"),
29         client("dc", "csr_display0a"),
30         client("dcb", "csr_display0ab"),
31         client("dc", "csr_display0b"),
32         client("dcb", "csr_display0bb"),
33         client("dc", "csr_display0c"),
34         client("dcb", "csr_display0cb"),
35         dummy_client,
36         dummy_client,
37         dummy_client,
38         dummy_client,
39         dummy_client,
40         dummy_client,
41         dummy_client,
42         client("afi", "csr_afir"),
43         client("avpc", "csr_avpcarm7r"),
44         client("dc", "csr_displayhc"),
45         client("dcb", "csr_displayhcb"),
46         dummy_client,
47         dummy_client,
48         dummy_client,
49         client("hda", "csr_hdar"),
50         client("hc", "csr_host1xdmar"),
51         client("hc", "csr_host1xr"),
52         dummy_client,
53         dummy_client,
54         dummy_client,
55         dummy_client,
56         client("msenc", "csr_msencsrd"),
57         client("ppcs", "csr_ppcsahbdmar"),
58         client("ppcs", "csr_ppcsahbslvr"),
59         client("sata", "csr_satar"),
60         dummy_client,
61         dummy_client,
62         client("vde", "csr_vdebsevr"),
63         client("vde", "csr_vdember"),
64         client("vde", "csr_vdemcer"),
65         client("vde", "csr_vdetper"),
66         client("mpcorelp", "csr_mpcorelpr"),
67         client("mpcore", "csr_mpcorer"),
68         dummy_client,
69         dummy_client,
70         dummy_client,
71         client("msenc", "csw_msencswr"),
72         dummy_client,
73         dummy_client,
74         dummy_client,
75         dummy_client,
76         dummy_client,
77         client("afi", "csw_afiw"),
78         client("avpc", "csw_avpcarm7w"),
79         dummy_client,
80         dummy_client,
81         client("hda", "csw_hdaw"),
82         client("hc", "csw_host1xw"),
83         dummy_client,
84         client("mpcorelp", "csw_mpcorelpw"),
85         client("mpcore", "csw_mpcorew"),
86         dummy_client,
87         client("ppcs", "csw_ppcsahbdmaw"),
88         client("ppcs", "csw_ppcsahbslvw"),
89         client("sata", "csw_sataw"),
90         client("vde", "csw_vdebsevw"),
91         client("vde", "csw_vdedbgw"),
92         client("vde", "csw_vdembew"),
93         client("vde", "csw_vdetpmw"),
94         dummy_client,
95         dummy_client,
96         client("isp2", "csr_ispra"),
97         dummy_client,
98         client("isp2", "csw_ispwa"),
99         client("isp2", "csw_ispwb"),
100         dummy_client,
101         dummy_client,
102         client("xusb_host", "csr_xusb_hostr"),
103         client("xusb_host", "csw_xusb_hostw"),
104         client("xusb_dev", "csr_xusb_devr"),
105         client("xusb_dev", "csw_xusb_devw"),
106         client("isp2b", "csr_isprab"),
107         dummy_client,
108         client("isp2b", "csw_ispwab"),
109         client("isp2b", "csw_ispwbb"),
110         dummy_client,
111         dummy_client,
112         client("tsec", "csr_tsecsrd"),
113         client("tsec", "csw_tsecswr"),
114         client("a9avp", "csr_a9avpscr"),
115         client("a9avp", "csw_a9avpscw"),
116         client("gpu", "csr_gpusrd"),
117         client("gpu", "csw_gpuswr"),
118         client("dc", "csr_displayt"),
119         dummy_client,
120         dummy_client,
121         dummy_client,
122         dummy_client,
123         dummy_client,
124         client("sdmmc1a", "csr_sdmmcra"),
125         client("sdmmc2a", "csr_sdmmcraa"),
126         client("sdmmc3a", "csr_sdmmcr"),
127         client("sdmmc4a", "csr_sdmmcrab"),
128         client("sdmmc1a", "csw_sdmmcwa"),
129         client("sdmmc2a", "csw_sdmmcwaa"),
130         client("sdmmc3a", "csw_sdmmcw"),
131         client("sdmmc4a", "csw_sdmmcwab"),
132         dummy_client,
133         dummy_client,
134         dummy_client,
135         dummy_client,
136         client("vic", "csr_vicsrd"),
137         client("vic", "csw_vicswr"),
138         dummy_client,
139         dummy_client,
140         dummy_client,
141         dummy_client,
142         client("vi", "csw_viw"),
143         client("dc", "csr_displayd"),
144 };
145 int mc_client_last = ARRAY_SIZE(mc_clients) - 1;
146 /*** Done. ***/
147
148 static void mcerr_t12x_info_update(struct mc_client *c, u32 stat)
149 {
150         if (stat & MC_INT_DECERR_EMEM)
151                 c->intr_counts[0]++;
152         if (stat & MC_INT_SECURITY_VIOLATION)
153                 c->intr_counts[1]++;
154         if (stat & MC_INT_INVALID_SMMU_PAGE)
155                 c->intr_counts[2]++;
156         if (stat & MC_INT_INVALID_APB_ASID_UPDATE)
157                 c->intr_counts[3]++;
158         if (stat & MC_INT_DECERR_VPR)
159                 c->intr_counts[4]++;
160         if (stat & MC_INT_SECERR_SEC)
161                 c->intr_counts[5]++;
162         if (stat & MC_INT_DECERR_MTS)
163                 c->intr_counts[6]++;
164
165         if (stat & ~mc_int_mask)
166                 c->intr_counts[7]++;
167 }
168
169 #define fmt_hdr "%-18s %-18s %-9s %-9s %-9s %-10s %-10s %-10s %-10s %-9s\n"
170 #define fmt_cli "%-18s %-18s %-9u %-9u %-9u %-10u %-10u %-10u %-10u %-9u\n"
171 static int mcerr_t12x_debugfs_show(struct seq_file *s, void *v)
172 {
173         int i, j;
174         int do_print;
175
176         seq_printf(s, fmt_hdr,
177                    "swgid", "client", "decerr", "secerr", "smmuerr",
178                    "apberr", "decerr-VPR", "secerr-SEC",
179                    "decerr-MTS", "unknown");
180         for (i = 0; i < ARRAY_SIZE(mc_clients); i++) {
181                 do_print = 0;
182                 if (strcmp(mc_clients[i].name, "dummy") == 0)
183                         continue;
184                 /* Only print clients who actually have errors. */
185                 for (j = 0; j < mc_intr_count; j++) {
186                         if (mc_clients[i].intr_counts[j]) {
187                                 do_print = 1;
188                                 break;
189                         }
190                 }
191                 if (do_print)
192                         seq_printf(s, fmt_cli,
193                                    mc_clients[i].swgid,
194                                    mc_clients[i].name,
195                                    mc_clients[i].intr_counts[0],
196                                    mc_clients[i].intr_counts[1],
197                                    mc_clients[i].intr_counts[2],
198                                    mc_clients[i].intr_counts[3],
199                                    mc_clients[i].intr_counts[4],
200                                    mc_clients[i].intr_counts[5],
201                                    mc_clients[i].intr_counts[6],
202                                    mc_clients[i].intr_counts[7]);
203         }
204         return 0;
205 }
206
207 /*
208  * Set up chip specific functions and data for handling this particular chip's
209  * error decoding and logging.
210  */
211 void mcerr_chip_specific_setup(struct mcerr_chip_specific *spec)
212 {
213         spec->mcerr_info_update = mcerr_t12x_info_update;
214         spec->mcerr_debugfs_show = mcerr_t12x_debugfs_show;
215         spec->nr_clients = ARRAY_SIZE(mc_clients);
216         return;
217 }
218