public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: "Raphaël Assénat" <raph@8d.com>
To: linux-omap@vger.kernel.org
Subject: [RFC PATCH 1/2] omap-serial: Overriding omap-serial built in serial_in/out functions
Date: Thu, 11 Aug 2011 15:48:43 -0400	[thread overview]
Message-ID: <4E44321B.4050009@8d.com> (raw)

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).

Signed-off-by: Raphaël Assénat <raph@8d.com>

--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -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
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

                 reply	other threads:[~2011-08-11 19:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E44321B.4050009@8d.com \
    --to=raph@8d.com \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox