Keyboard mapping for the Mipsbook (by P. Boddie)
Keyboard
The keyboard is configured with rows as inputs with pull-up enabled, and columns initially as inputs. The pins involved are as follows:
- Columns are GPIO port D pins 0..15 and 29
- Rows are GPIO port A pins 0..7
To read the keyboard, individual columns are switched to output and driven low, and each row value is read to provide the individual key state, before the column is switched back to input. A row value of zero (low) means that a given key is pressed because a connection is made between the column pin and the row pin, and the pull-up no longer holds the row pin high since it is being driven actively by the column pin.
A delay between switching a column to output and reading the key states is advised to avoid capturing the state of a key in the previous column.
Rows/Cols | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Pause | Q | W | E | R | U | I | O | P | ||||||||
1 | Tab | Caps | F3 | T | Y | ] | F7 | Bsp | [ | Zzz | L-Sh | ||||||
2 | A | S | D | F | J | K | L | ; | Up | R-Sh | |||||||
3 | Esc | L-\ | F4 | G | H | F6 | Spc | Alt | ' | Down | |||||||
4 | Z | X | C | V | M | , | . | Num | Ret | R-\ | Left | ||||||
5 | B | N | Menu | / | Right | ||||||||||||
6 | Ctrl | ` | 5 | 6 | = | F8 | Del | F9 | - | F2 | Ins | F1 | |||||
7 | F5 | 1 | 2 | 3 | 4 | 7 | 8 | 9 | PrtSc | 0 | F10 | Fn |
Driver
In the 2.6 kernel code, the keyboard driver is found in the drivers/input/keyboard/jz_keypad.c
file. It uses a timer to repeatedly scan the keyboard, tracking the previous state and comparing it with the current state to produce key events.
The driver also tracks the state of the Num Lock and Caps Lock keys, translating key presses when the Num Lock has been enabled. It also toggles the keyboard LEDs.