[NTOSKRNL]
[reactos.git] / reactos / boot / armllb / hw / omap3-zoom2 / hwsynkp.c
1 /*
2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/armllb/hw/omap3-zoom2/hwsynkpd.c
5 * PURPOSE: LLB Synpatics Keypad Support for OMAP3 ZOOM 2
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 #include "precomp.h"
10
11 /* FUNCTIONS ******************************************************************/
12
13 VOID
14 NTAPI
15 LlbHwOmap3SynKpdInitialize(VOID)
16 {
17 /* Set GPIO pin 8 on the TWL4030 as an output pin */
18 LlbHwOmap3TwlWrite1(0x49, 0x9B, 0xC0);
19
20 /* Set GPIO pin 8 signal on the TWL4030 ON. This powers the keypad backlight */
21 LlbHwOmap3TwlWrite1(0x49, 0xA4, 0xC0);
22
23 /* Set PENDDIS and COR on the the keypad interrupt controller */
24 LlbHwOmap3TwlWrite1(0x4A, 0xE9, 0x06);
25
26 /* Only falling edge detection for key pressed */
27 LlbHwOmap3TwlWrite1(0x4A, 0xE8, 0x01);
28
29 /* Unmask key-pressed events */
30 LlbHwOmap3TwlWrite1(0x4A, 0xE4, 0x0E);
31
32 /* Set the keypad control register to turn hardware sequencing and turn it on */
33 LlbHwOmap3TwlWrite1(0x4A, 0xD2, 0x0);
34 LlbHwOmap3TwlRead1(0x4A, 0xE3);
35 LlbHwOmap3TwlWrite1(0x4A, 0xD2, 0x43);
36 }
37
38 UCHAR KeyboardMatrixStatus[8];
39 BOOLEAN LastState = FALSE;
40
41 BOOLEAN
42 NTAPI
43 LlbHwKbdReady(VOID)
44 {
45 UCHAR Value;
46
47 Value = LlbHwOmap3TwlRead1(0x4A, 0xE3);
48 if (!Value) return FALSE;
49
50 LastState ^= 1;
51 if (!LastState) return FALSE;
52
53 /* Return whether or not an interrupt is pending */
54 return TRUE;
55 }
56
57 INT
58 NTAPI
59 LlbHwKbdRead(VOID)
60 {
61 UCHAR ActiveCol = 0, ActiveRow = 0, col, coldata, row;
62
63 for (col = 0; col < 8; col++)
64 {
65 coldata = LlbHwOmap3TwlRead1(0x4A, 0xDB + col);
66 if (coldata)
67 {
68 for (row = 0; row < 8; row++)
69 {
70 if (coldata == (1 << row))
71 {
72 ActiveRow = row;
73 ActiveCol = col;
74 break;
75 }
76 }
77 }
78 }
79
80 return ((ActiveCol << 4) | ActiveRow);
81 }
82
83 /* EOF */