Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: Jisheng Zhang <jszhang@marvell.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	CPGS <cpgs@samsung.com>, Bjorn Helgaas <bhelgaas@google.com>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Subject: Re: [query] how to use "ranges" in device tree
Date: Fri, 17 Apr 2015 10:32 +0200	[thread overview]
Message-ID: <5862495.WQJXyp7MlL@wuerfel> (raw)
In-Reply-To: <20150417115016.69857a77@xhacker>

On Friday 17 April 2015 11:50:16 Jisheng Zhang wrote:
> Hi all,
> 
> I got the solution, the ranges can define two or more ranges. What I need to do
> is just add ranges for 0xe0000000 - 0xf0000000 as the following:
> 
> soc {
>         ranges = <0 0xf7000000 0x1000000
>                   0xe0000000 0xe0000000 0x10000000>;  //add this line
>         ...
>         pcie: pcie@e40000 {
>                 ...
>                 reg = <0xe40000 0x10000>, <0xe0000000 0x8000000>;
>                 reg-names = "dbi", "pad", "config";
>                 ...
>         };
> }
> 
> Now, we can get the config space correctly.
> 

This will work correctly, but it is not a very clean solution, because
you define an intermediate address space that has some part of the
bus mapped to zero, and another part mapped to a high address that
matches the address the CPU sees.

A nicer (but a little more complicated) way to do this would be to use
#address-cells=<2> in the parent bus and use that to enumerate the
address ranges that get passed through:

soc {
	#address-cells=<2>;
	#size-cells=<1>;
        ranges = <0 0  0xf7000000  0x1000000>, /* 0: the normal regs */
		  <1 0  0xe0000000 0x16000000>; /* 1: reallocated registers for PCI */

	pcie@e40000 {
		#address-cells = <3>;
		#size-cells = <2>;
		reg = <0 0xe40000 0x10000>, <1 0 0x8000000>;

		/* memory space at pci address 0xf0000000, cpu address 0xf0000000, 
		   bus address 0x10000000 */
		ranges = <0x02000000 0 0xf0000000   0 0x10000000   0 0x06000000>;
	};

	...
};

The ranges property inside of the pcie node here should match whatever you program
into the inbound mapping registers of the PCIe host controller (if any).

	Arnd

  reply	other threads:[~2015-04-17  8:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16 13:59 [query] how to use "ranges" in device tree Jisheng Zhang
2015-04-16 22:59 ` Jaehoon Chung
2015-04-17  2:24   ` Jisheng Zhang
2015-04-17  3:50     ` Jisheng Zhang
2015-04-17  8:32       ` Arnd Bergmann [this message]
2015-04-17  8:45         ` Jisheng Zhang
2015-04-17  9:38           ` Arnd Bergmann
2015-04-17  8:38       ` Sebastian Hesselbarth
2015-04-17  8:51         ` Jisheng Zhang

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=5862495.WQJXyp7MlL@wuerfel \
    --to=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=cpgs@samsung.com \
    --cc=jh80.chung@samsung.com \
    --cc=jszhang@marvell.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox