net: ks8851: Clean up chip ID readout
[oweals/u-boot.git] / common / board_f.c
index 2ec5dbaa6843c2dfd9dd7cf596c98b79e9705ff4..01194eaa0e4d3cf9ba20c00aee0cd24ef69b0a20 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <bloblist.h>
+#include <bootstage.h>
 #include <clock_legacy.h>
 #include <console.h>
 #include <cpu.h>
@@ -25,6 +26,7 @@
 #include <init.h>
 #include <initcall.h>
 #include <lcd.h>
+#include <log.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <os.h>
@@ -40,6 +42,7 @@
 #include <trace.h>
 #include <video.h>
 #include <watchdog.h>
+#include <asm/cache.h>
 #ifdef CONFIG_MACH_TYPE
 #include <asm/mach-types.h>
 #endif
@@ -183,11 +186,11 @@ static int print_cpuinfo(void)
        char desc[512];
        int ret;
 
-       ret = uclass_first_device_err(UCLASS_CPU, &dev);
-       if (ret) {
-               debug("%s: Could not get CPU device (err = %d)\n",
-                     __func__, ret);
-               return ret;
+       dev = cpu_get_current_dev();
+       if (!dev) {
+               debug("%s: Could not get CPU device\n",
+                     __func__);
+               return -ENODEV;
        }
 
        ret = cpu_get_desc(dev, desc, sizeof(desc));
@@ -309,7 +312,7 @@ __weak int mach_cpu_init(void)
 /* Get the top of usable RAM */
 __weak ulong board_get_usable_ram_top(ulong total_size)
 {
-#ifdef CONFIG_SYS_SDRAM_BASE
+#if defined(CONFIG_SYS_SDRAM_BASE) && CONFIG_SYS_SDRAM_BASE > 0
        /*
         * Detect whether we have so much RAM that it goes past the end of our
         * 32-bit address space. If so, clip the usable RAM so it doesn't.
@@ -385,33 +388,10 @@ static int reserve_round_4k(void)
        return 0;
 }
 
-#ifdef CONFIG_ARM
-__weak int reserve_mmu(void)
+__weak int arch_reserve_mmu(void)
 {
-#if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
-       /* reserve TLB table */
-       gd->arch.tlb_size = PGTABLE_SIZE;
-       gd->relocaddr -= gd->arch.tlb_size;
-
-       /* round down to next 64 kB limit */
-       gd->relocaddr &= ~(0x10000 - 1);
-
-       gd->arch.tlb_addr = gd->relocaddr;
-       debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr,
-             gd->arch.tlb_addr + gd->arch.tlb_size);
-
-#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
-       /*
-        * Record allocated tlb_addr in case gd->tlb_addr to be overwritten
-        * with location within secure ram.
-        */
-       gd->arch.tlb_allocated = gd->arch.tlb_addr;
-#endif
-#endif
-
        return 0;
 }
-#endif
 
 static int reserve_video(void)
 {
@@ -845,9 +825,9 @@ static int initf_dm(void)
 #if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN)
        int ret;
 
-       bootstage_start(BOOTSTATE_ID_ACCUM_DM_F, "dm_f");
+       bootstage_start(BOOTSTAGE_ID_ACCUM_DM_F, "dm_f");
        ret = dm_init_and_scan(true);
-       bootstage_accum(BOOTSTATE_ID_ACCUM_DM_F);
+       bootstage_accum(BOOTSTAGE_ID_ACCUM_DM_F);
        if (ret)
                return ret;
 #endif
@@ -979,9 +959,7 @@ static const init_fnc_t init_sequence_f[] = {
        reserve_pram,
 #endif
        reserve_round_4k,
-#ifdef CONFIG_ARM
-       reserve_mmu,
-#endif
+       arch_reserve_mmu,
        reserve_video,
        reserve_trace,
        reserve_uboot,