blob: 1d6fb6a4e27cc7898228888eacb356ba7870ecea [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>
Simon Glass63334482019-11-14 12:57:39 -070010#include <cpu_func.h>
Simon Glassf11478f2019-12-28 10:45:07 -070011#include <hang.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060012#include <image.h>
Simon Glass6980b6b2019-11-14 12:57:45 -070013#include <init.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060014#include <asm/global_data.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;
Marek BehĂșn4bebdd32021-05-20 13:23:52 +020025gd_t gdata __section(".bss");
Paul Burton96c68472018-12-16 19:25:22 -030026
27void board_init_f(ulong dummy)
28{
29 typedef void __noreturn (*image_entry_noargs_t)(void);
30 struct mmc *mmc;
31 unsigned long count;
Simon Glassbb7d3bb2022-09-06 20:26:52 -060032 struct legacy_img_hdr *header;
Paul Burton96c68472018-12-16 19:25:22 -030033 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 */
Shiji Yangeff11fa2023-08-03 09:47:17 +080044 memset(__bss_start, 0, (size_t)__bss_end - (size_t)__bss_start);
Paul Burton96c68472018-12-16 19:25:22 -030045
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
Simon Glass72cc5382022-10-20 18:22:39 -060060 header = (struct legacy_img_hdr *)(CONFIG_TEXT_BASE -
Simon Glassbb7d3bb2022-09-06 20:26:52 -060061 sizeof(struct legacy_img_hdr));
Paul Burton96c68472018-12-16 19:25:22 -030062
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 =
Simon Glass72cc5382022-10-20 18:22:39 -060070 (image_entry_noargs_t)CONFIG_TEXT_BASE;
Paul Burton96c68472018-12-16 19:25:22 -030071
72 image_entry();
73
74 hang();
75}
76#endif /* CONFIG_SPL_BUILD */
77
Heinrich Schuchardt51a9aac2023-08-12 20:16:58 +020078phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
Paul Burton96c68472018-12-16 19:25:22 -030079{
Tom Rinibb4dd962022-11-16 13:10:37 -050080 return CFG_SYS_SDRAM_BASE + (256 * 1024 * 1024);
Paul Burton96c68472018-12-16 19:25:22 -030081}
82
83int print_cpuinfo(void)
84{
85 printf("CPU: Ingenic JZ4780\n");
86 return 0;
87}