icnss2.h 6.4 KB

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