[POWERPC] mpc5200: Add cuimage support for mpc5200 boards
authorGrant Likely <grant.likely@secretlab.ca>
Fri, 31 Aug 2007 17:34:37 +0000 (03:34 +1000)
committerPaul Mackerras <paulus@samba.org>
Sat, 22 Sep 2007 04:49:22 +0000 (14:49 +1000)
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/boot/Makefile
arch/powerpc/boot/cuboot-52xx.c [new file with mode: 0644]
arch/powerpc/boot/mpc52xx-psc.c [new file with mode: 0644]
arch/powerpc/boot/ops.h
arch/powerpc/boot/serial.c
arch/powerpc/platforms/52xx/Kconfig

index c1582b62911c6843d46f3f1b1eb4dce3779dc6ea..b63e423428c721a72f3727885b94fc774e679549 100644 (file)
@@ -45,8 +45,8 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
                ns16550.c serial.c simple_alloc.c div64.S util.S \
                gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
                4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
-               cpm-serial.c stdlib.c
-src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
+               cpm-serial.c stdlib.c mpc52xx-psc.c
+src-plat := of.c cuboot-52xx.c cuboot-83xx.c cuboot-85xx.c holly.c \
                cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
                ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
                cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c cuboot-bamboo.c
@@ -143,6 +143,7 @@ image-$(CONFIG_DEFAULT_UIMAGE)              += uImage
 ifneq ($(CONFIG_DEVICE_TREE),"")
 image-$(CONFIG_PPC_8xx)                        += cuImage.8xx
 image-$(CONFIG_8260)                   += cuImage.pq2
+image-$(CONFIG_PPC_MPC52xx)            += cuImage.52xx
 image-$(CONFIG_PPC_83xx)               += cuImage.83xx
 image-$(CONFIG_PPC_85xx)               += cuImage.85xx
 image-$(CONFIG_EBONY)                  += treeImage.ebony cuImage.ebony
diff --git a/arch/powerpc/boot/cuboot-52xx.c b/arch/powerpc/boot/cuboot-52xx.c
new file mode 100644 (file)
index 0000000..9256a26
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Old U-boot compatibility for MPC5200
+ *
+ * Author: Grant Likely <grant.likely@secretlab.ca>
+ *
+ * Copyright (c) 2007 Secret Lab Technologies Ltd.
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ops.h"
+#include "stdio.h"
+#include "io.h"
+#include "cuboot.h"
+
+#define TARGET_PPC_MPC52xx
+#include "ppcboot.h"
+
+static bd_t bd;
+
+static void platform_fixups(void)
+{
+       void *soc, *reg;
+       int div;
+       u32 sysfreq;
+
+
+       dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
+       dt_fixup_mac_addresses(bd.bi_enetaddr);
+       dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 4, bd.bi_busfreq);
+
+       /* Unfortunately, the specific model number is encoded in the
+        * soc node name in existing dts files -- once that is fixed,
+        * this can do a simple path lookup.
+        */
+       soc = find_node_by_devtype(NULL, "soc");
+       if (soc) {
+               setprop(soc, "bus-frequency", &bd.bi_ipbfreq,
+                       sizeof(bd.bi_ipbfreq));
+
+               if (!dt_xlate_reg(soc, 0, (void*)&reg, NULL))
+                       return;
+               div = in_8(reg + 0x204) & 0x0020 ? 8 : 4;
+               sysfreq = bd.bi_busfreq * div;
+               setprop(soc, "system-frequency", &sysfreq, sizeof(sysfreq));
+       }
+}
+
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+                   unsigned long r6, unsigned long r7)
+{
+       CUBOOT_INIT();
+       ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
+       serial_console_init();
+       platform_ops.fixups = platform_fixups;
+}
diff --git a/arch/powerpc/boot/mpc52xx-psc.c b/arch/powerpc/boot/mpc52xx-psc.c
new file mode 100644 (file)
index 0000000..1074626
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * MPC5200 PSC serial console support.
+ *
+ * Author: Grant Likely <grant.likely@secretlab.ca>
+ *
+ * Copyright (c) 2007 Secret Lab Technologies Ltd.
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * It is assumed that the firmware (or the platform file) has already set
+ * up the port.
+ */
+
+#include "types.h"
+#include "io.h"
+#include "ops.h"
+
+/* Programmable Serial Controller (PSC) status register bits */
+#define MPC52xx_PSC_SR         0x04
+#define MPC52xx_PSC_SR_RXRDY           0x0100
+#define MPC52xx_PSC_SR_RXFULL          0x0200
+#define MPC52xx_PSC_SR_TXRDY           0x0400
+#define MPC52xx_PSC_SR_TXEMP           0x0800
+
+#define MPC52xx_PSC_BUFFER     0x0C
+
+static void *psc;
+
+static int psc_open(void)
+{
+       /* Assume the firmware has already configured the PSC into
+        * uart mode */
+       return 0;
+}
+
+static void psc_putc(unsigned char c)
+{
+       while (!(in_be16(psc + MPC52xx_PSC_SR) & MPC52xx_PSC_SR_TXRDY)) ;
+       out_8(psc + MPC52xx_PSC_BUFFER, c);
+}
+
+static unsigned char psc_tstc(void)
+{
+       return (in_be16(psc + MPC52xx_PSC_SR) & MPC52xx_PSC_SR_RXRDY) != 0;
+}
+
+static unsigned char psc_getc(void)
+{
+       while (!(in_be16(psc + MPC52xx_PSC_SR) & MPC52xx_PSC_SR_RXRDY)) ;
+       return in_8(psc + MPC52xx_PSC_BUFFER);
+}
+
+int mpc5200_psc_console_init(void *devp, struct serial_console_data *scdp)
+{
+       int n;
+
+       /* Get the base address of the psc registers */
+       n = getprop(devp, "virtual-reg", &psc, sizeof(psc));
+       if (n != sizeof(psc)) {
+               if (!dt_xlate_reg(devp, 0, (void *)&psc, NULL))
+                       return -1;
+       }
+
+       scdp->open = psc_open;
+       scdp->putc = psc_putc;
+       scdp->getc = psc_getc;
+       scdp->tstc = psc_tstc;
+
+       return 0;
+}
index 703255bf0089c07af15d54cb4ca18d7d92a1e0a1..f639fcab2c4453e95df7f050ae629d4717c1004e 100644 (file)
@@ -84,6 +84,7 @@ int serial_console_init(void);
 int ns16550_console_init(void *devp, struct serial_console_data *scdp);
 int mpsc_console_init(void *devp, struct serial_console_data *scdp);
 int cpm_console_init(void *devp, struct serial_console_data *scdp);
+int mpc5200_psc_console_init(void *devp, struct serial_console_data *scdp);
 void *simple_alloc_init(char *base, unsigned long heap_size,
                        unsigned long granularity, unsigned long max_allocs);
 extern void flush_cache(void *, unsigned long);
index d47f8e0b4b8195e0564b888ae551ef90b692bdc3..95e08e4ddcd26db5999d1fbaa0b9768bc979b663 100644 (file)
@@ -126,6 +126,8 @@ int serial_console_init(void)
                 dt_is_compatible(devp, "fsl,cpm2-scc-uart") ||
                 dt_is_compatible(devp, "fsl,cpm2-smc-uart"))
                rc = cpm_console_init(devp, &serial_cd);
+       else if (dt_is_compatible(devp, "mpc5200-psc-uart"))
+               rc = mpc5200_psc_console_init(devp, &serial_cd);
 
        /* Add other serial console driver calls here */
 
index 3ffaa066c2c8b5660863d76647e8500b40d84235..9ddf251b192b2400174c15e054e1d7179d7105bd 100644 (file)
@@ -30,6 +30,7 @@ config PPC_EFIKA
 config PPC_LITE5200
        bool "Freescale Lite5200 Eval Board"
        depends on PPC_MULTIPLATFORM && PPC32
+       select WANT_DEVICE_TREE
        select PPC_MPC5200
        default n