mhi_qcom.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */
  3. #ifndef _MHI_QCOM_
  4. #define _MHI_QCOM_
  5. #define MHI_PCIE_VENDOR_ID (0x17cb)
  6. #define MHI_PCIE_DEBUG_ID (0xffff)
  7. /* runtime suspend timer */
  8. #define MHI_RPM_SUSPEND_TMR_MS (250)
  9. #define MHI_PCI_BAR_NUM (0)
  10. #define MHI_MAX_SFR_LEN (256)
  11. #define PCI_INVALID_READ(val) ((val) == U32_MAX)
  12. #define MHI_IPC_LOG_PAGES (100)
  13. #define MHI_CNTRL_LOG(fmt, ...) do { \
  14. struct mhi_qcom_priv *mhi_priv = \
  15. mhi_controller_get_privdata(mhi_cntrl); \
  16. ipc_log_string(mhi_priv->cntrl_ipc_log, "[I][%s] " fmt, __func__, \
  17. ##__VA_ARGS__); \
  18. } while (0)
  19. #define MHI_CNTRL_ERR(fmt, ...) do { \
  20. struct mhi_qcom_priv *mhi_priv = \
  21. mhi_controller_get_privdata(mhi_cntrl); \
  22. pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \
  23. ipc_log_string(mhi_priv->cntrl_ipc_log, "[E][%s] " fmt, __func__, \
  24. ##__VA_ARGS__); \
  25. } while (0)
  26. extern const char * const mhi_ee_str[MHI_EE_MAX];
  27. #define TO_MHI_EXEC_STR(ee) (ee >= MHI_EE_MAX ? "INVALID_EE" : mhi_ee_str[ee])
  28. enum mhi_debug_mode {
  29. MHI_DEBUG_OFF,
  30. MHI_DEBUG_ON, /* delayed power up */
  31. MHI_DEBUG_NO_LPM, /* delayed power up, low power modes disabled */
  32. MHI_DEBUG_MODE_MAX,
  33. };
  34. extern const char * const mhi_debug_mode_str[MHI_DEBUG_MODE_MAX];
  35. #define TO_MHI_DEBUG_MODE_STR(mode) \
  36. (mode >= MHI_DEBUG_MODE_MAX ? "Invalid" : mhi_debug_mode_str[mode])
  37. enum mhi_suspend_mode {
  38. MHI_ACTIVE_STATE,
  39. MHI_DEFAULT_SUSPEND,
  40. MHI_FAST_LINK_OFF,
  41. MHI_FAST_LINK_ON,
  42. MHI_SUSPEND_MODE_MAX,
  43. };
  44. extern const char * const mhi_suspend_mode_str[MHI_SUSPEND_MODE_MAX];
  45. #define TO_MHI_SUSPEND_MODE_STR(mode) \
  46. (mode >= MHI_SUSPEND_MODE_MAX ? "Invalid" : mhi_suspend_mode_str[mode])
  47. /**
  48. * struct mhi_pci_dev_info - MHI PCI device specific information
  49. * @config: MHI controller configuration
  50. * @device_id: PCI device ID
  51. * @name: name of the PCI module
  52. * @fw_image: firmware path (if any)
  53. * @edl_image: emergency download mode firmware path (if any)
  54. * @bar_num: PCI base address register to use for MHI MMIO register space
  55. * @dma_data_width: DMA transfer word size (32 or 64 bits)
  56. */
  57. struct mhi_pci_dev_info {
  58. const struct mhi_controller_config *config;
  59. unsigned int device_id;
  60. const char *name;
  61. const char *fw_image;
  62. const char *edl_image;
  63. unsigned int bar_num;
  64. unsigned int dma_data_width;
  65. bool allow_m1;
  66. bool skip_forced_suspend;
  67. bool sfr_support;
  68. bool timesync;
  69. bool drv_support;
  70. };
  71. struct mhi_qcom_priv {
  72. const struct mhi_pci_dev_info *dev_info;
  73. struct work_struct fatal_worker;
  74. void *cntrl_ipc_log;
  75. void *arch_info;
  76. bool powered_on;
  77. bool mdm_state;
  78. bool disable_pci_lpm;
  79. enum mhi_suspend_mode suspend_mode;
  80. bool driver_remove;
  81. };
  82. void mhi_deinit_pci_dev(struct pci_dev *pci_dev,
  83. const struct mhi_pci_dev_info *dev_info);
  84. int mhi_qcom_pci_probe(struct pci_dev *pci_dev,
  85. struct mhi_controller *mhi_cntrl,
  86. struct mhi_qcom_priv *mhi_priv);
  87. #ifdef CONFIG_ARCH_QCOM
  88. int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl);
  89. void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl);
  90. int mhi_arch_link_suspend(struct mhi_controller *mhi_cntrl);
  91. int mhi_arch_link_resume(struct mhi_controller *mhi_cntrl);
  92. void mhi_arch_mission_mode_enter(struct mhi_controller *mhi_cntrl);
  93. u64 mhi_arch_time_get(struct mhi_controller *mhi_cntrl);
  94. int mhi_arch_link_lpm_disable(struct mhi_controller *mhi_cntrl);
  95. int mhi_arch_link_lpm_enable(struct mhi_controller *mhi_cntrl);
  96. #else
  97. static inline int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl)
  98. {
  99. return 0;
  100. }
  101. static inline void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl)
  102. {
  103. }
  104. static inline int mhi_arch_link_suspend(struct mhi_controller *mhi_cntrl)
  105. {
  106. return 0;
  107. }
  108. static inline int mhi_arch_link_resume(struct mhi_controller *mhi_cntrl)
  109. {
  110. return 0;
  111. }
  112. static inline void mhi_arch_mission_mode_enter(struct mhi_controller *mhi_cntrl)
  113. {
  114. }
  115. static inline u64 mhi_arch_time_get(struct mhi_controller *mhi_cntrl)
  116. {
  117. return 0;
  118. }
  119. static inline int mhi_arch_link_lpm_disable(struct mhi_controller *mhi_cntrl)
  120. {
  121. return 0;
  122. }
  123. static inline int mhi_arch_link_lpm_enable(struct mhi_controller *mhi_cntrl)
  124. {
  125. return 0;
  126. }
  127. #endif
  128. #endif /* _MHI_QCOM_ */