diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index 772007805899..27b6447cea4e 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -133,6 +133,16 @@ enum pld_platform_cap_flag { PLD_HAS_DRV_SUPPORT = 0x04, }; +/** + * enum pld_wfc_mode - WFC Mode + * @PLD_WFC_MODE_OFF: WFC Inactive + * @PLD_WFC_MODE_ON: WFC Active + */ +enum pld_wfc_mode { + PLD_WFC_MODE_OFF, + PLD_WFC_MODE_ON, +}; + /** * struct pld_platform_cap - platform capabilities * @cap_flag: capabilities flag @@ -946,6 +956,15 @@ int pld_thermal_register(struct device *dev, unsigned long state, int mon_id); */ void pld_thermal_unregister(struct device *dev, int mon_id); +/** + * pld_set_wfc_mode() - Sent WFC mode to FW via platform driver + * @dev: The device structure + * @wfc_mode: WFC Modes (0 => Inactive, 1 => Active) + * + * Return: Error code on error + */ +int pld_set_wfc_mode(struct device *dev, enum pld_wfc_mode wfc_mode); + /** * pld_bus_width_type_to_str() - Helper function to convert PLD bandwidth level * to string diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index b756a115bb98..a75c8c20adad 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -3154,6 +3154,32 @@ void pld_thermal_unregister(struct device *dev, int mon_id) } } +int pld_set_wfc_mode(struct device *dev, enum pld_wfc_mode wfc_mode) +{ + int errno = -ENOTSUPP; + enum pld_bus_type type; + + type = pld_get_bus_type(dev); + switch (type) { + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + case PLD_BUS_TYPE_SNOC: + case PLD_BUS_TYPE_IPCI_FW_SIM: + case PLD_BUS_TYPE_SNOC_FW_SIM: + case PLD_BUS_TYPE_IPCI: + case PLD_BUS_TYPE_PCIE_FW_SIM: + break; + case PLD_BUS_TYPE_PCIE: + errno = pld_pcie_set_wfc_mode(dev, wfc_mode); + break; + default: + pr_err("Invalid device type %d\n", type); + break; + } + + return errno; +} + const char *pld_bus_width_type_to_str(enum pld_bus_width_type level) { switch (level) { diff --git a/core/pld/src/pld_pcie.c b/core/pld/src/pld_pcie.c index 8132f4f42069..e04f9a904397 100644 --- a/core/pld/src/pld_pcie.c +++ b/core/pld/src/pld_pcie.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -940,5 +941,30 @@ void pld_pcie_device_self_recovery(struct device *dev, } cnss_self_recovery(dev, cnss_reason); } + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) +int pld_pcie_set_wfc_mode(struct device *dev, + enum pld_wfc_mode wfc_mode) +{ + struct cnss_wfc_cfg cfg; + int ret; + + switch (wfc_mode) { + case PLD_WFC_MODE_OFF: + cfg.mode = CNSS_WFC_MODE_OFF; + break; + case PLD_WFC_MODE_ON: + cfg.mode = CNSS_WFC_MODE_ON; + break; + default: + ret = -EINVAL; + goto out; + } + + ret = cnss_set_wfc_mode(dev, cfg); +out: + return ret; +} +#endif #endif #endif diff --git a/core/pld/src/pld_pcie.h b/core/pld/src/pld_pcie.h index 07ed2933cf7b..607367c0c887 100644 --- a/core/pld/src/pld_pcie.h +++ b/core/pld/src/pld_pcie.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -404,7 +405,24 @@ static inline bool pld_pcie_platform_driver_support(void) { return false; } + +static inline int pld_pcie_set_wfc_mode(struct device *dev, + enum pld_wfc_mode wfc_mode) +{ + return 0; +} #else +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) +int pld_pcie_set_wfc_mode(struct device *dev, + enum pld_wfc_mode wfc_mode); +#else +static inline int pld_pcie_set_wfc_mode(struct device *dev, + enum pld_wfc_mode wfc_mode) +{ + return 0; +} +#endif + int pld_pcie_get_fw_files_for_target(struct device *dev, struct pld_fw_files *pfw_files, u32 target_type, u32 target_version);