Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 1 | /* |
| 2 | * 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 | */ |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/io.h> |
| 25 | #include <linux/platform_device.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/kernel.h> |
| 28 | #include <linux/slab.h> |
| 29 | |
| 30 | #include "omap_l3_noc.h" |
| 31 | |
| 32 | /* |
| 33 | * Interrupt Handler for L3 error detection. |
| 34 | * 1) Identify the L3 clockdomain partition to which the error belongs to. |
| 35 | * 2) Identify the slave where the error information is logged |
| 36 | * 3) Print the logged information. |
| 37 | * 4) Add dump stack to provide kernel trace. |
| 38 | * |
| 39 | * Two Types of errors : |
| 40 | * 1) Custom errors in L3 : |
| 41 | * Target like DMM/FW/EMIF generates SRESP=ERR error |
| 42 | * 2) Standard L3 error: |
| 43 | * - Unsupported CMD. |
| 44 | * L3 tries to access target while it is idle |
| 45 | * - OCP disconnect. |
| 46 | * - Address hole error: |
| 47 | * If DSS/ISS/FDIF/USBHOSTFS access a target where they |
| 48 | * do not have connectivity, the error is logged in |
| 49 | * their default target which is DMM2. |
| 50 | * |
| 51 | * On High Secure devices, firewall errors are possible and those |
| 52 | * can be trapped as well. But the trapping is implemented as part |
| 53 | * secure software and hence need not be implemented here. |
| 54 | */ |
| 55 | static irqreturn_t l3_interrupt_handler(int irq, void *_l3) |
| 56 | { |
| 57 | |
| 58 | struct omap4_l3 *l3 = _l3; |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 59 | int inttype, i; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 60 | int err_src = 0; |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 61 | u32 std_err_main, err_reg, clear, base, l3_targ_base; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 62 | char *source_name; |
| 63 | |
| 64 | /* Get the Type of interrupt */ |
omar ramirez | 35f7b96 | 2011-04-18 16:39:42 +0000 | [diff] [blame] | 65 | inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 66 | |
| 67 | for (i = 0; i < L3_MODULES; i++) { |
| 68 | /* |
| 69 | * Read the regerr register of the clock domain |
| 70 | * to determine the source |
| 71 | */ |
| 72 | base = (u32)l3->l3_base[i]; |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 73 | err_reg = readl(base + l3_flagmux[i] + |
| 74 | + L3_FLAGMUX_REGERR0 + (inttype << 3)); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 75 | |
| 76 | /* Get the corresponding error and analyse */ |
| 77 | if (err_reg) { |
| 78 | /* Identify the source from control status register */ |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 79 | err_src = __ffs(err_reg); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 80 | |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 81 | /* Read the stderrlog_main_source from clk domain */ |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 82 | l3_targ_base = base + *(l3_targ[i] + err_src); |
| 83 | std_err_main = readl(l3_targ_base + |
| 84 | L3_TARG_STDERRLOG_MAIN); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 85 | |
omar ramirez | 35f7b96 | 2011-04-18 16:39:42 +0000 | [diff] [blame] | 86 | switch (std_err_main & CUSTOM_ERROR) { |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 87 | case STANDARD_ERROR: |
| 88 | source_name = |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 89 | l3_targ_inst_name[i][err_src]; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 90 | WARN(true, "L3 standard error: SOURCE:%s at address 0x%x\n", |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 91 | source_name, |
| 92 | readl(l3_targ_base + |
| 93 | L3_TARG_STDERRLOG_SLVOFSLSB)); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 94 | /* clear the std error log*/ |
| 95 | clear = std_err_main | CLEAR_STDERR_LOG; |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 96 | writel(clear, l3_targ_base + |
| 97 | L3_TARG_STDERRLOG_MAIN); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 98 | break; |
| 99 | |
| 100 | case CUSTOM_ERROR: |
| 101 | source_name = |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 102 | l3_targ_inst_name[i][err_src]; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 103 | |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 104 | WARN(true, "L3 custom error: SOURCE:%s\n", |
| 105 | source_name); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 106 | /* clear the std error log*/ |
| 107 | clear = std_err_main | CLEAR_STDERR_LOG; |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 108 | writel(clear, l3_targ_base + |
| 109 | L3_TARG_STDERRLOG_MAIN); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 110 | break; |
| 111 | |
| 112 | default: |
| 113 | /* Nothing to be handled here as of now */ |
| 114 | break; |
| 115 | } |
| 116 | /* Error found so break the for loop */ |
| 117 | break; |
| 118 | } |
| 119 | } |
| 120 | return IRQ_HANDLED; |
| 121 | } |
| 122 | |
| 123 | static int __init omap4_l3_probe(struct platform_device *pdev) |
| 124 | { |
| 125 | static struct omap4_l3 *l3; |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 126 | struct resource *res; |
Todd Poynor | c1df2dc | 2011-08-29 17:42:23 +0530 | [diff] [blame^] | 127 | int ret; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 128 | |
| 129 | l3 = kzalloc(sizeof(*l3), GFP_KERNEL); |
| 130 | if (!l3) |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 131 | return -ENOMEM; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 132 | |
| 133 | platform_set_drvdata(pdev, l3); |
| 134 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 135 | if (!res) { |
| 136 | dev_err(&pdev->dev, "couldn't find resource 0\n"); |
| 137 | ret = -ENODEV; |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 138 | goto err0; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | l3->l3_base[0] = ioremap(res->start, resource_size(res)); |
omar ramirez | 35f7b96 | 2011-04-18 16:39:42 +0000 | [diff] [blame] | 142 | if (!l3->l3_base[0]) { |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 143 | dev_err(&pdev->dev, "ioremap failed\n"); |
| 144 | ret = -ENOMEM; |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 145 | goto err0; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 149 | if (!res) { |
| 150 | dev_err(&pdev->dev, "couldn't find resource 1\n"); |
| 151 | ret = -ENODEV; |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 152 | goto err1; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | l3->l3_base[1] = ioremap(res->start, resource_size(res)); |
omar ramirez | 35f7b96 | 2011-04-18 16:39:42 +0000 | [diff] [blame] | 156 | if (!l3->l3_base[1]) { |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 157 | dev_err(&pdev->dev, "ioremap failed\n"); |
| 158 | ret = -ENOMEM; |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 159 | goto err1; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | res = platform_get_resource(pdev, IORESOURCE_MEM, 2); |
| 163 | if (!res) { |
| 164 | dev_err(&pdev->dev, "couldn't find resource 2\n"); |
| 165 | ret = -ENODEV; |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 166 | goto err2; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | l3->l3_base[2] = ioremap(res->start, resource_size(res)); |
omar ramirez | 35f7b96 | 2011-04-18 16:39:42 +0000 | [diff] [blame] | 170 | if (!l3->l3_base[2]) { |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 171 | dev_err(&pdev->dev, "ioremap failed\n"); |
| 172 | ret = -ENOMEM; |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 173 | goto err2; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | /* |
| 177 | * Setup interrupt Handlers |
| 178 | */ |
Todd Poynor | c1df2dc | 2011-08-29 17:42:23 +0530 | [diff] [blame^] | 179 | l3->debug_irq = platform_get_irq(pdev, 0); |
| 180 | ret = request_irq(l3->debug_irq, |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 181 | l3_interrupt_handler, |
| 182 | IRQF_DISABLED, "l3-dbg-irq", l3); |
| 183 | if (ret) { |
| 184 | pr_crit("L3: request_irq failed to register for 0x%x\n", |
| 185 | OMAP44XX_IRQ_L3_DBG); |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 186 | goto err3; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 187 | } |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 188 | |
Todd Poynor | c1df2dc | 2011-08-29 17:42:23 +0530 | [diff] [blame^] | 189 | l3->app_irq = platform_get_irq(pdev, 1); |
| 190 | ret = request_irq(l3->app_irq, |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 191 | l3_interrupt_handler, |
| 192 | IRQF_DISABLED, "l3-app-irq", l3); |
| 193 | if (ret) { |
| 194 | pr_crit("L3: request_irq failed to register for 0x%x\n", |
| 195 | OMAP44XX_IRQ_L3_APP); |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 196 | goto err4; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 197 | } |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 198 | |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 199 | return 0; |
| 200 | |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 201 | err4: |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 202 | free_irq(l3->debug_irq, l3); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 203 | err3: |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 204 | iounmap(l3->l3_base[2]); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 205 | err2: |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 206 | iounmap(l3->l3_base[1]); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 207 | err1: |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 208 | iounmap(l3->l3_base[0]); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 209 | err0: |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 210 | kfree(l3); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 211 | return ret; |
| 212 | } |
| 213 | |
| 214 | static int __exit omap4_l3_remove(struct platform_device *pdev) |
| 215 | { |
| 216 | struct omap4_l3 *l3 = platform_get_drvdata(pdev); |
| 217 | |
| 218 | free_irq(l3->app_irq, l3); |
| 219 | free_irq(l3->debug_irq, l3); |
| 220 | iounmap(l3->l3_base[0]); |
| 221 | iounmap(l3->l3_base[1]); |
| 222 | iounmap(l3->l3_base[2]); |
| 223 | kfree(l3); |
| 224 | |
| 225 | return 0; |
| 226 | } |
| 227 | |
| 228 | static struct platform_driver omap4_l3_driver = { |
| 229 | .remove = __exit_p(omap4_l3_remove), |
| 230 | .driver = { |
| 231 | .name = "omap_l3_noc", |
| 232 | }, |
| 233 | }; |
| 234 | |
| 235 | static int __init omap4_l3_init(void) |
| 236 | { |
| 237 | return platform_driver_probe(&omap4_l3_driver, omap4_l3_probe); |
| 238 | } |
| 239 | postcore_initcall_sync(omap4_l3_init); |
| 240 | |
| 241 | static void __exit omap4_l3_exit(void) |
| 242 | { |
| 243 | platform_driver_unregister(&omap4_l3_driver); |
| 244 | } |
| 245 | module_exit(omap4_l3_exit); |