From patchwork Mon Apr 4 21:53:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 8744711 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AC29BC0553 for ; Mon, 4 Apr 2016 21:56:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C18BC2022A for ; Mon, 4 Apr 2016 21:56:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6F1E201EF for ; Mon, 4 Apr 2016 21:56:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1anCRd-00012u-G8; Mon, 04 Apr 2016 21:54:01 +0000 Received: from vps0.lunn.ch ([178.209.37.122]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1anCRa-0000rg-Nh for linux-arm-kernel@lists.infradead.org; Mon, 04 Apr 2016 21:53:59 +0000 Received: from andrew by vps0.lunn.ch with local (Exim 4.80) (envelope-from ) id 1anCQv-00021L-Ld; Mon, 04 Apr 2016 23:53:17 +0200 From: Andrew Lunn To: Shawn Guo , Sascha Hauer , Stefan Agner Subject: [PATCH v5 1/2] serial: fsl_lpuart: Add DMA quirk Date: Mon, 4 Apr 2016 23:53:11 +0200 Message-Id: <1459806792-7729-2-git-send-email-andrew@lunn.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1459806792-7729-1-git-send-email-andrew@lunn.ch> References: <1459806792-7729-1-git-send-email-andrew@lunn.ch> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160404_145358_963979_5D291673 X-CRM114-Status: GOOD ( 12.98 ) X-Spam-Score: -2.9 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , linux ARM MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using DMA with the vf610 and other Vybrid devices results in a corrupt serial stream. Add a quirk to disable the use of DMA. Refactor the existing code to add a 32 bit access quirk for the fsl,ls1021a-lpuart. Signed-off-by: Andrew Lunn --- drivers/tty/serial/fsl_lpuart.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 3d790033744e..8d2f67b93e1f 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -257,12 +257,17 @@ struct lpuart_port { struct timer_list lpuart_timer; }; +#define QUIRK_LPUART32 BIT(0) +#define QUIRK_NO_DMA BIT(1) + static const struct of_device_id lpuart_dt_ids[] = { { .compatible = "fsl,vf610-lpuart", + .data = (void *)QUIRK_NO_DMA, }, { .compatible = "fsl,ls1021a-lpuart", + .data = (void *)QUIRK_LPUART32, }, { /* sentinel */ } }; @@ -1803,7 +1808,9 @@ static struct uart_driver lpuart_reg = { static int lpuart_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; + const struct of_device_id *match; struct lpuart_port *sport; + kernel_ulong_t quirks; struct resource *res; int ret; @@ -1819,7 +1826,10 @@ static int lpuart_probe(struct platform_device *pdev) return ret; } sport->port.line = ret; - sport->lpuart32 = of_device_is_compatible(np, "fsl,ls1021a-lpuart"); + + match = of_match_node(lpuart_dt_ids, np); + quirks = (kernel_ulong_t)match->data; + sport->lpuart32 = quirks & QUIRK_LPUART32; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sport->port.membase = devm_ioremap_resource(&pdev->dev, res); @@ -1867,15 +1877,21 @@ static int lpuart_probe(struct platform_device *pdev) return ret; } - sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx"); - if (!sport->dma_tx_chan) - dev_info(sport->port.dev, "DMA tx channel request failed, " - "operating without tx DMA\n"); - - sport->dma_rx_chan = dma_request_slave_channel(sport->port.dev, "rx"); - if (!sport->dma_rx_chan) - dev_info(sport->port.dev, "DMA rx channel request failed, " - "operating without rx DMA\n"); + if (quirks & QUIRK_NO_DMA) { + dev_info(sport->port.dev, "Not using DMA\n"); + } else { + sport->dma_tx_chan = dma_request_slave_channel( + sport->port.dev, "tx"); + if (!sport->dma_tx_chan) + dev_info(sport->port.dev, + "DMA tx channel request failed, operating without tx DMA\n"); + + sport->dma_rx_chan = dma_request_slave_channel( + sport->port.dev, "rx"); + if (!sport->dma_rx_chan) + dev_info(sport->port.dev, + "DMA rx channel request failed, operating without rx DMA\n"); + } return 0; }