blob: 0ae5e09e01985ec969e3d8ef4f5f243805e32bc5 [file] [log] [blame]
Paul Burton96c68472018-12-16 19:25:22 -03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * JZ4780 common routines
4 *
5 * Copyright (c) 2013 Imagination Technologies
6 * Author: Paul Burton <paul.burton@imgtec.com>
7 */
8
9#include <config.h>
10#include <common.h>
Simon Glass63334482019-11-14 12:57:39 -070011#include <cpu_func.h>
Simon Glass6980b6b2019-11-14 12:57:45 -070012#include <init.h>
Paul Burton96c68472018-12-16 19:25:22 -030013#include <asm/io.h>
14#include <asm/sections.h>
15#include <mach/jz4780.h>
16#include <mach/jz4780_dram.h>
17#include <mmc.h>
18#include <spl.h>
19
20#ifdef CONFIG_SPL_BUILD
21/* Pointer to the global data structure for SPL */
22DECLARE_GLOBAL_DATA_PTR;
23gd_t gdata __attribute__ ((section(".bss")));
24
25void board_init_f(ulong dummy)
26{
27 typedef void __noreturn (*image_entry_noargs_t)(void);
28 struct mmc *mmc;
29 unsigned long count;
30 struct image_header *header;
31 int ret;
32
33 /* Set global data pointer */
34 gd = &gdata;
35
36 timer_init();
37 pll_init();
38 sdram_init();
39 enable_caches();
40
41 /* Clear the BSS */
42 memset(__bss_start, 0, (char *)&__bss_end - __bss_start);
43
44 gd->flags |= GD_FLG_SPL_INIT;
45
46 ret = mmc_initialize(NULL);
47 if (ret)
48 hang();
49
50 mmc = find_mmc_device(BOOT_DEVICE_MMC1);
51 if (ret)
52 hang();
53
54 ret = mmc_init(mmc);
55 if (ret)
56 hang();
57
58 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
59 sizeof(struct image_header));
60
61 count = blk_dread(mmc_get_blk_desc(mmc),
62 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
63 0x800, header);
64 if (count == 0)
65 hang();
66
67 image_entry_noargs_t image_entry =
68 (image_entry_noargs_t)CONFIG_SYS_TEXT_BASE;
69
70 image_entry();
71
72 hang();
73}
74#endif /* CONFIG_SPL_BUILD */
75
76ulong board_get_usable_ram_top(ulong total_size)
77{
78 return CONFIG_SYS_SDRAM_BASE + (256 * 1024 * 1024);
79}
80
81int print_cpuinfo(void)
82{
83 printf("CPU: Ingenic JZ4780\n");
84 return 0;
85}