1*db405d19SRob Herring #ifndef FDT_H 2*db405d19SRob Herring #define FDT_H 3c0e032e0STom Rini /* 4c0e032e0STom Rini * libfdt - Flat Device Tree manipulation 5c0e032e0STom Rini * Copyright (C) 2006 David Gibson, IBM Corporation. 6c0e032e0STom Rini * Copyright 2012 Kim Phillips, Freescale Semiconductor. 7c0e032e0STom Rini * 8c0e032e0STom Rini * libfdt is dual licensed: you can use it either under the terms of 9c0e032e0STom Rini * the GPL, or the BSD license, at your option. 10c0e032e0STom Rini * 11c0e032e0STom Rini * a) This library is free software; you can redistribute it and/or 12c0e032e0STom Rini * modify it under the terms of the GNU General Public License as 13c0e032e0STom Rini * published by the Free Software Foundation; either version 2 of the 14c0e032e0STom Rini * License, or (at your option) any later version. 15c0e032e0STom Rini * 16c0e032e0STom Rini * This library is distributed in the hope that it will be useful, 17c0e032e0STom Rini * but WITHOUT ANY WARRANTY; without even the implied warranty of 18c0e032e0STom Rini * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19c0e032e0STom Rini * GNU General Public License for more details. 20c0e032e0STom Rini * 21c0e032e0STom Rini * You should have received a copy of the GNU General Public 22c0e032e0STom Rini * License along with this library; if not, write to the Free 23c0e032e0STom Rini * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 24c0e032e0STom Rini * MA 02110-1301 USA 25c0e032e0STom Rini * 26c0e032e0STom Rini * Alternatively, 27c0e032e0STom Rini * 28c0e032e0STom Rini * b) Redistribution and use in source and binary forms, with or 29c0e032e0STom Rini * without modification, are permitted provided that the following 30c0e032e0STom Rini * conditions are met: 31c0e032e0STom Rini * 32c0e032e0STom Rini * 1. Redistributions of source code must retain the above 33c0e032e0STom Rini * copyright notice, this list of conditions and the following 34c0e032e0STom Rini * disclaimer. 35c0e032e0STom Rini * 2. Redistributions in binary form must reproduce the above 36c0e032e0STom Rini * copyright notice, this list of conditions and the following 37c0e032e0STom Rini * disclaimer in the documentation and/or other materials 38c0e032e0STom Rini * provided with the distribution. 39c0e032e0STom Rini * 40c0e032e0STom Rini * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 41c0e032e0STom Rini * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 42c0e032e0STom Rini * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 43c0e032e0STom Rini * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 44c0e032e0STom Rini * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 45c0e032e0STom Rini * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 46c0e032e0STom Rini * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 47c0e032e0STom Rini * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 48c0e032e0STom Rini * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 49c0e032e0STom Rini * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 50c0e032e0STom Rini * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 51c0e032e0STom Rini * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 52c0e032e0STom Rini * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53c0e032e0STom Rini */ 54c0e032e0STom Rini 55c0e032e0STom Rini #ifndef __ASSEMBLY__ 56c0e032e0STom Rini 57c0e032e0STom Rini struct fdt_header { 58c0e032e0STom Rini fdt32_t magic; /* magic word FDT_MAGIC */ 59c0e032e0STom Rini fdt32_t totalsize; /* total size of DT block */ 60c0e032e0STom Rini fdt32_t off_dt_struct; /* offset to structure */ 61c0e032e0STom Rini fdt32_t off_dt_strings; /* offset to strings */ 62c0e032e0STom Rini fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ 63c0e032e0STom Rini fdt32_t version; /* format version */ 64c0e032e0STom Rini fdt32_t last_comp_version; /* last compatible version */ 65c0e032e0STom Rini 66c0e032e0STom Rini /* version 2 fields below */ 67c0e032e0STom Rini fdt32_t boot_cpuid_phys; /* Which physical CPU id we're 68c0e032e0STom Rini booting on */ 69c0e032e0STom Rini /* version 3 fields below */ 70c0e032e0STom Rini fdt32_t size_dt_strings; /* size of the strings block */ 71c0e032e0STom Rini 72c0e032e0STom Rini /* version 17 fields below */ 73c0e032e0STom Rini fdt32_t size_dt_struct; /* size of the structure block */ 74c0e032e0STom Rini }; 75c0e032e0STom Rini 76c0e032e0STom Rini struct fdt_reserve_entry { 77c0e032e0STom Rini fdt64_t address; 78c0e032e0STom Rini fdt64_t size; 79c0e032e0STom Rini }; 80c0e032e0STom Rini 81c0e032e0STom Rini struct fdt_node_header { 82c0e032e0STom Rini fdt32_t tag; 83c0e032e0STom Rini char name[0]; 84c0e032e0STom Rini }; 85c0e032e0STom Rini 86c0e032e0STom Rini struct fdt_property { 87c0e032e0STom Rini fdt32_t tag; 88c0e032e0STom Rini fdt32_t len; 89c0e032e0STom Rini fdt32_t nameoff; 90c0e032e0STom Rini char data[0]; 91c0e032e0STom Rini }; 92c0e032e0STom Rini 93c0e032e0STom Rini #endif /* !__ASSEMBLY */ 94c0e032e0STom Rini 95c0e032e0STom Rini #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ 96c0e032e0STom Rini #define FDT_TAGSIZE sizeof(fdt32_t) 97c0e032e0STom Rini 98c0e032e0STom Rini #define FDT_BEGIN_NODE 0x1 /* Start node: full name */ 99c0e032e0STom Rini #define FDT_END_NODE 0x2 /* End node */ 100c0e032e0STom Rini #define FDT_PROP 0x3 /* Property: name off, 101c0e032e0STom Rini size, content */ 102c0e032e0STom Rini #define FDT_NOP 0x4 /* nop */ 103c0e032e0STom Rini #define FDT_END 0x9 104c0e032e0STom Rini 105c0e032e0STom Rini #define FDT_V1_SIZE (7*sizeof(fdt32_t)) 106c0e032e0STom Rini #define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t)) 107c0e032e0STom Rini #define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t)) 108c0e032e0STom Rini #define FDT_V16_SIZE FDT_V3_SIZE 109c0e032e0STom Rini #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) 110c0e032e0STom Rini 111*db405d19SRob Herring #endif /* FDT_H */ 112