Commit e84160ea authored by Ye Li's avatar Ye Li

MLK-12527-1 mxc_keyb: Add MXC keyboard driver

The i.MX6SL EVK needs this driver in android fastboot support. Add
this driver to u-boot.

To use the driver, user must define:

CONFIG_MXC_KPD          Enable the driver
CONFIG_MXC_KEYMAPPING   Key mapping matrix
CONFIG_MXC_KPD_COLMAX   The column size of key mapping matrix
CONFIG_MXC_KPD_ROWMAX   The row size of the key mapping matrix
Signed-off-by: default avatarYe Li <ye.li@nxp.com>
(cherry picked from commit 5096e572667ff41217deb4ba9b1bd15e93fa6b59)
parent 19c68fcb
/*
* Copyright (C) 2009-2014 Freescale Semiconductor, Inc. All Rights Reserved.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef _MXC_KEYPAD_H_
#define _MXC_KEYPAD_H_
#define KEY_1 2
#define KEY_2 3
#define KEY_3 4
#define KEY_F1 59
#define KEY_UP 103
#define KEY_F2 60
#define KEY_4 5
#define KEY_5 6
#define KEY_6 7
#define KEY_LEFT 105
#define KEY_SELECT 0x161
#define KEY_RIGHT 106
#define KEY_7 8
#define KEY_8 9
#define KEY_9 10
#define KEY_F3 61
#define KEY_DOWN 108
#define KEY_F4 62
#define KEY_0 11
#define KEY_OK 0x160
#define KEY_ESC 1
#define KEY_ENTER 28
#define KEY_MENU 139 /* Menu (show menu) */
#define KEY_BACK 158 /* AC Back */
#endif
......@@ -18,3 +18,4 @@ obj-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
endif
obj-y += input.o
obj-$(CONFIG_$(SPL_)OF_CONTROL) += key_matrix.o
obj-$(CONFIG_MXC_KPD) += mxc_keyb.o
This diff is collapsed.
/*
* Copyright (C) 2009-2014 Freescale Semiconductor, Inc. All Rights Reserved.
*
* SPDX-License-Identifier: GPL-2.0+
*/
/*!
* @defgroup keypad Keypad Driver
*/
/*!
* @file mxc_keyb.h
*
* @brief MXC keypad header file.
*
* @ingroup keypad
*/
#ifndef __MXC_KEYB_H__
#define __MXC_KEYB_H__
/*!
* Keypad Module Name
*/
#define MOD_NAME "mxckpd"
/*!
* Keypad irq number
*/
#define KPP_IRQ MXC_INT_KPP
/*!
* XLATE mode selection
*/
#define KEYPAD_XLATE 0
/*!
* RAW mode selection
*/
#define KEYPAD_RAW 1
/*!
* Maximum number of keys.
*/
#define MAXROW 8
#define MAXCOL 8
#define MXC_MAXKEY (MAXROW * MAXCOL)
/*!
* This define indicates break scancode for every key release. A constant
* of 128 is added to the key press scancode.
*/
#define MXC_KEYRELEASE 128
/*
* _reg_KPP_KPCR _reg_KPP_KPSR _reg_KPP_KDDR _reg_KPP_KPDR
* Keypad Control Register Address
*/
#define KPCR (KPP_BASE_ADDR + 0x00)
/*
* Keypad Status Register Address
*/
#define KPSR (KPP_BASE_ADDR + 0x02)
/*
* Keypad Data Direction Address
*/
#define KDDR (KPP_BASE_ADDR + 0x04)
/*
* Keypad Data Register
*/
#define KPDR (KPP_BASE_ADDR + 0x06)
/*
* Key Press Interrupt Status bit
*/
#define KBD_STAT_KPKD 0x01
/*
* Key Release Interrupt Status bit
*/
#define KBD_STAT_KPKR 0x02
/*
* Key Depress Synchronizer Chain Status bit
*/
#define KBD_STAT_KDSC 0x04
/*
* Key Release Synchronizer Status bit
*/
#define KBD_STAT_KRSS 0x08
/*
* Key Depress Interrupt Enable Status bit
*/
#define KBD_STAT_KDIE 0x100
/*
* Key Release Interrupt Enable
*/
#define KBD_STAT_KRIE 0x200
/*
* Keypad Clock Enable
*/
#define KBD_STAT_KPPEN 0x400
/*!
* Buffer size of keypad queue. Should be a power of 2.
*/
#define KPP_BUF_SIZE 128
/*!
* Test whether bit is set for integer c
*/
#define TEST_BIT(c, n) ((c) & (0x1 << (n)))
/*!
* Set nth bit in the integer c
*/
#define BITSET(c, n) ((c) | (1 << (n)))
/*!
* Reset nth bit in the integer c
*/
#define BITRESET(c, n) ((c) & ~(1 << (n)))
enum KeyEvent {
KDepress,
KRelease
};
/*!
* This enum represents the keypad state machine to maintain debounce logic
* for key press/release.
*/
enum KeyState {
/*!
* Key press state.
*/
KStateUp,
/*!
* Key press debounce state.
*/
KStateFirstDown,
/*!
* Key release state.
*/
KStateDown,
/*!
* Key release debounce state.
*/
KStateFirstUp
};
/*!
* Keypad Private Data Structure
*/
struct keypad_priv {
/*!
* Keypad state machine.
*/
enum KeyState iKeyState;
/*!
* Number of rows configured in the keypad matrix
*/
unsigned long kpp_rows;
/*!
* Number of Columns configured in the keypad matrix
*/
unsigned long kpp_cols;
};
/*!
* Keypad Data Structure
* */
struct kpp_key_info {
enum KeyEvent evt;
unsigned short val;
};
int mxc_kpp_init(void);
int mxc_kpp_getc(struct kpp_key_info **);
/*!
* These functions are used to configure and the GPIO pins for keypad to
* activate and deactivate it.
*/
void setup_mxc_kpd(void);
#endif /* __MXC_KEYB_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment