summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-03-25 12:22:34 -0600
committerSimon Glass <sjg@chromium.org>2015-04-18 11:11:25 -0600
commit697033cbf0a0bf0e0564b08c8b02dd543b431a2f (patch)
tree1c765949695b6e8e45846f2d6b4c98fa80b3baa6 /common
parent603afaf0e5c895751c3fb24aa0ef05badc44a49e (diff)
downloadu-boot-imx-697033cbf0a0bf0e0564b08c8b02dd543b431a2f.zip
u-boot-imx-697033cbf0a0bf0e0564b08c8b02dd543b431a2f.tar.gz
u-boot-imx-697033cbf0a0bf0e0564b08c8b02dd543b431a2f.tar.bz2
dm: usb: Support driver model with USB keyboards
Allow USB keyboards to work with driver model. The main difference is that we can have multiple buses (each with its own device numbering) and each bus must be scanned. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'common')
-rw-r--r--common/usb_kbd.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index e02529f..24a1a56 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -8,6 +8,7 @@
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
+#include <dm.h>
#include <errno.h>
#include <malloc.h>
#include <stdio_dev.h>
@@ -520,7 +521,37 @@ int drv_usb_kbd_init(void)
{
int error, i;
- debug("%s: Probing for keyboard\n", __func__);/* Scan all USB Devices */
+ debug("%s: Probing for keyboard\n", __func__);
+#ifdef CONFIG_DM_USB
+ /*
+ * TODO: We should add USB_DEVICE() declarations to each USB ethernet
+ * driver and then most of this file can be removed.
+ */
+ struct udevice *bus;
+ struct uclass *uc;
+ int ret;
+
+ ret = uclass_get(UCLASS_USB, &uc);
+ if (ret)
+ return ret;
+ uclass_foreach_dev(bus, uc) {
+ for (i = 0; i < USB_MAX_DEVICE; i++) {
+ struct usb_device *dev;
+
+ dev = usb_get_dev_index(bus, i); /* get device */
+ debug("i=%d, %p\n", i, dev);
+ if (!dev)
+ break; /* no more devices available */
+
+ error = probe_usb_keyboard(dev);
+ if (!error)
+ return 1;
+ if (error && error != -ENOENT)
+ return error;
+ } /* for */
+ }
+#else
+ /* Scan all USB Devices */
for (i = 0; i < USB_MAX_DEVICE; i++) {
struct usb_device *dev;
@@ -538,6 +569,7 @@ int drv_usb_kbd_init(void)
if (error && error != -ENOENT)
return error;
}
+#endif
/* No USB Keyboard found */
return -1;