From 4ca03b657915f597b94d1da88bc40d8d1a4bd37c Mon Sep 17 00:00:00 2001 From: Houston Hoffman Date: Mon, 14 Mar 2016 21:11:51 -0700 Subject: [PATCH] qcacmn: Add dummy functions to bus_ops table for snoc Use bus ops table to tunnel into dummy implementations for snoc. Needed to support both pcie and snoc in the same binary. Change-Id: I11725ed4dfa5dd7b43a4b29236d3caca58fda41f CRs-Fixed: 986480 --- hif/src/dispatcher/dummy.c | 96 ++++++++++++++++++++++++++++++ hif/src/dispatcher/dummy.h | 35 +++++++++++ hif/src/dispatcher/multibus.c | 38 ++++++++++++ hif/src/dispatcher/multibus.h | 6 ++ hif/src/dispatcher/multibus_pci.c | 7 +++ hif/src/dispatcher/multibus_snoc.c | 8 +++ hif/src/dispatcher/pci_api.h | 6 ++ hif/src/hif_main.h | 3 + hif/src/pcie/hif_io32_pci.h | 4 -- hif/src/pcie/if_pci.c | 37 ++++++------ hif/src/snoc/hif_io32_snoc.h | 21 ------- hif/src/snoc/if_snoc.c | 72 +--------------------- 12 files changed, 217 insertions(+), 116 deletions(-) create mode 100644 hif/src/dispatcher/dummy.c create mode 100644 hif/src/dispatcher/dummy.h diff --git a/hif/src/dispatcher/dummy.c b/hif/src/dispatcher/dummy.c new file mode 100644 index 000000000000..3691613d2c2c --- /dev/null +++ b/hif/src/dispatcher/dummy.c @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ + +#include "qdf_types.h" +#include "dummy.h" +#include "hif_debug.h" + +/** + * hif_dummy_bus_prevent_linkdown() - prevent linkdown + * @hif_ctx: hif context + * @flag: weather to keep the bus alive or not + * + * Dummy function for busses and platforms that do not support + * link down. This may need to be replaced with a wakelock. + */ +void hif_dummy_bus_prevent_linkdown(struct hif_softc *scn, bool flag) +{ + HIF_ERROR("wlan: %s pcie power collapse ignored", + (flag ? "disable" : "enable")); +} + +/** + * hif_reset_soc(): reset soc + * + * this function resets soc + * + * @hif_ctx: HIF context + * + * Return: void + */ +/* Function to reset SoC */ +void hif_dummy_reset_soc(struct hif_softc *hif_ctx) +{ +} + +/** + * hif_dummy_suspend() - suspend the bus + * @hif_ctx: hif context + * + * dummy for busses that don't need to suspend. + * + * Return: 0 for success and non-zero for failure + */ +int hif_dummy_bus_suspend(struct hif_softc *hif_ctx) +{ + return 0; +} + +/** + * hif_dummy_resume() - hif resume API + * + * This function resumes the bus. but snoc doesn't need to resume. + * Therefore do nothing. + * + * Return: 0 for success and non-zero for failure + */ +int hif_dummy_bus_resume(struct hif_softc *hif_ctx) +{ + return 0; +} + +/** + * hif_dummy_target_sleep_state_adjust() - api to adjust state of target + * @scn: hif context + * @sleep_ok: allow or deny target to go to sleep + * @wait_for_it: ensure target has change + */ +int hif_dummy_target_sleep_state_adjust(struct hif_softc *scn, + bool sleep_ok, bool wait_for_it) +{ + return 0; +} diff --git a/hif/src/dispatcher/dummy.h b/hif/src/dispatcher/dummy.h new file mode 100644 index 000000000000..7daa2ae4542a --- /dev/null +++ b/hif/src/dispatcher/dummy.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ +struct hif_softc; + +void hif_dummy_bus_prevent_linkdown(struct hif_softc *scn, bool flag); +void hif_dummy_reset_soc(struct hif_softc *scn); +int hif_dummy_bus_suspend(struct hif_softc *hif_ctx); +int hif_dummy_bus_resume(struct hif_softc *hif_ctx); +int hif_dummy_target_sleep_state_adjust(struct hif_softc *scn, + bool sleep_ok, bool wait_for_it); + diff --git a/hif/src/dispatcher/multibus.c b/hif/src/dispatcher/multibus.c index 3e0d1257ec4b..373a24548eda 100644 --- a/hif/src/dispatcher/multibus.c +++ b/hif/src/dispatcher/multibus.c @@ -120,3 +120,41 @@ void hif_bus_close(struct hif_softc *hif_sc) { hif_sc->bus_ops.hif_bus_close(hif_sc); } + +/** + * hif_bus_prevent_linkdown() - prevent linkdown + * @hif_ctx: hif context + * @flag: true = keep bus alive false = let bus go to sleep + * + * Keeps the bus awake durring suspend. + */ +void hif_bus_prevent_linkdown(struct hif_softc *hif_sc, bool flag) +{ + hif_sc->bus_ops.hif_bus_prevent_linkdown(hif_sc, flag); +} + + +void hif_reset_soc(struct hif_opaque_softc *hif_ctx) +{ + struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); + hif_sc->bus_ops.hif_reset_soc(hif_sc); +} + +int hif_bus_suspend(struct hif_opaque_softc *hif_ctx) +{ + struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); + return hif_sc->bus_ops.hif_bus_suspend(hif_sc); +} + +int hif_bus_resume(struct hif_opaque_softc *hif_ctx) +{ + struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); + return hif_sc->bus_ops.hif_bus_resume(hif_sc); +} + +int hif_target_sleep_state_adjust(struct hif_softc *hif_sc, + bool sleep_ok, bool wait_for_it) +{ + return hif_sc->bus_ops.hif_target_sleep_state_adjust(hif_sc, + sleep_ok, wait_for_it); +} diff --git a/hif/src/dispatcher/multibus.h b/hif/src/dispatcher/multibus.h index 4a1d7df31ebe..b30013b01d8c 100644 --- a/hif/src/dispatcher/multibus.h +++ b/hif/src/dispatcher/multibus.h @@ -38,6 +38,12 @@ struct hif_bus_ops { QDF_STATUS (*hif_bus_open)(struct hif_softc *hif_sc, enum qdf_bus_type bus_type); void (*hif_bus_close)(struct hif_softc *hif_sc); + void (*hif_bus_prevent_linkdown)(struct hif_softc *hif_sc, bool flag); + void (*hif_reset_soc)(struct hif_softc *hif_sc); + int (*hif_bus_suspend)(struct hif_softc *hif_ctx); + int (*hif_bus_resume)(struct hif_softc *hif_ctx); + int (*hif_target_sleep_state_adjust)(struct hif_softc *scn, + bool sleep_ok, bool wait_for_it); }; #ifdef HIF_SNOC diff --git a/hif/src/dispatcher/multibus_pci.c b/hif/src/dispatcher/multibus_pci.c index d765fc834109..6a505e611005 100644 --- a/hif/src/dispatcher/multibus_pci.c +++ b/hif/src/dispatcher/multibus_pci.c @@ -39,5 +39,12 @@ QDF_STATUS hif_initialize_pci_ops(struct hif_bus_ops *bus_ops) { bus_ops->hif_bus_open = &hif_pci_open; bus_ops->hif_bus_close = &hif_pci_close; + bus_ops->hif_bus_prevent_linkdown = &hif_pci_prevent_linkdown; + bus_ops->hif_reset_soc = &hif_pci_reset_soc; + bus_ops->hif_bus_suspend = &hif_pci_bus_suspend; + bus_ops->hif_bus_resume = &hif_pci_bus_resume; + bus_ops->hif_target_sleep_state_adjust = + &hif_pci_target_sleep_state_adjust; + return QDF_STATUS_SUCCESS; } diff --git a/hif/src/dispatcher/multibus_snoc.c b/hif/src/dispatcher/multibus_snoc.c index 95b6c313ef07..3b9fd18aeb4f 100644 --- a/hif/src/dispatcher/multibus_snoc.c +++ b/hif/src/dispatcher/multibus_snoc.c @@ -29,6 +29,7 @@ #include "hif.h" #include "hif_main.h" #include "snoc_api.h" +#include "dummy.h" /** * hif_initialize_pci_ops() - initialize the pci ops @@ -40,5 +41,12 @@ QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *bus_ops) { bus_ops->hif_bus_open = &hif_snoc_open; bus_ops->hif_bus_close = &hif_snoc_close; + bus_ops->hif_bus_prevent_linkdown = &hif_dummy_bus_prevent_linkdown; + bus_ops->hif_reset_soc = &hif_dummy_reset_soc; + bus_ops->hif_bus_suspend = &hif_dummy_bus_suspend; + bus_ops->hif_bus_resume = &hif_dummy_bus_resume; + bus_ops->hif_target_sleep_state_adjust = + &hif_dummy_target_sleep_state_adjust; + return QDF_STATUS_SUCCESS; } diff --git a/hif/src/dispatcher/pci_api.h b/hif/src/dispatcher/pci_api.h index f3935232a87a..4f6b8e7cd666 100644 --- a/hif/src/dispatcher/pci_api.h +++ b/hif/src/dispatcher/pci_api.h @@ -28,3 +28,9 @@ QDF_STATUS hif_pci_open(struct hif_softc *hif_ctx, enum qdf_bus_type bus_type); void hif_pci_close(struct hif_softc *hif_ctx); +void hif_pci_prevent_linkdown(struct hif_softc *scn, bool flag); +void hif_pci_reset_soc(struct hif_softc *ol_sc); +int hif_pci_bus_suspend(struct hif_softc *scn); +int hif_pci_bus_resume(struct hif_softc *scn); +int hif_pci_target_sleep_state_adjust(struct hif_softc *scn, + bool sleep_ok, bool wait_for_it); diff --git a/hif/src/hif_main.h b/hif/src/hif_main.h index 3c4464653d7a..5664b425f7fb 100644 --- a/hif/src/hif_main.h +++ b/hif/src/hif_main.h @@ -190,4 +190,7 @@ struct hif_callbacks *hif_get_callbacks_handle(struct hif_softc *scn); bool hif_is_driver_unloading(struct hif_softc *scn); bool hif_is_load_or_unload_in_progress(struct hif_softc *scn); bool hif_is_recovery_in_progress(struct hif_softc *scn); +int hif_target_sleep_state_adjust(struct hif_softc *scn, + bool sleep_ok, + bool wait_for_it); #endif /* __HIF_MAIN_H__ */ diff --git a/hif/src/pcie/hif_io32_pci.h b/hif/src/pcie/hif_io32_pci.h index 78892634d8c2..af2fa2ffa21b 100644 --- a/hif/src/pcie/hif_io32_pci.h +++ b/hif/src/pcie/hif_io32_pci.h @@ -88,10 +88,6 @@ #define hif_write32_mb(addr, value) \ iowrite32((u32)(value), (void __iomem *)(addr)) -extern int hif_target_sleep_state_adjust(struct hif_softc *scn, - bool sleep_ok, - bool wait_for_it); - #if CONFIG_ATH_PCIE_MAX_PERF #define A_TARGET_ACCESS_BEGIN(scn) \ do {struct hif_softc *unused = scn; \ diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c index 6afbaba2d5be..43c75e64d62a 100644 --- a/hif/src/pcie/if_pci.c +++ b/hif/src/pcie/if_pci.c @@ -1236,7 +1236,7 @@ void hif_enable_power_management(struct hif_opaque_softc *hif_ctx, if (!CONFIG_ATH_PCIE_MAX_PERF && CONFIG_ATH_PCIE_AWAKE_WHILE_DRIVER_LOAD) { - if (hif_target_sleep_state_adjust(hif_sc, true, false) < 0) + if (hif_pci_target_sleep_state_adjust(hif_sc, true, false) < 0) HIF_ERROR("%s, failed to set target to sleep", __func__); } @@ -1725,7 +1725,8 @@ int hif_bus_configure(struct hif_softc *hif_sc) if (CONFIG_ATH_PCIE_MAX_PERF || CONFIG_ATH_PCIE_AWAKE_WHILE_DRIVER_LOAD) { /* Force AWAKE forever/till the driver is loaded */ - if (hif_target_sleep_state_adjust(hif_sc, false, true) < 0) { + if (hif_pci_target_sleep_state_adjust(hif_sc, false, true) + < 0) { status = -EACCES; goto disable_wlan; } @@ -2259,7 +2260,7 @@ static void hif_runtime_prevent_linkdown(struct hif_softc *scn, bool flag) * * Return: n/a */ -void hif_bus_prevent_linkdown(struct hif_softc *scn, bool flag) +void hif_pci_prevent_linkdown(struct hif_softc *scn, bool flag) { HIF_ERROR("wlan: %s pcie power collapse", (flag ? "disable" : "enable")); @@ -2267,7 +2268,7 @@ void hif_bus_prevent_linkdown(struct hif_softc *scn, bool flag) cnss_wlan_pm_control(flag); } #else -void hif_bus_prevent_linkdown(struct hif_opaque_softc *scn, bool flag) +void hif_pci_prevent_linkdown(struct hif_opaque_softc *scn, bool flag) { HIF_ERROR("wlan: %s pcie power collapse", (flag ? "disable" : "enable")); @@ -2427,17 +2428,15 @@ static int hif_bus_resume_link_down(struct hif_softc *scn) } /** - * hif_bus_suspend(): prepare hif for suspend + * hif_pci_suspend(): prepare hif for suspend * * chose suspend type based on link suspend voting. * * Return: 0 for success and non-zero error code for failure */ -int hif_bus_suspend(struct hif_opaque_softc *hif_ctx) +int hif_pci_bus_suspend(struct hif_softc *scn) { - struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); - - if (hif_can_suspend_link(hif_ctx)) + if (hif_can_suspend_link(GET_HIF_OPAQUE_HDL(scn))) return hif_bus_suspend_link_down(scn); else return hif_bus_suspend_link_up(scn); @@ -2450,11 +2449,9 @@ int hif_bus_suspend(struct hif_opaque_softc *hif_ctx) * * Return: 0 for success and non-zero error code for failure */ -int hif_bus_resume(struct hif_opaque_softc *hif_ctx) +int hif_pci_bus_resume(struct hif_softc *scn) { - struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); - - if (hif_can_suspend_link(hif_ctx)) + if (hif_can_suspend_link(GET_HIF_OPAQUE_HDL(scn))) return hif_bus_resume_link_down(scn); else return hif_bus_resume_link_up(scn); @@ -2660,7 +2657,7 @@ void hif_process_runtime_resume_success(struct hif_opaque_softc *hif_ctx) */ int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx) { - return hif_bus_suspend(hif_ctx); + return hif_pci_bus_suspend(HIF_GET_SOFTC(hif_ctx)); } #ifdef WLAN_FEATURE_FASTPATH @@ -2704,7 +2701,7 @@ static void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx) {} */ int hif_runtime_resume(struct hif_opaque_softc *hif_ctx) { - int status = hif_bus_resume(hif_ctx); + int status = hif_pci_bus_resume(HIF_GET_SOFTC(hif_ctx)); hif_fastpath_resume(hif_ctx); @@ -2743,9 +2740,10 @@ void hif_disable_isr(struct hif_opaque_softc *ol_sc) } /* Function to reset SoC */ -void hif_reset_soc(struct hif_opaque_softc *ol_sc) +void hif_pci_reset_soc(struct hif_softc *hif_sc) { - struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(ol_sc); + struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_sc); + struct hif_opaque_softc *ol_sc = GET_HIF_OPAQUE_HDL(hif_sc); struct hif_target_info *tgt_info = hif_get_target_info_handle(ol_sc); #if defined(CPU_WARM_RESET_WAR) @@ -2874,8 +2872,7 @@ static int hif_log_soc_wakeup_timeout(struct hif_pci_softc *sc) * Return: int */ #if ((CONFIG_ATH_PCIE_MAX_PERF == 0) && CONFIG_ATH_PCIE_AWAKE_WHILE_DRIVER_LOAD) -int -hif_target_sleep_state_adjust(struct hif_softc *scn, +int hif_pci_target_sleep_state_adjust(struct hif_softc *scn, bool sleep_ok, bool wait_for_it) { struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); @@ -2991,7 +2988,7 @@ hif_target_sleep_state_adjust(struct hif_softc *scn, } #else inline int -hif_target_sleep_state_adjust(struct hif_softc *scn, +hif_pci_sleep_state_adjust(struct hif_softc *scn, bool sleep_ok, bool wait_for_it) { return 0; diff --git a/hif/src/snoc/hif_io32_snoc.h b/hif/src/snoc/hif_io32_snoc.h index d8011114688d..9056f9265fe6 100644 --- a/hif/src/snoc/hif_io32_snoc.h +++ b/hif/src/snoc/hif_io32_snoc.h @@ -66,27 +66,6 @@ #define Q_TARGET_ACCESS_BEGIN(scn) 0 #define Q_TARGET_ACCESS_END(scn) 0 -static inline void hif_pci_cancel_deferred_target_sleep(struct hif_softc *scn) -{ - return; -} - -static inline void hif_target_sleep_state_adjust(struct hif_softc *scn, - bool sleep_ok, bool wait_for_it) -{ - return; -} - -/** - * soc_wake_reset() - soc_wake_reset - * @scn: hif_softc - * - * Return: void - */ -static inline void soc_wake_reset(struct hif_softc *scn) -{ -} - /** * hif_write32_mb - SNOC write 32 * @addr: physical address diff --git a/hif/src/snoc/if_snoc.c b/hif/src/snoc/if_snoc.c index 7c2785af4db5..45e66a6ed444 100644 --- a/hif/src/snoc/if_snoc.c +++ b/hif/src/snoc/if_snoc.c @@ -38,50 +38,6 @@ #include "ce_main.h" #include "ce_tasklet.h" -/** - * hif_bus_prevent_linkdown(): prevent linkdown - * - * Dummy function for busses and platforms that do not support - * link down. This may need to be replaced with a wakelock. - * - * This is duplicated here because CONFIG_CNSS can be defined - * even though it is not used for the snoc bus. - */ -void hif_bus_prevent_linkdown(struct hif_softc *scn, bool flag) -{ - HIF_ERROR("wlan: %s pcie power collapse ignored", - (flag ? "disable" : "enable")); -} - -/** - * hif_targ_is_awake(): check if target is awake - * - * This function returns true if the target is awake - * - * @scn: struct hif_softc - * @mem: mapped mem base - * - * Return: bool - */ -bool hif_targ_is_awake(struct hif_softc *scn, void *__iomem *mem) -{ - return true; -} - -/** - * hif_reset_soc(): reset soc - * - * this function resets soc - * - * @hif_ctx: HIF context - * - * Return: void - */ -/* Function to reset SoC */ -void hif_reset_soc(struct hif_opaque_softc *hif_ctx) -{ -} - /** * hif_disable_isr(): disable isr * @@ -136,33 +92,7 @@ int hif_dump_registers(struct hif_opaque_softc *hif_ctx) } /** - * hif_bus_suspend() - suspend the bus - * - * This function suspends the bus, but snoc doesn't need to suspend. - * Therefore do nothing. - * - * Return: 0 for success and non-zero for failure - */ -int hif_bus_suspend(struct hif_opaque_softc *hif_ctx) -{ - return 0; -} - -/** - * hif_bus_resume() - hif resume API - * - * This function resumes the bus. but snoc doesn't need to resume. - * Therefore do nothing. - * - * Return: 0 for success and non-zero for failure - */ -int hif_bus_resume(struct hif_opaque_softc *hif_ctx) -{ - return 0; -} - -/** - * hif_bus_close(): hif_bus_close + * hif_snoc_close(): hif_bus_close * * Return: n/a */