1 /* 2 * (C) Copyright 2018 Linaro Ltd. 3 * Sam Protsenko <semen.protsenko@linaro.org> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 #ifndef IMAGE_ANDROID_DT_H 9 #define IMAGE_ANDROID_DT_H 10 11 #include <linux/types.h> 12 13 bool android_dt_check_header(ulong hdr_addr); 14 bool android_dt_get_fdt_by_index(ulong hdr_addr, u32 index, ulong *addr, 15 u32 *size); 16 int android_dt_get_count(ulong hdr_addr); 17 18 #if !defined(CONFIG_SPL_BUILD) 19 void android_dt_print_contents(ulong hdr_addr); 20 #endif 21 22 /** 23 * dt_for_each_entry() - iterate over all dt entry of DT image 24 * 25 * @entry: struct dt_table_entry pointing to entry address 26 * @hdr: struct dt_table_header pointing to hdr address 27 * @idx: temporary index variant 28 * 29 * This is a wrapper around a for loop and is used like so: 30 * 31 * struct dt_table_header *hdr; 32 * struct dt_table_entry *entry; 33 * int index; 34 * 35 * ...... 36 * 37 * dt_for_each_entry(entry, hdr, index) { 38 * Use entry 39 * ... 40 * } 41 * 42 */ 43 #define dt_for_each_entry(entry, hdr, idx) \ 44 for (idx = 0, android_dt_get_fdt_by_index((ulong)hdr, idx, (ulong *)&entry, NULL); \ 45 idx < android_dt_get_count((ulong)hdr); \ 46 idx++, android_dt_get_fdt_by_index((ulong)hdr, idx, (ulong *)&entry, NULL)) 47 48 #endif /* IMAGE_ANDROID_DT_H */ 49