Lines Matching +full:serial +full:- +full:dir
1 // SPDX-License-Identifier: GPL-2.0
3 * Probe module for 8250/16550-type Exar chips PCI serial ports.
5 * Based on drivers/tty/serial/8250/8250_pci.c,
53 #define UART_FCTR_EXAR_485 0x20 /* Auto 485 half duplex dir ctl */
59 #define UART_EXAR_TXTRG 0x0a /* Tx FIFO trigger level write-only */
60 #define UART_EXAR_RXTRG 0x0b /* Rx FIFO trigger level write-only */
81 * ---- ---- --------
85 * 3 - <reserved>
89 * 7 - <reserved>
92 * 10 - Red LED
93 * 11..15 - <unused>
123 * struct exar8250_board - board information
124 * @num_ports: number of serial ports
126 * @setup: quirk run at ->probe() stage
127 * @exit: quirk run at ->remove() stage
157 * Calculate divisor with extra 4-bit fractional portion
164 quot_16 = DIV_ROUND_CLOSEST(p->uartclk, baud); in xr17v35x_get_divisor()
201 struct circ_buf *xmit = &port->state->xmit; in exar_shutdown()
221 const struct exar8250_board *board = priv->board; in default_setup()
225 port->port.iotype = UPIO_MEM; in default_setup()
226 port->port.mapbase = pci_resource_start(pcidev, bar) + offset; in default_setup()
227 port->port.membase = priv->virt + offset; in default_setup()
228 port->port.regshift = board->reg_shift; in default_setup()
237 status = readb(port->port.membase + UART_EXAR_DVID); in default_setup()
239 port->port.type = PORT_XR17V35X; in default_setup()
241 port->port.get_divisor = xr17v35x_get_divisor; in default_setup()
242 port->port.set_divisor = xr17v35x_set_divisor; in default_setup()
244 port->port.startup = xr17v35x_startup; in default_setup()
246 port->port.type = PORT_XR17D15X; in default_setup()
249 port->port.pm = exar_pm; in default_setup()
250 port->port.shutdown = exar_shutdown; in default_setup()
264 port->port.uartclk = baud * 16; in pci_fastcom335_setup()
270 p = port->port.membase; in pci_fastcom335_setup()
281 switch (pcidev->device) { in pci_fastcom335_setup()
310 port->port.uartclk = baud * 16; in pci_connect_tech_setup()
321 port->port.uartclk = baud * 16; in pci_xr17c154_setup()
329 * devices will export them as GPIOs, so we pre-configure them safely in setup_gpio()
333 u8 dir = 0x00; in setup_gpio() local
335 if ((pcidev->vendor == PCI_VENDOR_ID_EXAR) && in setup_gpio()
336 (pcidev->subsystem_vendor != PCI_VENDOR_ID_SEALEVEL)) { in setup_gpio()
338 dir = 0xff; in setup_gpio()
341 dir = 0x00; in setup_gpio()
348 writeb(dir, p + UART_EXAR_MPIOSEL_7_0); in setup_gpio()
354 writeb(dir, p + UART_EXAR_MPIOSEL_15_8); in setup_gpio()
367 pdev->dev.parent = &pcidev->dev; in __xr17v35x_register_gpio()
368 ACPI_COMPANION_SET(&pdev->dev, ACPI_COMPANION(&pcidev->dev)); in __xr17v35x_register_gpio()
370 if (device_add_software_node(&pdev->dev, node) < 0 || in __xr17v35x_register_gpio()
381 device_remove_software_node(&pdev->dev); in __xr17v35x_unregister_gpio()
386 PROPERTY_ENTRY_U32("exar,first-pin", 0),
397 if (pcidev->vendor == PCI_VENDOR_ID_EXAR) in xr17v35x_register_gpio()
398 port->port.private_data = in xr17v35x_register_gpio()
406 if (!port->port.private_data) in xr17v35x_unregister_gpio()
409 __xr17v35x_unregister_gpio(port->port.private_data); in xr17v35x_unregister_gpio()
410 port->port.private_data = NULL; in xr17v35x_unregister_gpio()
416 bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED); in generic_rs485_config()
417 u8 __iomem *p = port->membase; in generic_rs485_config()
448 bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED); in iot2040_rs485_config()
449 u8 __iomem *p = port->membase; in iot2040_rs485_config()
454 if (rs485->flags & SER_RS485_RX_DURING_TX) in iot2040_rs485_config()
459 if (rs485->flags & SER_RS485_TERMINATE_BUS) in iot2040_rs485_config()
465 if (port->line == 3) { in iot2040_rs485_config()
483 PROPERTY_ENTRY_U32("exar,first-pin", 10),
495 u8 __iomem *p = port->port.membase; in iot2040_register_gpio()
502 port->port.private_data = in iot2040_register_gpio()
536 return dmi_match->driver_data; in exar_get_platform()
551 port->port.uartclk = baud * 16; in pci_xr17v35x_setup()
552 port->port.rs485_config = platform->rs485_config; in pci_xr17v35x_setup()
553 port->port.rs485_supported = *(platform->rs485_supported); in pci_xr17v35x_setup()
560 port->port.uartclk /= 2; in pci_xr17v35x_setup()
566 p = port->port.membase; in pci_xr17v35x_setup()
577 ret = platform->register_gpio(pcidev, port); in pci_xr17v35x_setup()
587 struct uart_8250_port *port = serial8250_get_port(priv->line[0]); in pci_xr17v35x_exit()
589 platform->unregister_gpio(port); in pci_xr17v35x_exit()
595 readb(priv->virt + UART_EXAR_INT0); in exar_misc_clear()
598 if (priv->board->num_ports > 8) in exar_misc_clear()
599 readb(priv->virt + 0x2000 + UART_EXAR_INT0); in exar_misc_clear()
627 board = (struct exar8250_board *)ent->driver_data; in exar_pci_probe()
629 return -EINVAL; in exar_pci_probe()
635 maxnr = pci_resource_len(pcidev, bar) >> (board->reg_shift + 3); in exar_pci_probe()
637 if (pcidev->vendor == PCI_VENDOR_ID_ACCESSIO) in exar_pci_probe()
638 nr_ports = BIT(((pcidev->device & 0x38) >> 3) - 1); in exar_pci_probe()
639 else if (board->num_ports) in exar_pci_probe()
640 nr_ports = board->num_ports; in exar_pci_probe()
642 nr_ports = pcidev->device & 0x0f; in exar_pci_probe()
644 priv = devm_kzalloc(&pcidev->dev, struct_size(priv, line, nr_ports), GFP_KERNEL); in exar_pci_probe()
646 return -ENOMEM; in exar_pci_probe()
648 priv->board = board; in exar_pci_probe()
649 priv->virt = pcim_iomap(pcidev, bar, 0); in exar_pci_probe()
650 if (!priv->virt) in exar_pci_probe()
651 return -ENOMEM; in exar_pci_probe()
662 uart.port.dev = &pcidev->dev; in exar_pci_probe()
664 rc = devm_request_irq(&pcidev->dev, uart.port.irq, exar_misc_handler, in exar_pci_probe()
673 rc = board->setup(priv, pcidev, &uart, i); in exar_pci_probe()
675 dev_err(&pcidev->dev, "Failed to setup port %u\n", i); in exar_pci_probe()
679 dev_dbg(&pcidev->dev, "Setup PCI port: port %lx, irq %d, type %d\n", in exar_pci_probe()
682 priv->line[i] = serial8250_register_8250_port(&uart); in exar_pci_probe()
683 if (priv->line[i] < 0) { in exar_pci_probe()
684 dev_err(&pcidev->dev, in exar_pci_probe()
685 "Couldn't register serial port %lx, irq %d, type %d, error %d\n", in exar_pci_probe()
687 uart.port.iotype, priv->line[i]); in exar_pci_probe()
691 priv->nr = i; in exar_pci_probe()
701 for (i = 0; i < priv->nr; i++) in exar_pci_remove()
702 serial8250_unregister_port(priv->line[i]); in exar_pci_remove()
704 if (priv->board->exit) in exar_pci_remove()
705 priv->board->exit(pcidev); in exar_pci_remove()
714 for (i = 0; i < priv->nr; i++) in exar_suspend()
715 if (priv->line[i] >= 0) in exar_suspend()
716 serial8250_suspend_port(priv->line[i]); in exar_suspend()
719 if (priv->board->exit) in exar_suspend()
720 priv->board->exit(pcidev); in exar_suspend()
732 for (i = 0; i < priv->nr; i++) in exar_resume()
733 if (priv->line[i] >= 0) in exar_resume()
734 serial8250_resume_port(priv->line[i]); in exar_resume()
883 MODULE_DESCRIPTION("Exar Serial Driver");