icnss2.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _ICNSS_WLAN_H_
  6. #define _ICNSS_WLAN_H_
  7. #include <linux/interrupt.h>
  8. #include <linux/device.h>
  9. #define ICNSS_MAX_IRQ_REGISTRATIONS 12
  10. #define IWCN_MAX_IRQ_REGISTRATIONS 32
  11. #define ICNSS_MAX_TIMESTAMP_LEN 32
  12. #define ICNSS_WLFW_MAX_BUILD_ID_LEN 128
  13. #ifndef ICNSS_API_WITH_DEV
  14. #define ICNSS_API_WITH_DEV
  15. #endif
  16. #define DEVICE_NAME_MAX 10
  17. enum icnss_uevent {
  18. ICNSS_UEVENT_FW_CRASHED,
  19. ICNSS_UEVENT_FW_DOWN,
  20. ICNSS_UEVENT_HANG_DATA,
  21. ICNSS_UEVENT_SMMU_FAULT,
  22. };
  23. enum icnss_device_config {
  24. ICNSS_IPA_DISABLED,
  25. };
  26. struct icnss_uevent_hang_data {
  27. void *hang_event_data;
  28. uint16_t hang_event_data_len;
  29. };
  30. struct icnss_uevent_fw_down_data {
  31. bool crashed;
  32. };
  33. struct icnss_uevent_data {
  34. enum icnss_uevent uevent;
  35. void *data;
  36. };
  37. /* Device information like supported device ids, etc*/
  38. struct device_info {
  39. char name[DEVICE_NAME_MAX];
  40. uint16_t device_id;
  41. };
  42. struct icnss_driver_ops {
  43. char *name;
  44. struct device_info *dev_info;
  45. unsigned long drv_state;
  46. struct device_driver driver;
  47. int (*probe)(struct device *dev);
  48. void (*remove)(struct device *dev);
  49. void (*shutdown)(struct device *dev);
  50. int (*reinit)(struct device *dev);
  51. void (*crash_shutdown)(void *pdev);
  52. int (*pm_suspend)(struct device *dev);
  53. int (*pm_resume)(struct device *dev);
  54. int (*suspend_noirq)(struct device *dev);
  55. int (*resume_noirq)(struct device *dev);
  56. int (*runtime_suspend)(struct device *dev);
  57. int (*runtime_resume)(struct device *dev);
  58. int (*uevent)(struct device *dev, struct icnss_uevent_data *uevent);
  59. int (*idle_shutdown)(struct device *dev);
  60. int (*idle_restart)(struct device *dev);
  61. int (*set_therm_cdev_state)(struct device *dev,
  62. unsigned long thermal_state,
  63. int tcdev_id);
  64. };
  65. struct ce_tgt_pipe_cfg {
  66. u32 pipe_num;
  67. u32 pipe_dir;
  68. u32 nentries;
  69. u32 nbytes_max;
  70. u32 flags;
  71. u32 reserved;
  72. };
  73. struct ce_svc_pipe_cfg {
  74. u32 service_id;
  75. u32 pipe_dir;
  76. u32 pipe_num;
  77. };
  78. struct icnss_shadow_reg_cfg {
  79. u16 ce_id;
  80. u16 reg_offset;
  81. };
  82. struct icnss_shadow_reg_v2_cfg {
  83. u32 addr;
  84. };
  85. struct icnss_rri_over_ddr_cfg {
  86. u32 base_addr_low;
  87. u32 base_addr_high;
  88. };
  89. /* CE configuration to target */
  90. struct icnss_wlan_enable_cfg {
  91. u32 num_ce_tgt_cfg;
  92. struct ce_tgt_pipe_cfg *ce_tgt_cfg;
  93. u32 num_ce_svc_pipe_cfg;
  94. struct ce_svc_pipe_cfg *ce_svc_cfg;
  95. u32 num_shadow_reg_cfg;
  96. struct icnss_shadow_reg_cfg *shadow_reg_cfg;
  97. u32 num_shadow_reg_v2_cfg;
  98. struct icnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
  99. bool rri_over_ddr_cfg_valid;
  100. struct icnss_rri_over_ddr_cfg rri_over_ddr_cfg;
  101. };
  102. /* driver modes */
  103. enum icnss_driver_mode {
  104. ICNSS_MISSION,
  105. ICNSS_FTM,
  106. ICNSS_EPPING,
  107. ICNSS_WALTEST,
  108. ICNSS_OFF,
  109. ICNSS_CCPM,
  110. ICNSS_QVIT,
  111. ICNSS_CALIBRATION,
  112. };
  113. struct icnss_soc_info {
  114. void __iomem *v_addr;
  115. phys_addr_t p_addr;
  116. uint32_t chip_id;
  117. uint32_t chip_family;
  118. uint32_t board_id;
  119. uint32_t soc_id;
  120. uint32_t fw_version;
  121. char fw_build_timestamp[ICNSS_MAX_TIMESTAMP_LEN + 1];
  122. char fw_build_id[ICNSS_WLFW_MAX_BUILD_ID_LEN + 1];
  123. };
  124. #define icnss_register_driver(ops) \
  125. __icnss_register_driver(ops, THIS_MODULE, KBUILD_MODNAME)
  126. extern int __icnss_register_driver(struct icnss_driver_ops *ops,
  127. struct module *owner, const char *mod_name);
  128. extern int icnss_unregister_driver(struct icnss_driver_ops *ops);
  129. extern int icnss_wlan_enable(struct device *dev,
  130. struct icnss_wlan_enable_cfg *config,
  131. enum icnss_driver_mode mode,
  132. const char *host_version);
  133. extern int icnss_wlan_disable(struct device *dev, enum icnss_driver_mode mode);
  134. extern void icnss_enable_irq(struct device *dev, unsigned int ce_id);
  135. extern void icnss_disable_irq(struct device *dev, unsigned int ce_id);
  136. extern int icnss_get_soc_info(struct device *dev, struct icnss_soc_info *info);
  137. extern int icnss_ce_free_irq(struct device *dev, unsigned int ce_id, void *ctx);
  138. extern int icnss_ce_request_irq(struct device *dev, unsigned int ce_id,
  139. irqreturn_t (*handler)(int, void *),
  140. unsigned long flags, const char *name, void *ctx);
  141. extern int icnss_get_ce_id(struct device *dev, int irq);
  142. extern int icnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode);
  143. extern int icnss_athdiag_read(struct device *dev, uint32_t offset,
  144. uint32_t mem_type, uint32_t data_len,
  145. uint8_t *output);
  146. extern int icnss_athdiag_write(struct device *dev, uint32_t offset,
  147. uint32_t mem_type, uint32_t data_len,
  148. uint8_t *input);
  149. extern int icnss_get_irq(struct device *dev, int ce_id);
  150. extern int icnss_power_on(struct device *dev);
  151. extern int icnss_power_off(struct device *dev);
  152. extern struct dma_iommu_mapping *icnss_smmu_get_mapping(struct device *dev);
  153. extern struct iommu_domain *icnss_smmu_get_domain(struct device *dev);
  154. extern int icnss_smmu_map(struct device *dev, phys_addr_t paddr,
  155. uint32_t *iova_addr, size_t size);
  156. extern int icnss_smmu_unmap(struct device *dev,
  157. uint32_t iova_addr, size_t size);
  158. extern unsigned int icnss_socinfo_get_serial_number(struct device *dev);
  159. extern bool icnss_is_qmi_disable(struct device *dev);
  160. extern bool icnss_is_fw_ready(void);
  161. extern bool icnss_is_fw_down(void);
  162. extern bool icnss_is_rejuvenate(void);
  163. extern int icnss_trigger_recovery(struct device *dev);
  164. extern void icnss_block_shutdown(bool status);
  165. extern bool icnss_is_pdr(void);
  166. extern int icnss_idle_restart(struct device *dev);
  167. extern int icnss_idle_shutdown(struct device *dev);
  168. extern int icnss_get_user_msi_assignment(struct device *dev, char *user_name,
  169. int *num_vectors, u32 *user_base_data,
  170. u32 *base_vector);
  171. extern int icnss_get_msi_irq(struct device *dev, unsigned int vector);
  172. extern void icnss_get_msi_address(struct device *dev, u32 *msi_addr_low,
  173. u32 *msi_addr_high);
  174. extern int icnss_qmi_send(struct device *dev, int type, void *cmd,
  175. int cmd_len, void *cb_ctx,
  176. int (*cb)(void *ctx, void *event, int event_len));
  177. extern int icnss_force_wake_request(struct device *dev);
  178. extern int icnss_force_wake_release(struct device *dev);
  179. extern int icnss_is_device_awake(struct device *dev);
  180. extern int icnss_thermal_cdev_register(struct device *dev,
  181. unsigned long max_state,
  182. int tcdev_id);
  183. extern void icnss_thermal_cdev_unregister(struct device *dev, int tcdev_id);
  184. extern int icnss_get_curr_therm_cdev_state(struct device *dev,
  185. unsigned long *thermal_state,
  186. int tcdev_id);
  187. extern int icnss_exit_power_save(struct device *dev);
  188. extern int icnss_prevent_l1(struct device *dev);
  189. extern void icnss_allow_l1(struct device *dev);
  190. extern int icnss_get_mhi_state(struct device *dev);
  191. extern int icnss_is_pci_ep_awake(struct device *dev);
  192. extern unsigned long icnss_get_device_config(void);
  193. #endif /* _ICNSS_WLAN_H_ */