Module Name: src
Committed By: marty
Date: Mon Dec 14 22:06:57 UTC 2015
Modified Files:
src/sys/arch/arm/samsung: files.exynos
src/sys/arch/evbarm/conf: ODROID-XU4 files.exynos
src/sys/arch/evbarm/exynos: exynos_machdep.c
Log Message:
XU4 FDT Enable the minimum device tree
This enables the use of FDT on the XU4 but doesn't add any drivers. However,
with this check in, XU4 becomes useless without a device tree blob from the
Linux tree, which isn't checked in anywhere.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/samsung/files.exynos
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/conf/ODROID-XU4
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/conf/files.exynos
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/exynos/exynos_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/samsung/files.exynos
diff -u src/sys/arch/arm/samsung/files.exynos:1.10 src/sys/arch/arm/samsung/files.exynos:1.11
--- src/sys/arch/arm/samsung/files.exynos:1.10 Sat Dec 12 21:56:54 2015
+++ src/sys/arch/arm/samsung/files.exynos Mon Dec 14 22:06:57 2015
@@ -1,4 +1,4 @@
-# $NetBSD: files.exynos,v 1.10 2015/12/12 21:56:54 marty Exp $
+# $NetBSD: files.exynos,v 1.11 2015/12/14 22:06:57 marty Exp $
#
# Configuration info for Samsung Exynos SoC ARM Peripherals
#
@@ -44,6 +44,11 @@ defflag opt_exynos.h EXYNOS5420: EXYN
defflag opt_exynos.h EXYNOS5440: EXYNOS5
defflag opt_exynos.h EXYNOS5422: EXYNOS5
+# On-board I/O
+device exynosfdt : bus_space_generic, fdtbus
+attach exynosfdt at mainbus with exynos_fdt
+file arch/arm/samsung/exynos_fdt.c exynos_fdt
+
# SoC I/O attach point
device exyo { [port=-1], [intr=-1] } : bus_space_generic
attach exyo at mainbus with exyo_io
Index: src/sys/arch/evbarm/conf/ODROID-XU4
diff -u src/sys/arch/evbarm/conf/ODROID-XU4:1.4 src/sys/arch/evbarm/conf/ODROID-XU4:1.5
--- src/sys/arch/evbarm/conf/ODROID-XU4:1.4 Mon Dec 14 00:00:22 2015
+++ src/sys/arch/evbarm/conf/ODROID-XU4 Mon Dec 14 22:06:57 2015
@@ -1,5 +1,5 @@
#
-# $NetBSD: ODROID-XU4,v 1.4 2015/12/14 00:00:22 marty Exp $
+# $NetBSD: ODROID-XU4,v 1.5 2015/12/14 22:06:57 marty Exp $
#
# ODROID-XU -- ODROID-XU4 Exynos5422 based kernel
#
@@ -33,6 +33,11 @@ options CPU_CORTEXA15
options EXYNOS5422
#options MULTIPROCESSOR
+options FDT # not really but soon
+pseudo-device openfirm # jmcneill: oops, fdtbus should depend on
+ # openfirm. don't let me forget.
+
+
options PMAPCOUNTERS
options BUSDMA_COUNTERS
options EXYNOS_CONSOLE_EARLY
@@ -196,6 +201,14 @@ armperiph0 at mainbus?
armgic0 at armperiph? # Interrupt Controller
armgtmr0 at armperiph? # Generic Timer
+# On-board I/O
+exynosfdt0 at mainbus?
+fdt0 at exynosfdt0
+simplebus* at fdt?
+fdt* at simplebus?
+
+fregulator* at fdt?
+
# Exynos SoC
exyo0 at mainbus?
Index: src/sys/arch/evbarm/conf/files.exynos
diff -u src/sys/arch/evbarm/conf/files.exynos:1.1 src/sys/arch/evbarm/conf/files.exynos:1.2
--- src/sys/arch/evbarm/conf/files.exynos:1.1 Sun Dec 6 00:31:24 2015
+++ src/sys/arch/evbarm/conf/files.exynos Mon Dec 14 22:06:57 2015
@@ -1,4 +1,4 @@
-# $NetBSD: files.exynos,v 1.1 2015/12/06 00:31:24 marty Exp $
+# $NetBSD: files.exynos,v 1.2 2015/12/14 22:06:57 marty Exp $
#
# EXYNOS 5422 board configuration info
#
@@ -8,5 +8,11 @@ file arch/evbarm/exynos/exynos_machdep.c
# Kernel boot arguments
defparam opt_machdep.h BOOT_ARGS
+# FDT
+
+include "dev/ofw/files.ofw"
+include "dev/fdt/files.fdt"
+include "arch/arm/fdt/files.fdt"
+
# Pull in Exynos SoC default
include "arch/arm/samsung/files.exynos"
Index: src/sys/arch/evbarm/exynos/exynos_machdep.c
diff -u src/sys/arch/evbarm/exynos/exynos_machdep.c:1.3 src/sys/arch/evbarm/exynos/exynos_machdep.c:1.4
--- src/sys/arch/evbarm/exynos/exynos_machdep.c:1.3 Sun Dec 13 22:28:09 2015
+++ src/sys/arch/evbarm/exynos/exynos_machdep.c Mon Dec 14 22:06:57 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: exynos_machdep.c,v 1.3 2015/12/13 22:28:09 marty Exp $ */
+/* $NetBSD: exynos_machdep.c,v 1.4 2015/12/14 22:06:57 marty Exp $ */
/*
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exynos_machdep.c,v 1.3 2015/12/13 22:28:09 marty Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos_machdep.c,v 1.4 2015/12/14 22:06:57 marty Exp $");
#include "opt_evbarm_boardtype.h"
#include "opt_exynos.h"
@@ -101,6 +101,16 @@ __KERNEL_RCSID(0, "$NetBSD: exynos_machd
#include <arm/samsung/sscom_var.h>
#include <arm/samsung/sscom_reg.h>
+/* so we can load the device tree. NOTE: This requires the kernel to be
+ * made into a linux (not netbsd) uboot image.
+ */
+#include <libfdt.h>
+#include <dev/fdt/fdt_openfirm.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/fdt/fdtvar.h>
+#define FDT_BUF_SIZE (128*1024)
+static uint8_t fdt_data[FDT_BUF_SIZE];
+
extern const int num_exynos_uarts_entries;
extern const struct sscom_uart_info exynos_uarts[];
@@ -368,6 +378,7 @@ initarm(void *arg)
char mi_bootargs[] = BOOT_ARGS;
parse_mi_bootargs(mi_bootargs);
#endif
+
boot_args = bootargs;
parse_mi_bootargs(boot_args);
exynos_extract_mac_adress();
@@ -390,6 +401,22 @@ initarm(void *arg)
const bool mapallmem_p = false;
#endif
+ /* Load the dtb */
+ const uint8_t *fdt_addr_r = (const uint8_t *)uboot_args[2];
+ printf("fdt addr 0x%08x\n", (uint)fdt_addr_r);
+ int error = fdt_check_header(fdt_addr_r);
+ printf("fdt check header returns %d\n", error);
+ if (error == 0) {
+ error = fdt_move(fdt_addr_r, fdt_data, sizeof(fdt_data));
+ printf("fdt move returns %d\n", error);
+ if (error != 0) {
+ panic("fdt_move failed: %s", fdt_strerror(error));
+ }
+ fdt_openfirm_set_data(fdt_data);
+ } else {
+ panic("fdt_check_header failed: %s", fdt_strerror(error));
+ }
+
/* Fake bootconfig structure for the benefit of pmap.c. */
bootconfig.dramblocks = 1;
bootconfig.dram[0].address = rambase;