Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 10 | #include <cpu_func.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 11 | #include <hang.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 12 | #include <image.h> |
Simon Glass | 6980b6b | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 13 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 15 | #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 */ |
| 24 | DECLARE_GLOBAL_DATA_PTR; |
Marek BehĂșn | 4bebdd3 | 2021-05-20 13:23:52 +0200 | [diff] [blame] | 25 | gd_t gdata __section(".bss"); |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 26 | |
| 27 | void board_init_f(ulong dummy) |
| 28 | { |
| 29 | typedef void __noreturn (*image_entry_noargs_t)(void); |
| 30 | struct mmc *mmc; |
| 31 | unsigned long count; |
Simon Glass | bb7d3bb | 2022-09-06 20:26:52 -0600 | [diff] [blame] | 32 | struct legacy_img_hdr *header; |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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 */ |
Shiji Yang | eff11fa | 2023-08-03 09:47:17 +0800 | [diff] [blame] | 44 | memset(__bss_start, 0, (size_t)__bss_end - (size_t)__bss_start); |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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 | |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 60 | header = (struct legacy_img_hdr *)(CONFIG_TEXT_BASE - |
Simon Glass | bb7d3bb | 2022-09-06 20:26:52 -0600 | [diff] [blame] | 61 | sizeof(struct legacy_img_hdr)); |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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 = |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 70 | (image_entry_noargs_t)CONFIG_TEXT_BASE; |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 71 | |
| 72 | image_entry(); |
| 73 | |
| 74 | hang(); |
| 75 | } |
| 76 | #endif /* CONFIG_SPL_BUILD */ |
| 77 | |
Heinrich Schuchardt | 51a9aac | 2023-08-12 20:16:58 +0200 | [diff] [blame] | 78 | phys_addr_t board_get_usable_ram_top(phys_size_t total_size) |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 79 | { |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 80 | return CFG_SYS_SDRAM_BASE + (256 * 1024 * 1024); |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | int print_cpuinfo(void) |
| 84 | { |
| 85 | printf("CPU: Ingenic JZ4780\n"); |
| 86 | return 0; |
| 87 | } |