From patchwork Fri Dec 1 06:20:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 172275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp914079vqy; Thu, 30 Nov 2023 22:21:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhBJwtqnj5P99nJKu/aqpFc1rlmKFGFGFUaujv1SeG54NwEXrsx+wVS4ZPJzznl5iCB164 X-Received: by 2002:a05:6a00:1ca8:b0:6cd:f6e6:2f4e with SMTP id y40-20020a056a001ca800b006cdf6e62f4emr3107834pfw.4.1701411693380; Thu, 30 Nov 2023 22:21:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701411693; cv=none; d=google.com; s=arc-20160816; b=zPwp7vUIrfUSWvVW2DAQqntyR/2Az7RFMOi/yxYFDXb6xwpfDa29h5ygFSR38hMaRy e9meKvlHlTLIBcMjx5jhnqfb2GcLc+frWoIpA00RnUk27MxZBthGEnvVdFyHm2jA5AXe HFuxOp1nJZw1xfSlLHsDdlazkDqH3L9fcT5zO38q8KL7oMvIbvHmVZ6axuB4r/nNM43p RTgt7rNO7PTWq3LQl6pe1viJJ2Ike3dLLhKXM9FwOqc9nl1sysvmA01/Y4UYgXHwKgmJ ElTYoOiyb3GQnrxwIOP46d7UA9C0hMYYatvLICZKb/sdGAzxzWpmmnCefGE9U+ZkF410 kslw== 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=6zzpcu8uPRrwJqzLXiTQTDB7pmiHKZgjdfmmzTOsGGo=; fh=78ZiYAsMqkMiOIWlhjjSgWn2SS9khyeUqw/r/4rUn1M=; b=erLmzf1s8ER3ERhMmMm8f8htBuaqKIz7xtutkMG2rdlRiu4kJnLX16GWKgbc/t+ldr dUH9MJ0/M2bWKhv4mnVlYWOpqki9Xsp+QafmMF10CNt36oSYWvOY9TLVNI+GkTg9PLFV tJRcKB4V7TfRK87juuMqTA+ffPi7KJYolt297QLYttjmgPyH8h/B0wAgMbwM5I8m9Ca1 PR1Kpq18lCpJxBBh65KrvWxpRXa9U0ZCmiRY0bvVsYQZGzCn5p1qnNKud19fuDE9gGGI EfvVaX+Y7tI9l6dPyEzW4/MDs6vasa6G7rSYEs8uonzJX0yVH9Yl0H33EAdHumiJQRU9 HUxw== 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 i8-20020a63d448000000b005c1b2fdfe6dsi2882711pgj.573.2023.11.30.22.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 22:21:33 -0800 (PST) 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 780D180ABFD1; Thu, 30 Nov 2023 22:21:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbjLAGVX (ORCPT + 99 others); Fri, 1 Dec 2023 01:21:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235195AbjLAGVO (ORCPT ); Fri, 1 Dec 2023 01:21:14 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A36C171A; Thu, 30 Nov 2023 22:21:18 -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 4972E1042; Thu, 30 Nov 2023 22:22:04 -0800 (PST) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.41.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5B4053F73F; Thu, 30 Nov 2023 22:21:13 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com Cc: Anshuman Khandual , Lorenzo Pieralisi , Sudeep Holla , Mike Leach , James Clark , Maxime Coquelin , Alexandre Torgue , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH V2 2/7] coresight: funnel: Move ACPI support from AMBA driver to platform driver Date: Fri, 1 Dec 2023 11:50:48 +0530 Message-Id: <20231201062053.1268492-3-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231201062053.1268492-1-anshuman.khandual@arm.com> References: <20231201062053.1268492-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,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 22:21:32 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784059467555777943 X-GMAIL-MSGID: 1784059467555777943 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. Cc: Lorenzo Pieralisi Cc: Sudeep Holla Cc: Suzuki K Poulose Cc: Mike Leach Cc: James Clark Cc: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: coresight@lists.linaro.org Signed-off-by: Anshuman Khandual Acked-by: Sudeep Holla # For ACPI related changes Tested-by: Sudeep Holla # Boot and driver probe only --- 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 270f4e3819a2..afb6afb66967 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..939fe79f031f 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_OR_NULL(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_OR_NULL(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); }