From patchwork Sun Feb 27 20:56:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12762147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A88DC433F5 for ; Sun, 27 Feb 2022 21:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dm2iBrzdrNPMS88PQrB/svM0TrvFXw4dT68fVxdLxwg=; b=BDphY2p2oyEEGC vWjc5inc9mM8L3rbnpFyXMt1cIBAXOmAY2Q6ak5tGbPQadV5YbZoEyvA4efSGg7Jxkr+cn6FLEgHW Cm/c/mVt+q/5O7ojVELrd+6RTmZNrOzmSb9Y03qujnOoBBw0cJ8LcZ/C+7MvXPtLGYJY1tIbpv1Cd HdHKrI4ezgtuLJohidXp6J1Gp/0rmf7P37AgNe+Pi/BKmtIG3UrTDZqx7ZGZZ7q8NIDjCerXsjndu +j9DRSMUKnROZV8FJmAXsNnAltETL+0h0dIxXsKQbixfywsyy7qM5WMUrCX+6a15RIQOH6Puz6ycC VFlutDpM41OOqZ2/YNGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOQg5-00AA0K-My; Sun, 27 Feb 2022 21:02:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOQaz-00A7IU-Ct for linux-arm-kernel@lists.infradead.org; Sun, 27 Feb 2022 20:56:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E786C1063; Sun, 27 Feb 2022 12:56:44 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C7BD3F66F; Sun, 27 Feb 2022 12:56:43 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, peter.hilber@opensynergy.com, cristian.marussi@arm.com Subject: [RFC PATCH 14/16] firmware: arm_scmi: Add testing Voltage protocol support Date: Sun, 27 Feb 2022 20:56:06 +0000 Message-Id: <20220227205608.30812-15-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220227205608.30812-1-cristian.marussi@arm.com> References: <20220227205608.30812-1-cristian.marussi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220227_125645_559057_F73A0D99 X-CRM114-Status: GOOD ( 15.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org firmware: arm_scmi: Add testing Voltage protocol support Signed-off-by: Cristian Marussi --- .../arm_scmi/scmi_test_driver/Makefile | 2 +- .../arm_scmi/scmi_test_driver/scmi_test.c | 2 + .../arm_scmi/scmi_test_driver/test_common.h | 1 + .../arm_scmi/scmi_test_driver/test_voltages.c | 51 +++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/arm_scmi/scmi_test_driver/test_voltages.c diff --git a/drivers/firmware/arm_scmi/scmi_test_driver/Makefile b/drivers/firmware/arm_scmi/scmi_test_driver/Makefile index 68a3d94a6a88..3b7df18de250 100644 --- a/drivers/firmware/arm_scmi/scmi_test_driver/Makefile +++ b/drivers/firmware/arm_scmi/scmi_test_driver/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only scmi_test_driver-objs := scmi_test.o test_common.o test_clocks.o test_sensors.o \ - test_powers.o + test_powers.o test_voltages.o obj-$(CONFIG_ARM_SCMI_TEST_DRIVER) += scmi_test_driver.o diff --git a/drivers/firmware/arm_scmi/scmi_test_driver/scmi_test.c b/drivers/firmware/arm_scmi/scmi_test_driver/scmi_test.c index df0d3e572010..2ca9f82c5bf3 100644 --- a/drivers/firmware/arm_scmi/scmi_test_driver/scmi_test.c +++ b/drivers/firmware/arm_scmi/scmi_test_driver/scmi_test.c @@ -26,6 +26,7 @@ int (*scmi_test_init[SCMI_MAX_PROTOCOLS])(struct scmi_test_setup *) = { [SCMI_PROTOCOL_POWER] = scmi_test_power_init, [SCMI_PROTOCOL_CLOCK] = scmi_test_clock_init, [SCMI_PROTOCOL_SENSOR] = scmi_test_sensor_init, + [SCMI_PROTOCOL_VOLTAGE] = scmi_test_voltage_init, }; static void @@ -125,6 +126,7 @@ static int scmi_testing_probe(struct scmi_device *sdev) } static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_VOLTAGE, "__scmi_test-voltage" }, { SCMI_PROTOCOL_CLOCK, "__scmi_test-clock" }, { SCMI_PROTOCOL_SENSOR, "__scmi_test-sensor" }, { SCMI_PROTOCOL_POWER, "__scmi_test-power" }, diff --git a/drivers/firmware/arm_scmi/scmi_test_driver/test_common.h b/drivers/firmware/arm_scmi/scmi_test_driver/test_common.h index 9f3d35ba4477..338b65da593f 100644 --- a/drivers/firmware/arm_scmi/scmi_test_driver/test_common.h +++ b/drivers/firmware/arm_scmi/scmi_test_driver/test_common.h @@ -102,6 +102,7 @@ int scmi_test_release(struct inode *ino, struct file *filp); int scmi_test_clock_init(struct scmi_test_setup *tsp); int scmi_test_sensor_init(struct scmi_test_setup *tsp); +int scmi_test_voltage_init(struct scmi_test_setup *tsp); int scmi_test_power_init(struct scmi_test_setup *tsp); #endif /* __SCMI_TEST_COMMON_H */ diff --git a/drivers/firmware/arm_scmi/scmi_test_driver/test_voltages.c b/drivers/firmware/arm_scmi/scmi_test_driver/test_voltages.c new file mode 100644 index 000000000000..ab91080e3a0f --- /dev/null +++ b/drivers/firmware/arm_scmi/scmi_test_driver/test_voltages.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * SCMI Testing Driver - Voltage Protocol + * + * Copyright (C) 2022 ARM Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "test_common.h" + +struct scmi_voltage_data { + unsigned int version; + int count; +}; + +int scmi_test_voltage_init(struct scmi_test_setup *tsp) +{ + struct scmi_voltage_data *vdata; + struct device *dev = &tsp->sdev->dev; + const struct scmi_voltage_proto_ops *voltage_ops; + + vdata = devm_kzalloc(dev, sizeof(*vdata), GFP_KERNEL); + if (!vdata) + return -ENOMEM; + + voltage_ops = tsp->ops; + vdata->version = voltage_ops->version_get(tsp->ph); + vdata->count = voltage_ops->num_domains_get(tsp->ph); + + if (vdata->count <= 0) { + dev_err(dev, "number of voltage doms invalid: %d\n", + vdata->count); + return vdata->count ?: -EINVAL; + } + + dev_info(dev, "Found %d voltage resources.\n", vdata->count); + + tsp->priv = vdata; + debugfs_create_x32("version", 0400, tsp->parent, &vdata->version); + + return 0; +}