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/init.h>
18 #include <linux/interrupt.h>
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/of_device.h>
24 #include <linux/platform_device.h>
25 #include <linux/slab.h>
27 #include "omap_l3_noc.h"
30 * Interrupt Handler for L3 error detection.
31 * 1) Identify the L3 clockdomain partition to which the error belongs to.
32 * 2) Identify the slave where the error information is logged
33 * 3) Print the logged information.
34 * 4) Add dump stack to provide kernel trace.
36 * Two Types of errors :
37 * 1) Custom errors in L3 :
38 * Target like DMM/FW/EMIF generates SRESP=ERR error
39 * 2) Standard L3 error:
41 * L3 tries to access target while it is idle
43 * - Address hole error:
44 * If DSS/ISS/FDIF/USBHOSTFS access a target where they
45 * do not have connectivity, the error is logged in
46 * their default target which is DMM2.
48 * On High Secure devices, firewall errors are possible and those
49 * can be trapped as well. But the trapping is implemented as part
50 * secure software and hence need not be implemented here.
52 static irqreturn_t l3_interrupt_handler(int irq, void *_l3)
55 struct omap_l3 *l3 = _l3;
58 u32 std_err_main, err_reg, clear, masterid;
59 void __iomem *base, *l3_targ_base;
60 void __iomem *l3_targ_stderr, *l3_targ_slvofslsb, *l3_targ_mstaddr;
61 char *target_name, *master_name = "UN IDENTIFIED";
62 struct l3_target_data *l3_targ_inst;
63 struct l3_masters_data *master;
65 /* Get the Type of interrupt */
66 inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR;
68 for (i = 0; i < l3->num_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 = readl_relaxed(base + l3->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 /* We DONOT expect err_src to go out of bounds */
83 BUG_ON(err_src > MAX_CLKDM_TARGETS);
85 l3_targ_inst = &l3->l3_targ[i][err_src];
86 target_name = l3_targ_inst->name;
87 l3_targ_base = base + l3_targ_inst->offset;
90 * If we do not know of a register offset to decode
91 * and clear, then mask.
93 if (target_name == L3_TARGET_NOT_SUPPORTED) {
95 void __iomem *mask_reg;
98 * Certain plaforms may have "undocumented"
99 * status pending on boot.. So dont generate
100 * a severe warning here.
103 "L3 %s error: target %d mod:%d %s\n",
104 inttype ? "debug" : "application",
105 err_src, i, "(unclearable)");
107 mask_reg = base + l3->l3_flagmux[i] +
108 L3_FLAGMUX_MASK0 + (inttype << 3);
109 mask_val = readl_relaxed(mask_reg);
110 mask_val &= ~(1 << err_src);
111 writel_relaxed(mask_val, mask_reg);
116 /* Read the stderrlog_main_source from clk domain */
117 l3_targ_stderr = l3_targ_base + L3_TARG_STDERRLOG_MAIN;
118 l3_targ_slvofslsb = l3_targ_base +
119 L3_TARG_STDERRLOG_SLVOFSLSB;
120 l3_targ_mstaddr = l3_targ_base +
121 L3_TARG_STDERRLOG_MSTADDR;
123 std_err_main = readl_relaxed(l3_targ_stderr);
124 masterid = readl_relaxed(l3_targ_mstaddr);
126 switch (std_err_main & CUSTOM_ERROR) {
128 WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n",
130 readl_relaxed(l3_targ_slvofslsb));
131 /* clear the std error log*/
132 clear = std_err_main | CLEAR_STDERR_LOG;
133 writel_relaxed(clear, l3_targ_stderr);
137 for (k = 0, master = l3->l3_masters;
138 k < l3->num_masters; k++, master++) {
139 if (masterid == master->id) {
140 master_name = master->name;
144 WARN(true, "L3 custom error: MASTER:%s TARGET:%s\n",
145 master_name, target_name);
146 /* clear the std error log*/
147 clear = std_err_main | CLEAR_STDERR_LOG;
148 writel_relaxed(clear, l3_targ_stderr);
152 /* Nothing to be handled here as of now */
155 /* Error found so break the for loop */
162 static const struct of_device_id l3_noc_match[] = {
163 {.compatible = "ti,omap4-l3-noc", .data = &omap_l3_data},
166 MODULE_DEVICE_TABLE(of, l3_noc_match);
168 static int omap_l3_probe(struct platform_device *pdev)
170 const struct of_device_id *of_id;
171 static struct omap_l3 *l3;
174 of_id = of_match_device(l3_noc_match, &pdev->dev);
176 dev_err(&pdev->dev, "OF data missing\n");
180 l3 = devm_kzalloc(&pdev->dev, sizeof(*l3), GFP_KERNEL);
184 memcpy(l3, of_id->data, sizeof(*l3));
185 l3->dev = &pdev->dev;
186 platform_set_drvdata(pdev, l3);
188 /* Get mem resources */
189 for (i = 0; i < l3->num_modules; i++) {
190 struct resource *res = platform_get_resource(pdev,
193 l3->l3_base[i] = devm_ioremap_resource(&pdev->dev, res);
194 if (IS_ERR(l3->l3_base[i])) {
195 dev_err(l3->dev, "ioremap %d failed\n", i);
196 return PTR_ERR(l3->l3_base[i]);
201 * Setup interrupt Handlers
203 l3->debug_irq = platform_get_irq(pdev, 0);
204 ret = devm_request_irq(l3->dev, l3->debug_irq, l3_interrupt_handler,
205 IRQF_DISABLED, "l3-dbg-irq", l3);
207 dev_err(l3->dev, "request_irq failed for %d\n",
212 l3->app_irq = platform_get_irq(pdev, 1);
213 ret = devm_request_irq(l3->dev, l3->app_irq, l3_interrupt_handler,
214 IRQF_DISABLED, "l3-app-irq", l3);
216 dev_err(l3->dev, "request_irq failed for %d\n", l3->app_irq);
221 static struct platform_driver omap_l3_driver = {
222 .probe = omap_l3_probe,
224 .name = "omap_l3_noc",
225 .owner = THIS_MODULE,
226 .of_match_table = of_match_ptr(l3_noc_match),
230 static int __init omap_l3_init(void)
232 return platform_driver_register(&omap_l3_driver);
234 postcore_initcall_sync(omap_l3_init);
236 static void __exit omap_l3_exit(void)
238 platform_driver_unregister(&omap_l3_driver);
240 module_exit(omap_l3_exit);