luowei modified battery driver on 100530
author罗伟 <lw@rock-chips.com>
Mon, 31 May 2010 05:23:31 +0000 (05:23 +0000)
committer黄涛 <huangtao@rock-chips.com>
Mon, 21 Jun 2010 05:35:20 +0000 (13:35 +0800)
arch/arm/mach-rk2818/board-midsdk.c
drivers/input/keyboard/rk2818_adckey.c
drivers/power/rk2818_battery.c

index 75b94bd1677a0eec6db50e1e8b6c949f67f0dec0..4644f728025b3aec26b8144435ba5bac3e58153c 100644 (file)
@@ -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));
index 4b33162010ad2600ae77eabc376b8326351c55a9..b11e46b540743b72cdd4b505e03fd5e83c101dce 100644 (file)
@@ -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");
index fac5d031b94b34cf99e57265989946143b0b369b..969f45f60354f52507e05ceb73e522c6de6cf5ae 100644 (file)
@@ -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...)