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