Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

interconnect: qcom: Add interconnect RPM over SMD driver

On some Qualcomm SoCs, there is a remote processor, which controls some of
the Network-On-Chip interconnect resources. Other CPUs express their needs
by communicating with this processor. Add a driver to handle communication
with this remote processor.

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

+97
+3
drivers/interconnect/qcom/Kconfig
··· 12 12 help 13 13 This is a driver for the Qualcomm Network-on-Chip on sdm845-based 14 14 platforms. 15 + 16 + config INTERCONNECT_QCOM_SMD_RPM 17 + tristate
+2
drivers/interconnect/qcom/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 3 qnoc-sdm845-objs := sdm845.o 4 + icc-smd-rpm-objs := smd-rpm.o 4 5 5 6 obj-$(CONFIG_INTERCONNECT_QCOM_SDM845) += qnoc-sdm845.o 7 + obj-$(CONFIG_INTERCONNECT_QCOM_SMD_RPM) += icc-smd-rpm.o
+77
drivers/interconnect/qcom/smd-rpm.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * RPM over SMD communication wrapper for interconnects 4 + * 5 + * Copyright (C) 2019 Linaro Ltd 6 + * Author: Georgi Djakov <georgi.djakov@linaro.org> 7 + */ 8 + 9 + #include <linux/interconnect-provider.h> 10 + #include <linux/module.h> 11 + #include <linux/of.h> 12 + #include <linux/of_platform.h> 13 + #include <linux/platform_device.h> 14 + #include <linux/soc/qcom/smd-rpm.h> 15 + 16 + #include "smd-rpm.h" 17 + 18 + #define RPM_KEY_BW 0x00007762 19 + 20 + static struct qcom_smd_rpm *icc_smd_rpm; 21 + 22 + struct icc_rpm_smd_req { 23 + __le32 key; 24 + __le32 nbytes; 25 + __le32 value; 26 + }; 27 + 28 + bool qcom_icc_rpm_smd_available(void) 29 + { 30 + return !!icc_smd_rpm; 31 + } 32 + EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_available); 33 + 34 + int qcom_icc_rpm_smd_send(int ctx, int rsc_type, int id, u32 val) 35 + { 36 + struct icc_rpm_smd_req req = { 37 + .key = cpu_to_le32(RPM_KEY_BW), 38 + .nbytes = cpu_to_le32(sizeof(u32)), 39 + .value = cpu_to_le32(val), 40 + }; 41 + 42 + return qcom_rpm_smd_write(icc_smd_rpm, ctx, rsc_type, id, &req, 43 + sizeof(req)); 44 + } 45 + EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_send); 46 + 47 + static int qcom_icc_rpm_smd_remove(struct platform_device *pdev) 48 + { 49 + icc_smd_rpm = NULL; 50 + 51 + return 0; 52 + } 53 + 54 + static int qcom_icc_rpm_smd_probe(struct platform_device *pdev) 55 + { 56 + icc_smd_rpm = dev_get_drvdata(pdev->dev.parent); 57 + 58 + if (!icc_smd_rpm) { 59 + dev_err(&pdev->dev, "unable to retrieve handle to RPM\n"); 60 + return -ENODEV; 61 + } 62 + 63 + return 0; 64 + } 65 + 66 + static struct platform_driver qcom_interconnect_rpm_smd_driver = { 67 + .driver = { 68 + .name = "icc_smd_rpm", 69 + }, 70 + .probe = qcom_icc_rpm_smd_probe, 71 + .remove = qcom_icc_rpm_smd_remove, 72 + }; 73 + module_platform_driver(qcom_interconnect_rpm_smd_driver); 74 + MODULE_AUTHOR("Georgi Djakov <georgi.djakov@linaro.org>"); 75 + MODULE_DESCRIPTION("Qualcomm SMD RPM interconnect proxy driver"); 76 + MODULE_LICENSE("GPL v2"); 77 + MODULE_ALIAS("platform:icc_smd_rpm");
+15
drivers/interconnect/qcom/smd-rpm.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (c) 2019, Linaro Ltd. 4 + * Author: Georgi Djakov <georgi.djakov@linaro.org> 5 + */ 6 + 7 + #ifndef __DRIVERS_INTERCONNECT_QCOM_SMD_RPM_H 8 + #define __DRIVERS_INTERCONNECT_QCOM_SMD_RPM_H 9 + 10 + #include <linux/soc/qcom/smd-rpm.h> 11 + 12 + bool qcom_icc_rpm_smd_available(void); 13 + int qcom_icc_rpm_smd_send(int ctx, int rsc_type, int id, u32 val); 14 + 15 + #endif