From patchwork Mon Apr 13 04:17:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 17874 X-Patchwork-Delegate: lethal@linux-sh.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3D4sLhx013495 for ; Mon, 13 Apr 2009 04:54:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752846AbZDMEx7 (ORCPT ); Mon, 13 Apr 2009 00:53:59 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752167AbZDMEx7 (ORCPT ); Mon, 13 Apr 2009 00:53:59 -0400 Received: from mail.renesas.com ([202.234.163.13]:59767 "EHLO mail05.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754151AbZDMEx6 (ORCPT ); Mon, 13 Apr 2009 00:53:58 -0400 X-AuditID: ac140388-0000000b00006b18-68-49e2c5633a1a Received: from guardian02.idc.renesas.com ([172.20.8.201]) by mail05.idc.renesas.com (sendmail) with ESMTP id n3D4rt4J023153 for ; Mon, 13 Apr 2009 13:53:55 +0900 (JST) Received: (from root@localhost) by guardian02.idc.renesas.com with id n3D4ruUs010503 for linux-sh@vger.kernel.org; Mon, 13 Apr 2009 13:53:56 +0900 (JST) Received: from mta04.idc.renesas.com (localhost [127.0.0.1]) by mta04.idc.renesas.com with ESMTP id n3D4rsg7011710 for ; Mon, 13 Apr 2009 13:53:54 +0900 (JST) Received: from PG10870.renesas.com ([172.30.8.159]) by ims05.idc.renesas.com (Sendmail) with ESMTPA id <0KI0008CJW9V54@ims05.idc.renesas.com> for linux-sh@vger.kernel.org; Mon, 13 Apr 2009 13:53:55 +0900 (JST) Date: Mon, 13 Apr 2009 13:17:59 +0900 From: Kuninori Morimoto Subject: [Review request] sh-sci clock To: SH-Linux Message-id: MIME-version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-type: text/plain; charset=US-ASCII User-Agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.7 Emacs/22.1 (i386-mingw-nt5.1.2600) MULE/5.0 (SAKAKI) Meadow/3.00-dev (KIKU) X-Brightmail-Tracker: AAAAAA== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Hi all Now I'm creating SH7724 sub cpu support patch. And I would like to use "bus_clk" for SCIFA on sh-sci. Current sh-sci use module_clk only. So, I created attached patch to be able to select "bus_clk" or "module_clk". It works well on SH7724/SH7723/SH7722 But I can not check about other CPU. Please review it. ** from here ** sh-sci: sh-sci can select bus_clk or module_clk SCIFA had used module_clk up to now though it used bus_clk. This patch modify this problem, and checked by SH7723/SH7722. Signed-off-by: Kuninori Morimoto --- drivers/serial/sh-sci.c | 18 ++++++++++++++---- drivers/serial/sh-sci.h | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index dbf5357..dd60a1c 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c @@ -92,6 +92,11 @@ static void sci_stop_tx(struct uart_port *port); static struct sci_port sci_ports[SCI_NPORTS]; static struct uart_driver sci_uart_driver; +static inline const char *get_clk_source(struct sci_port *s) +{ + return (s->type == PORT_SCIFA) ? "bus_clk" : "module_clk"; +} + static inline struct sci_port * to_sci_port(struct uart_port *uart) { @@ -871,7 +876,7 @@ static int sci_startup(struct uart_port *port) s->enable(port); #ifdef CONFIG_HAVE_CLK - s->clk = clk_get(NULL, "module_clk"); + s->clk = clk_get(NULL, get_clk_source(s)); #endif sci_request_irq(s); @@ -1059,7 +1064,8 @@ static void __init sci_init_ports(void) * XXX: We should use a proper SCI/SCIF clock */ { - struct clk *clk = clk_get(NULL, "module_clk"); + struct clk *clk = clk_get(NULL, + get_clk_source(sci_ports+i)); sci_ports[i].port.uartclk = clk_get_rate(clk); clk_put(clk); } @@ -1147,8 +1153,12 @@ static int __init serial_console_setup(struct console *co, char *options) port->type = serial_console_port->type; #ifdef CONFIG_HAVE_CLK - if (!serial_console_port->clk) - serial_console_port->clk = clk_get(NULL, "module_clk"); + if (!serial_console_port->clk) { + serial_console_port->clk = + clk_get(NULL, get_clk_source(serial_console_port)); + serial_console_port->port.uartclk = + clk_get_rate(serial_console_port->clk); + } #endif if (port->flags & UPF_IOREMAP) diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index d0aa82d..5215b9d 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h @@ -761,9 +761,9 @@ static inline int sci_rxd_in(struct uart_port *port) static inline int scbrr_calc(struct uart_port *port, int bps, int clk) { if (port->type == PORT_SCIF) - return (clk+16*bps)/(32*bps)-1; + return (clk/(32*bps))-1; else - return ((clk*2)+16*bps)/(16*bps)-1; + return (clk/(16*bps))-1; } #define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk) #elif defined(__H8300H__) || defined(__H8300S__)