blob: 676c305fd3e900b655256de1ed7a0a0ad1b29ae9 [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>
Simon Glass3ba929a2020-10-30 21:38:53 -060015#include <asm/global_data.h>
Paul Burton96c68472018-12-16 19:25:22 -030016#include <asm/io.h>
17#include <asm/sections.h>
18#include <mach/jz4780.h>
19#include <mach/jz4780_dram.h>
20#include <mmc.h>
21#include <spl.h>
22
23#ifdef CONFIG_SPL_BUILD
24/* Pointer to the global data structure for SPL */
25DECLARE_GLOBAL_DATA_PTR;
Marek BehĂșn4bebdd32021-05-20 13:23:52 +020026gd_t gdata __section(".bss");
Paul Burton96c68472018-12-16 19:25:22 -030027
28void board_init_f(ulong dummy)
29{
30 typedef void __noreturn (*image_entry_noargs_t)(void);
31 struct mmc *mmc;
32 unsigned long count;
Simon Glassbb7d3bb2022-09-06 20:26:52 -060033 struct legacy_img_hdr *header;
Paul Burton96c68472018-12-16 19:25:22 -030034 int ret;
35
36 /* Set global data pointer */
37 gd = &gdata;
38
39 timer_init();
40 pll_init();
41 sdram_init();
42 enable_caches();
43
44 /* Clear the BSS */
45 memset(__bss_start, 0, (char *)&__bss_end - __bss_start);
46
47 gd->flags |= GD_FLG_SPL_INIT;
48
49 ret = mmc_initialize(NULL);
50 if (ret)
51 hang();
52
53 mmc = find_mmc_device(BOOT_DEVICE_MMC1);
54 if (ret)
55 hang();
56
57 ret = mmc_init(mmc);
58 if (ret)
59 hang();
60
Simon Glass72cc5382022-10-20 18:22:39 -060061 header = (struct legacy_img_hdr *)(CONFIG_TEXT_BASE -
Simon Glassbb7d3bb2022-09-06 20:26:52 -060062 sizeof(struct legacy_img_hdr));
Paul Burton96c68472018-12-16 19:25:22 -030063
64 count = blk_dread(mmc_get_blk_desc(mmc),
65 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
66 0x800, header);
67 if (count == 0)
68 hang();
69
70 image_entry_noargs_t image_entry =
Simon Glass72cc5382022-10-20 18:22:39 -060071 (image_entry_noargs_t)CONFIG_TEXT_BASE;
Paul Burton96c68472018-12-16 19:25:22 -030072
73 image_entry();
74
75 hang();
76}
77#endif /* CONFIG_SPL_BUILD */
78
Heinrich Schuchardt51a9aac2023-08-12 20:16:58 +020079phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
Paul Burton96c68472018-12-16 19:25:22 -030080{
Tom Rinibb4dd962022-11-16 13:10:37 -050081 return CFG_SYS_SDRAM_BASE + (256 * 1024 * 1024);
Paul Burton96c68472018-12-16 19:25:22 -030082}
83
84int print_cpuinfo(void)
85{
86 printf("CPU: Ingenic JZ4780\n");
87 return 0;
88}