Lines Matching +full:up +full:-

1 // SPDX-License-Identifier: GPL-2.0
48 /* On 32-bit sparcs we need to delay after register accesses
50 * On 64-bit sparc we only need to flush single writes to ensure
61 readb(&((__channel)->control))
105 #define ZILOG_CHANNEL_FROM_PORT(PORT) ((struct zilog_channel __iomem *)((PORT)->membase))
108 #define ZS_IS_KEYB(UP) ((UP)->flags & SUNZILOG_FLAG_CONS_KEYB) argument
109 #define ZS_IS_MOUSE(UP) ((UP)->flags & SUNZILOG_FLAG_CONS_MOUSE) argument
110 #define ZS_IS_CONS(UP) ((UP)->flags & SUNZILOG_FLAG_IS_CONS) argument
111 #define ZS_IS_KGDB(UP) ((UP)->flags & SUNZILOG_FLAG_IS_KGDB) argument
112 #define ZS_WANTS_MODEM_STATUS(UP) ((UP)->flags & SUNZILOG_FLAG_MODEM_STATUS) argument
113 #define ZS_IS_CHANNEL_A(UP) ((UP)->flags & SUNZILOG_FLAG_IS_CHANNEL_A) argument
114 #define ZS_REGS_HELD(UP) ((UP)->flags & SUNZILOG_FLAG_REGS_HELD) argument
115 #define ZS_TX_STOPPED(UP) ((UP)->flags & SUNZILOG_FLAG_TX_STOPPED) argument
116 #define ZS_TX_ACTIVE(UP) ((UP)->flags & SUNZILOG_FLAG_TX_ACTIVE) argument
121 * flip-flops which implement the settle time we do in software.
131 writeb(reg, &channel->control); in read_zsreg()
133 retval = readb(&channel->control); in read_zsreg()
142 writeb(reg, &channel->control); in write_zsreg()
144 writeb(value, &channel->control); in write_zsreg()
155 regval = readb(&channel->control); in sunzilog_clear_fifo()
161 readb(&channel->data); in sunzilog_clear_fifo()
165 writeb(ERR_RES, &channel->control); in sunzilog_clear_fifo()
189 writeb(ERR_RES, &channel->control); in __load_zsregs()
268 static void sunzilog_maybe_update_regs(struct uart_sunzilog_port *up, in sunzilog_maybe_update_regs() argument
271 if (!ZS_REGS_HELD(up)) { in sunzilog_maybe_update_regs()
272 if (ZS_TX_ACTIVE(up)) { in sunzilog_maybe_update_regs()
273 up->flags |= SUNZILOG_FLAG_REGS_HELD; in sunzilog_maybe_update_regs()
275 __load_zsregs(channel, up->curregs); in sunzilog_maybe_update_regs()
280 static void sunzilog_change_mouse_baud(struct uart_sunzilog_port *up) in sunzilog_change_mouse_baud() argument
282 unsigned int cur_cflag = up->cflag; in sunzilog_change_mouse_baud()
285 up->cflag &= ~CBAUD; in sunzilog_change_mouse_baud()
286 up->cflag |= suncore_mouse_baud_cflag_next(cur_cflag, &new_baud); in sunzilog_change_mouse_baud()
289 up->curregs[R12] = (brg & 0xff); in sunzilog_change_mouse_baud()
290 up->curregs[R13] = (brg >> 8) & 0xff; in sunzilog_change_mouse_baud()
291 sunzilog_maybe_update_regs(up, ZILOG_CHANNEL_FROM_PORT(&up->port)); in sunzilog_change_mouse_baud()
294 static void sunzilog_kbdms_receive_chars(struct uart_sunzilog_port *up, in sunzilog_kbdms_receive_chars() argument
297 if (ZS_IS_KEYB(up)) { in sunzilog_kbdms_receive_chars()
298 /* Stop-A is handled by drivers/char/keyboard.c now. */ in sunzilog_kbdms_receive_chars()
300 if (up->serio_open) in sunzilog_kbdms_receive_chars()
301 serio_interrupt(&up->serio, ch, 0); in sunzilog_kbdms_receive_chars()
303 } else if (ZS_IS_MOUSE(up)) { in sunzilog_kbdms_receive_chars()
308 sunzilog_change_mouse_baud(up); in sunzilog_kbdms_receive_chars()
315 if (up->serio_open) in sunzilog_kbdms_receive_chars()
316 serio_interrupt(&up->serio, ch, 0); in sunzilog_kbdms_receive_chars()
324 sunzilog_receive_chars(struct uart_sunzilog_port *up, in sunzilog_receive_chars() argument
330 if (up->port.state != NULL) /* Unopened serial console */ in sunzilog_receive_chars()
331 port = &up->port.state->port; in sunzilog_receive_chars()
337 writeb(ERR_RES, &channel->control); in sunzilog_receive_chars()
342 ch = readb(&channel->control); in sunzilog_receive_chars()
354 ch = readb(&channel->data); in sunzilog_receive_chars()
357 ch &= up->parity_mask; in sunzilog_receive_chars()
359 if (unlikely(ZS_IS_KEYB(up)) || unlikely(ZS_IS_MOUSE(up))) { in sunzilog_receive_chars()
360 sunzilog_kbdms_receive_chars(up, ch, 0); in sunzilog_receive_chars()
366 up->port.icount.rx++; in sunzilog_receive_chars()
370 up->port.icount.brk++; in sunzilog_receive_chars()
371 if (uart_handle_break(&up->port)) in sunzilog_receive_chars()
375 up->port.icount.parity++; in sunzilog_receive_chars()
377 up->port.icount.frame++; in sunzilog_receive_chars()
379 up->port.icount.overrun++; in sunzilog_receive_chars()
380 r1 &= up->port.read_status_mask; in sunzilog_receive_chars()
388 if (uart_handle_sysrq_char(&up->port, ch) || !port) in sunzilog_receive_chars()
391 if (up->port.ignore_status_mask == 0xff || in sunzilog_receive_chars()
392 (r1 & up->port.ignore_status_mask) == 0) { in sunzilog_receive_chars()
402 static void sunzilog_status_handle(struct uart_sunzilog_port *up, in sunzilog_status_handle() argument
407 status = readb(&channel->control); in sunzilog_status_handle()
410 writeb(RES_EXT_INT, &channel->control); in sunzilog_status_handle()
415 if (ZS_IS_MOUSE(up)) in sunzilog_status_handle()
416 sunzilog_kbdms_receive_chars(up, 0, 1); in sunzilog_status_handle()
417 if (ZS_IS_CONS(up)) { in sunzilog_status_handle()
422 status = readb(&channel->control); in sunzilog_status_handle()
432 if (ZS_WANTS_MODEM_STATUS(up)) { in sunzilog_status_handle()
434 up->port.icount.dsr++; in sunzilog_status_handle()
440 if ((status ^ up->prev_status) ^ DCD) in sunzilog_status_handle()
441 uart_handle_dcd_change(&up->port, in sunzilog_status_handle()
443 if ((status ^ up->prev_status) ^ CTS) in sunzilog_status_handle()
444 uart_handle_cts_change(&up->port, in sunzilog_status_handle()
447 wake_up_interruptible(&up->port.state->port.delta_msr_wait); in sunzilog_status_handle()
450 up->prev_status = status; in sunzilog_status_handle()
453 static void sunzilog_transmit_chars(struct uart_sunzilog_port *up, in sunzilog_transmit_chars() argument
458 if (ZS_IS_CONS(up)) { in sunzilog_transmit_chars()
459 unsigned char status = readb(&channel->control); in sunzilog_transmit_chars()
468 * to poll on enough port->xmit space becoming free. -DaveM in sunzilog_transmit_chars()
474 up->flags &= ~SUNZILOG_FLAG_TX_ACTIVE; in sunzilog_transmit_chars()
476 if (ZS_REGS_HELD(up)) { in sunzilog_transmit_chars()
477 __load_zsregs(channel, up->curregs); in sunzilog_transmit_chars()
478 up->flags &= ~SUNZILOG_FLAG_REGS_HELD; in sunzilog_transmit_chars()
481 if (ZS_TX_STOPPED(up)) { in sunzilog_transmit_chars()
482 up->flags &= ~SUNZILOG_FLAG_TX_STOPPED; in sunzilog_transmit_chars()
486 if (up->port.x_char) { in sunzilog_transmit_chars()
487 up->flags |= SUNZILOG_FLAG_TX_ACTIVE; in sunzilog_transmit_chars()
488 writeb(up->port.x_char, &channel->data); in sunzilog_transmit_chars()
492 up->port.icount.tx++; in sunzilog_transmit_chars()
493 up->port.x_char = 0; in sunzilog_transmit_chars()
497 if (up->port.state == NULL) in sunzilog_transmit_chars()
499 xmit = &up->port.state->xmit; in sunzilog_transmit_chars()
503 if (uart_tx_stopped(&up->port)) in sunzilog_transmit_chars()
506 up->flags |= SUNZILOG_FLAG_TX_ACTIVE; in sunzilog_transmit_chars()
507 writeb(xmit->buf[xmit->tail], &channel->data); in sunzilog_transmit_chars()
511 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in sunzilog_transmit_chars()
512 up->port.icount.tx++; in sunzilog_transmit_chars()
515 uart_write_wakeup(&up->port); in sunzilog_transmit_chars()
520 writeb(RES_Tx_P, &channel->control); in sunzilog_transmit_chars()
527 struct uart_sunzilog_port *up = dev_id; in sunzilog_interrupt() local
529 while (up) { in sunzilog_interrupt()
531 = ZILOG_CHANNEL_FROM_PORT(&up->port); in sunzilog_interrupt()
535 spin_lock(&up->port.lock); in sunzilog_interrupt()
541 writeb(RES_H_IUS, &channel->control); in sunzilog_interrupt()
546 port = sunzilog_receive_chars(up, channel); in sunzilog_interrupt()
548 sunzilog_status_handle(up, channel); in sunzilog_interrupt()
550 sunzilog_transmit_chars(up, channel); in sunzilog_interrupt()
552 spin_unlock(&up->port.lock); in sunzilog_interrupt()
558 up = up->next; in sunzilog_interrupt()
559 channel = ZILOG_CHANNEL_FROM_PORT(&up->port); in sunzilog_interrupt()
561 spin_lock(&up->port.lock); in sunzilog_interrupt()
564 writeb(RES_H_IUS, &channel->control); in sunzilog_interrupt()
569 port = sunzilog_receive_chars(up, channel); in sunzilog_interrupt()
571 sunzilog_status_handle(up, channel); in sunzilog_interrupt()
573 sunzilog_transmit_chars(up, channel); in sunzilog_interrupt()
575 spin_unlock(&up->port.lock); in sunzilog_interrupt()
580 up = up->next; in sunzilog_interrupt()
595 status = readb(&channel->control); in sunzilog_read_channel_status()
608 spin_lock_irqsave(&port->lock, flags); in sunzilog_tx_empty()
612 spin_unlock_irqrestore(&port->lock, flags); in sunzilog_tx_empty()
644 struct uart_sunzilog_port *up = in sunzilog_set_mctrl() local
661 up->curregs[R5] |= set_bits; in sunzilog_set_mctrl()
662 up->curregs[R5] &= ~clear_bits; in sunzilog_set_mctrl()
663 write_zsreg(channel, R5, up->curregs[R5]); in sunzilog_set_mctrl()
669 struct uart_sunzilog_port *up = in sunzilog_stop_tx() local
672 up->flags |= SUNZILOG_FLAG_TX_STOPPED; in sunzilog_stop_tx()
678 struct uart_sunzilog_port *up = in sunzilog_start_tx() local
683 up->flags |= SUNZILOG_FLAG_TX_ACTIVE; in sunzilog_start_tx()
684 up->flags &= ~SUNZILOG_FLAG_TX_STOPPED; in sunzilog_start_tx()
686 status = readb(&channel->control); in sunzilog_start_tx()
693 /* Send the first character to jump-start the TX done in sunzilog_start_tx()
696 if (port->x_char) { in sunzilog_start_tx()
697 writeb(port->x_char, &channel->data); in sunzilog_start_tx()
701 port->icount.tx++; in sunzilog_start_tx()
702 port->x_char = 0; in sunzilog_start_tx()
704 struct circ_buf *xmit = &port->state->xmit; in sunzilog_start_tx()
708 writeb(xmit->buf[xmit->tail], &channel->data); in sunzilog_start_tx()
712 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in sunzilog_start_tx()
713 port->icount.tx++; in sunzilog_start_tx()
716 uart_write_wakeup(&up->port); in sunzilog_start_tx()
723 struct uart_sunzilog_port *up = UART_ZILOG(port); in sunzilog_stop_rx() local
726 if (ZS_IS_CONS(up)) in sunzilog_stop_rx()
732 up->curregs[R1] &= ~RxINT_MASK; in sunzilog_stop_rx()
733 sunzilog_maybe_update_regs(up, channel); in sunzilog_stop_rx()
739 struct uart_sunzilog_port *up = in sunzilog_enable_ms() local
744 new_reg = up->curregs[R15] | (DCDIE | SYNCIE | CTSIE); in sunzilog_enable_ms()
745 if (new_reg != up->curregs[R15]) { in sunzilog_enable_ms()
746 up->curregs[R15] = new_reg; in sunzilog_enable_ms()
749 write_zsreg(channel, R15, up->curregs[R15] & ~WR7pEN); in sunzilog_enable_ms()
756 struct uart_sunzilog_port *up = in sunzilog_break_ctl() local
769 spin_lock_irqsave(&port->lock, flags); in sunzilog_break_ctl()
771 new_reg = (up->curregs[R5] | set_bits) & ~clear_bits; in sunzilog_break_ctl()
772 if (new_reg != up->curregs[R5]) { in sunzilog_break_ctl()
773 up->curregs[R5] = new_reg; in sunzilog_break_ctl()
776 write_zsreg(channel, R5, up->curregs[R5]); in sunzilog_break_ctl()
779 spin_unlock_irqrestore(&port->lock, flags); in sunzilog_break_ctl()
782 static void __sunzilog_startup(struct uart_sunzilog_port *up) in __sunzilog_startup() argument
786 channel = ZILOG_CHANNEL_FROM_PORT(&up->port); in __sunzilog_startup()
787 up->prev_status = readb(&channel->control); in __sunzilog_startup()
790 up->curregs[R3] |= RxENAB; in __sunzilog_startup()
791 up->curregs[R5] |= TxENAB; in __sunzilog_startup()
793 up->curregs[R1] |= EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB; in __sunzilog_startup()
794 sunzilog_maybe_update_regs(up, channel); in __sunzilog_startup()
799 struct uart_sunzilog_port *up = UART_ZILOG(port); in sunzilog_startup() local
802 if (ZS_IS_CONS(up)) in sunzilog_startup()
805 spin_lock_irqsave(&port->lock, flags); in sunzilog_startup()
806 __sunzilog_startup(up); in sunzilog_startup()
807 spin_unlock_irqrestore(&port->lock, flags); in sunzilog_startup()
812 * The test for ZS_IS_CONS is explained by the following e-mail:
817 * On Sun, Dec 08, 2002 at 02:43:36AM -0500, Pete Zaitcev wrote:
833 * do the normal software shutdown - ie, free irqs etc)
838 struct uart_sunzilog_port *up = UART_ZILOG(port); in sunzilog_shutdown() local
842 if (ZS_IS_CONS(up)) in sunzilog_shutdown()
845 spin_lock_irqsave(&port->lock, flags); in sunzilog_shutdown()
850 up->curregs[R3] &= ~RxENAB; in sunzilog_shutdown()
851 up->curregs[R5] &= ~TxENAB; in sunzilog_shutdown()
854 up->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK); in sunzilog_shutdown()
855 up->curregs[R5] &= ~SND_BRK; in sunzilog_shutdown()
856 sunzilog_maybe_update_regs(up, channel); in sunzilog_shutdown()
858 spin_unlock_irqrestore(&port->lock, flags); in sunzilog_shutdown()
865 sunzilog_convert_to_zs(struct uart_sunzilog_port *up, unsigned int cflag, in sunzilog_convert_to_zs() argument
869 up->curregs[R10] = NRZ; in sunzilog_convert_to_zs()
870 up->curregs[R11] = TCBR | RCBR; in sunzilog_convert_to_zs()
873 up->curregs[R4] &= ~XCLK_MASK; in sunzilog_convert_to_zs()
874 up->curregs[R4] |= X16CLK; in sunzilog_convert_to_zs()
875 up->curregs[R12] = brg & 0xff; in sunzilog_convert_to_zs()
876 up->curregs[R13] = (brg >> 8) & 0xff; in sunzilog_convert_to_zs()
877 up->curregs[R14] = BRSRC | BRENAB; in sunzilog_convert_to_zs()
880 up->curregs[R3] &= ~RxN_MASK; in sunzilog_convert_to_zs()
881 up->curregs[R5] &= ~TxN_MASK; in sunzilog_convert_to_zs()
884 up->curregs[R3] |= Rx5; in sunzilog_convert_to_zs()
885 up->curregs[R5] |= Tx5; in sunzilog_convert_to_zs()
886 up->parity_mask = 0x1f; in sunzilog_convert_to_zs()
889 up->curregs[R3] |= Rx6; in sunzilog_convert_to_zs()
890 up->curregs[R5] |= Tx6; in sunzilog_convert_to_zs()
891 up->parity_mask = 0x3f; in sunzilog_convert_to_zs()
894 up->curregs[R3] |= Rx7; in sunzilog_convert_to_zs()
895 up->curregs[R5] |= Tx7; in sunzilog_convert_to_zs()
896 up->parity_mask = 0x7f; in sunzilog_convert_to_zs()
900 up->curregs[R3] |= Rx8; in sunzilog_convert_to_zs()
901 up->curregs[R5] |= Tx8; in sunzilog_convert_to_zs()
902 up->parity_mask = 0xff; in sunzilog_convert_to_zs()
905 up->curregs[R4] &= ~0x0c; in sunzilog_convert_to_zs()
907 up->curregs[R4] |= SB2; in sunzilog_convert_to_zs()
909 up->curregs[R4] |= SB1; in sunzilog_convert_to_zs()
911 up->curregs[R4] |= PAR_ENAB; in sunzilog_convert_to_zs()
913 up->curregs[R4] &= ~PAR_ENAB; in sunzilog_convert_to_zs()
915 up->curregs[R4] |= PAR_EVEN; in sunzilog_convert_to_zs()
917 up->curregs[R4] &= ~PAR_EVEN; in sunzilog_convert_to_zs()
919 up->port.read_status_mask = Rx_OVR; in sunzilog_convert_to_zs()
921 up->port.read_status_mask |= CRC_ERR | PAR_ERR; in sunzilog_convert_to_zs()
923 up->port.read_status_mask |= BRK_ABRT; in sunzilog_convert_to_zs()
925 up->port.ignore_status_mask = 0; in sunzilog_convert_to_zs()
927 up->port.ignore_status_mask |= CRC_ERR | PAR_ERR; in sunzilog_convert_to_zs()
929 up->port.ignore_status_mask |= BRK_ABRT; in sunzilog_convert_to_zs()
931 up->port.ignore_status_mask |= Rx_OVR; in sunzilog_convert_to_zs()
935 up->port.ignore_status_mask = 0xff; in sunzilog_convert_to_zs()
943 struct uart_sunzilog_port *up = in sunzilog_set_termios() local
950 spin_lock_irqsave(&up->port.lock, flags); in sunzilog_set_termios()
954 sunzilog_convert_to_zs(up, termios->c_cflag, termios->c_iflag, brg); in sunzilog_set_termios()
956 if (UART_ENABLE_MS(&up->port, termios->c_cflag)) in sunzilog_set_termios()
957 up->flags |= SUNZILOG_FLAG_MODEM_STATUS; in sunzilog_set_termios()
959 up->flags &= ~SUNZILOG_FLAG_MODEM_STATUS; in sunzilog_set_termios()
961 up->cflag = termios->c_cflag; in sunzilog_set_termios()
963 sunzilog_maybe_update_regs(up, ZILOG_CHANNEL_FROM_PORT(port)); in sunzilog_set_termios()
965 uart_update_timeout(port, termios->c_cflag, baud); in sunzilog_set_termios()
967 spin_unlock_irqrestore(&up->port.lock, flags); in sunzilog_set_termios()
972 struct uart_sunzilog_port *up = UART_ZILOG(port); in sunzilog_type() local
974 return (up->flags & SUNZILOG_FLAG_ESCC) ? "zs (ESCC)" : "zs"; in sunzilog_type()
997 return -EINVAL; in sunzilog_verify_port()
1004 struct uart_sunzilog_port *up = in sunzilog_get_poll_char() local
1007 = ZILOG_CHANNEL_FROM_PORT(&up->port); in sunzilog_get_poll_char()
1012 writeb(ERR_RES, &channel->control); in sunzilog_get_poll_char()
1017 ch = readb(&channel->control); in sunzilog_get_poll_char()
1029 ch = readb(&channel->data); in sunzilog_get_poll_char()
1032 ch &= up->parity_mask; in sunzilog_get_poll_char()
1039 struct uart_sunzilog_port *up = in sunzilog_put_poll_char() local
1042 sunzilog_putchar(&up->port, ch); in sunzilog_put_poll_char()
1084 struct uart_sunzilog_port *up; in sunzilog_alloc_tables() local
1092 return -ENOMEM; in sunzilog_alloc_tables()
1095 up = &sunzilog_port_table[i]; in sunzilog_alloc_tables()
1097 spin_lock_init(&up->port.lock); in sunzilog_alloc_tables()
1100 sunzilog_irq_chain = up; in sunzilog_alloc_tables()
1102 if (i < num_channels - 1) in sunzilog_alloc_tables()
1103 up->next = up + 1; in sunzilog_alloc_tables()
1105 up->next = NULL; in sunzilog_alloc_tables()
1113 return -ENOMEM; in sunzilog_alloc_tables()
1134 * udelay with ZSDELAY as that is a NOP on some platforms. -DaveM in sunzilog_putchar()
1137 unsigned char val = readb(&channel->control); in sunzilog_putchar()
1143 } while (--loops); in sunzilog_putchar()
1145 writeb(ch, &channel->data); in sunzilog_putchar()
1156 struct uart_sunzilog_port *up = serio->port_data; in sunzilog_serio_write() local
1161 sunzilog_putchar(&up->port, ch); in sunzilog_serio_write()
1170 struct uart_sunzilog_port *up = serio->port_data; in sunzilog_serio_open() local
1175 if (!up->serio_open) { in sunzilog_serio_open()
1176 up->serio_open = 1; in sunzilog_serio_open()
1179 ret = -EBUSY; in sunzilog_serio_open()
1187 struct uart_sunzilog_port *up = serio->port_data; in sunzilog_serio_close() local
1191 up->serio_open = 0; in sunzilog_serio_close()
1201 struct uart_sunzilog_port *up = &sunzilog_port_table[con->index]; in sunzilog_console_write() local
1205 if (up->port.sysrq || oops_in_progress) in sunzilog_console_write()
1206 locked = spin_trylock_irqsave(&up->port.lock, flags); in sunzilog_console_write()
1208 spin_lock_irqsave(&up->port.lock, flags); in sunzilog_console_write()
1210 uart_console_write(&up->port, s, count, sunzilog_putchar); in sunzilog_console_write()
1214 spin_unlock_irqrestore(&up->port.lock, flags); in sunzilog_console_write()
1219 struct uart_sunzilog_port *up = &sunzilog_port_table[con->index]; in sunzilog_console_setup() local
1223 if (up->port.type != PORT_SUNZILOG) in sunzilog_console_setup()
1224 return -EINVAL; in sunzilog_console_setup()
1227 (sunzilog_reg.minor - 64) + con->index, con->index); in sunzilog_console_setup()
1230 sunserial_console_termios(con, up->port.dev->of_node); in sunzilog_console_setup()
1232 /* Firmware console speed is limited to 150-->38400 baud so in sunzilog_console_setup()
1235 switch (con->cflag & CBAUD) { in sunzilog_console_setup()
1249 spin_lock_irqsave(&up->port.lock, flags); in sunzilog_console_setup()
1251 up->curregs[R15] |= BRKIE; in sunzilog_console_setup()
1252 sunzilog_convert_to_zs(up, con->cflag, 0, brg); in sunzilog_console_setup()
1254 sunzilog_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); in sunzilog_console_setup()
1255 __sunzilog_startup(up); in sunzilog_console_setup()
1257 spin_unlock_irqrestore(&up->port.lock, flags); in sunzilog_console_setup()
1268 .index = -1,
1281 static void sunzilog_init_kbdms(struct uart_sunzilog_port *up) in sunzilog_init_kbdms() argument
1285 if (up->flags & SUNZILOG_FLAG_CONS_KEYB) { in sunzilog_init_kbdms()
1286 up->cflag = B1200 | CS8 | CLOCAL | CREAD; in sunzilog_init_kbdms()
1289 up->cflag = B4800 | CS8 | CLOCAL | CREAD; in sunzilog_init_kbdms()
1293 up->curregs[R15] |= BRKIE; in sunzilog_init_kbdms()
1295 sunzilog_convert_to_zs(up, up->cflag, 0, brg); in sunzilog_init_kbdms()
1296 sunzilog_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); in sunzilog_init_kbdms()
1297 __sunzilog_startup(up); in sunzilog_init_kbdms()
1301 static void sunzilog_register_serio(struct uart_sunzilog_port *up) in sunzilog_register_serio() argument
1303 struct serio *serio = &up->serio; in sunzilog_register_serio()
1305 serio->port_data = up; in sunzilog_register_serio()
1307 serio->id.type = SERIO_RS232; in sunzilog_register_serio()
1308 if (up->flags & SUNZILOG_FLAG_CONS_KEYB) { in sunzilog_register_serio()
1309 serio->id.proto = SERIO_SUNKBD; in sunzilog_register_serio()
1310 strlcpy(serio->name, "zskbd", sizeof(serio->name)); in sunzilog_register_serio()
1312 serio->id.proto = SERIO_SUN; in sunzilog_register_serio()
1313 serio->id.extra = 1; in sunzilog_register_serio()
1314 strlcpy(serio->name, "zsms", sizeof(serio->name)); in sunzilog_register_serio()
1316 strlcpy(serio->phys, in sunzilog_register_serio()
1317 ((up->flags & SUNZILOG_FLAG_CONS_KEYB) ? in sunzilog_register_serio()
1319 sizeof(serio->phys)); in sunzilog_register_serio()
1321 serio->write = sunzilog_serio_write; in sunzilog_register_serio()
1322 serio->open = sunzilog_serio_open; in sunzilog_register_serio()
1323 serio->close = sunzilog_serio_close; in sunzilog_register_serio()
1324 serio->dev.parent = up->port.dev; in sunzilog_register_serio()
1330 static void sunzilog_init_hw(struct uart_sunzilog_port *up) in sunzilog_init_hw() argument
1336 channel = ZILOG_CHANNEL_FROM_PORT(&up->port); in sunzilog_init_hw()
1338 spin_lock_irqsave(&up->port.lock, flags); in sunzilog_init_hw()
1339 if (ZS_IS_CHANNEL_A(up)) { in sunzilog_init_hw()
1345 if (up->flags & (SUNZILOG_FLAG_CONS_KEYB | in sunzilog_init_hw()
1347 up->curregs[R1] = EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB; in sunzilog_init_hw()
1348 up->curregs[R4] = PAR_EVEN | X16CLK | SB1; in sunzilog_init_hw()
1349 up->curregs[R3] = RxENAB | Rx8; in sunzilog_init_hw()
1350 up->curregs[R5] = TxENAB | Tx8; in sunzilog_init_hw()
1351 up->curregs[R6] = 0x00; /* SDLC Address */ in sunzilog_init_hw()
1352 up->curregs[R7] = 0x7E; /* SDLC Flag */ in sunzilog_init_hw()
1353 up->curregs[R9] = NV; in sunzilog_init_hw()
1354 up->curregs[R7p] = 0x00; in sunzilog_init_hw()
1355 sunzilog_init_kbdms(up); in sunzilog_init_hw()
1357 if (up->flags & SUNZILOG_FLAG_ISR_HANDLER) in sunzilog_init_hw()
1358 up->curregs[R9] |= MIE; in sunzilog_init_hw()
1359 write_zsreg(channel, R9, up->curregs[R9]); in sunzilog_init_hw()
1362 up->parity_mask = 0xff; in sunzilog_init_hw()
1363 up->curregs[R1] = EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB; in sunzilog_init_hw()
1364 up->curregs[R4] = PAR_EVEN | X16CLK | SB1; in sunzilog_init_hw()
1365 up->curregs[R3] = RxENAB | Rx8; in sunzilog_init_hw()
1366 up->curregs[R5] = TxENAB | Tx8; in sunzilog_init_hw()
1367 up->curregs[R6] = 0x00; /* SDLC Address */ in sunzilog_init_hw()
1368 up->curregs[R7] = 0x7E; /* SDLC Flag */ in sunzilog_init_hw()
1369 up->curregs[R9] = NV; in sunzilog_init_hw()
1370 up->curregs[R10] = NRZ; in sunzilog_init_hw()
1371 up->curregs[R11] = TCBR | RCBR; in sunzilog_init_hw()
1374 up->curregs[R12] = (brg & 0xff); in sunzilog_init_hw()
1375 up->curregs[R13] = (brg >> 8) & 0xff; in sunzilog_init_hw()
1376 up->curregs[R14] = BRSRC | BRENAB; in sunzilog_init_hw()
1377 up->curregs[R15] = FIFOEN; /* Use FIFO if on ESCC */ in sunzilog_init_hw()
1378 up->curregs[R7p] = TxFIFO_LVL | RxFIFO_LVL; in sunzilog_init_hw()
1379 if (__load_zsregs(channel, up->curregs)) { in sunzilog_init_hw()
1380 up->flags |= SUNZILOG_FLAG_ESCC; in sunzilog_init_hw()
1383 if (up->flags & SUNZILOG_FLAG_ISR_HANDLER) in sunzilog_init_hw()
1384 up->curregs[R9] |= MIE; in sunzilog_init_hw()
1385 write_zsreg(channel, R9, up->curregs[R9]); in sunzilog_init_hw()
1388 spin_unlock_irqrestore(&up->port.lock, flags); in sunzilog_init_hw()
1391 if (up->flags & (SUNZILOG_FLAG_CONS_KEYB | in sunzilog_init_hw()
1393 sunzilog_register_serio(up); in sunzilog_init_hw()
1403 struct uart_sunzilog_port *up; in zs_probe() local
1408 if (of_find_property(op->dev.of_node, "keyboard", NULL)) in zs_probe()
1417 sunzilog_chip_regs[inst] = of_ioremap(&op->resource[0], 0, in zs_probe()
1421 return -ENOMEM; in zs_probe()
1426 zilog_irq = op->archdata.irqs[0]; in zs_probe()
1428 up = &sunzilog_port_table[inst * 2]; in zs_probe()
1431 up[0].port.mapbase = op->resource[0].start + 0x00; in zs_probe()
1432 up[0].port.membase = (void __iomem *) &rp->channelA; in zs_probe()
1433 up[0].port.iotype = UPIO_MEM; in zs_probe()
1434 up[0].port.irq = op->archdata.irqs[0]; in zs_probe()
1435 up[0].port.uartclk = ZS_CLOCK; in zs_probe()
1436 up[0].port.fifosize = 1; in zs_probe()
1437 up[0].port.ops = &sunzilog_pops; in zs_probe()
1438 up[0].port.type = PORT_SUNZILOG; in zs_probe()
1439 up[0].port.flags = 0; in zs_probe()
1440 up[0].port.line = (inst * 2) + 0; in zs_probe()
1441 up[0].port.dev = &op->dev; in zs_probe()
1442 up[0].flags |= SUNZILOG_FLAG_IS_CHANNEL_A; in zs_probe()
1443 up[0].port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNZILOG_CONSOLE); in zs_probe()
1445 up[0].flags |= SUNZILOG_FLAG_CONS_KEYB; in zs_probe()
1446 sunzilog_init_hw(&up[0]); in zs_probe()
1449 up[1].port.mapbase = op->resource[0].start + 0x04; in zs_probe()
1450 up[1].port.membase = (void __iomem *) &rp->channelB; in zs_probe()
1451 up[1].port.iotype = UPIO_MEM; in zs_probe()
1452 up[1].port.irq = op->archdata.irqs[0]; in zs_probe()
1453 up[1].port.uartclk = ZS_CLOCK; in zs_probe()
1454 up[1].port.fifosize = 1; in zs_probe()
1455 up[1].port.ops = &sunzilog_pops; in zs_probe()
1456 up[1].port.type = PORT_SUNZILOG; in zs_probe()
1457 up[1].port.flags = 0; in zs_probe()
1458 up[1].port.line = (inst * 2) + 1; in zs_probe()
1459 up[1].port.dev = &op->dev; in zs_probe()
1460 up[1].flags |= 0; in zs_probe()
1461 up[1].port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNZILOG_CONSOLE); in zs_probe()
1463 up[1].flags |= SUNZILOG_FLAG_CONS_MOUSE; in zs_probe()
1464 sunzilog_init_hw(&up[1]); in zs_probe()
1467 if (sunserial_console_match(SUNZILOG_CONSOLE(), op->dev.of_node, in zs_probe()
1468 &sunzilog_reg, up[0].port.line, in zs_probe()
1470 up->flags |= SUNZILOG_FLAG_IS_CONS; in zs_probe()
1471 err = uart_add_one_port(&sunzilog_reg, &up[0].port); in zs_probe()
1473 of_iounmap(&op->resource[0], in zs_probe()
1477 if (sunserial_console_match(SUNZILOG_CONSOLE(), op->dev.of_node, in zs_probe()
1478 &sunzilog_reg, up[1].port.line, in zs_probe()
1480 up->flags |= SUNZILOG_FLAG_IS_CONS; in zs_probe()
1481 err = uart_add_one_port(&sunzilog_reg, &up[1].port); in zs_probe()
1483 uart_remove_one_port(&sunzilog_reg, &up[0].port); in zs_probe()
1484 of_iounmap(&op->resource[0], in zs_probe()
1492 dev_name(&op->dev), in zs_probe()
1493 (unsigned long long) up[0].port.mapbase, in zs_probe()
1494 op->archdata.irqs[0], sunzilog_type(&up[0].port)); in zs_probe()
1497 dev_name(&op->dev), in zs_probe()
1498 (unsigned long long) up[1].port.mapbase, in zs_probe()
1499 op->archdata.irqs[0], sunzilog_type(&up[1].port)); in zs_probe()
1503 platform_set_drvdata(op, &up[0]); in zs_probe()
1508 static void zs_remove_one(struct uart_sunzilog_port *up) in zs_remove_one() argument
1510 if (ZS_IS_KEYB(up) || ZS_IS_MOUSE(up)) { in zs_remove_one()
1512 serio_unregister_port(&up->serio); in zs_remove_one()
1515 uart_remove_one_port(&sunzilog_reg, &up->port); in zs_remove_one()
1520 struct uart_sunzilog_port *up = platform_get_drvdata(op); in zs_remove() local
1523 zs_remove_one(&up[0]); in zs_remove()
1524 zs_remove_one(&up[1]); in zs_remove()
1526 regs = sunzilog_chip_regs[up[0].port.line / 2]; in zs_remove()
1527 of_iounmap(&op->resource[0], regs, sizeof(struct zilog_layout)); in zs_remove()
1567 uart_chip_count = num_sunzilog - num_keybms; in sunzilog_init()
1580 struct uart_sunzilog_port *up = sunzilog_irq_chain; in sunzilog_init() local
1587 while (up) { in sunzilog_init()
1590 /* printk (KERN_INFO "Enable IRQ for ZILOG Hardware %p\n", up); */ in sunzilog_init()
1591 channel = ZILOG_CHANNEL_FROM_PORT(&up->port); in sunzilog_init()
1592 up->flags |= SUNZILOG_FLAG_ISR_HANDLER; in sunzilog_init()
1593 up->curregs[R9] |= MIE; in sunzilog_init()
1594 write_zsreg(channel, R9, up->curregs[R9]); in sunzilog_init()
1595 up = up->next; in sunzilog_init()
1621 struct uart_sunzilog_port *up = sunzilog_irq_chain; in sunzilog_exit() local
1624 while (up) { in sunzilog_exit()
1627 /* printk (KERN_INFO "Disable IRQ for ZILOG Hardware %p\n", up); */ in sunzilog_exit()
1628 channel = ZILOG_CHANNEL_FROM_PORT(&up->port); in sunzilog_exit()
1629 up->flags &= ~SUNZILOG_FLAG_ISR_HANDLER; in sunzilog_exit()
1630 up->curregs[R9] &= ~MIE; in sunzilog_exit()
1631 write_zsreg(channel, R9, up->curregs[R9]); in sunzilog_exit()
1632 up = up->next; in sunzilog_exit()