boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c: Appease nxstyle

This commit is contained in:
YAMAMOTO Takashi 2020-11-26 12:15:36 +09:00 committed by Xiang Xiao
parent 56803db5e8
commit 5631b7f464

View File

@ -43,15 +43,17 @@
* 2. Orise Tech SPFD5408B * 2. Orise Tech SPFD5408B
* 3. RenesasSP R61580 * 3. RenesasSP R61580
* *
* The driver dynamically selects the LCD based on the reported LCD ID value. However, * The driver dynamically selects the LCD based on the reported LCD ID value.
* code size can be reduced by suppressing support for individual LCDs using: * However, code size can be reduced by suppressing support for individual
* LCDs using:
* *
* CONFIG_STM3210E_AM240320_DISABLE * CONFIG_STM3210E_AM240320_DISABLE
* CONFIG_STM3210E_SPFD5408B_DISABLE * CONFIG_STM3210E_SPFD5408B_DISABLE
* CONFIG_STM3210E_R61580_DISABLE * CONFIG_STM3210E_R61580_DISABLE
* *
* Omitting the above (or setting them to "n") enables support for the LCD. Setting * Omitting the above (or setting them to "n") enables support for the LCD.
* any of the above to "y" will disable support for the corresponding LCD. * Setting any of the above to "y" will disable support for the
* corresponding LCD.
*/ */
/**************************************************************************** /****************************************************************************
@ -83,7 +85,8 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration **********************************************************************/ /* Configuration ************************************************************/
/* Check contrast selection */ /* Check contrast selection */
#if !defined(CONFIG_LCD_MAXCONTRAST) #if !defined(CONFIG_LCD_MAXCONTRAST)
@ -159,7 +162,8 @@
#define SPFD5408B_RDSHIFT 5 #define SPFD5408B_RDSHIFT 5
/* Display/Color Properties ***********************************************************/ /* Display/Color Properties *************************************************/
/* Display Resolution */ /* Display Resolution */
#ifdef CONFIG_LCD_LANDSCAPE #ifdef CONFIG_LCD_LANDSCAPE
@ -175,7 +179,8 @@
#define STM3210E_BPP 16 #define STM3210E_BPP 16
#define STM3210E_COLORFMT FB_FMT_RGB16_565 #define STM3210E_COLORFMT FB_FMT_RGB16_565
/* STM3210E-EVAL LCD Hardware Definitions *********************************************/ /* STM3210E-EVAL LCD Hardware Definitions ***********************************/
/* LCD /CS is CE4, Bank 4 of NOR/SRAM Bank 1~4 */ /* LCD /CS is CE4, Bank 4 of NOR/SRAM Bank 1~4 */
#define STM3210E_LCDBASE ((uint32_t)(0x60000000 | 0x0c000000)) #define STM3210E_LCDBASE ((uint32_t)(0x60000000 | 0x0c000000))
@ -340,6 +345,7 @@ struct stm3210e_dev_s
/**************************************************************************** /****************************************************************************
* Private Function Protototypes * Private Function Protototypes
****************************************************************************/ ****************************************************************************/
/* Low Level LCD access */ /* Low Level LCD access */
static void stm3210e_writereg(uint8_t regaddr, uint16_t regval); static void stm3210e_writereg(uint8_t regaddr, uint16_t regval);
@ -356,17 +362,20 @@ static void stm3210e_setcursor(uint16_t col, uint16_t row);
/* LCD Data Transfer Methods */ /* LCD Data Transfer Methods */
static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, static int stm3210e_putrun(fb_coord_t row, fb_coord_t col,
size_t npixels); FAR const uint8_t *buffer,
static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, size_t npixels);
size_t npixels); static int stm3210e_getrun(fb_coord_t row, fb_coord_t col,
FAR uint8_t *buffer,
size_t npixels);
/* LCD Configuration */ /* LCD Configuration */
static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev, static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
FAR struct fb_videoinfo_s *vinfo); FAR struct fb_videoinfo_s *vinfo);
static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev,
FAR struct lcd_planeinfo_s *pinfo); unsigned int planeno,
FAR struct lcd_planeinfo_s *pinfo);
/* LCD RGB Mapping */ /* LCD RGB Mapping */
@ -385,7 +394,8 @@ static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno
static int stm3210e_getpower(struct lcd_dev_s *dev); static int stm3210e_getpower(struct lcd_dev_s *dev);
static int stm3210e_setpower(struct lcd_dev_s *dev, int power); static int stm3210e_setpower(struct lcd_dev_s *dev, int power);
static int stm3210e_getcontrast(struct lcd_dev_s *dev); static int stm3210e_getcontrast(struct lcd_dev_s *dev);
static int stm3210e_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); static int stm3210e_setcontrast(struct lcd_dev_s *dev,
unsigned int contrast);
/* LCD Power Management */ /* LCD Power Management */
@ -436,10 +446,10 @@ static const struct fb_videoinfo_s g_videoinfo =
static const struct lcd_planeinfo_s g_planeinfo = static const struct lcd_planeinfo_s g_planeinfo =
{ {
.putrun = stm3210e_putrun, /* Put a run into LCD memory */ .putrun = stm3210e_putrun, /* Put a run into LCD memory */
.getrun = stm3210e_getrun, /* Get a run from LCD memory */ .getrun = stm3210e_getrun, /* Get a run from LCD memory */
.buffer = (uint8_t*)g_runbuffer, /* Run scratch buffer */ .buffer = (uint8_t *)g_runbuffer, /* Run scratch buffer */
.bpp = STM3210E_BPP, /* Bits-per-pixel */ .bpp = STM3210E_BPP, /* Bits-per-pixel */
}; };
/* This is the standard, NuttX LCD driver object */ /* This is the standard, NuttX LCD driver object */
@ -454,6 +464,7 @@ static struct stm3210e_dev_s g_lcddev =
.getplaneinfo = stm3210e_getplaneinfo, .getplaneinfo = stm3210e_getplaneinfo,
/* LCD RGB Mapping -- Not supported */ /* LCD RGB Mapping -- Not supported */
/* Cursor Controls -- Not supported */ /* Cursor Controls -- Not supported */
/* LCD Specific Controls */ /* LCD Specific Controls */
@ -473,7 +484,6 @@ static struct pm_callback_s g_lcdcb =
}; };
#endif #endif
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -542,9 +552,9 @@ static inline void stm3210e_writegram(uint16_t rgbval)
* Name: stm3210e_readsetup / stm3210e_readnosetup * Name: stm3210e_readsetup / stm3210e_readnosetup
* *
* Description: * Description:
* Prime the operation by reading one pixel from the GRAM memory if necessary for * Prime the operation by reading one pixel from the GRAM memory if
* this LCD type. When reading 16-bit gram data, there may be some shifts in the * necessary for this LCD type. When reading 16-bit gram data, there may
* returned data: * be some shifts in the returned data:
* *
* - SPFD5408B: There appears to be a 5-bit shift in the returned data. * - SPFD5408B: There appears to be a 5-bit shift in the returned data.
* - R61580: There is a 16-bit (1 pixel) shift in the returned data. * - R61580: There is a 16-bit (1 pixel) shift in the returned data.
@ -575,8 +585,8 @@ static void stm3210e_readnosetup(FAR uint16_t *accum)
* Name: stm3210e_readshift / stm3210e_readnoshift * Name: stm3210e_readshift / stm3210e_readnoshift
* *
* Description: * Description:
* Read one correctly aligned pixel from the GRAM memory. Possibly shifting the * Read one correctly aligned pixel from the GRAM memory. Possibly
* data and possibly swapping red and green components. * shifting the data and possibly swapping red and green components.
* *
* - SPFD5408B: There appears to be a 5-bit shift in the returned data. * - SPFD5408B: There appears to be a 5-bit shift in the returned data.
* Red and green appear to be swapped on read-back as well * Red and green appear to be swapped on read-back as well
@ -586,8 +596,8 @@ static void stm3210e_readnosetup(FAR uint16_t *accum)
* *
****************************************************************************/ ****************************************************************************/
/* This version is used only for the SPFD5408B. It shifts the data by 5-bits and swaps /* This version is used only for the SPFD5408B. It shifts the data by
* red and green * 5-bits and swaps red and green
*/ */
#ifndef CONFIG_STM3210E_SPFD5408B_DISABLE #ifndef CONFIG_STM3210E_SPFD5408B_DISABLE
@ -601,7 +611,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
uint16_t next = LCD->value; uint16_t next = LCD->value;
/* Return previous bits 0-10 as bits 6-15 and next data bits 11-15 as bits 0-5 /* Return previous bits 0-10 as bits 6-15 and next data bits 11-15 as
* bits 0-5
* *
* xxxx xPPP PPPP PPPP * xxxx xPPP PPPP PPPP
* NNNN Nxxx xxxx xxxx * NNNN Nxxx xxxx xxxx
@ -609,7 +620,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
* Assuming that SPFD5408B_RDSHIFT == 5 * Assuming that SPFD5408B_RDSHIFT == 5
*/ */
uint16_t value = *accum << SPFD5408B_RDSHIFT | next >> (16-SPFD5408B_RDSHIFT); uint16_t value = *accum << SPFD5408B_RDSHIFT |
next >> (16 - SPFD5408B_RDSHIFT);
/* Save the value for the next time we are called */ /* Save the value for the next time we are called */
@ -617,9 +629,9 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
/* Tear the RGB655 apart. Swap read and green */ /* Tear the RGB655 apart. Swap read and green */
red = (value << (11-5)) & 0xf800; /* Move bits 5-9 to 11-15 */ red = (value << (11 - 5)) & 0xf800; /* Move bits 5-9 to 11-15 */
green = (value >> (10-5)) & 0x07e0; /* Move bits 10-15 to bits 5-10 */ green = (value >> (10 - 5)) & 0x07e0; /* Move bits 10-15 to bits 5-10 */
blue = value & 0x001f; /* Blue is in the right place */ blue = value & 0x001f; /* Blue is in the right place */
/* And put the RGB565 back together */ /* And put the RGB565 back together */
@ -627,7 +639,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
/* This is weird... If blue is zero, then red+green values are off by 0x20. /* This is weird... If blue is zero, then red+green values are off by 0x20.
* Except that both 0x0000 and 0x0020 can map to 0x0000. Need to revisit * Except that both 0x0000 and 0x0020 can map to 0x0000. Need to revisit
* this!!!!!!!!!!! I might be misinterpreting some of the data that I have. * this!!!!!!!!!!! I might be misinterpreting some of the data that I
* have.
*/ */
#if 0 /* REVISIT */ #if 0 /* REVISIT */
@ -641,8 +654,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
} }
#endif #endif
/* This version is used for the R61580 and for the AM240320. It neither shifts nor /* This version is used for the R61580 and for the AM240320. It neither
* swaps colors. * shifts nor swaps colors.
*/ */
#if !defined(CONFIG_STM3210E_R61580_DISABLE) || !defined(CONFIG_STM3210E_AM240320_DISABLE) #if !defined(CONFIG_STM3210E_R61580_DISABLE) || !defined(CONFIG_STM3210E_AM240320_DISABLE)
@ -658,8 +671,8 @@ static uint16_t stm3210e_readnoshift(FAR uint16_t *accum)
* Name: stm3210e_setcursor * Name: stm3210e_setcursor
* *
* Description: * Description:
* Set the cursor position. In landscape mode, the "column" is actually the physical * Set the cursor position. In landscape mode, the "column" is actually
* Y position and the "row" is the physical X position. * the physical Y position and the "row" is the physical X position.
* *
****************************************************************************/ ****************************************************************************/
@ -681,9 +694,11 @@ static void stm3210e_setcursor(uint16_t col, uint16_t row)
****************************************************************************/ ****************************************************************************/
#if 0 /* Sometimes useful */ #if 0 /* Sometimes useful */
static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels) static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run,
size_t npixels)
{ {
int i, j; int i;
int j;
syslog(LOG_DEBUG, "\n%s:\n", msg); syslog(LOG_DEBUG, "\n%s:\n", msg);
for (i = 0; i < npixels; i += 16) for (i = 0; i < npixels; i += 16)
@ -714,10 +729,11 @@ static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npix
* *
****************************************************************************/ ****************************************************************************/
static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, static int stm3210e_putrun(fb_coord_t row, fb_coord_t col,
size_t npixels) FAR const uint8_t *buffer,
size_t npixels)
{ {
FAR const uint16_t *src = (FAR const uint16_t*)buffer; FAR const uint16_t *src = (FAR const uint16_t *)buffer;
int i; int i;
/* Buffer must be provided and aligned to a 16-bit address boundary */ /* Buffer must be provided and aligned to a 16-bit address boundary */
@ -728,11 +744,11 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
/* Write the run to GRAM. */ /* Write the run to GRAM. */
#ifdef CONFIG_LCD_LANDSCAPE #ifdef CONFIG_LCD_LANDSCAPE
/* Convert coordinates -- Which edge of the display is the "top?" Here the edge /* Convert coordinates -- Which edge of the display is the "top?" Here the
* with the simplest conversion is used. * edge with the simplest conversion is used.
*/ */
col = (STM3210E_XRES-1) - col; col = (STM3210E_XRES - 1) - col;
/* Set the cursor position */ /* Set the cursor position */
@ -743,7 +759,9 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
stm3210e_gramselect(); stm3210e_gramselect();
for (i = 0; i < npixels; i++) for (i = 0; i < npixels; i++)
{ {
/* Write the next pixel to this position (auto-decrements to the next column) */ /* Write the next pixel to this position (auto-decrements to the next
* column)
*/
stm3210e_writegram(*src++); stm3210e_writegram(*src++);
} }
@ -769,8 +787,8 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
* Which edge of the display is the "top"? * Which edge of the display is the "top"?
*/ */
col = (STM3210E_XRES-1) - col; col = (STM3210E_XRES - 1) - col;
row = (STM3210E_YRES-1) - row; row = (STM3210E_YRES - 1) - row;
/* Then write the GRAM data, manually incrementing Y (which is col) */ /* Then write the GRAM data, manually incrementing Y (which is col) */
@ -787,6 +805,7 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
col--; col--;
} }
#endif #endif
return OK; return OK;
} }
@ -804,10 +823,11 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
* *
****************************************************************************/ ****************************************************************************/
static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, static int stm3210e_getrun(fb_coord_t row, fb_coord_t col,
size_t npixels) FAR uint8_t *buffer,
size_t npixels)
{ {
FAR uint16_t *dest = (FAR uint16_t*)buffer; FAR uint16_t *dest = (FAR uint16_t *)buffer;
void (*readsetup)(FAR uint16_t *accum); void (*readsetup)(FAR uint16_t *accum);
uint16_t (*readgram)(FAR uint16_t *accum); uint16_t (*readgram)(FAR uint16_t *accum);
uint16_t accum; uint16_t accum;
@ -850,11 +870,11 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
/* Read the run from GRAM. */ /* Read the run from GRAM. */
#ifdef CONFIG_LCD_LANDSCAPE #ifdef CONFIG_LCD_LANDSCAPE
/* Convert coordinates -- Which edge of the display is the "top?" Here the edge /* Convert coordinates -- Which edge of the display is the "top?" Here the
* with the simplest conversion is used. * edge with the simplest conversion is used.
*/ */
col = (STM3210E_XRES-1) - col; col = (STM3210E_XRES - 1) - col;
/* Set the cursor position */ /* Set the cursor position */
@ -870,7 +890,9 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
for (i = 0; i < npixels; i++) for (i = 0; i < npixels; i++)
{ {
/* Read the next pixel from this position (autoincrements to the next row) */ /* Read the next pixel from this position (autoincrements to the next
* row)
*/
*dest++ = readgram(&accum); *dest++ = readgram(&accum);
} }
@ -897,8 +919,8 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
* Which edge of the display is the "top"? * Which edge of the display is the "top"?
*/ */
col = (STM3210E_XRES-1) - col; col = (STM3210E_XRES - 1) - col;
row = (STM3210E_YRES-1) - row; row = (STM3210E_YRES - 1) - row;
/* Then write the GRAM data, manually incrementing Y (which is col) */ /* Then write the GRAM data, manually incrementing Y (which is col) */
@ -933,7 +955,8 @@ static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
{ {
DEBUGASSERT(dev && vinfo); DEBUGASSERT(dev && vinfo);
ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n", ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n",
g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes); g_videoinfo.fmt, g_videoinfo.xres,
g_videoinfo.yres, g_videoinfo.nplanes);
memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s)); memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s));
return OK; return OK;
} }
@ -946,8 +969,9 @@ static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
* *
****************************************************************************/ ****************************************************************************/
static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev,
FAR struct lcd_planeinfo_s *pinfo) unsigned int planeno,
FAR struct lcd_planeinfo_s *pinfo)
{ {
DEBUGASSERT(dev && pinfo && planeno == 0); DEBUGASSERT(dev && pinfo && planeno == 0);
ginfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp); ginfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp);
@ -959,8 +983,9 @@ static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno
* Name: stm3210e_getpower * Name: stm3210e_getpower
* *
* Description: * Description:
* Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER:
* backlit LCDs, this setting may correspond to the backlight setting. * full on). On backlit LCDs, this setting may correspond to the backlight
* setting.
* *
****************************************************************************/ ****************************************************************************/
@ -974,8 +999,9 @@ static int stm3210e_getpower(struct lcd_dev_s *dev)
* Name: stm3210e_poweroff * Name: stm3210e_poweroff
* *
* Description: * Description:
* Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER:
* backlit LCDs, this setting may correspond to the backlight setting. * full on). On backlit LCDs, this setting may correspond to the backlight
* setting.
* *
****************************************************************************/ ****************************************************************************/
@ -1011,8 +1037,9 @@ static int stm3210e_poweroff(void)
* Name: stm3210e_setpower * Name: stm3210e_setpower
* *
* Description: * Description:
* Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER:
* backlit LCDs, this setting may correspond to the backlight setting. * full on). On backlit LCDs, this setting may correspond to the backlight
* setting.
* *
****************************************************************************/ ****************************************************************************/
@ -1029,7 +1056,9 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
uint32_t frac; uint32_t frac;
uint32_t duty; uint32_t duty;
/* If we are coming up from the power off state, then re-configure the timer */ /* If we are coming up from the power off state, then re-configure
* the timer
*/
if (g_lcddev.power == 0) if (g_lcddev.power == 0)
{ {
@ -1065,7 +1094,9 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
#ifndef CONFIG_STM3210E_AM240320_DISABLE #ifndef CONFIG_STM3210E_AM240320_DISABLE
# if !defined (CONFIG_STM3210E_SPFD5408B_DISABLE) || !defined(CONFIG_STM3210E_R61580_DISABLE) # if !defined (CONFIG_STM3210E_SPFD5408B_DISABLE) || !defined(CONFIG_STM3210E_R61580_DISABLE)
stm3210e_writereg(LCD_REG_7, g_lcddev.type == LCD_TYPE_AM240320 ? 0x0173 : 0x0112); stm3210e_writereg(LCD_REG_7,
g_lcddev.type == LCD_TYPE_AM240320 ?
0x0173 : 0x0112);
# else # else
stm3210e_writereg(LCD_REG_7, 0x0173); stm3210e_writereg(LCD_REG_7, 0x0173);
# endif # endif
@ -1211,7 +1242,7 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb, int domain,
stm3210e_writereg(LCD_REG_24, 0xc0); /* CP1, CP2, CP3 turn off */ stm3210e_writereg(LCD_REG_24, 0xc0); /* CP1, CP2, CP3 turn off */
up_mdelay(10); /* wait 10 ms */ up_mdelay(10); /* wait 10 ms */
stm3210e_writereg(LCD_REG_24, 0x00); /* VR1 / VR2 off*/ stm3210e_writereg(LCD_REG_24, 0x00); /* VR1 / VR2 off */
stm3210e_writereg(LCD_REG_28, 0x30); /* Step up circuit operating current stop */ stm3210e_writereg(LCD_REG_28, 0x30); /* Step up circuit operating current stop */
up_mdelay(10); up_mdelay(10);
@ -1231,7 +1262,6 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb, int domain,
default: default:
{ {
/* Should not get here */ /* Should not get here */
} }
break; break;
} }
@ -1276,8 +1306,8 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb, int domain,
static int stm3210e_pm_prepare(struct pm_callback_s *cb, int domain, static int stm3210e_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate) enum pm_state_e pmstate)
{ {
/* No preparation to change power modes is required by the LCD driver. We always /* No preparation to change power modes is required by the LCD driver.
* accept the state change by returning OK. * We always accept the state change by returning OK.
*/ */
return OK; return OK;
@ -1296,8 +1326,8 @@ static inline void stm3210e_lcdinitialize(void)
{ {
uint16_t id; uint16_t id;
/* Check if the LCD is Orise Tech SPFD5408B Controller (or the compatible RenesasSP /* Check if the LCD is Orise Tech SPFD5408B Controller (or the compatible
* R61580). * RenesasSP R61580).
*/ */
id = stm3210e_readreg(LCD_REG_0); id = stm3210e_readreg(LCD_REG_0);
@ -1337,7 +1367,7 @@ static inline void stm3210e_lcdinitialize(void)
stm3210e_writereg(LCD_REG_17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */ stm3210e_writereg(LCD_REG_17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */
up_mdelay(50); up_mdelay(50);
stm3210e_writereg(LCD_REG_16, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ stm3210e_writereg(LCD_REG_16, 0x12b0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
up_mdelay(50); up_mdelay(50);
stm3210e_writereg(LCD_REG_18, 0x01bd); /* External reference voltage= Vci */ stm3210e_writereg(LCD_REG_18, 0x01bd); /* External reference voltage= Vci */
@ -1350,7 +1380,7 @@ static inline void stm3210e_lcdinitialize(void)
stm3210e_writereg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */ stm3210e_writereg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */
stm3210e_writereg(LCD_REG_33, 0x013f); /* GRAM Vertical Address */ stm3210e_writereg(LCD_REG_33, 0x013f); /* GRAM Vertical Address */
/* Adjust the Gamma Curve (SPFD5408B)*/ /* Adjust the Gamma Curve (SPFD5408B) */
stm3210e_writereg(LCD_REG_48, 0x0b0d); stm3210e_writereg(LCD_REG_48, 0x0b0d);
stm3210e_writereg(LCD_REG_49, 0x1923); stm3210e_writereg(LCD_REG_49, 0x1923);
@ -1577,7 +1607,7 @@ static inline void stm3210e_lcdinitialize(void)
#else #else
lcderr("ERROR: Unsupported LCD type\n"); lcderr("ERROR: Unsupported LCD type\n");
#endif #endif
} }
} }
/**************************************************************************** /****************************************************************************
@ -1604,7 +1634,8 @@ static void stm3210e_backlight(void)
/* Calculate the TIM1 prescaler value */ /* Calculate the TIM1 prescaler value */
prescaler = (STM32_PCLK2_FREQUENCY / CONFIG_STM3210E_LCD_PWMFREQUENCY + 65534) / 65535; prescaler = (STM32_PCLK2_FREQUENCY / CONFIG_STM3210E_LCD_PWMFREQUENCY +
65534) / 65535;
if (prescaler < 1) if (prescaler < 1)
{ {
prescaler = 1; prescaler = 1;
@ -1649,11 +1680,11 @@ static void stm3210e_backlight(void)
/* Set the Autoreload value */ /* Set the Autoreload value */
putreg16(reload-1, STM32_TIM1_ARR); putreg16(reload - 1, STM32_TIM1_ARR);
/* Set the Prescaler value */ /* Set the Prescaler value */
putreg16(prescaler-1, STM32_TIM1_PSC); putreg16(prescaler - 1, STM32_TIM1_PSC);
/* Generate an update event to reload the Prescaler value immediately */ /* Generate an update event to reload the Prescaler value immediately */
@ -1696,15 +1727,15 @@ static void stm3210e_backlight(void)
/* Select the output polarity level == LOW and enable */ /* Select the output polarity level == LOW and enable */
ccer |= (ATIM_CCER_CC1E ); ccer |= (ATIM_CCER_CC1E);
/* Reset the Output N Polarity level */ /* Reset the Output N Polarity level */
ccer &= ~(ATIM_CCER_CC1NP|ATIM_CCER_CC1NE); ccer &= ~(ATIM_CCER_CC1NP | ATIM_CCER_CC1NE);
/* Reset the Output Compare and Output Compare N IDLE State */ /* Reset the Output Compare and Output Compare N IDLE State */
cr2 &= ~(ATIM_CR2_OIS1|ATIM_CR2_OIS1N); cr2 &= ~(ATIM_CR2_OIS1 | ATIM_CR2_OIS1N);
/* Write the timer configuration */ /* Write the timer configuration */
@ -1754,9 +1785,9 @@ static void stm3210e_backlight(void)
* Name: board_lcd_initialize * Name: board_lcd_initialize
* *
* Description: * Description:
* Initialize the LCD video hardware. The initial state of the LCD is fully * Initialize the LCD video hardware. The initial state of the LCD is
* initialized, display memory cleared, and the LCD ready to use, but with the power * fully initialized, display memory cleared, and the LCD ready to use,
* setting at 0 (full off). * but with the power setting at 0 (full off).
* *
****************************************************************************/ ****************************************************************************/
@ -1801,8 +1832,8 @@ int board_lcd_initialize(void)
* Name: board_lcd_getdev * Name: board_lcd_getdev
* *
* Description: * Description:
* Return a a reference to the LCD object for the specified LCD. This allows support * Return a a reference to the LCD object for the specified LCD. This
* for multiple LCD devices. * allows support for multiple LCD devices.
* *
****************************************************************************/ ****************************************************************************/
@ -1830,10 +1861,11 @@ void board_lcd_uninitialize(void)
* Name: stm3210e_lcdclear * Name: stm3210e_lcdclear
* *
* Description: * Description:
* This is a non-standard LCD interface just for the STM3210E-EVAL board. Because * This is a non-standard LCD interface just for the STM3210E-EVAL board.
* of the various rotations, clearing the display in the normal way by writing a * Because of the various rotations, clearing the display in the normal
* sequences of runs that covers the entire display can be very slow. Here the * way by writing a sequences of runs that covers the entire display can
* display is cleared by simply setting all GRAM memory to the specified color. * be very slow. Here the display is cleared by simply setting all GRAM
* memory to the specified color.
* *
****************************************************************************/ ****************************************************************************/
@ -1841,7 +1873,7 @@ void stm3210e_lcdclear(uint16_t color)
{ {
uint32_t i = 0; uint32_t i = 0;
stm3210e_setcursor(0, STM3210E_XRES-1); stm3210e_setcursor(0, STM3210E_XRES - 1);
stm3210e_gramselect(); stm3210e_gramselect();
for (i = 0; i < STM3210E_XRES * STM3210E_YRES; i++) for (i = 0; i < STM3210E_XRES * STM3210E_YRES; i++)
{ {