]> git.sur5r.net Git - u-boot/blobdiff - board/atc/atc.c
dm: rpi: Move serial to driver model
[u-boot] / board / atc / atc.c
index 21ed2b051632ff42dee302fa27fe93866d44e057..0038561b10e6f0a5c4e0cc73c8ff233f87fc1371 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2001
  * Wolfgang Denk, DENX Software Engineering, wd@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>
@@ -92,20 +76,20 @@ const iop_conf_t iop_conf_tab[4][32] = {
        /* PB20 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RxD[1] */
        /* PB19 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RxD[2] */
        /* PB18 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RxD[3] */
-       /* PB17 */ {   0,   0,   0,   0,   0,   0   }, /* PB17 */
-       /* PB16 */ {   0,   0,   0,   0,   0,   0   }, /* PB16 */
-       /* PB15 */ {   0,   0,   0,   0,   0,   0   }, /* PB15 */
-       /* PB14 */ {   0,   0,   0,   0,   0,   0   }, /* PB14 */
-       /* PB13 */ {   0,   0,   0,   0,   0,   0   }, /* PB13 */
-       /* PB12 */ {   0,   0,   0,   0,   0,   0   }, /* PB12 */
-       /* PB11 */ {   0,   0,   0,   0,   0,   0   }, /* PB11 */
-       /* PB10 */ {   0,   0,   0,   0,   0,   0   }, /* PB10 */
-       /* PB9  */ {   0,   0,   0,   0,   0,   0   }, /* PB9 */
-       /* PB8  */ {   0,   0,   0,   0,   0,   0   }, /* PB8 */
-       /* PB7  */ {   0,   0,   0,   0,   0,   0   }, /* PB7 */
-       /* PB6  */ {   0,   0,   0,   0,   0,   0   }, /* PB6 */
-       /* PB5  */ {   0,   0,   0,   0,   0,   0   }, /* PB5 */
-       /* PB4  */ {   0,   0,   0,   0,   0,   0   }, /* PB4 */
+       /* PB17 */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII RX_DV */
+       /* PB16 */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII RX_ER */
+       /* PB15 */ {   1,   1,   0,   1,   0,   0   }, /* FCC3 MII TX_ER */
+       /* PB14 */ {   1,   1,   0,   1,   0,   0   }, /* FCC3 MII TX_EN */
+       /* PB13 */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII COL */
+       /* PB12 */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII CRS */
+       /* PB11 */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII RxD */
+       /* PB10 */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII RxD */
+       /* PB9  */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII RxD */
+       /* PB8  */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII RxD */
+       /* PB7  */ {   1,   1,   0,   1,   0,   0   }, /* FCC3 MII TxD */
+       /* PB6  */ {   1,   1,   0,   1,   0,   0   }, /* FCC3 MII TxD */
+       /* PB5  */ {   1,   1,   0,   1,   0,   0   }, /* FCC3 MII TxD */
+       /* PB4  */ {   1,   1,   0,   1,   0,   0   }, /* FCC3 MII TxD */
        /* PB3  */ {   0,   0,   0,   0,   0,   0   }, /* PB3 */
        /* PB2  */ {   0,   0,   0,   0,   0,   0   }, /* PB2 */
        /* PB1  */ {   0,   0,   0,   0,   0,   0   }, /* PB1 */
@@ -128,8 +112,8 @@ const iop_conf_t iop_conf_tab[4][32] = {
        /* PC20 */ {   1,   1,   0,   0,   0,   0   }, /* FCC1 MII TX_CLK */
        /* PC19 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RX_CLK */
        /* PC18 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII TX_CLK */
-       /* PC17 */ {   0,   0,   0,   0,   0,   0   }, /* PC17 */
-       /* PC16 */ {   0,   0,   0,   0,   0,   0   }, /* PC16 */
+       /* PC17 */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII RX_CLK */
+       /* PC16 */ {   1,   1,   0,   0,   0,   0   }, /* FCC3 MII TX_CLK */
 #if 0
        /* PC15 */ {   0,   0,   0,   0,   0,   0   }, /* PC15 */
 #else
@@ -170,7 +154,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
        /* PD18 */ {   0,   0,   0,   0,   0,   0   }, /* PD18 */
        /* PD17 */ {   0,   0,   0,   0,   0,   0   }, /* PD17 */
        /* PD16 */ {   0,   0,   0,   0,   0,   0   }, /* PD16 */
-#if defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_SOFT)
        /* PD15 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SDA */
        /* PD14 */ {   1,   0,   0,   1,   1,   1   }, /* I2C SCL */
 #else
@@ -203,6 +187,49 @@ const iop_conf_t iop_conf_tab[4][32] = {
     }
 };
 
+/*
+ * UPMB initialization table
+ */
+#define        _NOT_USED_      0xFFFFFFFF
+
+static const uint rtc_table[] =
+{
+       /*
+        * Single Read. (Offset 0 in UPMA RAM)
+        */
+       0xfffec00, 0xfffac00, 0xfff2d00, 0xfef2800,
+       0xfaf2080, 0xfaf2080, 0xfff2400, 0x1fff6c05, /* last */
+       /*
+        * Burst Read. (Offset 8 in UPMA RAM)
+        */
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       /*
+        * Single Write. (Offset 18 in UPMA RAM)
+        */
+       0xfffec00, 0xfffac00, 0xfff2d00, 0xfef2800,
+       0xfaf2080, 0xfaf2080, 0xfaf2400, 0x1fbf6c05, /* last */
+       /*
+        * Burst Write. (Offset 20 in UPMA RAM)
+        */
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       /*
+        * Refresh  (Offset 30 in UPMA RAM)
+        */
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+       /*
+        * Exception. (Offset 3c in UPMA RAM)
+        */
+       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+};
+
 /* ------------------------------------------------------------------------- */
 
 /* Check Board Identity:
@@ -226,13 +253,10 @@ static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
                          ulong orx, volatile uchar * base)
 {
        volatile uchar c = 0xff;
-       ulong cnt, val;
-       volatile ulong *addr;
        volatile uint *sdmr_ptr;
        volatile uint *orx_ptr;
+       ulong maxsize, size;
        int i;
-       ulong save[32];         /* to make test non-destructive */
-       ulong maxsize;
 
        /* We must be able to test a location outsize the maximum legal size
         * to find out THAT we are outside; but this address still has to be
@@ -241,7 +265,7 @@ static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
         */
        maxsize = (1 + (~orx | 0x7fff)) / 2;
 
-       /* Since CFG_SDRAM_BASE is always 0 (??), we assume that
+       /* Since CONFIG_SYS_SDRAM_BASE is always 0 (??), we assume that
         * we are configuring CS1 if base != 0
         */
        sdmr_ptr = &memctl->memc_psdmr;
@@ -266,7 +290,7 @@ static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
         *  accessing the SDRAM with a single-byte transaction."
         *
         * The appropriate BRx/ORx registers have already been set when we
-        * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
+        * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
         */
 
        *sdmr_ptr = sdmr | PSDMR_OP_PREA;
@@ -277,92 +301,72 @@ static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
                *base = c;
 
        *sdmr_ptr = sdmr | PSDMR_OP_MRW;
-       *(base + CFG_MRS_OFFS) = c;     /* setting MR on address lines */
+       *(base + CONFIG_SYS_MRS_OFFS) = c;      /* setting MR on address lines */
 
        *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
        *base = c;
 
-       /*
-        * Check memory range for valid RAM. A simple memory test determines
-        * the actually available RAM size between addresses `base' and
-        * `base + maxsize'. Some (not all) hardware errors are detected:
-        * - short between address lines
-        * - short between data lines
-        */
-       i = 0;
-       for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) {
-               addr = (volatile ulong *) base + cnt;   /* pointer arith! */
-               save[i++] = *addr;
-               *addr = ~cnt;
-       }
+       size = get_ram_size((long *)base, maxsize);
 
-       addr = (volatile ulong *) base;
-       save[i] = *addr;
-       *addr = 0;
+       *orx_ptr = orx | ~(size - 1);
 
-       if ((val = *addr) != 0) {
-               *addr = save[i];
-               return (0);
-       }
+       return (size);
+}
 
-       for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) {
-               addr = (volatile ulong *) base + cnt;   /* pointer arith! */
-               val = *addr;
-               *addr = save[--i];
-               if (val != ~cnt) {
-                       /* Write the actual size to ORx
-                        */
-                       *orx_ptr = orx | ~(cnt * sizeof (long) - 1);
-                       return (cnt * sizeof (long));
-               }
-       }
-       return (maxsize);
+int misc_init_r(void)
+{
+       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
+       volatile memctl8260_t *memctl = &immap->im_memctl;
+
+       upmconfig(UPMA, (uint *)rtc_table, sizeof(rtc_table) / sizeof(uint));
+       memctl->memc_mamr = MxMR_RLFx_6X | MxMR_WLFx_6X | MxMR_OP_NORM;
+
+       return (0);
 }
 
-long int initdram (int board_type)
+phys_size_t initdram (int board_type)
 {
-       volatile immap_t *immap = (immap_t *) CFG_IMMR;
+       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
        volatile memctl8260_t *memctl = &immap->im_memctl;
 
-#ifndef CFG_RAMBOOT
+#ifndef CONFIG_SYS_RAMBOOT
        ulong size8, size9;
 #endif
        long psize;
 
        psize = 8 * 1024 * 1024;
 
-       memctl->memc_mptpr = CFG_MPTPR;
-       memctl->memc_psrt = CFG_PSRT;
+       memctl->memc_mptpr = CONFIG_SYS_MPTPR;
+       memctl->memc_psrt = CONFIG_SYS_PSRT;
 
-#ifndef CFG_RAMBOOT
+#ifndef CONFIG_SYS_RAMBOOT
        /* 60x SDRAM setup:
         */
-       size8 = try_init (memctl, CFG_PSDMR_8COL, CFG_OR2_8COL,
-                         (uchar *) CFG_SDRAM_BASE);
-       size9 = try_init (memctl, CFG_PSDMR_9COL, CFG_OR2_9COL,
-                         (uchar *) CFG_SDRAM_BASE);
+       size8 = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR2_8COL,
+                         (uchar *) CONFIG_SYS_SDRAM_BASE);
+       size9 = try_init (memctl, CONFIG_SYS_PSDMR_9COL, CONFIG_SYS_OR2_9COL,
+                         (uchar *) CONFIG_SYS_SDRAM_BASE);
 
        if (size8 < size9) {
                psize = size9;
                printf ("(60x:9COL) ");
        } else {
-               psize = try_init (memctl, CFG_PSDMR_8COL, CFG_OR2_8COL,
-                                 (uchar *) CFG_SDRAM_BASE);
+               psize = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR2_8COL,
+                                 (uchar *) CONFIG_SYS_SDRAM_BASE);
                printf ("(60x:8COL) ");
        }
 
-#endif /* CFG_RAMBOOT */
+#endif /* CONFIG_SYS_RAMBOOT */
 
        icache_enable ();
 
        return (psize);
 }
 
-#if (CONFIG_COMMANDS & CFG_CMD_DOC)
-extern void doc_probe (ulong physadr);
+#if defined(CONFIG_CMD_DOC)
 void doc_init (void)
 {
-       doc_probe (CFG_DOC_BASE);
+       doc_probe (CONFIG_SYS_DOC_BASE);
 }
 #endif