All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Raphaël Assénat" <raph@8d.com>
To: linux-omap@vger.kernel.org
Subject: [RFC PATCH 2/2] omap-serial: Allow board files to override serial_in/out
Date: Thu, 11 Aug 2011 15:50:07 -0400	[thread overview]
Message-ID: <4E44326F.6010004@8d.com> (raw)

This patch adds a way to override the default serial_in and serial_out
functions, typically from the board-??? file.

In some cases, mach-omap2/serial.c may already be overriding the
default serial_in/out functions. When this happens, old_serial_in/out
will be non-null and the board implementation should then call these 
instead of going ahead and performing direct memory access.

Tested with 8250.c and omap-serial.c on a custom AM3505 system.

Signed-off-by: Raphaël Assénat

--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -105,10 +105,20 @@
 
 #ifndef __ASSEMBLER__
 
+struct uart_port;
 struct omap_board_data;
 
+struct omap_serio_funcs {
+	unsigned int	(*serial_in)(struct uart_port *, int);
+	void		(*serial_out)(struct uart_port *, int, int);
+	
+	unsigned int	(*old_serial_in)(struct uart_port *, int);
+	void		(*old_serial_out)(struct uart_port *, int, int);
+};
+
 extern void omap_serial_init(void);
 extern void omap_serial_init_port(struct omap_board_data *bdata);
+extern void omap_serial_init_port_serio(struct omap_board_data *bdata, struct omap_serio_funcs *serio_funcs);
 extern int omap_uart_can_sleep(void);
 extern void omap_uart_check_wakeup(void);
 extern void omap_uart_prepare_suspend(void);
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -696,6 +696,11 @@ static int __init omap_serial_early_init(void)
 }
 core_initcall(omap_serial_early_init);
 
+void __init omap_serial_init_port(struct omap_board_data *bdata)
+{
+	omap_serial_init_port_serio(bdata, NULL);
+}
+
 /**
  * omap_serial_init_port() - initialize single serial port
  * @bdata: port specific board data pointer
@@ -707,7 +712,7 @@ core_initcall(omap_serial_early_init);
  * Don't mix calls to omap_serial_init_port() and omap_serial_init(),
  * use only one of the two.
  */
-void __init omap_serial_init_port(struct omap_board_data *bdata)
+void __init omap_serial_init_port_serio(struct omap_board_data *bdata, struct omap_serio_funcs *serio_funcs)
 {
 	struct omap_uart_state *uart;
 	struct omap_hwmod *oh;
@@ -779,6 +784,15 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 		p->serial_out = serial_out_override;
 	}
 
+	if (serio_funcs) {
+		serio_funcs->old_serial_in = p->serial_in;
+		serio_funcs->old_serial_out = p->serial_out;
+		if (serio_funcs->serial_in)
+			p->serial_in = serio_funcs->serial_in;
+		if (serio_funcs->serial_out)
+			p->serial_out = serio_funcs->serial_out;
+	}
+
 	pdata = &ports[0];
 	pdata_size = 2 * sizeof(struct plat_serial8250_port);
 #else
@@ -792,6 +806,11 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
 	omap_up.irqflags = IRQF_SHARED;
 	omap_up.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
 
+	if (serio_funcs) {
+		omap_up.serial_in = serio_funcs->serial_in;
+		omap_up.serial_out = serio_funcs->serial_out;
+	}
+
 	pdata = &omap_up;
 	pdata_size = sizeof(struct omap_uart_port_info);
 #endif

--
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:50 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=4E44326F.6010004@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.