Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2185766pxm; Sun, 27 Feb 2022 13:58:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6qWFlWQzDkiF+2K7NmYSTerm2jTdSyTgw7keSYREjeTZ4LJDt4NutgQCEN20ZcmCucQge X-Received: by 2002:a63:4c63:0:b0:378:ac4c:60f3 with SMTP id m35-20020a634c63000000b00378ac4c60f3mr1401952pgl.486.1645999088635; Sun, 27 Feb 2022 13:58:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645999088; cv=none; d=google.com; s=arc-20160816; b=bm5NT8T2vR4dGUAcPWug7rYASl+WkOlW40VZwTNf1LaLjdR840XBvyws6A4YJmh/1w ycLJEHx3sYh0OUcOFolanDS9Qa6ayW2gPM8Ep/2EqqCf8Ipem35vW4fOEbswqXToxzjh yk6zuCQ+gkIEzV1KDfsvuObrhaPHX66vPUe1ltbimY58JxYUUcpD0+kyYfzVF50Fl+/r Lhs5JmvcNQJ343qbA4yhXb0CHXRQD9bITn1KVm4A5CUdWCLzRF5kLz6FTgHsbRga7exK J0NzgVlB/dZwXdvjjEsfK4PGS6k80al8yYkntLWG41pgNwNo8z24YjmQE/zmWJN3ZDDI DNtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=dSdZbmSnIcorsbfuccGFGgKPHVa1l224FHf5II7YLzk=; b=AQucCXUMEVjmmHo92iZPpN85ZDJ3i3rC+u70MKI7JguiGlILaS6QxiHK0CKystyMyh x9NkqvBgmdvHLgEWZGpx1ynuBmXmTe2AFZTElv5UEZ8LXyi2UdHF3MYtAAOr9t2eBiKB cMwxibKuH8MJGF88XgPXi4tDSrlV4YOZLte8ddO8WaGxFrFANFbFN7nwslzbz0CWmbrg nPTkOr+jtGnGzq3OfQMjoCcMhzW6Nva2nH/qfcDWUVcHjJfMbfhra0ovlCm8pofqWaWi GQZDzjEOfU3fvWiwFQDL7tq13RKPRiG29T3fK9En8+NJlqd0KnEMIOcf8Qr3I+0sP+Me NXsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a170902b10b00b0014dc39c0a1esi7384596plr.461.2022.02.27.13.57.53; Sun, 27 Feb 2022 13:58:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231896AbiB0U6A (ORCPT + 99 others); Sun, 27 Feb 2022 15:58:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231912AbiB0U52 (ORCPT ); Sun, 27 Feb 2022 15:57:28 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0BD2F6E2B2 for ; Sun, 27 Feb 2022 12:56:45 -0800 (PST) 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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; +} -- 2.17.1