Add support for the WolfVision PF5 mainboard, which features the Rockchip RK3568 SoC and can be extended with different expansion boards. Signed-off-by: Michael Riesch <michael.riesch@xxxxxxxxxxxxxx> --- arch/arm/boards/Makefile | 1 + arch/arm/boards/wolfvision-pf5/.gitignore | 1 + arch/arm/boards/wolfvision-pf5/Makefile | 3 + arch/arm/boards/wolfvision-pf5/board.c | 88 ++++++++++++++++++++++ arch/arm/boards/wolfvision-pf5/lowlevel.c | 36 +++++++++ arch/arm/dts/Makefile | 3 + .../arm/dts/rk3568-wolfvision-pf5-io-expander.dtso | 11 +++ arch/arm/dts/rk3568-wolfvision-pf5.dts | 48 ++++++++++++ arch/arm/mach-rockchip/Kconfig | 9 +++ images/Makefile.rockchip | 1 + 10 files changed, 201 insertions(+) diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile index 84e777092d..98eab17af2 100644 --- a/arch/arm/boards/Makefile +++ b/arch/arm/boards/Makefile @@ -204,3 +204,4 @@ obj-$(CONFIG_MACH_RADXA_ROCK5) += radxa-rock5/ obj-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP) += variscite-dt8mcustomboard-imx8mp/ obj-$(CONFIG_MACH_RADXA_CM3) += radxa-cm3/ obj-$(CONFIG_MACH_TQMA93XX) += tqma93xx/ +obj-$(CONFIG_MACH_WOLFVISION_PF5) += wolfvision-pf5/ diff --git a/arch/arm/boards/wolfvision-pf5/.gitignore b/arch/arm/boards/wolfvision-pf5/.gitignore new file mode 100644 index 0000000000..f458f794b5 --- /dev/null +++ b/arch/arm/boards/wolfvision-pf5/.gitignore @@ -0,0 +1 @@ +sdram-init.bin diff --git a/arch/arm/boards/wolfvision-pf5/Makefile b/arch/arm/boards/wolfvision-pf5/Makefile new file mode 100644 index 0000000000..b37b6c870b --- /dev/null +++ b/arch/arm/boards/wolfvision-pf5/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-y += board.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/wolfvision-pf5/board.c b/arch/arm/boards/wolfvision-pf5/board.c new file mode 100644 index 0000000000..797f51bc2e --- /dev/null +++ b/arch/arm/boards/wolfvision-pf5/board.c @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Board code for the WolfVision PF5 mainboard. + * + * Copyright (C) 2024 WolfVision GmbH. + */ +#include <common.h> +#include <deep-probe.h> +#include <globalvar.h> +#include <init.h> + +#include <boards/wolfvision/common.h> +#include <mach/rockchip/bbu.h> + +#define PF5_IO_EXPANDER_FILENAME "rk3568-wolfvision-pf5-io-expander.dtbo" +#define PF5_IO_EXPANDER_DATA __dtbo_rk3568_wolfvision_pf5_io_expander_start + +enum { + PF5_HWID_CHANNEL_MAINBOARD = 1, + PF5_HWID_CHANNEL_MODULE = 2, +}; + +extern char PF5_IO_EXPANDER_DATA[]; + +static const struct wv_rk3568_extension pf5_extensions[] = { + { + .adc_chan = PF5_HWID_CHANNEL_MAINBOARD, + .name = "mainboard", + .overlays = { + [0] = { .name = "PF5 DC V1.0 A", }, + [4] = { .name = "PF5 DC V1.1 A", }, + }, + }, + { + .adc_chan = PF5_HWID_CHANNEL_MODULE, + .name = "module", + .overlays = { + [0] = { .name = "PF5 IO Expander V1.0 A", + .filename = PF5_IO_EXPANDER_FILENAME, + .data = PF5_IO_EXPANDER_DATA, + }, + [16] = { .name = "no", }, + }, + }, +}; + +static int pf5_probe(struct device *dev) +{ + char *pf5_overlays = NULL; + int ret; + + barebox_set_model("WolfVision PF5"); + barebox_set_hostname("PF5"); + + ret = wolfvision_register_ethaddr(); + if (ret) + pr_warning("failed to register MAC addresses\n"); + + rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc0"); + + ret = wolfvision_rk3568_detect_hw( + pf5_extensions, ARRAY_SIZE(pf5_extensions), &pf5_overlays); + if (ret) + pr_warning("failed to detect HW\n"); + + if (pf5_overlays) + globalvar_set("of.overlay.filepattern", pf5_overlays); + + free(pf5_overlays); + + return 0; +} + +static const struct of_device_id pf5_of_match[] = { + { + .compatible = "wolfvision,rk3568-pf5", + }, + { /* sentinel */ }, +}; + +static struct driver_d pf5_board_driver = { + .name = "board-wolfvision-pf5", + .probe = pf5_probe, + .of_compatible = pf5_of_match, +}; +coredevice_platform_driver(pf5_board_driver); + +BAREBOX_DEEP_PROBE_ENABLE(pf5_of_match); diff --git a/arch/arm/boards/wolfvision-pf5/lowlevel.c b/arch/arm/boards/wolfvision-pf5/lowlevel.c new file mode 100644 index 0000000000..c20ca4ae13 --- /dev/null +++ b/arch/arm/boards/wolfvision-pf5/lowlevel.c @@ -0,0 +1,36 @@ +// 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/rockchip/hardware.h> +#include <mach/rockchip/atf.h> +#include <debug_ll.h> +#include <mach/rockchip/rockchip.h> + +extern char __dtb_rk3568_wolfvision_pf5_start[]; + +ENTRY_FUNCTION(start_rk3568_wolfvision_pf5, r0, r1, r2) +{ + /* + * Enable vccio4 1.8V and vccio5 1.8V + * FIXME: This is done by the io-domain driver as well, but there + * currently is no mechanism to make sure the driver gets probed + * before its consumers. Remove this setup once this issue is + * resolved. + */ + writel(RK_SETBITS(0x30), 0xfdc20140); + + /* + * 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_barebox_entry(__dtb_rk3568_wolfvision_pf5_start); +} diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 7671b9e2ad..e4af867027 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -186,6 +186,7 @@ lwl-$(CONFIG_MACH_WARP7) += imx7s-warp.dtb.o lwl-$(CONFIG_MACH_VF610_TWR) += vf610-twr.dtb.o lwl-$(CONFIG_MACH_WEBASTO_CCBV2) += imx6ul-webasto-ccbv2.dtb.o lwl-$(CONFIG_MACH_WEBASTO_CCBV2) += imx6ul-webasto-marvel.dtb.o +lwl-$(CONFIG_MACH_WOLFVISION_PF5) += rk3568-wolfvision-pf5.dtb.o lwl-$(CONFIG_MACH_ZII_RDU1) += \ imx51-zii-rdu1.dtb.o \ imx51-zii-scu2-mezz.dtb.o \ @@ -230,4 +231,6 @@ lwl-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP) += imx8mp-var-dart-dt8mcusto lwl-$(CONFIG_MACH_TQMA93XX) += imx93-tqma9352-mba93xxca.dtb.o \ imx93-tqma9352-mba93xxla.dtb.o +obj-$(CONFIG_MACH_WOLFVISION_PF5) += rk3568-wolfvision-pf5-io-expander.dtbo.o + clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z diff --git a/arch/arm/dts/rk3568-wolfvision-pf5-io-expander.dtso b/arch/arm/dts/rk3568-wolfvision-pf5-io-expander.dtso new file mode 100644 index 0000000000..37b48afd2d --- /dev/null +++ b/arch/arm/dts/rk3568-wolfvision-pf5-io-expander.dtso @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT) +/* + * Device tree overlay for the WolfVision PF5 IO Expander board. + * + * Copyright (C) 2024 WolfVision GmbH. + */ + +/dts-v1/; +/plugin/; + +#include "rk3568-wolfvision-pf5-io-expander-upstream.dtso" diff --git a/arch/arm/dts/rk3568-wolfvision-pf5.dts b/arch/arm/dts/rk3568-wolfvision-pf5.dts new file mode 100644 index 0000000000..e214842ee4 --- /dev/null +++ b/arch/arm/dts/rk3568-wolfvision-pf5.dts @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT) +/* + * Device tree for the WolfVision PF5 mainboard. + * + * Copyright (C) 2024 WolfVision GmbH. + */ + +/dts-v1/; +#include "rk3568-wolfvision-pf5-upstream.dts" +#include "rk356x.dtsi" +#include "wolfvision-state.dtsi" + +/ { + aliases { + saradc = &saradc; + }; + + chosen: chosen { + environment-emmc { + compatible = "barebox,environment"; + device-path = &environment_emmc; + }; + }; + /* + memory@a00000 { + device_type = "memory"; + reg = <0x0 0x00a00000 0x0 0x7f600000>; + }; + */ +}; + +&sdhci { + partitions { + compatible = "fixed-partitions"; + #address-cells = <2>; + #size-cells = <2>; + + environment_emmc: partition@408000 { + label = "barebox-environment"; + reg = <0x0 0x408000 0x0 0x8000>; + }; + + barebox_state: partition@410000 { + reg = <0x0 0x410000 0x0 0x8000>; + label = "state"; + }; + }; +}; diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index 0e2b7810bc..f373624f5c 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -115,6 +115,15 @@ config MACH_RADXA_CM3 help Say Y here if you are using a Radxa CM3 +config MACH_WOLFVISION_PF5 + select ARCH_RK3568 + select AIODEV + select BOARD_WOLFVISION + select ROCKCHIP_SARADC + bool "WolfVision PF5 mainboard" + help + Say Y here if you are using a WolfVision PF5 mainboard + endif comment "select board features:" diff --git a/images/Makefile.rockchip b/images/Makefile.rockchip index ceacfde10d..e344e893a0 100644 --- a/images/Makefile.rockchip +++ b/images/Makefile.rockchip @@ -36,3 +36,4 @@ $(call build_rockchip_image, CONFIG_MACH_PROTONIC_MECSBC, start_mecsbc, protonic $(call build_rockchip_image, CONFIG_MACH_RADXA_ROCK3, start_rock3a, radxa-rock3/sdram-init.bin, rock3a) $(call build_rockchip_image, CONFIG_MACH_RADXA_ROCK5, start_rock5b, radxa-rock5/sdram-init.bin, rock5b) $(call build_rockchip_image, CONFIG_MACH_RADXA_CM3, start_radxa_cm3_io, radxa-cm3/sdram-init.bin, radxa-cm3-io) +$(call build_rockchip_image, CONFIG_MACH_WOLFVISION_PF5, start_rk3568_wolfvision_pf5, wolfvision-pf5/sdram-init.bin, rk3568-wolfvision-pf5) -- 2.34.1