12
12
#include <linux/console.h>
13
13
#include <linux/delay.h>
14
14
#include <linux/io.h>
15
+ #include <linux/iopoll.h>
15
16
#include <linux/module.h>
16
17
#include <linux/of.h>
17
18
#include <linux/platform_device.h>
62
63
#define OWL_UART_STAT_TRFL_MASK GENMASK(16, 11)
63
64
#define OWL_UART_STAT_UTBB BIT(17)
64
65
66
+ #define OWL_UART_POLL_USEC 5
67
+ #define OWL_UART_TIMEOUT_USEC 10000
68
+
65
69
static struct uart_driver owl_uart_driver ;
66
70
67
71
struct owl_uart_info {
@@ -461,6 +465,36 @@ static void owl_uart_config_port(struct uart_port *port, int flags)
461
465
}
462
466
}
463
467
468
+ #ifdef CONFIG_CONSOLE_POLL
469
+
470
+ static int owl_uart_poll_get_char (struct uart_port * port )
471
+ {
472
+ if (owl_uart_read (port , OWL_UART_STAT ) & OWL_UART_STAT_RFEM )
473
+ return NO_POLL_CHAR ;
474
+
475
+ return owl_uart_read (port , OWL_UART_RXDAT );
476
+ }
477
+
478
+ static void owl_uart_poll_put_char (struct uart_port * port , unsigned char ch )
479
+ {
480
+ u32 reg ;
481
+ int ret ;
482
+
483
+ /* Wait while FIFO is full or timeout */
484
+ ret = readl_poll_timeout_atomic (port -> membase + OWL_UART_STAT , reg ,
485
+ !(reg & OWL_UART_STAT_TFFU ),
486
+ OWL_UART_POLL_USEC ,
487
+ OWL_UART_TIMEOUT_USEC );
488
+ if (ret == - ETIMEDOUT ) {
489
+ dev_err (port -> dev , "Timeout waiting while UART TX FULL\n" );
490
+ return ;
491
+ }
492
+
493
+ owl_uart_write (port , ch , OWL_UART_TXDAT );
494
+ }
495
+
496
+ #endif /* CONFIG_CONSOLE_POLL */
497
+
464
498
static const struct uart_ops owl_uart_ops = {
465
499
.set_mctrl = owl_uart_set_mctrl ,
466
500
.get_mctrl = owl_uart_get_mctrl ,
@@ -476,6 +510,10 @@ static const struct uart_ops owl_uart_ops = {
476
510
.request_port = owl_uart_request_port ,
477
511
.release_port = owl_uart_release_port ,
478
512
.verify_port = owl_uart_verify_port ,
513
+ #ifdef CONFIG_CONSOLE_POLL
514
+ .poll_get_char = owl_uart_poll_get_char ,
515
+ .poll_put_char = owl_uart_poll_put_char ,
516
+ #endif
479
517
};
480
518
481
519
#ifdef CONFIG_SERIAL_OWL_CONSOLE
0 commit comments