blob: da050bf800f2b35cb4d5e877d29fdebf40a13d45 [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>
York Sun9b85a482013-06-27 10:48:29 -07009#include <i2c.h>
Simon Glassa7b51302019-11-14 12:57:46 -070010#include <init.h>
York Sun9b85a482013-06-27 10:48:29 -070011#include <netdev.h>
12#include <linux/compiler.h>
13#include <asm/mmu.h>
14#include <asm/processor.h>
15#include <asm/cache.h>
16#include <asm/immap_85xx.h>
17#include <asm/fsl_law.h>
18#include <asm/fsl_serdes.h>
York Sun9b85a482013-06-27 10:48:29 -070019#include <asm/fsl_liodn.h>
20
21DECLARE_GLOBAL_DATA_PTR;
22
23int checkboard(void)
24{
25 struct cpu_type *cpu = gd->arch.cpu;
26
27 printf("Board: %sEMU\n", cpu->name);
28
29 return 0;
30}
31
32int board_early_init_r(void)
33{
34 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
York Sun220c3462014-06-24 21:16:20 -070035 int flash_esel = find_tlb_idx((void *)flashbase, 1);
York Sun9b85a482013-06-27 10:48:29 -070036
37 /*
38 * Remap Boot flash + PROMJET region to caching-inhibited
39 * so that flash can be erased properly.
40 */
41
42 /* Flush d-cache and invalidate i-cache of any FLASH data */
43 flush_dcache();
44 invalidate_icache();
45
York Sun220c3462014-06-24 21:16:20 -070046 if (flash_esel == -1) {
47 /* very unlikely unless something is messed up */
48 puts("Error: Could not find TLB for FLASH BASE\n");
49 flash_esel = 2; /* give our best effort to continue */
50 } else {
51 /* invalidate existing TLB entry for flash */
52 disable_tlb(flash_esel);
53 }
York Sun9b85a482013-06-27 10:48:29 -070054
55 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
56 MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
57 0, flash_esel, BOOKE_PAGESZ_256M, 1);
58
York Sun9b85a482013-06-27 10:48:29 -070059 return 0;
60}
61
62int misc_init_r(void)
63{
64 return 0;
65}
66
Simon Glass2aec3cc2014-10-23 18:58:47 -060067int ft_board_setup(void *blob, bd_t *bd)
York Sun9b85a482013-06-27 10:48:29 -070068{
69 phys_addr_t base;
70 phys_size_t size;
71
72 ft_cpu_setup(blob, bd);
73
Simon Glassda1a1342017-08-03 12:22:15 -060074 base = env_get_bootm_low();
75 size = env_get_bootm_size();
York Sun9b85a482013-06-27 10:48:29 -070076
77 fdt_fixup_memory(blob, (u64)base, (u64)size);
78
79 fdt_fixup_liodn(blob);
Sriram Dash9fd465c2016-09-16 17:12:15 +053080 fsl_fdt_fixup_dr_usb(blob, bd);
Simon Glass2aec3cc2014-10-23 18:58:47 -060081
82 return 0;
York Sun9b85a482013-06-27 10:48:29 -070083}