s5pc110: universal: Auto USB download support by keypad
authorKyungmin Park <kyungmin.park@samsung.com>
Tue, 11 Aug 2009 07:54:09 +0000 (16:54 +0900)
committerKyungmin Park <kyungmin.park@samsung.com>
Tue, 11 Aug 2009 07:54:09 +0000 (16:54 +0900)
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
board/samsung/universal/universal.c
include/asm-arm/arch-s5pc1xx/gpio.h
include/asm-arm/arch-s5pc1xx/keypad.h [new file with mode: 0644]

index ca99eac..4a57d14 100644 (file)
@@ -27,6 +27,7 @@
 #include <i2c.h>
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/keypad.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -169,6 +170,61 @@ static void enable_touch_ldo(void)
 #endif
 }
 
+static void check_keypad(void)
+{
+       unsigned int reg, value;
+       unsigned int auto_download = 0;
+
+       if (cpu_is_s5pc100()) {
+               /* Set GPH2[2:0] to KP_COL[2:0] */
+               reg = S5PC100_GPIO_BASE(S5PC100_GPIO_H2_OFFSET);
+               reg += S5PC1XX_GPIO_CON_OFFSET;
+               value = readl(reg);
+               value &= ~(0xFFF);
+               value |= (0x333);
+               writel(value, reg);
+
+               /* Set GPH3[2:0] to KP_ROW[2:0] */
+               reg = S5PC100_GPIO_BASE(S5PC100_GPIO_H3_OFFSET);
+               reg += S5PC1XX_GPIO_CON_OFFSET;
+               value = readl(reg);
+               value &= ~(0xFFF);
+               value |= (0x333);
+               writel(value, reg);
+
+               reg = S5PC100_KEYPAD_BASE;
+       } else {
+               /* Set GPH2[3:0] to KP_COL[3:0] */
+               reg = S5PC110_GPIO_BASE(S5PC110_GPIO_H2_OFFSET);
+               reg += S5PC1XX_GPIO_CON_OFFSET;
+               value = readl(reg);
+               value &= ~(0xFFFF);
+               value |= (0x3333);
+               writel(value, reg);
+
+               /* Set GPH3[3:0] to KP_ROW[3:0] */
+               reg = S5PC110_GPIO_BASE(S5PC110_GPIO_H3_OFFSET);
+               reg += S5PC1XX_GPIO_CON_OFFSET;
+               value = readl(reg);
+               value &= ~(0xFFFF);
+               value |= (0x3333);
+               writel(value, reg);
+
+               reg = S5PC110_KEYPAD_BASE;
+       }
+
+       value = 0x00;
+       writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
+
+       value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
+
+       if ((value & 0x1) == 0)
+               auto_download = 1;
+
+       if (auto_download)
+               setenv("bootcmd", "usbdown");
+}
+
 int misc_init_r(void)
 {
        check_hw_revision();
@@ -179,6 +235,9 @@ int misc_init_r(void)
        /* To power up I2C2 */
        enable_touch_ldo();
 
+       /* To usbdown automatically */
+       check_keypad();
+
        return 0;
 }
 #endif
index 8bcb0a9..9490525 100644 (file)
 #define S5PC110_GPIO_MP2_6_OFFSET      0x5A0
 #define S5PC110_GPIO_MP2_7_OFFSET      0x5C0
 #define S5PC110_GPIO_MP2_8_OFFSET      0x5E0
+#define S5PC110_GPIO_H0_OFFSET         0xC00
 #define S5PC110_GPIO_H1_OFFSET         0xC20
+#define S5PC110_GPIO_H2_OFFSET         0xC40
+#define S5PC110_GPIO_H3_OFFSET         0xC60
 
 /* GPIO bank Offset */
 #define S5PC1XX_GPIO_CON_OFFSET                0x0
diff --git a/include/asm-arm/arch-s5pc1xx/keypad.h b/include/asm-arm/arch-s5pc1xx/keypad.h
new file mode 100644 (file)
index 0000000..97aafb0
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 Samsung Electronics
+ * Kyungnin Park <kyungmin.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_ARCH_KEYPAD_H_
+#define __ASM_ARCH_KEYPAD_H_
+
+/* I2C */
+#define S5PC100_KEYPAD_BASE            0xF3100000
+#define S5PC110_KEYPAD_BASE            0xE1600000
+
+#define S5PC1XX_KEYIFCON_OFFSET                (0x00)
+#define S5PC1XX_KEYIFSTSCLR_OFFSET     (0x04)
+#define S5PC1XX_KEYIFCOL_OFFSET                (0x08)
+#define S5PC1XX_KEYIFROW_OFFSET                (0x0C)
+#define S5PC1XX_KEYIFFC_OFFSET         (0x10)
+
+#endif