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