ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de, linux-sunxi@lists.linux.dev,
	Samuel Holland <samuel@sholland.org>
Subject: [PATCH] ns16550: Fix DM serial operation with non-DM SPL
Date: Tue, 17 Jan 2023 12:09:38 +0000	[thread overview]
Message-ID: <20230117120938.818180-1-andre.przywara@arm.com> (raw)

Commit 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig")
moved some NS16550 configuration variables into Kconfig.
Among those there is CONFIG_SYS_NS16550_REG_SIZE, which used to be only
defined for SPL build runs, but now is always set (thanks for Kconfig).
However this breaks the gating logic in ns16550.h, where we *override*
this variable for DM build, as we learn this setting from the DT instead.

As a consequence, we did the register shift twice: once when building
the register struct (as required for non-DM SPL builds), but then also
again in the driver after we parsed the reg-shift DT property.

Change the logic to match what the comment says: only observe
CONFIG_SYS_NS16550_REG_SIZE when not using DM, and ignore it otherwise.

This fixes U-Boot proper for all sunxi boards, since they are relying
on this driver being build non-DM for the SPL, but DM for U-Boot proper.

Fixes: 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig")
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
Hi,

this is admittedly a quick fix, to get sunxi booting again. This whole
code around the register access looks somewhat bonkers, to be honest,
but at the moment I don't have time to rework this.
Another possible "quicker fix" would be use a separate variable for the
register shift, so that we don't have to redefine a Kconfig variable.
Another idea would be to get rid of the struct for the registers
altogether, to remove the hacks about when to shift.

Cheers,
Andre

 include/ns16550.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/ns16550.h b/include/ns16550.h
index 243226fc3d9..e9e2aeedd16 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -26,11 +26,12 @@
 
 #include <linux/types.h>
 
-#if CONFIG_IS_ENABLED(DM_SERIAL) && !defined(CONFIG_SYS_NS16550_REG_SIZE)
+#if CONFIG_IS_ENABLED(DM_SERIAL)
 /*
  * For driver model we always use one byte per register, and sort out the
  * differences in the driver
  */
+#undef CONFIG_SYS_NS16550_REG_SIZE
 #define CONFIG_SYS_NS16550_REG_SIZE (-1)
 #endif
 
-- 
2.25.1


             reply	other threads:[~2023-01-17 12:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 12:09 Andre Przywara [this message]
2023-01-17 13:12 ` [PATCH] ns16550: Fix DM serial operation with non-DM SPL Sergei Antonov
2023-01-17 16:13   ` Andre Przywara
2023-01-18 13:08     ` Sergei Antonov
2023-01-17 16:16   ` Tom Rini
2023-01-17 13:15 ` Tom Rini
2023-01-17 15:55   ` Tom Rini
2023-01-17 16:09   ` Andre Przywara
2023-01-17 16:14     ` Tom Rini
2023-01-17 22:15       ` Andre Przywara
2023-01-17 22:23         ` Tom Rini
2023-01-17 23:35           ` Andre Przywara

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=20230117120938.818180-1-andre.przywara@arm.com \
    --to=andre.przywara@arm.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=samuel@sholland.org \
    --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