omap_l3_noc.c 6.7 KB

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