Lines Matching refs:sport
104 struct sbd_port sport[2]; member
125 static u64 __read_sbdchn(struct sbd_port *sport, int reg) in __read_sbdchn() argument
127 void __iomem *csr = sport->port.membase + reg; in __read_sbdchn()
132 static u64 __read_sbdshr(struct sbd_port *sport, int reg) in __read_sbdshr() argument
134 void __iomem *csr = sport->memctrl + reg; in __read_sbdshr()
139 static void __write_sbdchn(struct sbd_port *sport, int reg, u64 value) in __write_sbdchn() argument
141 void __iomem *csr = sport->port.membase + reg; in __write_sbdchn()
146 static void __write_sbdshr(struct sbd_port *sport, int reg, u64 value) in __write_sbdshr() argument
148 void __iomem *csr = sport->memctrl + reg; in __write_sbdshr()
157 static void __war_sbd1956(struct sbd_port *sport) in __war_sbd1956() argument
159 __read_sbdchn(sport, R_DUART_MODE_REG_1); in __war_sbd1956()
160 __read_sbdchn(sport, R_DUART_MODE_REG_2); in __war_sbd1956()
163 static unsigned char read_sbdchn(struct sbd_port *sport, int reg) in read_sbdchn() argument
167 retval = __read_sbdchn(sport, reg); in read_sbdchn()
169 __war_sbd1956(sport); in read_sbdchn()
173 static unsigned char read_sbdshr(struct sbd_port *sport, int reg) in read_sbdshr() argument
177 retval = __read_sbdshr(sport, reg); in read_sbdshr()
179 __war_sbd1956(sport); in read_sbdshr()
183 static void write_sbdchn(struct sbd_port *sport, int reg, unsigned int value) in write_sbdchn() argument
185 __write_sbdchn(sport, reg, value); in write_sbdchn()
187 __war_sbd1956(sport); in write_sbdchn()
190 static void write_sbdshr(struct sbd_port *sport, int reg, unsigned int value) in write_sbdshr() argument
192 __write_sbdshr(sport, reg, value); in write_sbdshr()
194 __war_sbd1956(sport); in write_sbdshr()
198 static int sbd_receive_ready(struct sbd_port *sport) in sbd_receive_ready() argument
200 return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_RX_RDY; in sbd_receive_ready()
203 static int sbd_receive_drain(struct sbd_port *sport) in sbd_receive_drain() argument
207 while (sbd_receive_ready(sport) && --loops) in sbd_receive_drain()
208 read_sbdchn(sport, R_DUART_RX_HOLD); in sbd_receive_drain()
212 static int __maybe_unused sbd_transmit_ready(struct sbd_port *sport) in sbd_transmit_ready() argument
214 return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_TX_RDY; in sbd_transmit_ready()
217 static int __maybe_unused sbd_transmit_drain(struct sbd_port *sport) in sbd_transmit_drain() argument
221 while (!sbd_transmit_ready(sport) && --loops) in sbd_transmit_drain()
226 static int sbd_transmit_empty(struct sbd_port *sport) in sbd_transmit_empty() argument
228 return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_TX_EMT; in sbd_transmit_empty()
231 static int sbd_line_drain(struct sbd_port *sport) in sbd_line_drain() argument
235 while (!sbd_transmit_empty(sport) && --loops) in sbd_line_drain()
243 struct sbd_port *sport = to_sport(uport); in sbd_tx_empty() local
245 return sbd_transmit_empty(sport) ? TIOCSER_TEMT : 0; in sbd_tx_empty()
250 struct sbd_port *sport = to_sport(uport); in sbd_get_mctrl() local
253 status = read_sbdshr(sport, R_DUART_IN_PORT); in sbd_get_mctrl()
264 struct sbd_port *sport = to_sport(uport); in sbd_set_mctrl() local
278 mode2 = read_sbdchn(sport, R_DUART_MODE_REG_2); in sbd_set_mctrl()
285 write_sbdshr(sport, R_DUART_CLEAR_OPR, clr); in sbd_set_mctrl()
286 write_sbdshr(sport, R_DUART_SET_OPR, set); in sbd_set_mctrl()
287 write_sbdchn(sport, R_DUART_MODE_REG_2, mode2); in sbd_set_mctrl()
292 struct sbd_port *sport = to_sport(uport); in sbd_stop_tx() local
294 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS); in sbd_stop_tx()
295 sport->tx_stopped = 1; in sbd_stop_tx()
300 struct sbd_port *sport = to_sport(uport); in sbd_start_tx() local
304 mask = read_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2)); in sbd_start_tx()
306 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), mask); in sbd_start_tx()
309 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_EN); in sbd_start_tx()
310 sport->tx_stopped = 0; in sbd_start_tx()
315 struct sbd_port *sport = to_sport(uport); in sbd_stop_rx() local
317 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), 0); in sbd_stop_rx()
322 struct sbd_port *sport = to_sport(uport); in sbd_enable_ms() local
324 write_sbdchn(sport, R_DUART_AUXCTL_X, in sbd_enable_ms()
330 struct sbd_port *sport = to_sport(uport); in sbd_break_ctl() local
333 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_START_BREAK); in sbd_break_ctl()
335 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_STOP_BREAK); in sbd_break_ctl()
339 static void sbd_receive_chars(struct sbd_port *sport) in sbd_receive_chars() argument
341 struct uart_port *uport = &sport->port; in sbd_receive_chars()
347 status = read_sbdchn(sport, R_DUART_STATUS); in sbd_receive_chars()
351 ch = read_sbdchn(sport, R_DUART_RX_HOLD); in sbd_receive_chars()
390 static void sbd_transmit_chars(struct sbd_port *sport) in sbd_transmit_chars() argument
392 struct uart_port *uport = &sport->port; in sbd_transmit_chars()
393 struct circ_buf *xmit = &sport->port.state->xmit; in sbd_transmit_chars()
398 if (sport->port.x_char) { in sbd_transmit_chars()
399 write_sbdchn(sport, R_DUART_TX_HOLD, sport->port.x_char); in sbd_transmit_chars()
400 sport->port.icount.tx++; in sbd_transmit_chars()
401 sport->port.x_char = 0; in sbd_transmit_chars()
406 stop_tx = (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)); in sbd_transmit_chars()
410 write_sbdchn(sport, R_DUART_TX_HOLD, xmit->buf[xmit->tail]); in sbd_transmit_chars()
412 sport->port.icount.tx++; in sbd_transmit_chars()
415 uart_write_wakeup(&sport->port); in sbd_transmit_chars()
421 mask = read_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2)); in sbd_transmit_chars()
423 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), mask); in sbd_transmit_chars()
427 static void sbd_status_handle(struct sbd_port *sport) in sbd_status_handle() argument
429 struct uart_port *uport = &sport->port; in sbd_status_handle()
432 delta = read_sbdshr(sport, R_DUART_INCHREG((uport->line) % 2)); in sbd_status_handle()
448 struct sbd_port *sport = dev_id; in sbd_interrupt() local
449 struct uart_port *uport = &sport->port; in sbd_interrupt()
455 intstat = read_sbdshr(sport, in sbd_interrupt()
457 intstat &= read_sbdshr(sport, in sbd_interrupt()
464 sbd_receive_chars(sport); in sbd_interrupt()
466 sbd_status_handle(sport); in sbd_interrupt()
468 sbd_transmit_chars(sport); in sbd_interrupt()
479 struct sbd_port *sport = to_sport(uport); in sbd_startup() local
483 ret = request_irq(sport->port.irq, sbd_interrupt, in sbd_startup()
484 IRQF_SHARED, "sb1250-duart", sport); in sbd_startup()
489 sbd_receive_drain(sport); in sbd_startup()
492 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_RESET_BREAK_INT); in sbd_startup()
493 read_sbdshr(sport, R_DUART_INCHREG((uport->line) % 2)); in sbd_startup()
496 mode1 = read_sbdchn(sport, R_DUART_MODE_REG_1); in sbd_startup()
498 write_sbdchn(sport, R_DUART_MODE_REG_1, mode1); in sbd_startup()
501 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS | M_DUART_RX_EN); in sbd_startup()
502 sport->tx_stopped = 1; in sbd_startup()
505 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), in sbd_startup()
513 struct sbd_port *sport = to_sport(uport); in sbd_shutdown() local
515 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS | M_DUART_RX_DIS); in sbd_shutdown()
516 sport->tx_stopped = 1; in sbd_shutdown()
517 free_irq(sport->port.irq, sport); in sbd_shutdown()
521 static void sbd_init_port(struct sbd_port *sport) in sbd_init_port() argument
523 struct uart_port *uport = &sport->port; in sbd_init_port()
525 if (sport->initialised) in sbd_init_port()
529 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_RESET_TX); in sbd_init_port()
530 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_RESET_RX); in sbd_init_port()
531 write_sbdchn(sport, R_DUART_MODE_REG_1, V_DUART_BITS_PER_CHAR_8); in sbd_init_port()
532 write_sbdchn(sport, R_DUART_MODE_REG_2, 0); in sbd_init_port()
533 write_sbdchn(sport, R_DUART_FULL_CTL, in sbd_init_port()
535 write_sbdchn(sport, R_DUART_OPCR_X, 0); in sbd_init_port()
536 write_sbdchn(sport, R_DUART_AUXCTL_X, 0); in sbd_init_port()
537 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), 0); in sbd_init_port()
539 sport->initialised = 1; in sbd_init_port()
545 struct sbd_port *sport = to_sport(uport); in sbd_set_termios() local
624 if (sport->tx_stopped) in sbd_set_termios()
629 oldmode1 = read_sbdchn(sport, R_DUART_MODE_REG_1) & mode1mask; in sbd_set_termios()
630 oldmode2 = read_sbdchn(sport, R_DUART_MODE_REG_2) & mode2mask; in sbd_set_termios()
631 oldaux = read_sbdchn(sport, R_DUART_AUXCTL_X) & auxmask; in sbd_set_termios()
633 if (!sport->tx_stopped) in sbd_set_termios()
634 sbd_line_drain(sport); in sbd_set_termios()
635 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS | M_DUART_RX_DIS); in sbd_set_termios()
637 write_sbdchn(sport, R_DUART_MODE_REG_1, mode1 | oldmode1); in sbd_set_termios()
638 write_sbdchn(sport, R_DUART_MODE_REG_2, mode2 | oldmode2); in sbd_set_termios()
639 write_sbdchn(sport, R_DUART_CLK_SEL, brg); in sbd_set_termios()
640 write_sbdchn(sport, R_DUART_AUXCTL_X, aux | oldaux); in sbd_set_termios()
642 write_sbdchn(sport, R_DUART_CMD, command); in sbd_set_termios()
655 struct sbd_port *sport = to_sport(uport); in sbd_release_port() local
656 struct sbd_duart *duart = sport->duart; in sbd_release_port()
659 iounmap(sport->memctrl); in sbd_release_port()
660 sport->memctrl = NULL; in sbd_release_port()
673 struct sbd_port *sport = to_sport(uport); in sbd_map_port() local
674 struct sbd_duart *duart = sport->duart; in sbd_map_port()
684 if (!sport->memctrl) in sbd_map_port()
685 sport->memctrl = ioremap_nocache(duart->mapctrl, in sbd_map_port()
687 if (!sport->memctrl) { in sbd_map_port()
736 struct sbd_port *sport = to_sport(uport); in sbd_config_port() local
744 sbd_init_port(sport); in sbd_config_port()
811 struct sbd_port *sport = &sbd_duarts[chip].sport[side]; in sbd_probe_duarts() local
812 struct uart_port *uport = &sport->port; in sbd_probe_duarts()
814 sport->duart = &sbd_duarts[chip]; in sbd_probe_duarts()
837 struct sbd_port *sport = to_sport(uport); in sbd_console_putchar() local
839 sbd_transmit_drain(sport); in sbd_console_putchar()
840 write_sbdchn(sport, R_DUART_TX_HOLD, ch); in sbd_console_putchar()
848 struct sbd_port *sport = &sbd_duarts[chip].sport[side]; in sbd_console_write() local
849 struct uart_port *uport = &sport->port; in sbd_console_write()
855 mask = read_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2)); in sbd_console_write()
856 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), in sbd_console_write()
858 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_EN); in sbd_console_write()
861 uart_console_write(&sport->port, s, count, sbd_console_putchar); in sbd_console_write()
865 sbd_line_drain(sport); in sbd_console_write()
866 if (sport->tx_stopped) in sbd_console_write()
867 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS); in sbd_console_write()
868 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), mask); in sbd_console_write()
876 struct sbd_port *sport = &sbd_duarts[chip].sport[side]; in sbd_console_setup() local
877 struct uart_port *uport = &sport->port; in sbd_console_setup()
884 if (!sport->duart) in sbd_console_setup()
891 sbd_init_port(sport); in sbd_console_setup()
948 struct sbd_port *sport = &duart->sport[i % DUART_MAX_SIDE]; in sbd_init() local
949 struct uart_port *uport = &sport->port; in sbd_init()
951 if (sport->duart) in sbd_init()
965 struct sbd_port *sport = &duart->sport[i % DUART_MAX_SIDE]; in sbd_exit() local
966 struct uart_port *uport = &sport->port; in sbd_exit()
968 if (sport->duart) in sbd_exit()