mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Cc: Rob Herring <rob.herring@calxeda.com>
Subject: [PATCH 6/6] highbank: use the provided dtb by the firmware to probe barebox device and mem size
Date: Wed, 13 Feb 2013 11:06:44 +0100	[thread overview]
Message-ID: <1360750004-17713-6-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1360750004-17713-1-git-send-email-plagnioj@jcrosoft.com>

the dtb is at 0x1000

if no dtb present use C code device

keep in C the timer/gpio/uart

have a nice tree

barebox 2013.02.0-00294-g6802ddf #124 Wed Feb 13 02:31:01 CST 2013

Board: Calxeda Highbank
memory: ram0: 0xff900000@0x0
highbank: dtb probed memory size
registered netconsole as cs1
malloc space: 0x03500000 -> 0x03efffff (size 10 MiB)
Open /dev/env0 No such file or directory
no valid environment found on /dev/env0. Using default environment
running /env/bin/init...
ahci ffe08000.sata: port 0: SATA link ok
ahci ffe08000.sata: port 0: Spinning up device...
ahci ffe08000.sata: port 0: ok.
ahci ffe08000.sata: registered /dev/ata0
eth0: got preset MAC address: 52:54:00:12:34:56
eth1: got preset MAC address: 52:54:00:12:34:57

Hit any key to stop autoboot:  3
[barebox@Calxeda Highbank]:/
 # devinfo
devices:
`---- platform
     `---- mem0
          `---- 0x00000000-0x3fffffff: /dev/ram0
          `---- 0x00001000-0x00010fff: /dev/dtb
     `---- mem1
          `---- 0x00000000-0x000051af: /dev/defaultenv
     `---- mem2
          `---- 0x00000000-0xfffffffe: /dev/mem
     `---- cs1
     `---- fff10600.timer
     `---- fff10620.watchdog
     `---- fff11000.interrupt-controller
     `---- l2-cache
     `---- ffe08000.sata
          `---- 0x00000000-0x3fffffff: /dev/ata0
          `---- 0x00100000-0x014fffff: /dev/ata0.0
          `---- 0x01500000-0x3fffffff: /dev/ata0.1
     `---- ffe0e000.sdhci
     `---- fff00000.memory-controller
     `---- mem3
     `---- fff3c000.sregs
     `---- fff3c200.sregs
     `---- fff50000.ethernet
          `---- eth0
     `---- fff51000.ethernet
          `---- eth1
`---- amba
     `---- sp804
     `---- uart-pl011
          `---- cs0
     `---- fff30000.gpio
     `---- fff31000.gpio
     `---- fff32000.gpio
     `---- fff33000.gpio
     `---- fff35000.rtc
`---- fs
     `---- ramfs0
     `---- devfs0
`---- net
`---- global

drivers:
uart-pl011
sp804
pl061_gpio
ramfs
devfs
tftp
hb-xgmac
ahci
mem
[barebox@Calxeda Highbank]:/
 #

Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/highbank/env/bin/init_board |    7 ++++
 arch/arm/boards/highbank/init.c             |   52 ++++++++++++++++++++++-----
 arch/arm/configs/highbank_defconfig         |    1 +
 3 files changed, 52 insertions(+), 8 deletions(-)
 create mode 100644 arch/arm/boards/highbank/env/bin/init_board

diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/bin/init_board
new file mode 100644
index 0000000..610db15
--- /dev/null
+++ b/arch/arm/boards/highbank/env/bin/init_board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ -e /dev/dtb ]
+then
+	oftree -l /dev/dtb
+	oftree -p
+fi
diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
index b793642..bcd2783 100644
--- a/arch/arm/boards/highbank/init.c
+++ b/arch/arm/boards/highbank/init.c
@@ -15,23 +15,59 @@
 #include <sizes.h>
 #include <io.h>
 
+#define FIRMWARE_DTB_BASE	0x1000
+
+struct fdt_header *fdt = NULL;
+
 static int highbank_mem_init(void)
 {
-	highbank_add_ddram(4089 << 20);
+	struct device_node *np;
+	int ret;
+
+	/* load by the firmware at 0x1000 */
+	fdt = IOMEM(FIRMWARE_DTB_BASE);
+
+	ret = of_unflatten_dtb(fdt);
+	if (ret) {
+		pr_warn("no dtb found at 0x1000 use default configuration\n");
+		fdt = NULL;
+		goto not_found;
+	}
 
+	np = of_find_node_by_path("/memory");
+	if (!np) {
+		pr_warn("no memory node use default configuration\n");
+		goto not_found;
+	}
+
+	ret = of_add_memory(np, true);
+	if (ret) {
+		pr_warn("memory node: probe failed use default configuration\n");
+		goto not_found;
+	}
+
+	pr_info("highbank: dtb probed memory size\n");
+
+	return 0;
+not_found:
+	highbank_add_ddram(4089 << 20);
 	return 0;
 }
 mem_initcall(highbank_mem_init);
 
 static int highbank_devices_init(void)
 {
-	highbank_register_gpio(0);
-	highbank_register_gpio(1);
-	highbank_register_gpio(2);
-	highbank_register_gpio(3);
-	highbank_register_ahci();
-	highbank_register_xgmac(0);
-	highbank_register_xgmac(1);
+	if (!fdt) {
+		highbank_register_gpio(0);
+		highbank_register_gpio(1);
+		highbank_register_gpio(2);
+		highbank_register_gpio(3);
+		highbank_register_ahci();
+		highbank_register_xgmac(0);
+		highbank_register_xgmac(1);
+	} else {
+		devfs_add_partition("ram0", FIRMWARE_DTB_BASE, SZ_64K, DEVFS_PARTITION_FIXED, "dtb");
+	}
 
 	armlinux_set_bootparams((void *)(0x00000100));
 
diff --git a/arch/arm/configs/highbank_defconfig b/arch/arm/configs/highbank_defconfig
index 22c1dcd..31ac954 100644
--- a/arch/arm/configs/highbank_defconfig
+++ b/arch/arm/configs/highbank_defconfig
@@ -37,6 +37,7 @@ CONFIG_CMD_UIMAGE=y
 CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
 CONFIG_CMD_OFTREE=y
+CONFIG_CMD_OFTREE_PROBE=y
 CONFIG_CMD_MTEST=y
 CONFIG_CMD_MTEST_ALTERNATIVE=y
 CONFIG_CMD_TIMEOUT=y
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-02-13 10:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-13 10:02 [PATCH 0/6 v3] arm: add Calxeda Highbank support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06 ` [PATCH 1/6] ahci-generic: add oftree support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` [PATCH 2/6] of: make of_add_memory available for other board Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 17:31     ` Sascha Hauer
2013-02-13 17:59       ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 18:09       ` [PATCH 1/1] of_add_memory: check the device_type is memory Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` [PATCH 3/6] highbank: add xgmac support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` [PATCH 4/6] arm: add highbank support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` [PATCH 5/6] highbank: add l2x0 support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-02-14 13:47 ` [PATCH 0/6 v3] arm: add Calxeda Highbank support Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360750004-17713-6-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=rob.herring@calxeda.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox