summaryrefslogtreecommitdiff
path: root/include/dm/read.h
Commit message (Collapse)AuthorAgeFilesLines
* dm: core: add a function to decode display timingsDario Binacchi2021-01-121-0/+24
| | | | | | | | The patch adds a function to get display timings from the device tree node attached to the device. Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Access device ofnode through functionsSimon Glass2021-01-051-1/+1
| | | | | | | | At present ofnode is present in the device even if it is never used. With of-platdata this field is not used, so can be removed. In preparation for this, change the access to go through inline functions. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Use dev_has_ofnode() instead of dev_of_valid()Simon Glass2021-01-051-16/+0
| | | | | | | | | | | We have two functions which do the same thing. Standardise on dev_has_ofnode() since there is no such thing as an 'invalid' ofnode in normal operation: it is either null or missing. Also move the functions into one place. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* dm: add cells_count parameter in *_count_phandle_with_argsPatrick Delaunay2020-10-061-3/+5
| | | | | | | | | | | | | | | | | | | The cell_count argument is required when cells_name is NULL. This patch adds this parameter in live tree API - of_count_phandle_with_args - ofnode_count_phandle_with_args - dev_count_phandle_with_args This parameter solves issue when these API is used to count the number of element of a cell without cell name. This parameter allow to force the size cell. For example: count = dev_count_phandle_with_args(dev, "array", NULL, 3); Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Add API to read PCI bus-range propertyStefan Roese2020-08-251-0/+12
| | | | | | | Add dev_read_pci_bus_range() to read bus-range property values Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Fix devfdt_get_addr_ptr return valueOvidiu Panait2020-08-221-3/+1
| | | | | | | | | | | | According to the description of devfdt_get_addr_ptr, this function should return NULL on failure, but currently it returns (void *)FDT_ADDR_T_NONE. Fix this by making devfdt_get_addr_ptr return NULL on failure, as described in the function comments. Also, update the drivers currently checking (void *)FDT_ADDR_T_NONE to check for NULL. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: fix ofnode_read_addr/size_cells()Heinrich Schuchardt2020-08-221-4/+6
| | | | | | | | | | | | | | | | | | | | In the case of the live tree ofnode_read_addr_cells() and ofnode_read_size_cells() return the #address-cells and #size-cells defined in the parent node. With the patch the same is done for a non-live tree. The only consumer of these functions is currently the CFI flash driver. This patch fixes the incorrect parsing of the device tree leading to 'saveenv' failing on qemu_arm64_defconfig. For testing qemu-system-aarch64 has to be called with -drive if=pflash,format=raw,index=1,file=envstore.img to provide the flash memory. envstore.img must be 64 MiB large. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Stefan Roese <sr@denx.de>
* net: Drop dm.h header file from phy.hSimon Glass2020-08-031-0/+1
| | | | | | | This header file should not be included in other header files. Remove it and use other headers and C inclusions instead. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Fix build error when OF_CONTROL is not setDan Murphy2020-07-281-0/+2
| | | | | | | | | With OF_CONTROL disabled the build fails for include/dm/read.h:932:10: error: ‘ENOTSUPP’ undeclared (first use in this function) 932 | return -ENOTSUPP; Fixes: 45224e8f2691 ("dm: core: gracefully handle alias seq without of") Signed-off-by: Dan Murphy <dmurphy@ti.com>
* dm: Fix error handling for dev_read_addr_ptrSean Anderson2020-07-011-1/+3
| | | | | | | | | | | | dev_read_addr_ptr had different semantics depending on whether OF_LIVE was enabled. This patch converts both implementations to return NULL on error, and converts all call sites which check for FDT_ADDR_T_NONE to check for NULL instead. This patch also removes the call to map_physmem, since we have dev_remap_addr* for those semantics. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: gracefully handle alias seq without ofMarcel Ziswiler2020-06-301-0/+4
| | | | | | Gracefully handle alias seq in the platform data rather than OF case. Signed-off-by: Marcel Ziswiler <marcel@ziswiler.com>
* dm: core: fix dev_read_alias_highest_id() without libfdtMichael Walle2020-06-111-0/+2
| | | | | | | | | | | | | | If CONFIG_DM_DEV_READ_INLINE is set, dev_read_alias_highest_id() calls libfdt_get_highest_id(). But this function is only available if we have libfdt compiled in. If its not available return -1, which matches the return code for no alias found. This fixes the following error on omapl138_lcdk: arm-linux-gnueabi-ld.bfd: drivers/built-in.o: in function `dev_read_alias_highest_id': /home/mw/repo/u-boot/include/dm/read.h:986: undefined reference to `fdtdec_get_alias_highest_id' Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Add function to get child count of ofnode or deviceChunfeng Yun2020-05-021-0/+13
| | | | | | | | | | This patch add function used to get the child count of a ofnode or a device Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Signed-off-by: Frank Wunderlich <frank-w@public-files.de> Reviewed-by: Weijie Gao <weijie.gao@mediatek.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: add ofnode and dev function to iterate on node propertyPatrick Delaunay2020-04-161-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add functions to iterate on all property with livetree - dev_read_first_prop - dev_read_next_prop - dev_read_prop_by_prop and - ofnode_get_first_property - ofnode_get_next_property - ofnode_get_property_by_prop And helper: dev_for_each_property For example: struct ofprop property; dev_for_each_property(property, config) { value = dev_read_prop_by_prop(&property, &propname, &len); or: for (res = ofnode_get_first_property(node, &property); !res; res = ofnode_get_next_property(&property)) { value = ofnode_get_property_by_prop(&property, &propname, &len); .... } Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: support reading a single indexed u32 valueDario Binacchi2020-04-161-0/+40
| | | | | | | | | The patch adds helper functions to allow reading a single indexed u32 value from a device-tree property containing multiple u32 values, that is an array of integers. Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Add a way to read platdata for all child devicesSimon Glass2020-02-051-1/+2
| | | | | | | | | When generating ACPI tables we need to make sure that all devices have read their platform data, so that they can generate the tables correctly. Rather than adding this code in ACPI, create a core function to handle it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Use const device for the dev_read_...() interfaceSimon Glass2020-02-051-97/+108
| | | | | | | These functions do not modify the device so should use a const pointer to it. Update the code accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Use const where possible in device.hSimon Glass2020-02-051-2/+2
| | | | | | | Update this header file to use const devices where possible, to permit callers to also use const. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: pci: Add a function to read a PCI BARSimon Glass2019-10-081-0/+25
| | | | | | | | | | | | | | | At present PCI address transaction is not supported so drivers must manually read the correct BAR after reading the device tree info. The ns16550 has a suitable implementation, so move this code into the core DM support. Note that there is no live-tree equivalent at present. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: correct the unclear comments in test.dts] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
* dm: core: Add functions to read 64-bit dt propertiesT Karthik Reddy2019-09-061-0/+33
| | | | | | | | | This patch adds functions dev_read_u64_default & dev_read_u64 to read unsigned 64-bit values from devicetree. Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* dm: core: add support for getting register address and sizeSekhar Nori2019-08-121-0/+41
| | | | | | | | | | | | | Current dev_read_*() API lacks support to get address and size of a "reg" property by name or index. Add support for the same. Livetree support has been added but not tested on real hardware. The existing unit tests testing reading address from device-tree have been updated to test address as well as size. Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
* dm: Fix parameter description of dev_read_name()Bin Meng2019-07-241-1/+1
| | | | | | | | The comments of dev_read_name() wrongly describe "node" as its parameter. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Introduce xxx_translate_dma_address()Fabien Dessenne2019-07-221-1/+19
| | | | | | | | | | | | | | | | | | | Add the following functions to translate DMA address to CPU address: - dev_translate_dma_address() - ofnode_translate_dma_address() - of_translate_dma_address() - fdt_translate_dma_address() These functions work the same way as xxx_translate_address(), with the difference that the translation relies on the "dma-ranges" property instead of the "ranges" property. Add related test. Test report: => ut dm fdt_translation Test: dm_test_fdt_translation: test-fdt.c Test: dm_test_fdt_translation: test-fdt.c (flat tree) Failures: 0 Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
* dm: core: Introduce dev_read_alias_highest_id()Michal Simek2019-02-081-0/+16
| | | | | | | | | It is wrapper for calling of_alias_get_highest_id() when live tree is enabled and fdtdec_get_alias_highest_id() if not. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Heiko Schocher <hs@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Add a function to read into a unsigned intSimon Glass2018-12-131-0/+58
| | | | | | | | | | | The current dev_read...() functions use s32 and u32 which are convenient for device tree but not so useful for normal code, which often wants to use normal integers for values. Add a helper which supports returning an unsigned int. Also add signed versions of the unsigned readers. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: add functions to get/remap I/O addresses by nameÁlvaro Fernández Rojas2018-12-051-0/+36
| | | | | | | | | | This functions allow us to get and remap I/O addresses by name, which is useful when there are multiple reg addresses indexed by reg-names property. This is needed in bmips dma/eth patch series, but can also be used on many other drivers. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: add functions to get memory-mapped I/O addressesÁlvaro Fernández Rojas2018-06-011-0/+32
| | | | | | | Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
* include: dm: Fix 'devioe'/'devuce' typosMario Six2018-01-281-4/+4
| | | | | | | | There are some typos in the documentation of some functions in read.h; fix those. Signed-off-by: Mario Six <mario.six@gdsys.cc> Reviewed-by: Simon Glass <sjg@chromium.org>
* Merge git://git.denx.de/u-boot-mmcTom Rini2018-01-241-0/+16
|\
| * dm: add dev_read_u32()Masahiro Yamada2018-01-221-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | dev_read_u32_default() always returns something even when the property is missing. So, it is impossible to do nothing in the case. One solution is to use ofnode_read_u32() instead, but adding dev_read_u32() will be helpful. BTW, Linux has an equvalent function, device_property_read_u32(); it is clearer that it reads a property. I cannot understand the behavior of dev_read_u32() from its name. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* | core: Add {ofnode, dev}_translate_address functionsMario Six2018-01-211-0/+17
|/ | | | | Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
* dm: core: Add functions to get strings and the string count from a stringlistJean-Jacques Hiblot2017-09-221-0/+36
| | | | | | | | | dev_read_string_count() is used to get the number of strings in a stringlist. dev_read_string_index() is used to get a string in the stringlist based on its position in the list. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
* dm: core: add dev_read_addr_ptr()Philipp Tomsich2017-09-181-0/+15
| | | | | | | | | | The dev_read_addr_ptr() mimics the behaviour of the devfdt_get_addr_ptr(), retrieving the first address of the node's reg-property and returning it as a pointer (or NULL on failure). Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* ofnode: add {ofnode, dev}_read_resource_byname()Masahiro Yamada2017-08-291-1/+19
| | | | | | | | | | | Linux supports platform_get_resource_byname() to look up a resource by name. We want a similar helper. It is useful when a device node has named register regions. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* Merge git://git.denx.de/u-boot-usbTom Rini2017-07-291-0/+25
|\
| * dm: core: add ofnode_count_phandle_with_args()Patrice Chotard2017-07-281-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function is usefull to get phandle number contained in a property list. For example, this allows to allocate the right amount of memory to keep clock's reference contained into the "clocks" property. To implement it, either of_count_phandle_with_args() or fdtdec_parse_phandle_with_args() are used respectively for live tree and flat tree. By passing index = -1, these 2 functions returns the number of phandle contained into the property list. Add also the dev_count_phandle_with_args() based on ofnode_count_phandle_with_args() Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | dm: core: Add ofnode_read_resource()Simon Glass2017-07-281-10/+16
| | | | | | | | | | | | | | | | | | | | | | We sometimes need to read a resource from an arbitrary node. In any case for consistency we should not put the live-tree switching code in a dev_read_...() function. Update this to suit. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1 Tested-by: Stephen Warren <swarren@nvidia.com>
* | dm: ofnode: change return type of dev_read_prop() to opaque pointerMasahiro Yamada2017-07-281-3/+3
|/ | | | | | | | DT property values can be strings as well as integers. This is why of_get_property/fdt_getprop returns an opaque pointer. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
* dm: ofnode: rename ofnode_read_prop() to ofnode_get_property()Masahiro Yamada2017-07-111-1/+1
| | | | | | | | | | | | | This function returns the pointer to the value of a node property. The current name ofnode_read_prop() is confusing. Follow the naming of_get_property() from Linux. The return type (const u32 *) is wrong. DT property values can be strings as well as integers. This is why of_get_property/fdt_getprop returns an opaque pointer. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
* dm: core: Add functions to obtain node's address/size cellsSimon Glass2017-07-111-0/+32
| | | | | | | | | | | | | | | | The of_n_addr_cells() and of_n_size_cells() functions are useful for getting the size of addresses in a node, but in a few places U-Boot needs to obtain the actual property value for a node without walking up the stack. Add functions for this and just the existing code to use it. Add a comment to the existing ofnode functions which do not do the right thing with a flat tree. This fixes a problem reading PCI addresses. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1
* dm: core: Add dev_read_enabled() to check if a device is enabledSimon Glass2017-07-111-0/+18
| | | | | | | | | | | | This function allows a device's status to be read. This indicates whether the device should be enabled or disabled. Note: In normal operation disabled devices will not be present in the driver-model tree. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1
* dm: core: Add dev_read_resource() to read device resourcesSimon Glass2017-07-111-0/+12
| | | | | | | | | | | | | Add a function which reads resources from a device, such as the device hardware address. This uses the "reg" property in the device. Unlike other functions there is little sense in inlining this when livetree is not being used because it has some logic in it and this would just bloat the code size. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1
* dm: core: Implement live tree 'read' functionsSimon Glass2017-06-011-92/+148
| | | | | | | When the live tree is supported some functions need to change a little. Add an implementation which is used when not inlining these functions. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Add device-based 'read' functions to access DTSimon Glass2017-06-011-0/+383
It is common to read a device-tree property from the node associated with a device. Add convenience functions to do this so that drivers do not need to deal with accessing the ofnode from the device. These functions all start with 'dev_read_' to provide consistent naming for all functions which read information from a device's device tree node. These are inlined when using the flat DT to save code size. The live tree implementation is added in a later commit. Signed-off-by: Simon Glass <sjg@chromium.org>