From patchwork Tue Aug 14 13:49:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 1319581 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id B7A11DF215 for ; Tue, 14 Aug 2012 14:00: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 1T1Hb7-0003Ti-73; Tue, 14 Aug 2012 13:55:55 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T1HW6-0000bp-IQ for linux-arm-kernel@lists.infradead.org; Tue, 14 Aug 2012 13:50:48 +0000 Received: by weyr3 with SMTP id r3so277996wey.36 for ; Tue, 14 Aug 2012 06:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=wpTUjCYcoSE4HcP9U6gc75sGV8XrpA8ibQ29zIU1Wko=; b=HNAhaULm1CPGGGwG7RWiZYbPv2PYPDxcuN2TNLqIE1d5JKU9Lo6KBNXbrB/Nn/r3GK 6WgsUbboNTLOVNMFEtJ2KI5oXp43HnbQyrQ/gwdQEhlZWBblejiZm8+EHor0NCzGwMkx Gdj7/NuAyRyWkizPxETfzmGGYhrAwiD3hBZSy+m8VFgCvmgTaFFnGw1QvX27bV5xwpTq t/7qZHhxuJD6sPiZXqXVzgRvDuGtroY21r1czem6SlwyZYBnDhM4U5Q4LPbIM0O5jH+O hnOfxW2Qe51HjwOLVxjFzEPYjAfJQt7+bNNvFDR1NVjbDbUKNmE9PItgU1iptJb1B06C IArg== Received: by 10.180.76.36 with SMTP id h4mr28103250wiw.13.1344952241440; Tue, 14 Aug 2012 06:50:41 -0700 (PDT) Received: from localhost.localdomain (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPS id eu4sm22509397wib.2.2012.08.14.06.50.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Aug 2012 06:50:40 -0700 (PDT) From: Richard Genoud To: Nicolas Ferre Subject: [PATCH 15/23] spi-atmel: add DMA OF support Date: Tue, 14 Aug 2012 15:49:29 +0200 Message-Id: <1344952177-18385-16-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1344952177-18385-1-git-send-email-richard.genoud@gmail.com> References: <1344952177-18385-1-git-send-email-richard.genoud@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (richard.genoud[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Richard Genoud , Jean-Christophe PLAGNIOL-VILLARD , linux-arm-kernel@lists.infradead.org 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 Signed-off-by: Richard Genoud --- drivers/of/of_atmel.c | 1 - drivers/spi/spi-atmel.c | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/drivers/of/of_atmel.c b/drivers/of/of_atmel.c index bcd3c54a..a59b9ced 100644 --- a/drivers/of/of_atmel.c +++ b/drivers/of/of_atmel.c @@ -55,7 +55,6 @@ struct at_dma_slave *of_create_at_dma_slave(struct device_node *np, atslave->cfg |= of_property_read_bool(np, "atc_sod") ? ATC_SOD : 0; atslave->cfg |= of_property_read_bool(np, "atc_lock_if") ? ATC_LOCK_IF : 0; atslave->cfg |= of_property_read_bool(np, "atc_lock_b") ? ATC_LOCK_B : 0; - atslave->cfg |= of_property_read_bool(np, "atc_lock_if_l") ? ATC_LOCK_IF_L : 0; atslave->cfg |= of_property_read_bool(np, "atc_lock_if_l_buffer") ? ATC_LOCK_IF_L_BUFFER : 0; if (of_property_read_bool(np, "atc_fifocfg_halffifo")) atslave->cfg = (atslave->cfg & ~ATC_FIFOCFG_MASK) | ATC_FIFOCFG_HALFFIFO; diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 28a00ab..d629422 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -1411,6 +1412,8 @@ static int __devinit atmel_spi_probe(struct platform_device *pdev) int ret; struct spi_master *master; struct atmel_spi *as; + struct bus_type *bus = pdev->dev.bus; + struct device_node *of = pdev->dev.of_node; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!regs) @@ -1430,6 +1433,17 @@ static int __devinit atmel_spi_probe(struct platform_device *pdev) if (!master) goto out_free; + + /* populate platform_data from device tree */ + if (of) { + pdev->dev.platform_data = of_create_at_dma_slave(of, bus); + if (!pdev->dev.platform_data) { + dev_err(&pdev->dev, "could not get DMA\n"); + ret = -EINVAL; + goto out_free; + } + } + /* the spi->mode bits understood by this driver: */ master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; @@ -1504,6 +1518,10 @@ out_free_buffer: dma_free_coherent(&pdev->dev, BUFFER_SIZE, as->buffer, as->buffer_dma); out_free: + if (of) { + kfree((struct at_dma_slave*)(pdev->dev.platform_data)); + pdev->dev.platform_data = NULL; + } clk_put(clk); spi_master_put(master); return ret; @@ -1546,6 +1564,10 @@ static int __devexit atmel_spi_remove(struct platform_device *pdev) iounmap(as->regs); spi_unregister_master(master); + if (pdev->dev.of_node) { + kfree((struct at_dma_slave*)(pdev->dev.platform_data)); + pdev->dev.platform_data = NULL; + } return 0; }