1*d18719a4STom Rini #ifndef _LIBFDT_H 2*d18719a4STom Rini #define _LIBFDT_H 3*d18719a4STom Rini /* 4*d18719a4STom Rini * libfdt - Flat Device Tree manipulation 5*d18719a4STom Rini * Copyright (C) 2006 David Gibson, IBM Corporation. 6*d18719a4STom Rini * 7*d18719a4STom Rini * libfdt is dual licensed: you can use it either under the terms of 8*d18719a4STom Rini * the GPL, or the BSD license, at your option. 9*d18719a4STom Rini * 10*d18719a4STom Rini * a) This library is free software; you can redistribute it and/or 11*d18719a4STom Rini * modify it under the terms of the GNU General Public License as 12*d18719a4STom Rini * published by the Free Software Foundation; either version 2 of the 13*d18719a4STom Rini * License, or (at your option) any later version. 14*d18719a4STom Rini * 15*d18719a4STom Rini * This library is distributed in the hope that it will be useful, 16*d18719a4STom Rini * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*d18719a4STom Rini * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*d18719a4STom Rini * GNU General Public License for more details. 19*d18719a4STom Rini * 20*d18719a4STom Rini * You should have received a copy of the GNU General Public 21*d18719a4STom Rini * License along with this library; if not, write to the Free 22*d18719a4STom Rini * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 23*d18719a4STom Rini * MA 02110-1301 USA 24*d18719a4STom Rini * 25*d18719a4STom Rini * Alternatively, 26*d18719a4STom Rini * 27*d18719a4STom Rini * b) Redistribution and use in source and binary forms, with or 28*d18719a4STom Rini * without modification, are permitted provided that the following 29*d18719a4STom Rini * conditions are met: 30*d18719a4STom Rini * 31*d18719a4STom Rini * 1. Redistributions of source code must retain the above 32*d18719a4STom Rini * copyright notice, this list of conditions and the following 33*d18719a4STom Rini * disclaimer. 34*d18719a4STom Rini * 2. Redistributions in binary form must reproduce the above 35*d18719a4STom Rini * copyright notice, this list of conditions and the following 36*d18719a4STom Rini * disclaimer in the documentation and/or other materials 37*d18719a4STom Rini * provided with the distribution. 38*d18719a4STom Rini * 39*d18719a4STom Rini * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 40*d18719a4STom Rini * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 41*d18719a4STom Rini * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 42*d18719a4STom Rini * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 43*d18719a4STom Rini * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 44*d18719a4STom Rini * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45*d18719a4STom Rini * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46*d18719a4STom Rini * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47*d18719a4STom Rini * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48*d18719a4STom Rini * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 49*d18719a4STom Rini * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 50*d18719a4STom Rini * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 51*d18719a4STom Rini * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 52*d18719a4STom Rini */ 53*d18719a4STom Rini 54*d18719a4STom Rini #include "libfdt_env.h" 55*d18719a4STom Rini #include "fdt.h" 56*d18719a4STom Rini 57*d18719a4STom Rini #define FDT_FIRST_SUPPORTED_VERSION 0x10 58*d18719a4STom Rini #define FDT_LAST_SUPPORTED_VERSION 0x11 59*d18719a4STom Rini 60*d18719a4STom Rini /* Error codes: informative error codes */ 61*d18719a4STom Rini #define FDT_ERR_NOTFOUND 1 62*d18719a4STom Rini /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ 63*d18719a4STom Rini #define FDT_ERR_EXISTS 2 64*d18719a4STom Rini /* FDT_ERR_EXISTS: Attempted to create a node or property which 65*d18719a4STom Rini * already exists */ 66*d18719a4STom Rini #define FDT_ERR_NOSPACE 3 67*d18719a4STom Rini /* FDT_ERR_NOSPACE: Operation needed to expand the device 68*d18719a4STom Rini * tree, but its buffer did not have sufficient space to 69*d18719a4STom Rini * contain the expanded tree. Use fdt_open_into() to move the 70*d18719a4STom Rini * device tree to a buffer with more space. */ 71*d18719a4STom Rini 72*d18719a4STom Rini /* Error codes: codes for bad parameters */ 73*d18719a4STom Rini #define FDT_ERR_BADOFFSET 4 74*d18719a4STom Rini /* FDT_ERR_BADOFFSET: Function was passed a structure block 75*d18719a4STom Rini * offset which is out-of-bounds, or which points to an 76*d18719a4STom Rini * unsuitable part of the structure for the operation. */ 77*d18719a4STom Rini #define FDT_ERR_BADPATH 5 78*d18719a4STom Rini /* FDT_ERR_BADPATH: Function was passed a badly formatted path 79*d18719a4STom Rini * (e.g. missing a leading / for a function which requires an 80*d18719a4STom Rini * absolute path) */ 81*d18719a4STom Rini #define FDT_ERR_BADPHANDLE 6 82*d18719a4STom Rini /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle. 83*d18719a4STom Rini * This can be caused either by an invalid phandle property 84*d18719a4STom Rini * length, or the phandle value was either 0 or -1, which are 85*d18719a4STom Rini * not permitted. */ 86*d18719a4STom Rini #define FDT_ERR_BADSTATE 7 87*d18719a4STom Rini /* FDT_ERR_BADSTATE: Function was passed an incomplete device 88*d18719a4STom Rini * tree created by the sequential-write functions, which is 89*d18719a4STom Rini * not sufficiently complete for the requested operation. */ 90*d18719a4STom Rini 91*d18719a4STom Rini /* Error codes: codes for bad device tree blobs */ 92*d18719a4STom Rini #define FDT_ERR_TRUNCATED 8 93*d18719a4STom Rini /* FDT_ERR_TRUNCATED: Structure block of the given device tree 94*d18719a4STom Rini * ends without an FDT_END tag. */ 95*d18719a4STom Rini #define FDT_ERR_BADMAGIC 9 96*d18719a4STom Rini /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a 97*d18719a4STom Rini * device tree at all - it is missing the flattened device 98*d18719a4STom Rini * tree magic number. */ 99*d18719a4STom Rini #define FDT_ERR_BADVERSION 10 100*d18719a4STom Rini /* FDT_ERR_BADVERSION: Given device tree has a version which 101*d18719a4STom Rini * can't be handled by the requested operation. For 102*d18719a4STom Rini * read-write functions, this may mean that fdt_open_into() is 103*d18719a4STom Rini * required to convert the tree to the expected version. */ 104*d18719a4STom Rini #define FDT_ERR_BADSTRUCTURE 11 105*d18719a4STom Rini /* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt 106*d18719a4STom Rini * structure block or other serious error (e.g. misnested 107*d18719a4STom Rini * nodes, or subnodes preceding properties). */ 108*d18719a4STom Rini #define FDT_ERR_BADLAYOUT 12 109*d18719a4STom Rini /* FDT_ERR_BADLAYOUT: For read-write functions, the given 110*d18719a4STom Rini * device tree has it's sub-blocks in an order that the 111*d18719a4STom Rini * function can't handle (memory reserve map, then structure, 112*d18719a4STom Rini * then strings). Use fdt_open_into() to reorganize the tree 113*d18719a4STom Rini * into a form suitable for the read-write operations. */ 114*d18719a4STom Rini 115*d18719a4STom Rini /* "Can't happen" error indicating a bug in libfdt */ 116*d18719a4STom Rini #define FDT_ERR_INTERNAL 13 117*d18719a4STom Rini /* FDT_ERR_INTERNAL: libfdt has failed an internal assertion. 118*d18719a4STom Rini * Should never be returned, if it is, it indicates a bug in 119*d18719a4STom Rini * libfdt itself. */ 120*d18719a4STom Rini 121*d18719a4STom Rini /* Errors in device tree content */ 122*d18719a4STom Rini #define FDT_ERR_BADNCELLS 14 123*d18719a4STom Rini /* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells 124*d18719a4STom Rini * or similar property with a bad format or value */ 125*d18719a4STom Rini 126*d18719a4STom Rini #define FDT_ERR_BADVALUE 15 127*d18719a4STom Rini /* FDT_ERR_BADVALUE: Device tree has a property with an unexpected 128*d18719a4STom Rini * value. For example: a property expected to contain a string list 129*d18719a4STom Rini * is not NUL-terminated within the length of its value. */ 130*d18719a4STom Rini 131*d18719a4STom Rini #define FDT_ERR_BADOVERLAY 16 132*d18719a4STom Rini /* FDT_ERR_BADOVERLAY: The device tree overlay, while 133*d18719a4STom Rini * correctly structured, cannot be applied due to some 134*d18719a4STom Rini * unexpected or missing value, property or node. */ 135*d18719a4STom Rini 136*d18719a4STom Rini #define FDT_ERR_NOPHANDLES 17 137*d18719a4STom Rini /* FDT_ERR_NOPHANDLES: The device tree doesn't have any 138*d18719a4STom Rini * phandle available anymore without causing an overflow */ 139*d18719a4STom Rini 140*d18719a4STom Rini #define FDT_ERR_MAX 17 141*d18719a4STom Rini 142*d18719a4STom Rini /**********************************************************************/ 143*d18719a4STom Rini /* Low-level functions (you probably don't need these) */ 144*d18719a4STom Rini /**********************************************************************/ 145*d18719a4STom Rini 146*d18719a4STom Rini const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen); 147*d18719a4STom Rini static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) 148*d18719a4STom Rini { 149*d18719a4STom Rini return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); 150*d18719a4STom Rini } 151*d18719a4STom Rini 152*d18719a4STom Rini uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); 153*d18719a4STom Rini 154*d18719a4STom Rini /**********************************************************************/ 155*d18719a4STom Rini /* Traversal functions */ 156*d18719a4STom Rini /**********************************************************************/ 157*d18719a4STom Rini 158*d18719a4STom Rini int fdt_next_node(const void *fdt, int offset, int *depth); 159*d18719a4STom Rini 160*d18719a4STom Rini /** 161*d18719a4STom Rini * fdt_first_subnode() - get offset of first direct subnode 162*d18719a4STom Rini * 163*d18719a4STom Rini * @fdt: FDT blob 164*d18719a4STom Rini * @offset: Offset of node to check 165*d18719a4STom Rini * @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none 166*d18719a4STom Rini */ 167*d18719a4STom Rini int fdt_first_subnode(const void *fdt, int offset); 168*d18719a4STom Rini 169*d18719a4STom Rini /** 170*d18719a4STom Rini * fdt_next_subnode() - get offset of next direct subnode 171*d18719a4STom Rini * 172*d18719a4STom Rini * After first calling fdt_first_subnode(), call this function repeatedly to 173*d18719a4STom Rini * get direct subnodes of a parent node. 174*d18719a4STom Rini * 175*d18719a4STom Rini * @fdt: FDT blob 176*d18719a4STom Rini * @offset: Offset of previous subnode 177*d18719a4STom Rini * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more 178*d18719a4STom Rini * subnodes 179*d18719a4STom Rini */ 180*d18719a4STom Rini int fdt_next_subnode(const void *fdt, int offset); 181*d18719a4STom Rini 182*d18719a4STom Rini /** 183*d18719a4STom Rini * fdt_for_each_subnode - iterate over all subnodes of a parent 184*d18719a4STom Rini * 185*d18719a4STom Rini * @node: child node (int, lvalue) 186*d18719a4STom Rini * @fdt: FDT blob (const void *) 187*d18719a4STom Rini * @parent: parent node (int) 188*d18719a4STom Rini * 189*d18719a4STom Rini * This is actually a wrapper around a for loop and would be used like so: 190*d18719a4STom Rini * 191*d18719a4STom Rini * fdt_for_each_subnode(node, fdt, parent) { 192*d18719a4STom Rini * Use node 193*d18719a4STom Rini * ... 194*d18719a4STom Rini * } 195*d18719a4STom Rini * 196*d18719a4STom Rini * if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) { 197*d18719a4STom Rini * Error handling 198*d18719a4STom Rini * } 199*d18719a4STom Rini * 200*d18719a4STom Rini * Note that this is implemented as a macro and @node is used as 201*d18719a4STom Rini * iterator in the loop. The parent variable be constant or even a 202*d18719a4STom Rini * literal. 203*d18719a4STom Rini * 204*d18719a4STom Rini */ 205*d18719a4STom Rini #define fdt_for_each_subnode(node, fdt, parent) \ 206*d18719a4STom Rini for (node = fdt_first_subnode(fdt, parent); \ 207*d18719a4STom Rini node >= 0; \ 208*d18719a4STom Rini node = fdt_next_subnode(fdt, node)) 209*d18719a4STom Rini 210*d18719a4STom Rini /**********************************************************************/ 211*d18719a4STom Rini /* General functions */ 212*d18719a4STom Rini /**********************************************************************/ 213*d18719a4STom Rini 214*d18719a4STom Rini #define fdt_get_header(fdt, field) \ 215*d18719a4STom Rini (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) 216*d18719a4STom Rini #define fdt_magic(fdt) (fdt_get_header(fdt, magic)) 217*d18719a4STom Rini #define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) 218*d18719a4STom Rini #define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) 219*d18719a4STom Rini #define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings)) 220*d18719a4STom Rini #define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap)) 221*d18719a4STom Rini #define fdt_version(fdt) (fdt_get_header(fdt, version)) 222*d18719a4STom Rini #define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version)) 223*d18719a4STom Rini #define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys)) 224*d18719a4STom Rini #define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) 225*d18719a4STom Rini #define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) 226*d18719a4STom Rini 227*d18719a4STom Rini #define __fdt_set_hdr(name) \ 228*d18719a4STom Rini static inline void fdt_set_##name(void *fdt, uint32_t val) \ 229*d18719a4STom Rini { \ 230*d18719a4STom Rini struct fdt_header *fdth = (struct fdt_header *)fdt; \ 231*d18719a4STom Rini fdth->name = cpu_to_fdt32(val); \ 232*d18719a4STom Rini } 233*d18719a4STom Rini __fdt_set_hdr(magic); 234*d18719a4STom Rini __fdt_set_hdr(totalsize); 235*d18719a4STom Rini __fdt_set_hdr(off_dt_struct); 236*d18719a4STom Rini __fdt_set_hdr(off_dt_strings); 237*d18719a4STom Rini __fdt_set_hdr(off_mem_rsvmap); 238*d18719a4STom Rini __fdt_set_hdr(version); 239*d18719a4STom Rini __fdt_set_hdr(last_comp_version); 240*d18719a4STom Rini __fdt_set_hdr(boot_cpuid_phys); 241*d18719a4STom Rini __fdt_set_hdr(size_dt_strings); 242*d18719a4STom Rini __fdt_set_hdr(size_dt_struct); 243*d18719a4STom Rini #undef __fdt_set_hdr 244*d18719a4STom Rini 245*d18719a4STom Rini /** 246*d18719a4STom Rini * fdt_check_header - sanity check a device tree or possible device tree 247*d18719a4STom Rini * @fdt: pointer to data which might be a flattened device tree 248*d18719a4STom Rini * 249*d18719a4STom Rini * fdt_check_header() checks that the given buffer contains what 250*d18719a4STom Rini * appears to be a flattened device tree with sane information in its 251*d18719a4STom Rini * header. 252*d18719a4STom Rini * 253*d18719a4STom Rini * returns: 254*d18719a4STom Rini * 0, if the buffer appears to contain a valid device tree 255*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 256*d18719a4STom Rini * -FDT_ERR_BADVERSION, 257*d18719a4STom Rini * -FDT_ERR_BADSTATE, standard meanings, as above 258*d18719a4STom Rini */ 259*d18719a4STom Rini int fdt_check_header(const void *fdt); 260*d18719a4STom Rini 261*d18719a4STom Rini /** 262*d18719a4STom Rini * fdt_move - move a device tree around in memory 263*d18719a4STom Rini * @fdt: pointer to the device tree to move 264*d18719a4STom Rini * @buf: pointer to memory where the device is to be moved 265*d18719a4STom Rini * @bufsize: size of the memory space at buf 266*d18719a4STom Rini * 267*d18719a4STom Rini * fdt_move() relocates, if possible, the device tree blob located at 268*d18719a4STom Rini * fdt to the buffer at buf of size bufsize. The buffer may overlap 269*d18719a4STom Rini * with the existing device tree blob at fdt. Therefore, 270*d18719a4STom Rini * fdt_move(fdt, fdt, fdt_totalsize(fdt)) 271*d18719a4STom Rini * should always succeed. 272*d18719a4STom Rini * 273*d18719a4STom Rini * returns: 274*d18719a4STom Rini * 0, on success 275*d18719a4STom Rini * -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree 276*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 277*d18719a4STom Rini * -FDT_ERR_BADVERSION, 278*d18719a4STom Rini * -FDT_ERR_BADSTATE, standard meanings 279*d18719a4STom Rini */ 280*d18719a4STom Rini int fdt_move(const void *fdt, void *buf, int bufsize); 281*d18719a4STom Rini 282*d18719a4STom Rini /**********************************************************************/ 283*d18719a4STom Rini /* Read-only functions */ 284*d18719a4STom Rini /**********************************************************************/ 285*d18719a4STom Rini 286*d18719a4STom Rini /** 287*d18719a4STom Rini * fdt_string - retrieve a string from the strings block of a device tree 288*d18719a4STom Rini * @fdt: pointer to the device tree blob 289*d18719a4STom Rini * @stroffset: offset of the string within the strings block (native endian) 290*d18719a4STom Rini * 291*d18719a4STom Rini * fdt_string() retrieves a pointer to a single string from the 292*d18719a4STom Rini * strings block of the device tree blob at fdt. 293*d18719a4STom Rini * 294*d18719a4STom Rini * returns: 295*d18719a4STom Rini * a pointer to the string, on success 296*d18719a4STom Rini * NULL, if stroffset is out of bounds 297*d18719a4STom Rini */ 298*d18719a4STom Rini const char *fdt_string(const void *fdt, int stroffset); 299*d18719a4STom Rini 300*d18719a4STom Rini /** 301*d18719a4STom Rini * fdt_get_max_phandle - retrieves the highest phandle in a tree 302*d18719a4STom Rini * @fdt: pointer to the device tree blob 303*d18719a4STom Rini * 304*d18719a4STom Rini * fdt_get_max_phandle retrieves the highest phandle in the given 305*d18719a4STom Rini * device tree. This will ignore badly formatted phandles, or phandles 306*d18719a4STom Rini * with a value of 0 or -1. 307*d18719a4STom Rini * 308*d18719a4STom Rini * returns: 309*d18719a4STom Rini * the highest phandle on success 310*d18719a4STom Rini * 0, if no phandle was found in the device tree 311*d18719a4STom Rini * -1, if an error occurred 312*d18719a4STom Rini */ 313*d18719a4STom Rini uint32_t fdt_get_max_phandle(const void *fdt); 314*d18719a4STom Rini 315*d18719a4STom Rini /** 316*d18719a4STom Rini * fdt_num_mem_rsv - retrieve the number of memory reserve map entries 317*d18719a4STom Rini * @fdt: pointer to the device tree blob 318*d18719a4STom Rini * 319*d18719a4STom Rini * Returns the number of entries in the device tree blob's memory 320*d18719a4STom Rini * reservation map. This does not include the terminating 0,0 entry 321*d18719a4STom Rini * or any other (0,0) entries reserved for expansion. 322*d18719a4STom Rini * 323*d18719a4STom Rini * returns: 324*d18719a4STom Rini * the number of entries 325*d18719a4STom Rini */ 326*d18719a4STom Rini int fdt_num_mem_rsv(const void *fdt); 327*d18719a4STom Rini 328*d18719a4STom Rini /** 329*d18719a4STom Rini * fdt_get_mem_rsv - retrieve one memory reserve map entry 330*d18719a4STom Rini * @fdt: pointer to the device tree blob 331*d18719a4STom Rini * @address, @size: pointers to 64-bit variables 332*d18719a4STom Rini * 333*d18719a4STom Rini * On success, *address and *size will contain the address and size of 334*d18719a4STom Rini * the n-th reserve map entry from the device tree blob, in 335*d18719a4STom Rini * native-endian format. 336*d18719a4STom Rini * 337*d18719a4STom Rini * returns: 338*d18719a4STom Rini * 0, on success 339*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 340*d18719a4STom Rini * -FDT_ERR_BADVERSION, 341*d18719a4STom Rini * -FDT_ERR_BADSTATE, standard meanings 342*d18719a4STom Rini */ 343*d18719a4STom Rini int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size); 344*d18719a4STom Rini 345*d18719a4STom Rini /** 346*d18719a4STom Rini * fdt_subnode_offset_namelen - find a subnode based on substring 347*d18719a4STom Rini * @fdt: pointer to the device tree blob 348*d18719a4STom Rini * @parentoffset: structure block offset of a node 349*d18719a4STom Rini * @name: name of the subnode to locate 350*d18719a4STom Rini * @namelen: number of characters of name to consider 351*d18719a4STom Rini * 352*d18719a4STom Rini * Identical to fdt_subnode_offset(), but only examine the first 353*d18719a4STom Rini * namelen characters of name for matching the subnode name. This is 354*d18719a4STom Rini * useful for finding subnodes based on a portion of a larger string, 355*d18719a4STom Rini * such as a full path. 356*d18719a4STom Rini */ 357*d18719a4STom Rini int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, 358*d18719a4STom Rini const char *name, int namelen); 359*d18719a4STom Rini /** 360*d18719a4STom Rini * fdt_subnode_offset - find a subnode of a given node 361*d18719a4STom Rini * @fdt: pointer to the device tree blob 362*d18719a4STom Rini * @parentoffset: structure block offset of a node 363*d18719a4STom Rini * @name: name of the subnode to locate 364*d18719a4STom Rini * 365*d18719a4STom Rini * fdt_subnode_offset() finds a subnode of the node at structure block 366*d18719a4STom Rini * offset parentoffset with the given name. name may include a unit 367*d18719a4STom Rini * address, in which case fdt_subnode_offset() will find the subnode 368*d18719a4STom Rini * with that unit address, or the unit address may be omitted, in 369*d18719a4STom Rini * which case fdt_subnode_offset() will find an arbitrary subnode 370*d18719a4STom Rini * whose name excluding unit address matches the given name. 371*d18719a4STom Rini * 372*d18719a4STom Rini * returns: 373*d18719a4STom Rini * structure block offset of the requested subnode (>=0), on success 374*d18719a4STom Rini * -FDT_ERR_NOTFOUND, if the requested subnode does not exist 375*d18719a4STom Rini * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE 376*d18719a4STom Rini * tag 377*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 378*d18719a4STom Rini * -FDT_ERR_BADVERSION, 379*d18719a4STom Rini * -FDT_ERR_BADSTATE, 380*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 381*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings. 382*d18719a4STom Rini */ 383*d18719a4STom Rini int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name); 384*d18719a4STom Rini 385*d18719a4STom Rini /** 386*d18719a4STom Rini * fdt_path_offset_namelen - find a tree node by its full path 387*d18719a4STom Rini * @fdt: pointer to the device tree blob 388*d18719a4STom Rini * @path: full path of the node to locate 389*d18719a4STom Rini * @namelen: number of characters of path to consider 390*d18719a4STom Rini * 391*d18719a4STom Rini * Identical to fdt_path_offset(), but only consider the first namelen 392*d18719a4STom Rini * characters of path as the path name. 393*d18719a4STom Rini */ 394*d18719a4STom Rini int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen); 395*d18719a4STom Rini 396*d18719a4STom Rini /** 397*d18719a4STom Rini * fdt_path_offset - find a tree node by its full path 398*d18719a4STom Rini * @fdt: pointer to the device tree blob 399*d18719a4STom Rini * @path: full path of the node to locate 400*d18719a4STom Rini * 401*d18719a4STom Rini * fdt_path_offset() finds a node of a given path in the device tree. 402*d18719a4STom Rini * Each path component may omit the unit address portion, but the 403*d18719a4STom Rini * results of this are undefined if any such path component is 404*d18719a4STom Rini * ambiguous (that is if there are multiple nodes at the relevant 405*d18719a4STom Rini * level matching the given component, differentiated only by unit 406*d18719a4STom Rini * address). 407*d18719a4STom Rini * 408*d18719a4STom Rini * returns: 409*d18719a4STom Rini * structure block offset of the node with the requested path (>=0), on 410*d18719a4STom Rini * success 411*d18719a4STom Rini * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid 412*d18719a4STom Rini * -FDT_ERR_NOTFOUND, if the requested node does not exist 413*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 414*d18719a4STom Rini * -FDT_ERR_BADVERSION, 415*d18719a4STom Rini * -FDT_ERR_BADSTATE, 416*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 417*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings. 418*d18719a4STom Rini */ 419*d18719a4STom Rini int fdt_path_offset(const void *fdt, const char *path); 420*d18719a4STom Rini 421*d18719a4STom Rini /** 422*d18719a4STom Rini * fdt_get_name - retrieve the name of a given node 423*d18719a4STom Rini * @fdt: pointer to the device tree blob 424*d18719a4STom Rini * @nodeoffset: structure block offset of the starting node 425*d18719a4STom Rini * @lenp: pointer to an integer variable (will be overwritten) or NULL 426*d18719a4STom Rini * 427*d18719a4STom Rini * fdt_get_name() retrieves the name (including unit address) of the 428*d18719a4STom Rini * device tree node at structure block offset nodeoffset. If lenp is 429*d18719a4STom Rini * non-NULL, the length of this name is also returned, in the integer 430*d18719a4STom Rini * pointed to by lenp. 431*d18719a4STom Rini * 432*d18719a4STom Rini * returns: 433*d18719a4STom Rini * pointer to the node's name, on success 434*d18719a4STom Rini * If lenp is non-NULL, *lenp contains the length of that name 435*d18719a4STom Rini * (>=0) 436*d18719a4STom Rini * NULL, on error 437*d18719a4STom Rini * if lenp is non-NULL *lenp contains an error code (<0): 438*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE 439*d18719a4STom Rini * tag 440*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 441*d18719a4STom Rini * -FDT_ERR_BADVERSION, 442*d18719a4STom Rini * -FDT_ERR_BADSTATE, standard meanings 443*d18719a4STom Rini */ 444*d18719a4STom Rini const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp); 445*d18719a4STom Rini 446*d18719a4STom Rini /** 447*d18719a4STom Rini * fdt_first_property_offset - find the offset of a node's first property 448*d18719a4STom Rini * @fdt: pointer to the device tree blob 449*d18719a4STom Rini * @nodeoffset: structure block offset of a node 450*d18719a4STom Rini * 451*d18719a4STom Rini * fdt_first_property_offset() finds the first property of the node at 452*d18719a4STom Rini * the given structure block offset. 453*d18719a4STom Rini * 454*d18719a4STom Rini * returns: 455*d18719a4STom Rini * structure block offset of the property (>=0), on success 456*d18719a4STom Rini * -FDT_ERR_NOTFOUND, if the requested node has no properties 457*d18719a4STom Rini * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag 458*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 459*d18719a4STom Rini * -FDT_ERR_BADVERSION, 460*d18719a4STom Rini * -FDT_ERR_BADSTATE, 461*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 462*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings. 463*d18719a4STom Rini */ 464*d18719a4STom Rini int fdt_first_property_offset(const void *fdt, int nodeoffset); 465*d18719a4STom Rini 466*d18719a4STom Rini /** 467*d18719a4STom Rini * fdt_next_property_offset - step through a node's properties 468*d18719a4STom Rini * @fdt: pointer to the device tree blob 469*d18719a4STom Rini * @offset: structure block offset of a property 470*d18719a4STom Rini * 471*d18719a4STom Rini * fdt_next_property_offset() finds the property immediately after the 472*d18719a4STom Rini * one at the given structure block offset. This will be a property 473*d18719a4STom Rini * of the same node as the given property. 474*d18719a4STom Rini * 475*d18719a4STom Rini * returns: 476*d18719a4STom Rini * structure block offset of the next property (>=0), on success 477*d18719a4STom Rini * -FDT_ERR_NOTFOUND, if the given property is the last in its node 478*d18719a4STom Rini * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag 479*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 480*d18719a4STom Rini * -FDT_ERR_BADVERSION, 481*d18719a4STom Rini * -FDT_ERR_BADSTATE, 482*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 483*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings. 484*d18719a4STom Rini */ 485*d18719a4STom Rini int fdt_next_property_offset(const void *fdt, int offset); 486*d18719a4STom Rini 487*d18719a4STom Rini /** 488*d18719a4STom Rini * fdt_for_each_property_offset - iterate over all properties of a node 489*d18719a4STom Rini * 490*d18719a4STom Rini * @property_offset: property offset (int, lvalue) 491*d18719a4STom Rini * @fdt: FDT blob (const void *) 492*d18719a4STom Rini * @node: node offset (int) 493*d18719a4STom Rini * 494*d18719a4STom Rini * This is actually a wrapper around a for loop and would be used like so: 495*d18719a4STom Rini * 496*d18719a4STom Rini * fdt_for_each_property_offset(property, fdt, node) { 497*d18719a4STom Rini * Use property 498*d18719a4STom Rini * ... 499*d18719a4STom Rini * } 500*d18719a4STom Rini * 501*d18719a4STom Rini * if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) { 502*d18719a4STom Rini * Error handling 503*d18719a4STom Rini * } 504*d18719a4STom Rini * 505*d18719a4STom Rini * Note that this is implemented as a macro and property is used as 506*d18719a4STom Rini * iterator in the loop. The node variable can be constant or even a 507*d18719a4STom Rini * literal. 508*d18719a4STom Rini */ 509*d18719a4STom Rini #define fdt_for_each_property_offset(property, fdt, node) \ 510*d18719a4STom Rini for (property = fdt_first_property_offset(fdt, node); \ 511*d18719a4STom Rini property >= 0; \ 512*d18719a4STom Rini property = fdt_next_property_offset(fdt, property)) 513*d18719a4STom Rini 514*d18719a4STom Rini /** 515*d18719a4STom Rini * fdt_get_property_by_offset - retrieve the property at a given offset 516*d18719a4STom Rini * @fdt: pointer to the device tree blob 517*d18719a4STom Rini * @offset: offset of the property to retrieve 518*d18719a4STom Rini * @lenp: pointer to an integer variable (will be overwritten) or NULL 519*d18719a4STom Rini * 520*d18719a4STom Rini * fdt_get_property_by_offset() retrieves a pointer to the 521*d18719a4STom Rini * fdt_property structure within the device tree blob at the given 522*d18719a4STom Rini * offset. If lenp is non-NULL, the length of the property value is 523*d18719a4STom Rini * also returned, in the integer pointed to by lenp. 524*d18719a4STom Rini * 525*d18719a4STom Rini * returns: 526*d18719a4STom Rini * pointer to the structure representing the property 527*d18719a4STom Rini * if lenp is non-NULL, *lenp contains the length of the property 528*d18719a4STom Rini * value (>=0) 529*d18719a4STom Rini * NULL, on error 530*d18719a4STom Rini * if lenp is non-NULL, *lenp contains an error code (<0): 531*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag 532*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 533*d18719a4STom Rini * -FDT_ERR_BADVERSION, 534*d18719a4STom Rini * -FDT_ERR_BADSTATE, 535*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 536*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 537*d18719a4STom Rini */ 538*d18719a4STom Rini const struct fdt_property *fdt_get_property_by_offset(const void *fdt, 539*d18719a4STom Rini int offset, 540*d18719a4STom Rini int *lenp); 541*d18719a4STom Rini 542*d18719a4STom Rini /** 543*d18719a4STom Rini * fdt_get_property_namelen - find a property based on substring 544*d18719a4STom Rini * @fdt: pointer to the device tree blob 545*d18719a4STom Rini * @nodeoffset: offset of the node whose property to find 546*d18719a4STom Rini * @name: name of the property to find 547*d18719a4STom Rini * @namelen: number of characters of name to consider 548*d18719a4STom Rini * @lenp: pointer to an integer variable (will be overwritten) or NULL 549*d18719a4STom Rini * 550*d18719a4STom Rini * Identical to fdt_get_property(), but only examine the first namelen 551*d18719a4STom Rini * characters of name for matching the property name. 552*d18719a4STom Rini */ 553*d18719a4STom Rini const struct fdt_property *fdt_get_property_namelen(const void *fdt, 554*d18719a4STom Rini int nodeoffset, 555*d18719a4STom Rini const char *name, 556*d18719a4STom Rini int namelen, int *lenp); 557*d18719a4STom Rini 558*d18719a4STom Rini /** 559*d18719a4STom Rini * fdt_get_property - find a given property in a given node 560*d18719a4STom Rini * @fdt: pointer to the device tree blob 561*d18719a4STom Rini * @nodeoffset: offset of the node whose property to find 562*d18719a4STom Rini * @name: name of the property to find 563*d18719a4STom Rini * @lenp: pointer to an integer variable (will be overwritten) or NULL 564*d18719a4STom Rini * 565*d18719a4STom Rini * fdt_get_property() retrieves a pointer to the fdt_property 566*d18719a4STom Rini * structure within the device tree blob corresponding to the property 567*d18719a4STom Rini * named 'name' of the node at offset nodeoffset. If lenp is 568*d18719a4STom Rini * non-NULL, the length of the property value is also returned, in the 569*d18719a4STom Rini * integer pointed to by lenp. 570*d18719a4STom Rini * 571*d18719a4STom Rini * returns: 572*d18719a4STom Rini * pointer to the structure representing the property 573*d18719a4STom Rini * if lenp is non-NULL, *lenp contains the length of the property 574*d18719a4STom Rini * value (>=0) 575*d18719a4STom Rini * NULL, on error 576*d18719a4STom Rini * if lenp is non-NULL, *lenp contains an error code (<0): 577*d18719a4STom Rini * -FDT_ERR_NOTFOUND, node does not have named property 578*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE 579*d18719a4STom Rini * tag 580*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 581*d18719a4STom Rini * -FDT_ERR_BADVERSION, 582*d18719a4STom Rini * -FDT_ERR_BADSTATE, 583*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 584*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 585*d18719a4STom Rini */ 586*d18719a4STom Rini const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset, 587*d18719a4STom Rini const char *name, int *lenp); 588*d18719a4STom Rini static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset, 589*d18719a4STom Rini const char *name, 590*d18719a4STom Rini int *lenp) 591*d18719a4STom Rini { 592*d18719a4STom Rini return (struct fdt_property *)(uintptr_t) 593*d18719a4STom Rini fdt_get_property(fdt, nodeoffset, name, lenp); 594*d18719a4STom Rini } 595*d18719a4STom Rini 596*d18719a4STom Rini /** 597*d18719a4STom Rini * fdt_getprop_by_offset - retrieve the value of a property at a given offset 598*d18719a4STom Rini * @fdt: pointer to the device tree blob 599*d18719a4STom Rini * @ffset: offset of the property to read 600*d18719a4STom Rini * @namep: pointer to a string variable (will be overwritten) or NULL 601*d18719a4STom Rini * @lenp: pointer to an integer variable (will be overwritten) or NULL 602*d18719a4STom Rini * 603*d18719a4STom Rini * fdt_getprop_by_offset() retrieves a pointer to the value of the 604*d18719a4STom Rini * property at structure block offset 'offset' (this will be a pointer 605*d18719a4STom Rini * to within the device blob itself, not a copy of the value). If 606*d18719a4STom Rini * lenp is non-NULL, the length of the property value is also 607*d18719a4STom Rini * returned, in the integer pointed to by lenp. If namep is non-NULL, 608*d18719a4STom Rini * the property's namne will also be returned in the char * pointed to 609*d18719a4STom Rini * by namep (this will be a pointer to within the device tree's string 610*d18719a4STom Rini * block, not a new copy of the name). 611*d18719a4STom Rini * 612*d18719a4STom Rini * returns: 613*d18719a4STom Rini * pointer to the property's value 614*d18719a4STom Rini * if lenp is non-NULL, *lenp contains the length of the property 615*d18719a4STom Rini * value (>=0) 616*d18719a4STom Rini * if namep is non-NULL *namep contiains a pointer to the property 617*d18719a4STom Rini * name. 618*d18719a4STom Rini * NULL, on error 619*d18719a4STom Rini * if lenp is non-NULL, *lenp contains an error code (<0): 620*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag 621*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 622*d18719a4STom Rini * -FDT_ERR_BADVERSION, 623*d18719a4STom Rini * -FDT_ERR_BADSTATE, 624*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 625*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 626*d18719a4STom Rini */ 627*d18719a4STom Rini const void *fdt_getprop_by_offset(const void *fdt, int offset, 628*d18719a4STom Rini const char **namep, int *lenp); 629*d18719a4STom Rini 630*d18719a4STom Rini /** 631*d18719a4STom Rini * fdt_getprop_namelen - get property value based on substring 632*d18719a4STom Rini * @fdt: pointer to the device tree blob 633*d18719a4STom Rini * @nodeoffset: offset of the node whose property to find 634*d18719a4STom Rini * @name: name of the property to find 635*d18719a4STom Rini * @namelen: number of characters of name to consider 636*d18719a4STom Rini * @lenp: pointer to an integer variable (will be overwritten) or NULL 637*d18719a4STom Rini * 638*d18719a4STom Rini * Identical to fdt_getprop(), but only examine the first namelen 639*d18719a4STom Rini * characters of name for matching the property name. 640*d18719a4STom Rini */ 641*d18719a4STom Rini const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, 642*d18719a4STom Rini const char *name, int namelen, int *lenp); 643*d18719a4STom Rini static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset, 644*d18719a4STom Rini const char *name, int namelen, 645*d18719a4STom Rini int *lenp) 646*d18719a4STom Rini { 647*d18719a4STom Rini return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name, 648*d18719a4STom Rini namelen, lenp); 649*d18719a4STom Rini } 650*d18719a4STom Rini 651*d18719a4STom Rini /** 652*d18719a4STom Rini * fdt_getprop - retrieve the value of a given property 653*d18719a4STom Rini * @fdt: pointer to the device tree blob 654*d18719a4STom Rini * @nodeoffset: offset of the node whose property to find 655*d18719a4STom Rini * @name: name of the property to find 656*d18719a4STom Rini * @lenp: pointer to an integer variable (will be overwritten) or NULL 657*d18719a4STom Rini * 658*d18719a4STom Rini * fdt_getprop() retrieves a pointer to the value of the property 659*d18719a4STom Rini * named 'name' of the node at offset nodeoffset (this will be a 660*d18719a4STom Rini * pointer to within the device blob itself, not a copy of the value). 661*d18719a4STom Rini * If lenp is non-NULL, the length of the property value is also 662*d18719a4STom Rini * returned, in the integer pointed to by lenp. 663*d18719a4STom Rini * 664*d18719a4STom Rini * returns: 665*d18719a4STom Rini * pointer to the property's value 666*d18719a4STom Rini * if lenp is non-NULL, *lenp contains the length of the property 667*d18719a4STom Rini * value (>=0) 668*d18719a4STom Rini * NULL, on error 669*d18719a4STom Rini * if lenp is non-NULL, *lenp contains an error code (<0): 670*d18719a4STom Rini * -FDT_ERR_NOTFOUND, node does not have named property 671*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE 672*d18719a4STom Rini * tag 673*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 674*d18719a4STom Rini * -FDT_ERR_BADVERSION, 675*d18719a4STom Rini * -FDT_ERR_BADSTATE, 676*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 677*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 678*d18719a4STom Rini */ 679*d18719a4STom Rini const void *fdt_getprop(const void *fdt, int nodeoffset, 680*d18719a4STom Rini const char *name, int *lenp); 681*d18719a4STom Rini static inline void *fdt_getprop_w(void *fdt, int nodeoffset, 682*d18719a4STom Rini const char *name, int *lenp) 683*d18719a4STom Rini { 684*d18719a4STom Rini return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp); 685*d18719a4STom Rini } 686*d18719a4STom Rini 687*d18719a4STom Rini /** 688*d18719a4STom Rini * fdt_get_phandle - retrieve the phandle of a given node 689*d18719a4STom Rini * @fdt: pointer to the device tree blob 690*d18719a4STom Rini * @nodeoffset: structure block offset of the node 691*d18719a4STom Rini * 692*d18719a4STom Rini * fdt_get_phandle() retrieves the phandle of the device tree node at 693*d18719a4STom Rini * structure block offset nodeoffset. 694*d18719a4STom Rini * 695*d18719a4STom Rini * returns: 696*d18719a4STom Rini * the phandle of the node at nodeoffset, on success (!= 0, != -1) 697*d18719a4STom Rini * 0, if the node has no phandle, or another error occurs 698*d18719a4STom Rini */ 699*d18719a4STom Rini uint32_t fdt_get_phandle(const void *fdt, int nodeoffset); 700*d18719a4STom Rini 701*d18719a4STom Rini /** 702*d18719a4STom Rini * fdt_get_alias_namelen - get alias based on substring 703*d18719a4STom Rini * @fdt: pointer to the device tree blob 704*d18719a4STom Rini * @name: name of the alias th look up 705*d18719a4STom Rini * @namelen: number of characters of name to consider 706*d18719a4STom Rini * 707*d18719a4STom Rini * Identical to fdt_get_alias(), but only examine the first namelen 708*d18719a4STom Rini * characters of name for matching the alias name. 709*d18719a4STom Rini */ 710*d18719a4STom Rini const char *fdt_get_alias_namelen(const void *fdt, 711*d18719a4STom Rini const char *name, int namelen); 712*d18719a4STom Rini 713*d18719a4STom Rini /** 714*d18719a4STom Rini * fdt_get_alias - retrieve the path referenced by a given alias 715*d18719a4STom Rini * @fdt: pointer to the device tree blob 716*d18719a4STom Rini * @name: name of the alias th look up 717*d18719a4STom Rini * 718*d18719a4STom Rini * fdt_get_alias() retrieves the value of a given alias. That is, the 719*d18719a4STom Rini * value of the property named 'name' in the node /aliases. 720*d18719a4STom Rini * 721*d18719a4STom Rini * returns: 722*d18719a4STom Rini * a pointer to the expansion of the alias named 'name', if it exists 723*d18719a4STom Rini * NULL, if the given alias or the /aliases node does not exist 724*d18719a4STom Rini */ 725*d18719a4STom Rini const char *fdt_get_alias(const void *fdt, const char *name); 726*d18719a4STom Rini 727*d18719a4STom Rini /** 728*d18719a4STom Rini * fdt_get_path - determine the full path of a node 729*d18719a4STom Rini * @fdt: pointer to the device tree blob 730*d18719a4STom Rini * @nodeoffset: offset of the node whose path to find 731*d18719a4STom Rini * @buf: character buffer to contain the returned path (will be overwritten) 732*d18719a4STom Rini * @buflen: size of the character buffer at buf 733*d18719a4STom Rini * 734*d18719a4STom Rini * fdt_get_path() computes the full path of the node at offset 735*d18719a4STom Rini * nodeoffset, and records that path in the buffer at buf. 736*d18719a4STom Rini * 737*d18719a4STom Rini * NOTE: This function is expensive, as it must scan the device tree 738*d18719a4STom Rini * structure from the start to nodeoffset. 739*d18719a4STom Rini * 740*d18719a4STom Rini * returns: 741*d18719a4STom Rini * 0, on success 742*d18719a4STom Rini * buf contains the absolute path of the node at 743*d18719a4STom Rini * nodeoffset, as a NUL-terminated string. 744*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 745*d18719a4STom Rini * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1) 746*d18719a4STom Rini * characters and will not fit in the given buffer. 747*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 748*d18719a4STom Rini * -FDT_ERR_BADVERSION, 749*d18719a4STom Rini * -FDT_ERR_BADSTATE, 750*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, standard meanings 751*d18719a4STom Rini */ 752*d18719a4STom Rini int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen); 753*d18719a4STom Rini 754*d18719a4STom Rini /** 755*d18719a4STom Rini * fdt_supernode_atdepth_offset - find a specific ancestor of a node 756*d18719a4STom Rini * @fdt: pointer to the device tree blob 757*d18719a4STom Rini * @nodeoffset: offset of the node whose parent to find 758*d18719a4STom Rini * @supernodedepth: depth of the ancestor to find 759*d18719a4STom Rini * @nodedepth: pointer to an integer variable (will be overwritten) or NULL 760*d18719a4STom Rini * 761*d18719a4STom Rini * fdt_supernode_atdepth_offset() finds an ancestor of the given node 762*d18719a4STom Rini * at a specific depth from the root (where the root itself has depth 763*d18719a4STom Rini * 0, its immediate subnodes depth 1 and so forth). So 764*d18719a4STom Rini * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL); 765*d18719a4STom Rini * will always return 0, the offset of the root node. If the node at 766*d18719a4STom Rini * nodeoffset has depth D, then: 767*d18719a4STom Rini * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL); 768*d18719a4STom Rini * will return nodeoffset itself. 769*d18719a4STom Rini * 770*d18719a4STom Rini * NOTE: This function is expensive, as it must scan the device tree 771*d18719a4STom Rini * structure from the start to nodeoffset. 772*d18719a4STom Rini * 773*d18719a4STom Rini * returns: 774*d18719a4STom Rini * structure block offset of the node at node offset's ancestor 775*d18719a4STom Rini * of depth supernodedepth (>=0), on success 776*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 777*d18719a4STom Rini * -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of 778*d18719a4STom Rini * nodeoffset 779*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 780*d18719a4STom Rini * -FDT_ERR_BADVERSION, 781*d18719a4STom Rini * -FDT_ERR_BADSTATE, 782*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, standard meanings 783*d18719a4STom Rini */ 784*d18719a4STom Rini int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset, 785*d18719a4STom Rini int supernodedepth, int *nodedepth); 786*d18719a4STom Rini 787*d18719a4STom Rini /** 788*d18719a4STom Rini * fdt_node_depth - find the depth of a given node 789*d18719a4STom Rini * @fdt: pointer to the device tree blob 790*d18719a4STom Rini * @nodeoffset: offset of the node whose parent to find 791*d18719a4STom Rini * 792*d18719a4STom Rini * fdt_node_depth() finds the depth of a given node. The root node 793*d18719a4STom Rini * has depth 0, its immediate subnodes depth 1 and so forth. 794*d18719a4STom Rini * 795*d18719a4STom Rini * NOTE: This function is expensive, as it must scan the device tree 796*d18719a4STom Rini * structure from the start to nodeoffset. 797*d18719a4STom Rini * 798*d18719a4STom Rini * returns: 799*d18719a4STom Rini * depth of the node at nodeoffset (>=0), on success 800*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 801*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 802*d18719a4STom Rini * -FDT_ERR_BADVERSION, 803*d18719a4STom Rini * -FDT_ERR_BADSTATE, 804*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, standard meanings 805*d18719a4STom Rini */ 806*d18719a4STom Rini int fdt_node_depth(const void *fdt, int nodeoffset); 807*d18719a4STom Rini 808*d18719a4STom Rini /** 809*d18719a4STom Rini * fdt_parent_offset - find the parent of a given node 810*d18719a4STom Rini * @fdt: pointer to the device tree blob 811*d18719a4STom Rini * @nodeoffset: offset of the node whose parent to find 812*d18719a4STom Rini * 813*d18719a4STom Rini * fdt_parent_offset() locates the parent node of a given node (that 814*d18719a4STom Rini * is, it finds the offset of the node which contains the node at 815*d18719a4STom Rini * nodeoffset as a subnode). 816*d18719a4STom Rini * 817*d18719a4STom Rini * NOTE: This function is expensive, as it must scan the device tree 818*d18719a4STom Rini * structure from the start to nodeoffset, *twice*. 819*d18719a4STom Rini * 820*d18719a4STom Rini * returns: 821*d18719a4STom Rini * structure block offset of the parent of the node at nodeoffset 822*d18719a4STom Rini * (>=0), on success 823*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 824*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 825*d18719a4STom Rini * -FDT_ERR_BADVERSION, 826*d18719a4STom Rini * -FDT_ERR_BADSTATE, 827*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, standard meanings 828*d18719a4STom Rini */ 829*d18719a4STom Rini int fdt_parent_offset(const void *fdt, int nodeoffset); 830*d18719a4STom Rini 831*d18719a4STom Rini /** 832*d18719a4STom Rini * fdt_node_offset_by_prop_value - find nodes with a given property value 833*d18719a4STom Rini * @fdt: pointer to the device tree blob 834*d18719a4STom Rini * @startoffset: only find nodes after this offset 835*d18719a4STom Rini * @propname: property name to check 836*d18719a4STom Rini * @propval: property value to search for 837*d18719a4STom Rini * @proplen: length of the value in propval 838*d18719a4STom Rini * 839*d18719a4STom Rini * fdt_node_offset_by_prop_value() returns the offset of the first 840*d18719a4STom Rini * node after startoffset, which has a property named propname whose 841*d18719a4STom Rini * value is of length proplen and has value equal to propval; or if 842*d18719a4STom Rini * startoffset is -1, the very first such node in the tree. 843*d18719a4STom Rini * 844*d18719a4STom Rini * To iterate through all nodes matching the criterion, the following 845*d18719a4STom Rini * idiom can be used: 846*d18719a4STom Rini * offset = fdt_node_offset_by_prop_value(fdt, -1, propname, 847*d18719a4STom Rini * propval, proplen); 848*d18719a4STom Rini * while (offset != -FDT_ERR_NOTFOUND) { 849*d18719a4STom Rini * // other code here 850*d18719a4STom Rini * offset = fdt_node_offset_by_prop_value(fdt, offset, propname, 851*d18719a4STom Rini * propval, proplen); 852*d18719a4STom Rini * } 853*d18719a4STom Rini * 854*d18719a4STom Rini * Note the -1 in the first call to the function, if 0 is used here 855*d18719a4STom Rini * instead, the function will never locate the root node, even if it 856*d18719a4STom Rini * matches the criterion. 857*d18719a4STom Rini * 858*d18719a4STom Rini * returns: 859*d18719a4STom Rini * structure block offset of the located node (>= 0, >startoffset), 860*d18719a4STom Rini * on success 861*d18719a4STom Rini * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the 862*d18719a4STom Rini * tree after startoffset 863*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 864*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 865*d18719a4STom Rini * -FDT_ERR_BADVERSION, 866*d18719a4STom Rini * -FDT_ERR_BADSTATE, 867*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, standard meanings 868*d18719a4STom Rini */ 869*d18719a4STom Rini int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, 870*d18719a4STom Rini const char *propname, 871*d18719a4STom Rini const void *propval, int proplen); 872*d18719a4STom Rini 873*d18719a4STom Rini /** 874*d18719a4STom Rini * fdt_node_offset_by_phandle - find the node with a given phandle 875*d18719a4STom Rini * @fdt: pointer to the device tree blob 876*d18719a4STom Rini * @phandle: phandle value 877*d18719a4STom Rini * 878*d18719a4STom Rini * fdt_node_offset_by_phandle() returns the offset of the node 879*d18719a4STom Rini * which has the given phandle value. If there is more than one node 880*d18719a4STom Rini * in the tree with the given phandle (an invalid tree), results are 881*d18719a4STom Rini * undefined. 882*d18719a4STom Rini * 883*d18719a4STom Rini * returns: 884*d18719a4STom Rini * structure block offset of the located node (>= 0), on success 885*d18719a4STom Rini * -FDT_ERR_NOTFOUND, no node with that phandle exists 886*d18719a4STom Rini * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1) 887*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 888*d18719a4STom Rini * -FDT_ERR_BADVERSION, 889*d18719a4STom Rini * -FDT_ERR_BADSTATE, 890*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, standard meanings 891*d18719a4STom Rini */ 892*d18719a4STom Rini int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle); 893*d18719a4STom Rini 894*d18719a4STom Rini /** 895*d18719a4STom Rini * fdt_node_check_compatible: check a node's compatible property 896*d18719a4STom Rini * @fdt: pointer to the device tree blob 897*d18719a4STom Rini * @nodeoffset: offset of a tree node 898*d18719a4STom Rini * @compatible: string to match against 899*d18719a4STom Rini * 900*d18719a4STom Rini * 901*d18719a4STom Rini * fdt_node_check_compatible() returns 0 if the given node contains a 902*d18719a4STom Rini * 'compatible' property with the given string as one of its elements, 903*d18719a4STom Rini * it returns non-zero otherwise, or on error. 904*d18719a4STom Rini * 905*d18719a4STom Rini * returns: 906*d18719a4STom Rini * 0, if the node has a 'compatible' property listing the given string 907*d18719a4STom Rini * 1, if the node has a 'compatible' property, but it does not list 908*d18719a4STom Rini * the given string 909*d18719a4STom Rini * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property 910*d18719a4STom Rini * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag 911*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 912*d18719a4STom Rini * -FDT_ERR_BADVERSION, 913*d18719a4STom Rini * -FDT_ERR_BADSTATE, 914*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, standard meanings 915*d18719a4STom Rini */ 916*d18719a4STom Rini int fdt_node_check_compatible(const void *fdt, int nodeoffset, 917*d18719a4STom Rini const char *compatible); 918*d18719a4STom Rini 919*d18719a4STom Rini /** 920*d18719a4STom Rini * fdt_node_offset_by_compatible - find nodes with a given 'compatible' value 921*d18719a4STom Rini * @fdt: pointer to the device tree blob 922*d18719a4STom Rini * @startoffset: only find nodes after this offset 923*d18719a4STom Rini * @compatible: 'compatible' string to match against 924*d18719a4STom Rini * 925*d18719a4STom Rini * fdt_node_offset_by_compatible() returns the offset of the first 926*d18719a4STom Rini * node after startoffset, which has a 'compatible' property which 927*d18719a4STom Rini * lists the given compatible string; or if startoffset is -1, the 928*d18719a4STom Rini * very first such node in the tree. 929*d18719a4STom Rini * 930*d18719a4STom Rini * To iterate through all nodes matching the criterion, the following 931*d18719a4STom Rini * idiom can be used: 932*d18719a4STom Rini * offset = fdt_node_offset_by_compatible(fdt, -1, compatible); 933*d18719a4STom Rini * while (offset != -FDT_ERR_NOTFOUND) { 934*d18719a4STom Rini * // other code here 935*d18719a4STom Rini * offset = fdt_node_offset_by_compatible(fdt, offset, compatible); 936*d18719a4STom Rini * } 937*d18719a4STom Rini * 938*d18719a4STom Rini * Note the -1 in the first call to the function, if 0 is used here 939*d18719a4STom Rini * instead, the function will never locate the root node, even if it 940*d18719a4STom Rini * matches the criterion. 941*d18719a4STom Rini * 942*d18719a4STom Rini * returns: 943*d18719a4STom Rini * structure block offset of the located node (>= 0, >startoffset), 944*d18719a4STom Rini * on success 945*d18719a4STom Rini * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the 946*d18719a4STom Rini * tree after startoffset 947*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 948*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 949*d18719a4STom Rini * -FDT_ERR_BADVERSION, 950*d18719a4STom Rini * -FDT_ERR_BADSTATE, 951*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, standard meanings 952*d18719a4STom Rini */ 953*d18719a4STom Rini int fdt_node_offset_by_compatible(const void *fdt, int startoffset, 954*d18719a4STom Rini const char *compatible); 955*d18719a4STom Rini 956*d18719a4STom Rini /** 957*d18719a4STom Rini * fdt_stringlist_contains - check a string list property for a string 958*d18719a4STom Rini * @strlist: Property containing a list of strings to check 959*d18719a4STom Rini * @listlen: Length of property 960*d18719a4STom Rini * @str: String to search for 961*d18719a4STom Rini * 962*d18719a4STom Rini * This is a utility function provided for convenience. The list contains 963*d18719a4STom Rini * one or more strings, each terminated by \0, as is found in a device tree 964*d18719a4STom Rini * "compatible" property. 965*d18719a4STom Rini * 966*d18719a4STom Rini * @return: 1 if the string is found in the list, 0 not found, or invalid list 967*d18719a4STom Rini */ 968*d18719a4STom Rini int fdt_stringlist_contains(const char *strlist, int listlen, const char *str); 969*d18719a4STom Rini 970*d18719a4STom Rini /** 971*d18719a4STom Rini * fdt_stringlist_count - count the number of strings in a string list 972*d18719a4STom Rini * @fdt: pointer to the device tree blob 973*d18719a4STom Rini * @nodeoffset: offset of a tree node 974*d18719a4STom Rini * @property: name of the property containing the string list 975*d18719a4STom Rini * @return: 976*d18719a4STom Rini * the number of strings in the given property 977*d18719a4STom Rini * -FDT_ERR_BADVALUE if the property value is not NUL-terminated 978*d18719a4STom Rini * -FDT_ERR_NOTFOUND if the property does not exist 979*d18719a4STom Rini */ 980*d18719a4STom Rini int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property); 981*d18719a4STom Rini 982*d18719a4STom Rini /** 983*d18719a4STom Rini * fdt_stringlist_search - find a string in a string list and return its index 984*d18719a4STom Rini * @fdt: pointer to the device tree blob 985*d18719a4STom Rini * @nodeoffset: offset of a tree node 986*d18719a4STom Rini * @property: name of the property containing the string list 987*d18719a4STom Rini * @string: string to look up in the string list 988*d18719a4STom Rini * 989*d18719a4STom Rini * Note that it is possible for this function to succeed on property values 990*d18719a4STom Rini * that are not NUL-terminated. That's because the function will stop after 991*d18719a4STom Rini * finding the first occurrence of @string. This can for example happen with 992*d18719a4STom Rini * small-valued cell properties, such as #address-cells, when searching for 993*d18719a4STom Rini * the empty string. 994*d18719a4STom Rini * 995*d18719a4STom Rini * @return: 996*d18719a4STom Rini * the index of the string in the list of strings 997*d18719a4STom Rini * -FDT_ERR_BADVALUE if the property value is not NUL-terminated 998*d18719a4STom Rini * -FDT_ERR_NOTFOUND if the property does not exist or does not contain 999*d18719a4STom Rini * the given string 1000*d18719a4STom Rini */ 1001*d18719a4STom Rini int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property, 1002*d18719a4STom Rini const char *string); 1003*d18719a4STom Rini 1004*d18719a4STom Rini /** 1005*d18719a4STom Rini * fdt_stringlist_get() - obtain the string at a given index in a string list 1006*d18719a4STom Rini * @fdt: pointer to the device tree blob 1007*d18719a4STom Rini * @nodeoffset: offset of a tree node 1008*d18719a4STom Rini * @property: name of the property containing the string list 1009*d18719a4STom Rini * @index: index of the string to return 1010*d18719a4STom Rini * @lenp: return location for the string length or an error code on failure 1011*d18719a4STom Rini * 1012*d18719a4STom Rini * Note that this will successfully extract strings from properties with 1013*d18719a4STom Rini * non-NUL-terminated values. For example on small-valued cell properties 1014*d18719a4STom Rini * this function will return the empty string. 1015*d18719a4STom Rini * 1016*d18719a4STom Rini * If non-NULL, the length of the string (on success) or a negative error-code 1017*d18719a4STom Rini * (on failure) will be stored in the integer pointer to by lenp. 1018*d18719a4STom Rini * 1019*d18719a4STom Rini * @return: 1020*d18719a4STom Rini * A pointer to the string at the given index in the string list or NULL on 1021*d18719a4STom Rini * failure. On success the length of the string will be stored in the memory 1022*d18719a4STom Rini * location pointed to by the lenp parameter, if non-NULL. On failure one of 1023*d18719a4STom Rini * the following negative error codes will be returned in the lenp parameter 1024*d18719a4STom Rini * (if non-NULL): 1025*d18719a4STom Rini * -FDT_ERR_BADVALUE if the property value is not NUL-terminated 1026*d18719a4STom Rini * -FDT_ERR_NOTFOUND if the property does not exist 1027*d18719a4STom Rini */ 1028*d18719a4STom Rini const char *fdt_stringlist_get(const void *fdt, int nodeoffset, 1029*d18719a4STom Rini const char *property, int index, 1030*d18719a4STom Rini int *lenp); 1031*d18719a4STom Rini 1032*d18719a4STom Rini /**********************************************************************/ 1033*d18719a4STom Rini /* Read-only functions (addressing related) */ 1034*d18719a4STom Rini /**********************************************************************/ 1035*d18719a4STom Rini 1036*d18719a4STom Rini /** 1037*d18719a4STom Rini * FDT_MAX_NCELLS - maximum value for #address-cells and #size-cells 1038*d18719a4STom Rini * 1039*d18719a4STom Rini * This is the maximum value for #address-cells, #size-cells and 1040*d18719a4STom Rini * similar properties that will be processed by libfdt. IEE1275 1041*d18719a4STom Rini * requires that OF implementations handle values up to 4. 1042*d18719a4STom Rini * Implementations may support larger values, but in practice higher 1043*d18719a4STom Rini * values aren't used. 1044*d18719a4STom Rini */ 1045*d18719a4STom Rini #define FDT_MAX_NCELLS 4 1046*d18719a4STom Rini 1047*d18719a4STom Rini /** 1048*d18719a4STom Rini * fdt_address_cells - retrieve address size for a bus represented in the tree 1049*d18719a4STom Rini * @fdt: pointer to the device tree blob 1050*d18719a4STom Rini * @nodeoffset: offset of the node to find the address size for 1051*d18719a4STom Rini * 1052*d18719a4STom Rini * When the node has a valid #address-cells property, returns its value. 1053*d18719a4STom Rini * 1054*d18719a4STom Rini * returns: 1055*d18719a4STom Rini * 0 <= n < FDT_MAX_NCELLS, on success 1056*d18719a4STom Rini * 2, if the node has no #address-cells property 1057*d18719a4STom Rini * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid 1058*d18719a4STom Rini * #address-cells property 1059*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1060*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1061*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1062*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1063*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1064*d18719a4STom Rini */ 1065*d18719a4STom Rini int fdt_address_cells(const void *fdt, int nodeoffset); 1066*d18719a4STom Rini 1067*d18719a4STom Rini /** 1068*d18719a4STom Rini * fdt_size_cells - retrieve address range size for a bus represented in the 1069*d18719a4STom Rini * tree 1070*d18719a4STom Rini * @fdt: pointer to the device tree blob 1071*d18719a4STom Rini * @nodeoffset: offset of the node to find the address range size for 1072*d18719a4STom Rini * 1073*d18719a4STom Rini * When the node has a valid #size-cells property, returns its value. 1074*d18719a4STom Rini * 1075*d18719a4STom Rini * returns: 1076*d18719a4STom Rini * 0 <= n < FDT_MAX_NCELLS, on success 1077*d18719a4STom Rini * 2, if the node has no #address-cells property 1078*d18719a4STom Rini * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid 1079*d18719a4STom Rini * #size-cells property 1080*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1081*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1082*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1083*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1084*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1085*d18719a4STom Rini */ 1086*d18719a4STom Rini int fdt_size_cells(const void *fdt, int nodeoffset); 1087*d18719a4STom Rini 1088*d18719a4STom Rini 1089*d18719a4STom Rini /**********************************************************************/ 1090*d18719a4STom Rini /* Write-in-place functions */ 1091*d18719a4STom Rini /**********************************************************************/ 1092*d18719a4STom Rini 1093*d18719a4STom Rini /** 1094*d18719a4STom Rini * fdt_setprop_inplace_namelen_partial - change a property's value, 1095*d18719a4STom Rini * but not its size 1096*d18719a4STom Rini * @fdt: pointer to the device tree blob 1097*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1098*d18719a4STom Rini * @name: name of the property to change 1099*d18719a4STom Rini * @namelen: number of characters of name to consider 1100*d18719a4STom Rini * @idx: index of the property to change in the array 1101*d18719a4STom Rini * @val: pointer to data to replace the property value with 1102*d18719a4STom Rini * @len: length of the property value 1103*d18719a4STom Rini * 1104*d18719a4STom Rini * Identical to fdt_setprop_inplace(), but modifies the given property 1105*d18719a4STom Rini * starting from the given index, and using only the first characters 1106*d18719a4STom Rini * of the name. It is useful when you want to manipulate only one value of 1107*d18719a4STom Rini * an array and you have a string that doesn't end with \0. 1108*d18719a4STom Rini */ 1109*d18719a4STom Rini int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, 1110*d18719a4STom Rini const char *name, int namelen, 1111*d18719a4STom Rini uint32_t idx, const void *val, 1112*d18719a4STom Rini int len); 1113*d18719a4STom Rini 1114*d18719a4STom Rini /** 1115*d18719a4STom Rini * fdt_setprop_inplace - change a property's value, but not its size 1116*d18719a4STom Rini * @fdt: pointer to the device tree blob 1117*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1118*d18719a4STom Rini * @name: name of the property to change 1119*d18719a4STom Rini * @val: pointer to data to replace the property value with 1120*d18719a4STom Rini * @len: length of the property value 1121*d18719a4STom Rini * 1122*d18719a4STom Rini * fdt_setprop_inplace() replaces the value of a given property with 1123*d18719a4STom Rini * the data in val, of length len. This function cannot change the 1124*d18719a4STom Rini * size of a property, and so will only work if len is equal to the 1125*d18719a4STom Rini * current length of the property. 1126*d18719a4STom Rini * 1127*d18719a4STom Rini * This function will alter only the bytes in the blob which contain 1128*d18719a4STom Rini * the given property value, and will not alter or move any other part 1129*d18719a4STom Rini * of the tree. 1130*d18719a4STom Rini * 1131*d18719a4STom Rini * returns: 1132*d18719a4STom Rini * 0, on success 1133*d18719a4STom Rini * -FDT_ERR_NOSPACE, if len is not equal to the property's current length 1134*d18719a4STom Rini * -FDT_ERR_NOTFOUND, node does not have the named property 1135*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1136*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1137*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1138*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1139*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1140*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1141*d18719a4STom Rini */ 1142*d18719a4STom Rini int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, 1143*d18719a4STom Rini const void *val, int len); 1144*d18719a4STom Rini 1145*d18719a4STom Rini /** 1146*d18719a4STom Rini * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property 1147*d18719a4STom Rini * @fdt: pointer to the device tree blob 1148*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1149*d18719a4STom Rini * @name: name of the property to change 1150*d18719a4STom Rini * @val: 32-bit integer value to replace the property with 1151*d18719a4STom Rini * 1152*d18719a4STom Rini * fdt_setprop_inplace_u32() replaces the value of a given property 1153*d18719a4STom Rini * with the 32-bit integer value in val, converting val to big-endian 1154*d18719a4STom Rini * if necessary. This function cannot change the size of a property, 1155*d18719a4STom Rini * and so will only work if the property already exists and has length 1156*d18719a4STom Rini * 4. 1157*d18719a4STom Rini * 1158*d18719a4STom Rini * This function will alter only the bytes in the blob which contain 1159*d18719a4STom Rini * the given property value, and will not alter or move any other part 1160*d18719a4STom Rini * of the tree. 1161*d18719a4STom Rini * 1162*d18719a4STom Rini * returns: 1163*d18719a4STom Rini * 0, on success 1164*d18719a4STom Rini * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 1165*d18719a4STom Rini * -FDT_ERR_NOTFOUND, node does not have the named property 1166*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1167*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1168*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1169*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1170*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1171*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1172*d18719a4STom Rini */ 1173*d18719a4STom Rini static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, 1174*d18719a4STom Rini const char *name, uint32_t val) 1175*d18719a4STom Rini { 1176*d18719a4STom Rini fdt32_t tmp = cpu_to_fdt32(val); 1177*d18719a4STom Rini return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp)); 1178*d18719a4STom Rini } 1179*d18719a4STom Rini 1180*d18719a4STom Rini /** 1181*d18719a4STom Rini * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property 1182*d18719a4STom Rini * @fdt: pointer to the device tree blob 1183*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1184*d18719a4STom Rini * @name: name of the property to change 1185*d18719a4STom Rini * @val: 64-bit integer value to replace the property with 1186*d18719a4STom Rini * 1187*d18719a4STom Rini * fdt_setprop_inplace_u64() replaces the value of a given property 1188*d18719a4STom Rini * with the 64-bit integer value in val, converting val to big-endian 1189*d18719a4STom Rini * if necessary. This function cannot change the size of a property, 1190*d18719a4STom Rini * and so will only work if the property already exists and has length 1191*d18719a4STom Rini * 8. 1192*d18719a4STom Rini * 1193*d18719a4STom Rini * This function will alter only the bytes in the blob which contain 1194*d18719a4STom Rini * the given property value, and will not alter or move any other part 1195*d18719a4STom Rini * of the tree. 1196*d18719a4STom Rini * 1197*d18719a4STom Rini * returns: 1198*d18719a4STom Rini * 0, on success 1199*d18719a4STom Rini * -FDT_ERR_NOSPACE, if the property's length is not equal to 8 1200*d18719a4STom Rini * -FDT_ERR_NOTFOUND, node does not have the named property 1201*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1202*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1203*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1204*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1205*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1206*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1207*d18719a4STom Rini */ 1208*d18719a4STom Rini static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, 1209*d18719a4STom Rini const char *name, uint64_t val) 1210*d18719a4STom Rini { 1211*d18719a4STom Rini fdt64_t tmp = cpu_to_fdt64(val); 1212*d18719a4STom Rini return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp)); 1213*d18719a4STom Rini } 1214*d18719a4STom Rini 1215*d18719a4STom Rini /** 1216*d18719a4STom Rini * fdt_setprop_inplace_cell - change the value of a single-cell property 1217*d18719a4STom Rini * 1218*d18719a4STom Rini * This is an alternative name for fdt_setprop_inplace_u32() 1219*d18719a4STom Rini */ 1220*d18719a4STom Rini static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, 1221*d18719a4STom Rini const char *name, uint32_t val) 1222*d18719a4STom Rini { 1223*d18719a4STom Rini return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val); 1224*d18719a4STom Rini } 1225*d18719a4STom Rini 1226*d18719a4STom Rini /** 1227*d18719a4STom Rini * fdt_nop_property - replace a property with nop tags 1228*d18719a4STom Rini * @fdt: pointer to the device tree blob 1229*d18719a4STom Rini * @nodeoffset: offset of the node whose property to nop 1230*d18719a4STom Rini * @name: name of the property to nop 1231*d18719a4STom Rini * 1232*d18719a4STom Rini * fdt_nop_property() will replace a given property's representation 1233*d18719a4STom Rini * in the blob with FDT_NOP tags, effectively removing it from the 1234*d18719a4STom Rini * tree. 1235*d18719a4STom Rini * 1236*d18719a4STom Rini * This function will alter only the bytes in the blob which contain 1237*d18719a4STom Rini * the property, and will not alter or move any other part of the 1238*d18719a4STom Rini * tree. 1239*d18719a4STom Rini * 1240*d18719a4STom Rini * returns: 1241*d18719a4STom Rini * 0, on success 1242*d18719a4STom Rini * -FDT_ERR_NOTFOUND, node does not have the named property 1243*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1244*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1245*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1246*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1247*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1248*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1249*d18719a4STom Rini */ 1250*d18719a4STom Rini int fdt_nop_property(void *fdt, int nodeoffset, const char *name); 1251*d18719a4STom Rini 1252*d18719a4STom Rini /** 1253*d18719a4STom Rini * fdt_nop_node - replace a node (subtree) with nop tags 1254*d18719a4STom Rini * @fdt: pointer to the device tree blob 1255*d18719a4STom Rini * @nodeoffset: offset of the node to nop 1256*d18719a4STom Rini * 1257*d18719a4STom Rini * fdt_nop_node() will replace a given node's representation in the 1258*d18719a4STom Rini * blob, including all its subnodes, if any, with FDT_NOP tags, 1259*d18719a4STom Rini * effectively removing it from the tree. 1260*d18719a4STom Rini * 1261*d18719a4STom Rini * This function will alter only the bytes in the blob which contain 1262*d18719a4STom Rini * the node and its properties and subnodes, and will not alter or 1263*d18719a4STom Rini * move any other part of the tree. 1264*d18719a4STom Rini * 1265*d18719a4STom Rini * returns: 1266*d18719a4STom Rini * 0, on success 1267*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1268*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1269*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1270*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1271*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1272*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1273*d18719a4STom Rini */ 1274*d18719a4STom Rini int fdt_nop_node(void *fdt, int nodeoffset); 1275*d18719a4STom Rini 1276*d18719a4STom Rini /**********************************************************************/ 1277*d18719a4STom Rini /* Sequential write functions */ 1278*d18719a4STom Rini /**********************************************************************/ 1279*d18719a4STom Rini 1280*d18719a4STom Rini int fdt_create(void *buf, int bufsize); 1281*d18719a4STom Rini int fdt_resize(void *fdt, void *buf, int bufsize); 1282*d18719a4STom Rini int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); 1283*d18719a4STom Rini int fdt_finish_reservemap(void *fdt); 1284*d18719a4STom Rini int fdt_begin_node(void *fdt, const char *name); 1285*d18719a4STom Rini int fdt_property(void *fdt, const char *name, const void *val, int len); 1286*d18719a4STom Rini static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val) 1287*d18719a4STom Rini { 1288*d18719a4STom Rini fdt32_t tmp = cpu_to_fdt32(val); 1289*d18719a4STom Rini return fdt_property(fdt, name, &tmp, sizeof(tmp)); 1290*d18719a4STom Rini } 1291*d18719a4STom Rini static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val) 1292*d18719a4STom Rini { 1293*d18719a4STom Rini fdt64_t tmp = cpu_to_fdt64(val); 1294*d18719a4STom Rini return fdt_property(fdt, name, &tmp, sizeof(tmp)); 1295*d18719a4STom Rini } 1296*d18719a4STom Rini static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) 1297*d18719a4STom Rini { 1298*d18719a4STom Rini return fdt_property_u32(fdt, name, val); 1299*d18719a4STom Rini } 1300*d18719a4STom Rini #define fdt_property_string(fdt, name, str) \ 1301*d18719a4STom Rini fdt_property(fdt, name, str, strlen(str)+1) 1302*d18719a4STom Rini int fdt_end_node(void *fdt); 1303*d18719a4STom Rini int fdt_finish(void *fdt); 1304*d18719a4STom Rini 1305*d18719a4STom Rini /**********************************************************************/ 1306*d18719a4STom Rini /* Read-write functions */ 1307*d18719a4STom Rini /**********************************************************************/ 1308*d18719a4STom Rini 1309*d18719a4STom Rini int fdt_create_empty_tree(void *buf, int bufsize); 1310*d18719a4STom Rini int fdt_open_into(const void *fdt, void *buf, int bufsize); 1311*d18719a4STom Rini int fdt_pack(void *fdt); 1312*d18719a4STom Rini 1313*d18719a4STom Rini /** 1314*d18719a4STom Rini * fdt_add_mem_rsv - add one memory reserve map entry 1315*d18719a4STom Rini * @fdt: pointer to the device tree blob 1316*d18719a4STom Rini * @address, @size: 64-bit values (native endian) 1317*d18719a4STom Rini * 1318*d18719a4STom Rini * Adds a reserve map entry to the given blob reserving a region at 1319*d18719a4STom Rini * address address of length size. 1320*d18719a4STom Rini * 1321*d18719a4STom Rini * This function will insert data into the reserve map and will 1322*d18719a4STom Rini * therefore change the indexes of some entries in the table. 1323*d18719a4STom Rini * 1324*d18719a4STom Rini * returns: 1325*d18719a4STom Rini * 0, on success 1326*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1327*d18719a4STom Rini * contain the new reservation entry 1328*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1329*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1330*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1331*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1332*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1333*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1334*d18719a4STom Rini */ 1335*d18719a4STom Rini int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size); 1336*d18719a4STom Rini 1337*d18719a4STom Rini /** 1338*d18719a4STom Rini * fdt_del_mem_rsv - remove a memory reserve map entry 1339*d18719a4STom Rini * @fdt: pointer to the device tree blob 1340*d18719a4STom Rini * @n: entry to remove 1341*d18719a4STom Rini * 1342*d18719a4STom Rini * fdt_del_mem_rsv() removes the n-th memory reserve map entry from 1343*d18719a4STom Rini * the blob. 1344*d18719a4STom Rini * 1345*d18719a4STom Rini * This function will delete data from the reservation table and will 1346*d18719a4STom Rini * therefore change the indexes of some entries in the table. 1347*d18719a4STom Rini * 1348*d18719a4STom Rini * returns: 1349*d18719a4STom Rini * 0, on success 1350*d18719a4STom Rini * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there 1351*d18719a4STom Rini * are less than n+1 reserve map entries) 1352*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1353*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1354*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1355*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1356*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1357*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1358*d18719a4STom Rini */ 1359*d18719a4STom Rini int fdt_del_mem_rsv(void *fdt, int n); 1360*d18719a4STom Rini 1361*d18719a4STom Rini /** 1362*d18719a4STom Rini * fdt_set_name - change the name of a given node 1363*d18719a4STom Rini * @fdt: pointer to the device tree blob 1364*d18719a4STom Rini * @nodeoffset: structure block offset of a node 1365*d18719a4STom Rini * @name: name to give the node 1366*d18719a4STom Rini * 1367*d18719a4STom Rini * fdt_set_name() replaces the name (including unit address, if any) 1368*d18719a4STom Rini * of the given node with the given string. NOTE: this function can't 1369*d18719a4STom Rini * efficiently check if the new name is unique amongst the given 1370*d18719a4STom Rini * node's siblings; results are undefined if this function is invoked 1371*d18719a4STom Rini * with a name equal to one of the given node's siblings. 1372*d18719a4STom Rini * 1373*d18719a4STom Rini * This function may insert or delete data from the blob, and will 1374*d18719a4STom Rini * therefore change the offsets of some existing nodes. 1375*d18719a4STom Rini * 1376*d18719a4STom Rini * returns: 1377*d18719a4STom Rini * 0, on success 1378*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob 1379*d18719a4STom Rini * to contain the new name 1380*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1381*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1382*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1383*d18719a4STom Rini * -FDT_ERR_BADSTATE, standard meanings 1384*d18719a4STom Rini */ 1385*d18719a4STom Rini int fdt_set_name(void *fdt, int nodeoffset, const char *name); 1386*d18719a4STom Rini 1387*d18719a4STom Rini /** 1388*d18719a4STom Rini * fdt_setprop - create or change a property 1389*d18719a4STom Rini * @fdt: pointer to the device tree blob 1390*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1391*d18719a4STom Rini * @name: name of the property to change 1392*d18719a4STom Rini * @val: pointer to data to set the property value to 1393*d18719a4STom Rini * @len: length of the property value 1394*d18719a4STom Rini * 1395*d18719a4STom Rini * fdt_setprop() sets the value of the named property in the given 1396*d18719a4STom Rini * node to the given value and length, creating the property if it 1397*d18719a4STom Rini * does not already exist. 1398*d18719a4STom Rini * 1399*d18719a4STom Rini * This function may insert or delete data from the blob, and will 1400*d18719a4STom Rini * therefore change the offsets of some existing nodes. 1401*d18719a4STom Rini * 1402*d18719a4STom Rini * returns: 1403*d18719a4STom Rini * 0, on success 1404*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1405*d18719a4STom Rini * contain the new property value 1406*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1407*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1408*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1409*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1410*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1411*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1412*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1413*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1414*d18719a4STom Rini */ 1415*d18719a4STom Rini int fdt_setprop(void *fdt, int nodeoffset, const char *name, 1416*d18719a4STom Rini const void *val, int len); 1417*d18719a4STom Rini 1418*d18719a4STom Rini /** 1419*d18719a4STom Rini * fdt_setprop_u32 - set a property to a 32-bit integer 1420*d18719a4STom Rini * @fdt: pointer to the device tree blob 1421*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1422*d18719a4STom Rini * @name: name of the property to change 1423*d18719a4STom Rini * @val: 32-bit integer value for the property (native endian) 1424*d18719a4STom Rini * 1425*d18719a4STom Rini * fdt_setprop_u32() sets the value of the named property in the given 1426*d18719a4STom Rini * node to the given 32-bit integer value (converting to big-endian if 1427*d18719a4STom Rini * necessary), or creates a new property with that value if it does 1428*d18719a4STom Rini * not already exist. 1429*d18719a4STom Rini * 1430*d18719a4STom Rini * This function may insert or delete data from the blob, and will 1431*d18719a4STom Rini * therefore change the offsets of some existing nodes. 1432*d18719a4STom Rini * 1433*d18719a4STom Rini * returns: 1434*d18719a4STom Rini * 0, on success 1435*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1436*d18719a4STom Rini * contain the new property value 1437*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1438*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1439*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1440*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1441*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1442*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1443*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1444*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1445*d18719a4STom Rini */ 1446*d18719a4STom Rini static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, 1447*d18719a4STom Rini uint32_t val) 1448*d18719a4STom Rini { 1449*d18719a4STom Rini fdt32_t tmp = cpu_to_fdt32(val); 1450*d18719a4STom Rini return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); 1451*d18719a4STom Rini } 1452*d18719a4STom Rini 1453*d18719a4STom Rini /** 1454*d18719a4STom Rini * fdt_setprop_u64 - set a property to a 64-bit integer 1455*d18719a4STom Rini * @fdt: pointer to the device tree blob 1456*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1457*d18719a4STom Rini * @name: name of the property to change 1458*d18719a4STom Rini * @val: 64-bit integer value for the property (native endian) 1459*d18719a4STom Rini * 1460*d18719a4STom Rini * fdt_setprop_u64() sets the value of the named property in the given 1461*d18719a4STom Rini * node to the given 64-bit integer value (converting to big-endian if 1462*d18719a4STom Rini * necessary), or creates a new property with that value if it does 1463*d18719a4STom Rini * not already exist. 1464*d18719a4STom Rini * 1465*d18719a4STom Rini * This function may insert or delete data from the blob, and will 1466*d18719a4STom Rini * therefore change the offsets of some existing nodes. 1467*d18719a4STom Rini * 1468*d18719a4STom Rini * returns: 1469*d18719a4STom Rini * 0, on success 1470*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1471*d18719a4STom Rini * contain the new property value 1472*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1473*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1474*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1475*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1476*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1477*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1478*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1479*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1480*d18719a4STom Rini */ 1481*d18719a4STom Rini static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, 1482*d18719a4STom Rini uint64_t val) 1483*d18719a4STom Rini { 1484*d18719a4STom Rini fdt64_t tmp = cpu_to_fdt64(val); 1485*d18719a4STom Rini return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); 1486*d18719a4STom Rini } 1487*d18719a4STom Rini 1488*d18719a4STom Rini /** 1489*d18719a4STom Rini * fdt_setprop_cell - set a property to a single cell value 1490*d18719a4STom Rini * 1491*d18719a4STom Rini * This is an alternative name for fdt_setprop_u32() 1492*d18719a4STom Rini */ 1493*d18719a4STom Rini static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, 1494*d18719a4STom Rini uint32_t val) 1495*d18719a4STom Rini { 1496*d18719a4STom Rini return fdt_setprop_u32(fdt, nodeoffset, name, val); 1497*d18719a4STom Rini } 1498*d18719a4STom Rini 1499*d18719a4STom Rini /** 1500*d18719a4STom Rini * fdt_setprop_string - set a property to a string value 1501*d18719a4STom Rini * @fdt: pointer to the device tree blob 1502*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1503*d18719a4STom Rini * @name: name of the property to change 1504*d18719a4STom Rini * @str: string value for the property 1505*d18719a4STom Rini * 1506*d18719a4STom Rini * fdt_setprop_string() sets the value of the named property in the 1507*d18719a4STom Rini * given node to the given string value (using the length of the 1508*d18719a4STom Rini * string to determine the new length of the property), or creates a 1509*d18719a4STom Rini * new property with that value if it does not already exist. 1510*d18719a4STom Rini * 1511*d18719a4STom Rini * This function may insert or delete data from the blob, and will 1512*d18719a4STom Rini * therefore change the offsets of some existing nodes. 1513*d18719a4STom Rini * 1514*d18719a4STom Rini * returns: 1515*d18719a4STom Rini * 0, on success 1516*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1517*d18719a4STom Rini * contain the new property value 1518*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1519*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1520*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1521*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1522*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1523*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1524*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1525*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1526*d18719a4STom Rini */ 1527*d18719a4STom Rini #define fdt_setprop_string(fdt, nodeoffset, name, str) \ 1528*d18719a4STom Rini fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1529*d18719a4STom Rini 1530*d18719a4STom Rini 1531*d18719a4STom Rini /** 1532*d18719a4STom Rini * fdt_setprop_empty - set a property to an empty value 1533*d18719a4STom Rini * @fdt: pointer to the device tree blob 1534*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1535*d18719a4STom Rini * @name: name of the property to change 1536*d18719a4STom Rini * 1537*d18719a4STom Rini * fdt_setprop_empty() sets the value of the named property in the 1538*d18719a4STom Rini * given node to an empty (zero length) value, or creates a new empty 1539*d18719a4STom Rini * property if it does not already exist. 1540*d18719a4STom Rini * 1541*d18719a4STom Rini * This function may insert or delete data from the blob, and will 1542*d18719a4STom Rini * therefore change the offsets of some existing nodes. 1543*d18719a4STom Rini * 1544*d18719a4STom Rini * returns: 1545*d18719a4STom Rini * 0, on success 1546*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1547*d18719a4STom Rini * contain the new property value 1548*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1549*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1550*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1551*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1552*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1553*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1554*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1555*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1556*d18719a4STom Rini */ 1557*d18719a4STom Rini #define fdt_setprop_empty(fdt, nodeoffset, name) \ 1558*d18719a4STom Rini fdt_setprop((fdt), (nodeoffset), (name), NULL, 0) 1559*d18719a4STom Rini 1560*d18719a4STom Rini /** 1561*d18719a4STom Rini * fdt_appendprop - append to or create a property 1562*d18719a4STom Rini * @fdt: pointer to the device tree blob 1563*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1564*d18719a4STom Rini * @name: name of the property to append to 1565*d18719a4STom Rini * @val: pointer to data to append to the property value 1566*d18719a4STom Rini * @len: length of the data to append to the property value 1567*d18719a4STom Rini * 1568*d18719a4STom Rini * fdt_appendprop() appends the value to the named property in the 1569*d18719a4STom Rini * given node, creating the property if it does not already exist. 1570*d18719a4STom Rini * 1571*d18719a4STom Rini * This function may insert data into the blob, and will therefore 1572*d18719a4STom Rini * change the offsets of some existing nodes. 1573*d18719a4STom Rini * 1574*d18719a4STom Rini * returns: 1575*d18719a4STom Rini * 0, on success 1576*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1577*d18719a4STom Rini * contain the new property value 1578*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1579*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1580*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1581*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1582*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1583*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1584*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1585*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1586*d18719a4STom Rini */ 1587*d18719a4STom Rini int fdt_appendprop(void *fdt, int nodeoffset, const char *name, 1588*d18719a4STom Rini const void *val, int len); 1589*d18719a4STom Rini 1590*d18719a4STom Rini /** 1591*d18719a4STom Rini * fdt_appendprop_u32 - append a 32-bit integer value to a property 1592*d18719a4STom Rini * @fdt: pointer to the device tree blob 1593*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1594*d18719a4STom Rini * @name: name of the property to change 1595*d18719a4STom Rini * @val: 32-bit integer value to append to the property (native endian) 1596*d18719a4STom Rini * 1597*d18719a4STom Rini * fdt_appendprop_u32() appends the given 32-bit integer value 1598*d18719a4STom Rini * (converting to big-endian if necessary) to the value of the named 1599*d18719a4STom Rini * property in the given node, or creates a new property with that 1600*d18719a4STom Rini * value if it does not already exist. 1601*d18719a4STom Rini * 1602*d18719a4STom Rini * This function may insert data into the blob, and will therefore 1603*d18719a4STom Rini * change the offsets of some existing nodes. 1604*d18719a4STom Rini * 1605*d18719a4STom Rini * returns: 1606*d18719a4STom Rini * 0, on success 1607*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1608*d18719a4STom Rini * contain the new property value 1609*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1610*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1611*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1612*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1613*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1614*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1615*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1616*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1617*d18719a4STom Rini */ 1618*d18719a4STom Rini static inline int fdt_appendprop_u32(void *fdt, int nodeoffset, 1619*d18719a4STom Rini const char *name, uint32_t val) 1620*d18719a4STom Rini { 1621*d18719a4STom Rini fdt32_t tmp = cpu_to_fdt32(val); 1622*d18719a4STom Rini return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); 1623*d18719a4STom Rini } 1624*d18719a4STom Rini 1625*d18719a4STom Rini /** 1626*d18719a4STom Rini * fdt_appendprop_u64 - append a 64-bit integer value to a property 1627*d18719a4STom Rini * @fdt: pointer to the device tree blob 1628*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1629*d18719a4STom Rini * @name: name of the property to change 1630*d18719a4STom Rini * @val: 64-bit integer value to append to the property (native endian) 1631*d18719a4STom Rini * 1632*d18719a4STom Rini * fdt_appendprop_u64() appends the given 64-bit integer value 1633*d18719a4STom Rini * (converting to big-endian if necessary) to the value of the named 1634*d18719a4STom Rini * property in the given node, or creates a new property with that 1635*d18719a4STom Rini * value if it does not already exist. 1636*d18719a4STom Rini * 1637*d18719a4STom Rini * This function may insert data into the blob, and will therefore 1638*d18719a4STom Rini * change the offsets of some existing nodes. 1639*d18719a4STom Rini * 1640*d18719a4STom Rini * returns: 1641*d18719a4STom Rini * 0, on success 1642*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1643*d18719a4STom Rini * contain the new property value 1644*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1645*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1646*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1647*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1648*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1649*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1650*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1651*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1652*d18719a4STom Rini */ 1653*d18719a4STom Rini static inline int fdt_appendprop_u64(void *fdt, int nodeoffset, 1654*d18719a4STom Rini const char *name, uint64_t val) 1655*d18719a4STom Rini { 1656*d18719a4STom Rini fdt64_t tmp = cpu_to_fdt64(val); 1657*d18719a4STom Rini return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); 1658*d18719a4STom Rini } 1659*d18719a4STom Rini 1660*d18719a4STom Rini /** 1661*d18719a4STom Rini * fdt_appendprop_cell - append a single cell value to a property 1662*d18719a4STom Rini * 1663*d18719a4STom Rini * This is an alternative name for fdt_appendprop_u32() 1664*d18719a4STom Rini */ 1665*d18719a4STom Rini static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, 1666*d18719a4STom Rini const char *name, uint32_t val) 1667*d18719a4STom Rini { 1668*d18719a4STom Rini return fdt_appendprop_u32(fdt, nodeoffset, name, val); 1669*d18719a4STom Rini } 1670*d18719a4STom Rini 1671*d18719a4STom Rini /** 1672*d18719a4STom Rini * fdt_appendprop_string - append a string to a property 1673*d18719a4STom Rini * @fdt: pointer to the device tree blob 1674*d18719a4STom Rini * @nodeoffset: offset of the node whose property to change 1675*d18719a4STom Rini * @name: name of the property to change 1676*d18719a4STom Rini * @str: string value to append to the property 1677*d18719a4STom Rini * 1678*d18719a4STom Rini * fdt_appendprop_string() appends the given string to the value of 1679*d18719a4STom Rini * the named property in the given node, or creates a new property 1680*d18719a4STom Rini * with that value if it does not already exist. 1681*d18719a4STom Rini * 1682*d18719a4STom Rini * This function may insert data into the blob, and will therefore 1683*d18719a4STom Rini * change the offsets of some existing nodes. 1684*d18719a4STom Rini * 1685*d18719a4STom Rini * returns: 1686*d18719a4STom Rini * 0, on success 1687*d18719a4STom Rini * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1688*d18719a4STom Rini * contain the new property value 1689*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1690*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1691*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1692*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1693*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1694*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1695*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1696*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1697*d18719a4STom Rini */ 1698*d18719a4STom Rini #define fdt_appendprop_string(fdt, nodeoffset, name, str) \ 1699*d18719a4STom Rini fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1700*d18719a4STom Rini 1701*d18719a4STom Rini /** 1702*d18719a4STom Rini * fdt_delprop - delete a property 1703*d18719a4STom Rini * @fdt: pointer to the device tree blob 1704*d18719a4STom Rini * @nodeoffset: offset of the node whose property to nop 1705*d18719a4STom Rini * @name: name of the property to nop 1706*d18719a4STom Rini * 1707*d18719a4STom Rini * fdt_del_property() will delete the given property. 1708*d18719a4STom Rini * 1709*d18719a4STom Rini * This function will delete data from the blob, and will therefore 1710*d18719a4STom Rini * change the offsets of some existing nodes. 1711*d18719a4STom Rini * 1712*d18719a4STom Rini * returns: 1713*d18719a4STom Rini * 0, on success 1714*d18719a4STom Rini * -FDT_ERR_NOTFOUND, node does not have the named property 1715*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1716*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1717*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1718*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1719*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1720*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1721*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1722*d18719a4STom Rini */ 1723*d18719a4STom Rini int fdt_delprop(void *fdt, int nodeoffset, const char *name); 1724*d18719a4STom Rini 1725*d18719a4STom Rini /** 1726*d18719a4STom Rini * fdt_add_subnode_namelen - creates a new node based on substring 1727*d18719a4STom Rini * @fdt: pointer to the device tree blob 1728*d18719a4STom Rini * @parentoffset: structure block offset of a node 1729*d18719a4STom Rini * @name: name of the subnode to locate 1730*d18719a4STom Rini * @namelen: number of characters of name to consider 1731*d18719a4STom Rini * 1732*d18719a4STom Rini * Identical to fdt_add_subnode(), but use only the first namelen 1733*d18719a4STom Rini * characters of name as the name of the new node. This is useful for 1734*d18719a4STom Rini * creating subnodes based on a portion of a larger string, such as a 1735*d18719a4STom Rini * full path. 1736*d18719a4STom Rini */ 1737*d18719a4STom Rini int fdt_add_subnode_namelen(void *fdt, int parentoffset, 1738*d18719a4STom Rini const char *name, int namelen); 1739*d18719a4STom Rini 1740*d18719a4STom Rini /** 1741*d18719a4STom Rini * fdt_add_subnode - creates a new node 1742*d18719a4STom Rini * @fdt: pointer to the device tree blob 1743*d18719a4STom Rini * @parentoffset: structure block offset of a node 1744*d18719a4STom Rini * @name: name of the subnode to locate 1745*d18719a4STom Rini * 1746*d18719a4STom Rini * fdt_add_subnode() creates a new node as a subnode of the node at 1747*d18719a4STom Rini * structure block offset parentoffset, with the given name (which 1748*d18719a4STom Rini * should include the unit address, if any). 1749*d18719a4STom Rini * 1750*d18719a4STom Rini * This function will insert data into the blob, and will therefore 1751*d18719a4STom Rini * change the offsets of some existing nodes. 1752*d18719a4STom Rini 1753*d18719a4STom Rini * returns: 1754*d18719a4STom Rini * structure block offset of the created nodeequested subnode (>=0), on 1755*d18719a4STom Rini * success 1756*d18719a4STom Rini * -FDT_ERR_NOTFOUND, if the requested subnode does not exist 1757*d18719a4STom Rini * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE 1758*d18719a4STom Rini * tag 1759*d18719a4STom Rini * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of 1760*d18719a4STom Rini * the given name 1761*d18719a4STom Rini * -FDT_ERR_NOSPACE, if there is insufficient free space in the 1762*d18719a4STom Rini * blob to contain the new node 1763*d18719a4STom Rini * -FDT_ERR_NOSPACE 1764*d18719a4STom Rini * -FDT_ERR_BADLAYOUT 1765*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1766*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1767*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1768*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1769*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings. 1770*d18719a4STom Rini */ 1771*d18719a4STom Rini int fdt_add_subnode(void *fdt, int parentoffset, const char *name); 1772*d18719a4STom Rini 1773*d18719a4STom Rini /** 1774*d18719a4STom Rini * fdt_del_node - delete a node (subtree) 1775*d18719a4STom Rini * @fdt: pointer to the device tree blob 1776*d18719a4STom Rini * @nodeoffset: offset of the node to nop 1777*d18719a4STom Rini * 1778*d18719a4STom Rini * fdt_del_node() will remove the given node, including all its 1779*d18719a4STom Rini * subnodes if any, from the blob. 1780*d18719a4STom Rini * 1781*d18719a4STom Rini * This function will delete data from the blob, and will therefore 1782*d18719a4STom Rini * change the offsets of some existing nodes. 1783*d18719a4STom Rini * 1784*d18719a4STom Rini * returns: 1785*d18719a4STom Rini * 0, on success 1786*d18719a4STom Rini * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1787*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1788*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1789*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1790*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1791*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1792*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1793*d18719a4STom Rini */ 1794*d18719a4STom Rini int fdt_del_node(void *fdt, int nodeoffset); 1795*d18719a4STom Rini 1796*d18719a4STom Rini /** 1797*d18719a4STom Rini * fdt_overlay_apply - Applies a DT overlay on a base DT 1798*d18719a4STom Rini * @fdt: pointer to the base device tree blob 1799*d18719a4STom Rini * @fdto: pointer to the device tree overlay blob 1800*d18719a4STom Rini * 1801*d18719a4STom Rini * fdt_overlay_apply() will apply the given device tree overlay on the 1802*d18719a4STom Rini * given base device tree. 1803*d18719a4STom Rini * 1804*d18719a4STom Rini * Expect the base device tree to be modified, even if the function 1805*d18719a4STom Rini * returns an error. 1806*d18719a4STom Rini * 1807*d18719a4STom Rini * returns: 1808*d18719a4STom Rini * 0, on success 1809*d18719a4STom Rini * -FDT_ERR_NOSPACE, there's not enough space in the base device tree 1810*d18719a4STom Rini * -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or 1811*d18719a4STom Rini * properties in the base DT 1812*d18719a4STom Rini * -FDT_ERR_BADPHANDLE, 1813*d18719a4STom Rini * -FDT_ERR_BADOVERLAY, 1814*d18719a4STom Rini * -FDT_ERR_NOPHANDLES, 1815*d18719a4STom Rini * -FDT_ERR_INTERNAL, 1816*d18719a4STom Rini * -FDT_ERR_BADLAYOUT, 1817*d18719a4STom Rini * -FDT_ERR_BADMAGIC, 1818*d18719a4STom Rini * -FDT_ERR_BADOFFSET, 1819*d18719a4STom Rini * -FDT_ERR_BADPATH, 1820*d18719a4STom Rini * -FDT_ERR_BADVERSION, 1821*d18719a4STom Rini * -FDT_ERR_BADSTRUCTURE, 1822*d18719a4STom Rini * -FDT_ERR_BADSTATE, 1823*d18719a4STom Rini * -FDT_ERR_TRUNCATED, standard meanings 1824*d18719a4STom Rini */ 1825*d18719a4STom Rini int fdt_overlay_apply(void *fdt, void *fdto); 1826*d18719a4STom Rini 1827*d18719a4STom Rini /**********************************************************************/ 1828*d18719a4STom Rini /* Debugging / informational functions */ 1829*d18719a4STom Rini /**********************************************************************/ 1830*d18719a4STom Rini 1831*d18719a4STom Rini const char *fdt_strerror(int errval); 1832*d18719a4STom Rini 1833*d18719a4STom Rini #endif /* _LIBFDT_H */ 1834