eeh_pseries.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * The file intends to implement the platform dependent EEH operations on pseries.
  3. * Actually, the pseries platform is built based on RTAS heavily. That means the
  4. * pseries platform dependent EEH operations will be built on RTAS calls. The functions
  5. * are devired from arch/powerpc/platforms/pseries/eeh.c and necessary cleanup has
  6. * been done.
  7. *
  8. * Copyright Benjamin Herrenschmidt & Gavin Shan, IBM Corporation 2011.
  9. * Copyright IBM Corporation 2001, 2005, 2006
  10. * Copyright Dave Engebretsen & Todd Inglett 2001
  11. * Copyright Linas Vepstas 2005, 2006
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27. #include <linux/atomic.h>
  28. #include <linux/delay.h>
  29. #include <linux/export.h>
  30. #include <linux/init.h>
  31. #include <linux/list.h>
  32. #include <linux/of.h>
  33. #include <linux/pci.h>
  34. #include <linux/proc_fs.h>
  35. #include <linux/rbtree.h>
  36. #include <linux/sched.h>
  37. #include <linux/seq_file.h>
  38. #include <linux/spinlock.h>
  39. #include <asm/eeh.h>
  40. #include <asm/eeh_event.h>
  41. #include <asm/io.h>
  42. #include <asm/machdep.h>
  43. #include <asm/ppc-pci.h>
  44. #include <asm/rtas.h>
  45. /**
  46. * pseries_eeh_init - EEH platform dependent initialization
  47. *
  48. * EEH platform dependent initialization on pseries.
  49. */
  50. static int pseries_eeh_init(void)
  51. {
  52. return 0;
  53. }
  54. /**
  55. * pseries_eeh_set_option - Initialize EEH or MMIO/DMA reenable
  56. * @dn: device node
  57. * @option: operation to be issued
  58. *
  59. * The function is used to control the EEH functionality globally.
  60. * Currently, following options are support according to PAPR:
  61. * Enable EEH, Disable EEH, Enable MMIO and Enable DMA
  62. */
  63. static int pseries_eeh_set_option(struct device_node *dn, int option)
  64. {
  65. return 0;
  66. }
  67. /**
  68. * pseries_eeh_get_pe_addr - Retrieve PE address
  69. * @dn: device node
  70. *
  71. * Retrieve the assocated PE address. Actually, there're 2 RTAS
  72. * function calls dedicated for the purpose. We need implement
  73. * it through the new function and then the old one. Besides,
  74. * you should make sure the config address is figured out from
  75. * FDT node before calling the function.
  76. *
  77. * It's notable that zero'ed return value means invalid PE config
  78. * address.
  79. */
  80. static int pseries_eeh_get_pe_addr(struct device_node *dn)
  81. {
  82. return 0;
  83. }
  84. /**
  85. * pseries_eeh_get_state - Retrieve PE state
  86. * @dn: PE associated device node
  87. * @state: return value
  88. *
  89. * Retrieve the state of the specified PE. On RTAS compliant
  90. * pseries platform, there already has one dedicated RTAS function
  91. * for the purpose. It's notable that the associated PE config address
  92. * might be ready when calling the function. Therefore, endeavour to
  93. * use the PE config address if possible. Further more, there're 2
  94. * RTAS calls for the purpose, we need to try the new one and back
  95. * to the old one if the new one couldn't work properly.
  96. */
  97. static int pseries_eeh_get_state(struct device_node *dn, int *state)
  98. {
  99. return 0;
  100. }
  101. /**
  102. * pseries_eeh_reset - Reset the specified PE
  103. * @dn: PE associated device node
  104. * @option: reset option
  105. *
  106. * Reset the specified PE
  107. */
  108. static int pseries_eeh_reset(struct device_node *dn, int option)
  109. {
  110. return 0;
  111. }
  112. /**
  113. * pseries_eeh_wait_state - Wait for PE state
  114. * @dn: PE associated device node
  115. * @max_wait: maximal period in microsecond
  116. *
  117. * Wait for the state of associated PE. It might take some time
  118. * to retrieve the PE's state.
  119. */
  120. static int pseries_eeh_wait_state(struct device_node *dn, int max_wait)
  121. {
  122. return 0;
  123. }
  124. /**
  125. * pseries_eeh_get_log - Retrieve error log
  126. * @dn: device node
  127. * @severity: temporary or permanent error log
  128. * @drv_log: driver log to be combined with retrieved error log
  129. * @len: length of driver log
  130. *
  131. * Retrieve the temporary or permanent error from the PE.
  132. * Actually, the error will be retrieved through the dedicated
  133. * RTAS call.
  134. */
  135. static int pseries_eeh_get_log(struct device_node *dn, int severity, char *drv_log, unsigned long len)
  136. {
  137. return 0;
  138. }
  139. /**
  140. * pseries_eeh_configure_bridge - Configure PCI bridges in the indicated PE
  141. * @dn: PE associated device node
  142. *
  143. * The function will be called to reconfigure the bridges included
  144. * in the specified PE so that the mulfunctional PE would be recovered
  145. * again.
  146. */
  147. static int pseries_eeh_configure_bridge(struct device_node *dn)
  148. {
  149. return 0;
  150. }
  151. static struct eeh_ops pseries_eeh_ops = {
  152. .name = "pseries",
  153. .init = pseries_eeh_init,
  154. .set_option = pseries_eeh_set_option,
  155. .get_pe_addr = pseries_eeh_get_pe_addr,
  156. .get_state = pseries_eeh_get_state,
  157. .reset = pseries_eeh_reset,
  158. .wait_state = pseries_eeh_wait_state,
  159. .get_log = pseries_eeh_get_log,
  160. .configure_bridge = pseries_eeh_configure_bridge
  161. };
  162. /**
  163. * eeh_pseries_init - Register platform dependent EEH operations
  164. *
  165. * EEH initialization on pseries platform. This function should be
  166. * called before any EEH related functions.
  167. */
  168. int __init eeh_pseries_init(void)
  169. {
  170. return eeh_ops_register(&pseries_eeh_ops);
  171. }