All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2 v2] 8xx, kup4: add FDT support
Date: Mon, 19 Jul 2010 14:13:53 +0200	[thread overview]
Message-ID: <4C444181.9000305@denx.de> (raw)

Signed-off-by: Heiko Schocher <hs@denx.de>

---
- changes since v1
  - rebased against current mainline
  - fix printf output

 board/kup/kup4k/kup4k.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++
 include/configs/KUP4K.h |    4 +++
 2 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/board/kup/kup4k/kup4k.c b/board/kup/kup4k/kup4k.c
index 7eb36ab..637fe3d 100644
--- a/board/kup/kup4k/kup4k.c
+++ b/board/kup/kup4k/kup4k.c
@@ -24,6 +24,7 @@

 #include <common.h>
 #include <command.h>
+#include <libfdt.h>
 #include <mpc8xx.h>
 #include <hwconfig.h>
 #include <i2c.h>
@@ -291,3 +292,60 @@ static unsigned char swapbyte(unsigned char c)
 	}
 	return result;
 }
+
+/*
+ * Device Tree Support
+ */
+#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
+int fdt_set_node_and_value(void *blob,
+				char *nodename,
+				char *regname,
+				void *var,
+				int size)
+{
+	int ret = 0;
+	int nodeoffset = 0;
+
+	nodeoffset = fdt_path_offset(blob, nodename);
+	if (nodeoffset >= 0) {
+		ret = fdt_setprop(blob, nodeoffset, regname, var,
+					size);
+		if (ret < 0) {
+			printf("%s: cannot set %s/%s property; err: %s\n",
+			__func__, nodename, regname, fdt_strerror(ret));
+		}
+	} else {
+		printf("%s: cannot find %s node err:%s\n", __func__,
+			nodename, fdt_strerror(nodeoffset));
+	}
+	return ret;
+}
+
+/*
+ * update "brg" property in the blob
+ */
+void ft_blob_update(void *blob, bd_t *bd)
+{
+	uchar enetaddr[6];
+	ulong brg_data = 0;
+
+	/* BRG */
+	brg_data = cpu_to_be32(bd->bi_busfreq);
+	fdt_set_node_and_value(blob,
+				"/soc/cpm", "brg-frequency",
+				&brg_data, sizeof(brg_data));
+
+	/* MAC addr */
+	if (eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		fdt_set_node_and_value(blob,
+					"ethernet0", "local-mac-address",
+					enetaddr, sizeof(u8) * 6);
+	}
+}
+
+void ft_board_setup(void *blob, bd_t *bd)
+{
+	ft_cpu_setup(blob, bd);
+	ft_blob_update(blob, bd);
+}
+#endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */
diff --git a/include/configs/KUP4K.h b/include/configs/KUP4K.h
index ab708ae..14d412d 100644
--- a/include/configs/KUP4K.h
+++ b/include/configs/KUP4K.h
@@ -510,5 +510,9 @@
 #define CONFIG_SYS_DEVICE_NULLDEV	1       /* enble null device            */
 #define CONFIG_VERSION_VARIABLE		1

+/* pass open firmware flat tree */
+#define CONFIG_OF_LIBFDT	1
+#define CONFIG_OF_BOARD_SETUP	1
+
 #endif	/* __CONFIG_H */

-- 
1.6.2.5

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

             reply	other threads:[~2010-07-19 12:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-19 12:13 Heiko Schocher [this message]
2010-07-19 17:48 ` [U-Boot] [PATCH 2/2 v2] 8xx, kup4: add FDT support Scott Wood

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=4C444181.9000305@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.