linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards
@ 2024-06-07 11:43 Crescent Hsieh
  2024-06-07 11:43 ` [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device Crescent Hsieh
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Crescent Hsieh @ 2024-06-07 11:43 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial, Crescent Hsieh

There are 6 patches within this patch series to make some adjustments
and enhancements for MOXA PCI serial boards, a briefly description is
written below:

- The first patch is an independent bug fix patch.
- The second and third patches migrate some MOXA PCI devices from
  `mxser.c` to `8250_pci.c`.
- The fourth and fifth patches address improvements and adjustments in
  handling the serial interface.
- The sixth patch adds a UART configuration that aligns with the
  hardware capabilities of MOXA PCI serial boards.

Crescent Hsieh (6):
  tty: serial: 8250: Fix the amount of ports doesn't match the device
  tty: serial: 8250: Add 2 ports PCI configuration for 921600 BAR 2
  tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci
  tty: serial: 8250: Add check for setting default serial interface
  tty: serial: 8250: Add support for Moxa PCIe boards to switch
    interface
  tty: serial: 8250: Add support for MUEX50 UART

 drivers/tty/mxser.c                 |  50 ----------
 drivers/tty/serial/8250/8250_pci.c  | 139 +++++++++++++++++++++++++++-
 drivers/tty/serial/8250/8250_port.c |   8 ++
 include/uapi/linux/serial_core.h    |   3 +
 4 files changed, 146 insertions(+), 54 deletions(-)

-- 
2.34.1


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

* [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device
  2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
@ 2024-06-07 11:43 ` Crescent Hsieh
  2024-06-08  9:58   ` Andy Shevchenko
  2024-06-11  7:39   ` Jiri Slaby
  2024-06-07 11:43 ` [PATCH 2/6] tty: serial: 8250: Add 2 ports PCI configuration for 921600 BAR 2 Crescent Hsieh
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 16+ messages in thread
From: Crescent Hsieh @ 2024-06-07 11:43 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial, Crescent Hsieh

Normally, the amount of ports is written at the third digit of device ID
of Moxa PCI boards, for example: `0x1121` indicates a 2 ports device.

However, `CP116E_A_A` and `CP116E_A_B` are two exceptions, which has 8
ports but the third digit of device ID is `6`.

This patch fixes the issue above by adding checks.

Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
---
 drivers/tty/serial/8250/8250_pci.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 40af74b55933..4e88ee07e548 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -2041,6 +2041,10 @@ static int pci_moxa_init(struct pci_dev *dev)
 	unsigned int num_ports = (device & 0x00F0) >> 4, i;
 	u8 val, init_mode = MOXA_RS232;
 
+	if (device == PCI_DEVICE_ID_MOXA_CP116E_A_A ||
+	    device == PCI_DEVICE_ID_MOXA_CP116E_A_B)
+		num_ports = 8;
+
 	if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232)) {
 		init_mode = MOXA_RS422;
 	}
-- 
2.34.1


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

* [PATCH 2/6] tty: serial: 8250: Add 2 ports PCI configuration for 921600 BAR 2
  2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
  2024-06-07 11:43 ` [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device Crescent Hsieh
@ 2024-06-07 11:43 ` Crescent Hsieh
  2024-06-07 11:43 ` [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci Crescent Hsieh
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Crescent Hsieh @ 2024-06-07 11:43 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial, Crescent Hsieh

In PCI configuration table, there are 1, 4, 8 ports for 921600 BAR 2
except 2 ports.

This patch adds 2 ports PCI configuration for 921600 BAR 2.

Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
---
 drivers/tty/serial/8250/8250_pci.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 4e88ee07e548..4964cb9ccaa0 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -3043,6 +3043,7 @@ enum pci_board_num_t {
 	pbn_b2_16_460800,
 
 	pbn_b2_1_921600,
+	pbn_b2_2_921600,
 	pbn_b2_4_921600,
 	pbn_b2_8_921600,
 
@@ -3462,6 +3463,12 @@ static struct pciserial_board pci_boards[] = {
 		.base_baud	= 921600,
 		.uart_offset	= 8,
 	},
+	[pbn_b2_2_921600] = {
+		.flags		= FL_BASE2,
+		.num_ports	= 2,
+		.base_baud	= 921600,
+		.uart_offset	= 8,
+	},
 	[pbn_b2_4_921600] = {
 		.flags		= FL_BASE2,
 		.num_ports	= 4,
-- 
2.34.1


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

* [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci
  2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
  2024-06-07 11:43 ` [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device Crescent Hsieh
  2024-06-07 11:43 ` [PATCH 2/6] tty: serial: 8250: Add 2 ports PCI configuration for 921600 BAR 2 Crescent Hsieh
@ 2024-06-07 11:43 ` Crescent Hsieh
  2024-06-11  7:42   ` Jiri Slaby
  2024-06-07 11:43 ` [PATCH 4/6] tty: serial: 8250: Add check for setting default serial interface Crescent Hsieh
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Crescent Hsieh @ 2024-06-07 11:43 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial, Crescent Hsieh

The devices in mxser could be supported by 8250_pci, so this patch
relocates these device IDs from mxser into 8250_pci.

Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
---
 drivers/tty/mxser.c                | 50 ------------------------------
 drivers/tty/serial/8250/8250_pci.c | 50 ++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 458bb1280ebf..b0e7ea6611bf 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -160,31 +160,6 @@
 #define MXSER_CUSTOM_DIVISOR	(MXSER_BAUD_BASE * 16)
 
 #define PCI_DEVICE_ID_MOXA_RC7000	0x0001
-#define PCI_DEVICE_ID_MOXA_CP102	0x1020
-#define PCI_DEVICE_ID_MOXA_CP102UL	0x1021
-#define PCI_DEVICE_ID_MOXA_CP102U	0x1022
-#define PCI_DEVICE_ID_MOXA_CP102UF	0x1023
-#define PCI_DEVICE_ID_MOXA_C104		0x1040
-#define PCI_DEVICE_ID_MOXA_CP104U	0x1041
-#define PCI_DEVICE_ID_MOXA_CP104JU	0x1042
-#define PCI_DEVICE_ID_MOXA_CP104EL	0x1043
-#define PCI_DEVICE_ID_MOXA_POS104UL	0x1044
-#define PCI_DEVICE_ID_MOXA_CB108	0x1080
-#define PCI_DEVICE_ID_MOXA_CP112UL	0x1120
-#define PCI_DEVICE_ID_MOXA_CT114	0x1140
-#define PCI_DEVICE_ID_MOXA_CP114	0x1141
-#define PCI_DEVICE_ID_MOXA_CB114	0x1142
-#define PCI_DEVICE_ID_MOXA_CP114UL	0x1143
-#define PCI_DEVICE_ID_MOXA_CP118U	0x1180
-#define PCI_DEVICE_ID_MOXA_CP118EL	0x1181
-#define PCI_DEVICE_ID_MOXA_CP132	0x1320
-#define PCI_DEVICE_ID_MOXA_CP132U	0x1321
-#define PCI_DEVICE_ID_MOXA_CP134U	0x1340
-#define PCI_DEVICE_ID_MOXA_CB134I	0x1341
-#define PCI_DEVICE_ID_MOXA_CP138U	0x1380
-#define PCI_DEVICE_ID_MOXA_C168		0x1680
-#define PCI_DEVICE_ID_MOXA_CP168U	0x1681
-#define PCI_DEVICE_ID_MOXA_CP168EL	0x1682
 
 #define MXSER_NPORTS(ddata)		((ddata) & 0xffU)
 #define MXSER_HIGHBAUD			0x0100
@@ -212,32 +187,7 @@ static const struct {
 /* driver_data correspond to the lines in the structure above
    see also ISA probe function before you change something */
 static const struct pci_device_id mxser_pcibrds[] = {
-	{ PCI_DEVICE_DATA(MOXA, C168,		8) },
-	{ PCI_DEVICE_DATA(MOXA, C104,		4) },
-	{ PCI_DEVICE_DATA(MOXA, CP132,		2) },
-	{ PCI_DEVICE_DATA(MOXA, CP114,		4) },
-	{ PCI_DEVICE_DATA(MOXA, CT114,		4) },
-	{ PCI_DEVICE_DATA(MOXA, CP102,		2 | MXSER_HIGHBAUD) },
-	{ PCI_DEVICE_DATA(MOXA, CP104U,		4) },
-	{ PCI_DEVICE_DATA(MOXA, CP168U,		8) },
-	{ PCI_DEVICE_DATA(MOXA, CP132U,		2) },
-	{ PCI_DEVICE_DATA(MOXA, CP134U,		4) },
-	{ PCI_DEVICE_DATA(MOXA, CP104JU,	4) },
 	{ PCI_DEVICE_DATA(MOXA, RC7000,		8) }, /* RC7000 */
-	{ PCI_DEVICE_DATA(MOXA, CP118U,		8) },
-	{ PCI_DEVICE_DATA(MOXA, CP102UL,	2) },
-	{ PCI_DEVICE_DATA(MOXA, CP102U,		2) },
-	{ PCI_DEVICE_DATA(MOXA, CP118EL,	8) },
-	{ PCI_DEVICE_DATA(MOXA, CP168EL,	8) },
-	{ PCI_DEVICE_DATA(MOXA, CP104EL,	4) },
-	{ PCI_DEVICE_DATA(MOXA, CB108,		8) },
-	{ PCI_DEVICE_DATA(MOXA, CB114,		4) },
-	{ PCI_DEVICE_DATA(MOXA, CB134I,		4) },
-	{ PCI_DEVICE_DATA(MOXA, CP138U,		8) },
-	{ PCI_DEVICE_DATA(MOXA, POS104UL,	4) },
-	{ PCI_DEVICE_DATA(MOXA, CP114UL,	4) },
-	{ PCI_DEVICE_DATA(MOXA, CP102UF,	2) },
-	{ PCI_DEVICE_DATA(MOXA, CP112UL,	2) },
 	{ }
 };
 MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 4964cb9ccaa0..e5bdabcce720 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -82,23 +82,48 @@
 #define PCIE_DEVICE_ID_WCH_CH384_8S	0x3853
 #define PCIE_DEVICE_ID_WCH_CH382_2S	0x3253
 
+#define PCI_DEVICE_ID_MOXA_CP102	0x1020
+#define PCI_DEVICE_ID_MOXA_CP102UL	0x1021
+#define PCI_DEVICE_ID_MOXA_CP102U	0x1022
+#define PCI_DEVICE_ID_MOXA_CP102UF	0x1023
 #define PCI_DEVICE_ID_MOXA_CP102E	0x1024
 #define PCI_DEVICE_ID_MOXA_CP102EL	0x1025
 #define PCI_DEVICE_ID_MOXA_CP102N	0x1027
+#define PCI_DEVICE_ID_MOXA_C104		0x1040
+#define PCI_DEVICE_ID_MOXA_CP104U	0x1041
+#define PCI_DEVICE_ID_MOXA_CP104JU	0x1042
+#define PCI_DEVICE_ID_MOXA_CP104EL	0x1043
+#define PCI_DEVICE_ID_MOXA_POS104UL	0x1044
 #define PCI_DEVICE_ID_MOXA_CP104EL_A	0x1045
 #define PCI_DEVICE_ID_MOXA_CP104N	0x1046
+#define PCI_DEVICE_ID_MOXA_CB108	0x1080
+#define PCI_DEVICE_ID_MOXA_CP112UL	0x1120
 #define PCI_DEVICE_ID_MOXA_CP112N	0x1121
+#define PCI_DEVICE_ID_MOXA_CT114	0x1140
+#define PCI_DEVICE_ID_MOXA_CP114	0x1141
+#define PCI_DEVICE_ID_MOXA_CB114	0x1142
+#define PCI_DEVICE_ID_MOXA_CP114UL	0x1143
 #define PCI_DEVICE_ID_MOXA_CP114EL	0x1144
 #define PCI_DEVICE_ID_MOXA_CP114N	0x1145
 #define PCI_DEVICE_ID_MOXA_CP116E_A_A	0x1160
 #define PCI_DEVICE_ID_MOXA_CP116E_A_B	0x1161
+#define PCI_DEVICE_ID_MOXA_CP118U	0x1180
+#define PCI_DEVICE_ID_MOXA_CP118EL	0x1181
 #define PCI_DEVICE_ID_MOXA_CP118EL_A	0x1182
 #define PCI_DEVICE_ID_MOXA_CP118E_A_I	0x1183
+#define PCI_DEVICE_ID_MOXA_CP132	0x1320
+#define PCI_DEVICE_ID_MOXA_CP132U	0x1321
 #define PCI_DEVICE_ID_MOXA_CP132EL	0x1322
 #define PCI_DEVICE_ID_MOXA_CP132N	0x1323
+#define PCI_DEVICE_ID_MOXA_CP134U	0x1340
+#define PCI_DEVICE_ID_MOXA_CB134I	0x1341
 #define PCI_DEVICE_ID_MOXA_CP134EL_A	0x1342
 #define PCI_DEVICE_ID_MOXA_CP134N	0x1343
+#define PCI_DEVICE_ID_MOXA_CP138U	0x1380
 #define PCI_DEVICE_ID_MOXA_CP138E_A	0x1381
+#define PCI_DEVICE_ID_MOXA_C168		0x1680
+#define PCI_DEVICE_ID_MOXA_CP168U	0x1681
+#define PCI_DEVICE_ID_MOXA_CP168EL	0x1682
 #define PCI_DEVICE_ID_MOXA_CP168EL_A	0x1683
 
 /* Unknown vendors/cards - this should not be in linux/pci_ids.h */
@@ -5774,23 +5799,48 @@ static const struct pci_device_id serial_pci_tbl[] = {
 	/*
 	 * MOXA
 	 */
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102),	    pbn_b2_2_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),    pbn_b2_2_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U),	    pbn_b2_2_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UF),    pbn_b2_2_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102E),	    pbn_moxa_2 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102EL),    pbn_moxa_2 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102N),	    pbn_moxa_2 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104),	    pbn_b2_4_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U),	    pbn_b2_4_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),    pbn_b2_4_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),    pbn_b2_4_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_POS104UL),   pbn_b2_4_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL_A),  pbn_moxa_4 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104N),	    pbn_moxa_4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CB108),	    pbn_b2_8_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP112UL),    pbn_b2_2_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP112N),	    pbn_moxa_2 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CT114),	    pbn_b2_4_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114),	    pbn_b2_4_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CB114),	    pbn_b2_4_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114UL),    pbn_b2_4_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114EL),    pbn_moxa_4 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114N),	    pbn_moxa_4 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP116E_A_A), pbn_moxa_8 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP116E_A_B), pbn_moxa_8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U),	    pbn_b2_8_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),    pbn_b2_8_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL_A),  pbn_moxa_8 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118E_A_I), pbn_moxa_8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132),	    pbn_b2_2_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U),	    pbn_b2_2_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132EL),    pbn_moxa_2 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132N),     pbn_moxa_2 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U),	    pbn_b2_4_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CB134I),	    pbn_b2_4_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134EL_A),  pbn_moxa_4 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134N),	    pbn_moxa_4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP138U),	    pbn_b2_8_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP138E_A),   pbn_moxa_8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168),	    pbn_b2_8_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U),	    pbn_b2_8_921600 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),    pbn_b2_8_921600 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL_A),  pbn_moxa_8 },
 
 	/*
-- 
2.34.1


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

* [PATCH 4/6] tty: serial: 8250: Add check for setting default serial interface
  2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
                   ` (2 preceding siblings ...)
  2024-06-07 11:43 ` [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci Crescent Hsieh
@ 2024-06-07 11:43 ` Crescent Hsieh
  2024-06-08  9:57   ` Andy Shevchenko
  2024-06-07 11:43 ` [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards to switch interface Crescent Hsieh
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Crescent Hsieh @ 2024-06-07 11:43 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial, Crescent Hsieh

Moxa PCIe and Mini-PCIe boards are capable of switching the serial
interface through software control, while other PCI boards switch the
serial interface through hardware DIP switches.

This patch adds a check while setting the default serial interface.

Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
---
 drivers/tty/serial/8250/8250_pci.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index e5bdabcce720..e4e6493a5497 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -2010,6 +2010,25 @@ enum {
 	MOXA_SUPP_RS485 = BIT(2),
 };
 
+static bool pci_moxa_is_pcie(unsigned short device)
+{
+	if (device == PCI_DEVICE_ID_MOXA_CP102E     ||
+	    device == PCI_DEVICE_ID_MOXA_CP102EL    ||
+	    device == PCI_DEVICE_ID_MOXA_CP104EL_A  ||
+	    device == PCI_DEVICE_ID_MOXA_CP114EL    ||
+	    device == PCI_DEVICE_ID_MOXA_CP116E_A_A ||
+	    device == PCI_DEVICE_ID_MOXA_CP116E_A_B ||
+	    device == PCI_DEVICE_ID_MOXA_CP118EL_A  ||
+	    device == PCI_DEVICE_ID_MOXA_CP118E_A_I ||
+	    device == PCI_DEVICE_ID_MOXA_CP132EL    ||
+	    device == PCI_DEVICE_ID_MOXA_CP134EL_A  ||
+	    device == PCI_DEVICE_ID_MOXA_CP138E_A   ||
+	    device == PCI_DEVICE_ID_MOXA_CP168EL_A)
+		return true;
+
+	return false;
+}
+
 static bool pci_moxa_is_mini_pcie(unsigned short device)
 {
 	if (device == PCI_DEVICE_ID_MOXA_CP102N	||
@@ -2070,11 +2089,13 @@ static int pci_moxa_init(struct pci_dev *dev)
 	    device == PCI_DEVICE_ID_MOXA_CP116E_A_B)
 		num_ports = 8;
 
-	if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232)) {
-		init_mode = MOXA_RS422;
+	if (pci_moxa_is_pcie(device) || pci_moxa_is_mini_pcie(device)) {
+		if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232))
+			init_mode = MOXA_RS422;
+
+		for (i = 0; i < num_ports; ++i)
+			pci_moxa_set_interface(dev, i, init_mode);
 	}
-	for (i = 0; i < num_ports; ++i)
-		pci_moxa_set_interface(dev, i, init_mode);
 
 	/*
 	 * Enable hardware buffer to prevent break signal output when system boots up.
-- 
2.34.1


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

* [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards to switch interface
  2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
                   ` (3 preceding siblings ...)
  2024-06-07 11:43 ` [PATCH 4/6] tty: serial: 8250: Add check for setting default serial interface Crescent Hsieh
@ 2024-06-07 11:43 ` Crescent Hsieh
  2024-06-08  9:51   ` Andy Shevchenko
  2024-06-07 11:43 ` [PATCH 6/6] tty: serial: 8250: Add support for MUEX50 UART Crescent Hsieh
  2024-06-08  9:47 ` [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Andy Shevchenko
  6 siblings, 1 reply; 16+ messages in thread
From: Crescent Hsieh @ 2024-06-07 11:43 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial, Crescent Hsieh

This patch adds support for Moxa PCIe serial boards to switch the serial
interface by using ioctl() command "TIOCSRS485" with the flags of struct
"serial_rs485":

    - RS232                  = (no flags are set)
    - RS422                  = SER_RS485_ENABLED | SER_RS485_MODE_RS422
    - RS485_2W (half-duplex) = SER_RS485_ENABLED
    - RS485_4W (full-duplex) = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX

Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
---
 drivers/tty/serial/8250/8250_pci.c | 46 ++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index e4e6493a5497..e2fcddec9ab5 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -2010,6 +2010,10 @@ enum {
 	MOXA_SUPP_RS485 = BIT(2),
 };
 
+static const struct serial_rs485 pci_moxa_rs485_supported = {
+	.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX | SER_RS485_MODE_RS422,
+};
+
 static bool pci_moxa_is_pcie(unsigned short device)
 {
 	if (device == PCI_DEVICE_ID_MOXA_CP102E     ||
@@ -2078,6 +2082,37 @@ static int pci_moxa_set_interface(const struct pci_dev *dev,
 	return 0;
 }
 
+/*
+ * Moxa PCIe boards support switching the serial interface using the ioctl()
+ * command "TIOCSRS485".
+ *
+ *      RS232                   = (no flags are set)
+ *      RS422                   = SER_RS485_ENABLED | SER_RS485_MODE_RS422
+ *      RS485_2W (half-duplex)  = SER_RS485_ENABLED
+ *      RS485_4W (full-duplex)  = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX
+ */
+static int pci_moxa_rs485_config(struct uart_port *port,
+				 struct ktermios *termios,
+				 struct serial_rs485 *rs485)
+{
+	struct pci_dev *dev = to_pci_dev(port->dev);
+	u8 mode = MOXA_RS232;
+
+	if (rs485->flags & SER_RS485_ENABLED) {
+		if (rs485->flags & SER_RS485_MODE_RS422)
+			mode = MOXA_RS422;
+		else if (rs485->flags & SER_RS485_RX_DURING_TX)
+			mode = MOXA_RS485_4W;
+		else
+			mode = MOXA_RS485_2W;
+	} else {
+		if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232))
+			return -ENODEV;
+	}
+
+	return pci_moxa_set_interface(dev, port->port_id, mode);
+}
+
 static int pci_moxa_init(struct pci_dev *dev)
 {
 	unsigned short device = dev->device;
@@ -2120,9 +2155,20 @@ pci_moxa_setup(struct serial_private *priv,
 		const struct pciserial_board *board,
 		struct uart_8250_port *port, int idx)
 {
+	struct pci_dev *dev = priv->dev;
 	unsigned int bar = FL_GET_BASE(board->flags);
 	int offset;
 
+	if (pci_moxa_is_pcie(dev->device) || pci_moxa_is_mini_pcie(dev->device)) {
+		if (pci_moxa_supported_rs(dev) & MOXA_SUPP_RS485) {
+			port->port.rs485_config = pci_moxa_rs485_config;
+			port->port.rs485_supported = pci_moxa_rs485_supported;
+
+			if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232))
+				port->port.rs485.flags = SER_RS485_ENABLED | SER_RS485_MODE_RS422;
+		}
+	}
+
 	if (board->num_ports == 4 && idx == 3)
 		offset = 7 * board->uart_offset;
 	else
-- 
2.34.1


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

* [PATCH 6/6] tty: serial: 8250: Add support for MUEX50 UART
  2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
                   ` (4 preceding siblings ...)
  2024-06-07 11:43 ` [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards to switch interface Crescent Hsieh
@ 2024-06-07 11:43 ` Crescent Hsieh
  2024-06-08  9:52   ` Andy Shevchenko
  2024-06-08  9:47 ` [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Andy Shevchenko
  6 siblings, 1 reply; 16+ messages in thread
From: Crescent Hsieh @ 2024-06-07 11:43 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial, Crescent Hsieh

The MUEX50 UART does not directly match to PORT_16550A or other generic
UART configurations.

This patch adds an UART configuration to capture the hardware
capabilities of MUEX50 UART and apply to Moxa PCI serial boards.

Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
---
 drivers/tty/serial/8250/8250_pci.c  | 3 +++
 drivers/tty/serial/8250/8250_port.c | 8 ++++++++
 include/uapi/linux/serial_core.h    | 3 +++
 3 files changed, 14 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index e2fcddec9ab5..3ccbb406f505 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -2159,6 +2159,9 @@ pci_moxa_setup(struct serial_private *priv,
 	unsigned int bar = FL_GET_BASE(board->flags);
 	int offset;
 
+	port->port.flags |= UPF_FIXED_TYPE;
+	port->port.type = PORT_MUEX50;
+
 	if (pci_moxa_is_pcie(dev->device) || pci_moxa_is_mini_pcie(dev->device)) {
 		if (pci_moxa_supported_rs(dev) & MOXA_SUPP_RS485) {
 			port->port.rs485_config = pci_moxa_rs485_config;
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 893bc493f662..c3de350e9a30 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -319,6 +319,14 @@ static const struct serial8250_config uart_config[] = {
 		.rxtrig_bytes	= {1, 8, 16, 30},
 		.flags		= UART_CAP_FIFO | UART_CAP_AFE,
 	},
+	[PORT_MUEX50] = {
+		.name		= "Moxa PCIe UART",
+		.fifo_size	= 128,
+		.tx_loadsz	= 128,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+		.rxtrig_bytes	= {1, 4, 8, 14},
+		.flags		= UART_CAP_FIFO,
+	},
 };
 
 /* Uart divisor latch read */
diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h
index 9c007a106330..5afeb6d99e7e 100644
--- a/include/uapi/linux/serial_core.h
+++ b/include/uapi/linux/serial_core.h
@@ -231,6 +231,9 @@
 /* Sunplus UART */
 #define PORT_SUNPLUS	123
 
+/* Moxa PCIe UART */
+#define PORT_MUEX50	124
+
 /* Generic type identifier for ports which type is not important to userspace. */
 #define PORT_GENERIC	(-1)
 
-- 
2.34.1


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

* Re: [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards
  2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
                   ` (5 preceding siblings ...)
  2024-06-07 11:43 ` [PATCH 6/6] tty: serial: 8250: Add support for MUEX50 UART Crescent Hsieh
@ 2024-06-08  9:47 ` Andy Shevchenko
  2024-06-13 10:15   ` Crescent CY Hsieh
  6 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2024-06-08  9:47 UTC (permalink / raw)
  To: Crescent Hsieh; +Cc: Jiri Slaby, Greg Kroah-Hartman, linux-kernel, linux-serial

Fri, Jun 07, 2024 at 07:43:30PM +0800, Crescent Hsieh kirjoitti:
> There are 6 patches within this patch series to make some adjustments
> and enhancements for MOXA PCI serial boards, a briefly description is
> written below:
> 
> - The first patch is an independent bug fix patch.
> - The second and third patches migrate some MOXA PCI devices from
>   `mxser.c` to `8250_pci.c`.
> - The fourth and fifth patches address improvements and adjustments in
>   handling the serial interface.
> - The sixth patch adds a UART configuration that aligns with the
>   hardware capabilities of MOXA PCI serial boards.

Everything is fine except one issue. Can we avoid polluting 8250_pci?
What I would expect as a patch 2 is a separation of 8250_moxa from
8250_pci (see examples how it was done in the past: 8250_exar, 8250_lpss,
8250_mid, ...) and then updating code there. Can it be achievable?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards to switch interface
  2024-06-07 11:43 ` [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards to switch interface Crescent Hsieh
@ 2024-06-08  9:51   ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-06-08  9:51 UTC (permalink / raw)
  To: Crescent Hsieh; +Cc: Jiri Slaby, Greg Kroah-Hartman, linux-kernel, linux-serial

Fri, Jun 07, 2024 at 07:43:35PM +0800, Crescent Hsieh kirjoitti:
> This patch adds support for Moxa PCIe serial boards to switch the serial
> interface by using ioctl() command "TIOCSRS485" with the flags of struct
> "serial_rs485":
> 
>     - RS232                  = (no flags are set)
>     - RS422                  = SER_RS485_ENABLED | SER_RS485_MODE_RS422
>     - RS485_2W (half-duplex) = SER_RS485_ENABLED
>     - RS485_4W (full-duplex) = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX
> 

...

> +	if (rs485->flags & SER_RS485_ENABLED) {
> +		if (rs485->flags & SER_RS485_MODE_RS422)
> +			mode = MOXA_RS422;
> +		else if (rs485->flags & SER_RS485_RX_DURING_TX)
> +			mode = MOXA_RS485_4W;
> +		else
> +			mode = MOXA_RS485_2W;

> +	} else {
> +		if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232))

	} else if ... {

> +			return -ENODEV;
> +	}

...

> +	if (pci_moxa_is_pcie(dev->device) || pci_moxa_is_mini_pcie(dev->device)) {
> +		if (pci_moxa_supported_rs(dev) & MOXA_SUPP_RS485) {

Two if:s can be replaced with if (foo && bar), but it's up to you.

> +			port->port.rs485_config = pci_moxa_rs485_config;
> +			port->port.rs485_supported = pci_moxa_rs485_supported;
> +
> +			if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232))
> +				port->port.rs485.flags = SER_RS485_ENABLED | SER_RS485_MODE_RS422;
> +		}
> +	}

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 6/6] tty: serial: 8250: Add support for MUEX50 UART
  2024-06-07 11:43 ` [PATCH 6/6] tty: serial: 8250: Add support for MUEX50 UART Crescent Hsieh
@ 2024-06-08  9:52   ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-06-08  9:52 UTC (permalink / raw)
  To: Crescent Hsieh; +Cc: Jiri Slaby, Greg Kroah-Hartman, linux-kernel, linux-serial

Fri, Jun 07, 2024 at 07:43:36PM +0800, Crescent Hsieh kirjoitti:
> The MUEX50 UART does not directly match to PORT_16550A or other generic
> UART configurations.

Does it match any non-generic configuration?

> This patch adds an UART configuration to capture the hardware
> capabilities of MUEX50 UART and apply to Moxa PCI serial boards.

...

> +/* Moxa PCIe UART */
> +#define PORT_MUEX50	124

Please find a gap in the previous numbers, I believe we have a few.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 4/6] tty: serial: 8250: Add check for setting default serial interface
  2024-06-07 11:43 ` [PATCH 4/6] tty: serial: 8250: Add check for setting default serial interface Crescent Hsieh
@ 2024-06-08  9:57   ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-06-08  9:57 UTC (permalink / raw)
  To: Crescent Hsieh; +Cc: Jiri Slaby, Greg Kroah-Hartman, linux-kernel, linux-serial

Fri, Jun 07, 2024 at 07:43:34PM +0800, Crescent Hsieh kirjoitti:
> Moxa PCIe and Mini-PCIe boards are capable of switching the serial
> interface through software control, while other PCI boards switch the
> serial interface through hardware DIP switches.
> 
> This patch adds a check while setting the default serial interface.

...

> +static bool pci_moxa_is_pcie(unsigned short device)

Please, avoid potential collisions in the namespace, i.e.
start your function names with moxa, and not with pci.

This can be amended once you split out 8250_moxa.

> +{
> +	if (device == PCI_DEVICE_ID_MOXA_CP102E     ||
> +	    device == PCI_DEVICE_ID_MOXA_CP102EL    ||
> +	    device == PCI_DEVICE_ID_MOXA_CP104EL_A  ||
> +	    device == PCI_DEVICE_ID_MOXA_CP114EL    ||
> +	    device == PCI_DEVICE_ID_MOXA_CP116E_A_A ||
> +	    device == PCI_DEVICE_ID_MOXA_CP116E_A_B ||
> +	    device == PCI_DEVICE_ID_MOXA_CP118EL_A  ||
> +	    device == PCI_DEVICE_ID_MOXA_CP118E_A_I ||
> +	    device == PCI_DEVICE_ID_MOXA_CP132EL    ||
> +	    device == PCI_DEVICE_ID_MOXA_CP134EL_A  ||
> +	    device == PCI_DEVICE_ID_MOXA_CP138E_A   ||
> +	    device == PCI_DEVICE_ID_MOXA_CP168EL_A)
> +		return true;
> +
> +	return false;

Hmm... First of all, can this be done by using pci_is_pcie()?
Second, if the above is not sufficient, this can be read from driver data, no?

> +}

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device
  2024-06-07 11:43 ` [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device Crescent Hsieh
@ 2024-06-08  9:58   ` Andy Shevchenko
  2024-06-11  7:39   ` Jiri Slaby
  1 sibling, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-06-08  9:58 UTC (permalink / raw)
  To: Crescent Hsieh; +Cc: Jiri Slaby, Greg Kroah-Hartman, linux-kernel, linux-serial

Fri, Jun 07, 2024 at 07:43:31PM +0800, Crescent Hsieh kirjoitti:
> Normally, the amount of ports is written at the third digit of device ID
> of Moxa PCI boards, for example: `0x1121` indicates a 2 ports device.
> 
> However, `CP116E_A_A` and `CP116E_A_B` are two exceptions, which has 8
> ports but the third digit of device ID is `6`.
> 
> This patch fixes the issue above by adding checks.

Can you send this patch separately and add Fixes tag?
I will give my tag on it, but the rest needs some additional work
I think.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device
  2024-06-07 11:43 ` [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device Crescent Hsieh
  2024-06-08  9:58   ` Andy Shevchenko
@ 2024-06-11  7:39   ` Jiri Slaby
  1 sibling, 0 replies; 16+ messages in thread
From: Jiri Slaby @ 2024-06-11  7:39 UTC (permalink / raw)
  To: Crescent Hsieh, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial

On 07. 06. 24, 13:43, Crescent Hsieh wrote:
> Normally, the amount of ports is written at the third digit of device ID
> of Moxa PCI boards, for example: `0x1121` indicates a 2 ports device.
> 
> However, `CP116E_A_A` and `CP116E_A_B` are two exceptions, which has 8
> ports but the third digit of device ID is `6`.
> 
> This patch fixes the issue above by adding checks.
> 
> Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
> ---
>   drivers/tty/serial/8250/8250_pci.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
> index 40af74b55933..4e88ee07e548 100644
> --- a/drivers/tty/serial/8250/8250_pci.c
> +++ b/drivers/tty/serial/8250/8250_pci.c
> @@ -2041,6 +2041,10 @@ static int pci_moxa_init(struct pci_dev *dev)
>   	unsigned int num_ports = (device & 0x00F0) >> 4, i;
>   	u8 val, init_mode = MOXA_RS232;
>   
> +	if (device == PCI_DEVICE_ID_MOXA_CP116E_A_A ||
> +	    device == PCI_DEVICE_ID_MOXA_CP116E_A_B)
> +		num_ports = 8;

Can you perhaps introduce a helper like:
static unsigned short mxser_get_nports(struct pci_dev *pdev)
{
   switch (pdev->device) {
   case ...CP116E_A_A:
   case ...CP116E_A_B:
     return 8;
   }

   return FIELD_GET(0x00F0, pdev->device);
}

?

> +
>   	if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232)) {
>   		init_mode = MOXA_RS422;
>   	}

-- 
js
suse labs


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

* Re: [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci
  2024-06-07 11:43 ` [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci Crescent Hsieh
@ 2024-06-11  7:42   ` Jiri Slaby
  2024-06-13 10:03     ` Crescent CY Hsieh
  0 siblings, 1 reply; 16+ messages in thread
From: Jiri Slaby @ 2024-06-11  7:42 UTC (permalink / raw)
  To: Crescent Hsieh, Greg Kroah-Hartman; +Cc: linux-kernel, linux-serial

On 07. 06. 24, 13:43, Crescent Hsieh wrote:
> The devices in mxser could be supported by 8250_pci, so this patch
> relocates these device IDs from mxser into 8250_pci.
> 
> Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
> ---
>   drivers/tty/mxser.c                | 50 ------------------------------
>   drivers/tty/serial/8250/8250_pci.c | 50 ++++++++++++++++++++++++++++++
>   2 files changed, 50 insertions(+), 50 deletions(-)
> 
> diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
> index 458bb1280ebf..b0e7ea6611bf 100644
> --- a/drivers/tty/mxser.c
> +++ b/drivers/tty/mxser.c
> @@ -160,31 +160,6 @@
>   #define MXSER_CUSTOM_DIVISOR	(MXSER_BAUD_BASE * 16)
>   
>   #define PCI_DEVICE_ID_MOXA_RC7000	0x0001
> -#define PCI_DEVICE_ID_MOXA_CP102	0x1020
> -#define PCI_DEVICE_ID_MOXA_CP102UL	0x1021
> -#define PCI_DEVICE_ID_MOXA_CP102U	0x1022
> -#define PCI_DEVICE_ID_MOXA_CP102UF	0x1023
> -#define PCI_DEVICE_ID_MOXA_C104		0x1040
> -#define PCI_DEVICE_ID_MOXA_CP104U	0x1041
> -#define PCI_DEVICE_ID_MOXA_CP104JU	0x1042
> -#define PCI_DEVICE_ID_MOXA_CP104EL	0x1043
> -#define PCI_DEVICE_ID_MOXA_POS104UL	0x1044
> -#define PCI_DEVICE_ID_MOXA_CB108	0x1080
> -#define PCI_DEVICE_ID_MOXA_CP112UL	0x1120
> -#define PCI_DEVICE_ID_MOXA_CT114	0x1140
> -#define PCI_DEVICE_ID_MOXA_CP114	0x1141
> -#define PCI_DEVICE_ID_MOXA_CB114	0x1142
> -#define PCI_DEVICE_ID_MOXA_CP114UL	0x1143
> -#define PCI_DEVICE_ID_MOXA_CP118U	0x1180
> -#define PCI_DEVICE_ID_MOXA_CP118EL	0x1181
> -#define PCI_DEVICE_ID_MOXA_CP132	0x1320
> -#define PCI_DEVICE_ID_MOXA_CP132U	0x1321
> -#define PCI_DEVICE_ID_MOXA_CP134U	0x1340
> -#define PCI_DEVICE_ID_MOXA_CB134I	0x1341
> -#define PCI_DEVICE_ID_MOXA_CP138U	0x1380
> -#define PCI_DEVICE_ID_MOXA_C168		0x1680
> -#define PCI_DEVICE_ID_MOXA_CP168U	0x1681
> -#define PCI_DEVICE_ID_MOXA_CP168EL	0x1682
>   
>   #define MXSER_NPORTS(ddata)		((ddata) & 0xffU)
>   #define MXSER_HIGHBAUD			0x0100
> @@ -212,32 +187,7 @@ static const struct {
>   /* driver_data correspond to the lines in the structure above
>      see also ISA probe function before you change something */
>   static const struct pci_device_id mxser_pcibrds[] = {
> -	{ PCI_DEVICE_DATA(MOXA, C168,		8) },
> -	{ PCI_DEVICE_DATA(MOXA, C104,		4) },
> -	{ PCI_DEVICE_DATA(MOXA, CP132,		2) },
> -	{ PCI_DEVICE_DATA(MOXA, CP114,		4) },
> -	{ PCI_DEVICE_DATA(MOXA, CT114,		4) },
> -	{ PCI_DEVICE_DATA(MOXA, CP102,		2 | MXSER_HIGHBAUD) },

How is this MXSER_HIGHBAUD handled in 8250_pci?

> -	{ PCI_DEVICE_DATA(MOXA, CP104U,		4) },
> -	{ PCI_DEVICE_DATA(MOXA, CP168U,		8) },
> -	{ PCI_DEVICE_DATA(MOXA, CP132U,		2) },
> -	{ PCI_DEVICE_DATA(MOXA, CP134U,		4) },
> -	{ PCI_DEVICE_DATA(MOXA, CP104JU,	4) },
>   	{ PCI_DEVICE_DATA(MOXA, RC7000,		8) }, /* RC7000 */

Can you simply add this exception to mxser_get_nports() I suggested in 
1/6 and drop the whole mxser then \o/?

I had a long-term plan to mount mxser onto serial-core (or 8250). I 
haven't managed the conversion yet. So I am glad to see this.

> -	{ PCI_DEVICE_DATA(MOXA, CP118U,		8) },
> -	{ PCI_DEVICE_DATA(MOXA, CP102UL,	2) },
> -	{ PCI_DEVICE_DATA(MOXA, CP102U,		2) },
> -	{ PCI_DEVICE_DATA(MOXA, CP118EL,	8) },
> -	{ PCI_DEVICE_DATA(MOXA, CP168EL,	8) },
> -	{ PCI_DEVICE_DATA(MOXA, CP104EL,	4) },
> -	{ PCI_DEVICE_DATA(MOXA, CB108,		8) },
> -	{ PCI_DEVICE_DATA(MOXA, CB114,		4) },
> -	{ PCI_DEVICE_DATA(MOXA, CB134I,		4) },
> -	{ PCI_DEVICE_DATA(MOXA, CP138U,		8) },
> -	{ PCI_DEVICE_DATA(MOXA, POS104UL,	4) },
> -	{ PCI_DEVICE_DATA(MOXA, CP114UL,	4) },
> -	{ PCI_DEVICE_DATA(MOXA, CP102UF,	2) },
> -	{ PCI_DEVICE_DATA(MOXA, CP112UL,	2) },
>   	{ }
>   };
-- 
js


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

* Re: [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci
  2024-06-11  7:42   ` Jiri Slaby
@ 2024-06-13 10:03     ` Crescent CY Hsieh
  0 siblings, 0 replies; 16+ messages in thread
From: Crescent CY Hsieh @ 2024-06-13 10:03 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Greg Kroah-Hartman, linux-kernel, linux-serial

On Tue, Jun 11, 2024 at 09:42:36AM +0200, Jiri Slaby wrote:
> On 07. 06. 24, 13:43, Crescent Hsieh wrote:
> > @@ -212,32 +187,7 @@ static const struct {
> >   /* driver_data correspond to the lines in the structure above
> >      see also ISA probe function before you change something */
> >   static const struct pci_device_id mxser_pcibrds[] = {
> > -	{ PCI_DEVICE_DATA(MOXA, C168,		8) },
> > -	{ PCI_DEVICE_DATA(MOXA, C104,		4) },
> > -	{ PCI_DEVICE_DATA(MOXA, CP132,		2) },
> > -	{ PCI_DEVICE_DATA(MOXA, CP114,		4) },
> > -	{ PCI_DEVICE_DATA(MOXA, CT114,		4) },
> > -	{ PCI_DEVICE_DATA(MOXA, CP102,		2 | MXSER_HIGHBAUD) },
> 
> How is this MXSER_HIGHBAUD handled in 8250_pci?

I will first create a patch to split the Moxa-related code from
`8250_pci.c` into `8250_moxa.c`. Then, I will try to migrate `mxser.c`
to `8250_moxa.c` and handle MXSER_HIGHBAUD there.

> 
> > -	{ PCI_DEVICE_DATA(MOXA, CP104U,		4) },
> > -	{ PCI_DEVICE_DATA(MOXA, CP168U,		8) },
> > -	{ PCI_DEVICE_DATA(MOXA, CP132U,		2) },
> > -	{ PCI_DEVICE_DATA(MOXA, CP134U,		4) },
> > -	{ PCI_DEVICE_DATA(MOXA, CP104JU,	4) },
> >   	{ PCI_DEVICE_DATA(MOXA, RC7000,		8) }, /* RC7000 */
> 
> Can you simply add this exception to mxser_get_nports() I suggested in 1/6
> and drop the whole mxser then \o/?
> 
> I had a long-term plan to mount mxser onto serial-core (or 8250). I haven't
> managed the conversion yet. So I am glad to see this.

Yes, I know you have been working hard to convert `mxser.c` into a
general driver, and I truly appreciate your efforts.
https://lore.kernel.org/linux-serial/20210618061516.662-1-jslaby@suse.cz/

However, I am curious if a general serial driver can support the full
functionality of PCI serial boards. Additionally, what's the plans for
addressing specific functionalities?

---
Sincerely,
Crescent Hsieh

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

* Re: [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards
  2024-06-08  9:47 ` [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Andy Shevchenko
@ 2024-06-13 10:15   ` Crescent CY Hsieh
  0 siblings, 0 replies; 16+ messages in thread
From: Crescent CY Hsieh @ 2024-06-13 10:15 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jiri Slaby, Greg Kroah-Hartman, linux-kernel, linux-serial

On Sat, Jun 08, 2024 at 12:47:40PM +0300, Andy Shevchenko wrote:
> Fri, Jun 07, 2024 at 07:43:30PM +0800, Crescent Hsieh kirjoitti:
> > There are 6 patches within this patch series to make some adjustments
> > and enhancements for MOXA PCI serial boards, a briefly description is
> > written below:
> > 
> > - The first patch is an independent bug fix patch.
> > - The second and third patches migrate some MOXA PCI devices from
> >   `mxser.c` to `8250_pci.c`.
> > - The fourth and fifth patches address improvements and adjustments in
> >   handling the serial interface.
> > - The sixth patch adds a UART configuration that aligns with the
> >   hardware capabilities of MOXA PCI serial boards.
> 
> Everything is fine except one issue. Can we avoid polluting 8250_pci?
> What I would expect as a patch 2 is a separation of 8250_moxa from
> 8250_pci (see examples how it was done in the past: 8250_exar, 8250_lpss,
> 8250_mid, ...) and then updating code there. Can it be achievable?

Agree, I have been putting too much stuff into `8250_pci.c`.
I will send the bug fix patch first, then create a new patch series to
split the code into `8250_moxa.c`.

---
Sincerely,
Crescent Hsieh

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

end of thread, other threads:[~2024-06-13 10:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
2024-06-07 11:43 ` [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device Crescent Hsieh
2024-06-08  9:58   ` Andy Shevchenko
2024-06-11  7:39   ` Jiri Slaby
2024-06-07 11:43 ` [PATCH 2/6] tty: serial: 8250: Add 2 ports PCI configuration for 921600 BAR 2 Crescent Hsieh
2024-06-07 11:43 ` [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci Crescent Hsieh
2024-06-11  7:42   ` Jiri Slaby
2024-06-13 10:03     ` Crescent CY Hsieh
2024-06-07 11:43 ` [PATCH 4/6] tty: serial: 8250: Add check for setting default serial interface Crescent Hsieh
2024-06-08  9:57   ` Andy Shevchenko
2024-06-07 11:43 ` [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards to switch interface Crescent Hsieh
2024-06-08  9:51   ` Andy Shevchenko
2024-06-07 11:43 ` [PATCH 6/6] tty: serial: 8250: Add support for MUEX50 UART Crescent Hsieh
2024-06-08  9:52   ` Andy Shevchenko
2024-06-08  9:47 ` [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Andy Shevchenko
2024-06-13 10:15   ` Crescent CY Hsieh

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