diff --git a/boards/arm/stm32h7/linum-stm32h753bi/include/board.h b/boards/arm/stm32h7/linum-stm32h753bi/include/board.h index 3430686f19..88d0e02457 100644 --- a/boards/arm/stm32h7/linum-stm32h753bi/include/board.h +++ b/boards/arm/stm32h7/linum-stm32h753bi/include/board.h @@ -548,6 +548,72 @@ #define GPIO_TIM5_CH1IN GPIO_TIM5_CH1IN_1 /* PA0 */ #define GPIO_TIM5_CH2IN GPIO_TIM5_CH2IN_2 /* PH11 */ +/* LTDC */ + +#define GPIO_LTDC_R0 (GPIO_LTDC_R0_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_R1 (GPIO_LTDC_R1_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_R2 (GPIO_LTDC_R2_4 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_R3 (GPIO_LTDC_R3_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_R4 (GPIO_LTDC_R4_4 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_R5 (GPIO_LTDC_R5_4 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_R6 (GPIO_LTDC_R6_4 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_R7 (GPIO_LTDC_R7_3 | GPIO_SPEED_100MHz) + +#define GPIO_LTDC_G0 (GPIO_LTDC_G0_2 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_G1 (GPIO_LTDC_G1_2 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_G2 (GPIO_LTDC_G2_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_G3 (GPIO_LTDC_G3_4 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_G4 (GPIO_LTDC_G4_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_G5 (GPIO_LTDC_G5_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_G6 (GPIO_LTDC_G6_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_G7 (GPIO_LTDC_G7_3 | GPIO_SPEED_100MHz) + +#define GPIO_LTDC_B0 (GPIO_LTDC_B0_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_B1 (GPIO_LTDC_B1_2 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_B2 (GPIO_LTDC_B2_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_B3 (GPIO_LTDC_B3_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_B4 (GPIO_LTDC_B4_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_B5 (GPIO_LTDC_B5_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_B6 (GPIO_LTDC_B6_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_B7 (GPIO_LTDC_B7_3 | GPIO_SPEED_100MHz) + +#define GPIO_LTDC_VSYNC (GPIO_LTDC_VSYNC_2 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_HSYNC (GPIO_LTDC_HSYNC_2 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_DE (GPIO_LTDC_DE_3 | GPIO_SPEED_100MHz) +#define GPIO_LTDC_CLK (GPIO_LTDC_CLK_3 | GPIO_SPEED_100MHz) + +/* LCD definitions **********************************************************/ + +#define BOARD_LTDC_WIDTH 1024 +#define BOARD_LTDC_HEIGHT 600 + +#define BOARD_LTDC_OUTPUT_BPP 16 +#define BOARD_LTDC_HFP 160 +#define BOARD_LTDC_HBP 160 +#define BOARD_LTDC_VFP 1 +#define BOARD_LTDC_VBP 23 +#define BOARD_LTDC_HSYNC 0 +#define BOARD_LTDC_VSYNC 0 + +#define BOARD_LTDC_PLLSAIN 192 +#define BOARD_LTDC_PLLSAIR 5 + +/* Pixel Clock Polarity */ + +#define BOARD_LTDC_GCR_PCPOL 0 /* !LTDC_GCR_PCPOL */ + +/* Data Enable Polarity */ + +#define BOARD_LTDC_GCR_DEPOL 0 /* !LTDC_GCR_DEPOL */ + +/* Vertical Sync Polarity */ + +#define BOARD_LTDC_GCR_VSPOL 0 /* !LTDC_GCR_VSPOL */ + +/* Horizontal Sync Polarity */ + +#define BOARD_LTDC_GCR_HSPOL 0 /* !LTDC_GCR_HSPOL */ + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h b/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h index 19942b0ca2..7331213401 100644 --- a/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h +++ b/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h @@ -118,6 +118,14 @@ #define LINUMSTM32H753BI_QETIMER 5 +/* LCD */ + +#define GPIO_LCD_DISP (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ + GPIO_OUTPUT_SET|GPIO_PORTI|GPIO_PIN7) + +#define GPIO_LCD_BL (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ + GPIO_OUTPUT_SET|GPIO_PORTH|GPIO_PIN6) + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c index c50094ca8e..1069085fd5 100644 --- a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c +++ b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c @@ -53,10 +53,38 @@ #include #endif +#ifdef CONFIG_VIDEO_FB +# include +#endif + +#include + /**************************************************************************** * Private Functions ****************************************************************************/ +static void convert_lcd_rgb565(void) +{ + /* Put LCD_{R0,R1,R2,G0,G1,B0,B1,B2} in low level */ + + stm32_configgpio(GPIO_LTDC_R0); + stm32_gpiowrite(GPIO_LTDC_R0, 0); + stm32_configgpio(GPIO_LTDC_R1); + stm32_gpiowrite(GPIO_LTDC_R1, 0); + stm32_configgpio(GPIO_LTDC_R2); + stm32_gpiowrite(GPIO_LTDC_R2, 0); + stm32_configgpio(GPIO_LTDC_G0); + stm32_gpiowrite(GPIO_LTDC_G0, 0); + stm32_configgpio(GPIO_LTDC_G1); + stm32_gpiowrite(GPIO_LTDC_G1, 0); + stm32_configgpio(GPIO_LTDC_B0); + stm32_gpiowrite(GPIO_LTDC_B0, 0); + stm32_configgpio(GPIO_LTDC_B1); + stm32_gpiowrite(GPIO_LTDC_B1, 0); + stm32_configgpio(GPIO_LTDC_B2); + stm32_gpiowrite(GPIO_LTDC_B2, 0); +} + /**************************************************************************** * Name: stm32_i2c_register * @@ -158,6 +186,20 @@ int stm32_bringup(void) } #endif /* CONFIG_FS_PROCFS */ + /* Put pin not used in RG565 to level zero */ + + convert_lcd_rgb565(); + +#ifdef CONFIG_VIDEO_FB + /* Initialize and register the framebuffer driver */ + + ret = fb_register(0, 0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret); + } +#endif + #ifdef CONFIG_USERLED /* Register the LED driver */ diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_lcd.c b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_lcd.c new file mode 100644 index 0000000000..326b5b4b06 --- /dev/null +++ b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_lcd.c @@ -0,0 +1,120 @@ +/**************************************************************************** + * boards/arm/stm32h7/linum-stm32h753bi/src/stm32_lcd.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include +#include + +#include "stm32_gpio.h" +#include "stm32_ltdc.h" + +#include "linum-stm32h753bi.h" + +#ifdef CONFIG_STM32H7_LTDC +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_fbinitialize + * + * Description: + * Initialize the framebuffer video hardware associated with the display. + * + * Input Parameters: + * display - In the case of hardware with multiple displays, this + * specifies the display. Normally this is zero. + * + * Returned Value: + * Zero is returned on success; a negated errno value is returned on any + * failure. + * + ****************************************************************************/ + +int up_fbinitialize(int display) +{ + /* Custom LCD display with RGB interface */ + + stm32_configgpio(GPIO_LCD_DISP); + stm32_configgpio(GPIO_LCD_BL); + + stm32_gpiowrite(GPIO_LCD_DISP, true); + stm32_gpiowrite(GPIO_LCD_BL, true); + + return stm32_ltdcinitialize(); +} + +/**************************************************************************** + * Name: up_fbgetvplane + * + * Description: + * Return a a reference to the framebuffer object for the specified video + * plane of the specified plane. + * Many OSDs support multiple planes of video. + * + * Input Parameters: + * display - In the case of hardware with multiple displays, this + * specifies the display. Normally this is zero. + * vplane - Identifies the plane being queried. + * + * Returned Value: + * A non-NULL pointer to the frame buffer access structure is returned on + * success; NULL is returned on any failure. + * + ****************************************************************************/ + +struct fb_vtable_s *up_fbgetvplane(int display, int vplane) +{ + return stm32_ltdcgetvplane(vplane); +} + +/**************************************************************************** + * Name: up_fbuninitialize + * + * Description: + * Uninitialize the framebuffer support for the specified display. + * + * Input Parameters: + * display - In the case of hardware with multiple displays, this + * specifies the display. Normally this is zero. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void up_fbuninitialize(int display) +{ + stm32_gpiowrite(GPIO_LCD_DISP, false); + stm32_gpiowrite(GPIO_LCD_BL, false); + + stm32_ltdcuninitialize(); +} +#endif /* CONFIG_STM32_LTDC */