blob: e5193e31e37e485041865ec7bf5fb9ffc58197ea [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
Bin Meng184eadb2018-10-15 02:21:13 -07006#include <dm.h>
Anup Patel5c5f64c2022-01-27 11:41:09 +05307#include <dm/ofnode.h>
Simon Glass313112a2019-08-01 09:46:46 -06008#include <env.h>
Bin Meng8a8694d2018-09-26 06:55:21 -07009#include <fdtdec.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060010#include <image.h>
Simon Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
Lukas Auerdf3f1002019-08-21 21:14:49 +020012#include <spl.h>
Simon Glassa7b51302019-11-14 12:57:46 -070013#include <init.h>
Bin Mengf6809fb2023-07-23 12:40:41 +080014#include <usb.h>
Bin Meng184eadb2018-10-15 02:21:13 -070015#include <virtio_types.h>
16#include <virtio.h>
Bin Meng8a8694d2018-09-26 06:55:21 -070017
Ilias Apalodimasdc35df42021-10-12 00:00:13 +030018DECLARE_GLOBAL_DATA_PTR;
19
Anup Patel5c5f64c2022-01-27 11:41:09 +053020#if IS_ENABLED(CONFIG_MTD_NOR_FLASH)
21int 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 Meng8a8694d2018-09-26 06:55:21 -070031int board_init(void)
32{
Bin Meng8a8694d2018-09-26 06:55:21 -070033 return 0;
34}
Lukas Auer7fcf2122018-11-22 11:26:36 +010035
36int board_late_init(void)
37{
Bin Mengf6809fb2023-07-23 12:40:41 +080038 /* start usb so that usb keyboard can be used as input device */
39 if (CONFIG_IS_ENABLED(USB_KEYBOARD))
40 usb_init();
41
Ɓukasz Stelmach1b100e52024-03-28 10:58:24 +010042 /*
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 Auer7fcf2122018-11-22 11:26:36 +010048 return 0;
49}
Lukas Auer74c2f122018-11-22 11:26:37 +010050
Lukas Auerdf3f1002019-08-21 21:14:49 +020051#ifdef CONFIG_SPL
52u32 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
60int board_fit_config_name_match(const char *name)
61{
62 /* boot using first FIT config */
63 return 0;
64}
65#endif
Ilias Apalodimasdc35df42021-10-12 00:00:13 +030066
Ilias Apalodimasab5348a2021-10-26 09:12:33 +030067void *board_fdt_blob_setup(int *err)
Ilias Apalodimasdc35df42021-10-12 00:00:13 +030068{
Ilias Apalodimasab5348a2021-10-26 09:12:33 +030069 *err = 0;
Ilias Apalodimasdc35df42021-10-12 00:00:13 +030070 /* Stored the DTB address there during our init */
71 return (void *)(ulong)gd->arch.firmware_fdt_addr;
72}