Lines Matching +full:keyboard +full:- +full:controller

5  * SPDX-License-Identifier:	GPL-2.0+
12 #include <keyboard.h>
15 #include <tegra-kbc.h>
19 #include <asm/arch-tegra/timer.h>
41 KBC_CLOCK_KHZ = 32, /* Keyboard uses a 32KHz clock */
44 /* keyboard controller config and state */
49 struct kbc_tegra *kbc; /* tegra keyboard controller */
50 unsigned char inited; /* 1 if keyboard has been inited */
54 * After init we must wait a short time before polling the keyboard.
55 * This gives the tegra keyboard controller time to react after reset
58 unsigned int init_dly_ms; /* Delay before we can read keyboard */
65 * reads the keyboard fifo for current keypresses
67 * @param priv Keyboard private data
82 kp_ent = readl(&priv->kbc->kp_ent[i / 4]); in tegra_kbc_find_keys()
84 key->valid = (kp_ent & KBC_KPENT_VALID) != 0; in tegra_kbc_find_keys()
85 key->row = (kp_ent >> 3) & 0xf; in tegra_kbc_find_keys()
86 key->col = kp_ent & 0x7; in tegra_kbc_find_keys()
91 return key_matrix_decode(&priv->matrix, keys, KBC_MAX_KPENT, fifo, in tegra_kbc_find_keys()
99 * consists of from 1-8 keycodes, representing the keycodes which
103 * for each. Not that one set may produce more than one ASCII characters -
110 * @param priv Keyboard private data
111 * @param fifo_cnt Number of entries in the keyboard fifo
123 input_send_keycodes(priv->input, fifo, cnt); in process_fifo()
124 } while (--fifo_cnt > 0); in process_fifo()
128 * Check the keyboard controller and emit ASCII characters for any keys that
131 * @param priv Keyboard private data
137 if (!priv->first_scan && in check_for_keys()
138 get_timer(priv->last_poll_ms) < KBC_REPEAT_RATE_MS) in check_for_keys()
140 priv->last_poll_ms = get_timer(0); in check_for_keys()
141 priv->first_scan = 0; in check_for_keys()
144 * Once we get here we know the keyboard has been scanned. So if there in check_for_keys()
147 fifo_cnt = (readl(&priv->kbc->interrupt) >> 4) & 0xf; in check_for_keys()
157 * @param priv Keyboard private data
161 if (!priv->inited) { in kbd_wait_for_fifo_init()
165 elapsed_time = get_timer(priv->start_time_ms); in kbd_wait_for_fifo_init()
166 delay_ms = priv->init_dly_ms - elapsed_time; in kbd_wait_for_fifo_init()
172 priv->inited = 1; in kbd_wait_for_fifo_init()
177 * Check the tegra keyboard, and send any keys that are pressed.
187 struct tegra_kbd_priv *priv = dev_get_priv(input->dev); in tegra_kbc_check()
195 /* configures keyboard GPIO registers to use the rows and columns */
209 row_cfg = readl(&kbc->row_cfg[r_offs]); in config_kbc_gpio()
210 col_cfg = readl(&kbc->col_cfg[c_offs]); in config_kbc_gpio()
215 if (i < priv->matrix.num_rows) { in config_kbc_gpio()
218 col_cfg |= (((i - priv->matrix.num_rows) << 1) | 1) in config_kbc_gpio()
222 writel(row_cfg, &kbc->row_cfg[r_offs]); in config_kbc_gpio()
223 writel(col_cfg, &kbc->col_cfg[c_offs]); in config_kbc_gpio()
228 * Start up the keyboard device
232 struct kbc_tegra *kbc = priv->kbc; in tegra_kbc_open()
237 * We will scan at twice the keyboard repeat rate, so that there is in tegra_kbc_open()
241 writel(scan_period * KBC_CLOCK_KHZ, &kbc->rpt_dly); in tegra_kbc_open()
242 writel(scan_period * KBC_CLOCK_KHZ, &kbc->init_dly); in tegra_kbc_open()
244 * Before reading from the keyboard we must wait for the init_dly in tegra_kbc_open()
247 priv->init_dly_ms = scan_period * 2 + 2; in tegra_kbc_open()
252 writel(val, &kbc->control); in tegra_kbc_open()
254 priv->start_time_ms = get_timer(0); in tegra_kbc_open()
255 priv->last_poll_ms = get_timer(0); in tegra_kbc_open()
256 priv->next_repeat_ms = priv->last_poll_ms; in tegra_kbc_open()
257 priv->first_scan = 1; in tegra_kbc_open()
267 config_kbc_gpio(priv, priv->kbc); in tegra_kbd_start()
270 debug("%s: Tegra keyboard ready\n", __func__); in tegra_kbd_start()
276 * Set up the tegra keyboard. This is called by the stdio device handler
278 * We want to do this init when the keyboard is actually used rather than
279 * at start-up, since keyboard input may not currently be selected.
281 * Once the keyboard starts there will be a period during which we must
282 * wait for the keyboard to init. We do this only when a key is first
283 * read - see kbd_wait_for_fifo_init().
285 * @return 0 if ok, -ve on error
291 struct stdio_dev *sdev = &uc_priv->sdev; in tegra_kbd_probe()
292 struct input_config *input = &uc_priv->input; in tegra_kbd_probe()
295 priv->kbc = (struct kbc_tegra *)devfdt_get_addr(dev); in tegra_kbd_probe()
296 if ((fdt_addr_t)priv->kbc == FDT_ADDR_T_NONE) { in tegra_kbd_probe()
297 debug("%s: No keyboard register found\n", __func__); in tegra_kbd_probe()
298 return -EINVAL; in tegra_kbd_probe()
302 /* Decode the keyboard matrix information (16 rows, 8 columns) */ in tegra_kbd_probe()
303 ret = key_matrix_init(&priv->matrix, 16, 8, 1); in tegra_kbd_probe()
308 ret = key_matrix_decode_fdt(dev, &priv->matrix); in tegra_kbd_probe()
315 if (priv->matrix.fn_keycode) { in tegra_kbd_probe()
316 ret = input_add_table(input, KEY_FN, -1, in tegra_kbd_probe()
317 priv->matrix.fn_keycode, in tegra_kbd_probe()
318 priv->matrix.key_count); in tegra_kbd_probe()
326 priv->input = input; in tegra_kbd_probe()
327 input->dev = dev; in tegra_kbd_probe()
328 input->read_keys = tegra_kbc_check; in tegra_kbd_probe()
329 strcpy(sdev->name, "tegra-kbc"); in tegra_kbd_probe()
344 { .compatible = "nvidia,tegra20-kbc" },