blob: f447e02102bb38b204849bf2424b82415ea9dc4e [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 */
Axel Lind4fc7eb2011-11-02 09:40:11 +080023#include <linux/module.h>
Santosh Shilimkar2722e562011-03-07 20:53:10 +053024#include <linux/init.h>
25#include <linux/io.h>
26#include <linux/platform_device.h>
27#include <linux/interrupt.h>
28#include <linux/kernel.h>
29#include <linux/slab.h>
30
Tony Lindgrendbc04162012-08-31 10:59:07 -070031#include "soc.h"
Santosh Shilimkar2722e562011-03-07 20:53:10 +053032#include "omap_l3_noc.h"
33
34/*
35 * Interrupt Handler for L3 error detection.
36 * 1) Identify the L3 clockdomain partition to which the error belongs to.
37 * 2) Identify the slave where the error information is logged
38 * 3) Print the logged information.
39 * 4) Add dump stack to provide kernel trace.
40 *
41 * Two Types of errors :
42 * 1) Custom errors in L3 :
43 * Target like DMM/FW/EMIF generates SRESP=ERR error
44 * 2) Standard L3 error:
45 * - Unsupported CMD.
46 * L3 tries to access target while it is idle
47 * - OCP disconnect.
48 * - Address hole error:
49 * If DSS/ISS/FDIF/USBHOSTFS access a target where they
50 * do not have connectivity, the error is logged in
51 * their default target which is DMM2.
52 *
53 * On High Secure devices, firewall errors are possible and those
54 * can be trapped as well. But the trapping is implemented as part
55 * secure software and hence need not be implemented here.
56 */
57static irqreturn_t l3_interrupt_handler(int irq, void *_l3)
58{
59
sricharaned0e3522011-08-24 20:07:45 +053060 struct omap4_l3 *l3 = _l3;
sricharan551a9fa2011-09-07 17:25:16 +053061 int inttype, i, k;
Santosh Shilimkar2722e562011-03-07 20:53:10 +053062 int err_src = 0;
sricharan551a9fa2011-09-07 17:25:16 +053063 u32 std_err_main, err_reg, clear, masterid;
sricharan6616aac2011-08-23 12:58:48 +053064 void __iomem *base, *l3_targ_base;
sricharan551a9fa2011-09-07 17:25:16 +053065 char *target_name, *master_name = "UN IDENTIFIED";
Santosh Shilimkar2722e562011-03-07 20:53:10 +053066
67 /* Get the Type of interrupt */
omar ramirez35f7b962011-04-18 16:39:42 +000068 inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR;
Santosh Shilimkar2722e562011-03-07 20:53:10 +053069
70 for (i = 0; i < L3_MODULES; i++) {
71 /*
72 * Read the regerr register of the clock domain
73 * to determine the source
74 */
sricharan6616aac2011-08-23 12:58:48 +053075 base = l3->l3_base[i];
76 err_reg = __raw_readl(base + l3_flagmux[i] +
Todd Poynor342fd142011-08-24 19:11:39 +053077 + L3_FLAGMUX_REGERR0 + (inttype << 3));
Santosh Shilimkar2722e562011-03-07 20:53:10 +053078
79 /* Get the corresponding error and analyse */
80 if (err_reg) {
81 /* Identify the source from control status register */
Todd Poynor342fd142011-08-24 19:11:39 +053082 err_src = __ffs(err_reg);
Santosh Shilimkar2722e562011-03-07 20:53:10 +053083
Santosh Shilimkar2722e562011-03-07 20:53:10 +053084 /* Read the stderrlog_main_source from clk domain */
Todd Poynor342fd142011-08-24 19:11:39 +053085 l3_targ_base = base + *(l3_targ[i] + err_src);
sricharan6616aac2011-08-23 12:58:48 +053086 std_err_main = __raw_readl(l3_targ_base +
Todd Poynor342fd142011-08-24 19:11:39 +053087 L3_TARG_STDERRLOG_MAIN);
sricharan551a9fa2011-09-07 17:25:16 +053088 masterid = __raw_readl(l3_targ_base +
89 L3_TARG_STDERRLOG_MSTADDR);
Santosh Shilimkar2722e562011-03-07 20:53:10 +053090
omar ramirez35f7b962011-04-18 16:39:42 +000091 switch (std_err_main & CUSTOM_ERROR) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +053092 case STANDARD_ERROR:
sricharan551a9fa2011-09-07 17:25:16 +053093 target_name =
Todd Poynor342fd142011-08-24 19:11:39 +053094 l3_targ_inst_name[i][err_src];
sricharan551a9fa2011-09-07 17:25:16 +053095 WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n",
96 target_name,
sricharan6616aac2011-08-23 12:58:48 +053097 __raw_readl(l3_targ_base +
Todd Poynor342fd142011-08-24 19:11:39 +053098 L3_TARG_STDERRLOG_SLVOFSLSB));
Santosh Shilimkar2722e562011-03-07 20:53:10 +053099 /* clear the std error log*/
100 clear = std_err_main | CLEAR_STDERR_LOG;
Todd Poynor342fd142011-08-24 19:11:39 +0530101 writel(clear, l3_targ_base +
102 L3_TARG_STDERRLOG_MAIN);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530103 break;
104
105 case CUSTOM_ERROR:
sricharan551a9fa2011-09-07 17:25:16 +0530106 target_name =
Todd Poynor342fd142011-08-24 19:11:39 +0530107 l3_targ_inst_name[i][err_src];
sricharan551a9fa2011-09-07 17:25:16 +0530108 for (k = 0; k < NUM_OF_L3_MASTERS; k++) {
109 if (masterid == l3_masters[k].id)
110 master_name =
111 l3_masters[k].name;
112 }
113 WARN(true, "L3 custom error: MASTER:%s TARGET:%s\n",
114 master_name, target_name);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530115 /* clear the std error log*/
116 clear = std_err_main | CLEAR_STDERR_LOG;
Todd Poynor342fd142011-08-24 19:11:39 +0530117 writel(clear, l3_targ_base +
118 L3_TARG_STDERRLOG_MAIN);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530119 break;
120
121 default:
122 /* Nothing to be handled here as of now */
123 break;
124 }
125 /* Error found so break the for loop */
126 break;
127 }
128 }
129 return IRQ_HANDLED;
130}
131
Benoit Coussond039c5b2011-08-12 13:52:50 +0200132static int __devinit omap4_l3_probe(struct platform_device *pdev)
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530133{
sricharaned0e3522011-08-24 20:07:45 +0530134 static struct omap4_l3 *l3;
Todd Poynor342fd142011-08-24 19:11:39 +0530135 struct resource *res;
Todd Poynorc1df2dc2011-08-29 17:42:23 +0530136 int ret;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530137
138 l3 = kzalloc(sizeof(*l3), GFP_KERNEL);
139 if (!l3)
omar ramirez7529b702011-04-18 16:39:41 +0000140 return -ENOMEM;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530141
142 platform_set_drvdata(pdev, l3);
143 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
144 if (!res) {
145 dev_err(&pdev->dev, "couldn't find resource 0\n");
146 ret = -ENODEV;
omar ramirez7529b702011-04-18 16:39:41 +0000147 goto err0;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530148 }
149
150 l3->l3_base[0] = ioremap(res->start, resource_size(res));
omar ramirez35f7b962011-04-18 16:39:42 +0000151 if (!l3->l3_base[0]) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530152 dev_err(&pdev->dev, "ioremap failed\n");
153 ret = -ENOMEM;
omar ramirez7529b702011-04-18 16:39:41 +0000154 goto err0;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530155 }
156
157 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
158 if (!res) {
159 dev_err(&pdev->dev, "couldn't find resource 1\n");
160 ret = -ENODEV;
omar ramirez7529b702011-04-18 16:39:41 +0000161 goto err1;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530162 }
163
164 l3->l3_base[1] = ioremap(res->start, resource_size(res));
omar ramirez35f7b962011-04-18 16:39:42 +0000165 if (!l3->l3_base[1]) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530166 dev_err(&pdev->dev, "ioremap failed\n");
167 ret = -ENOMEM;
omar ramirez7529b702011-04-18 16:39:41 +0000168 goto err1;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530169 }
170
171 res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
172 if (!res) {
173 dev_err(&pdev->dev, "couldn't find resource 2\n");
174 ret = -ENODEV;
omar ramirez7529b702011-04-18 16:39:41 +0000175 goto err2;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530176 }
177
178 l3->l3_base[2] = ioremap(res->start, resource_size(res));
omar ramirez35f7b962011-04-18 16:39:42 +0000179 if (!l3->l3_base[2]) {
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530180 dev_err(&pdev->dev, "ioremap failed\n");
181 ret = -ENOMEM;
omar ramirez7529b702011-04-18 16:39:41 +0000182 goto err2;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530183 }
184
185 /*
186 * Setup interrupt Handlers
187 */
Todd Poynorc1df2dc2011-08-29 17:42:23 +0530188 l3->debug_irq = platform_get_irq(pdev, 0);
189 ret = request_irq(l3->debug_irq,
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530190 l3_interrupt_handler,
191 IRQF_DISABLED, "l3-dbg-irq", l3);
192 if (ret) {
193 pr_crit("L3: request_irq failed to register for 0x%x\n",
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700194 9 + OMAP44XX_IRQ_GIC_START);
omar ramirez7529b702011-04-18 16:39:41 +0000195 goto err3;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530196 }
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530197
Todd Poynorc1df2dc2011-08-29 17:42:23 +0530198 l3->app_irq = platform_get_irq(pdev, 1);
199 ret = request_irq(l3->app_irq,
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530200 l3_interrupt_handler,
201 IRQF_DISABLED, "l3-app-irq", l3);
202 if (ret) {
203 pr_crit("L3: request_irq failed to register for 0x%x\n",
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700204 10 + OMAP44XX_IRQ_GIC_START);
omar ramirez7529b702011-04-18 16:39:41 +0000205 goto err4;
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530206 }
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530207
omar ramirez7529b702011-04-18 16:39:41 +0000208 return 0;
209
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530210err4:
omar ramirez7529b702011-04-18 16:39:41 +0000211 free_irq(l3->debug_irq, l3);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530212err3:
omar ramirez7529b702011-04-18 16:39:41 +0000213 iounmap(l3->l3_base[2]);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530214err2:
omar ramirez7529b702011-04-18 16:39:41 +0000215 iounmap(l3->l3_base[1]);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530216err1:
omar ramirez7529b702011-04-18 16:39:41 +0000217 iounmap(l3->l3_base[0]);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530218err0:
omar ramirez7529b702011-04-18 16:39:41 +0000219 kfree(l3);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530220 return ret;
221}
222
Benoit Coussond039c5b2011-08-12 13:52:50 +0200223static int __devexit omap4_l3_remove(struct platform_device *pdev)
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530224{
sricharaned0e3522011-08-24 20:07:45 +0530225 struct omap4_l3 *l3 = platform_get_drvdata(pdev);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530226
227 free_irq(l3->app_irq, l3);
228 free_irq(l3->debug_irq, l3);
229 iounmap(l3->l3_base[0]);
230 iounmap(l3->l3_base[1]);
231 iounmap(l3->l3_base[2]);
232 kfree(l3);
233
234 return 0;
235}
236
Benoit Coussond039c5b2011-08-12 13:52:50 +0200237#if defined(CONFIG_OF)
238static const struct of_device_id l3_noc_match[] = {
239 {.compatible = "ti,omap4-l3-noc", },
240 {},
Govindraj.R8770b072011-11-23 14:45:37 -0800241};
Benoit Coussond039c5b2011-08-12 13:52:50 +0200242MODULE_DEVICE_TABLE(of, l3_noc_match);
243#else
244#define l3_noc_match NULL
245#endif
246
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530247static struct platform_driver omap4_l3_driver = {
Benoit Coussond039c5b2011-08-12 13:52:50 +0200248 .probe = omap4_l3_probe,
249 .remove = __devexit_p(omap4_l3_remove),
250 .driver = {
251 .name = "omap_l3_noc",
252 .owner = THIS_MODULE,
253 .of_match_table = l3_noc_match,
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530254 },
255};
256
257static int __init omap4_l3_init(void)
258{
Benoit Coussond039c5b2011-08-12 13:52:50 +0200259 return platform_driver_register(&omap4_l3_driver);
Santosh Shilimkar2722e562011-03-07 20:53:10 +0530260}
261postcore_initcall_sync(omap4_l3_init);
262
263static void __exit omap4_l3_exit(void)
264{
265 platform_driver_unregister(&omap4_l3_driver);
266}
267module_exit(omap4_l3_exit);