of/pci: Provide support for parsing PCI DT ranges property
authorAndrew Murray <Andrew.Murray@arm.com>
Thu, 16 May 2013 15:55:17 +0000 (17:55 +0200)
committerLaxman Dewangan <ldewangan@nvidia.com>
Mon, 23 Jun 2014 08:45:13 +0000 (01:45 -0700)
commit5b128b3eb370c21353028d5de2982558194b76d2
treeebd0eb2c2c5d84156aa23680a430ebded742bbb5
parent15f161d7d234512eca31774c1f9d9f7b6bb45861
of/pci: Provide support for parsing PCI DT ranges property

This patch factors out common implementation patterns to reduce overall kernel
code and provide a means for host bridge drivers to directly obtain struct
resources from the DT's ranges property without relying on architecture specific
DT handling. This will make it easier to write archiecture independent host bridge
drivers and mitigate against further duplication of DT parsing code.

This patch can be used in the following way:

struct of_pci_range_parser parser;
struct of_pci_range range;

if (of_pci_range_parser_init(&parser, np))
; //no ranges property

for_each_of_pci_range(&parser, &range) {

/*
directly access properties of the address range, e.g.:
range.pci_space, range.pci_addr, range.cpu_addr,
range.size, range.flags

alternatively obtain a struct resource, e.g.:
struct resource res;
of_pci_range_to_resource(&range, np, &res);
*/
}

Additionally the implementation takes care of adjacent ranges and merges them
into a single range (as was the case with powerpc and microblaze).

Bug 200012096

Change-Id: I04ad247eb914853f6e1bd7caf11751ce38e576f8
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
Signed-off-by: Andrew Murray <Andrew.Murray@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Rob Herring <rob.herring@calxeda.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
(cherry picked from commit 29b635c00f3ebcdaf7a52c4948f6d948ad3757d3)
Reviewed-on: http://git-master/r/424861
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
drivers/of/address.c
include/linux/of_address.h