tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / board / spreadtrum / sp9630ea4mn / sprd_kp.c
1 #include <common.h>
2 #include <malloc.h>
3 #include "key_map.h"
4 #include <boot_mode.h>
5 #include <asm/arch/mfp.h>
6 #include <asm/arch/chip_drv_common_io.h>
7
8 void board_keypad_init(void)
9 {
10         sprd_gpio_request(NULL, 124);
11         sprd_gpio_direction_input(NULL, 124);
12
13         sprd_gpio_request(NULL, 125);
14         sprd_gpio_direction_input(NULL, 125);
15
16         printf("[gpio keys] init!\n");
17         return;
18 }
19
20 unsigned char board_key_scan(void)
21 {
22         uint32_t key_code = KEY_RESERVED;
23         int gpio_volumeup = -1;
24         int gpio_volumedown = -1;
25
26         gpio_volumedown = sprd_gpio_get(NULL, 124);
27         if(gpio_volumedown < 0)
28                 printf("[gpio keys] volumedown : sprd_gpio_get return ERROR!\n");
29
30         gpio_volumeup = sprd_gpio_get(NULL, 125);
31         if(gpio_volumeup < 0)
32                 printf("[gpio keys] volumeup : sprd_gpio_get return ERROR!\n");
33
34         if(0 == gpio_volumedown) {
35                 key_code = KEY_VOLUMEDOWN;
36                 printf("[gpio keys] volumedown pressed!\n");
37                 return key_code;
38         }
39
40         if(0 == gpio_volumeup) {
41                 key_code = KEY_VOLUMEUP;
42                 printf("[gpio keys] volumeup pressed!\n");
43                 return key_code;
44         }
45
46         printf("[gpio keys] no key pressed!\n");
47         return key_code;
48 }
49
50 unsigned int check_key_boot(unsigned char key)
51 {
52         if(KEY_VOLUMEUP == key)
53                 return BOOT_CALIBRATE;
54         else if(KEY_HOME == key)
55                 return BOOT_FASTBOOT;
56         else if(KEY_VOLUMEDOWN== key)
57                 return BOOT_RECOVERY;
58         else
59                 return 0;
60 }