Lines Matching +full:smd +full:- +full:rpm

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
15 #include <linux/soc/qcom/smd-rpm.h>
20 * struct qcom_smd_rpm - state of the rpm device driver
21 * @rpm_channel: reference to the smd channel
23 * @dev: rpm device
26 * @ack_status: result of the rpm request
39 * struct qcom_rpm_header - header for all rpm requests and responses
49 * struct qcom_rpm_request - request message to the rpm
65 * struct qcom_rpm_message - response message from the rpm
69 * @message: textual message from the rpm
71 * Multiple of these messages can be stacked in an rpm message.
88 * qcom_rpm_smd_write - write @buf to @type:@id
89 * @rpm: rpm handle
96 int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm, in qcom_rpm_smd_write() argument
112 /* SMD packets to the RPM may not exceed 256 bytes */ in qcom_rpm_smd_write()
114 return -EINVAL; in qcom_rpm_smd_write()
118 return -ENOMEM; in qcom_rpm_smd_write()
120 mutex_lock(&rpm->lock); in qcom_rpm_smd_write()
122 pkt->hdr.service_type = cpu_to_le32(RPM_SERVICE_TYPE_REQUEST); in qcom_rpm_smd_write()
123 pkt->hdr.length = cpu_to_le32(sizeof(struct qcom_rpm_request) + count); in qcom_rpm_smd_write()
125 pkt->req.msg_id = cpu_to_le32(msg_id++); in qcom_rpm_smd_write()
126 pkt->req.flags = cpu_to_le32(state); in qcom_rpm_smd_write()
127 pkt->req.type = cpu_to_le32(type); in qcom_rpm_smd_write()
128 pkt->req.id = cpu_to_le32(id); in qcom_rpm_smd_write()
129 pkt->req.data_len = cpu_to_le32(count); in qcom_rpm_smd_write()
130 memcpy(pkt->payload, buf, count); in qcom_rpm_smd_write()
132 ret = rpmsg_send(rpm->rpm_channel, pkt, size); in qcom_rpm_smd_write()
136 left = wait_for_completion_timeout(&rpm->ack, RPM_REQUEST_TIMEOUT); in qcom_rpm_smd_write()
138 ret = -ETIMEDOUT; in qcom_rpm_smd_write()
140 ret = rpm->ack_status; in qcom_rpm_smd_write()
144 mutex_unlock(&rpm->lock); in qcom_rpm_smd_write()
156 size_t hdr_length = le32_to_cpu(hdr->length); in qcom_smd_rpm_callback()
158 struct qcom_smd_rpm *rpm = dev_get_drvdata(&rpdev->dev); in qcom_smd_rpm_callback() local
165 if (le32_to_cpu(hdr->service_type) != RPM_SERVICE_TYPE_REQUEST || in qcom_smd_rpm_callback()
167 dev_err(rpm->dev, "invalid request\n"); in qcom_smd_rpm_callback()
173 msg_length = le32_to_cpu(msg->length); in qcom_smd_rpm_callback()
174 switch (le32_to_cpu(msg->msg_type)) { in qcom_smd_rpm_callback()
179 memcpy_fromio(msgbuf, msg->message, len); in qcom_smd_rpm_callback()
180 msgbuf[len - 1] = 0; in qcom_smd_rpm_callback()
183 status = -ENXIO; in qcom_smd_rpm_callback()
185 status = -EINVAL; in qcom_smd_rpm_callback()
192 rpm->ack_status = status; in qcom_smd_rpm_callback()
193 complete(&rpm->ack); in qcom_smd_rpm_callback()
199 struct qcom_smd_rpm *rpm; in qcom_smd_rpm_probe() local
202 rpm = devm_kzalloc(&rpdev->dev, sizeof(*rpm), GFP_KERNEL); in qcom_smd_rpm_probe()
203 if (!rpm) in qcom_smd_rpm_probe()
204 return -ENOMEM; in qcom_smd_rpm_probe()
206 mutex_init(&rpm->lock); in qcom_smd_rpm_probe()
207 init_completion(&rpm->ack); in qcom_smd_rpm_probe()
209 rpm->dev = &rpdev->dev; in qcom_smd_rpm_probe()
210 rpm->rpm_channel = rpdev->ept; in qcom_smd_rpm_probe()
211 dev_set_drvdata(&rpdev->dev, rpm); in qcom_smd_rpm_probe()
213 rpm->icc = platform_device_register_data(&rpdev->dev, "icc_smd_rpm", -1, in qcom_smd_rpm_probe()
215 if (IS_ERR(rpm->icc)) in qcom_smd_rpm_probe()
216 return PTR_ERR(rpm->icc); in qcom_smd_rpm_probe()
218 ret = of_platform_populate(rpdev->dev.of_node, NULL, NULL, &rpdev->dev); in qcom_smd_rpm_probe()
220 platform_device_unregister(rpm->icc); in qcom_smd_rpm_probe()
227 struct qcom_smd_rpm *rpm = dev_get_drvdata(&rpdev->dev); in qcom_smd_rpm_remove() local
229 platform_device_unregister(rpm->icc); in qcom_smd_rpm_remove()
230 of_platform_depopulate(&rpdev->dev); in qcom_smd_rpm_remove()
234 { .compatible = "qcom,rpm-apq8084" },
235 { .compatible = "qcom,rpm-ipq6018" },
236 { .compatible = "qcom,rpm-msm8916" },
237 { .compatible = "qcom,rpm-msm8936" },
238 { .compatible = "qcom,rpm-msm8974" },
239 { .compatible = "qcom,rpm-msm8976" },
240 { .compatible = "qcom,rpm-msm8994" },
241 { .compatible = "qcom,rpm-msm8996" },
242 { .compatible = "qcom,rpm-msm8998" },
243 { .compatible = "qcom,rpm-sdm660" },
244 { .compatible = "qcom,rpm-qcs404" },
272 MODULE_DESCRIPTION("Qualcomm SMD backed RPM driver");