]> git.sur5r.net Git - u-boot/blobdiff - board/freescale/mpc8349itx/mpc8349itx.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot] / board / freescale / mpc8349itx / mpc8349itx.c
index 56475795b68246c4cf7448cf52c71ff27c1c9bfc..3bdec1c40054d876d2e66208e5b4cc9e45639661 100644 (file)
@@ -1,23 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) Freescale Semiconductor, Inc. 2006.
- *
- * 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
  */
 
 #include <common.h>
 #include <spd_sdram.h>
 #include <asm/mmu.h>
 #if defined(CONFIG_OF_LIBFDT)
-#include <libfdt.h>
+#include <linux/libfdt.h>
 #endif
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifndef CONFIG_SPD_EEPROM
 /*************************************************************************
  *  fixed sdram init -- doesn't use serial presence detect.
 int fixed_sdram(void)
 {
        volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
-       u32 ddr_size;           /* The size of RAM, in bytes */
-       u32 ddr_size_log2 = 0;
-
-       for (ddr_size = CONFIG_SYS_DDR_SIZE * 0x100000; ddr_size > 1; ddr_size >>= 1) {
-               if (ddr_size & 1) {
-                       return -1;
-               }
-               ddr_size_log2++;
-       }
+       /* The size of RAM, in bytes */
+       u32 ddr_size = CONFIG_SYS_DDR_SIZE << 20;
+       u32 ddr_size_log2 = __ilog2(ddr_size);
 
        im->sysconf.ddrlaw[0].ar =
            LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
        im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
 
-       /* Only one CS0 for DDR */
-       im->ddr.csbnds[0].csbnds = 0x0000000f;
-       im->ddr.cs_config[0] = CONFIG_SYS_DDR_CONFIG;
+#if ((CONFIG_SYS_DDR_SDRAM_BASE & 0x00FFFFFF) != 0)
+#warning Chip select bounds is only configurable in 16MB increments
+#endif
+       im->ddr.csbnds[0].csbnds =
+               ((CONFIG_SYS_DDR_SDRAM_BASE >> CSBNDS_SA_SHIFT) & CSBNDS_SA) |
+               (((CONFIG_SYS_DDR_SDRAM_BASE + ddr_size - 1) >>
+                               CSBNDS_EA_SHIFT) & CSBNDS_EA);
+       im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
+
+       /* Only one CS for DDR */
+       im->ddr.cs_config[1] = 0;
+       im->ddr.cs_config[2] = 0;
+       im->ddr.cs_config[3] = 0;
 
        debug("cs0_bnds = 0x%08x\n", im->ddr.csbnds[0].csbnds);
        debug("cs0_config = 0x%08x\n", im->ddr.cs_config[0]);
@@ -128,7 +117,7 @@ volatile static struct pci_controller hose[] = {
 };
 #endif                         /* CONFIG_PCI */
 
-phys_size_t initdram(int board_type)
+int dram_init(void)
 {
        volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
        u32 msize = 0;
@@ -137,7 +126,7 @@ phys_size_t initdram(int board_type)
 #endif
 
        if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
-               return -1;
+               return -ENXIO;
 
        /* DDR SDRAM - Main SODIMM */
        im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
@@ -156,7 +145,9 @@ phys_size_t initdram(int board_type)
 #endif
 
        /* return total bus RAM size(bytes) */
-       return msize * 1024 * 1024;
+       gd->ram_size = msize * 1024 * 1024;
+
+       return 0;
 }
 
 int checkboard(void)
@@ -259,8 +250,7 @@ int misc_init_r(void)
 {
        int rc = 0;
 
-#ifdef CONFIG_HARD_I2C
-
+#if defined(CONFIG_SYS_I2C)
        unsigned int orig_bus = i2c_get_bus_num();
        u8 i2c_data;
 
@@ -391,11 +381,13 @@ int misc_init_r(void)
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP)
-void ft_board_setup(void *blob, bd_t *bd)
+int ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 #ifdef CONFIG_PCI
        ft_pci_setup(blob, bd);
 #endif
+
+       return 0;
 }
 #endif