From patchwork Tue Feb 9 14:52:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 8262461 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B3BDCBEEE5 for ; Tue, 9 Feb 2016 14:52:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1D192027D for ; Tue, 9 Feb 2016 14:52:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D64D420268 for ; Tue, 9 Feb 2016 14:52:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754161AbcBIOwi (ORCPT ); Tue, 9 Feb 2016 09:52:38 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37524 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005AbcBIOwh (ORCPT ); Tue, 9 Feb 2016 09:52:37 -0500 Received: by mail-wm0-f51.google.com with SMTP id g62so26763468wme.0; Tue, 09 Feb 2016 06:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iLwDuJnD/rYOd/QM0Qz5iZNr6+UxTEDyk6LiP3RInzc=; b=B82DsuUHcuoJUIxPjwL7xhoj6hVWxjd8WYPiYgD7IElQ4xQLJ1P88utmZlZmyhDHj3 itbI/c3EiT6XY1kYBbDppNj6dOfyFL/B7Ofm83S/6eCcKw5PH/DCd/VIU3qUqNRLCH15 4cFZEKSpMN7THSuIXeQ8EzQa0/+fB9NjeLh1YjTiNikTtGbipPwdI91hbnLWmQbUaCCg AvrTQUMbarmYICTCl7RxC2A89Y6iBrj2qmPp2EEwEe1z38uCHkAg0S5f8C+U6Rsdh1r7 5TgTNPK7gcshSdTHypX7rbHuoRqosHiOTkl5Q7B6mM3uCavcizpSsSpu2xqEYh3t05RF wdCg== 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=iLwDuJnD/rYOd/QM0Qz5iZNr6+UxTEDyk6LiP3RInzc=; b=e86pYFvnhwtYg1Zo0ptuxmoh/S1gDOgsndFIGtt38DkN2rYPAZe747DI29kD5yBJ2q ZpHql5iax3mRjCR0h8hx2g0bi3KUUmm2v2DeyD+iv3xIL6HARCSgZJ1AZYsDLA/w1PN7 6gsLvrQL2fzUKuRMizVBEyjXBQv1SReB6Y5Y9nYN7MftgbWUhFjuJWXmxzZ8qX4jXUOJ 9YAZWW5AQLIwyZrx5nh3J96rKg+un4dIIAvLO9j7kfO/Qar3NkOJuPpaHQ47YSWLrfO4 vicAcVh28bjIsBjndT/VoMH1TO8t3YOSnjx+aHqBnASxcXMIOFIXXgcBJrvXJ/W8QemQ EoOg== X-Gm-Message-State: AG10YOQMDxERObSxrkI+NthroRYCIDWxZM3NIzuqh2t7Y1xDDzVTA5GjDvVFByDr/hv7FQ== X-Received: by 10.194.246.37 with SMTP id xt5mr34520190wjc.7.1455029556149; Tue, 09 Feb 2016 06:52:36 -0800 (PST) Received: from localhost (port-17172.pppoe.wtnet.de. [46.59.128.173]) by smtp.gmail.com with ESMTPSA id h8sm35137636wjw.6.2016.02.09.06.52.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 06:52:35 -0800 (PST) From: Thierry Reding To: Bjorn Helgaas Cc: Stephen Warren , Alexandre Courbot , linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 2/3] PCI: tegra: Track bus -> CPU mapping Date: Tue, 9 Feb 2016 15:52:32 +0100 Message-Id: <1455029553-9460-2-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1455029553-9460-1-git-send-email-thierry.reding@gmail.com> References: <1455029553-9460-1-git-send-email-thierry.reding@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Track the offsets of the bus -> CPU mapping for I/O and memory. This is cosmetic for current Tegra chips because the offset is always 0. But to properly support legacy use-cases, like VGA, this would be needed so that PCI bus addresses can be relocated. While at it, also request the I/O resource both in physical memory and I/O space to make /proc/iomem consistent, as well as add the I/O region to the list of host bridge resources. Signed-off-by: Thierry Reding --- drivers/pci/host/pci-tegra.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c index 82d7ad3a1c3a..f6fc54b48606 100644 --- a/drivers/pci/host/pci-tegra.c +++ b/drivers/pci/host/pci-tegra.c @@ -281,6 +281,11 @@ struct tegra_pcie { struct resource prefetch; struct resource busn; + struct { + resource_size_t mem; + resource_size_t io; + } offset; + struct clk *pex_clk; struct clk *afi_clk; struct clk *pll_e; @@ -614,6 +619,17 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys) struct tegra_pcie *pcie = sys_to_pcie(sys); int err; + sys->mem_offset = pcie->offset.mem; + sys->io_offset = pcie->offset.io; + + err = devm_request_resource(pcie->dev, &pcie->all, &pcie->io); + if (err < 0) + return err; + + err = devm_request_resource(pcie->dev, &ioport_resource, &pcie->pio); + if (err < 0) + return err; + err = devm_request_resource(pcie->dev, &pcie->all, &pcie->mem); if (err < 0) return err; @@ -622,6 +638,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys) if (err) return err; + pci_add_resource_offset(&sys->resources, &pcie->pio, sys->io_offset); pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset); pci_add_resource_offset(&sys->resources, &pcie->prefetch, sys->mem_offset); @@ -1729,6 +1746,9 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) switch (res.flags & IORESOURCE_TYPE_BITS) { case IORESOURCE_IO: + /* Track the bus -> CPU I/O mapping offset. */ + pcie->offset.io = res.start - range.pci_addr; + memcpy(&pcie->pio, &res, sizeof(res)); pcie->pio.name = np->full_name; @@ -1749,6 +1769,14 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) break; case IORESOURCE_MEM: + /* + * Track the bus -> CPU memory mapping offset. This + * assumes that the prefetchable and non-prefetchable + * regions will be the last of type IORESOURCE_MEM in + * the ranges property. + * */ + pcie->offset.mem = res.start - range.pci_addr; + if (res.flags & IORESOURCE_PREFETCH) { memcpy(&pcie->prefetch, &res, sizeof(res)); pcie->prefetch.name = "prefetchable";