This commit fixes the PWM<A> that was previously used as a GPIO output
instead of a real PWM, it also reserve the framebuffer region to
preserve the splash screen while the OS is booting.

Signed-off-by: Thomas Bonnefille <[email protected]>
---
 board/toradex/colibri_imx7/colibri_imx7.c | 40 +++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/board/toradex/colibri_imx7/colibri_imx7.c 
b/board/toradex/colibri_imx7/colibri_imx7.c
index 69a8a18d3a7..b5d22337a04 100644
--- a/board/toradex/colibri_imx7/colibri_imx7.c
+++ b/board/toradex/colibri_imx7/colibri_imx7.c
@@ -7,6 +7,8 @@
 #include <env.h>
 #include <init.h>
 #include <net.h>
+#include <fdt_simplefb.h>
+#include <video.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/imx-regs.h>
@@ -29,6 +31,7 @@
 #include <netdev.h>
 #include <power/pmic.h>
 #include <power/rn5t567_pmic.h>
+#include <pwm.h>
 #include <usb.h>
 #include <usb/ehci-ci.h>
 #include "../common/tdx-common.h"
@@ -114,7 +117,7 @@ static iomux_v3_cfg_t const backlight_pads[] = {
        /* Backlight On */
        MX7D_PAD_SD1_WP__GPIO5_IO1 | MUX_PAD_CTRL(NO_PAD_CTRL),
        /* Backlight PWM<A> (multiplexed pin) */
-       MX7D_PAD_GPIO1_IO08__GPIO1_IO8   | MUX_PAD_CTRL(NO_PAD_CTRL),
+       MX7D_PAD_GPIO1_IO08__PWM1_OUT   | MUX_PAD_CTRL(NO_PAD_CTRL),
        MX7D_PAD_ECSPI2_MOSI__GPIO4_IO21 | MUX_PAD_CTRL(NO_PAD_CTRL),
 };
 
@@ -123,6 +126,8 @@ static iomux_v3_cfg_t const backlight_pads[] = {
 
 static int setup_lcd(void)
 {
+       int ret = 0;
+
        imx_iomux_v3_setup_multiple_pads(backlight_pads, 
ARRAY_SIZE(backlight_pads));
 
        /* Set BL_ON */
@@ -130,10 +135,14 @@ static int setup_lcd(void)
        gpio_direction_output(GPIO_BL_ON, 1);
 
        /* Set PWM<A> to full brightness (assuming inversed polarity) */
-       gpio_request(GPIO_PWM_A, "PWM<A>");
-       gpio_direction_output(GPIO_PWM_A, 0);
-
-       return 0;
+       enable_pwm_clk(1, 0);
+       ret = pwm_init(0, 0, 0);
+       if (ret)
+               return ret;
+       ret = pwm_config(0, 0, 6666666);
+       if (ret)
+               return ret;
+       ret = pwm_enable(0);
 }
 #endif
 
@@ -142,12 +151,11 @@ static int setup_lcd(void)
  */
 void board_preboot_os(void)
 {
-#ifdef CONFIG_VIDEO
-       gpio_direction_output(GPIO_PWM_A, 1);
-       gpio_direction_output(GPIO_BL_ON, 0);
-#endif
+       if (IS_ENABLED(CONFIG_VIDEO) && IS_ENABLED(CONFIG_VIDEO_REMOVE)) {
+               gpio_direction_output(GPIO_PWM_A, 1);
+               gpio_direction_output(GPIO_BL_ON, 0);
+       }
 }
-
 static void setup_iomux_uart(void)
 {
        imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
@@ -277,6 +285,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 {
 #if defined(CONFIG_IMX_BOOTAUX) && defined(CONFIG_ARCH_FIXUP_FDT_MEMORY)
        int up;
+       int ret = -1;
 
        up = arch_auxiliary_core_check_up(0);
        if (up) {
@@ -313,6 +322,17 @@ int ft_board_setup(void *blob, struct bd_info *bd)
        }
 #endif
 
+       if (IS_ENABLED(CONFIG_FDT_SIMPLEFB))
+               ret = fdt_simplefb_enable_and_mem_rsv(blob);
+
+       /* If simplefb is not enabled and video is active, then at least reserve
+        * the framebuffer region to preserve the splash screen while OS is 
booting
+        */
+       if (IS_ENABLED(CONFIG_VIDEO) && IS_ENABLED(CONFIG_OF_LIBFDT)) {
+               if (ret && video_is_active())
+                       return fdt_add_fb_mem_rsv(blob);
+       }
+
        return ft_common_board_setup(blob, bd);
 }
 #endif

-- 
2.52.0

Reply via email to