blob: a4d0becdcc8ad261638140f53d88ae11a543a701 [file] [log] [blame]
Marek Vasute7628752022-04-08 02:15:01 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2021-2022 Marek Vasut <marex@denx.de>
4 */
5
6#include <common.h>
7#include <asm/arch/clock.h>
8#include <asm/arch/imx8mm_pins.h>
9#include <asm/arch/sys_proto.h>
10#include <asm/global_data.h>
11#include <asm/io.h>
12#include <asm/mach-imx/iomux-v3.h>
13#include <spl.h>
14
15#define UART_PAD_CTRL (PAD_CTL_PUE | PAD_CTL_PE | PAD_CTL_DSE4)
16#define WDOG_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE)
17
18/* Verdin UART_3, Console/Debug UART */
19static iomux_v3_cfg_t const uart_pads[] = {
20 IMX8MM_PAD_SAI3_TXFS_UART2_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
21 IMX8MM_PAD_SAI3_TXC_UART2_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
22};
23
24static iomux_v3_cfg_t const wdog_pads[] = {
25 IMX8MM_PAD_GPIO1_IO02_WDOG1_WDOG_B | MUX_PAD_CTRL(WDOG_PAD_CTRL),
26};
27
28#define SNVS_BASE_ADDR 0x30370000
29#define SNVS_LPSR 0x4c
30#define SNVS_LPLVDR 0x64
31#define SNVS_LPPGDR_INIT 0x41736166
32
33static void setup_snvs(void)
34{
35 /* Enable SNVS clock */
36 clock_enable(CCGR_SNVS, 1);
37 /* Initialize glitch detect */
38 writel(SNVS_LPPGDR_INIT, SNVS_BASE_ADDR + SNVS_LPLVDR);
39 /* Clear interrupt status */
40 writel(0xffffffff, SNVS_BASE_ADDR + SNVS_LPSR);
41}
42
43void board_early_init(void)
44{
45 struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
46
47 imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
48
49 set_wdog_reset(wdog);
50
51 imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
52
53 init_uart_clk(1);
54
55 setup_snvs();
56}