[PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci

Crescent Hsieh posted 6 patches 1 year, 8 months ago
[PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci
Posted by Crescent Hsieh 1 year, 8 months ago
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
Re: [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci
Posted by Jiri Slaby 1 year, 8 months ago
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
Re: [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci
Posted by Crescent CY Hsieh 1 year, 8 months ago
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