Bin Meng | 8a8694d | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Bin Meng | 184eadb | 2018-10-15 02:21:13 -0700 | [diff] [blame] | 7 | #include <dm.h> |
Anup Patel | 5c5f64c | 2022-01-27 11:41:09 +0530 | [diff] [blame] | 8 | #include <dm/ofnode.h> |
Simon Glass | 313112a | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 9 | #include <env.h> |
Bin Meng | 8a8694d | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 10 | #include <fdtdec.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 11 | #include <image.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Lukas Auer | df3f100 | 2019-08-21 21:14:49 +0200 | [diff] [blame] | 13 | #include <spl.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 14 | #include <init.h> |
Bin Meng | f6809fb | 2023-07-23 12:40:41 +0800 | [diff] [blame] | 15 | #include <usb.h> |
Bin Meng | 184eadb | 2018-10-15 02:21:13 -0700 | [diff] [blame] | 16 | #include <virtio_types.h> |
| 17 | #include <virtio.h> |
Bin Meng | 8a8694d | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 18 | |
Ilias Apalodimas | dc35df4 | 2021-10-12 00:00:13 +0300 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Anup Patel | 5c5f64c | 2022-01-27 11:41:09 +0530 | [diff] [blame] | 21 | #if IS_ENABLED(CONFIG_MTD_NOR_FLASH) |
| 22 | int is_flash_available(void) |
| 23 | { |
| 24 | if (!ofnode_equal(ofnode_by_compatible(ofnode_null(), "cfi-flash"), |
| 25 | ofnode_null())) |
| 26 | return 1; |
| 27 | |
| 28 | return 0; |
| 29 | } |
| 30 | #endif |
| 31 | |
Bin Meng | 8a8694d | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 32 | int board_init(void) |
| 33 | { |
Bin Meng | 8a8694d | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 34 | return 0; |
| 35 | } |
Lukas Auer | 7fcf212 | 2018-11-22 11:26:36 +0100 | [diff] [blame] | 36 | |
| 37 | int board_late_init(void) |
| 38 | { |
Bin Meng | f6809fb | 2023-07-23 12:40:41 +0800 | [diff] [blame] | 39 | /* start usb so that usb keyboard can be used as input device */ |
| 40 | if (CONFIG_IS_ENABLED(USB_KEYBOARD)) |
| 41 | usb_init(); |
| 42 | |
Ćukasz Stelmach | 1b100e5 | 2024-03-28 10:58:24 +0100 | [diff] [blame] | 43 | /* |
| 44 | * Make sure virtio bus is enumerated so that peripherals |
| 45 | * on the virtio bus can be discovered by their drivers |
| 46 | */ |
| 47 | virtio_init(); |
| 48 | |
Lukas Auer | 7fcf212 | 2018-11-22 11:26:36 +0100 | [diff] [blame] | 49 | return 0; |
| 50 | } |
Lukas Auer | 74c2f12 | 2018-11-22 11:26:37 +0100 | [diff] [blame] | 51 | |
Lukas Auer | df3f100 | 2019-08-21 21:14:49 +0200 | [diff] [blame] | 52 | #ifdef CONFIG_SPL |
| 53 | u32 spl_boot_device(void) |
| 54 | { |
| 55 | /* RISC-V QEMU only supports RAM as SPL boot device */ |
| 56 | return BOOT_DEVICE_RAM; |
| 57 | } |
| 58 | #endif |
| 59 | |
| 60 | #ifdef CONFIG_SPL_LOAD_FIT |
| 61 | int board_fit_config_name_match(const char *name) |
| 62 | { |
| 63 | /* boot using first FIT config */ |
| 64 | return 0; |
| 65 | } |
| 66 | #endif |
Ilias Apalodimas | dc35df4 | 2021-10-12 00:00:13 +0300 | [diff] [blame] | 67 | |
Ilias Apalodimas | ab5348a | 2021-10-26 09:12:33 +0300 | [diff] [blame] | 68 | void *board_fdt_blob_setup(int *err) |
Ilias Apalodimas | dc35df4 | 2021-10-12 00:00:13 +0300 | [diff] [blame] | 69 | { |
Ilias Apalodimas | ab5348a | 2021-10-26 09:12:33 +0300 | [diff] [blame] | 70 | *err = 0; |
Ilias Apalodimas | dc35df4 | 2021-10-12 00:00:13 +0300 | [diff] [blame] | 71 | /* Stored the DTB address there during our init */ |
| 72 | return (void *)(ulong)gd->arch.firmware_fdt_addr; |
| 73 | } |