blob: 43f5651f832661567429d133e7592fd349267e1f [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;
26gd_t gdata __attribute__ ((section(".bss")));
27
28void board_init_f(ulong dummy)
29{
30 typedef void __noreturn (*image_entry_noargs_t)(void);
31 struct mmc *mmc;
32 unsigned long count;
33 struct image_header *header;
34 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
61 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
62 sizeof(struct image_header));
63
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 =
71 (image_entry_noargs_t)CONFIG_SYS_TEXT_BASE;
72
73 image_entry();
74
75 hang();
76}
77#endif /* CONFIG_SPL_BUILD */
78
79ulong board_get_usable_ram_top(ulong total_size)
80{
81 return CONFIG_SYS_SDRAM_BASE + (256 * 1024 * 1024);
82}
83
84int print_cpuinfo(void)
85{
86 printf("CPU: Ingenic JZ4780\n");
87 return 0;
88}