Skip to content

Commit

Permalink
WIP: HACK: speedup proper pre-reloc on rockchip
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwiboo committed Mar 19, 2024
1 parent e3163eb commit 3958919
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 18 deletions.
22 changes: 17 additions & 5 deletions arch/arm/mach-rockchip/rk3308/rk3308.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
/*
*Copyright (c) 2018 Rockchip Electronics Co., Ltd
*/
#include <common.h>

#include <debug_uart.h>
#include <init.h>
#include <malloc.h>
#include <asm/arch/grf_rk3308.h>
#include <ram.h>
#include <asm/arch-rockchip/bootrom.h>
#include <asm/arch-rockchip/hardware.h>
#include <asm/arch-rockchip/sdram.h>
#include <asm/arch/grf_rk3308.h>
#include <asm/armv8/mmu.h>
#include <asm/gpio.h>
#include <debug_uart.h>
#include <linux/bitops.h>

#include <asm/armv8/mmu.h>
static struct mm_region rk3308_mem_map[] = {
{
.virt = 0x0UL,
Expand Down Expand Up @@ -171,7 +173,7 @@ int rk_board_init(void)
}

#ifdef CONFIG_DEBUG_UART_BOARD_INIT
__weak void board_debug_uart_init(void)
void board_debug_uart_init(void)
{
static struct rk3308_grf * const grf = (void *)GRF_BASE;

Expand Down Expand Up @@ -216,3 +218,13 @@ int arch_cpu_init(void)
return 0;
}
#endif

int rockchip_ram_get_info(struct ram_info *ram)
{
static struct rk3308_grf * const grf = (void *)GRF_BASE;

ram->base = CFG_SYS_SDRAM_BASE;
ram->size = rockchip_sdram_size((phys_addr_t)&grf->os_reg2);

return 0;
}
15 changes: 13 additions & 2 deletions arch/arm/mach-rockchip/rk3328/rk3328.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* Copyright (c) 2016 Rockchip Electronics Co., Ltd
*/

#include <common.h>
#include <init.h>
#include <ram.h>
#include <asm/arch-rockchip/bootrom.h>
#include <asm/arch-rockchip/hardware.h>
#include <asm/arch-rockchip/grf_rk3328.h>
#include <asm/arch-rockchip/hardware.h>
#include <asm/arch-rockchip/sdram.h>
#include <asm/arch-rockchip/uart.h>
#include <asm/armv8/mmu.h>

Expand Down Expand Up @@ -135,3 +136,13 @@ void board_debug_uart_init(void)
/* enable FIFO */
writel(0x1, &uart->sfe);
}

int rockchip_ram_get_info(struct ram_info *ram)
{
struct rk3328_grf_regs * const grf = (void *)GRF_BASE;

ram->base = CFG_SYS_SDRAM_BASE;
ram->size = rockchip_sdram_size((phys_addr_t)&grf->os_reg[2]);

return 0;
}
13 changes: 12 additions & 1 deletion arch/arm/mach-rockchip/rk3399/rk3399.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* Copyright (c) 2016 Rockchip Electronics Co., Ltd
*/

#include <common.h>
#include <fdt_support.h>
#include <init.h>
#include <log.h>
#include <ram.h>
#include <spl.h>
#include <spl_gpio.h>
#include <syscon.h>
Expand All @@ -17,6 +17,7 @@
#include <asm/arch-rockchip/gpio.h>
#include <asm/arch-rockchip/grf_rk3399.h>
#include <asm/arch-rockchip/hardware.h>
#include <asm/arch-rockchip/sdram.h>
#include <linux/bitops.h>
#include <linux/printk.h>
#include <power/regulator.h>
Expand Down Expand Up @@ -231,3 +232,13 @@ void spl_board_init(void)
}
}
#endif

int rockchip_ram_get_info(struct ram_info *ram)
{
struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;

ram->base = CFG_SYS_SDRAM_BASE;
ram->size = rockchip_sdram_size((phys_addr_t)&pmugrf->os_reg2);

return 0;
}
16 changes: 12 additions & 4 deletions arch/arm/mach-rockchip/sdram.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
* Copyright (C) 2017 Rockchip Electronics Co., Ltd.
*/

#include <common.h>
#include <dm.h>
#include <dm/uclass-internal.h>
#include <init.h>
#include <log.h>
#include <ram.h>
#include <asm/arch-rockchip/sdram.h>
#include <asm/global_data.h>
#include <asm/io.h>
#include <asm/arch-rockchip/sdram.h>
#include <dm/uclass-internal.h>

DECLARE_GLOBAL_DATA_PTR;

Expand Down Expand Up @@ -200,18 +199,27 @@ size_t rockchip_sdram_size(phys_addr_t reg)
return (size_t)size_mb << 20;
}

__weak int rockchip_ram_get_info(struct ram_info *ram)
{
return -ENOSYS;
}

int dram_init(void)
{
struct ram_info ram;
struct udevice *dev;
int ret;
#if IS_ENABLED(CONFIG_TPL_BUILD)
struct udevice *dev;

ret = uclass_get_device(UCLASS_RAM, 0, &dev);
if (ret) {
debug("DRAM init failed: %d\n", ret);
return ret;
}
ret = ram_get_info(dev, &ram);
#else
ret = rockchip_ram_get_info(&ram);
#endif
if (ret) {
debug("Cannot get DRAM size: %d\n", ret);
return ret;
Expand Down
5 changes: 5 additions & 0 deletions common/board_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,9 @@ static int initf_bootstage(void)

static int initf_dm(void)
{
if (IS_ENABLED(CONFIG_ARCH_ROCKCHIP))
return 0;

#if defined(CONFIG_DM) && CONFIG_IS_ENABLED(SYS_MALLOC_F)
int ret;

Expand Down Expand Up @@ -894,7 +897,9 @@ static const init_fnc_t init_sequence_f[] = {
#endif
env_init, /* initialize environment */
init_baud_rate, /* initialze baudrate settings */
#if !IS_ENABLED(CONFIG_ARCH_ROCKCHIP)
serial_init, /* serial communications setup */
#endif
console_init_f, /* stage 1 init of console */
display_options, /* say that we are here */
display_text_info, /* show debugging info if required */
Expand Down
5 changes: 3 additions & 2 deletions drivers/core/ofnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,9 @@ static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
return of_read_number(prop_val, na);
}
} else {
na = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
ofnode parent = ofnode_get_parent(node);
na = ofnode_read_simple_addr_cells(parent);
ns = ofnode_read_simple_size_cells(parent);
return fdtdec_get_addr_size_fixed(ofnode_to_fdt(node),
ofnode_to_offset(node), "reg",
index, na, ns, size,
Expand Down
12 changes: 8 additions & 4 deletions drivers/core/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,16 @@ int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index)
int addr_len, size_len;
int ret;

addr_len = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
ofnode parent = ofnode_get_parent(node);

addr_len = ofnode_read_simple_addr_cells(parent);
if (addr_len < 0) {
debug("%s: Error while reading the addr length (ret = %d)\n",
ofnode_get_name(node), addr_len);
return addr_len;
}

size_len = ofnode_read_simple_size_cells(ofnode_get_parent(node));
size_len = ofnode_read_simple_size_cells(parent);
if (size_len < 0) {
debug("%s: Error while reading the size length: (ret = %d)\n",
ofnode_get_name(node), size_len);
Expand Down Expand Up @@ -249,14 +251,16 @@ int regmap_init_mem(ofnode node, struct regmap **mapp)
int index;
int ret;

addr_len = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
ofnode parent = ofnode_get_parent(node);

addr_len = ofnode_read_simple_addr_cells(parent);
if (addr_len < 0) {
debug("%s: Error while reading the addr length (ret = %d)\n",
ofnode_get_name(node), addr_len);
return addr_len;
}

size_len = ofnode_read_simple_size_cells(ofnode_get_parent(node));
size_len = ofnode_read_simple_size_cells(parent);
if (size_len < 0) {
debug("%s: Error while reading the size length: (ret = %d)\n",
ofnode_get_name(node), size_len);
Expand Down

0 comments on commit 3958919

Please sign in to comment.