Merge tag 'u-boot-stm32-20200117' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
[platform/kernel/u-boot.git] / board / freescale / t4qds / t4240emu.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2013 Freescale Semiconductor, Inc.
4  */
5
6 #include <common.h>
7 #include <command.h>
8 #include <env.h>
9 #include <fdt_support.h>
10 #include <i2c.h>
11 #include <init.h>
12 #include <netdev.h>
13 #include <linux/compiler.h>
14 #include <asm/mmu.h>
15 #include <asm/processor.h>
16 #include <asm/cache.h>
17 #include <asm/immap_85xx.h>
18 #include <asm/fsl_law.h>
19 #include <asm/fsl_serdes.h>
20 #include <asm/fsl_liodn.h>
21
22 DECLARE_GLOBAL_DATA_PTR;
23
24 int checkboard(void)
25 {
26         struct cpu_type *cpu = gd->arch.cpu;
27
28         printf("Board: %sEMU\n", cpu->name);
29
30         return 0;
31 }
32
33 int board_early_init_r(void)
34 {
35         const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
36         int flash_esel = find_tlb_idx((void *)flashbase, 1);
37
38         /*
39          * Remap Boot flash + PROMJET region to caching-inhibited
40          * so that flash can be erased properly.
41          */
42
43         /* Flush d-cache and invalidate i-cache of any FLASH data */
44         flush_dcache();
45         invalidate_icache();
46
47         if (flash_esel == -1) {
48                 /* very unlikely unless something is messed up */
49                 puts("Error: Could not find TLB for FLASH BASE\n");
50                 flash_esel = 2; /* give our best effort to continue */
51         } else {
52                 /* invalidate existing TLB entry for flash */
53                 disable_tlb(flash_esel);
54         }
55
56         set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
57                 MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
58                 0, flash_esel, BOOKE_PAGESZ_256M, 1);
59
60         return 0;
61 }
62
63 int misc_init_r(void)
64 {
65         return 0;
66 }
67
68 int ft_board_setup(void *blob, bd_t *bd)
69 {
70         phys_addr_t base;
71         phys_size_t size;
72
73         ft_cpu_setup(blob, bd);
74
75         base = env_get_bootm_low();
76         size = env_get_bootm_size();
77
78         fdt_fixup_memory(blob, (u64)base, (u64)size);
79
80         fdt_fixup_liodn(blob);
81         fsl_fdt_fixup_dr_usb(blob, bd);
82
83         return 0;
84 }