From c8f3d1842a51e6321e4cf0ac93243873f3e6b522 Mon Sep 17 00:00:00 2001 From: Mason Huo Date: Fri, 7 Apr 2023 09:34:08 +0800 Subject: [PATCH] board: starfive: jh7110: Modify cpu voltage set commands Update the cpu voltage set commands per binning information from OTP. Signed-off-by: Mason Huo --- board/starfive/evb/starfive_evb.c | 18 ++++++----- .../visionfive2/starfive_visionfive2.c | 17 +++++++---- include/configs/starfive-evb.h | 30 ++++++++++++------- include/configs/starfive-visionfive2.h | 11 +++++-- 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/board/starfive/evb/starfive_evb.c b/board/starfive/evb/starfive_evb.c index dc02aad206..e2e1e9b8a7 100644 --- a/board/starfive/evb/starfive_evb.c +++ b/board/starfive/evb/starfive_evb.c @@ -27,12 +27,14 @@ enum chip_type_t { }; enum cpu_voltage_type_t { - CPU_VOL_1020 = 0x0e, - CPU_VOL_1040 = 0xff, - CPU_VOL_1060 = 0xf0, - CPU_VOL_1080 = 0xf1, - CPU_VOL_1100 = 0xf2, + CPU_VOL_1020 = 0xef0, + CPU_VOL_1040 = 0xfff, + CPU_VOL_1060 = 0xff0, + CPU_VOL_1080 = 0xfe0, + CPU_VOL_1100 = 0xf80, + CPU_VOL_1120 = 0xf00, }; +#define CPU_VOL_MASK 0xfff #define SYS_CLOCK_ENABLE(clk) \ setbits_le32(SYS_CRG_BASE + clk, CLK_ENABLE_MASK) @@ -212,8 +214,10 @@ static void get_cpu_voltage_type(struct udevice *dev) if (ret != sizeof(buf)) printf("%s: error reading CPU vol from OTP\n", __func__); else { - buf = 0x0e; - switch ((buf & 0xff)) { + switch ((buf & CPU_VOL_MASK)) { + case CPU_VOL_1120: + env_set("cpu_max_vol", "1120000"); + break; case CPU_VOL_1100: env_set("cpu_max_vol", "1100000"); break; diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c index e1fe6b2e46..080077007e 100644 --- a/board/starfive/visionfive2/starfive_visionfive2.c +++ b/board/starfive/visionfive2/starfive_visionfive2.c @@ -53,12 +53,14 @@ enum board_type_t { enum cpu_voltage_type_t { - CPU_VOL_1020 = 0x0e, - CPU_VOL_1040 = 0xff, - CPU_VOL_1060 = 0xf0, - CPU_VOL_1080 = 0xf1, - CPU_VOL_1100 = 0xf2, + CPU_VOL_1020 = 0xef0, + CPU_VOL_1040 = 0xfff, + CPU_VOL_1060 = 0xff0, + CPU_VOL_1080 = 0xfe0, + CPU_VOL_1100 = 0xf80, + CPU_VOL_1120 = 0xf00, }; +#define CPU_VOL_MASK 0xfff static void sys_reset_clear(ulong assert, ulong status, u32 rst) { @@ -311,7 +313,10 @@ static void get_cpu_voltage_type(struct udevice *dev) if (ret != sizeof(buf)) printf("%s: error reading CPU vol from OTP\n", __func__); else { - switch ((buf & 0xff)) { + switch ((buf & CPU_VOL_MASK)) { + case CPU_VOL_1120: + env_set("cpu_max_vol", "1120000"); + break; case CPU_VOL_1100: env_set("cpu_max_vol", "1100000"); break; diff --git a/include/configs/starfive-evb.h b/include/configs/starfive-evb.h index ffe90264f2..82d0e842b9 100644 --- a/include/configs/starfive-evb.h +++ b/include/configs/starfive-evb.h @@ -120,20 +120,27 @@ "cpu_vol_1100_set=" \ "fdt set /opp-table-0/opp-1500000000 opp-microvolt <1100000>;\0" +#define CPU_VOL_1120_SET \ + "cpu_vol_1120_set=" \ + "fdt set /opp-table-0/opp-1500000000 opp-microvolt <1120000>;\0" + #define CPU_VOL_SET \ - "cpu_vol_set=" \ - "if test ${cpu_max_vol} = 1100000; then " \ - "run cpu_vol_1100_set;" \ - "elif test ${cpu_max_vol} = 1080000; then " \ - "run cpu_vol_1080_set;" \ - "elif test ${cpu_max_vol} = 1060000; then " \ - "run cpu_vol_1060_set;" \ - "elif test ${cpu_max_vol} = 1020000; then " \ - "run cpu_vol_1020_set;" \ - "else " \ - "run cpu_vol_1040_set;" \ + "cpu_vol_set=" \ + "if test ${cpu_max_vol} = 1120000; then " \ + "run cpu_vol_1120_set;" \ + "elif test ${cpu_max_vol} = 1100000; then " \ + "run cpu_vol_1100_set;" \ + "elif test ${cpu_max_vol} = 1080000; then " \ + "run cpu_vol_1080_set;" \ + "elif test ${cpu_max_vol} = 1060000; then " \ + "run cpu_vol_1060_set;" \ + "elif test ${cpu_max_vol} = 1020000; then " \ + "run cpu_vol_1020_set;" \ + "else " \ + "run cpu_vol_1040_set;" \ "fi; \0" + #define CHIPA_GMAC_SET \ "chipa_gmac_set=" \ "fdt set /soc/ethernet@16030000/ethernet-phy@0 tx_inverted_10 <0x1>;" \ @@ -174,6 +181,7 @@ CPU_VOL_1060_SET \ CPU_VOL_1080_SET \ CPU_VOL_1100_SET \ + CPU_VOL_1120_SET \ CPU_VOL_SET \ "type_guid_gpt_loader1=" TYPE_GUID_LOADER1 "\0" \ "type_guid_gpt_loader2=" TYPE_GUID_LOADER2 "\0" \ diff --git a/include/configs/starfive-visionfive2.h b/include/configs/starfive-visionfive2.h index fafd1f9de6..405829faf5 100644 --- a/include/configs/starfive-visionfive2.h +++ b/include/configs/starfive-visionfive2.h @@ -118,9 +118,15 @@ "cpu_vol_1100_set=" \ "fdt set /opp-table-0/opp-1500000000 opp-microvolt <1100000>;\0" +#define CPU_VOL_1120_SET \ + "cpu_vol_1120_set=" \ + "fdt set /opp-table-0/opp-1500000000 opp-microvolt <1120000>;\0" + #define CPU_VOL_SET \ - "cpu_vol_set=" \ - "if test ${cpu_max_vol} = 1100000; then " \ + "cpu_vol_set=" \ + "if test ${cpu_max_vol} = 1120000; then " \ + "run cpu_vol_1120_set;" \ + "elif test ${cpu_max_vol} = 1100000; then " \ "run cpu_vol_1100_set;" \ "elif test ${cpu_max_vol} = 1080000; then " \ "run cpu_vol_1080_set;" \ @@ -273,6 +279,7 @@ CPU_VOL_1060_SET \ CPU_VOL_1080_SET \ CPU_VOL_1100_SET \ + CPU_VOL_1120_SET \ CPU_VOL_SET \ CHIPA_SET_FORCE \ VISIONFIVE2_MEM_SET \