blob: 3b864fc738861dab1c82d586f7fa594f51a3dd95 [file] [log] [blame]
Kai Liu4cf21392017-12-15 21:14:08 +08001/* 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
15#include <linux/device.h>
16#include <linux/skbuff.h>
17#include <linux/pci.h>
18#include <linux/mmc/sdio_func.h>
19#include <linux/interrupt.h>
20
21#ifdef CONFIG_CNSS
22#define MAX_FIRMWARE_SIZE (1 * 1024 * 1024)
23#define CNSS_MAX_FILE_NAME 20
24#define PINCTRL_SLEEP 0
25#define PINCTRL_ACTIVE 1
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_cc_src {
35 CNSS_SOURCE_CORE,
36 CNSS_SOURCE_11D,
37 CNSS_SOURCE_USER
38};
39
40/* FW image files */
41struct cnss_fw_files {
42 char image_file[CNSS_MAX_FILE_NAME];
43 char board_data[CNSS_MAX_FILE_NAME];
44 char otp_data[CNSS_MAX_FILE_NAME];
45 char utf_file[CNSS_MAX_FILE_NAME];
46 char utf_board_data[CNSS_MAX_FILE_NAME];
47 char epping_file[CNSS_MAX_FILE_NAME];
48 char evicted_data[CNSS_MAX_FILE_NAME];
49};
50
51struct cnss_wlan_runtime_ops {
52 int (*runtime_suspend)(struct pci_dev *pdev);
53 int (*runtime_resume)(struct pci_dev *pdev);
54};
55
56struct cnss_wlan_driver {
57 char *name;
58 int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id);
59 void (*remove)(struct pci_dev *pdev);
60 int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id);
61 void (*shutdown)(struct pci_dev *pdev);
62 void (*crash_shutdown)(struct pci_dev *pdev);
63 int (*suspend)(struct pci_dev *pdev, pm_message_t state);
64 int (*resume)(struct pci_dev *pdev);
65 void (*modem_status)(struct pci_dev *, int state);
66 void (*update_status)(struct pci_dev *pdev, uint32_t status);
67 struct cnss_wlan_runtime_ops *runtime_ops;
68 const struct pci_device_id *id_table;
69};
70
71/*
72 * codeseg_total_bytes: Total bytes across all the codesegment blocks
73 * num_codesegs: No of Pages used
74 * codeseg_size: Size of each segment. Should be power of 2 and multiple of 4K
75 * codeseg_size_log2: log2(codeseg_size)
76 * codeseg_busaddr: Physical address of the DMAble memory;4K aligned
77 */
78
79#define CODESWAP_MAX_CODESEGS 16
80struct codeswap_codeseg_info {
81 u32 codeseg_total_bytes;
82 u32 num_codesegs;
83 u32 codeseg_size;
84 u32 codeseg_size_log2;
85 void *codeseg_busaddr[CODESWAP_MAX_CODESEGS];
86};
87
88struct image_desc_info {
89 dma_addr_t fw_addr;
90 u32 fw_size;
91 dma_addr_t bdata_addr;
92 u32 bdata_size;
93};
94
95/* platform capabilities */
96enum cnss_platform_cap_flag {
97 CNSS_HAS_EXTERNAL_SWREG = 0x01,
98 CNSS_HAS_UART_ACCESS = 0x02,
99};
100
101struct cnss_platform_cap {
102 u32 cap_flag;
103};
104
Yu Wange1d64b82017-12-26 14:43:21 +0800105/* WLAN driver status, keep it aligned with cnss2 */
Kai Liu4cf21392017-12-15 21:14:08 +0800106enum cnss_driver_status {
107 CNSS_UNINITIALIZED,
108 CNSS_INITIALIZED,
Yu Wange1d64b82017-12-26 14:43:21 +0800109 CNSS_LOAD_UNLOAD,
110 CNSS_RECOVERY,
111 CNSS_FW_DOWN,
112 CNSS_SSR_FAIL,
Kai Liu4cf21392017-12-15 21:14:08 +0800113};
114
115enum cnss_runtime_request {
116 CNSS_PM_RUNTIME_GET,
117 CNSS_PM_RUNTIME_PUT,
118 CNSS_PM_RUNTIME_MARK_LAST_BUSY,
119 CNSS_PM_RUNTIME_RESUME,
120 CNSS_PM_RUNTIME_PUT_NOIDLE,
121 CNSS_PM_REQUEST_RESUME,
122 CNSS_PM_RUNTIME_PUT_AUTO,
123 CNSS_PM_GET_NORESUME,
124};
125
Tang Yingyinga154fba2018-03-07 17:27:19 +0800126extern struct dma_iommu_mapping *cnss_smmu_get_mapping(void);
127extern int cnss_smmu_map(phys_addr_t paddr, uint32_t *iova_addr, size_t size);
Kai Liu4cf21392017-12-15 21:14:08 +0800128extern int cnss_get_fw_image(struct image_desc_info *image_desc_info);
129extern void cnss_runtime_init(struct device *dev, int auto_delay);
130extern void cnss_runtime_exit(struct device *dev);
131extern void cnss_wlan_pci_link_down(void);
132extern int cnss_pcie_shadow_control(struct pci_dev *dev, bool enable);
133extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver);
134extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver);
135extern int cnss_get_fw_files(struct cnss_fw_files *pfw_files);
136extern int cnss_get_fw_files_for_target(struct cnss_fw_files *pfw_files,
137 u32 target_type, u32 target_version);
138extern void cnss_get_qca9377_fw_files(struct cnss_fw_files *pfw_files,
139 u32 size, u32 tufello_dual_fw);
140
141extern int cnss_request_bus_bandwidth(int bandwidth);
142
143#ifdef CONFIG_CNSS_SECURE_FW
144extern int cnss_get_sha_hash(const u8 *data, u32 data_len,
145 u8 *hash_idx, u8 *out);
146extern void *cnss_get_fw_ptr(void);
147#endif
148
149extern int cnss_get_codeswap_struct(struct codeswap_codeseg_info *swap_seg);
150extern int cnss_get_bmi_setup(void);
151
152#ifdef CONFIG_PCI_MSM
153extern int cnss_wlan_pm_control(bool vote);
154#endif
155extern void cnss_lock_pm_sem(void);
156extern void cnss_release_pm_sem(void);
157
158extern void cnss_request_pm_qos_type(int latency_type, u32 qos_val);
159extern void cnss_request_pm_qos(u32 qos_val);
160extern void cnss_remove_pm_qos(void);
161
162extern void cnss_pci_request_pm_qos_type(int latency_type, u32 qos_val);
163extern void cnss_pci_request_pm_qos(u32 qos_val);
164extern void cnss_pci_remove_pm_qos(void);
165
166extern void cnss_sdio_request_pm_qos_type(int latency_type, u32 qos_val);
167extern void cnss_sdio_request_pm_qos(u32 qos_val);
168extern void cnss_sdio_remove_pm_qos(void);
169
170extern int cnss_get_platform_cap(struct cnss_platform_cap *cap);
171extern void cnss_set_driver_status(enum cnss_driver_status driver_status);
172
173#ifndef CONFIG_WCNSS_MEM_PRE_ALLOC
174static inline int wcnss_pre_alloc_reset(void) { return 0; }
175#endif
176
177extern int msm_pcie_enumerate(u32 rc_idx);
178extern int cnss_auto_suspend(void);
179extern int cnss_auto_resume(void);
180extern int cnss_prevent_auto_suspend(const char *caller_func);
181extern int cnss_allow_auto_suspend(const char *caller_func);
182extern int cnss_is_auto_suspend_allowed(const char *caller_func);
183
184extern int cnss_pm_runtime_request(struct device *dev, enum
185 cnss_runtime_request request);
186extern void cnss_set_cc_source(enum cnss_cc_src cc_source);
187extern enum cnss_cc_src cnss_get_cc_source(void);
188#endif
189
190extern void cnss_pm_wake_lock_init(struct wakeup_source *ws, const char *name);
191extern void cnss_pm_wake_lock(struct wakeup_source *ws);
192
193extern void cnss_device_crashed(void);
194extern void cnss_device_self_recovery(void);
195extern void *cnss_get_virt_ramdump_mem(unsigned long *size);
196
197extern void cnss_schedule_recovery_work(void);
198extern int cnss_pcie_set_wlan_mac_address(const u8 *in, uint32_t len);
199extern u8 *cnss_get_wlan_mac_address(struct device *dev, uint32_t *num);
200extern int cnss_sdio_set_wlan_mac_address(const u8 *in, uint32_t len);
201
202enum {
203 CNSS_RESET_SOC = 0,
204 CNSS_RESET_SUBSYS_COUPLED,
205 CNSS_RESET_LEVEL_MAX
206};
207extern int cnss_get_restart_level(void);
208
209struct cnss_sdio_wlan_driver {
210 const char *name;
211 const struct sdio_device_id *id_table;
212 int (*probe)(struct sdio_func *, const struct sdio_device_id *);
213 void (*remove)(struct sdio_func *);
214 int (*reinit)(struct sdio_func *, const struct sdio_device_id *);
215 void (*shutdown)(struct sdio_func *);
216 void (*crash_shutdown)(struct sdio_func *);
217 int (*suspend)(struct device *);
218 int (*resume)(struct device *);
219};
220
221extern int cnss_sdio_wlan_register_driver(
222 struct cnss_sdio_wlan_driver *driver);
223extern void cnss_sdio_wlan_unregister_driver(
224 struct cnss_sdio_wlan_driver *driver);
225
226typedef void (*oob_irq_handler_t)(void *dev_para);
227extern int cnss_wlan_query_oob_status(void);
228extern int cnss_wlan_register_oob_irq_handler(oob_irq_handler_t handler,
229 void *pm_oob);
230extern int cnss_wlan_unregister_oob_irq_handler(void *pm_oob);
231
232
233extern void cnss_dump_stack(struct task_struct *task);
234extern u8 *cnss_common_get_wlan_mac_address(struct device *dev, uint32_t *num);
235extern void cnss_init_work(struct work_struct *work, work_func_t func);
236extern void cnss_flush_delayed_work(void *dwork);
237extern void cnss_flush_work(void *work);
238extern void cnss_pm_wake_lock_timeout(struct wakeup_source *ws, ulong msec);
239extern void cnss_pm_wake_lock_release(struct wakeup_source *ws);
240extern void cnss_pm_wake_lock_destroy(struct wakeup_source *ws);
241extern void cnss_get_monotonic_boottime(struct timespec *ts);
242extern void cnss_get_boottime(struct timespec *ts);
243extern void cnss_init_delayed_work(struct delayed_work *work, work_func_t
244 func);
245extern int cnss_vendor_cmd_reply(struct sk_buff *skb);
246extern int cnss_set_cpus_allowed_ptr(struct task_struct *task, ulong cpu);
247extern int cnss_set_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 ch_count);
248extern int cnss_get_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 *ch_count,
249 u16 buf_len);
250extern int cnss_wlan_set_dfs_nol(const void *info, u16 info_len);
251extern int cnss_wlan_get_dfs_nol(void *info, u16 info_len);
252extern int cnss_common_request_bus_bandwidth(struct device *dev, int
253 bandwidth);
254extern void cnss_common_device_crashed(struct device *dev);
255extern void cnss_common_device_self_recovery(struct device *dev);
256extern void *cnss_common_get_virt_ramdump_mem(struct device *dev, unsigned long
257 *size);
258extern void cnss_common_schedule_recovery_work(struct device *dev);
259extern int cnss_common_set_wlan_mac_address(struct device *dev, const u8 *in,
260 uint32_t len);
261extern u8 *cnss_common_get_wlan_mac_address(struct device *dev, uint32_t *num);
262extern int cnss_power_up(struct device *dev);
263extern int cnss_power_down(struct device *dev);
264extern int cnss_sdio_configure_spdt(bool state);
265
266extern int cnss_common_register_tsf_captured_handler(struct device *dev,
267 irq_handler_t handler,
268 void *ctx);
269extern int cnss_common_unregister_tsf_captured_handler(struct device *dev,
270 void *ctx);
271#endif /* _NET_CNSS_H_ */