From patchwork Tue Sep 18 18:21:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1474181 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 7CFD73FCFC for ; Tue, 18 Sep 2012 18:28:29 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TE2Uu-0007u8-Gr; Tue, 18 Sep 2012 18:26:12 +0000 Received: from mail-yx0-f201.google.com ([209.85.213.201]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TE2TO-0007KF-Mj for linux-arm-kernel@lists.infradead.org; Tue, 18 Sep 2012 18:24:43 +0000 Received: by yenr11 with SMTP id r11so18970yen.0 for ; Tue, 18 Sep 2012 11:24:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=musvVOMLZKmXtdhtZsaZyK/p0wn1Q9CKGB2g8ZTSiEM=; b=EkudqmOvog7p1jgbdVh/RIWocvWFPWMBs4H6s6q6TSjj+jGB4i/NYv+oVYIJgsyQLT 0StdrjNEpULIgbj+y5LGcYYVRIz2FPPfMIhoXXapD501uOkCthKYQ8J2d6tUkCb9OD4W QCFlHwVJu8Po5/vSk5z+8V2jXbvESpGyq1ClYhXQXUAeaBk2KBSIM4719uGjoiKIjjcR 5SOpEe7/cnc6t35gGXojZXyyejdzus5YvWM2Hf83CGeyf3qMA1Dem/bGRXoExCNBBWlG RoVApfVPLfUbXfJghjhDTUuR1rtgr8D90AhPYMH+wb1jROIs6+fJ+y3SA3EjXNK8Rtkt BbLg== Received: by 10.236.91.229 with SMTP id h65mr465874yhf.24.1347992674201; Tue, 18 Sep 2012 11:24:34 -0700 (PDT) Received: by 10.236.91.229 with SMTP id h65mr465848yhf.24.1347992673566; Tue, 18 Sep 2012 11:24:33 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id c61si68942yhm.3.2012.09.18.11.24.33 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 18 Sep 2012 11:24:33 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 525C71E0043; Tue, 18 Sep 2012 11:24:33 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 0399C162135; Tue, 18 Sep 2012 11:24:32 -0700 (PDT) From: Simon Glass To: LKML , linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/7] spi: s3c64xx: Allow use with SPI ports without dma Date: Tue, 18 Sep 2012 11:21:57 -0700 Message-Id: <1347992519-6904-6-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1347992519-6904-1-git-send-email-sjg@chromium.org> References: <1347992519-6904-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQlbMYbb0QdAXtEKXIhlq2RrqrXXBpZ9Rvp4tqTmUbhNTt6/ONjMdX26j+ZH8MgpBdRXWdHrUesmdPuWIWlIBS7bOuKPyftKnmFU2FsmXA2TYQVTXp7aydajDO+bebxuYyJuvJgvV/695N2pRcSDbpP3J6zhhDp01Z5n/jMbeSXOeEMvg2XwKPHzjgLevEH3xoKwRUrq/5oEyoFKJH68arfFKBsAEg== X-Spam-Note: CRM114 invocation failed X-Spam-Score: -3.1 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.213.201 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.5 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] Cc: Simon Glass , "kgene.kim" , Ben Dooks , Srinivas KANDAGATLA 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: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The ISP SPI ports appear not to support dma. Allow these to work to some extent. The current driver will not permit transfers larger than the FIFO size, which is 256 bytes in the case of the ISP SPI ports, unless dma is enabled. Signed-off-by: Simon Glass --- drivers/spi/spi-s3c64xx.c | 54 ++++++++++++++++++++++++++++---------------- 1 files changed, 34 insertions(+), 20 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index db79d87..ed12872 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -675,6 +675,7 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, int status = 0, cs_toggle = 0; u32 speed; u8 bpw; + bool have_dma; /* If Master's(controller) state differs from that needed by Slave */ if (sdd->cur_speed != spi->max_speed_hz @@ -686,12 +687,14 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, s3c64xx_spi_config(sdd); } + have_dma = (sdd->rx_dma.direction != DMA_NONE); + /* Map all the transfers if needed */ - if (s3c64xx_spi_map_mssg(sdd, msg)) { + if (have_dma && s3c64xx_spi_map_mssg(sdd, msg)) { dev_err(&spi->dev, "Xfer: Unable to map message buffers!\n"); status = -ENOMEM; - goto out; + goto out_nomap; } /* Configure feedback delay */ @@ -722,8 +725,12 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, s3c64xx_spi_config(sdd); } - /* Polling method for xfers not bigger than FIFO capacity */ - if (xfer->len <= ((FIFO_LVL_MASK(sdd) >> 1) + 1)) + /* + * Polling method if we have no DMA support and for xfers + * not bigger than FIFO capacity + */ + if (xfer->len <= ((FIFO_LVL_MASK(sdd) >> 1) + 1) || + sdd->rx_dma.direction == DMA_NONE) use_dma = 0; else use_dma = 1; @@ -794,8 +801,9 @@ out: else sdd->tgl_spi = spi; - s3c64xx_spi_unmap_mssg(sdd, msg); - + if (have_dma) + s3c64xx_spi_unmap_mssg(sdd, msg); +out_nomap: msg->status = status; spi_finalize_current_message(master); @@ -807,9 +815,11 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) { struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); - /* Acquire DMA channels */ - while (!acquire_dma(sdd)) - msleep(10); + if (sdd->rx_dma.direction != DMA_NONE) { + /* Acquire DMA channels */ + while (!acquire_dma(sdd)) + msleep(10); + } pm_runtime_get_sync(&sdd->pdev->dev); @@ -820,9 +830,11 @@ static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi) { struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); - /* Free DMA channels */ - sdd->ops->release(sdd->rx_dma.ch, &s3c64xx_spi_dma_client); - sdd->ops->release(sdd->tx_dma.ch, &s3c64xx_spi_dma_client); + if (sdd->rx_dma.direction != DMA_NONE) { + /* Free DMA channels */ + sdd->ops->release(sdd->rx_dma.ch, &s3c64xx_spi_dma_client); + sdd->ops->release(sdd->tx_dma.ch, &s3c64xx_spi_dma_client); + } pm_runtime_put(&sdd->pdev->dev); @@ -1095,8 +1107,9 @@ static int __devinit s3c64xx_spi_get_dmares( sprintf(prop_name, "%s-dma-channel", chan_str); prop = of_find_property(pdev->dev.of_node, prop_name, NULL); if (!prop) { - dev_err(&pdev->dev, "%s dma channel property not specified\n", - chan_str); + dma_data->direction = DMA_NONE; + dev_warn(&pdev->dev, "%s no dma channel property" + " - falling back to PIO\n", chan_str); return -ENXIO; } @@ -1209,7 +1222,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) struct s3c64xx_spi_driver_data *sdd; struct s3c64xx_spi_info *sci = pdev->dev.platform_data; struct spi_master *master; - int ret, irq; + int ret, irq, ret_tx; char clk_name[16]; if (!sci && pdev->dev.of_node) { @@ -1264,13 +1277,14 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) sdd->cur_bpw = 8; - ret = s3c64xx_spi_get_dmares(sdd, true); - if (ret) - goto err0; - + /* These may fail, in which case we fall back to PIO */ + ret_tx = s3c64xx_spi_get_dmares(sdd, true); ret = s3c64xx_spi_get_dmares(sdd, false); - if (ret) + if (!!ret_tx != !!ret) { + dev_err(&pdev->dev, "dma rx/tx channels must either both be" + "enabled or disabled\n"); goto err0; + } master->dev.of_node = pdev->dev.of_node; master->bus_num = sdd->port_id;