/****************************************************************************
 *  
 * Project: U-Boot support for the LPC22xx and LPC24xx boards from Olimex
 *
 * Copyright: Ivan Vasilev, Olimex Ltd. All rights reserved.
 * 
 * File: $File lpc2478stk.h $
 * Description: Initialize the LPC2478 LCD controller and display a picture
 * Developer: Ivan Vasilev, <ivan at l123.org>
 *
 * This code is provided under the terms of the "beer-ware" license. You may do
 * whatever you like with it and if we meet some day, you may buy me a beer in
 * return.
 *
 ****************************************************************************/

#define	LCD_BASE	0xffe10000

#define	LCD_POL_PCD_HI	27
#define	LCD_POL_BCD	26
#define	LCD_POL_CPL	16
#define	LCD_POL_IOE	14
#define	LCD_POL_IPC	13
#define	LCD_POL_IHS	12
#define	LCD_POL_IVS	11
#define	LCD_POL_ACB	6
#define	LCD_POL_CLKSEL	5
#define	LCD_POL_PCD_LO	0

#define	LCD_LE_LEE	16
#define	LCD_LE_LED	0

#define	LCD_CTRL_WATERMARK	16
#define	LCD_CTRL_LCDVCOMP	12
#define	LCD_CTRL_LCDPWR		11
#define	LCD_CTRL_BEPO		10
#define	LCD_CTRL_BEBO		9
#define	LCD_CTRL_BGR		8
#define	LCD_CTRL_LCDDUAL	7
#define	LCD_CTRL_LCDMONO8	6
#define	LCD_CTRL_LCDTFT		5
#define	LCD_CTRL_LCDBW		4
#define	LCD_CTRL_LCDBPP		1
#define	LCD_CTRL_LCDEN		0

#define	LCD_INTMSK_BERIM	4
#define	LCD_INTMSK_VCOMPIM	3
#define	LCD_INTMSK_LNBUIM	2
#define	LCD_INTMSK_FUFIM	1

#define	LCD_INTRAW_BERRAW	4
#define	LCD_INTRAW_VCOMPRIS	3
#define	LCD_INTRAW_LNBURIS	2
#define	LCD_INTRAW_FUFRIS	1

#define	LCD_INTSTAT_BERMIS	4
#define	LCD_INTSTAT_VCOMPMIS	3
#define	LCD_INTSTAT_LNBUMIS	2
#define	LCD_INTSTAT_FUFMIS	1

#define	LCD_INTCLR_BERIC	4
#define	LCD_INTCLR_VCOMPIC	3
#define	LCD_INTCLR_LNBUIC	2
#define	LCD_INTCLR_FUFIC	1

#define	PANEL_X_SIZE	320
#define	PANEL_Y_SIZE	240

enum _COLOR_MODE
{
	COLOR_MODE_1BPP,
	COLOR_MODE_2BPP,
	COLOR_MODE_4BPP,
	COLOR_MODE_8BPP,
	COLOR_MODE_16BPP,
	COLOR_MODE_24BPP,
	COLOR_MODE_16BPP_565,
	COLOR_MODE_12BPP_444
};
typedef enum _COLOR_MODE COLOR_MODE;

typedef struct _LCD_INIT_STRUCTURE
{
	unsigned short	xsize;
	unsigned char	horiz_front_porch;
	unsigned char	horiz_back_porch;
	unsigned char	horiz_sync_pulse;
	unsigned short	ysize;
	unsigned char	vert_front_porch;
	unsigned char	vert_back_porch;
	unsigned char	vert_sync_pulse;
	COLOR_MODE	color_mode;
	unsigned char	hclk_divider;
	unsigned int	framebuffer;
} LCD_INIT_STRUCTURE;

/* function prototypes */
void lpc24xx_InitLCD(LCD_INIT_STRUCTURE *lcd);
void lpc24xx_EnableLCD(void);
