diff options
author | Julien Pichon <pichon.jln@gmail.com> | 2012-09-22 02:22:31 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-26 16:40:12 -0400 |
commit | 93b5c032d95e032691e627526b364cd463834347 (patch) | |
tree | 24e878c45faab98c8a4a6008731e19ca24b048e0 /drivers/tty | |
parent | 6e62bdc07e1b397704354cf3bd58950943ecaaf1 (diff) |
serial: samsung: Add poll_get_char & poll_put_char
The following patch allows users to use KGDB over serial console on
board based on Samsung SOC. It has been tested on a board using
exynos5.
[dianders: changed poll to return NO_POLL_CHAR, which appears to
fix 'help' in kgdb; also updated commit message]
Signed-off-by: Julien Pichon <pichon.jln@gmail.com>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/samsung.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 8eef1141b81d..7f04717176aa 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c | |||
@@ -876,11 +876,24 @@ s3c24xx_serial_verify_port(struct uart_port *port, struct serial_struct *ser) | |||
876 | 876 | ||
877 | static struct console s3c24xx_serial_console; | 877 | static struct console s3c24xx_serial_console; |
878 | 878 | ||
879 | static int __init s3c24xx_serial_console_init(void) | ||
880 | { | ||
881 | register_console(&s3c24xx_serial_console); | ||
882 | return 0; | ||
883 | } | ||
884 | console_initcall(s3c24xx_serial_console_init); | ||
885 | |||
879 | #define S3C24XX_SERIAL_CONSOLE &s3c24xx_serial_console | 886 | #define S3C24XX_SERIAL_CONSOLE &s3c24xx_serial_console |
880 | #else | 887 | #else |
881 | #define S3C24XX_SERIAL_CONSOLE NULL | 888 | #define S3C24XX_SERIAL_CONSOLE NULL |
882 | #endif | 889 | #endif |
883 | 890 | ||
891 | #ifdef CONFIG_CONSOLE_POLL | ||
892 | static int s3c24xx_serial_get_poll_char(struct uart_port *port); | ||
893 | static void s3c24xx_serial_put_poll_char(struct uart_port *port, | ||
894 | unsigned char c); | ||
895 | #endif | ||
896 | |||
884 | static struct uart_ops s3c24xx_serial_ops = { | 897 | static struct uart_ops s3c24xx_serial_ops = { |
885 | .pm = s3c24xx_serial_pm, | 898 | .pm = s3c24xx_serial_pm, |
886 | .tx_empty = s3c24xx_serial_tx_empty, | 899 | .tx_empty = s3c24xx_serial_tx_empty, |
@@ -899,6 +912,10 @@ static struct uart_ops s3c24xx_serial_ops = { | |||
899 | .request_port = s3c24xx_serial_request_port, | 912 | .request_port = s3c24xx_serial_request_port, |
900 | .config_port = s3c24xx_serial_config_port, | 913 | .config_port = s3c24xx_serial_config_port, |
901 | .verify_port = s3c24xx_serial_verify_port, | 914 | .verify_port = s3c24xx_serial_verify_port, |
915 | #ifdef CONFIG_CONSOLE_POLL | ||
916 | .poll_get_char = s3c24xx_serial_get_poll_char, | ||
917 | .poll_put_char = s3c24xx_serial_put_poll_char, | ||
918 | #endif | ||
902 | }; | 919 | }; |
903 | 920 | ||
904 | static struct uart_driver s3c24xx_uart_drv = { | 921 | static struct uart_driver s3c24xx_uart_drv = { |
@@ -1316,6 +1333,36 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon) | |||
1316 | return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0; | 1333 | return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0; |
1317 | } | 1334 | } |
1318 | 1335 | ||
1336 | #ifdef CONFIG_CONSOLE_POLL | ||
1337 | /* | ||
1338 | * Console polling routines for writing and reading from the uart while | ||
1339 | * in an interrupt or debug context. | ||
1340 | */ | ||
1341 | |||
1342 | static int s3c24xx_serial_get_poll_char(struct uart_port *port) | ||
1343 | { | ||
1344 | struct s3c24xx_uart_port *ourport = to_ourport(port); | ||
1345 | unsigned int ufstat; | ||
1346 | |||
1347 | ufstat = rd_regl(port, S3C2410_UFSTAT); | ||
1348 | if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0) | ||
1349 | return NO_POLL_CHAR; | ||
1350 | |||
1351 | return rd_regb(port, S3C2410_URXH); | ||
1352 | } | ||
1353 | |||
1354 | static void s3c24xx_serial_put_poll_char(struct uart_port *port, | ||
1355 | unsigned char c) | ||
1356 | { | ||
1357 | unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); | ||
1358 | |||
1359 | while (!s3c24xx_serial_console_txrdy(port, ufcon)) | ||
1360 | cpu_relax(); | ||
1361 | wr_regb(cons_uart, S3C2410_UTXH, c); | ||
1362 | } | ||
1363 | |||
1364 | #endif /* CONFIG_CONSOLE_POLL */ | ||
1365 | |||
1319 | static void | 1366 | static void |
1320 | s3c24xx_serial_console_putchar(struct uart_port *port, int ch) | 1367 | s3c24xx_serial_console_putchar(struct uart_port *port, int ch) |
1321 | { | 1368 | { |