From patchwork Fri Nov 16 01:51:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinya Kuribayashi X-Patchwork-Id: 1752471 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 4EC873FCA5 for ; Fri, 16 Nov 2012 01:54:07 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TZB6H-0005kB-6a; Fri, 16 Nov 2012 01:52:09 +0000 Received: from relmlor4.renesas.com ([210.160.252.174]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TZB65-0005fn-0d for linux-arm-kernel@lists.infradead.org; Fri, 16 Nov 2012 01:51:58 +0000 Received: from relmlir4.idc.renesas.com ([10.200.68.154]) by relmlor4.idc.renesas.com ( SJSMS) with ESMTP id <0MDK0095756KFV50@relmlor4.idc.renesas.com> for linux-arm-kernel@lists.infradead.org; Fri, 16 Nov 2012 10:51:56 +0900 (JST) Received: from relmlac2.idc.renesas.com ([10.200.69.22]) by relmlir4.idc.renesas.com ( SJSMS) with ESMTP id <0MDK00AAO56K7L10@relmlir4.idc.renesas.com> for linux-arm-kernel@lists.infradead.org; Fri, 16 Nov 2012 10:51:56 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 08277280A4; Fri, 16 Nov 2012 10:51:56 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 0316B280A0; Fri, 16 Nov 2012 10:51:56 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id LAC20077; Fri, 16 Nov 2012 10:51:55 +0900 X-IronPort-AV: E=Sophos; i="4.83,261,1352041200"; d="scan'208"; a="106494948" Received: from unknown (HELO [10.161.64.55]) ([10.161.64.55]) by relmlii2.idc.renesas.com with ESMTP; Fri, 16 Nov 2012 10:51:55 +0900 Message-id: <50A59C3B.7080605@renesas.com> Date: Fri, 16 Nov 2012 10:51:55 +0900 From: Shinya Kuribayashi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-version: 1.0 To: lethal@linux-sh.org, magnus.damm@gmail.com, rjw@sisk.pl, alan@linux.intel.com, gregkh@linuxfoundation.org Subject: [PATCH v2 04/10] serial: sh-sci: console runtime PM support (revisit) References: <509A0658.1010503@renesas.com> <509A0B4E.1030801@renesas.com> <20121116010107.GA6068@kroah.com> <50A59B9B.2010501@renesas.com> In-reply-to: <50A59B9B.2010501@renesas.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121115_205157_378456_30AF6C26 X-CRM114-Status: GOOD ( 14.79 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: takashi.yoshii.zj@renesas.com, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-sh@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Teppei Kamijou The commit 1ba7622094 (serial: sh-sci: console Runtime PM support, from Magnus Damm , 2011-08-03), tried to support console runtime PM, but unfortunately it didn't work for us for some reason. We did not investigated further at that time, instead would like to propose a different approach. In Linux tty/serial world, to get console PM work properly, a serial client driver does not have to maintain .runtime_suspend()/..resume() calls itself, but can leave console power power management handling to the serial core driver. This patch moves the sh-sci driver in that direction. Notes: * There is room to optimize console runtime PM more aggressively by maintaining additional local runtime PM calls, but as a first step having .pm() operation would suffice. * We still have a couple of direct calls to sci_port_enable/..disable left in the driver. We have to live with them, because they're out of serial core's help. Signed-off-by: Teppei Kamijou Signed-off-by: Shinya Kuribayashi --- drivers/tty/serial/sh-sci.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index e9e8883..e65e546 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1746,8 +1746,6 @@ static int sci_startup(struct uart_port *port) dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); - sci_port_enable(s); - ret = sci_request_irq(s); if (unlikely(ret < 0)) return ret; @@ -1771,8 +1769,6 @@ static void sci_shutdown(struct uart_port *port) sci_free_dma(port); sci_free_irq(s); - - sci_port_disable(s); } static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps, @@ -1921,6 +1917,21 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, sci_port_disable(s); } +static void sci_pm(struct uart_port *port, unsigned int state, + unsigned int oldstate) +{ + struct sci_port *sci_port = to_sci_port(port); + + switch (state) { + case 3: + sci_port_disable(sci_port); + break; + default: + sci_port_enable(sci_port); + break; + } +} + static const char *sci_type(struct uart_port *port) { switch (port->type) { @@ -2042,6 +2053,7 @@ static struct uart_ops sci_uart_ops = { .startup = sci_startup, .shutdown = sci_shutdown, .set_termios = sci_set_termios, + .pm = sci_pm, .type = sci_type, .release_port = sci_release_port, .request_port = sci_request_port, @@ -2195,16 +2207,12 @@ static void serial_console_write(struct console *co, const char *s, struct uart_port *port = &sci_port->port; unsigned short bits; - sci_port_enable(sci_port); - uart_console_write(port, s, count, serial_console_putchar); /* wait until fifo is empty and last bit has been transmitted */ bits = SCxSR_TDxE(port) | SCxSR_TEND(port); while ((serial_port_in(port, SCxSR) & bits) != bits) cpu_relax(); - - sci_port_disable(sci_port); } static int __devinit serial_console_setup(struct console *co, char *options) @@ -2236,12 +2244,9 @@ static int __devinit serial_console_setup(struct console *co, char *options) if (unlikely(ret != 0)) return ret; - sci_port_enable(sci_port); - if (options) uart_parse_options(options, &baud, &parity, &bits, &flow); - /* TODO: disable clock */ return uart_set_options(port, co, baud, parity, bits, flow); }