2 * OMAP L3 Interconnect error handling driver
4 * Copyright (C) 2011-2014 Texas Instruments Incorporated - http://www.ti.com/
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 version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 #include <linux/module.h>
18 #include <linux/init.h>
20 #include <linux/platform_device.h>
21 #include <linux/interrupt.h>
22 #include <linux/kernel.h>
23 #include <linux/slab.h>
25 #include "omap_l3_noc.h"
28 * Interrupt Handler for L3 error detection.
29 * 1) Identify the L3 clockdomain partition to which the error belongs to.
30 * 2) Identify the slave where the error information is logged
31 * 3) Print the logged information.
32 * 4) Add dump stack to provide kernel trace.
34 * Two Types of errors :
35 * 1) Custom errors in L3 :
36 * Target like DMM/FW/EMIF generates SRESP=ERR error
37 * 2) Standard L3 error:
39 * L3 tries to access target while it is idle
41 * - Address hole error:
42 * If DSS/ISS/FDIF/USBHOSTFS access a target where they
43 * do not have connectivity, the error is logged in
44 * their default target which is DMM2.
46 * On High Secure devices, firewall errors are possible and those
47 * can be trapped as well. But the trapping is implemented as part
48 * secure software and hence need not be implemented here.
50 static irqreturn_t l3_interrupt_handler(int irq, void *_l3)
53 struct omap_l3 *l3 = _l3;
56 u32 std_err_main, err_reg, clear, masterid;
57 void __iomem *base, *l3_targ_base;
58 char *target_name, *master_name = "UN IDENTIFIED";
60 /* Get the Type of interrupt */
61 inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR;
63 for (i = 0; i < L3_MODULES; i++) {
65 * Read the regerr register of the clock domain
66 * to determine the source
68 base = l3->l3_base[i];
69 err_reg = __raw_readl(base + l3_flagmux[i] +
70 + L3_FLAGMUX_REGERR0 + (inttype << 3));
72 /* Get the corresponding error and analyse */
74 /* Identify the source from control status register */
75 err_src = __ffs(err_reg);
77 /* Read the stderrlog_main_source from clk domain */
78 l3_targ_base = base + *(l3_targ[i] + err_src);
79 std_err_main = __raw_readl(l3_targ_base +
80 L3_TARG_STDERRLOG_MAIN);
81 masterid = __raw_readl(l3_targ_base +
82 L3_TARG_STDERRLOG_MSTADDR);
84 switch (std_err_main & CUSTOM_ERROR) {
87 l3_targ_inst_name[i][err_src];
88 WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n",
90 __raw_readl(l3_targ_base +
91 L3_TARG_STDERRLOG_SLVOFSLSB));
92 /* clear the std error log*/
93 clear = std_err_main | CLEAR_STDERR_LOG;
94 writel(clear, l3_targ_base +
95 L3_TARG_STDERRLOG_MAIN);
100 l3_targ_inst_name[i][err_src];
101 for (k = 0; k < NUM_OF_L3_MASTERS; k++) {
102 if (masterid == l3_masters[k].id)
106 WARN(true, "L3 custom error: MASTER:%s TARGET:%s\n",
107 master_name, target_name);
108 /* clear the std error log*/
109 clear = std_err_main | CLEAR_STDERR_LOG;
110 writel(clear, l3_targ_base +
111 L3_TARG_STDERRLOG_MAIN);
115 /* Nothing to be handled here as of now */
118 /* Error found so break the for loop */
125 static int omap_l3_probe(struct platform_device *pdev)
127 static struct omap_l3 *l3;
130 l3 = devm_kzalloc(&pdev->dev, sizeof(*l3), GFP_KERNEL);
134 platform_set_drvdata(pdev, l3);
136 /* Get mem resources */
137 for (i = 0; i < L3_MODULES; i++) {
138 struct resource *res = platform_get_resource(pdev,
141 l3->l3_base[i] = devm_ioremap_resource(&pdev->dev, res);
142 if (IS_ERR(l3->l3_base[i])) {
143 dev_err(&pdev->dev, "ioremap %d failed\n", i);
144 return PTR_ERR(l3->l3_base[i]);
149 * Setup interrupt Handlers
151 l3->debug_irq = platform_get_irq(pdev, 0);
152 ret = devm_request_irq(&pdev->dev, l3->debug_irq, l3_interrupt_handler,
153 IRQF_DISABLED, "l3-dbg-irq", l3);
155 dev_err(&pdev->dev, "request_irq failed for %d\n",
160 l3->app_irq = platform_get_irq(pdev, 1);
161 ret = devm_request_irq(&pdev->dev, l3->app_irq, l3_interrupt_handler,
162 IRQF_DISABLED, "l3-app-irq", l3);
164 dev_err(&pdev->dev, "request_irq failed for %d\n", l3->app_irq);
169 #if defined(CONFIG_OF)
170 static const struct of_device_id l3_noc_match[] = {
171 {.compatible = "ti,omap4-l3-noc", },
174 MODULE_DEVICE_TABLE(of, l3_noc_match);
176 #define l3_noc_match NULL
179 static struct platform_driver omap_l3_driver = {
180 .probe = omap_l3_probe,
182 .name = "omap_l3_noc",
183 .owner = THIS_MODULE,
184 .of_match_table = l3_noc_match,
188 static int __init omap_l3_init(void)
190 return platform_driver_register(&omap_l3_driver);
192 postcore_initcall_sync(omap_l3_init);
194 static void __exit omap_l3_exit(void)
196 platform_driver_unregister(&omap_l3_driver);
198 module_exit(omap_l3_exit);