Merge tag 'u-boot-atmel-fixes-2021.01-b' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / board / armltd / vexpress / vexpress_common.c
index 56febd9..8fea8ff 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2002
  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  * (C) Copyright 2004
  * ARM Ltd.
  * Philippe Robin, <philippe.robin@arm.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <bootstage.h>
+#include <cpu_func.h>
+#include <init.h>
 #include <malloc.h>
 #include <errno.h>
+#include <net.h>
 #include <netdev.h>
 #include <asm/io.h>
+#include <asm/mach-types.h>
 #include <asm/arch/systimer.h>
 #include <asm/arch/sysctrl.h>
 #include <asm/arch/wdt.h>
 #include "../drivers/mmc/arm_pl180_mmci.h"
 
-static ulong timestamp;
-static ulong lastdec;
-
 static struct systimer *systimer_base = (struct systimer *)V2M_TIMER01;
 static struct sysctrl *sysctrl_base = (struct sysctrl *)SCTL_BASE;
 
@@ -54,7 +55,6 @@ int board_init(void)
 {
        gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
        gd->bd->bi_arch_number = MACH_TYPE_VEXPRESS;
-       gd->flags = 0;
 
        icache_enable();
        flash__init();
@@ -63,7 +63,7 @@ int board_init(void)
        return 0;
 }
 
-int board_eth_init(bd_t *bis)
+int board_eth_init(struct bd_info *bis)
 {
        int rc = 0;
 #ifdef CONFIG_SMC911X
@@ -72,12 +72,13 @@ int board_eth_init(bd_t *bis)
        return rc;
 }
 
-int cpu_mmc_init(bd_t *bis)
+int cpu_mmc_init(struct bd_info *bis)
 {
        int rc = 0;
        (void) bis;
 #ifdef CONFIG_ARM_PL180_MMCI
        struct pl180_mmc_host *host;
+       struct mmc *mmc;
 
        host = malloc(sizeof(struct pl180_mmc_host));
        if (!host)
@@ -93,7 +94,7 @@ int cpu_mmc_init(bd_t *bis)
        host->clock_in = ARM_MCLK;
        host->clock_min = ARM_MCLK / (2 * (SDI_CLKCR_CLKDIV_INIT_V1 + 1));
        host->clock_max = CONFIG_ARM_PL180_MMCI_CLOCK_FREQ;
-       rc = arm_pl180_mmci_init(host);
+       rc = arm_pl180_mmci_init(host, &mmc);
 #endif
        return rc;
 }
@@ -112,7 +113,7 @@ int dram_init(void)
        return 0;
 }
 
-void dram_init_banksize(void)
+int dram_init_banksize(void)
 {
        gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
        gd->bd->bi_dram[0].size =
@@ -120,10 +121,7 @@ void dram_init_banksize(void)
        gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
        gd->bd->bi_dram[1].size =
                        get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
-}
 
-int timer_init(void)
-{
        return 0;
 }
 
@@ -152,8 +150,6 @@ static void vexpress_timer_init(void)
        writel(SYSTIMER_EN | SYSTIMER_32BIT |
               readl(&systimer_base->timer0control),
               &systimer_base->timer0control);
-
-       reset_timer_masked();
 }
 
 int v2m_cfg_write(u32 devfn, u32 data)
@@ -183,62 +179,6 @@ void reset_cpu(ulong addr)
                printf("Unable to reboot\n");
 }
 
-/*
- * Delay x useconds AND perserve advance timstamp value
- *     assumes timer is ticking at 1 msec
- */
-void __udelay(ulong usec)
-{
-       ulong tmo, tmp;
-
-       tmo = usec / 1000;
-       tmp = get_timer(0);     /* get current timestamp */
-
-       /*
-        * If setting this forward will roll time stamp then
-        * reset "advancing" timestamp to 0 and set lastdec value
-        * otherwise set the advancing stamp to the wake up time
-        */
-       if ((tmo + tmp + 1) < tmp)
-               reset_timer_masked();
-       else
-               tmo += tmp;
-
-       while (get_timer_masked() < tmo)
-               ; /* loop till wakeup event */
-}
-
-ulong get_timer(ulong base)
-{
-       return get_timer_masked() - base;
-}
-
-void reset_timer_masked(void)
-{
-       lastdec = readl(&systimer_base->timer0value) / 1000;
-       timestamp = 0;
-}
-
-ulong get_timer_masked(void)
-{
-       ulong now = readl(&systimer_base->timer0value) / 1000;
-
-       if (lastdec >= now) {   /* normal mode (non roll) */
-               timestamp += lastdec - now;
-       } else {                /* count down timer overflowed */
-               /*
-                * nts = ts + ld - now
-                * ts = old stamp, ld = time before passing through - 1
-                * now = amount of time after passing though - 1
-                * nts = new "advancing time stamp"
-                */
-               timestamp += lastdec + SYSTIMER_RELOAD - now;
-       }
-       lastdec = now;
-
-       return timestamp;
-}
-
 void lowlevel_init(void)
 {
 }
@@ -247,17 +187,7 @@ ulong get_board_rev(void){
        return readl((u32 *)SYS_ID);
 }
 
-unsigned long long get_ticks(void)
-{
-       return get_timer(0);
-}
-
-ulong get_tbclk(void)
-{
-       return (ulong)CONFIG_SYS_HZ;
-}
-
-#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV7_VIRT)
+#ifdef CONFIG_ARMV7_NONSEC
 /* Setting the address at which secondary cores start from.
  * Versatile Express uses one address for all cores, so ignore corenr
  */