From patchwork Tue Apr 14 03:08:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Mundt X-Patchwork-Id: 18013 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 n3E3DnK0016220 for ; Tue, 14 Apr 2009 03:13:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754627AbZDNDNK (ORCPT ); Mon, 13 Apr 2009 23:13:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754635AbZDNDNK (ORCPT ); Mon, 13 Apr 2009 23:13:10 -0400 Received: from 124x34x33x190.ap124.ftth.ucom.ne.jp ([124.34.33.190]:46658 "EHLO master.linux-sh.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754627AbZDNDNI (ORCPT ); Mon, 13 Apr 2009 23:13:08 -0400 Received: from localhost (unknown [127.0.0.1]) by master.linux-sh.org (Postfix) with ESMTP id DA53763754; Tue, 14 Apr 2009 03:08:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at linux-sh.org Received: from master.linux-sh.org ([127.0.0.1]) by localhost (master.linux-sh.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pKhNGztWZTPn; Tue, 14 Apr 2009 12:08:13 +0900 (JST) Received: by master.linux-sh.org (Postfix, from userid 500) id 2D97C63758; Tue, 14 Apr 2009 12:08:13 +0900 (JST) Date: Tue, 14 Apr 2009 12:08:13 +0900 From: Paul Mundt To: morimoto.kuninori@renesas.com Cc: SH-Linux Subject: Re: [Review request] sh-sci clock Message-ID: <20090414030812.GC17618@linux-sh.org> Mail-Followup-To: Paul Mundt , morimoto.kuninori@renesas.com, SH-Linux References: <20090414000048.GA17618@linux-sh.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org On Tue, Apr 14, 2009 at 11:08:50AM +0900, morimoto.kuninori@renesas.com wrote: > > > 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__) > > > > This looks like an unrelated change, can you explain what this is about? > > When SCIFA of SH7723/SH7724 use bus_clk, > SCBRR value calculation will be changed. > > Current SCIFA use module_clk, > and above calculation for SH7723 is (mey be) depend on ap325 board. > module_clk of ap325 is 33MHz and bus_clk is 66MHz, > mey be (clk*2) mean it. > But ms7724se module_clk is 33MHz and bus_clk is 83MHz. > So, ms7724se board's SCIFA can not work on it. > Ok. > And current SCIF(SCIFA also) calculation is wrong. > I don't know why this calculation is used. > Good question.. lets see what git blame has to say about it: pmundt@dysnomia ~/devel/git/linux-2.6 $ git show ba1d2818 commit ba1d28181c586deec468cc6ae558c0c099f1b956 Author: Nobuhiro Iwamatsu Date: Fri Oct 3 17:37:31 2008 +0900 serial: sh-sci: Add support SCIF of SH7723 SH7723 has two types of SCIF (SCIF and SCIFA). The current sh-sci driver supports only SCIFA, and calculation methods of SCBRR are different. This patch support this methods. Signed-off-by: Nobuhiro Iwamatsu Signed-off-by: Paul Mundt > return (clk+16*bps)/(32*bps)-1; > => > return clk/(32*bps) - 1/2; > > This calculation might be OK by lucky. > I have not looked at the SCIFA SCBRR algorithm, though it seems Iwamatsu-san has. Please split this part of the patch out separately, and get some feedback from Iwamatsu-san on it to make sure it doesn't break any boards. Maybe there is some strange Hitachi ULSI board with magical clock settings.. or someone copied the wrong line from the manual (possibly because the data sheet was suffering from accuracy problems).. :-) --- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index 511c10d..7cd28b2 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h @@ -789,7 +789,14 @@ static inline int sci_rxd_in(struct uart_port *port) defined(CONFIG_CPU_SUBTYPE_SH7721) #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) #elif defined(CONFIG_CPU_SUBTYPE_SH7723) -#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(16*bps)-1) +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; + else + return ((clk*2)+16*bps)/(16*bps)-1; +} +#define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk) #elif defined(__H8300H__) || defined(__H8300S__) #define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1) #else /* Generic SH */