// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2015, Sony Mobile Communications AB. * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. */ #include <linux/module.h> #include <linux/platform_device.h> #include <linux/of_platform.h> #include <linux/io.h> #include <linux/interrupt.h> #include <linux/slab.h> #include <linux/rpmsg.h> #include <linux/soc/qcom/smd-rpm.h> #define RPM_REQUEST_TIMEOUT … /** * struct qcom_smd_rpm - state of the rpm device driver * @rpm_channel: reference to the smd channel * @dev: rpm device * @ack: completion for acks * @lock: mutual exclusion around the send/complete pair * @ack_status: result of the rpm request */ struct qcom_smd_rpm { … }; /** * struct qcom_rpm_header - header for all rpm requests and responses * @service_type: identifier of the service * @length: length of the payload */ struct qcom_rpm_header { … }; /** * struct qcom_rpm_request - request message to the rpm * @msg_id: identifier of the outgoing message * @flags: active/sleep state flags * @type: resource type * @id: resource id * @data_len: length of the payload following this header */ struct qcom_rpm_request { … }; /** * struct qcom_rpm_message - response message from the rpm * @msg_type: indicator of the type of message * @length: the size of this message, including the message header * @msg_id: message id * @message: textual message from the rpm * * Multiple of these messages can be stacked in an rpm message. */ struct qcom_rpm_message { … }; #define RPM_SERVICE_TYPE_REQUEST … #define RPM_MSG_TYPE_ERR … #define RPM_MSG_TYPE_MSG_ID … /** * qcom_rpm_smd_write - write @buf to @type:@id * @rpm: rpm handle * @state: active/sleep state flags * @type: resource type * @id: resource identifier * @buf: the data to be written * @count: number of bytes in @buf */ int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm, int state, u32 type, u32 id, void *buf, size_t count) { … } EXPORT_SYMBOL_GPL(…); static int qcom_smd_rpm_callback(struct rpmsg_device *rpdev, void *data, int count, void *priv, u32 addr) { … } static int qcom_smd_rpm_probe(struct rpmsg_device *rpdev) { … } static void qcom_smd_rpm_remove(struct rpmsg_device *rpdev) { … } static const struct rpmsg_device_id qcom_smd_rpm_id_table[] = …; MODULE_DEVICE_TABLE(rpmsg, qcom_smd_rpm_id_table); static struct rpmsg_driver qcom_smd_rpm_driver = …; static int __init qcom_smd_rpm_init(void) { … } arch_initcall(qcom_smd_rpm_init); static void __exit qcom_smd_rpm_exit(void) { … } module_exit(qcom_smd_rpm_exit); MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;