From eec7849793c79b18b2bc29b8df2a2796e851aebe Mon Sep 17 00:00:00 2001
From: =?utf8?q?=E7=BD=97=E4=BC=9F?= <lw@rock-chips.com>
Date: Mon, 31 May 2010 05:23:31 +0000
Subject: [PATCH] luowei modified battery driver on 100530

---
 arch/arm/mach-rk2818/board-midsdk.c    | 30 ++++++++++++++++++++++++++
 drivers/input/keyboard/rk2818_adckey.c | 13 +++++++++--
 drivers/power/rk2818_battery.c         |  2 +-
 3 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-rk2818/board-midsdk.c b/arch/arm/mach-rk2818/board-midsdk.c
index 75b94bd1677a..4644f728025b 100644
--- a/arch/arm/mach-rk2818/board-midsdk.c
+++ b/arch/arm/mach-rk2818/board-midsdk.c
@@ -422,6 +422,34 @@ static struct platform_device *devices[] __initdata = {
 };
 
 extern struct sys_timer rk2818_timer;
+#define POWER_PIN	RK2818_PIN_PA3
+static void rk2818_power_on(void)
+{
+	int ret;
+	ret = gpio_request(POWER_PIN, NULL);
+	if (ret) {
+		printk("failed to request power_off gpio\n");
+		goto err_free_gpio;
+	}
+
+	gpio_pull_updown(POWER_PIN, GPIOPullUp);
+	ret = gpio_direction_output(POWER_PIN, GPIO_HIGH);
+	if (ret) {
+		printk("failed to set power_off gpio output\n");
+		goto err_free_gpio;
+	}
+
+	gpio_set_value(POWER_PIN, 1);/*power on*/
+	
+err_free_gpio:
+	gpio_free(POWER_PIN);
+}
+
+static void rk2818_power_off(void)
+{
+	printk("shut down system now ...\n");
+	gpio_set_value(POWER_PIN, 0);/*power down*/
+}
 
 static void __init machine_rk2818_init_irq(void)
 {
@@ -432,6 +460,8 @@ static void __init machine_rk2818_init_irq(void)
 
 static void __init machine_rk2818_board_init(void)
 {	
+	rk2818_power_on();
+	pm_power_off = rk2818_power_off;
 #ifdef CONFIG_I2C0_RK2818
 	i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
 			ARRAY_SIZE(board_i2c0_devices));
diff --git a/drivers/input/keyboard/rk2818_adckey.c b/drivers/input/keyboard/rk2818_adckey.c
index 4b33162010ad..b11e46b54074 100644
--- a/drivers/input/keyboard/rk2818_adckey.c
+++ b/drivers/input/keyboard/rk2818_adckey.c
@@ -112,7 +112,7 @@ unsigned int rk28_get_keycode(unsigned int advalue,pADC_keyst ptab)
 	return 0;
 }
 
-static irqreturn_t rk2818_playkey_irq(int irq, void *handle)
+static irqreturn_t rk28_playkey_irq(int irq, void *handle)
 { 
 	input_report_key(pRk28AdcKey->input_dev,KEYSTART,1);
 	input_sync(pRk28AdcKey->input_dev);
@@ -123,6 +123,15 @@ static irqreturn_t rk2818_playkey_irq(int irq, void *handle)
 	return IRQ_HANDLED;
 }
 
+
+void rk28_send_wakeup_key( void ) 
+{
+        input_report_key(pRk28AdcKey->input_dev,KEY_WAKEUP,1);
+        input_sync(pRk28AdcKey->input_dev);
+        input_report_key(pRk28AdcKey->input_dev,KEY_WAKEUP,0);
+        input_sync(pRk28AdcKey->input_dev);
+}
+
 static int rk28_adckey_open(struct input_dev *dev)
 {
 	//struct rk28_adckey *adckey = input_get_drvdata(dev);
@@ -298,7 +307,7 @@ static int __devinit rk28_adckey_probe(struct platform_device *pdev)
 	}
 	
 	gpio_pull_updown(KEY_PLAYON_PIN,GPIOPullUp);
-	error = request_irq(gpio_to_irq(KEY_PLAYON_PIN),rk2818_playkey_irq,IRQF_TRIGGER_FALLING,NULL,NULL);  
+	error = request_irq(gpio_to_irq(KEY_PLAYON_PIN),rk28_playkey_irq,IRQF_TRIGGER_FALLING,NULL,NULL);  
 	if(error)
 	{
 		printk("unable to request play key irq\n");
diff --git a/drivers/power/rk2818_battery.c b/drivers/power/rk2818_battery.c
index fac5d031b94b..969f45f60354 100644
--- a/drivers/power/rk2818_battery.c
+++ b/drivers/power/rk2818_battery.c
@@ -28,7 +28,7 @@
 #include <mach/adc.h>
 #include <mach/iomux.h>
 
-#if 1
+#if 0
 #define DBG(x...)   printk(x)
 #else
 #define DBG(x...)
-- 
2.34.1