blob: 39b7f5e5470469cb4b0bde5cea375ef8937b1e75 [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
105/* WLAN driver status */
106enum cnss_driver_status {
107 CNSS_UNINITIALIZED,
108 CNSS_INITIALIZED,
109 CNSS_LOAD_UNLOAD
110};
111
112enum cnss_runtime_request {
113 CNSS_PM_RUNTIME_GET,
114 CNSS_PM_RUNTIME_PUT,
115 CNSS_PM_RUNTIME_MARK_LAST_BUSY,
116 CNSS_PM_RUNTIME_RESUME,
117 CNSS_PM_RUNTIME_PUT_NOIDLE,
118 CNSS_PM_REQUEST_RESUME,
119 CNSS_PM_RUNTIME_PUT_AUTO,
120 CNSS_PM_GET_NORESUME,
121};
122
Tang Yingyinga154fba2018-03-07 17:27:19 +0800123extern struct dma_iommu_mapping *cnss_smmu_get_mapping(void);
124extern int cnss_smmu_map(phys_addr_t paddr, uint32_t *iova_addr, size_t size);
Kai Liu4cf21392017-12-15 21:14:08 +0800125extern int cnss_get_fw_image(struct image_desc_info *image_desc_info);
126extern void cnss_runtime_init(struct device *dev, int auto_delay);
127extern void cnss_runtime_exit(struct device *dev);
128extern void cnss_wlan_pci_link_down(void);
129extern int cnss_pcie_shadow_control(struct pci_dev *dev, bool enable);
130extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver);
131extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver);
132extern int cnss_get_fw_files(struct cnss_fw_files *pfw_files);
133extern int cnss_get_fw_files_for_target(struct cnss_fw_files *pfw_files,
134 u32 target_type, u32 target_version);
135extern void cnss_get_qca9377_fw_files(struct cnss_fw_files *pfw_files,
136 u32 size, u32 tufello_dual_fw);
137
138extern int cnss_request_bus_bandwidth(int bandwidth);
139
140#ifdef CONFIG_CNSS_SECURE_FW
141extern int cnss_get_sha_hash(const u8 *data, u32 data_len,
142 u8 *hash_idx, u8 *out);
143extern void *cnss_get_fw_ptr(void);
144#endif
145
146extern int cnss_get_codeswap_struct(struct codeswap_codeseg_info *swap_seg);
147extern int cnss_get_bmi_setup(void);
148
149#ifdef CONFIG_PCI_MSM
150extern int cnss_wlan_pm_control(bool vote);
151#endif
152extern void cnss_lock_pm_sem(void);
153extern void cnss_release_pm_sem(void);
154
155extern void cnss_request_pm_qos_type(int latency_type, u32 qos_val);
156extern void cnss_request_pm_qos(u32 qos_val);
157extern void cnss_remove_pm_qos(void);
158
159extern void cnss_pci_request_pm_qos_type(int latency_type, u32 qos_val);
160extern void cnss_pci_request_pm_qos(u32 qos_val);
161extern void cnss_pci_remove_pm_qos(void);
162
163extern void cnss_sdio_request_pm_qos_type(int latency_type, u32 qos_val);
164extern void cnss_sdio_request_pm_qos(u32 qos_val);
165extern void cnss_sdio_remove_pm_qos(void);
166
167extern int cnss_get_platform_cap(struct cnss_platform_cap *cap);
168extern void cnss_set_driver_status(enum cnss_driver_status driver_status);
169
170#ifndef CONFIG_WCNSS_MEM_PRE_ALLOC
171static inline int wcnss_pre_alloc_reset(void) { return 0; }
172#endif
173
174extern int msm_pcie_enumerate(u32 rc_idx);
175extern int cnss_auto_suspend(void);
176extern int cnss_auto_resume(void);
177extern int cnss_prevent_auto_suspend(const char *caller_func);
178extern int cnss_allow_auto_suspend(const char *caller_func);
179extern int cnss_is_auto_suspend_allowed(const char *caller_func);
180
181extern int cnss_pm_runtime_request(struct device *dev, enum
182 cnss_runtime_request request);
183extern void cnss_set_cc_source(enum cnss_cc_src cc_source);
184extern enum cnss_cc_src cnss_get_cc_source(void);
185#endif
186
187extern void cnss_pm_wake_lock_init(struct wakeup_source *ws, const char *name);
188extern void cnss_pm_wake_lock(struct wakeup_source *ws);
189
190extern void cnss_device_crashed(void);
191extern void cnss_device_self_recovery(void);
192extern void *cnss_get_virt_ramdump_mem(unsigned long *size);
193
194extern void cnss_schedule_recovery_work(void);
195extern int cnss_pcie_set_wlan_mac_address(const u8 *in, uint32_t len);
196extern u8 *cnss_get_wlan_mac_address(struct device *dev, uint32_t *num);
197extern int cnss_sdio_set_wlan_mac_address(const u8 *in, uint32_t len);
198
199enum {
200 CNSS_RESET_SOC = 0,
201 CNSS_RESET_SUBSYS_COUPLED,
202 CNSS_RESET_LEVEL_MAX
203};
204extern int cnss_get_restart_level(void);
205
206struct cnss_sdio_wlan_driver {
207 const char *name;
208 const struct sdio_device_id *id_table;
209 int (*probe)(struct sdio_func *, const struct sdio_device_id *);
210 void (*remove)(struct sdio_func *);
211 int (*reinit)(struct sdio_func *, const struct sdio_device_id *);
212 void (*shutdown)(struct sdio_func *);
213 void (*crash_shutdown)(struct sdio_func *);
214 int (*suspend)(struct device *);
215 int (*resume)(struct device *);
216};
217
218extern int cnss_sdio_wlan_register_driver(
219 struct cnss_sdio_wlan_driver *driver);
220extern void cnss_sdio_wlan_unregister_driver(
221 struct cnss_sdio_wlan_driver *driver);
222
223typedef void (*oob_irq_handler_t)(void *dev_para);
224extern int cnss_wlan_query_oob_status(void);
225extern int cnss_wlan_register_oob_irq_handler(oob_irq_handler_t handler,
226 void *pm_oob);
227extern int cnss_wlan_unregister_oob_irq_handler(void *pm_oob);
228
229
230extern void cnss_dump_stack(struct task_struct *task);
231extern u8 *cnss_common_get_wlan_mac_address(struct device *dev, uint32_t *num);
232extern void cnss_init_work(struct work_struct *work, work_func_t func);
233extern void cnss_flush_delayed_work(void *dwork);
234extern void cnss_flush_work(void *work);
235extern void cnss_pm_wake_lock_timeout(struct wakeup_source *ws, ulong msec);
236extern void cnss_pm_wake_lock_release(struct wakeup_source *ws);
237extern void cnss_pm_wake_lock_destroy(struct wakeup_source *ws);
238extern void cnss_get_monotonic_boottime(struct timespec *ts);
239extern void cnss_get_boottime(struct timespec *ts);
240extern void cnss_init_delayed_work(struct delayed_work *work, work_func_t
241 func);
242extern int cnss_vendor_cmd_reply(struct sk_buff *skb);
243extern int cnss_set_cpus_allowed_ptr(struct task_struct *task, ulong cpu);
244extern int cnss_set_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 ch_count);
245extern int cnss_get_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 *ch_count,
246 u16 buf_len);
247extern int cnss_wlan_set_dfs_nol(const void *info, u16 info_len);
248extern int cnss_wlan_get_dfs_nol(void *info, u16 info_len);
249extern int cnss_common_request_bus_bandwidth(struct device *dev, int
250 bandwidth);
251extern void cnss_common_device_crashed(struct device *dev);
252extern void cnss_common_device_self_recovery(struct device *dev);
253extern void *cnss_common_get_virt_ramdump_mem(struct device *dev, unsigned long
254 *size);
255extern void cnss_common_schedule_recovery_work(struct device *dev);
256extern int cnss_common_set_wlan_mac_address(struct device *dev, const u8 *in,
257 uint32_t len);
258extern u8 *cnss_common_get_wlan_mac_address(struct device *dev, uint32_t *num);
259extern int cnss_power_up(struct device *dev);
260extern int cnss_power_down(struct device *dev);
261extern int cnss_sdio_configure_spdt(bool state);
262
263extern int cnss_common_register_tsf_captured_handler(struct device *dev,
264 irq_handler_t handler,
265 void *ctx);
266extern int cnss_common_unregister_tsf_captured_handler(struct device *dev,
267 void *ctx);
268#endif /* _NET_CNSS_H_ */