/* * Copyright (c) 2016-2017, Linaro Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */#include<linux/idr.h>#include<linux/interrupt.h>#include<linux/io.h>#include<linux/list.h>#include<linux/mfd/syscon.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_address.h>#include<linux/of_irq.h>#include<linux/platform_device.h>#include<linux/regmap.h>#include<linux/rpmsg.h>#include<linux/slab.h>#include<linux/workqueue.h>#include<linux/mailbox_client.h>#include"rpmsg_internal.h"#include"qcom_glink_native.h"#define GLINK_NAME_SIZE 32#define GLINK_VERSION_1 1#define RPM_GLINK_CID_MIN 1#define RPM_GLINK_CID_MAX 65536structglink_msg{__le16cmd;__le16param1;__le32param2;u8data[];}__packed;/** * struct glink_defer_cmd - deferred incoming control message * @node: list node * @msg: message header * data: payload of the message * * Copy of a received control message, to be added to @rx_queue and processed * by @rx_work of @qcom_glink. */structglink_defer_cmd{structlist_headnode;structglink_msgmsg;u8data[];};/** * struct glink_core_rx_intent - RX intent * RX intent * * data: pointer to the data (may be NULL for zero-copy) * id: remote or local intent ID * size: size of the original intent (do not modify) * reuse: To mark if the intent can be reused after first use * in_use: To mark if intent is already in use for the channel * offset: next write offset (initially 0) */structglink_core_rx_intent{void*data;u32id;size_tsize;boolreuse;boolin_use;u32offset;structlist_headnode;};/** * struct qcom_glink - driver context, relates to one remote subsystem * @dev: reference to the associated struct device * @mbox_client: mailbox client * @mbox_chan: mailbox channel * @rx_pipe: pipe object for receive FIFO * @tx_pipe: pipe object for transmit FIFO * @irq: IRQ for signaling incoming events * @rx_work: worker for handling received control messages * @rx_lock: protects the @rx_queue * @rx_queue: queue of received control messages to be processed in @rx_work * @tx_lock: synchronizes operations on the tx fifo * @idr_lock: synchronizes @lcids and @rcids modifications * @lcids: idr of all channels with a known local channel id * @rcids: idr of all channels with a known remote channel id */structqcom_glink{structdevice*dev;structmbox_clientmbox_client;structmbox_chan*mbox_chan;structqcom_glink_pipe*rx_pipe;structqcom_glink_pipe*tx_pipe;intirq;structwork_struct<