From: Masahiro Yamada Date: Mon, 17 Nov 2014 19:45:43 +0900 Subject: [U-Boot] [RFC] How to get "#address-cells" in U-Boot? In-Reply-To: <20141117193840.943D.AA925319@jp.panasonic.com> References: <20141117193840.943D.AA925319@jp.panasonic.com> Message-ID: <20141117194543.9441.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Another question. Can U-boot handle the address transformation? If the upper "bus" node has "ranges" property, it must also be checked to get the correct base address, I think. On Mon, 17 Nov 2014 19:38:41 +0900 Masahiro Yamada wrote: > Hi. > > > I want to decode the base address of device nodes of my device trees. > > For example, drivers/serial/ns16550.c uses fdtdec_get_addr() function > to decode the "reg" property, but it is not very nice because > it does not check "#address-cells". > > Precisely, we need to check the parent node to get "#address-cells". > (If the parent does not have it, we need to search for it towards the root node.) > > > I am looking for something like of_n_addr_cells() and of_n_size_cells() functions > of Linux Kernel. > > > I don't think it is feasible in U-Boot because > U-Boot handles device tree blobs as they are (as flattened binaries). > > If we want to get properties of the parenet node, we must parse the DTB from the > beginning. Yes, U-Boot actually parses the same DTB over and over again. > > Any advice? Import drivers/of/* from Linux?? > > > > Simon, do you have any good idea to solve this problem by DM? > For example, add "address_cells" and "size_cells" members to struct udevice > and then modify drivers/core/simple-bus.c to parse "#address-cells" and "#size-cells" > and pass them to children. > >