@@ -368,6 +368,16 @@ static int on_baudrate(const char *name, const char *value, enum env_op op,
U_BOOT_ENV_CALLBACK(baudrate, on_baudrate);
#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
+__weak int board_check_serial(struct udevice *dev)
+{
+ return 0;
+}
+
+static int serial_pre_probe(struct udevice *dev)
+{
+ return board_check_serial(dev);
+}
+
static int serial_post_probe(struct udevice *dev)
{
struct dm_serial_ops *ops = serial_get_ops(dev);
@@ -440,6 +450,7 @@ UCLASS_DRIVER(serial) = {
.name = "serial",
.flags = DM_UC_FLAG_SEQ_ALIAS,
.post_probe = serial_post_probe,
+ .pre_probe = serial_pre_probe,
.pre_remove = serial_pre_remove,
.per_device_auto_alloc_size = sizeof(struct serial_dev_priv),
};
@@ -207,4 +207,15 @@ void sh_serial_initialize(void);
void uartlite_serial_initialize(void);
void zynq_serial_initialize(void);
+/**
+ * board_check_serial() - Determine whether a serial device works
+ *
+ * This is a board callback that allows boards to override whether a serial
+ * device is usable. By default, all devices are declared usable.
+ *
+ * @dev: Device pointer
+ * @return 0 if the device is usable, !0 otherwise
+ */
+int board_check_serial(struct udevice *dev);
+
#endif
On some boards, serial devices may or may not be muxed properly to actual pins, depending on firmware configuration. To determine whether we should use a serial device for U-Boot in-/output, we need to check whether it is muxed properly. This is something only the board file can do, so let's expose a weak function that a board can override to explicitly allow or disallow usage of certain serial devices. Signed-off-by: Alexander Graf <agraf@suse.de> --- drivers/serial/serial-uclass.c | 11 +++++++++++ include/serial.h | 11 +++++++++++ 2 files changed, 22 insertions(+)