From patchwork Thu Jan 2 15:11:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 3425071 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8A4F49F2E9 for ; Thu, 2 Jan 2014 15:12:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 641782013A for ; Thu, 2 Jan 2014 15:12:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4506820136 for ; Thu, 2 Jan 2014 15:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751785AbaABPML (ORCPT ); Thu, 2 Jan 2014 10:12:11 -0500 Received: from gw-1.arm.linux.org.uk ([78.32.30.217]:54127 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751136AbaABPMK (ORCPT ); Thu, 2 Jan 2014 10:12:10 -0500 X-Greylist: delayed 305 seconds by postgrey-1.27 at vger.kernel.org; Thu, 02 Jan 2014 10:12:10 EST DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora; h=Date:Sender:Message-Id:Subject:Cc:To:From:References:In-Reply-To; bh=KOkP+ACKDg34piqU/4OFNQDateVUm6lrD8fbq4Z24+4=; b=lEqtzmZvLtbqSmPQxQ+z9u8w1oal8PCbLhlFByl9J8gP5DpAQYX4KYldy2dKshR0+zSTFD/yb4grYpS86ngfCwu/2i7c+m7OwJX+q04mtQ2b6BMbs229943QyinQ5R1/C2ib7AB2qggWqDyuQOl9F7PuEoHhe5MwhCuQA+BSIQU=; Received: from [2001:4d48:ad52:3201:222:68ff:fe15:37dd] (port=56311 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1Vyjvx-0003dd-Te; Thu, 02 Jan 2014 15:11:41 +0000 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1Vyjvx-0005F4-Gd; Thu, 02 Jan 2014 15:11:41 +0000 In-Reply-To: <20140102150836.GA3826@n2100.arm.linux.org.uk> References: <20140102150836.GA3826@n2100.arm.linux.org.uk> From: Russell King To: dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org Cc: Vinod Koul , Dan Williams Subject: [PATCH RFC 17/26] dmaengine: omap-dma: cleanup errata 3.3 handling Message-Id: Date: Thu, 02 Jan 2014 15:11:41 +0000 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 Signed-off-by: Russell King --- drivers/dma/omap-dma.c | 52 ++++++++++++++++++++++++++--------------------- 1 files changed, 29 insertions(+), 23 deletions(-) diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index a1aefe9fe3fe..04631e6732c4 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/omap-dma.c @@ -451,28 +451,39 @@ static size_t omap_dma_desc_size_pos(struct omap_desc *d, dma_addr_t addr) return size; } +/* + * OMAP 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is + * read before the DMA controller finished disabling the channel. + */ +static uint32_t omap_dma_chan_read_3_3(struct omap_chan *c, unsigned reg) +{ + struct omap_dmadev *od = to_omap_dma_dev(c->vc.chan.device); + uint32_t val; + + val = omap_dma_chan_read(c, reg); + if (val == 0 && od->plat->errata & DMA_ERRATA_3_3) + val = omap_dma_chan_read(c, reg); + + return val; +} + static dma_addr_t omap_dma_get_src_pos(struct omap_chan *c) { struct omap_dmadev *od = to_omap_dma_dev(c->vc.chan.device); - dma_addr_t addr; + dma_addr_t addr, cdac; - if (__dma_omap15xx(od->plat->dma_attr)) + if (__dma_omap15xx(od->plat->dma_attr)) { addr = omap_dma_chan_read(c, CPC); - else - addr = omap_dma_chan_read(c, CSAC); - - if (od->plat->errata & DMA_ERRATA_3_3 && addr == 0) - addr = omap_dma_chan_read(c, CSAC); + } else { + addr = omap_dma_chan_read_3_3(c, CSAC); + cdac = omap_dma_chan_read_3_3(c, CDAC); - if (!__dma_omap15xx(od->plat->dma_attr)) { /* * CDAC == 0 indicates that the DMA transfer on the channel has * not been started (no data has been transferred so far). * Return the programmed source start address in this case. */ - if (omap_dma_chan_read(c, CDAC)) - addr = omap_dma_chan_read(c, CSAC); - else + if (cdac == 0) addr = omap_dma_chan_read(c, CSSA); } @@ -487,21 +498,16 @@ static dma_addr_t omap_dma_get_dst_pos(struct omap_chan *c) struct omap_dmadev *od = to_omap_dma_dev(c->vc.chan.device); dma_addr_t addr; - if (__dma_omap15xx(od->plat->dma_attr)) + if (__dma_omap15xx(od->plat->dma_attr)) { addr = omap_dma_chan_read(c, CPC); - else - addr = omap_dma_chan_read(c, CDAC); + } else { + addr = omap_dma_chan_read_3_3(c, CDAC); - /* - * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is - * read before the DMA controller finished disabling the channel. - */ - if (!__dma_omap15xx(od->plat->dma_attr) && addr == 0) { - addr = omap_dma_chan_read(c, CDAC); /* - * CDAC == 0 indicates that the DMA transfer on the channel has - * not been started (no data has been transferred so far). - * Return the programmed destination start address in this case. + * CDAC == 0 indicates that the DMA transfer on the channel + * has not been started (no data has been transferred so + * far). Return the programmed destination start address in + * this case. */ if (addr == 0) addr = omap_dma_chan_read(c, CDSA);