MN10300: Allow KGDB to use the MN10300 serial ports

Allow KGDB to use the MN10300 serial ports through the polled I/O interface
provided via the TTY/serial layer and the kgdboc driver. This allows the
kernel to be started with something like:

kgdboc=ttySM0,115200

added to the command line.

Signed-off-by: David Howells <dhowells@redhat.com>

+75
+75
arch/mn10300/kernel/mn10300-serial.c
··· 119 static void mn10300_serial_config_port(struct uart_port *, int); 120 static int mn10300_serial_verify_port(struct uart_port *, 121 struct serial_struct *); 122 123 static const struct uart_ops mn10300_serial_ops = { 124 .tx_empty = mn10300_serial_tx_empty, ··· 142 .request_port = mn10300_serial_request_port, 143 .config_port = mn10300_serial_config_port, 144 .verify_port = mn10300_serial_verify_port, 145 }; 146 147 static irqreturn_t mn10300_serial_interrupt(int irq, void *dev_id); ··· 1642 1643 console_initcall(mn10300_serial_console_init); 1644 #endif
··· 119 static void mn10300_serial_config_port(struct uart_port *, int); 120 static int mn10300_serial_verify_port(struct uart_port *, 121 struct serial_struct *); 122 + #ifdef CONFIG_CONSOLE_POLL 123 + static void mn10300_serial_poll_put_char(struct uart_port *, unsigned char); 124 + static int mn10300_serial_poll_get_char(struct uart_port *); 125 + #endif 126 127 static const struct uart_ops mn10300_serial_ops = { 128 .tx_empty = mn10300_serial_tx_empty, ··· 138 .request_port = mn10300_serial_request_port, 139 .config_port = mn10300_serial_config_port, 140 .verify_port = mn10300_serial_verify_port, 141 + #ifdef CONFIG_CONSOLE_POLL 142 + .poll_put_char = mn10300_serial_poll_put_char, 143 + .poll_get_char = mn10300_serial_poll_get_char, 144 + #endif 145 }; 146 147 static irqreturn_t mn10300_serial_interrupt(int irq, void *dev_id); ··· 1634 1635 console_initcall(mn10300_serial_console_init); 1636 #endif 1637 + 1638 + #ifdef CONFIG_CONSOLE_POLL 1639 + /* 1640 + * Polled character reception for the kernel debugger 1641 + */ 1642 + static int mn10300_serial_poll_get_char(struct uart_port *_port) 1643 + { 1644 + struct mn10300_serial_port *port = 1645 + container_of(_port, struct mn10300_serial_port, uart); 1646 + unsigned ix; 1647 + u8 st, ch; 1648 + 1649 + _enter("%s", port->name); 1650 + 1651 + do { 1652 + /* pull chars out of the hat */ 1653 + ix = port->rx_outp; 1654 + if (ix == port->rx_inp) 1655 + return NO_POLL_CHAR; 1656 + 1657 + ch = port->rx_buffer[ix++]; 1658 + st = port->rx_buffer[ix++]; 1659 + smp_rmb(); 1660 + port->rx_outp = ix & (MNSC_BUFFER_SIZE - 1); 1661 + 1662 + } while (st & (SC01STR_FEF | SC01STR_PEF | SC01STR_OEF)); 1663 + 1664 + return ch; 1665 + } 1666 + 1667 + 1668 + /* 1669 + * Polled character transmission for the kernel debugger 1670 + */ 1671 + static void mn10300_serial_poll_put_char(struct uart_port *_port, 1672 + unsigned char ch) 1673 + { 1674 + struct mn10300_serial_port *port = 1675 + container_of(_port, struct mn10300_serial_port, uart); 1676 + u8 intr, tmp; 1677 + 1678 + /* wait for the transmitter to finish anything it might be doing (and 1679 + * this includes the virtual DMA handler, so it might take a while) */ 1680 + while (*port->_status & (SC01STR_TBF | SC01STR_TXF)) 1681 + continue; 1682 + 1683 + /* disable the Tx ready interrupt */ 1684 + intr = *port->_intr; 1685 + *port->_intr = intr & ~SC01ICR_TI; 1686 + tmp = *port->_intr; 1687 + 1688 + if (ch == 0x0a) { 1689 + *(u8 *) port->_txb = 0x0d; 1690 + while (*port->_status & SC01STR_TBF) 1691 + continue; 1692 + } 1693 + 1694 + *(u8 *) port->_txb = ch; 1695 + while (*port->_status & SC01STR_TBF) 1696 + continue; 1697 + 1698 + /* restore the Tx interrupt flag */ 1699 + *port->_intr = intr; 1700 + tmp = *port->_intr; 1701 + } 1702 + 1703 + #endif /* CONFIG_CONSOLE_POLL */