From eee43706c5969f5d99096dddefae3be0c41a6ed2 Mon Sep 17 00:00:00 2001
From: Harald Welte <laforge@gnumonks.org>
Date: Thu, 13 Nov 2008 08:29:11 +0000
Subject: [PATCH] [ARM] S3C24xx: Add preliminary E-TEN glofiish M800 support

This patch adds preliminary support for the M800.  If booted
through haret, the system has the following working components:
* NAND read support
* framebuffer / LCM (no jbt6k74 power management yet)
* USB device controller (incl. Pullup)
* microSD card (incl. card-detect)
* backlight brightness control (using gta01-bl.c)
* input event device for power, camera and record button
* input event device for keyboard slide event
* bluetooth power control (using gta01-pm-bt)

Many things are still missing, like
* NAND write support
* GPS power control
* GSM/3G modem interface
* capsense buttons, joystick and querty-keyboard
* camera
* audio

Signed-off-by: Harald Welte <laforge@gnumonks.org>
---
 arch/arm/mach-s3c2440/Kconfig         |    7 +++++++
 arch/arm/mach-s3c2440/Makefile        |    1 +
 arch/arm/plat-s3c24xx/neo1973_pm_bt.c |   17 +++++++++++++++++
 arch/arm/tools/mach-types             |    1 +
 drivers/input/keyboard/Kconfig        |   11 +++++++++++
 drivers/input/keyboard/Makefile       |    1 +
 drivers/mtd/nand/nand_bbt.c           |    2 ++
 7 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig
index 4a211d8..4c3b6b2 100644
--- a/arch/arm/mach-s3c2440/Kconfig
+++ b/arch/arm/mach-s3c2440/Kconfig
@@ -98,6 +98,13 @@ config NEO1973_GTA02_2440
 	   Say Y here if you are using an early hardware revision
 	   of the FIC/Openmoko Neo1973 GTA02 GSM Phone.
 
+config MACH_M800
+	bool "E-TEN glofiish M800/X800"
+	select CPU_S3C2442
+	help
+	   Say Y here if you are using the E-TEN glofiish M800/X800.
+
+
 endmenu
 
 #source "arch/arm/mach-s3c2440/camera/Kconfig"
diff --git a/arch/arm/mach-s3c2440/Makefile b/arch/arm/mach-s3c2440/Makefile
index e3ca9e3..8617820 100644
--- a/arch/arm/mach-s3c2440/Makefile
+++ b/arch/arm/mach-s3c2440/Makefile
@@ -24,3 +24,4 @@ obj-$(CONFIG_ARCH_S3C2440)	+= mach-smdk2440.o
 obj-$(CONFIG_MACH_NEXCODER_2440) += mach-nexcoder.o
 obj-$(CONFIG_MACH_HXD8)		+= mach-hxd8.o
 obj-$(CONFIG_MACH_NEO1973_GTA02) += mach-gta02.o
+obj-$(CONFIG_MACH_M800)		+= mach-glofiish.o
diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_bt.c b/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
index dfc9ae8..dcb251b 100644
--- a/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
+++ b/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
@@ -30,6 +30,9 @@
 #include <linux/pcf50633.h>
 #endif
 
+#ifdef CONFIG_MACH_M800
+#include <asm/arch/glofiish.h>
+#endif
 
 #define DRVMSG "FIC Neo1973 Bluetooth Power Management"
 
@@ -56,6 +59,14 @@ static ssize_t bt_read(struct device *dev, struct device_attribute *attr,
 			break;
 #endif /* CONFIG_MACH_NEO1973_GTA02 */
 
+#ifdef CONFIG_MACH_M800
+		case MACH_TYPE_M800:
+			if (s3c2410_gpio_getpin(M800_GPIO_BT_POWER_1) &&
+			    s3c2410_gpio_getpin(M800_GPIO_BT_POWER_2))
+				goto out_1;
+			break;
+#endif /* CONFIG_MACH_M800 */
+
 		}
 	} else if (!strcmp(attr->attr.name, "reset")) {
 		switch (machine_arch_type) {
@@ -121,6 +132,12 @@ static ssize_t bt_write(struct device *dev, struct device_attribute *attr,
 			break;
 #endif /* CONFIG_MACH_NEO1973_GTA02 */
 
+#ifdef CONFIG_MACH_M800
+		case MACH_TYPE_M800:
+			s3c2410_gpio_setpin(M800_GPIO_BT_POWER_1, on);
+			s3c2410_gpio_setpin(M800_GPIO_BT_POWER_2, on);
+			break;
+#endif /* CONFIG_MACH_M800 */
 		}
 	} else if (!strcmp(attr->attr.name, "reset")) {
 		/* reset is low-active, so we need to invert */
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index 0a9a5e7..2578091 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -1367,3 +1367,4 @@ db88f5281		MACH_DB88F5281		DB88F5281		1358
 csb726			MACH_CSB726		CSB726			1359
 tik27			MACH_TIK27		TIK27			1360
 mx_uc7420		MACH_MX_UC7420		MX_UC7420		1361
+m800			MACH_M800		M800			1772
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index a61ca45..68a893f 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -304,6 +304,17 @@ config KEYBOARD_NEO1973
 	  To compile this driver as a module, choose M here: the
 	  module will be called neo1973kbd.
 
+config KEYBOARD_M800
+	tristate "E-TEN glofiish M800 buttons"
+	depends on MACH_M800
+	default y
+	help
+	  Say Y here to enable the buttons on the E-TEN glofiish
+	  M800 GSM phone.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called m800kbd.
+
 config KEYBOARD_QT2410
 	tristate "QT2410 buttons"
 	depends on MACH_QT2410
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 34bfc33..005a050 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_NEWTON)		+= newtonkbd.o
 obj-$(CONFIG_KEYBOARD_STOWAWAY)		+= stowaway.o
 obj-$(CONFIG_KEYBOARD_CORGI)		+= corgikbd.o
 obj-$(CONFIG_KEYBOARD_NEO1973)		+= neo1973kbd.o
+obj-$(CONFIG_KEYBOARD_M800)		+= m800kbd.o
 obj-$(CONFIG_KEYBOARD_QT2410)		+= qt2410kbd.o
 obj-$(CONFIG_KEYBOARD_SPITZ)		+= spitzkbd.o
 obj-$(CONFIG_KEYBOARD_HIL)		+= hil_kbd.o
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 5e121ce..7e20816 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -430,8 +430,10 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
 
 		if (ret) {
 			this->bbt[i >> 3] |= 0x03 << (i & 0x6);
+#if 0
 			printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
 			       i >> 1, (unsigned int)from);
+#endif
 			mtd->ecc_stats.badblocks++;
 		}
 
-- 
1.5.6.5