Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/uart/uart_tty.c
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include <sys/tty.h> | #include <sys/tty.h> | ||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#include <machine/stdarg.h> | #include <machine/stdarg.h> | ||||
#include <dev/uart/uart.h> | #include <dev/uart/uart.h> | ||||
#include <dev/uart/uart_bus.h> | #include <dev/uart/uart_bus.h> | ||||
#include <dev/uart/uart_cpu.h> | #include <dev/uart/uart_cpu.h> | ||||
#include <dev/puc/puc_bus.h> | |||||
#include "uart_if.h" | #include "uart_if.h" | ||||
static cn_probe_t uart_cnprobe; | static cn_probe_t uart_cnprobe; | ||||
static cn_init_t uart_cninit; | static cn_init_t uart_cninit; | ||||
static cn_init_t uart_cnresume; | static cn_init_t uart_cnresume; | ||||
static cn_term_t uart_cnterm; | static cn_term_t uart_cnterm; | ||||
static cn_getc_t uart_cngetc; | static cn_getc_t uart_cngetc; | ||||
static cn_putc_t uart_cnputc; | static cn_putc_t uart_cnputc; | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | uart_tty_ioctl(struct tty *tp, u_long cmd, caddr_t data, | ||||
switch (cmd) { | switch (cmd) { | ||||
case TIOCSBRK: | case TIOCSBRK: | ||||
UART_IOCTL(sc, UART_IOCTL_BREAK, 1); | UART_IOCTL(sc, UART_IOCTL_BREAK, 1); | ||||
return (0); | return (0); | ||||
case TIOCCBRK: | case TIOCCBRK: | ||||
UART_IOCTL(sc, UART_IOCTL_BREAK, 0); | UART_IOCTL(sc, UART_IOCTL_BREAK, 0); | ||||
return (0); | return (0); | ||||
case TIOCSFBAUD: | |||||
SERDEV_ADJUST_RCLK(sc->sc_dev, (struct baud_fraction *)data); | |||||
UART_IOCTL(sc, UART_IOCTL_SET_FBAUD, (intptr_t)data); | |||||
return (0); | |||||
case TIOCGFBAUD: | |||||
UART_IOCTL(sc, UART_IOCTL_GET_FBAUD, (intptr_t)data); | |||||
return (0); | |||||
default: | default: | ||||
return pps_ioctl(cmd, data, &sc->sc_pps); | return pps_ioctl(cmd, data, &sc->sc_pps); | ||||
imp: that's not going to fly. why is puc special? and why does that specialness have to be handled… | |||||
Done Inline ActionsYeah, the gross layer violation here is the biggest problem. As for why it's special, it's the source of the rclk value and where the chip-specific code for the OXPCIe958 lives. I think the best thing will be to add an interface to uart_if.m and have this handled in uart_bus_puc.c. I'll work on that tonight. shurd: Yeah, the gross layer violation here is the biggest problem. As for why it's special, it's the… | |||||
} | } | ||||
} | } | ||||
static int | static int | ||||
uart_tty_param(struct tty *tp, struct termios *t) | uart_tty_param(struct tty *tp, struct termios *t) | ||||
{ | { | ||||
struct uart_softc *sc; | struct uart_softc *sc; | ||||
int databits, parity, stopbits; | int databits, parity, stopbits; | ||||
struct baud_fraction bf; | |||||
sc = tty_softc(tp); | sc = tty_softc(tp); | ||||
if (sc == NULL || sc->sc_leaving) | if (sc == NULL || sc->sc_leaving) | ||||
return (ENODEV); | return (ENODEV); | ||||
if (t->c_ispeed != t->c_ospeed && t->c_ospeed != 0) | if (t->c_ispeed != t->c_ospeed && t->c_ospeed != 0) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (t->c_ospeed == 0) { | if (t->c_ospeed == 0) { | ||||
UART_SETSIG(sc, SER_DDTR | SER_DRTS); | UART_SETSIG(sc, SER_DDTR | SER_DRTS); | ||||
return (0); | return (0); | ||||
} | } | ||||
switch (t->c_cflag & CSIZE) { | switch (t->c_cflag & CSIZE) { | ||||
case CS5: databits = 5; break; | case CS5: databits = 5; break; | ||||
case CS6: databits = 6; break; | case CS6: databits = 6; break; | ||||
case CS7: databits = 7; break; | case CS7: databits = 7; break; | ||||
default: databits = 8; break; | default: databits = 8; break; | ||||
} | } | ||||
stopbits = (t->c_cflag & CSTOPB) ? 2 : 1; | stopbits = (t->c_cflag & CSTOPB) ? 2 : 1; | ||||
if (t->c_cflag & PARENB) | if (t->c_cflag & PARENB) | ||||
parity = (t->c_cflag & PARODD) ? UART_PARITY_ODD : | parity = (t->c_cflag & PARODD) ? UART_PARITY_ODD : | ||||
UART_PARITY_EVEN; | UART_PARITY_EVEN; | ||||
else | else | ||||
parity = UART_PARITY_NONE; | parity = UART_PARITY_NONE; | ||||
bf.bf_numerator = t->c_ospeed; | |||||
bf.bf_denominator = 1; | |||||
SERDEV_ADJUST_RCLK(sc->sc_dev, &bf); | |||||
if (UART_PARAM(sc, t->c_ospeed, databits, stopbits, parity) != 0) | if (UART_PARAM(sc, t->c_ospeed, databits, stopbits, parity) != 0) | ||||
return (EINVAL); | return (EINVAL); | ||||
UART_SETSIG(sc, SER_DDTR | SER_DTR); | UART_SETSIG(sc, SER_DDTR | SER_DTR); | ||||
/* Set input flow control state. */ | /* Set input flow control state. */ | ||||
if (!sc->sc_hwiflow) { | if (!sc->sc_hwiflow) { | ||||
if ((t->c_cflag & CRTS_IFLOW) && sc->sc_isquelch) | if ((t->c_cflag & CRTS_IFLOW) && sc->sc_isquelch) | ||||
UART_SETSIG(sc, SER_DRTS); | UART_SETSIG(sc, SER_DRTS); | ||||
else | else | ||||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |
that's not going to fly. why is puc special? and why does that specialness have to be handled here?