blob: 1951b40dcf5527a01538c847bddcdbdd804e76a8 [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>
Rajasekaran Kalidossff080602018-06-06 09:05:41 +053017#include <linux/usb.h>
Yue Ma0317e4a2018-01-10 11:48:32 -080018
19#define CNSS_MAX_FILE_NAME 20
20#define CNSS_MAX_TIMESTAMP_LEN 32
21
22/*
23 * Temporary change for compilation, will be removed
24 * after WLAN host driver switched to use new APIs
25 */
26#define CNSS_API_WITH_DEV
27
28enum cnss_bus_width_type {
29 CNSS_BUS_WIDTH_NONE,
30 CNSS_BUS_WIDTH_LOW,
31 CNSS_BUS_WIDTH_MEDIUM,
32 CNSS_BUS_WIDTH_HIGH
33};
34
35enum cnss_platform_cap_flag {
36 CNSS_HAS_EXTERNAL_SWREG = 0x01,
37 CNSS_HAS_UART_ACCESS = 0x02,
38};
39
40struct cnss_platform_cap {
41 u32 cap_flag;
42};
43
44struct cnss_fw_files {
45 char image_file[CNSS_MAX_FILE_NAME];
46 char board_data[CNSS_MAX_FILE_NAME];
47 char otp_data[CNSS_MAX_FILE_NAME];
48 char utf_file[CNSS_MAX_FILE_NAME];
49 char utf_board_data[CNSS_MAX_FILE_NAME];
50 char epping_file[CNSS_MAX_FILE_NAME];
51 char evicted_data[CNSS_MAX_FILE_NAME];
52};
53
Yue Ma6de7ba12019-04-17 15:05:28 -070054struct cnss_device_version {
55 u32 family_number;
56 u32 device_number;
57 u32 major_version;
58 u32 minor_version;
59};
60
Yue Ma0317e4a2018-01-10 11:48:32 -080061struct cnss_soc_info {
62 void __iomem *va;
63 phys_addr_t pa;
64 uint32_t chip_id;
65 uint32_t chip_family;
66 uint32_t board_id;
67 uint32_t soc_id;
68 uint32_t fw_version;
69 char fw_build_timestamp[CNSS_MAX_TIMESTAMP_LEN + 1];
Yue Ma6de7ba12019-04-17 15:05:28 -070070 struct cnss_device_version device_version;
Yue Ma0317e4a2018-01-10 11:48:32 -080071};
72
73struct cnss_wlan_runtime_ops {
74 int (*runtime_suspend)(struct pci_dev *pdev);
75 int (*runtime_resume)(struct pci_dev *pdev);
76};
77
78struct cnss_wlan_driver {
79 char *name;
80 int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id);
81 void (*remove)(struct pci_dev *pdev);
Yue Ma2ebdf5c2019-05-02 15:35:16 -070082 int (*idle_restart)(struct pci_dev *pdev,
83 const struct pci_device_id *id);
84 int (*idle_shutdown)(struct pci_dev *pdev);
Yue Ma0317e4a2018-01-10 11:48:32 -080085 int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id);
86 void (*shutdown)(struct pci_dev *pdev);
87 void (*crash_shutdown)(struct pci_dev *pdev);
88 int (*suspend)(struct pci_dev *pdev, pm_message_t state);
89 int (*resume)(struct pci_dev *pdev);
90 int (*suspend_noirq)(struct pci_dev *pdev);
91 int (*resume_noirq)(struct pci_dev *pdev);
92 void (*modem_status)(struct pci_dev *, int state);
93 void (*update_status)(struct pci_dev *pdev, uint32_t status);
94 struct cnss_wlan_runtime_ops *runtime_ops;
95 const struct pci_device_id *id_table;
96};
97
Rajasekaran Kalidossff080602018-06-06 09:05:41 +053098struct cnss_usb_wlan_driver {
99 char *name;
100 int (*probe)(struct usb_interface *pintf, const struct usb_device_id
101 *id);
102 void (*remove)(struct usb_interface *pintf);
103 int (*reinit)(struct usb_interface *pintf, const struct usb_device_id
104 *id);
105 void (*shutdown)(struct usb_interface *pintf);
106 void (*crash_shutdown)(struct usb_interface *pintf);
107 int (*suspend)(struct usb_interface *pintf, pm_message_t state);
108 int (*resume)(struct usb_interface *pintf);
109 int (*reset_resume)(struct usb_interface *pintf);
110 const struct usb_device_id *id_table;
111};
112
Yue Ma0317e4a2018-01-10 11:48:32 -0800113enum cnss_driver_status {
114 CNSS_UNINITIALIZED,
115 CNSS_INITIALIZED,
116 CNSS_LOAD_UNLOAD,
117 CNSS_RECOVERY,
Yue Ma8bead6d2018-02-01 12:25:47 -0800118 CNSS_FW_DOWN,
Yue Ma0317e4a2018-01-10 11:48:32 -0800119};
120
121struct cnss_ce_tgt_pipe_cfg {
122 u32 pipe_num;
123 u32 pipe_dir;
124 u32 nentries;
125 u32 nbytes_max;
126 u32 flags;
127 u32 reserved;
128};
129
130struct cnss_ce_svc_pipe_cfg {
131 u32 service_id;
132 u32 pipe_dir;
133 u32 pipe_num;
134};
135
136struct cnss_shadow_reg_cfg {
137 u16 ce_id;
138 u16 reg_offset;
139};
140
141struct cnss_shadow_reg_v2_cfg {
142 u32 addr;
143};
144
Jayachandran Sreekumaranb1be6c62018-10-04 16:06:06 +0530145struct cnss_rri_over_ddr_cfg {
146 u32 base_addr_low;
147 u32 base_addr_high;
148};
149
Yue Ma0317e4a2018-01-10 11:48:32 -0800150struct cnss_wlan_enable_cfg {
151 u32 num_ce_tgt_cfg;
152 struct cnss_ce_tgt_pipe_cfg *ce_tgt_cfg;
153 u32 num_ce_svc_pipe_cfg;
154 struct cnss_ce_svc_pipe_cfg *ce_svc_cfg;
155 u32 num_shadow_reg_cfg;
156 struct cnss_shadow_reg_cfg *shadow_reg_cfg;
157 u32 num_shadow_reg_v2_cfg;
158 struct cnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
Jayachandran Sreekumaranb1be6c62018-10-04 16:06:06 +0530159 bool rri_over_ddr_cfg_valid;
160 struct cnss_rri_over_ddr_cfg rri_over_ddr_cfg;
Yue Ma0317e4a2018-01-10 11:48:32 -0800161};
162
163enum cnss_driver_mode {
164 CNSS_MISSION,
165 CNSS_FTM,
166 CNSS_EPPING,
167 CNSS_WALTEST,
168 CNSS_OFF,
169 CNSS_CCPM,
170 CNSS_QVIT,
171 CNSS_CALIBRATION,
172};
173
174enum cnss_recovery_reason {
175 CNSS_REASON_DEFAULT,
176 CNSS_REASON_LINK_DOWN,
177 CNSS_REASON_RDDM,
178 CNSS_REASON_TIMEOUT,
179};
180
181extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver);
182extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver);
183extern void cnss_device_crashed(struct device *dev);
184extern int cnss_pci_link_down(struct device *dev);
Yue Ma41bc50a2018-09-10 17:20:54 -0700185extern int cnss_pci_is_device_down(struct device *dev);
Yue Ma0317e4a2018-01-10 11:48:32 -0800186extern void cnss_schedule_recovery(struct device *dev,
187 enum cnss_recovery_reason reason);
188extern int cnss_self_recovery(struct device *dev,
189 enum cnss_recovery_reason reason);
190extern int cnss_force_fw_assert(struct device *dev);
Yuanyuan Liu22184182018-12-03 15:29:44 -0800191extern int cnss_force_collect_rddm(struct device *dev);
Yue Ma0317e4a2018-01-10 11:48:32 -0800192extern void *cnss_get_virt_ramdump_mem(struct device *dev, unsigned long *size);
193extern int cnss_get_fw_files_for_target(struct device *dev,
194 struct cnss_fw_files *pfw_files,
195 u32 target_type, u32 target_version);
196extern int cnss_get_platform_cap(struct device *dev,
197 struct cnss_platform_cap *cap);
Frank Liu4fae0d12018-07-27 14:32:53 +0800198extern struct dma_iommu_mapping *cnss_smmu_get_mapping(struct device *dev);
199extern int cnss_smmu_map(struct device *dev,
200 phys_addr_t paddr, uint32_t *iova_addr, size_t size);
Yue Ma0317e4a2018-01-10 11:48:32 -0800201extern int cnss_get_soc_info(struct device *dev, struct cnss_soc_info *info);
202extern int cnss_request_bus_bandwidth(struct device *dev, int bandwidth);
203extern int cnss_power_up(struct device *dev);
204extern int cnss_power_down(struct device *dev);
Yue Ma2ebdf5c2019-05-02 15:35:16 -0700205extern int cnss_idle_restart(struct device *dev);
206extern int cnss_idle_shutdown(struct device *dev);
Yue Ma0317e4a2018-01-10 11:48:32 -0800207extern void cnss_request_pm_qos(struct device *dev, u32 qos_val);
208extern void cnss_remove_pm_qos(struct device *dev);
209extern void cnss_lock_pm_sem(struct device *dev);
210extern void cnss_release_pm_sem(struct device *dev);
211extern int cnss_wlan_pm_control(struct device *dev, bool vote);
212extern int cnss_auto_suspend(struct device *dev);
213extern int cnss_auto_resume(struct device *dev);
Yue Mae74079e2019-04-19 13:42:35 -0700214extern int cnss_pci_is_drv_connected(struct device *dev);
Yue Ma64167852018-08-07 16:47:09 -0700215extern int cnss_pci_force_wake_request(struct device *dev);
216extern int cnss_pci_is_device_awake(struct device *dev);
217extern int cnss_pci_force_wake_release(struct device *dev);
Yue Ma0317e4a2018-01-10 11:48:32 -0800218extern int cnss_get_user_msi_assignment(struct device *dev, char *user_name,
219 int *num_vectors,
220 uint32_t *user_base_data,
221 uint32_t *base_vector);
222extern int cnss_get_msi_irq(struct device *dev, unsigned int vector);
223extern void cnss_get_msi_address(struct device *dev, uint32_t *msi_addr_low,
224 uint32_t *msi_addr_high);
225extern int cnss_wlan_enable(struct device *dev,
226 struct cnss_wlan_enable_cfg *config,
227 enum cnss_driver_mode mode,
228 const char *host_version);
229extern int cnss_wlan_disable(struct device *dev, enum cnss_driver_mode mode);
Yue Mab79d4862018-07-11 12:32:12 -0700230extern unsigned int cnss_get_boot_timeout(struct device *dev);
Yue Ma0317e4a2018-01-10 11:48:32 -0800231extern int cnss_athdiag_read(struct device *dev, uint32_t offset,
232 uint32_t mem_type, uint32_t data_len,
233 uint8_t *output);
234extern int cnss_athdiag_write(struct device *dev, uint32_t offset,
235 uint32_t mem_type, uint32_t data_len,
236 uint8_t *input);
237extern int cnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode);
Rajasekaran Kalidossff080602018-06-06 09:05:41 +0530238extern int cnss_usb_wlan_register_driver(struct cnss_usb_wlan_driver *driver);
239extern void cnss_usb_wlan_unregister_driver(struct cnss_usb_wlan_driver *
240 driver);
Yue Ma0317e4a2018-01-10 11:48:32 -0800241#endif /* _NET_CNSS2_H */