ipa.h 5.6 KB

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