Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp691071imm; Mon, 9 Jul 2018 08:56:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeaPqKm3sZ2DWP5sgtCnFSHAC9yPO578CRWbc3bR+grwTFsog9q8B28OMOZQ4B3oOOK/U9f X-Received: by 2002:a65:5348:: with SMTP id w8-v6mr15020973pgr.247.1531151794870; Mon, 09 Jul 2018 08:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531151794; cv=none; d=google.com; s=arc-20160816; b=yvwD4uvzaGfCuRXwI6J4i1Jc0P90p92qCZwoLo4yT5ajtgzxWvn+PSoRR3cjoOYf3T ZFaZVqbXO+4kjXNHFoym7HFtNs5TusMQEGFfYu2+d0LWG1LTDfrLj7CTDuIZImsOG16G 7a6ktDAVLxtK1A/51mQ6xsguKVFFQD7kHSMx18W4Af1nX8xnLJrx/k5AFqJNO3io/kEM Wp4+IWCkg3hJx4sH7uXhIs22RGujEsSnrW7Pfbv/+Gi7h5JTxI/IX6MI4FinMraOmcf9 ivALgEVyXNKbE3rVF0TKvrHJHRjkbWzX75I+c8sBj+Ghpha+HfOvbzRcIKiy3XUv1Zkr WFlg== 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=z8uIUM9qc2byXQCDnypSuipDzqL6TYQx7BgUTRX5elc=; b=UfqtBxU4eHjhBJcVYMhUOl45FeyLgYVGPwJWy1FfY9Zto26F7FliUU8lNMV/2Q+H/a HOar+ppcDSaVi2bSbCTnAxK/KY2VhrikLKW7t1IbSt/iEoRSfZDhyIztm+VET+Yi6HEX m02Ou16DTA+5YfzlK8+C0vDtq8hBGl1iSQYDu2/0xjwUFM5PVtv5PLiabtNH1skGjSzb G6WaJmE6IHqfc9HhaW4eg3mUxWoQxKnOF6YGcUE8jme5syB4AwvokggPcpB2QqPf6M+x gI0XdtS1zhM8HhcDeHN2VoxqWs2x9vgojoElxZMyYo8NlzRkD33/LD9C1/0QxWheUY1Y CWYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cHo3jNtr; 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 m24-v6si9275865pfk.56.2018.07.09.08.56.20; Mon, 09 Jul 2018 08:56:34 -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=cHo3jNtr; 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 S933543AbeGIPy1 (ORCPT + 99 others); Mon, 9 Jul 2018 11:54:27 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54242 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932862AbeGIPvP (ORCPT ); Mon, 9 Jul 2018 11:51:15 -0400 Received: by mail-wm0-f66.google.com with SMTP id b188-v6so21698904wme.3 for ; Mon, 09 Jul 2018 08:51:15 -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=z8uIUM9qc2byXQCDnypSuipDzqL6TYQx7BgUTRX5elc=; b=cHo3jNtrA2M6fMuDUd5haEdYlQb/WoPo+UGz0tWDe/+XqMyg02pLM3/PLZRQfJ5tle j7ja75Tf7Q7uk3tUtkS8fg520c0Yse+TtPmhdP8SCJFonX6qx2ez0cztVHXDa35mUcZd wOsEbbrH3kjSLrapZYNDNwSM32UUZq7EUlBVk= 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=z8uIUM9qc2byXQCDnypSuipDzqL6TYQx7BgUTRX5elc=; b=d1TtKPH5hSbdzEYmr5Uib23lOsV6R+2mfdEjuen/U2Mgc8IrfjymNuZ9nZWQdbE+QW xw18zYaiL/VS6Y9CKPByPPjQ+jjvnDDCrXzuOepjramYXmUjbZScGDaBuN6e/mb+iUUk +Rri9VyfM9RFknLk1za3uzi0d34bxnRmYUnqhPAHmoD9LSdwLGtzH9GhbBMCmiZkpqyz Ur3KevKkEtRRkyvtRxu6cRFb41jpY0crJFnXNpd7u4EAPURS+NDqkpA5Fj5KdtuZieKZ 2JuwxbAJ9mnITBkvXA71iNY4olZsPNuo/dFH9UKs6cqe4nbq7VXcxezN3DW7xIXxyiEx 7fVg== X-Gm-Message-State: APt69E3gNvzFQhu2C3GFSxRAK2uOyy9aejhp8H0UnF0iViJg7hzIOxCU 3rFSoRBvuecYMJFDAhWjNOBECA== X-Received: by 2002:a1c:ee94:: with SMTP id j20-v6mr9424234wmi.66.1531151474590; Mon, 09 Jul 2018 08:51:14 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id o21-v6sm16229202wmg.28.2018.07.09.08.51.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jul 2018 08:51:13 -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, abailon@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, mka@chromium.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v6 4/8] interconnect: qcom: Add RPM communication Date: Mon, 9 Jul 2018 18:51:00 +0300 Message-Id: <20180709155104.25528-5-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180709155104.25528-1-georgi.djakov@linaro.org> References: <20180709155104.25528-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 --- .../bindings/interconnect/qcom-smd.txt | 32 +++++++ drivers/interconnect/qcom/Kconfig | 11 +++ drivers/interconnect/qcom/Makefile | 2 + drivers/interconnect/qcom/smd-rpm.c | 91 +++++++++++++++++++ drivers/interconnect/qcom/smd-rpm.h | 15 +++ 5 files changed, 151 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..88a5aeb50935 --- /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 = <0 168 1>; + 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..b0c2ff928d88 --- /dev/null +++ b/drivers/interconnect/qcom/Kconfig @@ -0,0 +1,11 @@ +config INTERCONNECT_QCOM + bool "Qualcomm Network-on-Chip interconnect drivers" + depends on INTERCONNECT + depends on ARCH_QCOM || COMPILE_TEST + +config INTERCONNECT_QCOM_SMD_RPM + tristate "Qualcomm SMD RPM interconnect driver" + depends on INTERCONNECT_QCOM + 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..c33b91a3dd51 --- /dev/null +++ b/drivers/interconnect/qcom/smd-rpm.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2018, Linaro Ltd. + * Author: Georgi Djakov + */ + +#ifndef __DRIVERS_INTERCONNECT_QCOM_RPM_H +#define __DRIVERS_INTERCONNECT_QCOM_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