blob: 173245b40e3ca0167cd55545d3c71dfd6a1d2023 [file] [log] [blame]
Bin Meng8a8694d2018-09-26 06:55:21 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
4 */
5
Tom Riniabb9a042024-05-18 20:20:43 -06006#include <common.h>
Bin Meng184eadb2018-10-15 02:21:13 -07007#include <dm.h>
Anup Patel5c5f64c2022-01-27 11:41:09 +05308#include <dm/ofnode.h>
Simon Glass313112a2019-08-01 09:46:46 -06009#include <env.h>
Bin Meng8a8694d2018-09-26 06:55:21 -070010#include <fdtdec.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060011#include <image.h>
Simon Glass0f2af882020-05-10 11:40:05 -060012#include <log.h>
Lukas Auerdf3f1002019-08-21 21:14:49 +020013#include <spl.h>
Simon Glassa7b51302019-11-14 12:57:46 -070014#include <init.h>
Bin Mengf6809fb2023-07-23 12:40:41 +080015#include <usb.h>
Bin Meng184eadb2018-10-15 02:21:13 -070016#include <virtio_types.h>
17#include <virtio.h>
Bin Meng8a8694d2018-09-26 06:55:21 -070018
Ilias Apalodimasdc35df42021-10-12 00:00:13 +030019DECLARE_GLOBAL_DATA_PTR;
20
Anup Patel5c5f64c2022-01-27 11:41:09 +053021#if IS_ENABLED(CONFIG_MTD_NOR_FLASH)
22int 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 Meng8a8694d2018-09-26 06:55:21 -070032int board_init(void)
33{
Bin Meng8a8694d2018-09-26 06:55:21 -070034 return 0;
35}
Lukas Auer7fcf2122018-11-22 11:26:36 +010036
37int board_late_init(void)
38{
Bin Mengf6809fb2023-07-23 12:40:41 +080039 /* start usb so that usb keyboard can be used as input device */
40 if (CONFIG_IS_ENABLED(USB_KEYBOARD))
41 usb_init();
42
Ɓukasz Stelmach1b100e52024-03-28 10:58:24 +010043 /*
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 Auer7fcf2122018-11-22 11:26:36 +010049 return 0;
50}
Lukas Auer74c2f122018-11-22 11:26:37 +010051
Lukas Auerdf3f1002019-08-21 21:14:49 +020052#ifdef CONFIG_SPL
53u32 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
61int board_fit_config_name_match(const char *name)
62{
63 /* boot using first FIT config */
64 return 0;
65}
66#endif
Ilias Apalodimasdc35df42021-10-12 00:00:13 +030067
Ilias Apalodimasab5348a2021-10-26 09:12:33 +030068void *board_fdt_blob_setup(int *err)
Ilias Apalodimasdc35df42021-10-12 00:00:13 +030069{
Ilias Apalodimasab5348a2021-10-26 09:12:33 +030070 *err = 0;
Ilias Apalodimasdc35df42021-10-12 00:00:13 +030071 /* Stored the DTB address there during our init */
72 return (void *)(ulong)gd->arch.firmware_fdt_addr;
73}