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); } From patchwork Thu Sep 21 04:20:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 143022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5223912vqi; Thu, 21 Sep 2023 17:12:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExzLoySHfVtCa84v+EHS98Bvb8QAtFRPus+3WehgIV/zJ6bsnc6qJh+T+6NW/CNNwiZA8I X-Received: by 2002:a25:ab48:0:b0:d16:7ccc:b407 with SMTP id u66-20020a25ab48000000b00d167cccb407mr7669742ybi.39.1695341533293; Thu, 21 Sep 2023 17:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695341533; cv=none; d=google.com; s=arc-20160816; b=QRy+MIiVvnOPV399mqhcgt6XLyuxj6xnSf8ns9Q+FOx+RAC2zjVZHDfEl9UVdKYdf7 OYHtAToXgJINh8WeIOZApSS9VUZMJpJ+zGX6LB+YULwifbX0jXZTDVDHeoNHKtTXatDQ YTvJ1x7Z3V9DEp65GdetuXjJzH9ITQEAEMpbHd3dN7j3qpDrQ0Jtn6QtNnhDGyv/t+NU Kd8aAzxVdaapW1nF/9mrpsJDctI3IglPGI/vXHESlKRjcctgjFgHJsFQS+JFSLMM6Kxg PlN+Zc3LSPzqqvczfy01EYPI5YZtgTuaSczU90bWpT9e9dObs9jbLnkaj6mrMOKL8OSy laEw== 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=A2HAMIMo0cKM9xf0VugnQTSQNXSA/JbwmM4dpxUCNXc=; fh=9UOEjelFW6YmeQm+a0pvrCM8CYMJ6MbEjrtZbtMEpHI=; b=p755v1vTP1b4ZzZVP0a+qqOH9Ox/1a/usuY/L1avoSh5R6rTzniMjTAkTq3NB//vfs DZgs+qcYSCI5tkH7owDDHs7bS64/3dIr1y8hjm3iDD/uEwPJvQzl4J+WUUivxK1xVT4r C8WhPQ8Pvds9/drysCI9J+dgf/lbf/l/e+FXPKy/2qqiah8ZfYRZ7XGlw21E+NM+Dels +TVY7y3oqSLBmdSi4atViovJTHBuPteaBys8mD7rOUEuF3gAWvg+UxVo4bMnEa8Fip0p a+EWSGKpftQ0vwV8lF1XsRYDkDiR6tQkaJztoLySlU4enBcrnjZejcelPgBwBMDKaGPL 2eSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id i67-20020a636d46000000b00578fcb85b89si2535596pgc.726.2023.09.21.17.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 17:12:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 B79CC82E27DD; Thu, 21 Sep 2023 13:02:16 -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 S231393AbjIUUB6 (ORCPT + 28 others); Thu, 21 Sep 2023 16:01:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbjIUUB1 (ORCPT ); Thu, 21 Sep 2023 16:01:27 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4790C55AF7 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 C3C3312FC; Wed, 20 Sep 2023 21:21:37 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.32.120]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2D6613F59C; Wed, 20 Sep 2023 21:20:57 -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 2/7] coresight: funnel: Move ACPI support from AMBA driver to platform driver Date: Thu, 21 Sep 2023 09:50:35 +0530 Message-Id: <20230921042040.1334641-3-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:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777694443996083648 X-GMAIL-MSGID: 1777694443996083648 Add support for the dynamic funnel device in the platform driver, which can then be used on ACPI based platforms. This change would allow runtime power management for 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 funnels. Signed-off-by: Anshuman Khandual --- drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-funnel.c | 49 ++++++++++++------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c index ac59ce50de07..18aa41d91729 100644 --- a/drivers/acpi/arm64/amba.c +++ b/drivers/acpi/arm64/amba.c @@ -28,7 +28,6 @@ static const struct acpi_device_id amba_id_list[] = { {"ARMHC979", 0}, /* ARM CoreSight TPIU */ {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */ {"ARMHC9CA", 0}, /* ARM CoreSight CATU */ - {"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */ {"", 0}, }; diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index b8e150e45b27..b4984596738c 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -43,6 +43,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel"); struct funnel_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; unsigned long priority; spinlock_t spinlock; @@ -236,6 +237,10 @@ static int funnel_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-funnel, which has been * validated by AMBA core. @@ -298,6 +303,9 @@ static int funnel_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; } @@ -308,6 +316,8 @@ static int funnel_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 @@ -316,16 +326,16 @@ static const struct dev_pm_ops funnel_dev_pm_ops = { SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL) }; -static int static_funnel_probe(struct platform_device *pdev) +static int funnel_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 funnel do not have programming base */ - ret = funnel_probe(&pdev->dev, NULL); + ret = funnel_probe(&pdev->dev, res); if (ret) { pm_runtime_put_noidle(&pdev->dev); @@ -335,37 +345,38 @@ static int static_funnel_probe(struct platform_device *pdev) return ret; } -static int static_funnel_remove(struct platform_device *pdev) +static int funnel_platform_remove(struct platform_device *pdev) { funnel_remove(&pdev->dev); pm_runtime_disable(&pdev->dev); return 0; } -static const struct of_device_id static_funnel_match[] = { +static const struct of_device_id funnel_match[] = { {.compatible = "arm,coresight-static-funnel"}, {} }; -MODULE_DEVICE_TABLE(of, static_funnel_match); +MODULE_DEVICE_TABLE(of, funnel_match); #ifdef CONFIG_ACPI -static const struct acpi_device_id static_funnel_ids[] = { - {"ARMHC9FE", 0}, +static const struct acpi_device_id funnel_acpi_ids[] = { + {"ARMHC9FE", 0}, /* ARM Coresight Static Funnel */ + {"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */ {}, }; -MODULE_DEVICE_TABLE(acpi, static_funnel_ids); +MODULE_DEVICE_TABLE(acpi, funnel_acpi_ids); #endif -static struct platform_driver static_funnel_driver = { - .probe = static_funnel_probe, - .remove = static_funnel_remove, - .driver = { - .name = "coresight-static-funnel", +static struct platform_driver funnel_driver = { + .probe = funnel_platform_probe, + .remove = funnel_platform_remove, + .driver = { + .name = "coresight-funnel", /* THIS_MODULE is taken care of by platform_driver_register() */ - .of_match_table = static_funnel_match, - .acpi_match_table = ACPI_PTR(static_funnel_ids), + .of_match_table = funnel_match, + .acpi_match_table = ACPI_PTR(funnel_acpi_ids), .pm = &funnel_dev_pm_ops, .suppress_bind_attrs = true, }, @@ -413,7 +424,7 @@ static int __init funnel_init(void) { int ret; - ret = platform_driver_register(&static_funnel_driver); + ret = platform_driver_register(&funnel_driver); if (ret) { pr_info("Error registering platform driver\n"); return ret; @@ -422,7 +433,7 @@ static int __init funnel_init(void) ret = amba_driver_register(&dynamic_funnel_driver); if (ret) { pr_info("Error registering amba driver\n"); - platform_driver_unregister(&static_funnel_driver); + platform_driver_unregister(&funnel_driver); } return ret; @@ -430,7 +441,7 @@ static int __init funnel_init(void) static void __exit funnel_exit(void) { - platform_driver_unregister(&static_funnel_driver); + platform_driver_unregister(&funnel_driver); amba_driver_unregister(&dynamic_funnel_driver); } From patchwork Thu Sep 21 04:20:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 142894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5126854vqi; Thu, 21 Sep 2023 13:43:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFefKafae8NMXGmmLceR6khc3cEbMePMUsW5GD7RvjaOgCrbul2PbSsPTSFZoIqHev4FJK6 X-Received: by 2002:a17:90b:896:b0:26d:5cd0:979f with SMTP id bj22-20020a17090b089600b0026d5cd0979fmr6635297pjb.43.1695328986475; Thu, 21 Sep 2023 13:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695328986; cv=none; d=google.com; s=arc-20160816; b=bq8o66nXlThqZVFo/JqGhr+T2VzP+FHh9UqDRLcM5hO5eE5ktmdBrH1+NeRkX/bHtE zSVWZWBbLjzY1J40UGw3YhJpLwW2cvUUFPmcylJDUJvTpG0QCW6/0v3UzqqTTCxSxhIA aSrqIK99racpBopaL4PFfDKcA5BmcWIYW77s5W1r9K3grGwabJvj5G5KJeNNqpmKlAx9 Kuz/DbWcxHdHY3NT9o2iA3SG/MJQSZZn9GfKEfMXWTl0Ds/BE+vkI3w/J3OI5uSIoCSv 4LpPanF3uvIj/8934cRcV6EXvdUhVJx82HKfh3Mfy6IgeFmzVMrmrJMZv0aen0rMK0Pc ONMg== 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=Vki6n4YcvV+pydf4isoVEIUh0afvcpsLV2EITJGug0k=; fh=9UOEjelFW6YmeQm+a0pvrCM8CYMJ6MbEjrtZbtMEpHI=; b=Jr2FpqkVLPVeis466bkqVzvkoJSxMgKd7jbcBC/gxXQI00GsXzOgIFCEX90Vipx99a iIstDg53UVg0DAtc8FQZHG4u374j5tlP6oNEPj1Mqovaq+3v1X8po0DExArrJr/AGsps bnY7pvm377M3Rh4gBPlM3gQSi1F1opusLZjNwg6KmDVhFt316B1ORljLSSHz66ofJ8WJ 9xE4rivrnVFrWdbRKtG7mSwRXehs6ScT0W2yyfwKCWZ7reXC8zUESOGGJ5zIddtagZaH F/sj5QfVw7A5h/636JEsBDO7uYi+jXcWNhl1by3JVLM69TUtnPxl7ytOIhSmE4ynu4lX YJpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id pi15-20020a17090b1e4f00b00263eb5054fdsi4894304pjb.32.2023.09.21.13.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:43:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 7986082F7F9B; Thu, 21 Sep 2023 13:23:46 -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 S229608AbjIUUXm (ORCPT + 29 others); Thu, 21 Sep 2023 16:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231674AbjIUUXV (ORCPT ); Thu, 21 Sep 2023 16:23:21 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EC813561C4 for ; Thu, 21 Sep 2023 10:17:39 -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 E0652139F; Wed, 20 Sep 2023 21:21:40 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.32.120]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3F19F3F59C; Wed, 20 Sep 2023 21:21:00 -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 3/7] coresight: catu: Move ACPI support from AMBA driver to platform driver Date: Thu, 21 Sep 2023 09:50:36 +0530 Message-Id: <20230921042040.1334641-4-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:23:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777681287166663442 X-GMAIL-MSGID: 1777681287166663442 Add support for the catu devices in a new platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for ACPI based systems. The driver would try to enable the APB clock if available. Signed-off-by: Anshuman Khandual --- drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-catu.c | 136 +++++++++++++++++-- drivers/hwtracing/coresight/coresight-catu.h | 1 + 3 files changed, 122 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c index 18aa41d91729..56a7e020555b 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 */ - {"ARMHC9CA", 0}, /* ARM CoreSight CATU */ {"", 0}, }; diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index 3949ded0d4fa..0cb076e8aa1d 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -7,6 +7,8 @@ * Author: Suzuki K Poulose */ +#include +#include #include #include #include @@ -502,28 +504,20 @@ static const struct coresight_ops catu_ops = { .helper_ops = &catu_helper_ops, }; -static int catu_probe(struct amba_device *adev, const struct amba_id *id) +static int __catu_probe(struct device *dev, struct resource *res) { int ret = 0; u32 dma_mask; - struct catu_drvdata *drvdata; + struct catu_drvdata *drvdata = dev_get_drvdata(dev); struct coresight_desc catu_desc; struct coresight_platform_data *pdata = NULL; - struct device *dev = &adev->dev; void __iomem *base; catu_desc.name = coresight_alloc_device_name(&catu_devs, dev); if (!catu_desc.name) return -ENOMEM; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); - if (!drvdata) { - ret = -ENOMEM; - goto out; - } - - dev_set_drvdata(dev, drvdata); - base = devm_ioremap_resource(dev, &adev->res); + base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) { ret = PTR_ERR(base); goto out; @@ -568,18 +562,35 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) if (IS_ERR(drvdata->csdev)) ret = PTR_ERR(drvdata->csdev); else - pm_runtime_put(&adev->dev); + pm_runtime_put(dev); out: return ret; } -static void catu_remove(struct amba_device *adev) +static int catu_probe(struct amba_device *adev, const struct amba_id *id) { - struct catu_drvdata *drvdata = dev_get_drvdata(&adev->dev); + struct catu_drvdata *drvdata; + + drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + amba_set_drvdata(adev, drvdata); + return __catu_probe(&adev->dev, &adev->res); +} + +static void __catu_remove(struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); coresight_unregister(drvdata->csdev); } +static void catu_remove(struct amba_device *adev) +{ + __catu_remove(&adev->dev); +} + static struct amba_id catu_ids[] = { CS_AMBA_ID(0x000bb9ee), {}, @@ -598,13 +609,107 @@ static struct amba_driver catu_driver = { .id_table = catu_ids, }; +static int catu_platform_probe(struct platform_device *pdev) +{ + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + struct catu_drvdata *drvdata; + int ret = 0; + + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + + if (res) { + drvdata->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(drvdata->base)) { + clk_put(drvdata->pclk); + return PTR_ERR(drvdata->base); + } + } + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + dev_set_drvdata(&pdev->dev, drvdata); + ret = __catu_probe(&pdev->dev, res); + if (ret) { + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + return ret; +} + +static int catu_platform_remove(struct platform_device *pdev) +{ + __catu_remove(&pdev->dev); + return 0; +} + +#ifdef CONFIG_PM +static int catu_runtime_suspend(struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata->pclk && !IS_ERR(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); + return 0; +} + +static int catu_runtime_resume(struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata->pclk && !IS_ERR(drvdata->pclk)) + clk_prepare_enable(drvdata->pclk); + return 0; +} +#endif + +static const struct dev_pm_ops catu_dev_pm_ops = { + SET_RUNTIME_PM_OPS(catu_runtime_suspend, catu_runtime_resume, NULL) +}; + +#ifdef CONFIG_ACPI +static const struct acpi_device_id catu_acpi_ids[] = { + {"ARMHC9CA", 0}, /* ARM CoreSight CATU */ + {}, +}; + +MODULE_DEVICE_TABLE(acpi, catu_platform_acpi_ids); +#endif + +static struct platform_driver catu_platform_driver = { + .probe = catu_platform_probe, + .remove = catu_platform_remove, + .driver = { + .name = "coresight-catu-platform", + .acpi_match_table = ACPI_PTR(catu_acpi_ids), + .suppress_bind_attrs = true, + .pm = &catu_dev_pm_ops, + }, +}; + static int __init catu_init(void) { int ret; + ret = platform_driver_register(&catu_platform_driver); + if (ret) { + pr_info("Error registering platform driver\n"); + return ret; + } + ret = amba_driver_register(&catu_driver); - if (ret) + if (ret) { pr_info("Error registering catu driver\n"); + platform_driver_unregister(&catu_platform_driver); + } + tmc_etr_set_catu_ops(&etr_catu_buf_ops); return ret; } @@ -613,6 +718,7 @@ static void __exit catu_exit(void) { tmc_etr_remove_catu_ops(); amba_driver_unregister(&catu_driver); + platform_driver_unregister(&catu_platform_driver); } module_init(catu_init); diff --git a/drivers/hwtracing/coresight/coresight-catu.h b/drivers/hwtracing/coresight/coresight-catu.h index 442e034bbfba..141feac1c14b 100644 --- a/drivers/hwtracing/coresight/coresight-catu.h +++ b/drivers/hwtracing/coresight/coresight-catu.h @@ -61,6 +61,7 @@ #define CATU_IRQEN_OFF 0x0 struct catu_drvdata { + struct clk *pclk; void __iomem *base; struct coresight_device *csdev; int irq; From patchwork Thu Sep 21 04:20:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 142890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5124724vqi; Thu, 21 Sep 2023 13:38:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgYVWh8AmlGbQnHsIJPf4l+PRAkNKeYKaKkXGD95BI3IjZ0fbVKnJq1BdmjM72C88SZ0MS X-Received: by 2002:a05:6a20:d402:b0:153:588c:f197 with SMTP id il2-20020a056a20d40200b00153588cf197mr5381456pzb.35.1695328714941; Thu, 21 Sep 2023 13:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695328714; cv=none; d=google.com; s=arc-20160816; b=mv/us5ZTPV49lmqfgvuXUaRK02LRb1+/lF/YXwHa3i4+mQEsQOEEn5FuBYcVpxT5dD fYvtNvXxKCBr+YnmtXpV8VoyFkqAfmoNWpSb4WFqNdpd9nSMb4U9IlTBiQipMKZei3Et yf3ctIS6X15vge214QCgha9RvE7lzveKKfJDdWnWuG7eoeZAAZpcviWHsUtoqRPrWlpv oFgz/GRekf1SiylbplPmndoh+R2lg0lBvPV5+KifCvSRqyTHtyXRrjBWzTxCehM2qmKD QzSjNNjotTOk/jWGkaNQi5RA/lUZmGc0w8FicbNEonUrgBeNZVoS1FpspLzMFZq4WeFa Ujjg== 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=IeEoU0P2Mb/ScB6+WUtJueX+cf/EVj8GzSaqwpTB7Ek=; fh=9UOEjelFW6YmeQm+a0pvrCM8CYMJ6MbEjrtZbtMEpHI=; b=MP14OrLvTo/T+rW16nphkYaztEhlj+FiYQSkQD8Glm/yZbjDqlGgCdPwrW9OHLzOi/ LcpLBF8tSYFzxlCsK3naQuXMv07CnEs65HGGacotnx7c1zjFKH8c2hKPuxQfbDqEggkR VUhhrDqQkzR7BsHFB3TPNdJB01tLMRl6Pl68eTVA7uxBBxYnRwR0X6DcjEqJBUwN2S9I QDQBfTAwDyroMFuQfHEwaBXtHErzYxAlBiPY1rOe/U0uNYpdTJqU1y+B0oGJtRf9n9PM E1xDRV91gBJPeGIdWxx6CptExOnPvV0b6P80pdQeXYXEUFyoOmVdCrguLYx2Ch89/eKZ 7XNw== 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:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x13-20020a170902a38d00b001bbd785e1d2si2051148pla.201.2023.09.21.13.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:38:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id A42368374A4F; Thu, 21 Sep 2023 13:23:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231295AbjIUUXs (ORCPT + 29 others); Thu, 21 Sep 2023 16:23:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231707AbjIUUXV (ORCPT ); Thu, 21 Sep 2023 16:23:21 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E9AF7561C2 for ; Thu, 21 Sep 2023 10:17:39 -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 CDAA1143D; Wed, 20 Sep 2023 21:21:43 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.32.120]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 40F913F59C; Wed, 20 Sep 2023 21:21:04 -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 4/7] coresight: tpiu: Move ACPI support from AMBA driver to platform driver Date: Thu, 21 Sep 2023 09:50:37 +0530 Message-Id: <20230921042040.1334641-5-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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:23:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777681002798541482 X-GMAIL-MSGID: 1777681002798541482 Add support for the tpiu device in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for ACPI based systems. The driver would try to enable the APB clock if available. Signed-off-by: Anshuman Khandual --- drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-tpiu.c | 76 ++++++++++++++++++-- 2 files changed, 69 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c index 56a7e020555b..8e1783166c33 100644 --- a/drivers/acpi/arm64/amba.c +++ b/drivers/acpi/arm64/amba.c @@ -25,7 +25,6 @@ static const struct acpi_device_id amba_id_list[] = { {"ARMHC501", 0}, /* ARM CoreSight ETR */ {"ARMHC502", 0}, /* ARM CoreSight STM */ {"ARMHC503", 0}, /* ARM CoreSight Debug */ - {"ARMHC979", 0}, /* ARM CoreSight TPIU */ {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */ {"", 0}, }; diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 59eac93fd6bb..9835a79c036e 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -5,6 +5,8 @@ * Description: CoreSight Trace Port Interface Unit driver */ +#include +#include #include #include #include @@ -57,6 +59,7 @@ DEFINE_CORESIGHT_DEVLIST(tpiu_devs, "tpiu"); struct tpiu_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; }; @@ -114,14 +117,12 @@ static const struct coresight_ops tpiu_cs_ops = { .sink_ops = &tpiu_sink_ops, }; -static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) +static int __tpiu_probe(struct device *dev, struct resource *res) { int ret; void __iomem *base; - struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; struct tpiu_drvdata *drvdata; - struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; desc.name = coresight_alloc_device_name(&tpiu_devs, dev); @@ -132,12 +133,16 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) return -ENOMEM; - drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ + drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); if (ret) return ret; } + + drvdata->pclk = coresight_get_enable_apb_pclk(dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; dev_set_drvdata(dev, drvdata); /* Validity for the resource is already checked by the AMBA core */ @@ -164,20 +169,30 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) drvdata->csdev = coresight_register(&desc); if (!IS_ERR(drvdata->csdev)) { - pm_runtime_put(&adev->dev); + pm_runtime_put(dev); return 0; } return PTR_ERR(drvdata->csdev); } -static void tpiu_remove(struct amba_device *adev) +static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) { - struct tpiu_drvdata *drvdata = dev_get_drvdata(&adev->dev); + return __tpiu_probe(&adev->dev, &adev->res); +} + +static void __tpiu_remove(struct device *dev) +{ + struct tpiu_drvdata *drvdata = dev_get_drvdata(dev); coresight_unregister(drvdata->csdev); } +static void tpiu_remove(struct amba_device *adev) +{ + __tpiu_remove(&adev->dev); +} + #ifdef CONFIG_PM static int tpiu_runtime_suspend(struct device *dev) { @@ -186,6 +201,8 @@ static int tpiu_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; } @@ -196,6 +213,8 @@ static int tpiu_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 @@ -237,6 +256,49 @@ static struct amba_driver tpiu_driver = { module_amba_driver(tpiu_driver); +static int tpiu_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); + + ret = __tpiu_probe(&pdev->dev, res); + if (ret) { + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + return ret; +} + +static int tpiu_platform_remove(struct platform_device *pdev) +{ + __tpiu_remove(&pdev->dev); + return 0; +} + +#ifdef CONFIG_ACPI +static const struct acpi_device_id tpiu_acpi_ids[] = { + {"ARMHC979", 0}, /* ARM CoreSight TPIU */ + {} +}; +MODULE_DEVICE_TABLE(acpi, tpiu_acpi_ids); +#endif + +static struct platform_driver tpiu_platform_driver = { + .probe = tpiu_platform_probe, + .remove = tpiu_platform_remove, + .driver = { + .name = "coresight-tpiu-platform", + .acpi_match_table = ACPI_PTR(tpiu_acpi_ids), + .suppress_bind_attrs = true, + .pm = &tpiu_dev_pm_ops, + }, +}; +module_platform_driver(tpiu_platform_driver); + MODULE_AUTHOR("Pratik Patel "); MODULE_AUTHOR("Mathieu Poirier "); MODULE_DESCRIPTION("Arm CoreSight TPIU (Trace Port Interface Unit) driver"); From patchwork Thu Sep 21 04:20:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 142892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5125890vqi; Thu, 21 Sep 2023 13:41:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2moFRh+Id7TE9gqAYtoDDOZTD9HKycT4/GToiSr8hCjBaRGJemqo9M+6vZgsEznmbVIK1 X-Received: by 2002:a05:6a20:9192:b0:14d:6309:fc96 with SMTP id v18-20020a056a20919200b0014d6309fc96mr6721138pzd.4.1695328859712; Thu, 21 Sep 2023 13:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695328859; cv=none; d=google.com; s=arc-20160816; b=evzk4sxE2ch+4vTGrLPobATZLR9JdDjADAgomDlJaNvSRlf9y5AXeIOvEjwurvmzI2 k/lPwXRv6fNX7h7U7THvWnKM7MqZ5OpI175ADi4Prbst0+yR2CS+S5hUBuXNjMkSbBKb A9o4t7kuCGkBrf58CP4sj/UN9PSRHicXYxvxXyFFgSyetO5pCjtBYFkGiZfAeRGp0q3+ +jTjMMxV0Q4J+ZPJsFgo3ApFG5DBb/IFYyFwq+JhgKCJ75Ft5e8VpEHRdpWL/UdNT9kQ 2xms5awRh0DA1Q+BEdRkYe9D7aLqs70mL8xwHjxbxgzQ6FuqKV3M2qhY5SZ8kudNJ3H0 inLg== 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=HUdFcHgo6tSKMKR8VVCQG+aBwB2969AufgW9gyeiA0w=; fh=9UOEjelFW6YmeQm+a0pvrCM8CYMJ6MbEjrtZbtMEpHI=; b=C7gnhJmQw/G3JXEqlouD9fEblqJ968Rw1Jkez1xZK6Dz+/pYcfGIudifw+u8y6ulcV XG+tJnS/Qehg1FSY2A50RWMYUuaCPh52wTlLJFtaSl/mlDINfwG8O4czkIQNyF5DAk/K lvnhc+wuIbwVZoEQ66oeT20HH35L1TK4IhvlVTlkEMLFxrxa+Bq6SUw51kgdyD8mFlQm XfknmqpyaFVq9fY1rVZxuJ4iSoMNnzwss7b+x4xgxWJqw+6PkijwNjUhCp+b2zRqY/BB 8mSP+f4ueyyJwzpBgUYAt91Q9lGKFbtOod5MHUEFHnRkGGpS5ZXvSAP5e0JF7pwVgwiN ltZw== 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:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t41-20020a056a0013a900b0068fbf6ba315si2350075pfg.233.2023.09.21.13.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:40:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id B260282DEE6A; Thu, 21 Sep 2023 13:01:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231535AbjIUUB2 (ORCPT + 28 others); Thu, 21 Sep 2023 16:01:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231414AbjIUUAw (ORCPT ); Thu, 21 Sep 2023 16:00:52 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4350555AF5 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 D2B6C1474; Wed, 20 Sep 2023 21:21:46 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.32.120]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 49B483F59C; Wed, 20 Sep 2023 21:21:06 -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 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver Date: Thu, 21 Sep 2023 09:50:38 +0530 Message-Id: <20230921042040.1334641-6-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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:01:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777681154337694841 X-GMAIL-MSGID: 1777681154337694841 Add support for the tmc devices in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for ACPI based systems. The driver would try to enable the APB clock if available. Signed-off-by: Anshuman Khandual --- drivers/acpi/arm64/amba.c | 2 - .../hwtracing/coresight/coresight-tmc-core.c | 127 +++++++++++++++--- drivers/hwtracing/coresight/coresight-tmc.h | 1 + 3 files changed, 113 insertions(+), 17 deletions(-) diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c index 8e1783166c33..6980502b7868 100644 --- a/drivers/acpi/arm64/amba.c +++ b/drivers/acpi/arm64/amba.c @@ -22,10 +22,8 @@ static const struct acpi_device_id amba_id_list[] = { {"ARMH0061", 0}, /* PL061 GPIO Device */ {"ARMH0330", 0}, /* ARM DMA Controller DMA-330 */ - {"ARMHC501", 0}, /* ARM CoreSight ETR */ {"ARMHC502", 0}, /* ARM CoreSight STM */ {"ARMHC503", 0}, /* ARM CoreSight Debug */ - {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */ {"", 0}, }; diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c index c106d142e632..510481ea635c 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-core.c +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include "coresight-priv.h" #include "coresight-tmc.h" @@ -429,24 +431,17 @@ static u32 tmc_etr_get_max_burst_size(struct device *dev) return burst_size; } -static int tmc_probe(struct amba_device *adev, const struct amba_id *id) +static int __tmc_probe(struct device *dev, struct resource *res, void *dev_caps) { int ret = 0; u32 devid; void __iomem *base; - struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; - struct tmc_drvdata *drvdata; - struct resource *res = &adev->res; + struct tmc_drvdata *drvdata = dev_get_drvdata(dev); struct coresight_desc desc = { 0 }; struct coresight_dev_list *dev_list = NULL; ret = -ENOMEM; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); - if (!drvdata) - goto out; - - dev_set_drvdata(dev, drvdata); /* Validity for the resource is already checked by the AMBA core */ base = devm_ioremap_resource(dev, res); @@ -487,8 +482,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) desc.type = CORESIGHT_DEV_TYPE_SINK; desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM; desc.ops = &tmc_etr_cs_ops; - ret = tmc_etr_setup_caps(dev, devid, - coresight_get_uci_data(id)); + ret = tmc_etr_setup_caps(dev, devid, dev_caps); if (ret) goto out; idr_init(&drvdata->idr); @@ -519,7 +513,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) ret = PTR_ERR(pdata); goto out; } - adev->dev.platform_data = pdata; + dev->platform_data = pdata; desc.pdata = pdata; drvdata->csdev = coresight_register(&desc); @@ -535,11 +529,23 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) if (ret) coresight_unregister(drvdata->csdev); else - pm_runtime_put(&adev->dev); + pm_runtime_put(dev); out: return ret; } +static int tmc_probe(struct amba_device *adev, const struct amba_id *id) +{ + struct tmc_drvdata *drvdata; + + drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + amba_set_drvdata(adev, drvdata); + return __tmc_probe(&adev->dev, &adev->res, coresight_get_uci_data(id)); +} + static void tmc_shutdown(struct amba_device *adev) { unsigned long flags; @@ -562,9 +568,9 @@ static void tmc_shutdown(struct amba_device *adev) spin_unlock_irqrestore(&drvdata->spinlock, flags); } -static void tmc_remove(struct amba_device *adev) +static void __tmc_remove(struct device *dev) { - struct tmc_drvdata *drvdata = dev_get_drvdata(&adev->dev); + struct tmc_drvdata *drvdata = dev_get_drvdata(dev); /* * Since misc_open() holds a refcount on the f_ops, which is @@ -575,6 +581,11 @@ static void tmc_remove(struct amba_device *adev) coresight_unregister(drvdata->csdev); } +static void tmc_remove(struct amba_device *adev) +{ + __tmc_remove(&adev->dev); +} + static const struct amba_id tmc_ids[] = { CS_AMBA_ID(0x000bb961), /* Coresight SoC 600 TMC-ETR/ETS */ @@ -602,6 +613,92 @@ static struct amba_driver tmc_driver = { module_amba_driver(tmc_driver); +static int tmc_platform_probe(struct platform_device *pdev) +{ + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + struct tmc_drvdata *drvdata; + int ret = 0; + + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + + if (res) { + drvdata->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(drvdata->base)) { + clk_put(drvdata->pclk); + return PTR_ERR(drvdata->base); + } + } + + dev_set_drvdata(&pdev->dev, drvdata); + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + ret = __tmc_probe(&pdev->dev, res, NULL); + if (ret) { + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + return ret; +} + +static int tmc_platform_remove(struct platform_device *pdev) +{ + __tmc_remove(&pdev->dev); + return 0; +} + +#ifdef CONFIG_PM +static int tmc_runtime_suspend(struct device *dev) +{ + struct tmc_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata->pclk && !IS_ERR(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); + return 0; +} + +static int tmc_runtime_resume(struct device *dev) +{ + struct tmc_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata->pclk && !IS_ERR(drvdata->pclk)) + clk_prepare_enable(drvdata->pclk); + return 0; +} +#endif + +static const struct dev_pm_ops tmc_dev_pm_ops = { + SET_RUNTIME_PM_OPS(tmc_runtime_suspend, tmc_runtime_resume, NULL) +}; + +#ifdef CONFIG_ACPI +static const struct acpi_device_id tmc_acpi_ids[] = { + {"ARMHC501", 0}, /* ARM CoreSight ETR */ + {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */ + {}, +}; +MODULE_DEVICE_TABLE(acpi, tmc_acpi_ids); +#endif + +static struct platform_driver tmc_platform_driver = { + .probe = tmc_platform_probe, + .remove = tmc_platform_remove, + .driver = { + .name = "coresight-tmc-platform", + .acpi_match_table = ACPI_PTR(tmc_acpi_ids), + .suppress_bind_attrs = true, + .pm = &tmc_dev_pm_ops, + }, +}; +module_platform_driver(tmc_platform_driver); + MODULE_AUTHOR("Pratik Patel "); MODULE_DESCRIPTION("Arm CoreSight Trace Memory Controller driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h index 0ee48c5ba764..193af5959f2c 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -189,6 +189,7 @@ struct etr_buf { * @perf_buf: PERF buffer for ETR. */ struct tmc_drvdata { + struct clk *pclk; void __iomem *base; struct coresight_device *csdev; struct miscdevice miscdev; From patchwork Thu Sep 21 04:20:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 142915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5143290vqi; Thu, 21 Sep 2023 14:15:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESn6fgDvTT1PqshioZ6REs2btVWJHEQ9oN2yXH+XaZp+ADpjBzY5Vw6AKnMBBDI880jtd+ X-Received: by 2002:a05:6870:c88d:b0:1d5:8d8b:dcc with SMTP id er13-20020a056870c88d00b001d58d8b0dccmr6415906oab.18.1695330909974; Thu, 21 Sep 2023 14:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695330909; cv=none; d=google.com; s=arc-20160816; b=osmVvReOOzKHxieRwy9WmyatHEBuiTfOaGX8dEuSTlDACI+PEhTXhN2a2Mnk0IuZaN X+XJKhb62DsRhRtNSbHRi9mB1rEGIwVYWBbTHXPD6ieIwUKOufRHPXzkfc5iS7YdBPOM hdhUxtR3pbcQqNIgpCOM0K/tFdsZJWeRFWIW1v1HLCZ4SQylsWI5ScSkar700WKfH7x3 PrNcdMcvoytQc9VpF8kZGiivxAdMlbumMLlmzyIncOVv57oUgE8VocV06RvHGK+RfDSW 5MxNMh4lgR/hFE1dtEloPN0GcQfGLab/Lj1ba52LkBM1YYSzHyJP1qws60hO0B6+2hQK Cbww== 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=8yGBP8C8v6q08PcGWZTyyCEnQGrVXs7S256tpxcZCbM=; fh=9UOEjelFW6YmeQm+a0pvrCM8CYMJ6MbEjrtZbtMEpHI=; b=pktsy6EdyeMOZdkfpjxb7hPn3H5Bz5pjXpkYvA6MdxaecVGpHICkoABJxSd/HvTCcP OiWKjGVQd8Pc5pFGM1GE6LJMwmQ0in01WaDHaLRwa+UxfA+NFRPdGefqmlYUOCL9zha1 wlsfY0bKiNRluOaBBwHBIADK3W2fpfsqm9qsNTN7BzWR7UldwFfCqOquOdNP1Cxpi1oY tx9c0lIBMDkIko/geNQR5rRhvtNghxH71AGIZpQ14EJdRgCbJbOzGSaPFWkqBp9WUoUn rEDt8MqQu/S/p5wjnXjBlCgrYKzcVWADuPuKpWjMoE3nm3ktGytu4roj3gVePDzVV+20 H9kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id x27-20020a63171b000000b005789abf4414si2152908pgl.399.2023.09.21.14.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 14:15:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 321C382114A8; Thu, 21 Sep 2023 12:59:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230273AbjIUT6u (ORCPT + 28 others); Thu, 21 Sep 2023 15:58:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230503AbjIUT6b (ORCPT ); Thu, 21 Sep 2023 15:58:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E559561C8 for ; Thu, 21 Sep 2023 10:17:40 -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 877151476; Wed, 20 Sep 2023 21:21:49 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.32.120]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 30C173F59C; Wed, 20 Sep 2023 21:21:09 -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 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver Date: Thu, 21 Sep 2023 09:50:39 +0530 Message-Id: <20230921042040.1334641-7-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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 12:59:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777683304267247486 X-GMAIL-MSGID: 1777683304267247486 Add support for the stm devices in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for ACPI based systems. The driver would try to enable the APB clock if available. Signed-off-by: Anshuman Khandual --- drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-stm.c | 80 ++++++++++++++++++--- 2 files changed, 71 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c index 6980502b7868..ebc866518057 100644 --- a/drivers/acpi/arm64/amba.c +++ b/drivers/acpi/arm64/amba.c @@ -22,7 +22,6 @@ static const struct acpi_device_id amba_id_list[] = { {"ARMH0061", 0}, /* PL061 GPIO Device */ {"ARMH0330", 0}, /* ARM DMA Controller DMA-330 */ - {"ARMHC502", 0}, /* ARM CoreSight STM */ {"ARMHC503", 0}, /* ARM CoreSight Debug */ {"", 0}, }; diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index a1c27c901ad1..7311b6d3039b 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include "coresight-priv.h" #include "coresight-trace-id.h" @@ -132,6 +134,7 @@ DEFINE_CORESIGHT_DEVLIST(stm_devs, "stm"); struct stm_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; spinlock_t spinlock; struct channel_space chs; @@ -804,14 +807,12 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata, drvdata->stm.set_options = stm_generic_set_options; } -static int stm_probe(struct amba_device *adev, const struct amba_id *id) +static int __stm_probe(struct device *dev, struct resource *res, void *dev_caps) { int ret, trace_id; void __iomem *base; - struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; struct stm_drvdata *drvdata; - struct resource *res = &adev->res; struct resource ch_res; struct coresight_desc desc = { 0 }; @@ -823,12 +824,16 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) if (!drvdata) return -ENOMEM; - drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ + drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); if (ret) return ret; } + + drvdata->pclk = coresight_get_enable_apb_pclk(dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; dev_set_drvdata(dev, drvdata); base = devm_ioremap_resource(dev, res); @@ -876,7 +881,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) ret = PTR_ERR(pdata); goto stm_unregister; } - adev->dev.platform_data = pdata; + dev->platform_data = pdata; desc.type = CORESIGHT_DEV_TYPE_SOURCE; desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE; @@ -897,10 +902,10 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) } drvdata->traceid = (u8)trace_id; - pm_runtime_put(&adev->dev); + pm_runtime_put(dev); dev_info(&drvdata->csdev->dev, "%s initialized\n", - (char *)coresight_get_uci_data(id)); + (char *)dev_caps); return 0; cs_unregister: @@ -911,9 +916,14 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) return ret; } -static void stm_remove(struct amba_device *adev) +static int stm_probe(struct amba_device *adev, const struct amba_id *id) +{ + return __stm_probe(&adev->dev, &adev->res, coresight_get_uci_data(id)); +} + +static void __stm_remove(struct device *dev) { - struct stm_drvdata *drvdata = dev_get_drvdata(&adev->dev); + struct stm_drvdata *drvdata = dev_get_drvdata(dev); coresight_trace_id_put_system_id(drvdata->traceid); coresight_unregister(drvdata->csdev); @@ -921,6 +931,11 @@ static void stm_remove(struct amba_device *adev) stm_unregister_device(&drvdata->stm); } +static void stm_remove(struct amba_device *adev) +{ + __stm_remove(&adev->dev); +} + #ifdef CONFIG_PM static int stm_runtime_suspend(struct device *dev) { @@ -929,6 +944,8 @@ static int stm_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; } @@ -939,6 +956,8 @@ static int stm_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 @@ -969,6 +988,49 @@ static struct amba_driver stm_driver = { module_amba_driver(stm_driver); +static int stm_platform_probe(struct platform_device *pdev) +{ + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + int ret = 0; + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + ret = __stm_probe(&pdev->dev, res, NULL); + if (ret) { + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + return ret; +} + +static int stm_platform_remove(struct platform_device *pdev) +{ + __stm_remove(&pdev->dev); + return 0; +} + +#ifdef CONFIG_ACPI +static const struct acpi_device_id stm_acpi_ids[] = { + {"ARMHC502", 0}, /* ARM CoreSight STM */ + {}, +}; +MODULE_DEVICE_TABLE(acpi, stm_acpi_ids); +#endif + +static struct platform_driver stm_platform_driver = { + .probe = stm_platform_probe, + .remove = stm_platform_remove, + .driver = { + .name = "coresight-stm-platform", + .acpi_match_table = ACPI_PTR(stm_acpi_ids), + .suppress_bind_attrs = true, + .pm = &stm_dev_pm_ops, + }, +}; +module_platform_driver(stm_platform_driver); + MODULE_AUTHOR("Pratik Patel "); MODULE_DESCRIPTION("Arm CoreSight System Trace Macrocell driver"); MODULE_LICENSE("GPL v2"); From patchwork Thu Sep 21 04:20:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 142905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5133803vqi; Thu, 21 Sep 2023 13:58:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQXGhOs2ilIWlsOz47epkyQLtM/sse0BoESOa81Ea4HpSXQqPiOFqE+tTeKw498us6fQAD X-Received: by 2002:a05:6a20:7483:b0:14d:d636:ed3a with SMTP id p3-20020a056a20748300b0014dd636ed3amr7618712pzd.23.1695329917740; Thu, 21 Sep 2023 13:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695329917; cv=none; d=google.com; s=arc-20160816; b=PVxdrFgLS+kj5wR/IQUCUNhy62U0NdR6s6LdzEHIMRRUqnv2cY3ITU69CjPP0llOse 0cpe6qyrnubktxPkU5AstqYnIWgX/qd/7UBe5zm6XcRC2TVjtB9DE8pLAxWlkTzg4rZq dA+9K7AjB9PjUrh1uL9Kth/XwhACurz4Lh+AMDS5NuLvQq16/CJXJkOgJO7iyjmUFlMy //jZGhmICGKWfBbXPOib6h0LALU2rU5xy3d9cuEFJP7rCpYQxC/ILa0SkCq6Ky1ik1JG 9V4pEs5J/yzTOGIihncXu0EXHBomrjzWX8qFTf/cP0O2Q/KX90evze37FzltKFf36lMh 7NXQ== 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=JCR+v819OKBoUWnfLUU+gZPMgKQDpgk+SpHGG89NZ6U=; fh=9UOEjelFW6YmeQm+a0pvrCM8CYMJ6MbEjrtZbtMEpHI=; b=g4PZxKg2+2bM4wK73me+F9P82kbdtRsB1fWOmn2KH8JRMfCaJmUEGqFHtQ98Ble+DP XAyXpAnpFzOKqJAbrSajY/AT0tGtTBfZZpkOinuMfHSeung+PnS6L6a7e3BfqFTXjgLX dcB2piA7l2U2Psn2l00Fc2ZTpCpgo9hBBEzw3cDw7lGw72HSsaEgHRLX61+Q8QY6HqKP BcbKQrVUgJI/yJM9UaxlVe6XR0FlPhKNfK7vQYOpNqhft1CwXXSZ/0VHVB0ZW7C1gzSj S3WM+E6Efqnobc8jZlVuDNxZVwkHf6VEJceOKmktSWuBbcvUzviC9L0CWeKNtxb6/rdM LKmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id i11-20020a17090332cb00b001c3323ff53asi2214965plr.139.2023.09.21.13.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:58:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 45CE7829B88D; Thu, 21 Sep 2023 13:23:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231794AbjIUUXf (ORCPT + 29 others); Thu, 21 Sep 2023 16:23:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231809AbjIUUXJ (ORCPT ); Thu, 21 Sep 2023 16:23:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA60D561C3 for ; Thu, 21 Sep 2023 10:17:39 -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 3E7581477; Wed, 20 Sep 2023 21:21:52 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.32.120]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DC0053F59C; Wed, 20 Sep 2023 21:21:12 -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 7/7] coresight: debug: Move ACPI support from AMBA driver to platform driver Date: Thu, 21 Sep 2023 09:50:40 +0530 Message-Id: <20230921042040.1334641-8-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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:23:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777682263598635256 X-GMAIL-MSGID: 1777682263598635256 Add support for the cpu debug devices in a new platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for ACPI based systems. The driver would try to enable the APB clock if available. Signed-off-by: Anshuman Khandual --- drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-cpu-debug.c | 130 ++++++++++++++++-- 2 files changed, 117 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c index ebc866518057..b591c7a650aa 100644 --- a/drivers/acpi/arm64/amba.c +++ b/drivers/acpi/arm64/amba.c @@ -22,7 +22,6 @@ static const struct acpi_device_id amba_id_list[] = { {"ARMH0061", 0}, /* PL061 GPIO Device */ {"ARMH0330", 0}, /* ARM DMA Controller DMA-330 */ - {"ARMHC503", 0}, /* ARM CoreSight Debug */ {"", 0}, }; diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c index 1874df7c6a73..77a42a7d5d7c 100644 --- a/drivers/hwtracing/coresight/coresight-cpu-debug.c +++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include "coresight-priv.h" @@ -84,6 +86,7 @@ #define DEBUG_WAIT_TIMEOUT 32000 struct debug_drvdata { + struct clk *pclk; void __iomem *base; struct device *dev; int cpu; @@ -557,18 +560,12 @@ static void debug_func_exit(void) debugfs_remove_recursive(debug_debugfs_dir); } -static int debug_probe(struct amba_device *adev, const struct amba_id *id) +static int __debug_probe(struct device *dev, struct resource *res) { + struct debug_drvdata *drvdata = dev_get_drvdata(dev); void __iomem *base; - struct device *dev = &adev->dev; - struct debug_drvdata *drvdata; - struct resource *res = &adev->res; int ret; - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); - if (!drvdata) - return -ENOMEM; - drvdata->cpu = coresight_get_cpu(dev); if (drvdata->cpu < 0) return drvdata->cpu; @@ -579,8 +576,7 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id) return -EBUSY; } - drvdata->dev = &adev->dev; - amba_set_drvdata(adev, drvdata); + drvdata->dev = dev; /* Validity for the resource is already checked by the AMBA core */ base = devm_ioremap_resource(dev, res); @@ -629,10 +625,21 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id) return ret; } -static void debug_remove(struct amba_device *adev) +static int debug_probe(struct amba_device *adev, const struct amba_id *id) { - struct device *dev = &adev->dev; - struct debug_drvdata *drvdata = amba_get_drvdata(adev); + struct debug_drvdata *drvdata; + + drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + amba_set_drvdata(adev, drvdata); + return __debug_probe(&adev->dev, &adev->res); +} + +static void __debug_remove(struct device *dev) +{ + struct debug_drvdata *drvdata = dev_get_drvdata(dev); per_cpu(debug_drvdata, drvdata->cpu) = NULL; @@ -646,6 +653,11 @@ static void debug_remove(struct amba_device *adev) debug_func_exit(); } +static void debug_remove(struct amba_device *adev) +{ + __debug_remove(&adev->dev); +} + static const struct amba_cs_uci_id uci_id_debug[] = { { /* CPU Debug UCI data */ @@ -679,6 +691,98 @@ static struct amba_driver debug_driver = { module_amba_driver(debug_driver); +static int debug_platform_probe(struct platform_device *pdev) +{ + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + struct debug_drvdata *drvdata; + int ret = 0; + + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + + if (res) { + drvdata->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(drvdata->base)) { + clk_put(drvdata->pclk); + return PTR_ERR(drvdata->base); + } + } + + dev_set_drvdata(&pdev->dev, drvdata); + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + ret = __debug_probe(&pdev->dev, res); + if (ret) { + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + return ret; +} + +static int debug_platform_remove(struct platform_device *pdev) +{ + struct debug_drvdata *drvdata = dev_get_drvdata(&pdev->dev); + + if (drvdata) + __debug_remove(&pdev->dev); + + pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_put(drvdata->pclk); + return 0; +} + +#ifdef CONFIG_ACPI +static const struct acpi_device_id debug_platform_ids[] = { + {"ARMHC503", 0}, /* ARM CoreSight Debug */ + {}, +}; +MODULE_DEVICE_TABLE(acpi, debug_platform_ids); +#endif + +#ifdef CONFIG_PM +static int debug_runtime_suspend(struct device *dev) +{ + struct debug_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata->pclk && !IS_ERR(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); + return 0; +} + +static int debug_runtime_resume(struct device *dev) +{ + struct debug_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata->pclk && !IS_ERR(drvdata->pclk)) + clk_prepare_enable(drvdata->pclk); + return 0; +} +#endif + +static const struct dev_pm_ops debug_dev_pm_ops = { + SET_RUNTIME_PM_OPS(debug_runtime_suspend, debug_runtime_resume, NULL) +}; + +static struct platform_driver debug_platform_driver = { + .probe = debug_platform_probe, + .remove = debug_platform_remove, + .driver = { + .name = "coresight-debug-platform", + .acpi_match_table = ACPI_PTR(debug_platform_ids), + .suppress_bind_attrs = true, + .pm = &debug_dev_pm_ops, + }, +}; +module_platform_driver(debug_platform_driver); + MODULE_AUTHOR("Leo Yan "); MODULE_DESCRIPTION("ARM Coresight CPU Debug Driver"); MODULE_LICENSE("GPL");