From patchwork Wed Mar 20 18:49:40 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: 160713 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp626063jan; Wed, 20 Mar 2019 11:50:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvkSMnVq3LR+s5EsYwN/ZDYXOc9MyZ3fqB4Cg85Ax0PIRKgPNYYCwP4mxXaX5HfljuGkOY X-Received: by 2002:a63:d4f:: with SMTP id 15mr8818456pgn.162.1553107853891; Wed, 20 Mar 2019 11:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553107853; cv=none; d=google.com; s=arc-20160816; b=ixMiRnwUlw9ZnML6tekVq008+W3WfW/OStG1ajY3CbAeADrP5RoWyX/8NHKOe6esP3 8E6a0Ovxe/pfFak+qvEjAmWXVE40Y/VSLBCnWT1m8fkBFOe4OEKbkJq4NlmiBzUei5VP O4L/OE1FZ9B5ZML5JKzawsTjIajqczGvnsm9y1brlw8mrNQ5LSQv/1uhQWBICSP+HRYM jXOZlH5LOthDmIxkEd0KmKGdS9gmqbJ2th27RMNLmo+2GQ+F/RvDj0kkFYw5H02aci3N EQ7+9+VOJquzOwNaFpUNiPL3N3lkjPoJJGVzXZR1tm9ZDECNBoeySSljFmQNxQRdhMjQ ff9Q== 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=mh91yunodMV/wO59NXNy3f12yaXyNLtubruvJGoQ9LA=; b=tJyayJaxakMRWEhT+BzPzHgz2yC5unzsbGra7TVmnSPR59T6wtId6fJ7cj93MxbDGU KQk1VjncrZ8qLds5M2NIJ2XIWvz8QIWWg7seSiXSJ2R1YMoDZZK5ZXyyLI5CTrvE5Vpq aNsSF0K3b5RAf6ehyofmvYSl7Ytl+FVboLOlh2faxRWMklr8lgogvjpl7zTPqzrlLrtT IRD09J7IN201cbAQo4PUbhpCa/3GSmddrrnu18LwBJTFWWDXWoa8+fqIckKG+8uwUWie N7++iTScnC5T4Wn3qDTh3bTbMl0r7DiQ2pY+xqMAMVaiidYv7gqZNV8Rq+FaqPKK2ymF JJ7Q== 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 d11si2367991pls.255.2019.03.20.11.50.53; Wed, 20 Mar 2019 11:50:53 -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 S1727710AbfCTSuw (ORCPT + 31 others); Wed, 20 Mar 2019 14:50:52 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45046 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727696AbfCTSuu (ORCPT ); Wed, 20 Mar 2019 14:50:50 -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 9D0161A25; Wed, 20 Mar 2019 11:50:49 -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 F41563F59C; Wed, 20 Mar 2019 11:50:47 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, coresight@lists.linaro.org, mike.leach@linaro.org, robert.walker@arm.com, Suzuki K Poulose , Mathieu Poirier , "Rafael J. Wysocki" Subject: [PATCH 23/25] coresight: stm: ACPI support for parsing stimulus base Date: Wed, 20 Mar 2019 18:49:40 +0000 Message-Id: <1553107783-3340-24-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553107783-3340-1-git-send-email-suzuki.poulose@arm.com> References: <1553107783-3340-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. 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 diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index d94ae22..995443a 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 @@ -717,10 +718,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; }