mic_debugfs.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Intel MIC Platform Software Stack (MPSS)
  3. *
  4. * Copyright(c) 2013 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License, version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Disclaimer: The codes contained in these modules may be specific to
  19. * the Intel Software Development Platform codenamed: Knights Ferry, and
  20. * the Intel product codenamed: Knights Corner, and are not backward
  21. * compatible with other Intel products. Additionally, Intel will NOT
  22. * support the codes or instruction set in future products.
  23. *
  24. * Intel MIC Card driver.
  25. *
  26. */
  27. #include <linux/debugfs.h>
  28. #include <linux/delay.h>
  29. #include <linux/seq_file.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/device.h>
  32. #include "../common/mic_dev.h"
  33. #include "mic_device.h"
  34. /* Debugfs parent dir */
  35. static struct dentry *mic_dbg;
  36. /**
  37. * mic_intr_test - Send interrupts to host.
  38. */
  39. static int mic_intr_test(struct seq_file *s, void *unused)
  40. {
  41. struct mic_driver *mdrv = s->private;
  42. struct mic_device *mdev = &mdrv->mdev;
  43. mic_send_intr(mdev, 0);
  44. msleep(1000);
  45. mic_send_intr(mdev, 1);
  46. msleep(1000);
  47. mic_send_intr(mdev, 2);
  48. msleep(1000);
  49. mic_send_intr(mdev, 3);
  50. msleep(1000);
  51. return 0;
  52. }
  53. static int mic_intr_test_open(struct inode *inode, struct file *file)
  54. {
  55. return single_open(file, mic_intr_test, inode->i_private);
  56. }
  57. static int mic_intr_test_release(struct inode *inode, struct file *file)
  58. {
  59. return single_release(inode, file);
  60. }
  61. static const struct file_operations intr_test_ops = {
  62. .owner = THIS_MODULE,
  63. .open = mic_intr_test_open,
  64. .read = seq_read,
  65. .llseek = seq_lseek,
  66. .release = mic_intr_test_release
  67. };
  68. /**
  69. * mic_create_card_debug_dir - Initialize MIC debugfs entries.
  70. */
  71. void __init mic_create_card_debug_dir(struct mic_driver *mdrv)
  72. {
  73. struct dentry *d;
  74. if (!mic_dbg)
  75. return;
  76. mdrv->dbg_dir = debugfs_create_dir(mdrv->name, mic_dbg);
  77. if (!mdrv->dbg_dir) {
  78. dev_err(mdrv->dev, "Cant create dbg_dir %s\n", mdrv->name);
  79. return;
  80. }
  81. d = debugfs_create_file("intr_test", 0444, mdrv->dbg_dir,
  82. mdrv, &intr_test_ops);
  83. if (!d) {
  84. dev_err(mdrv->dev,
  85. "Cant create dbg intr_test %s\n", mdrv->name);
  86. return;
  87. }
  88. }
  89. /**
  90. * mic_delete_card_debug_dir - Uninitialize MIC debugfs entries.
  91. */
  92. void mic_delete_card_debug_dir(struct mic_driver *mdrv)
  93. {
  94. if (!mdrv->dbg_dir)
  95. return;
  96. debugfs_remove_recursive(mdrv->dbg_dir);
  97. }
  98. /**
  99. * mic_init_card_debugfs - Initialize global debugfs entry.
  100. */
  101. void __init mic_init_card_debugfs(void)
  102. {
  103. mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
  104. if (!mic_dbg)
  105. pr_err("can't create debugfs dir\n");
  106. }
  107. /**
  108. * mic_exit_card_debugfs - Uninitialize global debugfs entry
  109. */
  110. void mic_exit_card_debugfs(void)
  111. {
  112. debugfs_remove(mic_dbg);
  113. }