upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / button-smdkc210.c
1 /* linux/arch/arm/mach-s5pv310/button-smdkv310.c
2  *
3  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com/
5  *
6  * S5PV310 - Button Driver
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11 */
12
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/irq.h>
16 #include <linux/ioport.h>
17 #include <linux/delay.h>
18 #include <linux/serial_core.h>
19 #include <linux/io.h>
20 #include <linux/platform_device.h>
21
22 #include <plat/map-base.h>
23 #include <plat/gpio-cfg.h>
24
25 #include <mach/regs-gpio.h>
26 #include <mach/regs-irq.h>
27 #include <linux/gpio.h>
28
29 static irqreturn_t
30 s3c_button_interrupt(int irq, void *dev_id)
31 {
32         if (irq == IRQ_EINT(0))
33                 printk(KERN_INFO "XEINT 0 Button Interrupt occure\n");
34         else if (irq == IRQ_EINT(31))
35                 printk(KERN_INFO "XEINT 31 Button Interrupt occure\n");
36         else
37                 printk(KERN_INFO "%d Button Interrupt occure\n", irq);
38
39         return IRQ_HANDLED;
40 }
41
42 static struct irqaction s3c_button_irq = {
43         .name           = "s3c button Tick",
44         .flags          = IRQF_SHARED ,
45         .handler        = s3c_button_interrupt,
46 };
47
48 static unsigned int s3c_button_gpio_init(void)
49 {
50         u32 err;
51
52         err = gpio_request(S5PV310_GPX3(7), "GPH3");
53         if (err) {
54                 printk(KERN_INFO "gpio request error : %d\n", err);
55         } else {
56                 s3c_gpio_cfgpin(S5PV310_GPX3(7), (0xf << 28));
57                 s3c_gpio_setpull(S5PV310_GPX3(7), S3C_GPIO_PULL_NONE);
58         }
59
60         return err;
61 }
62
63 static int __init s3c_button_init(void)
64 {
65         printk(KERN_INFO"SMDKV310 Button init function\n");
66
67         if (s3c_button_gpio_init()) {
68                 printk(KERN_ERR "%s failed\n", __func__);
69                 return 0;
70         }
71
72         set_irq_type(gpio_to_irq(S5PV310_GPX3(7)), IRQ_TYPE_EDGE_FALLING);
73
74         setup_irq(gpio_to_irq(S5PV310_GPX3(7)), &s3c_button_irq);
75
76 #ifdef CONFIG_PM
77         set_irq_wake(gpio_to_irq(S5PV310_GPX3(7)), 1);
78 #endif
79
80         return 0;
81 }
82 late_initcall(s3c_button_init);