opal.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. /*
  2. * PowerNV OPAL definitions.
  3. *
  4. * Copyright 2011 IBM Corp.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #ifndef __OPAL_H
  12. #define __OPAL_H
  13. /****** Takeover interface ********/
  14. /* PAPR H-Call used to querty the HAL existence and/or instanciate
  15. * it from within pHyp (tech preview only).
  16. *
  17. * This is exclusively used in prom_init.c
  18. */
  19. #ifndef __ASSEMBLY__
  20. struct opal_takeover_args {
  21. u64 k_image; /* r4 */
  22. u64 k_size; /* r5 */
  23. u64 k_entry; /* r6 */
  24. u64 k_entry2; /* r7 */
  25. u64 hal_addr; /* r8 */
  26. u64 rd_image; /* r9 */
  27. u64 rd_size; /* r10 */
  28. u64 rd_loc; /* r11 */
  29. };
  30. /*
  31. * SG entry
  32. *
  33. * WARNING: The current implementation requires each entry
  34. * to represent a block that is 4k aligned *and* each block
  35. * size except the last one in the list to be as well.
  36. */
  37. struct opal_sg_entry {
  38. void *data;
  39. long length;
  40. };
  41. /* sg list */
  42. struct opal_sg_list {
  43. unsigned long num_entries;
  44. struct opal_sg_list *next;
  45. struct opal_sg_entry entry[];
  46. };
  47. /* We calculate number of sg entries based on PAGE_SIZE */
  48. #define SG_ENTRIES_PER_NODE ((PAGE_SIZE - 16) / sizeof(struct opal_sg_entry))
  49. extern long opal_query_takeover(u64 *hal_size, u64 *hal_align);
  50. extern long opal_do_takeover(struct opal_takeover_args *args);
  51. struct rtas_args;
  52. extern int opal_enter_rtas(struct rtas_args *args,
  53. unsigned long data,
  54. unsigned long entry);
  55. #endif /* __ASSEMBLY__ */
  56. /****** OPAL APIs ******/
  57. /* Return codes */
  58. #define OPAL_SUCCESS 0
  59. #define OPAL_PARAMETER -1
  60. #define OPAL_BUSY -2
  61. #define OPAL_PARTIAL -3
  62. #define OPAL_CONSTRAINED -4
  63. #define OPAL_CLOSED -5
  64. #define OPAL_HARDWARE -6
  65. #define OPAL_UNSUPPORTED -7
  66. #define OPAL_PERMISSION -8
  67. #define OPAL_NO_MEM -9
  68. #define OPAL_RESOURCE -10
  69. #define OPAL_INTERNAL_ERROR -11
  70. #define OPAL_BUSY_EVENT -12
  71. #define OPAL_HARDWARE_FROZEN -13
  72. /* API Tokens (in r0) */
  73. #define OPAL_CONSOLE_WRITE 1
  74. #define OPAL_CONSOLE_READ 2
  75. #define OPAL_RTC_READ 3
  76. #define OPAL_RTC_WRITE 4
  77. #define OPAL_CEC_POWER_DOWN 5
  78. #define OPAL_CEC_REBOOT 6
  79. #define OPAL_READ_NVRAM 7
  80. #define OPAL_WRITE_NVRAM 8
  81. #define OPAL_HANDLE_INTERRUPT 9
  82. #define OPAL_POLL_EVENTS 10
  83. #define OPAL_PCI_SET_HUB_TCE_MEMORY 11
  84. #define OPAL_PCI_SET_PHB_TCE_MEMORY 12
  85. #define OPAL_PCI_CONFIG_READ_BYTE 13
  86. #define OPAL_PCI_CONFIG_READ_HALF_WORD 14
  87. #define OPAL_PCI_CONFIG_READ_WORD 15
  88. #define OPAL_PCI_CONFIG_WRITE_BYTE 16
  89. #define OPAL_PCI_CONFIG_WRITE_HALF_WORD 17
  90. #define OPAL_PCI_CONFIG_WRITE_WORD 18
  91. #define OPAL_SET_XIVE 19
  92. #define OPAL_GET_XIVE 20
  93. #define OPAL_GET_COMPLETION_TOKEN_STATUS 21 /* obsolete */
  94. #define OPAL_REGISTER_OPAL_EXCEPTION_HANDLER 22
  95. #define OPAL_PCI_EEH_FREEZE_STATUS 23
  96. #define OPAL_PCI_SHPC 24
  97. #define OPAL_CONSOLE_WRITE_BUFFER_SPACE 25
  98. #define OPAL_PCI_EEH_FREEZE_CLEAR 26
  99. #define OPAL_PCI_PHB_MMIO_ENABLE 27
  100. #define OPAL_PCI_SET_PHB_MEM_WINDOW 28
  101. #define OPAL_PCI_MAP_PE_MMIO_WINDOW 29
  102. #define OPAL_PCI_SET_PHB_TABLE_MEMORY 30
  103. #define OPAL_PCI_SET_PE 31
  104. #define OPAL_PCI_SET_PELTV 32
  105. #define OPAL_PCI_SET_MVE 33
  106. #define OPAL_PCI_SET_MVE_ENABLE 34
  107. #define OPAL_PCI_GET_XIVE_REISSUE 35
  108. #define OPAL_PCI_SET_XIVE_REISSUE 36
  109. #define OPAL_PCI_SET_XIVE_PE 37
  110. #define OPAL_GET_XIVE_SOURCE 38
  111. #define OPAL_GET_MSI_32 39
  112. #define OPAL_GET_MSI_64 40
  113. #define OPAL_START_CPU 41
  114. #define OPAL_QUERY_CPU_STATUS 42
  115. #define OPAL_WRITE_OPPANEL 43
  116. #define OPAL_PCI_MAP_PE_DMA_WINDOW 44
  117. #define OPAL_PCI_MAP_PE_DMA_WINDOW_REAL 45
  118. #define OPAL_PCI_RESET 49
  119. #define OPAL_PCI_GET_HUB_DIAG_DATA 50
  120. #define OPAL_PCI_GET_PHB_DIAG_DATA 51
  121. #define OPAL_PCI_FENCE_PHB 52
  122. #define OPAL_PCI_REINIT 53
  123. #define OPAL_PCI_MASK_PE_ERROR 54
  124. #define OPAL_SET_SLOT_LED_STATUS 55
  125. #define OPAL_GET_EPOW_STATUS 56
  126. #define OPAL_SET_SYSTEM_ATTENTION_LED 57
  127. #define OPAL_RESERVED1 58
  128. #define OPAL_RESERVED2 59
  129. #define OPAL_PCI_NEXT_ERROR 60
  130. #define OPAL_PCI_EEH_FREEZE_STATUS2 61
  131. #define OPAL_PCI_POLL 62
  132. #define OPAL_PCI_MSI_EOI 63
  133. #define OPAL_PCI_GET_PHB_DIAG_DATA2 64
  134. #define OPAL_XSCOM_READ 65
  135. #define OPAL_XSCOM_WRITE 66
  136. #define OPAL_LPC_READ 67
  137. #define OPAL_LPC_WRITE 68
  138. #define OPAL_RETURN_CPU 69
  139. #define OPAL_FLASH_VALIDATE 76
  140. #define OPAL_FLASH_MANAGE 77
  141. #define OPAL_FLASH_UPDATE 78
  142. #define OPAL_GET_MSG 85
  143. #define OPAL_CHECK_ASYNC_COMPLETION 86
  144. #define OPAL_SYNC_HOST_REBOOT 87
  145. #ifndef __ASSEMBLY__
  146. /* Other enums */
  147. enum OpalVendorApiTokens {
  148. OPAL_START_VENDOR_API_RANGE = 1000, OPAL_END_VENDOR_API_RANGE = 1999
  149. };
  150. enum OpalFreezeState {
  151. OPAL_EEH_STOPPED_NOT_FROZEN = 0,
  152. OPAL_EEH_STOPPED_MMIO_FREEZE = 1,
  153. OPAL_EEH_STOPPED_DMA_FREEZE = 2,
  154. OPAL_EEH_STOPPED_MMIO_DMA_FREEZE = 3,
  155. OPAL_EEH_STOPPED_RESET = 4,
  156. OPAL_EEH_STOPPED_TEMP_UNAVAIL = 5,
  157. OPAL_EEH_STOPPED_PERM_UNAVAIL = 6
  158. };
  159. enum OpalEehFreezeActionToken {
  160. OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO = 1,
  161. OPAL_EEH_ACTION_CLEAR_FREEZE_DMA = 2,
  162. OPAL_EEH_ACTION_CLEAR_FREEZE_ALL = 3
  163. };
  164. enum OpalPciStatusToken {
  165. OPAL_EEH_NO_ERROR = 0,
  166. OPAL_EEH_IOC_ERROR = 1,
  167. OPAL_EEH_PHB_ERROR = 2,
  168. OPAL_EEH_PE_ERROR = 3,
  169. OPAL_EEH_PE_MMIO_ERROR = 4,
  170. OPAL_EEH_PE_DMA_ERROR = 5
  171. };
  172. enum OpalPciErrorSeverity {
  173. OPAL_EEH_SEV_NO_ERROR = 0,
  174. OPAL_EEH_SEV_IOC_DEAD = 1,
  175. OPAL_EEH_SEV_PHB_DEAD = 2,
  176. OPAL_EEH_SEV_PHB_FENCED = 3,
  177. OPAL_EEH_SEV_PE_ER = 4,
  178. OPAL_EEH_SEV_INF = 5
  179. };
  180. enum OpalShpcAction {
  181. OPAL_SHPC_GET_LINK_STATE = 0,
  182. OPAL_SHPC_GET_SLOT_STATE = 1
  183. };
  184. enum OpalShpcLinkState {
  185. OPAL_SHPC_LINK_DOWN = 0,
  186. OPAL_SHPC_LINK_UP = 1
  187. };
  188. enum OpalMmioWindowType {
  189. OPAL_M32_WINDOW_TYPE = 1,
  190. OPAL_M64_WINDOW_TYPE = 2,
  191. OPAL_IO_WINDOW_TYPE = 3
  192. };
  193. enum OpalShpcSlotState {
  194. OPAL_SHPC_DEV_NOT_PRESENT = 0,
  195. OPAL_SHPC_DEV_PRESENT = 1
  196. };
  197. enum OpalExceptionHandler {
  198. OPAL_MACHINE_CHECK_HANDLER = 1,
  199. OPAL_HYPERVISOR_MAINTENANCE_HANDLER = 2,
  200. OPAL_SOFTPATCH_HANDLER = 3
  201. };
  202. enum OpalPendingState {
  203. OPAL_EVENT_OPAL_INTERNAL = 0x1,
  204. OPAL_EVENT_NVRAM = 0x2,
  205. OPAL_EVENT_RTC = 0x4,
  206. OPAL_EVENT_CONSOLE_OUTPUT = 0x8,
  207. OPAL_EVENT_CONSOLE_INPUT = 0x10,
  208. OPAL_EVENT_ERROR_LOG_AVAIL = 0x20,
  209. OPAL_EVENT_ERROR_LOG = 0x40,
  210. OPAL_EVENT_EPOW = 0x80,
  211. OPAL_EVENT_LED_STATUS = 0x100,
  212. OPAL_EVENT_PCI_ERROR = 0x200,
  213. OPAL_EVENT_MSG_PENDING = 0x800,
  214. };
  215. enum OpalMessageType {
  216. OPAL_MSG_ASYNC_COMP = 0,
  217. OPAL_MSG_MEM_ERR,
  218. OPAL_MSG_EPOW,
  219. OPAL_MSG_SHUTDOWN,
  220. OPAL_MSG_TYPE_MAX,
  221. };
  222. /* Machine check related definitions */
  223. enum OpalMCE_Version {
  224. OpalMCE_V1 = 1,
  225. };
  226. enum OpalMCE_Severity {
  227. OpalMCE_SEV_NO_ERROR = 0,
  228. OpalMCE_SEV_WARNING = 1,
  229. OpalMCE_SEV_ERROR_SYNC = 2,
  230. OpalMCE_SEV_FATAL = 3,
  231. };
  232. enum OpalMCE_Disposition {
  233. OpalMCE_DISPOSITION_RECOVERED = 0,
  234. OpalMCE_DISPOSITION_NOT_RECOVERED = 1,
  235. };
  236. enum OpalMCE_Initiator {
  237. OpalMCE_INITIATOR_UNKNOWN = 0,
  238. OpalMCE_INITIATOR_CPU = 1,
  239. };
  240. enum OpalMCE_ErrorType {
  241. OpalMCE_ERROR_TYPE_UNKNOWN = 0,
  242. OpalMCE_ERROR_TYPE_UE = 1,
  243. OpalMCE_ERROR_TYPE_SLB = 2,
  244. OpalMCE_ERROR_TYPE_ERAT = 3,
  245. OpalMCE_ERROR_TYPE_TLB = 4,
  246. };
  247. enum OpalMCE_UeErrorType {
  248. OpalMCE_UE_ERROR_INDETERMINATE = 0,
  249. OpalMCE_UE_ERROR_IFETCH = 1,
  250. OpalMCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH = 2,
  251. OpalMCE_UE_ERROR_LOAD_STORE = 3,
  252. OpalMCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 4,
  253. };
  254. enum OpalMCE_SlbErrorType {
  255. OpalMCE_SLB_ERROR_INDETERMINATE = 0,
  256. OpalMCE_SLB_ERROR_PARITY = 1,
  257. OpalMCE_SLB_ERROR_MULTIHIT = 2,
  258. };
  259. enum OpalMCE_EratErrorType {
  260. OpalMCE_ERAT_ERROR_INDETERMINATE = 0,
  261. OpalMCE_ERAT_ERROR_PARITY = 1,
  262. OpalMCE_ERAT_ERROR_MULTIHIT = 2,
  263. };
  264. enum OpalMCE_TlbErrorType {
  265. OpalMCE_TLB_ERROR_INDETERMINATE = 0,
  266. OpalMCE_TLB_ERROR_PARITY = 1,
  267. OpalMCE_TLB_ERROR_MULTIHIT = 2,
  268. };
  269. enum OpalThreadStatus {
  270. OPAL_THREAD_INACTIVE = 0x0,
  271. OPAL_THREAD_STARTED = 0x1,
  272. OPAL_THREAD_UNAVAILABLE = 0x2 /* opal-v3 */
  273. };
  274. enum OpalPciBusCompare {
  275. OpalPciBusAny = 0, /* Any bus number match */
  276. OpalPciBus3Bits = 2, /* Match top 3 bits of bus number */
  277. OpalPciBus4Bits = 3, /* Match top 4 bits of bus number */
  278. OpalPciBus5Bits = 4, /* Match top 5 bits of bus number */
  279. OpalPciBus6Bits = 5, /* Match top 6 bits of bus number */
  280. OpalPciBus7Bits = 6, /* Match top 7 bits of bus number */
  281. OpalPciBusAll = 7, /* Match bus number exactly */
  282. };
  283. enum OpalDeviceCompare {
  284. OPAL_IGNORE_RID_DEVICE_NUMBER = 0,
  285. OPAL_COMPARE_RID_DEVICE_NUMBER = 1
  286. };
  287. enum OpalFuncCompare {
  288. OPAL_IGNORE_RID_FUNCTION_NUMBER = 0,
  289. OPAL_COMPARE_RID_FUNCTION_NUMBER = 1
  290. };
  291. enum OpalPeAction {
  292. OPAL_UNMAP_PE = 0,
  293. OPAL_MAP_PE = 1
  294. };
  295. enum OpalPeltvAction {
  296. OPAL_REMOVE_PE_FROM_DOMAIN = 0,
  297. OPAL_ADD_PE_TO_DOMAIN = 1
  298. };
  299. enum OpalMveEnableAction {
  300. OPAL_DISABLE_MVE = 0,
  301. OPAL_ENABLE_MVE = 1
  302. };
  303. enum OpalPciResetScope {
  304. OPAL_PHB_COMPLETE = 1, OPAL_PCI_LINK = 2, OPAL_PHB_ERROR = 3,
  305. OPAL_PCI_HOT_RESET = 4, OPAL_PCI_FUNDAMENTAL_RESET = 5,
  306. OPAL_PCI_IODA_TABLE_RESET = 6,
  307. };
  308. enum OpalPciReinitScope {
  309. OPAL_REINIT_PCI_DEV = 1000
  310. };
  311. enum OpalPciResetState {
  312. OPAL_DEASSERT_RESET = 0,
  313. OPAL_ASSERT_RESET = 1
  314. };
  315. enum OpalPciMaskAction {
  316. OPAL_UNMASK_ERROR_TYPE = 0,
  317. OPAL_MASK_ERROR_TYPE = 1
  318. };
  319. enum OpalSlotLedType {
  320. OPAL_SLOT_LED_ID_TYPE = 0,
  321. OPAL_SLOT_LED_FAULT_TYPE = 1
  322. };
  323. enum OpalLedAction {
  324. OPAL_TURN_OFF_LED = 0,
  325. OPAL_TURN_ON_LED = 1,
  326. OPAL_QUERY_LED_STATE_AFTER_BUSY = 2
  327. };
  328. enum OpalEpowStatus {
  329. OPAL_EPOW_NONE = 0,
  330. OPAL_EPOW_UPS = 1,
  331. OPAL_EPOW_OVER_AMBIENT_TEMP = 2,
  332. OPAL_EPOW_OVER_INTERNAL_TEMP = 3
  333. };
  334. /*
  335. * Address cycle types for LPC accesses. These also correspond
  336. * to the content of the first cell of the "reg" property for
  337. * device nodes on the LPC bus
  338. */
  339. enum OpalLPCAddressType {
  340. OPAL_LPC_MEM = 0,
  341. OPAL_LPC_IO = 1,
  342. OPAL_LPC_FW = 2,
  343. };
  344. struct opal_msg {
  345. uint32_t msg_type;
  346. uint32_t reserved;
  347. uint64_t params[8];
  348. };
  349. struct opal_machine_check_event {
  350. enum OpalMCE_Version version:8; /* 0x00 */
  351. uint8_t in_use; /* 0x01 */
  352. enum OpalMCE_Severity severity:8; /* 0x02 */
  353. enum OpalMCE_Initiator initiator:8; /* 0x03 */
  354. enum OpalMCE_ErrorType error_type:8; /* 0x04 */
  355. enum OpalMCE_Disposition disposition:8; /* 0x05 */
  356. uint8_t reserved_1[2]; /* 0x06 */
  357. uint64_t gpr3; /* 0x08 */
  358. uint64_t srr0; /* 0x10 */
  359. uint64_t srr1; /* 0x18 */
  360. union { /* 0x20 */
  361. struct {
  362. enum OpalMCE_UeErrorType ue_error_type:8;
  363. uint8_t effective_address_provided;
  364. uint8_t physical_address_provided;
  365. uint8_t reserved_1[5];
  366. uint64_t effective_address;
  367. uint64_t physical_address;
  368. uint8_t reserved_2[8];
  369. } ue_error;
  370. struct {
  371. enum OpalMCE_SlbErrorType slb_error_type:8;
  372. uint8_t effective_address_provided;
  373. uint8_t reserved_1[6];
  374. uint64_t effective_address;
  375. uint8_t reserved_2[16];
  376. } slb_error;
  377. struct {
  378. enum OpalMCE_EratErrorType erat_error_type:8;
  379. uint8_t effective_address_provided;
  380. uint8_t reserved_1[6];
  381. uint64_t effective_address;
  382. uint8_t reserved_2[16];
  383. } erat_error;
  384. struct {
  385. enum OpalMCE_TlbErrorType tlb_error_type:8;
  386. uint8_t effective_address_provided;
  387. uint8_t reserved_1[6];
  388. uint64_t effective_address;
  389. uint8_t reserved_2[16];
  390. } tlb_error;
  391. } u;
  392. };
  393. /* FSP memory errors handling */
  394. enum OpalMemErr_Version {
  395. OpalMemErr_V1 = 1,
  396. };
  397. enum OpalMemErrType {
  398. OPAL_MEM_ERR_TYPE_RESILIENCE = 0,
  399. OPAL_MEM_ERR_TYPE_DYN_DALLOC,
  400. OPAL_MEM_ERR_TYPE_SCRUB,
  401. };
  402. /* Memory Reilience error type */
  403. enum OpalMemErr_ResilErrType {
  404. OPAL_MEM_RESILIENCE_CE = 0,
  405. OPAL_MEM_RESILIENCE_UE,
  406. OPAL_MEM_RESILIENCE_UE_SCRUB,
  407. };
  408. /* Dynamic Memory Deallocation type */
  409. enum OpalMemErr_DynErrType {
  410. OPAL_MEM_DYNAMIC_DEALLOC = 0,
  411. };
  412. /* OpalMemoryErrorData->flags */
  413. #define OPAL_MEM_CORRECTED_ERROR 0x0001
  414. #define OPAL_MEM_THRESHOLD_EXCEEDED 0x0002
  415. #define OPAL_MEM_ACK_REQUIRED 0x8000
  416. struct OpalMemoryErrorData {
  417. enum OpalMemErr_Version version:8; /* 0x00 */
  418. enum OpalMemErrType type:8; /* 0x01 */
  419. uint16_t flags; /* 0x02 */
  420. uint8_t reserved_1[4]; /* 0x04 */
  421. union {
  422. /* Memory Resilience corrected/uncorrected error info */
  423. struct {
  424. enum OpalMemErr_ResilErrType resil_err_type:8;
  425. uint8_t reserved_1[7];
  426. uint64_t physical_address_start;
  427. uint64_t physical_address_end;
  428. } resilience;
  429. /* Dynamic memory deallocation error info */
  430. struct {
  431. enum OpalMemErr_DynErrType dyn_err_type:8;
  432. uint8_t reserved_1[7];
  433. uint64_t physical_address_start;
  434. uint64_t physical_address_end;
  435. } dyn_dealloc;
  436. } u;
  437. };
  438. enum {
  439. OPAL_P7IOC_DIAG_TYPE_NONE = 0,
  440. OPAL_P7IOC_DIAG_TYPE_RGC = 1,
  441. OPAL_P7IOC_DIAG_TYPE_BI = 2,
  442. OPAL_P7IOC_DIAG_TYPE_CI = 3,
  443. OPAL_P7IOC_DIAG_TYPE_MISC = 4,
  444. OPAL_P7IOC_DIAG_TYPE_I2C = 5,
  445. OPAL_P7IOC_DIAG_TYPE_LAST = 6
  446. };
  447. struct OpalIoP7IOCErrorData {
  448. uint16_t type;
  449. /* GEM */
  450. uint64_t gemXfir;
  451. uint64_t gemRfir;
  452. uint64_t gemRirqfir;
  453. uint64_t gemMask;
  454. uint64_t gemRwof;
  455. /* LEM */
  456. uint64_t lemFir;
  457. uint64_t lemErrMask;
  458. uint64_t lemAction0;
  459. uint64_t lemAction1;
  460. uint64_t lemWof;
  461. union {
  462. struct OpalIoP7IOCRgcErrorData {
  463. uint64_t rgcStatus; /* 3E1C10 */
  464. uint64_t rgcLdcp; /* 3E1C18 */
  465. }rgc;
  466. struct OpalIoP7IOCBiErrorData {
  467. uint64_t biLdcp0; /* 3C0100, 3C0118 */
  468. uint64_t biLdcp1; /* 3C0108, 3C0120 */
  469. uint64_t biLdcp2; /* 3C0110, 3C0128 */
  470. uint64_t biFenceStatus; /* 3C0130, 3C0130 */
  471. uint8_t biDownbound; /* BI Downbound or Upbound */
  472. }bi;
  473. struct OpalIoP7IOCCiErrorData {
  474. uint64_t ciPortStatus; /* 3Dn008 */
  475. uint64_t ciPortLdcp; /* 3Dn010 */
  476. uint8_t ciPort; /* Index of CI port: 0/1 */
  477. }ci;
  478. };
  479. };
  480. /**
  481. * This structure defines the overlay which will be used to store PHB error
  482. * data upon request.
  483. */
  484. enum {
  485. OPAL_PHB_ERROR_DATA_VERSION_1 = 1,
  486. };
  487. enum {
  488. OPAL_PHB_ERROR_DATA_TYPE_P7IOC = 1,
  489. OPAL_PHB_ERROR_DATA_TYPE_PHB3 = 2
  490. };
  491. enum {
  492. OPAL_P7IOC_NUM_PEST_REGS = 128,
  493. OPAL_PHB3_NUM_PEST_REGS = 256
  494. };
  495. struct OpalIoPhbErrorCommon {
  496. uint32_t version;
  497. uint32_t ioType;
  498. uint32_t len;
  499. };
  500. struct OpalIoP7IOCPhbErrorData {
  501. struct OpalIoPhbErrorCommon common;
  502. uint32_t brdgCtl;
  503. // P7IOC utl regs
  504. uint32_t portStatusReg;
  505. uint32_t rootCmplxStatus;
  506. uint32_t busAgentStatus;
  507. // P7IOC cfg regs
  508. uint32_t deviceStatus;
  509. uint32_t slotStatus;
  510. uint32_t linkStatus;
  511. uint32_t devCmdStatus;
  512. uint32_t devSecStatus;
  513. // cfg AER regs
  514. uint32_t rootErrorStatus;
  515. uint32_t uncorrErrorStatus;
  516. uint32_t corrErrorStatus;
  517. uint32_t tlpHdr1;
  518. uint32_t tlpHdr2;
  519. uint32_t tlpHdr3;
  520. uint32_t tlpHdr4;
  521. uint32_t sourceId;
  522. uint32_t rsv3;
  523. // Record data about the call to allocate a buffer.
  524. uint64_t errorClass;
  525. uint64_t correlator;
  526. //P7IOC MMIO Error Regs
  527. uint64_t p7iocPlssr; // n120
  528. uint64_t p7iocCsr; // n110
  529. uint64_t lemFir; // nC00
  530. uint64_t lemErrorMask; // nC18
  531. uint64_t lemWOF; // nC40
  532. uint64_t phbErrorStatus; // nC80
  533. uint64_t phbFirstErrorStatus; // nC88
  534. uint64_t phbErrorLog0; // nCC0
  535. uint64_t phbErrorLog1; // nCC8
  536. uint64_t mmioErrorStatus; // nD00
  537. uint64_t mmioFirstErrorStatus; // nD08
  538. uint64_t mmioErrorLog0; // nD40
  539. uint64_t mmioErrorLog1; // nD48
  540. uint64_t dma0ErrorStatus; // nD80
  541. uint64_t dma0FirstErrorStatus; // nD88
  542. uint64_t dma0ErrorLog0; // nDC0
  543. uint64_t dma0ErrorLog1; // nDC8
  544. uint64_t dma1ErrorStatus; // nE00
  545. uint64_t dma1FirstErrorStatus; // nE08
  546. uint64_t dma1ErrorLog0; // nE40
  547. uint64_t dma1ErrorLog1; // nE48
  548. uint64_t pestA[OPAL_P7IOC_NUM_PEST_REGS];
  549. uint64_t pestB[OPAL_P7IOC_NUM_PEST_REGS];
  550. };
  551. struct OpalIoPhb3ErrorData {
  552. struct OpalIoPhbErrorCommon common;
  553. uint32_t brdgCtl;
  554. /* PHB3 UTL regs */
  555. uint32_t portStatusReg;
  556. uint32_t rootCmplxStatus;
  557. uint32_t busAgentStatus;
  558. /* PHB3 cfg regs */
  559. uint32_t deviceStatus;
  560. uint32_t slotStatus;
  561. uint32_t linkStatus;
  562. uint32_t devCmdStatus;
  563. uint32_t devSecStatus;
  564. /* cfg AER regs */
  565. uint32_t rootErrorStatus;
  566. uint32_t uncorrErrorStatus;
  567. uint32_t corrErrorStatus;
  568. uint32_t tlpHdr1;
  569. uint32_t tlpHdr2;
  570. uint32_t tlpHdr3;
  571. uint32_t tlpHdr4;
  572. uint32_t sourceId;
  573. uint32_t rsv3;
  574. /* Record data about the call to allocate a buffer */
  575. uint64_t errorClass;
  576. uint64_t correlator;
  577. uint64_t nFir; /* 000 */
  578. uint64_t nFirMask; /* 003 */
  579. uint64_t nFirWOF; /* 008 */
  580. /* PHB3 MMIO Error Regs */
  581. uint64_t phbPlssr; /* 120 */
  582. uint64_t phbCsr; /* 110 */
  583. uint64_t lemFir; /* C00 */
  584. uint64_t lemErrorMask; /* C18 */
  585. uint64_t lemWOF; /* C40 */
  586. uint64_t phbErrorStatus; /* C80 */
  587. uint64_t phbFirstErrorStatus; /* C88 */
  588. uint64_t phbErrorLog0; /* CC0 */
  589. uint64_t phbErrorLog1; /* CC8 */
  590. uint64_t mmioErrorStatus; /* D00 */
  591. uint64_t mmioFirstErrorStatus; /* D08 */
  592. uint64_t mmioErrorLog0; /* D40 */
  593. uint64_t mmioErrorLog1; /* D48 */
  594. uint64_t dma0ErrorStatus; /* D80 */
  595. uint64_t dma0FirstErrorStatus; /* D88 */
  596. uint64_t dma0ErrorLog0; /* DC0 */
  597. uint64_t dma0ErrorLog1; /* DC8 */
  598. uint64_t dma1ErrorStatus; /* E00 */
  599. uint64_t dma1FirstErrorStatus; /* E08 */
  600. uint64_t dma1ErrorLog0; /* E40 */
  601. uint64_t dma1ErrorLog1; /* E48 */
  602. uint64_t pestA[OPAL_PHB3_NUM_PEST_REGS];
  603. uint64_t pestB[OPAL_PHB3_NUM_PEST_REGS];
  604. };
  605. typedef struct oppanel_line {
  606. const char * line;
  607. uint64_t line_len;
  608. } oppanel_line_t;
  609. /* /sys/firmware/opal */
  610. extern struct kobject *opal_kobj;
  611. /* API functions */
  612. int64_t opal_console_write(int64_t term_number, __be64 *length,
  613. const uint8_t *buffer);
  614. int64_t opal_console_read(int64_t term_number, __be64 *length,
  615. uint8_t *buffer);
  616. int64_t opal_console_write_buffer_space(int64_t term_number,
  617. __be64 *length);
  618. int64_t opal_rtc_read(__be32 *year_month_day,
  619. __be64 *hour_minute_second_millisecond);
  620. int64_t opal_rtc_write(uint32_t year_month_day,
  621. uint64_t hour_minute_second_millisecond);
  622. int64_t opal_cec_power_down(uint64_t request);
  623. int64_t opal_cec_reboot(void);
  624. int64_t opal_read_nvram(uint64_t buffer, uint64_t size, uint64_t offset);
  625. int64_t opal_write_nvram(uint64_t buffer, uint64_t size, uint64_t offset);
  626. int64_t opal_handle_interrupt(uint64_t isn, __be64 *outstanding_event_mask);
  627. int64_t opal_poll_events(__be64 *outstanding_event_mask);
  628. int64_t opal_pci_set_hub_tce_memory(uint64_t hub_id, uint64_t tce_mem_addr,
  629. uint64_t tce_mem_size);
  630. int64_t opal_pci_set_phb_tce_memory(uint64_t phb_id, uint64_t tce_mem_addr,
  631. uint64_t tce_mem_size);
  632. int64_t opal_pci_config_read_byte(uint64_t phb_id, uint64_t bus_dev_func,
  633. uint64_t offset, uint8_t *data);
  634. int64_t opal_pci_config_read_half_word(uint64_t phb_id, uint64_t bus_dev_func,
  635. uint64_t offset, __be16 *data);
  636. int64_t opal_pci_config_read_word(uint64_t phb_id, uint64_t bus_dev_func,
  637. uint64_t offset, __be32 *data);
  638. int64_t opal_pci_config_write_byte(uint64_t phb_id, uint64_t bus_dev_func,
  639. uint64_t offset, uint8_t data);
  640. int64_t opal_pci_config_write_half_word(uint64_t phb_id, uint64_t bus_dev_func,
  641. uint64_t offset, uint16_t data);
  642. int64_t opal_pci_config_write_word(uint64_t phb_id, uint64_t bus_dev_func,
  643. uint64_t offset, uint32_t data);
  644. int64_t opal_set_xive(uint32_t isn, uint16_t server, uint8_t priority);
  645. int64_t opal_get_xive(uint32_t isn, __be16 *server, uint8_t *priority);
  646. int64_t opal_register_exception_handler(uint64_t opal_exception,
  647. uint64_t handler_address,
  648. uint64_t glue_cache_line);
  649. int64_t opal_pci_eeh_freeze_status(uint64_t phb_id, uint64_t pe_number,
  650. uint8_t *freeze_state,
  651. __be16 *pci_error_type,
  652. __be64 *phb_status);
  653. int64_t opal_pci_eeh_freeze_clear(uint64_t phb_id, uint64_t pe_number,
  654. uint64_t eeh_action_token);
  655. int64_t opal_pci_shpc(uint64_t phb_id, uint64_t shpc_action, uint8_t *state);
  656. int64_t opal_pci_phb_mmio_enable(uint64_t phb_id, uint16_t window_type,
  657. uint16_t window_num, uint16_t enable);
  658. int64_t opal_pci_set_phb_mem_window(uint64_t phb_id, uint16_t window_type,
  659. uint16_t window_num,
  660. uint64_t starting_real_address,
  661. uint64_t starting_pci_address,
  662. uint16_t segment_size);
  663. int64_t opal_pci_map_pe_mmio_window(uint64_t phb_id, uint16_t pe_number,
  664. uint16_t window_type, uint16_t window_num,
  665. uint16_t segment_num);
  666. int64_t opal_pci_set_phb_table_memory(uint64_t phb_id, uint64_t rtt_addr,
  667. uint64_t ivt_addr, uint64_t ivt_len,
  668. uint64_t reject_array_addr,
  669. uint64_t peltv_addr);
  670. int64_t opal_pci_set_pe(uint64_t phb_id, uint64_t pe_number, uint64_t bus_dev_func,
  671. uint8_t bus_compare, uint8_t dev_compare, uint8_t func_compare,
  672. uint8_t pe_action);
  673. int64_t opal_pci_set_peltv(uint64_t phb_id, uint32_t parent_pe, uint32_t child_pe,
  674. uint8_t state);
  675. int64_t opal_pci_set_mve(uint64_t phb_id, uint32_t mve_number, uint32_t pe_number);
  676. int64_t opal_pci_set_mve_enable(uint64_t phb_id, uint32_t mve_number,
  677. uint32_t state);
  678. int64_t opal_pci_get_xive_reissue(uint64_t phb_id, uint32_t xive_number,
  679. uint8_t *p_bit, uint8_t *q_bit);
  680. int64_t opal_pci_set_xive_reissue(uint64_t phb_id, uint32_t xive_number,
  681. uint8_t p_bit, uint8_t q_bit);
  682. int64_t opal_pci_msi_eoi(uint64_t phb_id, uint32_t hw_irq);
  683. int64_t opal_pci_set_xive_pe(uint64_t phb_id, uint32_t pe_number,
  684. uint32_t xive_num);
  685. int64_t opal_get_xive_source(uint64_t phb_id, uint32_t xive_num,
  686. __be32 *interrupt_source_number);
  687. int64_t opal_get_msi_32(uint64_t phb_id, uint32_t mve_number, uint32_t xive_num,
  688. uint8_t msi_range, __be32 *msi_address,
  689. __be32 *message_data);
  690. int64_t opal_get_msi_64(uint64_t phb_id, uint32_t mve_number,
  691. uint32_t xive_num, uint8_t msi_range,
  692. __be64 *msi_address, __be32 *message_data);
  693. int64_t opal_start_cpu(uint64_t thread_number, uint64_t start_address);
  694. int64_t opal_query_cpu_status(uint64_t thread_number, uint8_t *thread_status);
  695. int64_t opal_write_oppanel(oppanel_line_t *lines, uint64_t num_lines);
  696. int64_t opal_pci_map_pe_dma_window(uint64_t phb_id, uint16_t pe_number, uint16_t window_id,
  697. uint16_t tce_levels, uint64_t tce_table_addr,
  698. uint64_t tce_table_size, uint64_t tce_page_size);
  699. int64_t opal_pci_map_pe_dma_window_real(uint64_t phb_id, uint16_t pe_number,
  700. uint16_t dma_window_number, uint64_t pci_start_addr,
  701. uint64_t pci_mem_size);
  702. int64_t opal_pci_reset(uint64_t phb_id, uint8_t reset_scope, uint8_t assert_state);
  703. int64_t opal_pci_get_hub_diag_data(uint64_t hub_id, void *diag_buffer,
  704. uint64_t diag_buffer_len);
  705. int64_t opal_pci_get_phb_diag_data(uint64_t phb_id, void *diag_buffer,
  706. uint64_t diag_buffer_len);
  707. int64_t opal_pci_get_phb_diag_data2(uint64_t phb_id, void *diag_buffer,
  708. uint64_t diag_buffer_len);
  709. int64_t opal_pci_fence_phb(uint64_t phb_id);
  710. int64_t opal_pci_reinit(uint64_t phb_id, uint64_t reinit_scope, uint64_t data);
  711. int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action);
  712. int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action);
  713. int64_t opal_get_epow_status(__be64 *status);
  714. int64_t opal_set_system_attention_led(uint8_t led_action);
  715. int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe,
  716. uint16_t *pci_error_type, uint16_t *severity);
  717. int64_t opal_pci_poll(uint64_t phb_id);
  718. int64_t opal_return_cpu(void);
  719. int64_t opal_xscom_read(uint32_t gcid, uint64_t pcb_addr, __be64 *val);
  720. int64_t opal_xscom_write(uint32_t gcid, uint64_t pcb_addr, uint64_t val);
  721. int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type,
  722. uint32_t addr, uint32_t data, uint32_t sz);
  723. int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type,
  724. uint32_t addr, __be32 *data, uint32_t sz);
  725. int64_t opal_validate_flash(uint64_t buffer, uint32_t *size, uint32_t *result);
  726. int64_t opal_manage_flash(uint8_t op);
  727. int64_t opal_update_flash(uint64_t blk_list);
  728. int64_t opal_get_msg(uint64_t buffer, size_t size);
  729. int64_t opal_check_completion(uint64_t buffer, size_t size, uint64_t token);
  730. int64_t opal_sync_host_reboot(void);
  731. /* Internal functions */
  732. extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data);
  733. extern int opal_get_chars(uint32_t vtermno, char *buf, int count);
  734. extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len);
  735. extern void hvc_opal_init_early(void);
  736. /* Internal functions */
  737. extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
  738. int depth, void *data);
  739. extern int opal_notifier_register(struct notifier_block *nb);
  740. extern int opal_message_notifier_register(enum OpalMessageType msg_type,
  741. struct notifier_block *nb);
  742. extern void opal_notifier_enable(void);
  743. extern void opal_notifier_disable(void);
  744. extern void opal_notifier_update_evt(uint64_t evt_mask, uint64_t evt_val);
  745. extern int opal_get_chars(uint32_t vtermno, char *buf, int count);
  746. extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len);
  747. extern void hvc_opal_init_early(void);
  748. struct rtc_time;
  749. extern int opal_set_rtc_time(struct rtc_time *tm);
  750. extern void opal_get_rtc_time(struct rtc_time *tm);
  751. extern unsigned long opal_get_boot_time(void);
  752. extern void opal_nvram_init(void);
  753. extern void opal_flash_init(void);
  754. extern int opal_machine_check(struct pt_regs *regs);
  755. extern void opal_shutdown(void);
  756. extern void opal_lpc_init(void);
  757. #endif /* __ASSEMBLY__ */
  758. #endif /* __OPAL_H */