diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index 04be7b202da4..c8f1f437da48 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2021-2022 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 @@ -153,6 +154,16 @@ enum pld_uevent { PLD_SMMU_FAULT, }; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) +/** + * enum pld_device_config - Get PLD device config + * @PLD_IPA_DISABLD: IPA is disabled + */ +enum pld_device_config { + PLD_IPA_DISABLED, +}; +#endif + /** * struct pld_uevent_data - uevent status received from platform driver * @uevent: uevent type @@ -942,6 +953,21 @@ void pld_thermal_unregister(struct device *dev, int mon_id); int pld_get_thermal_state(struct device *dev, unsigned long *thermal_state, int mon_id); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) +/** + * pld_is_ipa_offload_disabled() - Check if IPA offload is enabled or not + * @dev: The device structure + * + * Return: Non-zero code for IPA offload disable; zero for IPA offload enable + */ +int pld_is_ipa_offload_disabled(struct device *dev); +#else +int pld_is_ipa_offload_disabled(struct device *dev); +{ + return 0; +} +#endif + #if IS_ENABLED(CONFIG_WCNSS_MEM_PRE_ALLOC) && defined(FEATURE_SKB_PRE_ALLOC) /** diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index 13e161862b0f..08fedf1f3e77 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2021-2022 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 @@ -3182,6 +3183,45 @@ int pld_get_thermal_state(struct device *dev, unsigned long *thermal_state, return errno; } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) +/** + * pld_is_ipa_offload_disabled() - Check if IPA offload is disabled or not + * + * @dev: device + * + * This API will be called to check if IPA offload is disabled or not. + * + * Return: Non-zero for IPA offload is disabled + * Otherwise IPA offload is enabled + */ +int pld_is_ipa_offload_disabled(struct device *dev) +{ + unsigned long dev_cfg = 0; + + enum pld_bus_type type = pld_get_bus_type(dev); + + switch (type) { + case PLD_BUS_TYPE_SNOC: + dev_cfg = pld_snoc_get_device_config(); + break; + case PLD_BUS_TYPE_IPCI: + case PLD_BUS_TYPE_PCIE: + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + case PLD_BUS_TYPE_SNOC_FW_SIM: + case PLD_BUS_TYPE_PCIE_FW_SIM: + case PLD_BUS_TYPE_IPCI_FW_SIM: + pr_err("Not supported on type %d\n", type); + break; + default: + pr_err("Invalid device type %d\n", type); + break; + } + + return test_bit(PLD_IPA_DISABLED, &dev_cfg); +} +#endif + #ifdef FEATURE_WLAN_TIME_SYNC_FTM /** * pld_get_audio_wlan_timestamp() - Get audio timestamp diff --git a/core/pld/src/pld_snoc.h b/core/pld/src/pld_snoc.h index 969504dd2e6c..1ee110486e0d 100644 --- a/core/pld/src/pld_snoc.h +++ b/core/pld/src/pld_snoc.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 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 @@ -124,6 +124,11 @@ static inline int pld_snoc_idle_shutdown(struct device *dev) return 0; } +static inline unsigned long pld_snoc_get_device_config(void) +{ + return 0; +} + static inline int pld_snoc_smmu_map(struct device *dev, phys_addr_t paddr, uint32_t *iova_addr, size_t size) { @@ -393,5 +398,10 @@ static inline int pld_snoc_idle_shutdown(struct device *dev) { return icnss_idle_shutdown(dev); } + +static inline unsigned long pld_snoc_get_device_config(void) +{ + return icnss_get_device_config(); +} #endif #endif