From patchwork Fri Apr 26 15:47:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2494201 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id AF2D4DF230 for ; Fri, 26 Apr 2013 15:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756898Ab3DZPr2 (ORCPT ); Fri, 26 Apr 2013 11:47:28 -0400 Received: from moutng.kundenserver.de ([212.227.17.9]:53322 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756690Ab3DZPr0 (ORCPT ); Fri, 26 Apr 2013 11:47:26 -0400 Received: from axis700.grange (dslb-088-076-028-093.pools.arcor-ip.net [88.76.28.93]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0ME295-1UHB5S00wp-00HNBu; Fri, 26 Apr 2013 17:47:21 +0200 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id 7012040BB4; Fri, 26 Apr 2013 17:47:20 +0200 (CEST) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1UVkro-0005t9-5T; Fri, 26 Apr 2013 17:47:20 +0200 From: Guennadi Liakhovetski To: linux-sh@vger.kernel.org Cc: Magnus Damm , linux-mmc@vger.kernel.org, Chris Ball , Samuel Ortiz , Vinod Koul , Guennadi Liakhovetski Subject: [PATCH 2/3] mmc: sdhi/tmio: switch to using dmaengine_slave_config() Date: Fri, 26 Apr 2013 17:47:18 +0200 Message-Id: <1366991239-22602-3-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1366991239-22602-1-git-send-email-g.liakhovetski@gmx.de> References: <1366991239-22602-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:KXTGNaV5+HPYx3E8QPTP5ynpsCUsZr/29vQLuTFSWOn ojM3dudxYIYqPmmpool/Xt/16a9X9o2vehP7bmxnJLxGUemt9U rpXHALpuBZU5pRJdtxYUO6726YDjTmy2Jbf7ex3EAY2cu+9rYD gdpnuFqcdJSqNbLXq/CEqqLeh0JwmamGx5SzkeEhc9oDIBgFSO MSDxAVJS1yBMalnTFTeojFq4EGtxu/Tp950HcegTEoN/xF8V5W U6Bv2Wnez0jTusWDTNI8vQReDSvykNZ9T3E/DH5EuTxh3gAjuX ihJHxdZE9l69j5posvypMAgkml9HlHn8HWQRlyIO+NzIZisM06 7S2uRVXaSPXsiVcKbFbPvDV6s0zjfxhQSeG2kQZ24U4jg/x24u qT0A4q3AoerZA== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org This removes the deprecated use of the .private member of struct dma_chan and switches the sdhi / tmio mmc driver to using the dmaengine_slave_config() channel configuration method. Signed-off-by: Guennadi Liakhovetski --- drivers/mmc/host/sh_mobile_sdhi.c | 33 ++++++++++++++++----------------- drivers/mmc/host/tmio_mmc_dma.c | 25 +++++++++++++++++++++++++ include/linux/mfd/tmio.h | 2 ++ 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index e0088d7..7f45f62 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -47,8 +46,6 @@ static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = { struct sh_mobile_sdhi { struct clk *clk; struct tmio_mmc_data mmc_data; - struct sh_dmae_slave param_tx; - struct sh_dmae_slave param_rx; struct tmio_mmc_dma dma_priv; }; @@ -125,13 +122,6 @@ static void sh_mobile_sdhi_cd_wakeup(const struct platform_device *pdev) mmc_detect_change(dev_get_drvdata(&pdev->dev), msecs_to_jiffies(100)); } -static bool sh_mobile_sdhi_filter(struct dma_chan *chan, void *arg) -{ - dev_dbg(chan->device->dev, "%s: slave data %p\n", __func__, arg); - chan->private = arg; - return true; -} - static const struct sh_mobile_sdhi_ops sdhi_ops = { .cd_wakeup = sh_mobile_sdhi_cd_wakeup, }; @@ -194,13 +184,22 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) mmc_data->get_cd = sh_mobile_sdhi_get_cd; if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { - priv->param_tx.shdma_slave.slave_id = p->dma_slave_tx; - priv->param_rx.shdma_slave.slave_id = p->dma_slave_rx; - priv->dma_priv.chan_priv_tx = &priv->param_tx.shdma_slave; - priv->dma_priv.chan_priv_rx = &priv->param_rx.shdma_slave; - priv->dma_priv.alignment_shift = 1; /* 2-byte alignment */ - priv->dma_priv.filter = sh_mobile_sdhi_filter; - mmc_data->dma = &priv->dma_priv; + struct tmio_mmc_dma *dma_priv = &priv->dma_priv; + + /* + * Yes, we have to provide slave IDs twice to TMIO: + * once as a filter parameter and once for channel + * configuration as an explicit slave ID + */ + dma_priv->chan_priv_tx = (void *)p->dma_slave_tx; + dma_priv->chan_priv_rx = (void *)p->dma_slave_rx; + dma_priv->slave_id_tx = p->dma_slave_tx; + dma_priv->slave_id_rx = p->dma_slave_rx; + + dma_priv->alignment_shift = 1; /* 2-byte alignment */ + dma_priv->filter = shdma_chan_filter; + + mmc_data->dma = dma_priv; } } diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c index dc4b10b..5fcf14f 100644 --- a/drivers/mmc/host/tmio_mmc_dma.c +++ b/drivers/mmc/host/tmio_mmc_dma.c @@ -268,7 +268,14 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat return; if (!host->chan_tx && !host->chan_rx) { + struct resource *res = platform_get_resource(host->pdev, + IORESOURCE_MEM, 0); + struct dma_slave_config cfg = {}; dma_cap_mask_t mask; + int ret; + + if (!res) + return; dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); @@ -281,6 +288,14 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat if (!host->chan_tx) return; + cfg.slave_id = pdata->dma->slave_id_tx; + cfg.direction = DMA_MEM_TO_DEV; + cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift); + cfg.src_addr = 0; + ret = dmaengine_slave_config(host->chan_tx, &cfg); + if (ret < 0) + goto ecfgtx; + host->chan_rx = dma_request_channel(mask, pdata->dma->filter, pdata->dma->chan_priv_rx); dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__, @@ -289,6 +304,14 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat if (!host->chan_rx) goto ereqrx; + cfg.slave_id = pdata->dma->slave_id_rx; + cfg.direction = DMA_DEV_TO_MEM; + cfg.src_addr = cfg.dst_addr; + cfg.dst_addr = 0; + ret = dmaengine_slave_config(host->chan_rx, &cfg); + if (ret < 0) + goto ecfgrx; + host->bounce_buf = (u8 *)__get_free_page(GFP_KERNEL | GFP_DMA); if (!host->bounce_buf) goto ebouncebuf; @@ -302,9 +325,11 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat return; ebouncebuf: +ecfgrx: dma_release_channel(host->chan_rx); host->chan_rx = NULL; ereqrx: +ecfgtx: dma_release_channel(host->chan_tx); host->chan_tx = NULL; } diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h index 0990d8a..ce35113 100644 --- a/include/linux/mfd/tmio.h +++ b/include/linux/mfd/tmio.h @@ -86,6 +86,8 @@ struct dma_chan; struct tmio_mmc_dma { void *chan_priv_tx; void *chan_priv_rx; + int slave_id_tx; + int slave_id_rx; int alignment_shift; bool (*filter)(struct dma_chan *chan, void *arg); };