ipa.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2018-2022 Linaro Ltd.
  4. */
  5. #ifndef _IPA_H_
  6. #define _IPA_H_
  7. #include <linux/types.h>
  8. #include <linux/device.h>
  9. #include <linux/notifier.h>
  10. #include <linux/pm_wakeup.h>
  11. #include "ipa_version.h"
  12. #include "gsi.h"
  13. #include "ipa_mem.h"
  14. #include "ipa_qmi.h"
  15. #include "ipa_endpoint.h"
  16. #include "ipa_interrupt.h"
  17. struct clk;
  18. struct icc_path;
  19. struct net_device;
  20. struct platform_device;
  21. struct ipa_power;
  22. struct ipa_smp2p;
  23. struct ipa_interrupt;
  24. /**
  25. * struct ipa - IPA information
  26. * @gsi: Embedded GSI structure
  27. * @version: IPA hardware version
  28. * @pdev: Platform device
  29. * @completion: Used to signal pipeline clear transfer complete
  30. * @nb: Notifier block used for remoteproc SSR
  31. * @notifier: Remoteproc SSR notifier
  32. * @smp2p: SMP2P information
  33. * @power: IPA power information
  34. * @table_addr: DMA address of filter/route table content
  35. * @table_virt: Virtual address of filter/route table content
  36. * @interrupt: IPA Interrupt information
  37. * @uc_powered: true if power is active by proxy for microcontroller
  38. * @uc_loaded: true after microcontroller has reported it's ready
  39. * @reg_addr: DMA address used for IPA register access
  40. * @reg_virt: Virtual address used for IPA register access
  41. * @regs: IPA register definitions
  42. * @mem_addr: DMA address of IPA-local memory space
  43. * @mem_virt: Virtual address of IPA-local memory space
  44. * @mem_offset: Offset from @mem_virt used for access to IPA memory
  45. * @mem_size: Total size (bytes) of memory at @mem_virt
  46. * @mem_count: Number of entries in the mem array
  47. * @mem: Array of IPA-local memory region descriptors
  48. * @imem_iova: I/O virtual address of IPA region in IMEM
  49. * @imem_size: Size of IMEM region
  50. * @smem_iova: I/O virtual address of IPA region in SMEM
  51. * @smem_size: Size of SMEM region
  52. * @zero_addr: DMA address of preallocated zero-filled memory
  53. * @zero_virt: Virtual address of preallocated zero-filled memory
  54. * @zero_size: Size (bytes) of preallocated zero-filled memory
  55. * @available: Bit mask indicating endpoints hardware supports
  56. * @filter_map: Bit mask indicating endpoints that support filtering
  57. * @initialized: Bit mask indicating endpoints initialized
  58. * @set_up: Bit mask indicating endpoints set up
  59. * @enabled: Bit mask indicating endpoints enabled
  60. * @modem_tx_count: Number of defined modem TX endoints
  61. * @endpoint: Array of endpoint information
  62. * @channel_map: Mapping of GSI channel to IPA endpoint
  63. * @name_map: Mapping of IPA endpoint name to IPA endpoint
  64. * @setup_complete: Flag indicating whether setup stage has completed
  65. * @modem_state: State of modem (stopped, running)
  66. * @modem_netdev: Network device structure used for modem
  67. * @qmi: QMI information
  68. */
  69. struct ipa {
  70. struct gsi gsi;
  71. enum ipa_version version;
  72. struct platform_device *pdev;
  73. struct completion completion;
  74. struct notifier_block nb;
  75. void *notifier;
  76. struct ipa_smp2p *smp2p;
  77. struct ipa_power *power;
  78. dma_addr_t table_addr;
  79. __le64 *table_virt;
  80. struct ipa_interrupt *interrupt;
  81. bool uc_powered;
  82. bool uc_loaded;
  83. dma_addr_t reg_addr;
  84. void __iomem *reg_virt;
  85. const struct ipa_regs *regs;
  86. dma_addr_t mem_addr;
  87. void *mem_virt;
  88. u32 mem_offset;
  89. u32 mem_size;
  90. u32 mem_count;
  91. const struct ipa_mem *mem;
  92. unsigned long imem_iova;
  93. size_t imem_size;
  94. unsigned long smem_iova;
  95. size_t smem_size;
  96. dma_addr_t zero_addr;
  97. void *zero_virt;
  98. size_t zero_size;
  99. /* Bit masks indicating endpoint state */
  100. u32 available; /* supported by hardware */
  101. u32 filter_map;
  102. u32 initialized;
  103. u32 set_up;
  104. u32 enabled;
  105. u32 modem_tx_count;
  106. struct ipa_endpoint endpoint[IPA_ENDPOINT_MAX];
  107. struct ipa_endpoint *channel_map[GSI_CHANNEL_COUNT_MAX];
  108. struct ipa_endpoint *name_map[IPA_ENDPOINT_COUNT];
  109. bool setup_complete;
  110. atomic_t modem_state; /* enum ipa_modem_state */
  111. struct net_device *modem_netdev;
  112. struct ipa_qmi qmi;
  113. };
  114. /**
  115. * ipa_setup() - Perform IPA setup
  116. * @ipa: IPA pointer
  117. *
  118. * IPA initialization is broken into stages: init; config; and setup.
  119. * (These have inverses exit, deconfig, and teardown.)
  120. *
  121. * Activities performed at the init stage can be done without requiring
  122. * any access to IPA hardware. Activities performed at the config stage
  123. * require IPA power, because they involve access to IPA registers.
  124. * The setup stage is performed only after the GSI hardware is ready
  125. * (more on this below). The setup stage allows the AP to perform
  126. * more complex initialization by issuing "immediate commands" using
  127. * a special interface to the IPA.
  128. *
  129. * This function, @ipa_setup(), starts the setup stage.
  130. *
  131. * In order for the GSI hardware to be functional it needs firmware to be
  132. * loaded (in addition to some other low-level initialization). This early
  133. * GSI initialization can be done either by Trust Zone on the AP or by the
  134. * modem.
  135. *
  136. * If it's done by Trust Zone, the AP loads the GSI firmware and supplies
  137. * it to Trust Zone to verify and install. When this completes, if
  138. * verification was successful, the GSI layer is ready and ipa_setup()
  139. * implements the setup phase of initialization.
  140. *
  141. * If the modem performs early GSI initialization, the AP needs to know
  142. * when this has occurred. An SMP2P interrupt is used for this purpose,
  143. * and receipt of that interrupt triggers the call to ipa_setup().
  144. */
  145. int ipa_setup(struct ipa *ipa);
  146. #endif /* _IPA_H_ */