linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards
@ 2019-08-09 19:01 Kai-Heng Feng
  2019-08-09 19:01 ` [PATCH v2 2/2] parport: parport_serial: Add support for Sunix Multi I/O boards Kai-Heng Feng
  2019-08-10 13:18 ` [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Kai-Heng Feng @ 2019-08-09 19:01 UTC (permalink / raw)
  To: gregkh, sudipm.mukherjee
  Cc: linux-serial, linux-kernel, Kai-Heng Feng, Morris Ku, Debbie Liu

Add support to Sunix serial boards with up to 16 ports.

Sunix board need its own setup callback instead of using Timedia's, to
properly support more than 4 ports.

Cc: Morris Ku <morris_ku@sunix.com>
Cc: Debbie Liu <debbie_liu@sunix.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v2:
 use div64_s64() instead of do_div()

 drivers/tty/serial/8250/8250_pci.c  | 93 +++++++++++++++++++++++------
 drivers/tty/serial/8250/8250_port.c |  8 +++
 include/uapi/linux/serial_core.h    |  3 +
 3 files changed, 87 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 7f740b37700b..b2a5c2228858 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -1692,6 +1692,30 @@ pci_wch_ch38x_setup(struct serial_private *priv,
 	return pci_default_setup(priv, board, port, idx);
 }
 
+static int
+pci_sunix_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 = 0;
+		offset = idx * board->uart_offset;
+	} else {
+		bar = 1;
+		idx -= 4;
+		idx = div_s64_rem(idx, 4, &offset);
+		offset = idx * 64 + offset * board->uart_offset;
+	}
+
+	return setup_port(priv, port, bar, offset, 0);
+}
+
 #define PCI_VENDOR_ID_SBSMODULARIO	0x124B
 #define PCI_SUBVENDOR_ID_SBSMODULARIO	0x124B
 #define PCI_DEVICE_ID_OCTPRO		0x0001
@@ -2289,21 +2313,14 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
 		.setup		= pci_timedia_setup,
 	},
 	/*
-	 * SUNIX (Timedia) cards
-	 * Do not "probe" for these cards as there is at least one combination
-	 * card that should be handled by parport_pc that doesn't match the
-	 * rule in pci_timedia_probe.
-	 * It is part number is MIO5079A but its subdevice ID is 0x0102.
-	 * There are some boards with part number SER5037AL that report
-	 * subdevice ID 0x0002.
+	 * Sunix PCI serial boards
 	 */
 	{
 		.vendor		= PCI_VENDOR_ID_SUNIX,
 		.device		= PCI_DEVICE_ID_SUNIX_1999,
 		.subvendor	= PCI_VENDOR_ID_SUNIX,
 		.subdevice	= PCI_ANY_ID,
-		.init		= pci_timedia_init,
-		.setup		= pci_timedia_setup,
+		.setup		= pci_sunix_setup,
 	},
 	/*
 	 * Xircom cards
@@ -2757,6 +2774,11 @@ enum pci_board_num_t {
 	pbn_pericom_PI7C9X7952,
 	pbn_pericom_PI7C9X7954,
 	pbn_pericom_PI7C9X7958,
+	pbn_sunix_pci_1s,
+	pbn_sunix_pci_2s,
+	pbn_sunix_pci_4s,
+	pbn_sunix_pci_8s,
+	pbn_sunix_pci_16s,
 };
 
 /*
@@ -3494,6 +3516,31 @@ static struct pciserial_board pci_boards[] = {
 		.base_baud      = 921600,
 		.uart_offset	= 0x8,
 	},
+	[pbn_sunix_pci_1s] = {
+		.num_ports	= 1,
+		.base_baud      = 921600,
+		.uart_offset	= 0x8,
+	},
+	[pbn_sunix_pci_2s] = {
+		.num_ports	= 2,
+		.base_baud      = 921600,
+		.uart_offset	= 0x8,
+	},
+	[pbn_sunix_pci_4s] = {
+		.num_ports	= 4,
+		.base_baud      = 921600,
+		.uart_offset	= 0x8,
+	},
+	[pbn_sunix_pci_8s] = {
+		.num_ports	= 8,
+		.base_baud      = 921600,
+		.uart_offset	= 0x8,
+	},
+	[pbn_sunix_pci_16s] = {
+		.num_ports	= 16,
+		.base_baud      = 921600,
+		.uart_offset	= 0x8,
+	},
 };
 
 static const struct pci_device_id blacklist[] = {
@@ -4532,17 +4579,29 @@ static const struct pci_device_id serial_pci_tbl[] = {
 		pbn_b0_bt_1_921600 },
 
 	/*
-	 * SUNIX (TIMEDIA)
+	 * Sunix PCI serial boards
 	 */
 	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
-		PCI_VENDOR_ID_SUNIX, PCI_ANY_ID,
-		PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xffff00,
-		pbn_b0_bt_1_921600 },
-
+		PCI_VENDOR_ID_SUNIX, 0x0001, 0, 0,
+		pbn_sunix_pci_1s },
 	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
-		PCI_VENDOR_ID_SUNIX, PCI_ANY_ID,
-		PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00,
-		pbn_b0_bt_1_921600 },
+		PCI_VENDOR_ID_SUNIX, 0x0002, 0, 0,
+		pbn_sunix_pci_2s },
+	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
+		PCI_VENDOR_ID_SUNIX, 0x0004, 0, 0,
+		pbn_sunix_pci_4s },
+	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
+		PCI_VENDOR_ID_SUNIX, 0x0084, 0, 0,
+		pbn_sunix_pci_4s },
+	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
+		PCI_VENDOR_ID_SUNIX, 0x0008, 0, 0,
+		pbn_sunix_pci_8s },
+	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
+		PCI_VENDOR_ID_SUNIX, 0x0088, 0, 0,
+		pbn_sunix_pci_8s },
+	{	PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
+		PCI_VENDOR_ID_SUNIX, 0x0010, 0, 0,
+		pbn_sunix_pci_16s },
 
 	/*
 	 * AFAVLAB serial card, from Harald Welte <laforge@gnumonks.org>
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index c1cec808571b..8900112ed232 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -308,6 +308,14 @@ static const struct serial8250_config uart_config[] = {
 		.rxtrig_bytes	= {1, 4, 8, 14},
 		.flags		= UART_CAP_FIFO,
 	},
+	[PORT_SUNIX] = {
+		.name		= "Sunix",
+		.fifo_size	= 128,
+		.tx_loadsz	= 128,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+		.rxtrig_bytes	= {1, 32, 64, 112},
+		.flags		= UART_CAP_FIFO | UART_CAP_SLEEP,
+	},
 };
 
 /* Uart divisor latch read */
diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h
index 3cc3af1c2ee1..055626ca0a40 100644
--- a/include/uapi/linux/serial_core.h
+++ b/include/uapi/linux/serial_core.h
@@ -290,4 +290,7 @@
 /* SiFive UART */
 #define PORT_SIFIVE_V0	120
 
+/* Sunix UART */
+#define PORT_SUNIX	121
+
 #endif /* _UAPILINUX_SERIAL_CORE_H */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] parport: parport_serial: Add support for Sunix Multi I/O boards
  2019-08-09 19:01 [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards Kai-Heng Feng
@ 2019-08-09 19:01 ` Kai-Heng Feng
  2019-08-10 13:18 ` [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Kai-Heng Feng @ 2019-08-09 19:01 UTC (permalink / raw)
  To: gregkh, sudipm.mukherjee
  Cc: linux-serial, linux-kernel, Kai-Heng Feng, Morris Ku, Debbie Liu

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

This patch adds proper support for Sunix MIO boards with 1 parallel and
up to 4 serial ports.

Cc: Morris Ku <morris_ku@sunix.com>
Cc: Debbie Liu <debbie_liu@sunix.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/parport/parport_serial.c | 44 +++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 461fd8a24278..60d5d985113c 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -61,7 +61,10 @@ enum parport_pc_pci_cards {
 	wch_ch382_0s1p,
 	wch_ch382_2s1p,
 	brainboxes_5s1p,
-	sunix_2s1p,
+	sunix_4008a,
+	sunix_5069a,
+	sunix_5079a,
+	sunix_5099a,
 };
 
 /* each element directly indexed from enum list, above */
@@ -151,7 +154,10 @@ static struct parport_pc_pci cards[] = {
 	/* wch_ch382_0s1p*/		{ 1, { { 2, -1}, } },
 	/* wch_ch382_2s1p*/             { 1, { { 2, -1}, } },
 	/* brainboxes_5s1p */           { 1, { { 3, -1 }, } },
-	/* sunix_2s1p */                { 1, { { 3, -1 }, } },
+	/* sunix_4008a */		{ 1, { { 1, 2 }, } },
+	/* sunix_5069a */		{ 1, { { 1, 2 }, } },
+	/* sunix_5079a */		{ 1, { { 1, 2 }, } },
+	/* sunix_5099a */		{ 1, { { 1, 2 }, } },
 };
 
 static struct pci_device_id parport_serial_pci_tbl[] = {
@@ -261,13 +267,15 @@ static struct pci_device_id parport_serial_pci_tbl[] = {
 	{ PCI_VENDOR_ID_INTASHIELD, 0x4100,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, brainboxes_5s1p },
 
-	/*
-	 * More SUNIX variations. At least one of these has part number
-	 * '5079A but subdevice 0x102. That board reports 0x0708 as
-	 * its PCI Class.
-	 */
+	/* Sunix boards */
 	{ PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999, PCI_VENDOR_ID_SUNIX,
-	  0x0102, 0, 0, sunix_2s1p },
+	  0x0100, 0, 0, sunix_4008a },
+	{ PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999, PCI_VENDOR_ID_SUNIX,
+	  0x0101, 0, 0, sunix_5069a },
+	{ PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999, PCI_VENDOR_ID_SUNIX,
+	  0x0102, 0, 0, sunix_5079a },
+	{ PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999, PCI_VENDOR_ID_SUNIX,
+	  0x0104, 0, 0, sunix_5099a },
 
 	{ 0, } /* terminate list */
 };
@@ -516,11 +524,23 @@ static struct pciserial_board pci_parport_serial_boards[] = {
 		.base_baud	= 921600,
 		.uart_offset	= 8,
 	},
-	[sunix_2s1p] = {
-		.flags		= FL_BASE0|FL_BASE_BARS,
+	[sunix_4008a] = {
+		.num_ports	= 0,
+	},
+	[sunix_5069a] = {
+		.num_ports	= 1,
+		.base_baud      = 921600,
+		.uart_offset	= 0x8,
+	},
+	[sunix_5079a] = {
 		.num_ports	= 2,
-		.base_baud	= 921600,
-		.uart_offset	= 8,
+		.base_baud      = 921600,
+		.uart_offset	= 0x8,
+	},
+	[sunix_5099a] = {
+		.num_ports	= 4,
+		.base_baud      = 921600,
+		.uart_offset	= 0x8,
 	},
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards
  2019-08-09 19:01 [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards Kai-Heng Feng
  2019-08-09 19:01 ` [PATCH v2 2/2] parport: parport_serial: Add support for Sunix Multi I/O boards Kai-Heng Feng
@ 2019-08-10 13:18 ` Andy Shevchenko
  2019-08-13  4:36   ` Kai-Heng Feng
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2019-08-10 13:18 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Greg Kroah-Hartman, Sudip Mukherjee, open list:SERIAL DRIVERS,
	Linux Kernel Mailing List, Morris Ku, Debbie Liu

On Fri, Aug 9, 2019 at 10:05 PM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
>
> Add support to Sunix serial boards with up to 16 ports.
>
> Sunix board need its own setup callback instead of using Timedia's, to
> properly support more than 4 ports.
>

Can you, please, split out the Sunix quirk driver to a separate module
(see examples like: 8250_exar, 8250_lpss, 8250_mid)?
And then with a fewer LOCs add a new boards.

> Cc: Morris Ku <morris_ku@sunix.com>
> Cc: Debbie Liu <debbie_liu@sunix.com>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> v2:
>  use div64_s64() instead of do_div()
>
>  drivers/tty/serial/8250/8250_pci.c  | 93 +++++++++++++++++++++++------
>  drivers/tty/serial/8250/8250_port.c |  8 +++
>  include/uapi/linux/serial_core.h    |  3 +
>  3 files changed, 87 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
> index 7f740b37700b..b2a5c2228858 100644
> --- a/drivers/tty/serial/8250/8250_pci.c
> +++ b/drivers/tty/serial/8250/8250_pci.c
> @@ -1692,6 +1692,30 @@ pci_wch_ch38x_setup(struct serial_private *priv,
>         return pci_default_setup(priv, board, port, idx);
>  }
>
> +static int
> +pci_sunix_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 = 0;
> +               offset = idx * board->uart_offset;
> +       } else {
> +               bar = 1;
> +               idx -= 4;
> +               idx = div_s64_rem(idx, 4, &offset);
> +               offset = idx * 64 + offset * board->uart_offset;
> +       }
> +
> +       return setup_port(priv, port, bar, offset, 0);
> +}
> +
>  #define PCI_VENDOR_ID_SBSMODULARIO     0x124B
>  #define PCI_SUBVENDOR_ID_SBSMODULARIO  0x124B
>  #define PCI_DEVICE_ID_OCTPRO           0x0001
> @@ -2289,21 +2313,14 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
>                 .setup          = pci_timedia_setup,
>         },
>         /*
> -        * SUNIX (Timedia) cards
> -        * Do not "probe" for these cards as there is at least one combination
> -        * card that should be handled by parport_pc that doesn't match the
> -        * rule in pci_timedia_probe.
> -        * It is part number is MIO5079A but its subdevice ID is 0x0102.
> -        * There are some boards with part number SER5037AL that report
> -        * subdevice ID 0x0002.
> +        * Sunix PCI serial boards
>          */
>         {
>                 .vendor         = PCI_VENDOR_ID_SUNIX,
>                 .device         = PCI_DEVICE_ID_SUNIX_1999,
>                 .subvendor      = PCI_VENDOR_ID_SUNIX,
>                 .subdevice      = PCI_ANY_ID,
> -               .init           = pci_timedia_init,
> -               .setup          = pci_timedia_setup,
> +               .setup          = pci_sunix_setup,
>         },
>         /*
>          * Xircom cards
> @@ -2757,6 +2774,11 @@ enum pci_board_num_t {
>         pbn_pericom_PI7C9X7952,
>         pbn_pericom_PI7C9X7954,
>         pbn_pericom_PI7C9X7958,
> +       pbn_sunix_pci_1s,
> +       pbn_sunix_pci_2s,
> +       pbn_sunix_pci_4s,
> +       pbn_sunix_pci_8s,
> +       pbn_sunix_pci_16s,
>  };
>
>  /*
> @@ -3494,6 +3516,31 @@ static struct pciserial_board pci_boards[] = {
>                 .base_baud      = 921600,
>                 .uart_offset    = 0x8,
>         },
> +       [pbn_sunix_pci_1s] = {
> +               .num_ports      = 1,
> +               .base_baud      = 921600,
> +               .uart_offset    = 0x8,
> +       },
> +       [pbn_sunix_pci_2s] = {
> +               .num_ports      = 2,
> +               .base_baud      = 921600,
> +               .uart_offset    = 0x8,
> +       },
> +       [pbn_sunix_pci_4s] = {
> +               .num_ports      = 4,
> +               .base_baud      = 921600,
> +               .uart_offset    = 0x8,
> +       },
> +       [pbn_sunix_pci_8s] = {
> +               .num_ports      = 8,
> +               .base_baud      = 921600,
> +               .uart_offset    = 0x8,
> +       },
> +       [pbn_sunix_pci_16s] = {
> +               .num_ports      = 16,
> +               .base_baud      = 921600,
> +               .uart_offset    = 0x8,
> +       },
>  };
>
>  static const struct pci_device_id blacklist[] = {
> @@ -4532,17 +4579,29 @@ static const struct pci_device_id serial_pci_tbl[] = {
>                 pbn_b0_bt_1_921600 },
>
>         /*
> -        * SUNIX (TIMEDIA)
> +        * Sunix PCI serial boards
>          */
>         {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
> -               PCI_VENDOR_ID_SUNIX, PCI_ANY_ID,
> -               PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xffff00,
> -               pbn_b0_bt_1_921600 },
> -
> +               PCI_VENDOR_ID_SUNIX, 0x0001, 0, 0,
> +               pbn_sunix_pci_1s },
>         {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
> -               PCI_VENDOR_ID_SUNIX, PCI_ANY_ID,
> -               PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00,
> -               pbn_b0_bt_1_921600 },
> +               PCI_VENDOR_ID_SUNIX, 0x0002, 0, 0,
> +               pbn_sunix_pci_2s },
> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
> +               PCI_VENDOR_ID_SUNIX, 0x0004, 0, 0,
> +               pbn_sunix_pci_4s },
> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
> +               PCI_VENDOR_ID_SUNIX, 0x0084, 0, 0,
> +               pbn_sunix_pci_4s },
> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
> +               PCI_VENDOR_ID_SUNIX, 0x0008, 0, 0,
> +               pbn_sunix_pci_8s },
> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
> +               PCI_VENDOR_ID_SUNIX, 0x0088, 0, 0,
> +               pbn_sunix_pci_8s },
> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
> +               PCI_VENDOR_ID_SUNIX, 0x0010, 0, 0,
> +               pbn_sunix_pci_16s },
>
>         /*
>          * AFAVLAB serial card, from Harald Welte <laforge@gnumonks.org>
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index c1cec808571b..8900112ed232 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -308,6 +308,14 @@ static const struct serial8250_config uart_config[] = {
>                 .rxtrig_bytes   = {1, 4, 8, 14},
>                 .flags          = UART_CAP_FIFO,
>         },
> +       [PORT_SUNIX] = {
> +               .name           = "Sunix",
> +               .fifo_size      = 128,
> +               .tx_loadsz      = 128,
> +               .fcr            = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
> +               .rxtrig_bytes   = {1, 32, 64, 112},
> +               .flags          = UART_CAP_FIFO | UART_CAP_SLEEP,
> +       },
>  };
>
>  /* Uart divisor latch read */
> diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h
> index 3cc3af1c2ee1..055626ca0a40 100644
> --- a/include/uapi/linux/serial_core.h
> +++ b/include/uapi/linux/serial_core.h
> @@ -290,4 +290,7 @@
>  /* SiFive UART */
>  #define PORT_SIFIVE_V0 120
>
> +/* Sunix UART */
> +#define PORT_SUNIX     121
> +
>  #endif /* _UAPILINUX_SERIAL_CORE_H */
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards
  2019-08-10 13:18 ` [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards Andy Shevchenko
@ 2019-08-13  4:36   ` Kai-Heng Feng
  2019-08-13  6:12     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Kai-Heng Feng @ 2019-08-13  4:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Sudip Mukherjee, open list:SERIAL DRIVERS,
	Linux Kernel Mailing List, Morris Ku, Debbie Liu

Hi Andy,

at 21:18, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Aug 9, 2019 at 10:05 PM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
>> Add support to Sunix serial boards with up to 16 ports.
>>
>> Sunix board need its own setup callback instead of using Timedia's, to
>> properly support more than 4 ports.
>
> Can you, please, split out the Sunix quirk driver to a separate module
> (see examples like: 8250_exar, 8250_lpss, 8250_mid)?
> And then with a fewer LOCs add a new boards.

Greg asked Sunix to use existing 8250_pci.c instead of its own module.
It only needs a special setup function, other parts are just 8250_pci.

Why does split them a better idea? I even think of squashing 8250_moxa into  
8250_pci.

Kai-Heng

>
>> Cc: Morris Ku <morris_ku@sunix.com>
>> Cc: Debbie Liu <debbie_liu@sunix.com>
>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> ---
>> v2:
>>  use div64_s64() instead of do_div()
>>
>>  drivers/tty/serial/8250/8250_pci.c  | 93 +++++++++++++++++++++++------
>>  drivers/tty/serial/8250/8250_port.c |  8 +++
>>  include/uapi/linux/serial_core.h    |  3 +
>>  3 files changed, 87 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_pci.c  
>> b/drivers/tty/serial/8250/8250_pci.c
>> index 7f740b37700b..b2a5c2228858 100644
>> --- a/drivers/tty/serial/8250/8250_pci.c
>> +++ b/drivers/tty/serial/8250/8250_pci.c
>> @@ -1692,6 +1692,30 @@ pci_wch_ch38x_setup(struct serial_private *priv,
>>         return pci_default_setup(priv, board, port, idx);
>>  }
>>
>> +static int
>> +pci_sunix_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 = 0;
>> +               offset = idx * board->uart_offset;
>> +       } else {
>> +               bar = 1;
>> +               idx -= 4;
>> +               idx = div_s64_rem(idx, 4, &offset);
>> +               offset = idx * 64 + offset * board->uart_offset;
>> +       }
>> +
>> +       return setup_port(priv, port, bar, offset, 0);
>> +}
>> +
>>  #define PCI_VENDOR_ID_SBSMODULARIO     0x124B
>>  #define PCI_SUBVENDOR_ID_SBSMODULARIO  0x124B
>>  #define PCI_DEVICE_ID_OCTPRO           0x0001
>> @@ -2289,21 +2313,14 @@ static struct pci_serial_quirk  
>> pci_serial_quirks[] __refdata = {
>>                 .setup          = pci_timedia_setup,
>>         },
>>         /*
>> -        * SUNIX (Timedia) cards
>> -        * Do not "probe" for these cards as there is at least one  
>> combination
>> -        * card that should be handled by parport_pc that doesn't match  
>> the
>> -        * rule in pci_timedia_probe.
>> -        * It is part number is MIO5079A but its subdevice ID is 0x0102.
>> -        * There are some boards with part number SER5037AL that report
>> -        * subdevice ID 0x0002.
>> +        * Sunix PCI serial boards
>>          */
>>         {
>>                 .vendor         = PCI_VENDOR_ID_SUNIX,
>>                 .device         = PCI_DEVICE_ID_SUNIX_1999,
>>                 .subvendor      = PCI_VENDOR_ID_SUNIX,
>>                 .subdevice      = PCI_ANY_ID,
>> -               .init           = pci_timedia_init,
>> -               .setup          = pci_timedia_setup,
>> +               .setup          = pci_sunix_setup,
>>         },
>>         /*
>>          * Xircom cards
>> @@ -2757,6 +2774,11 @@ enum pci_board_num_t {
>>         pbn_pericom_PI7C9X7952,
>>         pbn_pericom_PI7C9X7954,
>>         pbn_pericom_PI7C9X7958,
>> +       pbn_sunix_pci_1s,
>> +       pbn_sunix_pci_2s,
>> +       pbn_sunix_pci_4s,
>> +       pbn_sunix_pci_8s,
>> +       pbn_sunix_pci_16s,
>>  };
>>
>>  /*
>> @@ -3494,6 +3516,31 @@ static struct pciserial_board pci_boards[] = {
>>                 .base_baud      = 921600,
>>                 .uart_offset    = 0x8,
>>         },
>> +       [pbn_sunix_pci_1s] = {
>> +               .num_ports      = 1,
>> +               .base_baud      = 921600,
>> +               .uart_offset    = 0x8,
>> +       },
>> +       [pbn_sunix_pci_2s] = {
>> +               .num_ports      = 2,
>> +               .base_baud      = 921600,
>> +               .uart_offset    = 0x8,
>> +       },
>> +       [pbn_sunix_pci_4s] = {
>> +               .num_ports      = 4,
>> +               .base_baud      = 921600,
>> +               .uart_offset    = 0x8,
>> +       },
>> +       [pbn_sunix_pci_8s] = {
>> +               .num_ports      = 8,
>> +               .base_baud      = 921600,
>> +               .uart_offset    = 0x8,
>> +       },
>> +       [pbn_sunix_pci_16s] = {
>> +               .num_ports      = 16,
>> +               .base_baud      = 921600,
>> +               .uart_offset    = 0x8,
>> +       },
>>  };
>>
>>  static const struct pci_device_id blacklist[] = {
>> @@ -4532,17 +4579,29 @@ static const struct pci_device_id  
>> serial_pci_tbl[] = {
>>                 pbn_b0_bt_1_921600 },
>>
>>         /*
>> -        * SUNIX (TIMEDIA)
>> +        * Sunix PCI serial boards
>>          */
>>         {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
>> -               PCI_VENDOR_ID_SUNIX, PCI_ANY_ID,
>> -               PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xffff00,
>> -               pbn_b0_bt_1_921600 },
>> -
>> +               PCI_VENDOR_ID_SUNIX, 0x0001, 0, 0,
>> +               pbn_sunix_pci_1s },
>>         {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
>> -               PCI_VENDOR_ID_SUNIX, PCI_ANY_ID,
>> -               PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00,
>> -               pbn_b0_bt_1_921600 },
>> +               PCI_VENDOR_ID_SUNIX, 0x0002, 0, 0,
>> +               pbn_sunix_pci_2s },
>> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
>> +               PCI_VENDOR_ID_SUNIX, 0x0004, 0, 0,
>> +               pbn_sunix_pci_4s },
>> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
>> +               PCI_VENDOR_ID_SUNIX, 0x0084, 0, 0,
>> +               pbn_sunix_pci_4s },
>> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
>> +               PCI_VENDOR_ID_SUNIX, 0x0008, 0, 0,
>> +               pbn_sunix_pci_8s },
>> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
>> +               PCI_VENDOR_ID_SUNIX, 0x0088, 0, 0,
>> +               pbn_sunix_pci_8s },
>> +       {       PCI_VENDOR_ID_SUNIX, PCI_DEVICE_ID_SUNIX_1999,
>> +               PCI_VENDOR_ID_SUNIX, 0x0010, 0, 0,
>> +               pbn_sunix_pci_16s },
>>
>>         /*
>>          * AFAVLAB serial card, from Harald Welte <laforge@gnumonks.org>
>> diff --git a/drivers/tty/serial/8250/8250_port.c  
>> b/drivers/tty/serial/8250/8250_port.c
>> index c1cec808571b..8900112ed232 100644
>> --- a/drivers/tty/serial/8250/8250_port.c
>> +++ b/drivers/tty/serial/8250/8250_port.c
>> @@ -308,6 +308,14 @@ static const struct serial8250_config uart_config[]  
>> = {
>>                 .rxtrig_bytes   = {1, 4, 8, 14},
>>                 .flags          = UART_CAP_FIFO,
>>         },
>> +       [PORT_SUNIX] = {
>> +               .name           = "Sunix",
>> +               .fifo_size      = 128,
>> +               .tx_loadsz      = 128,
>> +               .fcr            = UART_FCR_ENABLE_FIFO |  
>> UART_FCR_R_TRIG_10,
>> +               .rxtrig_bytes   = {1, 32, 64, 112},
>> +               .flags          = UART_CAP_FIFO | UART_CAP_SLEEP,
>> +       },
>>  };
>>
>>  /* Uart divisor latch read */
>> diff --git a/include/uapi/linux/serial_core.h  
>> b/include/uapi/linux/serial_core.h
>> index 3cc3af1c2ee1..055626ca0a40 100644
>> --- a/include/uapi/linux/serial_core.h
>> +++ b/include/uapi/linux/serial_core.h
>> @@ -290,4 +290,7 @@
>>  /* SiFive UART */
>>  #define PORT_SIFIVE_V0 120
>>
>> +/* Sunix UART */
>> +#define PORT_SUNIX     121
>> +
>>  #endif /* _UAPILINUX_SERIAL_CORE_H */
>> --
>> 2.17.1
>
>
> -- 
> With Best Regards,
> Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards
  2019-08-13  4:36   ` Kai-Heng Feng
@ 2019-08-13  6:12     ` Greg Kroah-Hartman
  2019-08-13  8:23       ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-13  6:12 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Andy Shevchenko, Sudip Mukherjee, open list:SERIAL DRIVERS,
	Linux Kernel Mailing List, Morris Ku, Debbie Liu

On Tue, Aug 13, 2019 at 12:36:40PM +0800, Kai-Heng Feng wrote:
> Hi Andy,
> 
> at 21:18, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> 
> > On Fri, Aug 9, 2019 at 10:05 PM Kai-Heng Feng
> > <kai.heng.feng@canonical.com> wrote:
> > > Add support to Sunix serial boards with up to 16 ports.
> > > 
> > > Sunix board need its own setup callback instead of using Timedia's, to
> > > properly support more than 4 ports.
> > 
> > Can you, please, split out the Sunix quirk driver to a separate module
> > (see examples like: 8250_exar, 8250_lpss, 8250_mid)?
> > And then with a fewer LOCs add a new boards.
> 
> Greg asked Sunix to use existing 8250_pci.c instead of its own module.
> It only needs a special setup function, other parts are just 8250_pci.

Agreed.  And this patch is already in my tree :)

If people really worry about size issues, start carving this up by
different configuration options, or yes, split it up into tiny modules
(but note the overhead there when things get too tiny, it's a
diminishing return).

> Why does split them a better idea? I even think of squashing 8250_moxa into
> 8250_pci.

I would agree with you, I bet you save space if you do that.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards
  2019-08-13  6:12     ` Greg Kroah-Hartman
@ 2019-08-13  8:23       ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2019-08-13  8:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Kai-Heng Feng, Sudip Mukherjee, open list:SERIAL DRIVERS,
	Linux Kernel Mailing List, Morris Ku, Debbie Liu

On Tue, Aug 13, 2019 at 9:12 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Tue, Aug 13, 2019 at 12:36:40PM +0800, Kai-Heng Feng wrote:
> > at 21:18, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> > > On Fri, Aug 9, 2019 at 10:05 PM Kai-Heng Feng
> > > <kai.heng.feng@canonical.com> wrote:

> > > Can you, please, split out the Sunix quirk driver to a separate module
> > > (see examples like: 8250_exar, 8250_lpss, 8250_mid)?
> > > And then with a fewer LOCs add a new boards.
> >
> > Greg asked Sunix to use existing 8250_pci.c instead of its own module.
> > It only needs a special setup function, other parts are just 8250_pci.
>
> Agreed.  And this patch is already in my tree :)
>
> If people really worry about size issues, start carving this up by
> different configuration options, or yes, split it up into tiny modules
> (but note the overhead there when things get too tiny, it's a
> diminishing return).

It's always a trade off and associative pros and cons. If Sunix is a
simple one, I tend to agree that 8250_pci is a good place. For rather
big quirk modules, like Exar one, the separate sounds better (and as
we can see from retrospective of maintenance).

>
> > Why does split them a better idea? I even think of squashing 8250_moxa into
> > 8250_pci.
>
> I would agree with you, I bet you save space if you do that.



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-13  8:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 19:01 [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards Kai-Heng Feng
2019-08-09 19:01 ` [PATCH v2 2/2] parport: parport_serial: Add support for Sunix Multi I/O boards Kai-Heng Feng
2019-08-10 13:18 ` [PATCH v2 1/2] serial: 8250_pci: Add support for Sunix serial boards Andy Shevchenko
2019-08-13  4:36   ` Kai-Heng Feng
2019-08-13  6:12     ` Greg Kroah-Hartman
2019-08-13  8:23       ` Andy Shevchenko

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).