Keyboard mapping for the Mipsbook (by P. Boddie)
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.
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.