Lines Matching refs:sport
95 struct sbd_port sport[2]; member
116 static u64 __read_sbdchn(struct sbd_port *sport, int reg) in __read_sbdchn() argument
118 void __iomem *csr = sport->port.membase + reg; in __read_sbdchn()
123 static u64 __read_sbdshr(struct sbd_port *sport, int reg) in __read_sbdshr() argument
125 void __iomem *csr = sport->memctrl + reg; in __read_sbdshr()
130 static void __write_sbdchn(struct sbd_port *sport, int reg, u64 value) in __write_sbdchn() argument
132 void __iomem *csr = sport->port.membase + reg; in __write_sbdchn()
137 static void __write_sbdshr(struct sbd_port *sport, int reg, u64 value) in __write_sbdshr() argument
139 void __iomem *csr = sport->memctrl + reg; in __write_sbdshr()
148 static void __war_sbd1956(struct sbd_port *sport) in __war_sbd1956() argument
150 __read_sbdchn(sport, R_DUART_MODE_REG_1); in __war_sbd1956()
151 __read_sbdchn(sport, R_DUART_MODE_REG_2); in __war_sbd1956()
154 static unsigned char read_sbdchn(struct sbd_port *sport, int reg) in read_sbdchn() argument
158 retval = __read_sbdchn(sport, reg); in read_sbdchn()
160 __war_sbd1956(sport); in read_sbdchn()
164 static unsigned char read_sbdshr(struct sbd_port *sport, int reg) in read_sbdshr() argument
168 retval = __read_sbdshr(sport, reg); in read_sbdshr()
170 __war_sbd1956(sport); in read_sbdshr()
174 static void write_sbdchn(struct sbd_port *sport, int reg, unsigned int value) in write_sbdchn() argument
176 __write_sbdchn(sport, reg, value); in write_sbdchn()
178 __war_sbd1956(sport); in write_sbdchn()
181 static void write_sbdshr(struct sbd_port *sport, int reg, unsigned int value) in write_sbdshr() argument
183 __write_sbdshr(sport, reg, value); in write_sbdshr()
185 __war_sbd1956(sport); in write_sbdshr()
189 static int sbd_receive_ready(struct sbd_port *sport) in sbd_receive_ready() argument
191 return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_RX_RDY; in sbd_receive_ready()
194 static int sbd_receive_drain(struct sbd_port *sport) in sbd_receive_drain() argument
198 while (sbd_receive_ready(sport) && --loops) in sbd_receive_drain()
199 read_sbdchn(sport, R_DUART_RX_HOLD); in sbd_receive_drain()
203 static int __maybe_unused sbd_transmit_ready(struct sbd_port *sport) in sbd_transmit_ready() argument
205 return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_TX_RDY; in sbd_transmit_ready()
208 static int __maybe_unused sbd_transmit_drain(struct sbd_port *sport) in sbd_transmit_drain() argument
212 while (!sbd_transmit_ready(sport) && --loops) in sbd_transmit_drain()
217 static int sbd_transmit_empty(struct sbd_port *sport) in sbd_transmit_empty() argument
219 return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_TX_EMT; in sbd_transmit_empty()
222 static int sbd_line_drain(struct sbd_port *sport) in sbd_line_drain() argument
226 while (!sbd_transmit_empty(sport) && --loops) in sbd_line_drain()
234 struct sbd_port *sport = to_sport(uport); in sbd_tx_empty() local
236 return sbd_transmit_empty(sport) ? TIOCSER_TEMT : 0; in sbd_tx_empty()
241 struct sbd_port *sport = to_sport(uport); in sbd_get_mctrl() local
244 status = read_sbdshr(sport, R_DUART_IN_PORT); in sbd_get_mctrl()
255 struct sbd_port *sport = to_sport(uport); in sbd_set_mctrl() local
269 mode2 = read_sbdchn(sport, R_DUART_MODE_REG_2); in sbd_set_mctrl()
276 write_sbdshr(sport, R_DUART_CLEAR_OPR, clr); in sbd_set_mctrl()
277 write_sbdshr(sport, R_DUART_SET_OPR, set); in sbd_set_mctrl()
278 write_sbdchn(sport, R_DUART_MODE_REG_2, mode2); in sbd_set_mctrl()
283 struct sbd_port *sport = to_sport(uport); in sbd_stop_tx() local
285 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS); in sbd_stop_tx()
286 sport->tx_stopped = 1; in sbd_stop_tx()
291 struct sbd_port *sport = to_sport(uport); in sbd_start_tx() local
295 mask = read_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2)); in sbd_start_tx()
297 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), mask); in sbd_start_tx()
300 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_EN); in sbd_start_tx()
301 sport->tx_stopped = 0; in sbd_start_tx()
306 struct sbd_port *sport = to_sport(uport); in sbd_stop_rx() local
308 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), 0); in sbd_stop_rx()
313 struct sbd_port *sport = to_sport(uport); in sbd_enable_ms() local
315 write_sbdchn(sport, R_DUART_AUXCTL_X, in sbd_enable_ms()
321 struct sbd_port *sport = to_sport(uport); in sbd_break_ctl() local
324 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_START_BREAK); in sbd_break_ctl()
326 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_STOP_BREAK); in sbd_break_ctl()
330 static void sbd_receive_chars(struct sbd_port *sport) in sbd_receive_chars() argument
332 struct uart_port *uport = &sport->port; in sbd_receive_chars()
338 status = read_sbdchn(sport, R_DUART_STATUS); in sbd_receive_chars()
342 ch = read_sbdchn(sport, R_DUART_RX_HOLD); in sbd_receive_chars()
381 static void sbd_transmit_chars(struct sbd_port *sport) in sbd_transmit_chars() argument
383 struct uart_port *uport = &sport->port; in sbd_transmit_chars()
384 struct circ_buf *xmit = &sport->port.state->xmit; in sbd_transmit_chars()
389 if (sport->port.x_char) { in sbd_transmit_chars()
390 write_sbdchn(sport, R_DUART_TX_HOLD, sport->port.x_char); in sbd_transmit_chars()
391 sport->port.icount.tx++; in sbd_transmit_chars()
392 sport->port.x_char = 0; in sbd_transmit_chars()
397 stop_tx = (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)); in sbd_transmit_chars()
401 write_sbdchn(sport, R_DUART_TX_HOLD, xmit->buf[xmit->tail]); in sbd_transmit_chars()
403 sport->port.icount.tx++; in sbd_transmit_chars()
406 uart_write_wakeup(&sport->port); in sbd_transmit_chars()
412 mask = read_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2)); in sbd_transmit_chars()
414 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), mask); in sbd_transmit_chars()
418 static void sbd_status_handle(struct sbd_port *sport) in sbd_status_handle() argument
420 struct uart_port *uport = &sport->port; in sbd_status_handle()
423 delta = read_sbdshr(sport, R_DUART_INCHREG((uport->line) % 2)); in sbd_status_handle()
439 struct sbd_port *sport = dev_id; in sbd_interrupt() local
440 struct uart_port *uport = &sport->port; in sbd_interrupt()
446 intstat = read_sbdshr(sport, in sbd_interrupt()
448 intstat &= read_sbdshr(sport, in sbd_interrupt()
455 sbd_receive_chars(sport); in sbd_interrupt()
457 sbd_status_handle(sport); in sbd_interrupt()
459 sbd_transmit_chars(sport); in sbd_interrupt()
470 struct sbd_port *sport = to_sport(uport); in sbd_startup() local
474 ret = request_irq(sport->port.irq, sbd_interrupt, in sbd_startup()
475 IRQF_SHARED, "sb1250-duart", sport); in sbd_startup()
480 sbd_receive_drain(sport); in sbd_startup()
483 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_RESET_BREAK_INT); in sbd_startup()
484 read_sbdshr(sport, R_DUART_INCHREG((uport->line) % 2)); in sbd_startup()
487 mode1 = read_sbdchn(sport, R_DUART_MODE_REG_1); in sbd_startup()
489 write_sbdchn(sport, R_DUART_MODE_REG_1, mode1); in sbd_startup()
492 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS | M_DUART_RX_EN); in sbd_startup()
493 sport->tx_stopped = 1; in sbd_startup()
496 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), in sbd_startup()
504 struct sbd_port *sport = to_sport(uport); in sbd_shutdown() local
506 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS | M_DUART_RX_DIS); in sbd_shutdown()
507 sport->tx_stopped = 1; in sbd_shutdown()
508 free_irq(sport->port.irq, sport); in sbd_shutdown()
512 static void sbd_init_port(struct sbd_port *sport) in sbd_init_port() argument
514 struct uart_port *uport = &sport->port; in sbd_init_port()
516 if (sport->initialised) in sbd_init_port()
520 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_RESET_TX); in sbd_init_port()
521 write_sbdchn(sport, R_DUART_CMD, V_DUART_MISC_CMD_RESET_RX); in sbd_init_port()
522 write_sbdchn(sport, R_DUART_MODE_REG_1, V_DUART_BITS_PER_CHAR_8); in sbd_init_port()
523 write_sbdchn(sport, R_DUART_MODE_REG_2, 0); in sbd_init_port()
524 write_sbdchn(sport, R_DUART_FULL_CTL, in sbd_init_port()
526 write_sbdchn(sport, R_DUART_OPCR_X, 0); in sbd_init_port()
527 write_sbdchn(sport, R_DUART_AUXCTL_X, 0); in sbd_init_port()
528 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), 0); in sbd_init_port()
530 sport->initialised = 1; in sbd_init_port()
536 struct sbd_port *sport = to_sport(uport); in sbd_set_termios() local
615 if (sport->tx_stopped) in sbd_set_termios()
620 oldmode1 = read_sbdchn(sport, R_DUART_MODE_REG_1) & mode1mask; in sbd_set_termios()
621 oldmode2 = read_sbdchn(sport, R_DUART_MODE_REG_2) & mode2mask; in sbd_set_termios()
622 oldaux = read_sbdchn(sport, R_DUART_AUXCTL_X) & auxmask; in sbd_set_termios()
624 if (!sport->tx_stopped) in sbd_set_termios()
625 sbd_line_drain(sport); in sbd_set_termios()
626 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS | M_DUART_RX_DIS); in sbd_set_termios()
628 write_sbdchn(sport, R_DUART_MODE_REG_1, mode1 | oldmode1); in sbd_set_termios()
629 write_sbdchn(sport, R_DUART_MODE_REG_2, mode2 | oldmode2); in sbd_set_termios()
630 write_sbdchn(sport, R_DUART_CLK_SEL, brg); in sbd_set_termios()
631 write_sbdchn(sport, R_DUART_AUXCTL_X, aux | oldaux); in sbd_set_termios()
633 write_sbdchn(sport, R_DUART_CMD, command); in sbd_set_termios()
646 struct sbd_port *sport = to_sport(uport); in sbd_release_port() local
647 struct sbd_duart *duart = sport->duart; in sbd_release_port()
649 iounmap(sport->memctrl); in sbd_release_port()
650 sport->memctrl = NULL; in sbd_release_port()
662 struct sbd_port *sport = to_sport(uport); in sbd_map_port() local
663 struct sbd_duart *duart = sport->duart; in sbd_map_port()
673 if (!sport->memctrl) in sbd_map_port()
674 sport->memctrl = ioremap(duart->mapctrl, in sbd_map_port()
676 if (!sport->memctrl) { in sbd_map_port()
723 struct sbd_port *sport = to_sport(uport); in sbd_config_port() local
731 sbd_init_port(sport); in sbd_config_port()
798 struct sbd_port *sport = &sbd_duarts[chip].sport[side]; in sbd_probe_duarts() local
799 struct uart_port *uport = &sport->port; in sbd_probe_duarts()
801 sport->duart = &sbd_duarts[chip]; in sbd_probe_duarts()
825 struct sbd_port *sport = to_sport(uport); in sbd_console_putchar() local
827 sbd_transmit_drain(sport); in sbd_console_putchar()
828 write_sbdchn(sport, R_DUART_TX_HOLD, ch); in sbd_console_putchar()
836 struct sbd_port *sport = &sbd_duarts[chip].sport[side]; in sbd_console_write() local
837 struct uart_port *uport = &sport->port; in sbd_console_write()
843 mask = read_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2)); in sbd_console_write()
844 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), in sbd_console_write()
846 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_EN); in sbd_console_write()
849 uart_console_write(&sport->port, s, count, sbd_console_putchar); in sbd_console_write()
853 sbd_line_drain(sport); in sbd_console_write()
854 if (sport->tx_stopped) in sbd_console_write()
855 write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS); in sbd_console_write()
856 write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), mask); in sbd_console_write()
864 struct sbd_port *sport = &sbd_duarts[chip].sport[side]; in sbd_console_setup() local
865 struct uart_port *uport = &sport->port; in sbd_console_setup()
872 if (!sport->duart) in sbd_console_setup()
879 sbd_init_port(sport); in sbd_console_setup()
936 struct sbd_port *sport = &duart->sport[i % DUART_MAX_SIDE]; in sbd_init() local
937 struct uart_port *uport = &sport->port; in sbd_init()
939 if (sport->duart) in sbd_init()
953 struct sbd_port *sport = &duart->sport[i % DUART_MAX_SIDE]; in sbd_exit() local
954 struct uart_port *uport = &sport->port; in sbd_exit()
956 if (sport->duart) in sbd_exit()