PCI: tegra: Fixes and Tegra124 support
Subsystems (6)
v3 cover PCI: tegra: Fixes and Tegra124 support
From: Thierry Reding <[email protected]>
This series implements various fixes and adds support for Tegra124 to the Tegra PCIe controller driver.
Patches 1 and 2 were already sent out separately earlier on but haven't been applied yet, so I'm including them here for convenience.
Patches 3 to 5 are various fixes that should make the driver more reliable, though they don't (except maybe for patch 4) fix any known issues.
Patch 6 finally adds support for Tegra124.
Thierry
Eric Yuen (1):
PCI: tegra: Make sure the PCIe PLL is really reset
Peter Daifuku (1):
PCI: tegra: Fix extended configuration space mapping
Thierry Reding (4):
resource: Add device-managed request/release_resource()
PCI: tegra: Implement a proper resource hierarchy
PCI: tegra: Clear CLKREQ# enable on port disable
PCI: tegra: Add Tegra124 support
.../bindings/pci/nvidia,tegra20-pcie.txt | 25 +- Documentation/driver-model/devres.txt | 2 + drivers/pci/host/pci-tegra.c | 257 ++++++++++++++++++--- include/linux/ioport.h | 5 + kernel/resource.c | 70 ++++++ 5 files changed, 323 insertions(+), 36 deletions(-)
Signature · 1 line
2.0.4
PATCH v3 1/6 resource: Add device-managed request/release_resource()
From: Thierry Reding <[email protected]>
Provide device-managed implementations of the request_resource() and release_resource() functions. Upon failure to request a resource, the new devm_request_resource() function will output an error message for consistent error reporting.
---
Changes in v2:
- use more natural flow for error handling
- don't needlessly check for NULL pointers
Documentation/driver-model/devres.txt | 2 + include/linux/ioport.h | 5 +++ kernel/resource.c | 70 +++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+)
Documentation/driver-model/devres.txt +2 -0
@@ -264,8 +264,10 @@ IIO IO region devm_release_mem_region() devm_release_region() + devm_release_resource() devm_request_mem_region() devm_request_region() + devm_request_resource() IOMAP devm_ioport_map()
include/linux/ioport.h +5 -0
@@ -215,6 +215,11 @@ static inline int __deprecated check_region(resource_size_t s,/* Wrappers for managed devices */ struct device ; + +extern int devm_request_resource (struct device *dev,struct resource *root, +struct resource *new); +extern void devm_release_resource (struct device *dev,struct resource *new); +#define devm_request_region (dev,start,n,name) \ __devm_request_region(dev, &ioport_resource, (start), (n), (name))#define devm_request_mem_region (dev,start,n,name) \
kernel/resource.c +70 -0
76 lines not on this page · raw message
Signature · 1 line
2.0.4
Re: [PATCH v3 1/6] resource: Add device-managed request/release_resource()
Quoted 6 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Provide device-managed implementations of the
request_resource()andrelease_resource()functions. Upon failure to request a resource, the newdevm_request_resource()function will output an error message for consistent error reporting.
The series,
PATCH v3 2/6 PCI: tegra: Implement a proper resource hierarchy
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Currently the resource hierarchy generated from the PCIe host bridge is completely flat:
$ cat /proc/iomem 00000000-00000fff : /pcie-controller@00003000/pci@1,0 00003000-000037ff : pads 00003800-000039ff : afi 10000000-1fffffff : cs 28000000-28003fff : r8169 28004000-28004fff : r8169 ...
The host bridge driver doesn't request all the resources that are used. Windows allocated to each of the root ports aren't tracked, so there is no way for resources allocated to individual devices to be matched up with the correct parent resource by the PCI core.
This patch addresses this in two steps. It first takes the union of all regions associated with the PCIe host bridge (control registers, root port registers, configuration space, I/O and prefetchable as well as non-prefetchable memory regions) and uses it as the new root of the resource hierarchy.
Subsequently, regions are allocated from within this new root resource so that the resource tree looks much more like what's expected:
# cat /proc/iomem 00000000-3fffffff : /pcie-controller@00003000 00000000-00000fff : /pcie-controller@00003000/pci@1,0 00003000-000037ff : pads 00003800-000039ff : afi 10000000-1fffffff : cs 20000000-27ffffff : non-prefetchable 28000000-3fffffff : prefetchable 28000000-280fffff : PCI Bus 0000:01 28000000-28003fff : 0000:01:00.0 28000000-28003fff : r8169 28004000-28004fff : 0000:01:00.0 28004000-28004fff : r8169 ...
--- drivers/pci/host/pci-tegra.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
drivers/pci/host/pci-tegra.c +29 -3
@@ -253,6 +253,7 @@ struct tegra_pcie {struct list_head buses;struct resource *cs; +struct resource all;struct resource io;struct resource mem;struct resource prefetch;
@@ -626,6 +627,15 @@ DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_relax_enable);static int tegra_pcie_setup (int nr,struct pci_sys_data *sys) {struct tegra_pcie *pcie =sys_to_pcie (sys); +int err; + + err =devm_request_resource (pcie->dev, &pcie->all, &pcie->mem); +if (err <0 ) +return err; + + err =devm_request_resource (pcie->dev, &pcie->all, &pcie->prefetch); +if (err) +return err;pci_add_resource_offset (&sys->resources, &pcie->mem, sys->mem_offset); pci_add_resource_offset(&sys->resources, &pcie->prefetch,
@@ -1514,6 +1524,12 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)struct resource res;int err; +memset (&pcie->all,0 ,sizeof (pcie->all)); + pcie->all.flags =IORESOURCE_MEM ; + pcie->all.name = np->full_name; + pcie->all.start = ~0 ; + pcie->all.end =0 ; +if (of_pci_range_parser_init (&parser, np)) {dev_err (pcie->dev,"missing \"ranges\" property\n" );return -EINVAL ;
@@ -1525,21 +1541,31 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)switch (res.flags &IORESOURCE_TYPE_BITS ) {case IORESOURCE_IO :memcpy (&pcie->io, &res,sizeof (res)); - pcie->io.name ="I/O" ; + pcie->io.name = np->full_name;break ;case IORESOURCE_MEM :if (res.flags &IORESOURCE_PREFETCH ) {memcpy (&pcie->prefetch, &res,sizeof (res)); - pcie->prefetch.name ="PREFETCH" ; + pcie->prefetch.name ="prefetchable" ; }else {memcpy (&pcie->mem, &res,sizeof (res)); - pcie->mem.name ="MEM" ; + pcie->mem.name ="non-prefetchable" ; }break ; } + +if (res.start <= pcie->all.start) + pcie->all.start = res.start; + +if (res.end >= pcie->all.end) + pcie->all.end = res.end; } + err =devm_request_resource (pcie->dev, &iomem_resource, &pcie->all); +if (err <0 ) +return err; + err =of_pci_parse_bus_range (np, &pcie->busn);if (err <0 ) { dev_err(pcie->dev, "failed to parse ranges property: %d\n",
Signature · 1 line
2.0.4
PATCH v3 3/6 PCI: tegra: Clear CLKREQ# enable on port disable
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
When a root port is disabled, disable the CLKREQ# signal if available.
--- drivers/pci/host/pci-tegra.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/host/pci-tegra.c +5 -0
@@ -569,6 +569,7 @@ static void tegra_pcie_port_enable(struct tegra_pcie_port *port)static void tegra_pcie_port_disable (struct tegra_pcie_port *port) { +const struct tegra_pcie_soc_data *soc = port->pcie->soc_data;unsigned long ctrl =tegra_pcie_port_get_pex_ctrl (port);unsigned long value;
@@ -579,6 +580,10 @@ static void tegra_pcie_port_disable(struct tegra_pcie_port *port)/* disable reference clock */ value =afi_readl (port->pcie, ctrl); + +if (soc->has_pex_clkreq_en) + value &= ~AFI_PEX_CTRL_CLKREQ_EN ; + value &= ~AFI_PEX_CTRL_REFCLK_EN ;afi_writel (port->pcie, value, ctrl); }
Signature · 1 line
2.0.4
PATCH v3 4/6 PCI: tegra: Fix extended configuration space mapping
In reply to Thierry RedingFrom: Peter Daifuku <[email protected]>
The 16 chunks of 64 KiB that need to be stitched together to make up the configuration space for one bus (1 MiB) are located 24 bits (== 16 MiB) apart in physical address space. This is determined by the start of the extended register field (bits 24-27) in the physical mapping.
--- drivers/pci/host/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pci-tegra.c +1 -1
@@ -383,7 +383,7 @@ static struct tegra_pcie_bus *tegra_pcie_bus_alloc(struct tegra_pcie *pcie,for (i =0 ; i <16 ; i++) {unsigned long virt = (unsigned long )bus->area->addr + i *SZ_64K ; -phys_addr_t phys = cs + i *SZ_1M + busnr *SZ_64K ; +phys_addr_t phys = cs + i *SZ_16M + busnr *SZ_64K ; err =ioremap_page_range (virt, virt +SZ_64K , phys, prot);if (err <0 ) {
Signature · 1 line
2.0.4
PATCH v3 5/6 PCI: tegra: Make sure the PCIe PLL is really reset
In reply to Thierry RedingFrom: Eric Yuen <[email protected]>
Depending on the prior state of the controller, the PLL reset may not be pulsed. Clear the register bit and set it after a small delay to ensure that the PLL is really reset.
--- drivers/pci/host/pci-tegra.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pci/host/pci-tegra.c +7 -0
@@ -849,6 +849,13 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie) value |=PADS_PLL_CTL_REFCLK_INTERNAL_CML | soc->tx_ref_sel;pads_writel (pcie, value, soc->pads_pll_ctl); +/* reset PLL */ + value =pads_readl (pcie, soc->pads_pll_ctl); + value &= ~PADS_PLL_CTL_RST_B4SM ; +pads_writel (pcie, value, soc->pads_pll_ctl); + +usleep_range (20 ,100 ); +/* take PLL out of reset */ value =pads_readl (pcie, soc->pads_pll_ctl); value |=PADS_PLL_CTL_RST_B4SM ;
Signature · 1 line
2.0.4
PATCH v3 6/6 PCI: tegra: Add Tegra124 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The PCIe controller on Tegra124 has two root ports that can be used in a x4/x1 or x2/x1 configuration and can run at PCIe 2.0 link speeds (up to 5 GT/s). The PHY programming has been moved into a separate controller, so the driver now needs to request an external PHY referenced using the device tree.
---
Changes in v3:
- use the correct names for supplies
.../bindings/pci/nvidia,tegra20-pcie.txt | 25 ++- drivers/pci/host/pci-tegra.c | 211 ++++++++++++++++++--- 2 files changed, 204 insertions(+), 32 deletions(-)
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +24 -1
@@ -1,7 +1,10 @@ NVIDIA Tegra PCIe controller Required properties: -- compatible: "nvidia,tegra20-pcie" or "nvidia,tegra30-pcie" +- compatible: Must be one of: + - "nvidia,tegra20-pcie" + - "nvidia,tegra30-pcie" + - "nvidia,tegra124-pcie" - device_type: Must be "pci" - reg: A list of physical base address and length for each set of controller registers. Must contain an entry for each entry in the reg-names property.
@@ -57,6 +60,11 @@ Required properties: - afi - pcie_x +Required properties on Tegra124 and later: +- phys: Must contain an entry for each entry in phy-names. +- phy-names: Must include the following entries: + - pcie + Power supplies for Tegra20: - avdd-pex-supply: Power supply for analog PCIe logic. Must supply 1.05 V. - vdd-pex-supply: Power supply for digital PCIe I/O. Must supply 1.05 V.
@@ -84,6 +92,21 @@ Power supplies for Tegra30: - avdd-pexb-supply: Power supply for analog PCIe logic. Must supply 1.05 V. - vdd-pexb-supply: Power supply for digital PCIe I/O. Must supply 1.05 V. +Power supplies for Tegra124: +- Required: + - avddio-pex-supply: Power supply for analog PCIe logic. Must supply 1.05 V. + - dvddio-pex-supply: Power supply for digital PCIe I/O. Must supply 1.05 V. + - avdd-pex-pll-supply: Power supply for dedicated (internal) PCIe PLL. Must + supply 1.05 V. + - hvdd-pex-supply: High-voltage supply for PCIe I/O and PCIe output clocks. + Must supply 3.3 V. + - hvdd-pex-pll-e-supply: High-voltage supply for PLLE (shared with USB3). + Must supply 3.3 V. + - vddio-pex-ctl-supply: Power supply for PCIe control I/O partition. Must + supply 2.8-3.3 V. + - avdd-pll-erefe-supply: Power supply for PLLE (shared with USB3). Must + supply 1.05 V. + Root ports are defined as subnodes of the PCIe controller node. Required properties:
drivers/pci/host/pci-tegra.c +180 -31
360 lines not on this page · raw message
Signature · 1 line
2.0.4
Bjorn Helgaas
maintainerQuoted 27 lines · Thierry Reding
From: Thierry Reding <[email protected]>
This series implements various fixes and adds support for Tegra124 to the Tegra PCIe controller driver.
Patches 1 and 2 were already sent out separately earlier on but haven't been applied yet, so I'm including them here for convenience.
Patches 3 to 5 are various fixes that should make the driver more reliable, though they don't (except maybe for patch 4) fix any known issues.
Patch 6 finally adds support for Tegra124.
Thierry
Eric Yuen (1):
PCI: tegra: Make sure the PCIe PLL is really resetPeter Daifuku (1):
PCI: tegra: Fix extended configuration space mappingThierry Reding (4):
resource: Add device-managed request/release_resource()
PCI: tegra: Implement a proper resource hierarchy
PCI: tegra: Clear CLKREQ# enable on port disable
PCI: tegra: Add Tegra124 support
Quoted 6 lines
.../bindings/pci/nvidia,tegra20-pcie.txt | 25 +- Documentation/driver-model/devres.txt | 2 + drivers/pci/host/pci-tegra.c | 257 ++++++++++++++++++--- include/linux/ioport.h | 5 + kernel/resource.c | 70 ++++++ 5 files changed, 323 insertions(+), 36 deletions(-)
Applied to pci/host-tegra for v3.18, thanks. I added Stephens's Tested-by (though not to the first two because I had applied them before I got to this v3 posting).