1*9130ba88SRob Herring #ifndef FDT_H 2*9130ba88SRob Herring #define FDT_H 347605971SRob Herring /* 447605971SRob Herring * libfdt - Flat Device Tree manipulation 547605971SRob Herring * Copyright (C) 2006 David Gibson, IBM Corporation. 647605971SRob Herring * Copyright 2012 Kim Phillips, Freescale Semiconductor. 747605971SRob Herring * 847605971SRob Herring * libfdt is dual licensed: you can use it either under the terms of 947605971SRob Herring * the GPL, or the BSD license, at your option. 1047605971SRob Herring * 1147605971SRob Herring * a) This library is free software; you can redistribute it and/or 1247605971SRob Herring * modify it under the terms of the GNU General Public License as 1347605971SRob Herring * published by the Free Software Foundation; either version 2 of the 1447605971SRob Herring * License, or (at your option) any later version. 1547605971SRob Herring * 1647605971SRob Herring * This library is distributed in the hope that it will be useful, 1747605971SRob Herring * but WITHOUT ANY WARRANTY; without even the implied warranty of 1847605971SRob Herring * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1947605971SRob Herring * GNU General Public License for more details. 2047605971SRob Herring * 2147605971SRob Herring * You should have received a copy of the GNU General Public 2247605971SRob Herring * License along with this library; if not, write to the Free 2347605971SRob Herring * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 2447605971SRob Herring * MA 02110-1301 USA 2547605971SRob Herring * 2647605971SRob Herring * Alternatively, 2747605971SRob Herring * 2847605971SRob Herring * b) Redistribution and use in source and binary forms, with or 2947605971SRob Herring * without modification, are permitted provided that the following 3047605971SRob Herring * conditions are met: 3147605971SRob Herring * 3247605971SRob Herring * 1. Redistributions of source code must retain the above 3347605971SRob Herring * copyright notice, this list of conditions and the following 3447605971SRob Herring * disclaimer. 3547605971SRob Herring * 2. Redistributions in binary form must reproduce the above 3647605971SRob Herring * copyright notice, this list of conditions and the following 3747605971SRob Herring * disclaimer in the documentation and/or other materials 3847605971SRob Herring * provided with the distribution. 3947605971SRob Herring * 4047605971SRob Herring * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 4147605971SRob Herring * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 4247605971SRob Herring * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 4347605971SRob Herring * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 4447605971SRob Herring * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 4547605971SRob Herring * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4647605971SRob Herring * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 4747605971SRob Herring * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 4847605971SRob Herring * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4947605971SRob Herring * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 5047605971SRob Herring * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 5147605971SRob Herring * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 5247605971SRob Herring * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 5347605971SRob Herring */ 549fffb55fSDavid Gibson 559fffb55fSDavid Gibson #ifndef __ASSEMBLY__ 569fffb55fSDavid Gibson 579fffb55fSDavid Gibson struct fdt_header { 5847605971SRob Herring fdt32_t magic; /* magic word FDT_MAGIC */ 5947605971SRob Herring fdt32_t totalsize; /* total size of DT block */ 6047605971SRob Herring fdt32_t off_dt_struct; /* offset to structure */ 6147605971SRob Herring fdt32_t off_dt_strings; /* offset to strings */ 6247605971SRob Herring fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ 6347605971SRob Herring fdt32_t version; /* format version */ 6447605971SRob Herring fdt32_t last_comp_version; /* last compatible version */ 659fffb55fSDavid Gibson 669fffb55fSDavid Gibson /* version 2 fields below */ 6747605971SRob Herring fdt32_t boot_cpuid_phys; /* Which physical CPU id we're 689fffb55fSDavid Gibson booting on */ 699fffb55fSDavid Gibson /* version 3 fields below */ 7047605971SRob Herring fdt32_t size_dt_strings; /* size of the strings block */ 719fffb55fSDavid Gibson 729fffb55fSDavid Gibson /* version 17 fields below */ 7347605971SRob Herring fdt32_t size_dt_struct; /* size of the structure block */ 749fffb55fSDavid Gibson }; 759fffb55fSDavid Gibson 769fffb55fSDavid Gibson struct fdt_reserve_entry { 7747605971SRob Herring fdt64_t address; 7847605971SRob Herring fdt64_t size; 799fffb55fSDavid Gibson }; 809fffb55fSDavid Gibson 819fffb55fSDavid Gibson struct fdt_node_header { 8247605971SRob Herring fdt32_t tag; 839fffb55fSDavid Gibson char name[0]; 849fffb55fSDavid Gibson }; 859fffb55fSDavid Gibson 869fffb55fSDavid Gibson struct fdt_property { 8747605971SRob Herring fdt32_t tag; 8847605971SRob Herring fdt32_t len; 8947605971SRob Herring fdt32_t nameoff; 909fffb55fSDavid Gibson char data[0]; 919fffb55fSDavid Gibson }; 929fffb55fSDavid Gibson 939fffb55fSDavid Gibson #endif /* !__ASSEMBLY */ 949fffb55fSDavid Gibson 959fffb55fSDavid Gibson #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ 9647605971SRob Herring #define FDT_TAGSIZE sizeof(fdt32_t) 979fffb55fSDavid Gibson 989fffb55fSDavid Gibson #define FDT_BEGIN_NODE 0x1 /* Start node: full name */ 999fffb55fSDavid Gibson #define FDT_END_NODE 0x2 /* End node */ 1009fffb55fSDavid Gibson #define FDT_PROP 0x3 /* Property: name off, 1019fffb55fSDavid Gibson size, content */ 1029fffb55fSDavid Gibson #define FDT_NOP 0x4 /* nop */ 1039fffb55fSDavid Gibson #define FDT_END 0x9 1049fffb55fSDavid Gibson 10547605971SRob Herring #define FDT_V1_SIZE (7*sizeof(fdt32_t)) 10647605971SRob Herring #define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t)) 10747605971SRob Herring #define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t)) 1089fffb55fSDavid Gibson #define FDT_V16_SIZE FDT_V3_SIZE 10947605971SRob Herring #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) 1109fffb55fSDavid Gibson 111*9130ba88SRob Herring #endif /* FDT_H */ 112