diff options
author | Mason Huo <mason.huo@starfivetech.com> | 2023-02-28 12:59:06 +0300 |
---|---|---|
committer | Mason Huo <mason.huo@starfivetech.com> | 2023-02-28 13:56:09 +0300 |
commit | 8847bc69aafeadfa9cc1a9739c7f3f1d16629f11 (patch) | |
tree | 506353565566045e377272bfb5ee70280c6d9bbb /board | |
parent | 1ae835c25e3d8b7bc3c8981fb720f030c1892d57 (diff) | |
download | u-boot-8847bc69aafeadfa9cc1a9739c7f3f1d16629f11.tar.xz |
board: starfive: jh7110: Add cpu voltage set commands
Get the binning information from OTP,
and set change the cpu max voltage accordingly.
Signed-off-by: Mason Huo <mason.huo@starfivetech.com>
Diffstat (limited to 'board')
-rw-r--r--[-rwxr-xr-x] | board/starfive/visionfive2/starfive_visionfive2.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c index f3970f32c3..a2e6e5ec3e 100755..100644 --- a/board/starfive/visionfive2/starfive_visionfive2.c +++ b/board/starfive/visionfive2/starfive_visionfive2.c @@ -27,6 +27,8 @@ #define PCB_REVISION_B 0x0B #define CHIP_REVISION_SHIFT 80 +#define CPU_VOL_BINNING_OFFSET 0x7fc + enum { BOOT_FLASH = 0, BOOT_SD, @@ -46,6 +48,13 @@ enum board_type_t { BOARD_TYPE_MAX, }; + +enum cpu_voltage_type_t { + CPU_VOL_1040 = 0xff, + CPU_VOL_1060 = 0xf0, + CPU_VOL_1080 = 0xf1, +}; + static void sys_reset_clear(ulong assert, ulong status, u32 rst) { u32 value; @@ -287,6 +296,32 @@ static void jh7110_usb_init(bool usb2_enable) SYS_IOMUX_DOUT(25, 7); } +#if CONFIG_IS_ENABLED(STARFIVE_OTP) +static void get_cpu_voltage_type(struct udevice *dev) +{ + int ret; + u32 buf = CPU_VOL_1040; + + ret = misc_read(dev, CPU_VOL_BINNING_OFFSET, &buf, sizeof(buf)); + if (ret != sizeof(buf)) + printf("%s: error reading CPU vol from OTP\n", __func__); + else { + switch ((buf & 0xff)) { + case CPU_VOL_1080: + env_set("cpu_max_vol", "1080000"); + break; + case CPU_VOL_1060: + env_set("cpu_max_vol", "1060000"); + break; + case CPU_VOL_1040: + default: + env_set("cpu_max_vol", "1040000"); + break; + } + } +} +#endif + /*enable U74-mc hart1~hart4 prefetcher*/ static void enable_prefetcher(void) { @@ -452,6 +487,9 @@ err: get_chip_type(); set_uboot_fdt_addr_env(); +#if CONFIG_IS_ENABLED(STARFIVE_OTP) + get_cpu_voltage_type(dev); +#endif return 0; } #endif |