diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index 0395a2ec0a41..8a7b96b194ca 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -334,6 +334,18 @@ enum pld_recovery_reason { PLD_REASON_LINK_DOWN }; +#ifdef FEATURE_WLAN_TIME_SYNC_FTM +/** + * enum pld_wlan_time_sync_trigger_type - WLAN time sync trigger type + * @PLD_TRIGGER_POSITIVE_EDGE: Positive edge trigger + * @PLD_TRIGGER_NEGATIVE_EDGE: Negative edge trigger + */ +enum pld_wlan_time_sync_trigger_type { + PLD_TRIGGER_POSITIVE_EDGE, + PLD_TRIGGER_NEGATIVE_EDGE +}; +#endif /* FEATURE_WLAN_TIME_SYNC_FTM */ + /** * struct pld_driver_ops - driver callback functions * @probe: required operation, will be called when device is detected @@ -419,6 +431,13 @@ void pld_is_pci_link_down(struct device *dev); int pld_shadow_control(struct device *dev, bool enable); void pld_schedule_recovery_work(struct device *dev, enum pld_recovery_reason reason); + +#ifdef FEATURE_WLAN_TIME_SYNC_FTM +int pld_get_audio_wlan_timestamp(struct device *dev, + enum pld_wlan_time_sync_trigger_type type, + uint64_t *ts); +#endif /* FEATURE_WLAN_TIME_SYNC_FTM */ + #ifdef CONFIG_CNSS_UTILS /** * pld_set_wlan_unsafe_channel() - Set unsafe channel diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index 6dcf82b4cb9a..432d4f95d59a 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -2641,3 +2641,42 @@ int pld_idle_restart(struct device *dev, return errno; } + +#ifdef FEATURE_WLAN_TIME_SYNC_FTM +/** + * pld_get_audio_wlan_timestamp() - Get audio timestamp + * @dev: device pointer + * @type: trigger type + * @ts: audio timestamp + * + * This API can be used to get audio timestamp. + * + * Return: 0 if trigger to get audio timestamp is successful + * Non zero failure code for errors + */ +int pld_get_audio_wlan_timestamp(struct device *dev, + enum pld_wlan_time_sync_trigger_type type, + uint64_t *ts) +{ + int ret = 0; + enum pld_bus_type bus_type; + + bus_type = pld_get_bus_type(dev); + switch (bus_type) { + case PLD_BUS_TYPE_SNOC: + ret = pld_snoc_get_audio_wlan_timestamp(dev, type, ts); + break; + case PLD_BUS_TYPE_PCIE: + case PLD_BUS_TYPE_SNOC_FW_SIM: + case PLD_BUS_TYPE_PCIE_FW_SIM: + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + case PLD_BUS_TYPE_IPCI: + break; + default: + ret = -EINVAL; + break; + } + return ret; +} +#endif /* FEATURE_WLAN_TIME_SYNC_FTM */ diff --git a/core/pld/src/pld_snoc.h b/core/pld/src/pld_snoc.h index f76d791d7ceb..f965c8c0f07f 100644 --- a/core/pld/src/pld_snoc.h +++ b/core/pld/src/pld_snoc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020 The Linux Foundation. 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 @@ -150,6 +150,17 @@ static inline int pld_snoc_is_fw_rejuvenate(void) static inline void pld_snoc_block_shutdown(bool status) { } + +#ifdef FEATURE_WLAN_TIME_SYNC_FTM +static inline int +pld_snoc_get_audio_wlan_timestamp(struct device *dev, + enum pld_wlan_time_sync_trigger_type type, + uint64_t *ts) +{ + return 0; +} +#endif /* FEATURE_WLAN_TIME_SYNC_FTM */ + #else int pld_snoc_register_driver(void); void pld_snoc_unregister_driver(void); @@ -159,6 +170,29 @@ int pld_snoc_wlan_enable(struct device *dev, int pld_snoc_wlan_disable(struct device *dev, enum pld_driver_mode mode); int pld_snoc_get_soc_info(struct device *dev, struct pld_soc_info *info); +#ifdef FEATURE_WLAN_TIME_SYNC_FTM +/** + * pld_snoc_get_audio_wlan_timestamp() - Get audio timestamp + * @dev: device + * @type: trigger type + * @ts: timestamp + * + * Return audio timestamp to the ts. + * + * Return: 0 for success + * Non zero failure code for errors + */ +static inline int +pld_snoc_get_audio_wlan_timestamp(struct device *dev, + enum pld_wlan_time_sync_trigger_type type, + uint64_t *ts) +{ + if (!dev) + return -ENODEV; + + return 0; +} +#endif /* FEATURE_WLAN_TIME_SYNC_FTM */ static inline int pld_snoc_ce_request_irq(struct device *dev, unsigned int ce_id, irqreturn_t (*handler)(int, void *),