Lines Matching refs:up

104 static unsigned int serial_in(struct uart_sunsu_port *up, int offset)  in serial_in()  argument
106 offset <<= up->port.regshift; in serial_in()
108 switch (up->port.iotype) { in serial_in()
110 outb(up->port.hub6 - 1 + offset, up->port.iobase); in serial_in()
111 return inb(up->port.iobase + 1); in serial_in()
114 return readb(up->port.membase + offset); in serial_in()
117 return inb(up->port.iobase + offset); in serial_in()
121 static void serial_out(struct uart_sunsu_port *up, int offset, int value) in serial_out() argument
136 offset <<= up->port.regshift; in serial_out()
138 switch (up->port.iotype) { in serial_out()
140 outb(up->port.hub6 - 1 + offset, up->port.iobase); in serial_out()
141 outb(value, up->port.iobase + 1); in serial_out()
145 writeb(value, up->port.membase + offset); in serial_out()
149 outb(value, up->port.iobase + offset); in serial_out()
159 #define serial_inp(up, offset) serial_in(up, offset) argument
160 #define serial_outp(up, offset, value) serial_out(up, offset, value) argument
166 static void serial_icr_write(struct uart_sunsu_port *up, int offset, int value) in serial_icr_write() argument
168 serial_out(up, UART_SCR, offset); in serial_icr_write()
169 serial_out(up, UART_ICR, value); in serial_icr_write()
173 static unsigned int serial_icr_read(struct uart_sunsu_port *up, int offset)
177 serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD);
178 serial_out(up, UART_SCR, offset);
179 value = serial_in(up, UART_ICR);
180 serial_icr_write(up, UART_ACR, up->acr);
191 static int __enable_rsa(struct uart_sunsu_port *up) in __enable_rsa() argument
196 mode = serial_inp(up, UART_RSA_MSR); in __enable_rsa()
200 serial_outp(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); in __enable_rsa()
201 mode = serial_inp(up, UART_RSA_MSR); in __enable_rsa()
206 up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16; in __enable_rsa()
211 static void enable_rsa(struct uart_sunsu_port *up) in enable_rsa() argument
213 if (up->port.type == PORT_RSA) { in enable_rsa()
214 if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) { in enable_rsa()
215 spin_lock_irq(&up->port.lock); in enable_rsa()
216 __enable_rsa(up); in enable_rsa()
217 spin_unlock_irq(&up->port.lock); in enable_rsa()
219 if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) in enable_rsa()
220 serial_outp(up, UART_RSA_FRR, 0); in enable_rsa()
230 static void disable_rsa(struct uart_sunsu_port *up) in disable_rsa() argument
235 if (up->port.type == PORT_RSA && in disable_rsa()
236 up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) { in disable_rsa()
237 spin_lock_irq(&up->port.lock); in disable_rsa()
239 mode = serial_inp(up, UART_RSA_MSR); in disable_rsa()
243 serial_outp(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); in disable_rsa()
244 mode = serial_inp(up, UART_RSA_MSR); in disable_rsa()
249 up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; in disable_rsa()
250 spin_unlock_irq(&up->port.lock); in disable_rsa()
265 struct uart_sunsu_port *up = in sunsu_stop_tx() local
268 __stop_tx(up); in sunsu_stop_tx()
273 if (up->port.type == PORT_16C950) { in sunsu_stop_tx()
274 up->acr |= UART_ACR_TXDIS; in sunsu_stop_tx()
275 serial_icr_write(up, UART_ACR, up->acr); in sunsu_stop_tx()
281 struct uart_sunsu_port *up = in sunsu_start_tx() local
284 if (!(up->ier & UART_IER_THRI)) { in sunsu_start_tx()
285 up->ier |= UART_IER_THRI; in sunsu_start_tx()
286 serial_out(up, UART_IER, up->ier); in sunsu_start_tx()
292 if (up->port.type == PORT_16C950 && up->acr & UART_ACR_TXDIS) { in sunsu_start_tx()
293 up->acr &= ~UART_ACR_TXDIS; in sunsu_start_tx()
294 serial_icr_write(up, UART_ACR, up->acr); in sunsu_start_tx()
300 struct uart_sunsu_port *up = in sunsu_stop_rx() local
303 up->ier &= ~UART_IER_RLSI; in sunsu_stop_rx()
304 up->port.read_status_mask &= ~UART_LSR_DR; in sunsu_stop_rx()
305 serial_out(up, UART_IER, up->ier); in sunsu_stop_rx()
310 struct uart_sunsu_port *up = in sunsu_enable_ms() local
314 spin_lock_irqsave(&up->port.lock, flags); in sunsu_enable_ms()
315 up->ier |= UART_IER_MSI; in sunsu_enable_ms()
316 serial_out(up, UART_IER, up->ier); in sunsu_enable_ms()
317 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_enable_ms()
321 receive_chars(struct uart_sunsu_port *up, unsigned char *status) in receive_chars() argument
323 struct tty_port *port = &up->port.state->port; in receive_chars()
329 ch = serial_inp(up, UART_RX); in receive_chars()
331 up->port.icount.rx++; in receive_chars()
340 up->port.icount.brk++; in receive_chars()
341 if (up->port.cons != NULL && in receive_chars()
342 up->port.line == up->port.cons->index) in receive_chars()
350 if (uart_handle_break(&up->port)) in receive_chars()
353 up->port.icount.parity++; in receive_chars()
355 up->port.icount.frame++; in receive_chars()
357 up->port.icount.overrun++; in receive_chars()
362 *status &= up->port.read_status_mask; in receive_chars()
364 if (up->port.cons != NULL && in receive_chars()
365 up->port.line == up->port.cons->index) { in receive_chars()
367 *status |= up->lsr_break_flag; in receive_chars()
368 up->lsr_break_flag = 0; in receive_chars()
378 if (uart_handle_sysrq_char(&up->port, ch)) in receive_chars()
380 if ((*status & up->port.ignore_status_mask) == 0) in receive_chars()
390 *status = serial_inp(up, UART_LSR); in receive_chars()
397 static void transmit_chars(struct uart_sunsu_port *up) in transmit_chars() argument
399 struct circ_buf *xmit = &up->port.state->xmit; in transmit_chars()
402 if (up->port.x_char) { in transmit_chars()
403 serial_outp(up, UART_TX, up->port.x_char); in transmit_chars()
404 up->port.icount.tx++; in transmit_chars()
405 up->port.x_char = 0; in transmit_chars()
408 if (uart_tx_stopped(&up->port)) { in transmit_chars()
409 sunsu_stop_tx(&up->port); in transmit_chars()
413 __stop_tx(up); in transmit_chars()
417 count = up->port.fifosize; in transmit_chars()
419 serial_out(up, UART_TX, xmit->buf[xmit->tail]); in transmit_chars()
420 uart_xmit_advance(&up->port, 1); in transmit_chars()
426 uart_write_wakeup(&up->port); in transmit_chars()
429 __stop_tx(up); in transmit_chars()
432 static void check_modem_status(struct uart_sunsu_port *up) in check_modem_status() argument
436 status = serial_in(up, UART_MSR); in check_modem_status()
442 up->port.icount.rng++; in check_modem_status()
444 up->port.icount.dsr++; in check_modem_status()
446 uart_handle_dcd_change(&up->port, status & UART_MSR_DCD); in check_modem_status()
448 uart_handle_cts_change(&up->port, status & UART_MSR_CTS); in check_modem_status()
450 wake_up_interruptible(&up->port.state->port.delta_msr_wait); in check_modem_status()
455 struct uart_sunsu_port *up = dev_id; in sunsu_serial_interrupt() local
459 spin_lock_irqsave(&up->port.lock, flags); in sunsu_serial_interrupt()
462 status = serial_inp(up, UART_LSR); in sunsu_serial_interrupt()
464 receive_chars(up, &status); in sunsu_serial_interrupt()
465 check_modem_status(up); in sunsu_serial_interrupt()
467 transmit_chars(up); in sunsu_serial_interrupt()
469 tty_flip_buffer_push(&up->port.state->port); in sunsu_serial_interrupt()
471 } while (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT)); in sunsu_serial_interrupt()
473 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_serial_interrupt()
484 static void sunsu_change_mouse_baud(struct uart_sunsu_port *up) in sunsu_change_mouse_baud() argument
486 unsigned int cur_cflag = up->cflag; in sunsu_change_mouse_baud()
489 up->cflag &= ~CBAUD; in sunsu_change_mouse_baud()
490 up->cflag |= suncore_mouse_baud_cflag_next(cur_cflag, &new_baud); in sunsu_change_mouse_baud()
492 quot = up->port.uartclk / (16 * new_baud); in sunsu_change_mouse_baud()
494 sunsu_change_speed(&up->port, up->cflag, 0, quot); in sunsu_change_mouse_baud()
497 static void receive_kbd_ms_chars(struct uart_sunsu_port *up, int is_break) in receive_kbd_ms_chars() argument
500 unsigned char ch = serial_inp(up, UART_RX); in receive_kbd_ms_chars()
503 if (up->su_type == SU_PORT_KBD) { in receive_kbd_ms_chars()
505 serio_interrupt(&up->serio, ch, 0); in receive_kbd_ms_chars()
507 } else if (up->su_type == SU_PORT_MS) { in receive_kbd_ms_chars()
512 sunsu_change_mouse_baud(up); in receive_kbd_ms_chars()
519 serio_interrupt(&up->serio, ch, 0); in receive_kbd_ms_chars()
524 } while (serial_in(up, UART_LSR) & UART_LSR_DR); in receive_kbd_ms_chars()
529 struct uart_sunsu_port *up = dev_id; in sunsu_kbd_ms_interrupt() local
531 if (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT)) { in sunsu_kbd_ms_interrupt()
532 unsigned char status = serial_inp(up, UART_LSR); in sunsu_kbd_ms_interrupt()
535 receive_kbd_ms_chars(up, (status & UART_LSR_BI) != 0); in sunsu_kbd_ms_interrupt()
543 struct uart_sunsu_port *up = in sunsu_tx_empty() local
548 spin_lock_irqsave(&up->port.lock, flags); in sunsu_tx_empty()
549 ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0; in sunsu_tx_empty()
550 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_tx_empty()
557 struct uart_sunsu_port *up = in sunsu_get_mctrl() local
562 status = serial_in(up, UART_MSR); in sunsu_get_mctrl()
578 struct uart_sunsu_port *up = in sunsu_set_mctrl() local
593 serial_out(up, UART_MCR, mcr); in sunsu_set_mctrl()
598 struct uart_sunsu_port *up = in sunsu_break_ctl() local
602 spin_lock_irqsave(&up->port.lock, flags); in sunsu_break_ctl()
604 up->lcr |= UART_LCR_SBC; in sunsu_break_ctl()
606 up->lcr &= ~UART_LCR_SBC; in sunsu_break_ctl()
607 serial_out(up, UART_LCR, up->lcr); in sunsu_break_ctl()
608 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_break_ctl()
613 struct uart_sunsu_port *up = in sunsu_startup() local
618 if (up->port.type == PORT_16C950) { in sunsu_startup()
620 up->acr = 0; in sunsu_startup()
621 serial_outp(up, UART_LCR, 0xBF); in sunsu_startup()
622 serial_outp(up, UART_EFR, UART_EFR_ECB); in sunsu_startup()
623 serial_outp(up, UART_IER, 0); in sunsu_startup()
624 serial_outp(up, UART_LCR, 0); in sunsu_startup()
625 serial_icr_write(up, UART_CSR, 0); /* Reset the UART */ in sunsu_startup()
626 serial_outp(up, UART_LCR, 0xBF); in sunsu_startup()
627 serial_outp(up, UART_EFR, UART_EFR_ECB); in sunsu_startup()
628 serial_outp(up, UART_LCR, 0); in sunsu_startup()
636 enable_rsa(up); in sunsu_startup()
643 if (uart_config[up->port.type].flags & UART_CLEAR_FIFO) { in sunsu_startup()
644 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); in sunsu_startup()
645 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | in sunsu_startup()
647 serial_outp(up, UART_FCR, 0); in sunsu_startup()
653 (void) serial_inp(up, UART_LSR); in sunsu_startup()
654 (void) serial_inp(up, UART_RX); in sunsu_startup()
655 (void) serial_inp(up, UART_IIR); in sunsu_startup()
656 (void) serial_inp(up, UART_MSR); in sunsu_startup()
663 if (!(up->port.flags & UPF_BUGGY_UART) && in sunsu_startup()
664 (serial_inp(up, UART_LSR) == 0xff)) { in sunsu_startup()
665 printk("ttyS%d: LSR safety check engaged!\n", up->port.line); in sunsu_startup()
669 if (up->su_type != SU_PORT_PORT) { in sunsu_startup()
670 retval = request_irq(up->port.irq, sunsu_kbd_ms_interrupt, in sunsu_startup()
671 IRQF_SHARED, su_typev[up->su_type], up); in sunsu_startup()
673 retval = request_irq(up->port.irq, sunsu_serial_interrupt, in sunsu_startup()
674 IRQF_SHARED, su_typev[up->su_type], up); in sunsu_startup()
677 printk("su: Cannot register IRQ %d\n", up->port.irq); in sunsu_startup()
684 serial_outp(up, UART_LCR, UART_LCR_WLEN8); in sunsu_startup()
686 spin_lock_irqsave(&up->port.lock, flags); in sunsu_startup()
688 up->port.mctrl |= TIOCM_OUT2; in sunsu_startup()
690 sunsu_set_mctrl(&up->port, up->port.mctrl); in sunsu_startup()
691 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_startup()
698 up->ier = UART_IER_RLSI | UART_IER_RDI; in sunsu_startup()
699 serial_outp(up, UART_IER, up->ier); in sunsu_startup()
701 if (up->port.flags & UPF_FOURPORT) { in sunsu_startup()
706 icp = (up->port.iobase & 0xfe0) | 0x01f; in sunsu_startup()
714 (void) serial_inp(up, UART_LSR); in sunsu_startup()
715 (void) serial_inp(up, UART_RX); in sunsu_startup()
716 (void) serial_inp(up, UART_IIR); in sunsu_startup()
717 (void) serial_inp(up, UART_MSR); in sunsu_startup()
724 struct uart_sunsu_port *up = in sunsu_shutdown() local
731 up->ier = 0; in sunsu_shutdown()
732 serial_outp(up, UART_IER, 0); in sunsu_shutdown()
734 spin_lock_irqsave(&up->port.lock, flags); in sunsu_shutdown()
735 if (up->port.flags & UPF_FOURPORT) { in sunsu_shutdown()
737 inb((up->port.iobase & 0xfe0) | 0x1f); in sunsu_shutdown()
738 up->port.mctrl |= TIOCM_OUT1; in sunsu_shutdown()
740 up->port.mctrl &= ~TIOCM_OUT2; in sunsu_shutdown()
742 sunsu_set_mctrl(&up->port, up->port.mctrl); in sunsu_shutdown()
743 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_shutdown()
748 serial_out(up, UART_LCR, serial_inp(up, UART_LCR) & ~UART_LCR_SBC); in sunsu_shutdown()
749 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | in sunsu_shutdown()
752 serial_outp(up, UART_FCR, 0); in sunsu_shutdown()
758 disable_rsa(up); in sunsu_shutdown()
764 (void) serial_in(up, UART_RX); in sunsu_shutdown()
766 free_irq(up->port.irq, up); in sunsu_shutdown()
773 struct uart_sunsu_port *up = in sunsu_change_speed() local
808 if ((quot & 0xff) == 0 && up->port.type == PORT_16C950 && in sunsu_change_speed()
809 up->rev == 0x5201) in sunsu_change_speed()
812 if (uart_config[up->port.type].flags & UART_USE_FIFO) { in sunsu_change_speed()
813 if ((up->port.uartclk / quot) < (2400 * 16)) in sunsu_change_speed()
816 else if (up->port.type == PORT_RSA) in sunsu_change_speed()
822 if (up->port.type == PORT_16750) in sunsu_change_speed()
829 spin_lock_irqsave(&up->port.lock, flags); in sunsu_change_speed()
836 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; in sunsu_change_speed()
838 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; in sunsu_change_speed()
840 up->port.read_status_mask |= UART_LSR_BI; in sunsu_change_speed()
845 up->port.ignore_status_mask = 0; in sunsu_change_speed()
847 up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE; in sunsu_change_speed()
849 up->port.ignore_status_mask |= UART_LSR_BI; in sunsu_change_speed()
855 up->port.ignore_status_mask |= UART_LSR_OE; in sunsu_change_speed()
862 up->port.ignore_status_mask |= UART_LSR_DR; in sunsu_change_speed()
867 up->ier &= ~UART_IER_MSI; in sunsu_change_speed()
868 if (UART_ENABLE_MS(&up->port, cflag)) in sunsu_change_speed()
869 up->ier |= UART_IER_MSI; in sunsu_change_speed()
871 serial_out(up, UART_IER, up->ier); in sunsu_change_speed()
873 if (uart_config[up->port.type].flags & UART_STARTECH) { in sunsu_change_speed()
874 serial_outp(up, UART_LCR, 0xBF); in sunsu_change_speed()
875 serial_outp(up, UART_EFR, cflag & CRTSCTS ? UART_EFR_CTS :0); in sunsu_change_speed()
877 serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ in sunsu_change_speed()
878 serial_outp(up, UART_DLL, quot & 0xff); /* LS of divisor */ in sunsu_change_speed()
879 serial_outp(up, UART_DLM, quot >> 8); /* MS of divisor */ in sunsu_change_speed()
880 if (up->port.type == PORT_16750) in sunsu_change_speed()
881 serial_outp(up, UART_FCR, fcr); /* set fcr */ in sunsu_change_speed()
882 serial_outp(up, UART_LCR, cval); /* reset DLAB */ in sunsu_change_speed()
883 up->lcr = cval; /* Save LCR */ in sunsu_change_speed()
884 if (up->port.type != PORT_16750) { in sunsu_change_speed()
887 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); in sunsu_change_speed()
889 serial_outp(up, UART_FCR, fcr); /* set fcr */ in sunsu_change_speed()
892 up->cflag = cflag; in sunsu_change_speed()
894 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_change_speed()
923 struct uart_sunsu_port *up = in sunsu_config_port() local
932 port->type = up->type_probed; /* XXX */ in sunsu_config_port()
982 struct uart_sunsu_port *up = serio->port_data; in sunsu_serio_write() local
989 lsr = serial_in(up, UART_LSR); in sunsu_serio_write()
993 serial_out(up, UART_TX, ch); in sunsu_serio_write()
1002 struct uart_sunsu_port *up = serio->port_data; in sunsu_serio_open() local
1007 if (!up->serio_open) { in sunsu_serio_open()
1008 up->serio_open = 1; in sunsu_serio_open()
1019 struct uart_sunsu_port *up = serio->port_data; in sunsu_serio_close() local
1023 up->serio_open = 0; in sunsu_serio_close()
1029 static void sunsu_autoconfig(struct uart_sunsu_port *up) in sunsu_autoconfig() argument
1035 if (up->su_type == SU_PORT_NONE) in sunsu_autoconfig()
1038 up->type_probed = PORT_UNKNOWN; in sunsu_autoconfig()
1039 up->port.iotype = UPIO_MEM; in sunsu_autoconfig()
1041 spin_lock_irqsave(&up->port.lock, flags); in sunsu_autoconfig()
1043 if (!(up->port.flags & UPF_BUGGY_UART)) { in sunsu_autoconfig()
1053 scratch = serial_inp(up, UART_IER); in sunsu_autoconfig()
1054 serial_outp(up, UART_IER, 0); in sunsu_autoconfig()
1058 scratch2 = serial_inp(up, UART_IER); in sunsu_autoconfig()
1059 serial_outp(up, UART_IER, 0x0f); in sunsu_autoconfig()
1063 scratch3 = serial_inp(up, UART_IER); in sunsu_autoconfig()
1064 serial_outp(up, UART_IER, scratch); in sunsu_autoconfig()
1069 save_mcr = serial_in(up, UART_MCR); in sunsu_autoconfig()
1070 save_lcr = serial_in(up, UART_LCR); in sunsu_autoconfig()
1081 if (!(up->port.flags & UPF_SKIP_TEST)) { in sunsu_autoconfig()
1082 serial_outp(up, UART_MCR, UART_MCR_LOOP | 0x0A); in sunsu_autoconfig()
1083 status1 = serial_inp(up, UART_MSR) & 0xF0; in sunsu_autoconfig()
1084 serial_outp(up, UART_MCR, save_mcr); in sunsu_autoconfig()
1088 serial_outp(up, UART_LCR, 0xBF); /* set up for StarTech test */ in sunsu_autoconfig()
1089 serial_outp(up, UART_EFR, 0); /* EFR is the same as FCR */ in sunsu_autoconfig()
1090 serial_outp(up, UART_LCR, 0); in sunsu_autoconfig()
1091 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); in sunsu_autoconfig()
1092 scratch = serial_in(up, UART_IIR) >> 6; in sunsu_autoconfig()
1095 up->port.type = PORT_16450; in sunsu_autoconfig()
1098 up->port.type = PORT_UNKNOWN; in sunsu_autoconfig()
1101 up->port.type = PORT_16550; in sunsu_autoconfig()
1104 up->port.type = PORT_16550A; in sunsu_autoconfig()
1107 if (up->port.type == PORT_16550A) { in sunsu_autoconfig()
1109 serial_outp(up, UART_LCR, UART_LCR_DLAB); in sunsu_autoconfig()
1110 if (serial_in(up, UART_EFR) == 0) { in sunsu_autoconfig()
1111 up->port.type = PORT_16650; in sunsu_autoconfig()
1113 serial_outp(up, UART_LCR, 0xBF); in sunsu_autoconfig()
1114 if (serial_in(up, UART_EFR) == 0) in sunsu_autoconfig()
1115 up->port.type = PORT_16650V2; in sunsu_autoconfig()
1118 if (up->port.type == PORT_16550A) { in sunsu_autoconfig()
1120 serial_outp(up, UART_LCR, save_lcr | UART_LCR_DLAB); in sunsu_autoconfig()
1121 serial_outp(up, UART_FCR, in sunsu_autoconfig()
1123 scratch = serial_in(up, UART_IIR) >> 5; in sunsu_autoconfig()
1131 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); in sunsu_autoconfig()
1132 serial_outp(up, UART_LCR, 0); in sunsu_autoconfig()
1133 serial_outp(up, UART_FCR, in sunsu_autoconfig()
1135 scratch = serial_in(up, UART_IIR) >> 5; in sunsu_autoconfig()
1137 up->port.type = PORT_16750; in sunsu_autoconfig()
1139 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); in sunsu_autoconfig()
1141 serial_outp(up, UART_LCR, save_lcr); in sunsu_autoconfig()
1142 if (up->port.type == PORT_16450) { in sunsu_autoconfig()
1143 scratch = serial_in(up, UART_SCR); in sunsu_autoconfig()
1144 serial_outp(up, UART_SCR, 0xa5); in sunsu_autoconfig()
1145 status1 = serial_in(up, UART_SCR); in sunsu_autoconfig()
1146 serial_outp(up, UART_SCR, 0x5a); in sunsu_autoconfig()
1147 status2 = serial_in(up, UART_SCR); in sunsu_autoconfig()
1148 serial_outp(up, UART_SCR, scratch); in sunsu_autoconfig()
1151 up->port.type = PORT_8250; in sunsu_autoconfig()
1154 up->port.fifosize = uart_config[up->port.type].dfl_xmit_fifo_size; in sunsu_autoconfig()
1156 if (up->port.type == PORT_UNKNOWN) in sunsu_autoconfig()
1158 up->type_probed = up->port.type; /* XXX */ in sunsu_autoconfig()
1164 if (up->port.type == PORT_RSA) in sunsu_autoconfig()
1165 serial_outp(up, UART_RSA_FRR, 0); in sunsu_autoconfig()
1167 serial_outp(up, UART_MCR, save_mcr); in sunsu_autoconfig()
1168 serial_outp(up, UART_FCR, (UART_FCR_ENABLE_FIFO | in sunsu_autoconfig()
1171 serial_outp(up, UART_FCR, 0); in sunsu_autoconfig()
1172 (void)serial_in(up, UART_RX); in sunsu_autoconfig()
1173 serial_outp(up, UART_IER, 0); in sunsu_autoconfig()
1176 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_autoconfig()
1186 static int sunsu_kbd_ms_init(struct uart_sunsu_port *up) in sunsu_kbd_ms_init() argument
1193 if (up->su_type == SU_PORT_KBD) { in sunsu_kbd_ms_init()
1194 up->cflag = B1200 | CS8 | CLOCAL | CREAD; in sunsu_kbd_ms_init()
1197 up->cflag = B4800 | CS8 | CLOCAL | CREAD; in sunsu_kbd_ms_init()
1200 quot = up->port.uartclk / (16 * baud); in sunsu_kbd_ms_init()
1202 sunsu_autoconfig(up); in sunsu_kbd_ms_init()
1203 if (up->port.type == PORT_UNKNOWN) in sunsu_kbd_ms_init()
1207 up->port.dev->of_node, in sunsu_kbd_ms_init()
1208 (up->su_type == SU_PORT_KBD) ? "Keyboard" : "Mouse", in sunsu_kbd_ms_init()
1209 (unsigned long long) up->port.mapbase, in sunsu_kbd_ms_init()
1210 up->port.irq); in sunsu_kbd_ms_init()
1213 serio = &up->serio; in sunsu_kbd_ms_init()
1214 serio->port_data = up; in sunsu_kbd_ms_init()
1217 if (up->su_type == SU_PORT_KBD) { in sunsu_kbd_ms_init()
1226 (!(up->port.line & 1) ? "su/serio0" : "su/serio1"), in sunsu_kbd_ms_init()
1232 serio->dev.parent = up->port.dev; in sunsu_kbd_ms_init()
1237 sunsu_change_speed(&up->port, up->cflag, 0, quot); in sunsu_kbd_ms_init()
1239 sunsu_startup(&up->port); in sunsu_kbd_ms_init()
1254 static void wait_for_xmitr(struct uart_sunsu_port *up) in wait_for_xmitr() argument
1260 status = serial_in(up, UART_LSR); in wait_for_xmitr()
1263 up->lsr_break_flag = UART_LSR_BI; in wait_for_xmitr()
1271 if (up->port.flags & UPF_CONS_FLOW) { in wait_for_xmitr()
1274 ((serial_in(up, UART_MSR) & UART_MSR_CTS) == 0)) in wait_for_xmitr()
1281 struct uart_sunsu_port *up = in sunsu_console_putchar() local
1284 wait_for_xmitr(up); in sunsu_console_putchar()
1285 serial_out(up, UART_TX, ch); in sunsu_console_putchar()
1295 struct uart_sunsu_port *up = &sunsu_ports[co->index]; in sunsu_console_write() local
1300 if (up->port.sysrq || oops_in_progress) in sunsu_console_write()
1301 locked = spin_trylock_irqsave(&up->port.lock, flags); in sunsu_console_write()
1303 spin_lock_irqsave(&up->port.lock, flags); in sunsu_console_write()
1308 ier = serial_in(up, UART_IER); in sunsu_console_write()
1309 serial_out(up, UART_IER, 0); in sunsu_console_write()
1311 uart_console_write(&up->port, s, count, sunsu_console_putchar); in sunsu_console_write()
1317 wait_for_xmitr(up); in sunsu_console_write()
1318 serial_out(up, UART_IER, ier); in sunsu_console_write()
1321 spin_unlock_irqrestore(&up->port.lock, flags); in sunsu_console_write()
1427 struct uart_sunsu_port *up; in su_probe() local
1437 up = &sunsu_ports[nr_inst]; in su_probe()
1439 up = kzalloc(sizeof(*up), GFP_KERNEL); in su_probe()
1440 if (!up) in su_probe()
1444 up->port.line = nr_inst; in su_probe()
1446 spin_lock_init(&up->port.lock); in su_probe()
1448 up->su_type = type; in su_probe()
1451 up->port.mapbase = rp->start; in su_probe()
1452 up->reg_size = resource_size(rp); in su_probe()
1453 up->port.membase = of_ioremap(rp, 0, up->reg_size, "su"); in su_probe()
1454 if (!up->port.membase) { in su_probe()
1456 kfree(up); in su_probe()
1460 up->port.irq = op->archdata.irqs[0]; in su_probe()
1462 up->port.dev = &op->dev; in su_probe()
1464 up->port.type = PORT_UNKNOWN; in su_probe()
1465 up->port.uartclk = (SU_BASE_BAUD * 16); in su_probe()
1466 up->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNSU_CONSOLE); in su_probe()
1469 if (up->su_type == SU_PORT_KBD || up->su_type == SU_PORT_MS) { in su_probe()
1470 err = sunsu_kbd_ms_init(up); in su_probe()
1473 up->port.membase, up->reg_size); in su_probe()
1474 kfree(up); in su_probe()
1477 platform_set_drvdata(op, up); in su_probe()
1484 up->port.flags |= UPF_BOOT_AUTOCONF; in su_probe()
1486 sunsu_autoconfig(up); in su_probe()
1489 if (up->port.type == PORT_UNKNOWN) in su_probe()
1492 up->port.ops = &sunsu_pops; in su_probe()
1500 &sunsu_reg, up->port.line, in su_probe()
1502 err = uart_add_one_port(&sunsu_reg, &up->port); in su_probe()
1506 platform_set_drvdata(op, up); in su_probe()
1513 of_iounmap(&op->resource[0], up->port.membase, up->reg_size); in su_probe()
1514 kfree(up); in su_probe()
1520 struct uart_sunsu_port *up = platform_get_drvdata(op); in su_remove() local
1523 if (up->su_type == SU_PORT_MS || in su_remove()
1524 up->su_type == SU_PORT_KBD) in su_remove()
1529 serio_unregister_port(&up->serio); in su_remove()
1531 } else if (up->port.type != PORT_UNKNOWN) in su_remove()
1532 uart_remove_one_port(&sunsu_reg, &up->port); in su_remove()
1534 if (up->port.membase) in su_remove()
1535 of_iounmap(&op->resource[0], up->port.membase, up->reg_size); in su_remove()
1538 kfree(up); in su_remove()