From patchwork Wed May 22 10:35:00 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: 164793 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp694374ili; Wed, 22 May 2019 03:36:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLfHV5bmtR60EMPKnhpX1ZU/hE9YoKWfaeSDnwrpF0sKoyZh8URJ5ID4ZFh+UBA6fYajhJ X-Received: by 2002:a65:640c:: with SMTP id a12mr26568131pgv.1.1558521377633; Wed, 22 May 2019 03:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558521377; cv=none; d=google.com; s=arc-20160816; b=EnDJ1dOD9+gt2ireitRwRbJbVR7zCfgs42gLnDEuAeZOxX9LEw6H1/V8J6Sj8MBE3t Mf8X/JSU+xuiN49KTLMH/BHQCLjL/ODx2JOc7PzA2KhyvOzxNhNdiGcFl9QnAmC7xHPI +gV1xwKrhn6Xk7dAH9WIoMHb1zAgcJE20xY/ughQL/VCKNF55icK65hYVesGYWrNo1N4 KQxmuzU+3G7lj7ayfjpuNBKTGjjquEeInnChIa4Xm/CZNMSjoPYkRyACUOyNDzYnXhN1 IkKWxET988eGBxpqCHvRO5NWlZESarIhqATG3TC+H1Xo2WcZ0l1poGhHM/BUCVdhd5wz l5Bg== 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=k9cFnUeB7z48IZAQRawgI0j0myO3LRulY7CnweJuCP1rW8LnOtYZdIV9V0VXl5CqDc 4wi5+gXbbdgtqaT8DAr+ihx/f37Hr7yWw0ixsASi2oyVrdoik1zha6x0c+96t4nsJL08 yWTXibTZYcJnwyjKcroGFpAMPaXl7JoWnTVjCwZnFUboz1xM6M/r+fUk9btdfOaLN2s4 MfAlXbFd8vh2m6V0H+rg1BqLDWyETB3F2RfkisC0+yoNAqYnvSNp4+s6Zs2x4tcmhRKg H4qHh6/oD24fcb6V84zWVU6uDQiQc2f9fwfIsrp+EDJ1BxMulhaNzpSvKNHsiVR60fbh 2LIg== 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 h68si25312309pgc.270.2019.05.22.03.36.17; Wed, 22 May 2019 03:36: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 S1729557AbfEVKgQ (ORCPT + 30 others); Wed, 22 May 2019 06:36:16 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47212 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729465AbfEVKfy (ORCPT ); Wed, 22 May 2019 06:35:54 -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 A28EE1682; Wed, 22 May 2019 03:35:53 -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 6B7B53F575; Wed, 22 May 2019 03:35:52 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, Suzuki K Poulose , "Rafael J. Wysocki" Subject: [PATCH v4 27/30] coresight: stm: ACPI support for parsing stimulus base Date: Wed, 22 May 2019 11:35:00 +0100 Message-Id: <1558521304-27469-28-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558521304-27469-1-git-send-email-suzuki.poulose@arm.com> References: <1558521304-27469-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; }