usb: kbd: simplify coding for arrow keys
[oweals/u-boot.git] / common / usb_kbd.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2001
4  * Denis Peter, MPL AG Switzerland
5  *
6  * Part of this source has been derived from the Linux USB
7  * project.
8  */
9 #include <common.h>
10 #include <console.h>
11 #include <dm.h>
12 #include <env.h>
13 #include <errno.h>
14 #include <malloc.h>
15 #include <memalign.h>
16 #include <stdio_dev.h>
17 #include <watchdog.h>
18 #include <asm/byteorder.h>
19
20 #include <usb.h>
21
22 /*
23  * If overwrite_console returns 1, the stdin, stderr and stdout
24  * are switched to the serial port, else the settings in the
25  * environment are used
26  */
27 #ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
28 extern int overwrite_console(void);
29 #else
30 int overwrite_console(void)
31 {
32         return 0;
33 }
34 #endif
35
36 /* Keyboard sampling rate */
37 #define REPEAT_RATE     40              /* 40msec -> 25cps */
38 #define REPEAT_DELAY    10              /* 10 x REPEAT_RATE = 400msec */
39
40 #define NUM_LOCK        0x53
41 #define CAPS_LOCK       0x39
42 #define SCROLL_LOCK     0x47
43
44 /* Modifier bits */
45 #define LEFT_CNTR       (1 << 0)
46 #define LEFT_SHIFT      (1 << 1)
47 #define LEFT_ALT        (1 << 2)
48 #define LEFT_GUI        (1 << 3)
49 #define RIGHT_CNTR      (1 << 4)
50 #define RIGHT_SHIFT     (1 << 5)
51 #define RIGHT_ALT       (1 << 6)
52 #define RIGHT_GUI       (1 << 7)
53
54 /* Size of the keyboard buffer */
55 #define USB_KBD_BUFFER_LEN      0x20
56
57 /* Device name */
58 #define DEVNAME                 "usbkbd"
59
60 /* Keyboard maps */
61 static const unsigned char usb_kbd_numkey[] = {
62         '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
63         '\r', 0x1b, '\b', '\t', ' ', '-', '=', '[', ']',
64         '\\', '#', ';', '\'', '`', ',', '.', '/'
65 };
66 static const unsigned char usb_kbd_numkey_shifted[] = {
67         '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
68         '\r', 0x1b, '\b', '\t', ' ', '_', '+', '{', '}',
69         '|', '~', ':', '"', '~', '<', '>', '?'
70 };
71
72 static const unsigned char usb_kbd_num_keypad[] = {
73         '/', '*', '-', '+', '\r',
74         '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
75         '.', 0, 0, 0, '='
76 };
77
78 static const u8 usb_special_keys[] = {
79         'C', 'D', 'B', 'A'
80 };
81
82 /*
83  * NOTE: It's important for the NUM, CAPS, SCROLL-lock bits to be in this
84  *       order. See usb_kbd_setled() function!
85  */
86 #define USB_KBD_NUMLOCK         (1 << 0)
87 #define USB_KBD_CAPSLOCK        (1 << 1)
88 #define USB_KBD_SCROLLLOCK      (1 << 2)
89 #define USB_KBD_CTRL            (1 << 3)
90
91 #define USB_KBD_LEDMASK         \
92         (USB_KBD_NUMLOCK | USB_KBD_CAPSLOCK | USB_KBD_SCROLLLOCK)
93
94 /*
95  * USB Keyboard reports are 8 bytes in boot protocol.
96  * Appendix B of HID Device Class Definition 1.11
97  */
98 #define USB_KBD_BOOT_REPORT_SIZE 8
99
100 struct usb_kbd_pdata {
101         unsigned long   intpipe;
102         int             intpktsize;
103         int             intinterval;
104         unsigned long   last_report;
105         struct int_queue *intq;
106
107         uint32_t        repeat_delay;
108
109         uint32_t        usb_in_pointer;
110         uint32_t        usb_out_pointer;
111         uint8_t         usb_kbd_buffer[USB_KBD_BUFFER_LEN];
112
113         uint8_t         *new;
114         uint8_t         old[USB_KBD_BOOT_REPORT_SIZE];
115
116         uint8_t         flags;
117 };
118
119 extern int __maybe_unused net_busy_flag;
120
121 /* The period of time between two calls of usb_kbd_testc(). */
122 static unsigned long __maybe_unused kbd_testc_tms;
123
124 /* Puts character in the queue and sets up the in and out pointer. */
125 static void usb_kbd_put_queue(struct usb_kbd_pdata *data, u8 c)
126 {
127         if (data->usb_in_pointer == USB_KBD_BUFFER_LEN - 1) {
128                 /* Check for buffer full. */
129                 if (data->usb_out_pointer == 0)
130                         return;
131
132                 data->usb_in_pointer = 0;
133         } else {
134                 /* Check for buffer full. */
135                 if (data->usb_in_pointer == data->usb_out_pointer - 1)
136                         return;
137
138                 data->usb_in_pointer++;
139         }
140
141         data->usb_kbd_buffer[data->usb_in_pointer] = c;
142 }
143
144 /*
145  * Set the LEDs. Since this is used in the irq routine, the control job is
146  * issued with a timeout of 0. This means, that the job is queued without
147  * waiting for job completion.
148  */
149 static void usb_kbd_setled(struct usb_device *dev)
150 {
151         struct usb_interface *iface = &dev->config.if_desc[0];
152         struct usb_kbd_pdata *data = dev->privptr;
153         ALLOC_ALIGN_BUFFER(uint32_t, leds, 1, USB_DMA_MINALIGN);
154
155         *leds = data->flags & USB_KBD_LEDMASK;
156         usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
157                 USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
158                 0x200, iface->desc.bInterfaceNumber, leds, 1, 0);
159 }
160
161 #define CAPITAL_MASK    0x20
162 /* Translate the scancode in ASCII */
163 static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode,
164                                 unsigned char modifier, int pressed)
165 {
166         uint8_t keycode = 0;
167
168         /* Key released */
169         if (pressed == 0) {
170                 data->repeat_delay = 0;
171                 return 0;
172         }
173
174         if (pressed == 2) {
175                 data->repeat_delay++;
176                 if (data->repeat_delay < REPEAT_DELAY)
177                         return 0;
178
179                 data->repeat_delay = REPEAT_DELAY;
180         }
181
182         /* Alphanumeric values */
183         if ((scancode > 3) && (scancode <= 0x1d)) {
184                 keycode = scancode - 4 + 'a';
185
186                 if (data->flags & USB_KBD_CAPSLOCK)
187                         keycode &= ~CAPITAL_MASK;
188
189                 if (modifier & (LEFT_SHIFT | RIGHT_SHIFT)) {
190                         /* Handle CAPSLock + Shift pressed simultaneously */
191                         if (keycode & CAPITAL_MASK)
192                                 keycode &= ~CAPITAL_MASK;
193                         else
194                                 keycode |= CAPITAL_MASK;
195                 }
196         }
197
198         if ((scancode > 0x1d) && (scancode < 0x39)) {
199                 /* Shift pressed */
200                 if (modifier & (LEFT_SHIFT | RIGHT_SHIFT))
201                         keycode = usb_kbd_numkey_shifted[scancode - 0x1e];
202                 else
203                         keycode = usb_kbd_numkey[scancode - 0x1e];
204         }
205
206         /* Numeric keypad */
207         if ((scancode >= 0x54) && (scancode <= 0x67))
208                 keycode = usb_kbd_num_keypad[scancode - 0x54];
209
210         if (data->flags & USB_KBD_CTRL)
211                 keycode = scancode - 0x3;
212
213         if (pressed == 1) {
214                 if (scancode == NUM_LOCK) {
215                         data->flags ^= USB_KBD_NUMLOCK;
216                         return 1;
217                 }
218
219                 if (scancode == CAPS_LOCK) {
220                         data->flags ^= USB_KBD_CAPSLOCK;
221                         return 1;
222                 }
223                 if (scancode == SCROLL_LOCK) {
224                         data->flags ^= USB_KBD_SCROLLLOCK;
225                         return 1;
226                 }
227         }
228
229         /* Report keycode if any */
230         if (keycode) {
231                 debug("%c", keycode);
232                 usb_kbd_put_queue(data, keycode);
233                 return 0;
234         }
235
236         /* Left, Right, Up, Down */
237         if (scancode > 0x4e && scancode < 0x53) {
238                 usb_kbd_put_queue(data, 0x1b);
239                 usb_kbd_put_queue(data, '[');
240                 usb_kbd_put_queue(data, usb_special_keys[scancode - 0x4f]);
241                 return 0;
242         }
243         return 1;
244 }
245
246 static uint32_t usb_kbd_service_key(struct usb_device *dev, int i, int up)
247 {
248         uint32_t res = 0;
249         struct usb_kbd_pdata *data = dev->privptr;
250         uint8_t *new;
251         uint8_t *old;
252
253         if (up) {
254                 new = data->old;
255                 old = data->new;
256         } else {
257                 new = data->new;
258                 old = data->old;
259         }
260
261         if ((old[i] > 3) &&
262             (memscan(new + 2, old[i], USB_KBD_BOOT_REPORT_SIZE - 2) ==
263                         new + USB_KBD_BOOT_REPORT_SIZE)) {
264                 res |= usb_kbd_translate(data, old[i], data->new[0], up);
265         }
266
267         return res;
268 }
269
270 /* Interrupt service routine */
271 static int usb_kbd_irq_worker(struct usb_device *dev)
272 {
273         struct usb_kbd_pdata *data = dev->privptr;
274         int i, res = 0;
275
276         /* No combo key pressed */
277         if (data->new[0] == 0x00)
278                 data->flags &= ~USB_KBD_CTRL;
279         /* Left or Right Ctrl pressed */
280         else if ((data->new[0] == LEFT_CNTR) || (data->new[0] == RIGHT_CNTR))
281                 data->flags |= USB_KBD_CTRL;
282
283         for (i = 2; i < USB_KBD_BOOT_REPORT_SIZE; i++) {
284                 res |= usb_kbd_service_key(dev, i, 0);
285                 res |= usb_kbd_service_key(dev, i, 1);
286         }
287
288         /* Key is still pressed */
289         if ((data->new[2] > 3) && (data->old[2] == data->new[2]))
290                 res |= usb_kbd_translate(data, data->new[2], data->new[0], 2);
291
292         if (res == 1)
293                 usb_kbd_setled(dev);
294
295         memcpy(data->old, data->new, USB_KBD_BOOT_REPORT_SIZE);
296
297         return 1;
298 }
299
300 /* Keyboard interrupt handler */
301 static int usb_kbd_irq(struct usb_device *dev)
302 {
303         if ((dev->irq_status != 0) ||
304             (dev->irq_act_len != USB_KBD_BOOT_REPORT_SIZE)) {
305                 debug("USB KBD: Error %lX, len %d\n",
306                       dev->irq_status, dev->irq_act_len);
307                 return 1;
308         }
309
310         return usb_kbd_irq_worker(dev);
311 }
312
313 /* Interrupt polling */
314 static inline void usb_kbd_poll_for_event(struct usb_device *dev)
315 {
316 #if defined(CONFIG_SYS_USB_EVENT_POLL)
317         struct usb_kbd_pdata *data = dev->privptr;
318
319         /* Submit an interrupt transfer request */
320         if (usb_int_msg(dev, data->intpipe, &data->new[0],
321                         data->intpktsize, data->intinterval, true) >= 0)
322                 usb_kbd_irq_worker(dev);
323 #elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) || \
324       defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)
325 #if defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)
326         struct usb_interface *iface;
327         struct usb_kbd_pdata *data = dev->privptr;
328         iface = &dev->config.if_desc[0];
329         usb_get_report(dev, iface->desc.bInterfaceNumber,
330                        1, 0, data->new, USB_KBD_BOOT_REPORT_SIZE);
331         if (memcmp(data->old, data->new, USB_KBD_BOOT_REPORT_SIZE)) {
332                 usb_kbd_irq_worker(dev);
333 #else
334         struct usb_kbd_pdata *data = dev->privptr;
335         if (poll_int_queue(dev, data->intq)) {
336                 usb_kbd_irq_worker(dev);
337                 /* We've consumed all queued int packets, create new */
338                 destroy_int_queue(dev, data->intq);
339                 data->intq = create_int_queue(dev, data->intpipe, 1,
340                                       USB_KBD_BOOT_REPORT_SIZE, data->new,
341                                       data->intinterval);
342 #endif
343                 data->last_report = get_timer(0);
344         /* Repeat last usb hid report every REPEAT_RATE ms for keyrepeat */
345         } else if (data->last_report != -1 &&
346                    get_timer(data->last_report) > REPEAT_RATE) {
347                 usb_kbd_irq_worker(dev);
348                 data->last_report = get_timer(0);
349         }
350 #endif
351 }
352
353 /* test if a character is in the queue */
354 static int usb_kbd_testc(struct stdio_dev *sdev)
355 {
356         struct stdio_dev *dev;
357         struct usb_device *usb_kbd_dev;
358         struct usb_kbd_pdata *data;
359
360 #ifdef CONFIG_CMD_NET
361         /*
362          * If net_busy_flag is 1, NET transfer is running,
363          * then we check key-pressed every second (first check may be
364          * less than 1 second) to improve TFTP booting performance.
365          */
366         if (net_busy_flag && (get_timer(kbd_testc_tms) < CONFIG_SYS_HZ))
367                 return 0;
368         kbd_testc_tms = get_timer(0);
369 #endif
370         dev = stdio_get_by_name(sdev->name);
371         usb_kbd_dev = (struct usb_device *)dev->priv;
372         data = usb_kbd_dev->privptr;
373
374         usb_kbd_poll_for_event(usb_kbd_dev);
375
376         return !(data->usb_in_pointer == data->usb_out_pointer);
377 }
378
379 /* gets the character from the queue */
380 static int usb_kbd_getc(struct stdio_dev *sdev)
381 {
382         struct stdio_dev *dev;
383         struct usb_device *usb_kbd_dev;
384         struct usb_kbd_pdata *data;
385
386         dev = stdio_get_by_name(sdev->name);
387         usb_kbd_dev = (struct usb_device *)dev->priv;
388         data = usb_kbd_dev->privptr;
389
390         while (data->usb_in_pointer == data->usb_out_pointer) {
391                 WATCHDOG_RESET();
392                 usb_kbd_poll_for_event(usb_kbd_dev);
393         }
394
395         if (data->usb_out_pointer == USB_KBD_BUFFER_LEN - 1)
396                 data->usb_out_pointer = 0;
397         else
398                 data->usb_out_pointer++;
399
400         return data->usb_kbd_buffer[data->usb_out_pointer];
401 }
402
403 /* probes the USB device dev for keyboard type. */
404 static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum)
405 {
406         struct usb_interface *iface;
407         struct usb_endpoint_descriptor *ep;
408         struct usb_kbd_pdata *data;
409
410         if (dev->descriptor.bNumConfigurations != 1)
411                 return 0;
412
413         iface = &dev->config.if_desc[ifnum];
414
415         if (iface->desc.bInterfaceClass != USB_CLASS_HID)
416                 return 0;
417
418         if (iface->desc.bInterfaceSubClass != USB_SUB_HID_BOOT)
419                 return 0;
420
421         if (iface->desc.bInterfaceProtocol != USB_PROT_HID_KEYBOARD)
422                 return 0;
423
424         if (iface->desc.bNumEndpoints != 1)
425                 return 0;
426
427         ep = &iface->ep_desc[0];
428
429         /* Check if endpoint 1 is interrupt endpoint */
430         if (!(ep->bEndpointAddress & 0x80))
431                 return 0;
432
433         if ((ep->bmAttributes & 3) != 3)
434                 return 0;
435
436         debug("USB KBD: found set protocol...\n");
437
438         data = malloc(sizeof(struct usb_kbd_pdata));
439         if (!data) {
440                 printf("USB KBD: Error allocating private data\n");
441                 return 0;
442         }
443
444         /* Clear private data */
445         memset(data, 0, sizeof(struct usb_kbd_pdata));
446
447         /* allocate input buffer aligned and sized to USB DMA alignment */
448         data->new = memalign(USB_DMA_MINALIGN,
449                 roundup(USB_KBD_BOOT_REPORT_SIZE, USB_DMA_MINALIGN));
450
451         /* Insert private data into USB device structure */
452         dev->privptr = data;
453
454         /* Set IRQ handler */
455         dev->irq_handle = usb_kbd_irq;
456
457         data->intpipe = usb_rcvintpipe(dev, ep->bEndpointAddress);
458         data->intpktsize = min(usb_maxpacket(dev, data->intpipe),
459                                USB_KBD_BOOT_REPORT_SIZE);
460         data->intinterval = ep->bInterval;
461         data->last_report = -1;
462
463         /* We found a USB Keyboard, install it. */
464         usb_set_protocol(dev, iface->desc.bInterfaceNumber, 0);
465
466         debug("USB KBD: found set idle...\n");
467 #if !defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) && \
468     !defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)
469         usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE / 4, 0);
470 #else
471         usb_set_idle(dev, iface->desc.bInterfaceNumber, 0, 0);
472 #endif
473
474         debug("USB KBD: enable interrupt pipe...\n");
475 #ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
476         data->intq = create_int_queue(dev, data->intpipe, 1,
477                                       USB_KBD_BOOT_REPORT_SIZE, data->new,
478                                       data->intinterval);
479         if (!data->intq) {
480 #elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)
481         if (usb_get_report(dev, iface->desc.bInterfaceNumber,
482                            1, 0, data->new, USB_KBD_BOOT_REPORT_SIZE) < 0) {
483 #else
484         if (usb_int_msg(dev, data->intpipe, data->new, data->intpktsize,
485                         data->intinterval, false) < 0) {
486 #endif
487                 printf("Failed to get keyboard state from device %04x:%04x\n",
488                        dev->descriptor.idVendor, dev->descriptor.idProduct);
489                 /* Abort, we don't want to use that non-functional keyboard. */
490                 return 0;
491         }
492
493         /* Success. */
494         return 1;
495 }
496
497 static int probe_usb_keyboard(struct usb_device *dev)
498 {
499         char *stdinname;
500         struct stdio_dev usb_kbd_dev;
501         int error;
502
503         /* Try probing the keyboard */
504         if (usb_kbd_probe_dev(dev, 0) != 1)
505                 return -ENOENT;
506
507         /* Register the keyboard */
508         debug("USB KBD: register.\n");
509         memset(&usb_kbd_dev, 0, sizeof(struct stdio_dev));
510         strcpy(usb_kbd_dev.name, DEVNAME);
511         usb_kbd_dev.flags =  DEV_FLAGS_INPUT;
512         usb_kbd_dev.getc = usb_kbd_getc;
513         usb_kbd_dev.tstc = usb_kbd_testc;
514         usb_kbd_dev.priv = (void *)dev;
515         error = stdio_register(&usb_kbd_dev);
516         if (error)
517                 return error;
518
519         stdinname = env_get("stdin");
520 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
521         error = iomux_doenv(stdin, stdinname);
522         if (error)
523                 return error;
524 #else
525         /* Check if this is the standard input device. */
526         if (strcmp(stdinname, DEVNAME))
527                 return 1;
528
529         /* Reassign the console */
530         if (overwrite_console())
531                 return 1;
532
533         error = console_assign(stdin, DEVNAME);
534         if (error)
535                 return error;
536 #endif
537
538         return 0;
539 }
540
541 #if !CONFIG_IS_ENABLED(DM_USB)
542 /* Search for keyboard and register it if found. */
543 int drv_usb_kbd_init(void)
544 {
545         int error, i;
546
547         debug("%s: Probing for keyboard\n", __func__);
548         /* Scan all USB Devices */
549         for (i = 0; i < USB_MAX_DEVICE; i++) {
550                 struct usb_device *dev;
551
552                 /* Get USB device. */
553                 dev = usb_get_dev_index(i);
554                 if (!dev)
555                         break;
556
557                 if (dev->devnum == -1)
558                         continue;
559
560                 error = probe_usb_keyboard(dev);
561                 if (!error)
562                         return 1;
563                 if (error && error != -ENOENT)
564                         return error;
565         }
566
567         /* No USB Keyboard found */
568         return -1;
569 }
570
571 /* Deregister the keyboard. */
572 int usb_kbd_deregister(int force)
573 {
574 #if CONFIG_IS_ENABLED(SYS_STDIO_DEREGISTER)
575         struct stdio_dev *dev;
576         struct usb_device *usb_kbd_dev;
577         struct usb_kbd_pdata *data;
578
579         dev = stdio_get_by_name(DEVNAME);
580         if (dev) {
581                 usb_kbd_dev = (struct usb_device *)dev->priv;
582                 data = usb_kbd_dev->privptr;
583                 if (stdio_deregister_dev(dev, force) != 0)
584                         return 1;
585 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
586                 if (iomux_doenv(stdin, env_get("stdin")) != 0)
587                         return 1;
588 #endif
589 #ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
590                 destroy_int_queue(usb_kbd_dev, data->intq);
591 #endif
592                 free(data->new);
593                 free(data);
594         }
595
596         return 0;
597 #else
598         return 1;
599 #endif
600 }
601
602 #endif
603
604 #if CONFIG_IS_ENABLED(DM_USB)
605
606 static int usb_kbd_probe(struct udevice *dev)
607 {
608         struct usb_device *udev = dev_get_parent_priv(dev);
609
610         return probe_usb_keyboard(udev);
611 }
612
613 static int usb_kbd_remove(struct udevice *dev)
614 {
615         struct usb_device *udev = dev_get_parent_priv(dev);
616         struct usb_kbd_pdata *data;
617         struct stdio_dev *sdev;
618         int ret;
619
620         sdev = stdio_get_by_name(DEVNAME);
621         if (!sdev) {
622                 ret = -ENXIO;
623                 goto err;
624         }
625         data = udev->privptr;
626         if (stdio_deregister_dev(sdev, true)) {
627                 ret = -EPERM;
628                 goto err;
629         }
630 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
631         if (iomux_doenv(stdin, env_get("stdin"))) {
632                 ret = -ENOLINK;
633                 goto err;
634         }
635 #endif
636 #ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
637         destroy_int_queue(udev, data->intq);
638 #endif
639         free(data->new);
640         free(data);
641
642         return 0;
643 err:
644         printf("%s: warning, ret=%d", __func__, ret);
645         return ret;
646 }
647
648 static const struct udevice_id usb_kbd_ids[] = {
649         { .compatible = "usb-keyboard" },
650         { }
651 };
652
653 U_BOOT_DRIVER(usb_kbd) = {
654         .name   = "usb_kbd",
655         .id     = UCLASS_KEYBOARD,
656         .of_match = usb_kbd_ids,
657         .probe = usb_kbd_probe,
658         .remove = usb_kbd_remove,
659 };
660
661 static const struct usb_device_id kbd_id_table[] = {
662         {
663                 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
664                         USB_DEVICE_ID_MATCH_INT_SUBCLASS |
665                         USB_DEVICE_ID_MATCH_INT_PROTOCOL,
666                 .bInterfaceClass = USB_CLASS_HID,
667                 .bInterfaceSubClass = USB_SUB_HID_BOOT,
668                 .bInterfaceProtocol = USB_PROT_HID_KEYBOARD,
669         },
670         { }             /* Terminating entry */
671 };
672
673 U_BOOT_USB_DEVICE(usb_kbd, kbd_id_table);
674
675 #endif