Lines Matching +full:mode +full:- +full:capable
1 // SPDX-License-Identifier: GPL-2.0+
7 * for RS-485 transceiver control. This driver implements support for the
10 * Copyright 2012-2023 National Instruments Corporation
31 /* TFS - TX FIFO Size */
33 /* RFS - RX FIFO Size */
36 /* PMR - Port Mode Register */
38 /* PMR[1:0] - Port Capabilities */
41 #define NI16550_PMR_CAP_RS232 FIELD_PREP(NI16550_PMR_CAP_MASK, 1) /* RS-232 capable */
42 #define NI16550_PMR_CAP_RS485 FIELD_PREP(NI16550_PMR_CAP_MASK, 2) /* RS-485 capable */
43 #define NI16550_PMR_CAP_DUAL FIELD_PREP(NI16550_PMR_CAP_MASK, 3) /* dual-port */
44 /* PMR[4] - Interface Mode */
49 /* PCR - Port Control Register */
51 * Wire Mode | Tx enabled? | Rx enabled?
52 * ---------------|----------------------|--------------------------
85 pcr = port->serial_in(port, NI16550_PCR_OFFSET); in ni16550_enable_transceivers()
87 dev_dbg(port->dev, "enable transceivers: write pcr: 0x%02x\n", pcr); in ni16550_enable_transceivers()
88 port->serial_out(port, NI16550_PCR_OFFSET, pcr); in ni16550_enable_transceivers()
99 dev_dbg(port->dev, "disable transceivers: write pcr: 0x%02x\n", pcr); in ni16550_disable_transceivers()
115 if ((rs485->flags & SER_RS485_MODE_RS422) || in ni16550_rs485_config()
116 !(rs485->flags & SER_RS485_ENABLED)) { in ni16550_rs485_config()
117 /* RS-422 */ in ni16550_rs485_config()
119 up->acr &= ~NI16550_ACR_AUTO_DTR_EN; in ni16550_rs485_config()
121 /* RS-485 2-wire Auto */ in ni16550_rs485_config()
123 up->acr |= NI16550_ACR_AUTO_DTR_EN; in ni16550_rs485_config()
126 dev_dbg(port->dev, "config rs485: write pcr: 0x%02x, acr: %02x\n", pcr, up->acr); in ni16550_rs485_config()
128 serial_icr_write(up, UART_ACR, up->acr); in ni16550_rs485_config()
141 * connected to RS-485 transceivers in is_pmr_rs232_mode()
148 * If the port is dual-mode capable, then read the mode bit in is_pmr_rs232_mode()
149 * to know the current mode in is_pmr_rs232_mode()
153 * If it is not dual-mode capable, then decide based on the in is_pmr_rs232_mode()
163 * Page in the Enhanced Mode Registers in ni16550_config_prescaler()
164 * Sets EFR[4] for Enhanced Mode. in ni16550_config_prescaler()
177 /* Page out the Enhanced Mode Registers */ in ni16550_config_prescaler()
199 port->rs485_config = ni16550_rs485_config; in ni16550_rs485_setup()
200 port->rs485_supported = ni16550_rs485_supported; in ni16550_rs485_setup()
202 * The hardware comes up by default in 2-wire auto mode and we in ni16550_rs485_setup()
205 port->rs485.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND; in ni16550_rs485_setup()
233 return dev_err_probe(&pdev->dev, -EINVAL, "no registers defined\n"); in ni16550_get_regs()
237 port->iotype = UPIO_PORT; in ni16550_get_regs()
238 port->iobase = regs->start; in ni16550_get_regs()
242 port->iotype = UPIO_MEM; in ni16550_get_regs()
243 port->mapbase = regs->start; in ni16550_get_regs()
244 port->mapsize = resource_size(regs); in ni16550_get_regs()
245 port->flags |= UPF_IOREMAP; in ni16550_get_regs()
249 return -EINVAL; in ni16550_get_regs()
255 * defined, so we may read all-0s or all-1s. For such devices,
272 up->mcr |= UART_MCR_CLKSEL; in ni16550_set_mctrl()
280 struct device *dev = &pdev->dev; in ni16550_probe()
290 return -ENOMEM; in ni16550_probe()
294 return -ENOMEM; in ni16550_probe()
296 spin_lock_init(&uart->port.lock); in ni16550_probe()
298 ret = ni16550_get_regs(pdev, &uart->port); in ni16550_probe()
307 uart->port.dev = dev; in ni16550_probe()
308 uart->port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_FIXED_TYPE; in ni16550_probe()
309 uart->port.startup = ni16550_port_startup; in ni16550_probe()
310 uart->port.shutdown = ni16550_port_shutdown; in ni16550_probe()
321 uart->port.type = PORT_16550A; in ni16550_probe()
322 uart->port.fifosize = txfifosz; in ni16550_probe()
323 uart->tx_loadsz = txfifosz; in ni16550_probe()
324 uart->fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10; in ni16550_probe()
325 uart->capabilities = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR; in ni16550_probe()
329 * - static declaration in this driver (for older ACPI IDs) in ni16550_probe()
330 * - a "clock-frequency" ACPI in ni16550_probe()
332 uart->port.uartclk = info->uartclk; in ni16550_probe()
334 ret = uart_read_port_properties(&uart->port); in ni16550_probe()
338 if (!uart->port.uartclk) { in ni16550_probe()
339 data->clk = devm_clk_get_enabled(dev, NULL); in ni16550_probe()
340 if (!IS_ERR(data->clk)) in ni16550_probe()
341 uart->port.uartclk = clk_get_rate(data->clk); in ni16550_probe()
344 if (!uart->port.uartclk) in ni16550_probe()
345 return dev_err_probe(dev, -ENODEV, "unable to determine clock frequency!\n"); in ni16550_probe()
347 prescaler = info->prescaler; in ni16550_probe()
348 device_property_read_u32(dev, "clock-prescaler", &prescaler); in ni16550_probe()
350 uart->port.set_mctrl = ni16550_set_mctrl; in ni16550_probe()
355 * The determination of whether or not this is an RS-485 or RS-232 port in ni16550_probe()
356 * can come from the PMR (if present), otherwise we're solely an RS-485 in ni16550_probe()
359 * This is a device-specific property, and there are old devices in the in ni16550_probe()
364 rs232_property = strncmp(portmode, "RS-232", 6) == 0; in ni16550_probe()
366 dev_dbg(dev, "port is in %s mode (via device property)\n", in ni16550_probe()
367 rs232_property ? "RS-232" : "RS-485"); in ni16550_probe()
368 } else if (info->flags & NI_HAS_PMR) { in ni16550_probe()
371 dev_dbg(dev, "port is in %s mode (via PMR)\n", in ni16550_probe()
372 rs232_property ? "RS-232" : "RS-485"); in ni16550_probe()
376 dev_dbg(dev, "port is fixed as RS-485\n"); in ni16550_probe()
382 * that this is an RS-232 port, so it must be an RS-485 one. in ni16550_probe()
384 ni16550_rs485_setup(&uart->port); in ni16550_probe()
390 data->line = ret; in ni16550_probe()
400 serial8250_unregister_port(data->line); in ni16550_remove()
403 /* NI 16550 RS-485 Interface */
408 /* NI CVS-145x RS-485 Interface */
414 /* NI cRIO-904x RS-485 Interface */
421 /* NI sbRIO 96x8 RS-232/485 Interfaces */