From patchwork Thu Aug 30 16:34:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hein_Tibosch X-Patchwork-Id: 1388651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 01A7D3FDF5 for ; Thu, 30 Aug 2012 17:52:12 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T78rU-0001X0-QH; Thu, 30 Aug 2012 17:49:00 +0000 Received: from bombadil.infradead.org ([2001:4830:2446:ff00:4687:fcff:fea6:5117]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T78rR-0001Wi-Ku for linux-arm-kernel@merlin.infradead.org; Thu, 30 Aug 2012 17:48:57 +0000 Received: from bosmailout09.eigbox.net ([66.96.187.9]) by bombadil.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T78rQ-0004fX-1n for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2012 17:48:56 +0000 Received: from bosmailscan15.eigbox.net ([10.20.15.15]) by bosmailout09.eigbox.net with esmtp (Exim) id 1T78rN-00027v-Fl for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2012 13:48:53 -0400 Received: from bosimpout01.eigbox.net ([10.20.55.1]) by bosmailscan15.eigbox.net with esmtp (Exim) id 1T78rN-00022E-5A; Thu, 30 Aug 2012 13:48:53 -0400 Received: from bosauthsmtp02.eigbox.net ([10.20.18.2]) by bosimpout01.eigbox.net with NO UCE id t5ot1j00302gpmq015otcE; Thu, 30 Aug 2012 13:48:53 -0400 X-Authority-Analysis: v=2.0 cv=aPZHX8Bm c=1 sm=1 a=EVDLJLhrg0sUKeqAW2r0xw==:17 a=bc2JKO6qiGsA:10 a=tW0haWE2Y5YA:10 a=yNKk50g6HJIA:10 a=8nJEP1OIZ-IA:10 a=yUBu062l_5EA:10 a=bJ0fqD8TFZgqkSadqForXVIPBlU=:19 a=jAfPOIUMAAAA:8 a=6yQVg0x1IOBCQPKcG9QA:9 a=wPNLvfGTeEIA:10 a=gE_ZUhsuebIA:10 a=9MP9vxlQrmnoeofDS6o88g==:117 X-EN-OrigOutIP: 10.20.18.2 X-EN-IMPSID: t5ot1j00302gpmq015otcE Received: from [114.79.60.254] (helo=[10.251.242.253]) by bosauthsmtp02.eigbox.net with esmtpa (Exim) id 1T78rM-0004tr-1d; Thu, 30 Aug 2012 13:48:53 -0400 Message-ID: <503F961E.5010905@yahoo.es> Date: Fri, 31 Aug 2012 00:34:38 +0800 From: Hein Tibosch User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: Nicolas Ferre , "ludovic.desroches" Subject: [PATCH v2 1/2] mmc: atmel-mci: DMA can be used with other controller X-EN-UserInfo: 3946c951b80c12a8be5482963a0b1232:e0ae43bc192b431f8b69f09a37527cbc X-EN-AuthUser: hein@htibosch.net X-EN-OrigIP: 114.79.60.254 X-EN-OrigHost: unknown X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120830_134856_172110_FD7A7477 X-CRM114-Status: GOOD ( 11.94 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (hein_tibosch[at]yahoo.es) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED -0.0 SPF_PASS SPF: sender matches SPF record -0.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.9 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: Havard Skinnemoen , "linux-mmc@vger.kernel.org" , Chris Ball , linux-arm-kernel@lists.infradead.org, Hans-Christian Egtvedt X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org After the latest changes to atmel-mci, it could not be used with DMA on the AVR32 platform. This patch will allow to use DMA again and it will avoid access to MCI register ATMCI_DMA. v2: Even if the IP version is lower than v3xx and doesn't have the DMA configuration register, DMA transfers can be used with a different controller than the Atmel AHB DMA one. For instance, some AVR chips use the Synopsys DesignWare AHB DMA controller. v2: in atmci_configure_dma: check both pdata and pdata->dma_slave Signed-off-by: Hein Tibosch Acked-by: Ludovic Desroches --- drivers/mmc/host/atmel-mci.c | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index f2c115e..a6a5593 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -71,7 +71,7 @@ enum atmci_pdc_buf { }; struct atmel_mci_caps { - bool has_dma; + bool has_dma_conf_reg; bool has_pdc; bool has_cfg_reg; bool has_cstor_reg; @@ -411,7 +411,7 @@ static int atmci_regs_show(struct seq_file *s, void *v) atmci_show_status_reg(s, "SR", buf[ATMCI_SR / 4]); atmci_show_status_reg(s, "IMR", buf[ATMCI_IMR / 4]); - if (host->caps.has_dma) { + if (host->caps.has_dma_conf_reg) { u32 val; val = buf[ATMCI_DMA / 4]; @@ -767,7 +767,7 @@ static void atmci_dma_complete(void *arg) dev_vdbg(&host->pdev->dev, "DMA complete\n"); - if (host->caps.has_dma) + if (host->caps.has_dma_conf_reg) /* Disable DMA hardware handshaking on MCI */ atmci_writel(host, ATMCI_DMA, atmci_readl(host, ATMCI_DMA) & ~ATMCI_DMAEN); @@ -954,7 +954,9 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) maxburst = atmci_convert_chksize(host->dma_conf.dst_maxburst); } - atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(maxburst) | ATMCI_DMAEN); + if (host->caps.has_dma_conf_reg) + atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(maxburst) | + ATMCI_DMAEN); sglen = dma_map_sg(chan->device->dev, data->sg, data->sg_len, direction); @@ -2161,7 +2163,10 @@ static bool atmci_configure_dma(struct atmel_mci *host) pdata = host->pdev->dev.platform_data; - if (pdata && find_slave_dev(pdata->dma_slave)) { + if (!pdata) + return false; + + if (pdata->dma_slave && find_slave_dev(pdata->dma_slave)) { dma_cap_mask_t mask; /* Try to grab a DMA channel */ @@ -2202,7 +2207,7 @@ static void __init atmci_get_cap(struct atmel_mci *host) dev_info(&host->pdev->dev, "version: 0x%x\n", version); - host->caps.has_dma = 0; + host->caps.has_dma_conf_reg = 0; host->caps.has_pdc = 1; host->caps.has_cfg_reg = 0; host->caps.has_cstor_reg = 0; @@ -2219,12 +2224,7 @@ static void __init atmci_get_cap(struct atmel_mci *host) host->caps.has_odd_clk_div = 1; case 0x400: case 0x300: -#ifdef CONFIG_AT_HDMAC - host->caps.has_dma = 1; -#else - dev_info(&host->pdev->dev, - "has dma capability but dma engine is not selected, then use pio\n"); -#endif + host->caps.has_dma_conf_reg = 1; host->caps.has_pdc = 0; host->caps.has_cfg_reg = 1; host->caps.has_cstor_reg = 1; @@ -2298,7 +2298,7 @@ static int __init atmci_probe(struct platform_device *pdev) /* Get MCI capabilities and set operations according to it */ atmci_get_cap(host); - if (host->caps.has_dma && atmci_configure_dma(host)) { + if (atmci_configure_dma(host)) { host->prepare_data = &atmci_prepare_data_dma; host->submit_data = &atmci_submit_data_dma; host->stop_transfer = &atmci_stop_transfer_dma;