diff options
Diffstat (limited to 'arch/arm/boards/rockchip-rk3568-bpi-r2pro')
4 files changed, 145 insertions, 0 deletions
diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/.gitignore b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/.gitignore new file mode 100644 index 0000000000..f458f794b5 --- /dev/null +++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/.gitignore @@ -0,0 +1 @@ +sdram-init.bin diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/Makefile b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/Makefile new file mode 100644 index 0000000000..01c7a259e9 --- /dev/null +++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/Makefile @@ -0,0 +1,2 @@ +obj-y += board.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c new file mode 100644 index 0000000000..e472f13c8b --- /dev/null +++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#define pr_fmt(fmt) "rk3568-r2pro: " fmt + +#include <common.h> +#include <init.h> +#include <mach/bbu.h> +#include <aiodev.h> +#include <bootsource.h> +#include <environment.h> +#include <globalvar.h> +#include <magicvar.h> +#include <deep-probe.h> + +static bool machine_is_bpi_r2pro = false; + +static int rk3568_bpi_r2pro_probe(struct device_d *dev) +{ + enum bootsource bootsource = bootsource_get(); + int instance = bootsource_get_instance(); + + barebox_set_model("BPI R2PRO"); + barebox_set_hostname("bpi-r2pro"); + machine_is_bpi_r2pro = true; + + if (bootsource == BOOTSOURCE_MMC && instance == 1) + of_device_enable_path("/chosen/environment-sd"); + else + of_device_enable_path("/chosen/environment-emmc"); + + rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/emmc"); + rk3568_bbu_mmc_register("sd", 0, "/dev/sd"); + + return 0; +} + +static const struct of_device_id rk3568_bpi_r2pro_of_match[] = { + { .compatible = "rockchip,rk3568-bpi-r2pro" }, + { /* Sentinel */}, +}; + +static struct driver_d rk3568_bpi_r2pro_board_driver = { + .name = "board-rk3568-bpi-r2pro", + .probe = rk3568_bpi_r2pro_probe, + .of_compatible = rk3568_bpi_r2pro_of_match, +}; +coredevice_platform_driver(rk3568_bpi_r2pro_board_driver); + +BAREBOX_DEEP_PROBE_ENABLE(rk3568_bpi_r2pro_of_match); + +static int rk3568_bpi_r2pro_detect_hwid(void) +{ + int ret; + int hwid_voltage; + struct aiochannel *hwid_chan; + char *hwid; + + if (!IS_ENABLED(CONFIG_AIODEV)) + return 0; + + if (!machine_is_bpi_r2pro) + return 0; + + hwid_chan = aiochannel_by_name("aiodev0.in_value1_mV"); + if (IS_ERR(hwid_chan)) { + ret = PTR_ERR(hwid_chan); + goto err_hwid; + } + + ret = aiochannel_get_value(hwid_chan, &hwid_voltage); + if (ret) + goto err_hwid; + + pr_info("hwid_voltage: %d\n", hwid_voltage); + + if (hwid_voltage == 1800) + hwid = "V00"; + else + hwid = "unknown"; + + pr_info("Detected RK3568 BananaPi R2 Pro %s\n", hwid); + + globalvar_add_simple("board.hwid", hwid); + + return 0; + +err_hwid: + pr_err("couldn't retrieve hardware ID\n"); + return ret; +} +late_initcall(rk3568_bpi_r2pro_detect_hwid); + +BAREBOX_MAGICVAR(global.board.hwid, "The board hardware ID"); diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c new file mode 100644 index 0000000000..9f039c6048 --- /dev/null +++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <common.h> +#include <linux/sizes.h> +#include <asm/barebox-arm-head.h> +#include <asm/barebox-arm.h> +#include <mach/hardware.h> +#include <mach/atf.h> +#include <debug_ll.h> +#include <mach/rockchip.h> + +extern char __dtb_rk3568_bpi_r2_pro_start[]; + +static noinline void rk3568_start(void) +{ + void *fdt; + + /* + * Enable vccio4 1.8V and vccio6 1.8V + * Needed for GMAC to work. + */ + writel(RK_SETBITS(0x50), 0xfdc20140); + + fdt = __dtb_rk3568_bpi_r2_pro_start; + + if (current_el() == 3) { + rk3568_lowlevel_init(); + rk3568_atf_load_bl31(fdt); + /* not reached */ + } + + barebox_arm_entry(RK3568_DRAM_BOTTOM, 0x80000000 - RK3568_DRAM_BOTTOM, fdt); +} + +ENTRY_FUNCTION(start_rk3568_bpi_r2pro, r0, r1, r2) +{ + /* + * Image execution starts at 0x0, but this is used for ATF and + * OP-TEE later, so move away from here. + */ + if (current_el() == 3) + relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS); + else + relocate_to_current_adr(); + + setup_c(); + + rk3568_start(); +} |