From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Thu, 30 Jul 2020 17:09:18 +0200 Subject: [PATCH v1 01/24] fdtdec: Add API to read pci bus-range property In-Reply-To: References: <20200724100856.1482324-1-sr@denx.de> <20200724100856.1482324-2-sr@denx.de> Message-ID: <9982a030-5de7-2d31-364d-c6247f9cacc3@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On 28.07.20 21:01, Simon Glass wrote: > On Fri, 24 Jul 2020 at 04:09, Stefan Roese wrote: >> >> From: Suneel Garapati >> >> Add fdtdec_get_pci_bus_range to read bus-range property >> values. >> >> Signed-off-by: Suneel Garapati >> Cc: Simon Glass >> >> Signed-off-by: Stefan Roese >> --- >> >> Changes in v1: >> - Added return value description to function prototype in header >> - Changed from using be32_to_cpup() to fdt32_to_cpu() >> >> include/fdtdec.h | 13 +++++++++++++ >> lib/fdtdec.c | 16 ++++++++++++++++ >> 2 files changed, 29 insertions(+) > > Reviewed-by: Simon Glass > > Is the address always 32-bit? Yes, I think so. Its done in a similar way in the Linux kernel. Thanks, Stefan > >> >> diff --git a/include/fdtdec.h b/include/fdtdec.h >> index 760b392bdf..f6759c7f8e 100644 >> --- a/include/fdtdec.h >> +++ b/include/fdtdec.h >> @@ -444,6 +444,19 @@ int fdtdec_get_pci_vendev(const void *blob, int node, >> int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr, >> u32 *bar); >> >> +/** >> + * Look at the bus range property of a device node and return the pci bus >> + * range for this node. >> + * The property must hold one fdt_pci_addr with a length. >> + * @param blob FDT blob >> + * @param node node to examine >> + * @param res the resource structure to return the bus range >> + * @return 0 if ok, negative on error >> + */ >> + >> +int fdtdec_get_pci_bus_range(const void *blob, int node, >> + struct fdt_resource *res); >> + >> /** >> * Look up a 32-bit integer property in a node and return it. The property >> * must have at least 4 bytes of data. The value of the first cell is >> diff --git a/lib/fdtdec.c b/lib/fdtdec.c >> index 78576b530f..0b40fa374a 100644 >> --- a/lib/fdtdec.c >> +++ b/lib/fdtdec.c >> @@ -242,6 +242,22 @@ int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr, >> >> return 0; >> } >> + >> +int fdtdec_get_pci_bus_range(const void *blob, int node, >> + struct fdt_resource *res) >> +{ >> + const u32 *values; >> + int len; >> + >> + values = fdt_getprop(blob, node, "bus-range", &len); >> + if (!values || len < sizeof(*values) * 2) >> + return -EINVAL; >> + >> + res->start = fdt32_to_cpu(*values++); >> + res->end = fdt32_to_cpu(*values); >> + >> + return 0; >> +} >> #endif >> >> uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name, >> -- >> 2.27.0 >> Viele Gr??e, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de