cnss.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _NET_CNSS_H_
  13. #define _NET_CNSS_H_
  14. #include <linux/device.h>
  15. #include <linux/skbuff.h>
  16. #include <linux/pci.h>
  17. #include <linux/mmc/sdio_func.h>
  18. #include <linux/interrupt.h>
  19. #ifdef CONFIG_CNSS
  20. #define MAX_FIRMWARE_SIZE (1 * 1024 * 1024)
  21. #define CNSS_MAX_FILE_NAME 20
  22. #define PINCTRL_SLEEP 0
  23. #define PINCTRL_ACTIVE 1
  24. enum cnss_bus_width_type {
  25. CNSS_BUS_WIDTH_NONE,
  26. CNSS_BUS_WIDTH_LOW,
  27. CNSS_BUS_WIDTH_MEDIUM,
  28. CNSS_BUS_WIDTH_HIGH
  29. };
  30. enum cnss_cc_src {
  31. CNSS_SOURCE_CORE,
  32. CNSS_SOURCE_11D,
  33. CNSS_SOURCE_USER
  34. };
  35. /* FW image files */
  36. struct cnss_fw_files {
  37. char image_file[CNSS_MAX_FILE_NAME];
  38. char board_data[CNSS_MAX_FILE_NAME];
  39. char otp_data[CNSS_MAX_FILE_NAME];
  40. char utf_file[CNSS_MAX_FILE_NAME];
  41. char utf_board_data[CNSS_MAX_FILE_NAME];
  42. char epping_file[CNSS_MAX_FILE_NAME];
  43. char evicted_data[CNSS_MAX_FILE_NAME];
  44. };
  45. struct cnss_wlan_runtime_ops {
  46. int (*runtime_suspend)(struct pci_dev *pdev);
  47. int (*runtime_resume)(struct pci_dev *pdev);
  48. };
  49. struct cnss_wlan_driver {
  50. char *name;
  51. int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id);
  52. void (*remove)(struct pci_dev *pdev);
  53. int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id);
  54. void (*shutdown)(struct pci_dev *pdev);
  55. void (*crash_shutdown)(struct pci_dev *pdev);
  56. int (*suspend)(struct pci_dev *pdev, pm_message_t state);
  57. int (*resume)(struct pci_dev *pdev);
  58. void (*modem_status)(struct pci_dev *, int state);
  59. void (*update_status)(struct pci_dev *pdev, uint32_t status);
  60. struct cnss_wlan_runtime_ops *runtime_ops;
  61. const struct pci_device_id *id_table;
  62. };
  63. /*
  64. * codeseg_total_bytes: Total bytes across all the codesegment blocks
  65. * num_codesegs: No of Pages used
  66. * codeseg_size: Size of each segment. Should be power of 2 and multiple of 4K
  67. * codeseg_size_log2: log2(codeseg_size)
  68. * codeseg_busaddr: Physical address of the DMAble memory;4K aligned
  69. */
  70. #define CODESWAP_MAX_CODESEGS 16
  71. struct codeswap_codeseg_info {
  72. u32 codeseg_total_bytes;
  73. u32 num_codesegs;
  74. u32 codeseg_size;
  75. u32 codeseg_size_log2;
  76. void *codeseg_busaddr[CODESWAP_MAX_CODESEGS];
  77. };
  78. struct image_desc_info {
  79. dma_addr_t fw_addr;
  80. u32 fw_size;
  81. dma_addr_t bdata_addr;
  82. u32 bdata_size;
  83. };
  84. /* platform capabilities */
  85. enum cnss_platform_cap_flag {
  86. CNSS_HAS_EXTERNAL_SWREG = 0x01,
  87. CNSS_HAS_UART_ACCESS = 0x02,
  88. };
  89. struct cnss_platform_cap {
  90. u32 cap_flag;
  91. };
  92. /* WLAN driver status */
  93. enum cnss_driver_status {
  94. CNSS_UNINITIALIZED,
  95. CNSS_INITIALIZED,
  96. CNSS_LOAD_UNLOAD
  97. };
  98. enum cnss_runtime_request {
  99. CNSS_PM_RUNTIME_GET,
  100. CNSS_PM_RUNTIME_PUT,
  101. CNSS_PM_RUNTIME_MARK_LAST_BUSY,
  102. CNSS_PM_RUNTIME_RESUME,
  103. CNSS_PM_RUNTIME_PUT_NOIDLE,
  104. CNSS_PM_REQUEST_RESUME,
  105. CNSS_PM_RUNTIME_PUT_AUTO,
  106. CNSS_PM_GET_NORESUME,
  107. };
  108. extern int cnss_get_fw_image(struct image_desc_info *image_desc_info);
  109. extern void cnss_runtime_init(struct device *dev, int auto_delay);
  110. extern void cnss_runtime_exit(struct device *dev);
  111. extern void cnss_wlan_pci_link_down(void);
  112. extern int cnss_pcie_shadow_control(struct pci_dev *dev, bool enable);
  113. extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver);
  114. extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver);
  115. extern int cnss_get_fw_files(struct cnss_fw_files *pfw_files);
  116. extern int cnss_get_fw_files_for_target(struct cnss_fw_files *pfw_files,
  117. u32 target_type, u32 target_version);
  118. extern void cnss_get_qca9377_fw_files(struct cnss_fw_files *pfw_files,
  119. u32 size, u32 tufello_dual_fw);
  120. extern int cnss_request_bus_bandwidth(int bandwidth);
  121. #ifdef CONFIG_CNSS_SECURE_FW
  122. extern int cnss_get_sha_hash(const u8 *data, u32 data_len,
  123. u8 *hash_idx, u8 *out);
  124. extern void *cnss_get_fw_ptr(void);
  125. #endif
  126. extern int cnss_get_codeswap_struct(struct codeswap_codeseg_info *swap_seg);
  127. extern int cnss_get_bmi_setup(void);
  128. #ifdef CONFIG_PCI_MSM
  129. extern int cnss_wlan_pm_control(bool vote);
  130. #endif
  131. extern void cnss_lock_pm_sem(void);
  132. extern void cnss_release_pm_sem(void);
  133. extern void cnss_request_pm_qos_type(int latency_type, u32 qos_val);
  134. extern void cnss_request_pm_qos(u32 qos_val);
  135. extern void cnss_remove_pm_qos(void);
  136. extern void cnss_pci_request_pm_qos_type(int latency_type, u32 qos_val);
  137. extern void cnss_pci_request_pm_qos(u32 qos_val);
  138. extern void cnss_pci_remove_pm_qos(void);
  139. extern void cnss_sdio_request_pm_qos_type(int latency_type, u32 qos_val);
  140. extern void cnss_sdio_request_pm_qos(u32 qos_val);
  141. extern void cnss_sdio_remove_pm_qos(void);
  142. extern int cnss_get_platform_cap(struct cnss_platform_cap *cap);
  143. extern void cnss_set_driver_status(enum cnss_driver_status driver_status);
  144. #ifndef CONFIG_WCNSS_MEM_PRE_ALLOC
  145. static inline int wcnss_pre_alloc_reset(void) { return 0; }
  146. #endif
  147. extern int msm_pcie_enumerate(u32 rc_idx);
  148. extern int cnss_auto_suspend(void);
  149. extern int cnss_auto_resume(void);
  150. extern int cnss_prevent_auto_suspend(const char *caller_func);
  151. extern int cnss_allow_auto_suspend(const char *caller_func);
  152. extern int cnss_is_auto_suspend_allowed(const char *caller_func);
  153. extern int cnss_pm_runtime_request(struct device *dev, enum
  154. cnss_runtime_request request);
  155. extern void cnss_set_cc_source(enum cnss_cc_src cc_source);
  156. extern enum cnss_cc_src cnss_get_cc_source(void);
  157. #endif
  158. extern void cnss_pm_wake_lock_init(struct wakeup_source *ws, const char *name);
  159. extern void cnss_pm_wake_lock(struct wakeup_source *ws);
  160. extern void cnss_device_crashed(void);
  161. extern void cnss_device_self_recovery(void);
  162. extern void *cnss_get_virt_ramdump_mem(unsigned long *size);
  163. extern void cnss_schedule_recovery_work(void);
  164. extern int cnss_pcie_set_wlan_mac_address(const u8 *in, uint32_t len);
  165. extern u8 *cnss_get_wlan_mac_address(struct device *dev, uint32_t *num);
  166. extern int cnss_sdio_set_wlan_mac_address(const u8 *in, uint32_t len);
  167. enum {
  168. CNSS_RESET_SOC = 0,
  169. CNSS_RESET_SUBSYS_COUPLED,
  170. CNSS_RESET_LEVEL_MAX
  171. };
  172. extern int cnss_get_restart_level(void);
  173. struct cnss_sdio_wlan_driver {
  174. const char *name;
  175. const struct sdio_device_id *id_table;
  176. int (*probe)(struct sdio_func *, const struct sdio_device_id *);
  177. void (*remove)(struct sdio_func *);
  178. int (*reinit)(struct sdio_func *, const struct sdio_device_id *);
  179. void (*shutdown)(struct sdio_func *);
  180. void (*crash_shutdown)(struct sdio_func *);
  181. int (*suspend)(struct device *);
  182. int (*resume)(struct device *);
  183. };
  184. extern int cnss_sdio_wlan_register_driver(
  185. struct cnss_sdio_wlan_driver *driver);
  186. extern void cnss_sdio_wlan_unregister_driver(
  187. struct cnss_sdio_wlan_driver *driver);
  188. typedef void (*oob_irq_handler_t)(void *dev_para);
  189. extern int cnss_wlan_query_oob_status(void);
  190. extern int cnss_wlan_register_oob_irq_handler(oob_irq_handler_t handler,
  191. void *pm_oob);
  192. extern int cnss_wlan_unregister_oob_irq_handler(void *pm_oob);
  193. extern void cnss_dump_stack(struct task_struct *task);
  194. extern u8 *cnss_common_get_wlan_mac_address(struct device *dev, uint32_t *num);
  195. extern void cnss_init_work(struct work_struct *work, work_func_t func);
  196. extern void cnss_flush_delayed_work(void *dwork);
  197. extern void cnss_flush_work(void *work);
  198. extern void cnss_pm_wake_lock_timeout(struct wakeup_source *ws, ulong msec);
  199. extern void cnss_pm_wake_lock_release(struct wakeup_source *ws);
  200. extern void cnss_pm_wake_lock_destroy(struct wakeup_source *ws);
  201. extern void cnss_get_monotonic_boottime(struct timespec *ts);
  202. extern void cnss_get_boottime(struct timespec *ts);
  203. extern void cnss_init_delayed_work(struct delayed_work *work, work_func_t
  204. func);
  205. extern int cnss_vendor_cmd_reply(struct sk_buff *skb);
  206. extern int cnss_set_cpus_allowed_ptr(struct task_struct *task, ulong cpu);
  207. extern int cnss_set_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 ch_count);
  208. extern int cnss_get_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 *ch_count,
  209. u16 buf_len);
  210. extern int cnss_wlan_set_dfs_nol(const void *info, u16 info_len);
  211. extern int cnss_wlan_get_dfs_nol(void *info, u16 info_len);
  212. extern int cnss_common_request_bus_bandwidth(struct device *dev, int
  213. bandwidth);
  214. extern void cnss_common_device_crashed(struct device *dev);
  215. extern void cnss_common_device_self_recovery(struct device *dev);
  216. extern void *cnss_common_get_virt_ramdump_mem(struct device *dev, unsigned long
  217. *size);
  218. extern void cnss_common_schedule_recovery_work(struct device *dev);
  219. extern int cnss_common_set_wlan_mac_address(struct device *dev, const u8 *in,
  220. uint32_t len);
  221. extern u8 *cnss_common_get_wlan_mac_address(struct device *dev, uint32_t *num);
  222. extern int cnss_power_up(struct device *dev);
  223. extern int cnss_power_down(struct device *dev);
  224. extern int cnss_sdio_configure_spdt(bool state);
  225. extern int cnss_common_register_tsf_captured_handler(struct device *dev,
  226. irq_handler_t handler,
  227. void *ctx);
  228. extern int cnss_common_unregister_tsf_captured_handler(struct device *dev,
  229. void *ctx);
  230. #endif /* _NET_CNSS_H_ */