blob: 354eec1a795e0e59765b4c641a01c0f9a4c6631e [file] [log] [blame]
Govind Singh6a2fe032016-05-13 14:09:37 +05301/*
Jeff Johnson753f9d72019-03-18 13:41:04 -07002 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
Govind Singh6a2fe032016-05-13 14:09:37 +05303 *
4 * 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
19#ifndef __PLD_SDIO_H__
20#define __PLD_SDIO_H__
21
wadesongbf708792017-09-04 15:55:43 +080022#ifdef CONFIG_PLD_SDIO_CNSS
23#include <net/cnss.h>
24#endif
Govind Singh6a2fe032016-05-13 14:09:37 +053025#include "pld_common.h"
26
Yu Wang7d866f62019-03-13 17:55:44 +080027#ifdef DYNAMIC_SINGLE_CHIP
28#define PREFIX DYNAMIC_SINGLE_CHIP "/"
29#else
30
Yu Wang66e4ff22017-02-15 19:09:24 +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
Yu Wang66e4ff22017-02-15 19:09:24 +080039#define PLD_QCA9377_REV1_1_VERSION 0x5020001
Nirav Shaheb017be2018-02-15 11:20:58 +053040#define PLD_QCA9379_REV1_VERSION 0x5040000
Yu Wang66e4ff22017-02-15 19:09:24 +080041
Govind Singh6a2fe032016-05-13 14:09:37 +053042#ifndef CONFIG_CNSS
43#define PLD_AR6004_VERSION_REV1_3 0x31c8088a
44#define PLD_AR9888_REV2_VERSION 0x4100016c
45#define PLD_AR6320_REV1_VERSION 0x5000000
46#define PLD_AR6320_REV1_1_VERSION 0x5000001
47#define PLD_AR6320_REV1_3_VERSION 0x5000003
48#define PLD_AR6320_REV2_1_VERSION 0x5010000
49#define PLD_AR6320_REV3_VERSION 0x5020000
50#define PLD_AR6320_REV3_2_VERSION 0x5030000
51#define PLD_AR6320_DEV_VERSION 0x1000000
Govind Singh6a2fe032016-05-13 14:09:37 +053052
Samuel Ahnc9c48ca2016-09-19 15:46:36 +053053
Govind Singh6a2fe032016-05-13 14:09:37 +053054#endif
55
56#ifndef CONFIG_SDIO
57static inline int pld_sdio_register_driver(void)
58{
59 return 0;
60}
61
62static inline void pld_sdio_unregister_driver(void)
63{
64}
65
Jeff Johnsonbbaf4e42016-10-07 12:33:22 -070066static inline
Govind Singh6a2fe032016-05-13 14:09:37 +053067int pld_sdio_get_fw_files_for_target(struct pld_fw_files *pfw_files,
68 u32 target_type, u32 target_version)
69{
70 return 0;
71}
Komal Seelam355b1472016-09-02 14:36:21 +053072static inline uint8_t *pld_sdio_get_wlan_mac_address(struct device *dev,
73 uint32_t *num)
74{
75 *num = 0;
76 return NULL;
77}
Govind Singh6a2fe032016-05-13 14:09:37 +053078#else
79int pld_sdio_register_driver(void);
80void pld_sdio_unregister_driver(void);
81int pld_sdio_get_fw_files_for_target(struct pld_fw_files *pfw_files,
82 u32 target_type, u32 target_version);
Nirav Shaheb017be2018-02-15 11:20:58 +053083#ifdef CONFIG_CNSS
Komal Seelam355b1472016-09-02 14:36:21 +053084static inline uint8_t *pld_sdio_get_wlan_mac_address(struct device *dev,
85 uint32_t *num)
86{
87 return cnss_common_get_wlan_mac_address(dev, num);
88}
Nirav Shaheb017be2018-02-15 11:20:58 +053089#else
90static inline uint8_t *pld_sdio_get_wlan_mac_address(struct device *dev,
91 uint32_t *num)
92{
93 *num = 0;
94 return NULL;
95}
96#endif
Govind Singh6a2fe032016-05-13 14:09:37 +053097#endif
98
Yu Wangc407bf72017-02-23 15:33:42 +080099#ifdef CONFIG_PLD_SDIO_CNSS
100static inline void *pld_sdio_get_virt_ramdump_mem(struct device *dev,
101 unsigned long *size)
102{
103 return cnss_common_get_virt_ramdump_mem(dev, size);
104}
105
Yu Ouyang58648a52018-11-01 11:18:15 +0800106static inline void pld_sdio_release_virt_ramdump_mem(void *address)
107{
108}
109
Yu Wangc407bf72017-02-23 15:33:42 +0800110static inline void pld_sdio_device_crashed(struct device *dev)
111{
112 cnss_common_device_crashed(dev);
113}
Liangwei Dong95d6c372017-07-05 02:00:01 -0400114static inline bool pld_sdio_is_fw_dump_skipped(void)
115{
116 return cnss_get_restart_level() == CNSS_RESET_SUBSYS_COUPLED;
117}
wadesongbf708792017-09-04 15:55:43 +0800118
119static inline void pld_sdio_device_self_recovery(struct device *dev)
120{
121 cnss_common_device_self_recovery(dev);
122}
Yu Ouyang58648a52018-11-01 11:18:15 +0800123
124static inline bool pld_sdio_platform_driver_support(void)
125{
126 return true;
127}
Yu Wangc407bf72017-02-23 15:33:42 +0800128#else
129static inline void *pld_sdio_get_virt_ramdump_mem(struct device *dev,
130 unsigned long *size)
131{
Yu Ouyang58648a52018-11-01 11:18:15 +0800132 size_t length = 0;
133 int flags = GFP_KERNEL;
134
135 length = TOTAL_DUMP_SIZE;
136
137 if (!size)
138 return NULL;
139
140 *size = (unsigned long)length;
141
142 if (in_interrupt() || irqs_disabled() || in_atomic())
143 flags = GFP_ATOMIC;
144
145 return kzalloc(length, flags);
146}
147
148static inline void pld_sdio_release_virt_ramdump_mem(void *address)
149{
150 kfree(address);
Yu Wangc407bf72017-02-23 15:33:42 +0800151}
152
153static inline void pld_sdio_device_crashed(struct device *dev)
154{
155}
Liangwei Dong95d6c372017-07-05 02:00:01 -0400156static inline bool pld_sdio_is_fw_dump_skipped(void)
157{
158 return false;
159}
160
wadesongbf708792017-09-04 15:55:43 +0800161static inline void pld_sdio_device_self_recovery(struct device *dev)
162{
163}
Yu Ouyang58648a52018-11-01 11:18:15 +0800164
165static inline bool pld_sdio_platform_driver_support(void)
166{
167 return false;
168}
Yu Wangc407bf72017-02-23 15:33:42 +0800169#endif
bings75be2d02017-06-26 13:58:08 +0800170
171#ifdef CONFIG_PLD_SDIO_CNSS
172/**
173 * pld_hif_sdio_get_virt_ramdump_mem() - Get virtual ramdump memory
174 * @dev: device
175 * @size: buffer to virtual memory size
176 *
177 * Return: virtual ramdump memory address
178 */
179static inline void *pld_hif_sdio_get_virt_ramdump_mem(struct device *dev,
180 unsigned long *size)
181{
182 return cnss_common_get_virt_ramdump_mem(dev, size);
183}
184
185/**
186 * pld_hif_sdio_release_ramdump_mem() - Release virtual ramdump memory
187 * @address: virtual ramdump memory address
188 *
189 * Return: void
190 */
191static inline void pld_hif_sdio_release_ramdump_mem(unsigned long *address)
192{
193}
194#else
195/**
196 * pld_hif_sdio_get_virt_ramdump_mem() - Get virtual ramdump memory
197 * @dev: device
198 * @size: buffer to virtual memory size
199 *
200 * Return: virtual ramdump memory address
201 */
202static inline void *pld_hif_sdio_get_virt_ramdump_mem(struct device *dev,
203 unsigned long *size)
204{
205 size_t length = 0;
206 int flags = GFP_KERNEL;
207
208 length = TOTAL_DUMP_SIZE;
209
Jeff Johnson753f9d72019-03-18 13:41:04 -0700210 if (size)
bings75be2d02017-06-26 13:58:08 +0800211 *size = (unsigned long)length;
212
213 if (in_interrupt() || irqs_disabled() || in_atomic())
214 flags = GFP_ATOMIC;
215
216 return kzalloc(length, flags);
217}
218
219/**
220 * pld_hif_sdio_release_ramdump_mem() - Release virtual ramdump memory
221 * @address: virtual ramdump memory address
222 *
223 * Return: void
224 */
225static inline void pld_hif_sdio_release_ramdump_mem(unsigned long *address)
226{
Jeff Johnson753f9d72019-03-18 13:41:04 -0700227 if (address)
bings75be2d02017-06-26 13:58:08 +0800228 kfree(address);
229}
230#endif
Govind Singh6a2fe032016-05-13 14:09:37 +0530231#endif