blob: a99f10ab5dbc038b811541d90cec8241be8bfcb9 [file] [log] [blame]
Yue Ma8bead6d2018-02-01 12:25:47 -08001/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
Yue Ma0317e4a2018-01-10 11:48:32 -08002 *
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
13#ifndef _NET_CNSS2_H
14#define _NET_CNSS2_H
15
16#include <linux/pci.h>
17
18#define CNSS_MAX_FILE_NAME 20
19#define CNSS_MAX_TIMESTAMP_LEN 32
20
21/*
22 * Temporary change for compilation, will be removed
23 * after WLAN host driver switched to use new APIs
24 */
25#define CNSS_API_WITH_DEV
26
27enum cnss_bus_width_type {
28 CNSS_BUS_WIDTH_NONE,
29 CNSS_BUS_WIDTH_LOW,
30 CNSS_BUS_WIDTH_MEDIUM,
31 CNSS_BUS_WIDTH_HIGH
32};
33
34enum cnss_platform_cap_flag {
35 CNSS_HAS_EXTERNAL_SWREG = 0x01,
36 CNSS_HAS_UART_ACCESS = 0x02,
37};
38
39struct cnss_platform_cap {
40 u32 cap_flag;
41};
42
43struct cnss_fw_files {
44 char image_file[CNSS_MAX_FILE_NAME];
45 char board_data[CNSS_MAX_FILE_NAME];
46 char otp_data[CNSS_MAX_FILE_NAME];
47 char utf_file[CNSS_MAX_FILE_NAME];
48 char utf_board_data[CNSS_MAX_FILE_NAME];
49 char epping_file[CNSS_MAX_FILE_NAME];
50 char evicted_data[CNSS_MAX_FILE_NAME];
51};
52
53struct cnss_soc_info {
54 void __iomem *va;
55 phys_addr_t pa;
56 uint32_t chip_id;
57 uint32_t chip_family;
58 uint32_t board_id;
59 uint32_t soc_id;
60 uint32_t fw_version;
61 char fw_build_timestamp[CNSS_MAX_TIMESTAMP_LEN + 1];
62};
63
64struct cnss_wlan_runtime_ops {
65 int (*runtime_suspend)(struct pci_dev *pdev);
66 int (*runtime_resume)(struct pci_dev *pdev);
67};
68
69struct cnss_wlan_driver {
70 char *name;
71 int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id);
72 void (*remove)(struct pci_dev *pdev);
73 int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id);
74 void (*shutdown)(struct pci_dev *pdev);
75 void (*crash_shutdown)(struct pci_dev *pdev);
76 int (*suspend)(struct pci_dev *pdev, pm_message_t state);
77 int (*resume)(struct pci_dev *pdev);
78 int (*suspend_noirq)(struct pci_dev *pdev);
79 int (*resume_noirq)(struct pci_dev *pdev);
80 void (*modem_status)(struct pci_dev *, int state);
81 void (*update_status)(struct pci_dev *pdev, uint32_t status);
82 struct cnss_wlan_runtime_ops *runtime_ops;
83 const struct pci_device_id *id_table;
84};
85
86enum cnss_driver_status {
87 CNSS_UNINITIALIZED,
88 CNSS_INITIALIZED,
89 CNSS_LOAD_UNLOAD,
90 CNSS_RECOVERY,
Yue Ma8bead6d2018-02-01 12:25:47 -080091 CNSS_FW_DOWN,
Yue Ma0317e4a2018-01-10 11:48:32 -080092};
93
94struct cnss_ce_tgt_pipe_cfg {
95 u32 pipe_num;
96 u32 pipe_dir;
97 u32 nentries;
98 u32 nbytes_max;
99 u32 flags;
100 u32 reserved;
101};
102
103struct cnss_ce_svc_pipe_cfg {
104 u32 service_id;
105 u32 pipe_dir;
106 u32 pipe_num;
107};
108
109struct cnss_shadow_reg_cfg {
110 u16 ce_id;
111 u16 reg_offset;
112};
113
114struct cnss_shadow_reg_v2_cfg {
115 u32 addr;
116};
117
118struct cnss_wlan_enable_cfg {
119 u32 num_ce_tgt_cfg;
120 struct cnss_ce_tgt_pipe_cfg *ce_tgt_cfg;
121 u32 num_ce_svc_pipe_cfg;
122 struct cnss_ce_svc_pipe_cfg *ce_svc_cfg;
123 u32 num_shadow_reg_cfg;
124 struct cnss_shadow_reg_cfg *shadow_reg_cfg;
125 u32 num_shadow_reg_v2_cfg;
126 struct cnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
127};
128
129enum cnss_driver_mode {
130 CNSS_MISSION,
131 CNSS_FTM,
132 CNSS_EPPING,
133 CNSS_WALTEST,
134 CNSS_OFF,
135 CNSS_CCPM,
136 CNSS_QVIT,
137 CNSS_CALIBRATION,
138};
139
140enum cnss_recovery_reason {
141 CNSS_REASON_DEFAULT,
142 CNSS_REASON_LINK_DOWN,
143 CNSS_REASON_RDDM,
144 CNSS_REASON_TIMEOUT,
145};
146
147extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver);
148extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver);
149extern void cnss_device_crashed(struct device *dev);
150extern int cnss_pci_link_down(struct device *dev);
Yue Ma41bc50a2018-09-10 17:20:54 -0700151extern int cnss_pci_is_device_down(struct device *dev);
Yue Ma0317e4a2018-01-10 11:48:32 -0800152extern void cnss_schedule_recovery(struct device *dev,
153 enum cnss_recovery_reason reason);
154extern int cnss_self_recovery(struct device *dev,
155 enum cnss_recovery_reason reason);
156extern int cnss_force_fw_assert(struct device *dev);
157extern void *cnss_get_virt_ramdump_mem(struct device *dev, unsigned long *size);
158extern int cnss_get_fw_files_for_target(struct device *dev,
159 struct cnss_fw_files *pfw_files,
160 u32 target_type, u32 target_version);
161extern int cnss_get_platform_cap(struct device *dev,
162 struct cnss_platform_cap *cap);
Frank Liu4fae0d12018-07-27 14:32:53 +0800163extern struct dma_iommu_mapping *cnss_smmu_get_mapping(struct device *dev);
164extern int cnss_smmu_map(struct device *dev,
165 phys_addr_t paddr, uint32_t *iova_addr, size_t size);
Yue Ma0317e4a2018-01-10 11:48:32 -0800166extern int cnss_get_soc_info(struct device *dev, struct cnss_soc_info *info);
167extern int cnss_request_bus_bandwidth(struct device *dev, int bandwidth);
168extern int cnss_power_up(struct device *dev);
169extern int cnss_power_down(struct device *dev);
170extern void cnss_request_pm_qos(struct device *dev, u32 qos_val);
171extern void cnss_remove_pm_qos(struct device *dev);
172extern void cnss_lock_pm_sem(struct device *dev);
173extern void cnss_release_pm_sem(struct device *dev);
174extern int cnss_wlan_pm_control(struct device *dev, bool vote);
175extern int cnss_auto_suspend(struct device *dev);
176extern int cnss_auto_resume(struct device *dev);
Yue Ma64167852018-08-07 16:47:09 -0700177extern int cnss_pci_force_wake_request(struct device *dev);
178extern int cnss_pci_is_device_awake(struct device *dev);
179extern int cnss_pci_force_wake_release(struct device *dev);
Yue Ma0317e4a2018-01-10 11:48:32 -0800180extern int cnss_get_user_msi_assignment(struct device *dev, char *user_name,
181 int *num_vectors,
182 uint32_t *user_base_data,
183 uint32_t *base_vector);
184extern int cnss_get_msi_irq(struct device *dev, unsigned int vector);
185extern void cnss_get_msi_address(struct device *dev, uint32_t *msi_addr_low,
186 uint32_t *msi_addr_high);
187extern int cnss_wlan_enable(struct device *dev,
188 struct cnss_wlan_enable_cfg *config,
189 enum cnss_driver_mode mode,
190 const char *host_version);
191extern int cnss_wlan_disable(struct device *dev, enum cnss_driver_mode mode);
Yue Mab79d4862018-07-11 12:32:12 -0700192extern unsigned int cnss_get_boot_timeout(struct device *dev);
Yue Ma0317e4a2018-01-10 11:48:32 -0800193extern int cnss_athdiag_read(struct device *dev, uint32_t offset,
194 uint32_t mem_type, uint32_t data_len,
195 uint8_t *output);
196extern int cnss_athdiag_write(struct device *dev, uint32_t offset,
197 uint32_t mem_type, uint32_t data_len,
198 uint8_t *input);
199extern int cnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode);
200
201#endif /* _NET_CNSS2_H */