blob: 0ca83341c25c87b4d9856b1d2d68cbcd18d0790c [file] [log] [blame]
Jiaxun Yangb2c05382024-06-18 14:56:09 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
4 */
5
6#include <dm.h>
7#include <cpu.h>
8#include <log.h>
9#include <init.h>
10#include <usb.h>
11#include <virtio_types.h>
12#include <virtio.h>
13
14DECLARE_GLOBAL_DATA_PTR;
15
16int board_init(void)
17{
18 return 0;
19}
20
21unsigned long get_board_sys_clk(void)
22{
23 return gd->cpu_clk ? gd->cpu_clk : 40000000;
24}
25
26int dram_init(void)
27{
28 return fdtdec_setup_mem_size_base();
29}
30
31int board_early_init_f(void)
32{
33 struct cpu_plat *cpu_plat;
34 struct udevice *cpu = cpu_get_current_dev();
35
36 if (!cpu)
37 return -ENODEV;
38
39 cpu_plat = dev_get_parent_plat(cpu);
40 if (!cpu_plat)
41 return -ENODEV;
42
43 gd->cpu_clk = cpu_plat->timebase_freq;
44 return 0;
45}
46
47int board_late_init(void)
48{
49 /* start usb so that usb keyboard can be used as input device */
50 if (CONFIG_IS_ENABLED(USB_KEYBOARD))
51 usb_init();
52
53 /*
54 * Make sure virtio bus is enumerated so that peripherals
55 * on the virtio bus can be discovered by their drivers
56 */
57 virtio_init();
58
59 return 0;
60}