From: Hugo Villeneuve <hugo@hugovil.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Cc: hugo@hugovil.com, ilpo.jarvinen@linux.intel.com,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
Hugo Villeneuve <hvilleneuve@dimonoff.com>
Subject: [PATCH v2 11/15] serial: core: add new I/O type for SPI and I2C bus devices
Date: Tue, 28 Apr 2026 13:53:57 -0400 [thread overview]
Message-ID: <20260428-tty-upio-v2-11-01c1857cf761@dimonoff.com> (raw)
In-Reply-To: <20260428-tty-upio-v2-0-01c1857cf761@dimonoff.com>
From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
I2C/SPI serial drivers don't use the following struct uart_port variables:
port->membase
port->mapbase
port->iobase
However, they are forced to set membase to a non-zero value so that
uart_configure_port() will succeed because of the following check:
/* If there isn't a port here, don't do anything further. */
if (!port->iobase && !port->mapbase && !port->membase)
return;
Add a new I/O type for SPI and I2C bus devices to remove the need to
implement the kind of above-mentioned ambiguous workarounds to make them
work. Now that UART report functions are using uart_iotype_*() functions,
no more irrelevant I/O information are being printed for UPIO_BUS iotypes.
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
With this change, uart_match_port() will always return true for UPIO_BUS
types, and this function is not used by any of the SPI/I2C drivers.
---
drivers/tty/serial/serial_core.c | 11 ++++++-----
include/linux/serial_core.h | 1 +
include/uapi/linux/serial.h | 1 +
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d0d4dba41fb9ee43403391d9d599abc1d64b48ec..0e015477848504e37afb34c8088957083f1662c7 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2516,11 +2516,10 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
{
unsigned int flags;
- /*
- * If there isn't a port here, don't do anything further.
- */
- if (!port->iobase && !port->mapbase && !port->membase)
- return;
+ /* If there isn't a port here, don't do anything further. */
+ if (uart_iotype_mmio(port->iotype) || uart_iotype_legacy_io(port->iotype))
+ if (!port->iobase && !port->mapbase && !port->membase)
+ return;
/*
* Now do the auto configuration stuff. Note that config_port
@@ -3216,6 +3215,8 @@ bool uart_match_port(const struct uart_port *port1,
return hub6_match_port(port1, port2);
else if (uart_iotype_mmio(port1->iotype))
return port1->mapbase == port2->mapbase;
+ else if (port1->iotype == UPIO_BUS)
+ return true;
else
return false;
}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index fc3f5ebe389658c197ffc105ce4ac11cacef59bb..626dd939c53c9f920d71aadd360ec0ea0bacce0d 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -437,6 +437,7 @@ enum uart_iotype {
UPIO_TSI = SERIAL_IO_TSI, /* Tsi108/109 type IO */
UPIO_MEM32BE = SERIAL_IO_MEM32BE, /* 32b big endian */
UPIO_MEM16 = SERIAL_IO_MEM16, /* 16b little endian */
+ UPIO_BUS = SERIAL_IO_BUS, /* Serial bus I/O access (ex: SPI, I2C) */
};
struct uart_port {
diff --git a/include/uapi/linux/serial.h b/include/uapi/linux/serial.h
index de9b4733607e6b61b08ff7089ff90070168ff4a2..e6f61538fc2837a264d27942afaaf3f12e743445 100644
--- a/include/uapi/linux/serial.h
+++ b/include/uapi/linux/serial.h
@@ -72,6 +72,7 @@ struct serial_struct {
#define SERIAL_IO_TSI 5
#define SERIAL_IO_MEM32BE 6
#define SERIAL_IO_MEM16 7
+#define SERIAL_IO_BUS 8
#define UART_CLEAR_FIFO 0x01
#define UART_USE_FIFO 0x02
--
2.47.3
next prev parent reply other threads:[~2026-04-28 17:54 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 17:53 [PATCH v2 00/15] serial: add new I/O type for SPI and I2C bus devices Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 01/15] serial: 8250_hub6: add hub6_match_port() Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 02/15] serial: core: add uart_iotype_mmio/legacy_io helper functions Hugo Villeneuve
2026-04-30 15:08 ` Andy Shevchenko
2026-04-30 15:30 ` Hugo Villeneuve
2026-05-01 11:48 ` Andy Shevchenko
2026-05-02 23:25 ` Maciej W. Rozycki
2026-05-04 8:48 ` Andy Shevchenko
2026-05-04 11:44 ` Maciej W. Rozycki
2026-05-04 14:30 ` Andy Shevchenko
2026-05-04 15:20 ` Maciej W. Rozycki
2026-05-04 15:59 ` Andy Shevchenko
2026-04-28 17:53 ` [PATCH v2 03/15] serial: core: use uart_iotype_*() to simplify uart_match_port() Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 04/15] serial: core: use uart_iotype_*() to simplify uart_line_info() Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 05/15] serial: core: replace snprintf with more robust scnprintf Hugo Villeneuve
2026-04-30 15:07 ` Andy Shevchenko
2026-05-04 15:27 ` Hugo Villeneuve
2026-05-04 15:59 ` Andy Shevchenko
2026-04-28 17:53 ` [PATCH v2 06/15] serial: core: fix indentation/alignment Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 07/15] serial: core: use uart_iotype_*() to simplify uart_report_port() Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 08/15] serial: earlycon: use uart_iotype_*() to simplify code Hugo Villeneuve
2026-04-30 15:03 ` Andy Shevchenko
2026-05-04 15:40 ` Hugo Villeneuve
2026-05-04 16:01 ` Andy Shevchenko
2026-04-28 17:53 ` [PATCH v2 09/15] serial: 8250: " Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 10/15] serial: 8250_rsa: " Hugo Villeneuve
2026-04-28 17:53 ` Hugo Villeneuve [this message]
2026-04-28 17:53 ` [PATCH v2 12/15] serial: sc16is7xx: use new UPIO_BUS as iotype Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 13/15] serial: max310x: " Hugo Villeneuve
2026-04-28 17:54 ` [PATCH v2 14/15] serial: max3100: " Hugo Villeneuve
2026-04-28 17:54 ` [PATCH v2 15/15] serial: uniformize serial port I/O infos display Hugo Villeneuve
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=20260428-tty-upio-v2-11-01c1857cf761@dimonoff.com \
--to=hugo@hugovil.com \
--cc=gregkh@linuxfoundation.org \
--cc=hvilleneuve@dimonoff.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/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