2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-02-23 07:37:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Rockchip Electronics Co., Ltd
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2019-07-22 11:59:33 +00:00
|
|
|
#include <asm/arch-rockchip/bootrom.h>
|
2019-03-28 03:01:23 +00:00
|
|
|
#include <asm/arch-rockchip/hardware.h>
|
2019-07-22 12:01:58 +00:00
|
|
|
#include <asm/arch-rockchip/grf_rk3328.h>
|
|
|
|
#include <asm/arch-rockchip/uart.h>
|
2017-02-23 07:37:51 +00:00
|
|
|
#include <asm/armv8/mmu.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
2017-06-23 08:11:11 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2019-07-22 12:01:58 +00:00
|
|
|
#define CRU_BASE 0xFF440000
|
|
|
|
#define GRF_BASE 0xFF100000
|
|
|
|
#define UART2_BASE 0xFF130000
|
2019-07-29 09:18:18 +00:00
|
|
|
#define FW_DDR_CON_REG 0xFF7C0040
|
2019-07-22 12:01:58 +00:00
|
|
|
|
2019-07-22 11:59:33 +00:00
|
|
|
const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
|
2019-10-17 07:22:38 +00:00
|
|
|
[BROM_BOOTSOURCE_EMMC] = "/rksdmmc@ff520000",
|
|
|
|
[BROM_BOOTSOURCE_SD] = "/rksdmmc@ff500000",
|
2019-07-22 11:59:33 +00:00
|
|
|
};
|
|
|
|
|
2017-02-23 07:37:51 +00:00
|
|
|
static struct mm_region rk3328_mem_map[] = {
|
|
|
|
{
|
|
|
|
.virt = 0x0UL,
|
|
|
|
.phys = 0x0UL,
|
2017-06-13 13:00:12 +00:00
|
|
|
.size = 0xff000000UL,
|
2017-02-23 07:37:51 +00:00
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_INNER_SHARE
|
|
|
|
}, {
|
2017-06-13 13:00:12 +00:00
|
|
|
.virt = 0xff000000UL,
|
|
|
|
.phys = 0xff000000UL,
|
|
|
|
.size = 0x1000000UL,
|
2017-02-23 07:37:51 +00:00
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
}, {
|
|
|
|
/* List terminator */
|
|
|
|
0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mm_region *mem_map = rk3328_mem_map;
|
|
|
|
|
|
|
|
int arch_cpu_init(void)
|
|
|
|
{
|
2019-07-29 09:18:18 +00:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
2017-02-23 07:37:51 +00:00
|
|
|
/* We do some SoC one time setting here. */
|
|
|
|
|
2019-07-29 09:18:18 +00:00
|
|
|
/* Disable the ddr secure region setting to make it non-secure */
|
|
|
|
rk_setreg(FW_DDR_CON_REG, 0x200);
|
|
|
|
#endif
|
2017-02-23 07:37:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2019-07-22 12:01:58 +00:00
|
|
|
|
|
|
|
void board_debug_uart_init(void)
|
|
|
|
{
|
|
|
|
struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
|
|
|
|
struct rk_uart * const uart = (void *)UART2_BASE;
|
|
|
|
enum{
|
|
|
|
GPIO2A0_SEL_SHIFT = 0,
|
|
|
|
GPIO2A0_SEL_MASK = 3 << GPIO2A0_SEL_SHIFT,
|
|
|
|
GPIO2A0_UART2_TX_M1 = 1,
|
|
|
|
|
|
|
|
GPIO2A1_SEL_SHIFT = 2,
|
|
|
|
GPIO2A1_SEL_MASK = 3 << GPIO2A1_SEL_SHIFT,
|
|
|
|
GPIO2A1_UART2_RX_M1 = 1,
|
|
|
|
};
|
|
|
|
enum {
|
|
|
|
IOMUX_SEL_UART2_SHIFT = 0,
|
|
|
|
IOMUX_SEL_UART2_MASK = 3 << IOMUX_SEL_UART2_SHIFT,
|
|
|
|
IOMUX_SEL_UART2_M0 = 0,
|
|
|
|
IOMUX_SEL_UART2_M1,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* uart_sel_clk default select 24MHz */
|
|
|
|
writel((3 << (8 + 16)) | (2 << 8), CRU_BASE + 0x148);
|
|
|
|
|
|
|
|
/* init uart baud rate 1500000 */
|
|
|
|
writel(0x83, &uart->lcr);
|
|
|
|
writel(0x1, &uart->rbr);
|
|
|
|
writel(0x3, &uart->lcr);
|
|
|
|
|
|
|
|
/* Enable early UART2 */
|
|
|
|
rk_clrsetreg(&grf->com_iomux,
|
|
|
|
IOMUX_SEL_UART2_MASK,
|
|
|
|
IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT);
|
|
|
|
rk_clrsetreg(&grf->gpio2a_iomux,
|
|
|
|
GPIO2A0_SEL_MASK,
|
|
|
|
GPIO2A0_UART2_TX_M1 << GPIO2A0_SEL_SHIFT);
|
|
|
|
rk_clrsetreg(&grf->gpio2a_iomux,
|
|
|
|
GPIO2A1_SEL_MASK,
|
|
|
|
GPIO2A1_UART2_RX_M1 << GPIO2A1_SEL_SHIFT);
|
|
|
|
|
|
|
|
/* enable FIFO */
|
|
|
|
writel(0x1, &uart->sfe);
|
|
|
|
}
|