All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 15/23] pci: tegra: Add Tegra PCIe driver
Date: Fri, 22 Aug 2014 17:24:55 +0200	[thread overview]
Message-ID: <20140822152453.GI15686@ulmo> (raw)
In-Reply-To: <53F4F136.7010708@wwwdotorg.org>

On Wed, Aug 20, 2014 at 01:04:22PM -0600, Stephen Warren wrote:
> On 08/18/2014 01:16 AM, Thierry Reding wrote:
> >From: Thierry Reding <treding@nvidia.com>
> >
> >Add support for the PCIe controller found on some generations of Tegra.
> >Tegra20 has 2 root ports with a total of 4 lanes, Tegra30 has 3 root
> >ports with a total of 6 lanes and Tegra124 has 2 root ports with a total
> >of 5 lanes.
> 
> >diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c
> 
> >+ * Copyright (c) 2010, CompuLab, Ltd.
> >+ * Author: Mike Rapoport <mike@compulab.co.il>
> >+ *
> >+ * Based on NVIDIA PCIe driver
> >+ * Copyright (c) 2008-2009, NVIDIA Corporation.
> 
> Presumably also at least (c) 2013-2014 NVIDIA too?

Yes.

> Do you have Mike's S-o-b for the initial work?

Yes, I can take it from the kernel's git log.

> >+static int tegra_pcie_read_conf(struct pci_controller *hose, pci_dev_t bdf,
> >+				int where, u32 *value)
> >+{
> >+	struct tegra_pcie *pcie = to_tegra_pcie(hose);
> >+	unsigned long address;
> >+	int err;
> >+
> >+	err = tegra_pcie_conf_address(pcie, bdf, where, &address);
> >+	if (err < 0) {
> >+		*value = 0xffffffff;
> >+		return 1;
> >+	}
> 
> In the kernel, don't we have to play games to dynamically map/unmap memory
> regions and/or map pages in a non-linear fashion since the config space is
> so large, and bus/device ID -> address mapping is odd? I don't see that
> here.

We do that in the kernel to avoid having to I/O remap a full 256 MiB of
memory even if only a single PCI bus is needed. Since memory is mapped
1:1 in U-Boot and we access physical memory "directly", we don't have to
worry about being wasteful. The tegra_pcie_conf_offset() function
computes the proper offset:

	static unsigned long tegra_pcie_conf_offset(pci_dev_t bdf, int where)
	{
		return ((where & 0xf00) << 16) | (PCI_BUS(bdf) << 16) |
		       (PCI_DEV(bdf) << 11) | (PCI_FUNC(bdf) << 8) |
		       (where & 0xfc);
	}

> >+static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port)
> >+{
> >+	unsigned int retries = 3;
> >+	unsigned long value;
> >+
> >+	value = rp_readl(port, RP_PRIV_MISC);
> >+	value &= ~RP_PRIV_MISC_PRSNT_MAP_EP_ABSNT;
> >+	value |= RP_PRIV_MISC_PRSNT_MAP_EP_PRSNT;
> >+	rp_writel(port, value, RP_PRIV_MISC);
> >+
> >+	do {
> >+		unsigned int timeout = 200;
> >+
> >+		do {
> >+			value = rp_readl(port, RP_VEND_XP);
> >+			if (value & RP_VEND_XP_DL_UP)
> >+				break;
> 
> On my board, this almost never succeeds for Jetson TK1's built-in NIC,
> although it works fine for the mini-PCIe slot. On the other two boards I
> borrowed, this succeeds almost always. I'd prefer if we could get to the
> bottom of this before we actually apply this, although the bug is proving
> quite perplexing. The mainline kernel PCIe patches have the same issue.

That's indeed odd. It's possible that the powergate fix that I've
applied (to wait for the partition to become powered) may improve
things. I'll be pushing out my latest work shortly (I don't think
I'll manage to send out the whole series for review, though), so
in case you get the chance you may want to test it.

> >+static int process_nodes(const void *fdt, int nodes[], unsigned int count)
> 
> >+#ifdef CONFIG_PCI_SCAN_SHOW
> >+		printf("PCI: Enumerating devices...\n");
> >+		printf("---------------------------------------\n");
> >+		printf("  Device        ID          Description\n");
> >+		printf("  ------        --          -----------\n");
> >+#endif
> >+
> >+		pcie->hose.last_busno = pci_hose_scan(&pcie->hose);
> 
> Shouldn't that ifdef'd block be part of pci_hose_scan()?

Every driver does it this way, but I agree that it should presumably go
in the core somewhere. I'll see if I can find a good place to do it.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140822/c0069960/attachment.pgp>

  reply	other threads:[~2014-08-22 15:24 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18  7:16 [U-Boot] [PATCH 00/23] ARM: tegra: Add PCIe support Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 01/23] fdt: Add functions to query a node's #address- and #size-cells Thierry Reding
2014-08-18 17:52   ` Simon Glass
2014-08-19 10:59     ` Thierry Reding
2014-08-19 12:52       ` Simon Glass
2014-08-19 13:06         ` Thierry Reding
2014-08-19 13:06           ` [U-Boot] " Thierry Reding
2014-08-23  3:03           ` Simon Glass
2014-08-23  3:03             ` [U-Boot] " Simon Glass
     [not found]             ` <CAPnjgZ06b3UeeXra5STLht15jU00yAKCwM+UYuqc=50Th9Jd_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-08-23 11:26               ` Thierry Reding
2014-08-23 11:26                 ` [U-Boot] " Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 02/23] fdt: Add a function to get the index of a string Thierry Reding
2014-08-18 17:58   ` Simon Glass
2014-08-19 11:13     ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 03/23] fdt: Add resource parsing functions Thierry Reding
2014-08-18 18:06   ` Simon Glass
2014-08-19 11:35     ` Thierry Reding
2014-08-19 12:55       ` Simon Glass
2014-08-19 13:12         ` Thierry Reding
2014-08-19 21:28           ` Simon Glass
2014-08-20  6:36             ` Thierry Reding
2014-08-20 14:05               ` Simon Glass
2014-08-18  7:16 ` [U-Boot] [PATCH 04/23] fdt: Add a function to return PCI BDF triplet Thierry Reding
2014-08-18 18:20   ` Simon Glass
2014-08-18  7:16 ` [U-Boot] [PATCH 05/23] fdt: Add a subnodes iterator macro Thierry Reding
2014-08-18 18:11   ` Simon Glass
2014-08-19 12:22     ` Thierry Reding
2014-08-19 12:57       ` Simon Glass
2014-08-19 13:12         ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 06/23] pci: Abort early if bus does not exist Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 07/23] pci: Honour pci_skip_dev() Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 08/23] Add pr_fmt() macro Thierry Reding
2014-08-18 18:24   ` Simon Glass
2014-08-19 12:27     ` Thierry Reding
2014-08-19 12:58       ` Simon Glass
2014-08-18  7:16 ` [U-Boot] [PATCH 09/23] ARM: tegra: Implement tegra_plle_enable() Thierry Reding
2014-08-20 18:12   ` Stephen Warren
2014-08-18  7:16 ` [U-Boot] [PATCH 10/23] ARM: tegra: Provide PCIEXCLK reset ID Thierry Reding
2014-08-20 18:20   ` Stephen Warren
2014-08-22 12:38     ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 11/23] ARM: tegra: Implement powergate support Thierry Reding
2014-08-20 18:24   ` Stephen Warren
2014-08-22 13:54     ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 12/23] ARM: tegra: Implement XUSB pad controller Thierry Reding
2014-08-20 18:32   ` Stephen Warren
2014-08-22 14:11     ` Thierry Reding
2014-08-22 14:38     ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 13/23] ARM: tegra: Add XUSB pad controller on Tegra124 Thierry Reding
2014-08-20 18:33   ` Stephen Warren
2014-08-18  7:16 ` [U-Boot] [PATCH 14/23] ARM: tegra: Enable XUSB pad controller on Jetson TK1 Thierry Reding
2014-08-20 18:34   ` Stephen Warren
2014-08-18  7:16 ` [U-Boot] [PATCH 15/23] pci: tegra: Add Tegra PCIe driver Thierry Reding
2014-08-20 19:04   ` Stephen Warren
2014-08-22 15:24     ` Thierry Reding [this message]
2014-08-22 17:33     ` Stephen Warren
2014-08-22 19:41       ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 16/23] ARM: tegra: Add Tegra20 PCIe device tree node Thierry Reding
2014-08-20 18:37   ` Stephen Warren
2014-08-18  7:16 ` [U-Boot] [PATCH 17/23] ARM: tegra: Enable PCIe on TrimSlice Thierry Reding
2014-08-20 18:38   ` Stephen Warren
2014-08-22 14:44     ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 18/23] ARM: tegra: Add Tegra30 PCIe device tree node Thierry Reding
2014-08-20 18:39   ` Stephen Warren
2014-08-22 14:51     ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 19/23] ARM: tegra: Enable PCIe on Beaver Thierry Reding
2014-08-19 13:48   ` Marcel Ziswiler
2014-08-20  6:38     ` Thierry Reding
2014-08-20  8:56       ` Marcel Ziswiler
2014-08-20  9:46         ` Thierry Reding
2014-08-20 13:13           ` Marcel Ziswiler
2014-08-20 18:43   ` Stephen Warren
2014-08-22 12:33     ` Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 20/23] ARM: tegra: Enable PCIe on Cardhu Thierry Reding
2014-08-18  7:16 ` [U-Boot] [PATCH 21/23] ARM: tegra: Add GIC for Tegra124 Thierry Reding
2014-08-20 18:45   ` Stephen Warren
2014-08-18  7:16 ` [U-Boot] [PATCH 22/23] ARM: tegra: Add Tegra124 PCIe device tree node Thierry Reding
2014-08-20 18:46   ` Stephen Warren
2014-08-18  7:16 ` [U-Boot] [PATCH 23/23] ARM: tegra: Enable PCIe on Jetson TK1 Thierry Reding
2014-08-18 18:37   ` Simon Glass
2014-08-19 12:29     ` Thierry Reding
2014-08-19 13:07       ` Simon Glass
2014-08-20 18:51   ` Stephen Warren
2014-08-22 12:09     ` Thierry Reding
2014-08-22 18:50       ` Stephen Warren
2014-08-22 19:27       ` Simon Glass
2014-08-22 19:40         ` Thierry Reding
2014-08-22 20:12           ` Simon Glass
2014-08-22 22:03             ` Thierry Reding
2014-08-23  1:47               ` Simon Glass
2014-08-23 11:33                 ` Thierry Reding
2014-08-20 18:54   ` Stephen Warren
2014-08-26 12:54   ` Tuomas Tynkkynen
2014-08-27 13:28     ` Thierry Reding
2014-08-27 14:34       ` Thierry Reding
2014-08-27 16:52         ` Tuomas Tynkkynen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140822152453.GI15686@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.