blob: 302513e1c8a7c19bce4e9164cb01476678200e44 [file] [log] [blame]
Yuanyuan Liud9f7a362016-01-22 14:27:12 -08001/*
Yu Wang7d866f62019-03-13 17:55:44 +08002 * Copyright (c) 2016-2019 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
Yu Wang7d866f62019-03-13 17:55:44 +080027#ifdef DYNAMIC_SINGLE_CHIP
28#define PREFIX DYNAMIC_SINGLE_CHIP "/"
29#else
30
Qun Zhang4a83a462018-09-11 16:28:51 +080031#ifdef MULTI_IF_NAME
32#define PREFIX MULTI_IF_NAME "/"
33#else
34#define PREFIX ""
35#endif
36
Yu Wang7d866f62019-03-13 17:55:44 +080037#endif
38
Nirav Shahfb79af82018-03-12 18:10:33 +053039#ifndef HIF_PCI
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080040static inline int pld_pcie_register_driver(void)
41{
42 return 0;
43}
44
45static inline void pld_pcie_unregister_driver(void)
46{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080047}
48
Yue Ma85761e62017-10-30 11:13:45 -070049static inline int pld_pcie_get_ce_id(struct device *dev, int irq)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080050{
51 return 0;
52}
53#else
54int pld_pcie_register_driver(void);
55void pld_pcie_unregister_driver(void);
Yue Ma85761e62017-10-30 11:13:45 -070056int pld_pcie_get_ce_id(struct device *dev, int irq);
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080057#endif
58
Yue Ma08047522016-11-08 18:53:26 -080059#ifndef CONFIG_PLD_PCIE_CNSS
60static inline int pld_pcie_wlan_enable(struct device *dev,
61 struct pld_wlan_enable_cfg *config,
62 enum pld_driver_mode mode,
63 const char *host_version)
64{
65 return 0;
66}
Yue Ma85761e62017-10-30 11:13:45 -070067
Yue Ma08047522016-11-08 18:53:26 -080068static inline int pld_pcie_wlan_disable(struct device *dev,
69 enum pld_driver_mode mode)
70{
71 return 0;
72}
73#else
74int pld_pcie_wlan_enable(struct device *dev, struct pld_wlan_enable_cfg *config,
75 enum pld_driver_mode mode, const char *host_version);
76int pld_pcie_wlan_disable(struct device *dev, enum pld_driver_mode mode);
77#endif
78
Nirav Shah74be3842018-06-26 19:17:25 +053079#if defined(CONFIG_PLD_PCIE_CNSS)
Yuanyuan Liu81982b92017-04-13 14:25:19 -070080static inline int pld_pcie_set_fw_log_mode(struct device *dev, u8 fw_log_mode)
81{
82 return cnss_set_fw_log_mode(dev, fw_log_mode);
83}
Yue Ma85761e62017-10-30 11:13:45 -070084
85static inline void pld_pcie_intr_notify_q6(struct device *dev)
Yuanyuan Liu81982b92017-04-13 14:25:19 -070086{
87}
88#else
89static inline int pld_pcie_set_fw_log_mode(struct device *dev, u8 fw_log_mode)
90{
91 return 0;
92}
Yue Ma85761e62017-10-30 11:13:45 -070093
94static inline void pld_pcie_intr_notify_q6(struct device *dev)
Yuanyuan Liu81982b92017-04-13 14:25:19 -070095{
96}
Yuanyuan Liud9f7a362016-01-22 14:27:12 -080097#endif
98
Yuanyuan Liu11f526a2016-05-18 10:22:07 -070099#if (!defined(CONFIG_PLD_PCIE_CNSS)) || (!defined(CONFIG_CNSS_SECURE_FW))
Yue Ma85761e62017-10-30 11:13:45 -0700100static inline int pld_pcie_get_sha_hash(struct device *dev, const u8 *data,
Yuanyuan Liu59f81e02016-05-19 16:17:38 -0700101 u32 data_len, u8 *hash_idx, u8 *out)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800102{
103 return 0;
104}
Yue Ma85761e62017-10-30 11:13:45 -0700105
106static inline void *pld_pcie_get_fw_ptr(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800107{
108 return NULL;
109}
Yuanyuan Liu59f81e02016-05-19 16:17:38 -0700110#else
Yue Ma85761e62017-10-30 11:13:45 -0700111static inline int pld_pcie_get_sha_hash(struct device *dev, const u8 *data,
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700112 u32 data_len, u8 *hash_idx, u8 *out)
113{
114 return cnss_get_sha_hash(data, data_len, hash_idx, out);
115}
Yue Ma85761e62017-10-30 11:13:45 -0700116
117static inline void *pld_pcie_get_fw_ptr(struct device *dev)
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700118{
119 return cnss_get_fw_ptr();
120}
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800121#endif
122
Yuanyuan Liu11f526a2016-05-18 10:22:07 -0700123#if (!defined(CONFIG_PLD_PCIE_CNSS)) || (!defined(CONFIG_PCI_MSM))
Yue Ma85761e62017-10-30 11:13:45 -0700124static inline int pld_pcie_wlan_pm_control(struct device *dev, bool vote)
Yuanyuan Liu466ccb72016-04-21 15:13:22 -0700125{
126 return 0;
127}
Yuanyuan Liu59f81e02016-05-19 16:17:38 -0700128#else
Yue Ma85761e62017-10-30 11:13:45 -0700129static inline int pld_pcie_wlan_pm_control(struct device *dev, bool vote)
130{
131 return cnss_wlan_pm_control(dev, vote);
132}
Yue Ma85761e62017-10-30 11:13:45 -0700133#endif
Yuanyuan Liu466ccb72016-04-21 15:13:22 -0700134
Yuanyuan Liu11f526a2016-05-18 10:22:07 -0700135#ifndef CONFIG_PLD_PCIE_CNSS
Frank Liud462d9c2018-07-27 14:43:26 +0800136static inline void *pld_pcie_smmu_get_mapping(struct device *dev)
137{
138 return NULL;
139}
140
141static inline int
142pld_pcie_smmu_map(struct device *dev,
143 phys_addr_t paddr, uint32_t *iova_addr, size_t size)
144{
145 return 0;
146}
147
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800148static inline int
Yue Ma85761e62017-10-30 11:13:45 -0700149pld_pcie_get_fw_files_for_target(struct device *dev,
150 struct pld_fw_files *pfw_files,
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800151 u32 target_type, u32 target_version)
152{
Yuanyuan Liu6a313dc2016-05-10 14:19:10 -0700153 pld_get_default_fw_files(pfw_files);
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800154 return 0;
155}
Yue Ma85761e62017-10-30 11:13:45 -0700156
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800157static inline void pld_pcie_link_down(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800158{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800159}
Yue Ma85761e62017-10-30 11:13:45 -0700160
Yue Ma9c0e4802018-09-11 15:34:06 -0700161static inline int pld_pcie_is_fw_down(struct device *dev)
162{
163 return 0;
164}
165
Yue Ma6dbbb182017-04-26 17:06:05 -0700166static inline int pld_pcie_athdiag_read(struct device *dev, uint32_t offset,
167 uint32_t memtype, uint32_t datalen,
168 uint8_t *output)
169{
170 return 0;
171}
Yue Ma85761e62017-10-30 11:13:45 -0700172
Yue Ma6dbbb182017-04-26 17:06:05 -0700173static inline int pld_pcie_athdiag_write(struct device *dev, uint32_t offset,
174 uint32_t memtype, uint32_t datalen,
175 uint8_t *input)
176{
177 return 0;
178}
Yue Ma85761e62017-10-30 11:13:45 -0700179
180static inline void
181pld_pcie_schedule_recovery_work(struct device *dev,
182 enum pld_recovery_reason reason)
Yuanyuan Liu0e0aa932016-05-12 10:17:58 -0700183{
Yuanyuan Liu0e0aa932016-05-12 10:17:58 -0700184}
Yue Ma85761e62017-10-30 11:13:45 -0700185
186static inline void *pld_pcie_get_virt_ramdump_mem(struct device *dev,
187 unsigned long *size)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800188{
Yu Ouyang58648a52018-11-01 11:18:15 +0800189 size_t length = 0;
190 int flags = GFP_KERNEL;
191
192 length = TOTAL_DUMP_SIZE;
193
194 if (!size)
195 return NULL;
196
197 *size = (unsigned long)length;
198
199 if (in_interrupt() || irqs_disabled() || in_atomic())
200 flags = GFP_ATOMIC;
201
202 return kzalloc(length, flags);
203}
204
205static inline void pld_pcie_release_virt_ramdump_mem(void *address)
206{
207 kfree(address);
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800208}
Yue Ma85761e62017-10-30 11:13:45 -0700209
210static inline void pld_pcie_device_crashed(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800211{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800212}
Yue Ma85761e62017-10-30 11:13:45 -0700213
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800214static inline void pld_pcie_device_self_recovery(struct device *dev,
215 enum pld_recovery_reason reason)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800216{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800217}
Yue Ma85761e62017-10-30 11:13:45 -0700218
219static inline void pld_pcie_request_pm_qos(struct device *dev, u32 qos_val)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800220{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800221}
Yue Ma85761e62017-10-30 11:13:45 -0700222
223static inline void pld_pcie_remove_pm_qos(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800224{
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800225}
Yue Ma85761e62017-10-30 11:13:45 -0700226
227static inline int pld_pcie_request_bus_bandwidth(struct device *dev,
228 int bandwidth)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800229{
230 return 0;
231}
Yue Ma85761e62017-10-30 11:13:45 -0700232
233static inline int pld_pcie_get_platform_cap(struct device *dev,
234 struct pld_platform_cap *cap)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800235{
236 return 0;
237}
Yue Ma85761e62017-10-30 11:13:45 -0700238
Yue Macd243862016-11-04 19:21:16 -0700239static inline int pld_pcie_get_soc_info(struct device *dev,
240 struct pld_soc_info *info)
241{
242 return 0;
243}
Yue Ma85761e62017-10-30 11:13:45 -0700244
Yue Ma5ff417c2017-10-30 11:13:12 -0700245static inline int pld_pcie_auto_suspend(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800246{
247 return 0;
248}
Yue Ma85761e62017-10-30 11:13:45 -0700249
250static inline int pld_pcie_auto_resume(struct device *dev)
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800251{
252 return 0;
253}
Yue Ma85761e62017-10-30 11:13:45 -0700254
Yue Mafb3b78d2018-08-08 11:51:21 -0700255static inline int pld_pcie_force_wake_request(struct device *dev)
256{
257 return 0;
258}
259
260static inline int pld_pcie_is_device_awake(struct device *dev)
261{
262 return true;
263}
264
265static inline int pld_pcie_force_wake_release(struct device *dev)
266{
267 return 0;
268}
269
Yue Ma85761e62017-10-30 11:13:45 -0700270static inline void pld_pcie_lock_pm_sem(struct device *dev)
Yuanyuan Liu44c44772016-04-11 11:11:27 -0700271{
Yuanyuan Liu44c44772016-04-11 11:11:27 -0700272}
Yue Ma85761e62017-10-30 11:13:45 -0700273
274static inline void pld_pcie_release_pm_sem(struct device *dev)
Yuanyuan Liu44c44772016-04-11 11:11:27 -0700275{
Yuanyuan Liu44c44772016-04-11 11:11:27 -0700276}
Yue Ma85761e62017-10-30 11:13:45 -0700277
Arun Khandavalli1496fcb2016-07-25 16:53:00 +0530278static inline int pld_pcie_power_on(struct device *dev)
279{
280 return 0;
281}
Yue Ma85761e62017-10-30 11:13:45 -0700282
Arun Khandavalli1496fcb2016-07-25 16:53:00 +0530283static inline int pld_pcie_power_off(struct device *dev)
284{
285 return 0;
286}
Yue Ma85761e62017-10-30 11:13:45 -0700287
Yue Ma63d360a2017-06-20 17:00:35 -0700288static inline int pld_pcie_force_assert_target(struct device *dev)
289{
290 return -EINVAL;
291}
Yue Ma85761e62017-10-30 11:13:45 -0700292
Yuanyuan Liu3ab55312018-12-03 15:41:02 -0800293static inline int pld_pcie_collect_rddm(struct device *dev)
294{
295 return 0;
296}
297
Yue Mafd418ea2016-11-21 16:47:13 -0800298static inline int pld_pcie_get_user_msi_assignment(struct device *dev,
299 char *user_name,
300 int *num_vectors,
301 uint32_t *user_base_data,
302 uint32_t *base_vector)
303{
Yu Ouyang781f1b52018-12-27 15:24:07 +0800304 return -EINVAL;
Yue Mafd418ea2016-11-21 16:47:13 -0800305}
Yue Ma85761e62017-10-30 11:13:45 -0700306
Yue Mafd418ea2016-11-21 16:47:13 -0800307static inline int pld_pcie_get_msi_irq(struct device *dev, unsigned int vector)
308{
309 return 0;
310}
Yue Ma85761e62017-10-30 11:13:45 -0700311
Yue Mafd418ea2016-11-21 16:47:13 -0800312static inline void pld_pcie_get_msi_address(struct device *dev,
313 uint32_t *msi_addr_low,
314 uint32_t *msi_addr_high)
315{
316 return;
317}
Yu Ouyang58648a52018-11-01 11:18:15 +0800318
319static inline bool pld_pcie_platform_driver_support(void)
320{
321 return false;
322}
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800323#else
Yue Ma85761e62017-10-30 11:13:45 -0700324int pld_pcie_get_fw_files_for_target(struct device *dev,
325 struct pld_fw_files *pfw_files,
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800326 u32 target_type, u32 target_version);
Yue Ma85761e62017-10-30 11:13:45 -0700327int pld_pcie_get_platform_cap(struct device *dev, struct pld_platform_cap *cap);
Yue Macd243862016-11-04 19:21:16 -0700328int pld_pcie_get_soc_info(struct device *dev, struct pld_soc_info *info);
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800329void pld_pcie_schedule_recovery_work(struct device *dev,
330 enum pld_recovery_reason reason);
331void pld_pcie_device_self_recovery(struct device *dev,
332 enum pld_recovery_reason reason);
Yuanyuan Liu3ab55312018-12-03 15:41:02 -0800333static inline int pld_pcie_collect_rddm(struct device *dev)
334{
335 return cnss_force_collect_rddm(dev);
336}
Komal Seelam355b1472016-09-02 14:36:21 +0530337
Frank Liud462d9c2018-07-27 14:43:26 +0800338static inline void *pld_pcie_smmu_get_mapping(struct device *dev)
339{
340 return cnss_smmu_get_mapping(dev);
341}
342
343static inline int
344pld_pcie_smmu_map(struct device *dev,
345 phys_addr_t paddr, uint32_t *iova_addr, size_t size)
346{
347 return cnss_smmu_map(dev, paddr, iova_addr, size);
348}
349
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800350static inline void pld_pcie_link_down(struct device *dev)
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700351{
Yuanyuan Liu10fc3d32017-01-12 15:32:06 -0800352 cnss_pci_link_down(dev);
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700353}
Yue Ma85761e62017-10-30 11:13:45 -0700354
Yue Ma9c0e4802018-09-11 15:34:06 -0700355static inline int pld_pcie_is_fw_down(struct device *dev)
356{
357 return cnss_pci_is_device_down(dev);
358}
359
Yue Ma6dbbb182017-04-26 17:06:05 -0700360static inline int pld_pcie_athdiag_read(struct device *dev, uint32_t offset,
361 uint32_t memtype, uint32_t datalen,
362 uint8_t *output)
363{
364 return cnss_athdiag_read(dev, offset, memtype, datalen, output);
365}
Yue Ma85761e62017-10-30 11:13:45 -0700366
Yue Ma6dbbb182017-04-26 17:06:05 -0700367static inline int pld_pcie_athdiag_write(struct device *dev, uint32_t offset,
368 uint32_t memtype, uint32_t datalen,
369 uint8_t *input)
370{
371 return cnss_athdiag_write(dev, offset, memtype, datalen, input);
372}
Yue Ma85761e62017-10-30 11:13:45 -0700373
Yue Ma85761e62017-10-30 11:13:45 -0700374static inline void *pld_pcie_get_virt_ramdump_mem(struct device *dev,
375 unsigned long *size)
376{
377 return cnss_get_virt_ramdump_mem(dev, size);
378}
379
Yu Ouyang58648a52018-11-01 11:18:15 +0800380static inline void pld_pcie_release_virt_ramdump_mem(void *address)
381{
382}
383
Yue Ma85761e62017-10-30 11:13:45 -0700384static inline void pld_pcie_device_crashed(struct device *dev)
385{
386 cnss_device_crashed(dev);
387}
388
389static inline void pld_pcie_request_pm_qos(struct device *dev, u32 qos_val)
390{
391 cnss_request_pm_qos(dev, qos_val);
392}
393
394static inline void pld_pcie_remove_pm_qos(struct device *dev)
395{
396 cnss_remove_pm_qos(dev);
397}
398
399static inline int pld_pcie_request_bus_bandwidth(struct device *dev,
400 int bandwidth)
401{
402 return cnss_request_bus_bandwidth(dev, bandwidth);
403}
404
405static inline int pld_pcie_auto_suspend(struct device *dev)
406{
407 return cnss_auto_suspend(dev);
408}
409
410static inline int pld_pcie_auto_resume(struct device *dev)
411{
412 return cnss_auto_resume(dev);
413}
414
Yue Mafb3b78d2018-08-08 11:51:21 -0700415static inline int pld_pcie_force_wake_request(struct device *dev)
416{
417 return cnss_pci_force_wake_request(dev);
418}
419
420static inline int pld_pcie_is_device_awake(struct device *dev)
421{
422 return cnss_pci_is_device_awake(dev);
423}
424
425static inline int pld_pcie_force_wake_release(struct device *dev)
426{
427 return cnss_pci_force_wake_release(dev);
428}
429
Yue Ma85761e62017-10-30 11:13:45 -0700430static inline void pld_pcie_lock_pm_sem(struct device *dev)
431{
432 cnss_lock_pm_sem(dev);
433}
434
435static inline void pld_pcie_release_pm_sem(struct device *dev)
436{
437 cnss_release_pm_sem(dev);
438}
Yue Ma85761e62017-10-30 11:13:45 -0700439
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700440static inline int pld_pcie_power_on(struct device *dev)
441{
442 return cnss_power_up(dev);
443}
Yue Ma85761e62017-10-30 11:13:45 -0700444
Yuanyuan Liu16a55622016-09-14 16:15:59 -0700445static inline int pld_pcie_power_off(struct device *dev)
446{
447 return cnss_power_down(dev);
448}
Yue Ma85761e62017-10-30 11:13:45 -0700449
Yue Ma63d360a2017-06-20 17:00:35 -0700450static inline int pld_pcie_force_assert_target(struct device *dev)
451{
452 return cnss_force_fw_assert(dev);
453}
Yue Ma85761e62017-10-30 11:13:45 -0700454
Yue Mafd418ea2016-11-21 16:47:13 -0800455static inline int pld_pcie_get_user_msi_assignment(struct device *dev,
456 char *user_name,
457 int *num_vectors,
458 uint32_t *user_base_data,
459 uint32_t *base_vector)
460{
461 return cnss_get_user_msi_assignment(dev, user_name, num_vectors,
462 user_base_data, base_vector);
463}
Yue Ma85761e62017-10-30 11:13:45 -0700464
Yue Mafd418ea2016-11-21 16:47:13 -0800465static inline int pld_pcie_get_msi_irq(struct device *dev, unsigned int vector)
466{
467 return cnss_get_msi_irq(dev, vector);
468}
Yue Ma85761e62017-10-30 11:13:45 -0700469
Yue Mafd418ea2016-11-21 16:47:13 -0800470static inline void pld_pcie_get_msi_address(struct device *dev,
471 uint32_t *msi_addr_low,
472 uint32_t *msi_addr_high)
473{
474 cnss_get_msi_address(dev, msi_addr_low, msi_addr_high);
475}
Yu Ouyang58648a52018-11-01 11:18:15 +0800476
477static inline bool pld_pcie_platform_driver_support(void)
478{
479 return true;
480}
Komal Seelam355b1472016-09-02 14:36:21 +0530481#endif
Yuanyuan Liud9f7a362016-01-22 14:27:12 -0800482#endif