diff --git a/hif/src/dispatcher/multibus.c b/hif/src/dispatcher/multibus.c new file mode 100644 index 0000000000..3e0d1257ec --- /dev/null +++ b/hif/src/dispatcher/multibus.c @@ -0,0 +1,122 @@ +/* + * 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. + */ + + +/* this file dispatches functions to bus specific definitions */ +#include "hif_debug.h" +#include "hif.h" +#include "hif_main.h" +#include "multibus.h" + +/** + * hif_intialize_default_ops() - intializes default operations values + * + * bus specific features should assign their dummy implementations here. + */ +static void hif_intialize_default_ops(struct hif_softc *hif_sc) +{ + struct hif_bus_ops *bus_ops = &hif_sc->bus_ops; + + /* must be filled in by hif_bus_open */ + bus_ops->hif_bus_close = NULL; + + /* dummy implementations */ +} + +#define NUM_OPS (sizeof(struct hif_bus_ops) / sizeof(void *)) + +/** + * hif_verify_basic_ops() - ensure required bus apis are defined + * + * all bus operations must be defined to avoid crashes + * itterate over the structure and ensure all function pointers + * are non null. + * + * Return: QDF_STATUS_SUCCESS if all the operations are defined + */ +static QDF_STATUS hif_verify_basic_ops(struct hif_softc *hif_sc) +{ + struct hif_bus_ops *bus_ops = &hif_sc->bus_ops; + void **ops_array = (void *)bus_ops; + QDF_STATUS status = QDF_STATUS_SUCCESS; + int i; + + for (i = 0; i < NUM_OPS; i++) { + if (!ops_array[i]) { + HIF_ERROR("%s: function %d is null", __func__, i); + status = QDF_STATUS_E_NOSUPPORT; + } + } + return status; +} + +/** + * hif_bus_open() - initialize the bus_ops and call the bus specific open + * hif_sc: hif_context + * bus_type: type of bus being enumerated + * + * Return: QDF_STATUS_SUCCESS or error + */ +QDF_STATUS hif_bus_open(struct hif_softc *hif_sc, + enum qdf_bus_type bus_type) +{ + QDF_STATUS status = QDF_STATUS_E_INVAL; + + hif_intialize_default_ops(hif_sc); + + switch (bus_type) { + case QDF_BUS_TYPE_PCI: + status = hif_initialize_pci_ops(&hif_sc->bus_ops); + break; + case QDF_BUS_TYPE_SNOC: + status = hif_initialize_snoc_ops(&hif_sc->bus_ops); + break; + default: + status = QDF_STATUS_E_NOSUPPORT; + break; + } + + if (status != QDF_STATUS_SUCCESS) { + HIF_ERROR("%s: %d not supported", __func__, bus_type); + return status; + } + + status = hif_verify_basic_ops(hif_sc); + if (status != QDF_STATUS_SUCCESS) + return status; + + return hif_sc->bus_ops.hif_bus_open(hif_sc, bus_type); +} + +/** + * hif_bus_close() - close the bus + * @hif_sc: hif_context + */ +void hif_bus_close(struct hif_softc *hif_sc) +{ + hif_sc->bus_ops.hif_bus_close(hif_sc); +} diff --git a/hif/src/dispatcher/multibus.h b/hif/src/dispatcher/multibus.h new file mode 100644 index 0000000000..4a1d7df31e --- /dev/null +++ b/hif/src/dispatcher/multibus.h @@ -0,0 +1,63 @@ +/* + * 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. + */ + +#ifndef _MULTIBUS_H_ +#define _MULTIBUS_H_ + +#include "osdep.h" +#include "qdf_status.h" +#include "hif_debug.h" + +struct hif_softc; + +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); +}; + +#ifdef HIF_SNOC +QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc); +#else +static inline QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc) +{ + HIF_ERROR("%s: not supported", __func__); + return QDF_STATUS_E_NOSUPPORT; +} +#endif /* HIF_SNOC */ + +#ifdef HIF_PCI +QDF_STATUS hif_initialize_pci_ops(struct hif_bus_ops *hif_sc); +#else +static inline QDF_STATUS hif_initialize_pci_ops(struct hif_bus_ops *hif_sc) +{ + HIF_ERROR("%s: not supported", __func__); + return QDF_STATUS_E_NOSUPPORT; +} +#endif /* HIF_PCI */ + +#endif /* _MULTIBUS_H_ */ diff --git a/hif/src/dispatcher/multibus_pci.c b/hif/src/dispatcher/multibus_pci.c new file mode 100644 index 0000000000..d765fc8341 --- /dev/null +++ b/hif/src/dispatcher/multibus_pci.c @@ -0,0 +1,43 @@ +/* + * 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 "hif.h" +#include "multibus.h" +#include "pci_api.h" + +/** + * hif_initialize_pci_ops() - initialize the pci ops + * @bus_ops: hif_bus_ops table pointer to initialize + * + * Return: QDF_STATUS_SUCCESS + */ +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; + return QDF_STATUS_SUCCESS; +} diff --git a/hif/src/dispatcher/multibus_snoc.c b/hif/src/dispatcher/multibus_snoc.c new file mode 100644 index 0000000000..95b6c313ef --- /dev/null +++ b/hif/src/dispatcher/multibus_snoc.c @@ -0,0 +1,44 @@ +/* + * 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 "multibus.h" +#include "hif.h" +#include "hif_main.h" +#include "snoc_api.h" + +/** + * hif_initialize_pci_ops() - initialize the pci ops + * @bus_ops: hif_bus_ops table pointer to initialize + * + * Return: QDF_STATUS_SUCCESS + */ +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; + return QDF_STATUS_SUCCESS; +} diff --git a/hif/src/dispatcher/pci_api.h b/hif/src/dispatcher/pci_api.h new file mode 100644 index 0000000000..f3935232a8 --- /dev/null +++ b/hif/src/dispatcher/pci_api.h @@ -0,0 +1,30 @@ +/* + * 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. + */ + +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); diff --git a/hif/src/dispatcher/snoc_api.h b/hif/src/dispatcher/snoc_api.h new file mode 100644 index 0000000000..ff4dfd70b4 --- /dev/null +++ b/hif/src/dispatcher/snoc_api.h @@ -0,0 +1,30 @@ +/* + * 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. + */ + +QDF_STATUS hif_snoc_open(struct hif_softc *hif_ctx, + enum qdf_bus_type bus_type); +void hif_snoc_close(struct hif_softc *hif_ctx); diff --git a/hif/src/hif_main.h b/hif/src/hif_main.h index ed2245f835..1f769772d8 100644 --- a/hif/src/hif_main.h +++ b/hif/src/hif_main.h @@ -46,6 +46,7 @@ #include "qdf_lock.h" #include "cepci.h" #include "hif.h" +#include "multibus.h" #define HIF_MIN_SLEEP_INACTIVITY_TIME_MS 50 #define HIF_SLEEP_INACTIVITY_TIMER_PERIOD_MS 60 @@ -114,6 +115,7 @@ struct hif_softc { struct hif_target_info target_info; void __iomem *mem; enum qdf_bus_type bus_type; + struct hif_bus_ops bus_ops; void *ce_id_to_state[CE_COUNT_MAX]; qdf_device_t qdf_dev; bool hif_init_done; diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c index 84c413a403..6380d72f31 100644 --- a/hif/src/pcie/if_pci.c +++ b/hif/src/pcie/if_pci.c @@ -70,6 +70,8 @@ #include "icnss_stub.h" #include "ce_tasklet.h" +#include "pci_api.h" + /* Maximum ms timeout for host to wake up target */ #define PCIE_WAKE_TIMEOUT 1000 #define RAMDUMP_EVENT_TIMEOUT 2500 @@ -1194,16 +1196,16 @@ int hif_bus_get_context_size(void) * * Return: n/a */ -QDF_STATUS hif_bus_open(struct hif_softc *ol_sc, enum qdf_bus_type bus_type) +QDF_STATUS hif_pci_open(struct hif_softc *hif_ctx, enum qdf_bus_type bus_type) { - struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(ol_sc); + struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx); - ol_sc->bus_type = bus_type; + hif_ctx->bus_type = bus_type; hif_pm_runtime_open(sc); qdf_spinlock_create(&sc->irq_lock); - return hif_ce_open(ol_sc); + return hif_ce_open(hif_ctx); } #ifdef BMI_RSP_POLLING @@ -1296,12 +1298,10 @@ disable_wlan: * * Return: n/a */ -void hif_bus_close(struct hif_softc *hif_sc) +void hif_pci_close(struct hif_softc *hif_sc) { struct hif_pci_softc *hif_pci_sc = HIF_GET_PCI_SOFTC(hif_sc); - hif_pm_runtime_close(hif_pci_sc); - hif_ce_close(hif_sc); } diff --git a/hif/src/snoc/if_snoc.c b/hif/src/snoc/if_snoc.c index 88c94d20cd..20530fa0a3 100644 --- a/hif/src/snoc/if_snoc.c +++ b/hif/src/snoc/if_snoc.c @@ -184,7 +184,7 @@ void hif_disable_aspm(struct hif_opaque_softc *hif_ctx) * * Return: n/a */ -void hif_bus_close(struct hif_softc *scn) +void hif_snoc_close(struct hif_softc *scn) { hif_ce_close(scn); } @@ -198,16 +198,17 @@ int hif_bus_get_context_size(void) { return sizeof(struct HIF_CE_state); } + /** * hif_bus_open(): hif_bus_open - * @scn: scn + * @hif_ctx: hif context * @bus_type: bus type * * Return: n/a */ -QDF_STATUS hif_bus_open(struct hif_softc *scn, enum qdf_bus_type bus_type) +QDF_STATUS hif_snoc_open(struct hif_softc *hif_ctx, enum qdf_bus_type bus_type) { - return hif_ce_open(scn); + return hif_ce_open(hif_ctx); } /** @@ -223,7 +224,7 @@ static QDF_STATUS hif_snoc_get_soc_info(struct hif_softc *scn) int ret; struct icnss_soc_info soc_info; - cdf_mem_zero(&soc_info, sizeof(soc_info)); + qdf_mem_zero(&soc_info, sizeof(soc_info)); ret = icnss_get_soc_info(&soc_info); if (ret < 0) {