Commit | Line | Data |
---|---|---|
2722e56d | 1 | /* |
c10d5c9e | 2 | * OMAP L3 Interconnect error handling driver |
ed0e3520 | 3 | * |
c5f2aea0 | 4 | * Copyright (C) 2011-2014 Texas Instruments Incorporated - http://www.ti.com/ |
ed0e3520 | 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 | |
c5f2aea0 NM |
9 | * it under the terms of the GNU General Public License version 2 as |
10 | * published by the Free Software Foundation. | |
ed0e3520 | 11 | * |
c5f2aea0 NM |
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 | |
ed0e3520 | 15 | * GNU General Public License for more details. |
ed0e3520 | 16 | */ |
d4fc7eb5 | 17 | #include <linux/module.h> |
2722e56d SS |
18 | #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 | */ | |
50 | static irqreturn_t l3_interrupt_handler(int irq, void *_l3) | |
51 | { | |
52 | ||
c10d5c9e | 53 | struct omap_l3 *l3 = _l3; |
551a9fa9 | 54 | int inttype, i, k; |
2722e56d | 55 | int err_src = 0; |
551a9fa9 | 56 | u32 std_err_main, err_reg, clear, masterid; |
6616aac6 | 57 | void __iomem *base, *l3_targ_base; |
9e224c8f | 58 | void __iomem *l3_targ_stderr, *l3_targ_slvofslsb, *l3_targ_mstaddr; |
551a9fa9 | 59 | char *target_name, *master_name = "UN IDENTIFIED"; |
2722e56d SS |
60 | |
61 | /* Get the Type of interrupt */ | |
35f7b961 | 62 | inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR; |
2722e56d SS |
63 | |
64 | for (i = 0; i < L3_MODULES; i++) { | |
65 | /* | |
66 | * Read the regerr register of the clock domain | |
67 | * to determine the source | |
68 | */ | |
6616aac6 | 69 | base = l3->l3_base[i]; |
9e224c8f NM |
70 | err_reg = readl_relaxed(base + l3_flagmux[i] + |
71 | L3_FLAGMUX_REGERR0 + (inttype << 3)); | |
2722e56d SS |
72 | |
73 | /* Get the corresponding error and analyse */ | |
74 | if (err_reg) { | |
75 | /* Identify the source from control status register */ | |
342fd144 | 76 | err_src = __ffs(err_reg); |
2722e56d | 77 | |
2722e56d | 78 | /* Read the stderrlog_main_source from clk domain */ |
add6f74b | 79 | l3_targ_base = base + l3_targ[i][err_src]; |
9e224c8f NM |
80 | l3_targ_stderr = l3_targ_base + L3_TARG_STDERRLOG_MAIN; |
81 | l3_targ_slvofslsb = l3_targ_base + | |
82 | L3_TARG_STDERRLOG_SLVOFSLSB; | |
83 | l3_targ_mstaddr = l3_targ_base + | |
84 | L3_TARG_STDERRLOG_MSTADDR; | |
85 | ||
86 | std_err_main = readl_relaxed(l3_targ_stderr); | |
87 | masterid = readl_relaxed(l3_targ_mstaddr); | |
2722e56d | 88 | |
35f7b961 | 89 | switch (std_err_main & CUSTOM_ERROR) { |
2722e56d | 90 | case STANDARD_ERROR: |
551a9fa9 | 91 | target_name = |
342fd144 | 92 | l3_targ_inst_name[i][err_src]; |
551a9fa9 | 93 | WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n", |
94 | target_name, | |
9e224c8f | 95 | readl_relaxed(l3_targ_slvofslsb)); |
2722e56d SS |
96 | /* clear the std error log*/ |
97 | clear = std_err_main | CLEAR_STDERR_LOG; | |
9e224c8f | 98 | writel_relaxed(clear, l3_targ_stderr); |
2722e56d SS |
99 | break; |
100 | ||
101 | case CUSTOM_ERROR: | |
551a9fa9 | 102 | target_name = |
342fd144 | 103 | l3_targ_inst_name[i][err_src]; |
551a9fa9 | 104 | for (k = 0; k < NUM_OF_L3_MASTERS; k++) { |
105 | if (masterid == l3_masters[k].id) | |
106 | master_name = | |
107 | l3_masters[k].name; | |
108 | } | |
109 | WARN(true, "L3 custom error: MASTER:%s TARGET:%s\n", | |
110 | master_name, target_name); | |
2722e56d SS |
111 | /* clear the std error log*/ |
112 | clear = std_err_main | CLEAR_STDERR_LOG; | |
9e224c8f | 113 | writel_relaxed(clear, l3_targ_stderr); |
2722e56d SS |
114 | break; |
115 | ||
116 | default: | |
117 | /* Nothing to be handled here as of now */ | |
118 | break; | |
119 | } | |
120 | /* Error found so break the for loop */ | |
121 | break; | |
122 | } | |
123 | } | |
124 | return IRQ_HANDLED; | |
125 | } | |
126 | ||
c10d5c9e | 127 | static int omap_l3_probe(struct platform_device *pdev) |
2722e56d | 128 | { |
c10d5c9e | 129 | static struct omap_l3 *l3; |
56c4a022 | 130 | int ret, i; |
2722e56d | 131 | |
bae74510 | 132 | l3 = devm_kzalloc(&pdev->dev, sizeof(*l3), GFP_KERNEL); |
2722e56d | 133 | if (!l3) |
7529b703 | 134 | return -ENOMEM; |
2722e56d | 135 | |
ca6a3493 | 136 | l3->dev = &pdev->dev; |
2722e56d | 137 | platform_set_drvdata(pdev, l3); |
2722e56d | 138 | |
56c4a022 PU |
139 | /* Get mem resources */ |
140 | for (i = 0; i < L3_MODULES; i++) { | |
141 | struct resource *res = platform_get_resource(pdev, | |
142 | IORESOURCE_MEM, i); | |
2722e56d | 143 | |
56c4a022 PU |
144 | l3->l3_base[i] = devm_ioremap_resource(&pdev->dev, res); |
145 | if (IS_ERR(l3->l3_base[i])) { | |
ca6a3493 | 146 | dev_err(l3->dev, "ioremap %d failed\n", i); |
56c4a022 PU |
147 | return PTR_ERR(l3->l3_base[i]); |
148 | } | |
2722e56d SS |
149 | } |
150 | ||
151 | /* | |
152 | * Setup interrupt Handlers | |
153 | */ | |
c1df2dcc | 154 | l3->debug_irq = platform_get_irq(pdev, 0); |
ca6a3493 | 155 | ret = devm_request_irq(l3->dev, l3->debug_irq, l3_interrupt_handler, |
a0ef78f3 | 156 | IRQF_DISABLED, "l3-dbg-irq", l3); |
2722e56d | 157 | if (ret) { |
ca6a3493 | 158 | dev_err(l3->dev, "request_irq failed for %d\n", |
ae22598a | 159 | l3->debug_irq); |
56c4a022 | 160 | return ret; |
2722e56d | 161 | } |
2722e56d | 162 | |
c1df2dcc | 163 | l3->app_irq = platform_get_irq(pdev, 1); |
ca6a3493 | 164 | ret = devm_request_irq(l3->dev, l3->app_irq, l3_interrupt_handler, |
a0ef78f3 PU |
165 | IRQF_DISABLED, "l3-app-irq", l3); |
166 | if (ret) | |
ca6a3493 | 167 | dev_err(l3->dev, "request_irq failed for %d\n", l3->app_irq); |
7529b703 | 168 | |
2722e56d SS |
169 | return ret; |
170 | } | |
171 | ||
d039c5b9 BC |
172 | #if defined(CONFIG_OF) |
173 | static const struct of_device_id l3_noc_match[] = { | |
174 | {.compatible = "ti,omap4-l3-noc", }, | |
175 | {}, | |
8770b07c | 176 | }; |
d039c5b9 BC |
177 | MODULE_DEVICE_TABLE(of, l3_noc_match); |
178 | #else | |
179 | #define l3_noc_match NULL | |
180 | #endif | |
181 | ||
c10d5c9e S |
182 | static struct platform_driver omap_l3_driver = { |
183 | .probe = omap_l3_probe, | |
d039c5b9 BC |
184 | .driver = { |
185 | .name = "omap_l3_noc", | |
186 | .owner = THIS_MODULE, | |
187 | .of_match_table = l3_noc_match, | |
2722e56d SS |
188 | }, |
189 | }; | |
190 | ||
c10d5c9e | 191 | static int __init omap_l3_init(void) |
2722e56d | 192 | { |
c10d5c9e | 193 | return platform_driver_register(&omap_l3_driver); |
2722e56d | 194 | } |
c10d5c9e | 195 | postcore_initcall_sync(omap_l3_init); |
2722e56d | 196 | |
c10d5c9e | 197 | static void __exit omap_l3_exit(void) |
2722e56d | 198 | { |
c10d5c9e | 199 | platform_driver_unregister(&omap_l3_driver); |
2722e56d | 200 | } |
c10d5c9e | 201 | module_exit(omap_l3_exit); |