common: Drop linux/delay.h from common header
[oweals/u-boot.git] / board / tqc / tqm834x / tqm834x.c
index 7af8b4ca67751ed704a7f199055e02309f1ce1c7..165a5433e728a449acc4cded824415769b3c76bb 100644 (file)
@@ -1,29 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2005
  * 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
- *
  */
 
 #include <common.h>
+#include <fdt_support.h>
+#include <init.h>
 #include <ioports.h>
+#include <log.h>
 #include <mpc83xx.h>
 #include <asm/mpc8349_pci.h>
 #include <i2c.h>
@@ -31,6 +16,7 @@
 #include <asm/mmu.h>
 #include <pci.h>
 #include <flash.h>
+#include <linux/delay.h>
 #include <mtd/cfi_flash.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -60,7 +46,7 @@ ulong flash_get_size (ulong base, int banknum);
 /* Local functions */
 static int detect_num_flash_banks(void);
 static long int get_ddr_bank_size(short cs, long *base);
-static void set_cs_bounds(short cs, long base, long size);
+static void set_cs_bounds(short cs, ulong base, ulong size);
 static void set_cs_config(short cs, long config);
 static void set_ddr_config(void);
 
@@ -83,20 +69,20 @@ int board_early_init_r (void) {
 /**************************************************************************
  * DRAM initalization and size detection
  */
-phys_size_t initdram (int board_type)
+int dram_init(void)
 {
        long bank_size;
        long size;
        int cs;
 
        /* during size detection, set up the max DDRLAW size */
-       im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE;
+       im->sysconf.ddrlaw[0].bar = CONFIG_SYS_SDRAM_BASE;
        im->sysconf.ddrlaw[0].ar = (LAWAR_EN | LAWAR_SIZE_2G);
 
        /* set CS bounds to maximum size */
        for(cs = 0; cs < 4; ++cs) {
                set_cs_bounds(cs,
-                       CONFIG_SYS_DDR_BASE + (cs * DDR_MAX_SIZE_PER_CS),
+                       CONFIG_SYS_SDRAM_BASE + (cs * DDR_MAX_SIZE_PER_CS),
                        DDR_MAX_SIZE_PER_CS);
 
                set_cs_config(cs, INITIAL_CS_CONFIG);
@@ -120,7 +106,7 @@ phys_size_t initdram (int board_type)
                debug("\nDetecting Bank%d\n", cs);
 
                bank_size = get_ddr_bank_size(cs,
-                       (long *)(CONFIG_SYS_DDR_BASE + size));
+                       (long *)(CONFIG_SYS_SDRAM_BASE + size));
                size += bank_size;
 
                debug("DDR Bank%d size: %ld MiB\n\n", cs, bank_size >> 20);
@@ -129,7 +115,9 @@ phys_size_t initdram (int board_type)
                if(size < DDR_MAX_SIZE_PER_CS) break;
        }
 
-       return size;
+       gd->ram_size = size;
+
+       return 0;
 }
 
 /**************************************************************************
@@ -251,8 +239,8 @@ static int detect_num_flash_banks(void)
        debug("Number of flash banks detected: %d\n", cfi_flash_num_flash_banks);
 
        /* set OR0 and BR0 */
-       set_lbc_or(0, CONFIG_SYS_OR_TIMING_FLASH |
-                  (-(total_size) & OR_GPCM_AM));
+       set_lbc_or(0, OR_GPCM_CSNT | OR_GPCM_ACS_DIV4 | OR_GPCM_SCY_5 |
+                  OR_GPCM_TRLX | (-(total_size) & OR_GPCM_AM));
        set_lbc_br(0, (CONFIG_SYS_FLASH_BASE & BR_BA) |
                   (BR_MS_GPCM | BR_PS_32 | BR_V));
 
@@ -331,7 +319,7 @@ static long int get_ddr_bank_size(short cs, long *base)
 /**************************************************************************
  * Sets DDR bank CS bounds.
  */
-static void set_cs_bounds(short cs, long base, long size)
+static void set_cs_bounds(short cs, ulong base, ulong size)
 {
        debug("Setting bounds %08lx, %08lx for cs %d\n", base, size, cs);
        if(size == 0){
@@ -431,12 +419,14 @@ static void set_ddr_config(void) {
 }
 
 #ifdef 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 /* CONFIG_PCI */
+
+       return 0;
 }
 #endif /* CONFIG_OF_BOARD_SETUP */