18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
28c2ecf20Sopenharmony_ci#ifndef FDT_H
38c2ecf20Sopenharmony_ci#define FDT_H
48c2ecf20Sopenharmony_ci/*
58c2ecf20Sopenharmony_ci * libfdt - Flat Device Tree manipulation
68c2ecf20Sopenharmony_ci * Copyright (C) 2006 David Gibson, IBM Corporation.
78c2ecf20Sopenharmony_ci * Copyright 2012 Kim Phillips, Freescale Semiconductor.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistruct fdt_header {
138c2ecf20Sopenharmony_ci	fdt32_t magic;			 /* magic word FDT_MAGIC */
148c2ecf20Sopenharmony_ci	fdt32_t totalsize;		 /* total size of DT block */
158c2ecf20Sopenharmony_ci	fdt32_t off_dt_struct;		 /* offset to structure */
168c2ecf20Sopenharmony_ci	fdt32_t off_dt_strings;		 /* offset to strings */
178c2ecf20Sopenharmony_ci	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
188c2ecf20Sopenharmony_ci	fdt32_t version;		 /* format version */
198c2ecf20Sopenharmony_ci	fdt32_t last_comp_version;	 /* last compatible version */
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	/* version 2 fields below */
228c2ecf20Sopenharmony_ci	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
238c2ecf20Sopenharmony_ci					    booting on */
248c2ecf20Sopenharmony_ci	/* version 3 fields below */
258c2ecf20Sopenharmony_ci	fdt32_t size_dt_strings;	 /* size of the strings block */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci	/* version 17 fields below */
288c2ecf20Sopenharmony_ci	fdt32_t size_dt_struct;		 /* size of the structure block */
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistruct fdt_reserve_entry {
328c2ecf20Sopenharmony_ci	fdt64_t address;
338c2ecf20Sopenharmony_ci	fdt64_t size;
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistruct fdt_node_header {
378c2ecf20Sopenharmony_ci	fdt32_t tag;
388c2ecf20Sopenharmony_ci	char name[0];
398c2ecf20Sopenharmony_ci};
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistruct fdt_property {
428c2ecf20Sopenharmony_ci	fdt32_t tag;
438c2ecf20Sopenharmony_ci	fdt32_t len;
448c2ecf20Sopenharmony_ci	fdt32_t nameoff;
458c2ecf20Sopenharmony_ci	char data[0];
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY */
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
518c2ecf20Sopenharmony_ci#define FDT_TAGSIZE	sizeof(fdt32_t)
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define FDT_BEGIN_NODE	0x1		/* Start node: full name */
548c2ecf20Sopenharmony_ci#define FDT_END_NODE	0x2		/* End node */
558c2ecf20Sopenharmony_ci#define FDT_PROP	0x3		/* Property: name off,
568c2ecf20Sopenharmony_ci					   size, content */
578c2ecf20Sopenharmony_ci#define FDT_NOP		0x4		/* nop */
588c2ecf20Sopenharmony_ci#define FDT_END		0x9
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
618c2ecf20Sopenharmony_ci#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
628c2ecf20Sopenharmony_ci#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
638c2ecf20Sopenharmony_ci#define FDT_V16_SIZE	FDT_V3_SIZE
648c2ecf20Sopenharmony_ci#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#endif /* FDT_H */
67