Lines Matching full:up

52 static inline unsigned int serial_in(struct uart_pxa_port *up, int offset)  in serial_in()  argument
55 return readl(up->port.membase + offset); in serial_in()
58 static inline void serial_out(struct uart_pxa_port *up, int offset, int value) in serial_out() argument
61 writel(value, up->port.membase + offset); in serial_out()
66 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_enable_ms() local
68 up->ier |= UART_IER_MSI; in serial_pxa_enable_ms()
69 serial_out(up, UART_IER, up->ier); in serial_pxa_enable_ms()
74 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_stop_tx() local
76 if (up->ier & UART_IER_THRI) { in serial_pxa_stop_tx()
77 up->ier &= ~UART_IER_THRI; in serial_pxa_stop_tx()
78 serial_out(up, UART_IER, up->ier); in serial_pxa_stop_tx()
84 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_stop_rx() local
86 up->ier &= ~UART_IER_RLSI; in serial_pxa_stop_rx()
87 up->port.read_status_mask &= ~UART_LSR_DR; in serial_pxa_stop_rx()
88 serial_out(up, UART_IER, up->ier); in serial_pxa_stop_rx()
91 static inline void receive_chars(struct uart_pxa_port *up, int *status) in receive_chars() argument
104 up->ier &= ~UART_IER_RTOIE; in receive_chars()
105 serial_out(up, UART_IER, up->ier); in receive_chars()
107 ch = serial_in(up, UART_RX); in receive_chars()
109 up->port.icount.rx++; in receive_chars()
118 up->port.icount.brk++; in receive_chars()
125 if (uart_handle_break(&up->port)) in receive_chars()
128 up->port.icount.parity++; in receive_chars()
130 up->port.icount.frame++; in receive_chars()
132 up->port.icount.overrun++; in receive_chars()
137 *status &= up->port.read_status_mask; in receive_chars()
140 if (up->port.line == up->port.cons->index) { in receive_chars()
142 *status |= up->lsr_break_flag; in receive_chars()
143 up->lsr_break_flag = 0; in receive_chars()
154 if (uart_prepare_sysrq_char(&up->port, ch)) in receive_chars()
157 uart_insert_char(&up->port, *status, UART_LSR_OE, ch, flag); in receive_chars()
160 *status = serial_in(up, UART_LSR); in receive_chars()
162 tty_flip_buffer_push(&up->port.state->port); in receive_chars()
171 up->ier |= UART_IER_RTOIE; in receive_chars()
172 serial_out(up, UART_IER, up->ier); in receive_chars()
175 static void transmit_chars(struct uart_pxa_port *up) in transmit_chars() argument
179 uart_port_tx_limited(&up->port, ch, up->port.fifosize / 2, in transmit_chars()
181 serial_out(up, UART_TX, ch), in transmit_chars()
187 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_start_tx() local
189 if (!(up->ier & UART_IER_THRI)) { in serial_pxa_start_tx()
190 up->ier |= UART_IER_THRI; in serial_pxa_start_tx()
191 serial_out(up, UART_IER, up->ier); in serial_pxa_start_tx()
195 /* should hold up->port.lock */
196 static inline void check_modem_status(struct uart_pxa_port *up) in check_modem_status() argument
200 status = serial_in(up, UART_MSR); in check_modem_status()
206 up->port.icount.rng++; in check_modem_status()
208 up->port.icount.dsr++; in check_modem_status()
210 uart_handle_dcd_change(&up->port, status & UART_MSR_DCD); in check_modem_status()
212 uart_handle_cts_change(&up->port, status & UART_MSR_CTS); in check_modem_status()
214 wake_up_interruptible(&up->port.state->port.delta_msr_wait); in check_modem_status()
222 struct uart_pxa_port *up = dev_id; in serial_pxa_irq() local
225 iir = serial_in(up, UART_IIR); in serial_pxa_irq()
228 uart_port_lock(&up->port); in serial_pxa_irq()
229 lsr = serial_in(up, UART_LSR); in serial_pxa_irq()
231 receive_chars(up, &lsr); in serial_pxa_irq()
232 check_modem_status(up); in serial_pxa_irq()
234 transmit_chars(up); in serial_pxa_irq()
235 uart_unlock_and_check_sysrq(&up->port); in serial_pxa_irq()
241 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_tx_empty() local
245 uart_port_lock_irqsave(&up->port, &flags); in serial_pxa_tx_empty()
246 ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0; in serial_pxa_tx_empty()
247 uart_port_unlock_irqrestore(&up->port, flags); in serial_pxa_tx_empty()
254 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_get_mctrl() local
258 status = serial_in(up, UART_MSR); in serial_pxa_get_mctrl()
274 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_set_mctrl() local
288 mcr |= up->mcr; in serial_pxa_set_mctrl()
290 serial_out(up, UART_MCR, mcr); in serial_pxa_set_mctrl()
295 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_break_ctl() local
298 uart_port_lock_irqsave(&up->port, &flags); in serial_pxa_break_ctl()
300 up->lcr |= UART_LCR_SBC; in serial_pxa_break_ctl()
302 up->lcr &= ~UART_LCR_SBC; in serial_pxa_break_ctl()
303 serial_out(up, UART_LCR, up->lcr); in serial_pxa_break_ctl()
304 uart_port_unlock_irqrestore(&up->port, flags); in serial_pxa_break_ctl()
309 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_startup() local
314 up->mcr |= UART_MCR_AFE; in serial_pxa_startup()
316 up->mcr = 0; in serial_pxa_startup()
318 up->port.uartclk = clk_get_rate(up->clk); in serial_pxa_startup()
323 retval = request_irq(up->port.irq, serial_pxa_irq, 0, up->name, up); in serial_pxa_startup()
331 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in serial_pxa_startup()
332 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in serial_pxa_startup()
334 serial_out(up, UART_FCR, 0); in serial_pxa_startup()
339 (void) serial_in(up, UART_LSR); in serial_pxa_startup()
340 (void) serial_in(up, UART_RX); in serial_pxa_startup()
341 (void) serial_in(up, UART_IIR); in serial_pxa_startup()
342 (void) serial_in(up, UART_MSR); in serial_pxa_startup()
347 serial_out(up, UART_LCR, UART_LCR_WLEN8); in serial_pxa_startup()
349 uart_port_lock_irqsave(&up->port, &flags); in serial_pxa_startup()
350 up->port.mctrl |= TIOCM_OUT2; in serial_pxa_startup()
351 serial_pxa_set_mctrl(&up->port, up->port.mctrl); in serial_pxa_startup()
352 uart_port_unlock_irqrestore(&up->port, flags); in serial_pxa_startup()
359 up->ier = UART_IER_RLSI | UART_IER_RDI | UART_IER_RTOIE | UART_IER_UUE; in serial_pxa_startup()
360 serial_out(up, UART_IER, up->ier); in serial_pxa_startup()
365 (void) serial_in(up, UART_LSR); in serial_pxa_startup()
366 (void) serial_in(up, UART_RX); in serial_pxa_startup()
367 (void) serial_in(up, UART_IIR); in serial_pxa_startup()
368 (void) serial_in(up, UART_MSR); in serial_pxa_startup()
375 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_shutdown() local
378 free_irq(up->port.irq, up); in serial_pxa_shutdown()
383 up->ier = 0; in serial_pxa_shutdown()
384 serial_out(up, UART_IER, 0); in serial_pxa_shutdown()
386 uart_port_lock_irqsave(&up->port, &flags); in serial_pxa_shutdown()
387 up->port.mctrl &= ~TIOCM_OUT2; in serial_pxa_shutdown()
388 serial_pxa_set_mctrl(&up->port, up->port.mctrl); in serial_pxa_shutdown()
389 uart_port_unlock_irqrestore(&up->port, flags); in serial_pxa_shutdown()
394 serial_out(up, UART_LCR, serial_in(up, UART_LCR) & ~UART_LCR_SBC); in serial_pxa_shutdown()
395 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in serial_pxa_shutdown()
398 serial_out(up, UART_FCR, 0); in serial_pxa_shutdown()
405 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_set_termios() local
426 if ((up->port.uartclk / quot) < (2400 * 16)) in serial_pxa_set_termios()
428 else if ((up->port.uartclk / quot) < (230400 * 16)) in serial_pxa_set_termios()
437 uart_port_lock_irqsave(&up->port, &flags); in serial_pxa_set_termios()
443 up->ier |= UART_IER_UUE; in serial_pxa_set_termios()
450 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; in serial_pxa_set_termios()
452 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; in serial_pxa_set_termios()
454 up->port.read_status_mask |= UART_LSR_BI; in serial_pxa_set_termios()
459 up->port.ignore_status_mask = 0; in serial_pxa_set_termios()
461 up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE; in serial_pxa_set_termios()
463 up->port.ignore_status_mask |= UART_LSR_BI; in serial_pxa_set_termios()
469 up->port.ignore_status_mask |= UART_LSR_OE; in serial_pxa_set_termios()
476 up->port.ignore_status_mask |= UART_LSR_DR; in serial_pxa_set_termios()
481 up->ier &= ~UART_IER_MSI; in serial_pxa_set_termios()
482 if (UART_ENABLE_MS(&up->port, termios->c_cflag)) in serial_pxa_set_termios()
483 up->ier |= UART_IER_MSI; in serial_pxa_set_termios()
485 serial_out(up, UART_IER, up->ier); in serial_pxa_set_termios()
488 up->mcr |= UART_MCR_AFE; in serial_pxa_set_termios()
490 up->mcr &= ~UART_MCR_AFE; in serial_pxa_set_termios()
492 serial_out(up, UART_LCR, cval | UART_LCR_DLAB); /* set DLAB */ in serial_pxa_set_termios()
493 serial_out(up, UART_DLL, quot & 0xff); /* LS of divisor */ in serial_pxa_set_termios()
499 dll = serial_in(up, UART_DLL); in serial_pxa_set_termios()
502 serial_out(up, UART_DLM, quot >> 8); /* MS of divisor */ in serial_pxa_set_termios()
503 serial_out(up, UART_LCR, cval); /* reset DLAB */ in serial_pxa_set_termios()
504 up->lcr = cval; /* Save LCR */ in serial_pxa_set_termios()
505 serial_pxa_set_mctrl(&up->port, up->port.mctrl); in serial_pxa_set_termios()
506 serial_out(up, UART_FCR, fcr); in serial_pxa_set_termios()
507 uart_port_unlock_irqrestore(&up->port, flags); in serial_pxa_set_termios()
514 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_pm() local
517 clk_prepare_enable(up->clk); in serial_pxa_pm()
519 clk_disable_unprepare(up->clk); in serial_pxa_pm()
533 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_config_port() local
534 up->port.type = PORT_PXA; in serial_pxa_config_port()
547 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_type() local
548 return up->name; in serial_pxa_type()
559 static void wait_for_xmitr(struct uart_pxa_port *up) in wait_for_xmitr() argument
563 /* Wait up to 10ms for the character(s) to be sent. */ in wait_for_xmitr()
565 status = serial_in(up, UART_LSR); in wait_for_xmitr()
568 up->lsr_break_flag = UART_LSR_BI; in wait_for_xmitr()
575 /* Wait up to 1s for flow control if necessary */ in wait_for_xmitr()
576 if (up->port.flags & UPF_CONS_FLOW) { in wait_for_xmitr()
579 ((serial_in(up, UART_MSR) & UART_MSR_CTS) == 0)) in wait_for_xmitr()
586 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_console_putchar() local
588 wait_for_xmitr(up); in serial_pxa_console_putchar()
589 serial_out(up, UART_TX, ch); in serial_pxa_console_putchar()
601 struct uart_pxa_port *up = serial_pxa_ports[co->index]; in serial_pxa_console_write() local
606 clk_enable(up->clk); in serial_pxa_console_write()
608 locked = uart_port_trylock_irqsave(&up->port, &flags); in serial_pxa_console_write()
610 uart_port_lock_irqsave(&up->port, &flags); in serial_pxa_console_write()
615 ier = serial_in(up, UART_IER); in serial_pxa_console_write()
616 serial_out(up, UART_IER, UART_IER_UUE); in serial_pxa_console_write()
618 uart_console_write(&up->port, s, count, serial_pxa_console_putchar); in serial_pxa_console_write()
624 wait_for_xmitr(up); in serial_pxa_console_write()
625 serial_out(up, UART_IER, ier); in serial_pxa_console_write()
628 uart_port_unlock_irqrestore(&up->port, flags); in serial_pxa_console_write()
629 clk_disable(up->clk); in serial_pxa_console_write()
640 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_get_poll_char() local
641 unsigned char lsr = serial_in(up, UART_LSR); in serial_pxa_get_poll_char()
644 lsr = serial_in(up, UART_LSR); in serial_pxa_get_poll_char()
646 return serial_in(up, UART_RX); in serial_pxa_get_poll_char()
654 struct uart_pxa_port *up = (struct uart_pxa_port *)port; in serial_pxa_put_poll_char() local
659 ier = serial_in(up, UART_IER); in serial_pxa_put_poll_char()
660 serial_out(up, UART_IER, UART_IER_UUE); in serial_pxa_put_poll_char()
662 wait_for_xmitr(up); in serial_pxa_put_poll_char()
666 serial_out(up, UART_TX, c); in serial_pxa_put_poll_char()
672 wait_for_xmitr(up); in serial_pxa_put_poll_char()
673 serial_out(up, UART_IER, ier); in serial_pxa_put_poll_char()
681 struct uart_pxa_port *up; in serial_pxa_console_setup() local
689 up = serial_pxa_ports[co->index]; in serial_pxa_console_setup()
690 if (!up) in serial_pxa_console_setup()
696 return uart_set_options(&up->port, co, baud, parity, bits, flow); in serial_pxa_console_setup()