u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: Tom Rini <trini@konsulko.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Liviu Dudau <liviu.dudau@foss.arm.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Simon Glass <sjg@chromium.org>,
	u-boot@lists.denx.de, Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH v3 24/29] serial: smh: Initialize serial only if semihosting is enabled
Date: Tue, 22 Mar 2022 16:59:32 -0400	[thread overview]
Message-ID: <20220322205938.1721846-25-sean.anderson@seco.com> (raw)
In-Reply-To: <20220322205938.1721846-1-sean.anderson@seco.com>

If semihosting is disabled, then the user has no debugger attached, and
will not see any messages. Don't create a serial device in this
instance, to (hopefully) fall back on another working serial device.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

(no changes since v2)

Changes in v2:
- New

 drivers/serial/serial_semihosting.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/serial_semihosting.c b/drivers/serial/serial_semihosting.c
index 7c7c5d9455..62b1b2241b 100644
--- a/drivers/serial/serial_semihosting.c
+++ b/drivers/serial/serial_semihosting.c
@@ -41,6 +41,13 @@ static const struct dm_serial_ops smh_serial_ops = {
 	.getc = smh_serial_getc,
 };
 
+static int smh_serial_bind(struct udevice *dev)
+{
+	if (semihosting_enabled())
+		return 0;
+	return -ENOENT;
+}
+
 static int smh_serial_probe(struct udevice *dev)
 {
 	struct smh_serial_priv *priv = dev_get_priv(dev);
@@ -52,6 +59,7 @@ static int smh_serial_probe(struct udevice *dev)
 U_BOOT_DRIVER(smh_serial) = {
 	.name	= "serial_semihosting",
 	.id	= UCLASS_SERIAL,
+	.bind	= smh_serial_bind,
 	.probe	= smh_serial_probe,
 	.priv_auto = sizeof(struct smh_serial_priv),
 	.ops	= &smh_serial_ops,
@@ -122,7 +130,8 @@ struct serial_device serial_smh_device = {
 
 void smh_serial_initialize(void)
 {
-	serial_register(&serial_smh_device);
+	if (semihosting_enabled())
+		serial_register(&serial_smh_device);
 }
 
 __weak struct serial_device *default_serial_console(void)
-- 
2.25.1


  parent reply	other threads:[~2022-03-22 21:03 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22 20:59 [PATCH v3 00/29] arm: semihosting: Cleanups and new features Sean Anderson
2022-03-22 20:59 ` [PATCH v3 01/29] doc: Convert semihosting readme to rST Sean Anderson
2022-03-22 22:05   ` Heinrich Schuchardt
2022-03-22 23:16     ` Sean Anderson
2022-04-03  0:14   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 02/29] nxp: ls1046ardb: Convert README " Sean Anderson
2022-04-03  0:14   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 03/29] doc: ls1046ardb: Expand boot mode section Sean Anderson
2022-04-03  0:14   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 04/29] doc: ls1046ardb: Document debug uart Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 05/29] arm: smh: Add semihosting entry to MAINTAINERS Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 06/29] arm: smh: Export semihosting functions Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 07/29] arm: smh: Use numeric modes for smh_open Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 08/29] arm: smh: Return errno on error Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 09/29] arm: smh: Document functions in header Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 10/29] arm: smh: Add some file manipulation commands Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 11/29] spl: Add semihosting boot method Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 12/29] fs: Add semihosting filesystem Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 13/29] cmd: fdt: Use start/size for chosen instead of start/end Sean Anderson
2022-04-03  0:15   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 14/29] arm: smh: Remove smhload command Sean Anderson
2022-04-03  0:16   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 15/29] arm: smh: Add some functions for working with the host console Sean Anderson
2022-04-03  0:16   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 16/29] serial: Add semihosting driver Sean Anderson
2022-03-28  6:35   ` Simon Glass
2022-03-28  6:35   ` Simon Glass
2022-03-28 15:36     ` Sean Anderson
2022-03-28 16:03       ` Tom Rini
2022-03-28 16:14         ` Layerscape DM_SERIAL (Was: Re: [PATCH v3 16/29] serial: Add semihosting driver) Sean Anderson
2022-04-03  0:16   ` [PATCH v3 16/29] serial: Add semihosting driver Tom Rini
2022-03-22 20:59 ` [PATCH v3 17/29] doc: smh: Update semihosting documentation Sean Anderson
2022-04-03  0:16   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 20/29] arm64: Save spsr in pt_regs Sean Anderson
2022-04-03  0:16   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 22/29] arm: smh: Add option to detect semihosting Sean Anderson
2022-04-03  0:16   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 23/29] arm64: Catch non-emulated semihosting calls Sean Anderson
2022-04-03  0:16   ` Tom Rini
2022-03-22 20:59 ` Sean Anderson [this message]
2022-04-03  0:16   ` [PATCH v3 24/29] serial: smh: Initialize serial only if semihosting is enabled Tom Rini
2022-03-22 20:59 ` [PATCH v3 25/29] arm64: ls1046a: Support semihosting fallback Sean Anderson
2022-04-03  0:16   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 26/29] serial: dm: Add support for puts Sean Anderson
2022-03-28  6:35   ` Simon Glass
2022-04-03  0:16   ` Tom Rini
2022-03-22 20:59 ` [PATCH v3 27/29] serial: sandbox: Implement puts Sean Anderson
2022-03-28  6:35   ` Simon Glass
2022-04-01 22:39   ` Tom Rini
2022-04-04 18:26     ` Sean Anderson
2022-03-22 20:59 ` [PATCH v3 29/29] serial: smh: Implement puts for DM Sean Anderson
2022-03-22 21:16 ` [RESEND PATCH v3 18/29] ls1046ardb: Add support for JTAG boot Sean Anderson
2022-04-03  0:17   ` Tom Rini
2022-03-22 21:17 ` [RESEND PATCH v3 19/29] arm64: Save esr in pt_regs Sean Anderson
2022-04-03  0:17   ` Tom Rini
2022-03-22 21:18 ` [RESEND PATCH v3 21/29] arm64: Import some ESR and SPSR defines from Linux Sean Anderson
2022-04-03  0:17   ` Tom Rini
2022-03-22 21:19 ` [RESEND PATCH v3 28/29] test: serial: Add test for putc/puts Sean Anderson
2022-03-22 22:11 ` [PATCH v3 00/29] arm: semihosting: Cleanups and new features Heinrich Schuchardt
2022-03-22 23:21   ` Sean Anderson
     [not found] ` <20220322205938.1721846-29-sean.anderson@seco.com>
2022-03-28  6:35   ` [PATCH v3 28/29] test: serial: Add test for putc/puts Simon Glass
2022-03-28 15:37     ` Sean Anderson

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=20220322205938.1721846-25-sean.anderson@seco.com \
    --to=sean.anderson@seco.com \
    --cc=andre.przywara@arm.com \
    --cc=linus.walleij@linaro.org \
    --cc=liviu.dudau@foss.arm.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --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;
as well as URLs for NNTP newsgroup(s).