From: Parker Newman <[email protected]>
Hello,
These patches add proper support for most of Connect Tech's (CTI) Exar
based serial cards. Previously, only a subset of CTI's cards would work
with the Exar driver while the rest required the CTI out-of-tree driver.
These patches are intended to phase out the out-of-tree driver.
I am new to the mailing lists and contributing to the kernel so please
let me know if I have made any mistakes or if you have any feedback.
Changes in v2:
- Put missing PCI IDs in 8250_exar.c instead of pci_ids.h
- Split large patch into smaller ones
Changes in v3:
- Refactored patches to be easier to follow (based on feedback of v2)
- Patch specific changes listed in corresponding patch
Thank you,
Parker Newman (8):
serial: exar: adding missing CTI and Exar PCI ids
serial: exar: remove old Connect Tech setup
serial: exar: added a exar_get_nr_ports function
serial: exar: add optional board_init function
serial: exar: moved generic_rs485 further up in 8250_exar.c
serial: exar: add CTI cards to exar_get_nr_ports
serial: exar: add CTI specific setup code
serial: exar: fix: fix crash during shutdown if setup fails
drivers/tty/serial/8250/8250_exar.c | 1079 +++++++++++++++++++++++++--
1 file changed, 1013 insertions(+), 66 deletions(-)
base-commit: fec50db7033ea478773b159e0e2efb135270e3b7
--
2.43.2
From: Parker Newman <[email protected]>
- Add an optional "board_init()" function pointer to struct
exar8250_board which is called once during probe prior to setting up
the ports.
- Fix several "missing identifier name" warnings from checkpatch in
struct exar8250_platform and struct exar8250_board:
WARNING: function definition argument <arg> should also have an
identifier name
- Fix warning from checkpatch:
WARNING: please, no space before tabs
+ * 0^I^I2 ^IMode bit 0$
Changes in v3:
- Renamed board_setup to board_init.
- Changed pci_err to dev_err_probe
- Added note above about checkpatch fixes
Signed-off-by: Parker Newman <[email protected]>
---
drivers/tty/serial/8250/8250_exar.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 388dd60ad23a..cf7900bd2974 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -133,7 +133,7 @@
*
* MPIO Port Function
* ---- ---- --------
- * 0 2 Mode bit 0
+ * 0 2 Mode bit 0
* 1 2 Mode bit 1
* 2 2 Terminate bus
* 3 - <reserved>
@@ -169,22 +169,24 @@ struct exar8250_platform {
int (*rs485_config)(struct uart_port *port, struct ktermios *termios,
struct serial_rs485 *rs485);
const struct serial_rs485 *rs485_supported;
- int (*register_gpio)(struct pci_dev *, struct uart_8250_port *);
- void (*unregister_gpio)(struct uart_8250_port *);
+ int (*register_gpio)(struct pci_dev *pcidev, struct uart_8250_port *port);
+ void (*unregister_gpio)(struct uart_8250_port *port);
};
/**
* struct exar8250_board - board information
* @num_ports: number of serial ports
* @reg_shift: describes UART register mapping in PCI memory
- * @setup: quirk run at ->probe() stage
+ * @board_init: quirk run once at ->probe() stage before setting up ports
+ * @setup: quirk run at ->probe() stage for each port
* @exit: quirk run at ->remove() stage
*/
struct exar8250_board {
unsigned int num_ports;
unsigned int reg_shift;
- int (*setup)(struct exar8250 *, struct pci_dev *,
- struct uart_8250_port *, int);
+ int (*board_init)(struct exar8250 *priv);
+ int (*setup)(struct exar8250 *priv, struct pci_dev *pcidev,
+ struct uart_8250_port *port, int idx);
void (*exit)(struct pci_dev *pcidev);
};
@@ -772,6 +774,15 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
if (rc)
return rc;
+ if (board->board_init) {
+ rc = board->board_init(priv);
+ if (rc) {
+ dev_err_probe(&pcidev->dev, rc,
+ "failed to init serial board\n");
+ return rc;
+ }
+ }
+
for (i = 0; i < nr_ports && i < maxnr; i++) {
rc = board->setup(priv, pcidev, &uart, i);
if (rc) {
--
2.43.2
From: Parker Newman <[email protected]>
Preparatory patch moving generic_rs485_config and
generic_rs485_supported higher in the file to allow for CTI setup
functions to use it.
Changes in v3:
- split into separate preparatory patch
Signed-off-by: Parker Newman <[email protected]>
---
drivers/tty/serial/8250/8250_exar.c | 50 ++++++++++++++---------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index cf7900bd2974..7e47a4145c7b 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -197,6 +197,31 @@ struct exar8250 {
int line[];
};
+static int generic_rs485_config(struct uart_port *port, struct ktermios *termios,
+ struct serial_rs485 *rs485)
+{
+ bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
+ u8 __iomem *p = port->membase;
+ u8 value;
+
+ value = readb(p + UART_EXAR_FCTR);
+ if (is_rs485)
+ value |= UART_FCTR_EXAR_485;
+ else
+ value &= ~UART_FCTR_EXAR_485;
+
+ writeb(value, p + UART_EXAR_FCTR);
+
+ if (is_rs485)
+ writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
+
+ return 0;
+}
+
+static const struct serial_rs485 generic_rs485_supported = {
+ .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND,
+};
+
static void exar_pm(struct uart_port *port, unsigned int state, unsigned int old)
{
/*
@@ -458,27 +483,6 @@ static void xr17v35x_unregister_gpio(struct uart_8250_port *port)
port->port.private_data = NULL;
}
-static int generic_rs485_config(struct uart_port *port, struct ktermios *termios,
- struct serial_rs485 *rs485)
-{
- bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
- u8 __iomem *p = port->membase;
- u8 value;
-
- value = readb(p + UART_EXAR_FCTR);
- if (is_rs485)
- value |= UART_FCTR_EXAR_485;
- else
- value &= ~UART_FCTR_EXAR_485;
-
- writeb(value, p + UART_EXAR_FCTR);
-
- if (is_rs485)
- writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
-
- return 0;
-}
-
static int sealevel_rs485_config(struct uart_port *port, struct ktermios *termios,
struct serial_rs485 *rs485)
{
@@ -517,10 +521,6 @@ static int sealevel_rs485_config(struct uart_port *port, struct ktermios *termio
return 0;
}
-static const struct serial_rs485 generic_rs485_supported = {
- .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND,
-};
-
static const struct exar8250_platform exar8250_default_platform = {
.register_gpio = xr17v35x_register_gpio,
.unregister_gpio = xr17v35x_unregister_gpio,
--
2.43.2
On Tue, Apr 16, 2024 at 08:55:31AM -0400, Parker Newman wrote:
> From: Parker Newman <[email protected]>
>
> - Add an optional "board_init()" function pointer to struct
> exar8250_board which is called once during probe prior to setting up
> the ports.
>
> - Fix several "missing identifier name" warnings from checkpatch in
> struct exar8250_platform and struct exar8250_board:
>
> WARNING: function definition argument <arg> should also have an
> identifier name
>
> - Fix warning from checkpatch:
> WARNING: please, no space before tabs
> + * 0^I^I2 ^IMode bit 0$
>
> Changes in v3:
> - Renamed board_setup to board_init.
> - Changed pci_err to dev_err_probe
> - Added note above about checkpatch fixes
>
> Signed-off-by: Parker Newman <[email protected]>
> ---
> drivers/tty/serial/8250/8250_exar.c | 23 +++++++++++++++++------
> 1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 388dd60ad23a..cf7900bd2974 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -133,7 +133,7 @@
> *
> * MPIO Port Function
> * ---- ---- --------
> - * 0 2 Mode bit 0
> + * 0 2 Mode bit 0
This change isn't related to the exar8250_board change, right?
Just keep exar8250_board change as one patch, and the coding style
warning fixups as one for the very end, after you add all of your new
functionality.
thanks,
greg k-h
On Tue, Apr 16, 2024 at 08:55:27AM -0400, Parker Newman wrote:
> From: Parker Newman <[email protected]>
>
> Hello,
> These patches add proper support for most of Connect Tech's (CTI) Exar
> based serial cards. Previously, only a subset of CTI's cards would work
> with the Exar driver while the rest required the CTI out-of-tree driver.
> These patches are intended to phase out the out-of-tree driver.
>
> I am new to the mailing lists and contributing to the kernel so please
> let me know if I have made any mistakes or if you have any feedback.
Much better. I took the 1st patch already in my tree to make it
hopefully easire for you to rebase and redo the rest.
thanks,
greg k-h
On Wed, 17 Apr 2024 13:24:49 +0200
Greg Kroah-Hartman <[email protected]> wrote:
> On Tue, Apr 16, 2024 at 08:55:27AM -0400, Parker Newman wrote:
> > From: Parker Newman <[email protected]>
> >
> > Hello,
> > These patches add proper support for most of Connect Tech's (CTI) Exar
> > based serial cards. Previously, only a subset of CTI's cards would work
> > with the Exar driver while the rest required the CTI out-of-tree driver.
> > These patches are intended to phase out the out-of-tree driver.
> >
> > I am new to the mailing lists and contributing to the kernel so please
> > let me know if I have made any mistakes or if you have any feedback.
>
> Much better. I took the 1st patch already in my tree to make it
> hopefully easire for you to rebase and redo the rest.
>
> thanks,
>
> greg k-h
I will resend with the updates.
I have been using the "main" branch of gregkh/tty.git so far. Is that correct?
Or should I be using "tty-testing"?
Thanks again for bearing with me while I figure this out :).
Parker
On Wed, Apr 17, 2024 at 09:26:41AM -0400, Parker Newman wrote:
> On Wed, 17 Apr 2024 13:24:49 +0200
> Greg Kroah-Hartman <[email protected]> wrote:
>
> > On Tue, Apr 16, 2024 at 08:55:27AM -0400, Parker Newman wrote:
> > > From: Parker Newman <[email protected]>
> > >
> > > Hello,
> > > These patches add proper support for most of Connect Tech's (CTI) Exar
> > > based serial cards. Previously, only a subset of CTI's cards would work
> > > with the Exar driver while the rest required the CTI out-of-tree driver.
> > > These patches are intended to phase out the out-of-tree driver.
> > >
> > > I am new to the mailing lists and contributing to the kernel so please
> > > let me know if I have made any mistakes or if you have any feedback.
> >
> > Much better. I took the 1st patch already in my tree to make it
> > hopefully easire for you to rebase and redo the rest.
> >
> > thanks,
> >
> > greg k-h
>
> I will resend with the updates.
> I have been using the "main" branch of gregkh/tty.git so far. Is that correct?
> Or should I be using "tty-testing"?
tty-testing is where things go before they are considered "good enough"
to get into "tty-next" which is never rebased, and is what will be sent
to Linus for the "next" kernel release (not this one.)
Sometimes it is rebased if I mess things up, but usually it's pretty
stable. Patches only sit in there for 24 hours usually before ending up
in "tty-next"
"main" just tracks Linus's branch, don't use it, I just need a branch to
diff against.
"tty-linus" is what will be sent to Linus for "this" release (i.e. bug
fixes only.)
Or you can just work off of the linux-next tree, which merges in both of
my tty-next and tty-linus branches together (and all other maintainer
trees/branches), every day, and is usually a good base for what will be
the "next" release after this one.
hope this helps,
greg k-h