@@ -607,28 +607,30 @@ pci_fastcom335_setup(struct exar8250 *priv, struct pci_dev *pcidev,
607
607
writeb (32 , p + UART_EXAR_TXTRG );
608
608
writeb (32 , p + UART_EXAR_RXTRG );
609
609
610
+ /* Skip the initial (per device) setup */
611
+ if (idx )
612
+ return 0 ;
613
+
610
614
/*
611
615
* Setup Multipurpose Input/Output pins.
612
616
*/
613
- if (idx == 0 ) {
614
- switch (pcidev -> device ) {
615
- case PCI_DEVICE_ID_COMMTECH_4222PCI335 :
616
- case PCI_DEVICE_ID_COMMTECH_4224PCI335 :
617
- writeb (0x78 , p + UART_EXAR_MPIOLVL_7_0 );
618
- writeb (0x00 , p + UART_EXAR_MPIOINV_7_0 );
619
- writeb (0x00 , p + UART_EXAR_MPIOSEL_7_0 );
620
- break ;
621
- case PCI_DEVICE_ID_COMMTECH_2324PCI335 :
622
- case PCI_DEVICE_ID_COMMTECH_2328PCI335 :
623
- writeb (0x00 , p + UART_EXAR_MPIOLVL_7_0 );
624
- writeb (0xc0 , p + UART_EXAR_MPIOINV_7_0 );
625
- writeb (0xc0 , p + UART_EXAR_MPIOSEL_7_0 );
626
- break ;
627
- }
628
- writeb (0x00 , p + UART_EXAR_MPIOINT_7_0 );
629
- writeb (0x00 , p + UART_EXAR_MPIO3T_7_0 );
630
- writeb (0x00 , p + UART_EXAR_MPIOOD_7_0 );
617
+ switch (pcidev -> device ) {
618
+ case PCI_DEVICE_ID_COMMTECH_4222PCI335 :
619
+ case PCI_DEVICE_ID_COMMTECH_4224PCI335 :
620
+ writeb (0x78 , p + UART_EXAR_MPIOLVL_7_0 );
621
+ writeb (0x00 , p + UART_EXAR_MPIOINV_7_0 );
622
+ writeb (0x00 , p + UART_EXAR_MPIOSEL_7_0 );
623
+ break ;
624
+ case PCI_DEVICE_ID_COMMTECH_2324PCI335 :
625
+ case PCI_DEVICE_ID_COMMTECH_2328PCI335 :
626
+ writeb (0x00 , p + UART_EXAR_MPIOLVL_7_0 );
627
+ writeb (0xc0 , p + UART_EXAR_MPIOINV_7_0 );
628
+ writeb (0xc0 , p + UART_EXAR_MPIOSEL_7_0 );
629
+ break ;
631
630
}
631
+ writeb (0x00 , p + UART_EXAR_MPIOINT_7_0 );
632
+ writeb (0x00 , p + UART_EXAR_MPIO3T_7_0 );
633
+ writeb (0x00 , p + UART_EXAR_MPIOOD_7_0 );
632
634
633
635
return 0 ;
634
636
}
@@ -853,21 +855,19 @@ static enum cti_port_type cti_get_port_type_xr17v35x(struct exar8250 *priv,
853
855
port_flags = exar_ee_read (priv , offset );
854
856
855
857
port_type = FIELD_GET (CTI_EE_MASK_PORT_FLAGS_TYPE , port_flags );
856
- if (!CTI_PORT_TYPE_VALID (port_type )) {
857
- /*
858
- * If the port type is missing the card assume it is a
859
- * RS232/RS422/RS485 card to be safe.
860
- *
861
- * There is one known board (BEG013) that only has
862
- * 3 of 4 port types written to the EEPROM so this
863
- * acts as a work around.
864
- */
865
- dev_warn (& pcidev -> dev ,
866
- "failed to get port %d type from EEPROM\n" , port_num );
867
- port_type = CTI_PORT_TYPE_RS232_422_485_HW ;
868
- }
858
+ if (CTI_PORT_TYPE_VALID (port_type ))
859
+ return port_type ;
869
860
870
- return port_type ;
861
+ /*
862
+ * If the port type is missing the card assume it is a
863
+ * RS232/RS422/RS485 card to be safe.
864
+ *
865
+ * There is one known board (BEG013) that only has 3 of 4 port types
866
+ * written to the EEPROM so this acts as a work around.
867
+ */
868
+ dev_warn (& pcidev -> dev , "failed to get port %d type from EEPROM\n" , port_num );
869
+
870
+ return CTI_PORT_TYPE_RS232_422_485_HW ;
871
871
}
872
872
873
873
static int cti_rs485_config_mpio_tristate (struct uart_port * port ,
@@ -1190,11 +1190,10 @@ static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p)
1190
1190
* devices will export them as GPIOs, so we pre-configure them safely
1191
1191
* as inputs.
1192
1192
*/
1193
-
1194
1193
u8 dir = 0x00 ;
1195
1194
1196
1195
if ((pcidev -> vendor == PCI_VENDOR_ID_EXAR ) &&
1197
- (pcidev -> subsystem_vendor != PCI_VENDOR_ID_SEALEVEL )) {
1196
+ (pcidev -> subsystem_vendor != PCI_VENDOR_ID_SEALEVEL )) {
1198
1197
// Configure GPIO as inputs for Commtech adapters
1199
1198
dir = 0xff ;
1200
1199
} else {
@@ -1284,27 +1283,28 @@ static int sealevel_rs485_config(struct uart_port *port, struct ktermios *termio
1284
1283
if (ret )
1285
1284
return ret ;
1286
1285
1287
- if (rs485 -> flags & SER_RS485_ENABLED ) {
1288
- old_lcr = readb ( p + UART_LCR ) ;
1286
+ if (!( rs485 -> flags & SER_RS485_ENABLED ))
1287
+ return 0 ;
1289
1288
1290
- /* Set EFR[4]=1 to enable enhanced feature registers */
1291
- efr = readb (p + UART_XR_EFR );
1292
- efr |= UART_EFR_ECB ;
1293
- writeb (efr , p + UART_XR_EFR );
1289
+ old_lcr = readb (p + UART_LCR );
1294
1290
1295
- /* Set MCR to use DTR as Auto-RS485 Enable signal */
1296
- writeb (UART_MCR_OUT1 , p + UART_MCR );
1291
+ /* Set EFR[4]=1 to enable enhanced feature registers */
1292
+ efr = readb (p + UART_XR_EFR );
1293
+ efr |= UART_EFR_ECB ;
1294
+ writeb (efr , p + UART_XR_EFR );
1297
1295
1298
- /* Set LCR[7]=1 to enable access to DLD register */
1299
- writeb (old_lcr | UART_LCR_DLAB , p + UART_LCR );
1296
+ /* Set MCR to use DTR as Auto-RS485 Enable signal */
1297
+ writeb (UART_MCR_OUT1 , p + UART_MCR );
1300
1298
1301
- /* Set DLD[7]=1 for inverted RS485 Enable logic */
1302
- dld = readb (p + UART_EXAR_DLD );
1303
- dld |= UART_EXAR_DLD_485_POLARITY ;
1304
- writeb (dld , p + UART_EXAR_DLD );
1299
+ /* Set LCR[7]=1 to enable access to DLD register */
1300
+ writeb (old_lcr | UART_LCR_DLAB , p + UART_LCR );
1305
1301
1306
- writeb (old_lcr , p + UART_LCR );
1307
- }
1302
+ /* Set DLD[7]=1 for inverted RS485 Enable logic */
1303
+ dld = readb (p + UART_EXAR_DLD );
1304
+ dld |= UART_EXAR_DLD_485_POLARITY ;
1305
+ writeb (dld , p + UART_EXAR_DLD );
1306
+
1307
+ writeb (old_lcr , p + UART_LCR );
1308
1308
1309
1309
return 0 ;
1310
1310
}
0 commit comments