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> |
Paul Burton | 96c6847 | 2018-12-16 19:25:22 -0300 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | #include <asm/sections.h> |
| 14 | #include <mach/jz4780.h> |
| 15 | #include <mach/jz4780_dram.h> |
| 16 | #include <mmc.h> |
| 17 | #include <spl.h> |
| 18 | |
| 19 | #ifdef CONFIG_SPL_BUILD |
| 20 | /* Pointer to the global data structure for SPL */ |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | gd_t gdata __attribute__ ((section(".bss"))); |
| 23 | |
| 24 | void board_init_f(ulong dummy) |
| 25 | { |
| 26 | typedef void __noreturn (*image_entry_noargs_t)(void); |
| 27 | struct mmc *mmc; |
| 28 | unsigned long count; |
| 29 | struct image_header *header; |
| 30 | int ret; |
| 31 | |
| 32 | /* Set global data pointer */ |
| 33 | gd = &gdata; |
| 34 | |
| 35 | timer_init(); |
| 36 | pll_init(); |
| 37 | sdram_init(); |
| 38 | enable_caches(); |
| 39 | |
| 40 | /* Clear the BSS */ |
| 41 | memset(__bss_start, 0, (char *)&__bss_end - __bss_start); |
| 42 | |
| 43 | gd->flags |= GD_FLG_SPL_INIT; |
| 44 | |
| 45 | ret = mmc_initialize(NULL); |
| 46 | if (ret) |
| 47 | hang(); |
| 48 | |
| 49 | mmc = find_mmc_device(BOOT_DEVICE_MMC1); |
| 50 | if (ret) |
| 51 | hang(); |
| 52 | |
| 53 | ret = mmc_init(mmc); |
| 54 | if (ret) |
| 55 | hang(); |
| 56 | |
| 57 | header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - |
| 58 | sizeof(struct image_header)); |
| 59 | |
| 60 | count = blk_dread(mmc_get_blk_desc(mmc), |
| 61 | CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, |
| 62 | 0x800, header); |
| 63 | if (count == 0) |
| 64 | hang(); |
| 65 | |
| 66 | image_entry_noargs_t image_entry = |
| 67 | (image_entry_noargs_t)CONFIG_SYS_TEXT_BASE; |
| 68 | |
| 69 | image_entry(); |
| 70 | |
| 71 | hang(); |
| 72 | } |
| 73 | #endif /* CONFIG_SPL_BUILD */ |
| 74 | |
| 75 | ulong board_get_usable_ram_top(ulong total_size) |
| 76 | { |
| 77 | return CONFIG_SYS_SDRAM_BASE + (256 * 1024 * 1024); |
| 78 | } |
| 79 | |
| 80 | int print_cpuinfo(void) |
| 81 | { |
| 82 | printf("CPU: Ingenic JZ4780\n"); |
| 83 | return 0; |
| 84 | } |