ath10k: ath11k: add specific LinuxKPI support

Add files needed by ath1?k drivers to linuxkpi/linuxkpi_wlan.
This contain (skeleton) implementations of what is needed to
compile but specifically mhi/qmi/qrtr will need more work for
ath11k.

MFC after:	2 months
This commit is contained in:
Bjoern A. Zeeb 2023-04-18 20:21:37 +00:00
parent e17944a821
commit 06a1103fe3
6 changed files with 512 additions and 0 deletions

View File

@ -0,0 +1,198 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 Bjoern A. Zeeb
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _LINUXKPI_LINUX_MHI_H
#define _LINUXKPI_LINUX_MHI_H
#include <linux/types.h>
/* Modem Host Interface (MHI) */
/* XXX FIXME */
#define MHI_DB_BRST_DISABLE 0
#define MHI_ER_CTRL 0
enum mhi_callback {
MHI_CB_SYS_ERROR,
};
struct mhi_channel_config {
const char *name;
int auto_queue, dir, doorbell, doorbell_mode_switch, ee_mask, event_ring, lpm_notify, num, num_elements, offload_channel, pollcfg;
};
struct mhi_event_config {
int client_managed, data_type, hardware_event, irq, irq_moderation_ms, mode, num_elements, offload_channel, priority;
};
struct mhi_device {
};
struct mhi_controller_config {
struct mhi_channel_config *ch_cfg;
struct mhi_event_config *event_cfg;
int buf_len, max_channels, num_channels, num_events, use_bounce_buf;
uint32_t timeout_ms;
};
struct mhi_controller {
struct device *cntrl_dev;
struct mhi_device *mhi_dev;
void *regs;
int *irq;
const char *fw_image;
bool fbc_download;
size_t sbl_size;
size_t seg_len;
size_t reg_len;
int nr_irqs;
unsigned long irq_flags;
uint32_t timeout_ms;
dma_addr_t iova_start;
dma_addr_t iova_stop;
int (*runtime_get)(struct mhi_controller *);
void (*runtime_put)(struct mhi_controller *);
void (*status_cb)(struct mhi_controller *, enum mhi_callback);
int (*read_reg)(struct mhi_controller *, void __iomem *, uint32_t *);
void (*write_reg)(struct mhi_controller *, void __iomem *, uint32_t);
};
/* -------------------------------------------------------------------------- */
struct mhi_controller *linuxkpi_mhi_alloc_controller(void);
void linuxkpi_mhi_free_controller(struct mhi_controller *);
int linuxkpi_mhi_register_controller(struct mhi_controller *,
struct mhi_controller_config *);
void linuxkpi_mhi_unregister_controller(struct mhi_controller *);
/* -------------------------------------------------------------------------- */
static inline struct mhi_controller *
mhi_alloc_controller(void)
{
/* Keep allocations internal to our implementation. */
return (linuxkpi_mhi_alloc_controller());
}
static inline void
mhi_free_controller(struct mhi_controller *mhi_ctrl)
{
linuxkpi_mhi_free_controller(mhi_ctrl);
}
static inline int
mhi_register_controller(struct mhi_controller *mhi_ctrl,
struct mhi_controller_config *cfg)
{
return (linuxkpi_mhi_register_controller(mhi_ctrl, cfg));
}
static inline void
mhi_unregister_controller(struct mhi_controller *mhi_ctrl)
{
linuxkpi_mhi_unregister_controller(mhi_ctrl);
}
/* -------------------------------------------------------------------------- */
static __inline void
mhi_device_get_sync(struct mhi_device *mhi_dev)
{
/* XXX TODO */
}
static __inline void
mhi_device_put(struct mhi_device *mhi_dev)
{
/* XXX TODO */
}
/* -------------------------------------------------------------------------- */
static __inline int
mhi_prepare_for_power_up(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
static __inline int
mhi_async_power_up(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
static __inline void
mhi_power_down(struct mhi_controller *mhi_ctrl, bool x)
{
/* XXX TODO */
}
static __inline void
mhi_unprepare_after_power_down(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
}
/* -------------------------------------------------------------------------- */
static __inline int
mhi_pm_suspend(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
static __inline int
mhi_pm_resume_force(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
/* -------------------------------------------------------------------------- */
static __inline int
mhi_force_rddm_mode(struct mhi_controller *mhi_ctrl)
{
/* XXX TODO */
return (0);
}
#endif /* _LINUXKPI_LINUX_MHI_H */

View File

@ -0,0 +1,41 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 Bjoern A. Zeeb
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _LINUXKPI_LINUX_QRTR_H
#define _LINUXKPI_LINUX_QRTR_H
/* Qualcomm IPC Router (QRTR) */
#include <sys/socket.h>
struct sockaddr_qrtr {
sa_family_t sq_family;
uint32_t sq_node;
uint32_t sq_port;
};
#endif /* _LINUXKPI_LINUX_QRTR_H */

View File

@ -0,0 +1,174 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 Bjoern A. Zeeb
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _LINUXKPI_LINUX_SOC_QCOM_QMI_H
#define _LINUXKPI_LINUX_SOC_QCOM_QMI_H
/* QMI (Qualcomm MSM Interface) */
#include <linux/qrtr.h>
enum soc_qcom_qmi_data_type {
QMI_EOTI,
QMI_DATA_LEN,
QMI_OPT_FLAG,
QMI_UNSIGNED_1_BYTE,
QMI_UNSIGNED_2_BYTE,
QMI_UNSIGNED_4_BYTE,
QMI_UNSIGNED_8_BYTE,
QMI_SIGNED_4_BYTE_ENUM,
QMI_STRUCT,
QMI_STRING,
};
#define QMI_RESULT_SUCCESS_V01 __LINE__
#define QMI_INDICATION __LINE__
struct qmi_handle;
enum soc_qcom_qmi_array_type {
NO_ARRAY,
VAR_LEN_ARRAY,
};
/* Should this become an enum? */
#define QMI_COMMON_TLV_TYPE 0
struct qmi_elem_info {
enum soc_qcom_qmi_data_type data_type;
uint32_t elem_len;
uint32_t elem_size;
enum soc_qcom_qmi_array_type array_type;
uint8_t tlv_type;
uint32_t offset;
struct qmi_elem_info *ei_array;
};
struct qmi_response_type_v01 {
uint16_t result;
uint16_t error;
};
struct qmi_txn {
};
struct qmi_service {
uint32_t node;
uint32_t port;
};
struct qmi_msg_handler {
uint32_t type;
uint32_t msg_id;
struct qmi_elem_info *ei;
size_t decoded_size;
void (*fn)(struct qmi_handle *, struct sockaddr_qrtr *, struct qmi_txn *, const void *);
};
struct qmi_ops {
int (*new_server)(struct qmi_handle *, struct qmi_service *);
void (*del_server)(struct qmi_handle *, struct qmi_service *);
};
struct qmi_handle {
int sock;
const struct qmi_msg_handler *handler;
struct qmi_ops ops;
};
/* XXX-TODO need implementation somewhere... it is not in ath1xk* */
extern struct qmi_elem_info qmi_response_type_v01_ei[];
static inline int
qmi_handle_init(struct qmi_handle *handle, size_t resp_len_max,
const struct qmi_ops *ops, const struct qmi_msg_handler *handler)
{
handle->handler = handler;
if (ops != NULL)
handle->ops = *ops;
/* We will find out what else to do here. */
/* XXX TODO */
return (0);
}
static __inline int
qmi_add_lookup(struct qmi_handle *handle, uint32_t service, uint32_t version,
uint32_t service_ins_id)
{
/* XXX TODO */
return (0);
}
static __inline void
qmi_handle_release(struct qmi_handle *handle)
{
/* XXX TODO */
}
static __inline int
qmi_send_request(struct qmi_handle *handle, void *x, struct qmi_txn *txn,
uint32_t msd_id, size_t len, struct qmi_elem_info *ei, void *req)
{
/* XXX TODO */
return (-ENXIO);
}
static __inline void
qmi_txn_cancel(struct qmi_txn *txn)
{
/* XXX TODO */
}
static __inline int
qmi_txn_init(struct qmi_handle *handle, struct qmi_txn *txn,
struct qmi_elem_info *ei, void *resp)
{
/* XXX TODO */
return (-ENXIO);
}
static __inline int
qmi_txn_wait(struct qmi_txn *txn, uint64_t jiffies)
{
/* XXX TODO */
return (-ENXIO);
}
#endif /* _LINUXKPI_LINUX_SOC_QCOM_QMI_H */

View File

@ -0,0 +1,94 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 Bjoern A. Zeeb
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/types.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <linux/kernel.h> /* pr_debug */
#include <linux/mhi.h>
static MALLOC_DEFINE(M_LKPIMHI, "lkpimhi", "LinuxKPI MHI compat");
struct mhi_controller *
linuxkpi_mhi_alloc_controller(void)
{
struct mhi_controller *mhi_ctrl;
mhi_ctrl = malloc(sizeof(*mhi_ctrl), M_LKPIMHI, M_NOWAIT | M_ZERO);
return (mhi_ctrl);
}
void
linuxkpi_mhi_free_controller(struct mhi_controller *mhi_ctrl)
{
/* What else do we need to check that it is gone? */
free(mhi_ctrl, M_LKPIMHI);
}
int
linuxkpi_mhi_register_controller(struct mhi_controller *mhi_ctrl,
struct mhi_controller_config *cfg)
{
if (mhi_ctrl == NULL || cfg == NULL)
return (-EINVAL);
#define CHECK_FIELD(_f) \
if (!mhi_ctrl->_f) \
return (-ENXIO);
CHECK_FIELD(cntrl_dev);
CHECK_FIELD(regs);
CHECK_FIELD(irq);
CHECK_FIELD(reg_len);
CHECK_FIELD(nr_irqs);
CHECK_FIELD(runtime_get);
CHECK_FIELD(runtime_put);
CHECK_FIELD(status_cb);
CHECK_FIELD(read_reg);
CHECK_FIELD(write_reg);
#undef CHECK_FIELD
printf("%s: XXX-BZ TODO\n", __func__);
return (0);
}
void
linuxkpi_mhi_unregister_controller(struct mhi_controller *mhi_ctrl)
{
pr_debug("%s: TODO\n", __func__);
}

View File

@ -4564,6 +4564,8 @@ compat/linuxkpi/common/src/linux_kthread.c optional compat_linuxkpi \
compile-with "${LINUXKPI_C}"
compat/linuxkpi/common/src/linux_lock.c optional compat_linuxkpi \
compile-with "${LINUXKPI_C}"
compat/linuxkpi/common/src/linux_mhi.c optional compat_linuxkpi wlan \
compile-with "${LINUXKPI_C}"
compat/linuxkpi/common/src/linux_netdev.c optional compat_linuxkpi \
compile-with "${LINUXKPI_C}"
compat/linuxkpi/common/src/linux_page.c optional compat_linuxkpi \

View File

@ -5,6 +5,9 @@ KMOD= linuxkpi_wlan
SRCS= linux_80211.c \
linux_80211_macops.c
# QCA ath11k support.
SRCS+= linux_mhi.c
SRCS+= opt_wlan.h
SRCS+= ${LINUXKPI_GENSRCS}