blob: 2adb2517ef009408628e216207e2fa4474f2a87b [file] [log] [blame]
Nishanth Menon9dd6bdc2023-11-04 03:01:35 -05001// SPDX-License-Identifier: GPL-2.0
2/*
3 * https://beagleplay.org/
4 *
5 * Copyright (C) 2022-2023 Texas Instruments Incorporated - https://www.ti.com/
6 * Copyright (C) 2022-2023 Robert Nelson, BeagleBoard.org Foundation
7 */
8
9#include <cpu_func.h>
10#include <env.h>
11#include <fdt_support.h>
12#include <spl.h>
13
Nishanth Menon1af76902024-02-20 12:39:48 -060014#include <asm/arch/hardware.h>
15
Nishanth Menon9dd6bdc2023-11-04 03:01:35 -050016DECLARE_GLOBAL_DATA_PTR;
17
18int board_init(void)
19{
20 return 0;
21}
22
23int dram_init(void)
24{
25 return fdtdec_setup_mem_size_base();
26}
27
28int dram_init_banksize(void)
29{
30 return fdtdec_setup_memory_banksize();
31}
Nishanth Menon1af76902024-02-20 12:39:48 -060032
33#ifdef CONFIG_SPL_BOARD_INIT
34
35/*
36 * Enable the 32k Crystal: needed for accurate 32k clock
37 * and external clock sources such as wlan 32k input clock
38 * supplied from the SoC to the wlan chip.
39 *
40 * The trim setup can be very highly board type specific choice of the crystal
41 * So this is done in the board file, though, in this case, no specific trim
42 * is necessary.
43 */
44static void crystal_32k_enable(void)
45{
46 /* Only mess with 32k at the start of boot from R5 */
47 if (IS_ENABLED(CONFIG_CPU_V7R)) {
48 /*
49 * We have external 32k crystal, so lets enable it (0x0)
50 * and disable bypass (0x0)
51 */
52 writel(0x0, MCU_CTRL_LFXOSC_CTRL);
53
54 /* Add any crystal specific TRIM needed here.. */
55
56 /* Make sure to mux the SoC 32k from the crystal */
57 writel(MCU_CTRL_DEVICE_CLKOUT_LFOSC_SELECT_VAL,
58 MCU_CTRL_DEVICE_CLKOUT_32K_CTRL);
59 }
60}
61
62void spl_board_init(void)
63{
64 crystal_32k_enable();
65}
66#endif