rgb30: detect revisions in u-boot

This commit is contained in:
sydarn 2024-04-08 19:47:40 +02:00
parent 3096fbd8d7
commit db8f04b737
2 changed files with 106 additions and 7 deletions

View file

@ -1,10 +1,10 @@
diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
index d05502f67..98b3bc145 100644
index 043769dfe0..b44c0b63fe 100644
--- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
+++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
@@ -32,7 +32,7 @@
#define GPIO_WRITEMASK(bits) ((bits) << 16)
@@ -45,7 +45,7 @@
#define SARADC_INPUT_SRC_MSK 0x7
#define SARADC_POWER_CTRL BIT(3)
-#define DTB_DIR "rockchip/"
+#define DTB_DIR ""
@ -12,11 +12,11 @@ index d05502f67..98b3bc145 100644
struct rg3xx_model {
const u16 adc_value;
diff --git a/configs/anbernic-rgxx3-rk3566_defconfig b/configs/anbernic-rgxx3-rk3566_defconfig
index ed6643d9d..83e8358a0 100644
index c8c9238f96..f26801f4eb 100644
--- a/configs/anbernic-rgxx3-rk3566_defconfig
+++ b/configs/anbernic-rgxx3-rk3566_defconfig
@@ -27,7 +27,7 @@ CONFIG_FIT_VERBOSE=y
CONFIG_SPL_LOAD_FIT=y
@@ -22,7 +22,7 @@ CONFIG_SPL_LOAD_FIT=y
CONFIG_LEGACY_IMAGE_FORMAT=y
CONFIG_OF_BOARD_SETUP=y
CONFIG_OF_STDOUT_VIA_ALIAS=y
-CONFIG_DEFAULT_FDT_FILE="rockchip/rk3566-anbernic-rgxx3.dtb"

View file

@ -0,0 +1,99 @@
diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
index b44c0b63fe..9f30c3a6d0 100644
--- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
+++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
@@ -21,6 +21,7 @@
#include <pwm.h>
#include <stdlib.h>
#include <video_bridge.h>
+#include <i2c.h>
#define BOOT_BROM_DOWNLOAD 0xef08a53c
@@ -46,6 +47,7 @@
#define SARADC_POWER_CTRL BIT(3)
#define DTB_DIR ""
+#define RGB30R2_VDD_CPU_REGULATOR_ADDR 0x40
struct rg3xx_model {
const u16 adc_value;
@@ -68,6 +70,7 @@ enum rgxx3_device_id {
RG353PS,
RG353VS,
RGARCS,
+ RGB30R2,
};
static const struct rg3xx_model rg3xx_model_details[] = {
@@ -150,6 +153,13 @@ static const struct rg3xx_model rg3xx_model_details[] = {
.fdtfile = DTB_DIR "rk3566-anbernic-rg-arc-s.dtb",
.detect_panel = 0,
},
+ [RGB30R2] = {
+ .adc_value = 383, /* Gathered from second hand information */
+ .board = "rk3566-powkiddy-rgb30",
+ .board_name = "RGB30R2",
+ .fdtfile = DTB_DIR "rk3566-powkiddy-rgb30r2.dtb",
+ .detect_panel = 0,
+ },
};
struct rg353_panel {
@@ -398,6 +408,29 @@ int rgxx3_detect_display(void)
return 0;
}
+/*
+ * Detect vdd_cpu regulator, RGB30 has two revisions where this differs.
+ */
+int probe_rgb30r2_detect_vdd_cpu_regulator(void)
+{
+ struct udevice *bus, *dev;
+ int ret;
+
+ ret = uclass_get_device(UCLASS_I2C, 0, &bus);
+ if (ret) {
+ printf("i2c0 bus not found, regulator probe attempt failed.\n");
+ return ret;
+ }
+
+ ret = dm_i2c_probe(bus, RGB30R2_VDD_CPU_REGULATOR_ADDR, 0, &dev);
+ if (ret) {
+ printf("Regulator not found found\n");
+ return ret;
+ }
+
+ return 0;
+}
+
/* Detect which Anbernic RGXX3 device we are using so as to load the
* correct devicetree for Linux. Set an environment variable once
* found. The detection depends on the value of ADC channel 1, the
@@ -452,6 +485,10 @@ int rgxx3_detect_device(void)
}
}
+ if (board_id == RGB30 && probe_rgb30r2_detect_vdd_cpu_regulator() == 0) {
+ board_id = RGB30R2;
+ }
+
if (board_id < 0)
return board_id;
diff --git a/configs/anbernic-rgxx3-rk3566_defconfig b/configs/anbernic-rgxx3-rk3566_defconfig
index f26801f4eb..ff9a6bd81b 100644
--- a/configs/anbernic-rgxx3-rk3566_defconfig
+++ b/configs/anbernic-rgxx3-rk3566_defconfig
@@ -52,6 +52,11 @@ CONFIG_ARM_SMCCC_FEATURES=y
CONFIG_SCMI_FIRMWARE=y
CONFIG_ROCKCHIP_GPIO=y
CONFIG_SYS_I2C_ROCKCHIP=y
+CONFIG_DM=y
+CONFIG_DM_I2C=y
+CONFIG_DM_I2C_COMPAT=y
+CONFIG_SPL_I2C=y
+CONFIG_I2C0_ENABLE=y
CONFIG_MISC=y
CONFIG_SUPPORT_EMMC_RPMB=y
CONFIG_MMC_DW=y