Nishanth Menon | 9dd6bdc | 2023-11-04 03:01:35 -0500 | [diff] [blame] | 1 | // 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 Menon | 1af7690 | 2024-02-20 12:39:48 -0600 | [diff] [blame^] | 14 | #include <asm/arch/hardware.h> |
| 15 | |
Nishanth Menon | 9dd6bdc | 2023-11-04 03:01:35 -0500 | [diff] [blame] | 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
| 18 | int board_init(void) |
| 19 | { |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | int dram_init(void) |
| 24 | { |
| 25 | return fdtdec_setup_mem_size_base(); |
| 26 | } |
| 27 | |
| 28 | int dram_init_banksize(void) |
| 29 | { |
| 30 | return fdtdec_setup_memory_banksize(); |
| 31 | } |
Nishanth Menon | 1af7690 | 2024-02-20 12:39:48 -0600 | [diff] [blame^] | 32 | |
| 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 | */ |
| 44 | static 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 | |
| 62 | void spl_board_init(void) |
| 63 | { |
| 64 | crystal_32k_enable(); |
| 65 | } |
| 66 | #endif |