]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - cpu/ppc4xx/cpu.c
imported Ka-Ro specific additions to U-Boot 2009.08 for TX28
[karo-tx-uboot.git] / cpu / ppc4xx / cpu.c
index f4a7208c8f3d4e32b80e7e819ce57e2aef9d937e..e9861abe76292a0c73b3ef81488b110f53270bb9 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000-2006
+ * (C) Copyright 2000-2007
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
 #include <command.h>
 #include <asm/cache.h>
 #include <ppc4xx.h>
+#include <netdev.h>
 
-#if !defined(CONFIG_405)
 DECLARE_GLOBAL_DATA_PTR;
-#endif
 
-#if defined(CONFIG_440)
-#define FREQ_EBC               (sys_info.freqEPB)
-#else
-#define FREQ_EBC               (sys_info.freqPLB / sys_info.pllExtBusDiv)
-#endif
+void board_reset(void);
+
+/*
+ * To provide an interface to detect CPU number for boards that support
+ * more then one CPU, we implement the "weak" default functions here.
+ *
+ * Returns CPU number
+ */
+int __get_cpu_num(void)
+{
+       return NA_OR_UNKNOWN_CPU;
+}
+int get_cpu_num(void) __attribute__((weak, alias("__get_cpu_num")));
 
+#if defined(CONFIG_PCI)
 #if defined(CONFIG_405GP) || \
     defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
     defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
 
 #define PCI_ASYNC
 
-int pci_async_enabled(void)
+static int pci_async_enabled(void)
 {
 #if defined(CONFIG_405GP)
        return (mfdcr(strap) & PSR_PCI_ASYNC_EN);
 #endif
 
 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
-    defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
+    defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
+    defined(CONFIG_460EX) || defined(CONFIG_460GT)
        unsigned long val;
 
        mfsdr(sdr_sdstp1, val);
@@ -68,9 +77,11 @@ int pci_async_enabled(void)
 #endif
 }
 #endif
+#endif /* CONFIG_PCI */
 
-#if defined(CONFIG_PCI) && !defined(CONFIG_IOP480) && !defined(CONFIG_405)
-int pci_arbiter_enabled(void)
+#if defined(CONFIG_PCI) && !defined(CONFIG_IOP480) && \
+    !defined(CONFIG_405) && !defined(CONFIG_405EX)
+static int pci_arbiter_enabled(void)
 {
 #if defined(CONFIG_405GP)
        return (mfdcr(strap) & PSR_PCI_ARBIT_EN);
@@ -84,26 +95,27 @@ int pci_arbiter_enabled(void)
        return (mfdcr(cpc0_strp1) & CPC0_STRP1_PAE_MASK);
 #endif
 
-#if defined(CONFIG_440GX) || \
-    defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
+#if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
+       unsigned long val;
+
+       mfsdr(sdr_xcr, val);
+       return (val & 0x80000000);
+#endif
+#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
     defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
-    defined(CONFIG_440SP) || defined(CONFIG_440SPE)
+    defined(CONFIG_460EX) || defined(CONFIG_460GT)
        unsigned long val;
 
-       mfsdr(sdr_sdstp1, val);
-       return (val & SDR0_SDSTP1_PAE_MASK);
+       mfsdr(sdr_pci0, val);
+       return (val & 0x80000000);
 #endif
 }
 #endif
 
-#if defined(CONFIG_405EP) || defined(CONFIG_440GX) || \
-    defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
-    defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
-    defined(CONFIG_440SP) || defined(CONFIG_440SPE)
-
+#if defined(CONFIG_405EP)
 #define I2C_BOOTROM
 
-int i2c_bootrom_enabled(void)
+static int i2c_bootrom_enabled(void)
 {
 #if defined(CONFIG_405EP)
        return (mfdcr(cpc0_boot) & CPC0_BOOT_SEP);
@@ -114,6 +126,7 @@ int i2c_bootrom_enabled(void)
        return (val & SDR0_SDCS_SDD);
 #endif
 }
+#endif
 
 #if defined(CONFIG_440GX)
 #define SDR0_PINSTP_SHIFT      29
@@ -127,6 +140,7 @@ static char *bootstrap_str[] = {
        "Reserved",
        "I2C (Addr 0x50)",
 };
+static char bootstrap_char[] = { 'A', 'B', 'C', 'B', 'D', 'E', 'x', 'F' };
 #endif
 
 #if defined(CONFIG_440SP) || defined(CONFIG_440SPE)
@@ -137,6 +151,7 @@ static char *bootstrap_str[] = {
        "I2C (Addr 0x54)",
        "I2C (Addr 0x50)",
 };
+static char bootstrap_char[] = { 'A', 'B', 'C', 'D'};
 #endif
 
 #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
@@ -151,6 +166,7 @@ static char *bootstrap_str[] = {
        "PCI",
        "I2C (Addr 0x52)",
 };
+static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
 #endif
 
 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
@@ -165,6 +181,74 @@ static char *bootstrap_str[] = {
        "PCI",
        "I2C (Addr 0x52)",
 };
+static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
+#endif
+
+#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
+#define SDR0_PINSTP_SHIFT      29
+static char *bootstrap_str[] = {
+       "EBC (8 bits)",
+       "EBC (16 bits)",
+       "PCI",
+       "PCI",
+       "EBC (16 bits)",
+       "NAND (8 bits)",
+       "I2C (Addr 0x54)",      /* A8 */
+       "I2C (Addr 0x52)",      /* A4 */
+};
+static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
+#endif
+
+#if defined(CONFIG_460SX)
+#define SDR0_PINSTP_SHIFT      29
+static char *bootstrap_str[] = {
+       "EBC (8 bits)",
+       "EBC (16 bits)",
+       "EBC (32 bits)",
+       "NAND (8 bits)",
+       "I2C (Addr 0x54)",      /* A8 */
+       "I2C (Addr 0x52)",      /* A4 */
+};
+static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G' };
+#endif
+
+#if defined(CONFIG_405EZ)
+#define SDR0_PINSTP_SHIFT      28
+static char *bootstrap_str[] = {
+       "EBC (8 bits)",
+       "SPI (fast)",
+       "NAND (512 page, 4 addr cycle)",
+       "I2C (Addr 0x50)",
+       "EBC (32 bits)",
+       "I2C (Addr 0x50)",
+       "NAND (2K page, 5 addr cycle)",
+       "I2C (Addr 0x50)",
+       "EBC (16 bits)",
+       "Reserved",
+       "NAND (2K page, 4 addr cycle)",
+       "I2C (Addr 0x50)",
+       "NAND (512 page, 3 addr cycle)",
+       "I2C (Addr 0x50)",
+       "SPI (slow)",
+       "I2C (Addr 0x50)",
+};
+static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', \
+                                'I', 'x', 'K', 'L', 'M', 'N', 'O', 'P' };
+#endif
+
+#if defined(CONFIG_405EX)
+#define SDR0_PINSTP_SHIFT      29
+static char *bootstrap_str[] = {
+       "EBC (8 bits)",
+       "EBC (16 bits)",
+       "EBC (16 bits)",
+       "NAND (8 bits)",
+       "NAND (8 bits)",
+       "I2C (Addr 0x54)",
+       "EBC (8 bits)",
+       "I2C (Addr 0x52)",
+};
+static char bootstrap_char[] = { 'A', 'B', 'C', 'D', 'E', 'G', 'F', 'H' };
 #endif
 
 #if defined(SDR0_PINSTP_SHIFT)
@@ -172,15 +256,26 @@ static int bootstrap_option(void)
 {
        unsigned long val;
 
-       mfsdr(sdr_pinstp, val);
-       return ((val & 0xe0000000) >> SDR0_PINSTP_SHIFT);
+       mfsdr(SDR_PINSTP, val);
+       return ((val & 0xf0000000) >> SDR0_PINSTP_SHIFT);
 }
 #endif /* SDR0_PINSTP_SHIFT */
-#endif
 
 
 #if defined(CONFIG_440)
-static int do_chip_reset(unsigned long sys0, unsigned long sys1);
+static int do_chip_reset (unsigned long sys0, unsigned long sys1)
+{
+       /* Changes to cpc0_sys0 and cpc0_sys1 require chip
+        * reset.
+        */
+       mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000);    /* Set SWE */
+       mtdcr (cpc0_sys0, sys0);
+       mtdcr (cpc0_sys1, sys1);
+       mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000);   /* Clr SWE */
+       mtspr (SPRN_DBCR0, 0x20000000); /* Reset the chip */
+
+       return 1;
+}
 #endif
 
 
@@ -190,22 +285,40 @@ int checkcpu (void)
        uint pvr = get_pvr();
        ulong clock = gd->cpu_clk;
        char buf[32];
+#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
+       u32 reg;
+#endif
 
 #if !defined(CONFIG_IOP480)
        char addstr[64] = "";
        sys_info_t sys_info;
+       int cpu_num;
 
-       puts ("CPU:   ");
+       cpu_num = get_cpu_num();
+       if (cpu_num >= 0)
+               printf("CPU%d:  ", cpu_num);
+       else
+               puts("CPU:   ");
 
        get_sys_info(&sys_info);
 
+#if defined(CONFIG_XILINX_440)
+       puts("IBM PowerPC 4");
+#else
        puts("AMCC PowerPC 4");
+#endif
 
-#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
+#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
+    defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
+    defined(CONFIG_405EX)
        puts("05");
 #endif
 #if defined(CONFIG_440)
+#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
+       puts("60");
+#else
        puts("40");
+#endif
 #endif
 
        switch (pvr) {
@@ -249,6 +362,50 @@ int checkcpu (void)
                puts("EP Rev. B");
                break;
 
+       case PVR_405EZ_RA:
+               puts("EZ Rev. A");
+               break;
+
+       case PVR_405EX1_RA:
+               puts("EX Rev. A");
+               strcpy(addstr, "Security support");
+               break;
+
+       case PVR_405EX2_RA:
+               puts("EX Rev. A");
+               strcpy(addstr, "No Security support");
+               break;
+
+       case PVR_405EXR1_RA:
+               puts("EXr Rev. A");
+               strcpy(addstr, "Security support");
+               break;
+
+       case PVR_405EXR2_RA:
+               puts("EXr Rev. A");
+               strcpy(addstr, "No Security support");
+               break;
+
+       case PVR_405EX1_RC:
+               puts("EX Rev. C");
+               strcpy(addstr, "Security support");
+               break;
+
+       case PVR_405EX2_RC:
+               puts("EX Rev. C");
+               strcpy(addstr, "No Security support");
+               break;
+
+       case PVR_405EXR1_RC:
+               puts("EXr Rev. C");
+               strcpy(addstr, "Security support");
+               break;
+
+       case PVR_405EXR2_RC:
+               puts("EXr Rev. C");
+               strcpy(addstr, "No Security support");
+               break;
+
 #if defined(CONFIG_440)
        case PVR_440GP_RB:
                puts("GP Rev. B");
@@ -308,40 +465,132 @@ int checkcpu (void)
 #endif /* CONFIG_440GR */
 #endif /* CONFIG_440 */
 
-       case PVR_440EPX1_RA:
+#ifdef CONFIG_440EPX
+       case PVR_440EPX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
                puts("EPx Rev. A");
                strcpy(addstr, "Security/Kasumi support");
                break;
 
-       case PVR_440EPX2_RA:
+       case PVR_440EPX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
                puts("EPx Rev. A");
                strcpy(addstr, "No Security/Kasumi support");
                break;
+#endif /* CONFIG_440EPX */
 
-       case PVR_440GRX1_RA:
+#ifdef CONFIG_440GRX
+       case PVR_440GRX1_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
                puts("GRx Rev. A");
                strcpy(addstr, "Security/Kasumi support");
                break;
 
-       case PVR_440GRX2_RA:
+       case PVR_440GRX2_RA: /* 440EPx rev A and 440GRx rev A have same PVR */
                puts("GRx Rev. A");
                strcpy(addstr, "No Security/Kasumi support");
                break;
+#endif /* CONFIG_440GRX */
+
+       case PVR_440SP_6_RAB:
+               puts("SP Rev. A/B");
+               strcpy(addstr, "RAID 6 support");
+               break;
+
+       case PVR_440SP_RAB:
+               puts("SP Rev. A/B");
+               strcpy(addstr, "No RAID 6 support");
+               break;
+
+       case PVR_440SP_6_RC:
+               puts("SP Rev. C");
+               strcpy(addstr, "RAID 6 support");
+               break;
 
-       case PVR_440SP_RA:
-               puts("SP Rev. A");
+       case PVR_440SP_RC:
+               puts("SP Rev. C");
+               strcpy(addstr, "No RAID 6 support");
                break;
 
-       case PVR_440SP_RB:
-               puts("SP Rev. B");
+       case PVR_440SPe_6_RA:
+               puts("SPe Rev. A");
+               strcpy(addstr, "RAID 6 support");
                break;
 
        case PVR_440SPe_RA:
                puts("SPe Rev. A");
+               strcpy(addstr, "No RAID 6 support");
+               break;
+
+       case PVR_440SPe_6_RB:
+               puts("SPe Rev. B");
+               strcpy(addstr, "RAID 6 support");
                break;
 
        case PVR_440SPe_RB:
                puts("SPe Rev. B");
+               strcpy(addstr, "No RAID 6 support");
+               break;
+
+#if defined(CONFIG_460EX) || defined(CONFIG_460GT)
+       case PVR_460EX_RA:
+               puts("EX Rev. A");
+               strcpy(addstr, "No Security/Kasumi support");
+               break;
+
+       case PVR_460EX_SE_RA:
+               puts("EX Rev. A");
+               strcpy(addstr, "Security/Kasumi support");
+               break;
+
+       case PVR_460EX_RB:
+               puts("EX Rev. B");
+               mfsdr(SDR0_ECID3, reg);
+               if (reg & 0x00100000)
+                       strcpy(addstr, "No Security/Kasumi support");
+               else
+                       strcpy(addstr, "Security/Kasumi support");
+               break;
+
+       case PVR_460GT_RA:
+               puts("GT Rev. A");
+               strcpy(addstr, "No Security/Kasumi support");
+               break;
+
+       case PVR_460GT_SE_RA:
+               puts("GT Rev. A");
+               strcpy(addstr, "Security/Kasumi support");
+               break;
+
+       case PVR_460GT_RB:
+               puts("GT Rev. B");
+               mfsdr(SDR0_ECID3, reg);
+               if (reg & 0x00100000)
+                       strcpy(addstr, "No Security/Kasumi support");
+               else
+                       strcpy(addstr, "Security/Kasumi support");
+               break;
+#endif
+
+       case PVR_460SX_RA:
+               puts("SX Rev. A");
+               strcpy(addstr, "Security support");
+               break;
+
+       case PVR_460SX_RA_V1:
+               puts("SX Rev. A");
+               strcpy(addstr, "No Security support");
+               break;
+
+       case PVR_460GX_RA:
+               puts("GX Rev. A");
+               strcpy(addstr, "Security support");
+               break;
+
+       case PVR_460GX_RA_V1:
+               puts("GX Rev. A");
+               strcpy(addstr, "No Security support");
+               break;
+
+       case PVR_VIRTEX5:
+               puts("x5 VIRTEX5");
                break;
 
        default:
@@ -350,26 +599,30 @@ int checkcpu (void)
        }
 
        printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
-              sys_info.freqPLB / 1000000,
-              sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
-              FREQ_EBC / 1000000);
+               sys_info.freqPLB / 1000000,
+               get_OPB_freq() / 1000000,
+               sys_info.freqEBC / 1000000);
 
        if (addstr[0] != 0)
                printf("       %s\n", addstr);
 
 #if defined(I2C_BOOTROM)
        printf ("       I2C boot EEPROM %sabled\n", i2c_bootrom_enabled() ? "en" : "dis");
+#endif /* I2C_BOOTROM */
 #if defined(SDR0_PINSTP_SHIFT)
-       printf ("       Bootstrap Option %c - ", (char)bootstrap_option() + 'A');
-       printf ("Boot ROM Location %s\n", bootstrap_str[bootstrap_option()]);
+       printf ("       Bootstrap Option %c - ", bootstrap_char[bootstrap_option()]);
+       printf ("Boot ROM Location %s", bootstrap_str[bootstrap_option()]);
+#ifdef CONFIG_NAND_U_BOOT
+       puts(", booting from NAND");
+#endif /* CONFIG_NAND_U_BOOT */
+       putc('\n');
 #endif /* SDR0_PINSTP_SHIFT */
-#endif /* I2C_BOOTROM */
 
-#if defined(CONFIG_PCI)
+#if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
        printf ("       Internal PCI arbiter %sabled", pci_arbiter_enabled() ? "en" : "dis");
 #endif
 
-#if defined(PCI_ASYNC)
+#if defined(CONFIG_PCI) && defined(PCI_ASYNC)
        if (pci_async_enabled()) {
                printf (", PCI async ext clock used");
        } else {
@@ -378,11 +631,11 @@ int checkcpu (void)
        }
 #endif
 
-#if defined(CONFIG_PCI)
+#if defined(CONFIG_PCI) && !defined(CONFIG_405EX)
        putc('\n');
 #endif
 
-#if defined(CONFIG_405EP)
+#if defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX)
        printf ("       16 kB I-Cache 16 kB D-Cache");
 #elif defined(CONFIG_440)
        printf ("       32 kB I-Cache 32 kB D-Cache");
@@ -406,58 +659,36 @@ int checkcpu (void)
        return 0;
 }
 
-#if defined (CONFIG_440SPE)
 int ppc440spe_revB() {
        unsigned int pvr;
 
        pvr = get_pvr();
-       if (pvr == PVR_440SPe_RB)
+       if ((pvr == PVR_440SPe_6_RB) || (pvr == PVR_440SPe_RB))
                return 1;
        else
                return 0;
 }
-#endif
 
 /* ------------------------------------------------------------------------- */
 
 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-#if defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)
-       /*give reset to BCSR*/
-       *(unsigned char*)(CFG_BCSR_BASE | 0x06) = 0x09;
-
+#if defined(CONFIG_BOARD_RESET)
+       board_reset();
+#else
+#if defined(CONFIG_SYS_4xx_RESET_TYPE)
+       mtspr(SPRN_DBCR0, CONFIG_SYS_4xx_RESET_TYPE << 28);
 #else
-
        /*
         * Initiate system reset in debug control register DBCR
         */
-       __asm__ __volatile__("lis   3, 0x3000" ::: "r3");
-#if defined(CONFIG_440)
-       __asm__ __volatile__("mtspr 0x134, 3");
-#else
-       __asm__ __volatile__("mtspr 0x3f2, 3");
-#endif
+       mtspr(SPRN_DBCR0, 0x30000000);
+#endif /* defined(CONFIG_SYS_4xx_RESET_TYPE) */
+#endif /* defined(CONFIG_BOARD_RESET) */
 
-#endif/* defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)*/
        return 1;
 }
 
-#if defined(CONFIG_440)
-static int do_chip_reset (unsigned long sys0, unsigned long sys1)
-{
-       /* Changes to cpc0_sys0 and cpc0_sys1 require chip
-        * reset.
-        */
-       mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000);    /* Set SWE */
-       mtdcr (cpc0_sys0, sys0);
-       mtdcr (cpc0_sys1, sys1);
-       mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000);   /* Clr SWE */
-       mtspr (dbcr0, 0x20000000);      /* Reset the chip */
-
-       return 1;
-}
-#endif
-
 
 /*
  * Get timebase clock frequency
@@ -477,20 +708,30 @@ unsigned long get_tbclk (void)
 
 
 #if defined(CONFIG_WATCHDOG)
-void
-watchdog_reset(void)
+void watchdog_reset(void)
 {
        int re_enable = disable_interrupts();
        reset_4xx_watchdog();
        if (re_enable) enable_interrupts();
 }
 
-void
-reset_4xx_watchdog(void)
+void reset_4xx_watchdog(void)
 {
        /*
         * Clear TSR(WIS) bit
         */
-       mtspr(tsr, 0x40000000);
+       mtspr(SPRN_TSR, 0x40000000);
 }
 #endif /* CONFIG_WATCHDOG */
+
+/*
+ * Initializes on-chip ethernet controllers.
+ * to override, implement board_eth_init()
+ */
+int cpu_eth_init(bd_t *bis)
+{
+#if defined(CONFIG_PPC4xx_EMAC)
+       ppc_4xx_eth_initialize(bis);
+#endif
+       return 0;
+}