Commit b206cd737214d5bce3446c1368add9201dbb1813
1 parent
745009c4d0
Exists in
v2017.01-smarct4x
and in
30 other branches
dm: stdio: Plumb in the new keyboard uclass
When driver model is used for keyboards we must scan the available keyboards and register them with stdio. Add code to do this. At some point (once LCD/video is converted) we should be able to convert stdio to driver model and avoid these dual data structures. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Showing 1 changed file with 30 additions and 1 deletions Side-by-side Diff
common/stdio.c
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | |
12 | 12 | #include <config.h> |
13 | 13 | #include <common.h> |
14 | +#include <dm.h> | |
14 | 15 | #include <errno.h> |
15 | 16 | #include <stdarg.h> |
16 | 17 | #include <malloc.h> |
... | ... | @@ -24,6 +25,8 @@ |
24 | 25 | #include <i2c.h> |
25 | 26 | #endif |
26 | 27 | |
28 | +#include <dm/device-internal.h> | |
29 | + | |
27 | 30 | DECLARE_GLOBAL_DATA_PTR; |
28 | 31 | |
29 | 32 | static struct stdio_dev devs; |
... | ... | @@ -245,6 +248,32 @@ |
245 | 248 | |
246 | 249 | int stdio_add_devices(void) |
247 | 250 | { |
251 | +#ifdef CONFIG_DM_KEYBOARD | |
252 | + struct udevice *dev; | |
253 | + struct uclass *uc; | |
254 | + int ret; | |
255 | + | |
256 | + /* | |
257 | + * For now we probe all the devices here. At some point this should be | |
258 | + * done only when the devices are required - e.g. we have a list of | |
259 | + * input devices to start up in the stdin environment variable. That | |
260 | + * work probably makes more sense when stdio itself is converted to | |
261 | + * driver model. | |
262 | + * | |
263 | + * TODO(sjg@chromium.org): Convert changing uclass_first_device() etc. | |
264 | + * to return the device even on error. Then we could use that here. | |
265 | + */ | |
266 | + ret = uclass_get(UCLASS_KEYBOARD, &uc); | |
267 | + if (ret) | |
268 | + return ret; | |
269 | + | |
270 | + /* Don't report errors to the caller - assume that they are non-fatal */ | |
271 | + uclass_foreach_dev(dev, uc) { | |
272 | + ret = device_probe(dev); | |
273 | + if (ret) | |
274 | + printf("Failed to probe keyboard '%s'\n", dev->name); | |
275 | + } | |
276 | +#endif | |
248 | 277 | #ifdef CONFIG_SYS_I2C |
249 | 278 | i2c_init_all(); |
250 | 279 | #else |
... | ... | @@ -258,7 +287,7 @@ |
258 | 287 | #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) |
259 | 288 | drv_video_init (); |
260 | 289 | #endif |
261 | -#ifdef CONFIG_KEYBOARD | |
290 | +#if defined(CONFIG_KEYBOARD) && !defined(CONFIG_DM_KEYBOARD) | |
262 | 291 | drv_keyboard_init (); |
263 | 292 | #endif |
264 | 293 | #ifdef CONFIG_LOGBUFFER |