main.h 19 KB

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