Lines Matching +full:uart +full:- +full:state
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
45 #include <dev/uart/uart.h>
46 #include <dev/uart/uart_bus.h>
47 #include <dev/uart/uart_cpu.h>
71 uart,
77 /* TTY swi(9) event. Allows all uart soft handlers to share one ithread. */
84 cp->cn_pri = CN_DEAD; in uart_cnprobe()
94 strlcpy(cp->cn_name, uart_driver_name, sizeof(cp->cn_name)); in uart_cnprobe()
95 cp->cn_pri = (boothowto & RB_SERIAL) ? CN_REMOTE : CN_NORMAL; in uart_cnprobe()
96 cp->cn_arg = &uart_console; in uart_cnprobe()
106 * single- or multi-user. The problem is that we don't know at in uart_cninit()
113 di = cp->cn_arg; in uart_cninit()
114 KASSERT(di->cookie == NULL, ("foo")); in uart_cninit()
115 di->cookie = cp; in uart_cninit()
116 di->type = UART_DEV_CONSOLE; in uart_cninit()
125 uart_init(cp->cn_arg); in uart_cnresume()
132 uart_term(cp->cn_arg); in uart_cnterm()
139 uart_grab(cp->cn_arg); in uart_cngrab()
146 uart_ungrab(cp->cn_arg); in uart_cnungrab()
153 uart_putc(cp->cn_arg, c); in uart_cnputc()
160 return (uart_poll(cp->cn_arg)); in uart_cngetc()
170 if (sc == NULL || sc->sc_leaving) in uart_tty_open()
173 sc->sc_opened = 1; in uart_tty_open()
183 if (sc == NULL || sc->sc_leaving || !sc->sc_opened) in uart_tty_close()
186 if (sc->sc_hwiflow) in uart_tty_close()
188 if (sc->sc_hwoflow) in uart_tty_close()
190 if (sc->sc_sysdev == NULL) in uart_tty_close()
194 sc->sc_opened = 0; in uart_tty_close()
203 if (sc == NULL || sc->sc_leaving) in uart_tty_outwakeup()
206 if (sc->sc_txbusy) in uart_tty_outwakeup()
213 if ((tp->t_termios.c_cflag & CCTS_OFLOW) && !sc->sc_hwoflow && in uart_tty_outwakeup()
214 !(sc->sc_hwsig & SER_CTS)) in uart_tty_outwakeup()
217 sc->sc_txdatasz = ttydisc_getc(tp, sc->sc_txbuf, sc->sc_txfifosz); in uart_tty_outwakeup()
218 if (sc->sc_txdatasz != 0) in uart_tty_outwakeup()
228 if (sc == NULL || sc->sc_leaving) in uart_tty_inwakeup()
231 if (sc->sc_isquelch) { in uart_tty_inwakeup()
232 if ((tp->t_termios.c_cflag & CRTS_IFLOW) && !sc->sc_hwiflow) in uart_tty_inwakeup()
234 sc->sc_isquelch = 0; in uart_tty_inwakeup()
255 return pps_ioctl(cmd, data, &sc->sc_pps); in uart_tty_ioctl()
266 if (sc == NULL || sc->sc_leaving) in uart_tty_param()
268 if (t->c_ispeed != t->c_ospeed && t->c_ospeed != 0) in uart_tty_param()
270 if (t->c_ospeed == 0) { in uart_tty_param()
274 switch (t->c_cflag & CSIZE) { in uart_tty_param()
280 stopbits = (t->c_cflag & CSTOPB) ? 2 : 1; in uart_tty_param()
281 if (t->c_cflag & PARENB) in uart_tty_param()
282 parity = (t->c_cflag & PARODD) ? UART_PARITY_ODD : in uart_tty_param()
286 if (UART_PARAM(sc, t->c_ospeed, databits, stopbits, parity) != 0) in uart_tty_param()
288 if ((t->c_cflag & CNO_RTSDTR) == 0) in uart_tty_param()
290 /* Set input flow control state. */ in uart_tty_param()
291 if (!sc->sc_hwiflow) { in uart_tty_param()
292 if ((t->c_cflag & CRTS_IFLOW) && sc->sc_isquelch) in uart_tty_param()
295 if ((t->c_cflag & CNO_RTSDTR) == 0) in uart_tty_param()
299 UART_IOCTL(sc, UART_IOCTL_IFLOW, (t->c_cflag & CRTS_IFLOW)); in uart_tty_param()
300 /* Set output flow control state. */ in uart_tty_param()
301 if (sc->sc_hwoflow) in uart_tty_param()
302 UART_IOCTL(sc, UART_IOCTL_OFLOW, (t->c_cflag & CCTS_OFLOW)); in uart_tty_param()
315 return (sc->sc_hwsig); in uart_tty_modem()
325 if (sc->sc_leaving) in uart_tty_intr()
328 pend = atomic_readandclear_32(&sc->sc_ttypend); in uart_tty_intr()
332 tp = sc->sc_u.u_tty.tp; in uart_tty_intr()
336 while (!uart_rx_empty(sc) && !sc->sc_isquelch) { in uart_tty_intr()
346 sc->sc_isquelch = 1; in uart_tty_intr()
347 if ((tp->t_termios.c_cflag & CRTS_IFLOW) && in uart_tty_intr()
348 !sc->sc_hwiflow) in uart_tty_intr()
377 * XXX: uart(4) could reuse the device unit number before it is in uart_tty_free()
390 if (sc == NULL || sc->sc_leaving) in uart_tty_busy()
396 * which case we will incorrectly but non-fatally report a busy Tx in uart_tty_busy()
401 if (sc->sc_txbusy) in uart_tty_busy()
425 sc->sc_u.u_tty.tp = tp = tty_alloc(&uart_tty_class, sc); in uart_tty_attach()
427 unit = device_get_unit(sc->sc_dev); in uart_tty_attach()
429 if (sc->sc_sysdev != NULL && sc->sc_sysdev->type == UART_DEV_CONSOLE) { in uart_tty_attach()
430 sprintf(((struct consdev *)sc->sc_sysdev->cookie)->cn_name, in uart_tty_attach()
432 tty_init_console(tp, sc->sc_sysdev->baudrate); in uart_tty_attach()
436 INTR_TYPE_TTY, &sc->sc_softih); in uart_tty_attach()
448 tp = sc->sc_u.u_tty.tp; in uart_tty_detach()
451 swi_remove(sc->sc_softih); in uart_tty_detach()
461 if (sc->sc_u.u_tty.tp != NULL) in uart_tty_getlock()
462 return (tty_getlock(sc->sc_u.u_tty.tp)); in uart_tty_getlock()