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