ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/marvell/obm/Common/LCD/font.c b/marvell/obm/Common/LCD/font.c
new file mode 100644
index 0000000..5096987
--- /dev/null
+++ b/marvell/obm/Common/LCD/font.c
@@ -0,0 +1,107 @@
+#include "font.h"
+
+const unsigned char font_8x16_table [] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x08,0x00,0x08,0x18,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x34,0x24,0x24,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x16,0x24,0x7f,0x24,0x24,0x24,0x7e,0x24,0x24,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x08,0x3e,0x68,0x48,0x68,0x1c,0x16,0x12,0x12,0x7c,0x10,0x10,0x00,
+ 0x00,0x00,0x00,0x61,0xd2,0x96,0x74,0x08,0x10,0x16,0x29,0x49,0xc6,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x3c,0x64,0x64,0x38,0x72,0x4a,0xce,0x46,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x04,0x08,0x18,0x10,0x30,0x30,0x30,0x30,0x10,0x10,0x18,0x0c,0x04,
+ 0x00,0x00,0x00,0x20,0x10,0x08,0x08,0x0c,0x04,0x04,0x04,0x0c,0x08,0x18,0x10,0x20,
+ 0x00,0x00,0x00,0x08,0x0a,0x34,0x1c,0x6a,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x7f,0x18,0x18,0x18,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x08,0x30,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x06,0x04,0x0c,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x3c,0x66,0x42,0x47,0x5b,0x73,0x42,0x66,0x3c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x18,0x78,0x48,0x08,0x08,0x08,0x08,0x08,0x7e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x3c,0x46,0x06,0x06,0x04,0x08,0x10,0x20,0x7e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7c,0x06,0x06,0x04,0x3c,0x02,0x02,0x06,0x7c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x0c,0x1c,0x14,0x24,0x64,0x44,0xff,0x04,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7e,0x60,0x60,0x60,0x7e,0x02,0x02,0x06,0x7c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x1e,0x30,0x60,0x48,0x76,0x42,0x42,0x62,0x3c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7e,0x02,0x06,0x04,0x0c,0x08,0x18,0x10,0x30,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x3c,0x62,0x42,0x36,0x1c,0x66,0x42,0x42,0x3c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x3c,0x66,0x42,0x42,0x66,0x1a,0x02,0x04,0x78,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x08,0x30,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x18,0x30,0x60,0x10,0x0c,0x06,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x18,0x04,0x06,0x0c,0x10,0x20,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x30,0x1c,0x06,0x06,0x06,0x18,0x10,0x00,0x10,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0xdd,0xb5,0xa5,0xa5,0xaf,0x94,0xc0,0x40,0x3c,
+ 0x00,0x00,0x00,0x00,0x18,0x1c,0x34,0x24,0x26,0x62,0x7e,0x43,0xc1,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7c,0x46,0x42,0x46,0x7c,0x42,0x42,0x42,0x7c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x1e,0x20,0x40,0x40,0x40,0x40,0x40,0x60,0x3e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7c,0x46,0x42,0x43,0x43,0x43,0x42,0x46,0x78,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7e,0x60,0x60,0x60,0x7e,0x60,0x60,0x60,0x7e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7e,0x60,0x60,0x60,0x7e,0x60,0x60,0x60,0x60,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x1e,0x60,0x40,0x40,0xce,0x42,0x42,0x62,0x3e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x7e,0x42,0x42,0x42,0x42,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7c,0x04,0x04,0x04,0x04,0x04,0x04,0x44,0x78,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x42,0x44,0x48,0x50,0x70,0x58,0x4c,0x44,0x42,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x62,0x66,0x67,0x5f,0x5b,0x5b,0xc1,0xc1,0xc1,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x62,0x62,0x72,0x52,0x5a,0x4a,0x4e,0x46,0x46,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x3c,0x62,0x43,0xc3,0xc3,0xc3,0x43,0x62,0x3c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7c,0x46,0x42,0x42,0x46,0x78,0x40,0x40,0x40,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x3c,0x62,0x43,0xc3,0xc3,0xc3,0x43,0x62,0x3c,0x18,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x7c,0x66,0x62,0x66,0x7c,0x6c,0x64,0x66,0x62,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x3e,0x60,0x40,0x60,0x1c,0x06,0x02,0x02,0x7c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x62,0x3c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc1,0x43,0x42,0x62,0x26,0x24,0x34,0x1c,0x18,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc1,0xc1,0x41,0x49,0x5b,0x5b,0x76,0x66,0x66,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x43,0x66,0x34,0x18,0x18,0x1c,0x24,0x66,0xc3,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc1,0x42,0x66,0x34,0x1c,0x18,0x18,0x18,0x18,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7e,0x02,0x04,0x0c,0x18,0x10,0x20,0x60,0x7e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x1c,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1c,
+ 0x00,0x00,0x00,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x0c,0x04,0x06,0x02,0x00,0x00,
+ 0x00,0x00,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,
+ 0x00,0x00,0x00,0x00,0x18,0x1c,0x24,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0x00,0x00,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x06,0x02,0x3e,0x42,0x46,0x7a,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x40,0x40,0x5c,0x62,0x42,0x42,0x42,0x42,0x7c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x20,0x60,0x40,0x60,0x20,0x3e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x02,0x02,0x3e,0x62,0x42,0x42,0x42,0x66,0x3a,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x62,0x42,0x7e,0x40,0x60,0x3e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x0f,0x18,0x10,0x10,0x7e,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x66,0x42,0x66,0x58,0x40,0x3e,0x43,0x42,0x3c,
+ 0x00,0x00,0x00,0x40,0x40,0x40,0x5c,0x62,0x42,0x42,0x42,0x42,0x42,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x18,0x18,0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x7e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x04,0x0c,0x00,0x7c,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x0c,0x78,
+ 0x00,0x00,0x00,0x60,0x60,0x60,0x62,0x6c,0x78,0x70,0x68,0x64,0x62,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x7e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x4b,0x4b,0x4b,0x4b,0x4b,0x4b,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x62,0x42,0x42,0x42,0x42,0x42,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x62,0x42,0x43,0x42,0x62,0x3c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x62,0x42,0x42,0x42,0x42,0x7c,0x40,0x40,0x40,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x62,0x42,0x42,0x42,0x66,0x3a,0x02,0x02,0x02,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x72,0x63,0x60,0x60,0x60,0x60,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x20,0x20,0x3c,0x06,0x02,0x7c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x10,0x10,0xfe,0x10,0x10,0x10,0x10,0x10,0x1e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x66,0x3a,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x42,0x66,0x24,0x34,0x18,0x18,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xc1,0xc1,0x5b,0x5a,0x5e,0x66,0x66,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x26,0x1c,0x18,0x1c,0x26,0x62,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x42,0x66,0x24,0x34,0x1c,0x18,0x18,0x30,0xe0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x06,0x0c,0x18,0x10,0x20,0x7e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x0e,0x18,0x10,0x10,0x10,0x30,0x70,0x10,0x10,0x10,0x10,0x18,0x0e,
+ 0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x00,0x00,0x00,0x30,0x18,0x08,0x08,0x08,0x0c,0x0e,0x08,0x08,0x08,0x08,0x18,0x30,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x71,0x4b,0x06,0x00,0x00,0x00,0x00,0x00,
+};
+
+FONT Font8x16 = {
+ font_8x16_table,
+ 8, /* Width */
+ 16, /* Height */
+};
+
+static FONT *LCD_Currentfonts = &Font8x16;
diff --git a/marvell/obm/Common/LCD/font.h b/marvell/obm/Common/LCD/font.h
new file mode 100644
index 0000000..068457a
--- /dev/null
+++ b/marvell/obm/Common/LCD/font.h
@@ -0,0 +1,11 @@
+#ifndef __FONT_H__
+#define __FONT_H__
+
+typedef struct
+{
+ const unsigned char *table;
+ unsigned short width;
+ unsigned short height;
+} FONT;
+
+#endif
diff --git a/marvell/obm/Common/LCD/hal.c b/marvell/obm/Common/LCD/hal.c
new file mode 100644
index 0000000..ebafed5
--- /dev/null
+++ b/marvell/obm/Common/LCD/hal.c
@@ -0,0 +1,39 @@
+#include "hal.h"
+#include "PlatformCommon.h"
+
+CS_REGISTER_PAIR_S lcd_key_pins[] =
+{
+ (int *) (APPS_PAD_BASE | 0x00d8), 0xA001, 0x0, // GPIO126, LCD BL
+#ifndef CONFIG_SPI_LCD_3WIRE
+ (int *) (APPS_PAD_BASE | 0x0134), 0x1000, 0x0, // GPIO22, LCD RS
+#endif
+ (int *) (APPS_PAD_BASE | 0x013c), 0x1000, 0x0, // GPIO24, LCD RESET
+ /* spi */
+ (int *) (APPS_PAD_BASE | 0x0160), 0x1001, 0x0, // GPIO33, SPI SCL
+ (int *) (APPS_PAD_BASE | 0x0164), 0x1001, 0x0, // GPIO34, SPI CS
+ (int *) (APPS_PAD_BASE | 0x016c), 0x1001, 0x0, // GPIO36, SPI TX
+
+ 0x0,0x0,0x0 // termination
+};
+
+void gpio_direction_output(int gpio, int value)
+{
+
+ const unsigned int offset[] = {0, 4, 8, 0x100};
+ unsigned int gpio_base;
+ int bank = GPIO_TO_REG(gpio);
+
+ gpio_base = GPIO0_BASE + offset[bank];
+ *(VUINT_T *)(gpio_base + GPIO_SDR) |= GPIO_TO_BIT(gpio);
+ if (value)
+ *(VUINT_T *)(gpio_base + GPIO_PSR) |= GPIO_TO_BIT(gpio);
+ else
+ *(VUINT_T *)(gpio_base + GPIO_PCR) |= GPIO_TO_BIT(gpio);
+}
+
+void asr_lcd_init(void)
+{
+ ConfigRegWrite(lcd_key_pins);
+ SPI_Clk_Init();
+ spi_lcd_init();
+}
diff --git a/marvell/obm/Common/LCD/hal.h b/marvell/obm/Common/LCD/hal.h
new file mode 100644
index 0000000..47ea917
--- /dev/null
+++ b/marvell/obm/Common/LCD/hal.h
@@ -0,0 +1,18 @@
+#ifndef __HAL_H__
+#define __HAL_H__
+#include "spi.h"
+
+#define CONFIG_SPI_LCD_XRES 128
+#define CONFIG_SPI_LCD_YRES 128
+
+#define CONFIG_SPI_LCD_3WIRE
+
+#define CONFIG_SPI_LCD_BL_PIN 126
+#define CONFIG_SPI_LCD_RS_PIN 22
+#define CONFIG_SPI_LCD_RST_PIN 24
+
+#define GPIO_TO_REG(gp) (gp >> 5)
+#define GPIO_TO_BIT(gp) (1 << (gp % 32))
+#define GPIO_VAL(gp, val) ((val >> (gp % 32)) & 0x01)
+
+#endif
diff --git a/marvell/obm/Common/LCD/lcd.c b/marvell/obm/Common/LCD/lcd.c
new file mode 100644
index 0000000..7517c5c
--- /dev/null
+++ b/marvell/obm/Common/LCD/lcd.c
@@ -0,0 +1,290 @@
+#include "lcd.h"
+#include "st7735.c"
+#include "font.c"
+#include "hal.h"
+
+#define NULL 0
+#define printf obm_printf
+#define mdelay(x) Delay((x) * 1000)
+
+#ifdef CONFIG_SPI_LCD_3WIRE
+#define FB_SIZE (CONFIG_SPI_LCD_XRES * CONFIG_SPI_LCD_YRES * 2 * 2)
+#else
+#define FB_SIZE (CONFIG_SPI_LCD_XRES * CONFIG_SPI_LCD_YRES * 2)
+#endif
+
+static unsigned char *gFramebuffer = NULL;
+
+static inline void LCD_SELECT_DATA_OR_CMD(int a)
+{
+#ifndef CONFIG_SPI_LCD_3WIRE
+ gpio_direction_output(CONFIG_SPI_LCD_RS_PIN, a);
+#endif
+}
+
+void LCD_SEND_DATA(void)
+{
+ LCD_SELECT_DATA_OR_CMD(1);
+}
+
+void LCD_SEND_CMD(void)
+{
+ LCD_SELECT_DATA_OR_CMD(0);
+}
+
+void lcd_power(int on)
+{
+#ifdef CONFIG_SPI_LCD_POWER_PIN
+ gpio_direction_output(CONFIG_SPI_LCD_POWER_PIN, on);
+#endif
+}
+
+void lcd_reset(void)
+{
+ gpio_direction_output(CONFIG_SPI_LCD_RST_PIN, 1);
+ mdelay(50);
+ gpio_direction_output(CONFIG_SPI_LCD_RST_PIN, 0);
+ mdelay(50);
+ gpio_direction_output(CONFIG_SPI_LCD_RST_PIN, 1);
+ mdelay(150);
+}
+
+static void lcd_set_backlight(int on)
+{
+ gpio_direction_output(CONFIG_SPI_LCD_BL_PIN, on);
+}
+
+static void lcd_spi_write(unsigned int data)
+{
+ Assert_CS();
+ SPI_FireUp();
+ SPI_WriteData(data);
+ SPI_WaitSSPComplete();
+ SPI_DisableSSP();
+ Deassert_CS();
+}
+
+static int lcd_write_cmd(unsigned char cmd)
+{
+ int ret = 0;
+ unsigned short bits, _data;
+#ifdef CONFIG_SPI_LCD_3WIRE
+ bits = 9;
+ _data = cmd;
+#else
+ bits = 8;
+ _data = cmd;
+ LCD_SEND_CMD();
+#endif
+ SPI_ConfigDSS(bits);
+ lcd_spi_write(_data);
+
+ return ret;
+}
+
+static int lcd_write_data(unsigned char data)
+{
+ int ret = 0;
+ unsigned short bits, _data;
+#ifdef CONFIG_SPI_LCD_3WIRE
+ bits = 9;
+ _data = 0x100 | data;
+#else
+ bits = 8;
+ _data = data;
+ LCD_SEND_DATA();
+#endif
+ SPI_ConfigDSS(bits);
+ lcd_spi_write(_data);
+ return ret;
+}
+
+static int lcd_write_data16(unsigned short data)
+{
+ int ret = 0;
+ unsigned int bits, _data;
+#ifdef CONFIG_SPI_LCD_3WIRE
+ unsigned char h, l;
+ bits = 18;
+ h = (data >> 8) & 0xff;
+ l = data & 0xff;
+ _data = ((0x100 | h) << 9) | (0x100 | l);
+#else
+ bits = 16;
+ _data = data;
+ LCD_SEND_DATA();
+#endif
+ SPI_ConfigDSS(bits);
+ lcd_spi_write(_data);
+ return ret;
+}
+
+static int lcd_set_window(unsigned char xs, unsigned char ys, unsigned char xe, unsigned char ye)
+{
+ lcd_write_cmd(0x2a); // column addr set
+ lcd_write_data(0x00);
+ lcd_write_data(xs + 2);
+ lcd_write_data(0x00);
+ lcd_write_data(xe + 2);
+ lcd_write_cmd(0x2b); // row addr set
+ lcd_write_data(0x00);
+ lcd_write_data(ys + 3);
+ lcd_write_data(0x00);
+ lcd_write_data(ye + 3);
+ return 0;
+}
+
+static int lcd_write_memory(unsigned char *buf, int cnt)
+{
+ int i;
+ lcd_write_cmd(0x2c); // memory write command
+
+ for (i = 0; i < cnt; i++)
+ lcd_write_data(buf[i]);
+
+ return 0;
+}
+
+static int lcd_fill(unsigned short color)
+{
+ unsigned char x, y, low, high;
+ unsigned short *buf = (unsigned short *)gFramebuffer;
+ memset(buf, 0, FB_SIZE);
+
+ lcd_set_window(0, 0, CONFIG_SPI_LCD_XRES - 1, CONFIG_SPI_LCD_YRES - 1);
+ for (x=0; x < CONFIG_SPI_LCD_XRES; x++)
+ for (y=0; y < CONFIG_SPI_LCD_YRES; y++) {
+ low = color & 0xff;
+ high = (color & 0xff00) >> 8;
+#ifdef CONFIG_SPI_LCD_3WIRE
+ *(buf++) = low;
+ *(buf++) = high;
+#else
+ *(buf++) = (low << 8) | high;
+#endif
+ }
+
+ return lcd_write_memory(gFramebuffer, FB_SIZE);
+}
+
+static int lcd_draw_logo(
+ unsigned char p_x, unsigned char line,
+ unsigned char W, unsigned char H,
+ unsigned char *buf, unsigned short txt_color, unsigned short bg_color)
+{
+ int i, j, k;
+ unsigned char c;
+ int index, size;
+ unsigned short *buff = (unsigned short *)gFramebuffer;
+
+ lcd_set_window(line, p_x, (line + H - 1), (p_x + W - 1));
+
+ index = 0;
+ for(i = 0; i < W; i++) {
+ for(k = (H / 8 -1); k >= 0; k--) {
+ c = *buf++;
+ for(j = (8 - 1); j >= 0; j--) {
+ if((1 << (7 - j)) & c)
+ *(buff++) = txt_color;
+ else
+ *(buff++) = bg_color;
+ index++;
+ }
+ }
+ }
+
+ size = index;
+ return lcd_write_memory(gFramebuffer, size * 2);
+}
+
+static void panel_init(void *sequence)
+{
+ struct lcd_cmd *array = (struct lcd_cmd *)sequence;
+ if (!array) {
+ printf("Warning: null init sequence.\n");
+ return;
+ }
+
+ while (array->type != CMD_TYPE_END) {
+ switch (array->type) {
+ case CMD_TYPE_START:
+ break;
+ case CMD_TYPE_CMD:
+ lcd_write_cmd(array->data);
+ break;
+ case CMD_TYPE_DATA:
+ lcd_write_data(array->data);
+ break;
+ case CMD_TYPE_DELAY:
+ mdelay(array->data);
+ break;
+ }
+ array++;
+ }
+
+ printf("Panel: init done.\r\n");
+}
+
+int spi_lcd_init(void)
+{
+ int ret;
+
+ gFramebuffer = malloc(FB_SIZE);
+ lcd_reset();
+
+ panel_init(st7735_init_sequence);
+
+ lcd_fill(0); // 0: Black, 0xF800: Red, 0x7E0: Green, 0x1F: Blue
+ lcd_set_backlight(1);
+
+ return 0;
+}
+
+void lcd_display_char(unsigned char x, unsigned char y, const char c)
+{
+ int i, j, len;
+ unsigned short pos;
+ unsigned char *font;
+
+ pos = c - ' ';
+
+ /* font length */
+ len = (LCD_Currentfonts->width * LCD_Currentfonts->height) / 8;
+
+ font = (unsigned char *)&LCD_Currentfonts->table[pos * len];
+
+ lcd_set_window (x, y, x + LCD_Currentfonts->width - 1, y + LCD_Currentfonts->height - 1);
+ lcd_write_cmd(0x2c);
+
+ for (i = 0; i < len; i++) {
+ for (j = 0; j < 8; j++) {
+ if (font[i] & (0x80 >> j))
+ lcd_write_data16(0xffff);
+ else
+ lcd_write_data16(0);
+ }
+ }
+}
+
+void lcd_display_string(unsigned short x, unsigned short y, char *str)
+{
+ unsigned short x0, y0;
+ x0 = x;
+ y0 = y;
+
+ while (*str) {
+ if (x > CONFIG_SPI_LCD_XRES) {
+ x = x0;
+ y += LCD_Currentfonts->height;
+ }
+
+ if (y > CONFIG_SPI_LCD_YRES) {
+ x = x0;
+ y = y0;
+ }
+
+ lcd_display_char(x, y, *str);
+ str++;
+ x += LCD_Currentfonts->width;
+ }
+}
diff --git a/marvell/obm/Common/LCD/lcd.h b/marvell/obm/Common/LCD/lcd.h
new file mode 100644
index 0000000..7db8b4e
--- /dev/null
+++ b/marvell/obm/Common/LCD/lcd.h
@@ -0,0 +1,32 @@
+#ifndef __LCD_H__
+#define __LCD_H__
+
+enum {
+ PANEL_ST7735 = 1,
+ PANEL_GC9102,
+ PANEL_GC9106,
+};
+
+enum {
+ CMD_TYPE_START,
+ CMD_TYPE_END,
+ CMD_TYPE_CMD,
+ CMD_TYPE_DATA,
+ CMD_TYPE_DELAY,
+};
+
+struct lcd_cmd {
+ unsigned char type;
+ unsigned short data;
+};
+
+unsigned char lcd_gettype(void);
+void LCD_SEND_DATA(void);
+void LCD_SEND_CMD(void);
+
+void lcd_power(int on);
+int spi_lcd_init(void);
+
+extern void lcd_readid_pin_config(void);
+extern void lcd_readid_pin_restore(void);
+#endif
diff --git a/marvell/obm/Common/LCD/st7735.c b/marvell/obm/Common/LCD/st7735.c
new file mode 100644
index 0000000..94f9f6f
--- /dev/null
+++ b/marvell/obm/Common/LCD/st7735.c
@@ -0,0 +1,89 @@
+static struct lcd_cmd st7735_init_sequence[] = {
+ {CMD_TYPE_START, 0x00},
+ {CMD_TYPE_CMD, 0x11},
+ {CMD_TYPE_DELAY, 300},
+ {CMD_TYPE_CMD, 0xb1},
+ {CMD_TYPE_DATA, 0x02},
+ {CMD_TYPE_DATA, 0x35},
+ {CMD_TYPE_DATA, 0x36},
+ {CMD_TYPE_CMD, 0xb2},
+ {CMD_TYPE_DATA, 0x02},
+ {CMD_TYPE_DATA, 0x35},
+ {CMD_TYPE_DATA, 0x36},
+ {CMD_TYPE_CMD, 0xb3},
+ {CMD_TYPE_DATA, 0x02},
+ {CMD_TYPE_DATA, 0x35},
+ {CMD_TYPE_DATA, 0x36},
+ {CMD_TYPE_DATA, 0x02},
+ {CMD_TYPE_DATA, 0x35},
+ {CMD_TYPE_DATA, 0x36},
+ {CMD_TYPE_CMD, 0xb4},
+ {CMD_TYPE_DATA, 0x00},
+ {CMD_TYPE_CMD, 0xc0},
+ {CMD_TYPE_DATA, 0xa2},
+ {CMD_TYPE_DATA, 0x02},
+ {CMD_TYPE_DATA, 0x84},
+ {CMD_TYPE_CMD, 0xc1},
+ {CMD_TYPE_DATA, 0xc5},
+ {CMD_TYPE_CMD, 0xc2},
+ {CMD_TYPE_DATA, 0x0d},
+ {CMD_TYPE_DATA, 0x00},
+ {CMD_TYPE_CMD, 0xc3},
+ {CMD_TYPE_DATA, 0x8a},
+ {CMD_TYPE_DATA, 0x2a},
+ {CMD_TYPE_CMD, 0xc4},
+ {CMD_TYPE_DATA, 0x8d},
+ {CMD_TYPE_DATA, 0xee},
+ {CMD_TYPE_CMD, 0xc5},
+ {CMD_TYPE_DATA, 0x12},
+ {CMD_TYPE_CMD, 0x36},
+ {CMD_TYPE_DATA, 0xc8},
+ {CMD_TYPE_CMD, 0x3a},
+ {CMD_TYPE_DATA, 0x05},
+ {CMD_TYPE_CMD, 0x2a},
+ {CMD_TYPE_DATA, 0x00},
+ {CMD_TYPE_DATA, 0x02},
+ {CMD_TYPE_DATA, 0x00},
+ {CMD_TYPE_DATA, 0x81},
+ {CMD_TYPE_CMD, 0x2b},
+ {CMD_TYPE_DATA, 0x00},
+ {CMD_TYPE_DATA, 0x03},
+ {CMD_TYPE_DATA, 0x00},
+ {CMD_TYPE_DATA, 0xa2},
+ {CMD_TYPE_CMD, 0xe0},
+ {CMD_TYPE_DATA, 0x12},
+ {CMD_TYPE_DATA, 0x1c},
+ {CMD_TYPE_DATA, 0x10},
+ {CMD_TYPE_DATA, 0x18},
+ {CMD_TYPE_DATA, 0x33},
+ {CMD_TYPE_DATA, 0x2c},
+ {CMD_TYPE_DATA, 0x25},
+ {CMD_TYPE_DATA, 0x28},
+ {CMD_TYPE_DATA, 0x28},
+ {CMD_TYPE_DATA, 0x27},
+ {CMD_TYPE_DATA, 0x2f},
+ {CMD_TYPE_DATA, 0x3c},
+ {CMD_TYPE_DATA, 0x00},
+ {CMD_TYPE_DATA, 0x03},
+ {CMD_TYPE_DATA, 0x03},
+ {CMD_TYPE_DATA, 0x10},
+ {CMD_TYPE_CMD, 0xe1},
+ {CMD_TYPE_DATA, 0x12},
+ {CMD_TYPE_DATA, 0x1c},
+ {CMD_TYPE_DATA, 0x10},
+ {CMD_TYPE_DATA, 0x18},
+ {CMD_TYPE_DATA, 0x2d},
+ {CMD_TYPE_DATA, 0x28},
+ {CMD_TYPE_DATA, 0x23},
+ {CMD_TYPE_DATA, 0x28},
+ {CMD_TYPE_DATA, 0x28},
+ {CMD_TYPE_DATA, 0x26},
+ {CMD_TYPE_DATA, 0x2f},
+ {CMD_TYPE_DATA, 0x3b},
+ {CMD_TYPE_DATA, 0x00},
+ {CMD_TYPE_DATA, 0x03},
+ {CMD_TYPE_DATA, 0x03},
+ {CMD_TYPE_DATA, 0x10},
+ {CMD_TYPE_CMD, 0x29},
+ {CMD_TYPE_END, 0x00},
+};
\ No newline at end of file