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