Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp190368lqk; Wed, 13 Mar 2024 23:13:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2P9XLhnrEBrd6hsAbc9tEehDTrxhn60O6QeMVcAu6vfGX42FlK7bktOfI4zaGQb2qt4VvBWh+MdB8glq2HrMdtcwFNpuvrLSvVa7J3A== X-Google-Smtp-Source: AGHT+IH2p7+4xV3Q98X8/kW4t+hLpNAJMBF8APN7zHq6iPodixqVAcr/kIURTJfL8uXj3Qfk3kNF X-Received: by 2002:a17:906:71c7:b0:a43:9f21:1a08 with SMTP id i7-20020a17090671c700b00a439f211a08mr373485ejk.63.1710396797426; Wed, 13 Mar 2024 23:13:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710396797; cv=pass; d=google.com; s=arc-20160816; b=1K+9+fey+Vkx9BLVJt6AeMrtquZnoF+SmvXNNr/QddW6yPgVijrYxA/Nb0VeB5edBS BWDzHxu7UnEv7N+dUqRN/h7c5UbBUopZNjd3oGbUkZkfWfedIX5M1kMR/9p/oqKWvqab wts4NQmkzJdoOvhg6lSHfw+PfZfLuF4EY3T/n6WxOGEtCARo6JRjTc7Nb8bLm1Tgid94 uhZPJ5eSglz4JokuUvvHOdighZHIbE3JfEgtpj9sdfEcYIUhZk/yYwQxEn9VXUb3tVIQ 70BiydddIWEnim80C8C2ss1Qve4XiD9xBVvqugX76uJCm2pmZ2DWTn5V4leXzO/Kc4LP 5vsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ME9j6KAZjKmuoYhhDMwIBDPOLFeeNnzDdqCP8SQVtsw=; fh=78ZiYAsMqkMiOIWlhjjSgWn2SS9khyeUqw/r/4rUn1M=; b=VFfg2Jd76DDNoqXDNtOQl5XYRt/4DAWBHnrQ6XeM/+hQySYEVo2hlvlFs7M6yWXphr FtvsJGKyC0PlkzCbCiDSJSdm5bi2WeQVBpJIT1vAG43fiCCSZzgSSxsqGTHeCmEu9k6R zd+a9kOuHRyyfV/x4XYfF0JXr/TcNsSWDHb5LBu1vCouYqgB+/4+NoTaj6QML2Tvw9+G njkONnbZJM064LUpO7EivL0UAl1kiINsdJlFtFtdWdwBaafnG2iEKCqvn13+c9NpiZy7 QoCVMmdlasSGL6zkcZKiW1DGPOF5/1mbmZC72IJXIoSH0t36EqkJW0TU1ANh+yQpCVbG kngw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-102841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hb17-20020a170906b89100b00a44b3d10436si392129ejb.948.2024.03.13.23.13.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 23:13:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-102841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1E0601F250DA for ; Thu, 14 Mar 2024 06:04:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15BC43A1A6; Thu, 14 Mar 2024 05:59:50 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50501381D0; Thu, 14 Mar 2024 05:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710395989; cv=none; b=N4r075um2rPmJWhrmAE+fek5Yi8V7UCwpjKbuZyQBBs+Gx5amwpXDLhC4FEzajSWohjguZZXVBE0kIHFlI82o6S0M+8bS6rmgrMpQ8XlfnMV5TwK95hospqpJSmxNgXvdPQ7RnqElUTV5XkpV+C2hs28JHA1lhZZymtDJoS7jsU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710395989; c=relaxed/simple; bh=nF1vib//JfS9VVM1KMJL7ziPCfj+3ZudKLaYfcABLc0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=innDWgAYmhiA3bEfmuhatmt+zb+Lotv+2AvBbyJtBWcPW6G7PE32cwVW//NlLFSGARMiXlB4y5ROtrSSeheJrYMZi0CLSEg+H8giWbd9kGUGTnWMzhhpLOid1jA26ycM/eI/omCfuPqAdFN1NPsBIlFOCqi2M3B7wsFE8zse4nc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 CF30E1063; Wed, 13 Mar 2024 23:00:22 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.53.138]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8EC683F73F; Wed, 13 Mar 2024 22:59:42 -0700 (PDT) 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 V7 06/11] coresight: funnel: Move ACPI support from AMBA driver to platform driver Date: Thu, 14 Mar 2024 11:28:38 +0530 Message-Id: <20240314055843.2625883-7-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240314055843.2625883-1-anshuman.khandual@arm.com> References: <20240314055843.2625883-1-anshuman.khandual@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. But first this refactors funnel_probe() making sure it can be used both for platform and AMBA drivers, by moving the pm_runtime_put() to the callers. 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 Tested-by: Sudeep Holla # Boot and driver probe only Acked-by: Sudeep Holla # For ACPI related changes Reviewed-by: James Clark Signed-off-by: Anshuman Khandual --- Changes in V7: - Dropped reduntant drvdata check in funnel_platform_remove() drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-funnel.c | 72 ++++++++++++------- 2 files changed, 48 insertions(+), 25 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 ff3ea0670a5b..616735dc80a6 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -36,6 +36,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel"); * struct funnel_drvdata - specifics associated to a funnel component * @base: memory mapped base address for this component. * @atclk: optional clock for the core parts of the funnel. + * @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework. * @priority: port selection order. * @spinlock: serialize enable/disable operations. @@ -43,6 +44,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 +238,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. @@ -272,12 +278,13 @@ static int funnel_probe(struct device *dev, struct resource *res) goto out_disable_clk; } - pm_runtime_put(dev); ret = 0; out_disable_clk: if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); + if (ret && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); return ret; } @@ -298,6 +305,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 +318,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,55 +328,61 @@ 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); - - if (ret) { - pm_runtime_put_noidle(&pdev->dev); + ret = funnel_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) pm_runtime_disable(&pdev->dev); - } return ret; } -static void static_funnel_remove(struct platform_device *pdev) +static void funnel_platform_remove(struct platform_device *pdev) { + struct funnel_drvdata *drvdata = dev_get_drvdata(&pdev->dev); + + if (WARN_ON(!drvdata)) + return; + funnel_remove(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (!IS_ERR_OR_NULL(drvdata->pclk)) + clk_put(drvdata->pclk); } -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, 0, 0}, +static const struct acpi_device_id funnel_acpi_ids[] = { + {"ARMHC9FE", 0, 0, 0}, /* ARM Coresight Static Funnel */ + {"ARMHC9FF", 0, 0, 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_new = static_funnel_remove, - .driver = { - .name = "coresight-static-funnel", +static struct platform_driver funnel_driver = { + .probe = funnel_platform_probe, + .remove_new = 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, }, @@ -373,7 +391,13 @@ static struct platform_driver static_funnel_driver = { static int dynamic_funnel_probe(struct amba_device *adev, const struct amba_id *id) { - return funnel_probe(&adev->dev, &adev->res); + int ret; + + ret = funnel_probe(&adev->dev, &adev->res); + if (!ret) + pm_runtime_put(&adev->dev); + + return ret; } static void dynamic_funnel_remove(struct amba_device *adev) @@ -410,12 +434,12 @@ static struct amba_driver dynamic_funnel_driver = { static int __init funnel_init(void) { - return coresight_init_driver("funnel", &dynamic_funnel_driver, &static_funnel_driver); + return coresight_init_driver("funnel", &dynamic_funnel_driver, &funnel_driver); } static void __exit funnel_exit(void) { - coresight_remove_driver(&dynamic_funnel_driver, &static_funnel_driver); + coresight_remove_driver(&dynamic_funnel_driver, &funnel_driver); } module_init(funnel_init); -- 2.25.1