2 * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
6 * The code contained herein is licensed under the GNU General Public
7 * License. You may obtain a copy of the GNU General Public License
8 * Version 2 or later at the following locations:
10 * http://www.opensource.org/licenses/gpl-license.html
11 * http://www.gnu.org/copyleft/gpl.html
15 * @defgroup keypad Keypad Driver
21 * @brief MXC keypad header file.
25 #ifndef __MXC_KEYB_H__
26 #define __MXC_KEYB_H__
31 #define MOD_NAME "mxckpd"
36 #define KPP_IRQ MXC_INT_KPP
39 * XLATE mode selection
41 #define KEYPAD_XLATE 0
49 * Maximum number of keys.
53 #define MXC_MAXKEY (MAXROW * MAXCOL)
56 * This define indicates break scancode for every key release. A constant
57 * of 128 is added to the key press scancode.
59 #define MXC_KEYRELEASE 128
62 * _reg_KPP_KPCR _reg_KPP_KPSR _reg_KPP_KDDR _reg_KPP_KPDR
63 * Keypad Control Register Address
65 #define KPCR (KPP_BASE_ADDR + 0x00)
68 * Keypad Status Register Address
70 #define KPSR (KPP_BASE_ADDR + 0x02)
73 * Keypad Data Direction Address
75 #define KDDR (KPP_BASE_ADDR + 0x04)
78 * Keypad Data Register
80 #define KPDR (KPP_BASE_ADDR + 0x06)
83 * Key Press Interrupt Status bit
85 #define KBD_STAT_KPKD 0x01
88 * Key Release Interrupt Status bit
90 #define KBD_STAT_KPKR 0x02
93 * Key Depress Synchronizer Chain Status bit
95 #define KBD_STAT_KDSC 0x04
98 * Key Release Synchronizer Status bit
100 #define KBD_STAT_KRSS 0x08
103 * Key Depress Interrupt Enable Status bit
105 #define KBD_STAT_KDIE 0x100
108 * Key Release Interrupt Enable
110 #define KBD_STAT_KRIE 0x200
113 * Keypad Clock Enable
115 #define KBD_STAT_KPPEN 0x400
118 * Buffer size of keypad queue. Should be a power of 2.
120 #define KPP_BUF_SIZE 128
123 * Test whether bit is set for integer c
125 #define TEST_BIT(c, n) ((c) & (0x1 << (n)))
128 * Set nth bit in the integer c
130 #define BITSET(c, n) ((c) | (1 << (n)))
133 * Reset nth bit in the integer c
135 #define BITRESET(c, n) ((c) & ~(1 << (n)))
143 * This enum represents the keypad state machine to maintain debounce logic
144 * for key press/release.
154 * Key press debounce state.
164 * Key release debounce state.
170 * Keypad Private Data Structure
172 typedef struct keypad_priv {
175 * Keypad state machine.
177 enum KeyState iKeyState;
180 * Number of rows configured in the keypad matrix
182 unsigned long kpp_rows;
185 * Number of Columns configured in the keypad matrix
187 unsigned long kpp_cols;
191 * Keypad Data Structure
193 struct kpp_key_info {
198 int mxc_kpp_init(void);
199 int mxc_kpp_getc(struct kpp_key_info *);
201 #endif /* __MXC_KEYB_H__ */