Message ID | 20240607114336.4496-5-crescentcy.hsieh@moxa.com |
---|---|
State | New |
Headers | show |
Series | Adjustments and Enhancements for MOXA PCI Serial Boards | expand |
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? > +}
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.
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(-)