From patchwork Fri Aug 10 14:52:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 143945 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp49865ljj; Fri, 10 Aug 2018 07:52:57 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyhO6tiLY++vkRbKQenJyX3YLlD4PMnKY7kZAZhM0IfDHgTvfFhcVx5UFnZO5SkfKVv00jf X-Received: by 2002:a17:902:4124:: with SMTP id e33-v6mr6457881pld.48.1533912777812; Fri, 10 Aug 2018 07:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533912777; cv=none; d=google.com; s=arc-20160816; b=x9CceCcjITC+DlDQ4cnTi0EikKiY0/vV7a+k+18YYiL5Rz/psKOqnACMOT1pqhAril PkhXH7wnq13PKENoU07UtR01TaELPm35RdhbphXljK/0Vma4msJ2WXGXAWFqy6cqGmOu Tq7Ju3XQgjpFpctOMRZ7UL8IEFknm2+T22+uC0VDD2/6Tgaz9wrtH0N/WXjfiMRkAumv FGpth+8pP5WQdAP05acOkeZiX4R7EOk+gcSA4oFiyrUIL2DynREp+QMwNhfnI2ZPfkaI CWEARpaOAGINWfuuAKW6H8gilNqG05OTIqztRprdKM/SW4dMnm0/rEWyY1aXmlxnLQvq 8U5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=1jM7ZXItlRq3zbhWV6TmYrbuDhKvEvpgy6vWixlAq2M=; b=elLDPPLwJfbyB352/sA+nN/qHHPQt+sftipBoNnGHJC+U1rhkWEemUpL/UCs0iMLAE Np4Loqg7HEXtgV2Nscs7gHSO3KajHa1pIBY90A/QppwhVl+pOHcrP0/Tbxpezz9MhPMj fkgvRPIgQAD0lQ2d8d8YzgCl8OJWwbKMgVpA7Uz1RyeubOCdeaRXo0PYz61jJ4Rj+fH0 owtKU3TN6M9pAAK9LUMKi5UDY4TjEXS2pL5z94RbO8W8IMpbT+SggBKXGi7cgb+7UQYw neuukmZpldygOJhqe9SxZP7L9SxqMR+W7IIIGscXT8vA/Zn2wWMfE6nOYxUet2pj1Ld3 u5Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bd0/zAHl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3-v6si8642378pln.298.2018.08.10.07.52.57; Fri, 10 Aug 2018 07:52:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bd0/zAHl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728686AbeHJRXI (ORCPT + 31 others); Fri, 10 Aug 2018 13:23:08 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34850 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728582AbeHJRXH (ORCPT ); Fri, 10 Aug 2018 13:23:07 -0400 Received: by mail-wr1-f66.google.com with SMTP id g1-v6so8575873wru.2 for ; Fri, 10 Aug 2018 07:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1jM7ZXItlRq3zbhWV6TmYrbuDhKvEvpgy6vWixlAq2M=; b=bd0/zAHleQ+UoEgVy6lFTYFaqe5/8Xab+pkrP+rEnpg0qUct15joy45s0zRNMJ/3dM r5TYr4YDO9r9GmVDuJkY2Cl0KWQkGO+UMAxHkUfA92Wid2YSHN3rO6mj/bvkZYKQfPXq ou2i1H9gde03HYnDS6uAooJbips+A/n5+JsZ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1jM7ZXItlRq3zbhWV6TmYrbuDhKvEvpgy6vWixlAq2M=; b=ssqd5ANDYSjxnWZCWSC8WoSjWuGLwxinQB0S850xN/mlqnwfPJv8VLrM+ljrejHoGV 6CHGQyDo48gWg2QKnYAbKSmG93JpL1J4UTfFnJSfgSeke3wGh5geD0g9dsK3GOQDPlL5 LS4gRIYcPQGYwFyBI9PmXKSNyhH70nroTS1pw+2BGMMc8Aw93FwYvWVxVRb+WXOd31sZ FaSLyasGm0fHsQ8CqFZomh/cs9tDejuXuIUyDKDFdsOvuc5uWmQsxeUTHxeMESadnwxv Uwyl7BuTbryEilP3jj7yki0XVC/bM6C1GKzfkc/qd+GAcKeA6r4/+pb3ngAZYB3uYtCM 5M6Q== X-Gm-Message-State: AOUpUlEz3uh6y4jdCC3WDYO5oaXtmyCXMxg4Vk6j4eiBfQiaWCcmhYJH Kw17MtSgIixNQeD553CIEqsbvA== X-Received: by 2002:adf:ff49:: with SMTP id u9-v6mr4807099wrs.15.1533912772266; Fri, 10 Aug 2018 07:52:52 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id 9-v6sm19842700wrb.48.2018.08.10.07.52.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Aug 2018 07:52:51 -0700 (PDT) From: Georgi Djakov To: linux-pm@vger.kernel.org, gregkh@linuxfoundation.org Cc: rjw@rjwysocki.net, robh+dt@kernel.org, mturquette@baylibre.com, khilman@baylibre.com, vincent.guittot@linaro.org, skannan@codeaurora.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, abailon@baylibre.com, arnd@arndb.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 5/8] interconnect: qcom: Add RPM communication Date: Fri, 10 Aug 2018 17:52:30 +0300 Message-Id: <20180810145233.16466-6-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180810145233.16466-1-georgi.djakov@linaro.org> References: <20180810145233.16466-1-georgi.djakov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Georgi Djakov Reviewed-by: Evan Green --- .../bindings/interconnect/qcom-smd.txt | 32 +++++++ drivers/interconnect/qcom/Kconfig | 14 +++ drivers/interconnect/qcom/Makefile | 2 + drivers/interconnect/qcom/smd-rpm.c | 91 +++++++++++++++++++ drivers/interconnect/qcom/smd-rpm.h | 16 ++++ 5 files changed, 155 insertions(+) create mode 100644 Documentation/devicetree/bindings/interconnect/qcom-smd.txt create mode 100644 drivers/interconnect/qcom/Kconfig create mode 100644 drivers/interconnect/qcom/Makefile create mode 100644 drivers/interconnect/qcom/smd-rpm.c create mode 100644 drivers/interconnect/qcom/smd-rpm.h diff --git a/Documentation/devicetree/bindings/interconnect/qcom-smd.txt b/Documentation/devicetree/bindings/interconnect/qcom-smd.txt new file mode 100644 index 000000000000..2325167f6eaf --- /dev/null +++ b/Documentation/devicetree/bindings/interconnect/qcom-smd.txt @@ -0,0 +1,32 @@ +Qualcomm SMD-RPM interconnect driver binding +------------------------------------------------ +The RPM (Resource Power Manager) is a dedicated hardware engine +for managing the shared SoC resources in order to keep the lowest +power profile. It communicates with other hardware subsystems via +the shared memory driver (SMD) back-end and accepts requests for +various resources. + +Required properties : +- compatible : shall contain only one of the following: + "qcom,interconnect-smd-rpm" + +Example: + smd { + compatible = "qcom,smd"; + + rpm { + interrupts = ; + qcom,ipc = <&apcs 8 0>; + qcom,smd-edge = <15>; + + rpm_requests { + compatible = "qcom,rpm-msm8916"; + qcom,smd-channels = "rpm_requests"; + + interconnect-smd-rpm { + compatible = "qcom,interconnect-smd-rpm"; + }; + + }; + }; + }; diff --git a/drivers/interconnect/qcom/Kconfig b/drivers/interconnect/qcom/Kconfig new file mode 100644 index 000000000000..812e9464765a --- /dev/null +++ b/drivers/interconnect/qcom/Kconfig @@ -0,0 +1,14 @@ +config INTERCONNECT_QCOM + bool "Qualcomm Network-on-Chip interconnect drivers" + depends on INTERCONNECT + depends on ARCH_QCOM || COMPILE_TEST + help + Support for Qualcomm's Network-on-Chip interconnect hardware. + +config INTERCONNECT_QCOM_SMD_RPM + tristate "Qualcomm SMD RPM interconnect driver" + depends on INTERCONNECT_QCOM + depends on QCOM_SMD_RPM + help + This is a driver for communicating interconnect related configuration + details with a remote processor (RPM) on Qualcomm platforms. diff --git a/drivers/interconnect/qcom/Makefile b/drivers/interconnect/qcom/Makefile new file mode 100644 index 000000000000..5b65e4011b59 --- /dev/null +++ b/drivers/interconnect/qcom/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_INTERCONNECT_QCOM_SMD_RPM) += smd-rpm.o diff --git a/drivers/interconnect/qcom/smd-rpm.c b/drivers/interconnect/qcom/smd-rpm.c new file mode 100644 index 000000000000..48b7a2a6eb84 --- /dev/null +++ b/drivers/interconnect/qcom/smd-rpm.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * RPM over SMD communication wrapper for interconnects + * + * Copyright (C) 2018 Linaro Ltd + * Author: Georgi Djakov + */ + +#include +#include +#include +#include +#include +#include +#include "smd-rpm.h" + +#define RPM_KEY_BW 0x00007762 + +static struct qcom_icc_rpm { + struct qcom_smd_rpm *rpm; +} icc_rpm_smd; + +struct icc_rpm_smd_req { + __le32 key; + __le32 nbytes; + __le32 value; +}; + +bool qcom_icc_rpm_smd_available(void) +{ + if (!icc_rpm_smd.rpm) + return false; + + return true; +} +EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_available); + +int qcom_icc_rpm_smd_send(int ctx, int rsc_type, int id, u32 val) +{ + struct icc_rpm_smd_req req = { + .key = cpu_to_le32(RPM_KEY_BW), + .nbytes = cpu_to_le32(sizeof(u32)), + .value = cpu_to_le32(val), + }; + + return qcom_rpm_smd_write(icc_rpm_smd.rpm, ctx, rsc_type, id, &req, + sizeof(req)); +} +EXPORT_SYMBOL_GPL(qcom_icc_rpm_smd_send); + +static int qcom_icc_rpm_smd_probe(struct platform_device *pdev) +{ + icc_rpm_smd.rpm = dev_get_drvdata(pdev->dev.parent); + if (!icc_rpm_smd.rpm) { + dev_err(&pdev->dev, "unable to retrieve handle to RPM\n"); + return -ENODEV; + } + + return 0; +} + +static const struct of_device_id qcom_icc_rpm_smd_dt_match[] = { + { .compatible = "qcom,interconnect-smd-rpm", }, + { }, +}; + +MODULE_DEVICE_TABLE(of, qcom_icc_rpm_smd_dt_match); + +static struct platform_driver qcom_interconnect_rpm_smd_driver = { + .driver = { + .name = "qcom-interconnect-smd-rpm", + .of_match_table = qcom_icc_rpm_smd_dt_match, + }, + .probe = qcom_icc_rpm_smd_probe, +}; + +static int __init rpm_smd_interconnect_init(void) +{ + return platform_driver_register(&qcom_interconnect_rpm_smd_driver); +} +subsys_initcall(rpm_smd_interconnect_init); + +static void __exit rpm_smd_interconnect_exit(void) +{ + platform_driver_unregister(&qcom_interconnect_rpm_smd_driver); +} +module_exit(rpm_smd_interconnect_exit) + +MODULE_AUTHOR("Georgi Djakov "); +MODULE_DESCRIPTION("Qualcomm SMD RPM interconnect driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/interconnect/qcom/smd-rpm.h b/drivers/interconnect/qcom/smd-rpm.h new file mode 100644 index 000000000000..3b1c347475ff --- /dev/null +++ b/drivers/interconnect/qcom/smd-rpm.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2018, Linaro Ltd. + * Author: Georgi Djakov + */ + +#ifndef __DRIVERS_INTERCONNECT_QCOM_SMD_RPM_H +#define __DRIVERS_INTERCONNECT_QCOM_SMD_RPM_H + + +#include + +bool qcom_icc_rpm_smd_available(void); +int qcom_icc_rpm_smd_send(int ctx, int rsc_type, int id, u32 val); + +#endif