From patchwork Sat Nov 19 04:41:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 9437901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37D7360238 for ; Sat, 19 Nov 2016 04:41:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1919729941 for ; Sat, 19 Nov 2016 04:41:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 089722995B; Sat, 19 Nov 2016 04:41:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C5F729941 for ; Sat, 19 Nov 2016 04:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752419AbcKSEl3 (ORCPT ); Fri, 18 Nov 2016 23:41:29 -0500 Received: from vern.gendns.com ([206.190.152.46]:33396 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751690AbcKSEl3 (ORCPT ); Fri, 18 Nov 2016 23:41:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=08M8FNG+k99RcIsE0D0rLHFq15yj8yU9uwH+XSP0pY0=; b=dJEzLsvZprTPeYm/RhuUpz8Mmg M9Y6bdkRRCBZgnlS/NcKxS08Wae9rJ9Gjt7A5XiFwQl9A/ZvYW9byexf3HnOQVZFRbKcZGi3iugNS IJPl0Q5TSrSiTYqbAJTSDjBksocNqGsjUx/cOlzTPmC9xV18s665PJT7DnnQruFPrKPAA3eX+C3Lo baVxb5W3iizhKD0jAuSynm+uuvOb66P9qv4dTwE1CQd56YBob4891DQRhDlY7mfixMM7qGhub5T2n G2ai3SEt4A1rb2RBaI8O0smH7s1FrYBD0uhIWb4NRTlE8krdk77bkoOYsrdI/BPYY1q3TBB3WFYo2 QrPG0b0A==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:42610 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.87) (envelope-from ) id 1c7xSu-001ZD7-GP; Fri, 18 Nov 2016 23:41:24 -0500 From: David Lechner To: Mark Brown Cc: David Lechner , nsekhar@ti.com, khilman@kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: davinci: Allow device tree devices to use DMA Date: Fri, 18 Nov 2016 22:41:04 -0600 Message-Id: <1479530464-12538-1-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This makes SPI devices specified in a device tree use DMA when the master controller has DMA configured. Since device tree is supposed to only describe the hardware, adding a configuration option to device tree to enable DMA per-device would not be acceptable. So, this is the best we can do for now to get SPI devices working with DMA when using device tree. Unfortunately, this excludes the possibility of using one SPI device with DMA and one without on the same master. I have tested this on LEGO MINDSTORMS EV3 using the NOR flash. Reading the flash memory would fail with -EIO when DMA is not enabled for the device. Signed-off-by: David Lechner --- drivers/spi/spi-davinci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index d36c11b..c6cf73a 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -388,6 +388,7 @@ static int davinci_spi_setup_transfer(struct spi_device *spi, static int davinci_spi_of_setup(struct spi_device *spi) { struct davinci_spi_config *spicfg = spi->controller_data; + struct davinci_spi *dspi = spi_master_get_devdata(spi->master); struct device_node *np = spi->dev.of_node; u32 prop; @@ -400,6 +401,9 @@ static int davinci_spi_of_setup(struct spi_device *spi) if (!of_property_read_u32(np, "ti,spi-wdelay", &prop)) spicfg->wdelay = (u8)prop; spi->controller_data = spicfg; + /* Use DMA for device if master supports it */ + if (dspi->dma_rx) + spicfg->io_type = SPI_IO_TYPE_DMA; } return 0;