From patchwork Wed Apr 22 11:33:53 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 19343 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 n3MBaN2x000997 for ; Wed, 22 Apr 2009 11:36:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751477AbZDVLgU (ORCPT ); Wed, 22 Apr 2009 07:36:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752081AbZDVLgU (ORCPT ); Wed, 22 Apr 2009 07:36:20 -0400 Received: from ms01.sssup.it ([193.205.80.99]:57257 "EHLO sssup.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751477AbZDVLgT (ORCPT ); Wed, 22 Apr 2009 07:36:19 -0400 Received: from [193.205.82.7] (HELO gandalf.sssup.it) by sssup.it (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 50175670; Wed, 22 Apr 2009 13:28:48 +0200 Received: from [10.30.3.179] (vpn179.retis [10.30.3.179]) by gandalf.sssup.it (8.12.10/8.12.10) with ESMTP id n3MBaExj025277 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 22 Apr 2009 13:36:15 +0200 Message-ID: <49EF00A1.9080004@gandalf.sssup.it> Date: Wed, 22 Apr 2009 13:33:53 +0200 From: Michael Trimarchi User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Paul Mundt CC: SH-Linux Subject: Re: [RFC patch] sci_tx_empty for scif serial device References: <20090421120846.GA26186@gandalf.sssup.it> <20090422003417.GB23986@linux-sh.org> <49EEB5AF.9050603@gandalf.sssup.it> In-Reply-To: <49EEB5AF.9050603@gandalf.sssup.it> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Hi, Michael Trimarchi wrote: > Hi, > > Paul Mundt wrote: >> On Tue, Apr 21, 2009 at 02:08:47PM +0200, Michael Trimarchi wrote: >> >>> Add the sci_tx_empty function for scif serial device. >>> >>> Signed-off-by: Michael Trimarchi >>> --- >>> diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c >>> index dbf5357..6cea2c4 100644 >>> --- a/drivers/serial/sh-sci.c >>> +++ b/drivers/serial/sh-sci.c >>> @@ -794,6 +794,20 @@ static void sci_free_irq(struct sci_port *port) >>> >>> static unsigned int sci_tx_empty(struct uart_port *port) >>> { >>> + int txroom = SCIF_TXROOM_MAX; >>> + >>> +#if defined(CONFIG_CPU_SUBTYPE_SH7763) >>> + if (!(port->mapbase == 0xffe00000) && >>> + !(port->mapbase == 0xffe08000)) { >>> + txroom == SCIF2_TXROOM_MAX) >>> + } >>> +#endif >>> >> >> Uhm.. your version of gcc must be orders of magnitude more magical than >> mine, as I see no way for this to compile :-) >> > Of course is wrong here, I don't try the SH7763 configuration. Sorry... >> >>> + if (port->type == PORT_SCIF) { >>> + if (scif_txroom(port) == txroom) >>> + return TIOCSER_TEMT; >>> + return 0; >>> + } >>> + >>> >> This looks ok anyways, is there some reason this can't be applied to >> SH7763, too? >> >> > Apart the compilation issue, the sh7763 has the SCIF2 port has a > txroom different. > > I would like to know if it is correct that the fifosize of serial > device may equal to the > tx buffer size. In this case I can change the txroom and tx_empty > using this info from > the port strucy for scif device. For the sci device I don't think that > it is useful to read the tx status register to check if it's empty or > full, maybe no. > > Michael > > -- > 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 > Somenthing like this. It is just an example. static inline int scif_rxroom(struct uart_port *port) @@ -297,18 +293,6 @@ static inline int scif_rxroom(struct uart_port *port) return sci_in(port, SCRFDR) & 0xff; } #elif defined(CONFIG_CPU_SUBTYPE_SH7763) -static inline int scif_txroom(struct uart_port *port) -{ - if ((port->mapbase == 0xffe00000) || - (port->mapbase == 0xffe08000)) { - /* SCIF0/1*/ - return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff); - } else { - /* SCIF2 */ - return SCIF2_TXROOM_MAX - (sci_in(port, SCFDR) >> 8); - } -} - static inline int scif_rxroom(struct uart_port *port) { if ((port->mapbase == 0xffe00000) || @@ -321,10 +305,6 @@ static inline int scif_rxroom(struct uart_port *port) } } #else -static inline int scif_txroom(struct uart_port *port) -{ - return SCIF_TXROOM_MAX - (sci_in(port, SCFDR) >> 8); -} static inline int scif_rxroom(struct uart_port *port) { @@ -794,6 +774,12 @@ static void sci_free_irq(struct sci_port *port) static unsigned int sci_tx_empty(struct uart_port *port) { + if (port->type == PORT_SCIF) { + if (scif_txroom(port) == port->fifosize) + return TIOCSER_TEMT; + return 0; + } + /* Can't detect */ return TIOCSER_TEMT; } @@ -1255,6 +1241,7 @@ static int __devinit sci_probe(struct platform_device *dev) sciport->port.irq = p->irqs[SCIx_TXI_IRQ]; sciport->port.flags = p->flags; sciport->port.dev = &dev->dev; + sciport->port.fifosize = p->fifosize; sciport->type = sciport->port.type = p->type; --- 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.c b/drivers/serial/sh-sci.c index dbf5357..50563af 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c @@ -283,13 +283,9 @@ static inline void sci_init_pins(struct uart_port *port, unsigned int cflag) } #endif -#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ - defined(CONFIG_CPU_SUBTYPE_SH7780) || \ - defined(CONFIG_CPU_SUBTYPE_SH7785) || \ - defined(CONFIG_CPU_SUBTYPE_SH7786) static inline int scif_txroom(struct uart_port *port) { - return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff); + return port->fifosize - (sci_in(port, SCTFDR) & 0xff); }