omap_l3_noc.c 6.4 KB

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