s5pc110: modified auto_download using vol_down and power_key
authorDonghwa Lee <dh09.lee@samsung.com>
Mon, 2 Aug 2010 02:47:38 +0000 (11:47 +0900)
committerDonghwa Lee <dh09.lee@samsung.com>
Mon, 2 Aug 2010 02:47:38 +0000 (11:47 +0900)
board/samsung/universal/universal.c

index f4cf4ef..1ce0e1b 100644 (file)
@@ -884,6 +884,19 @@ static void setup_media_gpios(void)
        gpio_set_pull(&s5pc110_gpio->gpio_h3, 4, GPIO_PULL_UP);
 }
 
+static int power_key_check(void)
+{
+       unsigned char addr, val[2];
+
+       /* workaround: power_key check */
+       addr = 0xCC >> 1;
+       i2c_read(addr, 0x00, 1, val, 1);
+       if (val[0] == 0xa8)
+               return 1;
+       else
+               return 0;
+}
+
 #define KBR3           (1 << 3)
 #define KBR2           (1 << 2)
 #define KBR1           (1 << 1)
@@ -896,7 +909,7 @@ static void check_keypad(void)
        unsigned int col_mask;
        unsigned int col_mask_shift;
        unsigned int row_state[4];
-       unsigned int i;
+       unsigned int i, power_key;
        unsigned int auto_download = 0;
 
        if (mach_is_wmg160())
@@ -952,6 +965,9 @@ static void check_keypad(void)
        /* KEYIFCOL reg clear */
        writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
 
+       /* power_key check */
+       power_key = power_key_check();
+
        /* key_scan */
        for (i = 0; i < col_num; i++) {
                value = col_mask;
@@ -962,37 +978,35 @@ static void check_keypad(void)
 
                value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
                row_state[i] = ~value & ((1 << row_num) - 1);
-               if (row_state[i])
-                       printf("[%d col] row_state: 0x%x\n", i, row_state[i]);
        }
 
        /* KEYIFCOL reg clear */
        writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
 
        if (mach_is_aquila() || mach_is_goni()) {
-               /* volume down */
+               /* volume down && power key */
                if (row_state[1] & 0x2)
                        display_info = 1;
                if (board_is_sdk() && hwrevision(0)) {
-                       /* home & volume down */
-                       if ((row_state[1] & 0x1) && (row_state[1] & 0x2))
+                       /* volume down && power key */
+                       if ((row_state[1] & 0x2) && power_key)
                                auto_download = 1;
                } else if (board_is_sdk() && hwrevision(2)) {
-                       /* cam full shot & volume down */
-                       if ((row_state[1] & 0x6) && (row_state[2] & 0x4))
+                       /* volume down && power key */
+                       if ((row_state[2] & 0x4) && power_key)
                                auto_download = 1;
                } else if (board_is_sdk() && (hwrevision(3) || hwrevision(4))) {
-                       /* cam full shot & volume down */
-                       if ((row_state[1] & 0x6) && (row_state[2] & 0x4))
+                       /* volume down && power key */
+                       if ((row_state[2] & 0x4) && power_key)
                                auto_download = 1;
                } else {
-                       /* cam full shot & volume down */
-                       if ((row_state[0] & 0x1) && (row_state[1] & 0x2))
+                       /* volume down && power key */
+                       if ((row_state[1] & 0x2) && power_key)
                                auto_download = 1;
                }
        } else if (mach_is_geminus())
-               /* volume down & home */
-               if ((row_state[1] & 0x2) && (row_state[2] & 0x1))
+               /* volume down && power key */
+               if ((row_state[1] & 0x2) && power_key)
                        auto_download = 1;
 
        if (auto_download)