Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 1 | /* |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 2 | * OMAP L3 Interconnect error handling driver |
sricharan | ed0e352 | 2011-08-24 20:07:45 +0530 | [diff] [blame] | 3 | * |
Nishanth Menon | c5f2aea | 2014-04-11 13:15:43 -0500 | [diff] [blame] | 4 | * Copyright (C) 2011-2014 Texas Instruments Incorporated - http://www.ti.com/ |
sricharan | ed0e352 | 2011-08-24 20:07:45 +0530 | [diff] [blame] | 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 |
Nishanth Menon | c5f2aea | 2014-04-11 13:15:43 -0500 | [diff] [blame] | 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
sricharan | ed0e352 | 2011-08-24 20:07:45 +0530 | [diff] [blame] | 11 | * |
Nishanth Menon | c5f2aea | 2014-04-11 13:15:43 -0500 | [diff] [blame] | 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 |
sricharan | ed0e352 | 2011-08-24 20:07:45 +0530 | [diff] [blame] | 15 | * GNU General Public License for more details. |
sricharan | ed0e352 | 2011-08-24 20:07:45 +0530 | [diff] [blame] | 16 | */ |
Axel Lin | d4fc7eb | 2011-11-02 09:40:11 +0800 | [diff] [blame] | 17 | #include <linux/module.h> |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 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 | |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 53 | struct omap_l3 *l3 = _l3; |
sricharan | 551a9fa | 2011-09-07 17:25:16 +0530 | [diff] [blame] | 54 | int inttype, i, k; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 55 | int err_src = 0; |
sricharan | 551a9fa | 2011-09-07 17:25:16 +0530 | [diff] [blame] | 56 | u32 std_err_main, err_reg, clear, masterid; |
sricharan | 6616aac | 2011-08-23 12:58:48 +0530 | [diff] [blame] | 57 | void __iomem *base, *l3_targ_base; |
sricharan | 551a9fa | 2011-09-07 17:25:16 +0530 | [diff] [blame] | 58 | char *target_name, *master_name = "UN IDENTIFIED"; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 59 | |
| 60 | /* Get the Type of interrupt */ |
omar ramirez | 35f7b96 | 2011-04-18 16:39:42 +0000 | [diff] [blame] | 61 | inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 62 | |
| 63 | for (i = 0; i < L3_MODULES; i++) { |
| 64 | /* |
| 65 | * Read the regerr register of the clock domain |
| 66 | * to determine the source |
| 67 | */ |
sricharan | 6616aac | 2011-08-23 12:58:48 +0530 | [diff] [blame] | 68 | base = l3->l3_base[i]; |
| 69 | err_reg = __raw_readl(base + l3_flagmux[i] + |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 70 | + L3_FLAGMUX_REGERR0 + (inttype << 3)); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 71 | |
| 72 | /* Get the corresponding error and analyse */ |
| 73 | if (err_reg) { |
| 74 | /* Identify the source from control status register */ |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 75 | err_src = __ffs(err_reg); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 76 | |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 77 | /* Read the stderrlog_main_source from clk domain */ |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 78 | l3_targ_base = base + *(l3_targ[i] + err_src); |
sricharan | 6616aac | 2011-08-23 12:58:48 +0530 | [diff] [blame] | 79 | std_err_main = __raw_readl(l3_targ_base + |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 80 | L3_TARG_STDERRLOG_MAIN); |
sricharan | 551a9fa | 2011-09-07 17:25:16 +0530 | [diff] [blame] | 81 | masterid = __raw_readl(l3_targ_base + |
| 82 | L3_TARG_STDERRLOG_MSTADDR); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 83 | |
omar ramirez | 35f7b96 | 2011-04-18 16:39:42 +0000 | [diff] [blame] | 84 | switch (std_err_main & CUSTOM_ERROR) { |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 85 | case STANDARD_ERROR: |
sricharan | 551a9fa | 2011-09-07 17:25:16 +0530 | [diff] [blame] | 86 | target_name = |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 87 | l3_targ_inst_name[i][err_src]; |
sricharan | 551a9fa | 2011-09-07 17:25:16 +0530 | [diff] [blame] | 88 | WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n", |
| 89 | target_name, |
sricharan | 6616aac | 2011-08-23 12:58:48 +0530 | [diff] [blame] | 90 | __raw_readl(l3_targ_base + |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 91 | L3_TARG_STDERRLOG_SLVOFSLSB)); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 92 | /* clear the std error log*/ |
| 93 | clear = std_err_main | CLEAR_STDERR_LOG; |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 94 | writel(clear, l3_targ_base + |
| 95 | L3_TARG_STDERRLOG_MAIN); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 96 | break; |
| 97 | |
| 98 | case CUSTOM_ERROR: |
sricharan | 551a9fa | 2011-09-07 17:25:16 +0530 | [diff] [blame] | 99 | target_name = |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 100 | l3_targ_inst_name[i][err_src]; |
sricharan | 551a9fa | 2011-09-07 17:25:16 +0530 | [diff] [blame] | 101 | 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 Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 108 | /* clear the std error log*/ |
| 109 | clear = std_err_main | CLEAR_STDERR_LOG; |
Todd Poynor | 342fd14 | 2011-08-24 19:11:39 +0530 | [diff] [blame] | 110 | writel(clear, l3_targ_base + |
| 111 | L3_TARG_STDERRLOG_MAIN); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 112 | 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 | |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 125 | static int omap_l3_probe(struct platform_device *pdev) |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 126 | { |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 127 | static struct omap_l3 *l3; |
Peter Ujfalusi | 56c4a02 | 2014-04-01 16:23:47 +0300 | [diff] [blame] | 128 | int ret, i; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 129 | |
Peter Ujfalusi | bae7451 | 2014-04-01 16:23:46 +0300 | [diff] [blame] | 130 | l3 = devm_kzalloc(&pdev->dev, sizeof(*l3), GFP_KERNEL); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 131 | if (!l3) |
omar ramirez | 7529b70 | 2011-04-18 16:39:41 +0000 | [diff] [blame] | 132 | return -ENOMEM; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 133 | |
Nishanth Menon | ca6a349 | 2014-04-11 12:04:01 -0500 | [diff] [blame^] | 134 | l3->dev = &pdev->dev; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 135 | platform_set_drvdata(pdev, l3); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 136 | |
Peter Ujfalusi | 56c4a02 | 2014-04-01 16:23:47 +0300 | [diff] [blame] | 137 | /* Get mem resources */ |
| 138 | for (i = 0; i < L3_MODULES; i++) { |
| 139 | struct resource *res = platform_get_resource(pdev, |
| 140 | IORESOURCE_MEM, i); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 141 | |
Peter Ujfalusi | 56c4a02 | 2014-04-01 16:23:47 +0300 | [diff] [blame] | 142 | l3->l3_base[i] = devm_ioremap_resource(&pdev->dev, res); |
| 143 | if (IS_ERR(l3->l3_base[i])) { |
Nishanth Menon | ca6a349 | 2014-04-11 12:04:01 -0500 | [diff] [blame^] | 144 | dev_err(l3->dev, "ioremap %d failed\n", i); |
Peter Ujfalusi | 56c4a02 | 2014-04-01 16:23:47 +0300 | [diff] [blame] | 145 | return PTR_ERR(l3->l3_base[i]); |
| 146 | } |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /* |
| 150 | * Setup interrupt Handlers |
| 151 | */ |
Todd Poynor | c1df2dc | 2011-08-29 17:42:23 +0530 | [diff] [blame] | 152 | l3->debug_irq = platform_get_irq(pdev, 0); |
Nishanth Menon | ca6a349 | 2014-04-11 12:04:01 -0500 | [diff] [blame^] | 153 | ret = devm_request_irq(l3->dev, l3->debug_irq, l3_interrupt_handler, |
Peter Ujfalusi | a0ef78f | 2014-04-01 16:23:48 +0300 | [diff] [blame] | 154 | IRQF_DISABLED, "l3-dbg-irq", l3); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 155 | if (ret) { |
Nishanth Menon | ca6a349 | 2014-04-11 12:04:01 -0500 | [diff] [blame^] | 156 | dev_err(l3->dev, "request_irq failed for %d\n", |
Peter Ujfalusi | ae22598 | 2014-04-01 16:23:50 +0300 | [diff] [blame] | 157 | l3->debug_irq); |
Peter Ujfalusi | 56c4a02 | 2014-04-01 16:23:47 +0300 | [diff] [blame] | 158 | return ret; |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 159 | } |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 160 | |
Todd Poynor | c1df2dc | 2011-08-29 17:42:23 +0530 | [diff] [blame] | 161 | l3->app_irq = platform_get_irq(pdev, 1); |
Nishanth Menon | ca6a349 | 2014-04-11 12:04:01 -0500 | [diff] [blame^] | 162 | ret = devm_request_irq(l3->dev, l3->app_irq, l3_interrupt_handler, |
Peter Ujfalusi | a0ef78f | 2014-04-01 16:23:48 +0300 | [diff] [blame] | 163 | IRQF_DISABLED, "l3-app-irq", l3); |
| 164 | if (ret) |
Nishanth Menon | ca6a349 | 2014-04-11 12:04:01 -0500 | [diff] [blame^] | 165 | dev_err(l3->dev, "request_irq failed for %d\n", l3->app_irq); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 166 | |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 167 | return ret; |
| 168 | } |
| 169 | |
Benoit Cousson | d039c5b | 2011-08-12 13:52:50 +0200 | [diff] [blame] | 170 | #if defined(CONFIG_OF) |
| 171 | static const struct of_device_id l3_noc_match[] = { |
| 172 | {.compatible = "ti,omap4-l3-noc", }, |
| 173 | {}, |
Govindraj.R | 8770b07 | 2011-11-23 14:45:37 -0800 | [diff] [blame] | 174 | }; |
Benoit Cousson | d039c5b | 2011-08-12 13:52:50 +0200 | [diff] [blame] | 175 | MODULE_DEVICE_TABLE(of, l3_noc_match); |
| 176 | #else |
| 177 | #define l3_noc_match NULL |
| 178 | #endif |
| 179 | |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 180 | static struct platform_driver omap_l3_driver = { |
| 181 | .probe = omap_l3_probe, |
Benoit Cousson | d039c5b | 2011-08-12 13:52:50 +0200 | [diff] [blame] | 182 | .driver = { |
| 183 | .name = "omap_l3_noc", |
| 184 | .owner = THIS_MODULE, |
| 185 | .of_match_table = l3_noc_match, |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 186 | }, |
| 187 | }; |
| 188 | |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 189 | static int __init omap_l3_init(void) |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 190 | { |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 191 | return platform_driver_register(&omap_l3_driver); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 192 | } |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 193 | postcore_initcall_sync(omap_l3_init); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 194 | |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 195 | static void __exit omap_l3_exit(void) |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 196 | { |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 197 | platform_driver_unregister(&omap_l3_driver); |
Santosh Shilimkar | 2722e56 | 2011-03-07 20:53:10 +0530 | [diff] [blame] | 198 | } |
Sricharan R | c10d5c9 | 2014-04-11 13:09:36 -0500 | [diff] [blame] | 199 | module_exit(omap_l3_exit); |