omap_l3_noc.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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 "soc.h"
  31. #include "omap_l3_noc.h"
  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. struct omap4_l3 *l3 = _l3;
  58. int inttype, i, k;
  59. int err_src = 0;
  60. u32 std_err_main, err_reg, clear, masterid;
  61. void __iomem *base, *l3_targ_base;
  62. char *target_name, *master_name = "UN IDENTIFIED";
  63. /* Get the Type of interrupt */
  64. inttype = irq == l3->app_irq ? L3_APPLICATION_ERROR : L3_DEBUG_ERROR;
  65. for (i = 0; i < L3_MODULES; i++) {
  66. /*
  67. * Read the regerr register of the clock domain
  68. * to determine the source
  69. */
  70. base = l3->l3_base[i];
  71. err_reg = __raw_readl(base + l3_flagmux[i] +
  72. + L3_FLAGMUX_REGERR0 + (inttype << 3));
  73. /* Get the corresponding error and analyse */
  74. if (err_reg) {
  75. /* Identify the source from control status register */
  76. err_src = __ffs(err_reg);
  77. /* Read the stderrlog_main_source from clk domain */
  78. l3_targ_base = base + *(l3_targ[i] + err_src);
  79. std_err_main = __raw_readl(l3_targ_base +
  80. L3_TARG_STDERRLOG_MAIN);
  81. masterid = __raw_readl(l3_targ_base +
  82. L3_TARG_STDERRLOG_MSTADDR);
  83. switch (std_err_main & CUSTOM_ERROR) {
  84. case STANDARD_ERROR:
  85. target_name =
  86. l3_targ_inst_name[i][err_src];
  87. WARN(true, "L3 standard error: TARGET:%s at address 0x%x\n",
  88. target_name,
  89. __raw_readl(l3_targ_base +
  90. L3_TARG_STDERRLOG_SLVOFSLSB));
  91. /* clear the std error log*/
  92. clear = std_err_main | CLEAR_STDERR_LOG;
  93. writel(clear, l3_targ_base +
  94. L3_TARG_STDERRLOG_MAIN);
  95. break;
  96. case CUSTOM_ERROR:
  97. target_name =
  98. l3_targ_inst_name[i][err_src];
  99. for (k = 0; k < NUM_OF_L3_MASTERS; k++) {
  100. if (masterid == l3_masters[k].id)
  101. master_name =
  102. l3_masters[k].name;
  103. }
  104. WARN(true, "L3 custom error: MASTER:%s TARGET:%s\n",
  105. master_name, target_name);
  106. /* clear the std error log*/
  107. clear = std_err_main | CLEAR_STDERR_LOG;
  108. writel(clear, l3_targ_base +
  109. L3_TARG_STDERRLOG_MAIN);
  110. break;
  111. default:
  112. /* Nothing to be handled here as of now */
  113. break;
  114. }
  115. /* Error found so break the for loop */
  116. break;
  117. }
  118. }
  119. return IRQ_HANDLED;
  120. }
  121. static int __devinit omap4_l3_probe(struct platform_device *pdev)
  122. {
  123. static struct omap4_l3 *l3;
  124. struct resource *res;
  125. int ret;
  126. l3 = kzalloc(sizeof(*l3), GFP_KERNEL);
  127. if (!l3)
  128. return -ENOMEM;
  129. platform_set_drvdata(pdev, l3);
  130. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  131. if (!res) {
  132. dev_err(&pdev->dev, "couldn't find resource 0\n");
  133. ret = -ENODEV;
  134. goto err0;
  135. }
  136. l3->l3_base[0] = ioremap(res->start, resource_size(res));
  137. if (!l3->l3_base[0]) {
  138. dev_err(&pdev->dev, "ioremap failed\n");
  139. ret = -ENOMEM;
  140. goto err0;
  141. }
  142. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  143. if (!res) {
  144. dev_err(&pdev->dev, "couldn't find resource 1\n");
  145. ret = -ENODEV;
  146. goto err1;
  147. }
  148. l3->l3_base[1] = ioremap(res->start, resource_size(res));
  149. if (!l3->l3_base[1]) {
  150. dev_err(&pdev->dev, "ioremap failed\n");
  151. ret = -ENOMEM;
  152. goto err1;
  153. }
  154. res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
  155. if (!res) {
  156. dev_err(&pdev->dev, "couldn't find resource 2\n");
  157. ret = -ENODEV;
  158. goto err2;
  159. }
  160. l3->l3_base[2] = ioremap(res->start, resource_size(res));
  161. if (!l3->l3_base[2]) {
  162. dev_err(&pdev->dev, "ioremap failed\n");
  163. ret = -ENOMEM;
  164. goto err2;
  165. }
  166. /*
  167. * Setup interrupt Handlers
  168. */
  169. l3->debug_irq = platform_get_irq(pdev, 0);
  170. ret = request_irq(l3->debug_irq,
  171. l3_interrupt_handler,
  172. IRQF_DISABLED, "l3-dbg-irq", l3);
  173. if (ret) {
  174. pr_crit("L3: request_irq failed to register for 0x%x\n",
  175. 9 + OMAP44XX_IRQ_GIC_START);
  176. goto err3;
  177. }
  178. l3->app_irq = platform_get_irq(pdev, 1);
  179. ret = request_irq(l3->app_irq,
  180. l3_interrupt_handler,
  181. IRQF_DISABLED, "l3-app-irq", l3);
  182. if (ret) {
  183. pr_crit("L3: request_irq failed to register for 0x%x\n",
  184. 10 + OMAP44XX_IRQ_GIC_START);
  185. goto err4;
  186. }
  187. return 0;
  188. err4:
  189. free_irq(l3->debug_irq, l3);
  190. err3:
  191. iounmap(l3->l3_base[2]);
  192. err2:
  193. iounmap(l3->l3_base[1]);
  194. err1:
  195. iounmap(l3->l3_base[0]);
  196. err0:
  197. kfree(l3);
  198. return ret;
  199. }
  200. static int __devexit omap4_l3_remove(struct platform_device *pdev)
  201. {
  202. struct omap4_l3 *l3 = platform_get_drvdata(pdev);
  203. free_irq(l3->app_irq, l3);
  204. free_irq(l3->debug_irq, l3);
  205. iounmap(l3->l3_base[0]);
  206. iounmap(l3->l3_base[1]);
  207. iounmap(l3->l3_base[2]);
  208. kfree(l3);
  209. return 0;
  210. }
  211. #if defined(CONFIG_OF)
  212. static const struct of_device_id l3_noc_match[] = {
  213. {.compatible = "ti,omap4-l3-noc", },
  214. {},
  215. };
  216. MODULE_DEVICE_TABLE(of, l3_noc_match);
  217. #else
  218. #define l3_noc_match NULL
  219. #endif
  220. static struct platform_driver omap4_l3_driver = {
  221. .probe = omap4_l3_probe,
  222. .remove = __devexit_p(omap4_l3_remove),
  223. .driver = {
  224. .name = "omap_l3_noc",
  225. .owner = THIS_MODULE,
  226. .of_match_table = l3_noc_match,
  227. },
  228. };
  229. static int __init omap4_l3_init(void)
  230. {
  231. return platform_driver_register(&omap4_l3_driver);
  232. }
  233. postcore_initcall_sync(omap4_l3_init);
  234. static void __exit omap4_l3_exit(void)
  235. {
  236. platform_driver_unregister(&omap4_l3_driver);
  237. }
  238. module_exit(omap4_l3_exit);