Govind Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 1 | /* |
Jeff Johnson | 753f9d7 | 2019-03-18 13:41:04 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. |
Govind Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 3 | * |
| 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 | |
wadesong | bf70879 | 2017-09-04 15:55:43 +0800 | [diff] [blame] | 22 | #ifdef CONFIG_PLD_SDIO_CNSS |
| 23 | #include <net/cnss.h> |
| 24 | #endif |
Govind Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 25 | #include "pld_common.h" |
| 26 | |
Yu Wang | 7d866f6 | 2019-03-13 17:55:44 +0800 | [diff] [blame^] | 27 | #ifdef DYNAMIC_SINGLE_CHIP |
| 28 | #define PREFIX DYNAMIC_SINGLE_CHIP "/" |
| 29 | #else |
| 30 | |
Yu Wang | 66e4ff2 | 2017-02-15 19:09:24 +0800 | [diff] [blame] | 31 | #ifdef MULTI_IF_NAME |
| 32 | #define PREFIX MULTI_IF_NAME "/" |
| 33 | #else |
| 34 | #define PREFIX "" |
| 35 | #endif |
| 36 | |
Yu Wang | 7d866f6 | 2019-03-13 17:55:44 +0800 | [diff] [blame^] | 37 | #endif |
| 38 | |
Yu Wang | 66e4ff2 | 2017-02-15 19:09:24 +0800 | [diff] [blame] | 39 | #define PLD_QCA9377_REV1_1_VERSION 0x5020001 |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 40 | #define PLD_QCA9379_REV1_VERSION 0x5040000 |
Yu Wang | 66e4ff2 | 2017-02-15 19:09:24 +0800 | [diff] [blame] | 41 | |
Govind Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 42 | #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 Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 52 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 53 | |
Govind Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 54 | #endif |
| 55 | |
| 56 | #ifndef CONFIG_SDIO |
| 57 | static inline int pld_sdio_register_driver(void) |
| 58 | { |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | static inline void pld_sdio_unregister_driver(void) |
| 63 | { |
| 64 | } |
| 65 | |
Jeff Johnson | bbaf4e4 | 2016-10-07 12:33:22 -0700 | [diff] [blame] | 66 | static inline |
Govind Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 67 | int 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 Seelam | 355b147 | 2016-09-02 14:36:21 +0530 | [diff] [blame] | 72 | static 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 Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 78 | #else |
| 79 | int pld_sdio_register_driver(void); |
| 80 | void pld_sdio_unregister_driver(void); |
| 81 | int pld_sdio_get_fw_files_for_target(struct pld_fw_files *pfw_files, |
| 82 | u32 target_type, u32 target_version); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 83 | #ifdef CONFIG_CNSS |
Komal Seelam | 355b147 | 2016-09-02 14:36:21 +0530 | [diff] [blame] | 84 | static 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 Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 89 | #else |
| 90 | static 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 Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 97 | #endif |
| 98 | |
Yu Wang | c407bf7 | 2017-02-23 15:33:42 +0800 | [diff] [blame] | 99 | #ifdef CONFIG_PLD_SDIO_CNSS |
| 100 | static 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 Ouyang | 58648a5 | 2018-11-01 11:18:15 +0800 | [diff] [blame] | 106 | static inline void pld_sdio_release_virt_ramdump_mem(void *address) |
| 107 | { |
| 108 | } |
| 109 | |
Yu Wang | c407bf7 | 2017-02-23 15:33:42 +0800 | [diff] [blame] | 110 | static inline void pld_sdio_device_crashed(struct device *dev) |
| 111 | { |
| 112 | cnss_common_device_crashed(dev); |
| 113 | } |
Liangwei Dong | 95d6c37 | 2017-07-05 02:00:01 -0400 | [diff] [blame] | 114 | static inline bool pld_sdio_is_fw_dump_skipped(void) |
| 115 | { |
| 116 | return cnss_get_restart_level() == CNSS_RESET_SUBSYS_COUPLED; |
| 117 | } |
wadesong | bf70879 | 2017-09-04 15:55:43 +0800 | [diff] [blame] | 118 | |
| 119 | static inline void pld_sdio_device_self_recovery(struct device *dev) |
| 120 | { |
| 121 | cnss_common_device_self_recovery(dev); |
| 122 | } |
Yu Ouyang | 58648a5 | 2018-11-01 11:18:15 +0800 | [diff] [blame] | 123 | |
| 124 | static inline bool pld_sdio_platform_driver_support(void) |
| 125 | { |
| 126 | return true; |
| 127 | } |
Yu Wang | c407bf7 | 2017-02-23 15:33:42 +0800 | [diff] [blame] | 128 | #else |
| 129 | static inline void *pld_sdio_get_virt_ramdump_mem(struct device *dev, |
| 130 | unsigned long *size) |
| 131 | { |
Yu Ouyang | 58648a5 | 2018-11-01 11:18:15 +0800 | [diff] [blame] | 132 | 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 | |
| 148 | static inline void pld_sdio_release_virt_ramdump_mem(void *address) |
| 149 | { |
| 150 | kfree(address); |
Yu Wang | c407bf7 | 2017-02-23 15:33:42 +0800 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | static inline void pld_sdio_device_crashed(struct device *dev) |
| 154 | { |
| 155 | } |
Liangwei Dong | 95d6c37 | 2017-07-05 02:00:01 -0400 | [diff] [blame] | 156 | static inline bool pld_sdio_is_fw_dump_skipped(void) |
| 157 | { |
| 158 | return false; |
| 159 | } |
| 160 | |
wadesong | bf70879 | 2017-09-04 15:55:43 +0800 | [diff] [blame] | 161 | static inline void pld_sdio_device_self_recovery(struct device *dev) |
| 162 | { |
| 163 | } |
Yu Ouyang | 58648a5 | 2018-11-01 11:18:15 +0800 | [diff] [blame] | 164 | |
| 165 | static inline bool pld_sdio_platform_driver_support(void) |
| 166 | { |
| 167 | return false; |
| 168 | } |
Yu Wang | c407bf7 | 2017-02-23 15:33:42 +0800 | [diff] [blame] | 169 | #endif |
bings | 75be2d0 | 2017-06-26 13:58:08 +0800 | [diff] [blame] | 170 | |
| 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 | */ |
| 179 | static 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 | */ |
| 191 | static 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 | */ |
| 202 | static 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 Johnson | 753f9d7 | 2019-03-18 13:41:04 -0700 | [diff] [blame] | 210 | if (size) |
bings | 75be2d0 | 2017-06-26 13:58:08 +0800 | [diff] [blame] | 211 | *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 | */ |
| 225 | static inline void pld_hif_sdio_release_ramdump_mem(unsigned long *address) |
| 226 | { |
Jeff Johnson | 753f9d7 | 2019-03-18 13:41:04 -0700 | [diff] [blame] | 227 | if (address) |
bings | 75be2d0 | 2017-06-26 13:58:08 +0800 | [diff] [blame] | 228 | kfree(address); |
| 229 | } |
| 230 | #endif |
Govind Singh | 6a2fe03 | 2016-05-13 14:09:37 +0530 | [diff] [blame] | 231 | #endif |