• Home
  • Raw
  • Download

Lines Matching refs:up

180 static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1);
182 static inline unsigned int serial_in(struct uart_omap_port *up, int offset) in serial_in() argument
184 offset <<= up->port.regshift; in serial_in()
185 return readw(up->port.membase + offset); in serial_in()
188 static inline void serial_out(struct uart_omap_port *up, int offset, int value) in serial_out() argument
190 offset <<= up->port.regshift; in serial_out()
191 writew(value, up->port.membase + offset); in serial_out()
194 static inline void serial_omap_clear_fifos(struct uart_omap_port *up) in serial_omap_clear_fifos() argument
196 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in serial_omap_clear_fifos()
197 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in serial_omap_clear_fifos()
199 serial_out(up, UART_FCR, 0); in serial_omap_clear_fifos()
203 static int serial_omap_get_context_loss_count(struct uart_omap_port *up) in serial_omap_get_context_loss_count() argument
205 struct omap_uart_port_info *pdata = dev_get_platdata(up->dev); in serial_omap_get_context_loss_count()
210 return pdata->get_context_loss_count(up->dev); in serial_omap_get_context_loss_count()
214 static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable) in serial_omap_enable_wakeup() argument
216 struct omap_uart_port_info *pdata = dev_get_platdata(up->dev); in serial_omap_enable_wakeup()
221 pdata->enable_wakeup(up->dev, enable); in serial_omap_enable_wakeup()
284 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_enable_ms() local
286 dev_dbg(up->port.dev, "serial_omap_enable_ms+%d\n", up->port.line); in serial_omap_enable_ms()
288 pm_runtime_get_sync(up->dev); in serial_omap_enable_ms()
289 up->ier |= UART_IER_MSI; in serial_omap_enable_ms()
290 serial_out(up, UART_IER, up->ier); in serial_omap_enable_ms()
291 pm_runtime_mark_last_busy(up->dev); in serial_omap_enable_ms()
292 pm_runtime_put_autosuspend(up->dev); in serial_omap_enable_ms()
297 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_stop_tx() local
300 pm_runtime_get_sync(up->dev); in serial_omap_stop_tx()
304 if (up->scr & OMAP_UART_SCR_TX_EMPTY) { in serial_omap_stop_tx()
312 up->scr &= ~OMAP_UART_SCR_TX_EMPTY; in serial_omap_stop_tx()
313 serial_out(up, UART_OMAP_SCR, up->scr); in serial_omap_stop_tx()
316 if (gpio_get_value(up->rts_gpio) != res) { in serial_omap_stop_tx()
320 gpio_set_value(up->rts_gpio, res); in serial_omap_stop_tx()
331 up->scr |= OMAP_UART_SCR_TX_EMPTY; in serial_omap_stop_tx()
332 serial_out(up, UART_OMAP_SCR, up->scr); in serial_omap_stop_tx()
337 if (up->ier & UART_IER_THRI) { in serial_omap_stop_tx()
338 up->ier &= ~UART_IER_THRI; in serial_omap_stop_tx()
339 serial_out(up, UART_IER, up->ier); in serial_omap_stop_tx()
348 serial_out(up, UART_FCR, up->fcr | UART_FCR_CLEAR_RCVR); in serial_omap_stop_tx()
350 up->ier |= UART_IER_RLSI | UART_IER_RDI; in serial_omap_stop_tx()
351 up->port.read_status_mask |= UART_LSR_DR; in serial_omap_stop_tx()
352 serial_out(up, UART_IER, up->ier); in serial_omap_stop_tx()
355 pm_runtime_mark_last_busy(up->dev); in serial_omap_stop_tx()
356 pm_runtime_put_autosuspend(up->dev); in serial_omap_stop_tx()
361 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_stop_rx() local
363 pm_runtime_get_sync(up->dev); in serial_omap_stop_rx()
364 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); in serial_omap_stop_rx()
365 up->port.read_status_mask &= ~UART_LSR_DR; in serial_omap_stop_rx()
366 serial_out(up, UART_IER, up->ier); in serial_omap_stop_rx()
367 pm_runtime_mark_last_busy(up->dev); in serial_omap_stop_rx()
368 pm_runtime_put_autosuspend(up->dev); in serial_omap_stop_rx()
371 static void transmit_chars(struct uart_omap_port *up, unsigned int lsr) in transmit_chars() argument
373 struct circ_buf *xmit = &up->port.state->xmit; in transmit_chars()
376 if (up->port.x_char) { in transmit_chars()
377 serial_out(up, UART_TX, up->port.x_char); in transmit_chars()
378 up->port.icount.tx++; in transmit_chars()
379 up->port.x_char = 0; in transmit_chars()
382 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) { in transmit_chars()
383 serial_omap_stop_tx(&up->port); in transmit_chars()
386 count = up->port.fifosize / 4; in transmit_chars()
388 serial_out(up, UART_TX, xmit->buf[xmit->tail]); in transmit_chars()
390 up->port.icount.tx++; in transmit_chars()
396 uart_write_wakeup(&up->port); in transmit_chars()
399 serial_omap_stop_tx(&up->port); in transmit_chars()
402 static inline void serial_omap_enable_ier_thri(struct uart_omap_port *up) in serial_omap_enable_ier_thri() argument
404 if (!(up->ier & UART_IER_THRI)) { in serial_omap_enable_ier_thri()
405 up->ier |= UART_IER_THRI; in serial_omap_enable_ier_thri()
406 serial_out(up, UART_IER, up->ier); in serial_omap_enable_ier_thri()
412 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_start_tx() local
415 pm_runtime_get_sync(up->dev); in serial_omap_start_tx()
420 up->scr &= ~OMAP_UART_SCR_TX_EMPTY; in serial_omap_start_tx()
421 serial_out(up, UART_OMAP_SCR, up->scr); in serial_omap_start_tx()
425 if (gpio_get_value(up->rts_gpio) != res) { in serial_omap_start_tx()
426 gpio_set_value(up->rts_gpio, res); in serial_omap_start_tx()
436 serial_omap_enable_ier_thri(up); in serial_omap_start_tx()
437 pm_runtime_mark_last_busy(up->dev); in serial_omap_start_tx()
438 pm_runtime_put_autosuspend(up->dev); in serial_omap_start_tx()
443 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_throttle() local
446 pm_runtime_get_sync(up->dev); in serial_omap_throttle()
447 spin_lock_irqsave(&up->port.lock, flags); in serial_omap_throttle()
448 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); in serial_omap_throttle()
449 serial_out(up, UART_IER, up->ier); in serial_omap_throttle()
450 spin_unlock_irqrestore(&up->port.lock, flags); in serial_omap_throttle()
451 pm_runtime_mark_last_busy(up->dev); in serial_omap_throttle()
452 pm_runtime_put_autosuspend(up->dev); in serial_omap_throttle()
457 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_unthrottle() local
460 pm_runtime_get_sync(up->dev); in serial_omap_unthrottle()
461 spin_lock_irqsave(&up->port.lock, flags); in serial_omap_unthrottle()
462 up->ier |= UART_IER_RLSI | UART_IER_RDI; in serial_omap_unthrottle()
463 serial_out(up, UART_IER, up->ier); in serial_omap_unthrottle()
464 spin_unlock_irqrestore(&up->port.lock, flags); in serial_omap_unthrottle()
465 pm_runtime_mark_last_busy(up->dev); in serial_omap_unthrottle()
466 pm_runtime_put_autosuspend(up->dev); in serial_omap_unthrottle()
469 static unsigned int check_modem_status(struct uart_omap_port *up) in check_modem_status() argument
473 status = serial_in(up, UART_MSR); in check_modem_status()
474 status |= up->msr_saved_flags; in check_modem_status()
475 up->msr_saved_flags = 0; in check_modem_status()
479 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI && in check_modem_status()
480 up->port.state != NULL) { in check_modem_status()
482 up->port.icount.rng++; in check_modem_status()
484 up->port.icount.dsr++; in check_modem_status()
487 (&up->port, status & UART_MSR_DCD); in check_modem_status()
490 (&up->port, status & UART_MSR_CTS); in check_modem_status()
491 wake_up_interruptible(&up->port.state->port.delta_msr_wait); in check_modem_status()
497 static void serial_omap_rlsi(struct uart_omap_port *up, unsigned int lsr) in serial_omap_rlsi() argument
503 ch = serial_in(up, UART_RX); in serial_omap_rlsi()
505 up->port.icount.rx++; in serial_omap_rlsi()
511 up->port.icount.brk++; in serial_omap_rlsi()
518 if (uart_handle_break(&up->port)) in serial_omap_rlsi()
525 up->port.icount.parity++; in serial_omap_rlsi()
530 up->port.icount.frame++; in serial_omap_rlsi()
534 up->port.icount.overrun++; in serial_omap_rlsi()
537 if (up->port.line == up->port.cons->index) { in serial_omap_rlsi()
539 lsr |= up->lsr_break_flag; in serial_omap_rlsi()
542 uart_insert_char(&up->port, lsr, UART_LSR_OE, 0, flag); in serial_omap_rlsi()
545 static void serial_omap_rdi(struct uart_omap_port *up, unsigned int lsr) in serial_omap_rdi() argument
553 ch = serial_in(up, UART_RX); in serial_omap_rdi()
555 up->port.icount.rx++; in serial_omap_rdi()
557 if (uart_handle_sysrq_char(&up->port, ch)) in serial_omap_rdi()
560 uart_insert_char(&up->port, lsr, UART_LSR_OE, ch, flag); in serial_omap_rdi()
570 struct uart_omap_port *up = dev_id; in serial_omap_irq() local
576 spin_lock(&up->port.lock); in serial_omap_irq()
577 pm_runtime_get_sync(up->dev); in serial_omap_irq()
580 iir = serial_in(up, UART_IIR); in serial_omap_irq()
585 lsr = serial_in(up, UART_LSR); in serial_omap_irq()
592 check_modem_status(up); in serial_omap_irq()
595 transmit_chars(up, lsr); in serial_omap_irq()
600 serial_omap_rdi(up, lsr); in serial_omap_irq()
603 serial_omap_rlsi(up, lsr); in serial_omap_irq()
615 spin_unlock(&up->port.lock); in serial_omap_irq()
617 tty_flip_buffer_push(&up->port.state->port); in serial_omap_irq()
619 pm_runtime_mark_last_busy(up->dev); in serial_omap_irq()
620 pm_runtime_put_autosuspend(up->dev); in serial_omap_irq()
621 up->port_activity = jiffies; in serial_omap_irq()
628 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_tx_empty() local
632 pm_runtime_get_sync(up->dev); in serial_omap_tx_empty()
633 dev_dbg(up->port.dev, "serial_omap_tx_empty+%d\n", up->port.line); in serial_omap_tx_empty()
634 spin_lock_irqsave(&up->port.lock, flags); in serial_omap_tx_empty()
635 ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0; in serial_omap_tx_empty()
636 spin_unlock_irqrestore(&up->port.lock, flags); in serial_omap_tx_empty()
637 pm_runtime_mark_last_busy(up->dev); in serial_omap_tx_empty()
638 pm_runtime_put_autosuspend(up->dev); in serial_omap_tx_empty()
644 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_get_mctrl() local
648 pm_runtime_get_sync(up->dev); in serial_omap_get_mctrl()
649 status = check_modem_status(up); in serial_omap_get_mctrl()
650 pm_runtime_mark_last_busy(up->dev); in serial_omap_get_mctrl()
651 pm_runtime_put_autosuspend(up->dev); in serial_omap_get_mctrl()
653 dev_dbg(up->port.dev, "serial_omap_get_mctrl+%d\n", up->port.line); in serial_omap_get_mctrl()
668 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_set_mctrl() local
671 dev_dbg(up->port.dev, "serial_omap_set_mctrl+%d\n", up->port.line); in serial_omap_set_mctrl()
683 pm_runtime_get_sync(up->dev); in serial_omap_set_mctrl()
684 old_mcr = serial_in(up, UART_MCR); in serial_omap_set_mctrl()
687 up->mcr = old_mcr | mcr; in serial_omap_set_mctrl()
688 serial_out(up, UART_MCR, up->mcr); in serial_omap_set_mctrl()
691 lcr = serial_in(up, UART_LCR); in serial_omap_set_mctrl()
692 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_mctrl()
694 up->efr |= UART_EFR_RTS; in serial_omap_set_mctrl()
696 up->efr &= ~UART_EFR_RTS; in serial_omap_set_mctrl()
697 serial_out(up, UART_EFR, up->efr); in serial_omap_set_mctrl()
698 serial_out(up, UART_LCR, lcr); in serial_omap_set_mctrl()
700 pm_runtime_mark_last_busy(up->dev); in serial_omap_set_mctrl()
701 pm_runtime_put_autosuspend(up->dev); in serial_omap_set_mctrl()
706 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_break_ctl() local
709 dev_dbg(up->port.dev, "serial_omap_break_ctl+%d\n", up->port.line); in serial_omap_break_ctl()
710 pm_runtime_get_sync(up->dev); in serial_omap_break_ctl()
711 spin_lock_irqsave(&up->port.lock, flags); in serial_omap_break_ctl()
713 up->lcr |= UART_LCR_SBC; in serial_omap_break_ctl()
715 up->lcr &= ~UART_LCR_SBC; in serial_omap_break_ctl()
716 serial_out(up, UART_LCR, up->lcr); in serial_omap_break_ctl()
717 spin_unlock_irqrestore(&up->port.lock, flags); in serial_omap_break_ctl()
718 pm_runtime_mark_last_busy(up->dev); in serial_omap_break_ctl()
719 pm_runtime_put_autosuspend(up->dev); in serial_omap_break_ctl()
724 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_startup() local
731 retval = request_irq(up->port.irq, serial_omap_irq, up->port.irqflags, in serial_omap_startup()
732 up->name, up); in serial_omap_startup()
737 if (up->wakeirq) { in serial_omap_startup()
738 retval = dev_pm_set_dedicated_wake_irq(up->dev, up->wakeirq); in serial_omap_startup()
740 free_irq(up->port.irq, up); in serial_omap_startup()
745 dev_dbg(up->port.dev, "serial_omap_startup+%d\n", up->port.line); in serial_omap_startup()
747 pm_runtime_get_sync(up->dev); in serial_omap_startup()
752 serial_omap_clear_fifos(up); in serial_omap_startup()
757 (void) serial_in(up, UART_LSR); in serial_omap_startup()
758 if (serial_in(up, UART_LSR) & UART_LSR_DR) in serial_omap_startup()
759 (void) serial_in(up, UART_RX); in serial_omap_startup()
760 (void) serial_in(up, UART_IIR); in serial_omap_startup()
761 (void) serial_in(up, UART_MSR); in serial_omap_startup()
766 serial_out(up, UART_LCR, UART_LCR_WLEN8); in serial_omap_startup()
767 spin_lock_irqsave(&up->port.lock, flags); in serial_omap_startup()
771 up->port.mctrl |= TIOCM_OUT2; in serial_omap_startup()
772 serial_omap_set_mctrl(&up->port, up->port.mctrl); in serial_omap_startup()
773 spin_unlock_irqrestore(&up->port.lock, flags); in serial_omap_startup()
775 up->msr_saved_flags = 0; in serial_omap_startup()
781 up->ier = UART_IER_RLSI | UART_IER_RDI; in serial_omap_startup()
782 serial_out(up, UART_IER, up->ier); in serial_omap_startup()
785 up->wer = OMAP_UART_WER_MOD_WKUP; in serial_omap_startup()
786 if (up->features & OMAP_UART_WER_HAS_TX_WAKEUP) in serial_omap_startup()
787 up->wer |= OMAP_UART_TX_WAKEUP_EN; in serial_omap_startup()
789 serial_out(up, UART_OMAP_WER, up->wer); in serial_omap_startup()
791 pm_runtime_mark_last_busy(up->dev); in serial_omap_startup()
792 pm_runtime_put_autosuspend(up->dev); in serial_omap_startup()
793 up->port_activity = jiffies; in serial_omap_startup()
799 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_shutdown() local
802 dev_dbg(up->port.dev, "serial_omap_shutdown+%d\n", up->port.line); in serial_omap_shutdown()
804 pm_runtime_get_sync(up->dev); in serial_omap_shutdown()
808 up->ier = 0; in serial_omap_shutdown()
809 serial_out(up, UART_IER, 0); in serial_omap_shutdown()
811 spin_lock_irqsave(&up->port.lock, flags); in serial_omap_shutdown()
812 up->port.mctrl &= ~TIOCM_OUT2; in serial_omap_shutdown()
813 serial_omap_set_mctrl(&up->port, up->port.mctrl); in serial_omap_shutdown()
814 spin_unlock_irqrestore(&up->port.lock, flags); in serial_omap_shutdown()
819 serial_out(up, UART_LCR, serial_in(up, UART_LCR) & ~UART_LCR_SBC); in serial_omap_shutdown()
820 serial_omap_clear_fifos(up); in serial_omap_shutdown()
825 if (serial_in(up, UART_LSR) & UART_LSR_DR) in serial_omap_shutdown()
826 (void) serial_in(up, UART_RX); in serial_omap_shutdown()
828 pm_runtime_mark_last_busy(up->dev); in serial_omap_shutdown()
829 pm_runtime_put_autosuspend(up->dev); in serial_omap_shutdown()
830 free_irq(up->port.irq, up); in serial_omap_shutdown()
831 dev_pm_clear_wake_irq(up->dev); in serial_omap_shutdown()
836 struct uart_omap_port *up = container_of(work, struct uart_omap_port, in serial_omap_uart_qos_work() local
839 pm_qos_update_request(&up->pm_qos_request, up->latency); in serial_omap_uart_qos_work()
846 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_set_termios() local
884 up->calc_latency = (USEC_PER_SEC * up->port.fifosize) / (baud / 8); in serial_omap_set_termios()
885 up->latency = up->calc_latency; in serial_omap_set_termios()
886 schedule_work(&up->qos_work); in serial_omap_set_termios()
888 up->dll = quot & 0xff; in serial_omap_set_termios()
889 up->dlh = quot >> 8; in serial_omap_set_termios()
890 up->mdr1 = UART_OMAP_MDR1_DISABLE; in serial_omap_set_termios()
892 up->fcr = UART_FCR_R_TRIG_01 | UART_FCR_T_TRIG_01 | in serial_omap_set_termios()
899 pm_runtime_get_sync(up->dev); in serial_omap_set_termios()
900 spin_lock_irqsave(&up->port.lock, flags); in serial_omap_set_termios()
907 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; in serial_omap_set_termios()
909 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; in serial_omap_set_termios()
911 up->port.read_status_mask |= UART_LSR_BI; in serial_omap_set_termios()
916 up->port.ignore_status_mask = 0; in serial_omap_set_termios()
918 up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE; in serial_omap_set_termios()
920 up->port.ignore_status_mask |= UART_LSR_BI; in serial_omap_set_termios()
926 up->port.ignore_status_mask |= UART_LSR_OE; in serial_omap_set_termios()
933 up->port.ignore_status_mask |= UART_LSR_DR; in serial_omap_set_termios()
938 up->ier &= ~UART_IER_MSI; in serial_omap_set_termios()
939 if (UART_ENABLE_MS(&up->port, termios->c_cflag)) in serial_omap_set_termios()
940 up->ier |= UART_IER_MSI; in serial_omap_set_termios()
941 serial_out(up, UART_IER, up->ier); in serial_omap_set_termios()
942 serial_out(up, UART_LCR, cval); /* reset DLAB */ in serial_omap_set_termios()
943 up->lcr = cval; in serial_omap_set_termios()
944 up->scr = 0; in serial_omap_set_termios()
952 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in serial_omap_set_termios()
953 serial_out(up, UART_DLL, 0); in serial_omap_set_termios()
954 serial_out(up, UART_DLM, 0); in serial_omap_set_termios()
955 serial_out(up, UART_LCR, 0); in serial_omap_set_termios()
957 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_termios()
959 up->efr = serial_in(up, UART_EFR) & ~UART_EFR_ECB; in serial_omap_set_termios()
960 up->efr &= ~UART_EFR_SCD; in serial_omap_set_termios()
961 serial_out(up, UART_EFR, up->efr | UART_EFR_ECB); in serial_omap_set_termios()
963 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in serial_omap_set_termios()
964 up->mcr = serial_in(up, UART_MCR) & ~UART_MCR_TCRTLR; in serial_omap_set_termios()
965 serial_out(up, UART_MCR, up->mcr | UART_MCR_TCRTLR); in serial_omap_set_termios()
968 up->scr |= OMAP_UART_SCR_RX_TRIG_GRANU1_MASK; in serial_omap_set_termios()
982 up->fcr &= ~OMAP_UART_FCR_RX_FIFO_TRIG_MASK; in serial_omap_set_termios()
983 up->fcr &= ~OMAP_UART_FCR_TX_FIFO_TRIG_MASK; in serial_omap_set_termios()
984 up->fcr |= UART_FCR6_R_TRIGGER_16 | UART_FCR6_T_TRIGGER_24 | in serial_omap_set_termios()
987 serial_out(up, UART_FCR, up->fcr); in serial_omap_set_termios()
988 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_termios()
990 serial_out(up, UART_OMAP_SCR, up->scr); in serial_omap_set_termios()
993 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in serial_omap_set_termios()
994 serial_out(up, UART_MCR, up->mcr); in serial_omap_set_termios()
995 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_termios()
996 serial_out(up, UART_EFR, up->efr); in serial_omap_set_termios()
997 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in serial_omap_set_termios()
1001 if (up->errata & UART_ERRATA_i202_MDR1_ACCESS) in serial_omap_set_termios()
1002 serial_omap_mdr1_errataset(up, up->mdr1); in serial_omap_set_termios()
1004 serial_out(up, UART_OMAP_MDR1, up->mdr1); in serial_omap_set_termios()
1006 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_termios()
1007 serial_out(up, UART_EFR, up->efr | UART_EFR_ECB); in serial_omap_set_termios()
1009 serial_out(up, UART_LCR, 0); in serial_omap_set_termios()
1010 serial_out(up, UART_IER, 0); in serial_omap_set_termios()
1011 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_termios()
1013 serial_out(up, UART_DLL, up->dll); /* LS of divisor */ in serial_omap_set_termios()
1014 serial_out(up, UART_DLM, up->dlh); /* MS of divisor */ in serial_omap_set_termios()
1016 serial_out(up, UART_LCR, 0); in serial_omap_set_termios()
1017 serial_out(up, UART_IER, up->ier); in serial_omap_set_termios()
1018 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_termios()
1020 serial_out(up, UART_EFR, up->efr); in serial_omap_set_termios()
1021 serial_out(up, UART_LCR, cval); in serial_omap_set_termios()
1024 up->mdr1 = UART_OMAP_MDR1_13X_MODE; in serial_omap_set_termios()
1026 up->mdr1 = UART_OMAP_MDR1_16X_MODE; in serial_omap_set_termios()
1028 if (up->errata & UART_ERRATA_i202_MDR1_ACCESS) in serial_omap_set_termios()
1029 serial_omap_mdr1_errataset(up, up->mdr1); in serial_omap_set_termios()
1031 serial_out(up, UART_OMAP_MDR1, up->mdr1); in serial_omap_set_termios()
1034 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_termios()
1037 serial_out(up, UART_XON1, termios->c_cc[VSTART]); in serial_omap_set_termios()
1038 serial_out(up, UART_XOFF1, termios->c_cc[VSTOP]); in serial_omap_set_termios()
1041 serial_out(up, UART_EFR, up->efr | UART_EFR_ECB); in serial_omap_set_termios()
1042 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in serial_omap_set_termios()
1043 serial_out(up, UART_MCR, up->mcr | UART_MCR_TCRTLR); in serial_omap_set_termios()
1045 serial_out(up, UART_TI752_TCR, OMAP_UART_TCR_TRIG); in serial_omap_set_termios()
1047 up->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF); in serial_omap_set_termios()
1049 if (termios->c_cflag & CRTSCTS && up->port.flags & UPF_HARD_FLOW) { in serial_omap_set_termios()
1051 up->port.status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; in serial_omap_set_termios()
1052 up->efr |= UART_EFR_CTS; in serial_omap_set_termios()
1055 up->efr &= ~(UART_EFR_CTS | UART_EFR_RTS); in serial_omap_set_termios()
1058 if (up->port.flags & UPF_SOFT_FLOW) { in serial_omap_set_termios()
1060 up->efr &= OMAP_UART_SW_CLR; in serial_omap_set_termios()
1068 up->efr |= OMAP_UART_SW_RX; in serial_omap_set_termios()
1076 up->port.status |= UPSTAT_AUTOXOFF; in serial_omap_set_termios()
1077 up->efr |= OMAP_UART_SW_TX; in serial_omap_set_termios()
1087 up->mcr |= UART_MCR_XONANY; in serial_omap_set_termios()
1089 up->mcr &= ~UART_MCR_XONANY; in serial_omap_set_termios()
1091 serial_out(up, UART_MCR, up->mcr); in serial_omap_set_termios()
1092 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_set_termios()
1093 serial_out(up, UART_EFR, up->efr); in serial_omap_set_termios()
1094 serial_out(up, UART_LCR, up->lcr); in serial_omap_set_termios()
1096 serial_omap_set_mctrl(&up->port, up->port.mctrl); in serial_omap_set_termios()
1098 spin_unlock_irqrestore(&up->port.lock, flags); in serial_omap_set_termios()
1099 pm_runtime_mark_last_busy(up->dev); in serial_omap_set_termios()
1100 pm_runtime_put_autosuspend(up->dev); in serial_omap_set_termios()
1101 dev_dbg(up->port.dev, "serial_omap_set_termios+%d\n", up->port.line); in serial_omap_set_termios()
1108 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_pm() local
1111 dev_dbg(up->port.dev, "serial_omap_pm+%d\n", up->port.line); in serial_omap_pm()
1113 pm_runtime_get_sync(up->dev); in serial_omap_pm()
1114 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_pm()
1115 efr = serial_in(up, UART_EFR); in serial_omap_pm()
1116 serial_out(up, UART_EFR, efr | UART_EFR_ECB); in serial_omap_pm()
1117 serial_out(up, UART_LCR, 0); in serial_omap_pm()
1119 serial_out(up, UART_IER, (state != 0) ? UART_IERX_SLEEP : 0); in serial_omap_pm()
1120 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial_omap_pm()
1121 serial_out(up, UART_EFR, efr); in serial_omap_pm()
1122 serial_out(up, UART_LCR, 0); in serial_omap_pm()
1124 pm_runtime_mark_last_busy(up->dev); in serial_omap_pm()
1125 pm_runtime_put_autosuspend(up->dev); in serial_omap_pm()
1141 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_config_port() local
1143 dev_dbg(up->port.dev, "serial_omap_config_port+%d\n", in serial_omap_config_port()
1144 up->port.line); in serial_omap_config_port()
1145 up->port.type = PORT_OMAP; in serial_omap_config_port()
1146 up->port.flags |= UPF_SOFT_FLOW | UPF_HARD_FLOW; in serial_omap_config_port()
1160 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_type() local
1162 dev_dbg(up->port.dev, "serial_omap_type+%d\n", up->port.line); in serial_omap_type()
1163 return up->name; in serial_omap_type()
1168 static void __maybe_unused wait_for_xmitr(struct uart_omap_port *up) in wait_for_xmitr() argument
1174 status = serial_in(up, UART_LSR); in wait_for_xmitr()
1177 up->lsr_break_flag = UART_LSR_BI; in wait_for_xmitr()
1185 if (up->port.flags & UPF_CONS_FLOW) { in wait_for_xmitr()
1188 unsigned int msr = serial_in(up, UART_MSR); in wait_for_xmitr()
1190 up->msr_saved_flags |= msr & MSR_SAVE_FLAGS; in wait_for_xmitr()
1203 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_poll_put_char() local
1205 pm_runtime_get_sync(up->dev); in serial_omap_poll_put_char()
1206 wait_for_xmitr(up); in serial_omap_poll_put_char()
1207 serial_out(up, UART_TX, ch); in serial_omap_poll_put_char()
1208 pm_runtime_mark_last_busy(up->dev); in serial_omap_poll_put_char()
1209 pm_runtime_put_autosuspend(up->dev); in serial_omap_poll_put_char()
1214 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_poll_get_char() local
1217 pm_runtime_get_sync(up->dev); in serial_omap_poll_get_char()
1218 status = serial_in(up, UART_LSR); in serial_omap_poll_get_char()
1224 status = serial_in(up, UART_RX); in serial_omap_poll_get_char()
1227 pm_runtime_mark_last_busy(up->dev); in serial_omap_poll_get_char()
1228 pm_runtime_put_autosuspend(up->dev); in serial_omap_poll_get_char()
1243 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_console_putchar() local
1245 wait_for_xmitr(up); in serial_omap_console_putchar()
1246 serial_out(up, UART_TX, ch); in serial_omap_console_putchar()
1253 struct uart_omap_port *up = serial_omap_console_ports[co->index]; in serial_omap_console_write() local
1258 pm_runtime_get_sync(up->dev); in serial_omap_console_write()
1261 if (up->port.sysrq) in serial_omap_console_write()
1264 locked = spin_trylock(&up->port.lock); in serial_omap_console_write()
1266 spin_lock(&up->port.lock); in serial_omap_console_write()
1271 ier = serial_in(up, UART_IER); in serial_omap_console_write()
1272 serial_out(up, UART_IER, 0); in serial_omap_console_write()
1274 uart_console_write(&up->port, s, count, serial_omap_console_putchar); in serial_omap_console_write()
1280 wait_for_xmitr(up); in serial_omap_console_write()
1281 serial_out(up, UART_IER, ier); in serial_omap_console_write()
1289 if (up->msr_saved_flags) in serial_omap_console_write()
1290 check_modem_status(up); in serial_omap_console_write()
1292 pm_runtime_mark_last_busy(up->dev); in serial_omap_console_write()
1293 pm_runtime_put_autosuspend(up->dev); in serial_omap_console_write()
1295 spin_unlock(&up->port.lock); in serial_omap_console_write()
1302 struct uart_omap_port *up; in serial_omap_console_setup() local
1310 up = serial_omap_console_ports[co->index]; in serial_omap_console_setup()
1315 return uart_set_options(&up->port, co, baud, parity, bits, flow); in serial_omap_console_setup()
1328 static void serial_omap_add_console_port(struct uart_omap_port *up) in serial_omap_add_console_port() argument
1330 serial_omap_console_ports[up->port.line] = up; in serial_omap_add_console_port()
1339 static inline void serial_omap_add_console_port(struct uart_omap_port *up) in serial_omap_add_console_port() argument
1348 struct uart_omap_port *up = to_uart_omap_port(port); in serial_omap_config_rs485() local
1352 pm_runtime_get_sync(up->dev); in serial_omap_config_rs485()
1355 mode = up->ier; in serial_omap_config_rs485()
1356 up->ier = 0; in serial_omap_config_rs485()
1357 serial_out(up, UART_IER, 0); in serial_omap_config_rs485()
1370 if (gpio_is_valid(up->rts_gpio)) { in serial_omap_config_rs485()
1375 gpio_set_value(up->rts_gpio, val); in serial_omap_config_rs485()
1380 up->ier = mode; in serial_omap_config_rs485()
1381 serial_out(up, UART_IER, up->ier); in serial_omap_config_rs485()
1387 (up->scr & OMAP_UART_SCR_TX_EMPTY)) { in serial_omap_config_rs485()
1388 up->scr &= ~OMAP_UART_SCR_TX_EMPTY; in serial_omap_config_rs485()
1389 serial_out(up, UART_OMAP_SCR, up->scr); in serial_omap_config_rs485()
1392 pm_runtime_mark_last_busy(up->dev); in serial_omap_config_rs485()
1393 pm_runtime_put_autosuspend(up->dev); in serial_omap_config_rs485()
1435 struct uart_omap_port *up = dev_get_drvdata(dev); in serial_omap_prepare() local
1437 up->is_suspending = true; in serial_omap_prepare()
1444 struct uart_omap_port *up = dev_get_drvdata(dev); in serial_omap_complete() local
1446 up->is_suspending = false; in serial_omap_complete()
1451 struct uart_omap_port *up = dev_get_drvdata(dev); in serial_omap_suspend() local
1453 uart_suspend_port(&serial_omap_reg, &up->port); in serial_omap_suspend()
1454 flush_work(&up->qos_work); in serial_omap_suspend()
1457 serial_omap_enable_wakeup(up, true); in serial_omap_suspend()
1459 serial_omap_enable_wakeup(up, false); in serial_omap_suspend()
1466 struct uart_omap_port *up = dev_get_drvdata(dev); in serial_omap_resume() local
1469 serial_omap_enable_wakeup(up, false); in serial_omap_resume()
1471 uart_resume_port(&serial_omap_reg, &up->port); in serial_omap_resume()
1480 static void omap_serial_fill_features_erratas(struct uart_omap_port *up) in omap_serial_fill_features_erratas() argument
1485 mvr = readl(up->port.membase + (UART_OMAP_MVER << up->port.regshift)); in omap_serial_fill_features_erratas()
1505 dev_warn(up->dev, in omap_serial_fill_features_erratas()
1507 up->name); in omap_serial_fill_features_erratas()
1518 up->errata |= (UART_ERRATA_i202_MDR1_ACCESS | in omap_serial_fill_features_erratas()
1522 up->errata |= (UART_ERRATA_i202_MDR1_ACCESS | in omap_serial_fill_features_erratas()
1524 up->features |= OMAP_UART_WER_HAS_TX_WAKEUP; in omap_serial_fill_features_erratas()
1527 up->errata |= UART_ERRATA_i202_MDR1_ACCESS; in omap_serial_fill_features_erratas()
1528 up->features |= OMAP_UART_WER_HAS_TX_WAKEUP; in omap_serial_fill_features_erratas()
1548 static int serial_omap_probe_rs485(struct uart_omap_port *up, in serial_omap_probe_rs485() argument
1551 struct serial_rs485 *rs485conf = &up->port.rs485; in serial_omap_probe_rs485()
1557 up->rts_gpio = -EINVAL; in serial_omap_probe_rs485()
1568 up->rts_gpio = of_get_named_gpio_flags(np, "rts-gpio", 0, &flags); in serial_omap_probe_rs485()
1569 if (gpio_is_valid(up->rts_gpio)) { in serial_omap_probe_rs485()
1570 ret = devm_gpio_request(up->dev, up->rts_gpio, "omap-serial"); in serial_omap_probe_rs485()
1573 ret = gpio_direction_output(up->rts_gpio, in serial_omap_probe_rs485()
1577 } else if (up->rts_gpio == -EPROBE_DEFER) { in serial_omap_probe_rs485()
1580 up->rts_gpio = -EINVAL; in serial_omap_probe_rs485()
1601 struct uart_omap_port *up; in serial_omap_probe() local
1622 up = devm_kzalloc(&pdev->dev, sizeof(*up), GFP_KERNEL); in serial_omap_probe()
1623 if (!up) in serial_omap_probe()
1631 up->dev = &pdev->dev; in serial_omap_probe()
1632 up->port.dev = &pdev->dev; in serial_omap_probe()
1633 up->port.type = PORT_OMAP; in serial_omap_probe()
1634 up->port.iotype = UPIO_MEM; in serial_omap_probe()
1635 up->port.irq = uartirq; in serial_omap_probe()
1636 up->port.regshift = 2; in serial_omap_probe()
1637 up->port.fifosize = 64; in serial_omap_probe()
1638 up->port.ops = &serial_omap_pops; in serial_omap_probe()
1650 up->port.line = ret; in serial_omap_probe()
1652 if (up->port.line >= OMAP_MAX_HSUART_PORTS) { in serial_omap_probe()
1653 dev_err(&pdev->dev, "uart ID %d > MAX %d.\n", up->port.line, in serial_omap_probe()
1659 up->wakeirq = wakeirq; in serial_omap_probe()
1660 if (!up->wakeirq) in serial_omap_probe()
1661 dev_info(up->port.dev, "no wakeirq for uart%d\n", in serial_omap_probe()
1662 up->port.line); in serial_omap_probe()
1664 ret = serial_omap_probe_rs485(up, pdev->dev.of_node); in serial_omap_probe()
1668 sprintf(up->name, "OMAP UART%d", up->port.line); in serial_omap_probe()
1669 up->port.mapbase = mem->start; in serial_omap_probe()
1670 up->port.membase = base; in serial_omap_probe()
1671 up->port.flags = omap_up_info->flags; in serial_omap_probe()
1672 up->port.uartclk = omap_up_info->uartclk; in serial_omap_probe()
1673 up->port.rs485_config = serial_omap_config_rs485; in serial_omap_probe()
1674 if (!up->port.uartclk) { in serial_omap_probe()
1675 up->port.uartclk = DEFAULT_CLK_SPEED; in serial_omap_probe()
1681 up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; in serial_omap_probe()
1682 up->calc_latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; in serial_omap_probe()
1683 pm_qos_add_request(&up->pm_qos_request, in serial_omap_probe()
1684 PM_QOS_CPU_DMA_LATENCY, up->latency); in serial_omap_probe()
1685 INIT_WORK(&up->qos_work, serial_omap_uart_qos_work); in serial_omap_probe()
1687 platform_set_drvdata(pdev, up); in serial_omap_probe()
1691 device_init_wakeup(up->dev, true); in serial_omap_probe()
1701 omap_serial_fill_features_erratas(up); in serial_omap_probe()
1703 ui[up->port.line] = up; in serial_omap_probe()
1704 serial_omap_add_console_port(up); in serial_omap_probe()
1706 ret = uart_add_one_port(&serial_omap_reg, &up->port); in serial_omap_probe()
1710 pm_runtime_mark_last_busy(up->dev); in serial_omap_probe()
1711 pm_runtime_put_autosuspend(up->dev); in serial_omap_probe()
1718 pm_qos_remove_request(&up->pm_qos_request); in serial_omap_probe()
1719 device_init_wakeup(up->dev, false); in serial_omap_probe()
1727 struct uart_omap_port *up = platform_get_drvdata(dev); in serial_omap_remove() local
1729 pm_runtime_get_sync(up->dev); in serial_omap_remove()
1731 uart_remove_one_port(&serial_omap_reg, &up->port); in serial_omap_remove()
1733 pm_runtime_dont_use_autosuspend(up->dev); in serial_omap_remove()
1734 pm_runtime_put_sync(up->dev); in serial_omap_remove()
1735 pm_runtime_disable(up->dev); in serial_omap_remove()
1736 pm_qos_remove_request(&up->pm_qos_request); in serial_omap_remove()
1751 static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1) in serial_omap_mdr1_errataset() argument
1755 serial_out(up, UART_OMAP_MDR1, mdr1); in serial_omap_mdr1_errataset()
1757 serial_out(up, UART_FCR, up->fcr | UART_FCR_CLEAR_XMIT | in serial_omap_mdr1_errataset()
1763 while (UART_LSR_THRE != (serial_in(up, UART_LSR) & in serial_omap_mdr1_errataset()
1768 dev_crit(up->dev, "Errata i202: timedout %x\n", in serial_omap_mdr1_errataset()
1769 serial_in(up, UART_LSR)); in serial_omap_mdr1_errataset()
1777 static void serial_omap_restore_context(struct uart_omap_port *up) in serial_omap_restore_context() argument
1779 if (up->errata & UART_ERRATA_i202_MDR1_ACCESS) in serial_omap_restore_context()
1780 serial_omap_mdr1_errataset(up, UART_OMAP_MDR1_DISABLE); in serial_omap_restore_context()
1782 serial_out(up, UART_OMAP_MDR1, UART_OMAP_MDR1_DISABLE); in serial_omap_restore_context()
1784 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); /* Config B mode */ in serial_omap_restore_context()
1785 serial_out(up, UART_EFR, UART_EFR_ECB); in serial_omap_restore_context()
1786 serial_out(up, UART_LCR, 0x0); /* Operational mode */ in serial_omap_restore_context()
1787 serial_out(up, UART_IER, 0x0); in serial_omap_restore_context()
1788 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); /* Config B mode */ in serial_omap_restore_context()
1789 serial_out(up, UART_DLL, up->dll); in serial_omap_restore_context()
1790 serial_out(up, UART_DLM, up->dlh); in serial_omap_restore_context()
1791 serial_out(up, UART_LCR, 0x0); /* Operational mode */ in serial_omap_restore_context()
1792 serial_out(up, UART_IER, up->ier); in serial_omap_restore_context()
1793 serial_out(up, UART_FCR, up->fcr); in serial_omap_restore_context()
1794 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in serial_omap_restore_context()
1795 serial_out(up, UART_MCR, up->mcr); in serial_omap_restore_context()
1796 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); /* Config B mode */ in serial_omap_restore_context()
1797 serial_out(up, UART_OMAP_SCR, up->scr); in serial_omap_restore_context()
1798 serial_out(up, UART_EFR, up->efr); in serial_omap_restore_context()
1799 serial_out(up, UART_LCR, up->lcr); in serial_omap_restore_context()
1800 if (up->errata & UART_ERRATA_i202_MDR1_ACCESS) in serial_omap_restore_context()
1801 serial_omap_mdr1_errataset(up, up->mdr1); in serial_omap_restore_context()
1803 serial_out(up, UART_OMAP_MDR1, up->mdr1); in serial_omap_restore_context()
1804 serial_out(up, UART_OMAP_WER, up->wer); in serial_omap_restore_context()
1809 struct uart_omap_port *up = dev_get_drvdata(dev); in serial_omap_runtime_suspend() local
1811 if (!up) in serial_omap_runtime_suspend()
1820 if (up->is_suspending && !console_suspend_enabled && in serial_omap_runtime_suspend()
1821 uart_console(&up->port)) in serial_omap_runtime_suspend()
1824 up->context_loss_cnt = serial_omap_get_context_loss_count(up); in serial_omap_runtime_suspend()
1826 serial_omap_enable_wakeup(up, true); in serial_omap_runtime_suspend()
1828 up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; in serial_omap_runtime_suspend()
1829 schedule_work(&up->qos_work); in serial_omap_runtime_suspend()
1836 struct uart_omap_port *up = dev_get_drvdata(dev); in serial_omap_runtime_resume() local
1838 int loss_cnt = serial_omap_get_context_loss_count(up); in serial_omap_runtime_resume()
1840 serial_omap_enable_wakeup(up, false); in serial_omap_runtime_resume()
1845 serial_omap_restore_context(up); in serial_omap_runtime_resume()
1846 } else if (up->context_loss_cnt != loss_cnt) { in serial_omap_runtime_resume()
1847 serial_omap_restore_context(up); in serial_omap_runtime_resume()
1849 up->latency = up->calc_latency; in serial_omap_runtime_resume()
1850 schedule_work(&up->qos_work); in serial_omap_runtime_resume()