Skip to contentSkip to conversation

UART driver for PNX8330/8550/8950: next iteration

PATCH/RFC Vitaly Wool 2 participants 2 messages Aug 19, 2006 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

Hello Russell,

please find the patch that adds PNX8xxx UART support with your latest comments taken into account inlined.

 drivers/serial/Kconfig         |   16 
 drivers/serial/Makefile        |    1 
 drivers/serial/pnx8xxx_uart.c  |  879 +++++++++++++++++++++++++++++++++++++++++
 include/linux/serial_core.h    |    2 
 include/linux/serial_ip3106.h  |   81 ---
 include/linux/serial_pnx8xxx.h |   81 +++
 6 files changed, 978 insertions(+), 82 deletions(-)
drivers/serial/Kconfig +16 -0
Index: powerpc.git/drivers/serial/Kconfig
===================================================================
@@ -651,6 +651,22 @@ config SERIAL_SH_SCI_CONSOLE
 	depends on SERIAL_SH_SCI=y
 	select SERIAL_CORE_CONSOLE
 
+config SERIAL_PNX8XXX
+	bool "Enable PNX8XXX SoCs' UART Support"
+	depends on MIPS && SOC_PNX8550
+	select SERIAL_CORE
+	help
+	  If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330
+	  and you want to use serial ports, say Y.  Otherwise, say N.
+
+config SERIAL_PNX8XXX_CONSOLE
+	bool "Enable PNX8XX0 serial console"
+	depends on SERIAL_PNX8XXX
+	select SERIAL_CORE_CONSOLE
+	help
+	  If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330
+	  and you want to use serial console, say Y. Otherwise, say N.
+
 config SERIAL_CORE
 	tristate
 
drivers/serial/pnx8xxx_uart.c new file +879 -0

879 lines not on this page · raw message

drivers/serial/Makefile +1 -0
Index: powerpc.git/drivers/serial/Makefile
===================================================================
@@ -45,6 +45,7 @@ obj-$(CONFIG_SERIAL_SGI_L1_CONSOLE) += s
 obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
 obj-$(CONFIG_SERIAL_IMX) += imx.o
 obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
+obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o
 obj-$(CONFIG_SERIAL_ICOM) += icom.o
 obj-$(CONFIG_SERIAL_M32R_SIO) += m32r_sio.o
 obj-$(CONFIG_SERIAL_MPSC) += mpsc.o
include/linux/serial_ip3106.h deleted +0 -81

81 lines not on this page · raw message

include/linux/serial_pnx8xxx.h new file +81 -0

81 lines not on this page · raw message

include/linux/serial_core.h +1 -1
Index: powerpc.git/include/linux/serial_core.h
===================================================================
@@ -122,7 +122,7 @@
 /*Digi jsm */
 #define PORT_JSM        69
 
-#define PORT_IP3106	70
+#define PORT_PNX8XXX	70
 
 /* Hilscher netx */
 #define PORT_NETX	71
#1 lore raw
Quoted 2 lines · Vitaly Wool

please find the patch that adds PNX8xxx UART support with your latest comments taken into account inlined.

Okay, I'm now happy with this - thanks for addressing those points so far.

Consider the following two comments non-show stoppers, which can be fixed up later. If you do want to submit another patch which these two addressed that's also fine - I won't be applying any patches for at least a couple of hours. If not, I'll apply this patch as is.

Quoted 42 lines
drivers/serial/pnx8xxx_uart.c new file +42 -0
+static irqreturn_t pnx8xxx_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct pnx8xxx_port *sport = dev_id;
+	unsigned int status;
+
+	spin_lock(&sport->port.lock);
+	/* Get the interrupts */
+	status  = serial_in(sport, PNX8XXX_ISTAT) & serial_in(sport, PNX8XXX_IEN);
+
+	/* RX Receiver Holding Register Overrun */
+	if (status & PNX8XXX_UART_INT_RXOVRN) {
+		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_RXOVRN);
+	}
+
+	/* RX Frame Error */
+	if (status & PNX8XXX_UART_INT_FRERR) {
+		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_FRERR);
+	}
+
+	/* Break signal received */
+	if (status & PNX8XXX_UART_INT_BREAK) {
+		sport->port.icount.brk++;
+		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_BREAK);
+		uart_handle_break(&sport->port);
+	}
+
+	/* RX Parity Error */
+	if (status & PNX8XXX_UART_INT_PARITY) {
+		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_PARITY);
+	}
+
+	/* Byte received */
+	if (status & PNX8XXX_UART_INT_RX) {
+		pnx8xxx_rx_chars(sport, regs);
+		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_RX);
+	}
+
+	/* TX holding register empty - transmit a byte */
+	if (status & PNX8XXX_UART_INT_TX) {
+		pnx8xxx_tx_chars(sport);
+		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_TX);
+	}

drivers/serial/pnx8xxx_uart.c line 330

Quoted 10 lines
drivers/serial/pnx8xxx_uart.c new file +10 -0
+
+	/* TX shift register and holding register empty  */
+	if (status & PNX8XXX_UART_INT_EMPTY) {
+		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_EMPTY);
+	}
+
+	/* Receiver time out */
+	if (status & PNX8XXX_UART_INT_RCVTO) {
+		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_RCVTO);
+	}

Would it be more efficient to write to ICLR once at the end of the function, rather than once per status bit? Could you do this instead:

	if (status & PNX8XXX_UART_INT_BREAK) {
		sport->port.icount.brk++;
		serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_BREAK);
		uart_handle_break(&sport->port);
	}

	if (status & PNX8XXX_UART_INT_RX)
		pnx8xxx_rx_chars(sport, regs);

	if (status & PNX8XXX_UART_INT_TX)
		pnx8xxx_tx_chars(sport);

	serial_out(sport, PNX8XXX_ICLR, status);

?

Quoted 3 lines
drivers/serial/pnx8xxx_uart.c new file +3 -0
+	spin_unlock(&sport->port.lock);
+	return IRQ_HANDLED;
+}

...

Quoted 12 lines
drivers/serial/pnx8xxx_uart.c new file +12 -0
+static void pnx8xxx_shutdown(struct uart_port *port)
+{
+	struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+
+	/*
+	 * Stop our timer.
+	 */
+	del_timer_sync(&sport->timer);
+
+	/*
+	 * Disable all interrupts, port and break condition.
+	 */

drivers/serial/pnx8xxx_uart.c line 443

Quoted 10 lines
drivers/serial/pnx8xxx_uart.c new file +10 -0
+	serial_out(sport, PNX8XXX_IEN, 0);
+	serial_out(sport, PNX8XXX_LCR,
+		serial_in(sport, PNX8XXX_LCR) & ~PNX8XXX_UART_LCR_TXBREAK);
+
+	/*
+	 * Reset the Tx and Rx FIFOS
+	 */
+	serial_out(sport, PNX8XXX_LCR, serial_in(sport, PNX8XXX_LCR) |
+			    PNX8XXX_UART_LCR_TX_RST |
+			    PNX8XXX_UART_LCR_RX_RST);

Hmm, two read-modify-writes to the LCR in succession. Wouldn't:

	lcr = serial_in(sport, PNX8XXX_LCR);
	lcr &= ~PNX8XXX_UART_LCR_TXBREAK;
	lcr |= PNX8XXX_UART_LCR_TX_RST | PNX8XXX_UART_LCR_RX_RST;
	serial_out(sport, PNX8XXX_LCR, lcr);

be more efficient/smaller code?

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core