From patchwork Sun Apr 23 19:19:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Middelschulte X-Patchwork-Id: 9695269 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 5086F6037D for ; Sun, 23 Apr 2017 19:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32B5724151 for ; Sun, 23 Apr 2017 19:20:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2556226224; Sun, 23 Apr 2017 19:20:56 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 A8C1624151 for ; Sun, 23 Apr 2017 19:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163314AbdDWTUy (ORCPT ); Sun, 23 Apr 2017 15:20:54 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33891 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757315AbdDWTUx (ORCPT ); Sun, 23 Apr 2017 15:20:53 -0400 Received: by mail-wm0-f65.google.com with SMTP id z129so13517299wmb.1; Sun, 23 Apr 2017 12:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=mmh1+Xb/qne4oGvldby1wT3e2bpw0LzzGwjxBc3X/tQ=; b=tVpzsWTAMpUI+vtMeU9GSwSTuy90sp3UVm+w3odFLJj3W1vZx8ya2AaZhIoPjpte77 R7FBsQc6U6G7YlNA+MCvLxexBwGWowsIKArmhGw0DR+YFnPY6bLZc9aymcMmx7EX/5/A CSyKPp/NVDZU7VDXKbs5TwHk+lSMvUAXapQfIxkD1LJq7BE0Nl9g8yu51NjsMfoudM2U XpShIJxzvnY3wUNELnhGHI28sMUlQerWbVW4zgP6L6Fs/Tu5H3I43AyRjCtaENPXZdc4 IacXpwKdpwEozh0O/TDnF+arT8t8miv//T5E9ZVsU6aDJRgDz9tKBbCyOHO90SmWkyQU wYKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mmh1+Xb/qne4oGvldby1wT3e2bpw0LzzGwjxBc3X/tQ=; b=Dbm6qHpe9QzRpYFSJ7JIp7E5/M9RGrpJFPN4BXG/bphNdu7E4+mp0hZ2oO94UlorJl y2pXhPLlB5klI2uM1Awglsy8MmKdJoLkqhlT0sIRN+bh0QVdyvWNarvUo4h80JCqPq9Q sH52y766AlZ21eHN7rNndUW4UIeOvh9wM47yQXek+4XM55XZyjLNvQvGnRoxaW4TqLo1 ZocmPJYe1n3sijI+8EtnWwzxakrBKYtmqqfyoyysMU1IgctmjZhqtYaILf1InYVK4Rgd DRMJL1XiPGInq7RKDUClHA2jl2OGQ58UX2ttXoxilrQS9Fu2f4eUTYXxMZgw2nQQoCmq hsvg== X-Gm-Message-State: AN3rC/69yKrkrJXZsDUbArwZz9iDa0I7QX8mIf30QKPB4qD73ihbtBJF 6t5RiTrFPwpyTIva2hc= X-Received: by 10.28.128.197 with SMTP id b188mr6668217wmd.115.1492975251354; Sun, 23 Apr 2017 12:20:51 -0700 (PDT) Received: from UML026.umk.kls.zentral (x2f7f073.dyn.telefonica.de. [2.247.240.115]) by smtp.gmail.com with ESMTPSA id u36sm19634528wrc.20.2017.04.23.12.20.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Apr 2017 12:20:49 -0700 (PDT) From: Leif Middelschulte X-Google-Original-From: Leif Middelschulte To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, devicetree@vger.kernel.org, Leif Middelschulte Subject: [PATCH v3] spi-imx: Implements handling of the SPI_READY mode flag. Date: Sun, 23 Apr 2017 21:19:58 +0200 Message-Id: <20170423191958.32724-1-Leif.Middelschulte@gmail.com> X-Mailer: git-send-email 2.12.2 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 From: Leif Middelschulte This patch implements consideration of the SPI_READY mode flag as defined in spi.h. It extends the device tree bindings to support the values defined by the reference manual for the DRCTL field. Thus supporting edge-triggered and level-triggered bursts. Signed-off-by: Leif Middelschulte --- .../devicetree/bindings/spi/fsl-imx-cspi.txt | 7 +++++++ drivers/spi/spi-imx.c | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt index 8bc95e2fc47f..31b5b21598ff 100644 --- a/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt +++ b/Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt @@ -23,6 +23,12 @@ See the clock consumer binding, Obsolete properties: - fsl,spi-num-chipselects : Contains the number of the chipselect +Optional properties: +- fsl,spi-rdy-drctl: Integer, representing the value of DRCTL, the register +controlling the SPI_READY handling. Note that to enable the DRCTL consideration, +the SPI_READY mode-flag needs to be set too. +Valid values are: 0 (disabled), 1 (edge-triggered burst) and 2 (level-triggered burst). + Example: ecspi@70010000 { @@ -35,4 +41,5 @@ ecspi@70010000 { <&gpio3 25 0>; /* GPIO3_25 */ dmas = <&sdma 3 7 1>, <&sdma 4 7 2>; dma-names = "rx", "tx"; + fsl,spi-rdy-drctl = <1>; }; diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 9a7c62f471dc..b402530a7a9a 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -95,6 +95,7 @@ struct spi_imx_data { unsigned int spi_bus_clk; unsigned int bytes_per_word; + unsigned int spi_drctl; unsigned int count; void (*tx)(struct spi_imx_data *); @@ -246,6 +247,7 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi, #define MX51_ECSPI_CTRL_XCH (1 << 2) #define MX51_ECSPI_CTRL_SMC (1 << 3) #define MX51_ECSPI_CTRL_MODE_MASK (0xf << 4) +#define MX51_ECSPI_CTRL_DRCTL(drctl) ((drctl) << 16) #define MX51_ECSPI_CTRL_POSTDIV_OFFSET 8 #define MX51_ECSPI_CTRL_PREDIV_OFFSET 12 #define MX51_ECSPI_CTRL_CS(cs) ((cs) << 18) @@ -355,6 +357,12 @@ static int mx51_ecspi_config(struct spi_device *spi, */ ctrl |= MX51_ECSPI_CTRL_MODE_MASK; + /* + * Enable SPI_RDY handling (falling edge/level triggered). + */ + if (spi->mode & SPI_READY) + ctrl |= MX51_ECSPI_CTRL_DRCTL(spi_imx->spi_drctl); + /* set clock speed */ ctrl |= mx51_ecspi_clkdiv(spi_imx, config->speed_hz, &clk); spi_imx->spi_bus_clk = clk; @@ -1173,7 +1181,7 @@ static int spi_imx_probe(struct platform_device *pdev) struct spi_master *master; struct spi_imx_data *spi_imx; struct resource *res; - int i, ret, irq; + int i, ret, irq, spi_drctl; if (!np && !mxc_platform_info) { dev_err(&pdev->dev, "can't get the platform data\n"); @@ -1181,6 +1189,12 @@ static int spi_imx_probe(struct platform_device *pdev) } master = spi_alloc_master(&pdev->dev, sizeof(struct spi_imx_data)); + ret = of_property_read_u32(np, "fsl,spi-rdy-drctl", &spi_drctl); + if ((ret < 0) || (spi_drctl >= 0x3)) { + /* '11' is reserved */ + spi_drctl = 0; + } + if (!master) return -ENOMEM; @@ -1216,7 +1230,9 @@ static int spi_imx_probe(struct platform_device *pdev) spi_imx->bitbang.master->unprepare_message = spi_imx_unprepare_message; spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx)) - spi_imx->bitbang.master->mode_bits |= SPI_LOOP; + spi_imx->bitbang.master->mode_bits |= SPI_LOOP | SPI_READY; + + spi_imx->spi_drctl = spi_drctl; init_completion(&spi_imx->xfer_done);