summaryrefslogtreecommitdiffstats
path: root/scripts/dtc/libfdt/fdt_addresses.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-07-19 11:09:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-08-19 11:27:01 +0200
commit4e731e48d49ab77c1a331cda089b60406234ae6b (patch)
tree950d31450d8c926c29c63128b8d95a42e0140561 /scripts/dtc/libfdt/fdt_addresses.c
parent46bdae84e8ac7ee1e7efa3e9b5dfedabb0de0bf9 (diff)
downloadbarebox-4e731e48d49ab77c1a331cda089b60406234ae6b.tar.gz
barebox-4e731e48d49ab77c1a331cda089b60406234ae6b.tar.xz
scripts/dtc: Update to upstream version v1.5.0
This adds the following commits from upstream: d37f6b2 Bump version to v1.5.0 a4b1a30 pylibfdt:tests: Extend the way how to find a Python module 625dd8a pylibfdt: Change how passing tests are recognized 3646316 pylibfdt: Test fdt.setprop take bytes on Python 3, add error handling cb0f454 pylibfdt: check_err accepts only integer as a first argument. 4b68c6b pylibfdt: Proper handling of bytes/unicode strings and octal literals 78e113e Use PRIxPTR for printing uintptr_t values ea7a8f6 libfdt: Fix FDT_ERR_NOTFOUND typos in documentation 5aafd7c libfdt: Fix fdt_getprop_by_offset() parameter name in documentation 7cbc550 checks: Add unit address check if node is enabled f267e67 checks: Fix crash with multiple source annotations 3616b9a checks: Use source position information for check failures 2bdbd07 checks: Make each message output atomic a1eff70 util: Add xa{v}sprintf_append functions 82a52ce libfdt: Add a test for fdt_getprop_by_offset() 607b858 PEP8 / Flake8 cleanups for setup.py f9c0a42 Remove broken objdir / srcdir support 5182b5e pylibfdt: Use common PREFIX variable d45bf1f Refine make tests_clean target 99284c4 Refine pylibfdt_clean target a4629cf Refine libfdt_clean target 08380fc tests: Use modern octal literals for Python 8113c00 pylibfdt: Allow switch to Python 3 via environment variable PYTHON 11738cf libfdt: Don't use memcpy to handle unaligned reads on ARM 86a288a checks: Restructure check_msg to decrease indentation 5667e7e annotations: add the annotation functionality 8e20ccf annotations: add positions ca930e2 tests: Don't lose errors from make checkm 43366bb tests: Property count valgrind errors in wrapped tests 5062516 srcpos: Remove srcpos_empty a3143fa Revert "annotations: add positions" 403cc79 checks: Update SPI bus check for 'spi-slave' baa1d2c annotations: add positions ff2ad38 Merge remote-tracking branch 'origin/pr/18' aa7254d libfdt: return correct value if #size-cells property is not present 49903ae use ptrdiff_t modifier for printing pointer differences da2b691 treesource: Fix dts output for phandles in middle of a sequence of ints 8f8b77a tests: Wrap check_align() calls with base_run_test() 522d81d Fix dts output with a REF_PATH marker e45198c Added test cases for target references 0fcffda Merge nodes with local target label references 1e4a092 pylibfdt: Don't have setup.py depend on where it's invoked from ca399b1 pylibfdt: Eliminate run_setup make function 98972f1 pylibfdt: Improved version extraction 7ba2be6 pylibfdt: Don't silence setup.py when V=1 7691f9d pylibfdt: Make SETUP make variable 855b996 pylibfdt: Simpler CFLAGS handling 47cafbe pylibfdt: Link extension module with libfdt rather than rebuilding dd695d6 pylibfdt: Correctly set build output directory 5932752 pylibfdt: We don't need include files from the base directory e84742a checks: fix simple-bus compatible matching 8c59a97 Fix missing labels when emitting dts format d448f9a Revert dts output formatting changes of spaces around brackets c86da84 Add support for YAML encoded output 361b5e7 Make type_marker_length helper public bfbfab0 pylibfdt: Add a means to add and delete notes 9005f41 pylibfdt: Allow delprop() to return errors b94c056 Make valgrind optional fd06c54 tests: Better testing of dtc -I fs mode c3f50c9 tests: Allow dtbs_equal_unordered to ignore mem reserves 0ac9fde dtc: trivial '-I fs -O dts' test 0fd1c8c pylibfdt: fdt_get_mem_rsv returns 2 uint64_t values 04853ca pylibfdt: Don't incorrectly / unnecessarily override uint64_t typemap 9619c86 Kill bogus TYPE_BLOB marker type ac68ff9 parser: add TYPE_STRING marker to path references 90a190e checks: add SPI bus checks 53a1bd5 checks: add I2C bus checks Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/dtc/libfdt/fdt_addresses.c')
-rw-r--r--scripts/dtc/libfdt/fdt_addresses.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/scripts/dtc/libfdt/fdt_addresses.c b/scripts/dtc/libfdt/fdt_addresses.c
new file mode 100644
index 0000000000..f13a87dfa0
--- /dev/null
+++ b/scripts/dtc/libfdt/fdt_addresses.c
@@ -0,0 +1,97 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au>
+ * Copyright (C) 2018 embedded brains GmbH
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ * a) This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ * b) Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "libfdt_env.h"
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "libfdt_internal.h"
+
+static int fdt_cells(const void *fdt, int nodeoffset, const char *name)
+{
+ const fdt32_t *c;
+ int val;
+ int len;
+
+ c = fdt_getprop(fdt, nodeoffset, name, &len);
+ if (!c)
+ return len;
+
+ if (len != sizeof(*c))
+ return -FDT_ERR_BADNCELLS;
+
+ val = fdt32_to_cpu(*c);
+ if ((val <= 0) || (val > FDT_MAX_NCELLS))
+ return -FDT_ERR_BADNCELLS;
+
+ return val;
+}
+
+int fdt_address_cells(const void *fdt, int nodeoffset)
+{
+ int val;
+
+ val = fdt_cells(fdt, nodeoffset, "#address-cells");
+ if (val == -FDT_ERR_NOTFOUND)
+ return 2;
+ return val;
+}
+
+int fdt_size_cells(const void *fdt, int nodeoffset)
+{
+ int val;
+
+ val = fdt_cells(fdt, nodeoffset, "#size-cells");
+ if (val == -FDT_ERR_NOTFOUND)
+ return 1;
+ return val;
+}