From 2721f3e78705b209e65dc76c19da2db74bf290a5 Mon Sep 17 00:00:00 2001
From: Valentin Longchamp <valentin.longchamp@epfl.ch>
Date: Mon, 16 Feb 2009 12:47:55 +0100
Subject: [PATCH] mx31moboard: LCD support for the devboard

Example usage of the LCD device through the ipu_dma for a mx31-based
platform.

v2: exit function now returns void

v3: definition of ipu_dma for mx31moboard now included in this patch as
suggested by Sascha

v4: do not use init/exit functions for setting up the iomuxer

Signed-off-by: Valentin Longchamp <valentin.longchamp@epfl.ch>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-mx3/mx31moboard-devboard.c |   48 ++++++++++++++++++++++++++++-
 arch/arm/mach-mx3/mx31moboard.c          |    8 +++++
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mx3/mx31moboard-devboard.c b/arch/arm/mach-mx3/mx31moboard-devboard.c
index d080b4a..7834dc8 100644
--- a/arch/arm/mach-mx3/mx31moboard-devboard.c
+++ b/arch/arm/mach-mx3/mx31moboard-devboard.c
@@ -25,6 +25,7 @@
 #include <mach/common.h>
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx3.h>
+#include <mach/mx3fb.h>
 
 #include "devices.h"
 
@@ -32,9 +33,48 @@ static struct imxuart_platform_data uart_pdata = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
 
-static int mxc_uart1_pins[] = {
+static int mx31moboard_devboard_pins[] = {
 	MX31_PIN_CTS2__CTS2, MX31_PIN_RTS2__RTS2,
 	MX31_PIN_TXD2__TXD2, MX31_PIN_RXD2__RXD2,
+	MX31_PIN_LD0__LD0, MX31_PIN_LD1__LD1, MX31_PIN_LD2__LD2,
+	MX31_PIN_LD3__LD3, MX31_PIN_LD4__LD4, MX31_PIN_LD5__LD5,
+	MX31_PIN_LD6__LD6, MX31_PIN_LD7__LD7, MX31_PIN_LD8__LD8,
+	MX31_PIN_LD9__LD9, MX31_PIN_LD10__LD10, MX31_PIN_LD11__LD11,
+	MX31_PIN_LD12__LD12, MX31_PIN_LD13__LD13, MX31_PIN_LD14__LD14,
+	MX31_PIN_LD15__LD15, MX31_PIN_LD16__LD16, MX31_PIN_LD17__LD17,
+	MX31_PIN_VSYNC3__VSYNC3, MX31_PIN_HSYNC__HSYNC,
+	MX31_PIN_FPSHIFT__FPSHIFT, MX31_PIN_DRDY0__DRDY0,
+	MX31_PIN_D3_REV__D3_REV, MX31_PIN_CONTRAST__CONTRAST,
+	MX31_PIN_D3_SPL__D3_SPL, MX31_PIN_D3_CLS__D3_CLS,
+	MX31_PIN_LCS0__GPI03_23,
+};
+
+static const struct fb_videomode fb_modedb[] = {
+	{
+	/* 240x320 @ 60 Hz */
+		.name		= "Sharp-LQ035Q7DH06-QVGA",
+		.refresh	= 60,
+		.xres		= 240,
+		.yres		= 320,
+		.pixclock	= 185925,
+		.left_margin	= 9,
+		.right_margin	= 16,
+		.upper_margin	= 7,
+		.lower_margin	= 9,
+		.hsync_len	= 1,
+		.vsync_len	= 1,
+		.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_SHARP_MODE |
+				  FB_SYNC_CLK_INVERT | FB_SYNC_CLK_IDLE_EN,
+		.vmode		= FB_VMODE_NONINTERLACED,
+		.flag		= 0,
+	},
+};
+
+static struct mx3fb_platform_data mx3fb_pdata = {
+	.dma_dev	= &mx3_ipu.dev,
+	.name		= "Sharp-LQ035Q7",
+	.mode		= fb_modedb,
+	.num_modes	= ARRAY_SIZE(fb_modedb),
 };
 
 /*
@@ -43,6 +83,10 @@ static int mxc_uart1_pins[] = {
 void __init mx31moboard_devboard_init(void)
 {
 	printk(KERN_INFO "Initializing mx31devboard peripherals\n");
-	mxc_iomux_setup_multiple_pins(mxc_uart1_pins, ARRAY_SIZE(mxc_uart1_pins), "uart1");
+
+	mxc_iomux_setup_multiple_pins(mx31moboard_devboard_pins,
+			ARRAY_SIZE(mx31moboard_devboard_pins), "devboard");
+
 	mxc_register_device(&mxc_uart_device1, &uart_pdata);
+	mxc_register_device(&mx3_fb, &mx3fb_pdata);
 }
diff --git a/arch/arm/mach-mx3/mx31moboard.c b/arch/arm/mach-mx3/mx31moboard.c
index 34c2a1b..c212201 100644
--- a/arch/arm/mach-mx3/mx31moboard.c
+++ b/arch/arm/mach-mx3/mx31moboard.c
@@ -30,8 +30,10 @@
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
 #include <mach/common.h>
+#include <mach/irqs.h>
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx3.h>
+#include <mach/ipu.h>
 #include <mach/board-mx31moboard.h>
 
 #include "devices.h"
@@ -64,6 +66,10 @@ static struct platform_device *devices[] __initdata = {
 	&mx31moboard_flash,
 };
 
+static struct ipu_platform_data mx3_ipu_data = {
+	.irq_base = MXC_IPU_IRQ_START,
+};
+
 static int mxc_uart0_pins[] = {
 	MX31_PIN_CTS1__CTS1, MX31_PIN_RTS1__RTS1,
 	MX31_PIN_TXD1__TXD1, MX31_PIN_RXD1__RXD1,
@@ -89,6 +95,8 @@ static void __init mxc_board_init(void)
 	mxc_iomux_setup_multiple_pins(mxc_uart4_pins, ARRAY_SIZE(mxc_uart4_pins), "uart4");
 	mxc_register_device(&mxc_uart_device4, &uart_pdata);
 
+	mxc_register_device(&mx3_ipu, &mx3_ipu_data);
+
 	switch (mx31moboard_baseboard) {
 	case MX31NOBOARD:
 		break;
-- 
1.5.4

