1 // SPDX-License-Identifier: GPL-2.0
3 * RPM over SMD communication wrapper for interconnects
5 * Copyright (C) 2019 Linaro Ltd
6 * Author: Georgi Djakov <georgi.djakov@linaro.org>
9 #include <linux/interconnect-provider.h>
10 #include <linux/module.h>
11 #include <linux/platform_device.h>
12 #include <linux/soc/qcom/smd-rpm.h>
16 #define RPM_KEY_BW 0x00007762
17 #define QCOM_RPM_SMD_KEY_RATE 0x007a484b
19 static struct qcom_smd_rpm *icc_smd_rpm;
21 struct icc_rpm_smd_req {
27 bool qcom_icc_rpm_smd_available(void)
31 EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_available);
33 int qcom_icc_rpm_smd_send(int ctx, int rsc_type, int id, u32 val)
35 struct icc_rpm_smd_req req = {
36 .key = cpu_to_le32(RPM_KEY_BW),
37 .nbytes = cpu_to_le32(sizeof(u32)),
38 .value = cpu_to_le32(val),
41 return qcom_rpm_smd_write(icc_smd_rpm, ctx, rsc_type, id, &req,
44 EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_send);
46 int qcom_icc_rpm_set_bus_rate(const struct rpm_clk_resource *clk, int ctx, u32 rate)
48 struct clk_smd_rpm_req req = {
49 .key = cpu_to_le32(QCOM_RPM_SMD_KEY_RATE),
50 .nbytes = cpu_to_le32(sizeof(u32)),
53 /* Branch clocks are only on/off */
57 req.value = cpu_to_le32(rate);
58 return qcom_rpm_smd_write(icc_smd_rpm,
64 EXPORT_SYMBOL_GPL(qcom_icc_rpm_set_bus_rate);
66 static int qcom_icc_rpm_smd_remove(struct platform_device *pdev)
73 static int qcom_icc_rpm_smd_probe(struct platform_device *pdev)
75 icc_smd_rpm = dev_get_drvdata(pdev->dev.parent);
78 dev_err(&pdev->dev, "unable to retrieve handle to RPM\n");
85 static struct platform_driver qcom_interconnect_rpm_smd_driver = {
87 .name = "icc_smd_rpm",
89 .probe = qcom_icc_rpm_smd_probe,
90 .remove = qcom_icc_rpm_smd_remove,
92 module_platform_driver(qcom_interconnect_rpm_smd_driver);
93 MODULE_AUTHOR("Georgi Djakov <georgi.djakov@linaro.org>");
94 MODULE_DESCRIPTION("Qualcomm SMD RPM interconnect proxy driver");
95 MODULE_LICENSE("GPL v2");
96 MODULE_ALIAS("platform:icc_smd_rpm");