1 /***********************************************************************
4 * DENX Software Engineering
5 * Wolfgang Denk, wd@denx.de
9 ***********************************************************************/
15 #include <stdio_dev.h>
17 #include <stdio_dev.h>
19 static struct input_config config;
21 static int kbd_read_keys(struct input_config *config)
23 #if defined(CONFIG_MPC5xxx) || defined(CONFIG_ARCH_MPC8540) || \
24 defined(CONFIG_ARCH_MPC8541) || defined(CONFIG_ARCH_MPC8555)
25 /* no ISR is used, so received chars must be polled */
32 static int check_leds(int ret)
36 leds = input_leds_changed(&config);
43 /* test if a character is in the queue */
44 static int kbd_testc(struct stdio_dev *dev)
46 return check_leds(input_tstc(&config));
49 /* gets the character from the queue */
50 static int kbd_getc(struct stdio_dev *dev)
52 return check_leds(input_getc(&config));
55 void handle_scancode(unsigned char scan_code)
59 /* Compare with i8042_kbd_check() in i8042.c if some logic is missing */
60 if (scan_code & 0x80) {
65 input_add_keycode(&config, scan_code, release);
68 /* TODO: convert to driver model */
71 struct stdio_dev kbddev;
72 struct input_config *input = &config;
76 memset (&kbddev, 0, sizeof(kbddev));
77 strcpy(kbddev.name, "kbd");
78 kbddev.flags = DEV_FLAGS_INPUT;
79 kbddev.getc = kbd_getc;
80 kbddev.tstc = kbd_testc;
83 input->read_keys = kbd_read_keys;
84 input_add_tables(input, true);
86 return input_stdio_register(&kbddev);