From patchwork Fri Dec 30 09:29:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Bornyakov X-Patchwork-Id: 37618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2808392wrt; Fri, 30 Dec 2022 01:34:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXtePf2Z9n9UKD3lYeqzw8jJoKyXKzKP0LHPvbnqcFqz+I3Wx3w8yHhk4Uz+gICqqS/PbvTF X-Received: by 2002:aa7:9154:0:b0:57b:30b6:9e85 with SMTP id 20-20020aa79154000000b0057b30b69e85mr31055026pfi.22.1672392861194; Fri, 30 Dec 2022 01:34:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672392861; cv=none; d=google.com; s=arc-20160816; b=gy6dT9wMG0M96BvFohVyYGlbVyuGLFQxLiWkcXAbtrXmO1gCM5ozVQr+7SxULCGVVv TXzXP3ct09WhfoMul1qHNQT2J3voc4CL15c2pO2Ngv4NH8TQzs21fybD1lBonZKdJFsK W26TmkrQBjCejs34zXPstZclhfWAyNYjDtPaSSqn1Jy2u63UwtSq8iL5aQLW2Zj0W+Fx nzwd6d9r4nuoN/ZikZHy8D8qVaSMNPqGYjXV7MCDT+J06XyqB26+F12UzD5FovFEHrNo zNM+0jnaOE0bCXlu+dL/qVNe1xZzcwDekQtbZbXbYdR2CqOvA70meq/JAGX0UX2Ut3PR 4SZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8JMBUGm0iPt8z8ss4vWixfUi2Pukc2i4UJGB3rk7ZPk=; b=IrTb5wo5DFWPKZOwqmH9XTxgae9CEjifTwti0d7sbA3TiN5p7Sq7faCCFlXjZimy9P BpWSWviCZfgr9ZBlyl86OALxwl07oxx4DIl7x57ybeUl4fEU8YyVt2Fpe0OZQbTKns9b lzWtYpBVPx1aqK73WKVSXtFFbT23tFV4wmyYUNNVotitRuayWuBD5TgfD21NSZt5IeXY Bk7tJdGVznuBJK/r1XXBMmUvf76RIWNWlFzdRHe1ElS/T4bIEhixgUtrrLKwmpd0uTrO 2Iq2Yd3FjDKcU1l8CiWlC6R3irC22bVOkgZcOrRzbDN5tf7QdDduYwObZUyCYYYD8bNI QuPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@metrotek.ru header.s=mail header.b="e/uOV8Cp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v21-20020a056a00149500b00574e1e34522si23700365pfu.332.2022.12.30.01.34.09; Fri, 30 Dec 2022 01:34:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@metrotek.ru header.s=mail header.b="e/uOV8Cp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234849AbiL3JcU (ORCPT + 99 others); Fri, 30 Dec 2022 04:32:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234805AbiL3JcQ (ORCPT ); Fri, 30 Dec 2022 04:32:16 -0500 Received: from mail.pr-group.ru (mail.pr-group.ru [178.18.215.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A40B1A20F; Fri, 30 Dec 2022 01:32:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=metrotek.ru; s=mail; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding: in-reply-to:references; bh=/ihIkO5snmzqBy+4+LJopWc7knE0i7yPw81w1MiqSmQ=; b=e/uOV8CpIKBh6A8A0UK17zK1onjA8l07TCIrdxGMNAmYX/YsXNUvFAFKZliDyUKTvjH3U6ga2ZNA7 Mq4Zr2uMh4xB7fSEE+HcOuhJLmpVbHWETu2ZXmWHn4I6wsbMM6QmGKLqzCuuc6c/SXCPC4jcsGSZLl IT+oeWVUzREv0eCVcOIoKc21d1Zu/9OiY4q1j/DfOOpgc5eTyqH7ydvuDc1OpXLhUrUgBNpLAfKAwx U1bAtvyRCU1k9uhhSQRupAqPwlPtVY3/bz1/M5e8PaScSSy/h3tOaA62JLbfypCQGYWWKp968LMOvb yYzLxL9xfZ9AnRMzssj+F0E46Vy+79A== X-Kerio-Anti-Spam: Build: [Engines: 2.16.5.1460, Stamp: 3], Multi: [Enabled, t: (0.000010,0.010605)], BW: [Enabled, t: (0.000030,0.000002)], RTDA: [Enabled, t: (0.085502), Hit: No, Details: v2.42.0; Id: 15.52k84j.1glh5vaj6.26g; mclb], total: 0(700) X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: X-Footer: bWV0cm90ZWsucnU= Received: from localhost.localdomain ([78.37.162.181]) (authenticated user i.bornyakov@metrotek.ru) by mail.pr-group.ru with ESMTPSA (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)); Fri, 30 Dec 2022 12:31:52 +0300 From: Ivan Bornyakov To: linux-fpga@vger.kernel.org Cc: Ivan Bornyakov , Conor Dooley , Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , linux-kernel@vger.kernel.org, system@metrotek.ru Subject: [PATCH v5 3/3] fpga: microchip-spi: separate data frame write routine Date: Fri, 30 Dec 2022 12:29:22 +0300 Message-Id: <20221230092922.18822-4-i.bornyakov@metrotek.ru> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20221230092922.18822-1-i.bornyakov@metrotek.ru> References: <20221230092922.18822-1-i.bornyakov@metrotek.ru> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753631016593638118?= X-GMAIL-MSGID: =?utf-8?q?1753631016593638118?= mpf_ops_write() function writes bitstream data to the FPGA by a smaller frames. Introduce mpf_spi_frame_write() function which is for writing a single data frame and use it in mpf_ops_write(). No functional changes intended. Signed-off-by: Ivan Bornyakov Acked-by: Conor Dooley Acked-by: Xu Yilun --- drivers/fpga/microchip-spi.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/fpga/microchip-spi.c b/drivers/fpga/microchip-spi.c index 137fafdf57a6..d6070e7f5205 100644 --- a/drivers/fpga/microchip-spi.c +++ b/drivers/fpga/microchip-spi.c @@ -280,9 +280,30 @@ static int mpf_ops_write_init(struct fpga_manager *mgr, return 0; } +static int mpf_spi_frame_write(struct mpf_priv *priv, const char *buf) +{ + struct spi_transfer xfers[2] = { + { + .tx_buf = &priv->tx, + .len = 1, + }, { + .tx_buf = buf, + .len = MPF_SPI_FRAME_SIZE, + }, + }; + int ret; + + ret = mpf_poll_status(priv, 0); + if (ret < 0) + return ret; + + priv->tx = MPF_SPI_FRAME; + + return spi_sync_transfer(priv->spi, xfers, ARRAY_SIZE(xfers)); +} + static int mpf_ops_write(struct fpga_manager *mgr, const char *buf, size_t count) { - struct spi_transfer xfers[2] = { 0 }; struct mpf_priv *priv = mgr->priv; struct device *dev = &mgr->dev; int ret, i; @@ -293,19 +314,8 @@ static int mpf_ops_write(struct fpga_manager *mgr, const char *buf, size_t count return -EINVAL; } - xfers[0].tx_buf = &priv->tx; - xfers[0].len = 1; - for (i = 0; i < count / MPF_SPI_FRAME_SIZE; i++) { - xfers[1].tx_buf = buf + i * MPF_SPI_FRAME_SIZE; - xfers[1].len = MPF_SPI_FRAME_SIZE; - - ret = mpf_poll_status(priv, 0); - if (ret >= 0) { - priv->tx = MPF_SPI_FRAME; - ret = spi_sync_transfer(priv->spi, xfers, ARRAY_SIZE(xfers)); - } - + ret = mpf_spi_frame_write(priv, buf + i * MPF_SPI_FRAME_SIZE); if (ret) { dev_err(dev, "Failed to write bitstream frame %d/%zu\n", i, count / MPF_SPI_FRAME_SIZE);