mirror of
https://github.com/revyos/th1520-vendor-uboot.git
synced 2026-07-20 15:08:09 +02:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac3b305def | ||
|
|
57fa274f6d | ||
|
|
c1a95ddefe | ||
|
|
93ff49d9f5 | ||
|
|
6278bac553 | ||
|
|
b5ee6e549a | ||
|
|
3d877f3648 | ||
|
|
68565d2855 | ||
|
|
72c738e9ce | ||
|
|
a46c283102 | ||
|
|
71bb3b069e | ||
|
|
8942b2dce6 |
33
.github/workflows/build.yml
vendored
33
.github/workflows/build.yml
vendored
@@ -111,48 +111,17 @@ jobs:
|
||||
make -j$(nproc)
|
||||
find . -name "u-boot-with-spl.bin" | xargs -I{} cp -av {} ${GITHUB_WORKSPACE}/output/u-boot-with-spl-meles-4g.bin
|
||||
|
||||
# mainline support
|
||||
make clean
|
||||
make light_lpi4a_defconfig
|
||||
sed -i 's#thead/light-lpi4a.dtb#thead/th1520-lichee-pi-4a.dtb#' .config
|
||||
make -j$(nproc)
|
||||
find . -name "u-boot-with-spl.bin" | xargs -I{} cp -av {} ${GITHUB_WORKSPACE}/output/u-boot-with-spl-lpi4a-main.bin
|
||||
|
||||
make clean
|
||||
make light_lpi4a_16g_defconfig
|
||||
sed -i 's#thead/light-lpi4a-16gb.dtb#thead/th1520-lichee-pi-4a-16g.dtb#' .config
|
||||
make -j$(nproc)
|
||||
find . -name "u-boot-with-spl.bin" | xargs -I{} cp -av {} ${GITHUB_WORKSPACE}/output/u-boot-with-spl-lpi4a-16g-main.bin
|
||||
|
||||
make clean
|
||||
make light_lpi4a_cluster_defconfig
|
||||
sed -i 's#thead/light-lpi4a-cluster.dtb#thead/th1520-lichee-cluster-4a.dtb#' .config
|
||||
make -j$(nproc)
|
||||
find . -name "u-boot-with-spl.bin" | xargs -I{} cp -av {} ${GITHUB_WORKSPACE}/output/u-boot-with-spl-lc4a-main.bin
|
||||
|
||||
make clean
|
||||
make light_lpi4a_cluster_16g_defconfig
|
||||
sed -i 's#thead/light-lpi4a-cluster-16gb.dtb#thead/th1520-lichee-cluster-4a-16g.dtb#' .config
|
||||
make -j$(nproc)
|
||||
find . -name "u-boot-with-spl.bin" | xargs -I{} cp -av {} ${GITHUB_WORKSPACE}/output/u-boot-with-spl-lc4a-16g-main.bin
|
||||
|
||||
# 8g emmc support
|
||||
sed -i 's/name=swap,size=4096MiB,type=swap/name=swap,size=2MiB,type=swap/' include/configs/light-c910.h
|
||||
make clean
|
||||
make light_lpi4a_defconfig
|
||||
make -j$(nproc)
|
||||
find . -name "u-boot-with-spl.bin" | xargs -I{} cp -av {} ${GITHUB_WORKSPACE}/output/u-boot-with-spl-lpi4a_8gemmc.bin
|
||||
|
||||
make clean
|
||||
make light_lpi4a_defconfig
|
||||
sed -i 's#thead/light-lpi4a.dtb#thead/th1520-lichee-pi-4a.dtb#' .config
|
||||
make -j$(nproc)
|
||||
find . -name "u-boot-with-spl.bin" | xargs -I{} cp -av {} ${GITHUB_WORKSPACE}/output/u-boot-with-spl-lpi4a-main_8gemmc.bin
|
||||
popd
|
||||
tree ${GITHUB_WORKSPACE}/output
|
||||
|
||||
- name: 'Upload Artifact'
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: thead-u-uboot-${{ matrix.name }}
|
||||
path: output/*.bin
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#size-cells = <2>;
|
||||
|
||||
config {
|
||||
select-gpio = <&gpio1_porta 16 0>;
|
||||
select-gpio = <&gpio1_porta 16 0>; // Enable the blue LED on Milk-V Meles
|
||||
fan-gpio = <&gpio2_porta 4 0>; // Enable the fan on Milk-V Meles, see schematic for details
|
||||
};
|
||||
|
||||
memory@0 {
|
||||
|
||||
@@ -110,7 +110,7 @@ void next_stage(void)
|
||||
bool has_reset_sample(ulong dtb_addr)
|
||||
{
|
||||
int node_offset;
|
||||
node_offset = fdt_path_offset(dtb_addr, "/soc/reset-sample");
|
||||
node_offset = fdt_path_offset((void *)dtb_addr, "/soc/reset-sample");
|
||||
if (node_offset < 0) {
|
||||
printf("## fdt has no reset_sample\n");
|
||||
return false;
|
||||
@@ -160,8 +160,8 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
|
||||
|
||||
announce_and_cleanup(fake);
|
||||
|
||||
_load_start = kernel;
|
||||
_dtb_addr = images->ft_addr;
|
||||
_load_start = (ulong)kernel;
|
||||
_dtb_addr = (ulong)(images->ft_addr);
|
||||
_dyn_info_addr = (ulong)&opensbi_info;
|
||||
if (!has_reset_sample(_dtb_addr)) {
|
||||
opensbi_info.magic = FW_DYNAMIC_INFO_MAGIC_VALUE;
|
||||
|
||||
@@ -244,7 +244,7 @@ int do_bootslave(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
static void light_c910_set_gpio_output_high(void)
|
||||
static void light_c910_set_gpio_output_high(const char* gpio_name)
|
||||
{
|
||||
ofnode node;
|
||||
struct gpio_desc select_gpio;
|
||||
@@ -257,9 +257,9 @@ static void light_c910_set_gpio_output_high(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (gpio_request_by_name_nodev(node, "select-gpio", 0,
|
||||
if (gpio_request_by_name_nodev(node, gpio_name, 0,
|
||||
&select_gpio, GPIOD_IS_OUT)) {
|
||||
printf("%s: could not find a /config/select-gpio\n", __func__);
|
||||
printf("%s: could not find a /config/%s\n", __func__, gpio_name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,7 +268,12 @@ static void light_c910_set_gpio_output_high(void)
|
||||
|
||||
int misc_init_r(void)
|
||||
{
|
||||
light_c910_set_gpio_output_high();
|
||||
// Enable blue LED
|
||||
light_c910_set_gpio_output_high("select-gpio");
|
||||
|
||||
// Enable fan on some boards(currently only on Meles)
|
||||
// For LPi4A, the fan is controlled by PWM, see lpi4a_fan_pwm_config() in light.c
|
||||
light_c910_set_gpio_output_high("fan-gpio");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2402,13 +2402,59 @@ static void light_iopin_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define PWM_BASE ((void *)0xffec01c000)
|
||||
#define PWM_CHAN_REG(chan, off) (PWM_BASE + (chan) * 0x20 + (off))
|
||||
#define PWM_PER_OFFSET 0x08 // Offset for Periodic Control Register
|
||||
#define PWM_FP_OFFSET 0x0C // Offset for First Phase Control Register
|
||||
#define PWM_CTRL_OFFSET 0x00 // Offset for Control Register
|
||||
// See T-HEAD TH1520 Peripheral Interface User Manual
|
||||
// https://dl.sipeed.com/shareURL/LICHEE/licheepi4a/09_Doc
|
||||
|
||||
static void light_pwm_config(void)
|
||||
{
|
||||
/* pwm0 */
|
||||
writel(0x4b0, (void *)0xFFEC01C008);
|
||||
writel(0x258, (void *)0xFFEC01C00c);
|
||||
writel(0x328, (void *)0xFFEC01C000);
|
||||
/*
|
||||
* Enable MIPI Display backlight on PWM0.
|
||||
* Period=1200 clock cycles, Duty Cycle=50%
|
||||
*/
|
||||
// Set PWM Period to 1200 clock cycles
|
||||
writel(0x4b0, PWM_CHAN_REG(0, PWM_PER_OFFSET));
|
||||
// Set PWM First Phase to 600 clock cycles
|
||||
writel(0x258, PWM_CHAN_REG(0, PWM_FP_OFFSET));
|
||||
// Configure PWM Control Register:
|
||||
// [9] INACTOUT = 1 (inactive output set to high)
|
||||
// [8] FPOUT = 1 (first phase output set to high)
|
||||
// [7:6] EVTRIG = 00 (event-triggered mode disabled)
|
||||
// [5:4] MODE = 10 (continuous mode)
|
||||
// [3] INTEN = 1 (interrupt enabled)
|
||||
// [2] CFG_UPDATE = 0 (do not wait for configuration update)
|
||||
// [1] SOFT_RST = 0 (software reset disabled)
|
||||
// [0] START = 0 (PWM start coding enable, rising edge effective)
|
||||
// Final address: 0xffec01c000 + 0x00 (channel 0) + 0x00 (control register offset) = 0xffec01c000
|
||||
writel(0b1100101000, PWM_CHAN_REG(0, PWM_CTRL_OFFSET));
|
||||
}
|
||||
|
||||
static void lpi4a_fan_pwm_config(void)
|
||||
{
|
||||
/*
|
||||
* Enable fan on PWM1(GPIO10) for Lichee Pi 4A.
|
||||
* See LPi4A Schematic:
|
||||
* https://dl.sipeed.com/shareURL/LICHEE/licheepi4a/02_Schematic
|
||||
*/
|
||||
// Set PWM Period to 1200 clock cycles
|
||||
writel(0x4b0, PWM_CHAN_REG(1, PWM_PER_OFFSET));
|
||||
// Set PWM First Phase to 600 clock cycles
|
||||
writel(0x258, PWM_CHAN_REG(1, PWM_FP_OFFSET));
|
||||
// Configure PWM Control Register:
|
||||
// [9] INACTOUT = 1 (inactive output set to high)
|
||||
// [8] FPOUT = 1 (first phase output set to high)
|
||||
// [7:6] EVTRIG = 00 (event-triggered mode disabled)
|
||||
// [5:4] MODE = 10 (continuous mode)
|
||||
// [3] INTEN = 0 (interrupt disabled)
|
||||
// [2] CFG_UPDATE = 0 (do not wait for configuration update)
|
||||
// [1] SOFT_RST = 0 (software reset disabled)
|
||||
// [0] START = 0 (PWM start coding enable, rising edge effective)
|
||||
// Final address: 0xffec01c000 + 0x20 (channel 1) + 0x00 (control register offset) = 0xffec01c020
|
||||
writel(0b1100100000, PWM_CHAN_REG(1, PWM_CTRL_OFFSET));
|
||||
}
|
||||
|
||||
int board_init(void)
|
||||
@@ -2425,6 +2471,9 @@ int board_init(void)
|
||||
|
||||
light_pwm_config();
|
||||
|
||||
#ifdef CONFIG_TARGET_LIGHT_FM_C910_LPI4A
|
||||
lpi4a_fan_pwm_config();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../include/common_lib.h"
|
||||
#include "../include/ddr_common_func.h"
|
||||
#include "../include/ddr_retention.h"
|
||||
#include "../include/pinmux.h"
|
||||
|
||||
DDR_SYSREG_REG_SW_REG_S ddr_sysreg;
|
||||
|
||||
@@ -48,7 +49,7 @@ int get_ddr_rank_number() {
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
DDR_DEBUG("unsupported ddr rank type!!!\n");
|
||||
#endif
|
||||
return NULL;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "../include/common_lib.h"
|
||||
#include "../include/ddr_common_func.h"
|
||||
#include "../include/ddr_retention.h"
|
||||
#include "../include/pinmux.h"
|
||||
|
||||
/*
|
||||
/// data structure to store register address, value pairs
|
||||
|
||||
@@ -338,37 +338,37 @@ int boundary_verify(unsigned long boundary) {
|
||||
phys_addr_t verify_addr4 = (phys_addr_t)boundary + CONFIG_SYS_SDRAM_BASE;
|
||||
|
||||
// verify data accessing result firstly
|
||||
writel(MAGIC_DATA2, verify_addr);
|
||||
writel(MAGIC_DATA2, (void *)verify_addr);
|
||||
invalidate_dcache_range(verify_addr, verify_addr + CONFIG_SYS_CACHELINE_SIZE);
|
||||
if (readl(verify_addr) != MAGIC_DATA2) {
|
||||
if (readl((void *)verify_addr) != MAGIC_DATA2) {
|
||||
printf("ddr rw test failed\n");
|
||||
return -1;
|
||||
}
|
||||
writel(MAGIC_DATA, verify_addr); // writing at beginning
|
||||
writel(MAGIC_DATA, (void *)verify_addr); // writing at beginning
|
||||
invalidate_dcache_range(verify_addr, verify_addr + CONFIG_SYS_CACHELINE_SIZE);
|
||||
if (readl(verify_addr) != MAGIC_DATA) {
|
||||
if (readl((void *)verify_addr) != MAGIC_DATA) {
|
||||
printf("ddr rw test failed\n");
|
||||
return -1;
|
||||
}
|
||||
writel(MAGIC_DATA2, verify_addr2); // writing at one-quarter addr
|
||||
writel(MAGIC_DATA3, verify_addr3); // writing at half addr
|
||||
writel(MAGIC_DATA2, (void *)verify_addr2); // writing at one-quarter addr
|
||||
writel(MAGIC_DATA3, (void *)verify_addr3); // writing at half addr
|
||||
invalidate_dcache_range(verify_addr, verify_addr + CONFIG_SYS_CACHELINE_SIZE);
|
||||
invalidate_dcache_range(verify_addr2, verify_addr2 + CONFIG_SYS_CACHELINE_SIZE);
|
||||
invalidate_dcache_range(verify_addr3, verify_addr3 + CONFIG_SYS_CACHELINE_SIZE);
|
||||
|
||||
if (boundary == (unsigned long)MAXIMAL_DDR_DENSITY_MB * UNIT_MB) { // boundary by design
|
||||
if ((readl(verify_addr) == MAGIC_DATA) &&
|
||||
(readl(verify_addr2) == MAGIC_DATA2) &&
|
||||
(readl(verify_addr3) == MAGIC_DATA3))
|
||||
if ((readl((void *)verify_addr) == MAGIC_DATA) &&
|
||||
(readl((void *)verify_addr2) == MAGIC_DATA2) &&
|
||||
(readl((void *)verify_addr3) == MAGIC_DATA3))
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
writel(MAGIC_DATA4, verify_addr4); // writing out of boundary
|
||||
writel(MAGIC_DATA4, (void *)verify_addr4); // writing out of boundary
|
||||
invalidate_dcache_range(verify_addr4, verify_addr4 + CONFIG_SYS_CACHELINE_SIZE);
|
||||
if ((readl(verify_addr) == MAGIC_DATA4) && // overwrite by verify_addr4
|
||||
(readl(verify_addr2) == MAGIC_DATA2) &&
|
||||
(readl(verify_addr3) == MAGIC_DATA3) &&
|
||||
(readl(verify_addr4) == MAGIC_DATA4))
|
||||
if ((readl((void *)verify_addr) == MAGIC_DATA4) && // overwrite by verify_addr4
|
||||
(readl((void *)verify_addr2) == MAGIC_DATA2) &&
|
||||
(readl((void *)verify_addr3) == MAGIC_DATA3) &&
|
||||
(readl((void *)verify_addr4) == MAGIC_DATA4))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ static int label_localboot(struct pxe_label *label)
|
||||
* Loads fdt overlays specified in 'fdtoverlays'.
|
||||
*/
|
||||
#ifdef CONFIG_OF_LIBFDT_OVERLAY
|
||||
static void label_boot_fdtoverlay(struct cmd_tbl *cmdtp, struct pxe_label *label)
|
||||
static void label_boot_fdtoverlay(cmd_tbl_t *cmdtp, struct pxe_label *label)
|
||||
{
|
||||
char *fdtoverlay = label->fdtoverlays;
|
||||
struct fdt_header *working_fdt;
|
||||
|
||||
@@ -13,7 +13,7 @@ CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/light-beagle.dtb"
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/th1520-beaglev-ahead.dtb"
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
|
||||
@@ -88,7 +88,7 @@ CONFIG_USB_FUNCTION_MASS_STORAGE=y
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/light-lpi4a-16gb.dtb"
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/th1520-lichee-pi-4a-16g.dtb"
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
|
||||
@@ -88,7 +88,7 @@ CONFIG_USB_FUNCTION_MASS_STORAGE=y
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/light-lpi4a-cluster-16gb.dtb"
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/th1520-lpi4a-cluster-16g.dtb"
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
|
||||
@@ -87,7 +87,7 @@ CONFIG_USB_FUNCTION_MASS_STORAGE=y
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/light-lpi4a-cluster.dtb"
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/th1520-lpi4a-cluster.dtb"
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
|
||||
@@ -88,7 +88,7 @@ CONFIG_USB_FUNCTION_MASS_STORAGE=y
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/light-lpi4a-console-16g.dtb"
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/th1520-lpi4a-console-16g.dtb"
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
|
||||
@@ -87,7 +87,7 @@ CONFIG_USB_FUNCTION_MASS_STORAGE=y
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/light-lpi4a-console.dtb"
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/th1520-lpi4a-console.dtb"
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
|
||||
@@ -90,7 +90,7 @@ CONFIG_USB_FUNCTION_MASS_STORAGE=y
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/light-lpi4a.dtb"
|
||||
CONFIG_DEFAULT_FDT_FILE="thead/th1520-lichee-pi-4a.dtb"
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
|
||||
@@ -145,6 +145,7 @@
|
||||
"dtb_addr=0x03800000\0" \
|
||||
"fdt_addr_r=0x03800000\0" \
|
||||
"fdtoverlay_addr_r=0x03700000\0" \
|
||||
"initrd_high=0x1a000000\0" \
|
||||
"kernel_addr_r=0x00200000\0" \
|
||||
"ramdisk_addr_r=0x06000000\0" \
|
||||
"boot_conf_addr_r=0xc0000000\0" \
|
||||
|
||||
Reference in New Issue
Block a user