From patchwork Thu Aug 11 19:50:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFwaGHDq2wgQXNzw6luYXQ=?= X-Patchwork-Id: 1058612 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7BJoBlt004206 for ; Thu, 11 Aug 2011 19:50:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752297Ab1HKTuJ (ORCPT ); Thu, 11 Aug 2011 15:50:09 -0400 Received: from roc.holo.8d.com ([64.254.227.115]:55007 "EHLO roc.holo.8d.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751168Ab1HKTuI (ORCPT ); Thu, 11 Aug 2011 15:50:08 -0400 Received: from raph.usine.8d.com ([192.168.142.55]) by roc.holo.8d.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1QrbGZ-0006vI-BJ for linux-omap@vger.kernel.org; Thu, 11 Aug 2011 15:50:08 -0400 Message-ID: <4E44326F.6010004@8d.com> Date: Thu, 11 Aug 2011 15:50:07 -0400 From: =?ISO-8859-1?Q?Rapha=EBl_Ass=E9nat?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110505 Icedove/3.0.11 MIME-Version: 1.0 To: linux-omap@vger.kernel.org Subject: [RFC PATCH 2/2] omap-serial: Allow board files to override serial_in/out X-Enigmail-Version: 1.0.1 X-Spam-Score: -2.6 X-Spam-Level: -- X-Spam-Report: -2.6 points, 5.0 required autolearn=ham -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 11 Aug 2011 19:50:11 +0000 (UTC) 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 --- 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 --- 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