Socrates: Added FPGA base address update in FDT.
[oweals/u-boot.git] / board / socrates / socrates.c
index cb5899485a57da66b66d56a8c2e6675261031b2c..d791f1135f1036614a264c03af3dcad39b3f1243 100644 (file)
 #include <flash.h>
 #include <libfdt.h>
 #include <fdt_support.h>
+#include <asm/io.h>
 
+#if defined(CFG_FPGA_BASE)
+#include "upm_table.h"
+#endif
 DECLARE_GLOBAL_DATA_PTR;
 
 extern flash_info_t flash_info[];      /* FLASH chips info */
@@ -45,6 +49,9 @@ ulong flash_get_size (ulong base, int banknum);
 
 int checkboard (void)
 {
+       volatile ccsr_gur_t *gur = (void *)(CFG_MPC85xx_GUTS_ADDR);
+       char *src;
+       int f;
        char *s = getenv("serial#");
 
        puts("Board: Socrates");
@@ -55,8 +62,15 @@ int checkboard (void)
        putc('\n');
 
 #ifdef CONFIG_PCI
-       printf ("PCI1:  32 bit, %d MHz (compiled)\n",
-               CONFIG_SYS_CLK_FREQ / 1000000);
+       /* Check the PCI_clk sel bit */
+       if (in_be32(&gur->porpllsr) & (1<<15)) {
+               src = "SYSCLK";
+               f = CONFIG_SYS_CLK_FREQ;
+       } else {
+               src = "PCI_CLK";
+               f = CONFIG_PCI_CLK_FREQ;
+       }
+       printf ("PCI1:  32 bit, %d MHz (%s)\n", f/1000000, src);
 #else
        printf ("PCI1:  disabled\n");
 #endif
@@ -65,7 +79,10 @@ int checkboard (void)
         * Initialize local bus.
         */
        local_bus_init ();
-
+#if defined(CFG_FPGA_BASE)
+       /* Init UPMA for FPGA access */
+       upmconfig(UPMA, (uint *)UPMTableA, sizeof(UPMTableA)/sizeof(int));
+#endif
        return 0;
 }
 
@@ -207,5 +224,15 @@ ft_board_setup(void *blob, bd_t *bd)
        if (rc)
                printf("Unable to update property NOR mapping, err=%s\n",
                       fdt_strerror(rc));
+
+#if defined (CFG_FPGA_BASE)
+       memset(val, 0, sizeof(val));
+       val[0] = CFG_FPGA_BASE;
+       rc = fdt_find_and_setprop(blob, "/localbus/fpga", "virtual-reg",
+                                 val, sizeof(val), 1);
+       if (rc)
+               printf("Unable to update property \"fpga\", err=%s\n",
+                      fdt_strerror(rc));
+#endif
 }
 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */