1 /* 2 * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef __PLD_PCIE_FW_SIM_H__ 21 #define __PLD_PCIE_FW_SIM_H__ 22 23 #include "pld_internal.h" 24 25 #if !defined(CONFIG_PLD_PCIE_FW_SIM) && !defined(CONFIG_PLD_IPCIE_FW_SIM) 26 27 static inline int pld_pcie_fw_sim_register_driver(void) 28 { 29 return 0; 30 } 31 32 static inline void pld_pcie_fw_sim_unregister_driver(void) 33 { 34 } 35 36 static inline int pld_pcie_fw_sim_wlan_enable(struct device *dev, 37 struct pld_wlan_enable_cfg *cfg, 38 enum pld_driver_mode mode, 39 const char *host_version) 40 { 41 return 0; 42 } 43 44 static inline int pld_pcie_fw_sim_wlan_disable(struct device *dev, 45 enum pld_driver_mode mode) 46 { 47 return 0; 48 } 49 50 static inline void pld_pcie_fw_sim_link_down(struct device *dev) 51 { 52 } 53 54 static inline int pld_pcie_fw_sim_is_fw_down(struct device *dev) 55 { 56 return 0; 57 } 58 59 static inline int pld_pcie_fw_sim_get_platform_cap(struct device *dev, 60 struct pld_platform_cap *cap) 61 { 62 return 0; 63 } 64 65 static inline int pld_pcie_fw_sim_get_soc_info(struct device *dev, 66 struct pld_soc_info *info) 67 { 68 return 0; 69 } 70 71 static inline int pld_pcie_fw_sim_get_user_msi_assignment(struct device *dev, 72 char *user_name, 73 int *num_vectors, 74 uint32_t *base_data, 75 uint32_t *base_vector) 76 { 77 return -EINVAL; 78 } 79 80 static inline int pld_pcie_fw_sim_get_msi_irq(struct device *dev, 81 unsigned int vector) 82 { 83 return 0; 84 } 85 86 static inline void pld_pcie_fw_sim_get_msi_address(struct device *dev, 87 uint32_t *msi_addr_low, 88 uint32_t *msi_addr_high) 89 { 90 } 91 92 static inline int pld_pcie_fw_sim_request_irq(struct device *dev, int irq, 93 irq_handler_t handler, 94 unsigned long irqflags, 95 const char *devname, 96 void *dev_data) 97 { 98 return 0; 99 } 100 101 static inline int pld_pcie_fw_sim_read_config_word(struct device *dev, 102 int offset, uint16_t *val) 103 { 104 return 0; 105 } 106 107 static inline int pld_pcie_fw_sim_free_irq(struct device *dev, 108 unsigned int ce_id, void *ctx) 109 { 110 return 0; 111 } 112 113 static inline void pld_pcie_fw_sim_enable_irq(struct device *dev, 114 unsigned int irq) 115 { 116 } 117 118 static inline void pld_pcie_fw_sim_disable_irq(struct device *dev, 119 unsigned int irq) 120 { 121 } 122 123 static inline int pld_pcie_fw_sim_idle_shutdown(struct device *dev) 124 { 125 return 0; 126 } 127 128 static inline int pld_pcie_fw_sim_idle_restart(struct device *dev) 129 { 130 return 0; 131 } 132 133 static inline int pld_pcie_fw_sim_thermal_register(struct device *dev, 134 unsigned long max_state, 135 int mon_id) 136 { 137 return 0; 138 } 139 140 static inline void pld_pcie_fw_sim_thermal_unregister(struct device *dev, 141 int mon_id) 142 { 143 } 144 145 static inline int pld_pcie_fw_sim_get_thermal_state(struct device *dev, 146 unsigned long *therm_state, 147 int mon_id) 148 { 149 return 0; 150 } 151 152 static inline int pld_pcie_fw_sim_exit_power_save(struct device *dev) 153 { 154 return 0; 155 } 156 157 static inline int pld_pcie_fw_sim_get_irq(struct device *dev, int ce_id) 158 { 159 return 0; 160 } 161 #else 162 #include <net/cnss2.h> 163 164 int pld_pcie_fw_sim_wlan_enable(struct device *dev, 165 struct pld_wlan_enable_cfg *config, 166 enum pld_driver_mode mode, 167 const char *host_version); 168 int pld_pcie_fw_sim_wlan_disable(struct device *dev, enum pld_driver_mode mode); 169 int pld_pcie_fw_sim_register_driver(void); 170 void pld_pcie_fw_sim_unregister_driver(void); 171 int pld_pcie_fw_sim_get_platform_cap(struct device *dev, 172 struct pld_platform_cap *cap); 173 int pld_pcie_fw_sim_get_soc_info(struct device *dev, struct pld_soc_info *info); 174 int pld_pcie_fw_sim_get_irq(struct device *dev, int ce_id); 175 176 static inline int pld_pcie_fw_sim_get_user_msi_assignment(struct device *dev, 177 char *user_name, 178 int *num_vectors, 179 uint32_t *base_data, 180 uint32_t *base_vector) 181 { 182 return cnss_fw_sim_get_user_msi_assignment(dev, user_name, num_vectors, 183 base_data, base_vector); 184 } 185 186 static inline int pld_pcie_fw_sim_get_msi_irq(struct device *dev, 187 unsigned int vector) 188 { 189 return cnss_fw_sim_get_msi_irq(dev, vector); 190 } 191 192 static inline void pld_pcie_fw_sim_get_msi_address(struct device *dev, 193 uint32_t *msi_addr_low, 194 uint32_t *msi_addr_high) 195 { 196 cnss_fw_sim_get_msi_address(dev, msi_addr_low, msi_addr_high); 197 } 198 199 static inline int pld_pcie_fw_sim_request_irq(struct device *dev, int irq, 200 irq_handler_t handler, 201 unsigned long irqflags, 202 const char *devname, 203 void *dev_data) 204 { 205 return cnss_fw_sim_request_irq(dev, irq, handler, 206 irqflags, devname, dev_data); 207 } 208 209 static inline int pld_pcie_fw_sim_read_config_word(struct device *dev, 210 int offset, uint16_t *val) 211 { 212 return cnss_fw_sim_read_config_word(dev, offset, val); 213 } 214 215 static inline int pld_pcie_fw_sim_free_irq(struct device *dev, 216 int irq, void *dev_data) 217 { 218 return cnss_fw_sim_free_irq(dev, irq, dev_data); 219 } 220 221 static inline void pld_pcie_fw_sim_enable_irq(struct device *dev, int irq) 222 { 223 cnss_fw_sim_enable_irq(dev, irq); 224 } 225 226 static inline void pld_pcie_fw_sim_disable_irq(struct device *dev, int irq) 227 { 228 cnss_fw_sim_disable_irq(dev, irq); 229 } 230 231 static inline int pld_pcie_fw_sim_idle_shutdown(struct device *dev) 232 { 233 return cnss_fw_sim_idle_shutdown(dev); 234 } 235 236 static inline int pld_pcie_fw_sim_idle_restart(struct device *dev) 237 { 238 return cnss_fw_sim_idle_restart(dev); 239 } 240 241 static inline int pld_pcie_fw_sim_thermal_register(struct device *dev, 242 unsigned long max_state, 243 int mon_id) 244 { 245 return cnss_fw_sim_thermal_cdev_register(dev, max_state, mon_id); 246 } 247 248 static inline void pld_pcie_fw_sim_thermal_unregister(struct device *dev, 249 int mon_id) 250 { 251 cnss_fw_sim_thermal_cdev_unregister(dev, mon_id); 252 } 253 254 static inline int pld_pcie_fw_sim_get_thermal_state(struct device *dev, 255 unsigned long *therm_state, 256 int mon_id) 257 { 258 return cnss_fw_sim_get_curr_therm_cdev_state(dev, therm_state, 259 mon_id); 260 } 261 262 static inline int pld_pcie_fw_sim_exit_power_save(struct device *dev) 263 { 264 return cnss_fw_sim_exit_power_save(dev); 265 } 266 267 #endif 268 #endif 269