Chia-Wei Wang | 1c7ed53 | 2024-09-10 17:39:16 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (c) Aspeed Technology Inc. |
| 4 | */ |
| 5 | #include <asm/io.h> |
| 6 | #include <asm/arch/sli.h> |
| 7 | #include <dm.h> |
| 8 | #include <ram.h> |
| 9 | #include <spl.h> |
| 10 | |
| 11 | DECLARE_GLOBAL_DATA_PTR; |
| 12 | |
| 13 | int dram_init(void) |
| 14 | { |
| 15 | int ret; |
| 16 | struct udevice *dev; |
| 17 | struct ram_info ram; |
| 18 | |
| 19 | ret = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 20 | if (ret) { |
| 21 | printf("cannot get DRAM driver\n"); |
| 22 | return ret; |
| 23 | } |
| 24 | |
| 25 | ret = ram_get_info(dev, &ram); |
| 26 | if (ret) { |
| 27 | printf("cannot get DRAM information\n"); |
| 28 | return ret; |
| 29 | } |
| 30 | |
| 31 | gd->ram_size = ram.size; |
| 32 | |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | int spl_board_init_f(void) |
| 37 | { |
| 38 | sli_init(); |
| 39 | |
| 40 | dram_init(); |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size) |
| 46 | { |
| 47 | return (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR; |
| 48 | } |
| 49 | |
| 50 | void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len) |
| 51 | { |
| 52 | return (void *)spl_get_load_buffer(sectors, bl_len); |
| 53 | } |
| 54 | |
| 55 | u32 spl_boot_device(void) |
| 56 | { |
| 57 | return BOOT_DEVICE_RAM; |
| 58 | } |
| 59 | |
| 60 | int board_init(void) |
| 61 | { |
| 62 | struct udevice *dev; |
| 63 | int i = 0; |
| 64 | int ret; |
| 65 | |
| 66 | /* |
| 67 | * Loop over all MISC uclass drivers to call the comphy code |
| 68 | * and init all CP110 devices enabled in the DT |
| 69 | */ |
| 70 | while (1) { |
| 71 | /* Call the comphy code via the MISC uclass driver */ |
| 72 | ret = uclass_get_device(UCLASS_MISC, i++, &dev); |
| 73 | |
| 74 | /* We're done, once no further CP110 device is found */ |
| 75 | if (ret) |
| 76 | break; |
| 77 | } |
| 78 | |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | int board_late_init(void) |
| 83 | { |
| 84 | return 0; |
| 85 | } |