From patchwork Thu Sep 21 04:20:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 143025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5225514vqi; Thu, 21 Sep 2023 17:15:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAGuA7SzO//TnpSTkN0tW7zvbOTd4z3WDIxU741958X0TAfEPPa2J2v4H86pdn/1htzHm0 X-Received: by 2002:a05:6808:1246:b0:3ab:74d6:72ee with SMTP id o6-20020a056808124600b003ab74d672eemr6863588oiv.19.1695341748364; Thu, 21 Sep 2023 17:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695341748; cv=none; d=google.com; s=arc-20160816; b=PPVJHF0Ue7uFsCDhY8iDqzfjeMa1EaDV5+jApyR7NnCv9kENezC6XpYSAcOENvHZ3S Xc0wFJcldoVVhYGmjnoBoUDViQG6nrJNkici2fsGLcud83YCoJ0QrXeiCLs+1hWIl8Dd zR8JUgLFDWbEPDbGzFuLjpSQu9RV4w872ra1ufwINnNAWb2ey3V0zbDjvRkweiE209x6 xTsD/yKMXaMxGX3l53o1eQ9nWko9tumT2aJxI/AjeaBnZhq9ljtHREzjAMINFua+7zDI f6KNnmYKMmuyf5XTGWJOQQ7xWnVlH8Ir5sWBFcBYZWRNL50teHEXpaKgeK/uHDHWr40B nDJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=f2B+nf9MiLvAb31gIDPkJP2bOHSd2/W5dbyITAsCy3k=; fh=9UOEjelFW6YmeQm+a0pvrCM8CYMJ6MbEjrtZbtMEpHI=; b=Qzst/gl/WoL6gZpdoczofr6PEtjI1p07yl7muqr8/3l0YGLuxkUYstU0dG92s93oLL G/8jVBgB4v3xR0GrYksIqniPzCLejSUYzdoOO56ZCWWxhurqR/PSzCersQfyZ9tXcPF9 MNK9+gVuRDFnUx+zDKOI6QWTsFsv/IiQPEvMXKfrSmQCdve+P7z2IoquQ1kfWJfS+aqv jP8FyFWhbi5Mti2Bl0GKO2glIHpRrh0FQ1kK+vjfzo2zeFi619YC8IbSbeVHU0volsZA 8Gmxw8U9Soo3C24CVjr5Mri/X2Pvf+MAL5MU87fJ3Utv/q0o1Nat58I4ZnwzSDN2tPOh oimg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 36-20020a631564000000b00578bd92e502si2537586pgv.558.2023.09.21.17.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 17:15:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A40F182E3C41; Thu, 21 Sep 2023 13:02:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231538AbjIUUCD (ORCPT + 28 others); Thu, 21 Sep 2023 16:02:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231432AbjIUUBe (ORCPT ); Thu, 21 Sep 2023 16:01:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4582A55AF6 for ; Thu, 21 Sep 2023 10:17:37 -0700 (PDT) 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 BE3D111FB; Wed, 20 Sep 2023 21:21:34 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.32.120]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D26803F59C; Wed, 20 Sep 2023 21:20:54 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com Cc: Anshuman Khandual , James Clark , Mike Leach , coresight@lists.linaro.org, linux-kernel@vger.kernel.org Subject: [RFC RESEND 1/7] coresight: replicator: Move ACPI support from AMBA driver to platform driver Date: Thu, 21 Sep 2023 09:50:34 +0530 Message-Id: <20230921042040.1334641-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230921042040.1334641-1-anshuman.khandual@arm.com> References: <20230921042040.1334641-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:02:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777669828094255052 X-GMAIL-MSGID: 1777694669145623129 Add support for the dynamic replicator device in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for repliacator devices on ACPI based systems. The driver would try to enable the APB clock if available. Also, rename the code to reflect the fact that it now handles both static and dynamic replicators. Signed-off-by: Anshuman Khandual --- drivers/acpi/arm64/amba.c | 1 - .../coresight/coresight-replicator.c | 44 ++++++++++++------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c index 60be8ee1dbdc..ac59ce50de07 100644 --- a/drivers/acpi/arm64/amba.c +++ b/drivers/acpi/arm64/amba.c @@ -27,7 +27,6 @@ static const struct acpi_device_id amba_id_list[] = { {"ARMHC503", 0}, /* ARM CoreSight Debug */ {"ARMHC979", 0}, /* ARM CoreSight TPIU */ {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */ - {"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */ {"ARMHC9CA", 0}, /* ARM CoreSight CATU */ {"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */ {"", 0}, diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index b6be73034996..a18d5e8fcba1 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -38,6 +38,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); struct replicator_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; spinlock_t spinlock; bool check_idfilter_val; @@ -243,6 +244,10 @@ static int replicator_probe(struct device *dev, struct resource *res) return ret; } + drvdata->pclk = coresight_get_enable_apb_pclk(dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + /* * Map the device base for dynamic-replicator, which has been * validated by AMBA core @@ -301,16 +306,16 @@ static int replicator_remove(struct device *dev) return 0; } -static int static_replicator_probe(struct platform_device *pdev) +static int replicator_platform_probe(struct platform_device *pdev) { + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); int ret; pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); - /* Static replicators do not have programming base */ - ret = replicator_probe(&pdev->dev, NULL); + ret = replicator_probe(&pdev->dev, res); if (ret) { pm_runtime_put_noidle(&pdev->dev); @@ -320,7 +325,7 @@ static int static_replicator_probe(struct platform_device *pdev) return ret; } -static int static_replicator_remove(struct platform_device *pdev) +static int replicator_platform_remove(struct platform_device *pdev) { replicator_remove(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -335,6 +340,8 @@ static int replicator_runtime_suspend(struct device *dev) if (drvdata && !IS_ERR(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); + if (drvdata && !IS_ERR(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); return 0; } @@ -345,6 +352,8 @@ static int replicator_runtime_resume(struct device *dev) if (drvdata && !IS_ERR(drvdata->atclk)) clk_prepare_enable(drvdata->atclk); + if (drvdata && !IS_ERR(drvdata->pclk)) + clk_prepare_enable(drvdata->pclk); return 0; } #endif @@ -354,31 +363,32 @@ static const struct dev_pm_ops replicator_dev_pm_ops = { replicator_runtime_resume, NULL) }; -static const struct of_device_id static_replicator_match[] = { +static const struct of_device_id replicator_match[] = { {.compatible = "arm,coresight-replicator"}, {.compatible = "arm,coresight-static-replicator"}, {} }; -MODULE_DEVICE_TABLE(of, static_replicator_match); +MODULE_DEVICE_TABLE(of, replicator_match); #ifdef CONFIG_ACPI -static const struct acpi_device_id static_replicator_acpi_ids[] = { +static const struct acpi_device_id replicator_acpi_ids[] = { {"ARMHC985", 0}, /* ARM CoreSight Static Replicator */ + {"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */ {} }; -MODULE_DEVICE_TABLE(acpi, static_replicator_acpi_ids); +MODULE_DEVICE_TABLE(acpi, replicator_acpi_ids); #endif -static struct platform_driver static_replicator_driver = { - .probe = static_replicator_probe, - .remove = static_replicator_remove, +static struct platform_driver replicator_driver = { + .probe = replicator_platform_probe, + .remove = replicator_platform_remove, .driver = { - .name = "coresight-static-replicator", + .name = "coresight-replicator", /* THIS_MODULE is taken care of by platform_driver_register() */ - .of_match_table = of_match_ptr(static_replicator_match), - .acpi_match_table = ACPI_PTR(static_replicator_acpi_ids), + .of_match_table = of_match_ptr(replicator_match), + .acpi_match_table = ACPI_PTR(replicator_acpi_ids), .pm = &replicator_dev_pm_ops, .suppress_bind_attrs = true, }, @@ -419,7 +429,7 @@ static int __init replicator_init(void) { int ret; - ret = platform_driver_register(&static_replicator_driver); + ret = platform_driver_register(&replicator_driver); if (ret) { pr_info("Error registering platform driver\n"); return ret; @@ -428,7 +438,7 @@ static int __init replicator_init(void) ret = amba_driver_register(&dynamic_replicator_driver); if (ret) { pr_info("Error registering amba driver\n"); - platform_driver_unregister(&static_replicator_driver); + platform_driver_unregister(&replicator_driver); } return ret; @@ -436,7 +446,7 @@ static int __init replicator_init(void) static void __exit replicator_exit(void) { - platform_driver_unregister(&static_replicator_driver); + platform_driver_unregister(&replicator_driver); amba_driver_unregister(&dynamic_replicator_driver); }