blob: 8f2032acc7b27433d4145e68c9306b4df860a032 [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 Glass2dc9c342020-05-10 11:40:01 -060011#include <image.h>
Simon Glassa7b51302019-11-14 12:57:46 -070012#include <init.h>
York Sun9b85a482013-06-27 10:48:29 -070013#include <netdev.h>
14#include <linux/compiler.h>
15#include <asm/mmu.h>
16#include <asm/processor.h>
17#include <asm/cache.h>
18#include <asm/immap_85xx.h>
19#include <asm/fsl_law.h>
20#include <asm/fsl_serdes.h>
York Sun9b85a482013-06-27 10:48:29 -070021#include <asm/fsl_liodn.h>
22
23DECLARE_GLOBAL_DATA_PTR;
24
25int checkboard(void)
26{
27 struct cpu_type *cpu = gd->arch.cpu;
28
29 printf("Board: %sEMU\n", cpu->name);
30
31 return 0;
32}
33
34int board_early_init_r(void)
35{
36 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
York Sun220c3462014-06-24 21:16:20 -070037 int flash_esel = find_tlb_idx((void *)flashbase, 1);
York Sun9b85a482013-06-27 10:48:29 -070038
39 /*
40 * Remap Boot flash + PROMJET region to caching-inhibited
41 * so that flash can be erased properly.
42 */
43
44 /* Flush d-cache and invalidate i-cache of any FLASH data */
45 flush_dcache();
46 invalidate_icache();
47
York Sun220c3462014-06-24 21:16:20 -070048 if (flash_esel == -1) {
49 /* very unlikely unless something is messed up */
50 puts("Error: Could not find TLB for FLASH BASE\n");
51 flash_esel = 2; /* give our best effort to continue */
52 } else {
53 /* invalidate existing TLB entry for flash */
54 disable_tlb(flash_esel);
55 }
York Sun9b85a482013-06-27 10:48:29 -070056
57 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
58 MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
59 0, flash_esel, BOOKE_PAGESZ_256M, 1);
60
York Sun9b85a482013-06-27 10:48:29 -070061 return 0;
62}
63
64int misc_init_r(void)
65{
66 return 0;
67}
68
Simon Glass2aec3cc2014-10-23 18:58:47 -060069int ft_board_setup(void *blob, bd_t *bd)
York Sun9b85a482013-06-27 10:48:29 -070070{
71 phys_addr_t base;
72 phys_size_t size;
73
74 ft_cpu_setup(blob, bd);
75
Simon Glassda1a1342017-08-03 12:22:15 -060076 base = env_get_bootm_low();
77 size = env_get_bootm_size();
York Sun9b85a482013-06-27 10:48:29 -070078
79 fdt_fixup_memory(blob, (u64)base, (u64)size);
80
81 fdt_fixup_liodn(blob);
Sriram Dash9fd465c2016-09-16 17:12:15 +053082 fsl_fdt_fixup_dr_usb(blob, bd);
Simon Glass2aec3cc2014-10-23 18:58:47 -060083
84 return 0;
York Sun9b85a482013-06-27 10:48:29 -070085}