From patchwork Wed Jun 19 17:29:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11004913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 210F814DB for ; Wed, 19 Jun 2019 17:40:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09D062810E for ; Wed, 19 Jun 2019 17:40:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F13E12846C; Wed, 19 Jun 2019 17:40:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 641CC2810E for ; Wed, 19 Jun 2019 17:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UMsZ96JP3d8w1LCvPsQ1x6bs8TIkySqOzgk6l/WH4PY=; b=VrGkGlGxjBhwq571MHpxpX5sZq c/SEpQy0tAG7ocJzLTh0ozT+s395JWUraiT+/nwtNuLXwZGXUcZQsc4FkVVBR7tazjWPWKYyGSG35 3c3NfEZU08mRZok8HANra5Zjw6s95KDyWY/GauBKcyfasp1ntYnoLLBIeyLGgGu/o++z28qJ0U+LE 2wnpSVCWGZVTMHodsYJufGLrK6iOmV8osphNDYh0obC+j21OelD5MJ0l+i2gd/ZNWfYMfzRQpNanb M1CKon3kE/pH1ytVVK6l18xq4tAgvBqfCUqgWbLQ1JSKe8JtZF3NYKIHU/x40A1V0raCdiYeXnONO x1SvpbkA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hdeZG-0003XW-Fb; Wed, 19 Jun 2019 17:40:18 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hdePe-00007r-OX for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2019 17:30:29 +0000 Received: by mail-pl1-x642.google.com with SMTP id k8so99688plt.3 for ; Wed, 19 Jun 2019 10:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3eeHPEaBB7ibPeJGVTZBxrjCY9Q44woJ91BY0XbG0Qw=; b=PC6Mqnlfe+IGFJoho2q2hvurUCPsd7GTu7Bk6DYjliF+s5PVREROrFQtTRuSYiZ6s6 ePLQxWI8REQJU+xBffVM+vZuxABk1GWua5iouOBOuBNFQXE0j93luur6y0VVfmRR9QCr 1yRCeVydV8uwfmTLk3Lw9P0s/g8rM90x49UsVfsITQ9rvUTZbPNV73ge55XFc5/dRdpj lC6AlJFW0XkY4+gRJmKVESe6Jt+UC5NdGyFq+N4lSmjj55FN0NP4Sshih03yy7Vpg4yx F6bjJzFJ5pbC61BGlxacGgFHWFI+g+y92iVpgohocuJFjeFOjbVWnAMSnIKpx8fSPzfn 5QBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3eeHPEaBB7ibPeJGVTZBxrjCY9Q44woJ91BY0XbG0Qw=; b=T4TcICfZCjRwEVjuOOdCiXFpDCUFH9FhftB0ta4vAtssyWE9+q37zwmXyqJYpJ4joy yRVgPYs4ZX4r1Nikj2w+nIcJ+C2uLA6E1Q/NblG3pzXXeAO+MGiwKSabBHDheATfG9tI BhJ/xbYRIjkGPttxcGaaBVK+Okrovn3/HizsStEAYK3FUnxFZd03s/RZax+LiX886jSS ORjM5a/Gpd1GMrNaJHMEKz9/sViuTMGX30JD4CsbcuGU14hUdGaFU/DZ9I+GrKN28BUk cs8Kwn/EFTsR6h0lwtvsnbw8YZQFYgsppT7eq9jyqz1OX+etcE0eH8BznJxD5iL8hjrF 3i/Q== X-Gm-Message-State: APjAAAXZEUEKcd1v1j3yORaLKpi1oDMiW/QI8we/IXbkBWwNb8EWjkj+ HLXuy1aioWE00Iu73wA2C7G/RA== X-Google-Smtp-Source: APXvYqzJd+LEwjPQQBAjtrcJVCHtg/1eH6CQB3XJj7f9G9RkGVHFwfLWTEkVkxc9fdee/rMhRp1mhA== X-Received: by 2002:a17:902:aa8a:: with SMTP id d10mr83675207plr.159.1560965421449; Wed, 19 Jun 2019 10:30:21 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g2sm31348406pfb.95.2019.06.19.10.30.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 10:30:20 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 32/45] coresight: stm: ACPI support for parsing stimulus base Date: Wed, 19 Jun 2019 11:29:36 -0600 Message-Id: <20190619172949.4522-33-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190619172949.4522-1-mathieu.poirier@linaro.org> References: <20190619172949.4522-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190619_103022_889283_DC955B3D X-CRM114-Status: GOOD ( 14.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Suzuki K Poulose 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" Signed-off-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-stm.c | 53 ++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index e3e2b000cfb7..b908ca104645 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; }