From patchwork Fri Apr 26 15:47:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2494191 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 1DE913FD40 for ; Fri, 26 Apr 2013 15:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756738Ab3DZPr1 (ORCPT ); Fri, 26 Apr 2013 11:47:27 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:52586 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756684Ab3DZPr0 (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=mreu4) with ESMTP (Nemesis) id 0MM4YC-1UQHl00IWK-007htr; Fri, 26 Apr 2013 17:47:22 +0200 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id 79BD040BB5; Fri, 26 Apr 2013 17:47:20 +0200 (CEST) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1UVkro-0005tC-71; 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 3/3] mmc: sdhi/tmio: add DT DMA support Date: Fri, 26 Apr 2013 17:47:19 +0200 Message-Id: <1366991239-22602-4-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:BwUEmhT8m6xOwKAL4mNH0Eaxf0DWPRsaYN6gIh8dg3U 3Fo/OR0e03jiIt9uva0gVZDsYTDn4XlcHKLObuOny4cKGfu2q8 +y3rrUm5hEXSTg0X7Vj/rXDnHoHTieyb6KeNMzjpa7RAegko+n PiY+KPglM2OzcOg9pdCn0JJxJStx9oXf0wiTxt+qRRfyVur4pY AUGZijd8INUbXtzn8kLas/GynfK7efo/xbsOEKwSmfOTOu7qi8 Iq8WEq0DqBM3+bbGWnc08Kd4iZue92/3BR1+CTON6YwPO0+zAZ d7yRTgGPJui+yCCF9hkB3wvArbyd3jCRZb76iOCHdoogy0ynTc ayqNrPS5OW4TgSAC+HA/0sw+JMvU1AG1v3dn8k+LkLdzXADWYZ QlCM+Rx+q2lKA== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Add support for initialising DMA from the Device Tree. Signed-off-by: Guennadi Liakhovetski --- drivers/mmc/host/sh_mobile_sdhi.c | 14 +++++++------- drivers/mmc/host/tmio_mmc_dma.c | 19 ++++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 7f45f62..cc4c872 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -144,6 +144,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) struct tmio_mmc_host *host; int irq, ret, i = 0; bool multiplexed_isr = true; + struct tmio_mmc_dma *dma_priv; priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL); if (priv == NULL) { @@ -152,6 +153,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) } mmc_data = &priv->mmc_data; + dma_priv = &priv->dma_priv; if (p) { if (p->init) { @@ -184,8 +186,6 @@ 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) { - 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 @@ -195,14 +195,14 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) 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; } } + dma_priv->alignment_shift = 1; /* 2-byte alignment */ + dma_priv->filter = shdma_chan_filter; + + mmc_data->dma = dma_priv; + /* * All SDHI blocks support 2-byte and larger block sizes in 4-bit * bus width mode. diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c index 5fcf14f..47bdb8f 100644 --- a/drivers/mmc/host/tmio_mmc_dma.c +++ b/drivers/mmc/host/tmio_mmc_dma.c @@ -264,7 +264,8 @@ out: void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata) { /* We can only either use DMA for both Tx and Rx or not use it at all */ - if (!pdata->dma) + if (!pdata->dma || (!host->pdev->dev.of_node && + (!pdata->dma->chan_priv_tx || !pdata->dma->chan_priv_rx))) return; if (!host->chan_tx && !host->chan_rx) { @@ -280,15 +281,17 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); - host->chan_tx = dma_request_channel(mask, pdata->dma->filter, - pdata->dma->chan_priv_tx); + host->chan_tx = dma_request_slave_channel_compat(mask, + pdata->dma->filter, pdata->dma->chan_priv_tx, + &host->pdev->dev, "tx"); dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__, host->chan_tx); if (!host->chan_tx) return; - cfg.slave_id = pdata->dma->slave_id_tx; + if (pdata->dma->chan_priv_tx) + 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; @@ -296,15 +299,17 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat if (ret < 0) goto ecfgtx; - host->chan_rx = dma_request_channel(mask, pdata->dma->filter, - pdata->dma->chan_priv_rx); + host->chan_rx = dma_request_slave_channel_compat(mask, + pdata->dma->filter, pdata->dma->chan_priv_rx, + &host->pdev->dev, "rx"); dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__, host->chan_rx); if (!host->chan_rx) goto ereqrx; - cfg.slave_id = pdata->dma->slave_id_rx; + if (pdata->dma->chan_priv_rx) + cfg.slave_id = pdata->dma->slave_id_rx; cfg.direction = DMA_DEV_TO_MEM; cfg.src_addr = cfg.dst_addr; cfg.dst_addr = 0;