blob: 1eb6d85c19dcd3e6952aea9dcb6083f90a64c5b0 [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 *
Nishanth Menonc5f2aea2014-04-11 13:15:43 -05004 * Copyright (C) 2011-2014 Texas Instruments Incorporated - http://www.ti.com/
sricharaned0e3522011-08-24 20:07:45 +05305 * 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
Nishanth Menonc5f2aea2014-04-11 13:15:43 -05009 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
sricharaned0e3522011-08-24 20:07:45 +053011 *
Nishanth Menonc5f2aea2014-04-11 13:15:43 -050012 * 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
sricharaned0e3522011-08-24 20:07:45 +053015 * GNU General Public License for more details.
sricharaned0e3522011-08-24 20:07:45 +053016 */
Axel Lind4fc7eb2011-11-02 09:40:11 +080017#include <linux/module.h>
Santosh Shilimkar2722e562011-03-07 20:53:10 +053018#include <linux/init.h>
19#include <linux/io.h>
20#include <linux/platform_device.h>
21#include <linux/interrupt.h>
22#include <linux/kernel.h>
23#include <linux/slab.h>
24
25#include "omap_l3_noc.h"
26
27/*
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.
33 *
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:
38 * - Unsupported CMD.
39 * L3 tries to access target while it is idle
40 * - OCP disconnect.
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.
45 *
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.
49 */
50static irqreturn_t l3_interrupt_handler(int irq, void *_l3)
51{
52
sricharaned0e3522011-08-24 20:07:45 +053053 struct omap4_l3 *l3 = _l3;
sricharan551a9fa2011-09-07 17:25:16 +053054 int inttype, i, k;
Santosh Shilimkar2722e562011-03-07 20:53:10 +053055 int err_src = 0;
sricharan551a9fa2011-09-07 17:25:16 +053056 u32 std_err_main, err_reg, clear, masterid;
sricharan6616aac2011-08-23 12:58:48 +053057 void __iomem *base, *l3_targ_base;
sricharan551a9fa2011-09-07 17:25:16 +053058 char *target_name, *master_name = "UN IDENTIFIED";
Santosh Shilimkar2722e562011-03-07 20:53:10 +053059
60 /* Get the Type of interrupt */
omar ramirez35f7b962011-04-18 16:39:42 +000061 inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR;
Santosh Shilimkar2722e562011-03-07 20:53:10 +053062
63 for (i = 0; i < L3_MODULES; i++) {
64 /*
65 * Read the regerr register of the clock domain
66 * to determine the source
67 */
sricharan6616aac2011-08-23 12:58:48 +053068 base = l3->l3_base[i];
69 err_reg = __raw_readl(base + l3_flagmux[i] +
Todd Poynor342fd142011-08-24 19:11:39 +053070 + L3_FLAGMUX_REGERR0 + (inttype << 3));
Santosh Shilimkar2722e562011-03-07 20:53:10 +053071
72 /* Get the corresponding error and analyse */
73 if (err_reg) {
74 /* Identify the source from control status register */
Todd Poynor342fd142011-08-24 19:11:39 +053075 err_src = __ffs(err_reg);
Santosh Shilimkar2722e562011-03-07 20:53:10 +053076
Santosh Shilimkar2722e562011-03-07 20:53:10 +053077 /* Read the stderrlog_main_source from clk domain */
Todd Poynor342fd142011-08-24 19:11:39 +053078 l3_targ_base = base + *(l3_targ[i] + err_src);
sricharan6616aac2011-08-23 12:58:48 +053079 std_err_main = __raw_readl(l3_targ_base +
Todd Poynor342fd142011-08-24 19:11:39 +053080 L3_TARG_STDERRLOG_MAIN);
sricharan551a9fa2011-09-07 17:25:16 +053081 masterid = __raw_readl(l3_targ_base +
82 L3_TARG_STDERRLOG_MSTADDR);
Santosh Shilimkar2722e562011-03-07 20:53:10 +053083
omar ramirez35f7b962011-04-18 16:39:42 +000084 switch (std_err_main & CUSTOM_ERROR) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +053085 case STANDARD_ERROR:
sricharan551a9fa2011-09-07 17:25:16 +053086 target_name =
Todd Poynor342fd142011-08-24 19:11:39 +053087 l3_targ_inst_name[i][err_src];
sricharan551a9fa2011-09-07 17:25:16 +053088 WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n",
89 target_name,
sricharan6616aac2011-08-23 12:58:48 +053090 __raw_readl(l3_targ_base +
Todd Poynor342fd142011-08-24 19:11:39 +053091 L3_TARG_STDERRLOG_SLVOFSLSB));
Santosh Shilimkar2722e562011-03-07 20:53:10 +053092 /* clear the std error log*/
93 clear = std_err_main | CLEAR_STDERR_LOG;
Todd Poynor342fd142011-08-24 19:11:39 +053094 writel(clear, l3_targ_base +
95 L3_TARG_STDERRLOG_MAIN);
Santosh Shilimkar2722e562011-03-07 20:53:10 +053096 break;
97
98 case CUSTOM_ERROR:
sricharan551a9fa2011-09-07 17:25:16 +053099 target_name =
Todd Poynor342fd142011-08-24 19:11:39 +0530100 l3_targ_inst_name[i][err_src];
sricharan551a9fa2011-09-07 17:25:16 +0530101 for (k = 0; k < NUM_OF_L3_MASTERS; k++) {
102 if (masterid == l3_masters[k].id)
103 master_name =
104 l3_masters[k].name;
105 }
106 WARN(true, "L3 custom error: MASTER:%s TARGET:%s\n",
107 master_name, target_name);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530108 /* clear the std error log*/
109 clear = std_err_main | CLEAR_STDERR_LOG;
Todd Poynor342fd142011-08-24 19:11:39 +0530110 writel(clear, l3_targ_base +
111 L3_TARG_STDERRLOG_MAIN);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530112 break;
113
114 default:
115 /* Nothing to be handled here as of now */
116 break;
117 }
118 /* Error found so break the for loop */
119 break;
120 }
121 }
122 return IRQ_HANDLED;
123}
124
Greg Kroah-Hartman0fe763c2012-12-21 15:14:44 -0800125static int omap4_l3_probe(struct platform_device *pdev)
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530126{
sricharaned0e3522011-08-24 20:07:45 +0530127 static struct omap4_l3 *l3;
Peter Ujfalusi56c4a022014-04-01 16:23:47 +0300128 int ret, i;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530129
Peter Ujfalusibae74512014-04-01 16:23:46 +0300130 l3 = devm_kzalloc(&pdev->dev, sizeof(*l3), GFP_KERNEL);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530131 if (!l3)
omar ramirez7529b702011-04-18 16:39:41 +0000132 return -ENOMEM;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530133
134 platform_set_drvdata(pdev, l3);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530135
Peter Ujfalusi56c4a022014-04-01 16:23:47 +0300136 /* Get mem resources */
137 for (i = 0; i < L3_MODULES; i++) {
138 struct resource *res = platform_get_resource(pdev,
139 IORESOURCE_MEM, i);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530140
Peter Ujfalusi56c4a022014-04-01 16:23:47 +0300141 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]);
145 }
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530146 }
147
148 /*
149 * Setup interrupt Handlers
150 */
Todd Poynorc1df2dc2011-08-29 17:42:23 +0530151 l3->debug_irq = platform_get_irq(pdev, 0);
Peter Ujfalusia0ef78f2014-04-01 16:23:48 +0300152 ret = devm_request_irq(&pdev->dev, l3->debug_irq, l3_interrupt_handler,
153 IRQF_DISABLED, "l3-dbg-irq", l3);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530154 if (ret) {
Peter Ujfalusiae225982014-04-01 16:23:50 +0300155 dev_err(&pdev->dev, "request_irq failed for %d\n",
156 l3->debug_irq);
Peter Ujfalusi56c4a022014-04-01 16:23:47 +0300157 return ret;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530158 }
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530159
Todd Poynorc1df2dc2011-08-29 17:42:23 +0530160 l3->app_irq = platform_get_irq(pdev, 1);
Peter Ujfalusia0ef78f2014-04-01 16:23:48 +0300161 ret = devm_request_irq(&pdev->dev, l3->app_irq, l3_interrupt_handler,
162 IRQF_DISABLED, "l3-app-irq", l3);
163 if (ret)
Peter Ujfalusiae225982014-04-01 16:23:50 +0300164 dev_err(&pdev->dev, "request_irq failed for %d\n", l3->app_irq);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530165
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530166 return ret;
167}
168
Benoit Coussond039c5b2011-08-12 13:52:50 +0200169#if defined(CONFIG_OF)
170static const struct of_device_id l3_noc_match[] = {
171 {.compatible = "ti,omap4-l3-noc", },
172 {},
Govindraj.R8770b072011-11-23 14:45:37 -0800173};
Benoit Coussond039c5b2011-08-12 13:52:50 +0200174MODULE_DEVICE_TABLE(of, l3_noc_match);
175#else
176#define l3_noc_match NULL
177#endif
178
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530179static struct platform_driver omap4_l3_driver = {
Benoit Coussond039c5b2011-08-12 13:52:50 +0200180 .probe = omap4_l3_probe,
Benoit Coussond039c5b2011-08-12 13:52:50 +0200181 .driver = {
182 .name = "omap_l3_noc",
183 .owner = THIS_MODULE,
184 .of_match_table = l3_noc_match,
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530185 },
186};
187
188static int __init omap4_l3_init(void)
189{
Benoit Coussond039c5b2011-08-12 13:52:50 +0200190 return platform_driver_register(&omap4_l3_driver);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530191}
192postcore_initcall_sync(omap4_l3_init);
193
194static void __exit omap4_l3_exit(void)
195{
196 platform_driver_unregister(&omap4_l3_driver);
197}
198module_exit(omap4_l3_exit);