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