]> git.sur5r.net Git - u-boot/blobdiff - board/amcc/kilauea/kilauea.c
Merge branch 'u-boot-microblaze/zynq' into 'u-boot-arm/master'
[u-boot] / board / amcc / kilauea / kilauea.c
index 8ce244555acfdde7cb9c891368807860c948c082..abfaa1eee098aeeabb9ec834674018f9075247dd 100644 (file)
@@ -2,28 +2,12 @@
  * (C) Copyright 2007
  * Stefan Roese, DENX Software Engineering, sr@denx.de.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
-#include <ppc4xx.h>
-#include <ppc405.h>
+#include <asm/ppc4xx.h>
+#include <asm/ppc405.h>
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <asm/processor.h>
@@ -39,6 +23,37 @@ DECLARE_GLOBAL_DATA_PTR;
 
 extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips    */
 
+static int board_cpld_version(void)
+{
+       u32 cpld;
+
+       cpld = in_be32((void *)CONFIG_SYS_FPGA_FIFO_BASE);
+       if ((cpld & CONFIG_SYS_FPGA_MAGIC_MASK) != CONFIG_SYS_FPGA_MAGIC) {
+               /*
+                * Magic not found -> "old" CPLD revision which needs
+                * the "old" EBC configuration
+                */
+               mtebc(PB2AP, EBC_BXAP_BME_ENABLED | EBC_BXAP_FWT_ENCODE(5) |
+                     EBC_BXAP_BWT_ENCODE(0) | EBC_BXAP_BCE_DISABLE |
+                     EBC_BXAP_BCT_2TRANS | EBC_BXAP_CSN_ENCODE(0) |
+                     EBC_BXAP_OEN_ENCODE(0) | EBC_BXAP_WBN_ENCODE(3) |
+                     EBC_BXAP_WBF_ENCODE(0) | EBC_BXAP_TH_ENCODE(4) |
+                     EBC_BXAP_RE_DISABLED | EBC_BXAP_SOR_DELAYED |
+                     EBC_BXAP_BEM_WRITEONLY | EBC_BXAP_PEN_DISABLED);
+
+               /*
+                * Return 0 for "old" CPLD version
+                */
+               return 0;
+       }
+
+       /*
+        * Magic found -> "new" CPLD revision which needs no new
+        * EBC configuration
+        */
+       return (cpld & CONFIG_SYS_FPGA_VER_MASK) >> 8;
+}
+
 /*
  * Board early initialization function
  */
@@ -208,6 +223,13 @@ int board_early_init_f (void)
        val = SDR0_PFC1_USBEN | SDR0_PFC1_USBBIGEN | SDR0_PFC1_GPT_FREQ;
        mtsdr(SDR0_PFC1, val);
 
+       /*
+        * The CPLD version detection has to be the first access to
+        * the CPLD, so we need to make this access this early and
+        * save the CPLD version for later.
+        */
+       gd->board_type = board_cpld_version();
+
        /*
         * Configure FPGA register with PCIe reset
         */
@@ -269,18 +291,19 @@ int board_pcie_last(void)
 
 int checkboard (void)
 {
-       char *s = getenv("serial#");
+       char buf[64];
+       int i = getenv_f("serial#", buf, sizeof(buf));
 
        if (is_405exr())
                printf("Board: Haleakala - AMCC PPC405EXr Evaluation Board");
        else
                printf("Board: Kilauea - AMCC PPC405EX Evaluation Board");
 
-       if (s != NULL) {
+       if (i > 0) {
                puts(", serial# ");
-               puts(s);
+               puts(buf);
        }
-       putc('\n');
+       printf(" (CPLD rev. %ld)\n", gd->board_type);
 
        return (0);
 }