Skip to content

Commit 6d45a1a

Browse files
committed
sparc,sunzilog: Add console polling support for sunzilog serial driver
Allow kgdboc to work on sparc hardware with the Zilog serial chips. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: David S. Miller <davem@davemloft.net>
1 parent 3f255eb commit 6d45a1a

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

‎drivers/serial/sunzilog.c‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ struct uart_sunzilog_port {
102102
#endif
103103
};
104104

105+
static void sunzilog_putchar(struct uart_port *port, int ch);
106+
105107
#define ZILOG_CHANNEL_FROM_PORT(PORT) ((struct zilog_channel __iomem *)((PORT)->membase))
106108
#define UART_ZILOG(PORT) ((struct uart_sunzilog_port *)(PORT))
107109

@@ -996,6 +998,50 @@ static int sunzilog_verify_port(struct uart_port *port, struct serial_struct *se
996998
return -EINVAL;
997999
}
9981000

1001+
#ifdef CONFIG_CONSOLE_POLL
1002+
static int sunzilog_get_poll_char(struct uart_port *port)
1003+
{
1004+
unsigned char ch, r1;
1005+
struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
1006+
struct zilog_channel __iomem *channel
1007+
= ZILOG_CHANNEL_FROM_PORT(&up->port);
1008+
1009+
1010+
r1 = read_zsreg(channel, R1);
1011+
if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) {
1012+
writeb(ERR_RES, &channel->control);
1013+
ZSDELAY();
1014+
ZS_WSYNC(channel);
1015+
}
1016+
1017+
ch = readb(&channel->control);
1018+
ZSDELAY();
1019+
1020+
/* This funny hack depends upon BRK_ABRT not interfering
1021+
* with the other bits we care about in R1.
1022+
*/
1023+
if (ch & BRK_ABRT)
1024+
r1 |= BRK_ABRT;
1025+
1026+
if (!(ch & Rx_CH_AV))
1027+
return NO_POLL_CHAR;
1028+
1029+
ch = readb(&channel->data);
1030+
ZSDELAY();
1031+
1032+
ch &= up->parity_mask;
1033+
return ch;
1034+
}
1035+
1036+
static void sunzilog_put_poll_char(struct uart_port *port,
1037+
unsigned char ch)
1038+
{
1039+
struct uart_sunzilog_port *up = (struct uart_sunzilog_port *)port;
1040+
1041+
sunzilog_putchar(&up->port, ch);
1042+
}
1043+
#endif /* CONFIG_CONSOLE_POLL */
1044+
9991045
static struct uart_ops sunzilog_pops = {
10001046
.tx_empty = sunzilog_tx_empty,
10011047
.set_mctrl = sunzilog_set_mctrl,
@@ -1013,6 +1059,10 @@ static struct uart_ops sunzilog_pops = {
10131059
.request_port = sunzilog_request_port,
10141060
.config_port = sunzilog_config_port,
10151061
.verify_port = sunzilog_verify_port,
1062+
#ifdef CONFIG_CONSOLE_POLL
1063+
.poll_get_char = sunzilog_get_poll_char,
1064+
.poll_put_char = sunzilog_put_poll_char,
1065+
#endif
10161066
};
10171067

10181068
static int uart_chip_count;

0 commit comments

Comments
 (0)