Lines Matching +full:mux +full:- +full:locked
1 // SPDX-License-Identifier: GPL-2.0
12 * [31-AUG-98] triemer
14 * removed base_addr code - moving address assignment to setup.c
16 * [13-NOV-98] triemer fixed code to receive characters
18 * [09-JAN-99] triemer minor fix for schedule - due to removal of timeout
19 * field from "current" - somewhere between 2.1.121 and 2.1.131
21 * [27-JUN-2001] Arnaldo Carvalho de Melo <acme@conectiva.com.br> - cleanups
24 * [07-SEP-99] Bugfixes
26 * [06-Jan-2002] Russell King <rmk@arm.linux.org.uk>
71 struct dz_mux *mux; member
91 * ------------------------------------------------------------
96 * ------------------------------------------------------------
101 void __iomem *addr = dport->port.membase + offset; in dz_in()
108 void __iomem *addr = dport->port.membase + offset; in dz_out()
114 * ------------------------------------------------------------
118 * tty->flow.stopped. They enable or disable transmitter interrupts,
120 * ------------------------------------------------------------
126 u16 tmp, mask = 1 << dport->port.line; in dz_stop_tx()
136 u16 tmp, mask = 1 << dport->port.line; in dz_start_tx()
147 dport->cflag &= ~DZ_RXENAB; in dz_stop_rx()
148 dz_out(dport, DZ_LPR, dport->cflag); in dz_stop_rx()
152 * ------------------------------------------------------------
168 * ------------------------------------------------------------
172 * ------------------------------------------------------------
176 * ------------------------------------------------------------
178 static inline void dz_receive_chars(struct dz_mux *mux) in dz_receive_chars() argument
181 struct dz_port *dport = &mux->dport[0]; in dz_receive_chars()
183 int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 }; in dz_receive_chars()
189 dport = &mux->dport[LINE(status)]; in dz_receive_chars()
190 uport = &dport->port; in dz_receive_chars()
195 icount = &uport->icount; in dz_receive_chars()
196 icount->rx++; in dz_receive_chars()
208 (ffs(DZ_FERR) - ffs(DZ_BREAK)); in dz_receive_chars()
214 icount->brk++; in dz_receive_chars()
218 icount->frame++; in dz_receive_chars()
220 icount->parity++; in dz_receive_chars()
222 icount->overrun++; in dz_receive_chars()
224 status &= uport->read_status_mask; in dz_receive_chars()
242 tty_flip_buffer_push(&mux->dport[i].port.state->port); in dz_receive_chars()
246 * ------------------------------------------------------------
250 * ------------------------------------------------------------
252 static inline void dz_transmit_chars(struct dz_mux *mux) in dz_transmit_chars() argument
254 struct dz_port *dport = &mux->dport[0]; in dz_transmit_chars()
260 dport = &mux->dport[LINE(status)]; in dz_transmit_chars()
261 xmit = &dport->port.state->xmit; in dz_transmit_chars()
263 if (dport->port.x_char) { /* XON/XOFF chars */ in dz_transmit_chars()
264 dz_out(dport, DZ_TDR, dport->port.x_char); in dz_transmit_chars()
265 dport->port.icount.tx++; in dz_transmit_chars()
266 dport->port.x_char = 0; in dz_transmit_chars()
270 if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) { in dz_transmit_chars()
271 spin_lock(&dport->port.lock); in dz_transmit_chars()
272 dz_stop_tx(&dport->port); in dz_transmit_chars()
273 spin_unlock(&dport->port.lock); in dz_transmit_chars()
279 * so we go one char at a time) :-< in dz_transmit_chars()
281 tmp = xmit->buf[xmit->tail]; in dz_transmit_chars()
282 xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1); in dz_transmit_chars()
284 dport->port.icount.tx++; in dz_transmit_chars()
287 uart_write_wakeup(&dport->port); in dz_transmit_chars()
291 spin_lock(&dport->port.lock); in dz_transmit_chars()
292 dz_stop_tx(&dport->port); in dz_transmit_chars()
293 spin_unlock(&dport->port.lock); in dz_transmit_chars()
298 * ------------------------------------------------------------
303 * ------------------------------------------------------------
310 * 2. Handle the 3100/5000 as appropriate. --macro in check_modem_status()
315 if (dport->port.line != DZ_MODEM) in check_modem_status()
322 dport->port.icount.dsr++; in check_modem_status()
326 * ------------------------------------------------------------
331 * ------------------------------------------------------------
335 struct dz_mux *mux = dev_id; in dz_interrupt() local
336 struct dz_port *dport = &mux->dport[0]; in dz_interrupt()
343 dz_receive_chars(mux); in dz_interrupt()
346 dz_transmit_chars(mux); in dz_interrupt()
352 * -------------------------------------------------------------------
354 * -------------------------------------------------------------------
360 * FIXME: Handle the 3100/5000 as appropriate. --macro in dz_get_mctrl()
365 if (dport->port.line == DZ_MODEM) { in dz_get_mctrl()
376 * FIXME: Handle the 3100/5000 as appropriate. --macro in dz_set_mctrl()
381 if (dport->port.line == DZ_MODEM) { in dz_set_mctrl()
392 * -------------------------------------------------------------------
396 * -------------------------------------------------------------------
401 struct dz_mux *mux = dport->mux; in dz_startup() local
407 irq_guard = atomic_add_return(1, &mux->irq_guard); in dz_startup()
411 ret = request_irq(dport->port.irq, dz_interrupt, in dz_startup()
412 IRQF_SHARED, "dz", mux); in dz_startup()
414 atomic_add(-1, &mux->irq_guard); in dz_startup()
415 printk(KERN_ERR "dz: Cannot get IRQ %d!\n", dport->port.irq); in dz_startup()
419 spin_lock_irqsave(&dport->port.lock, flags); in dz_startup()
426 spin_unlock_irqrestore(&dport->port.lock, flags); in dz_startup()
432 * -------------------------------------------------------------------
437 * -------------------------------------------------------------------
442 struct dz_mux *mux = dport->mux; in dz_shutdown() local
447 spin_lock_irqsave(&dport->port.lock, flags); in dz_shutdown()
448 dz_stop_tx(&dport->port); in dz_shutdown()
449 spin_unlock_irqrestore(&dport->port.lock, flags); in dz_shutdown()
451 irq_guard = atomic_add_return(-1, &mux->irq_guard); in dz_shutdown()
458 free_irq(dport->port.irq, mux); in dz_shutdown()
463 * -------------------------------------------------------------------
464 * dz_tx_empty() -- get the transmitter empty status
472 * -------------------------------------------------------------------
477 unsigned short tmp, mask = 1 << dport->port.line; in dz_tx_empty()
489 * reuse the code for polled TX. --macro in dz_break_ctl()
493 unsigned short tmp, mask = 1 << dport->port.line; in dz_break_ctl()
495 spin_lock_irqsave(&uport->lock, flags); in dz_break_ctl()
502 spin_unlock_irqrestore(&uport->lock, flags); in dz_break_ctl()
539 return -1; in dz_encode_baud_rate()
546 struct dz_mux *mux = dport->mux; in dz_reset() local
548 if (mux->initialised) in dz_reset()
558 mux->initialised = 1; in dz_reset()
569 cflag = dport->port.line; in dz_set_termios()
571 switch (termios->c_cflag & CSIZE) { in dz_set_termios()
586 if (termios->c_cflag & CSTOPB) in dz_set_termios()
588 if (termios->c_cflag & PARENB) in dz_set_termios()
590 if (termios->c_cflag & PARODD) in dz_set_termios()
609 if (termios->c_cflag & CREAD) in dz_set_termios()
612 spin_lock_irqsave(&dport->port.lock, flags); in dz_set_termios()
614 uart_update_timeout(uport, termios->c_cflag, baud); in dz_set_termios()
617 dport->cflag = cflag; in dz_set_termios()
620 dport->port.read_status_mask = DZ_OERR; in dz_set_termios()
621 if (termios->c_iflag & INPCK) in dz_set_termios()
622 dport->port.read_status_mask |= DZ_FERR | DZ_PERR; in dz_set_termios()
623 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) in dz_set_termios()
624 dport->port.read_status_mask |= DZ_BREAK; in dz_set_termios()
627 uport->ignore_status_mask = 0; in dz_set_termios()
628 if ((termios->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK)) in dz_set_termios()
629 dport->port.ignore_status_mask |= DZ_OERR; in dz_set_termios()
630 if (termios->c_iflag & IGNPAR) in dz_set_termios()
631 dport->port.ignore_status_mask |= DZ_FERR | DZ_PERR; in dz_set_termios()
632 if (termios->c_iflag & IGNBRK) in dz_set_termios()
633 dport->port.ignore_status_mask |= DZ_BREAK; in dz_set_termios()
635 spin_unlock_irqrestore(&dport->port.lock, flags); in dz_set_termios()
640 * Required solely so that the initial PROM-based console
649 spin_lock_irqsave(&dport->port.lock, flags); in dz_pm()
651 dz_start_tx(&dport->port); in dz_pm()
653 dz_stop_tx(&dport->port); in dz_pm()
654 spin_unlock_irqrestore(&dport->port.lock, flags); in dz_pm()
665 struct dz_mux *mux = to_dport(uport)->mux; in dz_release_port() local
668 iounmap(uport->membase); in dz_release_port()
669 uport->membase = NULL; in dz_release_port()
671 map_guard = atomic_add_return(-1, &mux->map_guard); in dz_release_port()
673 release_mem_region(uport->mapbase, dec_kn_slot_size); in dz_release_port()
678 if (!uport->membase) in dz_map_port()
679 uport->membase = ioremap(uport->mapbase, in dz_map_port()
681 if (!uport->membase) { in dz_map_port()
683 return -ENOMEM; in dz_map_port()
690 struct dz_mux *mux = to_dport(uport)->mux; in dz_request_port() local
694 map_guard = atomic_add_return(1, &mux->map_guard); in dz_request_port()
696 if (!request_mem_region(uport->mapbase, dec_kn_slot_size, in dz_request_port()
698 atomic_add(-1, &mux->map_guard); in dz_request_port()
701 return -EBUSY; in dz_request_port()
706 map_guard = atomic_add_return(-1, &mux->map_guard); in dz_request_port()
708 release_mem_region(uport->mapbase, dec_kn_slot_size); in dz_request_port()
722 uport->type = PORT_DZ; in dz_config_port()
735 if (ser->type != PORT_UNKNOWN && ser->type != PORT_DZ) in dz_verify_port()
736 ret = -EINVAL; in dz_verify_port()
737 if (ser->irq != uport->irq) in dz_verify_port()
738 ret = -EINVAL; in dz_verify_port()
778 struct uart_port *uport = &dport->port; in dz_init_ports()
780 dport->mux = &dz_mux; in dz_init_ports()
782 uport->irq = dec_interrupt[DEC_IRQ_DZ11]; in dz_init_ports()
783 uport->fifosize = 1; in dz_init_ports()
784 uport->iotype = UPIO_MEM; in dz_init_ports()
785 uport->flags = UPF_BOOT_AUTOCONF; in dz_init_ports()
786 uport->ops = &dz_ops; in dz_init_ports()
787 uport->line = line; in dz_init_ports()
788 uport->mapbase = base; in dz_init_ports()
789 uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_DZ_CONSOLE); in dz_init_ports()
795 * -------------------------------------------------------------------
796 * dz_console_putchar() -- transmit a character
805 * restored. Welcome to the world of PDP-11!
806 * -------------------------------------------------------------------
815 spin_lock_irqsave(&dport->port.lock, flags); in dz_console_putchar()
819 tcr |= 1 << dport->port.line; in dz_console_putchar()
823 spin_unlock_irqrestore(&dport->port.lock, flags); in dz_console_putchar()
830 if (trdy == dport->port.line) in dz_console_putchar()
836 } while (--loops); in dz_console_putchar()
846 * -------------------------------------------------------------------
850 * The console must be locked when we get here.
851 * -------------------------------------------------------------------
857 struct dz_port *dport = &dz_mux.dport[co->index]; in dz_console_print()
861 uart_console_write(&dport->port, str, count, dz_console_putchar); in dz_console_print()
866 struct dz_port *dport = &dz_mux.dport[co->index]; in dz_console_setup()
867 struct uart_port *uport = &dport->port; in dz_console_setup()
878 spin_lock_init(&dport->port.lock); /* For dz_pm(). */ in dz_console_setup()
881 dz_pm(uport, 0, -1); in dz_console_setup()
886 return uart_set_options(&dport->port, co, baud, parity, bits, flow); in dz_console_setup()
896 .index = -1,
907 return -ENXIO; in dz_serial_console_init()
932 return -ENXIO; in dz_init()