#include <i2c.h>
#include <asm/io.h>
#include <asm/arch/gpio.h>
+#include <asm/arch/keypad.h>
DECLARE_GLOBAL_DATA_PTR;
#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();
/* To power up I2C2 */
enable_touch_ldo();
+ /* To usbdown automatically */
+ check_keypad();
+
return 0;
}
#endif
#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
--- /dev/null
+/*
+ * 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