From b33d7eb59f31dace2bd4b07908f68578f20bec25 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Dec 2017 12:53:33 -0600 Subject: [PATCH] arch/arm/src/lpc54xx: Add the ported LPC1788 LCD driver to use the LPC54xx pin definitions and SYSCON. --- arch/arm/src/lpc54xx/Kconfig | 15 ++++ arch/arm/src/lpc54xx/chip/lpc546x_pinmux.h | 70 +++++++-------- arch/arm/src/lpc54xx/chip/lpc54_syscon.h | 22 ++++- arch/arm/src/lpc54xx/lpc54_lcd.c | 99 ++++++++++++---------- configs/lpcxpresso-lpc54628/README.txt | 6 ++ 5 files changed, 131 insertions(+), 81 deletions(-) diff --git a/arch/arm/src/lpc54xx/Kconfig b/arch/arm/src/lpc54xx/Kconfig index 89af9ee0dc7..fac7a850083 100644 --- a/arch/arm/src/lpc54xx/Kconfig +++ b/arch/arm/src/lpc54xx/Kconfig @@ -640,6 +640,21 @@ config LPC54_LCD_VRAMBASE Base address of the video RAM frame buffer. The default is (LPC54_EXTDRAM_CS0 + 0x00010000) +config LPC54_LCD_USE_VD012 + bool "Use VD0, VD1, and VD2 pins" + default y + ---help--- + Some LCDs do not connect these pins. + +config LPC54_LCD_USE_CLKIN + bool "Use optional input clock" + default n + +config LPC54_LCD_CLKIN_FREQUENCY + int "Input clock frequency" + default 0 + depends on LPC54_LCD_USE_CLKIN + config LPC54_LCD_REFRESH_FREQ int "LCD refesh rate (Hz)" default 50 diff --git a/arch/arm/src/lpc54xx/chip/lpc546x_pinmux.h b/arch/arm/src/lpc54xx/chip/lpc546x_pinmux.h index 9985a8fa9dd..46f507929cb 100644 --- a/arch/arm/src/lpc54xx/chip/lpc546x_pinmux.h +++ b/arch/arm/src/lpc54xx/chip/lpc546x_pinmux.h @@ -584,41 +584,41 @@ /* LCD */ -#define GPIO_LCD_AC (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN15) -#define GPIO_LCD_CLKIN (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN17) -#define GPIO_LCD_DCLK (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN13) -#define GPIO_LCD_FP (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN14) -#define GPIO_LCD_LE (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN12) -#define GPIO_LCD_LP (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN16) -#define GPIO_LCD_PWR (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN11) -#define GPIO_LCD_VD0_1 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN18) -#define GPIO_LCD_VD0_2 (GPIO_ALT2 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN6) -#define GPIO_LCD_VD1_1 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN19) -#define GPIO_LCD_VD1_2 (GPIO_ALT2 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN7) -#define GPIO_LCD_VD2_1 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN20) -#define GPIO_LCD_VD2_2 (GPIO_ALT2 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN8) -#define GPIO_LCD_VD3_1 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN21) -#define GPIO_LCD_VD3_2 (GPIO_ALT2 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN9) -#define GPIO_LCD_VD4 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN22) -#define GPIO_LCD_VD5 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN23) -#define GPIO_LCD_VD6 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN24) -#define GPIO_LCD_VD7 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN25) -#define GPIO_LCD_VD8 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN26) -#define GPIO_LCD_VD9 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN27) -#define GPIO_LCD_VD10 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN28) -#define GPIO_LCD_VD11 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN29) -#define GPIO_LCD_VD12 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN30) -#define GPIO_LCD_VD13 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT2 | GPIO_PIN31) -#define GPIO_LCD_VD14 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN0) -#define GPIO_LCD_VD15 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN1) -#define GPIO_LCD_VD16 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN2) -#define GPIO_LCD_VD17 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN3) -#define GPIO_LCD_VD18 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN4) -#define GPIO_LCD_VD19 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN5) -#define GPIO_LCD_VD20 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN6) -#define GPIO_LCD_VD21 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN7) -#define GPIO_LCD_VD22 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN8) -#define GPIO_LCD_VD23 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_PORT3 | GPIO_PIN9) +#define GPIO_LCD_AC (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN15) +#define GPIO_LCD_CLKIN (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN17) +#define GPIO_LCD_DCLK (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN13) +#define GPIO_LCD_FP (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN14) +#define GPIO_LCD_LE (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN12) +#define GPIO_LCD_LP (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN16) +#define GPIO_LCD_PWR (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN11) +#define GPIO_LCD_VD0_1 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN18) +#define GPIO_LCD_VD0_2 (GPIO_ALT2 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN6) +#define GPIO_LCD_VD1_1 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN19) +#define GPIO_LCD_VD1_2 (GPIO_ALT2 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN7) +#define GPIO_LCD_VD2_1 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN20) +#define GPIO_LCD_VD2_2 (GPIO_ALT2 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN8) +#define GPIO_LCD_VD3_1 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN21) +#define GPIO_LCD_VD3_2 (GPIO_ALT2 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN9) +#define GPIO_LCD_VD4 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN22) +#define GPIO_LCD_VD5 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN23) +#define GPIO_LCD_VD6 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN24) +#define GPIO_LCD_VD7 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN25) +#define GPIO_LCD_VD8 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN26) +#define GPIO_LCD_VD9 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN27) +#define GPIO_LCD_VD10 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN28) +#define GPIO_LCD_VD11 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN29) +#define GPIO_LCD_VD12 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN30) +#define GPIO_LCD_VD13 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT2 | GPIO_PIN31) +#define GPIO_LCD_VD14 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN0) +#define GPIO_LCD_VD15 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN1) +#define GPIO_LCD_VD16 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN2) +#define GPIO_LCD_VD17 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN3) +#define GPIO_LCD_VD18 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN4) +#define GPIO_LCD_VD19 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN5) +#define GPIO_LCD_VD20 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN6) +#define GPIO_LCD_VD21 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN7) +#define GPIO_LCD_VD22 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN8) +#define GPIO_LCD_VD23 (GPIO_ALT1 | GPIO_MODE_DIGITAL | GPIO_FILTER_OFF | GPIO_PORT3 | GPIO_PIN9) /* MCLK */ diff --git a/arch/arm/src/lpc54xx/chip/lpc54_syscon.h b/arch/arm/src/lpc54xx/chip/lpc54_syscon.h index 0893f72131c..67e8bbc0f37 100644 --- a/arch/arm/src/lpc54xx/chip/lpc54_syscon.h +++ b/arch/arm/src/lpc54xx/chip/lpc54_syscon.h @@ -553,8 +553,16 @@ #define SYSCON_DMICCLKSEL_ /* SCTimer/PWM clock source select */ #define SYSCON_SCTCLKSEL_ + /* LCD clock source select */ -#define SYSCON_LCDCLKSEL_ + +#define SYSCON_LCDCLKSEL_SHIFT (0) /* Bits 0-1: LCD clock source select */ +#define SYSCON_LCDCLKSEL_MASK (3 << SYSCON_LCDCLKSEL_SHIFT) +# define SYSCON_LCDCLKSEL_MAINCLK (0 << SYSCON_LCDCLKSEL_SHIFT) /* Main clock (main_clk) */ +# define SYSCON_LCDCLKSEL_LCDCLKIN (1 << SYSCON_LCDCLKSEL_SHIFT) /* LCD external clock input (LCD_CLKIN) */ +# define SYSCON_LCDCLKSEL_FROHF (2 << SYSCON_LCDCLKSEL_SHIFT) /* FRO 96 or 48 MHz (fro_hf) */ +# define SYSCON_LCDCLKSEL_NONE (3 << SYSCON_LCDCLKSEL_SHIFT) /* None */ + /* SDIO clock source select */ #define SYSCON_SDIOCLKSEL_ @@ -610,8 +618,16 @@ #define SYSCON_DMICCLKDIV_ /* I2S MCLK clock divider */ #define SYSCON_MCLKDIV_ + /* LCD clock divider */ -#define SYSCON_LCDCLKDIV_ + +#define SYSCON_LCDCLKDIV_DIV_SHIFT (0) /* Bits 0-7: Clock divider value */ +#define SYSCON_LCDCLKDIV_DIV_MASK (0xff < 16 - lpc54_configgpio(GPIO_LCD_VD16); - lpc54_configgpio(GPIO_LCD_VD54); - lpc54_configgpio(GPIO_LCD_VD18); - lpc54_configgpio(GPIO_LCD_VD19); - lpc54_configgpio(GPIO_LCD_VD20); - lpc54_configgpio(GPIO_LCD_VD21); - lpc54_configgpio(GPIO_LCD_VD22); - lpc54_configgpio(GPIO_LCD_VD23); + lpc54_gpio_config(GPIO_LCD_VD16); + lpc54_gpio_config(GPIO_LCD_VD54); + lpc54_gpio_config(GPIO_LCD_VD18); + lpc54_gpio_config(GPIO_LCD_VD19); + lpc54_gpio_config(GPIO_LCD_VD20); + lpc54_gpio_config(GPIO_LCD_VD21); + lpc54_gpio_config(GPIO_LCD_VD22); + lpc54_gpio_config(GPIO_LCD_VD23); #endif /* Other pins */ - lpc54_configgpio(GPIO_LCD_DCLK); - lpc54_configgpio(GPIO_LCD_LP); - lpc54_configgpio(GPIO_LCD_FP); - lpc54_configgpio(GPIO_LCD_ENABM); - lpc54_configgpio(GPIO_LCD_PWR); + lpc54_gpio_config(GPIO_LCD_AC); /* STN AC bias drive or TFT data enable output */ + lpc54_gpio_config(GPIO_LCD_DCLK); /* LCD panel clock */ + lpc54_gpio_config(GPIO_LCD_FP); /* Frame pulse (STN). + * Vertical synchronization pulse (TFT) */ + lpc54_gpio_config(GPIO_LCD_LE); /* Line end signal */ + lpc54_gpio_config(GPIO_LCD_LP); /* Line synchronization pulse (STN). + * Horizontal synchronization pulse (TFT) */ + lpc54_gpio_config(GPIO_LCD_PWR); /* LCD panel power enable */ - /* Turn on LCD clock */ +#ifdef CONFIG_LPC54_LCD_USE_CLKIN + lpc54_gpio_config(GPIO_LCD_CLKIN); /* Optional clock input */ +#endif - modifyreg32(LPC54_SYSCON_PCONP, 0, SYSCON_PCONP_PCLCD); + /* Route Main clock (or LCK CLKIN) to LCD. */ + +#ifdef CONFIG_LPC54_LCD_USE_CLKIN + putreg32(SYSCON_LCDCLKSEL_LCDCLKIN, LPC54_SYSCON_LCDCLKSEL); +#else + putreg32(SYSCON_LCDCLKSEL_MAINCLK, LPC54_SYSCON_LCDCLKSEL); +#endif lcdinfo("Configuring the LCD controller\n"); @@ -544,10 +551,16 @@ int up_fbinitialize(int display) putreg32(0, LPC54_LCD_CTRL); - /* Initialize pixel clock (assuming clock source is the peripheral clock) */ + /* Initialize pixel clock */ - putreg32(((uint32_t)BOARD_PCLK_FREQUENCY / (uint32_t)LPC54_LCD_PIXEL_CLOCK)+1, - LPC54_SYSCON_LCDCFG); +#ifdef CONFIG_LPC54_LCD_USE_CLKIN + lcddiv = ((uint32_t)CONFIG_LPC54_LCD_CLKIN_FREQUENCY / + (uint32_t)LPC54_LCD_PIXEL_CLOCK) + 1 +#else + lcddiv = ((uint32_t)BOARD_MAIN_CLK / (uint32_t)LPC54_LCD_PIXEL_CLOCK) + 1 +#endif + putreg32(lcddiv, LPC54_SYSCON_LCDCLKDIV); + putreg32(lcddiv | SYSCON_LCDCLKDIV_REQFLAG, LPC54_SYSCON_LCDCLKDIV); /* Set the bits per pixel */ @@ -781,7 +794,7 @@ void up_fbuninitialize(int display) /* Turn off clocking to the LCD. modifyreg32() can do this atomically. */ - modifyreg32(LPC54_SYSCON_PCONP, SYSCON_PCONP_PCLCD, 0); + putreg32(SYSCON_LCDCLKSEL_NONE, LPC54_SYSCON_LCDCLKSEL); } /**************************************************************************** diff --git a/configs/lpcxpresso-lpc54628/README.txt b/configs/lpcxpresso-lpc54628/README.txt index d60488020d1..a7384524d29 100644 --- a/configs/lpcxpresso-lpc54628/README.txt +++ b/configs/lpcxpresso-lpc54628/README.txt @@ -34,6 +34,12 @@ STATUS but not reliable. Added framework for future I2C and SPI flexcomm drivers (mostly empty files for now) 2017-12-12: The SDRAM is now functional passes the commplete RAM test. + Included configurations and logic to add none, portions, or all of the + external SDRAM to the system heap. Brought in the LPC1788 LCD driver. + The LPC1788 LCD registers are identical to the LPC54xx (other than a + minor clock source setting). That port required modifications only + for differences in some SYSCON and pin-related settings. No testing + has yet been performed. Configurations ==============