Skip to contentSkip to conversation

i.MX6SL EVK: Add keypad support

PATCH New nitin.garg at freescale.com 3 participants 4 messages Aug 31, 2014 – Sep 1, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i.MX6SL EVK: Add keypad support

From: Nitin Garg <[email protected]>

i.MX6sl evk has a keyboard on the board, so add mxc_keyb driver to support keypad.

Nitin Garg (1):
Add support for i.MX6SL EVK board keypad

 drivers/input/Makefile   |    1 +
 drivers/input/mxc_keyb.c |  588 ++++++++++++++++++++++++++++++++++++++++++++++
 include/mxc_keyb.h       |  240 +++++++++++++++++++
 3 files changed, 829 insertions(+)
 create mode 100644 drivers/input/mxc_keyb.c
 create mode 100644 include/mxc_keyb.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 Add support for i.MX6SL EVK board keypad

From: Nitin Garg <[email protected]>

i.MX6sl evk has a keyboard on the board, so add mxc_keyb driver to support keypad.

---
 drivers/input/Makefile   |    1 +
 drivers/input/mxc_keyb.c |  588 ++++++++++++++++++++++++++++++++++++++++++++++
 include/mxc_keyb.h       |  240 +++++++++++++++++++
 3 files changed, 829 insertions(+)
 create mode 100644 drivers/input/mxc_keyb.c
 create mode 100644 include/mxc_keyb.h
drivers/input/Makefile +1 -0
index a8e9be2..8b1b86c 100644
@@ -14,3 +14,4 @@ obj-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
 endif
 obj-y += input.o
 obj-$(CONFIG_OF_CONTROL) += key_matrix.o
+obj-$(CONFIG_MXC_KPD) += mxc_keyb.o
drivers/input/mxc_keyb.c new file +588 -0

588 lines not on this page · raw message

include/mxc_keyb.h new file +240 -0

240 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/1 Add support for i.MX6SL EVK board keypad

Quoted 6 lines · On Sun, Aug 31, 2014 at 6:31 PM, <[email protected]> wrote:

From: Nitin Garg <[email protected]>

i.MX6sl evk has a keyboard on the board, so add mxc_keyb driver to support keypad.

This driver seems to be generic and this can be used with the other reference designs which has the keyboard, doesn't it? So please rework the commit log.

Another thing, please add the support for the board so it has a board using it.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#3 lore raw

PATCH 1/1 Add support for i.MX6SL EVK board keypad

In reply to nitin.garg at freescale.com

Dear nitin.garg at freescale.com,

drivers/input/mxc_keyb.c line 53

Quoted 11 lines · In message <[email protected]> you…
drivers/input/mxc_keyb.c new file +11 -0
+static void mxc_kpp_dump_regs()
+{
+	unsigned short t1, t2, t3;
+
+	t1 = __raw_readw(KPCR);
+	t2 = __raw_readw(KPSR);
+	t3 = __raw_readw(KDDR);
+	/*
+	KPP_PRINTF("KPCR=0x%04x, KPSR=0x%04x, KDDR=0x%04x\n",
+		t1, t2, t3);
+		*/

Please do not add dead code.

drivers/input/mxc_keyb.c line 122

Quoted 5 lines
drivers/input/mxc_keyb.c new file +5 -0
+	/*
+	 * wmb() linux kernel function which guarantees orderings in write
+	 * operations
+	 */
+	/* wmb(); */

Please remove dead code. Please fix globally.[

drivers/input/mxc_keyb.c line 138

Quoted 5 lines
drivers/input/mxc_keyb.c new file +5 -0
+	for (col = 0; col < kpp_dev.kpp_cols; col++) {	/* Col */
+		/* 2. Write 1.s to KPDR[15:8] setting column data to 1.s */
+		reg_val = __raw_readw(KPDR);
+		reg_val |= 0xff00;
+		__raw_writew(reg_val, KPDR);

setbits?

Is there any specific reason for performing all these device accesses using the __raw_*() functions, i. e. without memory barriers?

That looks awfully suspicious to me...

drivers/input/mxc_keyb.c line 146

Quoted 3 lines
drivers/input/mxc_keyb.c new file +3 -0
+		reg_val = __raw_readw(KPCR);
+		reg_val &= 0x00ff;
+		__raw_writew(reg_val, KPCR);

clrbits?

drivers/input/mxc_keyb.c line 148

Quoted 1 line
drivers/input/mxc_keyb.c new file +1 -0
+		udelay(2);

Why exactly is this udelay() needed? Maybe just because you are lacking memory barriers, i. e. because you use the wrong I/O accessors?

drivers/input/mxc_keyb.c line 159

Quoted 3 lines
drivers/input/mxc_keyb.c new file +3 -0
+		reg_val = __raw_readw(KPCR);
+		reg_val |= ((1 << kpp_dev.kpp_cols) - 1) << 8;
+		__raw_writew(reg_val, KPCR);

setbits() ... etc. Please fix globally.

drivers/input/mxc_keyb.c line 174

Quoted 2 lines
drivers/input/mxc_keyb.c new file +2 -0
+		/* Delay added to avoid propagating the 0 from column to row
+		 * when scanning. */

Incorrect multiline comment style. Is this delay really needed when using non-__raw_ I/O accessors?

drivers/input/mxc_keyb.c line 252

Quoted 5 lines
drivers/input/mxc_keyb.c new file +4 -0
+		udelay(5);
+
 
+					KPress = 1;
+					kpp_dev.iKeyState = KStateUp;

Please fix variable names globally - they are all lower case.

Please fix everywhere, including the header file, sturct names, etc.

drivers/input/mxc_keyb.c line 256

Quoted 4 lines
drivers/input/mxc_keyb.c new file +4 -0
+
+					KPP_PRINTF("Press   (%d, %d) scan=%d "
+						 "Kpress=%d\n",
+						 row, col, scancode, KPress);

Any specific reason for not using standard debug() facility?

drivers/input/mxc_keyb.c line 360

Quoted 6 lines
drivers/input/mxc_keyb.c new file +6 -0
+	/*
+	* This switch case statement is the
+	* implementation of state machine of debounc
+	* logic for key press/release.
+	* The explaination of state machine is as
+	* follows:

There is no switch anywhere in the rest of this function?

drivers/input/mxc_keyb.c line 499

Quoted 7 lines
drivers/input/mxc_keyb.c new file +7 -0
+	/* Enable number of rows in keypad (KPCR[7:0])
+	 * Configure keypad columns as open-drain (KPCR[15:8])
+	 *
+	 * Configure the rows/cols in KPP
+	 * LSB nibble in KPP is for 8 rows
+	 * MSB nibble in KPP is for 8 cols
+	 */

Incorrect multiline comment style. Please fix globally.

drivers/input/mxc_keyb.c line 545

Quoted 2 lines
drivers/input/mxc_keyb.c new file +2 -0
+	press_scancode   = (short **)malloc(kpp_dev.kpp_rows * sizeof(press_scancode[0]));
+	release_scancode = (short **)malloc(kpp_dev.kpp_rows * sizeof(release_scancode[0]));

Line too long. Please fix globally.

Also, make sure to run your patches through checkpatch and fix such warnings!!

Quoted 10 lines
include/mxc_keyb.h new file +10 -0
+/*
+ * _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)

include/mxc_keyb.h line 101

Quoted 10 lines
include/mxc_keyb.h new file +10 -0
+
+/*
+ * Keypad Data Direction Address
+ */
+#define KDDR    (KPP_BASE_ADDR + 0x04)
+
+/*
+ * Keypad Data Register
+ */
+#define KPDR    (KPP_BASE_ADDR + 0x06)

Please use a C struct to describe the register map. We deprecate the notation of base register + offset.

Also consider to providing the comments at the end of the line - this would reduce your line count to 20% here and make the code much better to read.

Quoted 21 lines
include/mxc_keyb.h new file +21 -0
+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,
+

include/mxc_keyb.h line 206

Quoted 10 lines
include/mxc_keyb.h new file +10 -0
+	/*!
+	 * Key release state.
+	 */
+	KStateDown,
+
+	/*!
+	 * Key release debounce state.
+	 */
+	KStateFirstUp
+};

See before - please use all lower case variable names. We do not allow CamelCase in U-Boot.

Please fix globally!

Thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It's not an optical illusion, it just looks like one.   -- Phil White