Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * RPM over SMD communication wrapper for interconnects
0004  *
0005  * Copyright (C) 2019 Linaro Ltd
0006  * Author: Georgi Djakov <georgi.djakov@linaro.org>
0007  */
0008 
0009 #include <linux/interconnect-provider.h>
0010 #include <linux/module.h>
0011 #include <linux/of.h>
0012 #include <linux/of_platform.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/soc/qcom/smd-rpm.h>
0015 
0016 #include "smd-rpm.h"
0017 
0018 #define RPM_KEY_BW      0x00007762
0019 
0020 static struct qcom_smd_rpm *icc_smd_rpm;
0021 
0022 struct icc_rpm_smd_req {
0023     __le32 key;
0024     __le32 nbytes;
0025     __le32 value;
0026 };
0027 
0028 bool qcom_icc_rpm_smd_available(void)
0029 {
0030     return !!icc_smd_rpm;
0031 }
0032 EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_available);
0033 
0034 int qcom_icc_rpm_smd_send(int ctx, int rsc_type, int id, u32 val)
0035 {
0036     struct icc_rpm_smd_req req = {
0037         .key = cpu_to_le32(RPM_KEY_BW),
0038         .nbytes = cpu_to_le32(sizeof(u32)),
0039         .value = cpu_to_le32(val),
0040     };
0041 
0042     return qcom_rpm_smd_write(icc_smd_rpm, ctx, rsc_type, id, &req,
0043                   sizeof(req));
0044 }
0045 EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_send);
0046 
0047 static int qcom_icc_rpm_smd_remove(struct platform_device *pdev)
0048 {
0049     icc_smd_rpm = NULL;
0050 
0051     return 0;
0052 }
0053 
0054 static int qcom_icc_rpm_smd_probe(struct platform_device *pdev)
0055 {
0056     icc_smd_rpm = dev_get_drvdata(pdev->dev.parent);
0057 
0058     if (!icc_smd_rpm) {
0059         dev_err(&pdev->dev, "unable to retrieve handle to RPM\n");
0060         return -ENODEV;
0061     }
0062 
0063     return 0;
0064 }
0065 
0066 static struct platform_driver qcom_interconnect_rpm_smd_driver = {
0067     .driver = {
0068         .name       = "icc_smd_rpm",
0069     },
0070     .probe = qcom_icc_rpm_smd_probe,
0071     .remove = qcom_icc_rpm_smd_remove,
0072 };
0073 module_platform_driver(qcom_interconnect_rpm_smd_driver);
0074 MODULE_AUTHOR("Georgi Djakov <georgi.djakov@linaro.org>");
0075 MODULE_DESCRIPTION("Qualcomm SMD RPM interconnect proxy driver");
0076 MODULE_LICENSE("GPL v2");
0077 MODULE_ALIAS("platform:icc_smd_rpm");