diff options
| -rw-r--r-- | drivers/tty/serial/xilinx_uartps.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 5d5557af4d22..62259f37ddda 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c | |||
| @@ -775,6 +775,54 @@ static void xuartps_enable_ms(struct uart_port *port) | |||
| 775 | /* N/A */ | 775 | /* N/A */ |
| 776 | } | 776 | } |
| 777 | 777 | ||
| 778 | #ifdef CONFIG_CONSOLE_POLL | ||
| 779 | static int xuartps_poll_get_char(struct uart_port *port) | ||
| 780 | { | ||
| 781 | u32 imr; | ||
| 782 | int c; | ||
| 783 | |||
| 784 | /* Disable all interrupts */ | ||
| 785 | imr = xuartps_readl(XUARTPS_IMR_OFFSET); | ||
| 786 | xuartps_writel(imr, XUARTPS_IDR_OFFSET); | ||
| 787 | |||
| 788 | /* Check if FIFO is empty */ | ||
| 789 | if (xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_RXEMPTY) | ||
| 790 | c = NO_POLL_CHAR; | ||
| 791 | else /* Read a character */ | ||
| 792 | c = (unsigned char) xuartps_readl(XUARTPS_FIFO_OFFSET); | ||
| 793 | |||
| 794 | /* Enable interrupts */ | ||
| 795 | xuartps_writel(imr, XUARTPS_IER_OFFSET); | ||
| 796 | |||
| 797 | return c; | ||
| 798 | } | ||
| 799 | |||
| 800 | static void xuartps_poll_put_char(struct uart_port *port, unsigned char c) | ||
| 801 | { | ||
| 802 | u32 imr; | ||
| 803 | |||
| 804 | /* Disable all interrupts */ | ||
| 805 | imr = xuartps_readl(XUARTPS_IMR_OFFSET); | ||
| 806 | xuartps_writel(imr, XUARTPS_IDR_OFFSET); | ||
| 807 | |||
| 808 | /* Wait until FIFO is empty */ | ||
| 809 | while (!(xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_TXEMPTY)) | ||
| 810 | cpu_relax(); | ||
| 811 | |||
| 812 | /* Write a character */ | ||
| 813 | xuartps_writel(c, XUARTPS_FIFO_OFFSET); | ||
| 814 | |||
| 815 | /* Wait until FIFO is empty */ | ||
| 816 | while (!(xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_TXEMPTY)) | ||
| 817 | cpu_relax(); | ||
| 818 | |||
| 819 | /* Enable interrupts */ | ||
| 820 | xuartps_writel(imr, XUARTPS_IER_OFFSET); | ||
| 821 | |||
| 822 | return; | ||
| 823 | } | ||
| 824 | #endif | ||
| 825 | |||
| 778 | /** The UART operations structure | 826 | /** The UART operations structure |
| 779 | */ | 827 | */ |
| 780 | static struct uart_ops xuartps_ops = { | 828 | static struct uart_ops xuartps_ops = { |
| @@ -807,6 +855,10 @@ static struct uart_ops xuartps_ops = { | |||
| 807 | .config_port = xuartps_config_port, /* Configure when driver | 855 | .config_port = xuartps_config_port, /* Configure when driver |
| 808 | * adds a xuartps port | 856 | * adds a xuartps port |
| 809 | */ | 857 | */ |
| 858 | #ifdef CONFIG_CONSOLE_POLL | ||
| 859 | .poll_get_char = xuartps_poll_get_char, | ||
| 860 | .poll_put_char = xuartps_poll_put_char, | ||
| 861 | #endif | ||
| 810 | }; | 862 | }; |
| 811 | 863 | ||
| 812 | static struct uart_port xuartps_port[2]; | 864 | static struct uart_port xuartps_port[2]; |
