Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) 2015, Sony Mobile Communications AB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/of_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/rpmsg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/soc/qcom/smd-rpm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define RPM_REQUEST_TIMEOUT     (5 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * struct qcom_smd_rpm - state of the rpm device driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * @rpm_channel:	reference to the smd channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * @icc:		interconnect proxy device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * @dev:		rpm device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * @ack:		completion for acks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * @lock:		mutual exclusion around the send/complete pair
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * @ack_status:		result of the rpm request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct qcom_smd_rpm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct rpmsg_endpoint *rpm_channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct platform_device *icc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct completion ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	int ack_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * struct qcom_rpm_header - header for all rpm requests and responses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * @service_type:	identifier of the service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * @length:		length of the payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct qcom_rpm_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	__le32 service_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	__le32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * struct qcom_rpm_request - request message to the rpm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * @msg_id:	identifier of the outgoing message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * @flags:	active/sleep state flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * @type:	resource type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * @id:		resource id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * @data_len:	length of the payload following this header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) struct qcom_rpm_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	__le32 msg_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	__le32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	__le32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	__le32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	__le32 data_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * struct qcom_rpm_message - response message from the rpm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * @msg_type:	indicator of the type of message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * @length:	the size of this message, including the message header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * @msg_id:	message id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * @message:	textual message from the rpm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * Multiple of these messages can be stacked in an rpm message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) struct qcom_rpm_message {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	__le32 msg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	__le32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		__le32 msg_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		u8 message[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define RPM_SERVICE_TYPE_REQUEST	0x00716572 /* "req\0" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #define RPM_MSG_TYPE_ERR		0x00727265 /* "err\0" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define RPM_MSG_TYPE_MSG_ID		0x2367736d /* "msg#" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * qcom_rpm_smd_write - write @buf to @type:@id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * @rpm:	rpm handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * @state:	active/sleep state flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * @type:	resource type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * @id:		resource identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * @buf:	the data to be written
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  * @count:	number of bytes in @buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		       int state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		       u32 type, u32 id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		       void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		       size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	static unsigned msg_id = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	int left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		struct qcom_rpm_header hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		struct qcom_rpm_request req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		u8 payload[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	} *pkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	size_t size = sizeof(*pkt) + count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	/* SMD packets to the RPM may not exceed 256 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (WARN_ON(size >= 256))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	pkt = kmalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (!pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	mutex_lock(&rpm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	pkt->hdr.service_type = cpu_to_le32(RPM_SERVICE_TYPE_REQUEST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	pkt->hdr.length = cpu_to_le32(sizeof(struct qcom_rpm_request) + count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	pkt->req.msg_id = cpu_to_le32(msg_id++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	pkt->req.flags = cpu_to_le32(state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	pkt->req.type = cpu_to_le32(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	pkt->req.id = cpu_to_le32(id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	pkt->req.data_len = cpu_to_le32(count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	memcpy(pkt->payload, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	ret = rpmsg_send(rpm->rpm_channel, pkt, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	left = wait_for_completion_timeout(&rpm->ack, RPM_REQUEST_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	if (!left)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		ret = -ETIMEDOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		ret = rpm->ack_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	kfree(pkt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	mutex_unlock(&rpm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) EXPORT_SYMBOL(qcom_rpm_smd_write);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static int qcom_smd_rpm_callback(struct rpmsg_device *rpdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 				 void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 				 int count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 				 void *priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				 u32 addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	const struct qcom_rpm_header *hdr = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	size_t hdr_length = le32_to_cpu(hdr->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	const struct qcom_rpm_message *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	struct qcom_smd_rpm *rpm = dev_get_drvdata(&rpdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	const u8 *buf = data + sizeof(struct qcom_rpm_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	const u8 *end = buf + hdr_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	char msgbuf[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	u32 len, msg_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if (le32_to_cpu(hdr->service_type) != RPM_SERVICE_TYPE_REQUEST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	    hdr_length < sizeof(struct qcom_rpm_message)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		dev_err(rpm->dev, "invalid request\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	while (buf < end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		msg = (struct qcom_rpm_message *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		msg_length = le32_to_cpu(msg->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		switch (le32_to_cpu(msg->msg_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		case RPM_MSG_TYPE_MSG_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		case RPM_MSG_TYPE_ERR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			len = min_t(u32, ALIGN(msg_length, 4), sizeof(msgbuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			memcpy_fromio(msgbuf, msg->message, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			msgbuf[len - 1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			if (!strcmp(msgbuf, "resource does not exist"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 				status = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 				status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		buf = PTR_ALIGN(buf + 2 * sizeof(u32) + msg_length, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	rpm->ack_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	complete(&rpm->ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static int qcom_smd_rpm_probe(struct rpmsg_device *rpdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	struct qcom_smd_rpm *rpm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	rpm = devm_kzalloc(&rpdev->dev, sizeof(*rpm), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	if (!rpm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	mutex_init(&rpm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	init_completion(&rpm->ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	rpm->dev = &rpdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	rpm->rpm_channel = rpdev->ept;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	dev_set_drvdata(&rpdev->dev, rpm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	rpm->icc = platform_device_register_data(&rpdev->dev, "icc_smd_rpm", -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 						 NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (IS_ERR(rpm->icc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		return PTR_ERR(rpm->icc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	ret = of_platform_populate(rpdev->dev.of_node, NULL, NULL, &rpdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		platform_device_unregister(rpm->icc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static void qcom_smd_rpm_remove(struct rpmsg_device *rpdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	struct qcom_smd_rpm *rpm = dev_get_drvdata(&rpdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	platform_device_unregister(rpm->icc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	of_platform_depopulate(&rpdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static const struct of_device_id qcom_smd_rpm_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	{ .compatible = "qcom,rpm-apq8084" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	{ .compatible = "qcom,rpm-ipq6018" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	{ .compatible = "qcom,rpm-msm8916" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	{ .compatible = "qcom,rpm-msm8936" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	{ .compatible = "qcom,rpm-msm8974" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	{ .compatible = "qcom,rpm-msm8976" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	{ .compatible = "qcom,rpm-msm8994" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	{ .compatible = "qcom,rpm-msm8996" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	{ .compatible = "qcom,rpm-msm8998" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	{ .compatible = "qcom,rpm-sdm660" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	{ .compatible = "qcom,rpm-qcs404" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) MODULE_DEVICE_TABLE(of, qcom_smd_rpm_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static struct rpmsg_driver qcom_smd_rpm_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	.probe = qcom_smd_rpm_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	.remove = qcom_smd_rpm_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	.callback = qcom_smd_rpm_callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	.drv  = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		.name  = "qcom_smd_rpm",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		.of_match_table = qcom_smd_rpm_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static int __init qcom_smd_rpm_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	return register_rpmsg_driver(&qcom_smd_rpm_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) arch_initcall(qcom_smd_rpm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static void __exit qcom_smd_rpm_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	unregister_rpmsg_driver(&qcom_smd_rpm_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) module_exit(qcom_smd_rpm_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) MODULE_AUTHOR("Bjorn Andersson <bjorn.andersson@sonymobile.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) MODULE_DESCRIPTION("Qualcomm SMD backed RPM driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) MODULE_LICENSE("GPL v2");