+config REQUIRE_SERIAL_CONSOLE
+ bool "Require a serial port for console"
+ # Running without a serial console is not supported by the
+ # non-dm serial code
+ depends on DM_SERIAL
+ default y
+ help
+ Require a serial port for the console, and panic if none is found
+ during serial port initialization (default y). Set this to n on
+ boards which have no debug serial port whatsoever.
+
config DM_SERIAL
bool "Enable Driver Model for serial drivers"
depends on DM
#undef INDEX
}
+#ifdef CONFIG_REQUIRE_SERIAL_CONSOLE
panic_str("No serial driver found");
+#endif
}
/* Called prior to relocation */
void serial_putc(char ch)
{
- _serial_putc(gd->cur_serial_dev, ch);
+ if (gd->cur_serial_dev)
+ _serial_putc(gd->cur_serial_dev, ch);
}
void serial_puts(const char *str)
{
- _serial_puts(gd->cur_serial_dev, str);
+ if (gd->cur_serial_dev)
+ _serial_puts(gd->cur_serial_dev, str);
}
int serial_getc(void)
{
+ if (!gd->cur_serial_dev)
+ return 0;
+
return _serial_getc(gd->cur_serial_dev);
}
int serial_tstc(void)
{
+ if (!gd->cur_serial_dev)
+ return 0;
+
return _serial_tstc(gd->cur_serial_dev);
}
void serial_setbrg(void)
{
- struct dm_serial_ops *ops = serial_get_ops(gd->cur_serial_dev);
+ struct dm_serial_ops *ops;
+
+ if (!gd->cur_serial_dev)
+ return;
+ ops = serial_get_ops(gd->cur_serial_dev);
if (ops->setbrg)
ops->setbrg(gd->cur_serial_dev, gd->baudrate);
}