Lines Matching refs:zport
138 static u8 read_zsreg(struct zs_port *zport, int reg) in read_zsreg() argument
140 void __iomem *control = zport->port.membase + ZS_CHAN_IO_OFFSET; in read_zsreg()
153 static void write_zsreg(struct zs_port *zport, int reg, u8 value) in write_zsreg() argument
155 void __iomem *control = zport->port.membase + ZS_CHAN_IO_OFFSET; in write_zsreg()
167 static u8 read_zsdata(struct zs_port *zport) in read_zsdata() argument
169 void __iomem *data = zport->port.membase + in read_zsdata()
178 static void write_zsdata(struct zs_port *zport, u8 value) in write_zsdata() argument
180 void __iomem *data = zport->port.membase + in write_zsdata()
192 struct zs_port *zport; in zs_dump() local
196 zport = &zs_sccs[i / ZS_NUM_CHAN].zport[i % ZS_NUM_CHAN]; in zs_dump()
198 if (!zport->scc) in zs_dump()
202 printk("W%-2d = 0x%02x\t", j, zport->regs[j]); in zs_dump()
205 printk("R%-2d = 0x%02x\t", j, read_zsreg(zport, j)); in zs_dump()
228 static int zs_receive_drain(struct zs_port *zport) in zs_receive_drain() argument
232 while ((read_zsreg(zport, R0) & Rx_CH_AV) && --loops) in zs_receive_drain()
233 read_zsdata(zport); in zs_receive_drain()
237 static int zs_transmit_drain(struct zs_port *zport, int irq) in zs_transmit_drain() argument
239 struct zs_scc *scc = zport->scc; in zs_transmit_drain()
242 while (!(read_zsreg(zport, R0) & Tx_BUF_EMP) && --loops) { in zs_transmit_drain()
250 static int zs_line_drain(struct zs_port *zport, int irq) in zs_line_drain() argument
252 struct zs_scc *scc = zport->scc; in zs_line_drain()
255 while (!(read_zsreg(zport, R1) & ALL_SNT) && --loops) { in zs_line_drain()
264 static void load_zsregs(struct zs_port *zport, u8 *regs, int irq) in load_zsregs() argument
267 zs_line_drain(zport, irq); in load_zsregs()
269 write_zsreg(zport, R3, regs[3] & ~RxENABLE); in load_zsregs()
270 write_zsreg(zport, R5, regs[5] & ~TxENAB); in load_zsregs()
271 write_zsreg(zport, R4, regs[4]); in load_zsregs()
272 write_zsreg(zport, R9, regs[9]); in load_zsregs()
273 write_zsreg(zport, R1, regs[1]); in load_zsregs()
274 write_zsreg(zport, R2, regs[2]); in load_zsregs()
275 write_zsreg(zport, R10, regs[10]); in load_zsregs()
276 write_zsreg(zport, R14, regs[14] & ~BRENABL); in load_zsregs()
277 write_zsreg(zport, R11, regs[11]); in load_zsregs()
278 write_zsreg(zport, R12, regs[12]); in load_zsregs()
279 write_zsreg(zport, R13, regs[13]); in load_zsregs()
280 write_zsreg(zport, R14, regs[14]); in load_zsregs()
281 write_zsreg(zport, R15, regs[15]); in load_zsregs()
283 write_zsreg(zport, R3, regs[3]); in load_zsregs()
285 write_zsreg(zport, R5, regs[5]); in load_zsregs()
306 struct zs_port *zport = to_zport(uport); in zs_tx_empty() local
307 struct zs_scc *scc = zport->scc; in zs_tx_empty()
312 status = read_zsreg(zport, R1); in zs_tx_empty()
335 static unsigned int zs_raw_get_mctrl(struct zs_port *zport) in zs_raw_get_mctrl() argument
337 struct zs_port *zport_a = &zport->scc->zport[ZS_CHAN_A]; in zs_raw_get_mctrl()
339 return zport != zport_a ? zs_raw_get_ab_mctrl(zport_a, zport) : 0; in zs_raw_get_mctrl()
342 static unsigned int zs_raw_xor_mctrl(struct zs_port *zport) in zs_raw_xor_mctrl() argument
344 struct zs_port *zport_a = &zport->scc->zport[ZS_CHAN_A]; in zs_raw_xor_mctrl()
348 if (zport == zport_a) in zs_raw_xor_mctrl()
352 mask_b = zport->regs[15]; in zs_raw_xor_mctrl()
359 mctrl = zport->mctrl; in zs_raw_xor_mctrl()
362 mctrl |= zs_raw_get_ab_mctrl(zport_a, zport) & mmask; in zs_raw_xor_mctrl()
365 delta = mctrl ^ zport->mctrl; in zs_raw_xor_mctrl()
367 zport->mctrl = mctrl; in zs_raw_xor_mctrl()
374 struct zs_port *zport = to_zport(uport); in zs_get_mctrl() local
375 struct zs_scc *scc = zport->scc; in zs_get_mctrl()
379 mctrl = zs_raw_get_mctrl(zport); in zs_get_mctrl()
387 struct zs_port *zport = to_zport(uport); in zs_set_mctrl() local
388 struct zs_scc *scc = zport->scc; in zs_set_mctrl()
389 struct zs_port *zport_a = &scc->zport[ZS_CHAN_A]; in zs_set_mctrl()
393 if (zport != zport_a) { in zs_set_mctrl()
406 oldloop = zport->regs[14]; in zs_set_mctrl()
413 zport->regs[14] = newloop; in zs_set_mctrl()
414 write_zsreg(zport, R14, zport->regs[14]); in zs_set_mctrl()
419 static void zs_raw_stop_tx(struct zs_port *zport) in zs_raw_stop_tx() argument
421 write_zsreg(zport, R0, RES_Tx_P); in zs_raw_stop_tx()
422 zport->tx_stopped = 1; in zs_raw_stop_tx()
427 struct zs_port *zport = to_zport(uport); in zs_stop_tx() local
428 struct zs_scc *scc = zport->scc; in zs_stop_tx()
431 zs_raw_stop_tx(zport); in zs_stop_tx()
439 struct zs_port *zport = to_zport(uport); in zs_start_tx() local
440 struct zs_scc *scc = zport->scc; in zs_start_tx()
443 if (zport->tx_stopped) { in zs_start_tx()
444 zs_transmit_drain(zport, 0); in zs_start_tx()
445 zport->tx_stopped = 0; in zs_start_tx()
446 zs_raw_transmit_chars(zport); in zs_start_tx()
453 struct zs_port *zport = to_zport(uport); in zs_stop_rx() local
454 struct zs_scc *scc = zport->scc; in zs_stop_rx()
455 struct zs_port *zport_a = &scc->zport[ZS_CHAN_A]; in zs_stop_rx()
458 zport->regs[15] &= ~BRKIE; in zs_stop_rx()
459 zport->regs[1] &= ~(RxINT_MASK | TxINT_ENAB); in zs_stop_rx()
460 zport->regs[1] |= RxINT_DISAB; in zs_stop_rx()
462 if (zport != zport_a) { in zs_stop_rx()
472 zport->regs[15] &= ~(DCDIE | CTSIE); in zs_stop_rx()
473 zport->regs[1] &= ~EXT_INT_ENAB; in zs_stop_rx()
476 if (!(zport->regs[15] & (DCDIE | SYNCIE))) in zs_stop_rx()
477 zport->regs[1] &= ~EXT_INT_ENAB; in zs_stop_rx()
480 write_zsreg(zport, R15, zport->regs[15]); in zs_stop_rx()
481 write_zsreg(zport, R1, zport->regs[1]); in zs_stop_rx()
487 struct zs_port *zport = to_zport(uport); in zs_enable_ms() local
488 struct zs_scc *scc = zport->scc; in zs_enable_ms()
489 struct zs_port *zport_a = &scc->zport[ZS_CHAN_A]; in zs_enable_ms()
491 if (zport == zport_a) in zs_enable_ms()
505 zport->regs[15] |= DCDIE | CTSIE; in zs_enable_ms()
507 zs_raw_xor_mctrl(zport); in zs_enable_ms()
511 write_zsreg(zport, R15, zport->regs[15]); in zs_enable_ms()
517 struct zs_port *zport = to_zport(uport); in zs_break_ctl() local
518 struct zs_scc *scc = zport->scc; in zs_break_ctl()
523 zport->regs[5] |= SND_BRK; in zs_break_ctl()
525 zport->regs[5] &= ~SND_BRK; in zs_break_ctl()
526 write_zsreg(zport, R5, zport->regs[5]); in zs_break_ctl()
537 static void zs_receive_chars(struct zs_port *zport) in zs_receive_chars() argument
539 struct uart_port *uport = &zport->port; in zs_receive_chars()
540 struct zs_scc *scc = zport->scc; in zs_receive_chars()
548 avail = read_zsreg(zport, R0) & Rx_CH_AV; in zs_receive_chars()
554 status = read_zsreg(zport, R1) & (Rx_OVR | FRM_ERR | PAR_ERR); in zs_receive_chars()
555 ch = read_zsdata(zport); in zs_receive_chars()
565 status |= zport->tty_break; in zs_receive_chars()
568 zport->tty_break = 0; in zs_receive_chars()
573 write_zsreg(zport, R0, ERR_RES); in zs_receive_chars()
607 static void zs_raw_transmit_chars(struct zs_port *zport) in zs_raw_transmit_chars() argument
609 struct circ_buf *xmit = &zport->port.state->xmit; in zs_raw_transmit_chars()
612 if (zport->port.x_char) { in zs_raw_transmit_chars()
613 write_zsdata(zport, zport->port.x_char); in zs_raw_transmit_chars()
614 zport->port.icount.tx++; in zs_raw_transmit_chars()
615 zport->port.x_char = 0; in zs_raw_transmit_chars()
620 if (uart_circ_empty(xmit) || uart_tx_stopped(&zport->port)) { in zs_raw_transmit_chars()
621 zs_raw_stop_tx(zport); in zs_raw_transmit_chars()
626 write_zsdata(zport, xmit->buf[xmit->tail]); in zs_raw_transmit_chars()
627 uart_xmit_advance(&zport->port, 1); in zs_raw_transmit_chars()
630 uart_write_wakeup(&zport->port); in zs_raw_transmit_chars()
634 zs_raw_stop_tx(zport); in zs_raw_transmit_chars()
637 static void zs_transmit_chars(struct zs_port *zport) in zs_transmit_chars() argument
639 struct zs_scc *scc = zport->scc; in zs_transmit_chars()
642 zs_raw_transmit_chars(zport); in zs_transmit_chars()
646 static void zs_status_handle(struct zs_port *zport, struct zs_port *zport_a) in zs_status_handle() argument
648 struct uart_port *uport = &zport->port; in zs_status_handle()
649 struct zs_scc *scc = zport->scc; in zs_status_handle()
656 status = read_zsreg(zport, R0); in zs_status_handle()
658 if (zport->regs[15] & BRKIE) { in zs_status_handle()
660 if (brk && !zport->brk) { in zs_status_handle()
663 zport->tty_break = Rx_SYS; in zs_status_handle()
665 zport->tty_break = Rx_BRK; in zs_status_handle()
668 zport->brk = brk; in zs_status_handle()
671 if (zport != zport_a) { in zs_status_handle()
672 delta = zs_raw_xor_mctrl(zport); in zs_status_handle()
677 zport->mctrl & TIOCM_CTS); in zs_status_handle()
680 zport->mctrl & TIOCM_CAR); in zs_status_handle()
693 write_zsreg(zport, R0, RES_EXT_INT); in zs_status_handle()
704 struct zs_port *zport_a = &scc->zport[ZS_CHAN_A]; in zs_interrupt()
705 struct zs_port *zport_b = &scc->zport[ZS_CHAN_B]; in zs_interrupt()
754 struct zs_port *zport = to_zport(uport); in zs_startup() local
755 struct zs_scc *scc = zport->scc; in zs_startup()
762 ret = request_irq(zport->port.irq, zs_interrupt, in zs_startup()
767 zport->port.irq); in zs_startup()
775 zs_receive_drain(zport); in zs_startup()
778 write_zsreg(zport, R0, ERR_RES); in zs_startup()
779 write_zsreg(zport, R0, RES_Tx_P); in zs_startup()
781 if (!(zport->regs[1] & EXT_INT_ENAB)) in zs_startup()
782 write_zsreg(zport, R0, RES_EXT_INT); in zs_startup()
785 zport->regs[1] &= ~RxINT_MASK; in zs_startup()
786 zport->regs[1] |= RxINT_ALL | TxINT_ENAB | EXT_INT_ENAB; in zs_startup()
787 zport->regs[3] |= RxENABLE; in zs_startup()
788 zport->regs[15] |= BRKIE; in zs_startup()
789 write_zsreg(zport, R1, zport->regs[1]); in zs_startup()
790 write_zsreg(zport, R3, zport->regs[3]); in zs_startup()
791 write_zsreg(zport, R5, zport->regs[5]); in zs_startup()
792 write_zsreg(zport, R15, zport->regs[15]); in zs_startup()
795 zport->mctrl = zs_raw_get_mctrl(zport); in zs_startup()
796 zport->brk = read_zsreg(zport, R0) & BRK_ABRT; in zs_startup()
798 zport->tx_stopped = 1; in zs_startup()
807 struct zs_port *zport = to_zport(uport); in zs_shutdown() local
808 struct zs_scc *scc = zport->scc; in zs_shutdown()
814 zport->regs[3] &= ~RxENABLE; in zs_shutdown()
815 write_zsreg(zport, R5, zport->regs[5]); in zs_shutdown()
816 write_zsreg(zport, R3, zport->regs[3]); in zs_shutdown()
822 free_irq(zport->port.irq, scc); in zs_shutdown()
826 static void zs_reset(struct zs_port *zport) in zs_reset() argument
828 struct zs_scc *scc = zport->scc; in zs_reset()
836 read_zsreg(zport, R0); in zs_reset()
838 zs_line_drain(zport, irq); in zs_reset()
839 write_zsreg(zport, R9, FHWRES); in zs_reset()
841 write_zsreg(zport, R9, 0); in zs_reset()
844 load_zsregs(zport, zport->regs, irq); in zs_reset()
851 struct zs_port *zport = to_zport(uport); in zs_set_termios() local
852 struct zs_scc *scc = zport->scc; in zs_set_termios()
853 struct zs_port *zport_a = &scc->zport[ZS_CHAN_A]; in zs_set_termios()
862 zport->regs[3] &= ~RxNBITS_MASK; in zs_set_termios()
863 zport->regs[5] &= ~TxNBITS_MASK; in zs_set_termios()
866 zport->regs[3] |= Rx5; in zs_set_termios()
867 zport->regs[5] |= Tx5; in zs_set_termios()
870 zport->regs[3] |= Rx6; in zs_set_termios()
871 zport->regs[5] |= Tx6; in zs_set_termios()
874 zport->regs[3] |= Rx7; in zs_set_termios()
875 zport->regs[5] |= Tx7; in zs_set_termios()
879 zport->regs[3] |= Rx8; in zs_set_termios()
880 zport->regs[5] |= Tx8; in zs_set_termios()
885 zport->regs[4] &= ~(XCLK_MASK | SB_MASK | PAR_ENA | PAR_EVEN); in zs_set_termios()
887 zport->regs[4] |= SB2; in zs_set_termios()
889 zport->regs[4] |= SB1; in zs_set_termios()
891 zport->regs[4] |= PAR_ENA; in zs_set_termios()
893 zport->regs[4] |= PAR_EVEN; in zs_set_termios()
894 switch (zport->clk_mode) { in zs_set_termios()
896 zport->regs[4] |= X64CLK; in zs_set_termios()
899 zport->regs[4] |= X32CLK; in zs_set_termios()
902 zport->regs[4] |= X16CLK; in zs_set_termios()
905 zport->regs[4] |= X1CLK; in zs_set_termios()
912 uport->uartclk / zport->clk_mode / 4); in zs_set_termios()
914 brg = ZS_BPS_TO_BRG(baud, uport->uartclk / zport->clk_mode); in zs_set_termios()
915 zport->regs[12] = brg & 0xff; in zs_set_termios()
916 zport->regs[13] = (brg >> 8) & 0xff; in zs_set_termios()
936 zport->regs[3] |= RxENABLE; in zs_set_termios()
938 zport->regs[3] &= ~RxENABLE; in zs_set_termios()
940 if (zport != zport_a) { in zs_set_termios()
942 zport->regs[15] |= DCDIE; in zs_set_termios()
944 zport->regs[15] &= ~DCDIE; in zs_set_termios()
946 zport->regs[15] |= CTSIE; in zs_set_termios()
948 zport->regs[15] &= ~CTSIE; in zs_set_termios()
949 zs_raw_xor_mctrl(zport); in zs_set_termios()
953 load_zsregs(zport, zport->regs, irq); in zs_set_termios()
966 struct zs_port *zport = to_zport(uport); in zs_pm() local
969 zport->regs[5] |= TxENAB; in zs_pm()
971 zport->regs[5] &= ~TxENAB; in zs_pm()
972 write_zsreg(zport, R5, zport->regs[5]); in zs_pm()
1018 struct zs_port *zport = to_zport(uport); in zs_config_port() local
1026 zs_reset(zport); in zs_config_port()
1032 struct zs_port *zport = to_zport(uport); in zs_verify_port() local
1039 if (ser->baud_base != uport->uartclk / zport->clk_mode / 4) in zs_verify_port()
1099 struct zs_port *zport = &zs_sccs[chip].zport[side]; in zs_probe_sccs() local
1100 struct uart_port *uport = &zport->port; in zs_probe_sccs()
1102 zport->scc = &zs_sccs[chip]; in zs_probe_sccs()
1103 zport->clk_mode = 16; in zs_probe_sccs()
1118 zport->regs[i] = zs_init_regs[i]; in zs_probe_sccs()
1129 struct zs_port *zport = to_zport(uport); in zs_console_putchar() local
1130 struct zs_scc *scc = zport->scc; in zs_console_putchar()
1136 if (zs_transmit_drain(zport, irq)) in zs_console_putchar()
1137 write_zsdata(zport, ch); in zs_console_putchar()
1149 struct zs_port *zport = &zs_sccs[chip].zport[side]; in zs_console_write() local
1150 struct zs_scc *scc = zport->scc; in zs_console_write()
1157 txint = zport->regs[1]; in zs_console_write()
1158 txenb = zport->regs[5]; in zs_console_write()
1160 zport->regs[1] = txint & ~TxINT_ENAB; in zs_console_write()
1161 write_zsreg(zport, R1, zport->regs[1]); in zs_console_write()
1164 zport->regs[5] = txenb | TxENAB; in zs_console_write()
1165 write_zsreg(zport, R5, zport->regs[5]); in zs_console_write()
1169 uart_console_write(&zport->port, s, count, zs_console_putchar); in zs_console_write()
1174 zs_line_drain(zport, irq); in zs_console_write()
1176 zport->regs[5] &= ~TxENAB; in zs_console_write()
1177 write_zsreg(zport, R5, zport->regs[5]); in zs_console_write()
1180 zport->regs[1] |= TxINT_ENAB; in zs_console_write()
1181 write_zsreg(zport, R1, zport->regs[1]); in zs_console_write()
1184 if (!zport->tx_stopped) in zs_console_write()
1185 zs_raw_transmit_chars(zport); in zs_console_write()
1199 struct zs_port *zport = &zs_sccs[chip].zport[side]; in zs_console_setup() local
1200 struct uart_port *uport = &zport->port; in zs_console_setup()
1211 zs_reset(zport); in zs_console_setup()
1280 struct zs_port *zport = &scc->zport[i % ZS_NUM_CHAN]; in zs_init() local
1281 struct uart_port *uport = &zport->port; in zs_init()
1283 if (zport->scc) in zs_init()
1296 struct zs_port *zport = &scc->zport[i % ZS_NUM_CHAN]; in zs_exit() local
1297 struct uart_port *uport = &zport->port; in zs_exit()
1299 if (zport->scc) in zs_exit()