main.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _CNSS_MAIN_H
  7. #define _CNSS_MAIN_H
  8. #if IS_ENABLED(CONFIG_ARM) || IS_ENABLED(CONFIG_ARM64)
  9. #include <asm/arch_timer.h>
  10. #endif
  11. #if IS_ENABLED(CONFIG_ESOC)
  12. #include <linux/esoc_client.h>
  13. #endif
  14. #include <linux/etherdevice.h>
  15. #include <linux/firmware.h>
  16. #if IS_ENABLED(CONFIG_INTERCONNECT)
  17. #include <linux/interconnect.h>
  18. #endif
  19. #include <linux/mailbox_client.h>
  20. #include <linux/pm_qos.h>
  21. #include <linux/of.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/time64.h>
  24. #ifdef CONFIG_CNSS_OUT_OF_TREE
  25. #include "cnss2.h"
  26. #else
  27. #include <net/cnss2.h>
  28. #endif
  29. #if IS_ENABLED(CONFIG_QCOM_MEMORY_DUMP_V2) || IS_ENABLED(CONFIG_QCOM_MINIDUMP)
  30. #include <soc/qcom/memory_dump.h>
  31. #endif
  32. #if IS_ENABLED(CONFIG_MSM_SUBSYSTEM_RESTART) || \
  33. IS_ENABLED(CONFIG_QCOM_RAMDUMP)
  34. #include <soc/qcom/qcom_ramdump.h>
  35. #endif
  36. #if IS_ENABLED(CONFIG_MSM_SUBSYSTEM_RESTART)
  37. #include <soc/qcom/subsystem_notif.h>
  38. #include <soc/qcom/subsystem_restart.h>
  39. #endif
  40. #include <linux/iommu.h>
  41. #include "qmi.h"
  42. #include "cnss_prealloc.h"
  43. #include "cnss_common.h"
  44. #define MAX_NO_OF_MAC_ADDR 4
  45. #define QMI_WLFW_MAX_TIMESTAMP_LEN 32
  46. #define QMI_WLFW_MAX_BUILD_ID_LEN 128
  47. #define CNSS_RDDM_TIMEOUT_MS 20000
  48. #define RECOVERY_TIMEOUT 60000
  49. #define WLAN_WD_TIMEOUT_MS 60000
  50. #define WLAN_COLD_BOOT_CAL_TIMEOUT 60000
  51. #define WLAN_MISSION_MODE_TIMEOUT 30000
  52. #define TIME_CLOCK_FREQ_HZ 19200000
  53. #define CNSS_RAMDUMP_MAGIC 0x574C414E
  54. #define CNSS_RAMDUMP_VERSION 0
  55. #define MAX_FIRMWARE_NAME_LEN 40
  56. #define FW_V2_NUMBER 2
  57. #ifdef CONFIG_CNSS_SUPPORT_DUAL_DEV
  58. #define POWER_ON_RETRY_MAX_TIMES 2
  59. #else
  60. #define POWER_ON_RETRY_MAX_TIMES 4
  61. #endif
  62. #define POWER_ON_RETRY_DELAY_MS 500
  63. #define CNSS_FS_NAME "cnss"
  64. #define CNSS_FS_NAME_SIZE 15
  65. #define CNSS_DEVICE_NAME_SIZE 16
  66. #define QRTR_NODE_FW_ID_BASE 7
  67. #define POWER_ON_RETRY_DELAY_MS 500
  68. #define WLFW_MAX_HANG_EVENT_DATA_SIZE 384
  69. #define CNSS_EVENT_SYNC BIT(0)
  70. #define CNSS_EVENT_UNINTERRUPTIBLE BIT(1)
  71. #define CNSS_EVENT_UNKILLABLE BIT(2)
  72. #define CNSS_EVENT_SYNC_UNINTERRUPTIBLE (CNSS_EVENT_SYNC | \
  73. CNSS_EVENT_UNINTERRUPTIBLE)
  74. #define CNSS_EVENT_SYNC_UNKILLABLE (CNSS_EVENT_SYNC | CNSS_EVENT_UNKILLABLE)
  75. enum cnss_dt_type {
  76. CNSS_DTT_LEGACY = 0,
  77. CNSS_DTT_CONVERGED = 1,
  78. CNSS_DTT_MULTIEXCHG = 2
  79. };
  80. enum cnss_dev_bus_type {
  81. CNSS_BUS_NONE = -1,
  82. CNSS_BUS_PCI,
  83. CNSS_BUS_MAX
  84. };
  85. struct cnss_vreg_cfg {
  86. const char *name;
  87. u32 min_uv;
  88. u32 max_uv;
  89. u32 load_ua;
  90. u32 delay_us;
  91. u32 need_unvote;
  92. };
  93. struct cnss_vreg_info {
  94. struct list_head list;
  95. struct regulator *reg;
  96. struct cnss_vreg_cfg cfg;
  97. u32 enabled;
  98. };
  99. enum cnss_vreg_type {
  100. CNSS_VREG_PRIM,
  101. };
  102. struct cnss_clk_cfg {
  103. const char *name;
  104. u32 freq;
  105. u32 required;
  106. };
  107. struct cnss_clk_info {
  108. struct list_head list;
  109. struct clk *clk;
  110. struct cnss_clk_cfg cfg;
  111. u32 enabled;
  112. };
  113. struct cnss_pinctrl_info {
  114. struct pinctrl *pinctrl;
  115. struct pinctrl_state *bootstrap_active;
  116. struct pinctrl_state *sol_default;
  117. struct pinctrl_state *wlan_en_active;
  118. struct pinctrl_state *wlan_en_sleep;
  119. int bt_en_gpio;
  120. int wlan_en_gpio;
  121. int xo_clk_gpio; /*qca6490 only */
  122. int sw_ctrl_gpio;
  123. int wlan_sw_ctrl_gpio;
  124. };
  125. #if IS_ENABLED(CONFIG_MSM_SUBSYSTEM_RESTART)
  126. struct cnss_subsys_info {
  127. struct subsys_device *subsys_device;
  128. struct subsys_desc subsys_desc;
  129. void *subsys_handle;
  130. };
  131. #endif
  132. struct cnss_ramdump_info {
  133. void *ramdump_dev;
  134. unsigned long ramdump_size;
  135. void *ramdump_va;
  136. phys_addr_t ramdump_pa;
  137. #if IS_ENABLED(CONFIG_QCOM_MEMORY_DUMP_V2)
  138. struct msm_dump_data dump_data;
  139. #endif
  140. };
  141. struct cnss_dump_seg {
  142. unsigned long address;
  143. void *v_address;
  144. unsigned long size;
  145. u32 type;
  146. };
  147. struct cnss_dump_data {
  148. u32 version;
  149. u32 magic;
  150. char name[32];
  151. phys_addr_t paddr;
  152. int nentries;
  153. u32 seg_version;
  154. };
  155. struct cnss_ramdump_info_v2 {
  156. void *ramdump_dev;
  157. unsigned long ramdump_size;
  158. void *dump_data_vaddr;
  159. u8 dump_data_valid;
  160. struct cnss_dump_data dump_data;
  161. };
  162. #if IS_ENABLED(CONFIG_ESOC)
  163. struct cnss_esoc_info {
  164. struct esoc_desc *esoc_desc;
  165. u8 notify_modem_status;
  166. void *modem_notify_handler;
  167. int modem_current_status;
  168. };
  169. #endif
  170. #if IS_ENABLED(CONFIG_INTERCONNECT)
  171. /**
  172. * struct cnss_bus_bw_cfg - Interconnect vote data
  173. * @avg_bw: Vote for average bandwidth
  174. * @peak_bw: Vote for peak bandwidth
  175. */
  176. struct cnss_bus_bw_cfg {
  177. u32 avg_bw;
  178. u32 peak_bw;
  179. };
  180. /* Number of bw votes (avg, peak) entries that ICC requires */
  181. #define CNSS_ICC_VOTE_MAX 2
  182. /**
  183. * struct cnss_bus_bw_info - Bus bandwidth config for interconnect path
  184. * @list: Kernel linked list
  185. * @icc_name: Name of interconnect path as defined in Device tree
  186. * @icc_path: Interconnect path data structure
  187. * @cfg_table: Interconnect vote data for average and peak bandwidth
  188. */
  189. struct cnss_bus_bw_info {
  190. struct list_head list;
  191. const char *icc_name;
  192. struct icc_path *icc_path;
  193. struct cnss_bus_bw_cfg *cfg_table;
  194. };
  195. #endif
  196. /**
  197. * struct cnss_interconnect_cfg - CNSS platform interconnect config
  198. * @list_head: List of interconnect path bandwidth configs
  199. * @path_count: Count of interconnect path configured in device tree
  200. * @current_bw_vote: WLAN driver provided bandwidth vote
  201. * @bus_bw_cfg_count: Number of bandwidth configs for voting. It is the array
  202. * size of struct cnss_bus_bw_info.cfg_table
  203. */
  204. struct cnss_interconnect_cfg {
  205. struct list_head list_head;
  206. u32 path_count;
  207. int current_bw_vote;
  208. u32 bus_bw_cfg_count;
  209. };
  210. struct cnss_fw_mem {
  211. size_t size;
  212. void *va;
  213. phys_addr_t pa;
  214. u8 valid;
  215. u32 type;
  216. unsigned long attrs;
  217. };
  218. struct wlfw_rf_chip_info {
  219. u32 chip_id;
  220. u32 chip_family;
  221. };
  222. struct wlfw_rf_board_info {
  223. u32 board_id;
  224. };
  225. struct wlfw_soc_info {
  226. u32 soc_id;
  227. };
  228. struct wlfw_fw_version_info {
  229. u32 fw_version;
  230. char fw_build_timestamp[QMI_WLFW_MAX_TIMESTAMP_LEN + 1];
  231. };
  232. enum cnss_mem_type {
  233. CNSS_MEM_TYPE_MSA,
  234. CNSS_MEM_TYPE_DDR,
  235. CNSS_MEM_BDF,
  236. CNSS_MEM_M3,
  237. CNSS_MEM_CAL_V01,
  238. CNSS_MEM_DPD_V01,
  239. };
  240. enum cnss_fw_dump_type {
  241. CNSS_FW_IMAGE,
  242. CNSS_FW_RDDM,
  243. CNSS_FW_REMOTE_HEAP,
  244. CNSS_FW_DUMP_TYPE_MAX,
  245. };
  246. struct cnss_dump_entry {
  247. u32 type;
  248. u32 entry_start;
  249. u32 entry_num;
  250. };
  251. struct cnss_dump_meta_info {
  252. u32 magic;
  253. u32 version;
  254. u32 chipset;
  255. u32 total_entries;
  256. struct cnss_dump_entry entry[CNSS_FW_DUMP_TYPE_MAX];
  257. };
  258. struct cnss_host_dump_meta_info {
  259. u32 magic;
  260. u32 version;
  261. u32 chipset;
  262. u32 total_entries;
  263. struct cnss_dump_entry entry[CNSS_HOST_DUMP_TYPE_MAX];
  264. };
  265. enum cnss_driver_event_type {
  266. CNSS_DRIVER_EVENT_SERVER_ARRIVE,
  267. CNSS_DRIVER_EVENT_SERVER_EXIT,
  268. CNSS_DRIVER_EVENT_REQUEST_MEM,
  269. CNSS_DRIVER_EVENT_FW_MEM_READY,
  270. CNSS_DRIVER_EVENT_FW_READY,
  271. CNSS_DRIVER_EVENT_COLD_BOOT_CAL_START,
  272. CNSS_DRIVER_EVENT_COLD_BOOT_CAL_DONE,
  273. CNSS_DRIVER_EVENT_REGISTER_DRIVER,
  274. CNSS_DRIVER_EVENT_UNREGISTER_DRIVER,
  275. CNSS_DRIVER_EVENT_RECOVERY,
  276. CNSS_DRIVER_EVENT_FORCE_FW_ASSERT,
  277. CNSS_DRIVER_EVENT_POWER_UP,
  278. CNSS_DRIVER_EVENT_POWER_DOWN,
  279. CNSS_DRIVER_EVENT_IDLE_RESTART,
  280. CNSS_DRIVER_EVENT_IDLE_SHUTDOWN,
  281. CNSS_DRIVER_EVENT_IMS_WFC_CALL_IND,
  282. CNSS_DRIVER_EVENT_WLFW_TWT_CFG_IND,
  283. CNSS_DRIVER_EVENT_QDSS_TRACE_REQ_MEM,
  284. CNSS_DRIVER_EVENT_FW_MEM_FILE_SAVE,
  285. CNSS_DRIVER_EVENT_QDSS_TRACE_FREE,
  286. CNSS_DRIVER_EVENT_QDSS_TRACE_REQ_DATA,
  287. CNSS_DRIVER_EVENT_MAX,
  288. };
  289. enum cnss_driver_state {
  290. CNSS_QMI_WLFW_CONNECTED = 0,
  291. CNSS_FW_MEM_READY,
  292. CNSS_FW_READY,
  293. CNSS_IN_COLD_BOOT_CAL,
  294. CNSS_DRIVER_LOADING,
  295. CNSS_DRIVER_UNLOADING = 5,
  296. CNSS_DRIVER_IDLE_RESTART,
  297. CNSS_DRIVER_IDLE_SHUTDOWN,
  298. CNSS_DRIVER_PROBED,
  299. CNSS_DRIVER_RECOVERY,
  300. CNSS_FW_BOOT_RECOVERY = 10,
  301. CNSS_DEV_ERR_NOTIFY,
  302. CNSS_DRIVER_DEBUG,
  303. CNSS_COEX_CONNECTED,
  304. CNSS_IMS_CONNECTED,
  305. CNSS_IN_SUSPEND_RESUME = 15,
  306. CNSS_IN_REBOOT,
  307. CNSS_COLD_BOOT_CAL_DONE,
  308. CNSS_IN_PANIC,
  309. CNSS_QMI_DEL_SERVER,
  310. CNSS_QMI_DMS_CONNECTED = 20,
  311. CNSS_DAEMON_CONNECTED,
  312. CNSS_PCI_PROBE_DONE,
  313. CNSS_DRIVER_REGISTER,
  314. CNSS_WLAN_HW_DISABLED,
  315. CNSS_FS_READY = 25,
  316. CNSS_DRIVER_REGISTERED,
  317. CNSS_DMS_DEL_SERVER,
  318. };
  319. struct cnss_recovery_data {
  320. enum cnss_recovery_reason reason;
  321. };
  322. enum cnss_pins {
  323. CNSS_WLAN_EN,
  324. CNSS_PCIE_TXP,
  325. CNSS_PCIE_TXN,
  326. CNSS_PCIE_RXP,
  327. CNSS_PCIE_RXN,
  328. CNSS_PCIE_REFCLKP,
  329. CNSS_PCIE_REFCLKN,
  330. CNSS_PCIE_RST,
  331. CNSS_PCIE_WAKE,
  332. };
  333. struct cnss_pin_connect_result {
  334. u32 fw_pwr_pin_result;
  335. u32 fw_phy_io_pin_result;
  336. u32 fw_rf_pin_result;
  337. u32 host_pin_result;
  338. };
  339. enum cnss_debug_quirks {
  340. LINK_DOWN_SELF_RECOVERY,
  341. SKIP_DEVICE_BOOT,
  342. USE_CORE_ONLY_FW,
  343. SKIP_RECOVERY,
  344. QMI_BYPASS,
  345. ENABLE_WALTEST,
  346. ENABLE_PCI_LINK_DOWN_PANIC,
  347. FBC_BYPASS,
  348. ENABLE_DAEMON_SUPPORT,
  349. DISABLE_DRV,
  350. DISABLE_IO_COHERENCY,
  351. IGNORE_PCI_LINK_FAILURE,
  352. DISABLE_TIME_SYNC,
  353. FORCE_ONE_MSI,
  354. QUIRK_MAX_VALUE
  355. };
  356. enum cnss_bdf_type {
  357. CNSS_BDF_BIN,
  358. CNSS_BDF_ELF,
  359. CNSS_BDF_REGDB = 4,
  360. CNSS_BDF_HDS = 6,
  361. };
  362. enum cnss_cal_status {
  363. CNSS_CAL_DONE,
  364. CNSS_CAL_TIMEOUT,
  365. CNSS_CAL_FAILURE,
  366. };
  367. struct cnss_cal_info {
  368. enum cnss_cal_status cal_status;
  369. };
  370. struct cnss_control_params {
  371. unsigned long quirks;
  372. unsigned int mhi_timeout;
  373. unsigned int mhi_m2_timeout;
  374. unsigned int qmi_timeout;
  375. unsigned int bdf_type;
  376. unsigned int time_sync_period;
  377. };
  378. struct cnss_tcs_info {
  379. resource_size_t cmd_base_addr;
  380. void __iomem *cmd_base_addr_io;
  381. };
  382. struct cnss_cpr_info {
  383. resource_size_t tcs_cmd_data_addr;
  384. void __iomem *tcs_cmd_data_addr_io;
  385. u32 cpr_pmic_addr;
  386. u32 voltage;
  387. };
  388. enum cnss_ce_index {
  389. CNSS_CE_00,
  390. CNSS_CE_01,
  391. CNSS_CE_02,
  392. CNSS_CE_03,
  393. CNSS_CE_04,
  394. CNSS_CE_05,
  395. CNSS_CE_06,
  396. CNSS_CE_07,
  397. CNSS_CE_08,
  398. CNSS_CE_09,
  399. CNSS_CE_10,
  400. CNSS_CE_11,
  401. CNSS_CE_COMMON,
  402. };
  403. struct cnss_dms_data {
  404. u32 mac_valid;
  405. u8 mac[QMI_WLFW_MAC_ADDR_SIZE_V01];
  406. };
  407. enum cnss_timeout_type {
  408. CNSS_TIMEOUT_QMI,
  409. CNSS_TIMEOUT_POWER_UP,
  410. CNSS_TIMEOUT_IDLE_RESTART,
  411. CNSS_TIMEOUT_CALIBRATION,
  412. CNSS_TIMEOUT_WLAN_WATCHDOG,
  413. CNSS_TIMEOUT_RDDM,
  414. CNSS_TIMEOUT_RECOVERY,
  415. CNSS_TIMEOUT_DAEMON_CONNECTION,
  416. };
  417. struct cnss_sol_gpio {
  418. int dev_sol_gpio;
  419. int dev_sol_irq;
  420. u32 dev_sol_counter;
  421. int host_sol_gpio;
  422. };
  423. struct cnss_thermal_cdev {
  424. struct list_head tcdev_list;
  425. int tcdev_id;
  426. unsigned long curr_thermal_state;
  427. unsigned long max_thermal_state;
  428. struct device_node *dev_node;
  429. struct thermal_cooling_device *tcdev;
  430. };
  431. struct cnss_plat_data {
  432. struct platform_device *plat_dev;
  433. void *bus_priv;
  434. enum cnss_dev_bus_type bus_type;
  435. struct list_head vreg_list;
  436. struct list_head clk_list;
  437. struct cnss_pinctrl_info pinctrl_info;
  438. struct cnss_sol_gpio sol_gpio;
  439. #if IS_ENABLED(CONFIG_MSM_SUBSYSTEM_RESTART)
  440. struct cnss_subsys_info subsys_info;
  441. #endif
  442. struct cnss_ramdump_info ramdump_info;
  443. struct cnss_ramdump_info_v2 ramdump_info_v2;
  444. #if IS_ENABLED(CONFIG_ESOC)
  445. struct cnss_esoc_info esoc_info;
  446. #endif
  447. struct cnss_interconnect_cfg icc;
  448. struct notifier_block modem_nb;
  449. struct notifier_block reboot_nb;
  450. struct notifier_block panic_nb;
  451. struct cnss_platform_cap cap;
  452. struct pm_qos_request qos_request;
  453. struct cnss_device_version device_version;
  454. u32 rc_num;
  455. unsigned long device_id;
  456. enum cnss_driver_status driver_status;
  457. u32 recovery_count;
  458. u8 recovery_enabled;
  459. u8 recovery_pcss_enabled;
  460. u8 hds_enabled;
  461. unsigned long driver_state;
  462. struct list_head event_list;
  463. struct list_head cnss_tcdev_list;
  464. struct mutex tcdev_lock; /* mutex for cooling devices list access */
  465. spinlock_t event_lock; /* spinlock for driver work event handling */
  466. struct work_struct event_work;
  467. struct workqueue_struct *event_wq;
  468. struct work_struct recovery_work;
  469. struct delayed_work wlan_reg_driver_work;
  470. struct qmi_handle qmi_wlfw;
  471. struct qmi_handle qmi_dms;
  472. struct wlfw_rf_chip_info chip_info;
  473. struct wlfw_rf_board_info board_info;
  474. struct wlfw_soc_info soc_info;
  475. struct wlfw_fw_version_info fw_version_info;
  476. struct cnss_dev_mem_info dev_mem_info[CNSS_MAX_DEV_MEM_NUM];
  477. char fw_build_id[QMI_WLFW_MAX_BUILD_ID_LEN + 1];
  478. u32 otp_version;
  479. u32 fw_mem_seg_len;
  480. struct cnss_fw_mem fw_mem[QMI_WLFW_MAX_NUM_MEM_SEG_V01];
  481. struct cnss_fw_mem m3_mem;
  482. struct cnss_fw_mem *cal_mem;
  483. u64 cal_time;
  484. bool cbc_file_download;
  485. u32 cal_file_size;
  486. struct completion daemon_connected;
  487. u32 qdss_mem_seg_len;
  488. struct cnss_fw_mem qdss_mem[QMI_WLFW_MAX_NUM_MEM_SEG_V01];
  489. u32 *qdss_reg;
  490. struct cnss_pin_connect_result pin_result;
  491. struct dentry *root_dentry;
  492. atomic_t pm_count;
  493. struct timer_list fw_boot_timer;
  494. struct completion power_up_complete;
  495. struct completion cal_complete;
  496. struct mutex dev_lock; /* mutex for register access through debugfs */
  497. struct mutex driver_ops_lock; /* mutex for external driver ops */
  498. struct cnss_wlan_driver *driver_ops;
  499. u32 device_freq_hz;
  500. u32 diag_reg_read_addr;
  501. u32 diag_reg_read_mem_type;
  502. u32 diag_reg_read_len;
  503. u8 *diag_reg_read_buf;
  504. u8 cal_done;
  505. u8 powered_on;
  506. u8 use_fw_path_with_prefix;
  507. char firmware_name[MAX_FIRMWARE_NAME_LEN];
  508. char fw_fallback_name[MAX_FIRMWARE_NAME_LEN];
  509. #ifndef CONFIG_DISABLE_CNSS_SRAM_DUMP
  510. u8 *sram_dump;
  511. #endif
  512. struct completion rddm_complete;
  513. struct completion recovery_complete;
  514. struct cnss_control_params ctrl_params;
  515. struct cnss_cpr_info cpr_info;
  516. u64 antenna;
  517. u64 grant;
  518. struct qmi_handle coex_qmi;
  519. struct qmi_handle ims_qmi;
  520. struct qmi_txn txn;
  521. struct wakeup_source *recovery_ws;
  522. u64 dynamic_feature;
  523. void *get_info_cb_ctx;
  524. int (*get_info_cb)(void *ctx, void *event, int event_len);
  525. bool cbc_enabled;
  526. u8 use_pm_domain;
  527. u8 use_nv_mac;
  528. u8 set_wlaon_pwr_ctrl;
  529. struct cnss_tcs_info tcs_info;
  530. bool fw_pcie_gen_switch;
  531. u64 fw_caps;
  532. u8 pcie_gen_speed;
  533. struct iommu_domain *audio_iommu_domain;
  534. struct cnss_dms_data dms;
  535. int power_up_error;
  536. u32 hw_trc_override;
  537. u8 charger_mode;
  538. struct mbox_client mbox_client_data;
  539. struct mbox_chan *mbox_chan;
  540. const char *vreg_ol_cpr, *vreg_ipa;
  541. const char **pdc_init_table, **vreg_pdc_map, **pmu_vreg_map;
  542. int pdc_init_table_len, vreg_pdc_map_len, pmu_vreg_map_len;
  543. bool adsp_pc_enabled;
  544. u64 feature_list;
  545. u32 dt_type;
  546. struct kobject *wifi_kobj;
  547. u16 hang_event_data_len;
  548. u32 hang_data_addr_offset;
  549. /* bitmap to detect FEM combination */
  550. u8 hwid_bitmap;
  551. enum cnss_driver_mode driver_mode;
  552. uint32_t num_shadow_regs_v3;
  553. bool sec_peri_feature_disable;
  554. struct device_node *dev_node;
  555. char device_name[CNSS_DEVICE_NAME_SIZE];
  556. u32 plat_idx;
  557. bool enumerate_done;
  558. int qrtr_node_id;
  559. unsigned int wlfw_service_instance_id;
  560. const char *pld_bus_ops_name;
  561. u32 on_chip_pmic_devices_count;
  562. u32 *on_chip_pmic_board_ids;
  563. bool no_bwscale;
  564. bool sleep_clk;
  565. };
  566. #if IS_ENABLED(CONFIG_ARCH_QCOM)
  567. static inline u64 cnss_get_host_timestamp(struct cnss_plat_data *plat_priv)
  568. {
  569. u64 ticks = __arch_counter_get_cntvct();
  570. do_div(ticks, TIME_CLOCK_FREQ_HZ / 100000);
  571. return ticks * 10;
  572. }
  573. #else
  574. static inline u64 cnss_get_host_timestamp(struct cnss_plat_data *plat_priv)
  575. {
  576. struct timespec64 ts;
  577. ktime_get_ts64(&ts);
  578. return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
  579. }
  580. #endif
  581. int cnss_wlan_hw_disable_check(struct cnss_plat_data *plat_priv);
  582. int cnss_wlan_hw_enable(void);
  583. struct cnss_plat_data *cnss_get_plat_priv(struct platform_device *plat_dev);
  584. struct cnss_plat_data *cnss_get_first_plat_priv(struct platform_device *plat_dev);
  585. void cnss_pm_stay_awake(struct cnss_plat_data *plat_priv);
  586. void cnss_pm_relax(struct cnss_plat_data *plat_priv);
  587. struct cnss_plat_data *cnss_get_plat_priv_by_rc_num(int rc_num);
  588. int cnss_get_plat_env_count(void);
  589. struct cnss_plat_data *cnss_get_plat_env(int index);
  590. void cnss_get_qrtr_info(struct cnss_plat_data *plat_priv);
  591. void cnss_get_sleep_clk_supported(struct cnss_plat_data *plat_priv);
  592. void cnss_get_bwscal_info(struct cnss_plat_data *plat_priv);
  593. bool cnss_is_dual_wlan_enabled(void);
  594. int cnss_driver_event_post(struct cnss_plat_data *plat_priv,
  595. enum cnss_driver_event_type type,
  596. u32 flags, void *data);
  597. int cnss_get_vreg_type(struct cnss_plat_data *plat_priv,
  598. enum cnss_vreg_type type);
  599. void cnss_put_vreg_type(struct cnss_plat_data *plat_priv,
  600. enum cnss_vreg_type type);
  601. int cnss_vreg_on_type(struct cnss_plat_data *plat_priv,
  602. enum cnss_vreg_type type);
  603. int cnss_vreg_off_type(struct cnss_plat_data *plat_priv,
  604. enum cnss_vreg_type type);
  605. int cnss_get_clk(struct cnss_plat_data *plat_priv);
  606. void cnss_put_clk(struct cnss_plat_data *plat_priv);
  607. int cnss_vreg_unvote_type(struct cnss_plat_data *plat_priv,
  608. enum cnss_vreg_type type);
  609. int cnss_get_pinctrl(struct cnss_plat_data *plat_priv);
  610. int cnss_get_wlan_sw_ctrl(struct cnss_plat_data *plat_priv);
  611. int cnss_power_on_device(struct cnss_plat_data *plat_priv, bool reset);
  612. void cnss_power_off_device(struct cnss_plat_data *plat_priv);
  613. bool cnss_is_device_powered_on(struct cnss_plat_data *plat_priv);
  614. int cnss_enable_dev_sol_irq(struct cnss_plat_data *plat_priv);
  615. int cnss_disable_dev_sol_irq(struct cnss_plat_data *plat_priv);
  616. int cnss_get_dev_sol_value(struct cnss_plat_data *plat_priv);
  617. int cnss_init_dev_sol_irq(struct cnss_plat_data *plat_priv);
  618. int cnss_deinit_dev_sol_irq(struct cnss_plat_data *plat_priv);
  619. int cnss_set_host_sol_value(struct cnss_plat_data *plat_priv, int value);
  620. int cnss_get_host_sol_value(struct cnss_plat_data *plat_priv);
  621. int cnss_register_subsys(struct cnss_plat_data *plat_priv);
  622. void cnss_unregister_subsys(struct cnss_plat_data *plat_priv);
  623. int cnss_register_ramdump(struct cnss_plat_data *plat_priv);
  624. void cnss_unregister_ramdump(struct cnss_plat_data *plat_priv);
  625. int cnss_do_ramdump(struct cnss_plat_data *plat_priv);
  626. int cnss_do_elf_ramdump(struct cnss_plat_data *plat_priv);
  627. int cnss_do_host_ramdump(struct cnss_plat_data *plat_priv,
  628. struct cnss_ssr_driver_dump_entry *ssr_entry,
  629. size_t num_entries_loaded);
  630. void cnss_set_pin_connect_status(struct cnss_plat_data *plat_priv);
  631. int cnss_get_cpr_info(struct cnss_plat_data *plat_priv);
  632. int cnss_update_cpr_info(struct cnss_plat_data *plat_priv);
  633. int cnss_va_to_pa(struct device *dev, size_t size, void *va, dma_addr_t dma,
  634. phys_addr_t *pa, unsigned long attrs);
  635. int cnss_minidump_add_region(struct cnss_plat_data *plat_priv,
  636. enum cnss_fw_dump_type type, int seg_no,
  637. void *va, phys_addr_t pa, size_t size);
  638. int cnss_minidump_remove_region(struct cnss_plat_data *plat_priv,
  639. enum cnss_fw_dump_type type, int seg_no,
  640. void *va, phys_addr_t pa, size_t size);
  641. int cnss_enable_int_pow_amp_vreg(struct cnss_plat_data *plat_priv);
  642. int cnss_get_tcs_info(struct cnss_plat_data *plat_priv);
  643. unsigned int cnss_get_timeout(struct cnss_plat_data *plat_priv,
  644. enum cnss_timeout_type);
  645. int cnss_aop_mbox_init(struct cnss_plat_data *plat_priv);
  646. int cnss_aop_pdc_reconfig(struct cnss_plat_data *plat_priv);
  647. int cnss_aop_send_msg(struct cnss_plat_data *plat_priv, char *msg);
  648. void cnss_power_misc_params_init(struct cnss_plat_data *plat_priv);
  649. int cnss_aop_ol_cpr_cfg_setup(struct cnss_plat_data *plat_priv,
  650. struct wlfw_pmu_cfg_v01 *fw_pmu_cfg);
  651. int cnss_request_firmware_direct(struct cnss_plat_data *plat_priv,
  652. const struct firmware **fw_entry,
  653. const char *filename);
  654. int cnss_set_feature_list(struct cnss_plat_data *plat_priv,
  655. enum cnss_feature_v01 feature);
  656. int cnss_clear_feature_list(struct cnss_plat_data *plat_priv,
  657. enum cnss_feature_v01 feature);
  658. int cnss_get_feature_list(struct cnss_plat_data *plat_priv,
  659. u64 *feature_list);
  660. int cnss_get_input_gpio_value(struct cnss_plat_data *plat_priv, int gpio_num);
  661. bool cnss_check_driver_loading_allowed(void);
  662. int cnss_dev_specific_power_on(struct cnss_plat_data *plat_priv);
  663. #endif /* _CNSS_MAIN_H */