blob: 6d5a4ab3b5347e01e31e40a5e1a57e9469e6dff7 [file] [log] [blame]
Yuanyuan Liud9f7a362016-01-22 14:27:12 -08001/*
Nirav Shahfb79af82018-03-12 18:10:33 +05302 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Yuanyuan Liud9f7a362016-01-22 14:27:12 -08003 *
Yuanyuan Liud9f7a362016-01-22 14:27:12 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080019#ifndef __PLD_PCIE_H__
20#define __PLD_PCIE_H__
21
Yuanyuan Liu16a55622016-09-14 16:15:59 -070022#ifdef CONFIG_PLD_PCIE_CNSS
Yue Mae6a7a322016-08-31 11:09:23 -070023#include <net/cnss2.h>
24#endif
Yuanyuan Liuf7aea122016-05-25 16:39:40 -070025#include "pld_internal.h"
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080026
Qun Zhang4a83a462018-09-11 16:28:51 +080027#ifdef MULTI_IF_NAME
28#define PREFIX MULTI_IF_NAME "/"
29#else
30#define PREFIX ""
31#endif
32
Nirav Shahfb79af82018-03-12 18:10:33 +053033#ifndef HIF_PCI
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080034static inline int pld_pcie_register_driver(void)
35{
36 return 0;
37}
38
39static inline void pld_pcie_unregister_driver(void)
40{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080041}
42
Yue Ma85761e62017-10-30 11:13:45 -070043static inline int pld_pcie_get_ce_id(struct device *dev, int irq)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080044{
45 return 0;
46}
47#else
48int pld_pcie_register_driver(void);
49void pld_pcie_unregister_driver(void);
Yue Ma85761e62017-10-30 11:13:45 -070050int pld_pcie_get_ce_id(struct device *dev, int irq);
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080051#endif
52
Yue Ma08047522016-11-08 18:53:26 -080053#ifndef CONFIG_PLD_PCIE_CNSS
54static inline int pld_pcie_wlan_enable(struct device *dev,
55 struct pld_wlan_enable_cfg *config,
56 enum pld_driver_mode mode,
57 const char *host_version)
58{
59 return 0;
60}
Yue Ma85761e62017-10-30 11:13:45 -070061
Yue Ma08047522016-11-08 18:53:26 -080062static inline int pld_pcie_wlan_disable(struct device *dev,
63 enum pld_driver_mode mode)
64{
65 return 0;
66}
67#else
68int pld_pcie_wlan_enable(struct device *dev, struct pld_wlan_enable_cfg *config,
69 enum pld_driver_mode mode, const char *host_version);
70int pld_pcie_wlan_disable(struct device *dev, enum pld_driver_mode mode);
71#endif
72
Nirav Shah74be3842018-06-26 19:17:25 +053073#if defined(CONFIG_PLD_PCIE_CNSS)
Yuanyuan Liu81982b92017-04-13 14:25:19 -070074static inline int pld_pcie_set_fw_log_mode(struct device *dev, u8 fw_log_mode)
75{
76 return cnss_set_fw_log_mode(dev, fw_log_mode);
77}
Yue Ma85761e62017-10-30 11:13:45 -070078
79static inline void pld_pcie_intr_notify_q6(struct device *dev)
Yuanyuan Liu81982b92017-04-13 14:25:19 -070080{
81}
82#else
83static inline int pld_pcie_set_fw_log_mode(struct device *dev, u8 fw_log_mode)
84{
85 return 0;
86}
Yue Ma85761e62017-10-30 11:13:45 -070087
88static inline void pld_pcie_intr_notify_q6(struct device *dev)
Yuanyuan Liu81982b92017-04-13 14:25:19 -070089{
90}
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080091#endif
92
Yuanyuan Liu11f526a2016-05-18 10:22:07 -070093#if (!defined(CONFIG_PLD_PCIE_CNSS)) || (!defined(CONFIG_CNSS_SECURE_FW))
Yue Ma85761e62017-10-30 11:13:45 -070094static inline int pld_pcie_get_sha_hash(struct device *dev, const u8 *data,
Yuanyuan Liu59f81e02016-05-19 16:17:38 -070095 u32 data_len, u8 *hash_idx, u8 *out)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080096{
97 return 0;
98}
Yue Ma85761e62017-10-30 11:13:45 -070099
100static inline void *pld_pcie_get_fw_ptr(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800101{
102 return NULL;
103}
Yuanyuan Liu59f81e02016-05-19 16:17:38 -0700104#else
Yue Ma85761e62017-10-30 11:13:45 -0700105static inline int pld_pcie_get_sha_hash(struct device *dev, const u8 *data,
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700106 u32 data_len, u8 *hash_idx, u8 *out)
107{
108 return cnss_get_sha_hash(data, data_len, hash_idx, out);
109}
Yue Ma85761e62017-10-30 11:13:45 -0700110
111static inline void *pld_pcie_get_fw_ptr(struct device *dev)
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700112{
113 return cnss_get_fw_ptr();
114}
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800115#endif
116
Yuanyuan Liu11f526a2016-05-18 10:22:07 -0700117#if (!defined(CONFIG_PLD_PCIE_CNSS)) || (!defined(CONFIG_PCI_MSM))
Yue Ma85761e62017-10-30 11:13:45 -0700118static inline int pld_pcie_wlan_pm_control(struct device *dev, bool vote)
Yuanyuan Liu466ccb72016-04-21 15:13:22 -0700119{
120 return 0;
121}
Yuanyuan Liu59f81e02016-05-19 16:17:38 -0700122#else
Yue Ma85761e62017-10-30 11:13:45 -0700123static inline int pld_pcie_wlan_pm_control(struct device *dev, bool vote)
124{
125 return cnss_wlan_pm_control(dev, vote);
126}
Yue Ma85761e62017-10-30 11:13:45 -0700127#endif
Yuanyuan Liu466ccb72016-04-21 15:13:22 -0700128
Yuanyuan Liu11f526a2016-05-18 10:22:07 -0700129#ifndef CONFIG_PLD_PCIE_CNSS
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800130static inline int
Yue Ma85761e62017-10-30 11:13:45 -0700131pld_pcie_get_fw_files_for_target(struct device *dev,
132 struct pld_fw_files *pfw_files,
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800133 u32 target_type, u32 target_version)
134{
Yuanyuan Liu6a313dc2016-05-10 14:19:10 -0700135 pld_get_default_fw_files(pfw_files);
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800136 return 0;
137}
Yue Ma85761e62017-10-30 11:13:45 -0700138
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800139static inline void pld_pcie_link_down(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800140{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800141}
Yue Ma85761e62017-10-30 11:13:45 -0700142
Yue Ma9c0e4802018-09-11 15:34:06 -0700143static inline int pld_pcie_is_fw_down(struct device *dev)
144{
145 return 0;
146}
147
Yue Ma6dbbb182017-04-26 17:06:05 -0700148static inline int pld_pcie_athdiag_read(struct device *dev, uint32_t offset,
149 uint32_t memtype, uint32_t datalen,
150 uint8_t *output)
151{
152 return 0;
153}
Yue Ma85761e62017-10-30 11:13:45 -0700154
Yue Ma6dbbb182017-04-26 17:06:05 -0700155static inline int pld_pcie_athdiag_write(struct device *dev, uint32_t offset,
156 uint32_t memtype, uint32_t datalen,
157 uint8_t *input)
158{
159 return 0;
160}
Yue Ma85761e62017-10-30 11:13:45 -0700161
162static inline void
163pld_pcie_schedule_recovery_work(struct device *dev,
164 enum pld_recovery_reason reason)
Yuanyuan Liu0e0aa932016-05-12 10:17:58 -0700165{
Yuanyuan Liu0e0aa932016-05-12 10:17:58 -0700166}
Yue Ma85761e62017-10-30 11:13:45 -0700167
168static inline void *pld_pcie_get_virt_ramdump_mem(struct device *dev,
169 unsigned long *size)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800170{
171 return NULL;
172}
Yue Ma85761e62017-10-30 11:13:45 -0700173
174static inline void pld_pcie_device_crashed(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800175{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800176}
Yue Ma85761e62017-10-30 11:13:45 -0700177
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800178static inline void pld_pcie_device_self_recovery(struct device *dev,
179 enum pld_recovery_reason reason)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800180{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800181}
Yue Ma85761e62017-10-30 11:13:45 -0700182
183static inline void pld_pcie_request_pm_qos(struct device *dev, u32 qos_val)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800184{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800185}
Yue Ma85761e62017-10-30 11:13:45 -0700186
187static inline void pld_pcie_remove_pm_qos(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800188{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800189}
Yue Ma85761e62017-10-30 11:13:45 -0700190
191static inline int pld_pcie_request_bus_bandwidth(struct device *dev,
192 int bandwidth)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800193{
194 return 0;
195}
Yue Ma85761e62017-10-30 11:13:45 -0700196
197static inline int pld_pcie_get_platform_cap(struct device *dev,
198 struct pld_platform_cap *cap)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800199{
200 return 0;
201}
Yue Ma85761e62017-10-30 11:13:45 -0700202
Yue Macd243862016-11-04 19:21:16 -0700203static inline int pld_pcie_get_soc_info(struct device *dev,
204 struct pld_soc_info *info)
205{
206 return 0;
207}
Yue Ma85761e62017-10-30 11:13:45 -0700208
Yue Ma5ff417c2017-10-30 11:13:12 -0700209static inline int pld_pcie_auto_suspend(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800210{
211 return 0;
212}
Yue Ma85761e62017-10-30 11:13:45 -0700213
214static inline int pld_pcie_auto_resume(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800215{
216 return 0;
217}
Yue Ma85761e62017-10-30 11:13:45 -0700218
Yue Mafb3b78d2018-08-08 11:51:21 -0700219static inline int pld_pcie_force_wake_request(struct device *dev)
220{
221 return 0;
222}
223
224static inline int pld_pcie_is_device_awake(struct device *dev)
225{
226 return true;
227}
228
229static inline int pld_pcie_force_wake_release(struct device *dev)
230{
231 return 0;
232}
233
Yue Ma85761e62017-10-30 11:13:45 -0700234static inline void pld_pcie_lock_pm_sem(struct device *dev)
Yuanyuan Liu44c44772016-04-11 11:11:27 -0700235{
Yuanyuan Liu44c44772016-04-11 11:11:27 -0700236}
Yue Ma85761e62017-10-30 11:13:45 -0700237
238static inline void pld_pcie_release_pm_sem(struct device *dev)
Yuanyuan Liu44c44772016-04-11 11:11:27 -0700239{
Yuanyuan Liu44c44772016-04-11 11:11:27 -0700240}
Yue Ma85761e62017-10-30 11:13:45 -0700241
Arun Khandavalli1496fcb2016-07-25 16:53:00 +0530242static inline int pld_pcie_power_on(struct device *dev)
243{
244 return 0;
245}
Yue Ma85761e62017-10-30 11:13:45 -0700246
Arun Khandavalli1496fcb2016-07-25 16:53:00 +0530247static inline int pld_pcie_power_off(struct device *dev)
248{
249 return 0;
250}
Yue Ma85761e62017-10-30 11:13:45 -0700251
Yue Ma63d360a2017-06-20 17:00:35 -0700252static inline int pld_pcie_force_assert_target(struct device *dev)
253{
254 return -EINVAL;
255}
Yue Ma85761e62017-10-30 11:13:45 -0700256
Yue Mafd418ea2016-11-21 16:47:13 -0800257static inline int pld_pcie_get_user_msi_assignment(struct device *dev,
258 char *user_name,
259 int *num_vectors,
260 uint32_t *user_base_data,
261 uint32_t *base_vector)
262{
263 return 0;
264}
Yue Ma85761e62017-10-30 11:13:45 -0700265
Yue Mafd418ea2016-11-21 16:47:13 -0800266static inline int pld_pcie_get_msi_irq(struct device *dev, unsigned int vector)
267{
268 return 0;
269}
Yue Ma85761e62017-10-30 11:13:45 -0700270
Yue Mafd418ea2016-11-21 16:47:13 -0800271static inline void pld_pcie_get_msi_address(struct device *dev,
272 uint32_t *msi_addr_low,
273 uint32_t *msi_addr_high)
274{
275 return;
276}
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800277#else
Yue Ma85761e62017-10-30 11:13:45 -0700278int pld_pcie_get_fw_files_for_target(struct device *dev,
279 struct pld_fw_files *pfw_files,
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800280 u32 target_type, u32 target_version);
Yue Ma85761e62017-10-30 11:13:45 -0700281int pld_pcie_get_platform_cap(struct device *dev, struct pld_platform_cap *cap);
Yue Macd243862016-11-04 19:21:16 -0700282int pld_pcie_get_soc_info(struct device *dev, struct pld_soc_info *info);
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800283void pld_pcie_schedule_recovery_work(struct device *dev,
284 enum pld_recovery_reason reason);
285void pld_pcie_device_self_recovery(struct device *dev,
286 enum pld_recovery_reason reason);
Komal Seelam355b1472016-09-02 14:36:21 +0530287
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800288static inline void pld_pcie_link_down(struct device *dev)
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700289{
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800290 cnss_pci_link_down(dev);
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700291}
Yue Ma85761e62017-10-30 11:13:45 -0700292
Yue Ma9c0e4802018-09-11 15:34:06 -0700293static inline int pld_pcie_is_fw_down(struct device *dev)
294{
295 return cnss_pci_is_device_down(dev);
296}
297
Yue Ma6dbbb182017-04-26 17:06:05 -0700298static inline int pld_pcie_athdiag_read(struct device *dev, uint32_t offset,
299 uint32_t memtype, uint32_t datalen,
300 uint8_t *output)
301{
302 return cnss_athdiag_read(dev, offset, memtype, datalen, output);
303}
Yue Ma85761e62017-10-30 11:13:45 -0700304
Yue Ma6dbbb182017-04-26 17:06:05 -0700305static inline int pld_pcie_athdiag_write(struct device *dev, uint32_t offset,
306 uint32_t memtype, uint32_t datalen,
307 uint8_t *input)
308{
309 return cnss_athdiag_write(dev, offset, memtype, datalen, input);
310}
Yue Ma85761e62017-10-30 11:13:45 -0700311
Yue Ma85761e62017-10-30 11:13:45 -0700312static inline void *pld_pcie_get_virt_ramdump_mem(struct device *dev,
313 unsigned long *size)
314{
315 return cnss_get_virt_ramdump_mem(dev, size);
316}
317
318static inline void pld_pcie_device_crashed(struct device *dev)
319{
320 cnss_device_crashed(dev);
321}
322
323static inline void pld_pcie_request_pm_qos(struct device *dev, u32 qos_val)
324{
325 cnss_request_pm_qos(dev, qos_val);
326}
327
328static inline void pld_pcie_remove_pm_qos(struct device *dev)
329{
330 cnss_remove_pm_qos(dev);
331}
332
333static inline int pld_pcie_request_bus_bandwidth(struct device *dev,
334 int bandwidth)
335{
336 return cnss_request_bus_bandwidth(dev, bandwidth);
337}
338
339static inline int pld_pcie_auto_suspend(struct device *dev)
340{
341 return cnss_auto_suspend(dev);
342}
343
344static inline int pld_pcie_auto_resume(struct device *dev)
345{
346 return cnss_auto_resume(dev);
347}
348
Yue Mafb3b78d2018-08-08 11:51:21 -0700349static inline int pld_pcie_force_wake_request(struct device *dev)
350{
351 return cnss_pci_force_wake_request(dev);
352}
353
354static inline int pld_pcie_is_device_awake(struct device *dev)
355{
356 return cnss_pci_is_device_awake(dev);
357}
358
359static inline int pld_pcie_force_wake_release(struct device *dev)
360{
361 return cnss_pci_force_wake_release(dev);
362}
363
Yue Ma85761e62017-10-30 11:13:45 -0700364static inline void pld_pcie_lock_pm_sem(struct device *dev)
365{
366 cnss_lock_pm_sem(dev);
367}
368
369static inline void pld_pcie_release_pm_sem(struct device *dev)
370{
371 cnss_release_pm_sem(dev);
372}
Yue Ma85761e62017-10-30 11:13:45 -0700373
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700374static inline int pld_pcie_power_on(struct device *dev)
375{
376 return cnss_power_up(dev);
377}
Yue Ma85761e62017-10-30 11:13:45 -0700378
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700379static inline int pld_pcie_power_off(struct device *dev)
380{
381 return cnss_power_down(dev);
382}
Yue Ma85761e62017-10-30 11:13:45 -0700383
Yue Ma63d360a2017-06-20 17:00:35 -0700384static inline int pld_pcie_force_assert_target(struct device *dev)
385{
386 return cnss_force_fw_assert(dev);
387}
Yue Ma85761e62017-10-30 11:13:45 -0700388
Yue Mafd418ea2016-11-21 16:47:13 -0800389static inline int pld_pcie_get_user_msi_assignment(struct device *dev,
390 char *user_name,
391 int *num_vectors,
392 uint32_t *user_base_data,
393 uint32_t *base_vector)
394{
395 return cnss_get_user_msi_assignment(dev, user_name, num_vectors,
396 user_base_data, base_vector);
397}
Yue Ma85761e62017-10-30 11:13:45 -0700398
Yue Mafd418ea2016-11-21 16:47:13 -0800399static inline int pld_pcie_get_msi_irq(struct device *dev, unsigned int vector)
400{
401 return cnss_get_msi_irq(dev, vector);
402}
Yue Ma85761e62017-10-30 11:13:45 -0700403
Yue Mafd418ea2016-11-21 16:47:13 -0800404static inline void pld_pcie_get_msi_address(struct device *dev,
405 uint32_t *msi_addr_low,
406 uint32_t *msi_addr_high)
407{
408 cnss_get_msi_address(dev, msi_addr_low, msi_addr_high);
409}
Komal Seelam355b1472016-09-02 14:36:21 +0530410#endif
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800411#endif