From patchwork Tue May 7 10:52:54 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: 163497 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp1184269ilm; Tue, 7 May 2019 03:54:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyN3iCxrAIUGcXwHzkcLLY6JQIvveTCbCp67J0pefBT6ligDevm3PUa8Iervz+GWeuf6kUy X-Received: by 2002:a17:902:a510:: with SMTP id s16mr14434010plq.334.1557226467614; Tue, 07 May 2019 03:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557226467; cv=none; d=google.com; s=arc-20160816; b=gN3yLDVHtvv373CIprUlSKs4ncrIzB9nSVKxqTNbpl464iUsZwfMZYplTw1jSybHxs mGpUJsZ6b+Mwm7QWJFbhvYRZpk25va03pkPLpwZZedBdFcN/utpa5KWdgqVn8/XWpK/j YKY6JkAS3j/y0/Pl/a6esk77J5xkCDxIbaqYFX0SXtf/cn/T+zj9W5+W4Y/NeTqIgPp6 3F/t1WtchCArxgY2+ussE/uX/2prr+sNqmR15cS3f/l6B/a0EvBQJ3+SH0SGm9eV2sUr 7MrfKN8Omt3cG0ck0L0VFiZLAYTXV8cwV3AIaa4pwJlVyucZ4DRk8Z3+p2idKE2fiyQS PFOw== 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=NCyuNN91eyq3p16fEKhHU5Ruy1hfNlzd7uEkN5j0Wac=; b=iIiWhRvl/rtSDALfvSRLpd1GNhBC45rwDe4SCV5Z2Ea2Za0dkPHlESnjoUC7dkimNw +dlLzkAvWTbIXC5zd0EEw4QC4ckBkJD0emTLf/ORbLKP0MQRq7ug/EMm+215dOCdGaSd cge5+KOxJeNkq4oY+oBvZmMu16IlFRuGExwD7gjZpDkCeU027iEws7KOnNpxHSUr/dHI KPNMEYkbepxqnTEJn5MHVrCt5b65xwphT9ws8X73PPj0YH8xOU17LgUeVpP3o9yti1K1 nGfrfxVTHtdp+PtGsijBrccTWK7btIorilIYyNV3Zv07h0WrZx2T3OscKjVgpf7EWR6H hHaQ== 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 y29si19428379pgk.120.2019.05.07.03.54.27; Tue, 07 May 2019 03:54:27 -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 S1727279AbfEGKy0 (ORCPT + 30 others); Tue, 7 May 2019 06:54:26 -0400 Received: from foss.arm.com ([217.140.101.70]:50348 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727237AbfEGKyU (ORCPT ); Tue, 7 May 2019 06:54:20 -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 7F0751688; Tue, 7 May 2019 03:54:20 -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 4BB5D3F5AF; Tue, 7 May 2019 03:54:19 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, rjw@rjwysocki.net, mathieu.poirier@linaro.org, Suzuki K Poulose Subject: [PATCH v3 27/30] coresight: stm: ACPI support for parsing stimulus base Date: Tue, 7 May 2019 11:52:54 +0100 Message-Id: <1557226378-10131-28-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557226378-10131-1-git-send-email-suzuki.poulose@arm.com> References: <1557226378-10131-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: "Rafael J. Wysocki" Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-stm.c | 53 ++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index e3e2b00..b908ca1 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,60 @@ 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; + + /* + * 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 + * document (DEN0067). + */ + 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 (is_of_node(dev_fwnode(dev))) + struct fwnode_handle *fwnode = dev_fwnode(dev); + + if (is_of_node(fwnode)) return of_stm_get_stimulus_area(dev, res); + else if (is_acpi_node(fwnode)) + return acpi_stm_get_stimulus_area(dev, res); return -ENOENT; }