public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH 1/2] add ft_cpu_setup(..) on mpc8260
@ 2007-10-17  7:12 Sergej Stepanov
  2007-10-17  7:47 ` Wolfgang Denk
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Sergej Stepanov @ 2007-10-17  7:12 UTC (permalink / raw)
  To: u-boot

add ft_cpu_setup(..)-function to adapt it for use with libfdt
based on code from mpc5xxx

Sigend-off-by: Sergej Stepanov <Sergej.Stepanov@ids.de>
---

diff --git a/cpu/mpc8260/cpu.c b/cpu/mpc8260/cpu.c
index 94651dc..8e78d89 100644
--- a/cpu/mpc8260/cpu.c
+++ b/cpu/mpc8260/cpu.c
@@ -38,6 +38,9 @@
  *
  * added HiP7 (824x/827x/8280) processors support by
  * Yuli Barcohen <yuli@arabellasw.com>
+ * 
+ * add ft_cpu_setup(..) for use with CONFIG_OF_LIBFDT
+ * Sergej Stepanov <Sergej.Stepanov@ids.de> 
  */
 
 #include <common.h>
@@ -47,6 +50,11 @@
 #include <asm/processor.h>
 #include <asm/cpm_8260.h>
 
+#if defined(CONFIG_OF_LIBFDT)
+#include <libfdt.h>
+#include <libfdt_env.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #if defined(CONFIG_GET_CPU_STR_F)
@@ -294,3 +302,36 @@ void watchdog_reset (void)
 #endif /* CONFIG_WATCHDOG */
 
 /* ------------------------------------------------------------------------- */
+#if defined(CONFIG_OF_LIBFDT)
+static void do_fixup(void *fdt, const char *node, const char *prop,
+		     const void *val, int len, int create)
+{
+#if defined(DEBUG)
+	int i;
+	debug("Updating property '%s/%s' = ", node, prop);
+	for (i = 0; i < len; i++)
+		debug(" %.2x", *(u8*)(val+i));
+	debug("\n");
+#endif
+	int rc = fdt_find_and_setprop(fdt, node, prop, val, len, create);
+	if (rc)
+		printf("Unable to update property %s:%s, err=%s\n",
+		       node, prop, fdt_strerror(rc));
+}
+
+static void do_fixup_u32(void *fdt, const char *node, const char *prop,
+			 u32 val, int create)
+{
+	val = cpu_to_fdt32(val);
+	do_fixup(fdt, node, prop, &val, sizeof(val), create);
+}
+
+void ft_cpu_setup (void *blob, bd_t *bd)
+{
+	char * cpu_path = "/cpus/" OF_CPU;
+
+	do_fixup_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
+	do_fixup_u32(blob, cpu_path, "timebase-frequency", OF_TBCLK, 1);
+	do_fixup_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
+}
+#endif /* CONFIG_OF_LIBFDT */

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-10-24  7:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-17  7:12 [U-Boot-Users] [PATCH 1/2] add ft_cpu_setup(..) on mpc8260 Sergej Stepanov
2007-10-17  7:47 ` Wolfgang Denk
2007-10-17 14:34 ` [U-Boot-Users] FDT intentions in u-boot Zach Sadecki
2007-10-17 15:02   ` Jerry Van Baren
2007-10-17 16:37     ` Joakim Tjernlund
2007-10-17 17:35       ` Jerry Van Baren
2007-10-18 13:54     ` Zach Sadecki
2007-10-18 19:29       ` Jerry Van Baren
2007-10-18 22:08         ` Haavard Skinnemoen
2007-10-18 22:43           ` Jerry Van Baren
2007-10-23 19:34 ` [U-Boot-Users] [PATCH 1/2] add ft_cpu_setup(..) on mpc8260 Scott Wood
2007-10-24  7:28   ` Sergej Stepanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox