From 633531cdbaa3ed70a364db78fd7f8ae11da3e394 Mon Sep 17 00:00:00 2001
From: Wang Huan <wanghuan@zch06.freescale.net>
Date: Wed, 14 Sep 2011 17:40:41 +0800
Subject: [PATCH] Fix LCD framebuffer driver data swap bug for MCF54418

This patch fixed LCD framebuffer driver data swap bug
for MCF54418.

Signed-off-by: Alison Wang <b18965@freescale.com>
---
 drivers/video/fsl-ssd1289-fb.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

--- a/drivers/video/fsl-ssd1289-fb.c
+++ b/drivers/video/fsl-ssd1289-fb.c
@@ -54,8 +54,10 @@ static int ssd1289_spi_writeblock(struct
 	for (i = 0; i < SPI_LCD_BLOCK_SIZE; i++) {
 		if (i % 2 == 0)
 			spi_block_buffer[i] = 0x01;
-		else if (flag == 1)
-			spi_block_buffer[i] = *(daddr + (i >> 1));
+		else if ((flag == 1) && (i % 4 == 1))
+			spi_block_buffer[i] = *(daddr + (i >> 1) + 1);
+		else if ((flag == 1) && (i % 4 == 3))
+			spi_block_buffer[i] = *(daddr + (i >> 1) - 1);
 		else if (flag == 0)
 			spi_block_buffer[i] = 0;
 	}
@@ -331,6 +333,9 @@ static int ssd1289fbd(void *arg)
 	int i;
 	unsigned short *buf_p;
 	struct fsl_ssd1289_fb_info *fbinfo = info->par;
+#if defined(CONFIG_SSD1289_FLEXBUS_MODE)
+	unsigned short tmp;
+#endif
 #if defined(CONFIG_SSD1289_SPI_MODE)
 	unsigned char *bufspi_p;
 	int count;
@@ -344,7 +349,9 @@ static int ssd1289fbd(void *arg)
 
 #if defined(CONFIG_SSD1289_FLEXBUS_MODE)
 			for (i = 0; i < info->screen_size; i += 2) {
-				ssd1289_write(info, *buf_p, 1);
+				tmp = ((((*buf_p) & 0x00ff) << 8) |
+						(((*buf_p) & 0xff00) >> 8));
+				ssd1289_write(info, tmp, 1);
 				buf_p++;
 			}
 #elif defined(CONFIG_SSD1289_SPI_MODE)
