uboot-sifiveu: add bootloader package for SiFive Ux40 boards
[openwrt/staging/nbd.git] / package / boot / uboot-sifiveu / patches / 0003-board-sifive-Set-LED-s-color-to-purple-in-the-U-boot.patch
1 From 7ead6d662a2f9d8498af6650ea38418c64b52048 Mon Sep 17 00:00:00 2001
2 From: Vincent Chen <vincent.chen@sifive.com>
3 Date: Mon, 24 Jan 2022 02:42:02 -0800
4 Subject: [PATCH 3/8] board: sifive: Set LED's color to purple in the U-boot
5 stage
6
7 Set LED's color to purple in the U-boot stage. Because there are still
8 some functions to be executed before board_early_init_f(), it means
9 the LED's is not changed to purple instantly when entering the U-boot
10 stage.
11 ---
12 board/sifive/unmatched/pwm.c | 7 +++++++
13 board/sifive/unmatched/unmatched.c | 6 ++++++
14 configs/sifive_unmatched_defconfig | 1 +
15 3 files changed, 14 insertions(+)
16
17 diff --git a/board/sifive/unmatched/pwm.c b/board/sifive/unmatched/pwm.c
18 index e1cc02310a..bd67672c22 100644
19 --- a/board/sifive/unmatched/pwm.c
20 +++ b/board/sifive/unmatched/pwm.c
21 @@ -36,6 +36,7 @@ void pwm_device_init(void)
22 struct pwm_sifive_regs *pwm0, *pwm1;
23 pwm0 = (struct pwm_sifive_regs *)PWM0_BASE;
24 pwm1 = (struct pwm_sifive_regs *)PWM1_BASE;
25 +#ifdef CONFIG_SPL_BUILD
26 writel(PWM_CMP_DISABLE_VAL, (void *)&pwm0->cmp0);
27 /* Set the 3-color PWM LEDs to yellow in SPL */
28 writel(PWM_CMP_ENABLE_VAL, (void *)&pwm0->cmp1);
29 @@ -54,4 +55,10 @@ void pwm_device_init(void)
30 writel(PWM_CMP_ENABLE_VAL, (void *)&pwm1->cmp2);
31 writel(PWM_CMP_ENABLE_VAL, (void *)&pwm1->cmp3);
32 writel(PWM_CFG_INIT, (void *)&pwm1->cfg);
33 +#else
34 + /* Set the 3-color PWM LEDs to purple in U-boot */
35 + writel(PWM_CMP_DISABLE_VAL, (void *)&pwm0->cmp1);
36 + writel(PWM_CMP_ENABLE_VAL, (void *)&pwm0->cmp2);
37 + writel(PWM_CMP_ENABLE_VAL, (void *)&pwm0->cmp3);
38 +#endif
39 }
40 diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
41 index 6295deeae2..30c082d001 100644
42 --- a/board/sifive/unmatched/unmatched.c
43 +++ b/board/sifive/unmatched/unmatched.c
44 @@ -22,6 +22,12 @@ void *board_fdt_blob_setup(int *err)
45 return (ulong *)&_end;
46 }
47
48 +int board_early_init_f(void)
49 +{
50 + pwm_device_init();
51 + return 0;
52 +}
53 +
54 int board_init(void)
55 {
56 /* enable all cache ways */
57 diff --git a/configs/sifive_unmatched_defconfig b/configs/sifive_unmatched_defconfig
58 index d400ed0b23..0758f8e90f 100644
59 --- a/configs/sifive_unmatched_defconfig
60 +++ b/configs/sifive_unmatched_defconfig
61 @@ -51,3 +51,4 @@ CONFIG_DM_SCSI=y
62 CONFIG_USB=y
63 CONFIG_USB_XHCI_HCD=y
64 CONFIG_USB_XHCI_PCI=y
65 +CONFIG_BOARD_EARLY_INIT_F=y
66 --
67 2.27.0
68