2 * OMAP4XXX L3 Interconnect error handling driver
4 * Copyright (C) 2011 Texas Corporation
5 * Santosh Shilimkar <santosh.shilimkar@ti.com>
6 * Sricharan <r.sricharan@ti.com>
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.
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.
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
23 #include <linux/init.h>
25 #include <linux/platform_device.h>
26 #include <linux/interrupt.h>
27 #include <linux/kernel.h>
28 #include <linux/slab.h>
30 #include "omap_l3_noc.h"
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.
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:
44 * L3 tries to access target while it is idle
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.
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.
55 static irqreturn_t l3_interrupt_handler(int irq, void *_l3)
58 struct omap4_l3 *l3 = _l3;
61 u32 std_err_main, err_reg, clear, masterid;
62 void __iomem *base, *l3_targ_base;
63 char *target_name, *master_name = "UN IDENTIFIED";
65 /* Get the Type of interrupt */
66 inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR;
68 for (i = 0; i < L3_MODULES; i++) {
70 * Read the regerr register of the clock domain
71 * to determine the source
73 base = l3->l3_base[i];
74 err_reg = __raw_readl(base + l3_flagmux[i] +
75 + L3_FLAGMUX_REGERR0 + (inttype << 3));
77 /* Get the corresponding error and analyse */
79 /* Identify the source from control status register */
80 err_src = __ffs(err_reg);
82 /* Read the stderrlog_main_source from clk domain */
83 l3_targ_base = base + *(l3_targ[i] + err_src);
84 std_err_main = __raw_readl(l3_targ_base +
85 L3_TARG_STDERRLOG_MAIN);
86 masterid = __raw_readl(l3_targ_base +
87 L3_TARG_STDERRLOG_MSTADDR);
89 switch (std_err_main & CUSTOM_ERROR) {
92 l3_targ_inst_name[i][err_src];
93 WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n",
95 __raw_readl(l3_targ_base +
96 L3_TARG_STDERRLOG_SLVOFSLSB));
97 /* clear the std error log*/
98 clear = std_err_main | CLEAR_STDERR_LOG;
99 writel(clear, l3_targ_base +
100 L3_TARG_STDERRLOG_MAIN);
105 l3_targ_inst_name[i][err_src];
106 for (k = 0; k < NUM_OF_L3_MASTERS; k++) {
107 if (masterid == l3_masters[k].id)
111 WARN(true, "L3 custom error: MASTER:%s TARGET:%s\n",
112 master_name, target_name);
113 /* clear the std error log*/
114 clear = std_err_main | CLEAR_STDERR_LOG;
115 writel(clear, l3_targ_base +
116 L3_TARG_STDERRLOG_MAIN);
120 /* Nothing to be handled here as of now */
123 /* Error found so break the for loop */
130 static int __devinit omap4_l3_probe(struct platform_device *pdev)
132 static struct omap4_l3 *l3;
133 struct resource *res;
136 l3 = kzalloc(sizeof(*l3), GFP_KERNEL);
140 platform_set_drvdata(pdev, l3);
141 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
143 dev_err(&pdev->dev, "couldn't find resource 0\n");
148 l3->l3_base[0] = ioremap(res->start, resource_size(res));
149 if (!l3->l3_base[0]) {
150 dev_err(&pdev->dev, "ioremap failed\n");
155 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
157 dev_err(&pdev->dev, "couldn't find resource 1\n");
162 l3->l3_base[1] = ioremap(res->start, resource_size(res));
163 if (!l3->l3_base[1]) {
164 dev_err(&pdev->dev, "ioremap failed\n");
169 res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
171 dev_err(&pdev->dev, "couldn't find resource 2\n");
176 l3->l3_base[2] = ioremap(res->start, resource_size(res));
177 if (!l3->l3_base[2]) {
178 dev_err(&pdev->dev, "ioremap failed\n");
184 * Setup interrupt Handlers
186 l3->debug_irq = platform_get_irq(pdev, 0);
187 ret = request_irq(l3->debug_irq,
188 l3_interrupt_handler,
189 IRQF_DISABLED, "l3-dbg-irq", l3);
191 pr_crit("L3: request_irq failed to register for 0x%x\n",
192 OMAP44XX_IRQ_L3_DBG);
196 l3->app_irq = platform_get_irq(pdev, 1);
197 ret = request_irq(l3->app_irq,
198 l3_interrupt_handler,
199 IRQF_DISABLED, "l3-app-irq", l3);
201 pr_crit("L3: request_irq failed to register for 0x%x\n",
202 OMAP44XX_IRQ_L3_APP);
209 free_irq(l3->debug_irq, l3);
211 iounmap(l3->l3_base[2]);
213 iounmap(l3->l3_base[1]);
215 iounmap(l3->l3_base[0]);
221 static int __devexit omap4_l3_remove(struct platform_device *pdev)
223 struct omap4_l3 *l3 = platform_get_drvdata(pdev);
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]);
235 #if defined(CONFIG_OF)
236 static const struct of_device_id l3_noc_match[] = {
237 {.compatible = "ti,omap4-l3-noc", },
240 MODULE_DEVICE_TABLE(of, l3_noc_match);
242 #define l3_noc_match NULL
245 static struct platform_driver omap4_l3_driver = {
246 .probe = omap4_l3_probe,
247 .remove = __devexit_p(omap4_l3_remove),
249 .name = "omap_l3_noc",
250 .owner = THIS_MODULE,
251 .of_match_table = l3_noc_match,
255 static int __init omap4_l3_init(void)
257 return platform_driver_register(&omap4_l3_driver);
259 postcore_initcall_sync(omap4_l3_init);
261 static void __exit omap4_l3_exit(void)
263 platform_driver_unregister(&omap4_l3_driver);
265 module_exit(omap4_l3_exit);