drivers/lcd: Minor updates to FT80x initialization.
This commit is contained in:
parent
eb3663721e
commit
be73c65b64
2 changed files with 75 additions and 18 deletions
|
@ -78,12 +78,14 @@
|
|||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CHIPID 0x7c
|
||||
#define ROMID_MASK 0x0000ffff
|
||||
#if defined(CONFIG_LCD_FT800)
|
||||
# define DEVNAME "/dev/ft800"
|
||||
# define ROMID 0x01000800
|
||||
# define DEVNAME "/dev/ft800"
|
||||
# define ROMID 0x00000800
|
||||
#elif defined(CONFIG_LCD_FT801)
|
||||
# define DEVNAME "/dev/ft801"
|
||||
# define ROMID 0x01000801
|
||||
# define DEVNAME "/dev/ft801"
|
||||
# define ROMID 0x00000801
|
||||
#else
|
||||
# error No FT80x device configured
|
||||
#endif
|
||||
|
@ -800,6 +802,7 @@ static int ft80x_unlink(FAR struct inode *inode)
|
|||
|
||||
static int ft80x_initialize(FAR struct ft80x_dev_s *priv)
|
||||
{
|
||||
uint32_t timeout;
|
||||
uint8_t regval32;
|
||||
uint8_t regval8;
|
||||
|
||||
|
@ -874,23 +877,39 @@ static int ft80x_initialize(FAR struct ft80x_dev_s *priv)
|
|||
|
||||
/* 2. Send Host command CLKEXT to FT800
|
||||
* 3. Send Host command ACTIVE to enable clock to FT800.
|
||||
*
|
||||
* PLL output should default to 48MHz.
|
||||
*/
|
||||
|
||||
ft80x_host_command(priv, FT80X_CMD_CLKEXT);
|
||||
ft80x_host_command(priv, FT80X_CMD_ACTIVE);
|
||||
|
||||
/* Verify the chip ID */
|
||||
/* Verify the chip ID. Read repeatedly until FT80x is ready. */
|
||||
|
||||
regval32 = ft80x_read_word(priv, FT80X_REG_ID);
|
||||
if ((regval32 & ID_MASK) != 0x7c)
|
||||
timeout = 0;
|
||||
for (; ; )
|
||||
{
|
||||
lcderr("ERROR: Bad chip ID: %02x\n",
|
||||
(unsigned int)(regval32 & ID_MASK));
|
||||
return -ENODEV;
|
||||
/* Read the Chip ID */
|
||||
|
||||
regval8 = ft80x_read_byte(priv, FT80X_REG_ID);
|
||||
if (regval8 == CHIPID)
|
||||
{
|
||||
/* Chip ID verify so FT80x is ready */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* Initial Chip ID read may fail because the chip is not yet ready. */
|
||||
|
||||
if (++timeout > 100000)
|
||||
{
|
||||
lcderr("ERROR: Bad chip ID: %02x\n", regval8);
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
|
||||
regval32 = ft80x_read_word(priv, FT80X_ROM_CHIPID);
|
||||
if (regval32 != ROMID)
|
||||
if ((regval32 & ROMID_MASK) != ROMID)
|
||||
{
|
||||
lcderr("ERROR: Bad ROM chip ID: %08lx\n", (unsigned long)regval32);
|
||||
return -ENODEV;
|
||||
|
@ -907,8 +926,8 @@ static int ft80x_initialize(FAR struct ft80x_dev_s *priv)
|
|||
* b. Set the following registers with values for the chosen display.
|
||||
* Typical WQVGA and QVGA values are shown:
|
||||
*
|
||||
* Register Description WQVGA QVGA 320 x 240
|
||||
* 480x272 320x240
|
||||
* Register Description WQVGA QVGA
|
||||
* 480x272 320x240
|
||||
* FT80X_REG_PCLK_POL Pixel Clock Polarity 1 0
|
||||
* FT80X_REG_HSIZE Image width in pixels 480 320
|
||||
* FT80X_REG_HCYCLE Total number of clocks per line 548 408
|
||||
|
@ -958,7 +977,7 @@ static int ft80x_initialize(FAR struct ft80x_dev_s *priv)
|
|||
ft80x_write_hword(priv, FT80X_REG_VOFFSET, 13);
|
||||
ft80x_write_hword(priv, FT80X_REG_VSYNC0, 0);
|
||||
ft80x_write_hword(priv, FT80X_REG_VSYNC1, 2);
|
||||
ft80x_write_byte(priv, FT80X_REG_SWIZZLE, 0); /* REVISIT */
|
||||
ft80x_write_byte(priv, FT80X_REG_SWIZZLE, 2);
|
||||
ft80x_write_byte(priv, FT80X_REG_PCLK_POL, 0);
|
||||
ft80x_write_byte(priv, FT80X_REG_CSPREAD, 1);
|
||||
ft80x_write_hword(priv, FT80X_REG_HSIZE, 320);
|
||||
|
@ -998,19 +1017,42 @@ static int ft80x_initialize(FAR struct ft80x_dev_s *priv)
|
|||
|
||||
/* 8. Write FT80X_REG_PCLK, video output begins with the first display list */
|
||||
|
||||
#if defined(CONFIG_LCD_FT80X_WQVGA)
|
||||
ft80x_write_byte(priv, FT80X_REG_PCLK, 5);
|
||||
#elif defined(CONFIG_LCD_FT80X_QVGA)
|
||||
ft80x_write_byte(priv, FT80X_REG_PCLK, 8);
|
||||
#else
|
||||
# error Unknown display size
|
||||
#endif
|
||||
|
||||
/* 9. Use MCU SPI clock not more than 30MHz */
|
||||
|
||||
DEBUGASSERT(priv->lower->op_frequency <= 30000000);
|
||||
priv->frequency = priv->lower->op_frequency;
|
||||
|
||||
/* Configure touch threshold.
|
||||
* REVISIT: For FT800 set REG_TOUCH_RZTHRESH to 1200.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_LCD_FT800)
|
||||
/* Configure the REG_TOUCH_RZTHRESH the value 1200 may need to be tweaked
|
||||
* for your application.
|
||||
*/
|
||||
|
||||
ft80x_write_hword(priv, FT80X_REG_TOUCH_RZTHRESH, 1200);
|
||||
|
||||
#elif defined(CONFIG_LCD_FT801)
|
||||
# warning Missing logic
|
||||
#else
|
||||
# error No FT80x device configured
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
**************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_register
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/lcd/lcd_ioctl.h>
|
||||
|
@ -62,13 +63,23 @@
|
|||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration */
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifdef CONFIG_DISABLE_SIGNALS
|
||||
# error Signal support is required by this driver
|
||||
#endif
|
||||
|
||||
/* FT80x IOCTL commands:
|
||||
#if defined(CONFIG_LCD_FT80X_WQVGA)
|
||||
# define FT80X_DISPLAY_WIDTH 480
|
||||
# define FT80X_DISPLAY_HEIGHT 272
|
||||
#elif defined(CONFIG_LCD_FT80X_QVGA)
|
||||
# define FT80X_DISPLAY_WIDTH 320
|
||||
# define FT80X_DISPLAY_HEIGHT 240
|
||||
#else
|
||||
# error Unknown display size
|
||||
#endif
|
||||
|
||||
/* FT80x IOCTL commands *****************************************************
|
||||
*
|
||||
* FT80X_IOC_CREATEDL:
|
||||
* Description: Write a display list to the FT80x display list memory
|
||||
|
@ -144,6 +155,7 @@
|
|||
#define FT80X_IOC_GETTRACKER _LCDIOC(FT80X_NIOCTL_BASE + 3)
|
||||
#define FT80X_IOC_EVENTNOTIFY _LCDIOC(FT80X_NIOCTL_BASE + 4)
|
||||
|
||||
/* FT80x Display List Commands **********************************************/
|
||||
/* Host commands. 3 word commands. The first word begins with 0b01, the next two are zero */
|
||||
|
||||
#define FT80X_CMD_ACTIVE 0x00 /* Switch from Standby/Sleep modes to active mode */
|
||||
|
@ -466,6 +478,7 @@
|
|||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* FT80x Lower Half Interface Definitions ***********************************/
|
||||
/* Pins relevant to software control. The FT80X is a 48-pin part. Most of
|
||||
* the pins are associated with the TFT panel and other board-related
|
||||
* support. A few a relevant to software control of the part. Those are
|
||||
|
@ -524,6 +537,7 @@ struct ft80x_config_s
|
|||
#endif
|
||||
};
|
||||
|
||||
/* FT80x Display List Command Structures ************************************/
|
||||
/* This structure describes one generic display list command */
|
||||
|
||||
struct ft80x_dlcmd_s
|
||||
|
@ -1034,6 +1048,7 @@ struct ft80x_cmd_translate_s
|
|||
int32_t ty; /* 8: Y translate factor (b16) (input) */
|
||||
};
|
||||
|
||||
/* FT80x IOCTL Argument Structures ******************************************/
|
||||
/* This container structure is used by FT80X_IOC_CREATEDL and FT80X_IOC_APPENDDL. It
|
||||
* and defines the list of display commands to be written into display list memory.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue