From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable
Date: Wed, 17 Jan 2018 09:54:53 +0100 [thread overview]
Message-ID: <20180117085458.27293-3-agraf@suse.de> (raw)
In-Reply-To: <20180117085458.27293-1-agraf@suse.de>
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(+)
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 68ca2d09d1..ecd64f8e86 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -366,6 +366,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);
@@ -438,6 +448,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),
};
diff --git a/include/serial.h b/include/serial.h
index d87f01082a..221b3e1402 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -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
--
2.12.3
next prev parent reply other threads:[~2018-01-17 8:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 8:54 [U-Boot] [PATCH v2 0/7] RPi: Properly handle dynamic serial configuration Alexander Graf
2018-01-17 8:54 ` [U-Boot] [PATCH v2 1/7] serial: Use next serial device if probing fails Alexander Graf
2018-01-17 10:54 ` Heinrich Schuchardt
2018-01-17 19:34 ` Simon Glass
2018-01-17 22:02 ` Alexander Graf
2018-01-17 8:54 ` Alexander Graf [this message]
2018-01-17 19:39 ` [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable Simon Glass
2018-01-17 22:03 ` Alexander Graf
2018-01-17 22:11 ` Simon Glass
2018-01-17 22:37 ` Alexander Graf
2018-01-17 23:18 ` Simon Glass
2018-01-17 8:54 ` [U-Boot] [PATCH v2 3/7] rpi: Remove runtime disabling support for serial Alexander Graf
2018-01-17 8:54 ` [U-Boot] [PATCH v2 4/7] serial: bcm283x_mu: Remove support for post-init disabling Alexander Graf
2018-01-17 8:54 ` [U-Boot] [PATCH v2 5/7] rpi: Properly detect which serial device is active Alexander Graf
2018-01-17 19:46 ` Simon Glass
2018-01-17 22:05 ` Alexander Graf
2018-01-17 23:18 ` Simon Glass
2018-01-17 8:54 ` [U-Boot] [PATCH v2 6/7] rpi: Determine PL011/Mini-UART availability at runtime Alexander Graf
2018-01-17 8:54 ` [U-Boot] [PATCH v2 7/7] rpi: Force skip_init on serial devices Alexander Graf
2018-01-17 19:40 ` Simon Glass
2018-01-17 22:08 ` Alexander Graf
2018-01-17 23:18 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180117085458.27293-3-agraf@suse.de \
--to=agraf@suse.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox