Skip to content

Commit

Permalink
rockchip: add ArmSoM Sige5 (RK3576, 8 Cores) board support
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Nov 22, 2024
1 parent ab8cac3 commit 8fcfe76
Show file tree
Hide file tree
Showing 32 changed files with 2,336 additions and 1 deletion.
11 changes: 11 additions & 0 deletions package/boot/rockchip-rkbin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ define rkbin/rk3568
TPL:=rk35/rk3568_ddr_1560MHz_v1.21.bin
endef

define rkbin/rk3576
DEPENDS:=@TARGET_rockchip_armv8
ATF:=rk35/rk3576_bl31_v1.04.elf
TPL:=rk35/rk3576_ddr_lp4_2112MHz_lp5_2736MHz_v1.03.bin
TEE:=rk35/rk3576_bl32_v1.01.bin
endef

define rkbin/rk3588
DEPENDS:=@TARGET_rockchip_armv8
ATF:=rk35/rk3588_bl31_v1.45.elf
Expand All @@ -79,6 +86,7 @@ VARIANTS:= \
rk3528 \
rk3566 \
rk3568 \
rk3576 \
rk3588

define Build/Compile
Expand Down Expand Up @@ -117,6 +125,9 @@ ifneq ($(SPL),)
$(CP) $(PKG_BUILD_DIR)/$(BUILD_VARIANT)-idbloader.bin $(STAGING_DIR_IMAGE)/
$(CP) $(PKG_BUILD_DIR)/$(BUILD_VARIANT)-trust.bin $(STAGING_DIR_IMAGE)/
endif
ifneq ($(TEE),)
$(CP) $(PKG_BUILD_DIR)/bin/$(TEE) $(STAGING_DIR_IMAGE)/
endif
endef

$(eval $(call BuildPackage/rkbin))
Binary file not shown.
Binary file not shown.
Binary file not shown.
68 changes: 68 additions & 0 deletions package/boot/uboot-rk3576/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=uboot-rockchip
PKG_RELEASE:=2

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/ArmSoM/u-boot

PKG_SOURCE_DATE:=2024-04-18
PKG_SOURCE_VERSION:=57b8ceed1c31601ef81a5752a78c42e536c42cfe
PKG_MIRROR_HASH:=3ff3904f405e3389e316dfe0d54cc446563d98f610a81622f8bf41894f88a540

include $(INCLUDE_DIR)/u-boot.mk
include $(INCLUDE_DIR)/package.mk

define U-Boot/Default
BUILD_TARGET:=rockchip
UENV:=default
HIDDEN:=1
endef

define U-Boot/armsom-sige5-rk3576
BUILD_SUBTARGET:=armv8
NAME:=ArmSoM Sige5
BUILD_DEVICES:= \
armsom_sige5
DEPENDS:=+PACKAGE_u-boot-$(1):rkbin-rk3576
ATF:=rk3576_bl31_v1.04.elf
DDR:=rk3576_ddr_lp4_2112MHz_lp5_2736MHz_v1.03.bin
TEE:=rk3576_bl32_v1.01.bin
SOC:=rk3576
endef

UBOOT_TARGETS := \
armsom-sige5-rk3576

UBOOT_CONFIGURE_VARS += USE_PRIVATE_LIBGCC=yes

UBOOT_MAKE_FLAGS += \
IDB_SOC=$(SOC) TPL_BIN=$(STAGING_DIR_IMAGE)/$(DDR) u-boot.itb idbloader.img

define Build/Configure
$(call Build/Configure/U-Boot)

$(SED) 's/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/' $(PKG_BUILD_DIR)/.config
$(SED) 's#CONFIG_MKIMAGE_DTC_PATH=.*#CONFIG_MKIMAGE_DTC_PATH="$(PKG_BUILD_DIR)/scripts/dtc/dtc"#g' $(PKG_BUILD_DIR)/.config
echo 'CONFIG_IDENT_STRING=" OpenWrt"' >> $(PKG_BUILD_DIR)/.config
$(CP) $(STAGING_DIR_IMAGE)/$(ATF) $(PKG_BUILD_DIR)/bl31.elf
ifneq ($(TEE),)
$(CP) $(STAGING_DIR_IMAGE)/$(TEE) $(PKG_BUILD_DIR)/tee.bin
endif
endef

define Build/InstallDev
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
$(CP) $(PKG_BUILD_DIR)/idbloader.img $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-idbloader.img
$(CP) $(PKG_BUILD_DIR)/u-boot.itb $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-u-boot.itb
endef

define Package/u-boot/install/default
endef

$(eval $(call BuildPackage/U-Boot))
27 changes: 27 additions & 0 deletions package/boot/uboot-rk3576/patches/001-add-adc-cmd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -589,6 +589,14 @@ config CMD_ARMFLASH
help
ARM Ltd reference designs flash partition access

+config CMD_ADC
+ bool "adc - Access Analog to Digital Converters info and data"
+ select ADC
+ depends on DM_REGULATOR
+ help
+ Shows ADC device info and permit printing one-shot analog converted
+ data from a named Analog to Digital Converter.
+
config CMD_CLK
bool "clk - Show clock frequencies"
help
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -13,6 +13,7 @@ obj-y += help.o
obj-y += version.o

# command
+obj-$(CONFIG_CMD_ADC) += adc.o
obj-$(CONFIG_CMD_AES) += aes.o
obj-$(CONFIG_CMD_AMBAPP) += ambapp.o
obj-$(CONFIG_CMD_ANDROID_AB_SELECT) += android_ab_select.o android_cmds.o
42 changes: 42 additions & 0 deletions package/boot/uboot-rk3576/patches/002-adc-channel-mask-api.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--- a/drivers/adc/adc-uclass.c
+++ b/drivers/adc/adc-uclass.c
@@ -84,6 +84,18 @@ int adc_data_mask(struct udevice *dev, u
return 0;
}

+int adc_channel_mask(struct udevice *dev, unsigned int *channel_mask)
+{
+ struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev);
+
+ if (!uc_pdata)
+ return -ENOSYS;
+
+ *channel_mask = uc_pdata->channel_mask;
+
+ return 0;
+}
+
int adc_stop(struct udevice *dev)
{
const struct adc_ops *ops = dev_get_driver_ops(dev);
--- a/include/adc.h
+++ b/include/adc.h
@@ -220,6 +220,18 @@ int adc_channels_data(struct udevice *de
int adc_data_mask(struct udevice *dev, unsigned int *data_mask);

/**
+ * adc_channel_mask() - get channel mask for given ADC device
+ *
+ * This can be used if adc uclass platform data is filled.
+ *
+ * @dev: ADC device to check
+ * @channel_mask: pointer to the returned channel bitmask
+ * @return: 0 if OK, -ve on error
+ */
+int adc_channel_mask(struct udevice *dev, unsigned int *channel_mask);
+
+
+/**
* adc_channel_single_shot() - get output data of conversion for the ADC
* device's channel. This function searches for the device with the given name,
* starts the given channel conversion and returns the output data.
58 changes: 58 additions & 0 deletions package/boot/uboot-rk3576/patches/003-adc-raw-to-uv-api.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
--- a/drivers/adc/adc-uclass.c
+++ b/drivers/adc/adc-uclass.c
@@ -7,6 +7,7 @@

#include <common.h>
#include <errno.h>
+#include <div64.h>
#include <dm.h>
#include <dm/lists.h>
#include <dm/device-internal.h>
@@ -365,6 +366,30 @@ nodev:

return 0;
}
+
+int adc_raw_to_uV(struct udevice *dev, unsigned int raw, int *uV)
+{
+ unsigned int data_mask;
+ int ret, val, vref;
+ u64 raw64 = raw;
+
+ ret = adc_vdd_value(dev, &vref);
+ if (ret)
+ return ret;
+
+ if (!adc_vss_value(dev, &val))
+ vref -= val;
+
+ ret = adc_data_mask(dev, &data_mask);
+ if (ret)
+ return ret;
+
+ raw64 *= vref;
+ do_div(raw64, data_mask);
+ *uV = raw64;
+
+ return 0;
+}

static int adc_vdd_platdata_set(struct udevice *dev)
{
--- a/include/adc.h
+++ b/include/adc.h
@@ -297,4 +297,14 @@ int adc_vss_value(struct udevice *dev, i
*/
int adc_stop(struct udevice *dev);

+/**
+ * adc_raw_to_uV() - converts raw value to microvolts for given ADC device.
+ *
+ * @dev: ADC device used from conversion
+ * @raw: raw value to convert
+ * @uV: converted value in microvolts
+ * @return: 0 on success or -ve on error
+ */
+int adc_raw_to_uV(struct udevice *dev, unsigned int raw, int *uV);
+
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 34bfaa17488e5fd933dad63eacfef4f1c86ebd58 Mon Sep 17 00:00:00 2001
From: Liangbin Lian <[email protected]>
Date: Fri, 26 May 2023 14:25:07 +0800
Subject: [PATCH] disable adc to volt convert

---
drivers/adc/rockchip-saradc-v2.c | 2 ++
drivers/adc/rockchip-saradc.c | 2 ++
2 files changed, 4 insertions(+)

--- a/drivers/adc/rockchip-saradc-v2.c
+++ b/drivers/adc/rockchip-saradc-v2.c
@@ -207,6 +207,8 @@ static int rockchip_saradc_ofdata_to_pla
uc_pdata->data_format = ADC_DATA_FORMAT_BIN;
uc_pdata->data_timeout_us = SARADC_TIMEOUT / 5;
uc_pdata->channel_mask = (1 << priv->data->num_channels) - 1;
+ uc_pdata->vdd_microvolts = -ENODATA;
+ uc_pdata->vss_microvolts = -ENODATA;

return 0;
}
--- a/drivers/adc/rockchip-saradc.c
+++ b/drivers/adc/rockchip-saradc.c
@@ -134,6 +134,8 @@ int rockchip_saradc_ofdata_to_platdata(s
uc_pdata->data_format = ADC_DATA_FORMAT_BIN;
uc_pdata->data_timeout_us = SARADC_TIMEOUT / 5;
uc_pdata->channel_mask = (1 << priv->data->num_channels) - 1;
+ uc_pdata->vdd_microvolts = -ENODATA;
+ uc_pdata->vss_microvolts = -ENODATA;

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- a/drivers/adc/rockchip-saradc.c
+++ b/drivers/adc/rockchip-saradc.c
@@ -164,6 +164,12 @@ static const struct rockchip_saradc_data
.clk_rate = 1000000,
};

+static const struct rockchip_saradc_data rk3568_saradc_data = {
+ .num_bits = 10,
+ .num_channels = 8,
+ .clk_rate = 1000000,
+};
+
static const struct udevice_id rockchip_saradc_ids[] = {
{ .compatible = "rockchip,saradc",
.data = (ulong)&saradc_data },
@@ -171,6 +177,8 @@ static const struct udevice_id rockchip_
.data = (ulong)&rk3066_tsadc_data },
{ .compatible = "rockchip,rk3399-saradc",
.data = (ulong)&rk3399_saradc_data },
+ { .compatible = "rockchip,rk3568-saradc",
+ .data = (ulong)&rk3568_saradc_data },
{ }
};

38 changes: 38 additions & 0 deletions package/boot/uboot-rk3576/patches/006-fix-efi-detection.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 40361189b449992e14ff0bd0be18c92167ff8d00 Mon Sep 17 00:00:00 2001
From: jjm2473 <[email protected]>
Date: Tue, 6 Jun 2023 12:27:39 +0800
Subject: [PATCH] fix efi detection

---
disk/part_efi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -366,7 +366,7 @@ int part_get_info_efi(struct blk_desc *d
return 0;
}

-#ifdef CONFIG_RKIMG_BOOTLOADER
+#if 0
#if defined(CONFIG_SPL_KERNEL_BOOT) || !defined(CONFIG_SPL_BUILD)
static void gpt_entry_modify(struct blk_desc *dev_desc,
gpt_entry *gpt_pte,
@@ -489,7 +489,7 @@ static int part_test_efi(struct blk_desc
|| (is_pmbr_valid(legacymbr) != 1)) {
return -1;
}
-#ifdef CONFIG_RKIMG_BOOTLOADER
+#if 0
#if defined(CONFIG_SPL_KERNEL_BOOT) || !defined(CONFIG_SPL_BUILD)
gpt_entry *h_gpt_pte = NULL;
gpt_header *h_gpt_head = NULL;
@@ -1132,7 +1132,7 @@ static int is_pmbr_valid(legacy_mbr * mb
{
int i = 0;

-#ifdef CONFIG_ARCH_ROCKCHIP
+#if 0
/*
* In sd-update card, we use RKPARM partition in bootloader to load
* firmware, and use MS-DOS partition in recovery to update system.
20 changes: 20 additions & 0 deletions package/boot/uboot-rk3576/patches/007-supports-legacy-image.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
From 600dbd1d1ca42e82aa11540954725a7c19952bef Mon Sep 17 00:00:00 2001
From: jjm2473 <[email protected]>
Date: Mon, 5 Jun 2023 16:58:02 +0800
Subject: [PATCH] supports legacy image

---
include/configs/rockchip-common.h | 2 ++
1 file changed, 2 insertions(+)

--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -180,6 +180,8 @@
"run distro_bootcmd;"
#endif

+#define CONFIG_IMAGE_FORMAT_LEGACY /* enable also legacy image format */
+
#endif /* CONFIG_SPL_BUILD */

#define CONFIG_DISPLAY_BOARDINFO_LATE
21 changes: 21 additions & 0 deletions package/boot/uboot-rk3576/patches/008-fix-source-cmd-bug.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
From fba85cc35e748ce82af8d23c8ae6b7594a927ca1 Mon Sep 17 00:00:00 2001
From: jjm2473 <[email protected]>
Date: Mon, 5 Jun 2023 17:36:35 +0800
Subject: [PATCH] fix source cmd bug introduced by rk

11a331d232dea79e25443776ebc3044cbe91d259
---
cmd/source.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/cmd/source.c
+++ b/cmd/source.c
@@ -87,7 +87,7 @@ source (ulong addr, const char *fit_unam
* past the zero-terminated sequence of image lengths to get
* to the actual image data
*/
- while (*data++ != IMAGE_PARAM_INVAL);
+ while (*data++);
break;
#endif
#if defined(CONFIG_FIT)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From ca4343eb308b019c6bc6930361b56306cd3ba55d Mon Sep 17 00:00:00 2001
From: jjm2473 <[email protected]>
Date: Mon, 5 Jun 2023 18:48:45 +0800
Subject: [PATCH] fix boorargs not in effect

---
arch/arm/mach-rockchip/board.c | 2 ++
1 file changed, 2 insertions(+)

--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -1341,6 +1341,7 @@ static void bootargs_add_dtb_dtbo(void *
}
}

+#ifdef CONFIG_CMD_BOOT_ANDROID
char *board_fdt_chosen_bootargs(void *fdt)
{
int verbose = is_hotkey(HK_CMDLINE);
@@ -1384,6 +1385,7 @@ char *board_fdt_chosen_bootargs(void *fd

return (char *)bootargs;
}
+#endif

int ft_verify_fdt(void *fdt)
{
Loading

0 comments on commit 8fcfe76

Please sign in to comment.