Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp648818pxu; Thu, 3 Dec 2020 09:14:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzs+1o2C/jHSHyvmilURIG/4K+SqinlR1DsrA6LoRgjZtFDHrjVTwxXafzZT23s/x3VpY1 X-Received: by 2002:a05:6402:513:: with SMTP id m19mr3831388edv.244.1607015695082; Thu, 03 Dec 2020 09:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607015695; cv=none; d=google.com; s=arc-20160816; b=PONj7CwUNYCz9h+7S8d77YBZSJVWjuvigJ8HCEVS+M/oSdqW+2QL3pQx11zcNWMYxn fs7LwHajtU9kChw8KzhncSVVqNuz2SqQKWiUblcyIiEm3LM9bkjHeXXiCaxDW9iH1dd0 HDs5WGjDECHyyO1mUxBJB0hQYbY0t+XHNzfhF9d2q0mh6NzPco9uymixnmdS1zV1zCXi 7qbkTZvDhd+tfPaz0ONiGG8cKVZiPpYtU/NLczzrAdXi/mBIfvN+ILc6gSrLqWgZPQRA 0POHrgTWgH6bH0AdioY8bR0nFQ1SdboLG+XzWy1q49y+hrwSigtxRyVcfQt6nGH6YFB8 DccQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:mime-version :dkim-signature; bh=3rpkGdvnJ4tE6aT83D7Bz5ZVtxLPAIcugyQgY5ZXjpg=; b=GSgYwvUVorXJ1/CjnYTPuUw8+WuLodPuzZlEsnmKyyD8VbJ7Sd10MPoyMGXd3xtA7l wm1V7Ykv7n14Pq34AzU65gea32sMcgOYQ/7NyHbq5QosB4j0TNqOrBbfbmLTpnx6qilW AQZAVM3+m947uhNTKSk1Du9YH2V/rtrIMtKNCOAQ/ZyHXnStRh3momE/ubWkrMaTcos3 mM+TBc2wlw8TsvTtGrxWL/nPnAo+JCZ0zYAACkIAMs/OpcoIOFgjj2buvzIt7DzW/3/B 9zZJLWkLr7RK5UXvNEcxziKT35dfodLGGn6auYqWPkUmwzGwX/NbUEfUuv8J3Df0B5xR fypg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I4JbDRBz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si1218374edi.556.2020.12.03.09.14.32; Thu, 03 Dec 2020 09:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I4JbDRBz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731385AbgLCRNL (ORCPT + 99 others); Thu, 3 Dec 2020 12:13:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726257AbgLCRNL (ORCPT ); Thu, 3 Dec 2020 12:13:11 -0500 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35A98C061A4F; Thu, 3 Dec 2020 09:12:31 -0800 (PST) Received: by mail-pj1-x1041.google.com with SMTP id r9so1435186pjl.5; Thu, 03 Dec 2020 09:12:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=3rpkGdvnJ4tE6aT83D7Bz5ZVtxLPAIcugyQgY5ZXjpg=; b=I4JbDRBzK0VXbI7b3GMCZ9uASF7K2g3ZYeioXxgRkFWg1mTN5AyssIIRCk9lc6hHou DUjhfKWGgQj0pXz7xSaZyF+la3ri9wtENrzhSOldb8ap4CILBONRyrRUCnxBrcgEl7Ga kyD9UTMFlIeYqE88Ls738HvWufGmiWzxefVaLKHSztHGmwW+IhQ5/9yRFfOTc6svnexu qt5srIsT8RyD6tznPhFa2MV3VHTadlVrYk0RJwWwv/FKsNyUOl+dPOXFSL8k1vmGqSH+ 4qnEmIj7MqFjH1a5AFByAGzDxHKZuWkBCKfqCVNkc+XRURDHqfmyUzM+E6fp6vrXcOnM oXXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=3rpkGdvnJ4tE6aT83D7Bz5ZVtxLPAIcugyQgY5ZXjpg=; b=rCsWBH0xzv4t0+oYEvwWxR74C2SFjAQoD5YwUulVrHVaT2p2w2EXHlF7grSrSs/9NM TgMT6hBg1plelyKMSMJZkfuSJkygACmA7QDV/j21ddNE2tcQHdw8R2Bd8uIDXSxLhP38 lbQVdq5OFE9U0peOobJQin5aqvZK1UNDMucw3IIDJJv8CoMefO7xfOGnvnmJQbMBhD6J xfMEmT+Mu/9mEHkgDiboB/RlJ8BZsmwHijLeufbT9EVVrmUA/TV5D1QYRlIvN0l09zyc QO2iAIR7/RG1kkzFGp+aEPGjGSEy3a+jZ+UzzMm8mKsW3mOIuJe/c7xz/CjTOtlJ8rFT NI1w== X-Gm-Message-State: AOAM533xGycuECElJ5TPp5YhYzwb6pVyDOSrN1aAGLTTItYKT1XZwjkR URP1scr1JhoyY8c0Ow8hoe0SlBXdQehdGYJ9iIg= X-Received: by 2002:a17:90b:224e:: with SMTP id hk14mr111426pjb.98.1607015550757; Thu, 03 Dec 2020 09:12:30 -0800 (PST) MIME-Version: 1.0 From: =?UTF-8?B?0JzQsNC60YHQuNC8INCa0LjRgdC10LvRkdCy?= Date: Thu, 3 Dec 2020 20:12:19 +0300 Message-ID: Subject: [PATCH] spi: spi-fsl-dspi: Add GPIO chip select support To: Vladimir Oltean , Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?B?0JzQsNC60YHQuNC8INCa0LjRgdC10LvRkdCy?= , Maxim Kochetkov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Kiselev Date: Thu, 3 Dec 2020 18:56:12 +0300 Subject: [PATCH] spi: spi-fsl-dspi: Add GPIO chip select support This patch allows use of GPIO for the chip select. Because dSPI controller can't send transactions without hardware chip selects, so first unused native CS will be set in SPI_PUSHR_CMD_PCS Signed-off-by: Maxim Kiselev --- drivers/spi/spi-fsl-dspi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 028736687488..d5fba34de740 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -913,9 +913,14 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr, dspi->cur_transfer = transfer; dspi->cur_msg = message; dspi->cur_chip = spi_get_ctldata(spi); + + if (spi->cs_gpiod) + gpiod_set_value(spi->cs_gpiod, 1); + /* Prepare command word for CMD FIFO */ dspi->tx_cmd = SPI_PUSHR_CMD_CTAS(0) | - SPI_PUSHR_CMD_PCS(spi->chip_select); + SPI_PUSHR_CMD_PCS(spi->cs_gpiod ? + ctlr->unused_native_cs : spi->chip_select); if (list_is_last(&dspi->cur_transfer->transfer_list, &dspi->cur_msg->transfers)) { /* Leave PCS activated after last transfer when @@ -1240,6 +1245,7 @@ static int dspi_probe(struct platform_device *pdev) dspi->pdev = pdev; dspi->ctlr = ctlr; + ctlr->use_gpio_descriptors = true; ctlr->setup = dspi_setup; ctlr->transfer_one_message = dspi_transfer_one_message; ctlr->dev.of_node = pdev->dev.of_node; -- 2.27.0