From patchwork Mon Nov 12 08:52:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 1727081 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 53CA13FCAE for ; Mon, 12 Nov 2012 09:04:45 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TXptM-0006Wb-LH; Mon, 12 Nov 2012 09:01:17 +0000 Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TXpp2-0003lA-CU for linux-arm-kernel@lists.infradead.org; Mon, 12 Nov 2012 08:56:50 +0000 Received: from penbh01.corp.atmel.com ([10.168.5.31]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id qAC8pRWp029566; Mon, 12 Nov 2012 00:51:31 -0800 (PST) Received: from penmb01.corp.atmel.com ([10.168.5.33]) by penbh01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Nov 2012 16:56:35 +0800 Received: from shaarm01.corp.atmel.com ([10.217.6.34]) by penmb01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Nov 2012 16:56:34 +0800 From: Wenyou Yang To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 13/17] spi/atmel_spi: add function to read the spi data from the dts Date: Mon, 12 Nov 2012 16:52:33 +0800 Message-Id: <1352710357-3265-14-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352710357-3265-1-git-send-email-wenyou.yang@atmel.com> References: <1352710357-3265-1-git-send-email-wenyou.yang@atmel.com> X-OriginalArrivalTime: 12 Nov 2012 08:56:34.0754 (UTC) FILETIME=[9E161A20:01CDC0B3] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121112_035649_824141_A6C24C70 X-CRM114-Status: GOOD ( 13.45 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 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: linux-doc@vger.kernel.org, JM.Lin@atmel.com, nicolas.ferre@atmel.com, wenyou.yang@atmel.com, grant.likely@secretlab.ca, rob@landley.net, spi-devel-general@lists.sourceforge.net, devicetree-discuss@lists.ozlabs.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 The spi data include: dma_type and version. dma_type to decide the SPI xfer mode: = 1(pdc), = 2(dmaengine), 0(no dma, using PIO) version to give the SPI ip version. Signed-off-by: Wenyou Yang Cc: grant.likely@secretlab.ca Cc: rob@landley.net Cc: devicetree-discuss@lists.ozlabs.org Cc: linux-doc@vger.kernel.org Cc: spi-devel-general@lists.sourceforge.net --- .../devicetree/bindings/spi/spi_atmel.txt | 4 +++ drivers/spi/spi-atmel.c | 28 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi_atmel.txt b/Documentation/devicetree/bindings/spi/spi_atmel.txt index 20cdc91..a1ceeb5 100644 --- a/Documentation/devicetree/bindings/spi/spi_atmel.txt +++ b/Documentation/devicetree/bindings/spi/spi_atmel.txt @@ -6,6 +6,8 @@ Required properties: - interrupts: Should contain macb interrupt - cs-gpio: Should contain the GPIOs used for chipselect. - dma-mask: device coherent dma mask. +- dma_type: The dma type supported by the spi of SoC: = 0 (no used), = 1 (pdc), = 2 (dma) +- version: The version of the spi IP. spi0: spi@f0000000 { #address-cells = <1>; @@ -19,5 +21,7 @@ spi0: spi@f0000000 { &pioB 3 0 /* conflicts with ERXDV */ >; dma-mask = <0xffffffff>; + dma_type = <1>; + version = <2>; status = "disabled"; }; diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 568df5b..791800e 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1467,6 +1467,30 @@ static void atmel_spi_cleanup(struct spi_device *spi) kfree(asd); } +static int of_get_atmel_spi_data(struct device_node *np, struct atmel_spi *as) +{ + const __be32 *val; + + val = of_get_property(np, "dma_type", NULL); + if (!val) { + pr_err("%s: have no 'dma_type' property\n", + np->full_name); + return -EINVAL; + } + + as->data.dma_type = be32_to_cpup(val); + + val = of_get_property(np, "version", NULL); + if (!val) { + pr_err("%s: have no 'version' property\n", np->full_name); + return -EINVAL; + } + + as->data.version = be32_to_cpup(val); + + return 0; +} + /*-------------------------------------------------------------------------*/ static int __devinit atmel_spi_probe(struct platform_device *pdev) @@ -1535,6 +1559,10 @@ static int __devinit atmel_spi_probe(struct platform_device *pdev) if (ret) goto out_unmap_regs; + ret = of_get_atmel_spi_data(pdev->dev.of_node, as); + if (ret) + goto out_unmap_regs; + /* Initialize the hardware */ clk_enable(clk); spi_writel(as, CR, SPI_BIT(SWRST));