]> xenbits.xensource.com Git - people/julieng/boot-wrapper-aarch64.git/commitdiff
Discover device base addresses from the DTB
authorMark Rutland <mark.rutland@arm.com>
Tue, 15 Apr 2014 13:31:44 +0000 (14:31 +0100)
committerMark Rutland <mark.rutland@arm.com>
Tue, 15 Apr 2014 15:08:14 +0000 (16:08 +0100)
The base addresses of various components can differ from one model to
another. As these addresses are currently hard-coded in the bootwrapper,
it is necessary to manually alter the bootwrapper for each variation.

This patch adds scripting to extract the (absolute / CPU) addresses of
various system components. With this change the bootwrapper build system
will automatically discover the addresses that need to be used.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Makefile.am
findbase.pl [new file with mode: 0755]

index c911e512d614b7e1f9b7b267b44d18f252dc1720..41adf14cfff4035b98c97c35d53d42db3582f074 100644 (file)
@@ -9,10 +9,10 @@
 
 # VE
 PHYS_OFFSET    := 0x80000000
-UART_BASE      := 0x1c090000
-SYSREGS_BASE   := 0x1c010000
-GIC_DIST_BASE  := 0x2c001000
-GIC_CPU_BASE   := 0x2c002000
+UART_BASE      := $(shell $(top_srcdir)/findbase.pl $(KERNEL_DTB) 0 'arm,pl011')
+SYSREGS_BASE   := $(shell $(top_srcdir)/findbase.pl $(KERNEL_DTB) 0 'arm,vexpress-sysreg')
+GIC_DIST_BASE  := $(shell $(top_srcdir)/findbase.pl $(KERNEL_DTB) 0 'arm,cortex-a15-gic')
+GIC_CPU_BASE   := $(shell $(top_srcdir)/findbase.pl $(KERNEL_DTB) 1 'arm,cortex-a15-gic')
 CNTFRQ         := 0x01800000   # 24Mhz
 
 DEFINES                = -DCNTFRQ=$(CNTFRQ)
diff --git a/findbase.pl b/findbase.pl
new file mode 100755 (executable)
index 0000000..1b6b93e
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/perl -w
+# Find device register base addresses.
+#
+# Usage: ./$0 <DTB> <index> <compatible ...>
+#
+# Copyright (C) 2014 ARM Limited. All rights reserved.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE.txt file.
+
+use warnings;
+use strict;
+
+use FDT;
+
+my $filename = shift;
+die("No filename provided") unless defined($filename);
+
+my $idx = shift;
+die("no reg index provided") unless defined($idx);
+
+my @compats = shift;
+
+open (my $fh, "<:raw", $filename) or die("Unable to open file '$filename'");
+
+my $fdt = FDT->parse($fh) or die("Unable to parse DTB");
+
+my $root = $fdt->get_root();
+
+my @devs = ();
+for my $compat (@compats) {
+       push @devs, $root->find_compatible($compat);
+}
+
+# We only care about finding the first matching device
+my $dev = shift @devs;
+die("No matching devices found") if (not defined($dev));
+
+my ($addr, $size) = $dev->get_translated_reg($idx);
+die("Cannot find reg entry $idx") if (not defined($addr) or not defined($size));
+
+printf("0x%016x\n", $addr);