hw-me.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2012-2022, Intel Corporation. All rights reserved.
  4. * Intel Management Engine Interface (Intel MEI) Linux driver
  5. */
  6. #ifndef _MEI_INTERFACE_H_
  7. #define _MEI_INTERFACE_H_
  8. #include <linux/irqreturn.h>
  9. #include <linux/pci.h>
  10. #include <linux/mei.h>
  11. #include "mei_dev.h"
  12. #include "client.h"
  13. /*
  14. * mei_cfg - mei device configuration
  15. *
  16. * @fw_status: FW status
  17. * @quirk_probe: device exclusion quirk
  18. * @kind: MEI head kind
  19. * @dma_size: device DMA buffers size
  20. * @fw_ver_supported: is fw version retrievable from FW
  21. * @hw_trc_supported: does the hw support trc register
  22. */
  23. struct mei_cfg {
  24. const struct mei_fw_status fw_status;
  25. bool (*quirk_probe)(const struct pci_dev *pdev);
  26. const char *kind;
  27. size_t dma_size[DMA_DSCR_NUM];
  28. u32 fw_ver_supported:1;
  29. u32 hw_trc_supported:1;
  30. };
  31. #define MEI_PCI_DEVICE(dev, cfg) \
  32. .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \
  33. .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
  34. .driver_data = (kernel_ulong_t)(cfg),
  35. #define MEI_ME_RPM_TIMEOUT 500 /* ms */
  36. /**
  37. * struct mei_me_hw - me hw specific data
  38. *
  39. * @cfg: per device generation config and ops
  40. * @mem_addr: io memory address
  41. * @irq: irq number
  42. * @pg_state: power gating state
  43. * @d0i3_supported: di03 support
  44. * @hbuf_depth: depth of hardware host/write buffer in slots
  45. * @read_fws: read FW status register handler
  46. * @polling_thread: interrupt polling thread
  47. * @wait_active: the polling thread activity wait queue
  48. * @is_active: the device is active
  49. */
  50. struct mei_me_hw {
  51. const struct mei_cfg *cfg;
  52. void __iomem *mem_addr;
  53. int irq;
  54. enum mei_pg_state pg_state;
  55. bool d0i3_supported;
  56. u8 hbuf_depth;
  57. int (*read_fws)(const struct mei_device *dev, int where, u32 *val);
  58. /* polling */
  59. struct task_struct *polling_thread;
  60. wait_queue_head_t wait_active;
  61. bool is_active;
  62. };
  63. #define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw)
  64. static inline bool mei_me_hw_use_polling(const struct mei_me_hw *hw)
  65. {
  66. return hw->irq < 0;
  67. }
  68. /**
  69. * enum mei_cfg_idx - indices to platform specific configurations.
  70. *
  71. * Note: has to be synchronized with mei_cfg_list[]
  72. *
  73. * @MEI_ME_UNDEF_CFG: Lower sentinel.
  74. * @MEI_ME_ICH_CFG: I/O Controller Hub legacy devices.
  75. * @MEI_ME_ICH10_CFG: I/O Controller Hub platforms Gen10
  76. * @MEI_ME_PCH6_CFG: Platform Controller Hub platforms (Gen6).
  77. * @MEI_ME_PCH7_CFG: Platform Controller Hub platforms (Gen7).
  78. * @MEI_ME_PCH_CPT_PBG_CFG:Platform Controller Hub workstations
  79. * with quirk for Node Manager exclusion.
  80. * @MEI_ME_PCH8_CFG: Platform Controller Hub Gen8 and newer
  81. * client platforms.
  82. * @MEI_ME_PCH8_ITOUCH_CFG:Platform Controller Hub Gen8 and newer
  83. * client platforms (iTouch).
  84. * @MEI_ME_PCH8_SPS_4_CFG: Platform Controller Hub Gen8 and newer
  85. * servers platforms with quirk for
  86. * SPS firmware exclusion.
  87. * @MEI_ME_PCH12_CFG: Platform Controller Hub Gen12 and newer
  88. * @MEI_ME_PCH12_SPS_4_CFG:Platform Controller Hub Gen12 up to 4.0
  89. * servers platforms with quirk for
  90. * SPS firmware exclusion.
  91. * @MEI_ME_PCH12_SPS_CFG: Platform Controller Hub Gen12 5.0 and newer
  92. * servers platforms with quirk for
  93. * SPS firmware exclusion.
  94. * @MEI_ME_PCH15_CFG: Platform Controller Hub Gen15 and newer
  95. * @MEI_ME_PCH15_SPS_CFG: Platform Controller Hub Gen15 and newer
  96. * servers platforms with quirk for
  97. * SPS firmware exclusion.
  98. * @MEI_ME_NUM_CFG: Upper Sentinel.
  99. */
  100. enum mei_cfg_idx {
  101. MEI_ME_UNDEF_CFG,
  102. MEI_ME_ICH_CFG,
  103. MEI_ME_ICH10_CFG,
  104. MEI_ME_PCH6_CFG,
  105. MEI_ME_PCH7_CFG,
  106. MEI_ME_PCH_CPT_PBG_CFG,
  107. MEI_ME_PCH8_CFG,
  108. MEI_ME_PCH8_ITOUCH_CFG,
  109. MEI_ME_PCH8_SPS_4_CFG,
  110. MEI_ME_PCH12_CFG,
  111. MEI_ME_PCH12_SPS_4_CFG,
  112. MEI_ME_PCH12_SPS_CFG,
  113. MEI_ME_PCH12_SPS_ITOUCH_CFG,
  114. MEI_ME_PCH15_CFG,
  115. MEI_ME_PCH15_SPS_CFG,
  116. MEI_ME_GSC_CFG,
  117. MEI_ME_GSCFI_CFG,
  118. MEI_ME_NUM_CFG,
  119. };
  120. const struct mei_cfg *mei_me_get_cfg(kernel_ulong_t idx);
  121. struct mei_device *mei_me_dev_init(struct device *parent,
  122. const struct mei_cfg *cfg, bool slow_fw);
  123. int mei_me_pg_enter_sync(struct mei_device *dev);
  124. int mei_me_pg_exit_sync(struct mei_device *dev);
  125. irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id);
  126. irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id);
  127. int mei_me_polling_thread(void *_dev);
  128. #endif /* _MEI_INTERFACE_H_ */