Hardware: i.mx8m mini.
u-boot version: 2023.01+dfsg-2
I want to enable pwm to light up my leds in spl.c so that users can see the light on immediately after they power on the board.
I didn't find the interface to enable the IO as pwm functionality and now I can only set it as gpio. But you know for gpio only on/off, can not change to specific brightness.
So, is it possible to enbale pwm in spl? If yes, could give me some ideas or code examples?Thanks.
The following is the patch of my current changes and pin as gpio can be output high:
---
board/toradex/verdin-imx8mm/spl.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/board/toradex/verdin-imx8mm/spl.c b/board/toradex/verdin-imx8mm/spl.c
index 210665b..ba82269 100644
--- a/board/toradex/verdin-imx8mm/spl.c
+++ b/board/toradex/verdin-imx8mm/spl.c
@@ -26,6 +26,7 @@
#include <power/pca9450.h>
#include <power/pmic.h>
#include <spl.h>
+#include <asm/mach-imx/gpio.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -137,8 +138,27 @@ void board_init_f(ulong dummy)
power_init_board();
+ enable_status_light();
+
/* DDR initialization */
spl_dram_init();
board_init_r(NULL, 0);
}
+
+#define LED_PWM4 IMX_GPIO_NR(5,2)
+#define PWM_PAD_CTRL PAD_CTL_DSE6
+
+static iomux_v3_cfg_t const pwm_pads[] = {
+ IMX8MM_PAD_SAI3_MCLK_GPIO5_IO2 | MUX_PAD_CTRL(PWM_PAD_CTRL)
+};
+
+void enable_status_light(void)
+{
+ /* activate LED controller OE */
+ imx_iomux_v3_setup_multiple_pads(pwm_pads, ARRAY_SIZE(pwm_pads));
+
+ // LED green on
+ gpio_request(LED_PWM4, "PWM4");
+ gpio_direction_output(LED_PWM4, 1);
+}