#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/mfd/syscon.h>
#include <linux/circ_buf.h>
#include <linux/soc/qcom/smem.h>
#include <linux/regmap.h>
#include <linux/workqueue.h>
#include <linux/rpmsg/qcom_glink.h>
#include "qcom_glink_native.h"
#define FIFO_FULL_RESERVE 8
#define TX_BLOCKED_CMD_RESERVE 8
#define SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR 478
#define SMEM_GLINK_NATIVE_XPRT_FIFO_0 479
#define SMEM_GLINK_NATIVE_XPRT_FIFO_1 480
struct qcom_glink_pipe native;
#define to_smem_pipe(p) container_of(p, struct glink_smem_pipe, native)
static size_t glink_smem_rx_avail(struct qcom_glink_pipe *np)
struct glink_smem_pipe *pipe = to_smem_pipe(np);
fifo = qcom_smem_get(pipe->remote_pid,
SMEM_GLINK_NATIVE_XPRT_FIFO_1, &len);
pr_err("failed to acquire RX fifo handle: %ld\n",
pipe->native.length = len;
head = le32_to_cpu(*pipe->head);
tail = le32_to_cpu(*pipe->tail);
return pipe->native.length - tail + head;
static void glink_smem_rx_peak(struct qcom_glink_pipe *np,
void *data, unsigned int offset, size_t count)
struct glink_smem_pipe *pipe = to_smem_pipe(np);
tail = le32_to_cpu(*pipe->tail);
if (tail >= pipe->native.length)
tail -= pipe->native.length;
len = min_t(size_t, count, pipe->native.length - tail);