struct stdio_dev *stdio_devices[] = { NULL, NULL, NULL };
char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
+int stdio_file_to_flags(const int file)
+{
+ switch (file) {
+ case stdin:
+ return DEV_FLAGS_INPUT;
+ case stdout:
+ case stderr:
+ return DEV_FLAGS_OUTPUT;
+ default:
+ return -EINVAL;
+ }
+}
+
#if CONFIG_IS_ENABLED(SYS_DEVICE_NULLDEV)
static void nulldev_putc(struct stdio_dev *dev, const char c)
{
serial_puts(s);
}
+#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
+static void stdio_serial_flush(struct stdio_dev *dev)
+{
+ serial_flush();
+}
+#endif
+
static int stdio_serial_getc(struct stdio_dev *dev)
{
return serial_getc();
dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
dev.putc = stdio_serial_putc;
dev.puts = stdio_serial_puts;
+ STDIO_DEV_ASSIGN_FLUSH(&dev, stdio_serial_flush);
dev.getc = stdio_serial_getc;
dev.tstc = stdio_serial_tstc;
stdio_register (&dev);
* @name: stdio device name (e.g. "vidconsole")
* id: Uclass ID of device to look for (e.g. UCLASS_VIDEO)
* @sdevp: Returns stdout device, if found, else NULL
- * @return 0 if found, -ENOENT if no device found with that name, other -ve
+ * Return: 0 if found, -ENOENT if no device found with that name, other -ve
* on other error
*/
static int stdio_probe_device(const char *name, enum uclass_id id,
if (strcmp(sdev->name, name) == 0)
return sdev;
}
- if (IS_ENABLED(CONFIG_DM_VIDEO)) {
+ if (IS_ENABLED(CONFIG_VIDEO)) {
/*
* We did not find a suitable stdio device. If there is a video
* driver with a name starting with 'vidconsole', we can try
int stdio_deregister_dev(struct stdio_dev *dev, int force)
{
struct list_head *pos;
- char temp_names[3][16];
+ char temp_names[3][STDIO_NAME_LEN];
int i;
/* get stdio devices (ListRemoveItem changes the dev list) */
/* Device is assigned -> report error */
return -EBUSY;
}
- memcpy(&temp_names[i][0], stdio_devices[i]->name,
- sizeof(temp_names[i]));
+ strlcpy(&temp_names[i][0], stdio_devices[i]->name,
+ sizeof(temp_names[i]));
}
list_del(&dev->list);
int stdio_init_tables(void)
{
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
- /* already relocated for current ARM implementation */
- ulong relocation_offset = gd->reloc_off;
- int i;
-
- /* relocate device name pointers */
- for (i = 0; i < (sizeof (stdio_names) / sizeof (char *)); ++i) {
- stdio_names[i] = (char *) (((ulong) stdio_names[i]) +
- relocation_offset);
- }
-#endif /* CONFIG_NEEDS_MANUAL_RELOC */
-
/* Initialize the list */
INIT_LIST_HEAD(&devs.list);
int stdio_add_devices(void)
{
struct udevice *dev;
- struct uclass *uc;
int ret;
if (IS_ENABLED(CONFIG_DM_KEYBOARD)) {
* have a list of input devices to start up in the stdin
* environment variable. That work probably makes more sense
* when stdio itself is converted to driver model.
- *
- * uclass_first_device() etc. to return the device even on
- * error. Then we could use that here.
*/
- ret = uclass_get(UCLASS_KEYBOARD, &uc);
- if (ret)
- return ret;
/*
* Don't report errors to the caller - assume that they are
* non-fatal
*/
- uclass_foreach_dev(dev, uc) {
- ret = device_probe(dev);
+ for (ret = uclass_first_device_check(UCLASS_KEYBOARD, &dev);
+ dev;
+ ret = uclass_next_device_check(&dev)) {
if (ret)
- printf("Failed to probe keyboard '%s'\n",
- dev->name);
+ printf("%s: Failed to probe keyboard '%s' (ret=%d)\n",
+ __func__, dev->name, ret);
}
}
-#ifdef CONFIG_SYS_I2C
+#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
i2c_init_all();
#endif
- if (IS_ENABLED(CONFIG_DM_VIDEO)) {
+ if (IS_ENABLED(CONFIG_VIDEO)) {
/*
* If the console setting is not in environment variables then
* console_init_r() will not be calling iomux_doenv() (which
int ret;
if (!IS_ENABLED(CONFIG_SYS_CONSOLE_IS_IN_ENV)) {
- for (ret = uclass_first_device(UCLASS_VIDEO, &vdev);
- vdev;
- ret = uclass_next_device(&vdev))
- ;
- if (ret)
- printf("%s: Video device failed (ret=%d)\n",
- __func__, ret);
+ for (ret = uclass_first_device_check(UCLASS_VIDEO,
+ &vdev);
+ vdev;
+ ret = uclass_next_device_check(&vdev)) {
+ if (ret)
+ printf("%s: Failed to probe video device '%s' (ret=%d)\n",
+ __func__, vdev->name, ret);
+ }
}
if (IS_ENABLED(CONFIG_SPLASH_SCREEN) &&
IS_ENABLED(CONFIG_CMD_BMP))
splash_display();
- } else {
- if (IS_ENABLED(CONFIG_LCD))
- drv_lcd_init();
- if (IS_ENABLED(CONFIG_VIDEO) ||
- IS_ENABLED(CONFIG_CFB_CONSOLE) ||
- IS_ENABLED(CONFIG_VIDEO_VCXK))
- drv_video_init();
}
-#if defined(CONFIG_KEYBOARD) && !defined(CONFIG_DM_KEYBOARD)
- drv_keyboard_init();
-#endif
drv_system_init();
serial_stdio_init();
#ifdef CONFIG_USB_TTY
drv_usbtty_init();
+#endif
+#ifdef CONFIG_USB_FUNCTION_ACM
+ drv_usbacm_init ();
#endif
if (IS_ENABLED(CONFIG_NETCONSOLE))
drv_nc_init();
return 0;
}
-
-int stdio_init(void)
-{
- stdio_init_tables();
- stdio_add_devices();
-
- return 0;
-}