blob: 07a3d3ede768149441a14503539e8b25d7c0b9db [file] [log] [blame]
Santosh Shilimkar2722e562011-03-07 20:53:10 +05301/*
sricharaned0e3522011-08-24 20:07:45 +05302 * OMAP4XXX L3 Interconnect error handling driver
3 *
4 * Copyright (C) 2011 Texas Corporation
5 * Santosh Shilimkar <santosh.shilimkar@ti.com>
6 * Sricharan <r.sricharan@ti.com>
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 as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 * USA
22 */
Santosh Shilimkar2722e562011-03-07 20:53:10 +053023#include <linux/init.h>
24#include <linux/io.h>
25#include <linux/platform_device.h>
26#include <linux/interrupt.h>
27#include <linux/kernel.h>
28#include <linux/slab.h>
29
30#include "omap_l3_noc.h"
31
32/*
33 * Interrupt Handler for L3 error detection.
34 * 1) Identify the L3 clockdomain partition to which the error belongs to.
35 * 2) Identify the slave where the error information is logged
36 * 3) Print the logged information.
37 * 4) Add dump stack to provide kernel trace.
38 *
39 * Two Types of errors :
40 * 1) Custom errors in L3 :
41 * Target like DMM/FW/EMIF generates SRESP=ERR error
42 * 2) Standard L3 error:
43 * - Unsupported CMD.
44 * L3 tries to access target while it is idle
45 * - OCP disconnect.
46 * - Address hole error:
47 * If DSS/ISS/FDIF/USBHOSTFS access a target where they
48 * do not have connectivity, the error is logged in
49 * their default target which is DMM2.
50 *
51 * On High Secure devices, firewall errors are possible and those
52 * can be trapped as well. But the trapping is implemented as part
53 * secure software and hence need not be implemented here.
54 */
55static irqreturn_t l3_interrupt_handler(int irq, void *_l3)
56{
57
sricharaned0e3522011-08-24 20:07:45 +053058 struct omap4_l3 *l3 = _l3;
sricharan551a9fa2011-09-07 17:25:16 +053059 int inttype, i, k;
Santosh Shilimkar2722e562011-03-07 20:53:10 +053060 int err_src = 0;
sricharan551a9fa2011-09-07 17:25:16 +053061 u32 std_err_main, err_reg, clear, masterid;
sricharan6616aac2011-08-23 12:58:48 +053062 void __iomem *base, *l3_targ_base;
sricharan551a9fa2011-09-07 17:25:16 +053063 char *target_name, *master_name = "UN IDENTIFIED";
Santosh Shilimkar2722e562011-03-07 20:53:10 +053064
65 /* Get the Type of interrupt */
omar ramirez35f7b962011-04-18 16:39:42 +000066 inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR;
Santosh Shilimkar2722e562011-03-07 20:53:10 +053067
68 for (i = 0; i < L3_MODULES; i++) {
69 /*
70 * Read the regerr register of the clock domain
71 * to determine the source
72 */
sricharan6616aac2011-08-23 12:58:48 +053073 base = l3->l3_base[i];
74 err_reg = __raw_readl(base + l3_flagmux[i] +
Todd Poynor342fd142011-08-24 19:11:39 +053075 + L3_FLAGMUX_REGERR0 + (inttype << 3));
Santosh Shilimkar2722e562011-03-07 20:53:10 +053076
77 /* Get the corresponding error and analyse */
78 if (err_reg) {
79 /* Identify the source from control status register */
Todd Poynor342fd142011-08-24 19:11:39 +053080 err_src = __ffs(err_reg);
Santosh Shilimkar2722e562011-03-07 20:53:10 +053081
Santosh Shilimkar2722e562011-03-07 20:53:10 +053082 /* Read the stderrlog_main_source from clk domain */
Todd Poynor342fd142011-08-24 19:11:39 +053083 l3_targ_base = base + *(l3_targ[i] + err_src);
sricharan6616aac2011-08-23 12:58:48 +053084 std_err_main = __raw_readl(l3_targ_base +
Todd Poynor342fd142011-08-24 19:11:39 +053085 L3_TARG_STDERRLOG_MAIN);
sricharan551a9fa2011-09-07 17:25:16 +053086 masterid = __raw_readl(l3_targ_base +
87 L3_TARG_STDERRLOG_MSTADDR);
Santosh Shilimkar2722e562011-03-07 20:53:10 +053088
omar ramirez35f7b962011-04-18 16:39:42 +000089 switch (std_err_main & CUSTOM_ERROR) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +053090 case STANDARD_ERROR:
sricharan551a9fa2011-09-07 17:25:16 +053091 target_name =
Todd Poynor342fd142011-08-24 19:11:39 +053092 l3_targ_inst_name[i][err_src];
sricharan551a9fa2011-09-07 17:25:16 +053093 WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n",
94 target_name,
sricharan6616aac2011-08-23 12:58:48 +053095 __raw_readl(l3_targ_base +
Todd Poynor342fd142011-08-24 19:11:39 +053096 L3_TARG_STDERRLOG_SLVOFSLSB));
Santosh Shilimkar2722e562011-03-07 20:53:10 +053097 /* clear the std error log*/
98 clear = std_err_main | CLEAR_STDERR_LOG;
Todd Poynor342fd142011-08-24 19:11:39 +053099 writel(clear, l3_targ_base +
100 L3_TARG_STDERRLOG_MAIN);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530101 break;
102
103 case CUSTOM_ERROR:
sricharan551a9fa2011-09-07 17:25:16 +0530104 target_name =
Todd Poynor342fd142011-08-24 19:11:39 +0530105 l3_targ_inst_name[i][err_src];
sricharan551a9fa2011-09-07 17:25:16 +0530106 for (k = 0; k < NUM_OF_L3_MASTERS; k++) {
107 if (masterid == l3_masters[k].id)
108 master_name =
109 l3_masters[k].name;
110 }
111 WARN(true, "L3 custom error: MASTER:%s TARGET:%s\n",
112 master_name, target_name);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530113 /* clear the std error log*/
114 clear = std_err_main | CLEAR_STDERR_LOG;
Todd Poynor342fd142011-08-24 19:11:39 +0530115 writel(clear, l3_targ_base +
116 L3_TARG_STDERRLOG_MAIN);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530117 break;
118
119 default:
120 /* Nothing to be handled here as of now */
121 break;
122 }
123 /* Error found so break the for loop */
124 break;
125 }
126 }
127 return IRQ_HANDLED;
128}
129
130static int __init omap4_l3_probe(struct platform_device *pdev)
131{
sricharaned0e3522011-08-24 20:07:45 +0530132 static struct omap4_l3 *l3;
Todd Poynor342fd142011-08-24 19:11:39 +0530133 struct resource *res;
Todd Poynorc1df2dc2011-08-29 17:42:23 +0530134 int ret;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530135
136 l3 = kzalloc(sizeof(*l3), GFP_KERNEL);
137 if (!l3)
omar ramirez7529b702011-04-18 16:39:41 +0000138 return -ENOMEM;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530139
140 platform_set_drvdata(pdev, l3);
141 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
142 if (!res) {
143 dev_err(&pdev->dev, "couldn't find resource 0\n");
144 ret = -ENODEV;
omar ramirez7529b702011-04-18 16:39:41 +0000145 goto err0;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530146 }
147
148 l3->l3_base[0] = ioremap(res->start, resource_size(res));
omar ramirez35f7b962011-04-18 16:39:42 +0000149 if (!l3->l3_base[0]) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530150 dev_err(&pdev->dev, "ioremap failed\n");
151 ret = -ENOMEM;
omar ramirez7529b702011-04-18 16:39:41 +0000152 goto err0;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530153 }
154
155 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
156 if (!res) {
157 dev_err(&pdev->dev, "couldn't find resource 1\n");
158 ret = -ENODEV;
omar ramirez7529b702011-04-18 16:39:41 +0000159 goto err1;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530160 }
161
162 l3->l3_base[1] = ioremap(res->start, resource_size(res));
omar ramirez35f7b962011-04-18 16:39:42 +0000163 if (!l3->l3_base[1]) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530164 dev_err(&pdev->dev, "ioremap failed\n");
165 ret = -ENOMEM;
omar ramirez7529b702011-04-18 16:39:41 +0000166 goto err1;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530167 }
168
169 res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
170 if (!res) {
171 dev_err(&pdev->dev, "couldn't find resource 2\n");
172 ret = -ENODEV;
omar ramirez7529b702011-04-18 16:39:41 +0000173 goto err2;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530174 }
175
176 l3->l3_base[2] = ioremap(res->start, resource_size(res));
omar ramirez35f7b962011-04-18 16:39:42 +0000177 if (!l3->l3_base[2]) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530178 dev_err(&pdev->dev, "ioremap failed\n");
179 ret = -ENOMEM;
omar ramirez7529b702011-04-18 16:39:41 +0000180 goto err2;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530181 }
182
183 /*
184 * Setup interrupt Handlers
185 */
Todd Poynorc1df2dc2011-08-29 17:42:23 +0530186 l3->debug_irq = platform_get_irq(pdev, 0);
187 ret = request_irq(l3->debug_irq,
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530188 l3_interrupt_handler,
189 IRQF_DISABLED, "l3-dbg-irq", l3);
190 if (ret) {
191 pr_crit("L3: request_irq failed to register for 0x%x\n",
sricharaned0e3522011-08-24 20:07:45 +0530192 OMAP44XX_IRQ_L3_DBG);
omar ramirez7529b702011-04-18 16:39:41 +0000193 goto err3;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530194 }
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530195
Todd Poynorc1df2dc2011-08-29 17:42:23 +0530196 l3->app_irq = platform_get_irq(pdev, 1);
197 ret = request_irq(l3->app_irq,
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530198 l3_interrupt_handler,
199 IRQF_DISABLED, "l3-app-irq", l3);
200 if (ret) {
201 pr_crit("L3: request_irq failed to register for 0x%x\n",
sricharaned0e3522011-08-24 20:07:45 +0530202 OMAP44XX_IRQ_L3_APP);
omar ramirez7529b702011-04-18 16:39:41 +0000203 goto err4;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530204 }
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530205
omar ramirez7529b702011-04-18 16:39:41 +0000206 return 0;
207
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530208err4:
omar ramirez7529b702011-04-18 16:39:41 +0000209 free_irq(l3->debug_irq, l3);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530210err3:
omar ramirez7529b702011-04-18 16:39:41 +0000211 iounmap(l3->l3_base[2]);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530212err2:
omar ramirez7529b702011-04-18 16:39:41 +0000213 iounmap(l3->l3_base[1]);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530214err1:
omar ramirez7529b702011-04-18 16:39:41 +0000215 iounmap(l3->l3_base[0]);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530216err0:
omar ramirez7529b702011-04-18 16:39:41 +0000217 kfree(l3);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530218 return ret;
219}
220
221static int __exit omap4_l3_remove(struct platform_device *pdev)
222{
sricharaned0e3522011-08-24 20:07:45 +0530223 struct omap4_l3 *l3 = platform_get_drvdata(pdev);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530224
225 free_irq(l3->app_irq, l3);
226 free_irq(l3->debug_irq, l3);
227 iounmap(l3->l3_base[0]);
228 iounmap(l3->l3_base[1]);
229 iounmap(l3->l3_base[2]);
230 kfree(l3);
231
232 return 0;
233}
234
235static struct platform_driver omap4_l3_driver = {
sricharaned0e3522011-08-24 20:07:45 +0530236 .remove = __exit_p(omap4_l3_remove),
237 .driver = {
238 .name = "omap_l3_noc",
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530239 },
240};
241
242static int __init omap4_l3_init(void)
243{
244 return platform_driver_probe(&omap4_l3_driver, omap4_l3_probe);
245}
246postcore_initcall_sync(omap4_l3_init);
247
248static void __exit omap4_l3_exit(void)
249{
250 platform_driver_unregister(&omap4_l3_driver);
251}
252module_exit(omap4_l3_exit);