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> |
| 10 | #include <common.h> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 11 | #include <cpu_func.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 12 | #include <hang.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 13 | #include <image.h> |
Simon Glass | 6980b6b | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 14 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 15 | #include <asm/global_data.h> |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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; |
Marek Behún | 4bebdd3 | 2021-05-20 13:23:52 +0200 | [diff] [blame] | 26 | gd_t gdata __section(".bss"); |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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; |
Simon Glass | bb7d3bb | 2022-09-06 20:26:52 -0600 | [diff] [blame] | 33 | struct legacy_img_hdr *header; |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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 | |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame^] | 61 | header = (struct legacy_img_hdr *)(CONFIG_TEXT_BASE - |
Simon Glass | bb7d3bb | 2022-09-06 20:26:52 -0600 | [diff] [blame] | 62 | sizeof(struct legacy_img_hdr)); |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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 = |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame^] | 71 | (image_entry_noargs_t)CONFIG_TEXT_BASE; |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 72 | |
| 73 | image_entry(); |
| 74 | |
| 75 | hang(); |
| 76 | } |
| 77 | #endif /* CONFIG_SPL_BUILD */ |
| 78 | |
Pali Rohár | 4f4f583 | 2022-09-09 17:32:40 +0200 | [diff] [blame] | 79 | phys_size_t board_get_usable_ram_top(phys_size_t total_size) |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 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 | } |