From patchwork Tue Nov 13 10:22:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 10680221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C115413B5 for ; Tue, 13 Nov 2018 10:25:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD5E29C5B for ; Tue, 13 Nov 2018 10:25:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A033229C6D; Tue, 13 Nov 2018 10:25:11 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2995029C5B for ; Tue, 13 Nov 2018 10:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XYE/UEW7k4N++6IKk0vLCMu0XEkY6+v26kIYn80nbeY=; b=luPjYAq++vTc0G hxGgqhf+gKeRNGIPJcwXFWyAms39n59/htTEJsLYTFmOWIJVuP6ThfZqLF4oJfouC9s7MUCLJOW0A k0bptMK7yT85KQ7kkMJ6LYts/eJDmlilC5H/0QxH4/MiAxGexdJ8cH3JBBoElhNoyceg11vKPBfQH V9nUhse3qSgGm50hT2CCATXt4sOl92J2/8zIQwQils3uaGA/6yXz3ETj7TQcAFPWCQCVdZsDdnNhC 6SvmZ6Eoee88z1Xx5G6UCM/yFYf8E0WcfFecAHBhe72ZjlXjvFhc6Q4JF63D8nnnrIX3KSn/zkJth rEbpAdkyleWZn8p462GQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMVsR-0004Rm-Pr; Tue, 13 Nov 2018 10:24:59 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMVqx-00033H-Kz for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 10:23:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Tv6QIM0JzfZYDKcA1nHyH9CVTOCyyBDGNw0gS6vQyN8=; b=FtcYyhIN5E//tnZ/wUfm5id3i2 znOSjKZgB+vfDqaviBlmth1PnkeI4cWEmyO2eLjVAyJqCUy+IwwFx8ZxCXkJqRBzU3XxkiuiY9dJq SPBWDUKk7cW506Ubjzh5fcANXK5ybtIh0QaOt25xZW4t058p+mS+jv8rnn5PUGThxpE4Rw0hocmhk qHDt8Q8PEEdQalMCsuF9x08Z4muRjBqTleVHt4P+3fF+YpIEgUwrS5rRLIEuz1CyvsOfn0zyDRVOA HRlGw3M5MrUeBrqC/Uy2r1nmfYx4cbQLQoWbfBQGnsyVS3xMLiaa+RWMo8sQd6bbZn+1iG0+GrSh0 jflTYBpw==; Received: from shell.v3.sk ([90.176.6.54]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMVqu-000684-JX for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 10:23:26 +0000 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 884F9C6B32; Tue, 13 Nov 2018 11:23:08 +0100 (CET) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id BFl_KRM1NhgE; Tue, 13 Nov 2018 11:22:55 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id AFD9DC6AF3; Tue, 13 Nov 2018 11:22:47 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Kr3S2njupcVL; Tue, 13 Nov 2018 11:22:44 +0100 (CET) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id 0D7F4C6B2B; Tue, 13 Nov 2018 11:22:42 +0100 (CET) From: Lubomir Rintel To: Mark Brown , Geert Uytterhoeven Subject: [PATCH v3 5/6] spi: pxa2xx: Add ready signal Date: Tue, 13 Nov 2018 11:22:27 +0100 Message-Id: <20181113102228.820214-6-lkundrak@v3.sk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181113102228.820214-1-lkundrak@v3.sk> References: <20181113102228.820214-1-lkundrak@v3.sk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181113_102324_746720_8BACC771 X-CRM114-Status: GOOD ( 17.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Eric Miao , James Cameron , linux-kernel@vger.kernel.org, Haojian Zhuang , linux-spi@vger.kernel.org, Lubomir Rintel , Rob Herring , linux-arm-kernel@lists.infradead.org, Robert Jarzmik , Daniel Mack Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Strobe a GPIO line when the slave TX FIFO is filled. This is how the Embedded Controller on an OLPC XO-1.75 machine, that happens to be a SPI master, learns that it can initiate a transaction. Signed-off-by: Lubomir Rintel Tested-by: Pavel Machek Reviewed-by: Geert Uytterhoeven --- Changes since v2 - Avoid an useless delay if there's no ready GPIO - Remove useless (int)PTR_ERR(...) casts from pxa2xx_spi_probe() (thanks to Geert Uytterhoeven) drivers/spi/spi-pxa2xx.c | 16 +++++++++++++++- drivers/spi/spi-pxa2xx.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 54ae77f1227c..7e5aab0af501 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1081,6 +1081,11 @@ static int pxa2xx_spi_transfer_one(struct spi_controller *master, if (spi_controller_is_slave(master)) { while (drv_data->write(drv_data)) ; + if (drv_data->gpiod_ready) { + gpiod_set_value(drv_data->gpiod_ready, 1); + udelay(1); + gpiod_set_value(drv_data->gpiod_ready, 0); + } } /* @@ -1778,7 +1783,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) if (PTR_ERR(gpiod) == -ENOENT) continue; - status = (int)PTR_ERR(gpiod); + status = PTR_ERR(gpiod); goto out_error_clock_enabled; } else { drv_data->cs_gpiods[i] = gpiod; @@ -1786,6 +1791,15 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) } } + if (platform_info->is_slave) { + drv_data->gpiod_ready = devm_gpiod_get_optional(dev, + "ready", GPIOD_OUT_LOW); + if (IS_ERR(drv_data->gpiod_ready)) { + status = PTR_ERR(drv_data->gpiod_ready); + goto out_error_clock_enabled; + } + } + pm_runtime_set_autosuspend_delay(&pdev->dev, 50); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_active(&pdev->dev); diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index 513c53aaeab2..4e324da66ef7 100644 --- a/drivers/spi/spi-pxa2xx.h +++ b/drivers/spi/spi-pxa2xx.h @@ -64,6 +64,9 @@ struct driver_data { /* GPIOs for chip selects */ struct gpio_desc **cs_gpiods; + + /* Optional slave FIFO ready signal */ + struct gpio_desc *gpiod_ready; }; struct chip_data {