Skip to contentSkip to conversation

omap-serial: Overriding omap-serial built in serial_in/out functions

RFC PATCH New Raphaël Assénat 1 participant 1 message Aug 11, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 omap-serial: Overriding omap-serial built in serial_in/out functions

This patch provides a mean to replace the default serial_in and serial_out implementations provided by omap-serial.c. Inspired from the 8250.c driver.

Overridding those functions provide a very flexible way to implement special features such as GPIO connected modem lines. (By catching values written to MCR or rewriting values read from MSR on the fly).

arch/arm/plat-omap/include/plat/omap-serial.h +5 -0
@@ -63,6 +63,8 @@ struct omap_uart_port_info {
 	resource_size_t		mapbase;	/* resource base */
 	unsigned long		irqflags;	/* request_irq flags */
 	upf_t			flags;		/* UPF_* flags */
+	unsigned int		(*serial_in)(struct uart_port *, int);
+	void			(*serial_out)(struct uart_port *, int, int);
 };
 
 struct uart_omap_dma {
@@ -102,6 +104,9 @@ struct uart_omap_port {
 	unsigned char		efr;
 
 	int			use_dma;
+	
+	unsigned int		(*serial_in)(struct uart_port *, int);
+	void			(*serial_out)(struct uart_port *, int, int);
 	/*
 	 * Some bits in registers are cleared on a read, so they must
 	 * be saved whenever the register is read but the bits will not
drivers/tty/serial/omap-serial.c +13 -4
@@ -51,14 +51,23 @@ static int serial_omap_start_rxdma(struct uart_omap_port *up);
 
 static inline unsigned int serial_in(struct uart_omap_port *up, int offset)
 {
-	offset <<= up->port.regshift;
-	return readw(up->port.membase + offset);
+	if (up->serial_in) {
+		return up->serial_in(&up->port, offset);
+	}
+	else {
+		offset <<= up->port.regshift;
+		return readw(up->port.membase + offset);
+	}
 }
 
 static inline void serial_out(struct uart_omap_port *up, int offset, int value)
 {
-	offset <<= up->port.regshift;
-	writew(value, up->port.membase + offset);
+	if (up->serial_out) {
+		up->serial_out(&up->port, offset, value);
+	} else {
+		offset <<= up->port.regshift;
+		writew(value, up->port.membase + offset);
+	}
 }
 
 static inline void serial_omap_clear_fifos(struct uart_omap_port *up)

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html