Skip to contentSkip to conversation

Add support for SUNIX multi I/O board

PATCH Moriis Ku 2 participants 2 messages Apr 26, 2021 TTY layer and serial drivers

lore
Share & tools
lore

Moriis Ku

author
#0 lore raw

From: Morris Ku <[email protected]>

Sunix SDC Multi I/O board are different to Timedia's.

This patch adds proper support for Sunix SDC Multi I/O board.

---
 tty/serial/8250/8250_pci.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
tty/serial/8250/8250_pci.c +35 -1
index 8814ff38..5758a98b 100644
@@ -1802,6 +1802,25 @@ pci_sunix_setup(struct serial_private *priv,
 	return setup_port(priv, port, bar, offset, 0);
 }
 
+static int
+pci_sunix_sdc_setup(struct serial_private *priv,
+		const struct pciserial_board *board,
+		struct uart_8250_port *port, int idx)
+{
+	int bar;
+	int offset;
+
+	port->port.flags |= UPF_FIXED_TYPE;
+	port->port.type = PORT_SUNIX;
+
+	if (idx < 4) {
+		bar = 1
+		offset = idx * board->uart_offset;
+	}
+
+	return setup_port(priv, port, bar, offset, 0);
+}
+
 static int
 pci_moxa_setup(struct serial_private *priv,
 		const struct pciserial_board *board,
@@ -2430,6 +2449,13 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
 		.subdevice	= PCI_ANY_ID,
 		.setup		= pci_sunix_setup,
 	},
+	{
+		.vendor		= PCI_VENDOR_ID_SUNIX,
+		.device		= PCI_DEVICE_ID_SUNIX_2000,
+		.subvendor	= PCI_VENDOR_ID_SUNIX,
+		.subdevice	= PCI_ANY_ID,
+		.setup		= pci_sunix_sdc_setup,
+	},
 	/*
 	 * Xircom cards
 	 */
@@ -2924,6 +2950,7 @@ enum pci_board_num_t {
 	pbn_sunix_pci_4s,
 	pbn_sunix_pci_8s,
 	pbn_sunix_pci_16s,
+	pbn_sunix_sdc_pci_4s
 	pbn_moxa8250_2p,
 	pbn_moxa8250_4p,
 	pbn_moxa8250_8p,
@@ -3704,6 +3731,11 @@ static struct pciserial_board pci_boards[] = {
 		.base_baud      = 921600,
 		.uart_offset	= 0x8,
 	},
+	[pbn_sunix_sdc_pci_4s] = {
+		.num_ports	= 4,
+		.base_baud      = 921600,
+		.uart_offset	= 0x10,
+	},
 	[pbn_moxa8250_2p] = {
 		.flags		= FL_BASE1,
 		.num_ports      = 2,
@@ -4783,7 +4815,9 @@ static const struct pci_device_id serial_pci_tbl[] = {
 	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
 		PCI_VENDOR_ID_SUNIX, 0x0010, 0, 0,
 		pbn_sunix_pci_16s },
-
+	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_2000,
+		PCI_VENDOR_ID_SUNIX, 0x0001, 0, 0,
+		pbn_sunix_sdc_pci_4s },
 	/*
 	 * AFAVLAB serial card, from Harald Welte <[email protected]>
 	 */
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 7 lines · Moriis Ku

From: Morris Ku <[email protected]>

Sunix SDC Multi I/O board are different to Timedia's.

This patch adds proper support for Sunix SDC Multi I/O board.

Can you make your subject line look like:

	[PATCH] serial: 8250_pci: add support for...

to match up the other patches for this driver?

Quoted 9 lines
---
 tty/serial/8250/8250_pci.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
tty/serial/8250/8250_pci.c +0 -0
index 8814ff38..5758a98b 100644

tty/serial/8250/8250_pci.c pci_sunix_setup(struct serial_private *priv, · line 1806

Quoted 5 lines
tty/serial/8250/8250_pci.c +2 -0
@@ -1802,6 +1802,25 @@ pci_sunix_setup(struct serial_private *priv,
 	return setup_port(priv, port, bar, offset, 0);
 }
 
+static int
+pci_sunix_sdc_setup(struct serial_private *priv,

Move this to be all on one line please.

tty/serial/8250/8250_pci.c pci_sunix_setup(struct serial_private *priv, · line 1808

Quoted 2 lines
tty/serial/8250/8250_pci.c +2 -0
+		const struct pciserial_board *board,
+		struct uart_8250_port *port, int idx)

Line up with the "(" or checkpatch will complain.

tty/serial/8250/8250_pci.c pci_sunix_setup(struct serial_private *priv, · line 1819

Quoted 11 lines
tty/serial/8250/8250_pci.c +11 -0
+{
+	int bar;
+	int offset;
+
+	port->port.flags |= UPF_FIXED_TYPE;
+	port->port.type = PORT_SUNIX;
+
+	if (idx < 4) {
+		bar = 1
+		offset = idx * board->uart_offset;
+	}

So if idx is > 4, bar is unknown? That feels like a huge bug :(

tty/serial/8250/8250_pci.c pci_sunix_setup(struct serial_private *priv, · line 1821

Quoted 2 lines
tty/serial/8250/8250_pci.c +2 -0
+
+	return setup_port(priv, port, bar, offset, 0);

Same for offset, looks like it could be used uninitialized as well.

The compiler didn't complain about this?

thanks,

greg k-h