Lines Matching refs:ch
138 static void sbjcncn_grabdword(struct sbjcn_channel *ch);
139 static char sbjcncn_nextbyte(struct sbjcn_channel *ch);
143 static void sbjcn_enable_debugport(struct sbjcn_channel *ch);
145 void sbjcn_config(struct sbjcn_channel *ch);
146 void sbjcn_shutdown(struct sbjcn_channel *ch);
197 integrate void sbjcn_recv(struct sbjcn_channel *ch);
276 struct sbjcn_channel *ch = &sc->sc_channels[chan];
280 ch->ch_sc = sc;
281 ch->ch_num = chan;
284 ch->ch_base = (void *)MIPS_PHYS_TO_KSEG1(chan_addr);
285 ch->ch_input_reg =
287 ch->ch_output_reg =
289 ch->ch_control_reg =
291 ch->ch_waiting_input = 0;
293 ch->ch_i_dcd = ch->ch_i_dcd_pin = 0 /* XXXCGD */;
294 ch->ch_i_cts = ch->ch_i_cts_pin = 0 /* XXXCGD */;
295 ch->ch_i_dsr = ch->ch_i_dsr_pin = 0 /* XXXCGD */;
296 ch->ch_i_ri = ch->ch_i_ri_pin = 0 /* XXXCGD */;
297 ch->ch_i_mask =
298 ch->ch_i_dcd | ch->ch_i_cts | ch->ch_i_dsr | ch->ch_i_ri;
299 ch->ch_o_dtr = ch->ch_o_dtr_pin = 0 /* XXXCGD */;
300 ch->ch_o_rts = ch->ch_o_rts_pin = 0 /* XXXCGD */;
301 ch->ch_o_mask = ch->ch_o_dtr | ch->ch_o_rts;
303 callout_init(&ch->ch_diag_callout, 0);
304 callout_init(&ch->ch_callout, 0);
307 ch->ch_imr = 0;
315 SET(ch->ch_hwflags, SBJCN_HW_CONSOLE);
316 SET(ch->ch_swflags, TIOCFLAG_SOFTCAR);
324 ch->ch_tty = tp;
325 ch->ch_rbuf = kmem_alloc(sbjcn_rbuf_size << 1, KM_SLEEP);
326 ch->ch_ebuf = ch->ch_rbuf + (sbjcn_rbuf_size << 1);
330 if (ISSET(ch->ch_hwflags, SBJCN_HW_CONSOLE)) {
352 SET(ch->ch_hwflags, SBJCN_HW_KGDB);
358 sbjcn_config(ch);
360 callout_reset(&ch->ch_callout, hz/10, sbjcn_callout, ch);
362 SET(ch->ch_hwflags, SBJCN_HW_DEV_OK);
397 sbjcn_status(struct sbjcn_channel *ch, char *str)
399 struct sbjcn_softc *sc = ch->ch_sc;
400 struct tty *tp = ch->ch_tty;
404 ch->ch_num, str,
406 ISSET(ch->ch_iports, ch->ch_i_dcd) ? "+" : "-",
408 ISSET(ch->ch_oports, ch->ch_o_dtr) ? "+" : "-",
409 ch->ch_tx_stopped ? "+" : "-");
413 ch->ch_num, str,
415 ISSET(ch->ch_iports, ch->ch_i_cts) ? "+" : "-",
417 ISSET(ch->ch_oports, ch->ch_o_rts) ? "+" : "-",
418 ch->ch_rx_flags);
424 sbjcn_enable_debugport(struct sbjcn_channel *ch)
431 ch->ch_imr = 0x04;
432 SET(ch->ch_oports, ch->ch_o_dtr | ch->ch_o_rts);
439 sbjcn_config(struct sbjcn_channel *ch)
443 ch->ch_imr = 0x00;
446 if (ISSET(ch->ch_hwflags, SBJCN_HW_CONSOLE))
447 sbjcn_enable_debugport(ch);
455 if (ISSET(ch->ch_hwflags, SBJCN_HW_KGDB))
456 sbjcn_enable_debugport(ch);
461 sbjcn_shutdown(struct sbjcn_channel *ch)
463 struct tty *tp = ch->ch_tty;
469 SET(ch->ch_rx_flags, RX_IBUF_BLOCKED);
470 sbjcn_dohwiflow(ch);
473 sbjcn_break(ch, 0);
480 sbjcn_modem(ch, 0);
481 (void) tsleep(ch, TTIPRI, ttclos, hz);
486 if (ISSET(ch->ch_hwflags, SBJCN_HW_CONSOLE))
487 ch->ch_imr = 0x04; /* interrupt on break */
490 ch->ch_imr = 0;
500 struct sbjcn_channel *ch;
509 ch = &sc->sc_channels[chan];
510 if (!ISSET(ch->ch_hwflags, SBJCN_HW_DEV_OK) || ch->ch_rbuf == NULL)
517 if (ISSET(ch->ch_hwflags, SBJCN_HW_KGDB))
521 tp = ch->ch_tty;
539 ch->ch_imr = 0xe;
542 ch->ch_iports = 0;
543 ch->ch_iports_delta = 0;
551 if (ISSET(ch
558 if (ISSET(ch->ch_swflags, TIOCFLAG_CLOCAL))
560 if (ISSET(ch->ch_swflags, TIOCFLAG_CRTSCTS))
562 if (ISSET(ch->ch_swflags, TIOCFLAG_MDMBUF))
582 sbjcn_modem(ch, 1);
585 ch->ch_rbput = ch->ch_rbget = ch->ch_rbuf;
586 ch->ch_rbavail = sbjcn_rbuf_size;
587 sbjcn_iflush(ch);
588 CLR(ch->ch_rx_flags, RX_ANY_BLOCK);
589 sbjcn_dohwiflow(ch);
593 sbjcn_status(ch, "sbjcnopen ");
617 sbjcn_shutdown(ch);
627 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(dev)];
628 struct tty *tp = ch->ch_tty;
643 sbjcn_shutdown(ch);
653 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(dev)];
654 struct tty *tp = ch->ch_tty;
663 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(dev)];
664 struct tty *tp = ch->ch_tty;
673 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(dev)];
674 struct tty *tp = ch->ch_tty;
683 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(dev)];
684 struct tty *tp = ch->ch_tty;
702 sbjcn_break(ch, 1);
706 sbjcn_break(ch, 0);
710 sbjcn_modem(ch, 1);
714 sbjcn_modem(ch, 0);
718 *(int *)data = ch->ch_swflags;
726 ch->ch_swflags = *(int *)data;
732 tiocm_to_sbjcn(ch, cmd, *(int *)data);
736 *(int *)data = sbjcn_to_tiocm(ch);
748 sbjcn_status(ch, "sbjcn_ioctl ");
755 sbjcn_schedrx(struct sbjcn_channel *ch)
758 ch->ch_rx_ready = 1;
764 sbjcn_break(struct sbjcn_channel *ch, int onoff)
770 sbjcn_modem(struct sbjcn_channel *ch, int onoff)
773 if (ch->ch_o_dtr == 0)
777 SET(ch->ch_oports, ch->ch_o_dtr);
779 CLR(ch->ch_oports, ch->ch_o_dtr);
781 if (!ch->ch_heldchange) {
782 if (ch->ch_tx_busy) {
783 ch->ch_heldtbc = ch->ch_tbc;
784 ch->ch_tbc = 0;
785 ch->ch_heldchange = 1;
787 sbjcn_loadchannelregs(ch);
792 tiocm_to_sbjcn(struct sbjcn_channel *ch, int how, int ttybits)
798 SET(bits, ch->ch_o_dtr);
800 SET(bits, ch->ch_o_rts);
804 CLR(ch->ch_oports, bits);
808 SET(ch->ch_oports, bits);
812 ch->ch_oports = bits;
816 if (!ch->ch_heldchange) {
817 if (ch->ch_tx_busy) {
818 ch->ch_heldtbc = ch->ch_tbc;
819 ch->ch_tbc = 0;
820 ch->ch_heldchange = 1;
822 sbjcn_loadchannelregs(ch);
827 sbjcn_to_tiocm(struct sbjcn_channel *ch)
832 hwbits = ch->ch_oports;
833 if (ISSET(hwbits, ch->ch_o_dtr))
835 if (ISSET(hwbits, ch->ch_o_rts))
838 hwbits = ch->ch_iports;
839 if (ISSET(hwbits, ch->ch_i_dcd))
841 if (ISSET(hwbits, ch->ch_i_cts))
843 if (ISSET(hwbits, ch->ch_i_dsr))
845 if (ISSET(hwbits, ch->ch_i_ri))
848 if (ch->ch_imr != 0)
899 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(tp->t_dev)];
919 if (ISSET(ch->ch_swflags, TIOCFLAG_SOFTCAR) ||
920 ISSET(ch->ch_hwflags, SBJCN_HW_CONSOLE)) {
939 ch->ch_mode1 = mode1;
940 ch->ch_mode2 = mode2;
947 ch->ch_i_dcd = 0;
949 ch->ch_i_dcd = ch->ch_i_dcd_pin;
955 ch->ch_o_dtr = ch->ch_o_dtr_pin;
956 ch->ch_o_rts = ch->ch_o_rts_pin;
957 ch->ch_i_cts = ch->ch_i_cts_pin;
964 ch->ch_o_dtr = 0;
965 ch->ch_o_rts = ch->ch_o_dtr_pin;
966 ch->ch_i_cts = ch->ch_i_dcd_pin;
973 ch->ch_o_dtr = ch->ch_o_dtr_pin | ch->ch_o_rts_pin;
974 ch->ch_o_rts = 0;
975 ch->ch_i_cts = 0;
976 if (ISSET(ch->ch_oports, ch->ch_o_dtr_pin))
977 SET(ch->ch_oports, ch->ch_o_rts_pin);
979 CLR(ch->ch_oports, ch->ch_o_rts_pin);
983 ch->ch_brc = brc;
992 if (!ch->ch_heldchange) {
993 if (ch->ch_tx_busy) {
994 ch->ch_heldtbc = ch->ch_tbc;
995 ch->ch_tbc = 0;
996 ch->ch_heldchange = 1;
998 sbjcn_loadchannelregs(ch);
1003 ch->ch_r_hiwat = 0;
1004 ch->ch_r_lowat = 0;
1005 if (ISSET(ch->ch_rx_flags, RX_TTY_OVERFLOWED)) {
1006 CLR(ch->ch_rx_flags, RX_TTY_OVERFLOWED);
1007 sbjcn_schedrx(ch);
1009 if (ISSET(ch->ch_rx_flags, RX_TTY_BLOCKED|RX_IBUF_BLOCKED)) {
1010 CLR(ch->ch_rx_flags, RX_TTY_BLOCKED|RX_IBUF_BLOCKED);
1011 sbjcn_dohwiflow(ch);
1014 ch->ch_r_hiwat = sbjcn_rbuf_hiwat;
1015 ch->ch_r_lowat = sbjcn_rbuf_lowat;
1026 ISSET(ch->ch_iports, ch->ch_i_dcd));
1030 sbjcn_status(ch, "sbjcnparam ");
1034 if (ch->ch_tx_stopped) {
1035 ch->ch_tx_stopped = 0;
1044 sbjcn_iflush(struct sbjcn_channel *ch)
1051 while (((reg = READ_REG(ch->ch_input_reg)) != 0) && --timo)
1056 aprint_error_dev(ch->ch_sc->sc_dev,
1062 sbjcn_loadchannelregs(struct sbjcn_channel *ch)
1070 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(tp->t_dev)];
1073 if (ch->ch_o_rts == 0)
1078 if (!ISSET(ch->ch_rx_flags, RX_TTY_BLOCKED)) {
1079 SET(ch->ch_rx_flags, RX_TTY_BLOCKED);
1080 sbjcn_dohwiflow(ch);
1083 if (ISSET(ch->ch_rx_flags, RX_TTY_OVERFLOWED)) {
1084 CLR(ch->ch_rx_flags, RX_TTY_OVERFLOWED);
1085 sbjcn_schedrx(ch);
1087 if (ISSET(ch->ch_rx_flags, RX_TTY_BLOCKED)) {
1088 CLR(ch->ch_rx_flags, RX_TTY_BLOCKED);
1089 sbjcn_dohwiflow(ch);
1100 sbjcn_dohwiflow(struct sbjcn_channel *ch)
1103 if (ch->ch_o_rts == 0)
1106 if (ISSET(ch->ch_rx_flags, RX_ANY_BLOCK)) {
1107 CLR(ch->ch_oports, ch->ch_o_rts);
1108 CLR(ch->ch_oports_active, ch->ch_o_rts);
1110 SET(ch->ch_oports, ch->ch_o_rts);
1111 SET(ch->ch_oports_active, ch->ch_o_rts);
1119 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(tp->t_dev)];
1125 if (ch->ch_tx_stopped)
1140 ch->ch_tba = tba;
1141 ch->ch_tbc = tbc;
1145 ch->ch_tx_busy = 1;
1149 while (ch->ch_tbc) {
1153 bytes = (ch->ch_tbc > 7) ? 7 : ch->ch_tbc;
1157 data |= *ch->ch_tba++;
1161 ch->ch_tbc -= bytes;
1162 WRITE_REG(ch->ch_output_reg, data);
1164 ch->ch_tx_busy = 0;
1165 ch->ch_tx_done = 1;
1179 struct sbjcn_channel *ch = &sc->sc_channels[SBJCN_CHAN(tp->t_dev)];
1185 ch->ch_tbc = 0;
1186 ch->ch_heldtbc = 0;
1196 struct sbjcn_channel *ch = arg;
1197 struct sbjcn_softc *sc = ch->ch_sc;
1202 overflows = ch->ch_overflows;
1203 ch->ch_overflows = 0;
1204 floods = ch->ch_floods;
1205 ch->ch_floods = 0;
1206 ch->ch_errors = 0;
1210 device_xname(sc->sc_dev), ch->ch_num,
1216 sbjcn_rxsoft(struct sbjcn_channel *ch, struct tty *tp)
1225 end = ch->ch_ebuf;
1226 get = ch->ch_rbget;
1227 scc = cc = sbjcn_rbuf_size - ch->ch_rbavail;
1230 ch->ch_floods++;
1231 if (ch->ch_errors++ == 0)
1232 callout_reset(&ch->ch_diag_callout, 60 * hz,
1233 sbjcn_diag, ch);
1241 ch->ch_overflows++;
1242 if (ch->ch_errors++ == 0)
1243 callout_reset(&ch->ch_diag_callout,
1244 60 * hz, sbjcn_diag, ch);
1255 if (!ISSET(ch->ch_rx_flags, RX_TTY_BLOCKED)) {
1275 SET(ch->ch_rx_flags, RX_TTY_OVERFLOWED);
1281 get = ch->ch_rbuf;
1286 ch->ch_rbget = get;
1288 cc = ch->ch_rbavail += scc - cc;
1290 if (cc >= ch->ch_r_lowat) {
1291 if (ISSET(ch->ch_rx_flags, RX_IBUF_OVERFLOWED)) {
1292 CLR(ch->ch_rx_flags, RX_IBUF_OVERFLOWED);
1293 SET(ch->ch_imr, 0x02);
1295 if (ISSET(ch->ch_rx_flags, RX_IBUF_BLOCKED)) {
1296 CLR(ch->ch_rx_flags, RX_IBUF_BLOCKED);
1297 sbjcn_dohwiflow(ch);
1305 sbjcn_txsoft(struct sbjcn_channel *ch, struct tty *tp)
1312 ndflush(&tp->t_outq, (int)(ch->ch_tba - tp->t_outq.c_cf));
1317 sbjcn_stsoft(struct sbjcn_channel *ch, struct tty *tp)
1323 iports = ch->ch_iports;
1324 delta = ch->ch_iports_delta;
1325 ch->ch_iports_delta = 0;
1328 if (ISSET(delta, ch->ch_i_dcd)) {
1333 ISSET(iports, ch->ch_i_dcd));
1336 if (ISSET(delta, ch->ch_i_cts)) {
1338 if (ISSET(iports, ch->ch_i_cts)) {
1339 ch->ch_tx_stopped = 0;
1342 ch->ch_tx_stopped = 1;
1348 sbjcn_status(ch, "sbjcn_stsoft");
1353 sbjcn_recv(struct sbjcn_channel *ch)
1358 end = ch->ch_ebuf;
1359 put = ch->ch_rbput;
1360 cc = ch->ch_rbavail;
1364 sbjcncn_grabdword(ch);
1365 if (ch->ch_waiting_input) {
1366 if (!ISSET(ch->ch_rx_flags, RX_IBUF_OVERFLOWED)) {
1368 put[0] = sbjcncn_nextbyte(ch);
1372 put = ch->ch_rbuf;
1375 if (!ch->ch_waiting_input)
1386 ch->ch_rbput = put;
1387 ch->ch_rbavail = cc;
1388 if (!ISSET(ch->ch_rx_flags, RX_TTY_OVERFLOWED))
1389 ch->ch_rx_ready = 1;
1396 if (!ISSET(ch->ch_rx_flags, RX_IBUF_BLOCKED) &&
1397 cc < ch->ch_r_hiwat) {
1398 SET(ch->ch_rx_flags, RX_IBUF_BLOCKED);
1399 sbjcn_dohwiflow(ch);
1408 SET(ch->ch_rx_flags,
1410 CLR(ch->ch_imr, 0x02);
1414 CLR(ch->ch_imr, 0x02);
1423 if (ch->ch_heldchange) {
1424 sbjcn_loadchannelregs(ch);
1425 ch->ch_heldchange = 0;
1426 ch->ch_tbc = ch->ch_heldtbc;
1427 ch->ch_heldtbc = 0;
1434 struct sbjcn_channel *ch = arg;
1435 struct tty *tp = ch->ch_tty;
1438 sbjcn_recv(ch);
1441 if (ch->ch_rx_ready) {
1442 ch->ch_rx_ready = 0;
1443 sbjcn_rxsoft(ch, tp);
1447 if (ch->ch_tx_done) {
1448 ch->ch_tx_done = 0;
1449 sbjcn_txsoft(ch, tp);
1452 callout_reset(&ch->ch_callout, hz/10, sbjcn_callout, ch);
1455 static char sbjcncn_nextbyte(struct sbjcn_channel *ch)
1459 sbjcncn_grabdword(ch);
1460 c = (ch->ch_input_buf >> 56) & 0xff;
1461 ch->ch_input_buf <<= 8;
1462 ch->ch_waiting_input--;
1466 static void sbjcncn_grabdword(struct sbjcn_channel *ch)
1470 if (ch->ch_waiting_input)
1473 inbuf = READ_REG(ch->ch_input_reg);
1474 ch->ch_waiting_input = jtag_input_len(inbuf);
1475 ch->ch_input_buf = inbuf << 8;