nfit_test.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. #ifndef __NFIT_TEST_H__
  14. #define __NFIT_TEST_H__
  15. #include <linux/list.h>
  16. #include <linux/uuid.h>
  17. #include <linux/ioport.h>
  18. #include <linux/spinlock_types.h>
  19. struct nfit_test_request {
  20. struct list_head list;
  21. struct resource res;
  22. };
  23. struct nfit_test_resource {
  24. struct list_head requests;
  25. struct list_head list;
  26. struct resource res;
  27. struct device *dev;
  28. spinlock_t lock;
  29. int req_count;
  30. void *buf;
  31. };
  32. #define ND_TRANSLATE_SPA_STATUS_INVALID_SPA 2
  33. #define NFIT_ARS_INJECT_INVALID 2
  34. enum err_inj_options {
  35. ND_ARS_ERR_INJ_OPT_NOTIFY = 0,
  36. };
  37. /* nfit commands */
  38. enum nfit_cmd_num {
  39. NFIT_CMD_TRANSLATE_SPA = 5,
  40. NFIT_CMD_ARS_INJECT_SET = 7,
  41. NFIT_CMD_ARS_INJECT_CLEAR = 8,
  42. NFIT_CMD_ARS_INJECT_GET = 9,
  43. };
  44. struct nd_cmd_translate_spa {
  45. __u64 spa;
  46. __u32 status;
  47. __u8 flags;
  48. __u8 _reserved[3];
  49. __u64 translate_length;
  50. __u32 num_nvdimms;
  51. struct nd_nvdimm_device {
  52. __u32 nfit_device_handle;
  53. __u32 _reserved;
  54. __u64 dpa;
  55. } __packed devices[0];
  56. } __packed;
  57. struct nd_cmd_ars_err_inj {
  58. __u64 err_inj_spa_range_base;
  59. __u64 err_inj_spa_range_length;
  60. __u8 err_inj_options;
  61. __u32 status;
  62. } __packed;
  63. struct nd_cmd_ars_err_inj_clr {
  64. __u64 err_inj_clr_spa_range_base;
  65. __u64 err_inj_clr_spa_range_length;
  66. __u32 status;
  67. } __packed;
  68. struct nd_cmd_ars_err_inj_stat {
  69. __u32 status;
  70. __u32 inj_err_rec_count;
  71. struct nd_error_stat_query_record {
  72. __u64 err_inj_stat_spa_range_base;
  73. __u64 err_inj_stat_spa_range_length;
  74. } __packed record[0];
  75. } __packed;
  76. #define ND_INTEL_SMART 1
  77. #define ND_INTEL_SMART_THRESHOLD 2
  78. #define ND_INTEL_ENABLE_LSS_STATUS 10
  79. #define ND_INTEL_FW_GET_INFO 12
  80. #define ND_INTEL_FW_START_UPDATE 13
  81. #define ND_INTEL_FW_SEND_DATA 14
  82. #define ND_INTEL_FW_FINISH_UPDATE 15
  83. #define ND_INTEL_FW_FINISH_QUERY 16
  84. #define ND_INTEL_SMART_SET_THRESHOLD 17
  85. #define ND_INTEL_SMART_INJECT 18
  86. #define ND_INTEL_SMART_HEALTH_VALID (1 << 0)
  87. #define ND_INTEL_SMART_SPARES_VALID (1 << 1)
  88. #define ND_INTEL_SMART_USED_VALID (1 << 2)
  89. #define ND_INTEL_SMART_MTEMP_VALID (1 << 3)
  90. #define ND_INTEL_SMART_CTEMP_VALID (1 << 4)
  91. #define ND_INTEL_SMART_SHUTDOWN_COUNT_VALID (1 << 5)
  92. #define ND_INTEL_SMART_AIT_STATUS_VALID (1 << 6)
  93. #define ND_INTEL_SMART_PTEMP_VALID (1 << 7)
  94. #define ND_INTEL_SMART_ALARM_VALID (1 << 9)
  95. #define ND_INTEL_SMART_SHUTDOWN_VALID (1 << 10)
  96. #define ND_INTEL_SMART_VENDOR_VALID (1 << 11)
  97. #define ND_INTEL_SMART_SPARE_TRIP (1 << 0)
  98. #define ND_INTEL_SMART_TEMP_TRIP (1 << 1)
  99. #define ND_INTEL_SMART_CTEMP_TRIP (1 << 2)
  100. #define ND_INTEL_SMART_NON_CRITICAL_HEALTH (1 << 0)
  101. #define ND_INTEL_SMART_CRITICAL_HEALTH (1 << 1)
  102. #define ND_INTEL_SMART_FATAL_HEALTH (1 << 2)
  103. #define ND_INTEL_SMART_INJECT_MTEMP (1 << 0)
  104. #define ND_INTEL_SMART_INJECT_SPARE (1 << 1)
  105. #define ND_INTEL_SMART_INJECT_FATAL (1 << 2)
  106. #define ND_INTEL_SMART_INJECT_SHUTDOWN (1 << 3)
  107. struct nd_intel_smart {
  108. __u32 status;
  109. union {
  110. struct {
  111. __u32 flags;
  112. __u8 reserved0[4];
  113. __u8 health;
  114. __u8 spares;
  115. __u8 life_used;
  116. __u8 alarm_flags;
  117. __u16 media_temperature;
  118. __u16 ctrl_temperature;
  119. __u32 shutdown_count;
  120. __u8 ait_status;
  121. __u16 pmic_temperature;
  122. __u8 reserved1[8];
  123. __u8 shutdown_state;
  124. __u32 vendor_size;
  125. __u8 vendor_data[92];
  126. } __packed;
  127. __u8 data[128];
  128. };
  129. } __packed;
  130. struct nd_intel_smart_threshold {
  131. __u32 status;
  132. union {
  133. struct {
  134. __u16 alarm_control;
  135. __u8 spares;
  136. __u16 media_temperature;
  137. __u16 ctrl_temperature;
  138. __u8 reserved[1];
  139. } __packed;
  140. __u8 data[8];
  141. };
  142. } __packed;
  143. struct nd_intel_smart_set_threshold {
  144. __u16 alarm_control;
  145. __u8 spares;
  146. __u16 media_temperature;
  147. __u16 ctrl_temperature;
  148. __u32 status;
  149. } __packed;
  150. struct nd_intel_smart_inject {
  151. __u64 flags;
  152. __u8 mtemp_enable;
  153. __u16 media_temperature;
  154. __u8 spare_enable;
  155. __u8 spares;
  156. __u8 fatal_enable;
  157. __u8 unsafe_shutdown_enable;
  158. __u32 status;
  159. } __packed;
  160. #define INTEL_FW_STORAGE_SIZE 0x100000
  161. #define INTEL_FW_MAX_SEND_LEN 0xFFEC
  162. #define INTEL_FW_QUERY_INTERVAL 250000
  163. #define INTEL_FW_QUERY_MAX_TIME 3000000
  164. #define INTEL_FW_FIS_VERSION 0x0105
  165. #define INTEL_FW_FAKE_VERSION 0xffffffffabcd
  166. enum intel_fw_update_state {
  167. FW_STATE_NEW = 0,
  168. FW_STATE_IN_PROGRESS,
  169. FW_STATE_VERIFY,
  170. FW_STATE_UPDATED,
  171. };
  172. struct nd_intel_fw_info {
  173. __u32 status;
  174. __u32 storage_size;
  175. __u32 max_send_len;
  176. __u32 query_interval;
  177. __u32 max_query_time;
  178. __u8 update_cap;
  179. __u8 reserved[3];
  180. __u32 fis_version;
  181. __u64 run_version;
  182. __u64 updated_version;
  183. } __packed;
  184. struct nd_intel_fw_start {
  185. __u32 status;
  186. __u32 context;
  187. } __packed;
  188. /* this one has the output first because the variable input data size */
  189. struct nd_intel_fw_send_data {
  190. __u32 context;
  191. __u32 offset;
  192. __u32 length;
  193. __u8 data[0];
  194. /* this field is not declared due ot variable data from input */
  195. /* __u32 status; */
  196. } __packed;
  197. struct nd_intel_fw_finish_update {
  198. __u8 ctrl_flags;
  199. __u8 reserved[3];
  200. __u32 context;
  201. __u32 status;
  202. } __packed;
  203. struct nd_intel_fw_finish_query {
  204. __u32 context;
  205. __u32 status;
  206. __u64 updated_fw_rev;
  207. } __packed;
  208. struct nd_intel_lss {
  209. __u8 enable;
  210. __u32 status;
  211. } __packed;
  212. union acpi_object;
  213. typedef void *acpi_handle;
  214. typedef struct nfit_test_resource *(*nfit_test_lookup_fn)(resource_size_t);
  215. typedef union acpi_object *(*nfit_test_evaluate_dsm_fn)(acpi_handle handle,
  216. const guid_t *guid, u64 rev, u64 func,
  217. union acpi_object *argv4);
  218. void __iomem *__wrap_ioremap_nocache(resource_size_t offset,
  219. unsigned long size);
  220. void __wrap_iounmap(volatile void __iomem *addr);
  221. void nfit_test_setup(nfit_test_lookup_fn lookup,
  222. nfit_test_evaluate_dsm_fn evaluate);
  223. void nfit_test_teardown(void);
  224. struct nfit_test_resource *get_nfit_res(resource_size_t resource);
  225. #endif