Subject: [query] how to use "ranges" in device tree

From: [email-masked] (Jisheng Zhang)
Date: Fri, 17 Apr 2015 16:51:35 +0800

On Fri, 17 Apr 2015 01:38:16 -0700
Sebastian Hesselbarth <[email-masked]> wrote:

> On 17.04.2015 05:50, Jisheng Zhang wrote:
> > 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:
> 
> Jisheng,
> 
> the beauty of ranges property often reminds me of perl code: once you
> stop looking at it, you cannot recall how you did it nor how that
> has ever worked.
> 
> What the ranges property does is to map an address range back to the
> address space of the parent node. In this case, the parent node of
> "soc" is the root node with "ranges;", i.e. 1:1 mapping.
> 
> > soc {
> > 	ranges = <0 0xf7000000 0x1000000
> 
> The line above maps 0x1000000 bytes starting at 0 back to 0xf7000000
> of the parent node's address space. This allows us to leave the 0xf7
> prefix for each of the internal bus nodes below.
> 
> > 		  0xe0000000 0xe0000000 0x10000000>;  //add this line
> 
> You could have chosen any address as the first value that does not
> interfere with 0x0-0x1000000 of the first range, e.g.
> 
> 0x20000000 0xe0000000 0x10000000
> 
> would allow you to access the pcie memory space at 0x20000000 in nodes
> below that ranges property.
> 

Thanks for this explanation which gives me good guide about the "ranges" usage.

> 
> > 	pcie: pcie at e40000 {
> > 		...
> > 		reg = <0xe40000 0x10000>, <0xe0000000 0x8000000>;
> > 		reg-names = "dbi", "pad", "config";
> > 		...
> > 	};
> > }
> >
> > Now, we can get the config space correctly.
>