blob: 104b40a110969dfc9006ff61ae92e157dce37cb1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
York Sun9b85a482013-06-27 10:48:29 -07002/*
3 * Copyright 2013 Freescale Semiconductor, Inc.
York Sun9b85a482013-06-27 10:48:29 -07004 */
5
6#include <common.h>
7#include <command.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -06008#include <env.h>
Simon Glass3bbe70c2019-12-28 10:44:54 -07009#include <fdt_support.h>
York Sun9b85a482013-06-27 10:48:29 -070010#include <i2c.h>
Simon Glassa7b51302019-11-14 12:57:46 -070011#include <init.h>
York Sun9b85a482013-06-27 10:48:29 -070012#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>
York Sun9b85a482013-06-27 10:48:29 -070020#include <asm/fsl_liodn.h>
21
22DECLARE_GLOBAL_DATA_PTR;
23
24int 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
33int board_early_init_r(void)
34{
35 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
York Sun220c3462014-06-24 21:16:20 -070036 int flash_esel = find_tlb_idx((void *)flashbase, 1);
York Sun9b85a482013-06-27 10:48:29 -070037
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
York Sun220c3462014-06-24 21:16:20 -070047 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 }
York Sun9b85a482013-06-27 10:48:29 -070055
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
York Sun9b85a482013-06-27 10:48:29 -070060 return 0;
61}
62
63int misc_init_r(void)
64{
65 return 0;
66}
67
Simon Glass2aec3cc2014-10-23 18:58:47 -060068int ft_board_setup(void *blob, bd_t *bd)
York Sun9b85a482013-06-27 10:48:29 -070069{
70 phys_addr_t base;
71 phys_size_t size;
72
73 ft_cpu_setup(blob, bd);
74
Simon Glassda1a1342017-08-03 12:22:15 -060075 base = env_get_bootm_low();
76 size = env_get_bootm_size();
York Sun9b85a482013-06-27 10:48:29 -070077
78 fdt_fixup_memory(blob, (u64)base, (u64)size);
79
80 fdt_fixup_liodn(blob);
Sriram Dash9fd465c2016-09-16 17:12:15 +053081 fsl_fdt_fixup_dr_usb(blob, bd);
Simon Glass2aec3cc2014-10-23 18:58:47 -060082
83 return 0;
York Sun9b85a482013-06-27 10:48:29 -070084}