From patchwork Mon Apr 15 16:04:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 162221 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3106779jan; Mon, 15 Apr 2019 09:07:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtS7WAW5rCCLm3Dy9iaRMW7hQ+GJkT3PcCepAhMVQaQUDxPIWYq73xls+hRk2WXmxEupuB X-Received: by 2002:a62:b418:: with SMTP id h24mr75998039pfn.145.1555344437135; Mon, 15 Apr 2019 09:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555344437; cv=none; d=google.com; s=arc-20160816; b=H9VgD4NEzd4sTmn9gGpTjCRcwv116XPeoDaxp/DQoD0EAkYmijcX5L3nqa9RdKB5Cp aq3GsNLjF5J8vbzieTIVrHaHaQWuzqctWLpDOgFxdp1Ffsa2YPmLhwdPWDUSTCsLJquR dgASJxQE6D9tpdYM3+A+cb8NA3/E/F5llH5T/kBV5HYHL2sHrC1ii2DbmeKtGK7XK7pA HVuUloDLrdTw9epibrOW5WNVNwJFi+vh22YCxYtWDZ2PUqZwU8RxXfYAHLej3ArULw/N UJ00dNzwL915ShJwsqebRRspJQo6KreyDRcNiKjAbg+xV9aVu3Whg90AZGYd1u4u7np5 ajxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=k9/IqUhzBEf1EbTGCam7SdG7m9maqbNvmh0adI5FB4M=; b=kGrdtZLUtaKnFXIQfWBKMwRtdFvwjC6mFnRKyK2n5OwOCrmtrjPXSzrwD5Wg2QLdZd AVxiqTncoqH1Fl8ePMIWT+mFmGfRSOU9ojLJ0ngBQBuW8ePiP7gzjZHstM5aYBM8jVfF a0/KR7NTQYlBZN5Wb368/Z7LWIf3H1orlgw8HGR0E408jPQsWHzshzbczcl2bPSozT0/ kX7K6pzf4aNlPp9E48ebRe92qUd1/7/6ZK/+Rpw34FoN5dJ1p7olWNme9irRdCRZKGv9 sh1BlPKf5Sy5sTHC3OPobq6Woy8Wa7FqA6E592YlDEXe6yDs0lTujfO3n2Rhq1P4VIm2 6U2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si43694144pgp.239.2019.04.15.09.07.16; Mon, 15 Apr 2019 09:07:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728121AbfDOQGo (ORCPT + 30 others); Mon, 15 Apr 2019 12:06:44 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38056 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728092AbfDOQGj (ORCPT ); Mon, 15 Apr 2019 12:06:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 792611AC1; Mon, 15 Apr 2019 09:06:39 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F37C43F68F; Mon, 15 Apr 2019 09:06:37 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org, mike.leach@linaro.org, rjw@rjwysocki.net, robert.walker@arm.com, Suzuki K Poulose Subject: [PATCH v2 31/36] coresight: stm: ACPI support for parsing stimulus base Date: Mon, 15 Apr 2019 17:04:14 +0100 Message-Id: <1555344260-12375-32-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> References: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The stimulus base for STM device must be listed as the second memory resource, followed by the programming base address as described in "Section 2.3 Resources" in ACPI for CoreSightTM 1.0 Platform Design documen (DEN0067). Add support for parsing the information for ACPI. Cc: Mathieu Poirier Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-stm.c | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.7.4 Reviewed-by: Mathieu Poirier diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 2d6ae00..7cf2fe4 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -16,6 +16,7 @@ * (C) 2015-2016 Chunyan Zhang */ #include +#include #include #include #include @@ -716,10 +717,52 @@ static inline int of_stm_get_stimulus_area(struct device *dev, } #endif +#ifdef CONFIG_ACPI +static int acpi_stm_get_stimulus_area(struct device *dev, struct resource *res) +{ + int rc; + bool found_base = false; + struct resource_entry *rent; + LIST_HEAD(res_list); + + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return -ENODEV; + rc = acpi_dev_get_resources(adev, &res_list, NULL, NULL); + if (rc < 0) + return rc; + + rc = -ENOENT; + list_for_each_entry(rent, &res_list, node) { + if (resource_type(rent->res) != IORESOURCE_MEM) + continue; + if (found_base) { + *res = *rent->res; + rc = 0; + break; + } + + found_base = true; + } + + acpi_dev_free_resource_list(&res_list); + return rc; +} +#else +static inline int acpi_stm_get_stimulus_area(struct device *dev, + struct resource *res) +{ + return -ENOENT; +} +#endif + static int stm_get_stimulus_area(struct device *dev, struct resource *res) { if (dev->of_node) return of_stm_get_stimulus_area(dev, res); + else if (is_acpi_node(dev->fwnode)) + return acpi_stm_get_stimulus_area(dev, res); return -ENOENT; }