From patchwork Fri Sep 9 19:24:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 668204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sW6cx1tQGz9s4n for ; Sat, 10 Sep 2016 05:26:09 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b=d2eZWf8D; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753232AbcIIT0G (ORCPT ); Fri, 9 Sep 2016 15:26:06 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:33191 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752196AbcIITYw (ORCPT ); Fri, 9 Sep 2016 15:24:52 -0400 Received: by mail-lf0-f54.google.com with SMTP id h127so51017087lfh.0 for ; Fri, 09 Sep 2016 12:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TZrjiThXm5poE/qjDNQw5yS2rK3DvU+Y3bpPk1YD2Gs=; b=d2eZWf8DaD6ubyQOj+jmKakQX5RQN/eVEVNbGK6MYUbjDTlYpjGM/eBiRj/QccuAUV iLUKHXVnjTgTneD1Ea/8xVwQ479szftQkyrToHYLHvDtlcw3Qa0lmK1AUBuRbtCVYvqI kt/MsLi5m4XhQUmAV6KRUKGqmMGTuvO/qWgPeL2gGKtFOb73c+D6rDg2JBQgkOZ0fMEG ygkQt466KCnJvqOREwluCbSlLP71+0I2QoiL804hDRC++RxEx+5aE7s7jY03jb3JXyAf NIZuRPdAbbsYRLHUgX7g6xFwSYUu3+WumK+c7TWhnXsavFej/wRnwFmqKWYNjbonzare ZoZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TZrjiThXm5poE/qjDNQw5yS2rK3DvU+Y3bpPk1YD2Gs=; b=cGPoRlvt5MUMZA7ISQBBdMX2IHzGSTQdUo3JLgeTzTlbr562SKN5T5ibenk5YL84rT GgDD4Tcntc/m5ha2vDbzRXXxBVM1tpuCEKKPUTwRKIDAGKAwn5NwF6tpzqDifvhm84kj spnZtW8CeqWfNBiqHNqG+uuA4Ohg0xNKkILueRjm1A0crOJJhhTH1Ukb5HqmvayQSpny u3CNonZa5FwXjZ4MAd4F+buC4OOToonIPHdVFvlpZFaPh74IcBXo8vs7fUStLw7WOrg4 6fV7HZjrt/Bvdkw+pX3YOyyNKBz2ucrucZp9lDWkrvWM0t6g/AtzRcWkT1tccJXs9mfD q9aQ== X-Gm-Message-State: AE9vXwPBd4GHeCatMmbvgg7+vyDtn6LfHvPKMYzjUn5p8k9LgQDbAONSN/W3aXgkHX04Xg== X-Received: by 10.25.74.207 with SMTP id x198mr1940494lfa.12.1473449090183; Fri, 09 Sep 2016 12:24:50 -0700 (PDT) Received: from localhost.localdomain (bbservice74.mmpnet215.tnp.pl. [87.116.215.74]) by smtp.gmail.com with ESMTPSA id 143sm846673ljj.2.2016.09.09.12.24.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Sep 2016 12:24:49 -0700 (PDT) From: Tomasz Nowicki To: helgaas@kernel.org, will.deacon@arm.com, catalin.marinas@arm.com, rafael@kernel.org, Lorenzo.Pieralisi@arm.com Cc: arnd@arndb.de, hanjun.guo@linaro.org, okaya@codeaurora.org, jchandra@broadcom.com, cov@codeaurora.org, dhdang@apm.com, ard.biesheuvel@linaro.org, robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, wangyijing@huawei.com, msalter@redhat.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-acpi@lists.linaro.org, jcm@redhat.com, andrea.gallo@linaro.org, jeremy.linton@arm.com, liudongdong3@huawei.com, gabriele.paoloni@huawei.com, jhugo@codeaurora.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Tomasz Nowicki Subject: [PATCH V6 3/5] PCI: thunder-pem: Allow to probe PEM-specific register range for ACPI case Date: Fri, 9 Sep 2016 21:24:05 +0200 Message-Id: <1473449047-10499-4-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473449047-10499-1-git-send-email-tn@semihalf.com> References: <1473449047-10499-1-git-send-email-tn@semihalf.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org thunder-pem driver stands for being ACPI based PCI host controller. However, there is no standard way to describe its PEM-specific register ranges in ACPI tables. Thus we add thunder_pem_init() ACPI extension to obtain hardcoded addresses from static resource array. Although it is not pretty, it prevents from creating standard mechanism to handle similar cases in future. Signed-off-by: Tomasz Nowicki --- drivers/pci/host/pci-thunder-pem.c | 61 ++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/drivers/pci/host/pci-thunder-pem.c b/drivers/pci/host/pci-thunder-pem.c index 6abaf80..b048761 100644 --- a/drivers/pci/host/pci-thunder-pem.c +++ b/drivers/pci/host/pci-thunder-pem.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -284,6 +285,40 @@ static int thunder_pem_config_write(struct pci_bus *bus, unsigned int devfn, return pci_generic_config_write(bus, devfn, where, size, val); } +#ifdef CONFIG_ACPI +static struct resource thunder_pem_reg_res[] = { + [4] = DEFINE_RES_MEM(0x87e0c0000000UL, SZ_16M), + [5] = DEFINE_RES_MEM(0x87e0c1000000UL, SZ_16M), + [6] = DEFINE_RES_MEM(0x87e0c2000000UL, SZ_16M), + [7] = DEFINE_RES_MEM(0x87e0c3000000UL, SZ_16M), + [8] = DEFINE_RES_MEM(0x87e0c4000000UL, SZ_16M), + [9] = DEFINE_RES_MEM(0x87e0c5000000UL, SZ_16M), + [14] = DEFINE_RES_MEM(0x97e0c0000000UL, SZ_16M), + [15] = DEFINE_RES_MEM(0x97e0c1000000UL, SZ_16M), + [16] = DEFINE_RES_MEM(0x97e0c2000000UL, SZ_16M), + [17] = DEFINE_RES_MEM(0x97e0c3000000UL, SZ_16M), + [18] = DEFINE_RES_MEM(0x97e0c4000000UL, SZ_16M), + [19] = DEFINE_RES_MEM(0x97e0c5000000UL, SZ_16M), +}; + +static struct resource *thunder_pem_acpi_res(struct pci_config_window *cfg) +{ + struct acpi_device *adev = to_acpi_device(cfg->parent); + struct acpi_pci_root *root = acpi_driver_data(adev); + + if ((root->segment >= 4 && root->segment <= 9) || + (root->segment >= 14 && root->segment <= 19)) + return &thunder_pem_reg_res[root->segment]; + + return NULL; +} +#else +static struct resource *thunder_pem_acpi_res(struct pci_config_window *cfg) +{ + return NULL; +} +#endif + static int thunder_pem_init(struct pci_config_window *cfg) { struct device *dev = cfg->parent; @@ -292,24 +327,24 @@ static int thunder_pem_init(struct pci_config_window *cfg) struct thunder_pem_pci *pem_pci; struct platform_device *pdev; - /* Only OF support for now */ - if (!dev->of_node) - return -EINVAL; - pem_pci = devm_kzalloc(dev, sizeof(*pem_pci), GFP_KERNEL); if (!pem_pci) return -ENOMEM; - pdev = to_platform_device(dev); - - /* - * The second register range is the PEM bridge to the PCIe - * bus. It has a different config access method than those - * devices behind the bridge. - */ - res_pem = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (acpi_disabled) { + pdev = to_platform_device(dev); + + /* + * The second register range is the PEM bridge to the PCIe + * bus. It has a different config access method than those + * devices behind the bridge. + */ + res_pem = platform_get_resource(pdev, IORESOURCE_MEM, 1); + } else { + res_pem = thunder_pem_acpi_res(cfg); + } if (!res_pem) { - dev_err(dev, "missing \"reg[1]\"property\n"); + dev_err(dev, "missing configuration region\n"); return -EINVAL; }