common: Drop asm/global_data.h from common header
[platform/kernel/u-boot.git] / arch / mips / mach-jz47xx / jz4780 / jz4780.c
1 // 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>
11 #include <cpu_func.h>
12 #include <hang.h>
13 #include <image.h>
14 #include <init.h>
15 #include <asm/global_data.h>
16 #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 */
25 DECLARE_GLOBAL_DATA_PTR;
26 gd_t gdata __attribute__ ((section(".bss")));
27
28 void 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
79 ulong board_get_usable_ram_top(ulong total_size)
80 {
81         return CONFIG_SYS_SDRAM_BASE + (256 * 1024 * 1024);
82 }
83
84 int print_cpuinfo(void)
85 {
86         printf("CPU:   Ingenic JZ4780\n");
87         return 0;
88 }