Skip to content

Commit 3631e48

Browse files
holio0gregkh
authored andcommitted
serial: samsung: Add samsung_early_read to support early kgdboc
The 'kgdboc_earlycon_init' looks for boot console that has both .read and .write callbacks. Adds 'samsung_early_read' to samsung_tty.c's early console to support kgdboc. Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Woody Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3f8bab1 commit 3631e48

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/tty/serial/samsung_tty.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,6 +2949,7 @@ static void wr_reg_barrier(struct uart_port *port, u32 reg, u32 val)
29492949

29502950
struct samsung_early_console_data {
29512951
u32 txfull_mask;
2952+
u32 rxfifo_mask;
29522953
};
29532954

29542955
static void samsung_early_busyuart(struct uart_port *port)
@@ -2983,19 +2984,41 @@ static void samsung_early_write(struct console *con, const char *s,
29832984
uart_console_write(&dev->port, s, n, samsung_early_putc);
29842985
}
29852986

2987+
static int samsung_early_read(struct console *con, char *s, unsigned int n)
2988+
{
2989+
struct earlycon_device *dev = con->data;
2990+
const struct samsung_early_console_data *data = dev->port.private_data;
2991+
int ch, ufstat, num_read = 0;
2992+
2993+
while (num_read < n) {
2994+
ufstat = rd_regl(&dev->port, S3C2410_UFSTAT);
2995+
if (!(ufstat & data->rxfifo_mask))
2996+
break;
2997+
ch = rd_reg(&dev->port, S3C2410_URXH);
2998+
if (ch == NO_POLL_CHAR)
2999+
break;
3000+
3001+
s[num_read++] = ch;
3002+
}
3003+
3004+
return num_read;
3005+
}
3006+
29863007
static int __init samsung_early_console_setup(struct earlycon_device *device,
29873008
const char *opt)
29883009
{
29893010
if (!device->port.membase)
29903011
return -ENODEV;
29913012

29923013
device->con->write = samsung_early_write;
3014+
device->con->read = samsung_early_read;
29933015
return 0;
29943016
}
29953017

29963018
/* S3C2410 */
29973019
static struct samsung_early_console_data s3c2410_early_console_data = {
29983020
.txfull_mask = S3C2410_UFSTAT_TXFULL,
3021+
.rxfifo_mask = S3C2410_UFSTAT_RXFULL | S3C2410_UFSTAT_RXMASK,
29993022
};
30003023

30013024
static int __init s3c2410_early_console_setup(struct earlycon_device *device,
@@ -3011,6 +3034,7 @@ OF_EARLYCON_DECLARE(s3c2410, "samsung,s3c2410-uart",
30113034
/* S3C2412, S3C2440, S3C64xx */
30123035
static struct samsung_early_console_data s3c2440_early_console_data = {
30133036
.txfull_mask = S3C2440_UFSTAT_TXFULL,
3037+
.rxfifo_mask = S3C2440_UFSTAT_RXFULL | S3C2440_UFSTAT_RXMASK,
30143038
};
30153039

30163040
static int __init s3c2440_early_console_setup(struct earlycon_device *device,
@@ -3030,6 +3054,7 @@ OF_EARLYCON_DECLARE(s3c6400, "samsung,s3c6400-uart",
30303054
/* S5PV210, Exynos */
30313055
static struct samsung_early_console_data s5pv210_early_console_data = {
30323056
.txfull_mask = S5PV210_UFSTAT_TXFULL,
3057+
.rxfifo_mask = S5PV210_UFSTAT_RXFULL | S5PV210_UFSTAT_RXMASK,
30333058
};
30343059

30353060
static int __init s5pv210_early_console_setup(struct earlycon_device *device,

0 commit comments

Comments
 (0)